X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FInitializationPlugin%2FInitializationPlugin_Plugin.cpp;h=228c30e9a7e4e4e26d9fbb3b1114844f9e33c603;hb=88ee9b2b81cf93a6324336b57e30cc8a3a487499;hp=0d10a4b15f9e50c6deff99df5c896fc929e13129;hpb=7074394f8f08413d885f63be01df6bd5007b868c;p=modules%2Fshaper.git diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp index 0d10a4b15..228c30e9a 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 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 @@ -12,10 +12,9 @@ // // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -30,6 +29,8 @@ #include #include +#include + #include #include @@ -41,6 +42,9 @@ static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = InitializationPlugin_Plugin::InitializationPlugin_Plugin() { + char* isUnitTest = getenv("SHAPER_UNIT_TEST_IN_PROGRESS"); + myInitDataModel = (!isUnitTest || isUnitTest[0] != '1'); + Events_Loop* aLoop = Events_Loop::loop(); const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId(); aLoop->registerListener(this, kDocCreatedEvent, NULL, true); @@ -62,6 +66,9 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrmoduleDocument()) return; + if (myInitDataModel) + myEvalListener->initDataModel(); + std::list aFeatures; // the viewer update should be blocked in order to avoid the features blinking before they are @@ -70,7 +77,7 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrsend(aMsg); - FeaturePtr aOrigin = createPoint(aDoc, "Origin", 0., 0., 0.); + FeaturePtr aOrigin = createPoint(aDoc, L"Origin", 0., 0., 0.); aFeatures.push_back(aOrigin); aFeatures.push_back(createAxis(aDoc, aOrigin, 100., 0., 0.)); aFeatures.push_back(createAxis(aDoc, aOrigin, 0., 100., 0.)); @@ -113,11 +120,11 @@ FeaturePtr InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double t aPlane->real("D")->setValue(0.); if (theX) { - aPlane->data()->setName("YOZ"); + aPlane->data()->setName(L"YOZ"); } else if (theY) { - aPlane->data()->setName("XOZ"); + aPlane->data()->setName(L"XOZ"); } else if (theZ) { - aPlane->data()->setName("XOY"); + aPlane->data()->setName(L"XOY"); } // don't show automatically created feature in the features history aPlane->setInHistory(aPlane, false); @@ -133,14 +140,14 @@ FeaturePtr InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double t return aPlane; } -FeaturePtr InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc, const std::string& theName, +FeaturePtr InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc, const std::wstring& theName, double theX, double theY, double theZ) { std::shared_ptr aPoint = theDoc->addFeature("Point"); - //aPoint->string("creation_method")->setValue("by_xyz"); - aPoint->real("x")->setValue(theX); - aPoint->real("y")->setValue(theY); - aPoint->real("z")->setValue(theZ); + AttributePointPtr aPointAttr = std::dynamic_pointer_cast + (aPoint->data()->attribute("point3d")); + aPointAttr->setValue(theX, theY, theZ); + aPoint->string("creation_method")->setValue("by_xyz"); aPoint->data()->setName(theName); // don't show automatically created feature in the features history aPoint->setInHistory(aPoint, false); @@ -168,11 +175,11 @@ FeaturePtr InitializationPlugin_Plugin::createAxis(DocumentPtr theDoc, FeaturePt aAxis->real("Z_Direction")->setValue(theZ); if (theX != 0) { - aAxis->data()->setName("OX"); + aAxis->data()->setName(L"OX"); } else if (theY != 0) { - aAxis->data()->setName("OY"); + aAxis->data()->setName(L"OY"); } else if (theZ != 0) { - aAxis->data()->setName("OZ"); + aAxis->data()->setName(L"OZ"); } // don't show automatically created feature in the features history aAxis->setInHistory(aAxis, false);