#include <ModuleBase_WidgetValueFeature.h>
#include <ModuleBase_WidgetValue.h>
#include <ModuleBase_ResultValidators.h>
+#include <ModuleBase_Tools.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
return isDone;
}
-bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject)
+bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSendEvent)
{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
if (!isValid)
return false;
- myObject = theObject;
+ myObject = ModuleBase_Tools::feature(theObject);
myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
- emit valuesChanged();
+ if (theSendEvent)
+ emit valuesChanged();
return true;
}
/// Fill the widget values by given point
/// \param thePoint the point
/// \return the boolean result of the feature set
- bool setObject(const ObjectPtr& theObject);
+ bool setObject(const ObjectPtr& theObject, bool theSendEvent = true);
/// Returns current widget feature
/// \return the feature
/// \return the list of kinds
const QStringList& featureKinds() const { return myObjectKinds; }
-private:
ObjectPtr myObject; ///< the current widget feature
QStringList myObjectKinds; ///< the kinds of possible features
boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
ObjectPtr aObject = aFeatureValue->object();
if (aObject) {
- isDone = setObject(aObject);
+ isDone = setObject(aObject, false);
}
if (aValuePoint) {
FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
aFPoint = aCurPoint;
}
if (aFPoint)
- isDone = setAttribute(aFPoint);
+ isDone = setAttribute(aFPoint, false);
}
}
+ if (isDone)
+ emit valuesChanged();
}
}
return isDone;
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()));
- ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this;
- if (object())
- aRef->setObject(object());
+ if (myObject)
+ aRef->setObject(myObject);
if (myAttribute)
aRef->setAttr(myAttribute);
FeaturePtr aFeature = ModuleBase_Tools::feature(aRef->object());
if (aFeature) {
- setObject(aFeature);
+ myObject = aFeature;
myAttribute = aRef->attr();
std::string aText = "";
return false;
}
-bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute)
+bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(
+ const boost::shared_ptr<ModelAPI_Attribute>& theAttribute,
+ bool theSendEvent)
{
if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str()))
return false;
myAttribute = theAttribute;
editor()->setText(theAttribute ? theAttribute->attributeType().c_str() : "");
- emit valuesChanged();
+ if (theSendEvent)
+ emit valuesChanged();
return true;
}
/// Set the attribute
/// \param theAttribute value
/// \return the boolean result of the attribute set
- bool setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute);
+ bool setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute,
+ bool theSendEvent = true);
protected:
boost::shared_ptr<ModelAPI_Attribute> myAttribute; /// < the attribute