/// Returns whether the shape is an edge
virtual bool isEdge() const;
+
};
#endif
Model_ResultBody.h
Model_ResultConstruction.h
Model_ResultPart.h
+ Model_ResultValidators.h
)
SET(PROJECT_SOURCES
Model_ResultBody.cpp
Model_ResultConstruction.cpp
Model_ResultPart.cpp
+ Model_ResultValidators.cpp
)
SET(PROJECT_LIBRARIES
--- /dev/null
+// File: Model_ResultValidators.cpp
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "Model_ResultValidators.h"
+
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Tools.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 = ModelAPI_Tools::shape(theResult);
+ if (aShape)
+ return aShape->impl<TopoDS_Shape>();
+ return TopoDS_Shape();
+}
+
+
+bool Model_ResultPointValidator::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 Model_ResultLineValidator::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 Model_ResultArcValidator::isValid(const ObjectPtr theObject) const
+{
+ ResultPtr aResult = result(theObject);
+ if (!aResult)
+ return false;
+ TopoDS_Shape aShape = shape(aResult);
+ if (aShape.IsNull())
+ return false;
+
+ TopAbs_ShapeEnum aa = aShape.ShapeType();
+ 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: Model_ResultValidators.h
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef Model_ResultValidators_H
+#define Model_ResultValidators_H
+
+#include "Model.h"
+#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_Object.h>
+
+class Model_ResultPointValidator: public ModelAPI_ResultValidator
+{
+public:
+ MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class Model_ResultLineValidator: public ModelAPI_ResultValidator
+{
+public:
+ MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+class Model_ResultArcValidator: public ModelAPI_ResultValidator
+{
+public:
+ MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const;
+};
+
+#endif
\ No newline at end of file
// Author: Mikhail PONIKAROV
#include <Model_Validator.h>
+#include <Model_ResultValidators.h>
#include <ModelAPI_Feature.h>
#include <Events_Error.h>
Model_ValidatorsFactory::Model_ValidatorsFactory() : ModelAPI_ValidatorsFactory()
{
+ registerValidator("Model_ResultPointValidator", new Model_ResultPointValidator);
+ registerValidator("Model_ResultLineValidator", new Model_ResultLineValidator);
+ registerValidator("Model_ResultArcValidator", new Model_ResultArcValidator);
}
+
+
+const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string& theID) const
+{
+ std::map<std::string, ModelAPI_Validator*>::const_iterator aIt = myIDs.find(theID);
+ if (aIt != myIDs.end()) {
+ return aIt->second;
+ }
+ return NULL;
+}
\ No newline at end of file
std::list<ModelAPI_Validator*>& theValidators,
std::list<std::list<std::string> >& theArguments) const;
+ /// Returns registered validator by its Id
+ virtual const ModelAPI_Validator* validator(const std::string& theID) const;
+
/// Returns the result of "validate" method for attribute of validator.
/// If validator is not exists, returns true: everything is valid by default.
//MODEL_EXPORT virtual bool validate(
ModelAPI_ResultConstruction.h
ModelAPI_ResultPart.h
ModelAPI_ResultParameters.h
+ ModelAPI_ResultValidator.h
+ ModelAPI_AttributeValidator.h
+ ModelAPI_Tools.h
)
SET(PROJECT_SOURCES
ModelAPI_Feature.cpp
ModelAPI_PluginManager.cpp
+ ModelAPI_Tools.cpp
)
SET(PROJECT_LIBRARIES
--- /dev/null
+// File: ModelAPI_AttributeValidator.h
+// Created: 5 Aug 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef ModelAPI_AttributeValidator_H
+#define ModelAPI_AttributeValidator_H
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Validator.h>
+
+
+class ModelAPI_AttributeValidator: public ModelAPI_Validator
+{
+public:
+ virtual bool isValid(const FeaturePtr& theFeature,
+ const std::list<std::string>& theArguments,
+ const ObjectPtr& theObject) const = 0;
+};
+
+#endif
#include "ModelAPI_Feature.h"
#include <ModelAPI_Events.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_Document.h>
#include <Events_Loop.h>
const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results()
ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
}
}
+
+FeaturePtr ModelAPI_Feature::feature(ObjectPtr theObject)
+{
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (!aFeature) {
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult) {
+ DocumentPtr aDoc = aResult->document();
+ return aDoc->feature(aResult);
+ }
+ }
+ return aFeature;
+}
/// To virtually destroy the fields of successors
MODELAPI_EXPORT virtual ~ModelAPI_Feature();
+
+ MODELAPI_EXPORT static boost::shared_ptr<ModelAPI_Feature> feature(ObjectPtr theObject);
+
};
//! Pointer on feature object
--- /dev/null
+// File: ModelAPI_ResultValidators.h
+// Created: 23 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef ModelAPI_ResultValidators_H
+#define ModelAPI_ResultValidators_H
+
+#include "ModelAPI_Validator.h"
+#include "ModelAPI_Object.h"
+
+class ModelAPI_ResultValidator: public ModelAPI_Validator
+{
+public:
+ virtual bool isValid(const ObjectPtr theObject) const = 0;
+};
+
+
+#endif
\ No newline at end of file
--- /dev/null
+// File: ModelAPI_Tools.cpp
+// Created: 06 Aug 2014
+// Author: Vitaly Smetannikov
+
+#include "ModelAPI_Tools.h"
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+
+
+namespace ModelAPI_Tools {
+
+boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult)
+{
+ ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+ if (aBody) return aBody->shape();
+ ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
+ if (aConstruct) return aConstruct->shape();
+ return boost::shared_ptr<GeomAPI_Shape>();
+}
+
+}
\ No newline at end of file
--- /dev/null
+// File: ModelAPI_Tools.h
+// Created: 06 Aug 2014
+// Author: Vitaly Smetannikov
+
+#ifndef ModelAPI_Tools_HeaderFile
+#define ModelAPI_Tools_HeaderFile
+
+#include "ModelAPI.h"
+#include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
+
+namespace ModelAPI_Tools
+{
+ /// Returns shape from the given Result object
+ MODELAPI_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
+};
+
+#endif
\ No newline at end of file
std::list<ModelAPI_Validator*>& theValidators,
std::list<std::list<std::string> >& theArguments) const = 0;
+ /// Returns registered validator by its Id
+ virtual const ModelAPI_Validator* validator(const std::string& theID) 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_SelectionValidator.h
ModuleBase_ISelection.h
ModuleBase_ViewerPrs.h
- ModuleBase_Tools.h
- ModuleBase_ResultValidators.h
- ModuleBase_FeatureValidator.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetPoint2dDistance.cpp
ModuleBase_WidgetValue.cpp
ModuleBase_WidgetValueFeature.cpp
- ModuleBase_Tools.cpp
- ModuleBase_ResultValidators.cpp
)
SET(PROJECT_LIBRARIES
+++ /dev/null
-// File: ModuleBase_FeatureValidator.h
-// Created: 8 Jul 2014
-// Author: Vitaly SMETANNIKOV
-
-#ifndef ModuleBase_FeatureValidator_H
-#define ModuleBase_FeatureValidator_H
-
-#include "ModuleBase.h"
-
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Validator.h>
-
-
-class ModuleBase_FeatureValidator: public ModelAPI_Validator
-{
-public:
- virtual bool isValid(const FeaturePtr theFeature) const = 0;
-};
-
-#endif
#include <boost/shared_ptr.hpp>
class Config_WidgetAPI;
-class ModelAPI_Feature;
class ModuleBase_WidgetValue;
class QKeyEvent;
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
- virtual bool storeValue(ObjectPtr theObject) const = 0;
+ virtual bool storeValue() const = 0;
- virtual bool restoreValue(ObjectPtr theObject) = 0;
+ virtual bool restoreValue() = 0;
/// Set focus to the first control of the current widget. The focus policy of the control is checked.
/// If the widget has the NonFocus focus policy, it is skipped.
/// \returns the string value
std::string parentID() const { return myParentId; }
+ FeaturePtr feature() const { return myFeature;}
+ void setFeature(const FeaturePtr& theFeature) { myFeature = theFeature; }
+
signals:
/// The signal about widget values changed
void valuesChanged();
bool myHasDefaultValue; /// the boolean state whether the control has a default value
-private:
+
std::string myAttributeID; /// the attribute name of the model feature
std::string myParentId; /// name of parent
+ FeaturePtr myFeature;
};
#endif
#include "ModuleBase_OperationDescription.h"
#include "ModuleBase_ModelWidget.h"
-#include "ModuleBase_FeatureValidator.h"
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Document.h>
ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
if (aCustom)
- aCustom->storeValue(myFeature);
+ aCustom->storeValue();
}
void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
bool ModuleBase_Operation::canBeCommitted() const
{
if (ModuleBase_IOperation::canBeCommitted()) {
- FeaturePtr aFeature = feature();
+/* FeaturePtr aFeature = feature();
std::string aId = aFeature->getKind();
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
if (!aFValidator->isValid(aFeature))
return false;
}
- }
+ }*/
return true;
}
return false;
{
//******************************************************************
-boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult)
-{
- ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
- if (aBody) return aBody->shape();
- ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
- if (aConstruct) return aConstruct->shape();
- return boost::shared_ptr<GeomAPI_Shape>();
-}
//******************************************************************
-FeaturePtr feature(ObjectPtr theObject)
-{
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
- if (!aFeature) {
- ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult) {
- DocumentPtr aDoc = aResult->document();
- return aDoc->feature(aResult);
- }
- }
- return aFeature;
-}
-
}
return myCheckBox;
}
-bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetBoolValue::storeValue() const
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
if (aBool->value() != myCheckBox->isChecked()) {
aBool->setValue(myCheckBox->isChecked());
- updateObject(theObject);
+ updateObject(myFeature);
}
return true;
}
-bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetBoolValue::restoreValue()
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
bool isBlocked = myCheckBox->blockSignals(true);
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
- virtual bool storeValue(ObjectPtr theObject) const;
+ virtual bool storeValue() const;
- virtual bool restoreValue(ObjectPtr theObject);
+ virtual bool restoreValue();
/// Returns list of widget controls
/// \return a control list
{
}
-bool ModuleBase_WidgetDoubleValue::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetDoubleValue::storeValue() const
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
AttributeDoublePtr aReal = aData->real(attributeID());
if (aReal->value() != mySpinBox->value()) {
aReal->setValue(mySpinBox->value());
- updateObject(theObject);
+ updateObject(myFeature);
}
return true;
}
-bool ModuleBase_WidgetDoubleValue::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetDoubleValue::restoreValue()
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
AttributeDoublePtr aRef = aData->real(attributeID());
bool isBlocked = mySpinBox->blockSignals(true);
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
- virtual bool storeValue(ObjectPtr theObject) const;
+ virtual bool storeValue() const;
- virtual bool restoreValue(ObjectPtr theObject);
+ virtual bool restoreValue();
/// Returns list of widget controls
/// \return a control list
#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_WidgetValue.h>
-#include <ModuleBase_ResultValidators.h>
-#include <ModuleBase_Tools.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <Events_Loop.h>
-#include <ModelAPI_Events.h>
+#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_AttributeValidator.h>
#include <QWidget>
#include <QLineEdit>
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- //QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE));
- //myObjectKinds = aKinds.split(" ");
- //theData->
-
myContainer = new QWidget(theParent);
QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
aControlLay->setContentsMargins(0, 0, 0, 0);
std::list<ModelAPI_Validator*> aValidators;
std::list<std::list<std::string> > anArguments;
aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
+
+ // Check the type of selected object
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
bool isValid = true;
for(; aValidator != aValidators.end(); aValidator++) {
- const ModuleBase_ResultValidator* aResValidator =
- dynamic_cast<const ModuleBase_ResultValidator*>(*aValidator);
+ const ModelAPI_ResultValidator* aResValidator =
+ dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
if (aResValidator) {
isValid = false;
if (aResValidator->isValid(theObject)) {
if (!isValid)
return false;
- myObject = ModuleBase_Tools::feature(theObject);
+ // Check the acceptability of the object as attribute
+ aValidator = aValidators.begin();
+ std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+ for(; aValidator != aValidators.end(); aValidator++, aArgs++) {
+ const ModelAPI_AttributeValidator* aAttrValidator =
+ dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
+ if (aAttrValidator) {
+ if (!aAttrValidator->isValid(myFeature, *aArgs, theObject)) {
+ return false;
+ }
+ }
+ }
+
+ myObject = theObject;
myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
if (theSendEvent)
emit valuesChanged();
return true;
}
-bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetFeature::storeValue() const
{
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
- if (!aFeature)
- return false;
- boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+ //FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ //if (!aFeature)
+ // return false;
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
aRef->setObject(myObject);
- aFeature->execute();
- updateObject(theObject);
+ myFeature->execute();
+ updateObject(myFeature);
return true;
}
-bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetFeature::restoreValue()
{
- boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
+ ObjectPtr aObj = aRef->object();
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
if (aFeature) {
myObject = aFeature;
/// Saves the internal parameters to the given feature
/// \param theFeature a model feature to be changed
- virtual bool storeValue(ObjectPtr theObject) const;
+ virtual bool storeValue() const;
- virtual bool restoreValue(ObjectPtr theObject);
+ virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_WidgetValue.h>
-#include <ModuleBase_Tools.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 <GeomAPI_Pnt2d.h>
#include <GeomDataAPI_Point2D.h>
isDone = setObject(aObject, false);
}
if (aValuePoint) {
- FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
if (aFeature) {
// find the given point in the feature attributes
std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes =
return isDone;
}
-bool ModuleBase_WidgetFeatureOrAttribute::storeValue(ObjectPtr theFeature) const
+bool ModuleBase_WidgetFeatureOrAttribute::storeValue() const
{
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
- if (!aFeature)
- return false;
+ //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_Data> aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
if (myAttribute)
aRef->setAttr(myAttribute);
- aFeature->execute();
- updateObject(theFeature);
+ myFeature->execute();
+ updateObject(myFeature);
return true;
}
-bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(ObjectPtr theFeature)
+bool ModuleBase_WidgetFeatureOrAttribute::restoreValue()
{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
- FeaturePtr aFeature = ModuleBase_Tools::feature(aRef->object());
+ ObjectPtr aObj = aRef->object();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
if (aFeature) {
myObject = aFeature;
myAttribute = aRef->attr();
/// Saves the internal parameters to the given feature
/// \param theFeature a model feature to be changed
- virtual bool storeValue(ObjectPtr theFeature) const;
+ virtual bool storeValue() const;
- virtual bool restoreValue(ObjectPtr theFeature);
+ virtual bool restoreValue();
protected:
/// Set the attribute
emit valuesChanged();
}
-bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetPoint2D::storeValue() const
{
- boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
aPoint->setValue(myXSpin->value(), myYSpin->value());
- updateObject(theObject);
+ updateObject(myFeature);
that->blockSignals(isBlocked);
return true;
}
-bool ModuleBase_WidgetPoint2D::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetPoint2D::restoreValue()
{
- boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
- virtual bool storeValue(ObjectPtr theObject) const;
+ virtual bool storeValue() const;
- virtual bool restoreValue(ObjectPtr theObject);
+ virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
#include "ModuleBase_WidgetSelector.h"
#include "ModuleBase_IWorkshop.h"
-#include "ModuleBase_Tools.h"
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Tools.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
}
//********************************************************************
-bool ModuleBase_WidgetSelector::storeValue(ObjectPtr theObject) const
+bool ModuleBase_WidgetSelector::storeValue() const
{
- FeaturePtr aSelectedFeature = ModuleBase_Tools::feature(mySelectedObject);
- if (aSelectedFeature == theObject) // In order to avoid selection of the same object
+ FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject);
+ if (aSelectedFeature == myFeature) // In order to avoid selection of the same object
return false;
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeReference> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
ObjectPtr aObject = aRef->value();
if (!(aObject && aObject->isSame(mySelectedObject))) {
aRef->setValue(mySelectedObject);
- updateObject(theObject);
+ updateObject(myFeature);
}
return true;
}
//********************************************************************
-bool ModuleBase_WidgetSelector::restoreValue(ObjectPtr theObject)
+bool ModuleBase_WidgetSelector::restoreValue()
{
- DataPtr aData = theObject->data();
+ DataPtr aData = myFeature->data();
boost::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(attributeID());
bool isBlocked = this->blockSignals(true);
bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const
{
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theResult);
- boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+ boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (!aShapePtr) return false;
TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
if (aShape.IsNull()) return false;
/// Saves the internal parameters to the given feature
/// \param theObject a model feature to be changed
- virtual bool storeValue(ObjectPtr theObject) const;
+ virtual bool storeValue() const;
- virtual bool restoreValue(ObjectPtr theObject);
+ virtual bool restoreValue();
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_Operation.h>
-#include <ModuleBase_Tools.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
{
- FeaturePtr aFeature = ModuleBase_Tools::feature(theObject);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
if (!aFeature) {
qDebug("Warning! Restart operation without feature!");
return;
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Tools.h>
#include <ModelAPI_Events.h>
#include <SketchPlugin_Feature.h>
#include <GeomDataAPI_Point2D.h>
+
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
-
#include <ModelAPI_Events.h>
#include <Events_Loop.h>
if (!aObject && !theSelected.empty()) // changed for a constrain
aObject = theSelected.front().object();
- FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
if (!aFeature || aFeature != feature()) {
if (commit()) {
emit featureConstructed(feature(), FM_Deactivation);
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_Tools.h>
#include <ModelAPI_Events.h>
bool isSelected = false;
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
for (; anIt != aLast && !isSelected; anIt++) {
- isSelected = ModuleBase_Tools::feature((*anIt).object()) == feature();
+ isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature();
}
if (!isSelected)
myFeatures = theHighlighted;
ObjectPtr aObject = (*anIt).object();
if (!aObject || aObject == feature())
continue;
- FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
if (aFeature) {
aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
if (aSketchFeature)
/// Saves the internal parameters to the given feature
/// \param theFeature a model feature to be changed
- virtual bool storeValue(ObjectPtr theFeature) const { return true;}
+ virtual bool storeValue() const { return true;}
- virtual bool restoreValue(ObjectPtr theFeature) { return true;}
+ virtual bool restoreValue() { return true;}
/// Returns list of widget controls
/// \return a control list
../GeomAPI
../GeomAlgoAPI
../GeomDataAPI
- ../ModuleBase
)
INSTALL(TARGETS SketchPlugin DESTINATION plugins)
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
-/// Obtain the point object from specified constraint parameter
-static boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(
- DataPtr theData,
- const std::string& theAttribute);
-
-static boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute);
-
-static boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine,
- const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-
SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
{
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
if (anAttr)
- aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+ aFeature = ModelAPI_Feature::feature(anAttr->object());
if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID())
aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
if (anAttr) {
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
if (aFeature && aFeature->getKind() == SketchPlugin_Line::ID()) {
aLine = boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
}
#include "SketchPlugin.h"
#include "SketchPlugin_Constraint.h"
#include "SketchPlugin_Sketch.h"
+#include "ModelAPI_Data.h"
#include <list>
+class SketchPlugin_Line;
+class GeomDataAPI_Point2D;
+
/** \class SketchPlugin_ConstraintDistance
* \ingroup DataModel
* \brief Feature for creation of a new constraint which defines a distance
SketchPlugin_ConstraintDistance();
};
+
+/// Obtain the point object from specified constraint parameter
+boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
+ const std::string& theAttribute);
+
+boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute);
+
+boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine,
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
+
+
#endif
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
if (aFeature) {
// set length value
boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!anAttr)
return thePrevious;
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
return thePrevious;
!anAttr2 || !anAttr2->isObject())
return thePrevious;
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object());
if (!aFeature)
return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
- aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+ aFeature = ModelAPI_Feature::feature(anAttr2->object());
if (!aFeature)
return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
!anAttr2 || !anAttr2->isObject())
return thePrevious;
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object());
if (!aFeature)
return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
- aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+ aFeature = ModelAPI_Feature::feature(anAttr2->object());
if (!aFeature)
return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
if (aFeature) {
double aRadius = 0;
boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!anAttr)
return thePrevious;
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
std::string aKind = aFeature ? aFeature->getKind() : "";
if (aKind != SketchPlugin_Circle::ID() && aKind != SketchPlugin_Arc::ID())
return thePrevious;
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(aRef->object());
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
if (!aFeature)
return;
std::string aCenterAttrName;
{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ aFactory->registerValidator("SketchPlugin_DistanceAttrValidator", new SketchPlugin_DistanceAttrValidator);
// register this plugin
ModelAPI_PluginManager::get()->registerPlugin(this);
}
return boost::shared_ptr<GeomAPI_AISObject>();
}
-
-FeaturePtr SketchPlugin_Sketch::getFeature(ObjectPtr theObject)
-{
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
- if (!aFeature) {
- ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult) {
- DocumentPtr aDoc = aResult->document();
- return aDoc->feature(aResult);
- }
- }
- return aFeature;
-}
\ No newline at end of file
virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
boost::shared_ptr<GeomAPI_AISObject> thePrevious);
- static FeaturePtr getFeature(ObjectPtr theObject);
-
protected:
/// Creates a plane and append it to the list
/// \param theX the X normal value
// Author: Vitaly SMETANNIKOV
#include "SketchPlugin_Validators.h"
-#include "SketchPlugin_Constraint.h"
-#include "SketchPlugin_Sketch.h"
-#include "SketchPlugin_Point.h"
-#include "SketchPlugin_Line.h"
-#include "SketchPlugin_Circle.h"
-#include "SketchPlugin_Arc.h"
+#include "SketchPlugin_ConstraintDistance.h"
#include <ModelAPI_Data.h>
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultValidator.h>
+#include <GeomDataAPI_Point2D.h>
-bool isValidType(const std::string& theType)
+bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
+ const std::list<std::string>& theArguments,
+ const ObjectPtr& theObject) const
{
- return (theType == SketchPlugin_Point::ID()) ||
- (theType == SketchPlugin_Circle::ID()) ||
- (theType == SketchPlugin_Arc::ID());
+ std::string aParamA = theArguments.front();
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
+ // If the object is not a line then it is accepted
+ const ModelAPI_ResultValidator* aLineValidator = dynamic_cast<const ModelAPI_ResultValidator*>(
+ aFactory->validator("Model_ResultLineValidator"));
+ if (!aLineValidator->isValid(theObject))
+ return true;
+
+ // If it is a line then we have to check that first attribute id not a line
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = getFeaturePoint(theFeature->data(), aParamA);
+ if (aPoint)
+ return true;
+ return false;
}
-bool SketchPlugin_DistanceFeatureValidator::isValid(const FeaturePtr theFeature) const
-{
- if (!theFeature)
- return false;
- if (!theFeature->data() || !theFeature->data()->isValid())
- return false;
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefA =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefB =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
-
- if (!aRefA || !aRefB)
- return false;
-
- return true;
-/* FeaturePtr aFetureA = SketchPlugin_Sketch::getFeature(aRefA->object());
- FeaturePtr aFetureB = SketchPlugin_Sketch::getFeature(aRefB->object());
- if (!aFetureA || !aFetureB)
- return false;
-
- std::string aTypeA = aFetureA->getKind();
- std::string aTypeB = aFetureB->getKind();
-
- if (aTypeA == SketchPlugin_Line::ID()) {
- return isValidType(aTypeB);
- } else if (aTypeB == SketchPlugin_Line::ID()) {
- return isValidType(aTypeA);
- } else
- return isValidType(aTypeA) && isValidType(aTypeB);
- return false;*/
-}
+
+
#define SketchPlugin_Validators_H
#include "SketchPlugin.h"
-#include <ModuleBase_FeatureValidator.h>
+//#include <ModuleBase_FeatureValidator.h>
+#include <ModelAPI_AttributeValidator.h>
-//! A class to validate a selection for Perpendicular constraint operation
-class SketchPlugin_DistanceFeatureValidator: public ModuleBase_FeatureValidator
+class SketchPlugin_DistanceAttrValidator: public ModelAPI_AttributeValidator
{
public:
- SKETCHPLUGIN_EXPORT virtual bool isValid(const FeaturePtr theFeature) const;
+ virtual bool isValid(const FeaturePtr& theFeature,
+ const std::list<std::string>& theArguments,
+ const ObjectPtr& theObject) const;
+
};
#endif
\ No newline at end of file
<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 object" tooltip="Select an point in the viewer">
- <validator id="ModuleBase_ResultPointValidator"/>
- <validator id="ModuleBase_ResultLineValidator"/>
+ <validator id="Model_ResultPointValidator"/>
+ <validator id="Model_ResultLineValidator"/>
</feature_or_attribute_selector>
<feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select an point in the viewer">
- <validator id="ModuleBase_ResultPointValidator"/>
- <validator id="ModuleBase_ResultLineValidator"/>
+ <validator id="Model_ResultPointValidator"/>
+ <validator id="Model_ResultLineValidator"/>
+ <validator id="SketchPlugin_DistanceAttrValidator" parameters="ConstraintEntityA"/>
</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_ResultLineValidator"/>
+ <validator id="Model_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_ResultArcValidator"/>
+ <validator id="Model_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_ResultLineValidator"/>
+ <validator id="Model_ResultLineValidator"/>
</feature_selector>
<feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
- <validator id="ModuleBase_ResultLineValidator"/>
+ <validator id="Model_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_ResultLineValidator"/>
+ <validator id="Model_ResultLineValidator"/>
</feature_selector>
<feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
- <validator id="ModuleBase_ResultLineValidator"/>
+ <validator id="Model_ResultLineValidator"/>
</feature_selector>
<point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
<validator id="PartSet_PerpendicularValidator"/>
#include "XGUI_Viewer.h"
#include "XGUI_Workshop.h"
#include "XGUI_ViewerProxy.h"
-#include "ModuleBase_Tools.h"
#include <ModelAPI_Document.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_IPresentable.h>
} else {
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult) {
- boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+ boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (aShapePtr) {
anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
anAIS->createShape(aShapePtr);
} else {
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult) {
- boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModuleBase_Tools::shape(aResult);
+ boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (aShapePtr) {
Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
if (!aAISShape.IsNull()) {
void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
{
foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
- eachWidget->restoreValue(theFeature);
+ eachWidget->setFeature(theFeature);
+ eachWidget->restoreValue();
}
// the repaint is used here to immediatelly react in GUI to the values change.
repaint();
ModuleBase_ModelWidget* aWidget;
for (; anIt != aLast; anIt++) {
aWidget = *anIt;
+ aWidget->setFeature(aOperation->feature());
//QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue()));
QObject::connect(aWidget, SIGNAL(valuesChanged()),
this, SLOT(onWidgetValuesChanged()));
// Init default values
if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
- aWidget->storeValue(aOperation->feature());
+ //aWidget->storeValue(aOperation->feature());
+
+ aWidget->storeValue();
}
}
for (; anIt != aLast; anIt++) {
ModuleBase_ModelWidget* aCustom = *anIt;
if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/ aCustom == aSenderWidget)) {
- aCustom->storeValue(aFeature);
+ //aCustom->storeValue(aFeature);
+ aCustom->storeValue();
}
}
}
{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-
- aFactory->registerValidator("ModuleBase_ResultPointValidator", new ModuleBase_ResultPointValidator);
- aFactory->registerValidator("ModuleBase_ResultLineValidator", new ModuleBase_ResultLineValidator);
- aFactory->registerValidator("ModuleBase_ResultArcValidator", new ModuleBase_ResultArcValidator);
}