#include "PartSet_OverconstraintListener.h"
#include <PartSet_Module.h>
#include <PartSet_SketcherMgr.h>
+#include <PartSet_SketcherReentrantMgr.h>
#include "XGUI_ModuleConnector.h"
#include "XGUI_Workshop.h"
//#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
-: myWorkshop(theWorkshop), myIsFullyConstrained(false), myIsNeedUpdateCustomColor(false)
+: myWorkshop(theWorkshop), myIsFullyConstrained(false)//, myIsNeedUpdateCustomColor(false)
{
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_UNDER_CONSTRAINED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED));
+
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
}
void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject,
myIsFullyConstrained = anEventID == Events_Loop::eventByName(EVENT_SKETCH_FULLY_CONSTRAINED);
if (aPrevFullyConstrained != myIsFullyConstrained) {
- myIsNeedUpdateCustomColor = true;
+ //myIsNeedUpdateCustomColor = true;
std::set<ObjectPtr> aModifiedObjects;
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
- for (int i = 0; i < aSketch->numberOfSubs(); i++) {
- FeaturePtr aFeature = aSketch->subFeature(i);
- aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
- std::list<ResultPtr> aResults = aFeature->results();
- for (std::list<ResultPtr>::const_iterator aIt = aResults.begin();
- aIt != aResults.end(); ++aIt) {
- aModifiedObjects.insert(*aIt);
+ if (aSketch.get()) {
+ for (int i = 0; i < aSketch->numberOfSubs(); i++) {
+ FeaturePtr aFeature = aSketch->subFeature(i);
+ aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
+ std::list<ResultPtr> aResults = aFeature->results();
+ for (std::list<ResultPtr>::const_iterator aIt = aResults.begin();
+ aIt != aResults.end(); ++aIt) {
+ aModifiedObjects.insert(*aIt);
+ }
}
+ redisplayObjects(aModifiedObjects);
}
- redisplayObjects(aModifiedObjects);
- myIsNeedUpdateCustomColor = false;
+ //myIsNeedUpdateCustomColor = false;
+ }
+ }
+ else if (anEventID == Events_Loop::eventByName(EVENT_OBJECT_CREATED)) {
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ PartSet_SketcherReentrantMgr* aReentrantMgr = aModule->sketchReentranceMgr();
+ if (aReentrantMgr->isInternalEditActive()) {
+ std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
+ std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
+ std::set<ObjectPtr> anObjects = aUpdMsg->objects();
+ aReentrantMgr->appendCreatedObjects(anObjects);
}
}
-
#ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
aCurrentInfoStr = getObjectsInfo(myConflictingObjects);
qDebug(QString("RESULT: current objects count = %1:%2\n")