From: nds Date: Tue, 26 May 2015 05:21:09 +0000 (+0300) Subject: 1. "type_choice" is corrected(a regression) to use the 1st up letter in the type... X-Git-Tag: V_1.2.0~90 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3f461a8755c75fd9007ec5481b511ff5a6ac3b3c;p=modules%2Fshaper.git 1. "type_choice" is corrected(a regression) to use the 1st up letter in the type GUI presentation 2. GeomValidators_ShapeType using for shape selector like it is in multi selector --- diff --git a/src/ExchangePlugin/plugin-Exchange.xml b/src/ExchangePlugin/plugin-Exchange.xml index eb6cbe6d8..f478491fe 100644 --- a/src/ExchangePlugin/plugin-Exchange.xml +++ b/src/ExchangePlugin/plugin-Exchange.xml @@ -12,7 +12,7 @@ - + diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index b7798d9d9..f356304b0 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -5,14 +5,14 @@ label="Main object" icon=":icons/cut_shape.png" tooltip="Select an object solid" - type_choice="solid" + type_choice="Solids" concealment="true" /> --> @@ -20,7 +20,7 @@ label="Main object" icon=":icons/cut_shape.png" tooltip="Select an object solid" - shape_types="solid shell" + shape_types="solid" concealment="true" /> + type_choice="Faces"> @@ -53,7 +53,7 @@ label="Select a sketch face" icon=":icons/sketch.png" tooltip="Select a sketch face" - type_choice="face"> + type_choice="Faces"> + type_choice="Vertices Edges Faces Solids" /> \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 6ee99f6cf..298259260 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -215,7 +215,7 @@ void ModuleBase_WidgetMultiSelector::customValidators( theValidators.push_back(myShapeValidator); QString aType = myTypeCombo->currentText(); - anArguments.push_back(aType.toStdString().c_str()); + anArguments.push_back(validatorType(aType)); theArguments.push_back(anArguments); } @@ -437,6 +437,23 @@ void ModuleBase_WidgetMultiSelector::updateSelectionList(AttributeSelectionListP myListControl->repaint(); } +//******************************************************************** +std::string ModuleBase_WidgetMultiSelector::validatorType(const QString& theType) const +{ + std::string aType; + + if (theType == "Vertices") + aType = "vertex"; + else if (theType == "Edges") + aType = "edge"; + else if (theType == "Faces") + aType = "face"; + else if (theType == "Solids") + aType = "solid"; + + return aType; +} + //******************************************************************** void ModuleBase_WidgetMultiSelector::onCopyItem() { diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 889500616..b6fa60aed 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -41,7 +41,7 @@ class QAction; * \code * +* type_choice="Vertices Edges Faces Solids" /> * \endcode * It uses folloing parameters: * - id - is a name of corresponded attribute @@ -137,8 +137,12 @@ protected slots: QList getAttributeSelection() const; protected: - /// Update selection list - void updateSelectionList(AttributeSelectionListPtr); + /// Update selection list + void updateSelectionList(AttributeSelectionListPtr); + + /// Converts the XML defined type choice to the validator type + /// For example, the "Edges" is converted to "edge" + std::string validatorType(const QString& theType) const; /// List control QListWidget* myListControl; @@ -164,7 +168,7 @@ protected slots: /// Variable of GeomSelection QList mySelection; - /// A map of "type_choice" validators. + /// An instance of the "type_choice" validator. It is returns on validating in customValidator() GeomValidators_ShapeType* myShapeValidator; }; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 785e98b41..62e152f62 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -93,6 +95,8 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen std::string aTypes = theData->getProperty("shape_types"); myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts); + + myShapeValidator = new GeomValidators_ShapeType(); } //******************************************************************** @@ -100,6 +104,8 @@ ModuleBase_WidgetShapeSelector::~ModuleBase_WidgetShapeSelector() { activateSelection(false); activateFilters(myWorkshop, false); + + delete myShapeValidator; } //******************************************************************** @@ -228,15 +234,17 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() } //******************************************************************** -bool ModuleBase_WidgetShapeSelector::acceptSubShape(std::shared_ptr theShape) const +/*bool ModuleBase_WidgetShapeSelector::acceptSubShape(std::shared_ptr theShape) const { + return true; + TopoDS_Shape aShape = theShape->impl(); foreach (QString aType, myShapeTypes) { if (aShape.ShapeType() == ModuleBase_Tools::shapeType(aType)) return true; } return false; -} +}*/ //******************************************************************** GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const @@ -366,6 +374,20 @@ void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid) } } +//******************************************************************** +void ModuleBase_WidgetShapeSelector::customValidators( + std::list& theValidators, + std::list >& theArguments) const +{ + theValidators.push_back(myShapeValidator); + + std::list anArguments; + foreach(QString aType, myShapeTypes) { + anArguments.push_back(aType.toStdString().c_str()); + } + theArguments.push_back(anArguments); +} + //******************************************************************** bool ModuleBase_WidgetShapeSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs) { @@ -413,8 +435,8 @@ bool ModuleBase_WidgetShapeSelector::setSelectionCustom(const ModuleBase_ViewerP aShape->setImpl(new TopoDS_Shape(thePrs.shape())); } // Check that the selection corresponds to selection type - if (!acceptSubShape(aShape)) - return false; + //if (!acceptSubShape(aShape)) + // return false; setObject(aObject, aShape); return true; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index 2dcd3662d..cd82144c1 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -26,6 +26,8 @@ class QLabel; class QLineEdit; class QToolButton; class ModuleBase_IWorkshop; +class ModelAPI_Validator; +class GeomValidators_ShapeType; /** * \ingroup GUI @@ -112,6 +114,13 @@ Q_OBJECT /// \param theValid a boolean flag, if restore happens for valid parameters virtual void restoreAttributeValue(const bool theValid); + /// Puts additional validators to the given list. A separate validator is created for each of the + /// "type_choice" value + /// \param theValidators a list of validators + /// \param theArguments a list of validators arguments + virtual void customValidators(std::list& theValidators, + std::list >& theArguments) const; + /// Computes and updates name of selected object in the widget void updateSelectionName(); @@ -120,7 +129,7 @@ Q_OBJECT /// Returns true if selected shape corresponds to requested shape types /// \param theShape a shape - virtual bool acceptSubShape(std::shared_ptr theShape) const; + //virtual bool acceptSubShape(std::shared_ptr theShape) const; /// Clear attribute void clearAttribute(); @@ -166,6 +175,9 @@ Q_OBJECT AttributePtr myRefAttribute; /// A boolean value whether refAttr uses reference of object bool myIsObject; + + /// An instance of the "shape_type" validator. It is returns on validating in customValidator() + GeomValidators_ShapeType* myShapeValidator; }; #endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 9e3f411c5..59104a8f9 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -251,7 +251,7 @@ @@ -264,7 +264,7 @@ @@ -293,7 +293,7 @@