Back to index

salome-gui  6.5.0
QxGraph_Canvas.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME QxGraph : build Supervisor viewer into desktop
00024 //
00025 #include "QxGraph_Canvas.h"
00026 #include "QxGraph_Def.h"
00027 #include "QxGraph_Prs.h"
00028 
00029 #include <SUIT_ResourceMgr.h>
00030 
00031 #include <qobjectlist.h>
00032 #include <QxGraph_CanvasView.h>
00033 
00037 QxGraph_Canvas::QxGraph_Canvas(SUIT_ResourceMgr* theMgr) :
00038   QCanvas()
00039 {
00040   printf("Construct QxGraph_Canvas\n");
00041 
00042   resize(GRAPH_WIDTH, GRAPH_HEIGHT);
00043   setDoubleBuffering(true);
00044 
00045   QColor aColor = theMgr->colorValue( "QxGraph", "Background", DEF_BACK_COLOR );
00046   setBackgroundColor(aColor);
00047 }
00048 
00052 QxGraph_Canvas::~QxGraph_Canvas()
00053 {
00054   /*QObjectList* aNodeList = queryList("QObject");
00055   QObjectListIt aIt(*aNodeList);
00056   QObject* anObj;
00057   while ( (anObj = aIt.current()) != 0 ) {
00058     ++aIt;
00059     aNodeList->removeRef(anObj);
00060     delete anObj;
00061   }
00062   delete aNodeList;*/
00063 
00064   myPrsList.setAutoDelete(true);
00065   myPrsList.clear();
00066 }
00067 
00071 void QxGraph_Canvas::addView(QCanvasView* theView)
00072 {
00073   myViews.append( theView );
00074   QCanvas::addView(theView);
00075   theView->setPaletteBackgroundColor(backgroundColor().light(120)); 
00076 }
00077 
00081 void QxGraph_Canvas::removeView( QCanvasView* theView )
00082 {
00083   myViews.remove( theView );
00084 }
00085 
00089 void QxGraph_Canvas::removeItem( QCanvasItem* theItem )
00090 {
00091   QValueList< QCanvasView* >::iterator anIter;
00092   for ( anIter = myViews.begin(); anIter != myViews.end(); ++anIter )
00093   {
00094     QxGraph_CanvasView* aView = dynamic_cast<QxGraph_CanvasView*>( *anIter );
00095     if ( aView )
00096       aView->itemRemoved( theItem );
00097   }
00098 
00099   QCanvas::removeItem( theItem );
00100 }
00101 
00105 QxGraph_Prs* QxGraph_Canvas::getPrs(int theIndex)
00106 {
00107   QxGraph_Prs* aRetPrs = 0;
00108   if ( theIndex >= 0 && theIndex < myPrsList.count() )
00109     aRetPrs = myPrsList.at(theIndex);
00110   return aRetPrs;
00111 }