]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Visualization preferences for sketcher are created
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 14 Aug 2014 07:27:42 +0000 (11:27 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 14 Aug 2014 07:27:42 +0000 (11:27 +0400)
20 files changed:
src/Config/CMakeLists.txt
src/Config/Config_Prop.h [new file with mode: 0644]
src/Config/Config_PropManager.cpp [new file with mode: 0644]
src/Config/Config_PropManager.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_AISObject.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/XGUI/XGUI_Preferences.cpp
src/XGUI/XGUI_Preferences.h

index aa7ea19e4b193254b0f5a06615dfbb560a492052..1b52cfbb8ab2741236d9036c9ac6fd669beea995 100644 (file)
@@ -15,6 +15,8 @@ SET(PROJECT_HEADERS
   Config_PointerMessage.h
   Config_Common.h
   Config_ValidatorMessage.h
+  Config_Prop.h
+  Config_PropManager.h
  )
  
 SET(PROJECT_SOURCES
@@ -27,6 +29,7 @@ SET(PROJECT_SOURCES
   Config_PointerMessage.cpp
   Config_Common.cpp
   Config_ValidatorMessage.cpp
+  Config_PropManager.cpp
 )
 
 SET(XML_RESOURCES
diff --git a/src/Config/Config_Prop.h b/src/Config/Config_Prop.h
new file mode 100644 (file)
index 0000000..3e5ab7f
--- /dev/null
@@ -0,0 +1,59 @@
+// File:        Config_Prop.h
+// Created:     12 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef Config_Prop_H
+#define Config_Prop_H
+
+#include "Config_def.h"
+
+#include <string>
+#include <list>
+
+/// Class which describes a one property
+class Config_Prop
+{
+public:
+
+  enum PropType { Auto, Space, Bool, Color, String, Selector,
+                  DblSpin, IntSpin, Double, Integer,
+                  GroupBox, Tab, Frame, Font, DirList, File,
+                             Slider, Shortcut, ShortcutTree, BiColor, Background };
+
+
+  /** 
+  * Creates a one property
+  * \param theSection - name of section (domain of using) of the property.
+  * \param theName - name (title) of the value.
+  * \param theType - type of the value.
+  * \param theValue - initial value of the property.
+  */
+  Config_Prop(const std::string& theSection,
+              const std::string& theName,
+              const std::string& theTitle,
+              PropType theType,
+              const std::string& theValue ) {
+    mySection = theSection;
+    myName = theName;
+    myTitle = theTitle;
+    myType = theType;
+    myValue = theValue;
+  }
+
+  std::string section() const { return mySection; }
+  std::string name() const { return myName; }
+  std::string title() const { return myTitle; }
+  PropType type() const { return myType; }
+  std::string value() const { return myValue; }
+
+private:
+  std::string mySection;
+  std::string myName;
+  std::string myTitle;
+  PropType myType;
+  std::string myValue;
+};
+
+typedef std::list<Config_Prop*> Config_Properties;
+
+#endif
\ No newline at end of file
diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp
new file mode 100644 (file)
index 0000000..b859320
--- /dev/null
@@ -0,0 +1,121 @@
+// File:        Config_PropManager.cpp
+// Created:     13 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "Config_PropManager.h"
+
+
+std::map<std::string, Config_Properties> Config_PropManager::myPropMap;
+
+
+
+bool Config_PropManager::registerProp(const std::string& theOwnerId, 
+                                      const std::string& theSection,
+                                      const std::string& theName,
+                                      const std::string& theTitle,
+                                      Config_Prop::PropType theType,
+                                      const std::string& theValue)
+{
+  Config_Prop* aProp = new Config_Prop(theSection, theName, theTitle, theType, theValue);
+  return registerProp(theOwnerId, aProp);
+}
+
+bool Config_PropManager::registerProp(const std::string& theOwnerId, 
+                                      Config_Prop* theProp)
+{
+  if (myPropMap.find(theOwnerId) == myPropMap.end()) {
+    Config_Properties aPropList;
+    aPropList.push_back(theProp);
+    myPropMap[theOwnerId] = aPropList;
+  } else {
+    myPropMap[theOwnerId].push_back(theProp);
+  }
+  return true;
+}
+
+std::list<std::string> Config_PropManager::getOwners()
+{
+  std::list<std::string> aKeys;
+  std::map<std::string, Config_Properties>::const_iterator aIt;
+  for (aIt = myPropMap.cbegin(); aIt != myPropMap.cend(); ++aIt) 
+    aKeys.push_back((*aIt).first);
+  return aKeys;
+}
+
+Config_Properties Config_PropManager::getProperties(const std::string& theOwnerId)
+{
+  return myPropMap[theOwnerId];
+}
+
+
+std::list<std::string> Config_PropManager::getSections(const std::string& theOwnerId)
+{
+  std::list<std::string> aSections;
+  Config_Properties aProps = getProperties(theOwnerId);
+  Config_Properties::const_iterator aIt;
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
+    const Config_Prop* aProp = (*aIt);
+    aSections.push_back(aProp->section());
+  }
+  aSections.unique();
+  return aSections;
+}
+
+Config_Properties Config_PropManager::getProperties(const std::string& theOwnerId, 
+                                                    const std::string& theSection)
+{
+  Config_Properties aProps = getProperties(theOwnerId);
+  Config_Properties aRes;
+  Config_Properties::iterator aIt;
+  for (aIt = aProps.begin(); aIt != aProps.end(); aIt++) {
+    Config_Prop* aProp = (*aIt);
+    if (aProp->section() == theSection)
+      aRes.push_back(aProp);
+  }
+  return aRes;
+}
+
+
+std::string Config_PropManager::value(const std::string& theOwnerId, 
+                                      const std::string& theSection, 
+                                      const std::string& theName,
+                                      const std::string& theDefault)
+{
+  Config_Properties aProps = getProperties(theOwnerId, theSection);
+  Config_Properties::const_iterator aIt;
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
+    Config_Prop* aProp = (*aIt);
+    if (aProp->name() == theName)
+      return aProp->value();
+  }
+  return theDefault;
+}
+
+
+std::vector<int> stringToRGB(const std::string& theColor)
+{
+  std::vector<int> aRes(3);
+
+  int aPos = theColor.find(",");
+  char aBuf[10];
+  // Get Red
+  std::size_t length = theColor.copy(aBuf, aPos, 0);
+  aBuf[length] = '\0';
+  int aC = atoi(aBuf);
+  aRes[0] = aC;
+
+  // Get Green
+  int aNPos = theColor.find(",", aPos + 1);
+  length = theColor.copy(aBuf, aNPos - aPos - 1, aPos + 1);
+  aBuf[length] = '\0';
+  aC = atoi(aBuf);
+  aRes[1] = aC;
+
+  // Get Green
+  length = theColor.copy(aBuf, theColor.length() - aNPos - 1, aNPos + 1);
+  aBuf[length] = '\0';
+  aC = atoi(aBuf);
+  aRes[2] = aC;
+
+  return aRes;
+}
\ No newline at end of file
diff --git a/src/Config/Config_PropManager.h b/src/Config/Config_PropManager.h
new file mode 100644 (file)
index 0000000..4a6d432
--- /dev/null
@@ -0,0 +1,71 @@
+// File:        Config_PropManager.h
+// Created:     13 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef Config_PropManager_H
+#define Config_PropManager_H
+
+#include "Config_def.h"
+#include "Config_Prop.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+//! Class wihich let to register properties
+class CONFIG_EXPORT Config_PropManager
+{
+public:
+
+  /** 
+  * Registers property parameters
+  * \param theOwnerId - name of owner (name of plugin for example)
+  * \param theSection - name of section (domain of using) of the property.
+  * \param theName - name (title) of the value.
+  * \param theType - type of the value.
+  * \param theValue - initial value of the property
+  * Returns True if the property succesfully registered
+  */
+  static bool registerProp(const std::string& theOwnerId, 
+                           const std::string& theSection,
+                           const std::string& theName,
+                           const std::string& theTitle,
+                           Config_Prop::PropType theType,
+                           const std::string& theValue);
+
+  //! Returns list of registered owners.
+  static std::list<std::string> getOwners();
+
+  //! Returns list of properties by its owner.
+  static Config_Properties getProperties(const std::string& theOwnerId);
+
+  //! Returns list of registered section names.
+  static std::list<std::string> getSections(const std::string& theOwnerId);
+
+  //! Returns list of properties by its owner and section.
+  static Config_Properties getProperties(const std::string& theOwnerId, const std::string& theSection);
+
+  //! Returns value of the property by its owner, section, and name
+  static std::string value(const std::string& theOwnerId, 
+                           const std::string& theSection, 
+                           const std::string& theName,
+                           const std::string& theDefault);              
+
+private:
+
+  /** 
+  * Registers property parameters
+  * \param theOwnerId - name of owner (name of plugin for example)
+  * \param theProp - the Property object.
+  * Returns True if the property succesfully registered
+  */
+  static bool registerProp(const std::string& theOwnerId, 
+                           Config_Prop* theProp);
+
+  static std::map<std::string, Config_Properties> myPropMap;
+};
+
+
+CONFIG_EXPORT std::vector<int> stringToRGB(const std::string& theColor);
+
+#endif
\ No newline at end of file
index b2bb96faf0dcb7b2cb81c7fd7ebf3505cdec6fa9..ec44e1c6392da25dff9e702b0205e21885cf74b3 100644 (file)
@@ -234,7 +234,12 @@ void GeomAPI_AISObject::setColor(const int& theColor)
   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
   if (anAIS.IsNull())
     return ;
-  anAIS->SetColor(Quantity_Color((Quantity_NameOfColor)theColor));
+  Quantity_Color aColor((Quantity_NameOfColor)theColor);
+  anAIS->SetColor(aColor);
+  Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
+  if (!aDimAIS.IsNull()) {
+    aDimAIS->DimensionAspect()->SetCommonColor(aColor);
+  }
 }
 
 void GeomAPI_AISObject::setWidth(const double& theWidth)
@@ -245,6 +250,19 @@ void GeomAPI_AISObject::setWidth(const double& theWidth)
   anAIS->SetWidth(theWidth);
 }
 
+void GeomAPI_AISObject::setColor(int theR, int theG, int theB)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (anAIS.IsNull())
+    return ;
+  Quantity_Color aColor(theR/255., theG/255., theB/255., Quantity_TOC_RGB);
+  anAIS->SetColor(aColor);
+  Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS);
+  if (!aDimAIS.IsNull()) {
+    aDimAIS->DimensionAspect()->SetCommonColor(aColor);
+  }
+}
+
 bool GeomAPI_AISObject::empty() const
 {
   Handle(AIS_InteractiveObject) anAIS = 
index a874e5d3e8440f89b26c93f2468eb6b9371e0f21..12b29708be3a9e77ac87e1bf45f220abbc5dc7b3 100644 (file)
@@ -84,6 +84,13 @@ public:
    */
   void setColor(const int& theColor);
 
+  /** \brief Assigns the color for the shape
+   *  \param[in] theR value of the red component
+   *  \param[in] theG value of the green component
+   *  \param[in] theB value of the blue component
+   */
+  void setColor(int theR, int theG, int theB);
+
   /// \brief Assigns the width of the lines of shape
   void setWidth(const double& theWidth);
 
index d45087849ec89f9a252aea30cab8d64549fd5808..2cbe3e324921a683e456a8a7347dff55ec3cfcad 100644 (file)
@@ -39,6 +39,7 @@ SET(PROJECT_SOURCES
 )
 
 SET(PROJECT_LIBRARIES
+    Config
     GeomAPI
     GeomAlgoAPI
     ModelAPI
@@ -53,6 +54,7 @@ ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESO
 TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
+  ../Config
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
index de504f56ea4b1ca99cc88607c51d4dba6df46f09..de05942fef4e37963e79df8ae3c5b5b63ef42c31 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 
+#include <Config_PropManager.h>
 
 SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
 {
@@ -115,6 +116,12 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObje
   if (!anAIS)
     anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
   anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
+
+  // Set color from preferences
+  std::string aColor = Config_PropManager::value("Sketcher", "Visualization", 
+                                                 "distance_color", DISTANCE_COLOR);
+  std::vector<int> aRGB = stringToRGB(aColor);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
index afb687d09c49f1caa24932f4b821b6e9a38f556d..b63c170c594c5b90f97b0ce518e67cdf2507b322 100644 (file)
@@ -15,6 +15,8 @@
 class SketchPlugin_Line;
 class GeomDataAPI_Point2D;
 
+#define DISTANCE_COLOR "255, 0, 255"
+
 /** \class SketchPlugin_ConstraintDistance
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines a distance
index 28d2cf7d35b2b63dac6e836e0520cbb945efef88..7e3ddfd5f7a27a59d2ea63b6842eaf4d7c393775 100644 (file)
@@ -16,6 +16,7 @@
 #include <GeomAPI_Lin2d.h>
 #include <GeomAPI_Pnt2d.h>
 
+#include <Config_PropManager.h>
 
 
 SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
@@ -93,6 +94,12 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
   if (!anAIS)
     anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
   anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
+
+  // Set color from preferences
+  std::string aColor = Config_PropManager::value("Sketcher", "Visualization", 
+                                                 "length_color", LENGTH_COLOR);
+  std::vector<int> aRGB = stringToRGB(aColor);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
index cc96258e31c7b34c3ced796cd0a513967d24a166..52d26854a00b908148891ce73d3811ef219d96a7 100644 (file)
@@ -10,6 +10,8 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
+#define LENGTH_COLOR "255, 0, 255"
+
 /** \class SketchPlugin_ConstraintLength
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines a length of a line segment
index e2cd9c53dd2d52ab8b5ee548dd945362999502ac..ea09ad9cf488a7e5f5de9690df24139fad99af23 100644 (file)
@@ -15,6 +15,8 @@
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
 
+#include <Config_PropManager.h>
+
 SketchPlugin_ConstraintParallel::SketchPlugin_ConstraintParallel()
 {
 }
@@ -77,6 +79,12 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
   if (!anAIS)
     anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
   anAIS->createParallel(aLine1, aLine2, aFlyoutPnt, aPlane);
+
+  // Set color from preferences
+  std::string aColor = Config_PropManager::value("Sketcher", "Visualization", 
+                                                 "parallel_color", PARALLEL_COLOR);
+  std::vector<int> aRGB = stringToRGB(aColor);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
index 0da78ca640301a9f3e265db8fd62f35ca80ada97..9b0570fc04584699b1be36bd75fac931fb6f9189 100644 (file)
@@ -9,6 +9,9 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
+
+#define PARALLEL_COLOR "255, 255, 0"
+
 /** \class SketchPlugin_ConstraintParallel
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint parallelism of two lines
index 4f6a0b77136a4e5ef3794a065b23e310233689ef..e844f559dd7f711990ce4ac605148252296f18a5 100644 (file)
@@ -15,6 +15,8 @@
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
 
+#include <Config_PropManager.h>
+
 SketchPlugin_ConstraintPerpendicular::SketchPlugin_ConstraintPerpendicular()
 {
 }
@@ -73,6 +75,12 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
   if (!anAIS)
     anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
   anAIS->createPerpendicular(aLine1, aLine2, aPlane);
+
+  // Set color from preferences
+  std::string aColor = Config_PropManager::value("Sketcher", "Visualization", 
+                                                 "perpendicular_color", PERPENDICULAR_COLOR);
+  std::vector<int> aRGB = stringToRGB(aColor);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
index 33ad334e01bc5d3a5cb6c655557b38360e1045fa..d6d54b33b4199964bf4a0eb4f00c7f93c8f5f16e 100644 (file)
@@ -9,6 +9,8 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
+#define PERPENDICULAR_COLOR "255, 255, 0"
+
 /** \class SketchPlugin_ConstraintPerpendicular
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint for perpendicularity of two lines
index b771035423ffbe373fbf492317700b4f997323e0..72956417001da16d726e62ddc1f3d007030a4990 100644 (file)
@@ -19,6 +19,8 @@
 #include <GeomDataAPI_Point2D.h>
 #include <GeomDataAPI_Dir.h>
 
+#include <Config_PropManager.h>
+
 SketchPlugin_ConstraintRadius::SketchPlugin_ConstraintRadius()
 {
 }
@@ -119,6 +121,12 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
   if (!anAIS)
     anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
   anAIS->createRadius(aCircle, aFlyoutPnt, aValue);
+
+  // Set color from preferences
+  std::string aColor = Config_PropManager::value("Sketcher", "Visualization", 
+                                                 "radius_color", RADIUS_COLOR);
+  std::vector<int> aRGB = stringToRGB(aColor);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
 
index 829a15512f59ff273e78e255a52df18a6255d9e6..6950b9c0cba910dbce05d4e24e02d13f5ae62c53 100644 (file)
@@ -9,6 +9,8 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
+#define RADIUS_COLOR "255, 0, 255"
+
 /** \class SketchPlugin_ConstraintRadius
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines 
index 2a05d45641cd3c9e5dca8516904eec7bd6e224cd..28c20ff4e1f686129567101fc00e25af74cc7e20 100644 (file)
@@ -15,6 +15,8 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Validator.h>
 
+#include <Config_PropManager.h>
+
 using namespace std;
 
 // the only created instance of this plugin
@@ -28,6 +30,23 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
 
   // register this plugin
   ModelAPI_PluginManager::get()->registerPlugin(this);
+
+  // register sketcher properties
+  Config_PropManager::registerProp("Sketcher", "Visualization", 
+                                   "parallel_color", "Parallel constraint color",
+                                   Config_Prop::Color, PARALLEL_COLOR);
+  Config_PropManager::registerProp("Sketcher", "Visualization", 
+                                   "perpendicular_color", "Perpendicular constraint color",
+                                   Config_Prop::Color, PERPENDICULAR_COLOR);
+  Config_PropManager::registerProp("Sketcher", "Visualization", 
+                                   "distance_color", "Distance color",
+                                   Config_Prop::Color, DISTANCE_COLOR);
+  Config_PropManager::registerProp("Sketcher", "Visualization", 
+                                   "length_color", "Length color",
+                                   Config_Prop::Color, LENGTH_COLOR);
+  Config_PropManager::registerProp("Sketcher", "Visualization", 
+                                   "radius_color", "Radius color",
+                                   Config_Prop::Color, RADIUS_COLOR);
 }
 
 FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)
index 14fea9f987860c86ec41aa079e8d05e4699b6b85..b310ba7ced5b05ba717d831af1a3f21fe251f558 100644 (file)
@@ -79,10 +79,17 @@ XGUI_PreferencesDlg::~XGUI_PreferencesDlg()
 void XGUI_PreferencesDlg::createEditors()
 {
   int aLFpage = myPreferences->addItem("Desktop");
-  myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png"));
+  //myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png"));
 
   createMenuPage(aLFpage);
   createViewerPage(aLFpage);
+
+  std::list<std::string> aOwners = Config_PropManager::getOwners();
+  std::list<std::string>::const_iterator aIt;
+  for (aIt = aOwners.cbegin(); aIt != aOwners.cend(); ++ aIt) {
+    int aPage = myPreferences->addItem((*aIt).c_str());
+    createCustomPage(aPage, Config_PropManager::getProperties((*aIt)));
+  }
 }
 
 void XGUI_PreferencesDlg::createViewerPage(int thePageId)
@@ -144,6 +151,50 @@ void XGUI_PreferencesDlg::createMenuPage(int thePageId)
   myPreferences->setItemProperty( "max", 10, aRowsNb );
 }
 
+
+void XGUI_PreferencesDlg::createCustomPage(int thePageId, Config_Properties& theProps)
+{
+  SUIT_ResourceMgr* aResMgr = XGUI_Preferences::resourceMgr();
+  bool isResModified = false;
+
+  // Sort by sections
+  QMap<QString, Config_Properties> aGroupMap;
+  Config_Properties::const_iterator aIt;
+  for (aIt = theProps.cbegin(); aIt != theProps.cend(); ++aIt) {
+    QString aGroup((*aIt)->section().c_str());
+    if (aGroupMap.contains(aGroup)) {
+      aGroupMap[aGroup].push_back(*aIt);
+    } else {
+      Config_Properties aProps;
+      aProps.push_back(*aIt);
+      aGroupMap[aGroup] = aProps;
+    }
+    // check that the property is defined
+    QString aName((*aIt)->name().c_str());
+    if (!aResMgr->hasValue(aGroup, aName)) {
+      aResMgr->setValue(aGroup, aName, QString((*aIt)->value().c_str()));
+      isResModified = true;
+    }
+  }
+  if (isResModified)
+    aResMgr->save();
+
+  // Make a Tab from each section
+  QMap<QString, Config_Properties>::iterator it;
+  for (it = aGroupMap.begin(); it != aGroupMap.end(); ++it) {
+    int aTab = myPreferences->addItem(it.key(), thePageId );
+    myPreferences->setItemProperty( "columns", 2, aTab );
+    Config_Properties& aProps = it.value();
+    for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
+      myPreferences->addItem( QString((*aIt)->title().c_str()), aTab,
+                              (SUIT_PreferenceMgr::PrefItemType)(*aIt)->type(), 
+                              QString((*aIt)->section().c_str()), 
+                               QString((*aIt)->name().c_str()) );
+    }
+  }
+}
+
+
 void XGUI_PreferencesDlg::accept()
 {
   myPreferences->store();
index 90150c67f7c74e4d502297d25132b61a10226b95..bd30a31a581b0558d2fcf22b7eb22c362203e0f4 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "XGUI.h"
 
+#include <Config_PropManager.h>
 #include <SUIT_PreferenceMgr.h>
 #include <QDialog>
 
@@ -75,6 +76,7 @@ private:
   void createEditors();
   void createViewerPage(int thePageId);
   void createMenuPage(int thePageId);
+  void createCustomPage(int thePageId, Config_Properties& theProps);
   
   XGUI_PreferencesMgr* myPreferences;
   bool myIsChanged;