#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")
return !isActiveMgr() || myRestartingMode == RM_None;
}
-bool PartSet_SketcherReentrantMgr::isInternalEditStarted() const
+void PartSet_SketcherReentrantMgr::appendCreatedObjects(const std::set<ObjectPtr>& theObjects)
{
- return myIsInternalEditOperation;
+ if (!myIsFlagsBlocked) // we need to collect objects only when launch operation is called
+ return;
+
+ for (std::set<ObjectPtr>::const_iterator anIt = theObjects.begin();
+ anIt != theObjects.end(); ++anIt) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+ if (myCreatedFeatures.find(aFeature) != myCreatedFeatures.end())
+ myCreatedFeatures.insert(aFeature);
+ }
}
bool PartSet_SketcherReentrantMgr::isActiveMgr() const
myIsInternalEditOperation = false;
updateAcceptAllAction();
myRestartingMode = RM_None;
+ myCreatedFeatures.clear();
}
}
/// Returns false if the reentrant mode of the operation is not empty.
bool canBeCommittedByPreselection();
- /// returns true if an internal edit operation is started
- /// \return boolean value
- bool isInternalEditStarted() const;
+ /// Put information about created objects into a cash. It will be processed in
+ /// restart operation.
+ /// \param theObjects a list of created objects
+ void appendCreatedObjects(const std::set<ObjectPtr>& theObjects);
private slots:
/// SLOT, that is called by a widget activating in the property panel
bool myIsValueChangedBlocked; /// blocked flag to avoid circling by value changed
FeaturePtr myPreviousFeature; /// feature of the previous operation, which is restarted
+ std::set<FeaturePtr> myCreatedFeatures; /// list of created features by restart operation
FeaturePtr myInternalFeature;
QWidget* myInternalWidget;
ModuleBase_ModelWidget* myInternalActiveWidget;