From 39aa6031bea88f728de35921f26b560402b82fb0 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 16 Apr 2008 08:17:31 +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 511cad9e3..a27b8f000 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -135,6 +135,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 df9282a41..83fa5ed2e 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -97,6 +97,8 @@ private slots: void onInfoChanged( QString ); 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 437a4724f..2cc79ad71 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 +#include + #ifndef DISABLE_VTKVIEWER #ifndef DISABLE_SALOMEOBJECT #include @@ -160,11 +164,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 dbfed0b70..5d68e3c7d 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -132,6 +132,8 @@ protected: virtual void updateControls(); + virtual bool isSelectionCompatible(); + private: typedef QMap MapOfOperation; -- 2.39.2