From 898d1167030566b812400aee9ec5f57ec9643deb Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 28 Aug 2015 19:49:07 +0300 Subject: [PATCH] Issue #839 Selection of Part sub-results --- src/FeaturesPlugin/movement_widget.xml | 4 +- src/FeaturesPlugin/placement_widget.xml | 4 +- src/FeaturesPlugin/rotation_widget.xml | 3 +- src/GeomValidators/CMakeLists.txt | 2 - src/GeomValidators/GeomValidators_PartSet.cpp | 41 ------------------- src/GeomValidators/GeomValidators_PartSet.h | 29 ------------- .../ModuleBase_WidgetMultiSelector.cpp | 9 ++-- src/ModuleBase/ModuleBase_WidgetSelector.cpp | 4 ++ src/PartSet/PartSet_Module.cpp | 3 -- 9 files changed, 12 insertions(+), 87 deletions(-) delete mode 100755 src/GeomValidators/GeomValidators_PartSet.cpp delete mode 100755 src/GeomValidators/GeomValidators_PartSet.h diff --git a/src/FeaturesPlugin/movement_widget.xml b/src/FeaturesPlugin/movement_widget.xml index e7e162d0a..7f1671d85 100644 --- a/src/FeaturesPlugin/movement_widget.xml +++ b/src/FeaturesPlugin/movement_widget.xml @@ -5,10 +5,8 @@ label="Main objects" icon=":icons/cut_shape.png" tooltip="Select a solid objects" - type_choice="Objects Solids" - use_choice="false" + type_choice="" concealment="true"> - - - -#include - -#include -#include - -#include -#include -#include - -bool GeomValidators_PartSet::isValid(const AttributePtr& theAttribute, - const std::list& theArguments, - std::string& theError) const -{ - bool aValid = false; - SessionPtr aMgr = ModelAPI_Session::get(); - bool isPartSetDocument = aMgr->activeDocument() == aMgr->moduleDocument(); - if (!isPartSetDocument) - aValid = true; - else { - // only hole objects should be selected in PartSet document, there is no decomposition - if (theAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) { - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(theAttribute); - for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) { - AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i); - GeomShapePtr aShape = aSelectAttr->value(); - aValid = !aShape.get(); - } - } - } - - return aValid; -} - diff --git a/src/GeomValidators/GeomValidators_PartSet.h b/src/GeomValidators/GeomValidators_PartSet.h deleted file mode 100755 index b8b374303..000000000 --- a/src/GeomValidators/GeomValidators_PartSet.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomValidators_PartSet.h -// Created: 27 Aug 2015 -// Author: Natalia ERMOLAEVA - -#ifndef GeomValidators_PartSet_H -#define GeomValidators_PartSet_H - -#include -#include - -/** -* \ingroup Validators -* A validator for partset document. When PartSet is active, the attribute can accept only -* shape, which coincide to the shape of result. -*/ -class GeomValidators_PartSet : public ModelAPI_AttributeValidator -{ -public: - //! returns true if attribute is valid - //! \param theAttribute the checked attribute - //! \param theArguments arguments of the attribute - GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute, - const std::list& theArguments, - std::string& theError) const; -}; - -#endif diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index d58a23633..8a703d320 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -77,14 +77,15 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen std::string aPropertyTypes = theData->getProperty("type_choice"); QString aTypesStr = aPropertyTypes.c_str(); - QStringList aShapeTypes = aTypesStr.split(' '); + QStringList aShapeTypes = aTypesStr.split(' ', QString::SkipEmptyParts); myIsUseChoice = theData->getBooleanAttribute("use_choice", true); - myTypeCombo->addItems(aShapeTypes); + if (!aShapeTypes.empty()) + myTypeCombo->addItems(aShapeTypes); aMainLay->addWidget(myTypeCombo, 0, 1); // if the xml definition contains one type, the controls to select a type should not be shown - if (aShapeTypes.size() == 1 || !myIsUseChoice) { + if (aShapeTypes.size() <= 1 || !myIsUseChoice) { aTypeLabel->setVisible(false); myTypeCombo->setVisible(false); } @@ -94,7 +95,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen : tr("Selected objects:"), this); aMainLay->addWidget(aListLabel, 1, 0); // if the xml definition contains one type, an information label should be shown near to the latest - if (aShapeTypes.size() == 1) { + if (aShapeTypes.size() <= 1) { QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); if (!aLabelIcon.isEmpty()) { QLabel* aSelectedLabel = new QLabel("", this); diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index daafd6431..96cabdd00 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -64,6 +64,10 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, GeomShapePtr aShape = theShape; QIntList aShapeTypes = getShapeTypes(); + if (aShapeTypes.empty()) { + aValid = true; + return aValid; + } // when the SHAPE type is provided by XML, the hole result shape can be selected. if (!aShape.get() && aShapeTypes.contains(TopAbs_SHAPE)) { aValid = true; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 19c8469e3..ed2c71c73 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -36,7 +36,6 @@ #include #include -#include #include #include #include @@ -210,8 +209,6 @@ void PartSet_Module::registerValidators() aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType); aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face); - aFactory->registerValidator("GeomValidators_PartSet", new GeomValidators_PartSet); - aFactory->registerValidator("GeomValidators_Finite", new GeomValidators_Finite); aFactory->registerValidator("GeomValidators_ConstructionComposite", -- 2.39.2