Salome HOME
Task #3237: Allow usage of accented characters in ObjectBrowser EDF_2020_Lot2
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 10 Jul 2020 13:46:34 +0000 (16:46 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 10 Jul 2020 13:46:34 +0000 (16:46 +0300)
Use wide-strings for debug logging.

src/Model/Model_Data.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_Object.h

index f667942f8ba721310b5fff9d4398d9926e495111..0a3fa52d6e70a9e579336f964121dc3dd0a87107 100644 (file)
@@ -113,7 +113,7 @@ std::wstring Model_Data::name()
   Handle(TDataStd_Name) aName;
   if (shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) {
 #ifdef DEBUG_NAMES
-    myObject->myName = TCollection_AsciiString(aName->Get()).ToCString();
+    myObject->myName = Locale::Convert::toWString(aName->Get().ToExtString());
 #endif
     return Locale::Convert::toWString(aName->Get().ToExtString());
   }
index 09a56b18841be280804691a95982130a7ea5da6f..6b0ade0b5b9236e0b90402518a4800c91be4cd8e 100644 (file)
 Model_Update MY_UPDATER_INSTANCE;  /// the only one instance initialized on load of the library
 //#define DEB_UPDATE
 
+#ifdef DEB_UPDATE
+#include <Locale_Convert.h>
+#endif
+
 Model_Update::Model_Update()
 {
   Events_Loop* aLoop = Events_Loop::loop();
@@ -117,7 +121,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
     else if (myProcessOnFinish.find(theFeature) == myProcessOnFinish.end())
       myProcessOnFinish[theFeature] = std::set<std::shared_ptr<ModelAPI_Feature> >();
 #ifdef DEB_UPDATE
-      std::cout<<"*** Add process on finish "<<theFeature->name()<<std::endl;
+      std::wcout<<L"*** Add process on finish "<<theFeature->name()<<std::endl;
 #endif
     // keeps the currently updated features to avoid infinitive cycling here: where feature on
     // "updateArguments" sends "updated" (in selection attribute) and goes here again
@@ -325,8 +329,8 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
       if (!(*anObjIter)->data()->isValid())
         continue;
 #ifdef DEB_UPDATE
-      std::cout<<">>> in event updated "<<(*anObjIter)->groupName()<<
-        " "<<(*anObjIter)->data()->name()<<std::endl;
+      std::wcout<<L">>> in event updated "<<Locale::Convert::toWString((*anObjIter)->groupName())
+                <<L" "<<(*anObjIter)->data()->name()<<std::endl;
 #endif
       if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) {
         myIsParamUpdated = true;
@@ -563,14 +567,14 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
   }
 
 #ifdef DEB_UPDATE
-    std::cout<<"* Process feature "<<theFeature->name()<<std::endl;
+    std::wcout<<L"* Process feature "<<theFeature->name()<<std::endl;
 #endif
 
   // update the sketch plane before the sketch sub-elements are recomputed
   // (otherwise sketch will update plane, modify subs, after executed, but with old subs edges)
     if (aIsModified && theFeature->getKind() == "Sketch") {
 #ifdef DEB_UPDATE
-      std::cout << "****** Update sketch args " << theFeature->name() << std::endl;
+      std::wcout << L"****** Update sketch args " << theFeature->name() << std::endl;
 #endif
       AttributeSelectionPtr anExtSel = theFeature->selection("External");
       if (anExtSel.get()) {
@@ -689,7 +693,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
   }
 
 #ifdef DEB_UPDATE
-  std::cout<<"Update args "<<theFeature->name()<<std::endl;
+  std::wcout<<L"Update args "<<theFeature->name()<<std::endl;
 #endif
   // TestImport.py : after arguments are updated, theFeature may be removed
   if (!theFeature->data()->isValid())
@@ -712,7 +716,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
       // don't disable Part because it will make disabled all the features
       // (performance and problems with the current feature)
   #ifdef DEB_UPDATE
-    std::cout<<"Invalid args "<<theFeature->name()<<std::endl;
+    std::wcout<<L"Invalid args "<<theFeature->name()<<std::endl;
   #endif
     theFeature->eraseResults(false);
     redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
@@ -742,7 +746,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature)
     }
   } else {
     #ifdef DEB_UPDATE
-      std::cout<<"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
+      std::wcout<<L"Feature is not valid, erase results "<<theFeature->name()<<std::endl;
     #endif
     theFeature->eraseResults(false);
     redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
@@ -979,7 +983,7 @@ bool Model_Update::isReason(std::shared_ptr<ModelAPI_Feature>& theFeature,
 void Model_Update::executeFeature(FeaturePtr theFeature)
 {
 #ifdef DEB_UPDATE
-  std::cout<<"Execute Feature "<<theFeature->name()<<std::endl;
+  std::wcout<<L"Execute Feature "<<theFeature->name()<<std::endl;
 #endif
   // execute in try-catch to avoid internal problems of the feature
   ModelAPI_ExecState aState = ModelAPI_StateDone;
index 52b7bffa0b4fe5196d9dde79bbf8a10bf6184481..f0d2dce55977f0cd92427cf21743f98f1fb4bc47 100644 (file)
@@ -47,7 +47,7 @@ class ModelAPI_Object: public ModelAPI_Entity
   std::shared_ptr<ModelAPI_Document> myDoc;  ///< document this object belongs to
  public:
 #ifdef DEBUG_NAMES
-  std::string myName; // name of this object
+  std::wstring myName; // name of this object
 #endif
   /// By default object is displayed in the object browser.
   MODELAPI_EXPORT virtual bool isInHistory();