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