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