From: nds Date: Thu, 5 Oct 2017 06:53:03 +0000 (+0300) Subject: #2205 Ability to customize the arrows and texts of dimensions: GUI correction to... X-Git-Tag: V_2.9.0~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=60a67b71f3adcdcc8a27d4f3042efb89bcc81a51;p=modules%2Fshaper.git #2205 Ability to customize the arrows and texts of dimensions: GUI correction to process not obligatory location type --- diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.cpp b/src/ModuleBase/ModuleBase_WidgetChoice.cpp index 74e8b12aa..1bc6987e1 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.cpp +++ b/src/ModuleBase/ModuleBase_WidgetChoice.cpp @@ -154,7 +154,13 @@ bool ModuleBase_WidgetChoice::restoreValueCustom() myCombo->blockSignals(isBlocked); } else { bool isBlocked = myButtons->blockSignals(true); - myButtons->button(aIntAttr->value())->setChecked(true); + if (aIntAttr->isInitialized()) + myButtons->button(aIntAttr->value())->setChecked(true); + else { + bool aHasDefaultValue; + int aDefaultVal = QString::fromStdString(getDefaultValue()).toInt(&aHasDefaultValue); + myButtons->button(aHasDefaultValue ? aDefaultVal : 0)->setChecked(true); + } myButtons->blockSignals(isBlocked); emit itemSelected(this, aIntAttr->value()); } diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index 581990dcf..5f36a0872 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -564,8 +564,6 @@ std::shared_ptr SketchAPI_Sketch::setAngle( compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID()); fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT, aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID())); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID())); // fill the value before llines to avoid calculation of angle value by the Angle feature fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); @@ -583,8 +581,6 @@ std::shared_ptr SketchAPI_Sketch::setAngleComplementary( compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID()); fillAttribute(SketcherPrs_Tools::ANGLE_COMPLEMENTARY, aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID())); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID())); fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); @@ -602,8 +598,6 @@ std::shared_ptr SketchAPI_Sketch::setAngleBackward( compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID()); fillAttribute(SketcherPrs_Tools::ANGLE_BACKWARD, aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID())); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID())); fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID())); fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); @@ -644,8 +638,6 @@ std::shared_ptr SketchAPI_Sketch::setDistance( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID()); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID())); fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); @@ -677,8 +669,6 @@ std::shared_ptr SketchAPI_Sketch::setHorizontalDistance( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID()); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID())); fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); @@ -693,8 +683,6 @@ std::shared_ptr SketchAPI_Sketch::setVerticalDistance( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceVertical::ID()); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID())); fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B())); fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); @@ -768,8 +756,6 @@ std::shared_ptr SketchAPI_Sketch::setLength( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID()); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID())); fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); aFeature->execute(); @@ -818,8 +804,6 @@ std::shared_ptr SketchAPI_Sketch::setRadius( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID()); - fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC, - aFeature->integer(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID())); fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A())); fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE())); aFeature->execute(); diff --git a/src/SketcherPrs/SketcherPrs_Angle.cpp b/src/SketcherPrs/SketcherPrs_Angle.cpp index 5deea42e4..9521f1db1 100644 --- a/src/SketcherPrs/SketcherPrs_Angle.cpp +++ b/src/SketcherPrs/SketcherPrs_Angle.cpp @@ -239,10 +239,11 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP double aTextSize = 0.0; GetValueString(aTextSize); - AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast + AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast (myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID())); - updateArrows(myAspect, GetValue(), aTextSize, - (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value())); + SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ? + (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC; + updateArrows(myAspect, GetValue(), aTextSize, aLocationType); AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode); diff --git a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp index 898771342..7472d956b 100644 --- a/src/SketcherPrs/SketcherPrs_LengthDimension.cpp +++ b/src/SketcherPrs/SketcherPrs_LengthDimension.cpp @@ -181,10 +181,11 @@ void SketcherPrs_LengthDimension::Compute( else if (aConstraintKind == SketchPlugin_ConstraintDistanceVertical::ID()) aLocationAttribute = SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID(); - std::shared_ptr aLocationTypeAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeInteger>(myConstraint->data()->attribute(aLocationAttribute)); - updateArrows(DimensionAspect(), GetValue(), aTextSize, - (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value())); + AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast + (myConstraint->data()->attribute(aLocationAttribute)); + SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ? + (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC; + updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType); // Update text visualization: parameter value or parameter text myStyleListener->updateDimensions(this, myValue); diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index 8e557e32b..3381d5d63 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -164,10 +164,12 @@ void SketcherPrs_Radius::Compute( // Update variable aspect parameters (depending on viewer scale) double aTextSize = 0.0; GetValueString(aTextSize); - AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast + + AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast (myConstraint->data()->attribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID())); - updateArrows(DimensionAspect(), GetValue(), aTextSize, - (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value())); + SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ? + (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC; + updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType); AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index abb8d3e28..ad655723d 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -247,11 +247,9 @@ bool XGUI_OperationMgr::abortAllOperations(const XGUI_MessageKind& theMessageKin } else if (theMessageKind == XGUI_InformationMessage) { QString aMessage = tr("Please validate all your active operations before saving."); - QMessageBox::question(qApp->activeWindow(), - tr("Validate operation"), - aMessage, - QMessageBox::Ok, - QMessageBox::Ok); + myActiveMessageBox = createInformationBox(aMessage); + myActiveMessageBox->exec(); + myActiveMessageBox = 0; aResult = false; // do not perform abort } while(aResult && hasOperation()) { @@ -331,17 +329,15 @@ bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation, if (theMessageKind == XGUI_AbortOperationMessage) { QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id()); myActiveMessageBox = createMessageBox(aMessage); - int anAnswer = myActiveMessageBox->exec() == QMessageBox::Ok; + bool aResult = myActiveMessageBox->exec() == QMessageBox::Ok; myActiveMessageBox = 0; - return anAnswer == QMessageBox::Ok; + return aResult; } else if (theMessageKind == XGUI_InformationMessage) { QString aMessage = tr("Please validate your %1 before saving.").arg(theOperation->id()); - QMessageBox::question(qApp->activeWindow(), - tr("Validate operation"), - aMessage, - QMessageBox::Ok, - QMessageBox::Ok); + myActiveMessageBox = createInformationBox(aMessage); + myActiveMessageBox->exec(); + myActiveMessageBox = 0; return false; } } @@ -852,4 +848,15 @@ QMessageBox* XGUI_OperationMgr::createMessageBox(const QString& theMessage) aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key return aMessageBox; -} \ No newline at end of file +} + +QMessageBox* XGUI_OperationMgr::createInformationBox(const QString& theMessage) +{ + QMessageBox * aMessageBox = new QMessageBox(QMessageBox::Question, + QObject::tr("Validate operation"), theMessage, QMessageBox::Ok, + qApp->activeWindow()); + aMessageBox->setDefaultButton(QMessageBox::Ok); + aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key + + return aMessageBox; +} diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 81b414fbb..2c5eb0075 100755 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -261,6 +261,12 @@ private: /// \return message box static QMessageBox* createMessageBox(const QString& theMessage); + /// Creates information message box with OK button, + /// Escape is Null button + /// \param theMessage text of the message + /// \return message box + static QMessageBox* createInformationBox(const QString& theMessage); + private: typedef QList Operations; ///< definition for a list of operations Operations myOperations; ///< a stack of started operations. The active operation is on top,