ladanyi@1412: // -*- C++ -*- // ladanyi@1412: ladanyi@1412: #ifndef GRAPH_DISPLAYER_CANVAS_H ladanyi@1412: #define GRAPH_DISPLAYER_CANVAS_H ladanyi@1412: ladanyi@1412: #include ladanyi@1412: #include ladanyi@1412: #include ladanyi@1412: #include ladanyi@1412: hegyi@1440: ///This class is the canvas, on which the graph can be drawn. ladanyi@1412: class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA ladanyi@1412: { ladanyi@1412: typedef Gnome::Canvas::CanvasAA Parent; ladanyi@1412: ladanyi@1412: public: ladanyi@1412: GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &); ladanyi@1412: virtual ~GraphDisplayerCanvas(); ladanyi@1412: hegyi@1440: ///Changes the linewidth attribute according to the given map. hegyi@1440: ///\param mapname is the name of the map which contains the new values ladanyi@1412: int changeLineWidth (std::string mapname); hegyi@1440: hegyi@1440: ///Changes the linecolor attribute according to the given map. hegyi@1440: ///\param mapname is the name of the map which contains the new values ladanyi@1412: int changeColor (std::string mapname); hegyi@1440: hegyi@1440: ///Changes the text of line attribute according to the given map. hegyi@1440: ///\param mapname is the name of the map which contains the new values ladanyi@1412: int changeText (std::string mapname); hegyi@1440: hegyi@1440: ///Changes the dot-pro-pixel to be able to show the whole graph. ladanyi@1412: int rezoom(); ladanyi@1412: ladanyi@1412: protected: ladanyi@1412: hegyi@1440: //maximizing, minimizing, restoring window, etc. ladanyi@1412: virtual bool on_expose_event(GdkEventExpose *); ladanyi@1412: ladanyi@1412: private: ladanyi@1412: hegyi@1440: ///This function is responsible for the correct hegyi@1440: ///reaction of any action happened in the territory hegyi@1440: ///of the canvas ladanyi@1412: bool event_handler(GdkEvent* e, Node n); ladanyi@1412: ladanyi@1412: ///The graph, on which we work ladanyi@1412: Graph g; hegyi@1440: hegyi@1440: ///Map of nodes of graph ladanyi@1412: Graph::NodeMap nodesmap; hegyi@1440: hegyi@1440: ///Map of edges of graph ladanyi@1412: Graph::EdgeMap edgesmap; ladanyi@1412: ladanyi@1412: ///Map of texts to write on edges ladanyi@1412: Graph::EdgeMap edgetextmap; ladanyi@1412: ladanyi@1412: ///Group of graphical elements of displayed_graph ladanyi@1412: Gnome::Canvas::Group displayed_graph; ladanyi@1412: ladanyi@1412: ///Here we store the maps that can be displayed through properties. ladanyi@1412: MapStorage mapstorage; ladanyi@1412: ladanyi@1412: ///Indicates whether the button of mouse is pressed or not ladanyi@1412: bool isbutton; ladanyi@1412: ladanyi@1412: ///At this location was the mousebutton pressed. ladanyi@1412: ///It helps to calculate the distance of dragging. ladanyi@1412: double clicked_x, clicked_y; ladanyi@1412: ladanyi@1412: ///Remembers which Gnome::Canvas::Item was pressed. ladanyi@1412: ///this variable is needed, because ladanyi@1412: ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault ladanyi@1412: ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution ladanyi@1412: Gnome::Canvas::Item * active_item; ladanyi@1412: ladanyi@1412: ladanyi@1412: }; ladanyi@1412: ladanyi@1412: #endif //GRAPH_DISPLAYER_CANVAS_H