From 9c96ae3c42b79c0dff7a5426b26ee347309a767f Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 5 Nov 2015 08:46:50 +0300 Subject: [PATCH] Creation of GUI widgets for the re-entrant internal feature. They are hidden and used only for preselection for the started operation. --- src/ModuleBase/ModuleBase_IPropertyPanel.cpp | 9 +++- src/ModuleBase/ModuleBase_IPropertyPanel.h | 5 ++ src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 51 ++++++++++++++----- src/PartSet/PartSet_SketcherReetntrantMgr.h | 2 + 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.cpp b/src/ModuleBase/ModuleBase_IPropertyPanel.cpp index a3644773e..0a87a74c8 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.cpp +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.cpp @@ -16,13 +16,18 @@ ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent) : QDock } ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget() +{ + return ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(modelWidgets()); +} + +ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget( + const QList& theWidgets) { ModuleBase_ModelWidget* aFirstWidget = 0; - QList aWidgets = modelWidgets(); ModuleBase_ModelWidget* aWgt; QList::const_iterator aWIt; - for (aWIt = aWidgets.begin(); aWIt != aWidgets.end() && !aFirstWidget; ++aWIt) { + for (aWIt = theWidgets.begin(); aWIt != theWidgets.end() && !aFirstWidget; ++aWIt) { aWgt = (*aWIt); if (aWgt->canSetValue()) aFirstWidget = aWgt; diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.h b/src/ModuleBase/ModuleBase_IPropertyPanel.h index ea5a6edf6..afafce7a7 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.h +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.h @@ -68,6 +68,11 @@ public: /// \return a widget or null ModuleBase_ModelWidget* findFirstAcceptingValueWidget(); + /// Returns the first widget, where canSetValue returns true + /// \return a widget or null + static ModuleBase_ModelWidget* findFirstAcceptingValueWidget( + const QList& theWidgets); + signals: /// The signal about key release on the control, that corresponds to the attribute /// \param theEvent key release event diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index a74187148..3834a98d8 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -12,6 +12,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -19,6 +23,7 @@ #include #include #include +#include PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop) : QObject(theWorkshop), @@ -43,12 +48,8 @@ ModuleBase_ModelWidget* PartSet_SketcherReetntrantMgr::internalActiveWidget() co if (aOperation) { ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget(); - if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector())) { - // finds the first widget which can accept a value - ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget(); - if (aFirstWidget) - aWidget = aFirstWidget; - } + if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector())) + aWidget = myInternalActiveWidget; } return aWidget; } @@ -276,6 +277,27 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch(); myInternalFeature = aSketch->addFeature(anOperationFeature->getKind()); + XGUI_PropertyPanel* aPropertyPanel = dynamic_cast + (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 aWidgets = aFactory.getModelWidgets(); + + foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { + aWidget->setFeature(myInternalFeature, true); + } + ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget + (aWidgets); + if (aFirstWidget) + myInternalActiveWidget = aFirstWidget; myIsInternalEditOperation = true; isDone = true; @@ -314,18 +336,19 @@ void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit() disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped())); } + if (myInternalActiveWidget) { + ModuleBase_WidgetSelector* aWSelector = dynamic_cast(myInternalActiveWidget); + if (aWSelector) + aWSelector->activateSelectionAndFilters(false); + myInternalActiveWidget = 0; + } + delete myInternalWidget; + myInternalWidget = 0; + QObjectPtrList anObjects; anObjects.append(myInternalFeature); workshop()->deleteFeatures(anObjects); - PartSet_Module* aModule = module(); - ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget(); - ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel(); - if (aFirstWidget != aPanel->activeWidget()) { - ModuleBase_WidgetSelector* aWSelector = dynamic_cast(aFirstWidget); - if (aWSelector) - aWSelector->activateSelectionAndFilters(false); - } } void PartSet_SketcherReetntrantMgr::restartOperation() diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.h b/src/PartSet/PartSet_SketcherReetntrantMgr.h index 1f8d2e5fd..8853e10dc 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.h +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.h @@ -147,6 +147,8 @@ private: bool myIsInternalEditOperation; /// true when the 'internal' edit is started FeaturePtr myInternalFeature; + QWidget* myInternalWidget; + ModuleBase_ModelWidget* myInternalActiveWidget; }; #endif -- 2.39.2