ladanyi@1442: // -*- C++ -*- // ladanyi@1442: ladanyi@1442: #ifndef GRAPH_DISPLAYER_CANVAS_H ladanyi@1442: #define GRAPH_DISPLAYER_CANVAS_H ladanyi@1442: ladanyi@1442: #include ladanyi@1442: #include ladanyi@1442: #include ladanyi@1442: #include ladanyi@1442: ladanyi@1442: ///This class is the canvas, on which the graph can be drawn. ladanyi@1442: class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA ladanyi@1442: { ladanyi@1442: typedef Gnome::Canvas::CanvasAA Parent; ladanyi@1442: ladanyi@1442: public: ladanyi@1442: GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &); ladanyi@1442: virtual ~GraphDisplayerCanvas(); ladanyi@1442: ladanyi@1442: ///Changes the linewidth attribute according to the given map. ladanyi@1442: ///\param mapname is the name of the map which contains the new values ladanyi@1442: int changeLineWidth (std::string mapname); ladanyi@1442: ladanyi@1442: ///Changes the linecolor attribute according to the given map. ladanyi@1442: ///\param mapname is the name of the map which contains the new values ladanyi@1442: int changeColor (std::string mapname); ladanyi@1442: ladanyi@1442: ///Changes the text of line attribute according to the given map. ladanyi@1442: ///\param mapname is the name of the map which contains the new values ladanyi@1442: int changeText (std::string mapname); ladanyi@1442: ladanyi@1442: ///Callback for 'ViewZoomIn' action. ladanyi@1442: virtual void zoomIn(); ladanyi@1442: ///Callback for 'ViewZoomOut' action. ladanyi@1442: virtual void zoomOut(); ladanyi@1442: ///Callback for 'ViewZoomFit' action. ladanyi@1442: virtual void zoomFit(); ladanyi@1442: ///Callback for 'ViewZoom100' action. ladanyi@1442: virtual void zoom100(); ladanyi@1442: ///Sets the scroll region of the convas to the bounding box of the graph. ladanyi@1442: void updateScrollRegion(); ladanyi@1442: hegyi@1468: ///This function changes the tool in the graph-editor's hand hegyi@1468: void changeEditorialTool(int); hegyi@1468: ladanyi@1442: protected: ladanyi@1442: ladanyi@1442: //maximizing, minimizing, restoring window, etc. ladanyi@1442: virtual bool on_expose_event(GdkEventExpose *); ladanyi@1442: ladanyi@1442: private: ladanyi@1442: ladanyi@1442: ///This function is responsible for the correct ladanyi@1442: ///reaction of any action happened in the territory ladanyi@1442: ///of the canvas ladanyi@1442: bool event_handler(GdkEvent* e, Node n); ladanyi@1442: hegyi@1468: ///actual event handler hegyi@1468: /// hegyi@1468: ///Actual event handler should be stored, to be able to disconnect it and later reconnect it. hegyi@1468: sigc::connection actual_handler; hegyi@1468: hegyi@1468: ///event handler for the case when move-tool is active hegyi@1468: bool move_event_handler(GdkEvent*); hegyi@1468: ///event handler for the case when create_node-tool is active hegyi@1468: bool create_node_event_handler(GdkEvent*); hegyi@1468: ///event handler for the case when create_edge-tool is active hegyi@1468: bool create_edge_event_handler(GdkEvent*); hegyi@1468: ladanyi@1442: ///The graph, on which we work ladanyi@1442: Graph g; ladanyi@1442: ladanyi@1442: ///Map of nodes of graph ladanyi@1442: Graph::NodeMap nodesmap; ladanyi@1442: ladanyi@1442: ///Map of edges of graph ladanyi@1442: Graph::EdgeMap edgesmap; ladanyi@1442: ladanyi@1442: ///Map of texts to write on edges ladanyi@1442: Graph::EdgeMap edgetextmap; ladanyi@1442: ladanyi@1442: ///Group of graphical elements of displayed_graph ladanyi@1442: Gnome::Canvas::Group displayed_graph; ladanyi@1442: ladanyi@1442: ///Here we store the maps that can be displayed through properties. ladanyi@1442: MapStorage mapstorage; ladanyi@1442: ladanyi@1442: ///Indicates whether the button of mouse is pressed or not ladanyi@1442: bool isbutton; ladanyi@1442: ladanyi@1442: ///At this location was the mousebutton pressed. ladanyi@1442: ///It helps to calculate the distance of dragging. ladanyi@1442: double clicked_x, clicked_y; ladanyi@1442: ladanyi@1442: ///Remembers which Gnome::Canvas::Item was pressed. ladanyi@1442: ///this variable is needed, because ladanyi@1442: ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault ladanyi@1442: ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution ladanyi@1442: Gnome::Canvas::Item * active_item; hegyi@1468: Graph::NodeIt active_node; ladanyi@1442: ladanyi@1442: static const int zoom_step = 5; ladanyi@1442: }; ladanyi@1442: ladanyi@1442: #endif //GRAPH_DISPLAYER_CANVAS_H