Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Fri, 27 Feb 2015 12:41:47 +0000 (15:41 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 27 Feb 2015 12:41:47 +0000 (15:41 +0300)
39 files changed:
src/Config/Config_AttributeMessage.cpp
src/Config/Config_AttributeMessage.h
src/Config/Config_Common.cpp
src/Config/Config_Common.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/ConstructionPlugin/axis_widget.xml
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/ModuleBase/ModuleBase_WidgetChoice.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp
src/ModuleBase/ModuleBase_WidgetFileSelector.h
src/ModuleBase/ModuleBase_WidgetLabel.cpp
src/ModuleBase/ModuleBase_WidgetLabel.h
src/ModuleBase/ModuleBase_WidgetLineEdit.cpp
src/ModuleBase/ModuleBase_WidgetLineEdit.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h

index 3b37a27bdcef9d45009b941ae70c779403bed470..8009b12e49514ad900f7b43d5ca27d181415dc66 100644 (file)
@@ -5,10 +5,11 @@
 Config_AttributeMessage::Config_AttributeMessage(const Events_ID theId, const void* theParent)
     : Events_Message(theId, theParent)
 {
-  myAttributeId = ""; // Attribute unique id
-  myFeatureId = ""; // Feature unique id
+  myAttributeId = std::string(); // Attribute unique id
+  myFeatureId = std::string(); // Feature unique id
   myIsObligatory = true;
   myIsConcealment = false;
+  myCaseId = std::string();
 }
 
 Config_AttributeMessage::~Config_AttributeMessage()
@@ -55,3 +56,13 @@ void Config_AttributeMessage::setObligatory(bool theObligatory)
 {
   this->myIsObligatory = theObligatory;
 }
+
+const std::string& Config_AttributeMessage::caseId() const
+{
+  return myCaseId;
+}
+
+void Config_AttributeMessage::setCaseId(const std::string& theId)
+{
+  this->myCaseId = theId;
+}
index bfb9b64b1b5c1deb55c6986c7184c8ca78ffaa9e..7b2bd12b6014c223bd1f7161fd5ca4b5986706d4 100644 (file)
@@ -22,6 +22,7 @@ class Config_AttributeMessage : public Events_Message
   std::string myFeatureId; ///< Attribute's feature's unique id
   bool myIsObligatory; ///< Required to be set by user, else it's feature is invalid.
   bool myIsConcealment; ///< If true, conceals features used as input
+  std::string myCaseId; ///< Attribute's case's id, if it placed inside a paged containers
 
  public:
   /// Same event as Config_FeatureMessage::MODEL_EVENT()
@@ -45,15 +46,20 @@ class Config_AttributeMessage : public Events_Message
   CONFIG_EXPORT bool isObligatory() const;
   /// Returns true if attribute should conceal input features
   CONFIG_EXPORT bool isConcealment() const;
+  /// Returns id of a case which contain the attribute
+  CONFIG_EXPORT const std::string& caseId() const;
 
   /// Set attribute's unique id
   CONFIG_EXPORT void setAttributeId(const std::string& theId);
   /// Set attribute's feature's unique id
   CONFIG_EXPORT void setFeatureId(const std::string& id);
-  /// Returns attribute's concealment state
+  /// Set attribute's concealment state
   CONFIG_EXPORT void setConcealment(bool isConcealment);
-  /// Returns attribute's obligatory state
+  /// Set attribute's obligatory state
   CONFIG_EXPORT void setObligatory(bool isObligatory);
+  /// Set attribute's case
+  CONFIG_EXPORT void setCaseId(const std::string& id);
+
 };
 
 #endif // ATTRIBUTE_MESSAGE_H
index 9c4df7f57c539174f1496979685e7d8b48c113e9..8ffc9e126b6938135b3cde07239281aae9969115 100644 (file)
@@ -27,7 +27,6 @@ bool isElementNode(xmlNodePtr theNode)
 \r
 bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)\r
 {\r
-  bool result = false;\r
   const xmlChar* aName = theNode->name;\r
   if (!aName || !isElementNode(theNode)) {\r
     return false;\r
@@ -50,19 +49,44 @@ bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)
   return false;\r
 }\r
 \r
+bool isAttributeNode(xmlNodePtr theNode)\r
+{\r
+  if(!isElementNode(theNode))\r
+    return false;\r
+  // it's parent is "feature" or "source" or page ("case" or "box")\r
+  if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, \r
+                         WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL))\r
+    return false;\r
+\r
+  //it should not be a "source" or a "validator" node\r
+  bool isLogical = isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL);\r
+  bool isPagedContainer = isNode(theNode, WDG_TOOLBOX, WDG_TOOLBOX_BOX,\r
+                                          WDG_SWITCH, WDG_SWITCH_CASE,  NULL);\r
+  return !isLogical && !isPagedContainer;\r
+}\r
+\r
 bool isWidgetNode(xmlNodePtr theNode)\r
 {\r
   if(!isElementNode(theNode))\r
     return false;\r
   // it's parent is "feature" or "source"\r
-  xmlNodePtr aParentNode = theNode->parent;\r
-  if(!isNode(aParentNode, NODE_FEATURE, NODE_SOURCE, NULL))\r
+  if(!hasParent(theNode, NODE_FEATURE, NODE_SOURCE, \r
+                         WDG_TOOLBOX_BOX, WDG_SWITCH_CASE, NULL))\r
     return false;\r
 \r
   //it should not be a "source" or a "validator" node\r
   return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL);\r
 }\r
 \r
+// widget api?\r
+bool isCaseNode(xmlNodePtr theNode)\r
+{\r
+  if(!isElementNode(theNode))\r
+    return false;\r
+\r
+  return isNode(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL);\r
+}\r
+\r
 bool hasChild(xmlNodePtr theNode)\r
 {\r
   xmlNodePtr aNode = theNode->children;\r
@@ -74,6 +98,48 @@ bool hasChild(xmlNodePtr theNode)
   return false;\r
 }\r
 \r
+bool hasParent(xmlNodePtr theNode)\r
+{\r
+  xmlNodePtr aNode = theNode->parent;\r
+  if (!aNode) {\r
+    return false;\r
+  }\r
+  for (; aNode; aNode = aNode->next) {\r
+    if (isElementNode(theNode)) {\r
+      return true;\r
+    }\r
+  }\r
+  return false;\r
+}\r
+\r
+bool hasParent(xmlNodePtr theNode, const char* theNodeName, ...)\r
+{\r
+  if (!hasParent(theNode)) {\r
+    return false; // have no parents at all\r
+  }\r
+  xmlNodePtr aNode = theNode->parent;\r
+  const xmlChar* aName = aNode->name;\r
+  if (!aName || !isElementNode(aNode)) {\r
+    return false;\r
+  }\r
+  if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {\r
+    return true;\r
+  }\r
+  va_list args;  // define argument list variable\r
+  va_start(args, theNodeName);  // init list; point to last defined argument\r
+  while (true) {\r
+    char *anArg = va_arg (args, char*);  // get next argument\r
+    if (anArg == NULL)\r
+      break;\r
+    if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {\r
+      va_end(args);  // cleanup the system stack\r
+      return true;\r
+    }\r
+  }\r
+  va_end(args);  // cleanup the system stack\r
+  return false;\r
+}\r
+\r
 bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,\r
                       std::list<std::string>& outValidatorParameters)\r
 {\r
index c53586eb50cef0e721ad49aceabe5a703cd6f936..52fc1e1726fa0adbfedd95f72a7f3a930995c362 100644 (file)
@@ -44,10 +44,21 @@ CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
 CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
 
 /*!
- * Checks is the given node is attribute (widget) node.
+ * Checks if the given node is attribute node.
+ * Attribute node represents a widget, that is able to store/restore
+ * values from the model. Actually it's every widget, displayed
+ * in the XGUI_PropertyPanel, except paged containers (toolbox, switch/case).
+ */
+CONFIG_EXPORT bool isAttributeNode(xmlNodePtr theNode);
+
+/*!
+ * Checks if the given node is widget node.
+ * Widget nodes are attribute node + paged containers nodes.
  */
 CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
 
+CONFIG_EXPORT bool isCaseNode(xmlNodePtr theNode);
+
 /*!
  * Every xml node has child. Even if there is no explicit
  * child nodes libxml gives the "Text node" as child.
@@ -57,6 +68,17 @@ CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
  */
 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
 
+
+/*!
+ * Checks if the given node has a valid parent.
+ */
+CONFIG_EXPORT bool hasParent(xmlNodePtr theNode);
+
+/*!
+ * Checks if the given node has a valid parent with any of the given node names.
+ */
+CONFIG_EXPORT bool hasParent(xmlNodePtr theNode, const char* theNodeName, ...);
+
 /*!
  * Returns named property for an id node as std::string and the parameters of the node.
  */
index 839eca2410e55d74eaab5aa26e70778309e5bd30..adf8f5e7abb8623d3edc81e1f442ec2393ef7835 100644 (file)
@@ -61,26 +61,49 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
   } else if (isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL)) {
     storeAttribute(theNode, _ID);
     storeAttribute(theNode, WORKBENCH_DOC);
-  } else if (myIsProcessWidgets && isWidgetNode(theNode)) {
-    std::shared_ptr<Config_AttributeMessage> aMessage(new Config_AttributeMessage(aMenuItemEvent, this));
-    aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
-    std::string anAttributeID = getProperty(theNode, _ID);
-    if (!anAttributeID.empty()) {
-      aMessage->setAttributeId(anAttributeID);
-      aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
-      aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
-      Events_Loop::loop()->send(aMessage);
+  } else if (myIsProcessWidgets) {
+    // widgets, like shape_selector or containers, like toolbox
+    if (isAttributeNode(theNode)) {
+      std::shared_ptr<Config_AttributeMessage> aMessage(new Config_AttributeMessage(aMenuItemEvent, this));
+      aMessage->setFeatureId(restoreAttribute(NODE_FEATURE, _ID));
+      std::string anAttributeID = getProperty(theNode, _ID);
+      if (!anAttributeID.empty()) {
+        aMessage->setAttributeId(anAttributeID);
+        aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
+        aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
+        // nested "paged" widgets are not allowed, this issue may be resolved here:
+        if (hasParent(theNode, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, NULL)) {
+          const char* kWdgCase = hasParent(theNode, WDG_SWITCH_CASE, NULL)
+                                 ? WDG_SWITCH_CASE
+                                 : WDG_TOOLBOX_BOX;
+          aMessage->setCaseId(restoreAttribute(kWdgCase, _ID));
+        }
+        Events_Loop::loop()->send(aMessage);
+      }
+    // container pages, like "case" or "box"
+    } else if (isCaseNode(theNode)) {
+      storeAttribute(theNode, _ID); // save case:caseId (or box:boxId)
     }
   }
   //Process SOURCE, VALIDATOR nodes.
   Config_XMLReader::processNode(theNode);
 }
 
+void Config_FeatureReader::cleanup(xmlNodePtr theNode)
+{
+  if (isCaseNode(theNode)) {
+    // cleanup id of cases when leave case node
+    cleanupAttribute(theNode, _ID);
+  }
+}
+
 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
 {
   bool result = isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
   if(!result && myIsProcessWidgets) {
-    result = isNode(theNode, NODE_FEATURE, NULL);
+    result = isNode(theNode, NODE_FEATURE, 
+                             WDG_TOOLBOX, WDG_TOOLBOX_BOX,
+                             WDG_SWITCH, WDG_SWITCH_CASE, NULL);
   }
   return result;
 }
@@ -138,3 +161,23 @@ std::string Config_FeatureReader::restoreAttribute(const char* theNodeName,
   }
   return result;
 }
+
+bool Config_FeatureReader::cleanupAttribute(xmlNodePtr theNode,
+                                            const char* theNodeAttribute)
+{
+  return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
+}
+
+bool Config_FeatureReader::cleanupAttribute(const char* theNodeName,
+                                            const char* theNodeAttribute)
+{
+  std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
+  bool result = false;
+  std::map<std::string, std::string>::iterator anEntry = myParentAttributes.find(aKey);
+  if( anEntry != myParentAttributes.end()) {
+    myParentAttributes.erase(anEntry);
+    result = true;
+  }
+  return result;
+}
+
index 7f7889aaabfbd07fe0ab741f22162b226c354765..75eb376e5cdd88ba8a6249a863e522e7ec1c3163 100644 (file)
@@ -39,6 +39,10 @@ class Config_FeatureReader : public Config_XMLReader
  protected:
   /// Overloaded method. Defines how to process each node
   virtual void processNode(xmlNodePtr aNode);
+
+  /// Overloaded method. Clears attribute cache on extit from attribute's node
+  virtual void cleanup(xmlNodePtr aNode);
+
   /// Overloaded method. Defines if the given node should be parsed recursively
   virtual bool processChildren(xmlNodePtr aNode);
 
@@ -54,6 +58,9 @@ class Config_FeatureReader : public Config_XMLReader
   /// Restores an attribute from internal map.
   std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
 
+  bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
+
  private:
   /// A map to store all parent's attributes.
   /// The key has from "Node_Name:Node_Attribute"
index 03af8f4c7e5c4d8b43f1a5e6f7ec5ad1447c881e..768232b7457e05006f7e9b44caf1ba726fb124bd 100644 (file)
@@ -86,6 +86,11 @@ void Config_XMLReader::processNode(xmlNodePtr theNode)
   }
 }
 
+void Config_XMLReader::cleanup(xmlNodePtr)
+{
+  // do nothing;
+}
+
 bool Config_XMLReader::processChildren(xmlNodePtr aNode)
 {
   return true;
@@ -126,6 +131,7 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent)
     if (processChildren(aNode)) {
       readRecursively(aNode);
     }
+    cleanup(aNode);
   }
 }
 
index 01e64c39494cecb606212073c5daec89c38fd8a9..603ce7d1faea03605dcebf388af0af69105f8bc3 100644 (file)
@@ -61,6 +61,12 @@ class Config_XMLReader
    * "selection_filter" nodes.
    */
   virtual void processNode(xmlNodePtr aNode);
+
+  /*!
+   * This method gives an ability to finalize processing of a node,
+   * when reader is about to leave the node (node and all it's children are processed)
+   */
+  virtual void cleanup(xmlNodePtr aNode);
   /*!
    * \brief Defines which nodes should be processed recursively. Virtual.
    * The default impl is to read all nodes.
index a3424e3f1b1d5acb8a0b43f68b91684142b7da1d..0042745695cfdb98d3a7011925caded1e206e97e 100644 (file)
@@ -1,19 +1,32 @@
 <!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
 <source>
-  <shape_selector id="firstPoint"
-    label="First point"
-    icon=":icons/point.png"
-    tooltip="Select a first point"
-    shape_types="vertex">
-    <selection_filter id="NoConstructionSubShapesFilter"/>
-  </shape_selector>
-  <shape_selector id="secondPoint"
-    label="Second point"
-    icon=":icons/point.png"
-    tooltip="Select a second point"
-    shape_types="vertex">
-    <selection_filter id="NoConstructionSubShapesFilter"/>
-    <validator id="PartSet_DifferentShapes"/>
-  </shape_selector>
+  <toolbox>
+    <box id="AxisByPointsCase" title="By two points">
+      <shape_selector id="firstPoint"
+        label="First point"
+        icon=":icons/point.png"
+        tooltip="Select a first point"
+        shape_types="vertex">
+        <selection_filter id="NoConstructionSubShapesFilter"/>
+      </shape_selector>
+      <shape_selector id="secondPoint"
+        label="Second point"
+        icon=":icons/point.png"
+        tooltip="Select a second point"
+        shape_types="vertex">
+        <selection_filter id="NoConstructionSubShapesFilter"/>
+        <validator id="PartSet_DifferentShapes"/>
+      </shape_selector>
+    </box>
+    <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face">
+      <shape_selector id="main_object" 
+        label="Main object" 
+        icon=":icons/circle.png" 
+        tooltip="Select a cylindrical object"
+        shape_types="face solid shell">
+      </shape_selector>
+    </box>
+  </toolbox>
+  
 </source>
index ea7de61acc3b52dfd5b3e3fbb7dc0482b88af1d1..a4368946be30ddbfe501965959559300eb6e3487 100644 (file)
 #include <Events_Loop.h>
 
 #include <QEvent>
-#include <QWidget>
 #include <QGraphicsDropShadowEffect>
 #include <QColor>
 #include <QLabel>
 
-ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData,
+ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
+                                               const Config_WidgetAPI* theData,
                                                const std::string& theParentId)
-    : QObject(theParent),
-      myParentId(theParentId)
+    : QWidget(theParent),
+      myParentId(theParentId),
+      myIsEditing(false)
 {
   myDefaultValue = theData->getProperty(ATTR_DEFAULT);
   myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED;
index 3db67b661888ca9cd9abc755228f0b0636aab492..03067aa6810463257d3c92438816957ca870ff49 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <ModelAPI_Feature.h>
 
-#include <QObject>
+#include <QWidget>
 
 #include <memory>
 
@@ -28,7 +28,7 @@ class QKeyEvent;
  * Every widget are able to save/restore data from the model and/or to contain other widgets.
  *
  */
-class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QObject
+class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QWidget
 {
 Q_OBJECT
  public:
@@ -89,10 +89,6 @@ Q_OBJECT
   /// The methiod called when widget is deactivated
   virtual void deactivate() {}
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  virtual QWidget* getControl() const = 0;
-
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const = 0;
index 38357449c906bcafbf50e0f4406af18e662db9ff..06e8fb08dc8befc26ccd7f1dda8c3304313598eb 100644 (file)
@@ -28,7 +28,7 @@ void adjustMargins(QLayout* theLayout)
 {
   if(!theLayout)
     return;
-  theLayout->setContentsMargins(2, 5, 5, 2);
+  theLayout->setContentsMargins(2, 5, 2, 5);
   theLayout->setSpacing(4);
 }
 
index af2e7ee0ef3b79879863c3f61a17f8470133a47d..f1d5f2ba08a1443c15d63d9da31ea051d9bfaae9 100644 (file)
@@ -39,11 +39,6 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue()
 {
 }
 
-QWidget* ModuleBase_WidgetBoolValue::getControl() const
-{
-  return myCheckBox;
-}
-
 bool ModuleBase_WidgetBoolValue::storeValueCustom() const
 {
   DataPtr aData = myFeature->data();
index 47d574a14be67627cdf53f8b12f9d18dd0f53676..f5c3f494f91eeae10b00df4e649f3915c78a89bf 100644 (file)
@@ -35,8 +35,6 @@ Q_OBJECT
 
   virtual QList<QWidget*> getControls() const;
 
-  QWidget* getControl() const;
-
 protected:
   /// Saves the internal parameters to the given feature
   /// \return True in success
index e77c2d9790cb284b03278ed5dd03194e8b422386..83537b71d3bcf293047252fea682769153a22c48 100644 (file)
@@ -21,18 +21,17 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
                                                  const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  myContainer = new QWidget(theParent);
-  QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+  QHBoxLayout* aLayout = new QHBoxLayout(this);
   ModuleBase_Tools::adjustMargins(aLayout);
 
   QString aLabelText = QString::fromStdString(theData->widgetLabel());
   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
-  myLabel = new QLabel(aLabelText, myContainer);
+  myLabel = new QLabel(aLabelText, this);
   if (!aLabelIcon.isEmpty())
     myLabel->setPixmap(QPixmap(aLabelIcon));
   aLayout->addWidget(myLabel);
 
-  myCombo = new QComboBox(myContainer);
+  myCombo = new QComboBox(this);
   aLayout->addWidget(myCombo, 1);
  
   std::string aTypes = theData->getProperty("string_list");
index fd201bd8696b37febec4c81e9669c07a55bf6e14..412821d2c475ef3865f089b2bda411f99a93cfb5 100644 (file)
@@ -43,13 +43,6 @@ Q_OBJECT
 
   virtual bool focusTo();
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const
-  {
-    return myContainer;
-  }
-
   /// Returns list of widget controls
   /// \return a controls list
   virtual QList<QWidget*> getControls() const;
@@ -64,9 +57,6 @@ private slots:
   void onCurrentIndexChanged(int theIndex);
 
 private:
-  /// Container widget
-  QWidget* myContainer;
-
   /// The label
   QLabel* myLabel;
 
index df255b46bf363295b9776e0700851d077d7a98b6..20c798187058c1520d6caee2d67f882da30794d1 100644 (file)
@@ -18,7 +18,7 @@
 #include <ModelAPI_Events.h>
 
 #include <QWidget>
-#include <QLayout>
+#include <QFormLayout>
 #include <QLabel>
 #include <QEvent>
 #include <QTimer>
@@ -37,18 +37,16 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
                                                            const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  myContainer = new QWidget(theParent);
-  QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
+  QFormLayout* aControlLay = new QFormLayout(this);
   ModuleBase_Tools::adjustMargins(aControlLay);
 
   QString aLabelText = QString::fromStdString(theData->widgetLabel());
   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
-  myLabel = new QLabel(aLabelText, myContainer);
+  myLabel = new QLabel(aLabelText, this);
   if (!aLabelIcon.isEmpty())
     myLabel->setPixmap(QPixmap(aLabelIcon));
-  aControlLay->addWidget(myLabel);
 
-  mySpinBox = new ModuleBase_DoubleSpinBox(myContainer);
+  mySpinBox = new ModuleBase_DoubleSpinBox(this);
   QString anObjName = QString::fromStdString(attributeID());
   mySpinBox->setObjectName(anObjName);
 
@@ -87,9 +85,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
   QString aTTip = QString::fromStdString(theData->widgetTooltip());
   mySpinBox->setToolTip(aTTip);
 
-  aControlLay->addWidget(mySpinBox);
-  aControlLay->setStretch(1, 1);
-
+  aControlLay->addRow(myLabel, mySpinBox);
   connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
 }
 
index fd447a78050f26c525c4e3029855b383df288e7c..a83292914eda6145fcb24f9927d021705793a708 100644 (file)
@@ -48,13 +48,6 @@ Q_OBJECT
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const
-  {
-    return myContainer;
-  }
-
  public slots:
  // Delayed value chnged: when user starts typing something,
  // it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
@@ -66,9 +59,6 @@ protected:
   virtual bool storeValueCustom() const;
 
 protected:
-   /// Container for thw widget controls
-  QWidget* myContainer;
-
   /// Label of the widget
   QLabel* myLabel;
 
index 40f7227ca6d344cf1a2bfd77eb436960a91e8fd2..d606c0bf74105eafd628df4f0118637d54d3fc83 100644 (file)
@@ -70,6 +70,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
     return;
 
   QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
+  bool isStretchLayout = false;
   do {  //Iterate over each node
     std::string aWdgType = myWidgetApi->widgetType();
     //Create a widget (doublevalue, groupbox, toolbox, etc.
@@ -96,8 +97,8 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
       do {
         QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
         QWidget* aPage = new QWidget(aWidget);
-        ModuleBase_Tools::adjustMargins(aPage);
         createWidget(aPage);
+        ModuleBase_Tools::adjustMargins(aPage);
         if (aWdgType == WDG_SWITCH) {
           ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
           aSwitch->addPage(aPage, aPageName);
@@ -105,22 +106,37 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
           QToolBox* aToolbox = qobject_cast<QToolBox*>(aWidget);
           aToolbox->addItem(aPage, aPageName);
         }
+
       } while (myWidgetApi->toNextWidget());
     }
+    if (aWidget && !isStretchLayout) {
+      isStretchLayout = !hasExpandingControls(aWidget);
+    }
   } while (myWidgetApi->toNextWidget());
+  if (isStretchLayout) {
+    aWidgetLay->addStretch(1);
+  }
   theParent->setLayout(aWidgetLay);
 }
 
-
-QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent)
 {
-  ModuleBase_WidgetLabel* aWgt =
-      new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aWgt);
-  return aWgt->getControl();
+  bool result = false;
+  QList<QWidget *> aListToCheck;
+  aListToCheck << theParent;
+  ModuleBase_ModelWidget* aModelWidget = qobject_cast<ModuleBase_ModelWidget*>(theParent);
+  if(aModelWidget) {
+    aListToCheck << aModelWidget->getControls();
+  }
+  foreach(QWidget* eachWidget, aListToCheck) {
+    QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
+    if(aVPolicy & QSizePolicy::ExpandFlag) {
+      result = true;
+    }
+  }
+  return result;
 }
 
-
 QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
                                                       QWidget* theParent)
 {
@@ -137,12 +153,6 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
   } else if (theType == WDG_BOOLVALUE) {
     result = booleanControl(theParent);
 
-  //} else if (theType == WDG_FEATURE_SELECTOR) {
-  //  result = featureSelectorControl(theParent);
-
-  //} else if (theType == WDG_FEATURE_OR_ATTRIBUTE_SELECTOR) {
-  //  result = featureOrAttributeSelectorControl(theParent);
-
   } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
     result = doubleValueEditor(theParent);
 
@@ -179,9 +189,21 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q
     result = aGroupBox;
   } else if (theType == WDG_TOOLBOX) {
     result = new QToolBox(theParent);
+    // Dark-grey rounded tabs with button-like border #and bold font
+    QString css = "QToolBox::tab{background-color:#c8c8c8;"
+                                "border-radius:5px;"
+                                "border:1px inset;"
+                                //"font-weight:700;"
+                                "border-color:#fff #505050 #505050 #fff;}";
+    result->setStyleSheet(css);
+    // default vertical size policy is preferred
+    QSizePolicy aSizePolicy = result->sizePolicy();
+    aSizePolicy.setVerticalPolicy(QSizePolicy::MinimumExpanding);
+    result->setSizePolicy(aSizePolicy);
   } else if (theType == WDG_SWITCH) {
     result = new ModuleBase_WidgetSwitch(theParent);
   } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
+    // Do nothing for "box" and "case"
     result = NULL;
   }
 #ifdef _DEBUG
@@ -190,12 +212,20 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q
   return result;
 }
 
+QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+{
+  ModuleBase_WidgetLabel* aWgt =
+      new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
+  myModelWidgets.append(aWgt);
+  return aWgt;
+}
+
 QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
 {
   ModuleBase_WidgetDoubleValue* aDblWgt =
       new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aDblWgt);
-  return aDblWgt->getControl();
+  return aDblWgt;
 }
 
 QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
@@ -203,7 +233,7 @@ QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
   ModuleBase_WidgetEditor* aWidget =
       new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aWidget);
-  return aWidget->getControl();
+  return aWidget;
 }
 
 QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent)
@@ -211,7 +241,7 @@ QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent)
   ModuleBase_WidgetShapeSelector* aSelector =
       new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
   myModelWidgets.append(aSelector);
-  return aSelector->getControl();
+  return aSelector;
 }
 
 QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
@@ -219,7 +249,7 @@ QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
   ModuleBase_WidgetBoolValue* aBoolWgt =
       new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aBoolWgt);
-  return aBoolWgt->getControl();
+  return aBoolWgt;
 }
 
 QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
@@ -227,7 +257,7 @@ QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
   ModuleBase_WidgetFileSelector* aFileSelectorWgt =
       new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
   myModelWidgets.append(aFileSelectorWgt);
-  return aFileSelectorWgt->getControl();
+  return aFileSelectorWgt;
 }
 
 QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
@@ -235,7 +265,7 @@ QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
   ModuleBase_WidgetChoice* aChoiceWgt =
       new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
   myModelWidgets.append(aChoiceWgt);
-  return aChoiceWgt->getControl();
+  return aChoiceWgt;
 }
 
 QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
@@ -243,7 +273,7 @@ QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
   ModuleBase_WidgetLineEdit* aLineEditWgt =
       new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
   myModelWidgets.append(aLineEditWgt);
-  return aLineEditWgt->getControl();
+  return aLineEditWgt;
 }
 
 QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
@@ -251,7 +281,7 @@ QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
   ModuleBase_WidgetMultiSelector* aMultiselectorWgt =
       new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
   myModelWidgets.append(aMultiselectorWgt);
-  return aMultiselectorWgt->getControl();
+  return aMultiselectorWgt;
 }
 
 QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)
index 1292cec57fdd47a674a2d7121e596c3233f0baef..93b8443ae6c87f30dd041f61d5ec5277020c9756 100644 (file)
@@ -40,6 +40,7 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
   /// \param theParent a parent widget
   void createWidget(QWidget* theParent);
 
+
   /// Returns list of model widgets
   QList<ModuleBase_ModelWidget*> getModelWidgets() const
   {
@@ -47,6 +48,8 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
   }
 
  protected:
+  /// check if ModuleBase_Widget has expandable widgets in getControls
+  bool hasExpandingControls(QWidget* theParent);
    /// Create widget by its type
    /// \param theType a type
    /// \param theParent a parent widget
index d857d2d66f444a4e5e69aa183627f022511565cd..ac79ba82330ead050dcd9f6b306741734b812950 100644 (file)
@@ -37,15 +37,14 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent,
   myTitle = QString::fromStdString(theData->getProperty("title"));
   myDefaultPath = QString::fromStdString(theData->getProperty("path"));
 
-  myMainWidget = new QWidget(theParent);
-  QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+  QGridLayout* aMainLay = new QGridLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
-  QLabel* aTitleLabel = new QLabel(myTitle, myMainWidget);
+  QLabel* aTitleLabel = new QLabel(myTitle, this);
   aTitleLabel->setIndent(1);
   aMainLay->addWidget(aTitleLabel, 0, 0);
-  myPathField = new QLineEdit(myMainWidget);
+  myPathField = new QLineEdit(this);
   aMainLay->addWidget(myPathField, 1, 0);
-  QPushButton* aSelectPathBtn = new QPushButton("...", myMainWidget);
+  QPushButton* aSelectPathBtn = new QPushButton("...", this);
   aSelectPathBtn->setToolTip(tr("Select file..."));
   aSelectPathBtn->setMaximumWidth(20);
   aSelectPathBtn->setMaximumHeight(20);
@@ -53,7 +52,7 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent,
   aMainLay->setColumnStretch(0, 1);
   myPathField->setMinimumHeight(20);
   aMainLay->setHorizontalSpacing(1);
-  myMainWidget->setLayout(aMainLay);
+  this->setLayout(aMainLay);
 
   connect(myPathField, SIGNAL(textChanged(const QString&)),
           this,        SLOT(onPathChanged()));
@@ -93,15 +92,10 @@ bool ModuleBase_WidgetFileSelector::restoreValue()
   return true;
 }
 
-QWidget* ModuleBase_WidgetFileSelector::getControl() const
-{
-  return myMainWidget;
-}
-
 QList<QWidget*> ModuleBase_WidgetFileSelector::getControls() const
 {
   QList<QWidget*> result;
-  //QPushButton * aButton = myMainWidget->findChild<QPushButton *>();
+  //QPushButton * aButton = this->findChild<QPushButton *>();
   //result << aButton;
   result << myPathField;
   return result;
@@ -117,7 +111,7 @@ bool ModuleBase_WidgetFileSelector::isCurrentPathValid()
 void ModuleBase_WidgetFileSelector::onPathSelectionBtn()
 {
   QString aFilter = formatsString();
-  QString aFileName = QFileDialog::getOpenFileName(myMainWidget, myTitle, myDefaultPath, aFilter);
+  QString aFileName = QFileDialog::getOpenFileName(this, myTitle, myDefaultPath, aFilter);
   if (!aFileName.isEmpty()) {
     myPathField->setText(aFileName);
   }
index 4f64d215ca7ebdeec9fdfd2192d1f7fd6f4ddb7c..744770c61d9087afa07cfcb70cc5dd938a767939 100644 (file)
@@ -48,8 +48,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelW
 
   virtual bool restoreValue();
 
-  QWidget* getControl() const;
-
   virtual QList<QWidget*> getControls() const;
 
   /// Returns true if a file on the current path in the line edit
@@ -79,9 +77,6 @@ protected:
    /// A control for path input
   QLineEdit* myPathField;
 
-  /// Container
-  QWidget* myMainWidget;
-
   /// A title of open file dialog box
   QString myTitle;
 
index d5ffd015b3b01b931aa31c3a9b31cd23468d638e..3abae6c7b704c9062981fd4ee87f8da1b9b25afc 100644 (file)
@@ -7,19 +7,26 @@
 #include "ModuleBase_WidgetLabel.h"
 
 #include <Config_WidgetAPI.h>
+#include <ModuleBase_Tools.h>
 
 #include <QLabel>
+#include <QVBoxLayout>
 
 
 ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
-                                                     const Config_WidgetAPI* theData,
-                                                     const std::string& theParentId)
+                                               const Config_WidgetAPI* theData,
+                                               const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
   QString aText = QString::fromStdString(theData->getProperty("title"));
   myLabel = new QLabel(aText, theParent);
   myLabel->setWordWrap(true);
   myLabel->setIndent(5);
+  myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+  QVBoxLayout* aLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::zeroMargins(aLayout);
+  aLayout->addWidget(myLabel);
+  setLayout(aLayout);
 }
 
 ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
@@ -31,7 +38,3 @@ QList<QWidget*> ModuleBase_WidgetLabel::getControls() const
   return QList<QWidget*>();
 }
 
-QWidget* ModuleBase_WidgetLabel::getControl() const
-{
-  return myLabel;
-}
index 0f6e00baccfc3b67e57098c6a59a7bd5a49b69e8..62fb2d2e82d57eb3b292f4318d8efa2536e03280 100644 (file)
@@ -40,8 +40,6 @@ Q_OBJECT
 
   virtual QList<QWidget*> getControls() const;
 
-  QWidget* getControl() const;
-
   /// This control doesn't accept focus
   virtual bool focusTo() { return false; }
 
@@ -58,4 +56,4 @@ private:
   QLabel* myLabel;
 };
 
-#endif
\ No newline at end of file
+#endif
index c25c3befade9d54df48ca1e9698bf33015123b75..9c4a1b00f068fd36b0ef838b9320ca9f5a9f0a5b 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <Config_WidgetAPI.h>
 
-#include <QHBoxLayout>
+#include <QFormLayout>
 #include <QLabel>
 #include <QLineEdit>
 #include <QObject>
@@ -31,16 +31,13 @@ ModuleBase_WidgetLineEdit::ModuleBase_WidgetLineEdit(QWidget* theParent,
                                                      const std::string& theParentId)
     : ModuleBase_ModelWidget(theParent, theData, theParentId)
 {
-  myMainWidget = new QWidget(theParent);
-  QHBoxLayout* aMainLay = new QHBoxLayout(myMainWidget);
+  QFormLayout* aMainLay = new QFormLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
   QString aTitle = QString::fromStdString(theData->widgetLabel());
-  QLabel* aTitleLabel = new QLabel(aTitle, myMainWidget);
-  aMainLay->addWidget(aTitleLabel);
-  myLineEdit = new QLineEdit(myMainWidget);
-  aMainLay->addWidget(myLineEdit);
+  myLineEdit = new QLineEdit(this);
   myLineEdit->setMinimumHeight(20);
-  myMainWidget->setLayout(aMainLay);
+  aMainLay->addRow(aTitle, myLineEdit);
+  this->setLayout(aMainLay);
 
   connect(myLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged()));
 }
@@ -77,11 +74,6 @@ bool ModuleBase_WidgetLineEdit::restoreValue()
   return true;
 }
 
-QWidget* ModuleBase_WidgetLineEdit::getControl() const
-{
-  return myMainWidget;
-}
-
 QList<QWidget*> ModuleBase_WidgetLineEdit::getControls() const
 {
   QList<QWidget*> result;
index 1789b0e436305ed5a5fe8391e1561515ae74f53d..965049db6cc8d0ed5cb69559b4e2e079ca06705e 100644 (file)
@@ -40,8 +40,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidge
 
   virtual bool restoreValue();
 
-  QWidget* getControl() const;
-
   virtual QList<QWidget*> getControls() const;
 
  public slots:
@@ -56,9 +54,6 @@ protected:
 private:
    /// A line edit control
   QLineEdit* myLineEdit;
-
-  /// A container widget
-  QWidget* myMainWidget;
 };
 
 #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
index bd9d0d702467c33eada8d0f03137d3989779e370..18ae5e6a08542b7db828724375026a568382089f 100644 (file)
@@ -41,29 +41,28 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
     : ModuleBase_ModelWidget(theParent, theData, theParentId),
       myWorkshop(theWorkshop), myIsActive(false)
 {
-  myMainWidget = new QWidget(theParent);
-  QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+  QGridLayout* aMainLay = new QGridLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
 
-  QLabel* aTypeLabel = new QLabel(tr("Type"), myMainWidget);
+  QLabel* aTypeLabel = new QLabel(tr("Type"), this);
   aMainLay->addWidget(aTypeLabel, 0, 0);
 
-  myTypeCombo = new QComboBox(myMainWidget);
+  myTypeCombo = new QComboBox(this);
   // There is no sence to paramerize list of types while we can not parametrize selection mode
   QString aTypesStr("Vertices Edges Faces Solids");
   QStringList aShapeTypes = aTypesStr.split(' ');
   myTypeCombo->addItems(aShapeTypes);
   aMainLay->addWidget(myTypeCombo, 0, 1);
 
-  QLabel* aListLabel = new QLabel(tr("Selected objects:"), myMainWidget);
+  QLabel* aListLabel = new QLabel(tr("Selected objects:"), this);
   aMainLay->addWidget(aListLabel, 1, 0, 1, -1);
 
-  myListControl = new QListWidget(myMainWidget);
+  myListControl = new QListWidget(this);
   aMainLay->addWidget(myListControl, 2, 0, 2, -1);
   aMainLay->setRowStretch(2, 1);
-  aMainLay->addWidget(new QLabel(myMainWidget));
+  aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)???
   aMainLay->setRowMinimumHeight(3, 20);
-  myMainWidget->setLayout(aMainLay);
+  this->setLayout(aMainLay);
   connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
 
   myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this);
@@ -135,12 +134,6 @@ bool ModuleBase_WidgetMultiSelector::restoreValue()
   return false;
 }
 
-//********************************************************************
-QWidget* ModuleBase_WidgetMultiSelector::getControl() const
-{
-  return myMainWidget;
-}
-
 //********************************************************************
 QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
 {
index 84dc2b7dc70367d92a9210ed6ccf7e7c6e63efc4..660fe06983aaa8cbb572d5b53c065e63003ee896 100644 (file)
@@ -64,10 +64,6 @@ class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_Model
 
   virtual bool restoreValue();
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const;
-
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
@@ -118,9 +114,6 @@ protected slots:
   /// Combobox of types
   QComboBox* myTypeCombo;
 
-  /// Container
-  QWidget* myMainWidget;
-
   //TODO: Move into the base of selectors
   ModuleBase_IWorkshop* myWorkshop;
 
index 30787899f28139e6146833f6afbc4ebad2bc6cbb..093780bae232376dc2e313ed373f9fa37b5708e4 100644 (file)
@@ -55,6 +55,7 @@
 #include <QEvent>
 #include <QDockWidget>
 #include <QApplication>
+#include <QFormLayout>
 
 #include <TopExp_Explorer.hxx>
 #include <TopoDS_Shape.hxx>
@@ -95,25 +96,23 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen
     : ModuleBase_ModelWidget(theParent, theData, theParentId),
       myWorkshop(theWorkshop), myIsActive(false)
 {
-  myContainer = new QWidget(theParent);
-  QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+  QFormLayout* aLayout = new QFormLayout(this);
   ModuleBase_Tools::adjustMargins(aLayout);
 
   QString aLabelText = QString::fromStdString(theData->widgetLabel());
   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
-  myLabel = new QLabel(aLabelText, myContainer);
+  myLabel = new QLabel(aLabelText, this);
   if (!aLabelIcon.isEmpty())
     myLabel->setPixmap(QPixmap(aLabelIcon));
 
-  aLayout->addWidget(myLabel);
 
   QString aToolTip = QString::fromStdString(theData->widgetTooltip());
-  myTextLine = new QLineEdit(myContainer);
+  myTextLine = new QLineEdit(this);
   myTextLine->setReadOnly(true);
   myTextLine->setToolTip(aToolTip);
   myTextLine->installEventFilter(this);
 
-  aLayout->addWidget(myTextLine, 1);
+  aLayout->addRow(myLabel, myTextLine);
 
   std::string aTypes = theData->getProperty("shape_types");
   myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
@@ -466,7 +465,7 @@ void ModuleBase_WidgetShapeSelector::selectionFilters(SelectMgr_ListOfFilter& th
 //********************************************************************
 void ModuleBase_WidgetShapeSelector::raisePanel() const
 {
-  QWidget* aParent = myContainer->parentWidget();
+  QWidget* aParent = this->parentWidget();
   QWidget* aLastPanel = 0;
   while (!aParent->inherits("QDockWidget")) {
     aLastPanel = aParent;
@@ -542,4 +541,4 @@ bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<G
     }
   }
   return true;
-}
\ No newline at end of file
+}
index 2e6b2cc9a8cabe809b2f6063e7c678f76dc7d2f3..98a1e4c34c02c35e8e5aee81ef10e0feb989a7d7 100644 (file)
@@ -77,13 +77,6 @@ Q_OBJECT
   /// Defines if it is supposed that the widget should interact with the viewer.
   virtual bool isViewerSelector() { return true; }
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const
-  {
-    return myContainer;
-  }
-
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
@@ -158,10 +151,6 @@ Q_OBJECT
 
   //----------- Class members -------------
  protected:
-
-   /// Container of the widget's control
-  QWidget* myContainer;
-
   /// Label of the widget
   QLabel* myLabel;
 
index 1b693e1258324323a5c1b552a5b1f2ddb4ecff76..2c90b65a8d20c421ea28829492e1be55a238288b 100644 (file)
@@ -433,50 +433,38 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
   XGUI_Workshop* aWorkshop = aConnector->workshop();
+  ModuleBase_ModelWidget* aWgt = NULL;
   if (theType == "sketch-start-label") {
-    PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
-    aWgt->setWorkshop(aWorkshop);
-    connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
+    PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
+    aLabelWgt->setWorkshop(aWorkshop);
+    connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
       mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
-    theModelWidgets.append(aWgt);
-    return aWgt->getControl();
-
+    aWgt = aLabelWgt;
   } else if (theType == "sketch-2dpoint_selector") {
-    PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
-    aWgt->setWorkshop(aWorkshop);
-    aWgt->setSketch(mySketchMgr->activeSketch());
-
-    connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
-
-    theModelWidgets.append(aWgt);
-    return aWgt->getControl();
-
+    PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
+    aPointWgt->setWorkshop(aWorkshop);
+    aPointWgt->setSketch(mySketchMgr->activeSketch());
+    connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
+    aWgt = aPointWgt;
   } if (theType == "point2ddistance") {
-    PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
-    aWgt->setWorkshop(aWorkshop);
-    aWgt->setSketch(mySketchMgr->activeSketch());
-
-    theModelWidgets.append(aWgt);
-    return aWgt->getControl();
-
+    PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
+    aDistanceWgt->setWorkshop(aWorkshop);
+    aDistanceWgt->setSketch(mySketchMgr->activeSketch());
+    aWgt = aDistanceWgt;
   } if (theType == "sketch_shape_selector") {
-    PartSet_WidgetShapeSelector* aWgt = 
+    PartSet_WidgetShapeSelector* aShapeSelectorWgt =
       new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
-    aWgt->setSketcher(mySketchMgr->activeSketch());
-
-    theModelWidgets.append(aWgt);
-    return aWgt->getControl();
-
+    aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+    aWgt = aShapeSelectorWgt;
   } if (theType == "sketch_constraint_shape_selector") {
-    PartSet_WidgetConstraintShapeSelector* aWgt = 
+    PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
       new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
-    aWgt->setSketcher(mySketchMgr->activeSketch());
-
+    aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+    aWgt = aConstraintShapeSelectorWgt;
+  }
+  if(aWgt)
     theModelWidgets.append(aWgt);
-    return aWgt->getControl();
-
-  } else
-    return 0;
+  return aWgt;
 }
 
 void PartSet_Module::createActions()
index a6178e8760206af6a949f744efd01697a02ab794..a81a7f2c5a3c870da653d926d1fb402d05abe3b7 100644 (file)
@@ -90,6 +90,10 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
 
     connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
   }
+  QVBoxLayout* aLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::zeroMargins(aLayout);
+  aLayout->addWidget(myGroupBox);
+  setLayout(aLayout);
 }
 
 void PartSet_WidgetPoint2D::reset()
@@ -181,11 +185,6 @@ bool PartSet_WidgetPoint2D::restoreValue()
   return true;
 }
 
-QWidget* PartSet_WidgetPoint2D::getControl() const
-{
-  return myGroupBox;
-}
-
 QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
 {
   QList<QWidget*> aControls;
index f07c60fc9f69269f50df10c6dc5907b4b8a998a4..e39011c9054e32484b65472bdf9bdda846078354 100644 (file)
@@ -57,10 +57,6 @@ Q_OBJECT
 
   virtual bool restoreValue();
 
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const;
-
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
index f3001c881b3325eeb4f240d2d84406c932a83ccd..5925437ed68ebcdf91fe921535220636c0141e50 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomDataAPI_Point.h>
 #include <QLabel>
 #include <QTimer>
 #include <QApplication>
+#include <QVBoxLayout>
 
 
 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId), myPreviewDisplayed(false)
+    : ModuleBase_ModelWidget(theParent, theData, theParentId),
+      myPreviewDisplayed(false),
+      myWorkshop(NULL)
 {
   myText = QString::fromStdString(theData->getProperty("title"));
   myLabel = new QLabel("", theParent);
@@ -54,6 +58,11 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
   mySelectionTimer = new QTimer(this);
   connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode()));
   mySelectionTimer->setSingleShot(true);
+
+  QVBoxLayout* aLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::zeroMargins(aLayout);
+  aLayout->addWidget(myLabel);
+  setLayout(aLayout);
 }
 
 PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
@@ -66,11 +75,6 @@ QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
   return QList<QWidget*>();
 }
 
-QWidget* PartSet_WidgetSketchLabel::getControl() const
-{
-  return myLabel;
-}
-
 void PartSet_WidgetSketchLabel::onPlaneSelected()
 {
   XGUI_Selection* aSelection = myWorkshop->selector()->selection();
index 3a8f21a39fece222945b6eba2f67ff7858806403..8288bdf82ac54d8248693eaa42f5c28682cc668f 100644 (file)
@@ -57,8 +57,6 @@ Q_OBJECT
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
 
-  QWidget* getControl() const;
-
   /// The methiod called when widget is deactivated
   virtual void deactivate();
 
index 0798bbc4809bb11e9c0a8fb59e9eea9949c8ae26..33f1826a792e99d7bcb183d94f35cddb37e78f2d 100644 (file)
@@ -142,9 +142,6 @@ void XGUI_ActionsMgr::updateOnViewSelection()
   foreach(QString aId, nestedCommands(aFeatureId)) {
     std::list<ModelAPI_Validator*> aValidators;
     std::list<std::list<std::string> > anArguments;
-    if (!anArguments.empty()) {
-      std::list<std::string> firstArg = anArguments.front();
-    }
     aFactory->validators(aId.toStdString(), aValidators, anArguments);
     std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
     std::list<std::list<std::string> >::iterator aValidatorArgs = anArguments.begin();
index 348eb2a31c8d30d6fffe169f8a0439eb702d0bd9..2ff582bb7c70b08fa7024558839f717aa2a8eca3 100644 (file)
@@ -9,6 +9,8 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Object.h>
 
+#include <ModuleBase_Tools.h>
+
 #include <QLayout>
 #include <QLabel>
 #include <QLineEdit>
@@ -101,7 +103,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
     : QWidget(theParent)
 {
   QVBoxLayout* aLayout = new QVBoxLayout(this);
-  aLayout->setContentsMargins(0, 0, 0, 0);
+  ModuleBase_Tools::zeroMargins(aLayout);
   aLayout->setSpacing(0);
 
   QFrame* aLabelWgt = new QFrame(this);
@@ -112,7 +114,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
 
   aLayout->addWidget(aLabelWgt);
   QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
-  aLabelLay->setContentsMargins(0, 0, 0, 0);
+  ModuleBase_Tools::zeroMargins(aLabelLay);
   aLabelLay->setSpacing(0);
 
   QLabel* aLbl = new QLabel(aLabelWgt);
index 355614b7687d4a055ecb68f8f4de17199843d2b9..1779431f5511a3dc204568139f8b334c7e9f72eb 100644 (file)
@@ -11,6 +11,7 @@
 #include <XGUI_ActionsMgr.h>
 //#include <AppElements_Constants.h>
 #include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_Tools.h>
 
 #include <QEvent>
 #include <QFrame>
@@ -19,7 +20,7 @@
 #include <QLayoutItem>
 #include <QToolButton>
 #include <QVBoxLayout>
-#include <QVBoxLayout>
+#include <QGridLayout>
 #include <QWidget>
 #include <QToolButton>
 #include <QAction>
@@ -38,16 +39,18 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
 
   QWidget* aContent = new QWidget(this);
-  myMainLayout = new QVBoxLayout(aContent);
+  myMainLayout = new QGridLayout(aContent);
+  const int kPanelColumn = 0;
+  int aPanelRow = 0;
   myMainLayout->setContentsMargins(3, 3, 3, 3);
   this->setWidget(aContent);
 
   QFrame* aFrm = new QFrame(aContent);
-  aFrm->setFrameStyle(QFrame::Sunken);
+  aFrm->setFrameStyle(QFrame::Raised);
   aFrm->setFrameShape(QFrame::Panel);
   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
-  aBtnLay->setContentsMargins(0, 0, 0, 0);
-  myMainLayout->addWidget(aFrm);
+  ModuleBase_Tools::zeroMargins(aBtnLay);
+  myMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
 
   QStringList aBtnNames;
   aBtnNames << QString(PROP_PANEL_HELP)
@@ -60,10 +63,10 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
     aBtnLay->addWidget(aBtn);
   }
   aBtnLay->insertStretch(1, 1);
-  // aBtn->setShortcut(QKeySequence(Qt::Key_Escape));
 
   myCustomWidget = new QWidget(aContent);
-  myMainLayout->addWidget(myCustomWidget);
+  myCustomWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+  myMainLayout->addWidget(myCustomWidget, aPanelRow, kPanelColumn);
   setStretchEnabled(true);
 }
 
@@ -85,32 +88,14 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
 {
   myWidgets = theWidgets;
   if (theWidgets.empty()) return;
-  bool isEnableStretch = true;
-  QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
-      theWidgets.end();
-  for (; anIt != aLast; anIt++) {
+  QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin();
+  for (; anIt != theWidgets.end(); anIt++) {
     connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
     connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
             this,  SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
             this,  SLOT(activateWidget(ModuleBase_ModelWidget*)));
-
-    //ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
-    //if (aPointWidget)
-    //  connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
-    //          SIGNAL(storedPoint2D(ObjectPtr, const std::string&)))
-    //}
-
-    if (!isEnableStretch) continue;
-    foreach(QWidget* eachWidget, (*anIt)->getControls()) {
-      QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
-      if(aVPolicy == QSizePolicy::Expanding ||
-         aVPolicy == QSizePolicy::MinimumExpanding) {
-        isEnableStretch = false;
-      }
-    }
   }
-  setStretchEnabled(isEnableStretch);
   ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
   if (aLastWidget) {
     QList<QWidget*> aControls = aLastWidget->getControls();
@@ -179,17 +164,10 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
 
 void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
 {
-  if (myMainLayout->count() == 0)
+  int aStretchIdx = myMainLayout->rowCount() - 1;
+  if (aStretchIdx < 0)
     return;
-  int aStretchIdx = myMainLayout->count() - 1;
-  bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL;
-  QLayoutItem* aChild;
-  if (isEnabled) {
-    if (!hasStretch) myMainLayout->addStretch(1);
-  } else if (hasStretch) {
-    aChild = myMainLayout->takeAt(aStretchIdx);
-    delete aChild;
-  }
+  myMainLayout->setRowStretch(aStretchIdx, isEnabled ? 1 : 0);
 }
 
 void XGUI_PropertyPanel::activateNextWidget()
index c70e0aec7cacde7276ff3902fa4ec2203883ce7e..5d17060424687a4b5187498deb8a9841c9752665 100644 (file)
@@ -19,7 +19,7 @@
 
 class XGUI_ActionsMgr;
 class QKeyEvent;
-class QVBoxLayout;
+class QGridLayout;
 
 /// Internal name of property panel widget
 const static char* PROP_PANEL = "property_panel_dock";
@@ -106,7 +106,7 @@ Q_OBJECT
  private:
   QWidget* myCustomWidget;
   QList<ModuleBase_ModelWidget*> myWidgets;
-  QVBoxLayout* myMainLayout;
+  QGridLayout* myMainLayout;
 
   /// Currently active widget
   ModuleBase_ModelWidget* myActiveWidget;