From 1b8d9a406c6989ed8c12f927b0df520f64a9ee76 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 1 Dec 2014 13:22:38 +0300 Subject: [PATCH] Provide editing of dimensions --- src/ModuleBase/ModuleBase_IPropertyPanel.h | 5 +++ src/PartSet/PartSet_Module.cpp | 37 ++++++++++++++++++++++ src/XGUI/XGUI_PropertyPanel.h | 3 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.h b/src/ModuleBase/ModuleBase_IPropertyPanel.h index b0114eb0b..00ff516b8 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.h +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.h @@ -46,6 +46,11 @@ public slots: /// Activate the next from current widget in the property panel virtual void activateNextWidget() = 0; + + // Makes the given widget active, highlights it and removes + // highlighting from the previous active widget + // emits widgetActivated(theWidget) signal + virtual void activateWidget(ModuleBase_ModelWidget* theWidget) = 0; }; #endif \ No newline at end of file diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index a63aecd79..ba997dcd3 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -214,9 +214,11 @@ void PartSet_Module::onPlaneSelected(const std::shared_ptr& thePln) void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation) { + // Restart last operation type if ((theOperation->id() == myLastOperationId) && myLastFeature) { ModuleBase_ModelWidget* aWgt = theOperation->propertyPanel()->activeWidget(); if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) { + // Initialise new line with first point equal to end of previous PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast(aWgt); if (aPnt2dWgt) { std::shared_ptr aData = myLastFeature->data(); @@ -230,12 +232,47 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation) } } } + } else { + // Start editing constraint + if (theOperation->isEditOperation()) { + std::string aId = theOperation->id().toStdString(); + if ((aId == SketchPlugin_ConstraintRadius::ID()) || + (aId == SketchPlugin_ConstraintLength::ID()) || + (aId == SketchPlugin_ConstraintDistance::ID())) { + ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel(); + // Find and activate widget for management of point for dimension line position + QList aWidgets = aPanel->modelWidgets(); + foreach (ModuleBase_ModelWidget* aWgt, aWidgets) { + PartSet_WidgetPoint2D* aPntWgt = dynamic_cast(aWgt); + if (aPntWgt) { + aPanel->activateWidget(aPntWgt); + return; + } + } + } + } } } void PartSet_Module::onSelectionChanged() { + // Editing of constraints can be done on selection + ModuleBase_ISelection* aSelect = myWorkshop->selection(); + QList aSelected = aSelect->getSelected(); + if (aSelected.size() == 1) { + ModuleBase_ViewerPrs aPrs = aSelected.first(); + ObjectPtr aObject = aPrs.object(); + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (aFeature) { + std::string aId = aFeature->getKind(); + if ((aId == SketchPlugin_ConstraintRadius::ID()) || + (aId == SketchPlugin_ConstraintLength::ID()) || + (aId == SketchPlugin_ConstraintDistance::ID())) { + editFeature(aFeature); + } + } + } } void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 2a3f8e613..28c624618 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -56,11 +56,10 @@ Q_OBJECT // Enables / disables "ok" ("accept") button void setAcceptEnabled(bool); - protected slots: // Makes the given widget active, highlights it and removes // highlighting from the previous active widget // emits widgetActivated(theWidget) signal - void activateWidget(ModuleBase_ModelWidget* theWidget); + virtual void activateWidget(ModuleBase_ModelWidget* theWidget); signals: /// Signal about the point 2d set to the feature -- 2.39.2