]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
1. "type_choice" is corrected(a regression) to use the 1st up letter in the type...
authornds <natalia.donis@opencascade.com>
Tue, 26 May 2015 05:21:09 +0000 (08:21 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 26 May 2015 05:21:39 +0000 (08:21 +0300)
2. GeomValidators_ShapeType using for shape selector like it is in multi selector

src/ExchangePlugin/plugin-Exchange.xml
src/FeaturesPlugin/boolean_widget.xml
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/group_widget.xml
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/SketchPlugin/plugin-Sketch.xml

index eb6cbe6d8873c07b491816537ae52e4d2985006c..f478491fed0f0406b29dafb904437cdbd3fb1143 100644 (file)
@@ -12,7 +12,7 @@
         <export_file_selector id="export_file_selector" type="save" title="Export file" path="">
           <validator id="ExchangePlugin_ExportFormat" parameters="BREP:BREP,STEP|STP:STEP,IGES:IGES-5.1,IGES:IGES-5.3" />
         </export_file_selector>
-        <multi_selector id="selection_list" tooltip="Select a set of objects" type_choice="vertex edge face solid" /> 
+        <multi_selector id="selection_list" tooltip="Select a set of objects" type_choice="Vertices Edges Faces Solids" /> 
       </feature>
     </group>
   </workbench>
index b7798d9d91cf0f4890d1c6af39b41e958a1411bb..f356304b0ed84501ba5da677edb217b8ec00fa8e 100644 (file)
@@ -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"
   />
   <multi_selector id="tool_objects" 
     label="Tool object" 
     icon=":icons/cut_tool.png" 
     tooltip="Select a tool solid"
-    type_choice="solid"
+    type_choice="Solids"
     concealment="true" >
        <validator id="PartSet_DifferentObjects"/>
   </multi_selector>-->
@@ -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"
   />
   <shape_selector id="tool_object" 
index 63995f9562e457f01797bb0431edc267f01d4ae7..5783d542c91d650034452da3bccba393a648ea67 100644 (file)
@@ -5,7 +5,7 @@
     label="Select a sketch face"
     icon=":icons/sketch.png"
     tooltip="Select a sketch face"
-    type_choice="face">
+    type_choice="Faces">
     <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
   </multi_selector>
   <groupbox title="From">
@@ -53,7 +53,7 @@
     label="Select a sketch face"
     icon=":icons/sketch.png"
     tooltip="Select a sketch face"
-    type_choice="face">
+    type_choice="Faces">
     <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
   </multi_selector>
   <shape_selector id="axis_object"
index 2e7f988726774fbc36d9cf611ed5fc0c0006359e..1b1825329df41ef62ca2d60134d503eeaf788bb2 100644 (file)
@@ -3,5 +3,5 @@
 <source>
   <multi_selector id="group_list" 
     tooltip="Select a set of objects" 
-    type_choice="vertex edge face solid" /> 
+    type_choice="Vertices Edges Faces Solids" /> 
 </source>
\ No newline at end of file
index 6ee99f6cf82baf476267db07c1e8b81a8a43f519..298259260674750e49ed815e300f7e068512185d 100644 (file)
@@ -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()
 {
index 88950061685a23d5e773978cd1c74d32c8333661..b6fa60aed30361c8faea0168cb6ad26a770a350d 100644 (file)
@@ -41,7 +41,7 @@ class QAction;
 * \code
 * <multi_selector id="group_list" 
 *    tooltip="Select a set of objects" 
-*    type_choice="vertex edge face solid" /> 
+*    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<ModuleBase_ViewerPrs> 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<GeomSelection> mySelection;
 
-  /// A map of "type_choice" validators.
+  /// An instance of the "type_choice" validator. It is returns on validating in customValidator()
   GeomValidators_ShapeType* myShapeValidator;
 };
 
index 785e98b4141f73de40e9fbe431f8e9ee1d31ca67..62e152f620af1c039655b151707d2b3a2ee32579 100644 (file)
@@ -13,6 +13,8 @@
 #include <ModuleBase_FilterFactory.h>
 #include <ModuleBase_Filter.h>
 
+#include <GeomValidators_ShapeType.h>
+
 #include <Config_WidgetAPI.h>
 #include <Events_Loop.h>
 #include <Events_Message.h>
@@ -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<GeomAPI_Shape> theShape) const
+/*bool ModuleBase_WidgetShapeSelector::acceptSubShape(std::shared_ptr<GeomAPI_Shape> theShape) const
 {
+  return true;
+
   TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
   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<ModelAPI_Validator*>& theValidators,
+                                    std::list<std::list<std::string> >& theArguments) const
+{
+  theValidators.push_back(myShapeValidator);
+
+  std::list<std::string> 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;
index 2dcd3662d1fa3457edf6be3d096680d4a8f34ea6..cd82144c1a50b8b247843f16177b43a9630bbab0 100644 (file)
@@ -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<ModelAPI_Validator*>& theValidators,
+                                std::list<std::list<std::string> >& 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<GeomAPI_Shape> theShape) const;
+  //virtual bool acceptSubShape(std::shared_ptr<GeomAPI_Shape> 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
index 9e3f411c5b446c172efce4f476c1cc1e26d8c85a..59104a8f92f303ea43b82dfe9826dca284136c55 100644 (file)
         <sketch_multi_selector id="ConstraintMirrorList"
             label="List of objects"
             tooltip="Select list of mirroring objects"
-            type_choice="edge"
+            type_choice="Edges"
             use_external="true">
             <validator id="SketchPlugin_MirrorAttr" />
         </sketch_multi_selector>
         <sketch_multi_selector id="MultiTranslationList"
             label="List of objects"
             tooltip="Select list of translating objects"
-            type_choice="edge"
+            type_choice="Edges"
             use_external="true">
           <validator id="SketchPlugin_CopyValidator" />
         </sketch_multi_selector>
         <sketch_multi_selector id="MultiRotationList"
             label="List of objects"
             tooltip="Select list of rotating objects"
-            type_choice="edge"
+            type_choice="Edges"
             use_external="true">
           <validator id="SketchPlugin_CopyValidator" />
         </sketch_multi_selector>