Salome HOME
updated copyright message
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetPointInput.cpp
index 11b96c37c5d1005aa46b27ba63066fc747681985..9bb0f5b9eb8e2e1810f1d8899765200a213ff243 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "ModuleBase_WidgetPointInput.h"
@@ -35,7 +34,7 @@
 #include <QLabel>
 
 
-#define ERR_STRING "ERROR"
+#define ERR_STRING L"ERROR"
 
 ModuleBase_WidgetPointInput::ModuleBase_WidgetPointInput(QWidget* theParent,
   ModuleBase_IWorkshop* theWorkshop,
@@ -61,7 +60,7 @@ ModuleBase_WidgetPointInput::ModuleBase_WidgetPointInput(QWidget* theParent,
 
   myXSpin = new ModuleBase_ParamSpinBox(this);
   myXSpin->setAcceptVariables(aAcceptVariables);
-  myXSpin->setToolTip("X coordinate");
+  myXSpin->setToolTip(tr("X coordinate"));
   myXSpin->setValue(myDefaultValue[0]);
   QLabel* aXLbl = new QLabel(this);
   aXLbl->setPixmap(QPixmap(":pictures/x_size.png"));
@@ -69,7 +68,7 @@ ModuleBase_WidgetPointInput::ModuleBase_WidgetPointInput(QWidget* theParent,
 
   myYSpin = new ModuleBase_ParamSpinBox(this);
   myYSpin->setAcceptVariables(aAcceptVariables);
-  myYSpin->setToolTip("Y coordinate");
+  myYSpin->setToolTip(tr("Y coordinate"));
   myYSpin->setValue(myDefaultValue[1]);
   QLabel* aYLbl = new QLabel(this);
   aYLbl->setPixmap(QPixmap(":pictures/y_size.png"));
@@ -77,7 +76,7 @@ ModuleBase_WidgetPointInput::ModuleBase_WidgetPointInput(QWidget* theParent,
 
   myZSpin = new ModuleBase_ParamSpinBox(this);
   myZSpin->setAcceptVariables(aAcceptVariables);
-  myZSpin->setToolTip("Z coordinate");
+  myZSpin->setToolTip(tr("Z coordinate"));
   myZSpin->setValue(myDefaultValue[2]);
   QLabel* aZLbl = new QLabel(this);
   aZLbl->setPixmap(QPixmap(":pictures/z_size.png"));
@@ -104,7 +103,7 @@ QList<QWidget*> ModuleBase_WidgetPointInput::getControls() const
   return aList;
 }
 
-std::string getParmText(ModuleBase_ParamSpinBox* theSpin, FeaturePtr& theParam)
+std::wstring getParmText(ModuleBase_ParamSpinBox* theSpin, FeaturePtr& theParam)
 {
   QString aText = theSpin->text();
   if (aText.contains('=')) {
@@ -119,7 +118,7 @@ std::string getParmText(ModuleBase_ParamSpinBox* theSpin, FeaturePtr& theParam)
     }
     aText = aText.split('=').at(0);
   }
-  return aText.toStdString();
+  return aText.toStdWString();
 }
 
 //********************************************************************
@@ -129,21 +128,21 @@ bool ModuleBase_WidgetPointInput::storeValueCustom()
   if (aAttr.get()) {
     if (aAttr->isInitialized()) {
       if (myXSpin->hasVariable() || myYSpin->hasVariable() || myZSpin->hasVariable()) {
-        std::string aXText = getParmText(myXSpin, myXParam);
+        std::wstring aXText = getParmText(myXSpin, myXParam);
         if (aXText == ERR_STRING) {
           aAttr->setExpressionError(0, "Parameter cannot be created");
           aAttr->setExpressionInvalid(0, true);
           updateObject(myFeature);
           return false;
         }
-        std::string aYText = getParmText(myYSpin, myYParam);
+        std::wstring aYText = getParmText(myYSpin, myYParam);
         if (aYText == ERR_STRING) {
           aAttr->setExpressionError(1, "Parameter cannot be created");
           aAttr->setExpressionInvalid(1, true);
           updateObject(myFeature);
           return false;
         }
-        std::string aZText = getParmText(myZSpin, myZParam);
+        std::wstring aZText = getParmText(myZSpin, myZParam);
         if (aZText == ERR_STRING) {
           aAttr->setExpressionError(2, "Parameter cannot be created");
           aAttr->setExpressionInvalid(2, true);
@@ -152,6 +151,7 @@ bool ModuleBase_WidgetPointInput::storeValueCustom()
         }
         aAttr->setText(aXText, aYText, aZText);
       } else {
+        aAttr->setText(L"", L"", L"");
         aAttr->setValue(myXSpin->value(), myYSpin->value(), myZSpin->value());
       }
     } else {
@@ -169,26 +169,26 @@ bool ModuleBase_WidgetPointInput::restoreValueCustom()
   AttributePointPtr aAttr = std::dynamic_pointer_cast<GeomDataAPI_Point>(attribute());
   if (aAttr.get()) {
     if (aAttr->isInitialized()) {
-      std::string aXText = aAttr->textX();
+      std::wstring aXText = aAttr->textX();
       if (aXText.empty()) {
         myXSpin->setValue(aAttr->x());
       }
       else {
-        myXSpin->setText(aXText.c_str());
+        myXSpin->setText(QString::fromStdWString(aXText));
       }
-      std::string aYText = aAttr->textY();
+      std::wstring aYText = aAttr->textY();
       if (aYText.empty()) {
         myYSpin->setValue(aAttr->y());
       }
       else {
-        myYSpin->setText(aYText.c_str());
+        myYSpin->setText(QString::fromStdWString(aYText));
       }
-      std::string aZText = aAttr->textZ();
+      std::wstring aZText = aAttr->textZ();
       if (aZText.empty()) {
         myZSpin->setValue(aAttr->z());
       }
       else {
-        myZSpin->setText(aZText.c_str());
+        myZSpin->setText(QString::fromStdWString(aZText));
       }
     }
     else {
@@ -197,6 +197,7 @@ bool ModuleBase_WidgetPointInput::restoreValueCustom()
       myYSpin->setValue(myDefaultValue[1]);
       myZSpin->setValue(myDefaultValue[2]);
     }
+    setValueState(Stored);
     return true;
   }
   return false;