#include <ModelAPI_Object.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Pnt2d.h>
return aValid && isDone;
}
+void ModuleBase_OperationFeature::startOperation()
+{
+ FeaturePtr aFeature = feature();
+ if (!aFeature.get() || !isEditOperation())
+ return;
+
+ myVisualizedObjects.clear();
+ // store hidden result features
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ ObjectPtr anObject = *aIt;
+ if (anObject.get() && !anObject->isDisplayed()) {
+ myVisualizedObjects.insert(*aIt);
+ anObject->setDisplayed(true);
+ }
+ }
+ if (!aFeature->isDisplayed()) {
+ myVisualizedObjects.insert(aFeature);
+ aFeature->setDisplayed(true);
+ }
+ Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+}
+
+void ModuleBase_OperationFeature::stopOperation()
+{
+ FeaturePtr aFeature = feature();
+ if (!aFeature.get() || !isEditOperation())
+ return;
+
+ // store hidden result features
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ ObjectPtr anObject = *aIt;
+ if (anObject.get() && myVisualizedObjects.find(anObject) != myVisualizedObjects.end()) {
+ anObject->setDisplayed(false);
+ }
+ }
+ if (myVisualizedObjects.find(aFeature) != myVisualizedObjects.end()) {
+ aFeature->setDisplayed(false);
+ }
+ aFeature->setStable(true);
+ if (myVisualizedObjects.size() > 0)
+ Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+}
+
+void ModuleBase_OperationFeature::resumeOperation()
+{
+ ModuleBase_Operation::resumeOperation();
+ //if (!myIsEditing)
+ setCurrentFeature(feature());
+ //SessionPtr aMgr = ModelAPI_Session::get();
+ //DocumentPtr aDoc = aMgr->activeDocument();
+ //aDoc->setCurrentFeature(feature(), false);
+}
+
FeaturePtr ModuleBase_OperationFeature::createFeature(const bool theFlushMessage)
{
if (myParentFeature.get()) {
void ModuleBase_OperationFeature::setFeature(FeaturePtr theFeature)
{
myFeature = theFeature;
+ myFeature->setStable(false);
myIsEditing = true;
}
return false;
}
+bool ModuleBase_OperationFeature::isDisplayedOnStart(ObjectPtr theObject)
+{
+ return myVisualizedObjects.find(theObject) != myVisualizedObjects.end();
+}
+
void ModuleBase_OperationFeature::start()
{
setIsModified(false);
if (myIsEditing) {
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aDoc = aMgr->activeDocument();
- myCurrentFeature = aDoc->currentFeature(true);
+ // the parameter of current feature should be false, we should use all feature, not only visible
+ // in order to correctly save the previous feature of the nested operation, where the
+ // features can be not visible in the tree. The problem case is Edit sketch entitity(line)
+ // in the Sketch, created in ExtrusionCut operation. The entity disappears by commit.
+ // When sketch entity operation started, the sketch should be cashed here as the current.
+ // Otherwise(the flag is true), the ExtrusionCut is cashed, when commit happens, the sketch
+ // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch.
+ // As a result the sketch disappears from the viewer. However after commit it is displayed back.
+ myPreviousCurrentFeature = aDoc->currentFeature(false);
aDoc->setCurrentFeature(feature(), false);
}
bool aIsOp = aMgr->isOperation();
if (!aIsOp)
aMgr->startOperation();
- aDoc->setCurrentFeature(myCurrentFeature, true);
+ aDoc->setCurrentFeature(myPreviousCurrentFeature, false);//true);
if (!aIsOp)
aMgr->finishOperation();
- myCurrentFeature = FeaturePtr();
+ myPreviousCurrentFeature = FeaturePtr();
}
abortOperation();
stopOperation();
- // is is necessary to deactivate current widgets before the model operation is aborted
- // because abort removes the feature and activated filters should not check it
- propertyPanel()->cleanContent();
aMgr->abortOperation();
emit stopped();
SessionPtr aMgr = ModelAPI_Session::get();
/// Set current feature and remeber old current feature
+
if (myIsEditing) {
- DocumentPtr aDoc = aMgr->activeDocument();
+ setCurrentFeature(myPreviousCurrentFeature);
+ /*DocumentPtr aDoc = aMgr->activeDocument();
bool aIsOp = aMgr->isOperation();
if (!aIsOp)
aMgr->startOperation();
- aDoc->setCurrentFeature(myCurrentFeature, true);
+ aDoc->setCurrentFeature(myPreviousCurrentFeature, true);
if (!aIsOp)
- aMgr->finishOperation();
- myCurrentFeature = FeaturePtr();
+ aMgr->finishOperation();*/
+ myPreviousCurrentFeature = FeaturePtr();
+ }
+ else {
+ /*CompositeFeaturePtr aCompositeFeature = ModelAPI_Tools::compositeOwner(feature());
+ if (aCompositeFeature.get())
+ setCurrentFeature(aCompositeFeature);//myPreviousCurrentFeature);
+ //else
+ // setCurrentFeature(feature());*/
}
commitOperation();
aMgr->finishOperation();
return false;
}
+void ModuleBase_OperationFeature::setCurrentFeature(const FeaturePtr& theFeature)
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->activeDocument();
+ bool aIsOp = aMgr->isOperation();
+ if (!aIsOp)
+ aMgr->startOperation();
+ aDoc->setCurrentFeature(theFeature, false);//true);
+ if (!aIsOp)
+ aMgr->finishOperation();
+}
+
void ModuleBase_OperationFeature::activateByPreselection()
{
if (myPreSelection.empty())
// 4. activate the first obligatory widget
theProp->activateNextWidget(NULL);
}
-}
-
-bool ModuleBase_OperationFeature::isGranted(QString theId) const
-{
- return myNestedFeatures.contains(theId);
+ else {
+ // set focus on Ok button in order to operation manager could process Enter press
+ if (theProp)
+ theProp->setFocusOnOkButton();
+ }
}