]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
SketchShapePlugin: checked group box/multi editor controls, which highlight the paren...
authornds <nds@opencascade.com>
Mon, 14 Dec 2015 11:15:02 +0000 (14:15 +0300)
committernds <nds@opencascade.com>
Mon, 14 Dec 2015 11:15:45 +0000 (14:15 +0300)
22 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IWidgetCreator.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp [new file with mode: 0755]
src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h [new file with mode: 0755]
src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp
src/ModuleBase/ModuleBase_WidgetCreatorFactory.h
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/SketchShapePlugin/CMakeLists.txt
src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp
src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h
src/SketchShapePlugin/SketchShapePlugin_Plugin.cpp
src/SketchShapePlugin/SketchShapePlugin_Plugin.h
src/SketchShapePlugin/SketchShapePlugin_WidgetCheckGroupBox.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_WidgetCheckGroupBox.h [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.cpp
src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.h
src/SketchShapePlugin/SketchShapePlugin_WidgetMultiSelector.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_WidgetMultiSelector.h [new file with mode: 0755]
src/SketchShapePlugin/plugin-SketchShape.xml

index 304feb69c80f146661e1e9d65a651eb9f4c20403..48c904e16dd9106faf7355a2f22b0c43c4f8db3f 100644 (file)
@@ -39,6 +39,7 @@ SET(PROJECT_HEADERS
   ModuleBase_ViewerFilters.h
   ModuleBase_ViewerPrs.h
   ModuleBase_WidgetBoolValue.h
+  ModuleBase_WidgetCheckGroupBox.h
   ModuleBase_WidgetChoice.h
   ModuleBase_WidgetCreatorFactory.h
   ModuleBase_WidgetDoubleValue.h
@@ -92,6 +93,7 @@ SET(PROJECT_SOURCES
   ModuleBase_ViewerFilters.cpp
   ModuleBase_ViewerPrs.cpp
   ModuleBase_WidgetBoolValue.cpp
+  ModuleBase_WidgetCheckGroupBox.cpp
   ModuleBase_WidgetChoice.cpp
   ModuleBase_WidgetCreatorFactory.cpp
   ModuleBase_WidgetDoubleValue.cpp
index ecdee3a848a534f3e95c0af2d6a3bbafe049723e..91a076d447335fb4be8fad3ec1c390a3971d5f98 100755 (executable)
@@ -11,6 +11,9 @@
 
 class ModuleBase_ModelWidget;
 class ModuleBase_PageBase;
+class ModuleBase_IWorkshop;
+
+class Config_WidgetAPI;
 
 class QWidget;
 
@@ -39,13 +42,18 @@ public:
   /// \param theType a type
   /// \param theParent a parent widget
   virtual ModuleBase_PageBase* createPageByType(const std::string& theType,
-                                                QWidget* theParent) = 0;
+                                                QWidget* theParent,
+                                                Config_WidgetAPI* theWidgetApi,
+                                                std::string theParentId) = 0;
 
   /// Create widget by its type
    /// \param theType a type
    /// \param theParent a parent widget
   virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
-                                                     QWidget* theParent = NULL) = 0;
+                                                     QWidget* theParent,
+                                                     Config_WidgetAPI* theWidgetApi,
+                                                     std::string theParentId,
+                                                     ModuleBase_IWorkshop* theWorkshop) = 0;
 };
 
 typedef std::shared_ptr<ModuleBase_IWidgetCreator> WidgetCreatorPtr;
index ff7554f1dff06e840c764d1b6da435c2985129c7..d9c678185b11bd4138c2783094a028e4cf0ae382 100644 (file)
@@ -18,8 +18,6 @@
 #include <Events_Loop.h>
 
 #include <QEvent>
-#include <QGraphicsDropShadowEffect>
-#include <QColor>
 #include <QLabel>
 #include <QFocusEvent>
 
@@ -104,21 +102,10 @@ void ModuleBase_ModelWidget::setHighlighted(bool isHighlighted)
     QLabel* aLabel = qobject_cast<QLabel*>(aWidget);
     // We won't set the effect to QLabels - it looks ugly
     if(aLabel) continue;
-    if(isHighlighted) {
-      // If effect is the installed on a different widget, setGraphicsEffect() will
-      // remove the effect from the widget and install it on this widget.
-      // That's why we create a new effect for each widget
-      QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect();
-      aGlowEffect->setOffset(.0);
-      aGlowEffect->setBlurRadius(10.0);
-      aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF
-      aWidget->setGraphicsEffect(aGlowEffect);
-    } else {
-      QGraphicsEffect* anEffect = aWidget->graphicsEffect();
-      if(anEffect)
-        anEffect->deleteLater();
-      aWidget->setGraphicsEffect(NULL);
-    }
+    // If effect is the installed on a different widget, setGraphicsEffect() will
+    // remove the effect from the widget and install it on this widget.
+    // That's why we create a new effect for each widget
+    ModuleBase_Tools::setShadowEffect(aWidget, isHighlighted);
   }
 }
 
index d33467c7e883cacdbf53e1a68fb6b07c31a90518..66f2979fa4dd03f45a2383900d285b7c89fd4230 100755 (executable)
@@ -29,6 +29,8 @@
 #include <QPainter>
 #include <QBitmap>
 #include <QDoubleSpinBox>
+#include <QGraphicsDropShadowEffect>
+#include <QColor>
 
 #include <sstream>
 
@@ -91,6 +93,23 @@ void setFocus(QWidget* theWidget, const QString& theInfo)
 #endif
 }
 
+void setShadowEffect(QWidget* theWidget, const bool isSetEffect)
+{
+  if (isSetEffect) {
+    QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect();
+    aGlowEffect->setOffset(.0);
+    aGlowEffect->setBlurRadius(10.0);
+    aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF
+    theWidget->setGraphicsEffect(aGlowEffect);
+  }
+  else {
+    QGraphicsEffect* anEffect = theWidget->graphicsEffect();
+    if(anEffect)
+    anEffect->deleteLater();
+    theWidget->setGraphicsEffect(NULL);
+  }
+}
+
 QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
 {
   QImage anIcon(theIcon);
index 7aa9f9d647ed3fb71fc71110976eb40b9eae6a1d..c8d3c6afa7655b63bd716ddafa9d2a5423342172 100755 (executable)
@@ -55,6 +55,13 @@ MODULEBASE_EXPORT void activateWindow(QWidget* theWidget, const QString& theInfo
  */
 MODULEBASE_EXPORT void setFocus(QWidget* theWidget, const QString& theInfo = QString());
 
+
+//! Sets or removes the shadow effect to the widget
+//! \param theWidget a widget to be styled
+//! \param isSetEffect if true, the shadow effect is set, overwise cleared
+//! \return resulting pixmap
+MODULEBASE_EXPORT void setShadowEffect(QWidget* theWidget, const bool isSetEffect);
+
 /**
  * \ingroup GUI
  * Methods to modify a resource pixmap
diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp
new file mode 100755 (executable)
index 0000000..89d9356
--- /dev/null
@@ -0,0 +1,128 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        ModuleBase_WidgetCheckGroupBox.cpp
+// Created:     13 Dec 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <ModuleBase_WidgetCheckGroupBox.h>
+#include <ModelAPI_AttributeBoolean.h>
+
+#include <Config_WidgetAPI.h>
+#include <Config_Keywords.h>
+
+#include <QWidget>
+#include <QGroupBox>
+#include <QGridLayout>
+#include <QVBoxLayout>
+
+#include <QList>
+
+ModuleBase_WidgetCheckGroupBox::ModuleBase_WidgetCheckGroupBox(QWidget* theParent,
+                                                               const Config_WidgetAPI* theData,
+                                                               const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId),
+  ModuleBase_PageBase()
+{
+  QString aToolTip = QString::fromStdString(theData->widgetTooltip());
+  bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
+
+  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::zeroMargins(aMainLayout);
+  myGroupBox = new QGroupBox(this);
+  myGroupBox->setCheckable(true);
+  myGroupBox->setToolTip(aToolTip);
+  myGroupBox->setChecked(isChecked);
+
+  myMainLayout = new QGridLayout(myGroupBox);
+  ModuleBase_Tools::adjustMargins(myMainLayout);
+  myGroupBox->setLayout(myMainLayout);
+
+  // default vertical size policy is preferred
+  aMainLayout->addWidget(myGroupBox);
+  connect(myGroupBox, SIGNAL(clicked(bool)), this, SLOT(onPageClicked()));
+}
+
+ModuleBase_WidgetCheckGroupBox::~ModuleBase_WidgetCheckGroupBox()
+{
+}
+
+void ModuleBase_WidgetCheckGroupBox::setTitle(const QString& theTitle)
+{
+  myGroupBox->setTitle(theTitle);
+}
+
+QWidget* ModuleBase_WidgetCheckGroupBox::pageWidget()
+{
+  return myGroupBox;
+}
+
+QList<QWidget*> ModuleBase_WidgetCheckGroupBox::getControls() const
+{
+  QList<QWidget*> aControls;
+  aControls.append(myGroupBox);
+
+  return aControls;
+}
+
+void ModuleBase_WidgetCheckGroupBox::onPageClicked()
+{
+  storeValue();
+}
+
+void ModuleBase_WidgetCheckGroupBox::addPageStretch()
+{
+}
+
+void ModuleBase_WidgetCheckGroupBox::placeModelWidget(ModuleBase_ModelWidget* theWidget)
+{
+  const int kCol = 0;
+  const int kRow = myMainLayout->count();
+  // it seems, that the align on left is not necessary here, but leads to widgets, which are
+  // not extended on full width of the parent page. The case is grouped widgets in
+  // the sketch translation operation
+  myMainLayout->addWidget(theWidget, kRow, kCol, Qt::AlignTop);// | Qt::AlignLeft);
+  myMainLayout->setRowStretch(kRow, 0);
+
+}
+
+void ModuleBase_WidgetCheckGroupBox::placePageWidget(ModuleBase_PageBase* theWidget)
+{
+  QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
+  if (!aWidget) {
+#ifdef _DEBUG
+    std::cout << "ModuleBase_PageGroupBox::placePageWidget: can not cast page" << std::endl;
+#endif
+    return;
+  }
+  const int kCol = 0;
+  const int kRow = myMainLayout->count();
+  myMainLayout->addWidget(aWidget, kRow, kCol);
+  myMainLayout->setRowStretch(kRow, 0);
+}
+
+QLayout* ModuleBase_WidgetCheckGroupBox::pageLayout()
+{
+  return myMainLayout;
+}
+
+bool ModuleBase_WidgetCheckGroupBox::storeValueCustom() const
+{
+  DataPtr aData = myFeature->data();
+  std::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
+  aBool->setValue(myGroupBox->isChecked());
+  updateObject(myFeature);
+
+  return true;
+}
+
+bool ModuleBase_WidgetCheckGroupBox::restoreValueCustom()
+{
+  DataPtr aData = myFeature->data();
+  std::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
+
+  bool isBlocked = myGroupBox->blockSignals(true);
+  myGroupBox->setChecked(aRef->value());
+  myGroupBox->blockSignals(isBlocked);
+
+  return true;
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h
new file mode 100755 (executable)
index 0000000..4d8c12a
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        ModuleBase_WidgetCheckGroupBox.h
+// Created:     13 Dec 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_WidgetCheckGroupBox_H_
+#define ModuleBase_WidgetCheckGroupBox_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+class QGroupBox;
+class QGridLayout;
+
+/**
+* \ingroup GUI
+* Implements a model widget for switch as a container widget. It can be defined in XML with "toolbox" keyword
+*/
+class MODULEBASE_EXPORT ModuleBase_WidgetCheckGroupBox : public ModuleBase_ModelWidget,
+                                                         public ModuleBase_PageBase
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theData the widget configuration. The attribute of the model widget is obtained from
+  /// \param theParentId is Id of a parent of the current attribute
+  ModuleBase_WidgetCheckGroupBox(QWidget* theParent, const Config_WidgetAPI* theData,
+                                 const std::string& theParentId);
+  virtual ~ModuleBase_WidgetCheckGroupBox();
+
+  void setTitle(const QString& theTitle);
+
+  /// Methods to be redefined from ModuleBase_PageBase: start
+  /// Cast the page to regular QWidget
+  virtual QWidget* pageWidget();
+  /// Methods to be redefined from ModuleBase_PageBase: end
+
+  /// Methods to be redefined from ModuleBase_ModelWidget: start
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+  /// Methods to be redefined from ModuleBase_ModelWidget: end
+
+protected slots:
+  // store value to the model
+  void onPageClicked();
+
+protected:
+  /// Methods to be redefined from ModuleBase_PageBase: start
+  /// Adds the given widget to page's layout
+  virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget);
+  /// Adds the given page to page's layout
+  virtual void placePageWidget(ModuleBase_PageBase* theWidget);
+  /// Returns page's layout (QGridLayout)
+  virtual QLayout* pageLayout();
+  /// Adds a stretch to page's layout
+  virtual void addPageStretch();
+  /// Methods to be redefined from ModuleBase_PageBase: end
+
+
+  /// Methods to be redefined from ModuleBase_ModelWidget: start
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValueCustom() const;
+  /// Restore value from attribute data to the widget's control
+  virtual bool restoreValueCustom();
+  /// Methods to be redefined from ModuleBase_ModelWidget: end
+
+private:
+  QGroupBox* myGroupBox;
+  QGridLayout* myMainLayout; ///< page's layout
+};
+
+#endif /* ModuleBase_WidgetCheckGroupBox_H_ */
index 1427e22a709ef242ac8043081cee93f30217d193..cdf53e151274393d684b6bb353323817fae669a3 100755 (executable)
@@ -7,6 +7,8 @@
 #include <ModuleBase_WidgetCreatorFactory.h>
 #include <ModuleBase_IWidgetCreator.h>
 
+#include <Config_WidgetAPI.h>
+
 #include <Events_Error.h>
 
 #include <QStringList>
@@ -62,13 +64,14 @@ bool ModuleBase_WidgetCreatorFactory::hasPageWidget(const std::string& theType)
 }
 
 ModuleBase_PageBase* ModuleBase_WidgetCreatorFactory::createPageByType(
-                              const std::string& theType, QWidget* theParent)
+                              const std::string& theType, QWidget* theParent,
+                              Config_WidgetAPI* theWidgetApi, std::string theParentId)
 {
   ModuleBase_PageBase* aPage = 0;
 
   if (myPageToCreator.contains(theType)) {
     WidgetCreatorPtr aCreator = myPageToCreator[theType];
-    aPage = aCreator->createPageByType(theType, theParent);
+    aPage = aCreator->createPageByType(theType, theParent, theWidgetApi, theParentId);
   }
 
   return aPage;
@@ -76,13 +79,16 @@ ModuleBase_PageBase* ModuleBase_WidgetCreatorFactory::createPageByType(
 
 
 ModuleBase_ModelWidget* ModuleBase_WidgetCreatorFactory::createWidgetByType(
-                              const std::string& theType, QWidget* theParent)
+                              const std::string& theType, QWidget* theParent,
+                              Config_WidgetAPI* theWidgetApi, std::string theParentId,
+                              ModuleBase_IWorkshop* theWorkshop)
 {
   ModuleBase_ModelWidget* aWidget = 0;
 
   if (myCreators.contains(theType)) {
     WidgetCreatorPtr aCreator = myCreators[theType];
-    aWidget = aCreator->createWidgetByType(theType, theParent);
+    aWidget = aCreator->createWidgetByType(theType, theParent, theWidgetApi, theParentId,
+                                           theWorkshop);
   }
 
   return aWidget;
index 63c4d626085f11f733119af76bcde95ee4f018da..98f4d211d1b514d8f5d6f83e70766e6da8f1b0b0 100755 (executable)
@@ -18,6 +18,7 @@
 
 class ModuleBase_ModelWidget;
 class ModuleBase_PageBase;
+class ModuleBase_IWorkshop;
 
 class QWidget;
 
@@ -47,13 +48,18 @@ class MODULEBASE_EXPORT ModuleBase_WidgetCreatorFactory
   /// \param theType a type
   /// \param theParent a parent widget
   ModuleBase_PageBase* createPageByType(const std::string& theType,
-                                        QWidget* theParent = NULL);
+                                        QWidget* theParent,
+                                        Config_WidgetAPI* theWidgetApi,
+                                        std::string theParentId);
 
   /// Create widget by its type
   /// \param theType a type
   /// \param theParent a parent widget
   ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
-                                             QWidget* theParent = NULL);
+                                             QWidget* theParent,
+                                             Config_WidgetAPI* theWidgetApi,
+                                             std::string theParentId,
+                                             ModuleBase_IWorkshop* theWorkshop);
 
 private:
   /// Constructor is hidden
index dec5f78ab6efc24d0e717b0b784ca7128f3e0052..f32f0aca8dc7ce29cba19c7777daedfb0be209b5 100644 (file)
@@ -29,6 +29,7 @@
 #include <ModuleBase_WidgetToolbox.h>
 #include <ModuleBase_PageBase.h>
 #include <ModuleBase_PageGroupBox.h>
+#include <ModuleBase_WidgetCheckGroupBox.h>
 #include <ModuleBase_PageWidget.h>
 #include <ModuleBase_WidgetExprEditor.h>
 #include <ModuleBase_WidgetCreatorFactory.h>
@@ -131,9 +132,20 @@ ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::strin
     aPage->setTitle(aGroupName);
     aResult = aPage;
   }
-
+  else if (theType == WDG_CHECK_GROUP) {
+    QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+    ModuleBase_WidgetCheckGroupBox* aPage = new ModuleBase_WidgetCheckGroupBox(theParent,
+                                                                myWidgetApi, myParentId);
+    aPage->setTitle(aGroupName);
+    aResult = aPage;
+  }
   if (!aResult)
-    aResult = ModuleBase_WidgetCreatorFactory::get()->createPageByType(theType, theParent);
+    aResult = ModuleBase_WidgetCreatorFactory::get()->createPageByType(theType, theParent,
+                                                                       myWidgetApi, myParentId);
+
+  ModuleBase_ModelWidget* aWidget = dynamic_cast<ModuleBase_ModelWidget*>(aResult);
+  if (aWidget)
+    myModelWidgets.append(aWidget);
 
   return aResult;
 }
@@ -180,7 +192,8 @@ ModuleBase_ModelWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::
   } else {
     result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, myParentId);
     if (!result)
-      result = ModuleBase_WidgetCreatorFactory::get()->createWidgetByType(theType, theParent);
+      result = ModuleBase_WidgetCreatorFactory::get()->createWidgetByType(theType, theParent,
+                                                              myWidgetApi, myParentId, myWorkshop);
     #ifdef _DEBUG
     if (!result) {
       qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type %s", theType.c_str());
index 200ca71babc559ed10a08ee95bc4aa882806670c..f2516cd6523adb003e363f0825f015e776f32357 100755 (executable)
@@ -10,7 +10,9 @@ SET(PROJECT_HEADERS
     SketchShapePlugin_Plugin.h
     SketchShapePlugin_Validators.h
     SketchShapePlugin_Tools.h
+    SketchShapePlugin_WidgetCheckGroupBox.h
     SketchShapePlugin_WidgetCreator.h
+    SketchShapePlugin_WidgetMultiSelector.h
 )
 
 SET(PROJECT_SOURCES
@@ -19,7 +21,9 @@ SET(PROJECT_SOURCES
     SketchShapePlugin_Plugin.cpp
     SketchShapePlugin_Validators.cpp
     SketchShapePlugin_Tools.cpp
+    SketchShapePlugin_WidgetCheckGroupBox.cpp
     SketchShapePlugin_WidgetCreator.cpp
+    SketchShapePlugin_WidgetMultiSelector.cpp
 )
 
 SET(PROJECT_LIBRARIES
index a28cec528d1100fe5ebeb9238d51cd44d9d15d90..db4d9eb70196e51988369008798d03197492305e 100755 (executable)
@@ -9,6 +9,10 @@
 SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent)
 : ModuleBase_PageGroupBox(theParent)
 {
-  setTitle("SketchShapePlugin_PageGroupBox");
+}
+
+void SketchShapePlugin_PageGroupBox::setHighlightedGroupBox(bool isHighlighted)
+{
+  ModuleBase_Tools::setShadowEffect(this, isHighlighted);
 }
 
index 3da8919d42dbeea5845c84d1bd5505aac3f26690..f372d14f8d508c3015b44ba0f9059d541c8df7a1 100755 (executable)
@@ -23,6 +23,10 @@ public:
   SketchShapePlugin_PageGroupBox(QWidget* theParent = 0);
   /// Destructs the page
   virtual ~SketchShapePlugin_PageGroupBox() {}
+
+  //! Switch On/Off highlighting of the widget
+  //! Set highlight to the parent group box if there is such parent
+  void setHighlightedGroupBox(bool isHighlighted);
 };
 
 #endif /* SKETCHSHAPEPLUGIN_PAGEGROUPBOX_H_ */
index 751e41b82d4cb9d17019b52b7ce765001f07947f..9121a4219320ced00187b5ceae880ed784f70169 100755 (executable)
@@ -52,12 +52,3 @@ FeaturePtr SketchShapePlugin_Plugin::createFeature(std::string theFeatureID)
   return FeaturePtr();
 }
 
-/*ModuleBase_ModelWidget* SketchShapePlugin_Plugin::createWidgetByType(const std::string& theType,
-                                                                     QWidget* theParent)
-{
-  ModuleBase_ModelWidget* aWidget = 0;
-  if (theType == "sketchshape_groupbox")
-    aWidget = new SketchShapePlugin_PageGroupBox(theParent);
-  return aWidget;
-}*/
-
index 3c037c9658c99437013f2f0c22c06c858af11d16..69721d20fe385d65166253cc3cca220986980788 100755 (executable)
@@ -28,11 +28,6 @@ public:
   /// Creates the feature object of this plugin by the feature string ID
   virtual FeaturePtr createFeature(std::string theFeatureID);
 
-  /// Create widget by its type
-  /// \param theType a type
-  /// \param theParent a parent widget
-  //virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
-  //                                                   QWidget* theParent = NULL);
  public:
    SketchShapePlugin_Plugin();
 };
diff --git a/src/SketchShapePlugin/SketchShapePlugin_WidgetCheckGroupBox.cpp b/src/SketchShapePlugin/SketchShapePlugin_WidgetCheckGroupBox.cpp
new file mode 100755 (executable)
index 0000000..6c304fc
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_PageGroupBox.h
+// Created:     13 Dec 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <SketchShapePlugin_WidgetCheckGroupBox.h>
+
+#include <SketchShapePlugin_PageGroupBox.h>
+
+SketchShapePlugin_WidgetCheckGroupBox::SketchShapePlugin_WidgetCheckGroupBox(QWidget* theParent,
+                                                               const Config_WidgetAPI* theData,
+                                                               const std::string& theParentId)
+  : ModuleBase_WidgetCheckGroupBox(theParent, theData, theParentId)
+{
+}
+
+void SketchShapePlugin_WidgetCheckGroupBox::setHighlighted(bool isHighlighted)
+{
+  SketchShapePlugin_PageGroupBox* aShapeGroupBox = 0;
+  QWidget* aParent = qobject_cast<QWidget*>(parent());
+  while (aParent) {
+    aShapeGroupBox = dynamic_cast<SketchShapePlugin_PageGroupBox*>(aParent);
+    if (aShapeGroupBox)
+      break;
+    aParent = qobject_cast<QWidget*>(aParent->parent());
+  }
+
+  if (aShapeGroupBox)
+    aShapeGroupBox->setHighlightedGroupBox(isHighlighted);
+}
+
diff --git a/src/SketchShapePlugin/SketchShapePlugin_WidgetCheckGroupBox.h b/src/SketchShapePlugin/SketchShapePlugin_WidgetCheckGroupBox.h
new file mode 100755 (executable)
index 0000000..1744081
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_PageGroupBox.h
+// Created:     13 Dec 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_WIDGET_CHECK_GROUP_BOX_H_
+#define SKETCHSHAPEPLUGIN_WIDGET_CHECK_GROUP_BOX_H_
+
+#include <ModuleBase_WidgetCheckGroupBox.h>
+
+class QWidget;
+
+/*!
+ * \ingroup GUI
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class SketchShapePlugin_WidgetCheckGroupBox : public ModuleBase_WidgetCheckGroupBox
+{
+  //Q_OBJECT
+public:
+  /// Constructs a page that looks like a QGroupBox
+  SketchShapePlugin_WidgetCheckGroupBox(QWidget* theParent, const Config_WidgetAPI* theData,
+                                 const std::string& theParentId);
+  /// Destructs the page
+  virtual ~SketchShapePlugin_WidgetCheckGroupBox() {}
+
+  //! Switch On/Off highlighting of the widget
+  //! Set highlight to the parent group box if there is such parent
+  virtual void setHighlighted(bool isHighlighted);
+};
+
+#endif /* SKETCHSHAPEPLUGIN_WIDGET_CHECK_GROUP_BOX_H_ */
index a5fa8cda417b75e219040daaf0343b7e311c4d72..ad994b49616fb4b55328fd041a3983d7a8588693 100755 (executable)
@@ -1,12 +1,19 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
 #include "SketchShapePlugin_WidgetCreator.h"
+
 #include "SketchShapePlugin_PageGroupBox.h"
 
+#include "SketchShapePlugin_WidgetMultiSelector.h"
+#include "SketchShapePlugin_WidgetCheckGroupBox.h"
+
 SketchShapePlugin_WidgetCreator::SketchShapePlugin_WidgetCreator()
 : ModuleBase_IWidgetCreator()
 {
   myPages.insert("sketchshape_groupbox");
+  myPages.insert("sketchshape_check_groupbox");
+
+  myWidgets.insert("sketchshape_multi_selector");
 }
 
 const std::set<std::string>& SketchShapePlugin_WidgetCreator::pageTypes()
@@ -16,11 +23,12 @@ const std::set<std::string>& SketchShapePlugin_WidgetCreator::pageTypes()
 
 const std::set<std::string>& SketchShapePlugin_WidgetCreator::widgetTypes()
 {
-  return myTypes;
+  return myWidgets;
 }
 
 ModuleBase_PageBase* SketchShapePlugin_WidgetCreator::createPageByType(
-                                   const std::string& theType, QWidget* theParent)
+                                   const std::string& theType, QWidget* theParent,
+                                   Config_WidgetAPI* theWidgetApi, std::string theParentId)
 {
   ModuleBase_PageBase* aPage = 0;
   if (myPages.find(theType) == myPages.end())
@@ -29,20 +37,26 @@ ModuleBase_PageBase* SketchShapePlugin_WidgetCreator::createPageByType(
   if (theType == "sketchshape_groupbox") {
     aPage = new SketchShapePlugin_PageGroupBox(theParent);
   }
+  else if (theType == "sketchshape_check_groupbox") {
+    aPage = new SketchShapePlugin_WidgetCheckGroupBox(theParent, theWidgetApi, theParentId);
+  }
 
   return aPage;
 }
 
 ModuleBase_ModelWidget* SketchShapePlugin_WidgetCreator::createWidgetByType(
-                                   const std::string& theType, QWidget* theParent)
+                                   const std::string& theType, QWidget* theParent,
+                                   Config_WidgetAPI* theWidgetApi, std::string theParentId,
+                                   ModuleBase_IWorkshop* theWorkshop)
 {
   ModuleBase_ModelWidget* aWidget = 0;
-  if (myTypes.find(theType) == myTypes.end())
+  if (myWidgets.find(theType) == myWidgets.end())
     return aWidget;
 
-  //if (theType == "sketchshape_groupbox") {
-  //  aWidget = new SketchShapePlugin_PageGroupBox(theParent);
-  //}
+  if (theType == "sketchshape_multi_selector") {
+    aWidget = new SketchShapePlugin_WidgetMultiSelector(theParent, theWorkshop, theWidgetApi,
+                                                        theParentId);
+  }
 
   return aWidget;
 }
index 7d3e734b493e2f81b23f0a126d725fcdd24f6664..1ce859f99b0845088cfbb5f8bd5dbacfddfe4889 100755 (executable)
@@ -9,6 +9,7 @@
 #include <set>
 
 class ModuleBase_ModelWidget;
+class ModuleBase_IWorkshop;
 class QWidget;
 
 /** 
@@ -36,17 +37,22 @@ public:
   /// \param theType a type
   /// \param theParent a parent widget
   virtual ModuleBase_PageBase* createPageByType(const std::string& theType,
-                                                QWidget* theParent);
+                                                QWidget* theParent,
+                                                Config_WidgetAPI* theWidgetApi,
+                                                std::string theParentId);
 
   /// Create widget by its type
   /// \param theType a type
   /// \param theParent a parent widget
   virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
-                                                     QWidget* theParent = NULL);
+                                                     QWidget* theParent,
+                                                     Config_WidgetAPI* theWidgetApi,
+                                                     std::string theParentId,
+                                                     ModuleBase_IWorkshop* theWorkshop);
 
 private:
   std::set<std::string> myPages; /// types of pages
-  std::set<std::string> myTypes; /// types of widgets
+  std::set<std::string> myWidgets; /// types of widgets
 };
 
 typedef std::shared_ptr<SketchShapePlugin_WidgetCreator> SketchShapePlguinWidgetCreatorPtr;
diff --git a/src/SketchShapePlugin/SketchShapePlugin_WidgetMultiSelector.cpp b/src/SketchShapePlugin/SketchShapePlugin_WidgetMultiSelector.cpp
new file mode 100755 (executable)
index 0000000..f0ccc0f
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_PageGroupBox.h
+// Created:     13 Dec 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <SketchShapePlugin_WidgetMultiSelector.h>
+
+#include <SketchShapePlugin_PageGroupBox.h>
+
+#include <ModuleBase_IWorkshop.h>
+
+#include <Config_WidgetAPI.h>
+
+SketchShapePlugin_WidgetMultiSelector::SketchShapePlugin_WidgetMultiSelector(QWidget* theParent,
+                                                               ModuleBase_IWorkshop* theWorkshop,
+                                                               const Config_WidgetAPI* theData,
+                                                               const std::string& theParentId)
+  : ModuleBase_WidgetMultiSelector(theParent, theWorkshop, theData, theParentId)
+{
+}
+
+void SketchShapePlugin_WidgetMultiSelector::setHighlighted(bool isHighlighted)
+{
+  SketchShapePlugin_PageGroupBox* aShapeGroupBox = 0;
+  QWidget* aParent = qobject_cast<QWidget*>(parent());
+  while (aParent) {
+    aShapeGroupBox = dynamic_cast<SketchShapePlugin_PageGroupBox*>(aParent);
+    if (aShapeGroupBox)
+      break;
+    aParent = qobject_cast<QWidget*>(aParent->parent());
+  }
+
+  if (aShapeGroupBox)
+    aShapeGroupBox->setHighlightedGroupBox(isHighlighted);
+}
+
diff --git a/src/SketchShapePlugin/SketchShapePlugin_WidgetMultiSelector.h b/src/SketchShapePlugin/SketchShapePlugin_WidgetMultiSelector.h
new file mode 100755 (executable)
index 0000000..3e8c968
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_PageGroupBox.h
+// Created:     13 Dec 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_WIDGET_MULTI_SELECTOR_H_
+#define SKETCHSHAPEPLUGIN_WIDGET_MULTI_SELECTOR_H_
+
+#include <ModuleBase_WidgetMultiSelector.h>
+
+class ModuleBase_IWorkshop;
+class QWidget;
+
+/*!
+ * \ingroup GUI
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class SketchShapePlugin_WidgetMultiSelector : public ModuleBase_WidgetMultiSelector
+{
+  //Q_OBJECT
+public:
+  /// Constructs a multi selector widget, which can not be highlighted itself,
+  /// the parent SketchShapePlugin_GroupBox is highlighted instead of it
+  SketchShapePlugin_WidgetMultiSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+                                        const Config_WidgetAPI* theData,
+                                        const std::string& theParentId);
+  /// Destructs the page
+  virtual ~SketchShapePlugin_WidgetMultiSelector() {}
+
+  //! Switch On/Off highlighting of the widget
+  //! Set highlight to the parent group box if there is such parent
+  virtual void setHighlighted(bool isHighlighted);
+};
+
+#endif /* SKETCHSHAPEPLUGIN_PAGEGROUPBOX_H_ */
index 6f51667ca1c1f793eb77c668e18af605fd435077..ace539bf61857b5ed924877ba0cf11a5372080cc 100755 (executable)
           <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
         </shape_selector>
         <sketchshape_groupbox title="Direction">
-          <boolvalue id="VertexChoice" label="VERTICES" default="true" tooltip="Vertices selection on sketch"/>
-          <sketch_multi_selector id="VertexList"
-            label=""
-            tooltip="Select list of vertices"
-            type_choice="Vertices Edges Faces"
-            use_external="false"
-            use_choice="false">
-            <validator id="SketchShapePlugin_FeatureValidator" />
-          </sketch_multi_selector>
-
-          <boolvalue id="EdgeChoice" label="EDGES" default="true" tooltip="Edges selection on sketch"/>
-          <sketch_multi_selector id="EdgeList"
-            label=""
-            tooltip="Select list of edges"
-            type_choice="Vertices Edges Faces"
-            use_external="false"
-            use_choice="false">
-            <validator id="SketchShapePlugin_FeatureValidator" />
-          </sketch_multi_selector>
-
-          <boolvalue id="FaceChoice" label="FACES" default="true" tooltip="Faces selection on sketch"/>
-          <sketch_multi_selector id="FaceList"
-            label=""
-            tooltip="Select list of faces"
-            type_choice="Vertices Edges Faces"
-            use_external="false"
-            use_choice="false">
-            <validator id="SketchShapePlugin_FeatureValidator" />
-          </sketch_multi_selector>
+          <sketchshape_check_groupbox id="VertexChoice" title="VERTICES" default="true" tooltip="Vertices selection on sketch">
+            <sketchshape_multi_selector id="VertexList"
+              label=""
+              tooltip="Select list of vertices"
+              type_choice="Vertices Edges Faces"
+              use_external="false"
+              use_choice="false">
+              <validator id="SketchShapePlugin_FeatureValidator" />
+            </sketchshape_multi_selector>
+          </sketchshape_check_groupbox>
+          <sketchshape_check_groupbox id="EdgeChoice" title="EDGES" default="true" tooltip="Edges selection on sketch">
+            <sketchshape_multi_selector id="EdgeList"
+              label=""
+              tooltip="Select list of edges"
+              type_choice="Vertices Edges Faces"
+              use_external="false"
+              use_choice="false">
+              <validator id="SketchShapePlugin_FeatureValidator" />
+            </sketchshape_multi_selector>
+          </sketchshape_check_groupbox>
+          <sketchshape_check_groupbox id="FaceChoice" title="FACES" default="true" tooltip="Faces selection on sketch">
+            <sketchshape_multi_selector id="FaceList"
+              label=""
+              tooltip="Select list of faces"
+              type_choice="Vertices Edges Faces"
+              use_external="false"
+              use_choice="false">
+              <validator id="SketchShapePlugin_FeatureValidator" />
+            </sketchshape_multi_selector>
+          </sketchshape_check_groupbox>
         </sketchshape_groupbox>
       </feature>
     </group>