Salome HOME
ddba3d80a092cacbe378253703c24b0a38a0f9e5
[modules/gui.git] / src / QxGraph / QxGraph_ViewModel.h
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef QXGRAPH_VIEWMODEL_H
24 #define QXGRAPH_VIEWMODEL_H
25
26 #include "QxGraph.h"
27
28 #include "SUIT_ViewModel.h"
29
30 class QCanvasItem; // for addRectangleItem(...) method (can be removed in the future)
31
32 class QxGraph_Canvas;
33 class QxGraph_CanvasView;
34 class QxGraph_ViewWindow;
35 class QxGraph_Prs;
36
37 class QXGRAPH_EXPORT QxGraph_Viewer: public SUIT_ViewModel
38 {
39   Q_OBJECT
40
41  public:
42   static QString Type() { return "QxGraphViewer"; }
43
44   QxGraph_Viewer();
45   virtual ~QxGraph_Viewer();
46
47   virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
48   virtual QString          getType() const { return Type(); }
49
50   virtual void             contextMenuPopup(QPopupMenu*);
51
52   QxGraph_Canvas*          getCanvas() const { return myCanvas; }
53   void                     setCanvas(QxGraph_Canvas* theCanvas) { myCanvas = theCanvas; }
54   //QPtrList<QxGraph_Canvas> getCanvases() { return myCanvases; }
55   //void                     setCanvases(QPtrList<QxGraph_Canvas> theCanvases) { myCanvases = theCanvases; }
56
57   //void addCanvas(QxGraph_Canvas* theCanvas) { myCanvases.append(theCanvas); }
58   //void removeCanvas(QxGraph_Canvas* theCanvas) { myCanvases.remove(theCanvas); }
59
60   QPtrList<QxGraph_CanvasView> getCanvasViews() { return myCanvasViews; }
61   void                         setCanvasViews(QPtrList<QxGraph_CanvasView> theViews) { myCanvasViews = theViews; }
62
63   void addView(QxGraph_CanvasView* theView) { myCanvasViews.append(theView); }
64   void removeView(QxGraph_CanvasView* theView) { myCanvasViews.remove(theView); }
65   
66   QxGraph_CanvasView* getCurrentView() const { return myCurrentView; }
67   void                setCurrentView(QxGraph_CanvasView* theView) { myCurrentView = theView; }
68   void                setCurrentView(int theIndex);
69
70  protected:
71   void initView(QxGraph_ViewWindow* view);
72
73  protected slots:
74   void onShowToolbar();
75   void onChangeBgColor();
76
77  private:
78   QxGraph_Canvas*              myCanvas;
79   //QPtrList<QxGraph_Canvas>     myCanvases;
80   QPtrList<QxGraph_CanvasView> myCanvasViews;
81
82   QxGraph_CanvasView*          myCurrentView;
83  
84 };
85
86 #endif