Salome HOME
#2205 Ability to customize the arrows and texts of dimensions: GUI correction to...
authornds <nds@opencascade.com>
Thu, 5 Oct 2017 06:53:03 +0000 (09:53 +0300)
committernds <nds@opencascade.com>
Thu, 5 Oct 2017 06:53:03 +0000 (09:53 +0300)
src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketcherPrs/SketcherPrs_Angle.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h

index 74e8b12aa335a3b3e39fa68fb910bdc9ca7f8086..1bc6987e13ca85abce3a4453421d18871d0226da 100644 (file)
@@ -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());
     }
index 581990dcf061e3b64587c08e604f2e5b3a2a01e7..5f36a0872b89739ee9b13bbe9dfe7da691049ed7 100644 (file)
@@ -564,8 +564,6 @@ std::shared_ptr<ModelHighAPI_Interface> 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<ModelHighAPI_Interface> 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<ModelHighAPI_Interface> 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<ModelHighAPI_Interface> SketchAPI_Sketch::setDistance(
 {
   std::shared_ptr<ModelAPI_Feature> 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<ModelHighAPI_Interface> SketchAPI_Sketch::setHorizontalDistance(
 {
   std::shared_ptr<ModelAPI_Feature> 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<ModelHighAPI_Interface> SketchAPI_Sketch::setVerticalDistance(
 {
   std::shared_ptr<ModelAPI_Feature> 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<ModelHighAPI_Interface> SketchAPI_Sketch::setLength(
 {
   std::shared_ptr<ModelAPI_Feature> 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<ModelHighAPI_Interface> SketchAPI_Sketch::setRadius(
 {
   std::shared_ptr<ModelAPI_Feature> 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();
index 5deea42e4b6da201c7fc842c586e6aa924fd905d..9521f1db16133c227038ec3b31774bb5de21e722 100644 (file)
@@ -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<ModelAPI_AttributeInteger>
+  AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
     (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);
 
index 898771342b3de09febe969382823f3307263257d..7472d956b1a723cc55d3ee5563be78d8ada2cfd3 100644 (file)
@@ -181,10 +181,11 @@ void SketcherPrs_LengthDimension::Compute(
   else if (aConstraintKind == SketchPlugin_ConstraintDistanceVertical::ID())
     aLocationAttribute = SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID();
 
-  std::shared_ptr<ModelAPI_AttributeInteger> 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<ModelAPI_AttributeInteger>
+    (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);
index 8e557e32b9c62d10d0afb3fc1604c272dfaa9a9b..3381d5d63a81921dcb339e33a31362801fcd7b7f 100644 (file)
@@ -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<ModelAPI_AttributeInteger>
+
+  AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
     (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);
 
index abb8d3e283795dacf2d0f9501a78cba3560edd76..ad655723d54f603c55fcd010b18861dbacce117d 100644 (file)
@@ -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;
+}
index 81b414fbbfecee4c5ecf0b6ea4457dda48736aab..2c5eb00757834767951a87d088953bf8d9d00217 100755 (executable)
@@ -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<ModuleBase_Operation*> Operations;  ///< definition for a list of operations
   Operations myOperations;  ///< a stack of started operations. The active operation is on top,