Salome HOME
Provide translation of DoF string
authorvsv <vsv@opencascade.com>
Thu, 3 Oct 2019 07:17:28 +0000 (10:17 +0300)
committervsv <vsv@opencascade.com>
Thu, 3 Oct 2019 07:17:28 +0000 (10:17 +0300)
src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/PartSet/PartSet_msg_fr.ts
src/SketchPlugin/SketchPlugin_msg_fr.ts
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Group.cpp

index ffa27418a89ecd78a17c7f40d3a479c34c9908a6..59fbfa96edecbb2bb0b055177e1fca6800e81ecd 100644 (file)
@@ -74,8 +74,13 @@ void PartSet_OverconstraintListener::setActive(const bool& theActive)
     PartSet_Module* aModule = module();
     CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
     if (aSketch.get()) {
-      std::string aDOFMessage = aSketch->string(SketchPlugin_Sketch::SOLVER_DOF())->value();
-      myIsFullyConstrained = QString(aDOFMessage.c_str()).contains(" = 0");
+      QString aDOFMessage(aSketch->string(SketchPlugin_Sketch::SOLVER_DOF())->value().c_str());
+      if (aDOFMessage.contains('=')) {
+        // to support old data
+        aDOFMessage =
+          aDOFMessage.right(aDOFMessage.length() - aDOFMessage.lastIndexOf('=')).trimmed();
+      }
+      myIsFullyConstrained = (aDOFMessage == "0");
     }
   }
 }
index 960429f713e9fc098117195161d2d9c49fcc738a..44e3514b7304db660a55cc327cba38fd6043541b 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeString.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_ViewerPrs.h>
@@ -180,6 +181,9 @@ myIsSelection(false)
   connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
   aLayout->addWidget(aPlaneBtn);
 
+  myDoFLabel = new QLabel("", aSecondWgt);
+  aLayout->addWidget(myDoFLabel);
+
   myStackWidget->addWidget(aSecondWgt);
   //setLayout(aLayout);
 
@@ -730,3 +734,30 @@ void PartSet_WidgetSketchLabel::setShowPointsState(bool theState)
   myShowPoints->setChecked(theState);
   myShowPoints->blockSignals(aBlock);
 }
+
+bool PartSet_WidgetSketchLabel::restoreValueCustom()
+{
+  if (myFeature.get()) {
+    CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+    if (aSketch.get() && (aSketch->numberOfSubs() > 0)) {
+      AttributeStringPtr aDOFStr = aSketch->string("SolverDOF");
+      if (aDOFStr.get()) {
+        QString aVal(aDOFStr->value().c_str());
+        if (aVal.contains('=')) {
+          // to support old data
+          aVal = aVal.right(aVal.length() - aVal.lastIndexOf('='));
+        }
+        int aDoF = aVal.toInt();
+        if (aDoF == 0) {
+          myDoFLabel->setText(tr("Sketch is fully fixed (DoF = 0)"));
+        } else {
+          myDoFLabel->setText(tr("DoF (degrees of freedom) = ") + aVal);
+        }
+      }
+    }
+    else {
+      myDoFLabel->setText("");
+    }
+  }
+  return true;
+}
index b4158194bf4f8947b666b5cf621aeb5d9f63086c..fe9c147160014b099b18171cdc48c911ffdfcd06 100644 (file)
@@ -152,10 +152,7 @@ protected:
     return true;
   }
 
-  virtual bool restoreValueCustom()
-  {
-    return true;
-  }
+  virtual bool restoreValueCustom();
 
   /// The methiod called when widget is activated
   virtual void activateCustom();
@@ -237,6 +234,8 @@ private:
   QLineEdit* mySizeOfView; ///< Value of square of size of View
   QStackedWidget* myStackWidget;
 
+  QLabel* myDoFLabel;
+
   bool myOpenTransaction;
   bool myIsSelection;
 };
index 1f7584e47a5f1f7a5a7391e6491cc4ce3eb21aed..34195fb3516a4f8415b013c5a536adcab4dec2a1 100644 (file)
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE TS>
 <TS version="2.1" language="fr_FR">
-  <context>
+<context>
     <name>PartSet_MenuMgr</name>
     <message>
-      <location filename="PartSet_MenuMgr.cpp" line="91"/>
-      <location filename="PartSet_MenuMgr.cpp" line="529"/>
-      <source>Auxiliary</source>
-      <translation>Auxiliaire</translation>
+        <location filename="PartSet_MenuMgr.cpp" line="91"/>
+        <location filename="PartSet_MenuMgr.cpp" line="529"/>
+        <source>Auxiliary</source>
+        <translation>Auxiliaire</translation>
     </message>
     <message>
-      <location filename="PartSet_MenuMgr.cpp" line="95"/>
-      <location filename="PartSet_MenuMgr.cpp" line="100"/>
-      <source>Activate</source>
-      <translation>Activer</translation>
+        <location filename="PartSet_MenuMgr.cpp" line="95"/>
+        <location filename="PartSet_MenuMgr.cpp" line="100"/>
+        <source>Activate</source>
+        <translation>Activer</translation>
     </message>
     <message>
-      <location filename="PartSet_MenuMgr.cpp" line="104"/>
-      <source>Edit...</source>
-      <translation>Modifier...</translation>
+        <location filename="PartSet_MenuMgr.cpp" line="104"/>
+        <source>Edit...</source>
+        <translation>Modifier...</translation>
     </message>
     <message>
-      <location filename="PartSet_MenuMgr.cpp" line="185"/>
-      <location filename="PartSet_MenuMgr.cpp" line="324"/>
-      <location filename="PartSet_MenuMgr.cpp" line="528"/>
-      <source>Detach</source>
-      <translation>Détacher</translation>
+        <location filename="PartSet_MenuMgr.cpp" line="185"/>
+        <location filename="PartSet_MenuMgr.cpp" line="324"/>
+        <location filename="PartSet_MenuMgr.cpp" line="528"/>
+        <source>Detach</source>
+        <translation>Détacher</translation>
     </message>
     <message>
-      <location filename="PartSet_MenuMgr.cpp" line="317"/>
-      <source>Detach %1</source>
-      <translation>Détachez %1</translation>
+        <location filename="PartSet_MenuMgr.cpp" line="317"/>
+        <source>Detach %1</source>
+        <translation>Détachez %1</translation>
     </message>
-  </context>
-  <context>
+</context>
+<context>
     <name>PartSet_WidgetPoint2D</name>
     <message>
-      <location filename="PartSet_WidgetPoint2d.cpp" line="118"/>
-      <source>X</source>
-      <translation>X</translation>
+        <location filename="PartSet_WidgetPoint2d.cpp" line="118"/>
+        <source>X</source>
+        <translation>X</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetPoint2d.cpp" line="134"/>
-      <source>Y</source>
-      <translation>Y</translation>
+        <location filename="PartSet_WidgetPoint2d.cpp" line="134"/>
+        <source>Y</source>
+        <translation>Y</translation>
     </message>
-  </context>
-  <context>
+</context>
+<context>
     <name>PartSet_WidgetSketchCreator</name>
     <message>
-      <location filename="PartSet_WidgetSketchCreator.cpp" line="91"/>
-      <source>Size of the view</source>
-      <translation>Taille de la vue</translation>
+        <location filename="PartSet_WidgetSketchCreator.cpp" line="91"/>
+        <source>Size of the view</source>
+        <translation>Taille de la vue</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchCreator.cpp" line="546"/>
-      <source>Apply current feature</source>
-      <translation>Appliquer la fonctionnalité actuelle</translation>
+        <location filename="PartSet_WidgetSketchCreator.cpp" line="546"/>
+        <source>Apply current feature</source>
+        <translation>Appliquer la fonctionnalité actuelle</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchCreator.cpp" line="547"/>
-      <source>Sketch is invalid and will be deleted.
+        <location filename="PartSet_WidgetSketchCreator.cpp" line="547"/>
+        <source>Sketch is invalid and will be deleted.
 Error: %1</source>
-      <translation>L&apos;esquisse n&apos;est pas valide et sera supprimée.
+        <translation>L&apos;esquisse n&apos;est pas valide et sera supprimée.
 Erreur : %1</translation>
     </message>
-  </context>
-  <context>
+</context>
+<context>
     <name>PartSet_WidgetSketchLabel</name>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="105"/>
-      <source>Size of the view</source>
-      <translation>Taille de la vue</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="106"/>
+        <source>Size of the view</source>
+        <translation>Taille de la vue</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="126"/>
-      <source>Remove external dependencies</source>
-      <translation>Supprimer les dépendances externes</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="127"/>
+        <source>Remove external dependencies</source>
+        <translation>Supprimer les dépendances externes</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="140"/>
-      <source>Sketcher plane</source>
-      <translation>Plan du Sketcher</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="141"/>
+        <source>Sketcher plane</source>
+        <translation>Plan du Sketcher</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="143"/>
-      <source>Reversed</source>
-      <translation>Renversé</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="144"/>
+        <source>Reversed</source>
+        <translation>Renversé</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="147"/>
-      <source>Set plane view</source>
-      <translation>Définir la vue plane</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="148"/>
+        <source>Set plane view</source>
+        <translation>Définir la vue plane</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="154"/>
-      <source>Show geometrical constraints</source>
-      <translation>Afficher les contraintes géométriques</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="155"/>
+        <source>Show geometrical constraints</source>
+        <translation>Afficher les contraintes géométriques</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="155"/>
-      <source>Show dimensional constraints</source>
-      <translation>Afficher les contraintes dimensionnelles</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="156"/>
+        <source>Show dimensional constraints</source>
+        <translation>Afficher les contraintes dimensionnelles</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="156"/>
-      <source>Show existing expressions</source>
-      <translation>Afficher les expressions existantes</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="157"/>
+        <source>Show existing expressions</source>
+        <translation>Afficher les expressions existantes</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="171"/>
-      <source>Show free points</source>
-      <translation>Afficher les points libres</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="172"/>
+        <source>Show free points</source>
+        <translation>Afficher les points libres</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="175"/>
-      <source>Automatic constraints</source>
-      <translation>Contraintes automatiques</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="176"/>
+        <source>Automatic constraints</source>
+        <translation>Contraintes automatiques</translation>
     </message>
     <message>
-      <location filename="PartSet_WidgetSketchLabel.cpp" line="179"/>
-      <source>Change sketch plane</source>
-      <translation>Changer le plan d&apos;esquisse</translation>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="180"/>
+        <source>Change sketch plane</source>
+        <translation>Changer le plan d&apos;esquisse</translation>
     </message>
-  </context>
-  <context>
+    <message>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="752"/>
+        <source>Sketch is fully fixed (DoF = 0)</source>
+        <translation>L&apos;esquisse est entièrement fixée (DdL = 0)</translation>
+    </message>
+    <message>
+        <location filename="PartSet_WidgetSketchLabel.cpp" line="754"/>
+        <source>DoF (degrees of freedom) = </source>
+        <translation>DdL (degrés de liberté) = </translation>
+    </message>
+</context>
+<context>
     <name>QObject</name>
     <message>
-      <location filename="PartSet_TreeNodes.cpp" line="402"/>
-      <source>Parameters</source>
-      <translation>Paramètres</translation>
+        <location filename="PartSet_TreeNodes.cpp" line="402"/>
+        <source>Parameters</source>
+        <translation>Paramètres</translation>
     </message>
     <message>
-      <location filename="PartSet_TreeNodes.cpp" line="404"/>
-      <source>Constructions</source>
-      <translation>Constructions</translation>
+        <location filename="PartSet_TreeNodes.cpp" line="404"/>
+        <source>Constructions</source>
+        <translation>Constructions</translation>
     </message>
     <message>
-      <location filename="PartSet_TreeNodes.cpp" line="406"/>
-      <source>Parts</source>
-      <translation>Pièces</translation>
+        <location filename="PartSet_TreeNodes.cpp" line="406"/>
+        <source>Parts</source>
+        <translation>Pièces</translation>
     </message>
     <message>
-      <location filename="PartSet_TreeNodes.cpp" line="408"/>
-      <source>Results</source>
-      <translation>Résultats</translation>
+        <location filename="PartSet_TreeNodes.cpp" line="408"/>
+        <source>Results</source>
+        <translation>Résultats</translation>
     </message>
     <message>
-      <location filename="PartSet_TreeNodes.cpp" line="410"/>
-      <source>Fields</source>
-      <translation>Champs</translation>
+        <location filename="PartSet_TreeNodes.cpp" line="410"/>
+        <source>Fields</source>
+        <translation>Champs</translation>
     </message>
     <message>
-      <location filename="PartSet_TreeNodes.cpp" line="412"/>
-      <source>Groups</source>
-      <translation>Groupes</translation>
+        <location filename="PartSet_TreeNodes.cpp" line="412"/>
+        <source>Groups</source>
+        <translation>Groupes</translation>
     </message>
-  </context>
+</context>
 </TS>
index 9717b2dcdb775f35bf37d97893b24362bf5a7fa2..e82b2f531ad3c05bf1fe97b6b17287ba5fdd094f 100644 (file)
       <source>Sketch</source>
       <translation>Esquisse</translation>
     </message>
-    <message>
-      <source>DoF (degrees of freedom) = %1</source>
-      <translation>DdL (degrés de liberté) = %1</translation>
-    </message>
-    <message>
-      <source>Sketch is fully fixed (DoF = 0)</source>
-      <translation>L&apos;esquisse est entièrement fixée (DdL = 0)</translation>
-    </message>
   </context>
   <context>
     <name>Sketch:External</name>
index e57f5a3e8976f17617614866186910addbef55cc..69d6a1c71d70637290c81fc64e633db4ef402e9a 100644 (file)
@@ -25,7 +25,7 @@
         <sketch-start-label id="External" geometrical_selection="true" title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </sketch-start-label>
-        <label id="SolverDOF"/>
+        <!-- <label id="SolverDOF"/>  -->
         <label id="SolverError" styleSheet="color : red; font : bold"/>
         <validator id="SketchPlugin_SolverErrorValidator"/>
       </feature>
index efed9986da7ddac98de4bb05bce9e5c91804ee5c..ab9b38fc2df6789e841b275e22e425f2805d9e19 100644 (file)
@@ -358,20 +358,24 @@ void SketchSolver_Group::computeDoF()
   int aDoF = mySketchSolver->dof();
   /// "DoF = 0" content of string value is used in PartSet by Sketch edit
   /// If it is changed, it should be corrected also there
-  if (aDoF == 0) {
-    static const std::string aMsgDoF("Sketch is fully fixed (DoF = 0)");
-    aDoFMsg = Config_Translator::translate(aMsgContext, aMsgDoF);
-  } else {
-    static const std::string aMsgDoF("DoF (degrees of freedom) = %1");
-    Events_InfoMessage aMsg(aMsgContext, aMsgDoF);
-    aMsg.addParameter(aDoF);
-    aDoFMsg = Config_Translator::translate(aMsg);
-  }
-  // store Unicode value for translated message about DoF
-  size_t aLen = aDoFMsg.size();
-  std::wstring aWStr(aLen, L'#');
-  mbstowcs(&aWStr[0], aDoFMsg.c_str(), aLen);
-  mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aWStr);
+  //if (aDoF == 0) {
+  //  static const std::string aMsgDoF("Sketch is fully fixed (DoF = 0)");
+  //  aDoFMsg = Config_Translator::translate(aMsgContext, aMsgDoF);
+  //} else {
+  //  static const std::string aMsgDoF("DoF (degrees of freedom) = %1");
+  //  Events_InfoMessage aMsg(aMsgContext, aMsgDoF);
+  //  aMsg.addParameter(aDoF);
+  //  aDoFMsg = Config_Translator::translate(aMsg);
+  //}
+  //// store Unicode value for translated message about DoF
+  //size_t aLen = aDoFMsg.size();
+  //std::wstring aWStr(aLen, L'#');
+  //mbstowcs(&aWStr[0], aDoFMsg.c_str(), aLen);
+  //mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aWStr);
+
+  std::ostringstream aStr;
+  aStr << aDoF;
+  mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aStr.str());
 
   if (aDoF > 0 && myDOF <= 0)
     sendMessage(EVENT_SKETCH_UNDER_CONSTRAINED, mySketch, aDoF);