From 96e22851c7d22f9f095d68ac56fa765d36268d39 Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 25 Aug 2005 11:15:15 +0000 Subject: [PATCH] To provide a way to introduce new type of presentation --- src/VISUGUI/VisuGUI.cxx | 193 +++++++++++++++++++++++------ src/VISUGUI/VisuGUI.h | 9 +- src/VISUGUI/VisuGUI_ActionsDef.h | 9 ++ src/VISUGUI/VisuGUI_PopupTools.cxx | 48 ++----- src/VISUGUI/VisuGUI_Tools.cxx | 21 +++- src/VISUGUI/VisuGUI_Tools.h | 3 + 6 files changed, 200 insertions(+), 83 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6e66cf12..0596d493 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -680,57 +680,119 @@ OnErasePrs() QApplication::restoreOverrideCursor(); } + void VisuGUI:: -OnEditPrs() +OnEditScalarMap() { - if (CheckLock(GetCStudy(GetAppStudy(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; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ + EditPrs3d(this, aPrs3d); + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} - VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); - if (!aPrs3d) return; - switch (aPrs3d->GetType()) { - case VISU::TMESH: - break; - case VISU::TSCALARMAP: - EditPrs3d(this, aPrs3d); - break; - case VISU::TDEFORMEDSHAPE: +void +VisuGUI:: +OnEditDeformedShape() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - break; - case VISU::TCUTPLANES: + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} + + +void +VisuGUI:: +OnEditCutPlanes() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - break; - case VISU::TCUTLINES: + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} + + +void +VisuGUI:: +OnEditCutLines() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - break; - case VISU::TISOSURFACE: + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} + + +void +VisuGUI:: +OnEditIsoSurfaces() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - break; - case VISU::TVECTORS: + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} + + +void +VisuGUI:: +OnEditVectors() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - break; - case VISU::TSTREAMLINES: + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } +} + + +void +VisuGUI:: +OnEditStreamLines() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ EditPrs3d(this, aPrs3d); - break; - case VISU::TPLOT3D: - EditPrs3d(this, aPrs3d); - break; - default: - return; + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } } +} - if (SVTK_ViewWindow* vw = GetViewWindow()) - vw->highlight(anIO, 1); + +void +VisuGUI:: +OnEditPlot3D() +{ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ + EditPrs3d(this, aPrs3d); + if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ + aViewWindow->highlight(anIO, 1); + } + } } + void VisuGUI:: OnEraseAll() @@ -2083,9 +2145,39 @@ createActions() tr("MEN_LINE_WIDTH"), "", 0, aParent, false, this, SLOT(OnChangeLines())); - createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(), + + createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditScalarMap())); + + createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(), tr("MEN_EDIT_PRS"), "", 0, aParent, false, - this, SLOT(OnEditPrs())); + this, SLOT(OnEditDeformedShape())); + + createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditCutPlanes())); + + createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditCutLines())); + + createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditIsoSurfaces())); + + createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditVectors())); + + createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditStreamLines())); + + createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditPlot3D())); + createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(), tr("MEN_CREATE_TABLE"), "", 0, aParent, false, @@ -2234,7 +2326,14 @@ createPopupMenus() mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table // edit - mgr->insert( action( VISU_EDIT_PRS ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 ); // rename @@ -2414,8 +2513,22 @@ createPopupMenus() mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true ); mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true ); - aRule = "selcount=1 and $type in {" + aPrsAll + "}"; - mgr->setRule( action( VISU_EDIT_PRS ), aRule, true ); + mgr->setRule( action( VISU_EDIT_SCALARMAP ), + "selcount=1 and type='VISU::TSCALARMAP'", true ); + mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ), + "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true ); + mgr->setRule( action( VISU_EDIT_CUTPLANES ), + "selcount=1 and type='VISU::TCUTPLANES'", true ); + mgr->setRule( action( VISU_EDIT_CUTLINES ), + "selcount=1 and type='VISU::TCUTLINES'", true ); + mgr->setRule( action( VISU_EDIT_ISOSURFACE ), + "selcount=1 and type='VISU::TISOSURFACE'", true ); + mgr->setRule( action( VISU_EDIT_VECTORS ), + "selcount=1 and type='VISU::TVECTORS'", true ); + mgr->setRule( action( VISU_EDIT_STREAMLINES ), + "selcount=1 and type='VISU::TSTREAMLINES'", true ); + mgr->setRule( action( VISU_EDIT_PLOT3D ), + "selcount=1 and type='VISU::TPLOT3D'", true ); aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0"; mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 3735c340..adef1995 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -76,7 +76,14 @@ protected slots: void OnCreateManyMesh(); void OnCreatePlot2dView(); - void OnEditPrs(); + void OnEditScalarMap(); + void OnEditDeformedShape(); + void OnEditCutPlanes(); + void OnEditCutLines(); + void OnEditIsoSurfaces(); + void OnEditVectors(); + void OnEditStreamLines(); + void OnEditPlot3D(); void OnDisplayPrs(); void OnDisplayOnlyPrs(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index c78ac716..0a795733 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -61,6 +61,15 @@ #define VISU_OPACITY 4060 #define VISU_LINE_WIDTH 4061 +#define VISU_EDIT_SCALARMAP 40620 +#define VISU_EDIT_DEFORMEDSHAPE 40621 +#define VISU_EDIT_CUTPLANES 40622 +#define VISU_EDIT_CUTLINES 40623 +#define VISU_EDIT_ISOSURFACE 40624 +#define VISU_EDIT_VECTORS 40625 +#define VISU_EDIT_STREAMLINES 40626 +#define VISU_EDIT_PLOT3D 40627 + #define VISU_EDIT_PRS 4062 #define VISU_CREATE_TABLE 4063 #define VISU_SWEEP 4064 diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index a4143f84..837ba8af 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -62,48 +62,14 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const QString VisuGUI_Selection::type( const int ind ) const { - QString aTypeStr; + QString aResStr; VISU::Storable::TRestoringMap aMap; - CORBA::Object_var anObject = GetSelectedObj( study(), entry( ind ), &aMap ); - - VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject ); - - if ( !CORBA::is_nil( aVisuObj ) ){ - VISU::VISUType aType = aVisuObj->GetType(); - switch (aType) { - ENUM2STRING( aTypeStr, VISU::TVISUGEN ) - ENUM2STRING( aTypeStr, VISU::TRESULT ) - ENUM2STRING( aTypeStr, VISU::TTABLE ) - ENUM2STRING( aTypeStr, VISU::TCURVE ) - ENUM2STRING( aTypeStr, VISU::TCONTAINER ) - ENUM2STRING( aTypeStr, VISU::TMESH ) - ENUM2STRING( aTypeStr, VISU::TSCALARMAP ) - ENUM2STRING( aTypeStr, VISU::TISOSURFACE ) - ENUM2STRING( aTypeStr, VISU::TDEFORMEDSHAPE ) - ENUM2STRING( aTypeStr, VISU::TCUTPLANES ) - ENUM2STRING( aTypeStr, VISU::TCUTLINES ) - ENUM2STRING( aTypeStr, VISU::TVECTORS ) - ENUM2STRING( aTypeStr, VISU::TSTREAMLINES ) - ENUM2STRING( aTypeStr, VISU::TPLOT3D ) - ENUM2STRING( aTypeStr, VISU::TANIMATION ) - } - } - else{ - bool isExist; - VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue( aMap, "myType", &isExist).toInt(); - if( isExist ){ - switch (aType) { - ENUM2STRING( aTypeStr, VISU::TENTITY ) - ENUM2STRING( aTypeStr, VISU::TFAMILY ) - ENUM2STRING( aTypeStr, VISU::TGROUP ) - ENUM2STRING( aTypeStr, VISU::TVIEW3D ) - ENUM2STRING( aTypeStr, VISU::TFIELD ) - ENUM2STRING( aTypeStr, VISU::TTIMESTAMP ) - } - } - } - - return aTypeStr; + GetSelectedObj( study(), entry( ind ), &aMap ); + bool isExist; + const QString& aVal = VISU::Storable::FindValue(aMap,"myComment",&isExist); + if ( isExist ) + aResStr = "VISU::T" + aVal; + return aResStr; } QString VisuGUI_Selection::nbComponents( const int ind ) const diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 4606134b..a4f91d61 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -162,7 +162,7 @@ namespace VISU return aStr; } - //************************************************************ + //------------------------------------------------------------ // Selection CORBA::Object_var GetSelectedObj(const SalomeApp_Study* theStudy, @@ -206,6 +206,25 @@ namespace VISU return CORBA::Object::_nil(); } + VISU::Prs3d_i* + GetPrsToModify(const SalomeApp_Module* theModule, + Handle(SALOME_InteractiveObject)* theIO, + VISU::Storable::TRestoringMap* theMap) + { + if (CheckLock(GetCStudy(GetAppStudy(theModule)))) + return NULL; + + CORBA::Object_var anObject = GetSelectedObj(theModule, theIO); + if (CORBA::is_nil(anObject)) + return NULL; + + PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); + if (!aServant.in()) + return NULL; + + return dynamic_cast(aServant.in()); + } + void Add(SalomeApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO) diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 2af898e6..63a767f4 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -82,6 +82,9 @@ namespace VISU { CORBA::Object_var GetSelectedObj(const SalomeApp_Module* theModule, Handle(SALOME_InteractiveObject)* theIO = NULL, VISU::Storable::TRestoringMap* theMap = NULL); + VISU::Prs3d_i* GetPrsToModify(const SalomeApp_Module* theModule, + Handle(SALOME_InteractiveObject)* theIO = NULL, + VISU::Storable::TRestoringMap* theMap = NULL); void Add(SalomeApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO); -- 2.39.2