2. GeomValidators_ShapeType using for shape selector like it is in multi selector
<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>
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>-->
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"
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">
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"
<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
theValidators.push_back(myShapeValidator);
QString aType = myTypeCombo->currentText();
- anArguments.push_back(aType.toStdString().c_str());
+ anArguments.push_back(validatorType(aType));
theArguments.push_back(anArguments);
}
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()
{
* \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
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;
/// 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;
};
#include <ModuleBase_FilterFactory.h>
#include <ModuleBase_Filter.h>
+#include <GeomValidators_ShapeType.h>
+
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
#include <Events_Message.h>
std::string aTypes = theData->getProperty("shape_types");
myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
+
+ myShapeValidator = new GeomValidators_ShapeType();
}
//********************************************************************
{
activateSelection(false);
activateFilters(myWorkshop, false);
+
+ delete myShapeValidator;
}
//********************************************************************
}
//********************************************************************
-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
}
}
+//********************************************************************
+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)
{
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;
class QLineEdit;
class QToolButton;
class ModuleBase_IWorkshop;
+class ModelAPI_Validator;
+class GeomValidators_ShapeType;
/**
* \ingroup GUI
/// \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();
/// 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();
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
<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>