]> SALOME platform Git repositories - modules/gui.git/blob - src/QxGraph/QxGraph_Canvas.cxx
Salome HOME
82526d118add6f6554963b9466e0ee160fdd77f8
[modules/gui.git] / src / QxGraph / QxGraph_Canvas.cxx
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 //  SALOME QxGraph : build Supervisor viewer into desktop
24 //
25 #include "QxGraph_Canvas.h"
26 #include "QxGraph_Def.h"
27 #include "QxGraph_Prs.h"
28
29 #include <SUIT_ResourceMgr.h>
30
31 #include <qobjectlist.h>
32 #include <QxGraph_CanvasView.h>
33
34 /*!
35   Constructor
36 */
37 QxGraph_Canvas::QxGraph_Canvas(SUIT_ResourceMgr* theMgr) :
38   QCanvas()
39 {
40   printf("Construct QxGraph_Canvas\n");
41
42   resize(GRAPH_WIDTH, GRAPH_HEIGHT);
43   setDoubleBuffering(true);
44
45   QColor aColor = theMgr->colorValue( "QxGraph", "Background", DEF_BACK_COLOR );
46   setBackgroundColor(aColor);
47 }
48
49 /*!
50   Destructor
51 */
52 QxGraph_Canvas::~QxGraph_Canvas()
53 {
54   /*QObjectList* aNodeList = queryList("QObject");
55   QObjectListIt aIt(*aNodeList);
56   QObject* anObj;
57   while ( (anObj = aIt.current()) != 0 ) {
58     ++aIt;
59     aNodeList->removeRef(anObj);
60     delete anObj;
61   }
62   delete aNodeList;*/
63
64   myPrsList.setAutoDelete(true);
65   myPrsList.clear();
66 }
67
68 /*!
69   Add view
70 */
71 void QxGraph_Canvas::addView(QCanvasView* theView)
72 {
73   myViews.append( theView );
74   QCanvas::addView(theView);
75   theView->setPaletteBackgroundColor(backgroundColor().light(120)); 
76 }
77
78 /*!
79   Remove view
80 */
81 void QxGraph_Canvas::removeView( QCanvasView* theView )
82 {
83   myViews.remove( theView );
84 }
85
86 /*!
87   Remove item
88 */
89 void QxGraph_Canvas::removeItem( QCanvasItem* theItem )
90 {
91   QValueList< QCanvasView* >::iterator anIter;
92   for ( anIter = myViews.begin(); anIter != myViews.end(); ++anIter )
93   {
94     QxGraph_CanvasView* aView = dynamic_cast<QxGraph_CanvasView*>( *anIter );
95     if ( aView )
96       aView->itemRemoved( theItem );
97   }
98
99   QCanvas::removeItem( theItem );
100 }
101
102 /*!
103   Get Prs object with index theIndex
104 */
105 QxGraph_Prs* QxGraph_Canvas::getPrs(int theIndex)
106 {
107   QxGraph_Prs* aRetPrs = 0;
108   if ( theIndex >= 0 && theIndex < myPrsList.count() )
109     aRetPrs = myPrsList.at(theIndex);
110   return aRetPrs;
111 }