Salome HOME
import image: add documentation and improve image rendering
[modules/shaper.git] / src / PartSet / PartSet_TreeNodes.cpp
index c63a5eb3a7fb4a7faec1681a457544a002a33d9b..ef099a03057cd51be209e37566d9b4ee81c81dac 100644 (file)
@@ -40,6 +40,8 @@
 #include <ModelAPI_Folder.h>
 #include <ModelAPI_AttributeReference.h>
 
+#include <Config_PropManager.h>
+
 #include <QBrush>
 #include <QMap>
 
@@ -85,11 +87,16 @@ QVariant PartSet_TreeNode::data(int theColumn, int theRole) const
       return QBrush(DISABLED_COLOR);
     if (!aFlags.testFlag(Qt::ItemIsEditable))
       return QBrush(SELECTABLE_COLOR);
-    return ACTIVE_COLOR;
+    return activeItemColor();
   }
   return ModuleBase_ITreeNode::data(theColumn, theRole);
 }
 
+QColor PartSet_TreeNode::activeItemColor() const
+{
+  return ACTIVE_COLOR;
+}
+
 
 //////////////////////////////////////////////////////////////////////////////////
 QVariant PartSet_ObjectNode::data(int theColumn, int theRole) const
@@ -102,10 +109,10 @@ QVariant PartSet_ObjectNode::data(int theColumn, int theRole) const
         AttributeDoublePtr aValueAttribute =
           aParam->data()->real(ModelAPI_ResultParameter::VALUE());
         QString aVal = QString::number(aValueAttribute->value());
-        QString aTitle = QString(myObject->data()->name().c_str());
+        QString aTitle = QString::fromStdWString(myObject->data()->name());
         return aTitle + " = " + aVal;
       }
-      return myObject->data()->name().c_str();
+      return QString::fromStdWString(myObject->data()->name());
     }
     break;
   case Qt::DecorationRole:
@@ -133,6 +140,17 @@ QVariant PartSet_ObjectNode::data(int theColumn, int theRole) const
   return PartSet_TreeNode::data(theColumn, theRole);
 }
 
+QColor PartSet_ObjectNode::activeItemColor() const
+{
+  if (myObject.get() && myObject->groupName() == ModelAPI_Feature::group()) {
+    std::vector<int> aColor =
+      Config_PropManager::color("Visualization", "feature_objectbrowser_color");
+    return QColor(aColor[0], aColor[1], aColor[2]);
+  }
+  return PartSet_TreeNode::activeItemColor();
+}
+
+
 Qt::ItemFlags PartSet_ObjectNode::flags(int theColumn) const
 {
   if (myObject->isDisabled()) {
@@ -965,9 +983,9 @@ QVariant PartSet_PartRootNode::data(int theColumn, int theRole) const
       ResultPartPtr aPartRes = getPartResult(myObject);
       if (aPartRes.get()) {
         if (aPartRes->partDoc().get() == NULL)
-          return QString(myObject->data()->name().c_str()) + " (Not loaded)";
+          return QString::fromStdWString(myObject->data()->name()) + " (Not loaded)";
       }
-      return QString(myObject->data()->name().c_str());
+      return QString::fromStdWString(myObject->data()->name());
     }
     case Qt::DecorationRole:
       return ModuleBase_IconFactory::get()->getIcon(myObject);
@@ -1199,7 +1217,18 @@ QTreeNodesList PartSet_ObjectFolderNode::objectsDeleted(const DocumentPtr& /*the
   return aResult;
 }
 
+QVariant PartSet_ObjectFolderNode::data(int theColumn, int theRole) const
+{
+  if (theRole == Qt::ForegroundRole) {
+    if (!myObject->isDisabled()) {
+      std::vector<int> aColor =
+        Config_PropManager::color("Visualization", "feature_objectbrowser_color");
+      return QColor(aColor[0], aColor[1], aColor[2]);
+    }
+  }
+  return PartSet_ObjectNode::data(theColumn, theRole);
 
+}
 
 //////////////////////////////////////////////////////////////////////////////////
 QVariant PartSet_StepNode::data(int theColumn, int theRole) const