From: nds Date: Thu, 18 Feb 2016 06:07:30 +0000 (+0300) Subject: 1. myIsInitialized should have "false" by default. Validators check it to enable... X-Git-Tag: V_2.2.0~104 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba08b49c900003e00c5fdb67d80d1a9bb8134358;p=modules%2Fshaper.git 1. myIsInitialized should have "false" by default. Validators check it to enable "Apply". [the problem was in sketch while moving over planes] 2. do not stop contour creation by selection auxiliary edge 3. tool tip for "Apply", "Cancel", "Help" --- diff --git a/src/GeomData/GeomData_Point.cpp b/src/GeomData/GeomData_Point.cpp index d034dd656..f6becd98d 100644 --- a/src/GeomData/GeomData_Point.cpp +++ b/src/GeomData/GeomData_Point.cpp @@ -15,9 +15,9 @@ #include -GeomData_Point::GeomData_Point(TDF_Label& theLabel) +GeomData_Point::GeomData_Point() { - myIsInitialized = true; + myIsInitialized = false; } void GeomData_Point::setCalculatedValue(const double theX, const double theY, const double theZ) diff --git a/src/GeomData/GeomData_Point.h b/src/GeomData/GeomData_Point.h index 56d9c042b..3c08a706f 100644 --- a/src/GeomData/GeomData_Point.h +++ b/src/GeomData/GeomData_Point.h @@ -73,7 +73,7 @@ class GeomData_Point : public GeomDataAPI_Point protected: /// Initializes attributes - GEOMDATA_EXPORT GeomData_Point(TDF_Label& theLabel); + GEOMDATA_EXPORT GeomData_Point(); friend class Model_Data; }; diff --git a/src/GeomData/GeomData_Point2D.cpp b/src/GeomData/GeomData_Point2D.cpp index 0eca72f8c..fb7bdc99f 100644 --- a/src/GeomData/GeomData_Point2D.cpp +++ b/src/GeomData/GeomData_Point2D.cpp @@ -15,9 +15,9 @@ #include -GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel) +GeomData_Point2D::GeomData_Point2D() { - myIsInitialized = true; + myIsInitialized = false; } void GeomData_Point2D::setCalculatedValue(const double theX, const double theY) diff --git a/src/GeomData/GeomData_Point2D.h b/src/GeomData/GeomData_Point2D.h index 8b4affa03..d73b20207 100644 --- a/src/GeomData/GeomData_Point2D.h +++ b/src/GeomData/GeomData_Point2D.h @@ -68,7 +68,7 @@ class GeomData_Point2D : public GeomDataAPI_Point2D protected: /// Initializes attributes - GEOMDATA_EXPORT GeomData_Point2D(TDF_Label& theLabel); + GEOMDATA_EXPORT GeomData_Point2D(); friend class Model_Data; }; diff --git a/src/Model/Model_AttributeDouble.cpp b/src/Model/Model_AttributeDouble.cpp index 0a8566d11..05a256841 100644 --- a/src/Model/Model_AttributeDouble.cpp +++ b/src/Model/Model_AttributeDouble.cpp @@ -11,9 +11,9 @@ #include #include -Model_AttributeDouble::Model_AttributeDouble(TDF_Label& theLabel) +Model_AttributeDouble::Model_AttributeDouble() { - myIsInitialized = true; + myIsInitialized = false; } void Model_AttributeDouble::setCalculatedValue(const double theValue) diff --git a/src/Model/Model_AttributeDouble.h b/src/Model/Model_AttributeDouble.h index da9ca4b55..abf394aa6 100644 --- a/src/Model/Model_AttributeDouble.h +++ b/src/Model/Model_AttributeDouble.h @@ -59,7 +59,7 @@ class Model_AttributeDouble : public ModelAPI_AttributeDouble protected: /// Initializes attributes - Model_AttributeDouble(TDF_Label& theLabel); + Model_AttributeDouble(); friend class Model_Data; }; diff --git a/src/Model/Model_AttributeInteger.cpp b/src/Model/Model_AttributeInteger.cpp index bd355d4d8..38ce002c5 100644 --- a/src/Model/Model_AttributeInteger.cpp +++ b/src/Model/Model_AttributeInteger.cpp @@ -11,9 +11,9 @@ #include #include -Model_AttributeInteger::Model_AttributeInteger(TDF_Label& theLabel) +Model_AttributeInteger::Model_AttributeInteger() { - myIsInitialized = true; + myIsInitialized = false; } void Model_AttributeInteger::setCalculatedValue(const int theValue) diff --git a/src/Model/Model_AttributeInteger.h b/src/Model/Model_AttributeInteger.h index bd6a12da3..870db2990 100644 --- a/src/Model/Model_AttributeInteger.h +++ b/src/Model/Model_AttributeInteger.h @@ -57,7 +57,7 @@ class Model_AttributeInteger : public ModelAPI_AttributeInteger protected: /// Initializes attributes - Model_AttributeInteger(TDF_Label& theLabel); + Model_AttributeInteger(); friend class Model_Data; diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 530293b7e..3d16c14bb 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -121,17 +121,17 @@ AttributePtr Model_Data::addAttribute(const std::string& theID, const std::strin if (theAttrType == ModelAPI_AttributeDocRef::typeId()) { anAttr = new Model_AttributeDocRef(anAttrLab); } else if (theAttrType == Model_AttributeInteger::typeId()) { - Model_AttributeInteger* anAttribute = new Model_AttributeInteger(anAttrLab); + Model_AttributeInteger* anAttribute = new Model_AttributeInteger(); // Expression should use the same label to support backward compatibility TDF_Label anExpressionLab = anAttrLab; anAttribute->myExpression.reset(new Model_ExpressionInteger(anExpressionLab)); - anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression->isInitialized(); + anAttribute->myIsInitialized = anAttribute->myExpression->isInitialized(); anAttr = anAttribute; } else if (theAttrType == ModelAPI_AttributeDouble::typeId()) { - Model_AttributeDouble* anAttribute = new Model_AttributeDouble(anAttrLab); + Model_AttributeDouble* anAttribute = new Model_AttributeDouble(); TDF_Label anExpressionLab = anAttrLab.FindChild(1); anAttribute->myExpression.reset(new Model_ExpressionDouble(anExpressionLab)); - anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression->isInitialized(); + anAttribute->myIsInitialized = anAttribute->myExpression->isInitialized(); anAttr = anAttribute; } else if (theAttrType == Model_AttributeBoolean::typeId()) { anAttr = new Model_AttributeBoolean(anAttrLab); @@ -154,22 +154,26 @@ AttributePtr Model_Data::addAttribute(const std::string& theID, const std::strin } // create also GeomData attributes here because only here the OCAF structure is known else if (theAttrType == GeomData_Point::typeId()) { - GeomData_Point* anAttribute = new GeomData_Point(anAttrLab); + GeomData_Point* anAttribute = new GeomData_Point(); + bool anAllInitialized = true; for (int aComponent = 0; aComponent < GeomData_Point::NUM_COMPONENTS; ++aComponent) { TDF_Label anExpressionLab = anAttrLab.FindChild(aComponent + 1); anAttribute->myExpression[aComponent].reset(new Model_ExpressionDouble(anExpressionLab)); - anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression[aComponent]->isInitialized(); + anAllInitialized = anAllInitialized && anAttribute->myExpression[aComponent]->isInitialized(); } + anAttribute->myIsInitialized = anAllInitialized; anAttr = anAttribute; } else if (theAttrType == GeomData_Dir::typeId()) { anAttr = new GeomData_Dir(anAttrLab); } else if (theAttrType == GeomData_Point2D::typeId()) { - GeomData_Point2D* anAttribute = new GeomData_Point2D(anAttrLab); + GeomData_Point2D* anAttribute = new GeomData_Point2D(); + bool anAllInitialized = true; for (int aComponent = 0; aComponent < GeomData_Point2D::NUM_COMPONENTS; ++aComponent) { TDF_Label anExpressionLab = anAttrLab.FindChild(aComponent + 1); anAttribute->myExpression[aComponent].reset(new Model_ExpressionDouble(anExpressionLab)); - anAttribute->myIsInitialized = anAttribute->myIsInitialized && anAttribute->myExpression[aComponent]->isInitialized(); + anAllInitialized = anAllInitialized && anAttribute->myExpression[aComponent]->isInitialized(); } + anAttribute->myIsInitialized = anAllInitialized; anAttr = anAttribute; } if (anAttr) { diff --git a/src/Model/Model_Expression.cpp b/src/Model/Model_Expression.cpp index ef7408e36..c7ad95c81 100644 --- a/src/Model/Model_Expression.cpp +++ b/src/Model/Model_Expression.cpp @@ -20,23 +20,15 @@ static Standard_GUID kInvalidGUID("caee5ce4-34b1-4b29-abcb-685287d18096"); Model_Expression::Model_Expression(TDF_Label& theLabel) { - myIsInitialized = true; if (!theLabel.FindAttribute(TDataStd_Name::GetID(), myText)) { myText = TDataStd_Name::Set(theLabel, TCollection_ExtendedString()); -// myIsInitialized = false; } if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), myError)) { myError = TDataStd_Comment::Set(theLabel, TCollection_ExtendedString()); -// myIsInitialized = false; } if (!theLabel.FindAttribute(TDataStd_ExtStringList::GetID(), myUsedParameters)) { myUsedParameters = TDataStd_ExtStringList::Set(theLabel); -// myIsInitialized = false; } - // All this attributes should not set myIsInitialized = false. - // This attributes are optional and may absent in old files. So this is OK. - // The reason to set myIsInitialized = false is only absence of - // the value attribute. } void Model_Expression::setText(const std::string& theValue) @@ -106,7 +98,8 @@ Model_ExpressionDouble::Model_ExpressionDouble(TDF_Label& theLabel) } } } - } + } else + myIsInitialized = true; } void Model_ExpressionDouble::setValue(const double theValue) @@ -141,7 +134,8 @@ Model_ExpressionInteger::Model_ExpressionInteger(TDF_Label& theLabel) if (!theLabel.FindAttribute(TDataStd_Integer::GetID(), myInteger)) { myInteger = TDataStd_Integer::Set(theLabel, 0); myIsInitialized = false; - } + } else + myIsInitialized = true; } void Model_ExpressionInteger::setValue(const int theValue) diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 5793a383d..8cfec7f7d 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -429,6 +430,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous // do not set a coincidence constraint in the attribute if the feature contains a point // with the same coordinates. It is important for line creation in order to do not set // the same constraints for the same points, oterwise the result line has zero length. + bool isAuxiliaryFeature = false; if (getPoint2d(aView, aShape, aX, aY)) { setPoint(aX, aY); PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY); @@ -437,6 +439,13 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str())) { setConstraintWith(aObject); setValueState(Stored); // in case of edge selection, Apply state should also be updated + + FeaturePtr anObjectFeature = ModelAPI_Feature::feature(aObject); + std::string anAuxiliaryAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID(); + AttributeBooleanPtr anAuxiliaryAttr = std::dynamic_pointer_cast( + anObjectFeature->data()->attribute(anAuxiliaryAttribute)); + if (anAuxiliaryAttr.get()) + isAuxiliaryFeature = anAuxiliaryAttr->value(); } } // it is important to perform updateObject() in order to the current value is @@ -446,7 +455,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous // points of the line becomes less than the tolerance. Validator of the line returns // false, the line will be aborted, but sketch stays valid. updateObject(feature()); - if (!anOrphanPoint && !anExternal) + if (!anOrphanPoint && !anExternal && !isAuxiliaryFeature) emit vertexSelected(); emit focusOutWidget(this); } diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index c16332fd2..2468786c4 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -228,20 +228,25 @@ QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId, QOb } else { switch (theId) { case Accept: - case AcceptAll: + case AcceptAll: { aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent); - break; + aResult->setToolTip("Apply"); + } + break; case Abort: case AbortAll: { aResult = new QAction(QIcon(":pictures/button_cancel.png"), "", theParent); - if(theId == Abort) { + aResult->setToolTip("Cancel"); + if (theId == Abort) { aResult->setShortcut(QKeySequence(Qt::Key_Escape)); } } break; - case Help: + case Help: { aResult = new QAction(QIcon(":pictures/button_help.png"), "", theParent); - break; + aResult->setToolTip("Help"); + } + break; default: break; } diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index 9e379850c..e360e9971 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -39,7 +39,13 @@ XGUI_ErrorMgr::XGUI_ErrorMgr(QObject* theParent, ModuleBase_IWorkshop* theWorksh myErrorLabel(0), myWorkshop(theWorkshop) { + ModuleBase_ModelWidget* anActiveWidget = activeWidget(); + XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); + QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL); + myAcceptAllToolTip = anAcceptAllAction->toolTip(); + QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + myAcceptToolTip = anOkAction->toolTip(); } XGUI_ErrorMgr::~XGUI_ErrorMgr() @@ -88,7 +94,7 @@ void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature) QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL); bool anEnabled = anError.isEmpty(); anAcceptAllAction->setEnabled(anEnabled); - anAcceptAllAction->setToolTip(anError); + anAcceptAllAction->setToolTip(!anEnabled ? anError : myAcceptAllToolTip); } } @@ -110,6 +116,7 @@ void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theErro bool anEnabled = theError.isEmpty(); theAction->setEnabled(anEnabled); + theAction->setToolTip(anEnabled ? myAcceptToolTip : theError); // some operations have no property panel, so it is important to check that it is not null if (myPropertyPanel) { // update controls error information diff --git a/src/XGUI/XGUI_ErrorMgr.h b/src/XGUI/XGUI_ErrorMgr.h index 03d057c5b..23012267b 100644 --- a/src/XGUI/XGUI_ErrorMgr.h +++ b/src/XGUI/XGUI_ErrorMgr.h @@ -74,6 +74,8 @@ private: ModuleBase_IWorkshop* myWorkshop; /// workshop QDialog* myErrorDialog; /// contains the error message QLabel* myErrorLabel; /// contains an error information + QString myAcceptToolTip; /// cached tool tip value for enabled Accept action + QString myAcceptAllToolTip; /// cached tool tip value for enabled AcceptAll action }; #endif // XGUI_ErrorMgr_H \ No newline at end of file