return true;
}
-
void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
{
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
}
+void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) const
+{
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
+ ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
+ Events_Loop::loop()->flush(anEvent);
+}
+
bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
{
QWidget* aWidget = qobject_cast<QWidget*>(theObject);
}
void updateObject(ObjectPtr theObj) const;
+ void moveObject(ObjectPtr theObj) const;
protected:
std::string myAttributeID; /// the attribute name of the model feature
ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
}
}
+ // after movement the solver will call the update event: optimization
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
}
myDragDone = true;
myCurX = aX;
double _Y = myYSpin->value();
#endif
aPoint->setValue(myXSpin->value(), myYSpin->value());
- updateObject(myFeature);
+ // after movement the solver will call the update event: optimization
+ moveObject(myFeature);
aPoint->setImmutable(isImmutable);
that->blockSignals(isBlocked);
}
// Solve the set of constraints
- resolveConstraints();
+ resolveConstraints(isMovedEvt); // send update for movement in any case
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
// Class: SketchSolver_Session
// Purpose: change entities according to available constraints
// ============================================================================
-void SketchSolver_ConstraintManager::resolveConstraints()
+void SketchSolver_ConstraintManager::resolveConstraints(const bool theForceUpdate)
{
myIsComputed = true;
bool needToUpdate = false;
if ((*aGroupIter)->resolveConstraints())
needToUpdate = true;
- // Features may be updated => now send events, btu for all changed at once
+ // Features may be updated => now send events, but for all changed at once
if (isUpdateFlushed) {
Events_Loop::loop()->setFlushed(anUpdateEvent, true);
}
- if (needToUpdate)
- Events_Loop::loop()->flush(anUpdateEvent);
+ // Must be before flush because on "Updated" flush the results may be produced
+ // and the creation event is appeared with many new objects. If myIsComputed these
+ // events are missed in processEvents and some elements are not added.
myIsComputed = false;
+ if (needToUpdate || theForceUpdate)
+ Events_Loop::loop()->flush(anUpdateEvent);
}
void updateEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
/** \brief Goes through the list of groups and solve the constraints
+ * \param theForceUpdate flushes the update event in any case: something changed or not
*/
- void resolveConstraints();
+ void resolveConstraints(const bool theForceUpdate);
private:
/** \brief Searches list of groups which interact with specified feature