Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / QxGraph / QxGraph_ViewModel.h
1 //  Copyright (C) 2007-2008  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 #ifndef QXGRAPH_VIEWMODEL_H
23 #define QXGRAPH_VIEWMODEL_H
24
25 #include "QxGraph.h"
26
27 #include "SUIT_ViewModel.h"
28
29 class QCanvasItem; // for addRectangleItem(...) method (can be removed in the future)
30
31 class QxGraph_Canvas;
32 class QxGraph_CanvasView;
33 class QxGraph_ViewWindow;
34 class QxGraph_Prs;
35
36 class QXGRAPH_EXPORT QxGraph_Viewer: public SUIT_ViewModel
37 {
38   Q_OBJECT
39
40  public:
41   static QString Type() { return "QxGraphViewer"; }
42
43   QxGraph_Viewer();
44   virtual ~QxGraph_Viewer();
45
46   virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
47   virtual QString          getType() const { return Type(); }
48
49   virtual void             contextMenuPopup(QPopupMenu*);
50
51   QxGraph_Canvas*          getCanvas() const { return myCanvas; }
52   void                     setCanvas(QxGraph_Canvas* theCanvas) { myCanvas = theCanvas; }
53   //QPtrList<QxGraph_Canvas> getCanvases() { return myCanvases; }
54   //void                     setCanvases(QPtrList<QxGraph_Canvas> theCanvases) { myCanvases = theCanvases; }
55
56   //void addCanvas(QxGraph_Canvas* theCanvas) { myCanvases.append(theCanvas); }
57   //void removeCanvas(QxGraph_Canvas* theCanvas) { myCanvases.remove(theCanvas); }
58
59   QPtrList<QxGraph_CanvasView> getCanvasViews() { return myCanvasViews; }
60   void                         setCanvasViews(QPtrList<QxGraph_CanvasView> theViews) { myCanvasViews = theViews; }
61
62   void addView(QxGraph_CanvasView* theView) { myCanvasViews.append(theView); }
63   void removeView(QxGraph_CanvasView* theView) { myCanvasViews.remove(theView); }
64   
65   QxGraph_CanvasView* getCurrentView() const { return myCurrentView; }
66   void                setCurrentView(QxGraph_CanvasView* theView) { myCurrentView = theView; }
67   void                setCurrentView(int theIndex);
68
69  protected:
70   void initView(QxGraph_ViewWindow* view);
71
72  protected slots:
73   void onShowToolbar();
74   void onChangeBgColor();
75
76  private:
77   QxGraph_Canvas*              myCanvas;
78   //QPtrList<QxGraph_Canvas>     myCanvases;
79   QPtrList<QxGraph_CanvasView> myCanvasViews;
80
81   QxGraph_CanvasView*          myCurrentView;
82  
83 };
84
85 #endif