From 7a4461fd213a47bd2f657dd2275e8df468abe959 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 24 Nov 2006 15:45:48 +0000 Subject: [PATCH] Adjust Display/Erase popup functionality --- src/VISUGUI/VisuGUI.cxx | 85 ++++++------------ src/VISUGUI/VisuGUI_Displayer.cxx | 143 ++++++++++++++++-------------- src/VISUGUI/VisuGUI_Tools.cxx | 9 +- src/VISUGUI/VisuGUI_ViewTools.cxx | 37 ++++++-- 4 files changed, 139 insertions(+), 135 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 87143741..4809eeb6 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -624,78 +624,45 @@ OnDisplayPrs() { if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs"); - LightApp_SelectionMgr* mgr = GetSelectionMgr(this); - if (!mgr) return; + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + if (!aSelectionMgr) + return; QApplication::setOverrideCursor(Qt::waitCursor); - SVTK_ViewWindow* vw = GetActiveViewWindow(this); - SALOME_ListIO aSel, aList; - mgr->selectedObjects(aSel); + aSelectionMgr->selectedObjects(aSel); extractContainers(aSel, aList); for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) { Handle(SALOME_InteractiveObject) anIO = it.Value(); CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); - - if (!CORBA::is_nil(anObject)) { - // is it Holder ? - VISU::ColoredPrs3dHolder_i* aHolder = - dynamic_cast(VISU::GetServant(anObject).in()); - if (aHolder) { - if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Holder object"); - //UpdateViewer( this, aHolder ); - if (vw) { - displayer()->Display(anIO->getEntry()); - vw->highlight(anIO, 1); - } - continue; - } - - // is it Prs3d object ? - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); - if (aPrsObject) { - if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object"); - //UpdateViewer( this, aPrsObject ); - if (vw) { - displayer()->Display(anIO->getEntry()); - vw->highlight(anIO, 1); - } - continue; - } - // is it Curve ? - VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject).in()); - if (aCurve) { - if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object"); - //PlotCurve( this, aCurve, VISU::eDisplay ); - displayer()->Display(anIO->getEntry()); - continue; - } - // is it Container ? - VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject).in()); - if (aContainer) { - if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object"); - //PlotContainer( this, aContainer, VISU::eDisplay ); + if(CORBA::is_nil(anObject)) + continue; + + VISU::Base_var aBase = VISU::Base::_narrow(anObject); + if(!CORBA::is_nil(aBase)){ + VISU::VISUType aType = aBase->GetType(); + switch (aType) { + case VISU::TCURVE: + case VISU::TCONTAINER: + case VISU::TTABLE: displayer()->Display(anIO->getEntry()); - continue; - } - // is it Table ? - VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject).in()); - if (aTable) { - if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object"); - //PlotTable( this, aTable, VISU::eDisplay ); - displayer()->Display(anIO->getEntry()); - continue; - } + break; + default: { + VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aBase); + if(!CORBA::is_nil(aPrs3d) || aType == VISU::TCOLOREDPRS3DHOLDER){ + if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this)){ + displayer()->Display(anIO->getEntry()); + aViewWindow->highlight(anIO, 1); + aViewWindow->getRenderer()->ResetCameraClippingRange(); + aViewWindow->Repaint(); + } + } + }} } } - if (vw) { - vw->getRenderer()->ResetCameraClippingRange(); - vw->Repaint(); - } - QApplication::restoreOverrideCursor(); } diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index 9d1ff6b0..af25a1bc 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -57,86 +57,98 @@ VisuGUI_Displayer::~VisuGUI_Displayer() { } -SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame ) +SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOME_View* theView ) { - SALOME_Prs* prs = 0; + SALOME_Prs* aPrs = 0; - SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView(); - SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + SALOME_View* aView = theView ? theView : GetActiveView(); + SalomeApp_Study* aStudy = dynamic_cast( myApp->activeStudy() ); - if ( study && aViewFrame ) - { - _PTR(SObject) obj = study->studyDS()->FindObjectID( entry.latin1() ); - CORBA::Object_var anObj = VISU::ClientSObjectToObject( obj ); - if( CORBA::is_nil( anObj ) ) + if(aStudy && aView){ + _PTR(SObject) aSObject = aStudy->studyDS()->FindObjectID( theEntry.latin1() ); + CORBA::Object_var anObject = VISU::ClientSObjectToObject( aSObject ); + if( CORBA::is_nil( anObject ) ) return 0; - SVTK_Viewer* vtk_viewer = dynamic_cast( aViewFrame ); - if (!vtk_viewer) - vtk_viewer = dynamic_cast( aViewFrame ); - if( vtk_viewer ) - { - SVTK_ViewWindow* wnd = - dynamic_cast( vtk_viewer->getViewManager()->getActiveView() ); - if( wnd ) - { - VISU::Prs3d_i* thePrs; - VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObj).in()); - if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER) - { - VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast( aBase ); - thePrs = dynamic_cast( VISU::GetServant(aHolder->GetDevice()).in() ); - } - else - thePrs = dynamic_cast( aBase ); + VISU::Base_var aBase = VISU::Base::_narrow(anObject); + if (CORBA::is_nil(aBase)) + return 0; - if( thePrs ) - { - buildPrs3d( wnd, thePrs ); - prs = LightApp_Displayer::buildPresentation( thePrs->GetEntry(), aViewFrame ); + VISU::Base_i* aBaseServant = dynamic_cast(VISU::GetServant(aBase).in()); + + VISU::VISUType aType = aBase->GetType(); + VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aBase); + if(!CORBA::is_nil(aPrs3d) || aType == VISU::TCOLOREDPRS3DHOLDER){ + SVTK_Viewer* aViewer = dynamic_cast( aView ); + if (!aViewer) + aViewer = dynamic_cast( aView ); + if( aViewer ){ + SUIT_ViewManager* aViewManager = aViewer->getViewManager(); + SUIT_ViewWindow* aWindow = aViewManager->getActiveView(); + if(SVTK_ViewWindow* aViewWindow = dynamic_cast( aWindow )){ + VISU::Prs3d_i* aPrs3d = NULL; + if(aType == VISU::TCOLOREDPRS3DHOLDER){ + VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(aBase); + VISU::ColoredPrs3d_var aColoredPrs3d = aHolder->GetDevice(); + aPrs3d = dynamic_cast(VISU::GetServant(aColoredPrs3d).in()); + }else + aPrs3d = dynamic_cast(aBaseServant); + + if(aPrs3d){ + buildPrs3d( aViewWindow, aPrs3d ); + Handle(SALOME_InteractiveObject) anIO = aPrs3d->GetIO(); + if(anIO->hasEntry()){ + std::string anEntry = anIO->getEntry(); + aPrs = LightApp_Displayer::buildPresentation( anEntry, aView ); + } + } } } } - SPlot2d_Viewer* plot_viewer = dynamic_cast( aViewFrame ); - if( plot_viewer ) - { - Plot2d_ViewWindow* wnd = - dynamic_cast( plot_viewer->getViewManager()->getActiveView() ); - if( !wnd ) + if(SPlot2d_Viewer* aViewer = dynamic_cast(aView)){ + SUIT_ViewManager* aViewManager = aViewer->getViewManager(); + SUIT_ViewWindow* aWindow = aViewManager->getActiveView(); + Plot2d_ViewWindow* aViewWindow = dynamic_cast( aWindow ); + if( !aViewWindow ) return 0; + + SPlot2d_Prs* aPlot2dPrs = 0; + switch (aType) { + case VISU::TCURVE: { + VISU::Curve_i* aCurve = dynamic_cast(aBaseServant); + aPlot2dPrs = buildCurve( aViewWindow, aCurve ); + break; + } + case VISU::TCONTAINER: { + VISU::Container_i* aContainer = dynamic_cast(aBaseServant); + aPlot2dPrs = buildContainer( aViewWindow, aContainer ); + break; + } + case VISU::TTABLE: { + VISU::Table_i* aTable = dynamic_cast(aBaseServant); + aPlot2dPrs = buildTable( aViewWindow, aTable ); + break; + }} - VISU::Curve_i* aCurve = dynamic_cast( VISU::GetServant( anObj ).in() ); - SPlot2d_Prs* iprs = 0; - if( aCurve ) - iprs = buildCurve( wnd, aCurve ); - - VISU::Container_i* aCont = dynamic_cast( VISU::GetServant( anObj ).in() ); - if( aCont ) - iprs = buildContainer( wnd, aCont ); - - VISU::Table_i* aTable = dynamic_cast(VISU::GetServant( anObj ).in() ); - if( aTable ) - iprs = buildTable( wnd, aTable ); - - if( iprs ) - prs = new SPlot2d_Prs( iprs ); + if( aPlot2dPrs ) + aPrs = new SPlot2d_Prs( aPlot2dPrs ); - if( prs ) - UpdatePrs( prs ); + if( aPrs ) + UpdatePrs( aPrs ); } } - return prs; + return aPrs; } -void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* wnd, VISU::Prs3d_i* thePrs ) const +void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d ) const { - VISU_Actor* newAct = VISU::FindActor(wnd, thePrs); - if (!newAct) { + VISU_Actor* anActor = VISU::FindActor(theViewWindow, thePrs3d); + if (!anActor) { try { - newAct = thePrs->CreateActor(); + anActor = thePrs3d->CreateActor(); } catch (std::runtime_error& exc) { - thePrs->RemoveActors(); + thePrs3d->RemoveActors(); INFOS(exc.what()); SUIT_MessageBox::warn1 @@ -144,11 +156,12 @@ void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* wnd, VISU::Prs3d_i* thePrs QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), QObject::tr("BUT_OK")); } - } - if (newAct) { - wnd->AddActor(newAct); - wnd->Repaint(); - } + if (anActor) + theViewWindow->AddActor(anActor); + } else + anActor->SetVisibility(true); + + theViewWindow->Repaint(); } bool VisuGUI_Displayer::addCurve( SPlot2d_Prs* prs, Plot2d_ViewWindow* wnd, VISU::Curve_i* c ) const diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 4aa51ac2..ad1e41d6 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -708,9 +708,12 @@ namespace VISU FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs) { - SALOMEDS::SObject_var aSObject = thePrs->GetSObject(); - CORBA::String_var anEntry = aSObject->GetID(); - return FindActor(theViewWindow,anEntry.in()); + Handle(SALOME_InteractiveObject) anIO = thePrs->GetIO(); + if(anIO->hasEntry()){ + std::string anEntry = anIO->getEntry(); + return FindActor(theViewWindow, anEntry.c_str()); + } + return NULL; } void diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 047603e9..966636b4 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -35,14 +35,31 @@ namespace VISU { + //---------------------------------------------------------------------------- + void + ErasePrs3dObject(VisuGUI* theModule, + VISU::Prs3d_ptr thePrs3d, + bool theDoRepaint) + { + if(VISU::Prs3d_i* aPrs3d = dynamic_cast(VISU::GetServant(thePrs3d).in())){ + SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule); + RemoveScalarBarPosition(theModule, aViewWindow, aPrs3d); + ErasePrs3d(theModule, aPrs3d, theDoRepaint); + } + } + + //---------------------------------------------------------------------------- void ErasePrs(VisuGUI* theModule, CORBA::Object_ptr theObject, - bool theDoRepaintVW) + bool theDoRepaint) { - if (CORBA::is_nil(theObject)) return; + if (CORBA::is_nil(theObject)) + return; + VISU::Base_var aBase = VISU::Base::_narrow(theObject); - if (CORBA::is_nil(aBase)) return; + if (CORBA::is_nil(aBase)) + return; VISU::VISUType aType = aBase->GetType(); switch (aType) { @@ -61,12 +78,16 @@ namespace VISU PlotTable(theModule, aTable, VISU::eErase ); break; } + case VISU::TCOLOREDPRS3DHOLDER: { + VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(aBase); + VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice(); + ErasePrs3dObject(theModule, aPrs3d, theDoRepaint); + break; + } default: { - if (VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aBase).in())) { - SVTK_ViewWindow* vw = GetActiveViewWindow(theModule); - RemoveScalarBarPosition(theModule, vw, aPrsObject); - ErasePrs3d(theModule, aPrsObject, theDoRepaintVW); - } + VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aBase); + ErasePrs3dObject(theModule, aPrs3d, theDoRepaint); }} // switch (aType) } + } -- 2.39.2