return NULL; // not found
}
+const ModelAPI_Validator* Model_ValidatorsFactory::validator(
+ const std::string& theFeatureID, const std::string& theAttrID) const
+{
+ map<string, map<string, pair<ModelAPI_Validator*, list<string> > > >::const_iterator
+ aFeature = myAttrs.find(theFeatureID);
+ if (aFeature == myAttrs.cend()) return NULL; // feature is not found
+ map<string, pair<ModelAPI_Validator*, list<string> > >::const_iterator
+ anAttr = aFeature->second.find(theAttrID);
+ if (anAttr == aFeature->second.cend()) return NULL; // attribute is not found
+ return anAttr->second.first;
+}
+
/*bool Model_ValidatorsFactory::validate(
const boost::shared_ptr<ModelAPI_Feature>& theFeature, const string& theAttrID ) const
{
/// Provides a validator for the feature, returns NULL if no validator
MODEL_EXPORT virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const;
+ /// Provides a validator for the attribute, returns NULL if no validator
+ MODEL_EXPORT virtual const ModelAPI_Validator* validator(
+ const std::string& theFeatureID, const std::string& theAttrID) const;
/// Returns the result of "validate" method for attribute of validator.
/// If validator is not exists, returns true: everything is valid by default.
/// Provides a validator for the feature, returns NULL if no validator
virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const = 0;
+ /// Provides a validator for the attribute, returns NULL if no validator
+ virtual const ModelAPI_Validator* validator(
+ const std::string& theFeatureID, const std::string& theAttrID) const = 0;
+
/// Returns the result of "validate" method for attribute of validator.
/// If validator is not exists, returns true: everything is valid by default.
//virtual bool validate(
ModuleBase_ISelection.h
ModuleBase_ViewerPrs.h
ModuleBase_Tools.h
+ ModuleBase_ResultValidators.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetValue.cpp
ModuleBase_WidgetValueFeature.cpp
ModuleBase_Tools.cpp
+ ModuleBase_ResultValidators.cpp
)
SET(PROJECT_LIBRARIES
#include <QWidget>
-ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData)
- : QObject(theParent), myHasDefaultValue(false)
+ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : QObject(theParent), myHasDefaultValue(false), myParentId(theParentId)
{
myAttributeID = theData ? theData->widgetId() : "";
}
}
return true;
}
-
-std::string ModuleBase_ModelWidget::attributeID() const
-{
- return myAttributeID;
-}
/// Constructor
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
/// Destructor
virtual ~ModuleBase_ModelWidget() {};
/// Returns the attribute name
/// \returns the string value
- std::string attributeID() const;
+ std::string attributeID() const { return myAttributeID; }
+
+ /// Returns the parent of the attribute
+ /// \returns the string value
+ std::string parentID() const { return myParentId; }
signals:
/// The signal about widget values changed
private:
std::string myAttributeID; /// the attribute name of the model feature
+ std::string myParentId; /// name of parent
};
#endif
--- /dev/null
+// File: ModuleBase_ResultValidators.cpp
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "ModuleBase_ResultValidators.h"
+#include "ModuleBase_Tools.h"
+
+#include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+
+ResultPtr result(const ObjectPtr theObject)
+{
+ return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+}
+
+TopoDS_Shape shape(ResultPtr theResult)
+{
+ boost::shared_ptr<GeomAPI_Shape> aShape = ModuleBase_Tools::shape(theResult);
+ if (aShape)
+ return aShape->impl<TopoDS_Shape>();
+ return TopoDS_Shape();
+}
+
+
+bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ TopoDS_Shape aShape = shape(aResult);
+ if (aShape.IsNull())
+ return false;
+
+ return aShape.ShapeType() == TopAbs_VERTEX;
+}
+
+
+bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ TopoDS_Shape aShape = shape(aResult);
+ if (aShape.IsNull())
+ return false;
+
+ if (aShape.ShapeType() == TopAbs_EDGE) {
+ TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+ Standard_Real aStart, aEnd;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+ GeomAdaptor_Curve aAdaptor(aCurve);
+ return aAdaptor.GetType() == GeomAbs_Line;
+ }
+ return false;
+}
+
+
+bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ TopoDS_Shape aShape = shape(aResult);
+ if (aShape.IsNull())
+ return false;
+
+ if (aShape.ShapeType() == TopAbs_EDGE) {
+ TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+ Standard_Real aStart, aEnd;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
+ GeomAdaptor_Curve aAdaptor(aCurve);
+ return aAdaptor.GetType() == GeomAbs_Circle;
+ }
+ return false;
+}
+
--- /dev/null
+// File: ModuleBase_ResultValidators.h
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_ResultValidators_H
+#define ModuleBase_ResultValidators_H
+
+#include "ModuleBase.h"
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_Object.h>
+
+class ModuleBase_ResultValidator: public ModelAPI_Validator
+{
+public:
+ virtual bool isValid(const ObjectPtr theObject) const = 0;
+};
+
+class ModuleBase_ResulPointValidator: public ModuleBase_ResultValidator
+{
+public:
+ MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class ModuleBase_ResulLineValidator: public ModuleBase_ResultValidator
+{
+public:
+ MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class ModuleBase_ResulArcValidator: public ModuleBase_ResultValidator
+{
+public:
+ MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+#endif
\ No newline at end of file
#include <QLayout>
#include <QCheckBox>
-ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData)
- : ModuleBase_ModelWidget(theParent, theData)
+ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
{
QString aText = QString::fromStdString(theData->widgetLabel());
QString aToolTip = QString::fromStdString(theData->widgetTooltip());
/// Constructor
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
virtual ~ModuleBase_WidgetBoolValue();
#endif
-ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData)
- : ModuleBase_ModelWidget(theParent, theData)
+ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
{
myContainer = new QWidget(theParent);
QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
/// Constructor
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
virtual ~ModuleBase_WidgetDoubleValue();
#include <QDoubleSpinBox>
ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
- const Config_WidgetAPI* theData)
-: ModuleBase_WidgetDoubleValue(theParent, theData)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
{
}
ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute)
-: ModuleBase_WidgetDoubleValue(theParent, 0)
+: ModuleBase_WidgetDoubleValue(theParent, 0, "")
{
setAttributeID(theAttribute);
}
/// \theParent the parent object
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
/// Constructor
/// \theParent the parent object
/// \theParent the parent object
void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
{
+ myParentId = myWidgetApi->widgetId();
if (!myWidgetApi->toChildWidget())
return;
QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
{
- ModuleBase_WidgetDoubleValue* aDblWgt = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi);
+ ModuleBase_WidgetDoubleValue* aDblWgt =
+ new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aDblWgt);
return aDblWgt->getControl();
QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
{
- ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent, myWidgetApi);
+ ModuleBase_WidgetPoint2D* aWidget =
+ new ModuleBase_WidgetPoint2D(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aWidget);
return aWidget->getControl();
}
QWidget* ModuleBase_WidgetFactory::featureSelectorControl(QWidget* theParent)
{
- ModuleBase_WidgetFeature* aWidget = new ModuleBase_WidgetFeature(theParent, myWidgetApi);
+ ModuleBase_WidgetFeature* aWidget =
+ new ModuleBase_WidgetFeature(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aWidget);
return aWidget->getControl();
}
QWidget* ModuleBase_WidgetFactory::featureOrAttributeSelectorControl(QWidget* theParent)
{
- ModuleBase_WidgetFeatureOrAttribute* aWidget = new ModuleBase_WidgetFeatureOrAttribute(theParent,
- myWidgetApi);
+ ModuleBase_WidgetFeatureOrAttribute* aWidget =
+ new ModuleBase_WidgetFeatureOrAttribute(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aWidget);
return aWidget->getControl();
}
QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
{
- ModuleBase_WidgetEditor* aWidget = new ModuleBase_WidgetEditor(theParent, myWidgetApi);
+ ModuleBase_WidgetEditor* aWidget =
+ new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aWidget);
return aWidget->getControl();
}
QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
{
- ModuleBase_WidgetSelector* aSelector = new ModuleBase_WidgetSelector(theParent, myWorkshop, myWidgetApi);
+ ModuleBase_WidgetSelector* aSelector =
+ new ModuleBase_WidgetSelector(theParent, myWorkshop, myWidgetApi, myParentId);
myModelWidgets.append(aSelector);
return aSelector->getControl();
}
QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
{
- ModuleBase_WidgetBoolValue* aBoolWgt = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi);
+ ModuleBase_WidgetBoolValue* aBoolWgt =
+ new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aBoolWgt);
return aBoolWgt->getControl();
QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent)
{
- ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi);
+ ModuleBase_WidgetPoint2dDistance* aDistWgt =
+ new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aDistWgt);
return aDistWgt->getControl();
ModuleBase_IWorkshop* myWorkshop;
QList<ModuleBase_ModelWidget*> myModelWidgets;
+ std::string myParentId;
};
#endif /* ModuleBase_WidgetFactory_H_ */
#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_WidgetValue.h>
+#include <ModuleBase_ResultValidators.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Validator.h>
#include <QWidget>
#include <QLineEdit>
#include <QLabel>
ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent,
- const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
- myObjectKinds = aKinds.split(" ");
+ //QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
+ //myObjectKinds = aKinds.split(" ");
+ //theData->
myContainer = new QWidget(theParent);
QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject)
{
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ const ModelAPI_Validator* aValidator = aFactory->validator(parentID(), attributeID());
+ if (aValidator) {
+ const ModuleBase_ResultValidator* aResValidator =
+ dynamic_cast<const ModuleBase_ResultValidator*>(aValidator);
+ if (aResValidator) {
+ if (!aResValidator->isValid(theObject))
+ return false;
+ }
+ }
// TODO
//if (!myObjectKinds.contains(theObject->getKind().c_str()))
// return false;
/// \theParent the parent object
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
/// Destructor
virtual ~ModuleBase_WidgetFeature();
#include <QLabel>
ModuleBase_WidgetFeatureOrAttribute::ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent,
- const Config_WidgetAPI* theData)
-: ModuleBase_WidgetFeature(theParent, theData)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_WidgetFeature(theParent, theData, theParentId)
{
}
/// \theParent the parent object
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
/// Destructor
virtual ~ModuleBase_WidgetFeatureOrAttribute();
#include <climits>
ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent,
- const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)),
/// \theParent the parent object
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
/// Destructor
virtual ~ModuleBase_WidgetPoint2D();
#include <QDoubleSpinBox>
-ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData)
- : ModuleBase_WidgetDoubleValue(theParent, theData)
+ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent,
+ const Config_WidgetAPI* theData, const std::string& theParentId)
+ : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
{
myFirstPntName = theData->getProperty("first_point");
}
/// Constructor
/// \theParent the parent object
/// \theData the widget configuation. The attribute of the model widget is obtained from
- ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData);
+ ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId);
virtual ~ModuleBase_WidgetPoint2dDistance();
ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
- const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData), myWorkshop(theWorkshop), myActivateOnStart(false)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop), myActivateOnStart(false)
{
myContainer = new QWidget(theParent);
QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
public:
ModuleBase_WidgetSelector(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
- const Config_WidgetAPI* theData);
+ const Config_WidgetAPI* theData, const std::string& theParentId);
virtual ~ModuleBase_WidgetSelector();
void PartSet_Module::createFeatures()
{
- Config_ModuleReader aXMLReader = Config_ModuleReader();
- aXMLReader.readAll();
- myFeaturesInFiles = aXMLReader.featuresInFiles();
-
//!! Test registering of validators
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
+
+ Config_ModuleReader aXMLReader = Config_ModuleReader();
+ aXMLReader.readAll();
+ myFeaturesInFiles = aXMLReader.featuresInFiles();
}
void PartSet_Module::featureCreated(QAction* theFeature)
Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
{
if (theType == "sketch-start-label") {
- PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi);
+ PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
aWgt->setOperationsMgr(myWorkshop->operationMgr());
theModelWidgets.append(aWgt);
return aWgt->getControl();
}
}
ObjectPtr aFeature;
-/* TODO if (!theSelected.empty()) {
+ if (!theSelected.empty()) {
ModuleBase_ViewerPrs aPrs = theSelected.front();
aFeature = aPrs.object();
- } else*/
- aFeature = feature(); // for the widget distance only
+ } else
+ aFeature = feature(); // for the widget distance only
bool isApplyed = setWidgetValue(aFeature, aX, anY);
if (isApplyed) {
#include <QLabel>
PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
- const Config_WidgetAPI* theData)
-: ModuleBase_ModelWidget(theParent, theData)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
myText = QString::fromStdString(theData->getProperty("title"));
myLabel = new QLabel(myText, theParent);
{
Q_OBJECT
public:
- PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData);
+ PartSet_WidgetSketchLabel(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId);
virtual ~PartSet_WidgetSketchLabel() {};
<group id="Constraints">
<feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points" internal="1"/>
+
<feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object">
<label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
- <feature_or_attribute_selector id="ConstraintEntityA" label="First point" tooltip="Select an point in the viewer" keysequence="SketchPoint Point2D"/>
- <feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer" keysequence="SketchPoint Point2D"/>
+ <feature_or_attribute_selector id="ConstraintEntityA" label="First point" tooltip="Select an point in the viewer">
+ <validator id="ModuleBase_ResulPointValidator"/>
+ </feature_or_attribute_selector>
+ <feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer">
+ <validator id="ModuleBase_ResulPointValidator"/>
+ </feature_or_attribute_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
<validator id="PartSet_DistanceValidator"/>
</feature>
+
<feature id="SketchConstraintLength" title="Length" tooltip="Create constraint for the given length of a line segment">
<label title="Select a line on which to calculate lenght" tooltip="Select a line on which to calculate lenght"/>
- <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
+ <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer">
+ <validator id="ModuleBase_ResulLineValidator"/>
+ </feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
<validator id="PartSet_LengthValidator"/>
</feature>
+
<feature id="SketchConstraintRadius" title="Radius" tooltip="Create constraint for the given radius of a circle or an arc">
<label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
- <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer" keysequence="SketchCircle SketchArc"/>
+ <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer">
+ <validator id="ModuleBase_ResulArcValidator"/>
+ </feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
<validator id="PartSet_RadiusValidator"/>
</feature>
+
<feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines">
- <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
- <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
+ <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
+ <validator id="ModuleBase_ResulLineValidator"/>
+ </feature_selector>
+ <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
+ <validator id="ModuleBase_ResulLineValidator"/>
+ </feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<validator id="PartSet_ParallelValidator"/>
</feature>
+
<feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines">
- <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
- <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" keysequence="SketchLine"/>
+ <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
+ <validator id="ModuleBase_ResulLineValidator"/>
+ </feature_selector>
+ <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
+ <validator id="ModuleBase_ResulLineValidator"/>
+ </feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<validator id="PartSet_PerpendicularValidator"/>
</feature>
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_SelectionValidator.h>
+#include <ModuleBase_ResultValidators.h>
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ registerValidators();
activateModule();
if (myMainWindow) {
myMainWindow->show();
}
}
}
+
+
+//**************************************************************
+void XGUI_Workshop::registerValidators() const
+{
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+ aFactory->registerValidator("ModuleBase_ResulPointValidator", new ModuleBase_ResulPointValidator);
+ aFactory->registerValidator("ModuleBase_ResulLineValidator", new ModuleBase_ResulLineValidator);
+ aFactory->registerValidator("ModuleBase_ResulArcValidator", new ModuleBase_ResulArcValidator);
+}
private:
void initMenu();
+ void registerValidators() const;
+
+
ModuleBase_IModule* loadModule(const QString& theModule);
bool activateModule();