Salome HOME
83e49559f408b9b7bca6425eed8ffcc1ee1db018
[modules/gui.git] / src / QxGraph / QxGraph_Prs.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_PRS_H
23 #define QXGRAPH_PRS_H
24
25 #include "QxGraph.h"
26
27 #include <qcanvas.h>
28 #include <map>
29 #include <list>
30
31 class QxGraph_Canvas;
32
33 class QXGRAPH_EXPORT QxGraph_Prs
34 {
35  public:
36   QxGraph_Prs(QxGraph_Canvas*);
37   virtual ~QxGraph_Prs();
38
39   QxGraph_Canvas* getCanvas() const { return myCanvas; }
40
41   void addItem(QCanvasItem* theItem, int theDMode = -1);
42   void removeItem(QCanvasItem* theItem, int theDMode = -1);
43   
44   /* add items for display mode theDMode
45      if theDMode is equal to -1 add item for the current (active) display mode */
46   QCanvasItem*   addRectangleItem(QRect theRect, int theDMode = -1);
47   QCanvasItem*   addPolygonItem(QPointArray thePA, int theDMode = -1);
48   QCanvasItem*   addLineItem(QPoint theStart, QPoint theEnd, int theDMode = -1);
49   QCanvasItem*   addEllipseItem(int theW, int theH, int theStartAngle, int theAngle, int theDMode = -1);
50   QCanvasItem*   addTextItem(QString theText, int theDMode = -1);
51
52   typedef std::map< int, std::list<QCanvasItem*> > DMode2ItemList;
53
54   const DMode2ItemList& getDisplayMap() const { return myDisplayMap; }
55   const std::list<QCanvasItem*>& getItems(int theDMode) { return myDisplayMap[theDMode]; }
56   
57   void setDMode(int theDMode) { myDMode = theDMode; }
58   int  getDMode() const { return myDMode; }
59
60   virtual void    show();
61   virtual void    hide();
62   virtual void    setToUpdate( const bool );
63   bool            isToUpdate() { return needUpdate; }
64
65 protected:
66   virtual void    update();
67
68 private:
69   QxGraph_Canvas* myCanvas;
70   DMode2ItemList  myDisplayMap;
71
72   int             myDMode;
73   bool            needUpdate;
74 };
75
76 #endif