Scenario: start circle, click, click->internal edition mode[before a new create operation it should be the same current feature which was when the create of the circle is started]
2. Control by debug information setting current feature performed before starting/commit the operation.
if (isEditOperation())
return;
- myIsEditing = true;
if (theRestartTransaction) {
- FeaturePtr aPrevFeature = myPreviousCurrentFeature;
-
+ // finsh previous create operation
+ emit beforeCommitted();
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_Session::get()->finishOperation();
+ // start new edit operation
+ myIsEditing = true;
QString anId = getDescription()->operationId();
if (myIsEditing) {
anId = anId.append(EditSuffix());
}
ModelAPI_Session::get()->startOperation(anId.toStdString());
emit beforeStarted();
-
- myPreviousCurrentFeature = aPrevFeature;
}
+ else
+ myIsEditing = true;
propertyPanel()->setEditingMode(isEditOperation());
}
if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
aFOperation->setEditOperation(true);
- FeaturePtr anOperationFeature = aFOperation->feature();
-
- CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
- myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
- XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
- (aFOperation->propertyPanel());
- myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
- myInternalWidget->setVisible(false);
-
- ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
-
- QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
- ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
-
- aFactory.createWidget(anInternalPage);
- QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
-
- foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
- aWidget->setFeature(myInternalFeature, true);
- }
- ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
- (aWidgets);
- if (aFirstWidget)
- myInternalActiveWidget = aFirstWidget;
+ createInternalFeature();
myIsInternalEditOperation = true;
isDone = true;
disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
}
- if (myInternalActiveWidget) {
- ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
- if (aWSelector)
- aWSelector->activateSelectionAndFilters(false);
- myInternalActiveWidget = 0;
- }
- delete myInternalWidget;
- myInternalWidget = 0;
-
- QObjectPtrList anObjects;
- anObjects.append(myInternalFeature);
- workshop()->deleteFeatures(anObjects);
-
+ deleteInternalFeature();
}
void PartSet_SketcherReetntrantMgr::restartOperation()
}
}
+void PartSet_SketcherReetntrantMgr::createInternalFeature()
+{
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (myWorkshop->currentOperation());
+
+ if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
+ aFOperation->setEditOperation(true);
+ FeaturePtr anOperationFeature = aFOperation->feature();
+
+ CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
+ myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
+ XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
+ (aFOperation->propertyPanel());
+
+ myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
+ myInternalWidget->setVisible(false);
+
+ ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
+
+ QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
+
+ aFactory.createWidget(anInternalPage);
+ QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+
+ foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+ aWidget->setFeature(myInternalFeature, true);
+ }
+ ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
+ (aWidgets);
+ if (aFirstWidget)
+ myInternalActiveWidget = aFirstWidget;
+ }
+}
+
+void PartSet_SketcherReetntrantMgr::deleteInternalFeature()
+{
+ if (myInternalActiveWidget) {
+ ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
+ if (aWSelector)
+ aWSelector->activateSelectionAndFilters(false);
+ myInternalActiveWidget = 0;
+ }
+ delete myInternalWidget;
+ myInternalWidget = 0;
+
+ QObjectPtrList anObjects;
+ anObjects.append(myInternalFeature);
+ workshop()->deleteFeatures(anObjects);
+}
+
void PartSet_SketcherReetntrantMgr::resetFlags()
{
if (!myIsFlagsBlocked) {
/// Commits the current operation and launches a new with the commited operation feature index
void restartOperation();
+ /// Creates an internal feature and controls to process it
+ void createInternalFeature();
+
+ /// A pair method for an internal creation to remove it and clear all created controls
+ void deleteInternalFeature();
+
/// Breaks sequense of automatically resterted operations
void resetFlags();
#include <ModuleBase_IViewer.h>
#include "ModuleBase_OperationDescription.h"
#include "ModuleBase_OperationFeature.h"
+#include "ModuleBase_Tools.h"
#include "ModelAPI_CompositeFeature.h"
#include "ModelAPI_Session.h"
#include <QApplication>
#include <QKeyEvent>
+//#define DEBUG_CURRENT_FEATURE
+
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
ModuleBase_IWorkshop* theWorkshop)
: QObject(theParent), myIsApplyEnabled(false), myWorkshop(theWorkshop)
// 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.
aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false));
+
+#ifdef DEBUG_CURRENT_FEATURE
+ FeaturePtr aFeature = aFOperation->feature();
+ QString aKind = aFeature ? aFeature->getKind().c_str() : "";
+ qDebug(QString("onBeforeOperationStarted(), edit operation = %1, feature = %2")
+ .arg(aFOperation->isEditOperation())
+ .arg(ModuleBase_Tools::objectInfo(aFeature)).toStdString().c_str());
+
+ qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+ ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
+
if (aFOperation->isEditOperation()) // it should be performed by the feature edit only
// in create operation, the current feature is changed by addFeature()
aDoc->setCurrentFeature(aFOperation->feature(), false);
+
+#ifdef DEBUG_CURRENT_FEATURE
+ qDebug("\tdocument->setCurrentFeature");
+ qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+ ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
}
}
/// Restore the previous current feature
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
if (aFOperation) {
+#ifdef DEBUG_CURRENT_FEATURE
+ QString aKind = aFOperation->feature()->getKind().c_str();
+ qDebug(QString("onBeforeOperationCommitted(), edit operation = %1, feature = %2")
+ .arg(aFOperation->isEditOperation())
+ .arg(ModuleBase_Tools::objectInfo(aFOperation->feature())).toStdString().c_str());
+
+ qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+ ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
+
if (aFOperation->isEditOperation()) {
/// Restore the previous current feature
setCurrentFeature(aFOperation->previousCurrentFeature());
if (myOperations.front() != aFOperation)
setCurrentFeature(aFOperation->previousCurrentFeature());
}
+#ifdef DEBUG_CURRENT_FEATURE
+ qDebug("\tdocument->setCurrentFeature");
+ qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+ ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
}
}