Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

GUINetwork.h

00001 // Copyright (C) 2001 Jean-Marc Valin
00002 
00003 #ifndef GUINETWORK_H
00004 #define GUINETWORK_H
00005 
00006 #include "UINetwork.h"
00007 #include "GUINode.h"
00008 #include <gnome.h>
00009 
00010 namespace FD {
00011 
00012 class UIDocument;
00013 class GUINetPopup;
00014 class GUINodeTooltip;
00015 
00016 class GUINetwork : public UINetwork {
00017 
00018   friend void network_description_changed_event (GtkTextBuffer *textbuffer, GUINetwork *network);
00019 
00020 protected:
00021    GnomeCanvas *canvas;
00022    GtkWidget *scrolledwindow1;
00023    GtkWidget *networkProperties;
00024    GnomeCanvasGroup *group;
00025    GUINetPopup *popup;
00026    double zoom;
00027 
00028    std::list<GUINode*> selectedNodes;
00029    GUINodeTooltip *tooltip;
00030 
00031    double x_last_click;
00032    double y_last_click;
00033 
00034 public:
00035 
00036    //useful to know where we clicked on the canvas.
00037    void get_last_click(double &x, double &y) {x = x_last_click; y = y_last_click;}
00038 
00039    void emptySelectedNodes();
00040 
00041    void addSelectedNode(GUINode *node);
00042 
00043    void removeSelectedNode(GUINode *node);
00044 
00045    std::list<GUINode*>& getSelectedNodes(){return selectedNodes;}
00046 
00047    void moveSelectedNodes(double dx, double dy);
00048 
00049    void clearSelectedNodes();
00050 
00051    bool isNodeSelected(GUINode *node);
00052 
00053    GUINetwork(UIDocument *_doc, std::string _name, Type _type);
00054 
00055    GUINetwork(UIDocument *_doc, xmlNodePtr net);
00056 
00057    ~GUINetwork();
00058 
00059    UINode *addNode (std::string type, double xx, double yy);
00060 
00061    
00062 
00063    void create();
00064 
00065    GnomeCanvasGroup * getGroup() {return group;}
00066    GnomeCanvas * getCanvas() {return canvas;}
00067 
00068    GtkWidget* getView(){return scrolledwindow1;}
00069 
00070    void updateScroll ();
00071 
00072    gboolean buttonEvent(GdkEvent *event);
00073 
00074    void newNetNotify(const std::string &cat, const std::string &type);
00075 
00076    UITerminal *isNearInputTerminal (double &x, double &y);
00077 
00078    UITerminal *isNearOutputTerminal (double &x, double &y);
00079 
00080    virtual UINode *newNode(UINetwork* _net, xmlNodePtr def);
00081 
00082    virtual UINode *newNode(UINetwork* _net, std::string _name, std::string _type, double _x, double _y, bool doInit);
00083 
00084 //   virtual UITerminal *newTerminal (std::string _name, UINode *_node, bool _isInput, double _x, double _y);
00085 
00086    virtual UILink *newLink (UITerminal *_from, UITerminal *_to, char *str);
00087 
00088    virtual UINote* newNote(const std::string &text, double x, double y, bool visible);
00089 
00090    virtual UINetTerminal *newNetTerminal (UITerminal *_terminal, UINetTerminal::NetTermType _type, const std::string &_name ,
00091                                           const std::string &_objType="any", const std::string &_description="No description available");
00092 
00093    void zoomIn() {zoom *= 1.5; gnome_canvas_set_pixels_per_unit (canvas,zoom);}
00094 
00095    void zoomOut() {zoom /= 1.5; gnome_canvas_set_pixels_per_unit (canvas,zoom);}
00096 
00097    double getZoom() {return zoom;}
00098    //virtual void tata() {};
00099 
00100    void popTooltip(GUINode *node);
00101 
00102    void redraw() {gtk_widget_queue_draw(GTK_WIDGET(canvas));}
00103 
00104    void get_scroll_region(double &x1, double &y1, double &x2, double &y2) { 
00105      gnome_canvas_get_scroll_region  (GNOME_CANVAS(canvas),&x1,&y1,&x2,&y2);
00106    }
00107    
00108    void get_scroll_offsets(int &c1, int &c2) {
00109      gnome_canvas_get_scroll_offsets (GNOME_CANVAS(canvas),&c1,&c2);
00110    }
00111    
00112    virtual void rename(std::string newName);
00113    
00114 
00115    void showProperties();
00116 
00117    void applyNetworkProperties();
00118 };
00119 
00120 }//namespace FD
00121 
00122 #endif

Generated on Wed Oct 5 14:28:55 2005 for FlowDesigner by  doxygen 1.4.4