From: nds Date: Mon, 23 Jun 2014 16:11:13 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~266^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b6098dd8167affb46d7a3ef309b052de473fcb0e;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc Undoes the modification of the isEdit state of operation using. The default value of the feature is set after the operation is started Edit for a second line creation. This is not edit operation, but the property widget value should not be applyed to the line. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 089b1e637..dbac446a1 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -9,7 +9,7 @@ #include ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData) - : QObject(theParent) + : QObject(theParent), myHasDefaultValue(false) { myAttributeID = theData ? theData->widgetId() : ""; } @@ -36,3 +36,8 @@ std::string ModuleBase_ModelWidget::attributeID() const { return myAttributeID; } + +void ModuleBase_ModelWidget::setHasDefaultValue(const bool& theHasDefaultValue) +{ + myHasDefaultValue = theHasDefaultValue; +} diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 286d16f06..0f2cd543f 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -54,6 +54,10 @@ public: /// \return a control list virtual QList getControls() const = 0; + /// Returns whether the control has a default value + /// \return a boolean value + bool hasDefaultValue() const { return myHasDefaultValue; } + signals: /// The signal about widget values changed void valuesChanged(); @@ -67,7 +71,12 @@ protected: /// \returns the string value std::string attributeID() const; + /// Sets the has default value state to the widget + /// \param theHasDefaultValue the boolean value + void setHasDefaultValue(const bool& theHasDefaultValue); + private: + bool myHasDefaultValue; /// the boolean state whether the control has a default value std::string myAttributeID; /// the attribute name of the model feature }; diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 4b7e3c78c..64fb18e77 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -123,6 +123,6 @@ void ModuleBase_Operation::setFeature(FeaturePtr theFeature) void ModuleBase_Operation::setEditingFeature(FeaturePtr theFeature) { - myFeature = theFeature; + setFeature(theFeature); myIsEditing = true; } diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 6e5830bd7..37fd95892 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -96,6 +96,7 @@ protected: /// \returns the created feature virtual FeaturePtr createFeature(const bool theFlushMessage = true); +private: /// Sets the operation feature void setFeature(FeaturePtr theFeature); diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index b17b98f11..aac859c49 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -67,6 +67,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, c aProp = theData->getProperty(DOUBLE_WDG_DFLT); double aDefVal = QString::fromStdString(aProp).toDouble(&isOk); + setHasDefaultValue(isOk); if (isOk) { mySpinBox->setValue(aDefVal); } diff --git a/src/PartSet/PartSet_OperationEditConstraint.cpp b/src/PartSet/PartSet_OperationEditConstraint.cpp index 0c3fae216..82732d954 100644 --- a/src/PartSet/PartSet_OperationEditConstraint.cpp +++ b/src/PartSet/PartSet_OperationEditConstraint.cpp @@ -69,7 +69,7 @@ void PartSet_OperationEditConstraint::init(FeaturePtr theFeature, const std::list& theSelected, const std::list& theHighlighted) { - setFeature(theFeature); + setEditingFeature(theFeature); myFeaturePrs->init(theFeature); /* @@ -196,7 +196,7 @@ void PartSet_OperationEditConstraint::mouseDoubleClick(QMouseEvent* theEvent, Ha void PartSet_OperationEditConstraint::startOperation() { - // do nothing in order to do not create a new feature + PartSet_OperationSketchBase::startOperation(); emit multiSelectionEnabled(false); //if (myFeatures.size() > 1) diff --git a/src/PartSet/PartSet_OperationEditFeature.cpp b/src/PartSet/PartSet_OperationEditFeature.cpp index e0d52827d..5f53b1812 100644 --- a/src/PartSet/PartSet_OperationEditFeature.cpp +++ b/src/PartSet/PartSet_OperationEditFeature.cpp @@ -57,7 +57,7 @@ void PartSet_OperationEditFeature::init(FeaturePtr theFeature, const std::list& theSelected, const std::list& theHighlighted) { - setFeature(theFeature); + setEditingFeature(theFeature); if (!theHighlighted.empty()) { // if there is highlighted object, we check whether it is in the list of selected objects @@ -171,7 +171,7 @@ void PartSet_OperationEditFeature::mouseReleased(QMouseEvent* theEvent, Handle(V void PartSet_OperationEditFeature::startOperation() { - // do nothing in order to do not create a new feature + PartSet_OperationSketchBase::startOperation(); emit multiSelectionEnabled(false); if (myFeatures.size() > 1) diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 2da18786e..dcce1c5fb 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -62,7 +62,8 @@ void PartSet_OperationSketch::init(FeaturePtr theFeature, const std::list& /*theSelected*/, const std::list& /*theHighlighted*/) { - setFeature(theFeature); + if (theFeature) + setEditingFeature(theFeature); } FeaturePtr PartSet_OperationSketch::sketch() const @@ -167,10 +168,9 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const void PartSet_OperationSketch::startOperation() { - if (!feature()) { - setFeature(createFeature()); + PartSet_OperationSketchBase::startOperation(); + if (!isEditOperation()) emit fitAllView(); - } } bool PartSet_OperationSketch::hasSketchPlane() const diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 00446f23b..81f91c8ce 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -324,7 +324,7 @@ void XGUI_Workshop::onOperationStarted() aWidget = *anIt; QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue())); // Init default values - if (!aOperation->isEditOperation()) { + if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) { aWidget->storeValue(aOperation->feature()); } }