From: vsv Date: Thu, 22 Aug 2019 07:29:29 +0000 (+0300) Subject: Issue #2975: Do not select groups in all operations except operations on groups X-Git-Tag: VEDF2019Lot4~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7512741ecf3ef77404f02fe88a4548807935b329;p=modules%2Fshaper.git Issue #2975: Do not select groups in all operations except operations on groups --- diff --git a/src/BuildPlugin/compound_widget.xml b/src/BuildPlugin/compound_widget.xml index 5984821f9..0a3f626fc 100644 --- a/src/BuildPlugin/compound_widget.xml +++ b/src/BuildPlugin/compound_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/compsolid_widget.xml b/src/BuildPlugin/compsolid_widget.xml index ccad85948..28fab58ba 100644 --- a/src/BuildPlugin/compsolid_widget.xml +++ b/src/BuildPlugin/compsolid_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/edge_widget.xml b/src/BuildPlugin/edge_widget.xml index be0885578..f7ff11447 100644 --- a/src/BuildPlugin/edge_widget.xml +++ b/src/BuildPlugin/edge_widget.xml @@ -4,7 +4,7 @@ diff --git a/src/BuildPlugin/face_widget.xml b/src/BuildPlugin/face_widget.xml index a23c7cf07..e61ce59d1 100644 --- a/src/BuildPlugin/face_widget.xml +++ b/src/BuildPlugin/face_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/filling_widget.xml b/src/BuildPlugin/filling_widget.xml index da22fc0d7..5cd076931 100644 --- a/src/BuildPlugin/filling_widget.xml +++ b/src/BuildPlugin/filling_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/interpolation_widget.xml b/src/BuildPlugin/interpolation_widget.xml index 092273243..5a0acee2f 100644 --- a/src/BuildPlugin/interpolation_widget.xml +++ b/src/BuildPlugin/interpolation_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/polyline_widget.xml b/src/BuildPlugin/polyline_widget.xml index 3760b4ede..2c283b8b1 100644 --- a/src/BuildPlugin/polyline_widget.xml +++ b/src/BuildPlugin/polyline_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/shell_widget.xml b/src/BuildPlugin/shell_widget.xml index 27b8e3971..50575ff1e 100644 --- a/src/BuildPlugin/shell_widget.xml +++ b/src/BuildPlugin/shell_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/solid_widget.xml b/src/BuildPlugin/solid_widget.xml index 4eb1ce88f..8c9234f57 100644 --- a/src/BuildPlugin/solid_widget.xml +++ b/src/BuildPlugin/solid_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/subshapes_widget.xml b/src/BuildPlugin/subshapes_widget.xml index 7d74c0c9a..5f42c96a9 100644 --- a/src/BuildPlugin/subshapes_widget.xml +++ b/src/BuildPlugin/subshapes_widget.xml @@ -10,7 +10,7 @@ diff --git a/src/BuildPlugin/vertex_widget.xml b/src/BuildPlugin/vertex_widget.xml index 446ed1a45..77af0a18f 100644 --- a/src/BuildPlugin/vertex_widget.xml +++ b/src/BuildPlugin/vertex_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/BuildPlugin/wire_widget.xml b/src/BuildPlugin/wire_widget.xml index 87f03df66..96067ebe6 100644 --- a/src/BuildPlugin/wire_widget.xml +++ b/src/BuildPlugin/wire_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/CollectionPlugin/CollectionPlugin_Validators.cpp b/src/CollectionPlugin/CollectionPlugin_Validators.cpp index 7ef185389..7620506cf 100644 --- a/src/CollectionPlugin/CollectionPlugin_Validators.cpp +++ b/src/CollectionPlugin/CollectionPlugin_Validators.cpp @@ -51,7 +51,7 @@ static bool isGroupTypeCorrect(const AttributeSelectionPtr& theSelection, { // applicable the groups only ResultPtr aGroupResult = theSelection->context(); - if (aGroupResult->groupName() != ModelAPI_ResultGroup::group()) { + if (!aGroupResult.get() || aGroupResult->groupName() != ModelAPI_ResultGroup::group()) { theError = "Error: Groups can be selected only."; return false; } diff --git a/src/CollectionPlugin/group_addition_widget.xml b/src/CollectionPlugin/group_addition_widget.xml index 04eccb1f1..98f21d97e 100644 --- a/src/CollectionPlugin/group_addition_widget.xml +++ b/src/CollectionPlugin/group_addition_widget.xml @@ -6,7 +6,8 @@ + shape_types="objects" + allow_objects="Group"> diff --git a/src/CollectionPlugin/group_intersection_widget.xml b/src/CollectionPlugin/group_intersection_widget.xml index 04eccb1f1..35cbf714f 100644 --- a/src/CollectionPlugin/group_intersection_widget.xml +++ b/src/CollectionPlugin/group_intersection_widget.xml @@ -6,7 +6,7 @@ + shape_types="objects"> diff --git a/src/CollectionPlugin/group_substraction_widget.xml b/src/CollectionPlugin/group_substraction_widget.xml index 21e692192..ebd76f0eb 100644 --- a/src/CollectionPlugin/group_substraction_widget.xml +++ b/src/CollectionPlugin/group_substraction_widget.xml @@ -6,13 +6,13 @@ + shape_types="objects"> + shape_types="objects"> diff --git a/src/CollectionPlugin/group_widget.xml b/src/CollectionPlugin/group_widget.xml index 59bd93fb4..6c304ade6 100644 --- a/src/CollectionPlugin/group_widget.xml +++ b/src/CollectionPlugin/group_widget.xml @@ -5,7 +5,7 @@ + shape_types="Vertices Edges Faces Solids Compsolids Objects"> diff --git a/src/FeaturesPlugin/boolean_common_widget.xml b/src/FeaturesPlugin/boolean_common_widget.xml index 987dadc3a..9198588ce 100644 --- a/src/FeaturesPlugin/boolean_common_widget.xml +++ b/src/FeaturesPlugin/boolean_common_widget.xml @@ -7,7 +7,7 @@ label="Objects" icon="" tooltip="Select objects" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true"> @@ -20,7 +20,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true"> @@ -30,7 +30,7 @@ label="Tool objects" icon="" tooltip="Select tools" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true" > diff --git a/src/FeaturesPlugin/boolean_fuse_widget.xml b/src/FeaturesPlugin/boolean_fuse_widget.xml index cf622baf6..8617460db 100644 --- a/src/FeaturesPlugin/boolean_fuse_widget.xml +++ b/src/FeaturesPlugin/boolean_fuse_widget.xml @@ -7,7 +7,7 @@ label="Objects" icon="" tooltip="Select objects" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true"> @@ -20,7 +20,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true"> @@ -30,7 +30,7 @@ label="Tool objects" icon="" tooltip="Select tools" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true" > diff --git a/src/FeaturesPlugin/boolean_smash_widget.xml b/src/FeaturesPlugin/boolean_smash_widget.xml index 227fd02d8..07abf751d 100644 --- a/src/FeaturesPlugin/boolean_smash_widget.xml +++ b/src/FeaturesPlugin/boolean_smash_widget.xml @@ -3,7 +3,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="faces solids compsolids" + shape_types="faces solids compsolids" use_choice="false" concealment="true"> @@ -13,7 +13,7 @@ label="Tool objects" icon="" tooltip="Select tools" - type_choice="faces solids compsolids" + shape_types="faces solids compsolids" use_choice="false" concealment="true" > diff --git a/src/FeaturesPlugin/boolean_split_widget.xml b/src/FeaturesPlugin/boolean_split_widget.xml index 0b0281098..2131c8dda 100644 --- a/src/FeaturesPlugin/boolean_split_widget.xml +++ b/src/FeaturesPlugin/boolean_split_widget.xml @@ -3,7 +3,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true"> @@ -13,7 +13,7 @@ label="Tool objects" icon="" tooltip="Select tools" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true" > diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index 9ea5db5d1..dca9d22a9 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -3,7 +3,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true"> @@ -13,7 +13,7 @@ label="Tool objects" icon="" tooltip="Select tools" - type_choice="vertices edges wires faces shells solids compsolids compounds" + shape_types="vertices edges wires faces shells solids compsolids compounds" use_choice="false" concealment="true" > diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 77e543915..9ea0416c1 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -11,7 +11,7 @@ diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index e0c30ab3e..96079ccbd 100644 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -13,7 +13,7 @@ label="Select a sketch face" icon="icons/Features/sketch.png" tooltip="Select a sketch face" - type_choice="wires faces shells" + shape_types="wires faces shells" concealment="true"> @@ -89,7 +89,7 @@ label="Cut from:" icon="icons/Features/cut_shape.png" tooltip="Objects to Cut" - type_choice="Objects" + shape_types="Objects" use_choice="false" concealment="true" main_argument="true"> diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index 932f7d8a1..80082d14e 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -13,7 +13,7 @@ label="Select a sketch face" icon="icons/Features/sketch.png" tooltip="Select a sketch face" - type_choice="vertices edges wires faces shells compounds" + shape_types="vertices edges wires faces shells compounds" concealment="true"> @@ -89,7 +89,7 @@ label="Fuse with:" icon="icons/Features/cut_shape.png" tooltip="Objects to Fuse" - type_choice="Objects" + shape_types="Objects" use_choice="false" concealment="true" main_argument="true"> diff --git a/src/FeaturesPlugin/fillet_widget.xml b/src/FeaturesPlugin/fillet_widget.xml index 898173efb..7abb4a5df 100644 --- a/src/FeaturesPlugin/fillet_widget.xml +++ b/src/FeaturesPlugin/fillet_widget.xml @@ -8,7 +8,7 @@ label="Faces or/and edges" icon="" tooltip="Select objects" - type_choice="edges faces" + shape_types="edges faces" use_choice="false" concealment="true"> @@ -30,7 +30,7 @@ label="Faces or/and edges" icon="" tooltip="Select objects" - type_choice="edges faces" + shape_types="edges faces" use_choice="false" concealment="true"> diff --git a/src/FeaturesPlugin/intersection_widget.xml b/src/FeaturesPlugin/intersection_widget.xml index 167080c6e..5f09fb238 100644 --- a/src/FeaturesPlugin/intersection_widget.xml +++ b/src/FeaturesPlugin/intersection_widget.xml @@ -3,7 +3,7 @@ label="Objects" icon="icons/Features/cut_shape.png" tooltip="Select objects(compounds, compsolids, solids, shells, faces or edges)" - type_choice="edges faces shells solids compsolids compounds" + shape_types="edges faces shells solids compsolids compounds" use_choice="false" concealment="true"> diff --git a/src/FeaturesPlugin/multirotation_widget.xml b/src/FeaturesPlugin/multirotation_widget.xml index a14b35035..8fce3fb33 100644 --- a/src/FeaturesPlugin/multirotation_widget.xml +++ b/src/FeaturesPlugin/multirotation_widget.xml @@ -3,7 +3,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="objects" + shape_types="objects" concealment="true"> diff --git a/src/FeaturesPlugin/multitranslation_widget.xml b/src/FeaturesPlugin/multitranslation_widget.xml index b7cf37cb0..658939408 100644 --- a/src/FeaturesPlugin/multitranslation_widget.xml +++ b/src/FeaturesPlugin/multitranslation_widget.xml @@ -3,7 +3,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="objects" + shape_types="objects" concealment="true"> diff --git a/src/FeaturesPlugin/partition_widget.xml b/src/FeaturesPlugin/partition_widget.xml index a0d358bd1..ad5e97ef5 100644 --- a/src/FeaturesPlugin/partition_widget.xml +++ b/src/FeaturesPlugin/partition_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/FeaturesPlugin/pipe_widget.xml b/src/FeaturesPlugin/pipe_widget.xml index 11a967d03..6211dbc25 100644 --- a/src/FeaturesPlugin/pipe_widget.xml +++ b/src/FeaturesPlugin/pipe_widget.xml @@ -2,7 +2,7 @@ @@ -27,7 +27,7 @@ + shape_types="vertex"> diff --git a/src/FeaturesPlugin/placement_widget.xml b/src/FeaturesPlugin/placement_widget.xml index b62c06dba..5f277ff36 100644 --- a/src/FeaturesPlugin/placement_widget.xml +++ b/src/FeaturesPlugin/placement_widget.xml @@ -3,7 +3,7 @@ label="Select objects to move" icon="icons/Features/cut_shape.png" tooltip="Select objects" - type_choice="objects" + shape_types="objects" concealment="true" > diff --git a/src/FeaturesPlugin/remove_subshapes_widget.xml b/src/FeaturesPlugin/remove_subshapes_widget.xml index c880f816d..28a13de3b 100644 --- a/src/FeaturesPlugin/remove_subshapes_widget.xml +++ b/src/FeaturesPlugin/remove_subshapes_widget.xml @@ -15,7 +15,7 @@ @@ -26,7 +26,7 @@ diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index e5a28b89f..3a641befb 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -11,7 +11,7 @@ diff --git a/src/FeaturesPlugin/revolutioncut_widget.xml b/src/FeaturesPlugin/revolutioncut_widget.xml index fc2b82243..217f4fb60 100644 --- a/src/FeaturesPlugin/revolutioncut_widget.xml +++ b/src/FeaturesPlugin/revolutioncut_widget.xml @@ -13,7 +13,7 @@ label="Select a sketch face" icon="icons/Features/sketch.png" tooltip="Select a sketch face" - type_choice="wires faces shells" + shape_types="wires faces shells" concealment="true"> @@ -89,7 +89,7 @@ label="Cut from:" icon="icons/Features/cut_shape.png" tooltip="Objects to Cut" - type_choice="Objects" + shape_types="Objects" use_choice="false" concealment="true" main_argument="true"> diff --git a/src/FeaturesPlugin/revolutionfuse_widget.xml b/src/FeaturesPlugin/revolutionfuse_widget.xml index 575c6c4bf..26c0de8ff 100644 --- a/src/FeaturesPlugin/revolutionfuse_widget.xml +++ b/src/FeaturesPlugin/revolutionfuse_widget.xml @@ -13,7 +13,7 @@ label="Select a sketch face" icon="icons/Features/sketch.png" tooltip="Select a sketch face" - type_choice="vertices edges wires faces shells compounds" + shape_types="vertices edges wires faces shells compounds" concealment="true"> @@ -89,7 +89,7 @@ label="Fuse with:" icon="icons/Features/cut_shape.png" tooltip="Objects to Fuse" - type_choice="Objects" + shape_types="Objects" use_choice="false" concealment="true" main_argument="true"> diff --git a/src/FeaturesPlugin/rotation_widget.xml b/src/FeaturesPlugin/rotation_widget.xml index def2c3fa9..52b945ebb 100644 --- a/src/FeaturesPlugin/rotation_widget.xml +++ b/src/FeaturesPlugin/rotation_widget.xml @@ -7,7 +7,7 @@ label="Main objects" icon="" tooltip="Select solid objects" - type_choice="objects" + shape_types="objects" concealment="true"> @@ -35,7 +35,7 @@ label="Main objects" icon="" tooltip="Select solid objects" - type_choice="objects" + shape_types="objects" concealment="true"> diff --git a/src/FeaturesPlugin/scale_widget.xml b/src/FeaturesPlugin/scale_widget.xml index 6dc4303c1..c9ade559a 100644 --- a/src/FeaturesPlugin/scale_widget.xml +++ b/src/FeaturesPlugin/scale_widget.xml @@ -7,7 +7,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="objects" + shape_types="objects" concealment="true"> @@ -35,7 +35,7 @@ label="Main objects" icon="" tooltip="Select objects" - type_choice="objects" + shape_types="objects" concealment="true"> diff --git a/src/FeaturesPlugin/symmetry_widget.xml b/src/FeaturesPlugin/symmetry_widget.xml index bda3367ea..91133e99c 100644 --- a/src/FeaturesPlugin/symmetry_widget.xml +++ b/src/FeaturesPlugin/symmetry_widget.xml @@ -5,7 +5,7 @@ label="Main objects" icon="icons/Features/cut_shape.png" tooltip="Select solid objects" - type_choice="solid objects" + shape_types="solid objects" concealment="true"> @@ -23,7 +23,7 @@ label="Main objects" icon="icons/Features/cut_shape.png" tooltip="Select solid objects" - type_choice="solid objects" + shape_types="solid objects" concealment="true"> @@ -42,7 +42,7 @@ label="Main objects" icon="icons/Features/cut_shape.png" tooltip="Select solid objects" - type_choice="solid objects" + shape_types="solid objects" concealment="true"> diff --git a/src/FeaturesPlugin/translation_widget.xml b/src/FeaturesPlugin/translation_widget.xml index ca0264951..eb4d5636a 100644 --- a/src/FeaturesPlugin/translation_widget.xml +++ b/src/FeaturesPlugin/translation_widget.xml @@ -7,7 +7,7 @@ label="Main objects" icon="" tooltip="Select solid objects" - type_choice="objects" + shape_types="objects" concealment="true"> @@ -35,7 +35,7 @@ label="Main objects" icon="" tooltip="Select solid objects" - type_choice="objects" + shape_types="objects" concealment="true"> @@ -68,7 +68,7 @@ label="Main objects" icon="" tooltip="Select solid objects" - type_choice="objects" + shape_types="objects" concealment="true"> diff --git a/src/FeaturesPlugin/union_widget.xml b/src/FeaturesPlugin/union_widget.xml index 966068352..6bbc32395 100644 --- a/src/FeaturesPlugin/union_widget.xml +++ b/src/FeaturesPlugin/union_widget.xml @@ -2,7 +2,7 @@ diff --git a/src/FiltersPlugin/filter-BelongsTo.xml b/src/FiltersPlugin/filter-BelongsTo.xml index 217645b3a..7500646c0 100644 --- a/src/FiltersPlugin/filter-BelongsTo.xml +++ b/src/FiltersPlugin/filter-BelongsTo.xml @@ -2,6 +2,6 @@ + shape_types="objects"> diff --git a/src/FiltersPlugin/filter-OnGeometry.xml b/src/FiltersPlugin/filter-OnGeometry.xml index 80053d57e..6af2e9d5e 100644 --- a/src/FiltersPlugin/filter-OnGeometry.xml +++ b/src/FiltersPlugin/filter-OnGeometry.xml @@ -2,7 +2,7 @@ + shape_types="edges faces"> diff --git a/src/FiltersPlugin/filter-OnLine.xml b/src/FiltersPlugin/filter-OnLine.xml index 8f8f52702..0a7eeccfc 100644 --- a/src/FiltersPlugin/filter-OnLine.xml +++ b/src/FiltersPlugin/filter-OnLine.xml @@ -2,7 +2,7 @@ + shape_types="edges"> diff --git a/src/FiltersPlugin/filter-OnPlane.xml b/src/FiltersPlugin/filter-OnPlane.xml index fa65cc0a4..dceb874e7 100644 --- a/src/FiltersPlugin/filter-OnPlane.xml +++ b/src/FiltersPlugin/filter-OnPlane.xml @@ -2,7 +2,7 @@ + shape_types="faces"> diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index f8a1ff2c4..a7ce541f2 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -105,6 +105,7 @@ SET(PROJECT_HEADERS ModuleBase_ITreeNode.h ModuleBase_WidgetSelectionFilter.h ModuleBase_IStepPrs.h + ModuleBase_SelectionFilterType.h ) SET(PROJECT_MOC_HEADERS diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 05d1f93ef..03abb8233 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -71,6 +71,18 @@ ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent) // SLOT(onMouseDoubleClick(QMouseEvent*))); } +ModuleBase_IModule::~ModuleBase_IModule() +{ + std::map::const_iterator aFiltersIt = + mySelectionFilters.begin(); + for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) { + Handle(SelectMgr_Filter) aFilter = aFiltersIt->second; + if (!aFilter.IsNull()) + aFilter.Nullify(); + } +} + + void ModuleBase_IModule::launchModal(const QString& theCmdId) { bool isCommitted; @@ -323,3 +335,35 @@ void ModuleBase_IModule::getXMLRepresentation(const std::string& theFeatureId, theXmlCfg = aWdgReader.featureWidgetCfg(theFeatureId); theDescription = aWdgReader.featureDescription(theFeatureId); } + + +//****************************************************** +QIntList ModuleBase_IModule::selectionFilters() +{ + QIntList aTypes; + + std::map::const_iterator aFiltersIt = + mySelectionFilters.begin(); + for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) + aTypes.append(aFiltersIt->first); + + return aTypes; +} + +//****************************************************** +void ModuleBase_IModule::registerSelectionFilter(const ModuleBase_SelectionFilterType theFilterType, + const Handle(SelectMgr_Filter)& theFilter) +{ + mySelectionFilters[theFilterType] = theFilter; +} + +//****************************************************** +Handle(SelectMgr_Filter) ModuleBase_IModule::selectionFilter(const int theType) +{ + ModuleBase_SelectionFilterType aType = (ModuleBase_SelectionFilterType)theType; + + if (mySelectionFilters.find(aType) != mySelectionFilters.end()) + return mySelectionFilters[aType]; + else + return Handle(SelectMgr_Filter)(); +} diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 529c1f153..b748d6a14 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -22,6 +22,7 @@ #include "ModuleBase.h" #include "ModuleBase_IWorkshop.h" +#include #include #include @@ -76,7 +77,7 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theParent instance of workshop interface ModuleBase_IModule(ModuleBase_IWorkshop* theParent); - virtual ~ModuleBase_IModule() {} + virtual ~ModuleBase_IModule(); /// Stores the current selection virtual void storeSelection() {} @@ -242,12 +243,18 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Returns types of registered module selection filters /// \param theSelectionFilters [out] container of type value - virtual QIntList selectionFilters() { return QIntList(); } + virtual QIntList selectionFilters(); /// Returns selection filter /// \param theType selection filter type /// \param theFilter instance of filter - virtual Handle(SelectMgr_Filter) selectionFilter(const int theType) = 0; + virtual Handle(SelectMgr_Filter) selectionFilter(const int theType); + + /// Append selection filter into the module and type of the filter in internal container + /// \param theFilterType selection filter type + /// \param theFilter added filter + void registerSelectionFilter(const ModuleBase_SelectionFilterType theFilterType, + const Handle(SelectMgr_Filter)& theFilter); /// Return true if the custom presentation is activated /// \param theFlag a flag of level of customization, which means that only part of sub-elements @@ -424,6 +431,9 @@ protected: /// Map of features in XML std::map myFeaturesInFiles; + + std::map mySelectionFilters; + }; diff --git a/src/ModuleBase/ModuleBase_SelectionFilterType.h b/src/ModuleBase/ModuleBase_SelectionFilterType.h new file mode 100644 index 000000000..8b494f6e6 --- /dev/null +++ b/src/ModuleBase/ModuleBase_SelectionFilterType.h @@ -0,0 +1,34 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef ModuleBase_SelectionFilterType_H +#define ModuleBase_SelectionFilterType_H + +#include "ModuleBase.h" + +/// Enumeration to specify module selection filters +enum MODULEBASE_EXPORT ModuleBase_SelectionFilterType { + SF_GlobalFilter, /// filter for different documents, group results + SF_FilterInfinite, /// filter for infinite construction results + SF_ResultGroupNameFilter, /// filter for selection some kind of results + SF_SketchCirclePointFilter, /// filter for selection circle points on current sketch + SF_SketchPlaneFilter /// filter for selection in the current sketch plane only +}; + +#endif diff --git a/src/ModuleBase/ModuleBase_ViewerFilters.h b/src/ModuleBase/ModuleBase_ViewerFilters.h index 7481d9f5d..1eb023222 100644 --- a/src/ModuleBase/ModuleBase_ViewerFilters.h +++ b/src/ModuleBase/ModuleBase_ViewerFilters.h @@ -53,11 +53,35 @@ public: Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const; + /// Add an object type name to list of non selectable objects + /// \param theType - a name of an object type + Standard_EXPORT void addNonSelectableType(const QString& theType) + { + if (!myNonSelectableTypes.contains(theType)) + myNonSelectableTypes.append(theType); + } + + /// Removes an object type name from list of non selectable objects + /// \param theType - a name of an object type + Standard_EXPORT void removeNonSelectableType(const QString& theType) + { + if (myNonSelectableTypes.contains(theType)) + myNonSelectableTypes.removeAll(theType); + } + + /// Returns list of non-selectable an object type names + Standard_EXPORT QStringList nonSelectableTypes() const + { + return myNonSelectableTypes; + } + DEFINE_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter) protected: /// Reference to workshop ModuleBase_IWorkshop* myWorkshop; + + QStringList myNonSelectableTypes; }; /** diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 349b61502..511c9313f 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -116,11 +116,15 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen myIsSetSelectionBlocked(false), myCurrentHistoryIndex(-1), myIsFirst(true), myFiltersWgt(0) { - std::string aPropertyTypes = theData->getProperty("type_choice"); + std::string aPropertyTypes = theData->getProperty("shape_types"); QString aTypesStr = aPropertyTypes.c_str(); myShapeTypes = aTypesStr.split(' ', QString::SkipEmptyParts); myIsUseChoice = theData->getBooleanAttribute("use_choice", false); + QString aAllowedList(theData->getProperty("allow_objects").c_str()); + if (!aAllowedList.isEmpty()) + myAllowedObjects = aAllowedList.split(' ', QString::SkipEmptyParts); + QVBoxLayout* aMainLay = new QVBoxLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); @@ -215,9 +219,26 @@ void ModuleBase_WidgetMultiSelector::activateCustom() { ModuleBase_WidgetSelector::activateCustom(); - myWorkshop->module()->activateCustomPrs(myFeature, + ModuleBase_IModule* aModule = myWorkshop->module(); + aModule->activateCustomPrs(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects, true); clearSelectedHistory(); + if (myAllowedObjects.length() > 0) { + Handle(SelectMgr_Filter) aFilter = aModule->selectionFilter(SF_GlobalFilter); + if (!aFilter.IsNull()) { + Handle(ModuleBase_ShapeDocumentFilter) aDocFilter = + Handle(ModuleBase_ShapeDocumentFilter)::DownCast(aFilter); + if (!aDocFilter.IsNull()) { + QStringList aSelFilters = aDocFilter->nonSelectableTypes(); + foreach(QString aType, aSelFilters) { + if (aSelFilters.contains(aType)) { + aDocFilter->removeNonSelectableType(aType); + myTmpAllowed.append(aType); + } + } + } + } + } } //******************************************************************** @@ -231,6 +252,20 @@ void ModuleBase_WidgetMultiSelector::deactivate() myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true); clearSelectedHistory(); + if (myTmpAllowed.length() > 0) { + ModuleBase_IModule* aModule = myWorkshop->module(); + Handle(SelectMgr_Filter) aFilter = aModule->selectionFilter(SF_GlobalFilter); + if (!aFilter.IsNull()) { + Handle(ModuleBase_ShapeDocumentFilter) aDocFilter = + Handle(ModuleBase_ShapeDocumentFilter)::DownCast(aFilter); + if (!aDocFilter.IsNull()) { + foreach(QString aType, myTmpAllowed) { + aDocFilter->addNonSelectableType(aType); + } + } + } + myTmpAllowed.clear(); + } } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 1dec34d90..f34e18ef5 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -50,12 +50,12 @@ class ModuleBase_FilterStarter; * \code * +* shape_types="Vertices Edges Faces Solids" /> * \endcode * It uses following parameters: * - id - is a name of corresponded attribute * - tooltip - a tooltip for the widget -* - type_choice - list of expected shape types. +* - shape_types - list of expected shape types. */ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_WidgetSelector { @@ -257,6 +257,8 @@ protected: ModuleBase_FilterStarter* myFiltersWgt; QObjectPtrList myVisibleObjects; + QStringList myAllowedObjects; + QStringList myTmpAllowed; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp index 582161ace..88ba16c9a 100644 --- a/src/PartSet/PartSet_Filters.cpp +++ b/src/PartSet/PartSet_Filters.cpp @@ -36,6 +36,14 @@ IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter); +PartSet_GlobalFilter::PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop) + : ModuleBase_ShapeDocumentFilter(theWorkshop) +{ + addNonSelectableType(ModelAPI_ResultField::group().c_str()); + addNonSelectableType(ModelAPI_ResultGroup::group().c_str()); +} + + Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const { bool aValid = true; @@ -63,7 +71,7 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& if (aResultGroupName == ModelAPI_ResultPart::group()) { SessionPtr aMgr = ModelAPI_Session::get(); aValid = aMgr->activeDocument() == aMgr->moduleDocument(); - } else if (aResultGroupName == ModelAPI_ResultField::group()) { + } else if (myNonSelectableTypes.contains(aResultGroupName.c_str())) { aValid = Standard_False; } else aValid = Standard_True; @@ -72,7 +80,7 @@ Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& // only and there can not be Group feature FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature) { - aValid = aFeature->getKind() != "Group"; + aValid = !myNonSelectableTypes.contains(aFeature->getKind().c_str()); } else aValid = Standard_True; } diff --git a/src/PartSet/PartSet_Filters.h b/src/PartSet/PartSet_Filters.h index 55cde03bb..f4ea76ddf 100644 --- a/src/PartSet/PartSet_Filters.h +++ b/src/PartSet/PartSet_Filters.h @@ -36,8 +36,7 @@ class PartSet_GlobalFilter: public ModuleBase_ShapeDocumentFilter public: /// Constructor /// \param theWorkshop a pointer to workshop - PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop) - : ModuleBase_ShapeDocumentFilter(theWorkshop) {} + PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop); /// Returns True if selected presentation can be selected /// \param theOwner an owner of the persentation diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e9dbb6a38..7859a701c 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -233,13 +233,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) //****************************************************** PartSet_Module::~PartSet_Module() { - std::map::const_iterator aFiltersIt = - mySelectionFilters.begin(); - for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) { - Handle(SelectMgr_Filter) aFilter = aFiltersIt->second; - if (!aFilter.IsNull()) - aFilter.Nullify(); - } delete myCustomPrs; delete myOverconstraintListener; delete myRoot; @@ -659,7 +652,7 @@ void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes, { bool isSketchActive = mySketchMgr->activeSketch().get(); - std::map::const_iterator aFiltersIt = + std::map::const_iterator aFiltersIt = mySelectionFilters.begin(); for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) { int aFilterType = aFiltersIt->first; @@ -669,7 +662,7 @@ void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes, // using sketch filters only if sketch operation is active if (!isSketchActive && - mySketchMgr->sketchSelectionFilter((XGUI_SelectionFilterType)aFilterType)) + mySketchMgr->sketchSelectionFilter((ModuleBase_SelectionFilterType)aFilterType)) continue; // using filtering of construction results only from faces panel @@ -680,37 +673,6 @@ void PartSet_Module::moduleSelectionFilters(const QIntList& theFilterTypes, } } -//****************************************************** -QIntList PartSet_Module::selectionFilters() -{ - QIntList aTypes; - - std::map::const_iterator aFiltersIt = - mySelectionFilters.begin(); - for (; aFiltersIt != mySelectionFilters.end(); aFiltersIt++) - aTypes.append(aFiltersIt->first); - - return aTypes; -} - -//****************************************************** -void PartSet_Module::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, - const Handle(SelectMgr_Filter)& theFilter) -{ - mySelectionFilters[theFilterType] = theFilter; -} - -//****************************************************** -Handle(SelectMgr_Filter) PartSet_Module::selectionFilter(const int theType) -{ - XGUI_SelectionFilterType aType = (XGUI_SelectionFilterType)theType; - - if (mySelectionFilters.find(aType) != mySelectionFilters.end()) - return mySelectionFilters[aType]; - else - return Handle(SelectMgr_Filter)(); -} - //****************************************************** void PartSet_Module::customSubShapesSelectionModes(QIntList& theModes) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 66264e3ec..bcd16ee17 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -23,7 +23,6 @@ #include "PartSet.h" #include "PartSet_Tools.h" #include "PartSet_OverconstraintListener.h" -#include "XGUI_SelectionFilterType.h" #include "PartSet_SketcherMgr.h" #include @@ -230,20 +229,6 @@ public: virtual void moduleSelectionFilters(const QIntList& theFilterTypes, SelectMgr_ListOfFilter& theSelectionFilters); - /// Returns types of registered module selection filters - /// \param theSelectionFilters [out] container of type value - virtual QIntList selectionFilters(); - - /// Append selection filter into the module and type of the filter in internal container - /// \param theFilterType selection filter type - /// \param theFilter added filter - void registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, - const Handle(SelectMgr_Filter)& theFilter); - - /// Returns selection filter - /// \param theType selection filter type - /// \param theFilter instance of filter - virtual Handle(SelectMgr_Filter) selectionFilter(const int theType); /// Returns whether the mouse enter the viewer's window /// \return true if items are added and there is no necessity to provide standard menu @@ -485,7 +470,6 @@ protected: private: bool myIsOperationIsLaunched; /// state of application between launch and stop operation - std::map mySelectionFilters; PartSet_SketcherMgr* mySketchMgr; PartSet_SketcherReentrantMgr* mySketchReentrantMgr; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 004bdaf88..b4c6203c5 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1198,12 +1198,12 @@ void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation) } } -bool PartSet_SketcherMgr::sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType) +bool PartSet_SketcherMgr::sketchSelectionFilter(const ModuleBase_SelectionFilterType theFilterType) { return mySelectionFilterTypes.find(theFilterType) != mySelectionFilterTypes.end(); } -void PartSet_SketcherMgr::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, +void PartSet_SketcherMgr::registerSelectionFilter(const ModuleBase_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter) { mySelectionFilterTypes.insert(theFilterType); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 07c3160e6..c036615b5 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -23,13 +23,13 @@ #include "PartSet.h" #include "PartSet_PreviewSketchPlane.h" -#include "XGUI_SelectionFilterType.h" #include "PartSet_Tools.h" #include #include #include #include +#include #include #include @@ -201,12 +201,12 @@ public: /// Returns true if the filter is created by the sketch manager /// \param theFilterType a checked type /// \return boolean value - bool sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType); + bool sketchSelectionFilter(const ModuleBase_SelectionFilterType theFilterType); /// Append selection filter into the module and type of the filter in internal container /// \param theFilterType selection filter type /// \param theFilter added filter - void registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, + void registerSelectionFilter(const ModuleBase_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter); /// Commit the operation if it is possible. If the operation is dimention constraint, @@ -451,7 +451,7 @@ private: CompositeFeaturePtr myCurrentSketch; - std::set mySelectionFilterTypes; + std::set mySelectionFilterTypes; FeatureToSelectionMap myCurrentSelection; bool myPreviousUpdateViewerEnabled; diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 336d8af5f..a2e09b0f5 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -497,7 +497,7 @@ @@ -514,7 +514,7 @@ @@ -583,7 +583,7 @@ diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index d9178afe1..891551b9b 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -54,7 +54,6 @@ SET(PROJECT_HEADERS XGUI_SalomeConnector.h XGUI_Selection.h XGUI_SelectionActivate.h - XGUI_SelectionFilterType.h XGUI_SelectionMgr.h XGUI_Tools.h XGUI_TransparencyWidget.h diff --git a/src/XGUI/XGUI_FacesPanel.cpp b/src/XGUI/XGUI_FacesPanel.cpp index ba5e5f82a..50d56ab37 100644 --- a/src/XGUI/XGUI_FacesPanel.cpp +++ b/src/XGUI/XGUI_FacesPanel.cpp @@ -18,6 +18,19 @@ // #include "XGUI_FacesPanel.h" +#include "XGUI_ObjectsBrowser.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_Tools.h" +#include "XGUI_Workshop.h" + +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -25,20 +38,6 @@ #include -#include -#include -#include "ModuleBase_IWorkshop.h" -#include "ModuleBase_ListView.h" -#include "ModuleBase_ResultPrs.h" -#include "ModuleBase_Tools.h" -#include "ModuleBase_ViewerPrs.h" - -#include "XGUI_ObjectsBrowser.h" -#include "XGUI_SelectionMgr.h" -#include "XGUI_SelectionFilterType.h" -#include "XGUI_Tools.h" -#include "XGUI_Workshop.h" - #include #include #include diff --git a/src/XGUI/XGUI_SelectionFilterType.h b/src/XGUI/XGUI_SelectionFilterType.h deleted file mode 100644 index 8bc9f81de..000000000 --- a/src/XGUI/XGUI_SelectionFilterType.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef XGUI_SelectionFilterType_H -#define XGUI_SelectionFilterType_H - -#include "XGUI.h" - -/// Enumeration to specify module selection filters -enum XGUI_EXPORT XGUI_SelectionFilterType { - SF_GlobalFilter, /// filter for different documents, group results - SF_FilterInfinite, /// filter for infinite construction results - SF_ResultGroupNameFilter, /// filter for selection some kind of results - SF_SketchCirclePointFilter, /// filter for selection circle points on current sketch - SF_SketchPlaneFilter /// filter for selection in the current sketch plane only -}; - -#endif