From 5757e4873aa7ca6f17867f7c73e59decd80bd225 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 29 Nov 2006 09:19:36 +0000 Subject: [PATCH] Adjust popup --- src/VISUGUI/VisuGUI.cxx | 968 ++++++++++++------------ src/VISUGUI/VisuGUI_ClippingDlg.cxx | 22 +- src/VISUGUI/VisuGUI_CutLinesDlg.cxx | 5 +- src/VISUGUI/VisuGUI_CutPlanesDlg.cxx | 4 +- src/VISUGUI/VisuGUI_FieldFilter.cxx | 9 +- src/VISUGUI/VisuGUI_FieldFilter.h | 4 +- src/VISUGUI/VisuGUI_InputPane.cxx | 11 +- src/VISUGUI/VisuGUI_Module.cxx | 31 +- src/VISUGUI/VisuGUI_OffsetDlg.cxx | 14 +- src/VISUGUI/VisuGUI_Plot3DDlg.cxx | 2 +- src/VISUGUI/VisuGUI_PopupTools.cxx | 279 ++++--- src/VISUGUI/VisuGUI_Selection.cxx | 2 +- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 4 +- src/VISUGUI/VisuGUI_Tools.cxx | 274 ++++--- src/VISUGUI/VisuGUI_Tools.h | 49 +- src/VISUGUI/VisuGUI_TransparencyDlg.cxx | 7 +- src/VISUGUI/VisuGUI_TransparencyDlg.h | 2 + src/VISUGUI/VisuGUI_ViewTools.cxx | 47 +- src/VISUGUI/VisuGUI_ViewTools.h | 14 +- src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 50 +- src/VISU_I/VISU_ColoredPrs3dFactory.hh | 22 + src/VISU_I/VISU_ColoredPrs3d_i.cc | 33 + src/VISU_I/VISU_ColoredPrs3d_i.hh | 21 +- src/VISU_I/VISU_Prs3d_i.cc | 21 + src/VISU_I/VISU_Prs3d_i.hh | 22 + src/VISU_I/VISU_ViewManager_i.cc | 40 +- src/VISU_I/VISU_ViewManager_i.hh | 2 +- src/VISU_I/VISU_View_i.cc | 2 +- 28 files changed, 1121 insertions(+), 840 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 0c61cec1..56eeb594 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -504,9 +504,13 @@ VisuGUI if (CheckLock(aStudy,GetDesktop(this))) return; + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + // Get selected SObject - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(this, &anIO); + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; if (anIO.IsNull() || !anIO->hasEntry()) return; @@ -634,28 +638,26 @@ VisuGUI 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)) + TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); + VISU::Base_i* aBase = anObjectInfo.myBase; + if(!aBase) 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()); - 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(); - } + VISU::VISUType aType = aBase->GetType(); + switch (aType) { + case VISU::TCURVE: + case VISU::TCONTAINER: + case VISU::TTABLE: + displayer()->Display(anIO->getEntry()); + break; + default: { + VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase); + if(aPrs3d){ + if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this)){ + displayer()->Display(anIO->getEntry()); + aViewWindow->highlight(anIO, 1); + aViewWindow->getRenderer()->ResetCameraClippingRange(); + aViewWindow->Repaint(); } }} } @@ -677,31 +679,24 @@ VisuGUI ::OnErasePrs() { if(MYDEBUG) MESSAGE("OnErasePrs"); - QApplication::setOverrideCursor(Qt::waitCursor); - //SVTK_ViewWindow* vw = GetActiveViewWindow(this); - //if (vw) - // vw->unHighlightAll(); - SALOME_ListIO aList, aSel; - LightApp_SelectionMgr* mgr = GetSelectionMgr(this); - mgr->selectedObjects(aSel); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + 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()); - //ErasePrs(this, anObject, /*repaint_view_window = */false); - ErasePrs(this, anObject, /*repaint_view_window = */true); + TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); + VISU::Base_i* aBase = anObjectInfo.myBase; + ErasePrs(this, aBase, /*repaint_view_window = */true); } - //if (vw) - // vw->Repaint(); - QApplication::restoreOverrideCursor(); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEraseAll() @@ -727,88 +722,115 @@ VisuGUI } +namespace +{ + //---------------------------------------------------------------------------- + VISU::Prs3d_i* + GetPrsToModify(const SalomeApp_Module* theModule, + Handle(SALOME_InteractiveObject)& theIO) + { + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); + if(aSelectionInfo.empty()) + return NULL; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + theIO = aSelectionItem.myIO; + return VISU::GetPrs3dToModify(theModule, aSelectionItem.myObjectInfo.myBase); + } +} + +//---------------------------------------------------------------------------- void VisuGUI ::OnEditScalarMap() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditDeformedShape() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditScalarMapOnDeformedShape() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditCutPlanes() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditCutLines() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditIsoSurfaces() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditVectors() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditStreamLines() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditPlot3D() { Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMakeSurfaceframe() @@ -816,6 +838,7 @@ VisuGUI ChangeRepresentation(this, VISU::SURFACEFRAME); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMakeInsideframe() @@ -823,6 +846,7 @@ VisuGUI ChangeRepresentation(this, VISU::INSIDEFRAME); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMakeWireframe() @@ -830,6 +854,7 @@ VisuGUI ChangeRepresentation(this, VISU::WIREFRAME); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMakeSurface() @@ -837,6 +862,7 @@ VisuGUI ChangeRepresentation(this, VISU::SHADED); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMakePoints() @@ -844,6 +870,7 @@ VisuGUI ChangeRepresentation(this, VISU::POINT); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMakeShrink() @@ -851,6 +878,7 @@ VisuGUI ChangeRepresentation(this, VISU::SHRINK); } +//---------------------------------------------------------------------------- void VisuGUI ::OnSetShadingOn() @@ -858,6 +886,7 @@ VisuGUI SetShading(this, true); } +//---------------------------------------------------------------------------- void VisuGUI ::OnSetShadingOff() @@ -865,19 +894,48 @@ VisuGUI SetShading(this, false); } + +namespace +{ + //---------------------------------------------------------------------------- + bool + GetPrs3dSelectionInfo(const SalomeApp_Module* theModule, + VISU::Prs3d_i*& thePrs3d, + SVTK_ViewWindow*& theViewWindow, + VISU_Actor*& thenActor) + { + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); + if(aSelectionInfo.empty()) + return false; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); + if(!thePrs3d) + return false; + + theViewWindow = GetActiveViewWindow(theModule); + if(!theViewWindow) + return false; + + thenActor = FindActor(theViewWindow, thePrs3d); + if(!thenActor) + return false; + + return true; + } +} + +//---------------------------------------------------------------------------- void VisuGUI ::OnChangeColor() { - SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); - if(!aViewWindow) - return; - VISU::Prs3d_i* aPrs3d = GetPrsToModify(this); - if(!aPrs3d) - return; - VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d); - if(!anActor) + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) return; + VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d); VISU::DeformedShape_i* aDeformedShape = dynamic_cast(aPrs3d); @@ -932,24 +990,21 @@ VisuGUI } } +//---------------------------------------------------------------------------- void VisuGUI ::OnChangeWireframeColor() { - SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); - if(!aViewWindow) - return; - VISU::Prs3d_i* aPrs3d = GetPrsToModify(this); - if(!aPrs3d) - return; - VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d); - if(!anActor) - return; - if(aPrs3d->GetType() != VISU::TMESH) + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) return; + VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d); if(!aMesh) return; + SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor; QColor aColor (int(255*anOldColor.R), int(255*anOldColor.G), @@ -964,37 +1019,32 @@ VisuGUI } } +//---------------------------------------------------------------------------- void VisuGUI ::OnChangeOpacity() { - SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); - if(!aViewWindow) - return; - VISU::Prs3d_i* aPrs3d = GetPrsToModify(this); - if(!aPrs3d) - return; - VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d); - if(!anActor) + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) return; + VisuGUI_TransparencyDlg* aDialog = new VisuGUI_TransparencyDlg( this ); aDialog->show(); } +//---------------------------------------------------------------------------- void VisuGUI ::OnChangeLines() { - SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); - if(!aViewWindow) - return; - VISU::Prs3d_i* aPrs3d = GetPrsToModify(this); - if(!aPrs3d) + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) return; - VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d); - if(!anActor) - return; - + VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE); @@ -1016,34 +1066,27 @@ VisuGUI delete CursorDlg; } +//---------------------------------------------------------------------------- void VisuGUI ::OnShowTable() { - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( this, &anIO ); - _PTR(SObject) SO; - if ( !CORBA::is_nil( anObject ) ) { - VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject ); - if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) { - CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject ); - if( !CORBA::is_nil( aTable ) ) { - VISU::Table_i* table = dynamic_cast( VISU::GetServant(aTable).in() ); - if ( table ) { - SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() ); - } - } - } - } else { - // possibly this is Table SObject - SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() ); - } - - if( !IsSObjectTable( SO ) ) + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + if(VISU::Table_i* aTable = dynamic_cast(aBase)) + aSObject = GetCStudy( GetAppStudy( this ) )->FindObjectID( aTable->GetObjectEntry() ); + + if( !IsSObjectTable( aSObject ) ) return; VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ), - SO, + aSObject, false, //SAL2670 Orientation of show tables VisuGUI_TableDlg::ttAuto, @@ -1051,21 +1094,26 @@ VisuGUI dlg->show(); } +//---------------------------------------------------------------------------- void VisuGUI ::OnCreateTable() { - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( this, &anIO ); - _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) ); - _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry()); - VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject ); - if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) { + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + + if((aBase && aBase->GetType() == VISU::TCUTLINES) || IsSObjectTable(aSObject)) { GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() ); UpdateObjBrowser(this); } } +//---------------------------------------------------------------------------- void VisuGUI ::OnDeleteObjects() @@ -1096,45 +1144,35 @@ VisuGUI aStudyBuilder->NewCommand(); for (i = 0; i < nbSelected; i++) { - _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]); - if (aSObject) { - _PTR(SObject) aRefObj; - if (aSObject->ReferencedObject(aRefObj)) { - // It can be a reference on curve, published under a container. - // In this case the curve should be removed from the container. - // See bug 10441. - CORBA::Object_var aCorbaObj = VISU::GetSelectedObj(anAppStudy, aRefObj->GetID().c_str()); - if (!CORBA::is_nil(aCorbaObj)) { - VISU::Base_var aVisuObj = VISU::Base::_narrow(aCorbaObj); - if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TMESH) - { - DeleteSObject(this, aCStudy, aRefObj); - UpdateObjBrowser(this, true, aRefObj); + VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), entries[i]); + if(_PTR(SObject) aSObject = anObjectInfo.mySObject){ + _PTR(SObject) aRefSObject; + if (aSObject->ReferencedObject(aRefSObject)) { + // It can be a reference on curve, published under a container. + // In this case the curve should be removed from the container. + // See bug 10441. + VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(this), aRefSObject->GetID()); + VISU::Base_i* aRefBase = aRefObjectInfo.myBase; + if(aRefBase && aRefBase->GetType() == VISU::TMESH){ + DeleteSObject(this, aCStudy, aRefSObject); + UpdateObjBrowser(this, true, aRefSObject); + }else if(aRefBase && aRefBase->GetType() == VISU::TCURVE){ + CORBA::Object_var anObject = ClientSObjectToObject(aRefSObject); + VISU::Curve_var aCurve = VISU::Curve::_narrow(anObject); + _PTR(SObject) aParentSO = aSObject->GetFather(); + VISU::TObjectInfo aParentObjectInfo = GetObjectByEntry(GetAppStudy(this), aParentSO->GetID()); + if(VISU::Base_i* aParentBase = aParentObjectInfo.myBase){ + if(VISU::Container_i* aContainer = dynamic_cast(aParentBase)){ + if(aContainer->GetNbCurves() > 0){ + aContainer->RemoveCurve(aCurve); + UpdateObjBrowser(this, true, aParentSO); + } + } } - else if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) { - VISU::Curve_ptr aCurve = VISU::Curve::_narrow(aVisuObj); - _PTR(SObject) aParentSO = aSObject->GetFather(); - aCorbaObj = VISU::GetSelectedObj(anAppStudy, aParentSO->GetID().c_str()); - if (!CORBA::is_nil(aCorbaObj) && !CORBA::is_nil(aCurve)) { - aVisuObj = VISU::Base::_narrow(aCorbaObj); - if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) { - // Container object - CORBA::Object_ptr aCnt = VISU::Container::_narrow(aVisuObj); - if (!CORBA::is_nil(aCnt)) { - VISU::Container_i* aContainer = - dynamic_cast(VISU::GetServant(aCnt).in()); - if (aContainer && aContainer->GetNbCurves() > 0) { - aContainer->RemoveCurve(aCurve); - UpdateObjBrowser(this, true, aParentSO); - } - } - } - } - } - } - } else { - DeleteSObject(this, aCStudy, aSObject); - UpdateObjBrowser(this, true, aSObject); + } + }else{ + DeleteSObject(this, aCStudy, aSObject); + UpdateObjBrowser(this, true, aSObject); } } } @@ -1144,204 +1182,186 @@ VisuGUI mgr->clearSelected(); } +//---------------------------------------------------------------------------- void VisuGUI ::OnPlotData() { - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( this, &anIO ); - _PTR(SObject) SO; - _PTR(GenericAttribute) anAttr; - _PTR(AttributeName) aName; - QString SOName; - _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) ); - - if ( !CORBA::is_nil( anObject ) ) { - VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); - if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) { - // Table (VISU object) is selected - CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject ); - if( !CORBA::is_nil( aTbl ) ) { - VISU::Table_i* table = dynamic_cast(VISU::GetServant(aTbl).in()); - if ( table ) { - _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() ); - if ( IsSObjectTable(SO) ) { - // get name of SObject - if ( SO->FindAttribute( anAttr, "AttributeName" ) ) { - aName = anAttr; - SOName = QString( aName->Value().c_str() ); - } - VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) ); - if ( dlg->exec() == QDialog::Accepted ) { - if ( !IsStudyLocked( aStudy ) ) { - // if study is not locked - create new container, create curves and insert them - // into container, then plot container if current viewer is of VIEW_PLOT2D type - int horIndex; - QValueList verIndices, zIndices; - dlg->getCurvesSource( horIndex, verIndices, zIndices ); - if ( horIndex >= 0 && verIndices.count() > 0 ) { - CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer(); - if( !CORBA::is_nil( aContainer ) ) { - VISU::Container_i* pContainer = - dynamic_cast(VISU::GetServant(aContainer).in()); - if ( pContainer ) { - for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = - GetVisuGen(this)->CreateCurveWithZ( table->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); - if( !CORBA::is_nil( aNewCurve ) ) { - VISU::Curve_i* pCrv = - dynamic_cast(VISU::GetServant(aNewCurve).in()); - if ( pCrv ) { - bool isAuto; - int marker, line, lineWidth; - QColor color; - if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker, - line, lineWidth, color) && !isAuto ) { - SALOMEDS::Color c; - c.R = color.red() /255.; - c.G = color.green()/255.; - c.B = color.blue() /255.; - pCrv->SetColor( c ); - pCrv->SetMarker( ( VISU::Curve::MarkerType )marker ); - pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth ); - } - pContainer->AddCurve( pCrv->_this() ); - } - } - } - UpdateObjBrowser(this); - PlotContainer( this, pContainer, VISU::eDisplay ); - } - } - } - } - else { - // if study is locked just get curves info and plot them - // if current viewer is of VIEW_PLOT2D type - QPtrList container; - dlg->getCurves( container ); - if ( !container.isEmpty() ) { - GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true ); - GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName ); - } - } - } - delete dlg; - } - } + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){ + if(aBase->GetType() == VISU::TTABLE) { + if(VISU::Table_i* aTable = dynamic_cast(aBase)){ + _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); + _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() ); + if(IsSObjectTable(aSObject)){ + VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); + if(aDlg->exec() == QDialog::Accepted){ + if(!IsStudyLocked(aStudy)){ + // if study is not locked - create new container, create curves and insert them + // into container, then plot container if current viewer is of VIEW_PLOT2D type + int horIndex; + QValueList verIndices, zIndices; + aDlg->getCurvesSource( horIndex, verIndices, zIndices ); + if( horIndex >= 0 && verIndices.count() > 0 ){ + CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer(); + if(VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObj).in())){ + for( int i = 0; i < verIndices.count(); i++ ){ + VISU::Curve_var aCurveObject = + GetVisuGen(this)->CreateCurveWithZ(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); + if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ + bool isAuto; + int marker, line, lineWidth; + QColor color; + if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker, + line, lineWidth, color) && !isAuto ) + { + SALOMEDS::Color c; + c.R = color.red() /255.; + c.G = color.green()/255.; + c.B = color.blue() /255.; + aCurve->SetColor( c ); + aCurve->SetMarker( ( VISU::Curve::MarkerType )marker ); + aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth ); + } + aContainer->AddCurve(aCurveObject); + } + } + UpdateObjBrowser(this); + PlotContainer( this, aContainer, VISU::eDisplay ); + } + } + } else { + // get name of SObject + QString aSObjectName; + _PTR(GenericAttribute) anAttr; + if(aSObject->FindAttribute( anAttr, "AttributeName" )){ + _PTR(AttributeName) aName = anAttr; + aSObjectName = QString( aName->Value().c_str() ); + } + // if study is locked just get curves info and plot them + // if current viewer is of VIEW_PLOT2D type + QPtrList container; + aDlg->getCurves( container ); + if ( !container.isEmpty() ) { + GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true ); + GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName ); + } + } + } + delete aDlg; + } } } - } - else if ( !anIO.IsNull() ) { + }else if(!aSelectionItem.myIO.IsNull()){ // check if Table SObject is selected - SO = aStudy->FindObjectID( anIO->getEntry() ); - if ( IsSObjectTable(SO) ) { - // get name of SObject - if ( SO->FindAttribute( anAttr, "AttributeName" ) ) { - aName = anAttr; - SOName = QString( aName->Value().c_str() ); - } - VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) ); - if ( dlg->exec() == QDialog::Accepted ) { - if ( !IsStudyLocked( aStudy ) ) { + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + if(IsSObjectTable(aSObject)){ + VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this)); + if(aDlg->exec() == QDialog::Accepted){ + _PTR(Study) aStudy = GetCStudy(GetAppStudy(this)); + if(!IsStudyLocked(aStudy)){ // if study is not locked - create new table and container objects, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; QValueList verIndices, zIndices; - dlg->getCurvesSource( horIndex, verIndices, zIndices ); + aDlg->getCurvesSource( horIndex, verIndices, zIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { - CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() ); - CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer(); - if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) { - VISU::Table_i* pTable = dynamic_cast(VISU::GetServant(aTable).in()); - VISU::Container_i* pContainer = dynamic_cast(VISU::GetServant(aContainer).in()); - - if ( pContainer && pTable ) { - for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurveWithZ - ( pTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 ); - if( !CORBA::is_nil( aNewCurve ) ) { - VISU::Curve_i* pCrv = dynamic_cast(VISU::GetServant(aNewCurve).in()); - if ( pCrv ) { - bool isAuto; - int marker, line, lineWidth; - QColor color; - if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker, - line, lineWidth, color) && !isAuto ) { - SALOMEDS::Color c; - c.R = color.red()/255.; - c.G = color.green()/255.; - c.B = color.blue()/255.; - pCrv->SetColor( c ); - pCrv->SetMarker( ( VISU::Curve::MarkerType )marker ); - pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth ); - } - pContainer->AddCurve( pCrv->_this() ); - } - } - } - UpdateObjBrowser(this); - PlotContainer( this, pContainer, VISU::eDisplay ); - } - } - } + VISU::Table_var aTableObject = GetVisuGen(this)->CreateTable(aSObject->GetID().c_str()); + if(!CORBA::is_nil(aTableObject)){ + VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer(); + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aContainerObject).in()); + for ( int i = 0; i < verIndices.count(); i++ ) { + VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZ + ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1 ); + if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCurveObject).in())){ + bool isAuto; + int marker, line, lineWidth; + QColor color; + if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker, + line, lineWidth, color) && !isAuto ) + { + SALOMEDS::Color c; + c.R = color.red()/255.; + c.G = color.green()/255.; + c.B = color.blue()/255.; + aCurve->SetColor( c ); + aCurve->SetMarker( ( VISU::Curve::MarkerType )marker ); + aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth ); + } + aContainerObject->AddCurve(aCurveObject); + } + } + UpdateObjBrowser(this); + PlotContainer( this, aContainer, VISU::eDisplay ); + } + } } else { + // get name of SObject + QString aSObjectName; + _PTR(GenericAttribute) anAttr; + if(aSObject->FindAttribute(anAttr, "AttributeName")){ + _PTR(AttributeName) aName = anAttr; + aSObjectName = QString( aName->Value().c_str() ); + } // if study is locked just get curves info and plot them QPtrList container; - dlg->getCurves( container ); + aDlg->getCurves( container ); if ( !container.isEmpty() ) { GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true ); - GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName ); + GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName ); } } } - delete dlg; + delete aDlg; } } } +//---------------------------------------------------------------------------- void VisuGUI ::OnCurveProperties() { - LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - if (aListIO.Extent() != 1) return; + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.size() != 1) + return; - SalomeApp_Study* aAppStudy = GetAppStudy(this); - const Handle(SALOME_InteractiveObject)& anIO = aListIO.First(); - CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() ); - if (CORBA::is_nil( anObject )) return; + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(!aBase) + return; - VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); - if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) { + if(aBase->GetType() == VISU::TCURVE) { // Curve object - CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject ); - if( !CORBA::is_nil( aCurve ) ) { - VISU::Curve_i* aDSCurve = dynamic_cast(VISU::GetServant(aCurve).in()); - if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) { + if(VISU::Curve_i* aCurve = dynamic_cast(aBase)){ + if(!IsStudyLocked(GetCStudy(GetAppStudy(this)))){ Plot2d_SetupCurveDlg aDlg(GetDesktop( this )); - aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() ); - aDlg.setMarker( (int)aDSCurve->GetMarker() ); - SALOMEDS::Color aColor = aDSCurve->GetColor(); + aDlg.setLine( (int)aCurve->GetLine(), aCurve->GetLineWidth() ); + aDlg.setMarker( (int)aCurve->GetMarker() ); + SALOMEDS::Color aColor = aCurve->GetColor(); aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) ); if( aDlg.exec() == QDialog::Accepted ) { - aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() ); - aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker()); + aCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() ); + aCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker()); SALOMEDS::Color newColor; newColor.R = aDlg.getColor().red()/255.; newColor.G = aDlg.getColor().green()/255.; newColor.B = aDlg.getColor().blue()/255.; - aDSCurve->SetColor( newColor ); - PlotCurve(this, aDSCurve, VISU::eDisplay); + aCurve->SetColor( newColor ); + PlotCurve(this, aCurve, VISU::eDisplay); } } } } } +//---------------------------------------------------------------------------- void VisuGUI ::OnClearContainer() @@ -1349,37 +1369,44 @@ VisuGUI _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); if (CheckLock(aCStudy,GetDesktop(this))) return; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(this, &anIO); - if (anIO.IsNull() || CORBA::is_nil(anObject)) + + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(!aBase) return; - VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); - if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) { + if(aBase->GetType() == VISU::TCONTAINER){ // Container object - CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject); - if (!CORBA::is_nil(aCnt)) { - VISU::Container_i* container = dynamic_cast(VISU::GetServant(aCnt).in()); - if (container && container->GetNbCurves() > 0) { - container->Clear(); + if(VISU::Container_i* aContainer = dynamic_cast(aBase)){ + if(aContainer && aContainer->GetNbCurves() > 0){ + aContainer->Clear(); UpdateObjBrowser(this); } } } } +//---------------------------------------------------------------------------- void VisuGUI ::OnEditContainer() { - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(this, &anIO); - if (CORBA::is_nil(anObject)) return; + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(!aBase) + return; - PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); - if (!aServant.in()) return; - VISU::Container_i* aContainer = dynamic_cast(aServant.in()); - if (!aContainer) return; + VISU::Container_i* aContainer = dynamic_cast(aBase); + if(!aContainer) + return; VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this); aDlg->initFromPrsObject(aContainer); @@ -1390,6 +1417,7 @@ VisuGUI delete aDlg; } +//---------------------------------------------------------------------------- void VisuGUI ::OnSaveViewParams() @@ -1417,6 +1445,7 @@ VisuGUI UpdateObjBrowser(this); } +//---------------------------------------------------------------------------- void VisuGUI ::OnRestoreViewParams() @@ -1439,6 +1468,7 @@ VisuGUI VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp } +//---------------------------------------------------------------------------- void VisuGUI ::OnRename() @@ -1447,15 +1477,18 @@ VisuGUI if (CheckLock(aCStudy,GetDesktop(this))) return; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(this, &anIO); - - _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry()); - if (!aSObj) return; + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + if(!aSObject) + return; //TEST DU PARENT == VISU _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder(); - _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName"); + _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObject, "AttributeName"); if (anAttr) { _PTR(AttributeName) aName (anAttr); QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() ); @@ -1463,74 +1496,50 @@ VisuGUI QApplication::setOverrideCursor(Qt::waitCursor); // rename specific objects - if (!CORBA::is_nil(anObject)) { - VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); - if (!CORBA::is_nil(aVisuObj)) { - switch (aVisuObj->GetType()) { - case VISU::TCURVE: // Curve object - { - CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject); - if (!CORBA::is_nil(aCurve)) { - VISU::Curve_i* curve = - dynamic_cast(VISU::GetServant(aCurve).in()); - if (curve) - curve->SetName(Name.latin1(), true); - } - break; - } - case VISU::TTABLE: // Table object - { - CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject); - if (!CORBA::is_nil(aTable)) { - VISU::Table_i* table = - dynamic_cast(VISU::GetServant(aTable).in()); - if (table) - table->SetName(Name.latin1(), true); - } - break; - } - case VISU::TCONTAINER: // Container object - { - CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject); - if (!CORBA::is_nil(aContainer)) { - VISU::Container_i* container = - dynamic_cast(VISU::GetServant(aContainer).in()); - if (container) - container->SetName(Name.latin1(), true); - } - break; - } - default: - { - } - } - } + if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){ + switch(aBase->GetType()){ + case VISU::TCURVE: { // Curve object + if(VISU::Curve_i* aCurve = dynamic_cast(aBase)) + aCurve->SetName(Name.latin1(), true); + break; + } + case VISU::TTABLE: { // Table object + if(VISU::Table_i* aTable = dynamic_cast(aBase)) + aTable->SetName(Name.latin1(), true); + break; + } + case VISU::TCONTAINER: { // Container object + if(VISU::Container_i* aContainer = dynamic_cast(aBase)) + aContainer->SetName(Name.latin1(), true); + break; + } + default: { + }} } + } - // rename the study object - aName->SetValue(Name.latin1()); // rename the SObject - anIO->setName(Name.latin1()); // rename the InteractiveObject + // rename the study object + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + aName->SetValue(Name.latin1()); // rename the SObject + anIO->setName(Name.latin1()); // rename the InteractiveObject - ViewManagerList pvm_list; - getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list ); - for( SUIT_ViewManager* mgr = pvm_list.first(); mgr; mgr = pvm_list.next() ) - { - Plot2d_ViewManager* pvm = dynamic_cast( mgr ); - if( pvm ) - { - SPlot2d_Viewer* pv = dynamic_cast( pvm->getViewModel() ); - if( pv ) - pv->renameAll( anIO, Name.latin1() ); - } + ViewManagerList aViewManagerList; + getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList); + SUIT_ViewManager* aViewManager = aViewManagerList.first(); + for(; aViewManager; aViewManager = aViewManagerList.next()){ + if(Plot2d_ViewManager* aManager = dynamic_cast(aViewManager)){ + if(SPlot2d_Viewer* aViewer = dynamic_cast(aManager->getViewModel())) + aViewer->renameAll( anIO, Name.latin1() ); } + } - UpdateObjBrowser(this, false); + UpdateObjBrowser(this, false); - QApplication::restoreOverrideCursor(); - } + QApplication::restoreOverrideCursor(); } } +//---------------------------------------------------------------------------- void VisuGUI ::OnClippingPlanes() @@ -1538,22 +1547,21 @@ VisuGUI new VisuGUI_ClippingDlg (this, "", false); } +//---------------------------------------------------------------------------- void VisuGUI ::OnSweep() { - SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(this); - if(!aViewWindow) - return; - VISU::Prs3d_i* aPrs3d = GetPrsToModify(this); - if(!aPrs3d) + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) return; + VISU::ScalarMap_i* aScalarMap = dynamic_cast(aPrs3d); if(!aScalarMap) return; - VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d); - if(!anActor) - return; + if(!anActor->GetVisibility()) anActor->VisibilityOn(); @@ -1586,6 +1594,7 @@ VisuGUI QApplication::restoreOverrideCursor(); } +//---------------------------------------------------------------------------- void VisuGUI ::OnTimeAnimation() @@ -1624,7 +1633,7 @@ VisuGUI else delete aAnimationDlg; } -//************************************************************************ +//---------------------------------------------------------------------------- void VisuGUI ::OnShowAnimation() @@ -1664,22 +1673,6 @@ VisuGUI aAnimationDlg->show(); } -//---------------------------------------------------------------------------- -template -void -DoSameAs(VISU::Prs3d_i* thePrs3d) -{ - typedef typename TL::TColoredEnum2Type::TResult TColoredPrs3d; - TColoredPrs3d* aColoredPrs3d = dynamic_cast(thePrs3d); - TColoredPrs3d* aSameColoredPrs3d = new TColoredPrs3d(VISU::ColoredPrs3d_i::EPublishUnderTimeStamp); - aSameColoredPrs3d->SetCResult(aColoredPrs3d->GetCResult()); - aSameColoredPrs3d->SetMeshName(aColoredPrs3d->GetCMeshName().c_str()); - aSameColoredPrs3d->SetEntity(aColoredPrs3d->GetEntity()); - aSameColoredPrs3d->SetFieldName(aColoredPrs3d->GetCFieldName().c_str()); - aSameColoredPrs3d->SetTimeStampNumber(aColoredPrs3d->GetTimeStampNumber()); - aSameColoredPrs3d->SameAs(aColoredPrs3d); -} - //---------------------------------------------------------------------------- void VisuGUI @@ -1689,54 +1682,55 @@ VisuGUI if (CheckLock(aCStudy,GetDesktop(this))) return; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(this, &anIO); - if (CORBA::is_nil(anObject)) return; - PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); - if (!aServant.in()) return; + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(!aBase) + return; - VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in()); - if (!aPrsObject) return; + VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aBase); + if(!aPrs3d) + return; - switch (aPrsObject->GetType()) { - case VISU::TMESH: - { - VISU::Mesh_i* aPrs = dynamic_cast(aPrsObject); - VISU::Mesh_i* aSamePrs = new VISU::Mesh_i(aPrs->GetCResult()); - aSamePrs->SameAs(aPrs); + if(aBase->GetType() != VISU::TMESH){ + VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast(aBase); + switch (aBase->GetType()) { + case VISU::TSCALARMAP: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TDEFORMEDSHAPE: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TSCALARMAPONDEFORMEDSHAPE: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TCUTPLANES: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TCUTLINES: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TISOSURFACE: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TSTREAMLINES: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TVECTORS: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; + case VISU::TPLOT3D: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp); + break; } - break; - case VISU::TSCALARMAP: - DoSameAs(aPrsObject); - break; - case VISU::TDEFORMEDSHAPE: - DoSameAs(aPrsObject); - break; - case VISU::TSCALARMAPONDEFORMEDSHAPE: - DoSameAs(aPrsObject); - break; - case VISU::TCUTPLANES: - DoSameAs(aPrsObject); - break; - case VISU::TCUTLINES: - DoSameAs(aPrsObject); - break; - case VISU::TISOSURFACE: - DoSameAs(aPrsObject); - break; - case VISU::TSTREAMLINES: - DoSameAs(aPrsObject); - break; - case VISU::TVECTORS: - DoSameAs(aPrsObject); - break; - case VISU::TPLOT3D: - DoSameAs(aPrsObject); - break; + UpdateObjBrowser(this); } - UpdateObjBrowser(this); } +//---------------------------------------------------------------------------- void VisuGUI ::OnSelectionInfo() @@ -1750,6 +1744,7 @@ VisuGUI tr("BUT_OK") ); } +//---------------------------------------------------------------------------- void VisuGUI ::OnMergeScalarBars() @@ -1811,6 +1806,7 @@ VisuGUI } } +//---------------------------------------------------------------------------- void VisuGUI ::OnFreeScalarBars() @@ -1848,6 +1844,7 @@ VisuGUI } } +//---------------------------------------------------------------------------- void VisuGUI ::OnTranslatePrs() @@ -1865,8 +1862,8 @@ VisuGUI Handle(SALOME_InteractiveObject) anIO = anIter.Value(); if (anIO->hasEntry()) { QString anEntry(anIO->getEntry()); - CORBA::Object_var anObject = VISU::GetSelectedObj(aStudy, anEntry); - if(VISU::Prs3d_i* aPrsObject = VISU::GetPrsToModify(anObject)) + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry); + if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)) aDlg->addPresentation(aPrsObject); } } @@ -2642,17 +2639,14 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q if (isExist && aType == VISU::TCURVE) { isCurves = true; } else { - CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); - if (!CORBA::is_nil(anObject)) { - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); - if (aPrsObject) { - if (aPrsObject->GetType() == VISU::TCUTPLANES) { - VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); - if (aCutPrs) { - isOneCutPlane = aCutPrs->GetNbPlanes() == 1; - } - } - } + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); + if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){ + if (aPrsObject->GetType() == VISU::TCUTPLANES) { + VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); + if (aCutPrs) { + isOneCutPlane = aCutPrs->GetNbPlanes() == 1; + } + } } } } @@ -2662,13 +2656,18 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q if (isOneCutPlane) action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu); - Handle(SALOME_InteractiveObject) anIO; - VISU::Storable::TRestoringMap aMap; - CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap); - - if (!CORBA::is_nil(anObject)) { - VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObject).in()); - if (aBase && aBase->GetType() == VISU::TCOLOREDPRS3DCACHE) + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(aSObject); + CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject); + + if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){ + if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE) action( VISU_CACHE_PROPERTIES )->addTo(theMenu); } @@ -2686,11 +2685,9 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q } // Check single selection - if (aListIO.Extent() != 1) return; - - _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry()); - if ( !SO ) + if (aListIO.Extent() != 1) return; + bool isExist; VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); @@ -2698,7 +2695,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q action( VISU_SHOW_ANIMATION )->addTo(theMenu); } else if (isOBClient) { - if (IsSObjectTable(SO)) { + if (IsSObjectTable(aSObject)) { action( VISU_SHOW_TABLE )->addTo(theMenu); action( VISU_CREATE_CURVES )->addTo(theMenu); action( VISU_EXPORT_TABLE )->addTo(theMenu); @@ -2715,7 +2712,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp" } } else { - _PTR(SObject) aSFather = SO->GetFather(); + _PTR(SObject) aSFather = aSObject->GetFather(); if (aSFather) { _PTR(GenericAttribute) anAttr; aSFather->FindAttribute(anAttr, "AttributeName"); @@ -3223,14 +3220,13 @@ void VisuGUI::OnPlot3dFromCutPlane() aSObject = aCStudy->FindObjectID(anIO->getEntry()); if ( !aSObject ) continue; - CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); - if (!CORBA::is_nil(anObject)) { - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); - if (aPrsObject->GetType() == VISU::TCUTPLANES) { - aCutPrs = dynamic_cast(aPrsObject); - if (aCutPrs) - break; - } + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry()); + if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){ + if (aPrsObject->GetType() == VISU::TCUTPLANES) { + aCutPrs = dynamic_cast(aPrsObject); + if (aCutPrs) + break; + } } } } @@ -3306,7 +3302,17 @@ void VisuGUI::OnPlot3dFromCutPlane() void VisuGUI::OnCacheProperties() { - CORBA::Object_var anObject = GetSelectedObj(this); + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; + + CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject); + if( CORBA::is_nil( anObject ) ) + return; + VISU::ColoredPrs3dCache_var aCache = VISU::GetInterface(anObject); if( CORBA::is_nil( aCache ) ) return; diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 48360aad..9fd8c91e 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -596,18 +596,22 @@ void VisuGUI_ClippingDlg::ClickOnHelp() //================================================================================= void VisuGUI_ClippingDlg::onSelectionChanged() { - if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI)) { - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = VISU::GetSelectedObj(myVisuGUI, &anIO); - if (CORBA::is_nil(anObject)) return; - + if(SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI)){ + + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(myVisuGUI); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; + if(!aBase) + return; + + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; if (!anIO.IsNull()) myIO = anIO; - PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); - if (!aServant.in()) return; - - myPrs3d = dynamic_cast(aServant.in()); + myPrs3d = dynamic_cast(aBase); if (myPrs3d) { std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); myPlanes.clear(); diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index c2cb198e..6a30c79c 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -23,6 +23,8 @@ #include "VisuGUI_CutLinesDlg.h" +#include "VISU_ColoredPrs3dFactory.hh" + #include "VisuGUI.h" #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" @@ -313,8 +315,7 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs) setOrientation2(thePrs->GetOrientationType2()); hasInit = true; - myCutLines = new VISU::CutLines_i(VISU::ColoredPrs3d_i::EDoNotPublish); - myCutLines->SameAs(thePrs); + myCutLines = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted()); if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true); myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) ); diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 18de4229..5f62ba97 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -28,6 +28,8 @@ #include "VisuGUI_CutPlanesDlg.h" +#include "VISU_ColoredPrs3dFactory.hh" + #include "VisuGUI.h" #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" @@ -186,7 +188,7 @@ void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs) myPosSpn->setValue(thePrs->GetDisplacement()); hasInit = true; // init table - myCutPlanes = new VISU::CutPlanes_i(VISU::ColoredPrs3d_i::EDoNotPublish); + myCutPlanes = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); myCutPlanes->SameAs(thePrs); DrawTable(); diff --git a/src/VISUGUI/VisuGUI_FieldFilter.cxx b/src/VISUGUI/VisuGUI_FieldFilter.cxx index d1f22c81..88c3e3b5 100644 --- a/src/VISUGUI/VisuGUI_FieldFilter.cxx +++ b/src/VISUGUI/VisuGUI_FieldFilter.cxx @@ -39,8 +39,10 @@ using namespace VISU; -VisuGUI_FieldFilter::VisuGUI_FieldFilter( VISU::VISUType theType ) : - myType( theType ) +VisuGUI_FieldFilter::VisuGUI_FieldFilter( VISU::VISUType theType, + const QString& thePrs3dEntry ) : + myType( theType ), + myPrs3dEntry( thePrs3dEntry ) { } @@ -58,6 +60,9 @@ bool VisuGUI_FieldFilter::isOk( const SUIT_DataOwner* theDataOwner ) const if( anOwner && anAppStudy ) { + if(myPrs3dEntry == anOwner->entry()) + return true; + _PTR(Study) aStudy = anAppStudy->studyDS(); _PTR(SObject) aSObject = aStudy->FindObjectID( anOwner->entry() ); if (!aSObject) diff --git a/src/VISUGUI/VisuGUI_FieldFilter.h b/src/VISUGUI/VisuGUI_FieldFilter.h index b6816e4a..21e21aa6 100644 --- a/src/VISUGUI/VisuGUI_FieldFilter.h +++ b/src/VISUGUI/VisuGUI_FieldFilter.h @@ -33,13 +33,15 @@ class SUIT_DataOwner; class VisuGUI_FieldFilter : public SUIT_SelectionFilter { public: - VisuGUI_FieldFilter( VISU::VISUType theType ); + VisuGUI_FieldFilter( VISU::VISUType theType, + const QString& thePrs3dEntry ); ~VisuGUI_FieldFilter(); virtual bool isOk( const SUIT_DataOwner* ) const; private: VISU::VISUType myType; + QString myPrs3dEntry; }; #endif diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index f5002c76..db400a6d 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -85,9 +85,7 @@ VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* new QLabel( "Time Stamp : ", this ); myTimeStamps = new QComboBox( this ); - myFieldFilter = new VisuGUI_FieldFilter( theType ); - GetSelectionMgr( theModule )->installFilter( myFieldFilter ); - + myFieldFilter = 0; onSelectionChanged(); hide(); @@ -95,12 +93,10 @@ VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* VisuGUI_InputPane::~VisuGUI_InputPane() { - GetSelectionMgr( myModule )->removeFilter( myFieldFilter ); - if( myFieldFilter ) { + GetSelectionMgr( myModule )->removeFilter( myFieldFilter ); delete myFieldFilter; - myFieldFilter = 0; } } @@ -196,6 +192,9 @@ void VisuGUI_InputPane::onSelectionChanged() void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) { + myFieldFilter = new VisuGUI_FieldFilter( thePrs->GetType(), thePrs->GetHolderEntry() ); + GetSelectionMgr( myModule )->installFilter( myFieldFilter ); + clear(); CORBA::Long aTimeStampNumber = thePrs->GetTimeStampNumber(); diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index c073f752..0406c812 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -1050,8 +1050,14 @@ void VisuGUI_Module:: OnEditGaussPoints() { - Handle(SALOME_InteractiveObject) anIO; - if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) { + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this); + if(aSelectionInfo.empty()) + return; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; + + if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aSelectionItem.myObjectInfo.myBase)){ // Create VVTK_ViewWindow, if it does not exist if (VVTK_ViewWindow* aViewWindow = GetViewWindow(this)) { EditPrs3d(this, anIO, aPrs3d, aViewWindow); @@ -1812,25 +1818,6 @@ void VisuGUI_Module::storeVisualParameters(int savePoint) } } -// returns VISU_Actor with IO with given entry -VISU_Actor* getActor( const QString& entry, SVTK_ViewWindow* vtkView ) -{ - if ( vtkView && !entry.isEmpty() ) { - vtkActorCollection* allActors = vtkView->getRenderer()->GetActors(); - allActors->InitTraversal(); - while ( vtkActor* actor = allActors->GetNextActor() ) { - if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) { - if ( vActor->hasIO() ) { // actor corresponds to existing obj - Handle(SALOME_InteractiveObject) io = vActor->getIO(); - if ( entry == io->getEntry() ) - return vActor; - } - } - } - } - return 0; -} - const int ViewerType = 0; const int ViewIndex = 1; const int ParamName = 2; @@ -1935,7 +1922,7 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint) QMap viewActorMap; if ( vtkActors.contains( entry ) ) viewActorMap = vtkActors[ entry ]; - viewActorMap[ viewerTypeIndex ] = getActor( entry, vtkView ); + viewActorMap[ viewerTypeIndex ] = FindActor( GetAppStudy(this), vtkView, entry ); vtkActors[ entry ] = viewActorMap; } } diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index 7e535ac6..eb86611a 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -179,9 +179,11 @@ bool VisuGUI_OffsetDlg::isToSave() const void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointType* theOffset) { - if (myPrsList.count() == 0) return; + if (myPrsList.count() == 0) + return; - if (isToSave()) thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]); + if (isToSave()) + thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]); ViewManagerList aViewManagerList; SalomeApp_Application* anApp = myModule->getApp(); @@ -195,15 +197,11 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp if (SVTK_ViewWindow* vw = dynamic_cast(aViewWindow)) { vw->onAdjustTrihedron(); - if (VISU_Actor* anActor = VISU::GetActor(thePrs, vw)) { + if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) { anActor->SetPosition(theOffset); + vw->highlight(thePrs->GetIO(), 1); vw->getRenderer()->ResetCameraClippingRange(); vw->Repaint(); - - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = VISU::GetSelectedObj(myModule, &anIO); - if (!CORBA::is_nil(anObject)) - vw->highlight(anIO, 1); } } } diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index bceb5b00..3c4ae0e9 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -378,7 +378,7 @@ void VisuGUI_Plot3DPane::updatePreview() if (!planePreview) { myPreviewActor = planePreview = new TPlane(myPrs->GetInput()->GetLength()); myViewWindow->AddActor(planePreview); - fitall = !VISU::GetActor(myPrs, myViewWindow); + fitall = !VISU::FindActor(myViewWindow, myPrs); } // set plane parameters corresponding to control values storePrsParams(); diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 0708e576..2ce90f0c 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -77,17 +77,19 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const QString VisuGUI_Selection::type( const int ind ) const { QString aResStr; - VISU::Storable::TRestoringMap aMap; SalomeApp_Study* aStudy = GetStudy(); if ( !aStudy ) return aResStr; - CORBA::Object_var anObject = GetSelectedObj( aStudy, entry( ind ), &aMap ); - VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject ); - if ( !CORBA::is_nil( aVisuObj ) ){ - VISU::VISUType aType = aVisuObj->GetType(); + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject); + + VISU::Base_i* aBase = anObjectInfo.myBase; + if(aBase){ + VISU::VISUType aType = aBase->GetType(); if(aType == VISU::TCOLOREDPRS3DHOLDER){ - VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(aVisuObj); + CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject); + VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject); aType = aHolder->GetPrsType(); } switch (aType) { @@ -138,13 +140,15 @@ QString VisuGUI_Selection::type( const int ind ) const QString VisuGUI_Selection::nbComponents( const int ind ) const { QString aResStr; - VISU::Storable::TRestoringMap aMap; SalomeApp_Study* aStudy = GetStudy(); if ( !aStudy ) return aResStr; - GetSelectedObj( aStudy, entry( ind ), &aMap ); + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject); + bool isExist; - const QString& aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist); + QString aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist); if ( isExist ) aResStr = aVal; return aResStr; @@ -152,10 +156,15 @@ QString VisuGUI_Selection::nbComponents( const int ind ) const QString VisuGUI_Selection::medEntity( const int ind ) const { + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return QString(); + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject); + bool isExist; - VISU::Storable::TRestoringMap aMap; - GetSelectedObj( GetStudy(), entry( ind ), &aMap ); - const QString& aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist); + QString aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist); if ( isExist ) { using namespace VISU; TEntity anEntityId = TEntity(aVal.toInt()); @@ -203,11 +212,13 @@ QString VisuGUI_Selection::medSource( const int ind ) const QString VisuGUI_Selection::nbTimeStamps( const int ind ) const { QString aResStr; - VISU::Storable::TRestoringMap aMap; SalomeApp_Study* aStudy = GetStudy(); if ( !aStudy ) return aResStr; - GetSelectedObj( aStudy, entry( ind ), &aMap ); + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject); + bool isExist; const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist); if ( isExist ) @@ -215,26 +226,110 @@ QString VisuGUI_Selection::nbTimeStamps( const int ind ) const return aResStr; } -QString VisuGUI_Selection::representation( const int ind ) const -{ - QString aResStr; - if (SVTK_ViewWindow* aView = GetActiveViewWindow(myModule)) { - if (VISU_Actor* anVISUActor = FindActor(aView, entry(ind).latin1())) { - int aRepresent = anVISUActor->GetRepresentation(); - switch (aRepresent) { - ENUM2STRING( aResStr, VISU::POINT ); - ENUM2STRING( aResStr, VISU::WIREFRAME ); - ENUM2STRING( aResStr, VISU::SHADED ); - ENUM2STRING( aResStr, VISU::INSIDEFRAME ); - ENUM2STRING( aResStr, VISU::SURFACEFRAME ); - } +//---------------------------------------------------------------------------- +template +struct TPopupDispatcher +{ + QString + operator()(const SalomeApp_Module* theModule, + const QString& theEntry) + { + if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ + QString aType = aViewManager->getType(); + TPopupFunctor aFunctor; + if(aType == SVTK_Viewer::Type()) + return aFunctor.template Get(theModule, theEntry); + else if(aType == VVTK_Viewer::Type()) + return aFunctor.template Get(theModule, theEntry); } + return QString(); + } +}; + + +//---------------------------------------------------------------------------- +template +bool +GetPrs3dSelectionInfo(const SalomeApp_Module* theModule, + const QString& theEntry, + VISU::Prs3d_i*& thePrs3d, + SVTK_ViewWindow*& theViewWindow, + VISU_Actor*& thenActor) +{ + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), theEntry); + thePrs3d = GetPrs3dFromBase(anObjectInfo.myBase); + if(!thePrs3d) + return false; + + typedef typename TViewer::TViewWindow TViewWindow; + theViewWindow = GetActiveViewWindow(theModule); + if(!theViewWindow) + return false; + + thenActor = FindActor(theViewWindow, thePrs3d); + if(!thenActor) + return false; + + return true; +} + + +//---------------------------------------------------------------------------- +struct TViewFunctor +{ + template + QString + Get(const SalomeApp_Module* theModule, + const QString& theEntry) + { + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(!GetPrs3dSelectionInfo(theModule, theEntry, aPrs3d, aViewWindow, anActor)) + return QString(); + + return get(aPrs3d, aViewWindow, anActor); + } + + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return QString(); } +}; - return aResStr; + +//---------------------------------------------------------------------------- +struct TGetRepesentationFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + QString aResStr; + switch (theActor->GetRepresentation()) { + ENUM2STRING( aResStr, VISU::POINT ); + ENUM2STRING( aResStr, VISU::WIREFRAME ); + ENUM2STRING( aResStr, VISU::SHADED ); + ENUM2STRING( aResStr, VISU::INSIDEFRAME ); + ENUM2STRING( aResStr, VISU::SURFACEFRAME ); + } + return aResStr; + } +}; + +QString VisuGUI_Selection::representation( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); } +//---------------------------------------------------------------------------- SalomeApp_Study* VisuGUI_Selection::GetStudy() const { @@ -242,6 +337,7 @@ SalomeApp_Study* VisuGUI_Selection::GetStudy() const return dynamic_cast( aLightStudy ); } +//---------------------------------------------------------------------------- int VisuGUI_Selection::nbChild( const int ind, const bool named ) const { int cnt = 0; @@ -262,6 +358,7 @@ int VisuGUI_Selection::nbChild( const int ind, const bool named ) const return cnt; } +//---------------------------------------------------------------------------- QString VisuGUI_Selection::nbChildren( const int ind ) const { QString aResStr; @@ -269,6 +366,7 @@ QString VisuGUI_Selection::nbChildren( const int ind ) const return aResStr; } +//---------------------------------------------------------------------------- QString VisuGUI_Selection::nbNamedChildren( const int ind ) const { QString aResStr; @@ -276,92 +374,93 @@ QString VisuGUI_Selection::nbNamedChildren( const int ind ) const return aResStr; } -namespace -{ - struct TIsVisibleFunctor - { - template - QString - Get(VisuGUI* theModule, - const QString& theEntry) - { - typedef typename TViewer::TViewWindow TViewWindow; - if (TViewWindow* aViewWindow = GetActiveViewWindow(theModule)) - if (VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1())) - return anActor->GetVisibility() ? "true" : "false"; - - return QString(); - } - }; - template - struct TPopupDispatcher +//---------------------------------------------------------------------------- +struct TIsVisibleFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) { - QString - operator()(VisuGUI* theModule, - const QString& theEntry) - { - if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ - QString aType = aViewManager->getType(); - TPopupFunctor aFunctor; - if(aType == SVTK_Viewer::Type()) - return aFunctor.template Get(theModule,theEntry); - else if(aType == VVTK_Viewer::Type()) - return aFunctor.template Get(theModule,theEntry); - } - return QString(); - } - }; -} + return theActor->GetVisibility() ? "true" : "false"; + } +}; QString VisuGUI_Selection::isVisible( const int ind ) const { - return TPopupDispatcher()((VisuGUI*)myModule,entry(ind)); + return TPopupDispatcher()(myModule, entry(ind)); } -QString VisuGUI_Selection::isShrunk( const int ind ) const -{ - QString aResStr; - if ( SVTK_ViewWindow* aView = GetActiveViewWindow(myModule) ) - if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) - if ( anVISUActor->IsShrunkable() ) - aResStr = anVISUActor->IsShrunk() ? "1" : "0"; +//---------------------------------------------------------------------------- +struct TIsShrunkFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return theActor->IsShrunk() ? "1" : "0"; + } +}; - return aResStr; +QString VisuGUI_Selection::isShrunk( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); } + +//---------------------------------------------------------------------------- QString VisuGUI_Selection::hasActor( const int ind ) const { return representation( ind ).isEmpty() ? "0" : "1"; } + +//---------------------------------------------------------------------------- +struct TIsShadingFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)) + return anActor->IsShading() ? "1" : "0"; + return QString(); + } +}; + QString VisuGUI_Selection::isShading( const int ind ) const { - QString aResStr; - - if ( SVTK_ViewWindow* aView = GetActiveViewWindow(myModule) ) - if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) - if ( VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor) ) - aResStr = anActor->IsShading() ? "1" : "0"; - - return aResStr; + return TPopupDispatcher()(myModule, entry(ind)); } -QString VisuGUI_Selection::isScalarMapAct( const int ind ) const -{ - QString aResStr; - if ( SVTK_ViewWindow* aView = GetActiveViewWindow(myModule) ) - if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) - { - VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor); - aResStr = anActor ? "1" : "0"; - } +//---------------------------------------------------------------------------- +struct TIsScalarMapActFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return dynamic_cast(theActor)? "1" : "0"; + } +}; - return aResStr; +QString VisuGUI_Selection::isScalarMapAct( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); } + +//---------------------------------------------------------------------------- bool VisuGUI_Selection::isVisuComponent( const int ind ) const { SalomeApp_Study* study = GetStudy(); diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 140e0edd..3a5c5bdf 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -415,7 +415,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName); VISU_Actor* anVISUActor = - VISU::FindActor(aViewWindow, aSObject->GetID().c_str()); + VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str()); if (anVISUActor) { vtkFloatingPointType aCoord[6]; anVISUActor->GetBounds(aCoord); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 91d6fd39..876ab836 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -360,7 +360,7 @@ void ArrangeDlg::acceptViewWindow() for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it) { VISU::Prs3d_i* aPrs = it.key(); Offset& aOffs = myOffsets[it.data()]; - if (VISU_Actor* anActor = VISU::GetActor(aPrs, myViewWindow)) + if (VISU_Actor* anActor = VISU::FindActor(myViewWindow, aPrs)) anActor->SetPosition(aOffs.myOffset); if (mySaveChk) if (mySaveChk->isChecked()) @@ -375,7 +375,7 @@ void ArrangeDlg::acceptViewWindow() QMap::Iterator it; for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) { VISU::Prs3d_i* aPrs = it.key(); - if (VISU_Actor* aActor = VISU::GetActor(aPrs, myViewWindow)) { + if (VISU_Actor* aActor = VISU::FindActor(myViewWindow, aPrs)) { int aAxis = getAxis(); vtkFloatingPointType aZeroOffset[3]; diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 50ad7cfa..17e92c7b 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -39,6 +39,7 @@ #include "VISU_Table_i.hh" #include "VISU_Mesh_i.hh" #include "VISU_ViewManager_i.hh" +#include "VISU_ColoredPrs3dHolder_i.hh" #include "VISU_Actor.h" #include "VISU_ScalarMapAct.h" @@ -269,79 +270,117 @@ namespace VISU return aStr; } - //------------------------------------------------------------ - // Selection - CORBA::Object_var - GetSelectedObj(const SalomeApp_Study* theStudy, - const QString& theEntry, - VISU::Storable::TRestoringMap* theMap) - { - if (!theStudy || theEntry.isEmpty()) - return CORBA::Object::_nil(); - - _PTR(Study) aStudy = GetCStudy(theStudy); - _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry.latin1()); - if (aSObject) { - _PTR(GenericAttribute) anAttr; - if (theMap && aSObject->FindAttribute(anAttr,"AttributeComment")) { - _PTR(AttributeComment) aComment (anAttr); - std::string aValue = aComment->Value(); - QString aString (aValue.c_str()); - VISU::Storable::StrToMap(aString, *theMap); - } - return VISU::ClientSObjectToObject(aSObject); - } - return CORBA::Object::_nil(); - } - //------------------------------------------------------------ - CORBA::Object_var - GetSelectedObj(const SalomeApp_Module* theModule, - Handle(SALOME_InteractiveObject)* theIO, - VISU::Storable::TRestoringMap* theMap) + //---------------------------------------------------------------------------- + // Selection + TSelectionInfo + GetSelectedObjects(const SalomeApp_Module* theModule) { + TSelectionInfo aSelectionInfo; + const SalomeApp_Study* aStudy = GetAppStudy(theModule); LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); SALOME_ListIteratorOfListIO anIter(aListIO); if(anIter.More()){ Handle(SALOME_InteractiveObject) anIO = anIter.Value(); - if(theIO) - *theIO = anIO; - if(anIO->hasEntry()) - return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap ); + if(anIO->hasEntry()){ + TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry()); + TSelectionItem aSelectionItem; + aSelectionItem.myObjectInfo = anObjectInfo; + aSelectionItem.myIO = anIO; + aSelectionInfo.push_back(aSelectionItem); + } } - return CORBA::Object::_nil(); + return aSelectionInfo; } - //------------------------------------------------------------ + + //---------------------------------------------------------------------------- + TObjectInfo + GetObjectByEntry(const SalomeApp_Study* theStudy, + const std::string& theEntry) + { + TObjectInfo anObjectInfo; + if(!theStudy || theEntry == "") + return anObjectInfo; + + _PTR(Study) aStudy = GetCStudy(theStudy); + if(_PTR(SObject) aSObject = aStudy->FindObjectID(theEntry)){ + anObjectInfo.mySObject = aSObject; + CORBA::Object_var anObject = ClientSObjectToObject(aSObject); + if(VISU::Base_i* aBase = GetServantInterface(anObject)) + anObjectInfo.myBase = aBase; + } + + return anObjectInfo; + } + + + //---------------------------------------------------------------------------- VISU::Prs3d_i* - GetPrsToModify(const SalomeApp_Module* theModule, - Handle(SALOME_InteractiveObject)* theIO, - VISU::Storable::TRestoringMap* theMap) + GetPrs3dToModify(const SalomeApp_Module* theModule, + Base_i* theBase) { - if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule))) + if (CheckLock(GetCStudy(GetAppStudy(theModule)), GetDesktop(theModule))) return NULL; - return GetPrsToModify(GetSelectedObj(theModule, theIO)); + return GetPrs3dFromBase(theBase); } - //------------------------------------------------------------ + //---------------------------------------------------------------------------- VISU::Prs3d_i* - GetPrsToModify(CORBA::Object_var theObject) + GetPrs3dFromBase(Base_i* theBase) { - if(VISU::Base_i* aBase = GetServantInterface(theObject)){ - if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){ - VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(theObject); - VISU::ColoredPrs3d_var aColoredPrs3d = aHolder->GetDevice(); - aBase = dynamic_cast(GetServant(aColoredPrs3d).in()); - } - return dynamic_cast(aBase); + if(theBase && theBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){ + VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast(theBase); + return aHolder->GetPrs3dDevice(); } - return NULL; + return dynamic_cast(theBase); } - //------------------------------------------------------------ + //---------------------------------------------------------------------------- + Storable::TRestoringMap + GetStorableMap(_PTR(SObject) theSObject) + { + Storable::TRestoringMap aMap; + _PTR(GenericAttribute) anAttr; + if(theSObject->FindAttribute(anAttr,"AttributeComment")){ + _PTR(AttributeComment) aComment (anAttr); + std::string aValue = aComment->Value(); + VISU::Storable::StrToMap(aValue.c_str(), aMap); + } + return aMap; + } + + //---------------------------------------------------------------------------- + bool + GetPrs3dSelectionInfo(const SalomeApp_Module* theModule, + VISU::Prs3d_i*& thePrs3d, + SVTK_ViewWindow*& theViewWindow, + VISU_Actor*& thenActor) + { + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); + if(aSelectionInfo.empty()) + return false; + + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); + if(!thePrs3d) + return false; + + theViewWindow = GetActiveViewWindow(theModule); + if(!theViewWindow) + return false; + + thenActor = FindActor(theViewWindow, thePrs3d); + if(!thenActor) + return false; + + return true; + } + + //---------------------------------------------------------------------------- void Add(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO) @@ -491,16 +530,17 @@ namespace VISU { _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject); for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) { - _PTR(SObject) aChildSObject = aChildIter->Value(); - CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject); - ErasePrs(theModule, aChildObj, /*repaint_view_window = */false); + _PTR(SObject) aSObject = aChildIter->Value(); + TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aSObject->GetID()); + ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */false); } - CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject); - if (!CORBA::is_nil(anObj)) { - ErasePrs(theModule, anObj, /*repaint_view_window = */true); + TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), theSObject->GetID()); + if(anObjectInfo.myBase){ + ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */true); - VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj); + CORBA::Object_var anObject = ClientSObjectToObject(theSObject); + VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject); if (!CORBA::is_nil(aRemovableObject)) { aRemovableObject->RemoveFromStudy(); } @@ -535,28 +575,39 @@ namespace VISU ChangeRepresentation (const SalomeApp_Module* theModule, VISU::PresentationType theType) { - if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)){ - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(theModule)){ - if (VISU_Actor* anActor = GetActor(aPrs3d, aViewWindow)) { - switch (theType) { - case VISU::SHRINK: - if (anActor->IsShrunk()) - anActor->UnShrink(); - else - anActor->SetShrink(); - break; - default: - if (VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d)) { - aMesh->SetPresentationType(theType); - RecreateActor(theModule, aMesh); - } else { - anActor->SetRepresentation(theType); - } - } - aViewWindow->Repaint(); - } + TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule); + if(aSelectionInfo.empty()) + return; + + TSelectionItem aSelectionItem = aSelectionInfo.front(); + VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); + if(!aPrs3d) + return; + + SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule); + if(!aViewWindow) + return; + + VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d); + if(!anActor) + return; + + switch (theType) { + case VISU::SHRINK: + if (anActor->IsShrunk()) + anActor->UnShrink(); + else + anActor->SetShrink(); + break; + default: + if (VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d)) { + aMesh->SetPresentationType(theType); + RecreateActor(theModule, aMesh); + } else { + anActor->SetRepresentation(theType); } } + aViewWindow->Repaint(); } //------------------------------------------------------------ @@ -564,14 +615,26 @@ namespace VISU SetShading ( const SalomeApp_Module* theModule, bool theOn ) { - if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)){ - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(theModule)){ - if (VISU_Actor* anActor = GetActor(aPrs3d, aViewWindow)) { - if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor) ) - aScalarMapActor->SetShading( theOn ); - } - aViewWindow->Repaint(); - } + TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule); + if(aSelectionInfo.empty()) + return; + + TSelectionItem aSelectionItem = GetSelectedObjects(theModule).front(); + VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); + if(!aPrs3d) + return; + + SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule); + if(!aViewWindow) + return; + + VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d); + if(!anActor) + return; + + if(VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor)){ + aScalarMapActor->SetShading(theOn); + aViewWindow->Repaint(); } } @@ -583,10 +646,11 @@ namespace VISU Handle(SALOME_InteractiveObject)& theIO, ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode) { - CORBA::Object_var anObject = GetSelectedObj(theModule, &theIO); - if (!theIO.IsNull() && theIO->hasEntry()){ - _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule)); - theSObject = aStudy->FindObjectID(theIO->getEntry()); + TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule); + if(!aSelectionInfo.empty()){ + TSelectionItem aSelectionItem = aSelectionInfo.front(); + theIO = aSelectionItem.myIO; + theSObject = aSelectionItem.myObjectInfo.mySObject; QString aValue = getValue(theSObject,"myType"); if (aValue.toInt() == int(VISU::TTIMESTAMP)){ thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp; @@ -697,31 +761,13 @@ namespace VISU //------------------------------------------------------------ VISU_Actor* - FindActor(SVTK_ViewWindow* theViewWindow, - const char* theEntry) + FindActor(const SalomeApp_Study* theStudy, + SVTK_ViewWindow* theViewWindow, + const QString& theEntry) { - using namespace SVTK; - if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){ - if(vtkActorCollection* aCollection = aRenderer->GetActors()){ - if(VISU_Actor* anActor = Find(aCollection,TIsSameEntry(theEntry))){ - return anActor; - } - } - } - return NULL; - } - - //------------------------------------------------------------ - VISU_Actor* - FindActor(SVTK_ViewWindow* theViewWindow, - VISU::Prs3d_i* thePrs) - { - Handle(SALOME_InteractiveObject) anIO = thePrs->GetIO(); - if(anIO->hasEntry()){ - std::string anEntry = anIO->getEntry(); - return FindActor(theViewWindow, anEntry.c_str()); - } - return NULL; + TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry); + VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase); + return FindActor(theViewWindow, aPrs3d); } //------------------------------------------------------------ diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index d05afd28..469c19ce 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -54,8 +54,12 @@ class SalomeApp_Module; class SalomeApp_Study; class VisuGUI; +#include +#include + namespace VISU { + class Base_i; class Prs3d_i; class Result_i; class Table_i; @@ -64,6 +68,7 @@ namespace VISU typedef std::vector TViewWindows; + //---------------------------------------------------------------------------- SUIT_Desktop* GetDesktop(const CAM_Module* theModule); SalomeApp_Study* GetAppStudy(const CAM_Module* theModule); _PTR(Study) GetCStudy(const SalomeApp_Study* theStudy); @@ -72,12 +77,14 @@ namespace VISU bool CheckLock( _PTR(Study) theStudy, QWidget* theWidget ); + //---------------------------------------------------------------------------- int runAndWait( QDialog* dlg, const bool modal ); void UpdateObjBrowser(SalomeApp_Module* theModule, bool theIsUpdateDataModel = true, _PTR(SObject) theSObject = _PTR(SObject)()); + //---------------------------------------------------------------------------- VISU_Gen_i* GetVisuGen(const CAM_Module* theModule); SALOME_MED::MED_Gen_var GetMEDEngine(); @@ -87,20 +94,37 @@ namespace VISU // Selection LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule); - CORBA::Object_var GetSelectedObj(const SalomeApp_Study* theStudy, - const QString& theEntry, - VISU::Storable::TRestoringMap* theMap = NULL); + //---------------------------------------------------------------------------- + struct TObjectInfo + { + Base_i* myBase; + _PTR(SObject) mySObject; + TObjectInfo(): + myBase(NULL) + {} + }; + + struct TSelectionItem + { + TObjectInfo myObjectInfo; + Handle(SALOME_InteractiveObject) myIO; + }; + + typedef std::vector TSelectionInfo; - CORBA::Object_var GetSelectedObj(const SalomeApp_Module* theModule, - Handle(SALOME_InteractiveObject)* theIO = NULL, - VISU::Storable::TRestoringMap* theMap = NULL); + TSelectionInfo GetSelectedObjects(const SalomeApp_Module* theModule); - VISU::Prs3d_i* GetPrsToModify(CORBA::Object_var theObject); + TObjectInfo GetObjectByEntry(const SalomeApp_Study* theStudy, + const std::string& theEntry); + + VISU::Prs3d_i* GetPrs3dToModify(const SalomeApp_Module* theModule, + Base_i* theBase); - VISU::Prs3d_i* GetPrsToModify(const SalomeApp_Module* theModule, - Handle(SALOME_InteractiveObject)* theIO = NULL, - VISU::Storable::TRestoringMap* theMap = NULL); + VISU::Prs3d_i* GetPrs3dFromBase(Base_i* theBase); + + Storable::TRestoringMap GetStorableMap(_PTR(SObject) theSObject); + //---------------------------------------------------------------------------- void Add(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO); void Remove(LightApp_SelectionMgr* theSelectionMgr, @@ -146,8 +170,9 @@ namespace VISU void RepaintViewWindows(const SalomeApp_Module* theModule, const Handle(SALOME_InteractiveObject)& theIObject); - VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow, - const char* theEntry); + VISU_Actor* FindActor(const SalomeApp_Study* theStudy, + SVTK_ViewWindow* theViewWindow, + const QString& theEntry); VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs); void RecreateActor(const SalomeApp_Module* theModule, diff --git a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx index e8114766..af6de916 100644 --- a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx +++ b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx @@ -69,6 +69,7 @@ VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule, WFlags fl) : QDialog( VISU::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), + myModule(theModule), mySelectionMgr( VISU::GetSelectionMgr( theModule ) ), myViewWindow( VISU::GetActiveViewWindow(theModule) ) { @@ -210,7 +211,7 @@ void VisuGUI_TransparencyDlg::SetTransparency() SALOME_ListIteratorOfListIO anIter(aList); for (; anIter.More(); anIter.Next()) { Handle(SALOME_InteractiveObject) anIO = anIter.Value(); - VISU_Actor* anActor = VISU::FindActor(myViewWindow, anIO->getEntry()); + VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry()); if (anActor) anActor->SetOpacity(opacity); } @@ -243,7 +244,7 @@ void VisuGUI_TransparencyDlg::onSelectionChanged() if (aList.Extent() == 1) { Handle(SALOME_InteractiveObject) FirstIOS = aList.First(); if (!FirstIOS.IsNull()) { - VISU_Actor* anActor = VISU::FindActor(myViewWindow, FirstIOS->getEntry()); + VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, FirstIOS->getEntry()); if (anActor) opacity = int(anActor->GetOpacity() * 100. + 0.5); } @@ -253,7 +254,7 @@ void VisuGUI_TransparencyDlg::onSelectionChanged() for (; It.More(); It.Next()) { Handle(SALOME_InteractiveObject) IO = It.Value(); if (!IO.IsNull()) { - VISU_Actor* anActor = VISU::FindActor(myViewWindow, IO->getEntry()); + VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry()); if (anActor) { int op = int(anActor->GetOpacity() * 100. + 0.5); if (setOp < 0) diff --git a/src/VISUGUI/VisuGUI_TransparencyDlg.h b/src/VISUGUI/VisuGUI_TransparencyDlg.h index 2809a460..2bf3ddbb 100644 --- a/src/VISUGUI/VisuGUI_TransparencyDlg.h +++ b/src/VISUGUI/VisuGUI_TransparencyDlg.h @@ -36,6 +36,7 @@ class QLabel; class QPushButton; class QSlider; class LightApp_SelectionMgr; +class SalomeApp_Module; class SVTK_Selector; class SVTK_ViewWindow; class VisuGUI; @@ -62,6 +63,7 @@ private: private : LightApp_SelectionMgr* mySelectionMgr; SVTK_ViewWindow* myViewWindow; + const SalomeApp_Module* myModule; QPushButton* buttonOk; QPushButton* buttonHelp; diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 966636b4..4422d585 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -37,56 +37,51 @@ namespace VISU { //---------------------------------------------------------------------------- void - ErasePrs3dObject(VisuGUI* theModule, - VISU::Prs3d_ptr thePrs3d, - bool theDoRepaint) + ErasePrs3d(VisuGUI* theModule, + VISU::Prs3d_i* thePrs, + 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); + if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)){ + if(VISU_Actor* anActor = FindActor(aViewWindow, thePrs)){ + anActor->VisibilityOff(); + if(theDoRepaint) + aViewWindow->Repaint(); + } } } //---------------------------------------------------------------------------- void ErasePrs(VisuGUI* theModule, - CORBA::Object_ptr theObject, + Base_i* theBase, bool theDoRepaint) { - if (CORBA::is_nil(theObject)) + if(!theBase) return; - VISU::Base_var aBase = VISU::Base::_narrow(theObject); - if (CORBA::is_nil(aBase)) - return; - - VISU::VISUType aType = aBase->GetType(); - switch (aType) { + switch (theBase->GetType()) { case VISU::TCURVE: { - if (VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aBase).in())) + if (VISU::Curve_i* aCurve = dynamic_cast(theBase)) PlotCurve(theModule, aCurve, VISU::eErase ); break; } case VISU::TCONTAINER: { - if (VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aBase).in())) + if (VISU::Container_i* aContainer = dynamic_cast(theBase)) PlotContainer(theModule, aContainer, VISU::eErase ); break; } case VISU::TTABLE: { - if (VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aBase).in())) + if (VISU::Table_i* aTable = dynamic_cast(theBase)) 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: { - VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aBase); - ErasePrs3dObject(theModule, aPrs3d, theDoRepaint); + if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(theBase)){ + if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)){ + RemoveScalarBarPosition(theModule, aViewWindow, aPrs3d); + ErasePrs3d(theModule, aPrs3d, theDoRepaint); + } + } }} // switch (aType) } diff --git a/src/VISUGUI/VisuGUI_ViewTools.h b/src/VISUGUI/VisuGUI_ViewTools.h index 1e7c3d0e..9c7ae899 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.h +++ b/src/VISUGUI/VisuGUI_ViewTools.h @@ -243,24 +243,14 @@ namespace VISU //--------------------------------------------------------------- - inline void ErasePrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs, - const bool theDoRepaintVW = true) - { - if (SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)) { - if (VISU_Actor* anActor = FindActor(aViewWindow, thePrs)) { - anActor->VisibilityOff(); - if (theDoRepaintVW) - aViewWindow->Repaint(); - } - } - } + bool theDoRepaint = true); void ErasePrs(VisuGUI* theModule, - CORBA::Object_ptr theObject, + Base_i* theBase, bool theDoRepaintVW); } diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 43acacb4..47d7f477 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -29,19 +29,19 @@ #include "VISU_ColoredPrs3dHolder_i.hh" #include "VISU_ColoredPrs3dFactory.hh" -#include "VISU_Convertor.hxx" -#include "VISU_PipeLine.hxx" - -#include "VVTK_ViewWindow.h" -#include "SUIT_ResourceMgr.h" - -#include "VISU_Actor.h" +#include "VISU_ViewManager_i.hh" #include "VISU_View_i.hh" +#include "VISU_Actor.h" #include "VTKViewer_Algorithm.h" #include "SVTK_Functor.h" -#include +//#include "VISU_Convertor.hxx" +//#include "VISU_PipeLine.hxx" + +#include "VVTK_ViewWindow.h" +#include "SUIT_ResourceMgr.h" + #include #ifdef _DEBUG_ @@ -333,26 +333,6 @@ VISU::ColoredPrs3dCache_i } -//---------------------------------------------------------------------------- -namespace VISU -{ - struct TIsSamePrs3d - { - VISU::Prs3d_i* myPrs3d; - - TIsSamePrs3d(VISU::Prs3d_i* thePrs3d): - myPrs3d(thePrs3d) - {} - - bool - operator()(VISU_Actor* theActor) - { - return theActor->GetPrs3d() == myPrs3d; - } - }; -} - - //---------------------------------------------------------------------------- bool VISU::ColoredPrs3dCache_i @@ -393,30 +373,28 @@ VISU::ColoredPrs3dCache_i if(SUIT_ViewWindow* aView = aView3d->GetViewWindow()){ if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aView)){ // Find actor that corresponds to the holder - vtkRenderer* aRenderer = aViewWindow->getRenderer(); - vtkActorCollection* anActors = aRenderer->GetActors(); - VISU_Actor* anActor = - SVTK::Find(anActors, - VISU::TIsSamePrs3d(aLastVisitedPrs3d.GetPointer())); + VISU_Actor* anActor = VISU::FindActor(aViewWindow, aLastVisitedPrs3d); + // If the holder was erased from view then do nothing if(!anActor || !anActor->GetVisibility()) return true; if(aPrs3d != aLastVisitedPrs3d){ // To erase all actors that corresponds to the holder + vtkRenderer* aRenderer = aViewWindow->getRenderer(); + vtkActorCollection* anActors = aRenderer->GetActors(); Handle(SALOME_InteractiveObject) anIO = aPrs3d->GetIO(); SVTK::ForEachIf(anActors, SVTK::TIsSameIObject(anIO), SVTK::TSetVisibility(false)); // To find the new one that corresponds to fresh presentation - VISU_Actor* aNewActor = - SVTK::Find(anActors, - VISU::TIsSamePrs3d(aPrs3d)); + VISU_Actor* aNewActor = VISU::FindActor(aViewWindow, aPrs3d); if(!aNewActor){ aNewActor = aPrs3d->CreateActor(); aViewWindow->AddActor(aNewActor); }else aNewActor->SetVisibility(true); + //anActor->RemoveFromRender(); aNewActor->DeepCopy(anActor); } aViewWindow->Repaint(); diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.hh b/src/VISU_I/VISU_ColoredPrs3dFactory.hh index 2f0766e6..1dfda5aa 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.hh +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.hh @@ -278,6 +278,28 @@ namespace VISU return dynamic_cast(aColoredPrs3d); } + + //---------------------------------------------------------------------------- + template + struct TSameAsFactory + { + typedef typename TL::TColoredEnum2Type::TResult TColoredPrs3d; + + TColoredPrs3d* + Create(ColoredPrs3d_i* theColoredPrs3d, + ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode) + { + TColoredPrs3d* aSameColoredPrs3d = new TColoredPrs3d(thePublishInStudyMode); + aSameColoredPrs3d->SetCResult(theColoredPrs3d->GetCResult()); + aSameColoredPrs3d->SetMeshName(theColoredPrs3d->GetCMeshName().c_str()); + aSameColoredPrs3d->SetEntity(theColoredPrs3d->GetEntity()); + aSameColoredPrs3d->SetFieldName(theColoredPrs3d->GetCFieldName().c_str()); + aSameColoredPrs3d->SetTimeStampNumber(theColoredPrs3d->GetTimeStampNumber()); + aSameColoredPrs3d->SameAs(theColoredPrs3d); + return aSameColoredPrs3d; + } + }; + //---------------------------------------------------------------------------- //! Check is possible to create ColoredPrs3dHolder with the given input size_t diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 6dc381dd..c9d6c83e 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -123,11 +123,27 @@ VISU::ColoredPrs3d_i } +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::OnRestoreInput() +{ + TSuperClass::OnRestoreInput(); + myEntity = myPreviousEntity; + myFieldName = myPreviousFieldName; + myTimeStampNumber = myPreviousTimeStampNumber; +} + + //--------------------------------------------------------------- bool VISU::ColoredPrs3d_i ::OnSetInput() { + myPreviousEntity = myEntity; + myPreviousFieldName = myFieldName; + myPreviousTimeStampNumber = myTimeStampNumber; + bool anIsCreatNew = !IsPipeLineExists(); if(anIsCreatNew) CreatePipeLine(NULL); // to create proper pipeline @@ -379,6 +395,15 @@ VISU::ColoredPrs3d_i } +//---------------------------------------------------------------------------- +std::string +VISU::ColoredPrs3d_i +::GetHolderEntry() +{ + return myHolderEntry; +} + + //---------------------------------------------------------------------------- CORBA::Boolean VISU::ColoredPrs3d_i @@ -387,6 +412,14 @@ VISU::ColoredPrs3d_i return myIsTimeStampFixed; } +//---------------------------------------------------------------------------- +VISU::ColoredPrs3d_i::EPublishInStudyMode +VISU::ColoredPrs3d_i +::GetPublishInStudyMode() +{ + return myPublishInStudyMode; +} + //--------------------------------------------------------------- void VISU::ColoredPrs3d_i diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 5fb85781..885429bf 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -120,6 +120,10 @@ namespace VISU CORBA::Boolean IsTimeStampFixed(); + virtual + EPublishInStudyMode + GetPublishInStudyMode(); + //---------------------------------------------------------------------------- virtual CORBA::Long @@ -231,6 +235,10 @@ namespace VISU void SetHolderEntry(const std::string& theEntry); + virtual + std::string + GetHolderEntry(); + //---------------------------------------------------------------------------- public: /*! @@ -368,6 +376,11 @@ namespace VISU bool SetInput(); + //! Restore input parameters if Apply function fails (redefines Prs3d::OnRestoreInput) + virtual + void + OnRestoreInput(); + /*! Checks whether it is possible to create presentation with the given basic parameters or not. @@ -423,9 +436,15 @@ namespace VISU private: // Decalare basic input parameters - Entity myEntity; + VISU::Entity myEntity; + VISU::Entity myPreviousEntity; + std::string myFieldName; + std::string myPreviousFieldName; + CORBA::Long myTimeStampNumber; + CORBA::Long myPreviousTimeStampNumber; + bool myIsTimeStampFixed; PField myField; diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index f972fe8e..1c84445e 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -111,10 +111,30 @@ bool VISU::Prs3d_i ::SetInput() { + if(!myResult) + return false; + + myPreviousResult = myResult; + + if(myMeshName == "") + return false; + + myPreviousMeshName = myMeshName; + return true; } +//---------------------------------------------------------------------------- +void +VISU::Prs3d_i +::OnRestoreInput() +{ + myResult = myPreviousResult; + myMeshName = myPreviousMeshName; +} + + //---------------------------------------------------------------------------- CORBA::Boolean VISU::Prs3d_i @@ -130,6 +150,7 @@ VISU::Prs3d_i }catch(...){ INFOS("Unknown exception was occured!"); } + OnRestoreInput(); return false; } diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index ae38e76c..07cdbd8a 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -224,18 +224,22 @@ namespace VISU void GetBounds(vtkFloatingPointType aBounds[6]); + //! Move the 3D presentation according to the given offset parameters void SetOffset(const CORBA::Float* theOffsets); + //! Move the 3D presentation according to the given offset parameters virtual void SetOffset(CORBA::Float theDx, CORBA::Float theDy, CORBA::Float theDz); + //! Gets offset parameters for the 3D presentation void GetOffset(CORBA::Float* theOffsets); + //! Gets offset parameters for the 3D presentation virtual void GetOffset(CORBA::Float& theDx, @@ -261,16 +265,29 @@ namespace VISU GetIO(); protected: + /*! + Used in Apply method to get know whether it is possible to create presentation + with the input parameters or not. The derived classes can use this method + to customize Apply behaviour. + */ virtual bool SetInput(); + //! Restore input parameters if Apply function fails + virtual + void + OnRestoreInput(); + + //! Used in derived classes to initilize the myPipeLine member void SetPipeLine(VISU_PipeLine* thePipeLine); + //! Used in derived classes to initilize the myPipeLine member void CreateActor(VISU_Actor* theActor); + //! Gets or creates VISU_PipeLine instance for actor initilization virtual VISU_PipeLine* GetPL(); @@ -280,9 +297,11 @@ namespace VISU void CheckDataSet(); + //! Used in derived classes to initilize the mySObject member void SetSObject(SALOMEDS::SObject_var theSObject); + //! Used in derived classes to initilize the myIO member void SetIO(const Handle(SALOME_InteractiveObject)& theIO); @@ -292,7 +311,10 @@ namespace VISU private: Result_i *myResult; + Result_i *myPreviousResult; + std::string myMeshName; + std::string myPreviousMeshName; CORBA::Float myOffset[3]; diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index b0fe1cee..439bb3a4 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -51,6 +51,9 @@ #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" +#include "VTKViewer_Algorithm.h" +#include "SVTK_Functor.h" + #include #include #include @@ -446,17 +449,38 @@ 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 TDeleteActorsEvent: public SALOME_Event { VISU::Curve_i* myPrs; diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 2fc22558..2d489972 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -73,7 +73,7 @@ namespace VISU { VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs = NULL); void UpdatePlot2d (Plot2d_ViewFrame *theView, int theDisplaying, Curve_i* theCurve); - VISU_Actor* GetActor (VISU::Prs3d_i* thePrs, SVTK_ViewWindow* theViewWindow); + VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d); void DeleteActors (VISU::Prs3d_i* thePrs); void DeleteActors (VISU::Curve_i* thePrs); diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index ef63c4c9..7b03bad4 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -2195,7 +2195,7 @@ namespace VISU { if (!aPrs) { myError = "Corrupted presentation"; } else { - VISU_Actor* anActor = VISU::GetActor(aPrs, vw); + VISU_Actor* anActor = VISU::FindActor(vw, aPrs); if (!anActor) { myError = "No actor found. Display the presentation at first."; } else { -- 2.39.2