}
-bool ModuleBase_ResulPointValidator::isValid(const ObjectPtr theObject) const
+bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
if (!aResult)
}
-bool ModuleBase_ResulLineValidator::isValid(const ObjectPtr theObject) const
+bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
if (!aResult)
}
-bool ModuleBase_ResulArcValidator::isValid(const ObjectPtr theObject) const
+bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
if (!aResult)
virtual bool isValid(const ObjectPtr theObject) const = 0;
};
-class ModuleBase_ResulPointValidator: public ModuleBase_ResultValidator
+class ModuleBase_ResultPointValidator: public ModuleBase_ResultValidator
{
public:
MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
};
-class ModuleBase_ResulLineValidator: public ModuleBase_ResultValidator
+class ModuleBase_ResultLineValidator: public ModuleBase_ResultValidator
{
public:
MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
};
-class ModuleBase_ResulArcValidator: public ModuleBase_ResultValidator
+class ModuleBase_ResultArcValidator: public ModuleBase_ResultValidator
{
public:
MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_WidgetValue.h>
+#include <ModuleBase_Tools.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
if (aFeatureValue) {
boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
- ObjectPtr aValueFeature = aFeatureValue->object();
- if (aValueFeature) {
- isDone = setObject(aValueFeature);
+ ObjectPtr aObject = aFeatureValue->object();
+ if (aObject) {
+ isDone = setObject(aObject);
}
if (!isDone && aValuePoint) {
- // find the given point in the feature attributes
- std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes =
- aValueFeature->data()->attributes(GeomDataAPI_Point2D::type());
- std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
- aLast = anAttiributes.end();
- boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
- for (;anIt!=aLast && !aFPoint; anIt++) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
- if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
- aFPoint = aCurPoint;
+ FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+ if (aFeature) {
+ // find the given point in the feature attributes
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes =
+ aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
+ aLast = anAttiributes.end();
+ boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
+ for (;anIt!=aLast && !aFPoint; anIt++) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
+ aFPoint = aCurPoint;
+ }
+ if (aFPoint)
+ isDone = setAttribute(aFPoint);
}
- if (aFPoint)
- isDone = setAttribute(aFPoint);
}
}
}
return isDone;
}
-bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetFeatureOrAttribute::storeValue(ObjectPtr theFeature) const
{
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+ if (!aFeature)
+ return false;
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
else if (myAttribute)
aRef->setAttr(myAttribute);
- theFeature->execute();
+ aFeature->execute();
updateObject(theFeature);
return true;
}
-bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(ObjectPtr theFeature)
{
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+ FeaturePtr aFeature = ModuleBase_Tools::feature(aRef->object());
if (aFeature) {
setObject(aFeature);
myAttribute = aRef->attr();
bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute)
{
- if (!theAttribute || !featureKinds().contains(theAttribute->attributeType().c_str()))
+ if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str()))
return false;
myAttribute = theAttribute;
/// Saves the internal parameters to the given feature
/// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const;
+ virtual bool storeValue(ObjectPtr theFeature) const;
- virtual bool restoreValue(FeaturePtr theFeature);
+ virtual bool restoreValue(ObjectPtr theFeature);
protected:
/// Set the attribute
<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">
- <validator id="ModuleBase_ResulPointValidator"/>
+ <validator id="ModuleBase_ResultPointValidator"/>
</feature_or_attribute_selector>
<feature_or_attribute_selector id="ConstraintEntityB" label="Last point" tooltip="Select an point in the viewer">
- <validator id="ModuleBase_ResulPointValidator"/>
+ <validator id="ModuleBase_ResultPointValidator"/>
</feature_or_attribute_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
<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">
- <validator id="ModuleBase_ResulLineValidator"/>
+ <validator id="ModuleBase_ResultLineValidator"/>
</feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
<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">
- <validator id="ModuleBase_ResulArcValidator"/>
+ <validator id="ModuleBase_ResultArcValidator"/>
</feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue"/>
<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">
- <validator id="ModuleBase_ResulLineValidator"/>
+ <validator id="ModuleBase_ResultLineValidator"/>
</feature_selector>
<feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
- <validator id="ModuleBase_ResulLineValidator"/>
+ <validator id="ModuleBase_ResultLineValidator"/>
</feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<validator id="PartSet_ParallelValidator"/>
<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">
- <validator id="ModuleBase_ResulLineValidator"/>
+ <validator id="ModuleBase_ResultLineValidator"/>
</feature_selector>
<feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
- <validator id="ModuleBase_ResulLineValidator"/>
+ <validator id="ModuleBase_ResultLineValidator"/>
</feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<validator id="PartSet_PerpendicularValidator"/>
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);
+ aFactory->registerValidator("ModuleBase_ResultPointValidator", new ModuleBase_ResultPointValidator);
+ aFactory->registerValidator("ModuleBase_ResultLineValidator", new ModuleBase_ResultLineValidator);
+ aFactory->registerValidator("ModuleBase_ResultArcValidator", new ModuleBase_ResultArcValidator);
}