#include <ModelAPI_Data.h>
#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Events.h>
#include "Config_WidgetAPI.h"
+#include <Events_Loop.h>
+
#include <QWidget>
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent,
}
return true;
}
+
+
+void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
+{
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
+}
/// \returns the string value
void setAttributeID(const std::string& theAttribute) { myAttributeID = theAttribute; }
+ void updateObject(ObjectPtr theObj) const;
+
bool myHasDefaultValue; /// the boolean state whether the control has a default value
private:
if (aBool->value() != myCheckBox->isChecked()) {
aBool->setValue(myCheckBox->isChecked());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ updateObject(theObject);
}
return true;
}
AttributeDoublePtr aReal = aData->real(attributeID());
if (aReal->value() != mySpinBox->value()) {
aReal->setValue(mySpinBox->value());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ updateObject(theObject);
}
return true;
}
return false;
}
}
- // TODO
- //if (!myObjectKinds.contains(theObject->getKind().c_str()))
- // return false;
myObject = theObject;
myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
aRef->setObject(myObject);
aFeature->execute();
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-
+ updateObject(theObject);
return true;
}
aRef->setAttr(myAttribute);
theFeature->execute();
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ updateObject(theFeature);
return true;
}
ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
aPoint->setValue(myXSpin->value(), myYSpin->value());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ updateObject(theObject);
that->blockSignals(isBlocked);
return true;
ObjectPtr aObject = aRef->value();
if (!(aObject && aObject->isSame(mySelectedObject))) {
aRef->setValue(mySelectedObject);
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ updateObject(theObject);
}
return true;
}
activateFeature(aObject, false);
}
}
- //ObjectPtr aResults;
- //foreach(ObjectPtr aFeature, theFeatures) {
-/* TODO if (aFeature->results().size() > 0) {
- const std::list<ResultPtr>& aResList = aFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt)
- aResults.append(*aIt);
- }
- }*/
aDisplayer->stopSelection(theFeatures, isStop, false);
XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
#include <SketchPlugin_Sketch.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefAttr.h>
+
+#include <GeomAPI_IPresentable.h>
+
#include <list>
* \brief Feature for creation of a new constraint between other features.
* Base class for all constraints.
*/
-class SketchPlugin_Constraint: public SketchPlugin_Feature
+class SketchPlugin_Constraint: public SketchPlugin_Feature,
+ public GeomAPI_IPresentable
{
public:
/// The value parameter for the constraint
#include "SketchPlugin_Constraint.h"
#include "SketchPlugin_Sketch.h"
-#include <GeomAPI_IPresentable.h>
#include <list>
/** \class SketchPlugin_ConstraintDistance
* These constraint has three attributes:
* SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
*/
-class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint,
- public GeomAPI_IPresentable
+class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
{
public:
/// Distance constraint kind
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!anAttr)
return thePrevious;
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
+ FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr->object());
if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
return thePrevious;
if (!anAttr1 || !anAttr1->isObject() ||
!anAttr2 || !anAttr2->isObject())
return thePrevious;
+
+ FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+ if (!aFeature)
+ return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
+ aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+ if (!aFeature)
+ return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
if (!aLine1Feature || !aLine2Feature)
return thePrevious;
if (!anAttr1 || !anAttr1->isObject() ||
!anAttr2 || !anAttr2->isObject())
return thePrevious;
+
+ FeaturePtr aFeature = SketchPlugin_Sketch::getFeature(anAttr1->object());
+ if (!aFeature)
+ return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr1->object());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
+ aFeature = SketchPlugin_Sketch::getFeature(anAttr2->object());
+ if (!aFeature)
+ return thePrevious;
boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(anAttr2->object());
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+
if (!aLine1Feature || !aLine2Feature)
return thePrevious;
if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId))
break;
}
- Q_ASSERT(aId < aNb);
- return index(aId + historyOffset(), 0, QModelIndex());
+ if (aId < aNb)
+ return index(aId + historyOffset(), 0, QModelIndex());
} else {
QModelIndex aIndex = myModel->objectIndex(theObject);
return aIndex.isValid()?