static const char * EVENT_UPDATE_VIEWER_BLOCKED = "UpdateViewerBlocked";
static const char * EVENT_UPDATE_VIEWER_UNBLOCKED = "UpdateViewerUnblocked";
+static const char * EVENT_SOLVER_FAILED = "SolverFailed";
+static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired";
+
/// Message that feature was changed (used for Object Browser update): moved, updated and deleted
class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
{
Slvs_hGroup GroupIndexer::myGroupIndex = 0;
+static void sendMessage(const char* theMessageName)
+{
+ std::shared_ptr<Events_Message> aMessage = std::shared_ptr<Events_Message>(
+ new Events_Message(Events_Loop::eventByName(theMessageName)));
+ Events_Loop::loop()->send(aMessage);
+}
+
+
// ========================================================
// ========= SketchSolver_Group ===============
SketchSolver_Group::SketchSolver_Group(
std::shared_ptr<ModelAPI_CompositeFeature> theWorkplane)
- : myID(GroupIndexer::NEW_GROUP())
+ : myID(GroupIndexer::NEW_GROUP()),
+ myPrevSolved(true)
{
// Initialize workplane
myWorkplaneID = SLVS_E_UNKNOWN;
}
} catch (...) {
Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
+ if (myPrevSolved) {
+ sendMessage(EVENT_SOLVER_FAILED);
+ myPrevSolved = false;
+ }
return false;
}
if (aResult == SLVS_RESULT_OKAY) { // solution succeeded, store results into correspondent attributes
for (; aConstrIter != myConstraints.end(); aConstrIter++)
aConstrIter->second->refresh();
myFeatureStorage->blockEvents(false);
- } else if (!myConstraints.empty())
+ if (!myPrevSolved) {
+ sendMessage(EVENT_SOLVER_REPAIRED);
+ myPrevSolved = true;
+ }
+ } else if (!myConstraints.empty()) {
Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this);
+ if (myPrevSolved) {
+ sendMessage(EVENT_SOLVER_FAILED);
+ myPrevSolved = false;
+ }
+ }
aResolved = true;
}