Salome HOME
Preferences improvement
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 14 Aug 2014 15:35:33 +0000 (19:35 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 14 Aug 2014 15:35:33 +0000 (19:35 +0400)
22 files changed:
src/Config/Config_Prop.h
src/Config/Config_PropManager.cpp
src/Config/Config_PropManager.h
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_Line.cpp
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Preferences.cpp
src/XGUI/XGUI_Preferences.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/module.png [new file with mode: 0644]

index 3e5ab7f42822b91e1b64e7206d0a924384d5fbe0..246df80748f82e0882f6a9ef3a7fbd17d1cc6c02 100644 (file)
@@ -15,7 +15,7 @@ class Config_Prop
 {
 public:
 
-  enum PropType { Auto, Space, Bool, Color, String, Selector,
+  enum PropType { Disabled, Space, Bool, Color, String, Selector,
                   DblSpin, IntSpin, Double, Integer,
                   GroupBox, Tab, Frame, Font, DirList, File,
                              Slider, Shortcut, ShortcutTree, BiColor, Background };
@@ -42,9 +42,20 @@ public:
 
   std::string section() const { return mySection; }
   std::string name() const { return myName; }
+
   std::string title() const { return myTitle; }
+  void setTitle(const std::string& theTitle) { myTitle = theTitle; }
+
   PropType type() const { return myType; }
+  void setType(PropType theType) { myType = theType; }
+
   std::string value() const { return myValue; }
+  void setValue(const std::string& theValue) { myValue = theValue; }
+
+  bool operator==(const Config_Prop* theProp) const
+  {
+    return (mySection == theProp->section()) && (myName == theProp->name());
+  }
 
 private:
   std::string mySection;
index b8593206d57275f14ae0e12c5e15b53c8f5500d1..4fa3d7090043cbf73b7200b3069ccae48c02fd97 100644 (file)
@@ -5,83 +5,93 @@
 #include "Config_PropManager.h"
 
 
-std::map<std::string, Config_Properties> Config_PropManager::myPropMap;
 
+std::vector<int> stringToRGB(const std::string& theColor);
+int stringToInteger(const std::string& theInt);
+double stringToDouble(const std::string& theDouble);
 
 
-bool Config_PropManager::registerProp(const std::string& theOwnerId, 
-                                      const std::string& theSection,
+Config_Properties Config_PropManager::myProps;
+
+
+
+bool Config_PropManager::registerProp(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);
+  Config_Prop* aProp = findProp(theSection, theName);
+  if (aProp) {
+    if (aProp->type() == Config_Prop::Disabled) {
+      aProp->setType(theType);
+      aProp->setTitle(theTitle);
+      return true;
+    }
+    return false;
   }
+  aProp = new Config_Prop(theSection, theName, theTitle, theType, theValue);
+  myProps.push_back(aProp);
   return true;
 }
 
-std::list<std::string> Config_PropManager::getOwners()
+Config_Prop* Config_PropManager::findProp(const std::string& theSection,
+                                          const std::string& theName)
 {
-  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::const_iterator aIt;
+  for (aIt = myProps.cbegin(); aIt != myProps.cend(); ++aIt) {
+    Config_Prop* aProp = (*aIt);
+    if ((aProp->section() == theSection) && (aProp->name() == theName))
+      return aProp;
+  }
+  return NULL;
 }
 
-Config_Properties Config_PropManager::getProperties(const std::string& theOwnerId)
+
+Config_Properties Config_PropManager::getProperties()
 {
-  return myPropMap[theOwnerId];
+  Config_Properties aRes;
+  Config_Properties::const_iterator aIt;
+  for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) {
+    Config_Prop* aProp = (*aIt);
+    if (aProp->type() != Config_Prop::Disabled)
+      aRes.push_back(aProp);
+  }
+  return aRes;
 }
 
-
-std::list<std::string> Config_PropManager::getSections(const std::string& theOwnerId)
+std::list<std::string> Config_PropManager::getSections()
 {
+  // Return only non disabled sections
   std::list<std::string> aSections;
-  Config_Properties aProps = getProperties(theOwnerId);
   Config_Properties::const_iterator aIt;
-  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
+  for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) {
     const Config_Prop* aProp = (*aIt);
-    aSections.push_back(aProp->section());
+    if (aProp->type() != Config_Prop::Disabled)
+      aSections.push_back(aProp->section());
   }
   aSections.unique();
   return aSections;
 }
 
-Config_Properties Config_PropManager::getProperties(const std::string& theOwnerId, 
-                                                    const std::string& theSection)
+Config_Properties Config_PropManager::getProperties(const std::string& theSection)
 {
-  Config_Properties aProps = getProperties(theOwnerId);
   Config_Properties aRes;
   Config_Properties::iterator aIt;
-  for (aIt = aProps.begin(); aIt != aProps.end(); aIt++) {
+  for (aIt = myProps.begin(); aIt != myProps.end(); aIt++) {
     Config_Prop* aProp = (*aIt);
-    if (aProp->section() == theSection)
+    if ((aProp->section() == theSection) && (aProp->type() != Config_Prop::Disabled))
       aRes.push_back(aProp);
   }
   return aRes;
 }
 
 
-std::string Config_PropManager::value(const std::string& theOwnerId, 
-                                      const std::string& theSection, 
+std::string Config_PropManager::string(const std::string& theSection, 
                                       const std::string& theName,
                                       const std::string& theDefault)
 {
-  Config_Properties aProps = getProperties(theOwnerId, theSection);
+  Config_Properties aProps = getProperties(theSection);
   Config_Properties::const_iterator aIt;
   for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
     Config_Prop* aProp = (*aIt);
@@ -92,30 +102,81 @@ std::string Config_PropManager::value(const std::string& theOwnerId,
 }
 
 
+std::vector<int> Config_PropManager::color(const std::string& theSection, 
+                                           const std::string& theName,
+                                           const std::string& theDefault)
+{
+  std::string aStr = string(theSection, theName, theDefault);
+  return stringToRGB(aStr);
+}
+
+int Config_PropManager::integer(const std::string& theSection, 
+                      const std::string& theName,
+                      const std::string& theDefault)
+{
+  std::string aStr = string(theSection, theName, theDefault);
+  return stringToInteger(aStr);
+}
+
+double Config_PropManager::real(const std::string& theSection, 
+                      const std::string& theName,
+                      const std::string& theDefault)
+{
+  std::string aStr = string(theSection, theName, theDefault);
+  return stringToDouble(aStr);
+}
+
+
+
 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;
+  if (theColor[0] == '#') {
+    char aBuf[3];
+    char* aP;
+    aBuf[2] = '\0';
+
+    aBuf[0] = theColor[1];
+    aBuf[1] = theColor[2];
+    aRes[0] = strtol(aBuf, &aP, 16);
 
+    aBuf[0] = theColor[3];
+    aBuf[1] = theColor[4];
+    aRes[1] = strtol(aBuf, &aP, 16);
+
+    aBuf[0] = theColor[5];
+    aBuf[1] = theColor[6];
+    aRes[2] = strtol(aBuf, &aP, 16);
+  } else {
+    int aPos = theColor.find(",");
+    char aBuf[10];
+    // Get Red
+    std::size_t length = theColor.copy(aBuf, aPos, 0);
+    aBuf[length] = '\0';
+    aRes[0] = atoi(aBuf);
+
+    // Get Green
+    int aNPos = theColor.find(",", aPos + 1);
+    length = theColor.copy(aBuf, aNPos - aPos - 1, aPos + 1);
+    aBuf[length] = '\0';
+    aRes[1] = atoi(aBuf);
+
+    // Get Green
+    length = theColor.copy(aBuf, theColor.length() - aNPos - 1, aNPos + 1);
+    aBuf[length] = '\0';
+    aRes[2] = atoi(aBuf);
+  }
   return aRes;
-}
\ No newline at end of file
+}
+
+int stringToInteger(const std::string& theInt)
+{
+  return atoi(theInt.c_str());
+}
+
+double stringToDouble(const std::string& theDouble)
+{
+  char* p;
+  return strtod(theDouble.c_str(), &p);
+}
index 4a6d43226a5f1ea9246847c130cfa6f60bff57ae..d650b0e387c6b54dfeacde5d01b2828d5b4a1cae 100644 (file)
@@ -26,46 +26,40 @@ public:
   * \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,
+  static bool registerProp(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();
+  static Config_Prop* findProp(const std::string& theSection,
+                               const std::string& theName);
 
-  //! Returns list of properties by its owner.
-  static Config_Properties getProperties(const std::string& theOwnerId);
+  static Config_Properties getProperties();
 
   //! Returns list of registered section names.
-  static std::list<std::string> getSections(const std::string& theOwnerId);
+  static std::list<std::string> getSections();
 
   //! Returns list of properties by its owner and section.
-  static Config_Properties getProperties(const std::string& theOwnerId, const std::string& theSection);
+  static Config_Properties getProperties(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);              
+  static std::string string(const std::string& theSection, 
+                            const std::string& theName,
+                            const std::string& theDefault);              
+  static std::vector<int> color(const std::string& theSection, 
+                                const std::string& theName,
+                                const std::string& theDefault);              
+  static int integer(const std::string& theSection, 
+                      const std::string& theName,
+                      const std::string& theDefault);              
+  static double real(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;
+  static Config_Properties myProps;
 };
 
 
-CONFIG_EXPORT std::vector<int> stringToRGB(const std::string& theColor);
-
 #endif
\ No newline at end of file
index de05942fef4e37963e79df8ae3c5b5b63ef42c31..4d043e48b1a2a49106529c0d77c0b36e94f97968 100644 (file)
@@ -118,9 +118,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintDistance::getAISObje
   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);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "distance_color", DISTANCE_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
index b63c170c594c5b90f97b0ce518e67cdf2507b322..790068b952fdcb9c28cff1f0130aed8fd79a227b 100644 (file)
@@ -15,7 +15,7 @@
 class SketchPlugin_Line;
 class GeomDataAPI_Point2D;
 
-#define DISTANCE_COLOR "255, 0, 255"
+#define DISTANCE_COLOR "#ff00ff"
 
 /** \class SketchPlugin_ConstraintDistance
  *  \ingroup DataModel
index 7e3ddfd5f7a27a59d2ea63b6842eaf4d7c393775..fcd4a4053d3355b6d845d8cbcdf39fa8a969695b 100644 (file)
@@ -96,9 +96,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintLength::getAISObject
   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);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "length_color", LENGTH_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
index 52d26854a00b908148891ce73d3811ef219d96a7..461cb5ac89240275a6ccf1143b563bbb6f10e2f8 100644 (file)
@@ -10,7 +10,7 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
-#define LENGTH_COLOR "255, 0, 255"
+#define LENGTH_COLOR "#ff00ff"
 
 /** \class SketchPlugin_ConstraintLength
  *  \ingroup DataModel
index ea09ad9cf488a7e5f5de9690df24139fad99af23..e9bcfd0a351db66b157dace6e24103a268765cb4 100644 (file)
@@ -81,9 +81,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintParallel::getAISObje
   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);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "parallel_color", PARALLEL_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
index 9b0570fc04584699b1be36bd75fac931fb6f9189..6e02e1c997b4fd2cfa5dc6fac88481682ac79d76 100644 (file)
@@ -10,7 +10,7 @@
 #include "SketchPlugin_Constraint.h"
 
 
-#define PARALLEL_COLOR "255, 255, 0"
+#define PARALLEL_COLOR "#ffff00"
 
 /** \class SketchPlugin_ConstraintParallel
  *  \ingroup DataModel
index e844f559dd7f711990ce4ac605148252296f18a5..df192e8d9796d527c292922922d3d4207a3bb25f 100644 (file)
@@ -77,9 +77,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintPerpendicular::getAI
   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);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "perpendicular_color", PERPENDICULAR_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
index d6d54b33b4199964bf4a0eb4f00c7f93c8f5f16e..ac565f0763bed0b662e03426fee4b3fb88befbd2 100644 (file)
@@ -9,7 +9,7 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
-#define PERPENDICULAR_COLOR "255, 255, 0"
+#define PERPENDICULAR_COLOR "#ffff00"
 
 /** \class SketchPlugin_ConstraintPerpendicular
  *  \ingroup DataModel
index 72956417001da16d726e62ddc1f3d007030a4990..31b253d542b8010d97f6f19e47fe16f2cc34fef0 100644 (file)
@@ -123,9 +123,7 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_ConstraintRadius::getAISObject
   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);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "radius_color", RADIUS_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
index 6950b9c0cba910dbce05d4e24e02d13f5ae62c53..a6f1e16aeee53bcadb2959f7cef0448b4aa4d2b7 100644 (file)
@@ -9,7 +9,7 @@
 #include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
-#define RADIUS_COLOR "255, 0, 255"
+#define RADIUS_COLOR "#ff00ff"
 
 /** \class SketchPlugin_ConstraintRadius
  *  \ingroup DataModel
index 1a44e28605da683a8a4e7e8b19e426a9c645568c..8f98701349e636a84b92ba8d11783f1d01aa796f 100644 (file)
@@ -16,8 +16,6 @@
 
 using namespace std;
 
-// face of the square-face displayed for selection of general plane
-const double PLANE_SIZE = 200;
 
 SketchPlugin_Line::SketchPlugin_Line()
   : SketchPlugin_Feature()
index 28c20ff4e1f686129567101fc00e25af74cc7e20..eb0b16c3f7bb697ef7796cc62c67efb8aab8fe37 100644 (file)
@@ -32,19 +32,29 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
   ModelAPI_PluginManager::get()->registerPlugin(this);
 
   // register sketcher properties
-  Config_PropManager::registerProp("Sketcher", "Visualization", 
+  Config_PropManager::registerProp("Sketch planes", 
+                                   "planes_color", "Color",
+                                   Config_Prop::Color, SKETCH_PLANE_COLOR);
+  Config_PropManager::registerProp("Sketch planes", 
+                                   "planes_size", "Size",
+                                   Config_Prop::Double, PLANE_SIZE);
+  Config_PropManager::registerProp("Sketch planes", 
+                                   "planes_thikness", "Thickness",
+                                   Config_Prop::Integer, SKETCH_WIDTH);
+
+  Config_PropManager::registerProp("Visualization", 
                                    "parallel_color", "Parallel constraint color",
                                    Config_Prop::Color, PARALLEL_COLOR);
-  Config_PropManager::registerProp("Sketcher", "Visualization", 
+  Config_PropManager::registerProp("Visualization", 
                                    "perpendicular_color", "Perpendicular constraint color",
                                    Config_Prop::Color, PERPENDICULAR_COLOR);
-  Config_PropManager::registerProp("Sketcher", "Visualization", 
+  Config_PropManager::registerProp("Visualization", 
                                    "distance_color", "Distance color",
                                    Config_Prop::Color, DISTANCE_COLOR);
-  Config_PropManager::registerProp("Sketcher", "Visualization", 
+  Config_PropManager::registerProp("Visualization", 
                                    "length_color", "Length color",
                                    Config_Prop::Color, LENGTH_COLOR);
-  Config_PropManager::registerProp("Sketcher", "Visualization", 
+  Config_PropManager::registerProp("Visualization", 
                                    "radius_color", "Radius color",
                                    Config_Prop::Color, RADIUS_COLOR);
 }
index b3cacc6ae777b297067e9935282790f6116cff84..0b0381ab7eb647bedd648eca91db1374a47409ab 100644 (file)
 #include <GeomAlgoAPI_SketchBuilder.h>
 #include <ModelAPI_ResultConstruction.h>
 
+#include <Config_PropManager.h>
 
 using namespace std;
 
-const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color
-const double SKETCH_WIDTH = 4.0; /// the plane edge width
-// face of the square-face displayed for selection of general plane
-const double PLANE_SIZE = 200;
-
 
 SketchPlugin_Sketch::SketchPlugin_Sketch()
 {
@@ -138,8 +134,9 @@ void addPlane(double theX, double theY, double theZ, std::list<boost::shared_ptr
 {
   boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
   boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
+  double aSize = Config_PropManager::integer("Sketch definition", "Size of planes", PLANE_SIZE);
   boost::shared_ptr<GeomAPI_Shape> aFace = 
-    GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+    GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, aSize);
   theShapes.push_back(aFace);
 }
 
@@ -160,8 +157,15 @@ boost::shared_ptr<GeomAPI_AISObject> SketchPlugin_Sketch::
       boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
       aAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject());
       aAIS->createShape(aCompound);
-      aAIS->setColor(SKETCH_PLANE_COLOR);
-      aAIS->setWidth(SKETCH_WIDTH);
+
+      std::vector<int> aRGB = Config_PropManager::color("Sketch definition", 
+                                                        "planes_color", 
+                                                        SKETCH_PLANE_COLOR);
+      aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+
+      aAIS->setWidth(Config_PropManager::integer("Sketch definition", 
+                                                 "planes_thikness",
+                                                 SKETCH_WIDTH));
     }
     return aAIS;
   }
index 3c71a6505c29a65eb616adc9a7791d6a97888eb3..c0845fa8507fa342620064830496d2a8b23ad7b4 100644 (file)
 #include <GeomAPI_IPresentable.h>
 #include <list>
 
+/// the plane edge color
+#define SKETCH_PLANE_COLOR "#700000" 
+
+/// the plane edge width
+#define SKETCH_WIDTH        "4"
+
+/// face of the square-face displayed for selection of general plane
+#define PLANE_SIZE          "200"     
+
 /**\class SketchPlugin_Sketch
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
index b310ba7ced5b05ba717d831af1a3f21fe251f558..266580799fa83ab4adb725b94ed823d820d8d395 100644 (file)
@@ -42,6 +42,35 @@ bool XGUI_Preferences::editPreferences(XGUI_Prefs& theModified)
 }
 
 
+void XGUI_Preferences::updateCustomProps()
+{
+  Config_Properties aProps = Config_PropManager::getProperties();
+  Config_Properties::iterator aIt;
+  for (aIt = aProps.begin(); aIt != aProps.end(); ++ aIt) {
+    Config_Prop* aProp = (*aIt);
+    QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()), 
+                                              QString(aProp->name().c_str()));
+    if (!aVal.isNull())
+      aProp->setValue(qPrintable(aVal));
+  }
+}
+
+
+void XGUI_Preferences::loadCustomProps()
+{
+  QStringList aSections = myResourceMgr->sections();
+  foreach (QString aSection, aSections) {
+    QStringList aParams = myResourceMgr->parameters(aSection);
+    foreach (QString aParam, aParams) {
+      Config_PropManager::registerProp(qPrintable(aSection),
+                                       qPrintable(aParam),
+                                       "", Config_Prop::Disabled, 
+                                       qPrintable(myResourceMgr->stringValue(aSection, aParam)));
+    }
+  }
+}
+
+
 
 //**********************************************************
 //**********************************************************
@@ -78,18 +107,15 @@ XGUI_PreferencesDlg::~XGUI_PreferencesDlg()
 
 void XGUI_PreferencesDlg::createEditors()
 {
-  int aLFpage = myPreferences->addItem("Desktop");
-  //myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png"));
+  int aPage = myPreferences->addItem(tr("Desktop"));
+  myPreferences->setItemIcon(aPage, QIcon(":pictures/view_prefs.png"));
 
-  createMenuPage(aLFpage);
-  createViewerPage(aLFpage);
+  createMenuPage(aPage);
+  createViewerPage(aPage);
 
-  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)));
-  }
+  aPage = myPreferences->addItem(tr("Module"));
+  myPreferences->setItemIcon(aPage, QIcon(":pictures/module.png"));
+  createCustomPage(aPage);
 }
 
 void XGUI_PreferencesDlg::createViewerPage(int thePageId)
@@ -152,44 +178,35 @@ void XGUI_PreferencesDlg::createMenuPage(int thePageId)
 }
 
 
-void XGUI_PreferencesDlg::createCustomPage(int thePageId, Config_Properties& theProps)
+void XGUI_PreferencesDlg::createCustomPage(int thePageId)
 {
   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 );
+  std::list<std::string> aSections = Config_PropManager::getSections();
+  std::list<std::string>::const_iterator it;
+  for (it = aSections.cbegin(); it != aSections.cend(); ++it) {
+    Config_Properties aProps = Config_PropManager::getProperties(*it);
+    int aTab = myPreferences->addItem(QString((*it).c_str()), thePageId );
     myPreferences->setItemProperty( "columns", 2, aTab );
-    Config_Properties& aProps = it.value();
+
+    Config_Properties::const_iterator aIt;
     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()) );
+      Config_Prop* aProp = (*aIt);
+      // check that the property is defined
+      QString aSection(aProp->section().c_str());
+      QString aName(aProp->name().c_str());
+      if (!aResMgr->hasValue(aSection, aName)) {
+        aResMgr->setValue(aSection, aName, QString(aProp->value().c_str()));
+        isResModified = true;
+      }
+      // Add item
+      if (aProp->type() != Config_Prop::Disabled)
+        myPreferences->addItem( tr(aProp->title().c_str()), aTab,
+                                (SUIT_PreferenceMgr::PrefItemType)aProp->type(), 
+                                QString(aProp->section().c_str()), 
+                                QString(aProp->name().c_str()) );
     }
   }
 }
@@ -199,9 +216,13 @@ void XGUI_PreferencesDlg::accept()
 {
   myPreferences->store();
   myIsChanged = true;
+
+  // Save custom properties
+  XGUI_Preferences::updateCustomProps();
   QDialog::accept();
 }
 
+
 void XGUI_PreferencesDlg::modified(XGUI_Prefs& theModified) const
 {
   theModified = myPreferences->modified();
index bd30a31a581b0558d2fcf22b7eb22c362203e0f4..a694c34ba60446a24db62af1ba804ba9c8c924d7 100644 (file)
@@ -31,6 +31,10 @@ public:
 
   static SUIT_ResourceMgr* resourceMgr();
 
+  static void updateCustomProps();
+
+  static void loadCustomProps();
+
 private:
   static SUIT_ResourceMgr* myResourceMgr;
 };
@@ -76,7 +80,9 @@ private:
   void createEditors();
   void createViewerPage(int thePageId);
   void createMenuPage(int thePageId);
-  void createCustomPage(int thePageId, Config_Properties& theProps);
+  void createCustomPage(int thePageId);
+
+  void updateCustomProps();
   
   XGUI_PreferencesMgr* myPreferences;
   bool myIsChanged;
index 3d5441be77fa9b022830fd5e788ec24ace9d5bfb..021ab16b1ac00e857d3d0e8f9e6898a88e2080bc 100644 (file)
@@ -145,6 +145,7 @@ void XGUI_Workshop::startApplication()
     myMainWindow->show();
     updateCommandStatus();
   }
+  XGUI_Preferences::loadCustomProps();
   onNew();
 }
 
index 8a616c63812fefec59f886119648174f323043b7..07c5f4c9222fa875710815a3b5b4b1ba7aedc259 100644 (file)
@@ -62,5 +62,6 @@
      <file>pictures/eye_pencil_closed.png</file>
    
      <file>pictures/view_prefs.png</file>
+     <file>pictures/module.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/module.png b/src/XGUI/pictures/module.png
new file mode 100644 (file)
index 0000000..e44a041
Binary files /dev/null and b/src/XGUI/pictures/module.png differ