Salome HOME
Copyright update 2021
[modules/shaper.git] / src / ParametersPlugin / ParametersPlugin_WidgetParamsMgr.cpp
index 9938df1e66b911170eae3108086274f1a72ea186..62a432a8b95cd06c72969d2843b5290e2d00c267 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,8 @@
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IViewer.h>
 
 #include <Events_Loop.h>
 #include <Config_PropManager.h>
@@ -178,9 +180,9 @@ void ParametersPlugin_TreeWidget::closeEditor(QWidget* theEditor,
 /////////////////////////////////////////////////////////////////////////////////////////////////
 
 ParametersPlugin_WidgetParamsMgr::ParametersPlugin_WidgetParamsMgr(QWidget* theParent,
-  const Config_WidgetAPI* theData)
+  const Config_WidgetAPI* theData, ModuleBase_IWorkshop* theWorkshop)
   : ModuleBase_ModelDialogWidget(theParent, theData),
-  isUpplyBlocked(false)
+  myWorkshop(theWorkshop), isUpplyBlocked(false)
 {
   QVBoxLayout* aLayout = new QVBoxLayout(this);
 
@@ -383,27 +385,28 @@ QList<QStringList> ParametersPlugin_WidgetParamsMgr::
         } else {
           if (!theFeatureList.contains(aReferenced)) {
             QStringList aValNames;
-            aValNames << aReferenced->data()->name().c_str();
+            aValNames << QString::fromStdWString(aReferenced->data()->name());
 
             std::string aId = aAttr->attributeType();
             if (aId == ModelAPI_AttributeDouble::typeId()) {
               AttributeDoublePtr aDouble =
                 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aAttr);
-              aValNames << aDouble->text().c_str();
+              aValNames << QString::fromStdWString(aDouble->text());
               aValNames << QString::number(aDouble->value());
             }
             else if (aId == ModelAPI_AttributeInteger::typeId()) {
               AttributeIntegerPtr aInt =
                 std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(aAttr);
-              aValNames << aInt->text().c_str();
+              aValNames << QString::fromStdWString(aInt->text());
               aValNames << QString::number(aInt->value());
             }
             else if (aId == GeomDataAPI_Point::typeId()) {
               std::shared_ptr<GeomDataAPI_Point> aPnt =
                 std::dynamic_pointer_cast<GeomDataAPI_Point>(aAttr);
 
-              QString aExpr = QString("%1,%2,%3").arg(aPnt->textX().c_str()).
-                arg(aPnt->textY().c_str()).arg(aPnt->textZ().c_str());
+              QString aExpr = QString("%1,%2,%3").arg(QString::fromStdWString(aPnt->textX())).
+                                                  arg(QString::fromStdWString(aPnt->textY())).
+                                                  arg(QString::fromStdWString(aPnt->textZ()));
               aValNames << aExpr;
 
               QString aRes = QString("%1,%2,%3").arg(aPnt->x()).arg(aPnt->y()).arg(aPnt->z());
@@ -413,8 +416,8 @@ QList<QStringList> ParametersPlugin_WidgetParamsMgr::
               std::shared_ptr<GeomDataAPI_Point2D> aPnt =
                 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aAttr);
 
-              QString aExpr = QString("%1,%2").arg(aPnt->textX().c_str()).
-                arg(aPnt->textY().c_str());
+              QString aExpr = QString("%1,%2").arg(QString::fromStdWString(aPnt->textX())).
+                                               arg(QString::fromStdWString(aPnt->textY()));
               aValNames << aExpr;
 
               QString aRes = QString("%1,%2").arg(aPnt->x()).arg(aPnt->y());
@@ -453,8 +456,7 @@ QList<QStringList> ParametersPlugin_WidgetParamsMgr::
     } else
       aValues << aExpr.c_str();
 
-    std::string aErr =
-      aParameter->data()->string(ParametersPlugin_Parameter::EXPRESSION_ERROR_ID())->value();
+    aErr = aParameter->data()->string(ParametersPlugin_Parameter::EXPRESSION_ERROR_ID())->value();
     if (aErr.empty()) {
       AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
       aValues << QString::number(aValueAttribute->value());
@@ -767,7 +769,7 @@ bool ParametersPlugin_WidgetParamsMgr::hasName(const QString& theName) const
   int aCurrent = myDelegate->editIndex().row();
   int i = 0;
   foreach(FeaturePtr aFeature, myParametersList) {
-    if ((i != aCurrent) && (aFeature->data()->name() == theName.toStdString()))
+    if ((i != aCurrent) && (aFeature->data()->name() == theName.toStdWString()))
       return true;
     i++;
   }
@@ -857,4 +859,5 @@ void ParametersPlugin_WidgetParamsMgr::onShowPreview()
   SessionPtr aMgr = ModelAPI_Session::get();
   aMgr->blockAutoUpdate(false);
   aMgr->blockAutoUpdate(true);
-}
\ No newline at end of file
+  myWorkshop->viewer()->update();
+}