From: vsv Date: Mon, 8 Dec 2014 11:37:57 +0000 (+0300) Subject: Issue #310: Do not select Groups for operations X-Git-Tag: V_0.6.0^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=775a68ef324ad11fba818c46cc795046f7cbfa5a;p=modules%2Fshaper.git Issue #310: Do not select Groups for operations --- diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index c313a6ec9..55370797f 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -14,6 +14,7 @@ SET(PROJECT_HEADERS PartSet_WidgetPoint2dDistance.h PartSet_WidgetShapeSelector.h PartSet_OperationSketch.h + PartSet_Filters.h ) SET(PROJECT_SOURCES @@ -26,6 +27,7 @@ SET(PROJECT_SOURCES PartSet_WidgetPoint2dDistance.cpp PartSet_WidgetShapeSelector.cpp PartSet_OperationSketch.cpp + PartSet_Filters.cpp ) SET(PROJECT_RESOURCES @@ -70,6 +72,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI ${CMAKE_SOURCE_DIR}/src/GeomDataAPI ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI ${CMAKE_SOURCE_DIR}/src/SketchPlugin + ${CMAKE_SOURCE_DIR}/src/FeaturesPlugin ${CMAKE_SOURCE_DIR}/src/GeomAPI ${CAS_INCLUDE_DIRS} ${SUIT_INCLUDE} diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp new file mode 100644 index 000000000..04ea88b37 --- /dev/null +++ b/src/PartSet/PartSet_Filters.cpp @@ -0,0 +1,42 @@ +// File: PartSet_Filters.cpp +// Created: 08 Nov 2014 +// Author: Vitaly SMETANNIKOV + +#include "PartSet_Filters.h" + +#include + +#include +#include + +#include +#include + + +IMPLEMENT_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter); +IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter); + +Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const +{ + if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) { + if (theOwner->HasSelectable()) { + Handle(AIS_InteractiveObject) aAisObj = + Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); + if (!aAisObj.IsNull()) { + std::shared_ptr aAISObj = AISObjectPtr(new GeomAPI_AISObject()); + aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj)); + ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj); + if (aObj) { + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); + if (aFeature) { + return aFeature->getKind() != FeaturesPlugin_Group::ID(); + } else + return Standard_True; + } else + // This is not object controlled by the filter + return Standard_True; + } + } + } + return Standard_False; +} diff --git a/src/PartSet/PartSet_Filters.h b/src/PartSet/PartSet_Filters.h new file mode 100644 index 000000000..56715069d --- /dev/null +++ b/src/PartSet/PartSet_Filters.h @@ -0,0 +1,26 @@ +// File: PartSet_Filters.h +// Created: 08 Nov 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef PartSet_Filters_H +#define PartSet_Filters_H + +#include + + +/** +* A class which filters groups object in addition to documents (see issue #310) +*/ +DEFINE_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter); +class PartSet_GlobalFilter: public ModuleBase_ShapeDocumentFilter +{ +public: + PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop) + : ModuleBase_ShapeDocumentFilter(theWorkshop) {} + + Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const; + + DEFINE_STANDARD_RTTI(PartSet_GlobalFilter) +}; + +#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 2c055ffd6..16eac8958 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -203,7 +203,7 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) } } if (myDocumentShapeFilter.IsNull()) - myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(myWorkshop); + myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop); myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter); } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 1d9fc45df..42619830d 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -2,10 +2,10 @@ #define PartSet_Module_H #include "PartSet.h" +#include #include #include -#include #include #include #include @@ -133,7 +133,7 @@ protected slots: Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter; /// A filter which provides selection within a current document or whole PartSet - Handle(ModuleBase_ShapeDocumentFilter) myDocumentShapeFilter; + Handle(PartSet_GlobalFilter) myDocumentShapeFilter; }; #endif