From 7ffe38811ecbbe6c270f2153c1825fe9c510d69f Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 21 Jul 2014 11:15:22 +0400 Subject: [PATCH] Relaunch operation on end of previous sketch operation --- src/PartSet/PartSet_Module.cpp | 17 +++++++++++------ src/PartSet/PartSet_Module.h | 2 +- src/XGUI/XGUI_DocumentDataModel.cpp | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a5c40e7e8..ad4d26324 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -293,10 +293,15 @@ void PartSet_Module::onFitAllView() myWorkshop->viewer()->fitAll(); } -void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeature) +void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theFeature) { + FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); + if (!aFeature) { + qDebug("Warning! Restart operation without feature!"); + return; + } ModuleBase_Operation* anOperation = createOperation(theName.c_str(), - theFeature ? theFeature->getKind() : ""); + theFeature ? aFeature->getKind() : ""); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { @@ -304,10 +309,10 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur // Initialise operation with preliminary selection std::list aSelected = aSelection->getSelected(); std::list aHighlighted = aSelection->getHighlighted(); - aPreviewOp->initFeature(theFeature); + aPreviewOp->initFeature(aFeature); aPreviewOp->initSelection(aSelected, aHighlighted); } else { - anOperation->setEditingFeature(theFeature); + anOperation->setEditingFeature(aFeature); } sendOperation(anOperation); myWorkshop->actionsMgr()->updateCheckState(); @@ -435,8 +440,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI if (aPreviewOp) { connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)), this, SLOT(onFeatureConstructed(FeaturePtr, int))); - connect(aPreviewOp, SIGNAL(launchOperation(std::string, FeaturePtr)), - this, SLOT(onLaunchOperation(std::string, FeaturePtr))); + connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), + this, SLOT(onLaunchOperation(std::string, ObjectPtr))); connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, SLOT(onMultiSelectionEnabled(bool))); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index d95a75ebe..49a41a9ec 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -113,7 +113,7 @@ public slots: /// SLOT, to fit all current viewer void onFitAllView(); - void onLaunchOperation(std::string theName, FeaturePtr theFeature); + void onLaunchOperation(std::string theName, ObjectPtr theFeature); /// SLOT, to switch on/off the multi selection in the viewer /// \param theEnabled the enabled state diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 7b4db2366..43fe782d1 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -72,6 +72,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } else { // Update top groups (other except parts QModelIndex aIndex = myModel->findParent(aObject); int aStart = myModel->rowCount(aIndex) - 1; + if (aStart < 0) aStart = 0; aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); insertRow(aStart, aIndex); } -- 2.39.2