X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_I%2FVISU_ViewManager_i.cc;h=1878c1074255f505b36e00bf1f6496ed1c869035;hb=d90eeb25287fa1f390fe7a336547e74161708e44;hp=c86ac5d8cd41b7aa83fbb1c2ed9cf0794ddebd8d;hpb=953451df51750a1d9910c0325f01d5ca7b6e0330;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index c86ac5d8..1878c107 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -1,6 +1,6 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or @@ -17,19 +17,20 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// VISU OBJECT : interactive object for VISU entities implementation // File : VISU_ViewManager_i.cc // Author : Alexey PETROV // Module : VISU - +// #include "VISU_ViewManager_i.hh" #include "VISU_View_i.hh" #include "VISU_Prs3d_i.hh" #include "VISU_Table_i.hh" #include "VISU_Actor.h" +#include "VISU_ActorFactory.h" #include "SUIT_Tools.h" #include "SUIT_Session.h" @@ -47,20 +48,23 @@ #include "SalomeApp_Application.h" #include "LightApp_SelectionMgr.h" -#include "SALOME_Event.hxx" +#include "SALOME_Event.h" #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" +#include "VTKViewer_Algorithm.h" +#include "SVTK_Functor.h" + #include #include #include -#include +#include using namespace std; #ifdef _DEBUG_ -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif @@ -84,10 +88,10 @@ namespace VISU { { MESSAGE("Find application for study with id = : " << myStudyId); SUIT_Session* aSession = SUIT_Session::session(); - QPtrList anApplications = aSession->applications(); - QPtrListIterator anIter (anApplications); - while (SUIT_Application* anApp = anIter.current()) { - ++anIter; + QList anApplications = aSession->applications(); + QList::Iterator anIter = anApplications.begin(); + while ( anIter != anApplications.end() ) { + SUIT_Application* anApp = *anIter; if (SUIT_Study* aSStudy = anApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { @@ -99,6 +103,7 @@ namespace VISU { } } } + anIter++; } if (!myResult) { //MESSAGE("Error: application is not found for study : " << myStudyName); @@ -257,31 +262,29 @@ namespace VISU { //=========================================================================== // VISU namespace functions //=========================================================================== - SVTK_ViewWindow* GetViewWindow (SUIT_ViewWindow* theStudyFrame) + vtkRenderer* GetRenderer (SUIT_ViewWindow* theViewWindow) { - return dynamic_cast(theStudyFrame); - } - - vtkRenderer* GetRenderer (SUIT_ViewWindow* theStudyFrame) - { - return GetViewWindow(theStudyFrame)->getRenderer(); + if (SVTK_ViewWindow* vw = dynamic_cast(theViewWindow)) + return vw->getRenderer(); + return NULL; } - vtkCamera* GetCamera (SUIT_ViewWindow* theStudyFrame) + vtkCamera* GetCamera (SUIT_ViewWindow* theViewWindow) { - return GetRenderer(theStudyFrame)->GetActiveCamera(); + return GetRenderer(theViewWindow)->GetActiveCamera(); } void RepaintView (SUIT_ViewWindow* theViewWindow) { - SVTK_ViewWindow* vf = GetViewWindow(theViewWindow); - vf->getRenderer()->ResetCameraClippingRange(); - vf->getRenderWindow()->Render(); + if (SVTK_ViewWindow* vf = dynamic_cast(theViewWindow)) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->getRenderWindow()->Render(); + } } - VISU_Actor* UpdateViewer (SUIT_ViewWindow* theStudyFrame, int theDisplaing, Prs3d_i* thePrs) + VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs) { - SVTK_ViewWindow* vf = GetViewWindow(theStudyFrame); + SVTK_ViewWindow* vf = dynamic_cast(theViewWindow); if (!vf) return NULL; if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<eraseCurve(aSPlot2dC); } @@ -354,7 +357,7 @@ namespace VISU { for (int i = 0; i < clist.count(); i++) { SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); if (aSPlot2dC->hasIO() && - !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) { + !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC); aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() ); aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() ); @@ -362,14 +365,15 @@ namespace VISU { aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; - int nbPoints = theCurve->GetData( xList, yList ); + QStringList zList; + int nbPoints = theCurve->GetData( xList, yList, zList ); if (nbPoints > 0 && xList && yList) { - aSPlot2dC->setData( xList, yList, nbPoints ); + aSPlot2dC->setData( xList, yList, nbPoints, zList ); } if (!theCurve->IsAuto()) { - aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), + aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth()); - aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker()); + aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker()); SALOMEDS::Color color = theCurve->GetColor(); aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), @@ -402,7 +406,7 @@ namespace VISU { for (int i = 0; i < clist.count(); i++) { SPlot2d_Curve* aSPlot2dC = dynamic_cast(clist.at(i)); if (aSPlot2dC->hasIO() && - !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) { + !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) { if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC); aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() ); aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() ); @@ -410,13 +414,14 @@ namespace VISU { aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; - int nbPoints = theCurve->GetData( xList, yList ); + QStringList zList; + int nbPoints = theCurve->GetData( xList, yList, zList ); if ( nbPoints > 0 && xList && yList ) { - aSPlot2dC->setData( xList, yList, nbPoints ); + aSPlot2dC->setData( xList, yList, nbPoints, zList ); } if ( !theCurve->IsAuto() ) { - aSPlot2dC->setLine((Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth()); - aSPlot2dC->setMarker((Plot2d_Curve::MarkerType)theCurve->GetMarker()); + aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth()); + aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker()); SALOMEDS::Color color = theCurve->GetColor(); aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.))); } @@ -446,17 +451,67 @@ namespace VISU { } } - VISU_Actor* GetActor (VISU::Prs3d_i* thePrs3d, SVTK_ViewWindow* theVTKFrame) + + //---------------------------------------------------------------------------- + struct TIsSamePrs3d { - vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors(); - anActColl->InitTraversal(); - while (vtkActor *anActor = anActColl->GetNextActor()) - if (VISU_Actor* anVISUActor = dynamic_cast(anActor)) - if (thePrs3d == anVISUActor->GetPrs3d()) - return anVISUActor; - return NULL; + VISU::Prs3d_i* myPrs3d; + + TIsSamePrs3d(VISU::Prs3d_i* thePrs3d): + myPrs3d(thePrs3d) + {} + + bool + operator()(VISU_Actor* theActor) + { + return theActor->GetPrs3d() == myPrs3d; + } + }; + + + //---------------------------------------------------------------------------- + VISU_Actor* + FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d) + { + if(!thePrs3d) + return NULL; + + vtkRenderer* aRenderer = theViewWindow->getRenderer(); + vtkActorCollection* anActors = aRenderer->GetActors(); + return SVTK::Find(anActors, VISU::TIsSamePrs3d(thePrs3d)); + } + + + //---------------------------------------------------------------------------- + struct TIsSameActor + { + VISU::TActorFactory* myActor; + + TIsSameActor(VISU::TActorFactory* theActor): + myActor(theActor) + {} + + bool + operator()(VISU_ActorBase* theActor) + { + return theActor->GetFactory() == myActor; + } + }; + + //---------------------------------------------------------------------------- + VISU_ActorBase* + FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor) + { + if(!theActor) + return NULL; + + vtkRenderer* aRenderer = theViewWindow->getRenderer(); + vtkActorCollection* anActors = aRenderer->GetActors(); + return SVTK::Find(anActors, VISU::TIsSameActor(theActor)); } + + //---------------------------------------------------------------------------- struct TDeleteActorsEvent: public SALOME_Event { VISU::Curve_i* myPrs; @@ -477,10 +532,10 @@ namespace VISU { CORBA::String_var studyName = myStudyDocument->Name(); std::string aStudyName = studyName.in(); SUIT_Session* aSession = SUIT_Session::session(); - QPtrList anApplications = aSession->applications(); - QPtrListIterator anIter (anApplications); - while (SUIT_Application* aSUITApp = anIter.current()) { - ++anIter; + QList anApplications = aSession->applications(); + QList::Iterator anIter = anApplications.begin(); + while ( anIter != anApplications.end() ) { + SUIT_Application* aSUITApp = *anIter; if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { @@ -491,6 +546,7 @@ namespace VISU { } } } + anIter++; } if (!anApp) return; @@ -517,20 +573,20 @@ namespace VISU { // 3. Remove Actors ViewManagerList aViewManagerList; anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList); - QPtrListIterator anVMIter (aViewManagerList); - for (; anVMIter.current(); ++anVMIter) { - SUIT_ViewManager* aViewManager = anVMIter.current(); - QPtrVector aViews = aViewManager->getViews(); + QList::Iterator anVMIter = aViewManagerList.begin(); + for (; anVMIter != aViewManagerList.end(); anVMIter++ ) { + SUIT_ViewManager* aViewManager = *anVMIter; + QVector aViews = aViewManager->getViews(); for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { if (Plot2d_ViewWindow* vw = dynamic_cast(aViewWindow)) { Plot2d_ViewFrame* vf = vw->getViewFrame(); - QList clist; + QList clist; vf->getCurves(clist); for (int i = 0; i < clist.count(); i++) { if (SPlot2d_Curve* cu = dynamic_cast(clist.at(i))) { if (cu->hasIO() && - strcmp(cu->getIO()->getEntry(), myPrs->GetEntry()) == 0) { + strcmp(myPrs->GetEntry().c_str(), cu->getIO()->getEntry())) { vf->eraseCurve(cu); } } @@ -631,10 +687,10 @@ namespace VISU { CORBA::String_var studyName = myStudyDocument->Name(); std::string aStudyName = studyName.in(); SUIT_Session* aSession = SUIT_Session::session(); - QPtrList anApplications = aSession->applications(); - QPtrListIterator anIter (anApplications); - while (SUIT_Application* aSUITApp = anIter.current()) { - ++anIter; + QList anApplications = aSession->applications(); + QList::Iterator anIter = anApplications.begin(); + while (anIter != anApplications.end()) { + SUIT_Application* aSUITApp = *anIter; if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { @@ -645,6 +701,7 @@ namespace VISU { } } } + anIter++; } if (!anApp) return; @@ -671,10 +728,10 @@ namespace VISU { // 3. Remove Actors ViewManagerList aViewManagerList; anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList); - QPtrListIterator anVMIter (aViewManagerList); - for (; anVMIter.current(); ++anVMIter) { - SUIT_ViewManager* aViewManager = anVMIter.current(); - QPtrVector aViews = aViewManager->getViews(); + QList::Iterator anVMIter = aViewManagerList.begin(); + for (; anVMIter != aViewManagerList.end(); anVMIter++ ) { + SUIT_ViewManager* aViewManager = *anVMIter; + QVector aViews = aViewManager->getViews(); for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) { if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) { if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) {