From 4526c9de39cc3e655d3fbe5d8a48ab94a2dd3b71 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 17 Apr 2008 09:05:53 +0000 Subject: [PATCH] PAL18352, PAL19290: Conflict in objects selections when switching modules + virtual bool isSelectionCompatible(); --- src/CAM/CAM_Module.cxx | 7 +++++++ src/CAM/CAM_Module.h | 2 ++ src/LightApp/LightApp_Module.cxx | 32 ++++++++++++++++++++++++++++++++ src/LightApp/LightApp_Module.h | 2 ++ 4 files changed, 43 insertions(+) diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 9b37b3347..b5a714c7d 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -132,6 +132,13 @@ CAM_Application* CAM_Module::application() const return myApp; } +/*! \brief If return false, selection will be cleared at module activation + */ +bool CAM_Module::isSelectionCompatible() +{ + return false; +} + /*!Public slot * \retval true. */ diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index 3409905e7..3768d3fe5 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -90,6 +90,8 @@ public slots: virtual void onApplicationClosed( SUIT_Application* ); protected: + virtual bool isSelectionCompatible(); + virtual CAM_DataModel* createDataModel(); virtual void setModuleName( const QString& ); diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 15eb8b011..5d8977866 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -35,12 +35,16 @@ #include "LightApp_SwitchOp.h" #include "LightApp_UpdateFlags.h" #include "LightApp_ShowHideOp.h" +#include "LightApp_SelectionMgr.h" #include "SUIT_Operation.h" #include #include #include +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + #ifndef DISABLE_VTKVIEWER #ifndef DISABLE_SALOMEOBJECT #include @@ -164,11 +168,39 @@ void LightApp_Module::selectionChanged() { } +/*! \brief If return false, selection will be cleared at module activation + */ +bool LightApp_Module::isSelectionCompatible() +{ + // return true if selected objects belong to this module + bool isCompatible = true; + SALOME_ListIO selected; + if ( LightApp_SelectionMgr *Sel = getApp()->selectionMgr() ) + Sel->selectedObjects( selected ); + + LightApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); + LightApp_DataObject* aRoot = dynamic_cast( dataModel()->root() ); + if ( aStudy && aRoot ) { + // my data type + QString moduleDataType = aRoot->componentDataType(); + // check data type of selection + SALOME_ListIteratorOfListIO It( selected ); + for ( ; isCompatible && It.More(); It.Next()) { + Handle(SALOME_InteractiveObject)& io = It.Value(); + isCompatible = ( aStudy->componentDataType( io->getEntry() ) == moduleDataType ); + } + } + return isCompatible; +} + /*!Activate module.*/ bool LightApp_Module::activateModule( SUIT_Study* study ) { bool res = CAM_Module::activateModule( study ); + if ( !isSelectionCompatible() )// PAL19290, PAL18352 + getApp()->selectionMgr()->clearSelected(); + if ( res && application() && application()->resourceMgr() ) application()->resourceMgr()->raiseTranslators( name() ); diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index de4e6600f..2332b4bd4 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -128,6 +128,8 @@ protected: virtual void updateControls(); + virtual bool isSelectionCompatible(); + private: typedef QMap MapOfOperation; -- 2.39.2