From 835d25d8fbd0a23baffa83daf2c8d1ba6f80e45d Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 9 Nov 2006 11:59:37 +0000 Subject: [PATCH] Selection is improved --- src/VISUGUI/VisuGUI.cxx | 2 +- src/VISUGUI/VisuGUI_Prs3dTools.h | 45 +++++++++++--------------------- src/VISUGUI/VisuGUI_Tools.cxx | 31 +++++++++++++++++----- src/VISUGUI/VisuGUI_Tools.h | 7 ++--- src/VISU_I/VISU_Prs3d_i.cc | 11 +++++++- src/VISU_I/VISU_Prs3d_i.hh | 8 ++++++ 6 files changed, 62 insertions(+), 42 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 8d67b681..b64fd5fb 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3318,7 +3318,7 @@ void VisuGUI::OnPlot3dFromCutPlane() aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos); if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) { - DeletePrs3d(this, aPrs3d, anIO); + DeletePrs3d(this, aPrs3d); delete aDlg; return; } diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 2738c158..4de65344 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -39,17 +39,6 @@ namespace VISU class ColoredPrs3d_i; class CutLines_i; - //--------------------------------------------------------------- - inline - void - RestoreSelection(VisuGUI* theModule) - { - SALOME_ListIO aList; - theModule->selectedObjects(aList); - LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); - aSelectionMgr->setSelectedObjects(aList); - } - //--------------------------------------------------------------- inline int @@ -103,10 +92,8 @@ namespace VISU aDlg, false ); // in edition mode QApplication::restoreOverrideCursor(); - - RestoreSelection(theModule); - } + RestoreSelection(theModule, thePrs3d); delete aDlg; } } @@ -161,10 +148,9 @@ namespace VISU //--------------------------------------------------------------- template inline - bool + TPrs3d_i* CreateAndEditPrs3d(VisuGUI* theModule, _PTR(SObject) theTimeStamp, - const Handle(SALOME_InteractiveObject)& theIO, ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode) { Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp); @@ -172,7 +158,7 @@ namespace VISU bool isExist; QString aType = Storable::FindValue(aMap,"myType",&isExist); if (!isExist || aType.toInt() != TTIMESTAMP ) - return false; + return NULL; QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); @@ -217,10 +203,10 @@ namespace VISU QApplication::restoreOverrideCursor(); delete aDlg; } else { - DeletePrs3d(theModule,aPrs3d,theIO); + DeletePrs3d(theModule,aPrs3d); QApplication::restoreOverrideCursor(); delete aDlg; - return false; + return NULL; } } } @@ -233,10 +219,10 @@ namespace VISU AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos); } - return true; + return aPrs3d; } - return false; + return NULL; } @@ -246,7 +232,6 @@ namespace VISU void CreatePrs3dInViewer(VisuGUI* theModule, _PTR(SObject) theTimeStampSObj, - const Handle(SALOME_InteractiveObject)& theIO, ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode) { // Create new TViewWindow instance, if it does not exist. @@ -254,10 +239,10 @@ namespace VISU if (!GetViewWindow(theModule)) return; - if (!CreateAndEditPrs3d(theModule,theTimeStampSObj,theIO,thePublishInStudyMode)) - return; + TPrs3d_i* aPrs3d = CreateAndEditPrs3d + (theModule,theTimeStampSObj,thePublishInStudyMode); - RestoreSelection(theModule); + RestoreSelection(theModule, aPrs3d); theModule->application()->putInfo(QObject::tr("INF_DONE")); } @@ -279,25 +264,25 @@ namespace VISU if(aPublishInStudyMode == VISU::ColoredPrs3d_i::EPublishIndependently){ CreatePrs3dInViewer - (theModule,aTimeStampSObj,anIO,aPublishInStudyMode); + (theModule,aTimeStampSObj,aPublishInStudyMode); return; }else{ if(theDesiredViewerType.isNull()){ if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()) if (aViewManager->getType() == VVTK_Viewer::Type()){ CreatePrs3dInViewer - (theModule,aTimeStampSObj,anIO,aPublishInStudyMode); + (theModule,aTimeStampSObj,aPublishInStudyMode); return; } CreatePrs3dInViewer - (theModule,aTimeStampSObj,anIO,aPublishInStudyMode); + (theModule,aTimeStampSObj,aPublishInStudyMode); }else{ if(theDesiredViewerType == VVTK_Viewer::Type()) CreatePrs3dInViewer - (theModule,aTimeStampSObj,anIO,aPublishInStudyMode); + (theModule,aTimeStampSObj,aPublishInStudyMode); else CreatePrs3dInViewer - (theModule,aTimeStampSObj,anIO,aPublishInStudyMode); + (theModule,aTimeStampSObj,aPublishInStudyMode); } } } diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 212654c1..1b307d20 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -333,6 +333,25 @@ namespace VISU theSelectionMgr->setSelectedObjects(aNewListIO); } + /*! + * Restores selection after presentation creating and editing + */ + void + RestoreSelection(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d) + { + SALOME_ListIO aList; + theModule->selectedObjects(aList); + + if( thePrs3d ) + { + Handle(SALOME_InteractiveObject) anIO = thePrs3d->GetIO(); + aList.Append(anIO); + } + + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); + aSelectionMgr->setSelectedObjects(aList); + } + /*! * \brief Check, if "Delete" popup-menu can be put on current selection * @@ -459,8 +478,7 @@ namespace VISU void DeletePrs3d(VisuGUI* theModule, - VISU::Prs3d_i* thePrs, - const Handle(SALOME_InteractiveObject)& theIO) + VISU::Prs3d_i* thePrs) { if (!thePrs) return; @@ -549,14 +567,13 @@ namespace VISU bool CheckTimeStamp(const SalomeApp_Module* theModule, _PTR(SObject)& theSObject, - const Handle(SALOME_InteractiveObject)& theIO, + Handle(SALOME_InteractiveObject)& theIO, ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode) { - Handle(SALOME_InteractiveObject) anIO = theIO; - CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO); - if (!anIO.IsNull() && anIO->hasEntry()){ + CORBA::Object_var anObject = GetSelectedObj(theModule, &theIO); + if (!theIO.IsNull() && theIO->hasEntry()){ _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule)); - theSObject = aStudy->FindObjectID(anIO->getEntry()); + theSObject = aStudy->FindObjectID(theIO->getEntry()); QString aValue = getValue(theSObject,"myType"); if (aValue.toInt() == int(VISU::TTIMESTAMP)){ thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp; diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index fc53c2c2..c68ffffc 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -98,14 +98,15 @@ namespace VISU void Remove(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO); + void RestoreSelection(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d); + bool IsRemovableSelected(const SalomeApp_Module* theModule); void DeleteSObject(VisuGUI* theModule, _PTR(Study) theStudy, _PTR(SObject) theSObject); void DeletePrs3d(VisuGUI* theModule, - VISU::Prs3d_i* thePrs, - const Handle(SALOME_InteractiveObject)& theIO); + VISU::Prs3d_i* thePrs); // Presentation management void ChangeRepresentation (const SalomeApp_Module* theModule, @@ -116,7 +117,7 @@ namespace VISU // SObject type bool CheckTimeStamp(const SalomeApp_Module* theModule, _PTR(SObject)& theSObject, - const Handle(SALOME_InteractiveObject)& theIO, + Handle(SALOME_InteractiveObject)& theIO, ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode); VISU::Result_i* CheckResult(const SalomeApp_Module* theModule, _PTR(SObject) theSource, diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 75a0b42f..1f13d04f 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -372,6 +372,15 @@ GetInput() return GetPipeLine()->GetInput(); } +Handle(SALOME_InteractiveObject) +VISU::Prs3d_i:: +GetIO() +{ + if( myIO.IsNull() ) + myIO = new SALOME_InteractiveObject(GetEntry(),"VISU",GetName()); + + return myIO; +} //---------------------------------------------------------------------------- void @@ -382,7 +391,7 @@ VISU::Prs3d_i try{ Handle(SALOME_InteractiveObject) anIO = theIO; if(anIO.IsNull() && (!mySObject->_is_nil())){ - anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName()); + anIO = GetIO(); theActor->setIO(anIO); } diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 1852c1c7..28fac173 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -242,6 +242,12 @@ namespace VISU unsigned long int GetMTime(); + //---------------------------------------------------------------------------- + //! Create and return the interactive object + virtual + Handle(SALOME_InteractiveObject) + GetIO(); + protected: virtual bool @@ -283,6 +289,8 @@ namespace VISU vtkSmartPointer myActorCollection; VISU_PipeLine *myPipeLine; + + Handle(SALOME_InteractiveObject) myIO; }; //---------------------------------------------------------------------------- -- 2.39.2