]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Fri, 25 Apr 2014 13:57:22 +0000 (17:57 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 25 Apr 2014 13:57:22 +0000 (17:57 +0400)
Line feature realization:
1. Create operation
2. Create point widget
3. Move widgets to ModuleBase

25 files changed:
src/Config/Config_Keywords.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_WidgetCustom.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetFactory.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetFactory.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetPoint2D.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetSwitch.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetSwitch.h [new file with mode: 0644]
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchLine.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationSketchLine.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_SwitchWidget.cpp [deleted file]
src/XGUI/XGUI_SwitchWidget.h [deleted file]
src/XGUI/XGUI_WidgetFactory.cpp [deleted file]
src/XGUI/XGUI_WidgetFactory.h [deleted file]
src/XGUI/XGUI_Workshop.cpp

index 6c8f91835460e5464b9d830424bff0e40458c6a3..61f09f5c3e01932106fc2081ef4e0ba96a388147 100644 (file)
@@ -27,6 +27,9 @@ const static char* WDG_TOOLBOX_BOX = "box";
 const static char* WDG_SWITCH = "switch";
 const static char* WDG_SWITCH_CASE = "case";
 
+//Specific widget containers
+const static char* WDG_POINT_SELECTOR = "point_selector";
+
 const static char* _ID = "id";
 //const static char* WORKBENCH_ID = "id";
 //const static char* GROUP_ID = "id";
index fcd731c9e1db4f896a4756d0e23a356e17071d6d..116353000eccf4a1440a1d408b35ebb0bd9ae324 100644 (file)
@@ -5,14 +5,22 @@ SET(PROJECT_HEADERS
     ModuleBase.h
        ModuleBase_Operation.h
        ModuleBase_PropPanelOperation.h
+       ModuleBase_WidgetCustom.h
+       ModuleBase_WidgetFactory.h
+       ModuleBase_WidgetPoint2D.h
+       ModuleBase_WidgetSwitch.h
 )
 
 SET(PROJECT_SOURCES
        ModuleBase_Operation.cpp
        ModuleBase_PropPanelOperation.cpp
+       ModuleBase_WidgetFactory.cpp
+       ModuleBase_WidgetPoint2D.cpp
+       ModuleBase_WidgetSwitch.cpp
 )
 
 SET(PROJECT_LIBRARIES
+    Config
     ModelAPI
     ${QT_LIBRARIES}
 )
@@ -27,7 +35,11 @@ SET(PROJECT_AUTOMOC
 SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES})
 #SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/ModelAPI)
+INCLUDE_DIRECTORIES(
+    ${PROJECT_SOURCE_DIR}/src/Config
+    ${CMAKE_SOURCE_DIR}/src/ModelAPI
+    ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
+)
 
 ADD_DEFINITIONS(-DMODULEBASE_EXPORTS)
 ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
index 76459c132203a50b7d311cc2f89c6a73d67885c3..519efbf13ebacbf35de46b6122d47232925a8f21 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "ModuleBase_Operation.h"
 
+#include "ModuleBase_WidgetCustom.h"
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
@@ -14,6 +16,8 @@
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 
+#include <GeomDataAPI_Point2D.h>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
@@ -264,6 +268,27 @@ void ModuleBase_Operation::storeReal(double theValue)
   aReal->setValue(theValue);
 }
 
+/*!
+ * \brief Stores a real value in model.
+ * \param theValue - to store
+ *
+ * Public slot. Passes theValue into the model.
+ */
+void ModuleBase_Operation::storeCustomValue()
+{
+  if(!myFeature){
+    #ifdef _DEBUG
+    qDebug() << "ModuleBase_Operation::storeCustom: " <<
+        "trying to store value without opening a transaction.";
+    #endif
+    return;
+  }
+
+  ModuleBase_WidgetCustom* aCustom = dynamic_cast<ModuleBase_WidgetCustom*>(sender());
+  if (aCustom)
+    aCustom->store(myFeature);
+}
+
 /*!
  * \brief Verifies whether operator is ready to start.
  * \return TRUE if operation is ready to start
index 75724ea34e6e418524ebf2230986c3594fee9ac2..818476d6faf073a3eafc05bd01a95373f7600482 100644 (file)
@@ -111,6 +111,9 @@ public slots:
   // Data model operations.
   void storeReal(double);
 
+  // Data model operations.
+  void storeCustomValue();
+
 protected:
   virtual bool isReadyToStart() const;
 
diff --git a/src/ModuleBase/ModuleBase_WidgetCustom.h b/src/ModuleBase/ModuleBase_WidgetCustom.h
new file mode 100644 (file)
index 0000000..471d3f5
--- /dev/null
@@ -0,0 +1,41 @@
+// File:        ModuleBase_WidgetCustom.h
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_WidgetCustom_H
+#define ModuleBase_WidgetCustom_H
+
+#include <ModuleBase.h>
+
+#include <QObject>
+
+#include <boost/shared_ptr.hpp>
+
+class ModelAPI_Feature;
+
+/**\class ModuleBase_WidgetCustom
+ * \ingroup GUI
+ * \brief An abstract custom widget class. This class realization is assumed to create some controls.
+ * The controls values modification should send signal about values change. Method store is used to fill
+ * the feature with the 
+ */
+class MODULEBASE_EXPORT ModuleBase_WidgetCustom : public QObject
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \theParent the parent object
+  ModuleBase_WidgetCustom(QObject* theParent) :QObject(theParent) {};
+  /// Destructor
+  virtual ~ModuleBase_WidgetCustom() {};
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual void store(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+
+signals:
+  /// The signal about widget values changed
+  void valuesChanged();
+};
+
+#endif
diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp
new file mode 100644 (file)
index 0000000..d902d0e
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ * ModuleBase_WidgetFactory.cpp
+ *
+ *  Created on: Apr 3, 2014
+ *      Author: sbh
+ */
+
+#include <ModuleBase_WidgetFactory.h>
+
+#include <ModuleBase_WidgetSwitch.h>
+
+#include <ModuleBase_PropPanelOperation.h>
+#include <ModuleBase_WidgetPoint2D.h>
+#include <Config_Keywords.h>
+#include <Config_WidgetAPI.h>
+
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QGridLayout>
+#include <QSpinBox>
+#include <QMetaProperty>
+#include <QLabel>
+#include <QPixmap>
+#include <QGroupBox>
+#include <QToolBox>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+#include <cfloat>
+#include <climits>
+
+ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_PropPanelOperation* theOperation)
+    : myOperation(theOperation)
+{
+  QString aXml = myOperation->xmlRepresentation();
+  myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
+}
+
+ModuleBase_WidgetFactory::~ModuleBase_WidgetFactory()
+{
+}
+
+void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
+{
+  if (!myWidgetApi->toChildWidget())
+    return;
+
+  QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
+  aWidgetLay->setContentsMargins(2, 2, 2, 2);
+  do { //Iterate over each node
+    std::string aWdgType = myWidgetApi->widgetType();
+    //Create a widget (doublevalue, groupbox, toolbox, etc.
+    QWidget* aWidget = createWidgetByType(aWdgType, theParent);
+    if (aWidget) {
+      aWidgetLay->addWidget(aWidget);
+    }
+    if (myWidgetApi->isContainerWidget()) {
+      //if current widget is groupbox (container) process it's children recursively
+      QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+      createWidget(aWidget);
+      QGroupBox* aGrBox = qobject_cast<QGroupBox*>(aWidget);
+      aGrBox->setTitle(aGroupName);
+    }
+    if (myWidgetApi->isPagedWidget()) {
+      //If current widget is toolbox or switch-casebox then fetch all
+      //it's pages recursively and setup into the widget.
+      myWidgetApi->toChildWidget();
+      do {
+        QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
+        QWidget* aPage = new QWidget(aWidget);
+        createWidget(aPage);
+        if (aWdgType == WDG_SWITCH) {
+          ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
+          aSwitch->addPage(aPage, aPageName);
+        } else if (aWdgType == WDG_TOOLBOX){
+          QToolBox* aToolbox = qobject_cast<QToolBox*>(aWidget);
+          aToolbox->addItem(aPage, aPageName);
+        }
+      } while(myWidgetApi->toNextWidget());
+    }
+  } while(myWidgetApi->toNextWidget());
+  theParent->setLayout(aWidgetLay);
+}
+
+QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+{
+  QWidget* result = new QWidget(theParent);
+  QVBoxLayout* aLabelLay = new QVBoxLayout(result);
+  QLabel* aLabel = new QLabel(result);
+  aLabel->setText(qs(myWidgetApi->getProperty(INFO_WDG_TEXT)));
+  aLabel->setToolTip(qs(myWidgetApi->getProperty(INFO_WDG_TOOLTIP)));
+  aLabelLay->addWidget(aLabel);
+  aLabelLay->addStretch(1);
+  result->setLayout(aLabelLay);
+  return result;
+}
+
+QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType, QWidget* theParent)
+{
+  QWidget* result = NULL;
+  if (theType == WDG_DOUBLEVALUE) {
+    result = doubleSpinBoxControl();
+  } else if (theType == WDG_INFO) {
+    result = labelControl(theParent);
+  }
+  else if (theType == WDG_POINT_SELECTOR) {
+    result = pointSelectorControl(theParent);
+  }
+  else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
+    result = createContainer(theType, theParent);
+  }
+#ifdef _DEBUG
+  else { qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad widget type"; }
+#endif
+  return result;
+}
+
+QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, QWidget* theParent)
+{
+  QWidget* result = NULL;
+  if (theType == WDG_GROUP || theType == WDG_CHECK_GROUP) {
+    QGroupBox* aGroupBox = new QGroupBox(theParent);
+    aGroupBox->setCheckable(theType == WDG_CHECK_GROUP);
+    result = aGroupBox;
+  } else if (theType == WDG_TOOLBOX) {
+    result = new QToolBox(theParent);
+  } else if (theType == WDG_SWITCH) {
+    result = new ModuleBase_WidgetSwitch(theParent);
+  } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
+    result = NULL;
+  }
+#ifdef _DEBUG
+  else { qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad container type"; }
+#endif
+  return result;
+}
+
+QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl()
+{
+  QWidget* result = new QWidget();
+  QHBoxLayout* aControlLay = new QHBoxLayout(result);
+  aControlLay->setContentsMargins(0, 0, 0, 0);
+  QString aLabelText = qs(myWidgetApi->widgetLabel());
+  QString aLabelIcon = qs(myWidgetApi->widgetIcon());
+  QLabel* aLabel = new QLabel(aLabelText);
+  aLabel->setPixmap(QPixmap(aLabelIcon));
+
+  aControlLay->addWidget(aLabel);
+  QDoubleSpinBox* aBox = new QDoubleSpinBox(result);
+  QString anObjName = QString::fromStdString(myWidgetApi->widgetId());
+  aBox->setObjectName(anObjName);
+  bool isOk = false;
+  std::string aProp = myWidgetApi->getProperty(DOUBLE_WDG_MIN);
+  double aMinVal = qs(aProp).toDouble(&isOk);
+  if (isOk) {
+    aBox->setMinimum(aMinVal);
+  } else {
+    aBox->setMinimum(-DBL_MAX);
+  }
+  aProp = myWidgetApi->getProperty(DOUBLE_WDG_MAX);
+  double aMaxVal = qs(aProp).toDouble(&isOk);
+  if (isOk) {
+    aBox->setMaximum(aMaxVal);
+  } else {
+    aBox->setMaximum(DBL_MAX);
+  }
+  aProp = myWidgetApi->getProperty(DOUBLE_WDG_STEP);
+  double aStepVal = qs(aProp).toDouble(&isOk);
+  if (isOk) {
+    aBox->setSingleStep(aStepVal);
+  }
+  aProp = myWidgetApi->getProperty(DOUBLE_WDG_DFLT);
+  double aDefVal = qs(aProp).toDouble(&isOk);
+  if (isOk) {
+    aBox->setValue(aDefVal);
+  }
+  QString aTTip = qs(myWidgetApi->widgetTooltip());
+  aBox->setToolTip(aTTip);
+  aControlLay->addWidget(aBox);
+  aControlLay->setStretch(1, 1);
+  result->setLayout(aControlLay);
+  connectWidget(aBox, WDG_DOUBLEVALUE);
+  return result;
+}
+
+QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
+{
+  ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent,
+                       qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)), myWidgetApi->widgetId());
+  connectWidget(aWidget, WDG_POINT_SELECTOR);
+  return aWidget->getControl();
+}
+
+bool ModuleBase_WidgetFactory::connectWidget(QObject* theWidget,  const QString& theType)
+{
+  bool result = false;
+  if (theType == WDG_DOUBLEVALUE) {
+    result = QObject::connect(theWidget, SIGNAL(valueChanged(double)), 
+                              myOperation, SLOT(storeReal(double)));
+  }
+  if (theType == WDG_POINT_SELECTOR) {
+    ModuleBase_WidgetCustom* aCustom = dynamic_cast<ModuleBase_WidgetCustom*>(theWidget);
+    result = QObject::connect(aCustom, SIGNAL(valuesChanged()), 
+                              myOperation, SLOT(storeCustomValue()));
+  }
+  return result;
+}
+
+QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
+{
+  return QString::fromStdString(theStdString);
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h
new file mode 100644 (file)
index 0000000..404bcc0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * ModuleBase_WidgetFactory.h
+ *
+ *  Created on: Apr 3, 2014
+ *      Author: sbh
+ */
+
+#ifndef ModuleBase_WidgetFactory_H_
+#define ModuleBase_WidgetFactory_H_
+
+#include <ModuleBase.h>
+#include <QString>
+
+class QObject;
+class QWidget;
+class Config_WidgetAPI;
+class ModuleBase_PropPanelOperation;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetFactory
+{
+public:
+  ModuleBase_WidgetFactory(ModuleBase_PropPanelOperation*);
+  virtual ~ModuleBase_WidgetFactory();
+
+  void createWidget(QWidget* theParent);
+
+protected:
+  //Widgets
+  QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
+  QWidget* labelControl(QWidget* theParent);
+  QWidget* doubleSpinBoxControl();
+  QWidget* pointSelectorControl(QWidget* theParent);
+  QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
+
+  bool connectWidget(QObject*, const QString&);
+  QString qs(const std::string& theStdString) const;
+
+private:
+  Config_WidgetAPI* myWidgetApi;
+  ModuleBase_PropPanelOperation*   myOperation;
+
+
+};
+
+#endif /* ModuleBase_WidgetFactory_H_ */
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
new file mode 100644 (file)
index 0000000..9cd0a47
--- /dev/null
@@ -0,0 +1,72 @@
+// File:        ModuleBase_WidgetPoint2D.cpp
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <ModuleBase_WidgetPoint2D.h>
+
+#include <Config_Keywords.h>
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
+#include <GeomDataAPI_Point2D.h>
+
+#include <QGroupBox>
+#include <QGridLayout>
+#include <QDoubleSpinBox>
+#include <QLabel>
+
+ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, QString theTitle,
+                                                   const std::string& theFeatureAttributeID)
+: ModuleBase_WidgetCustom(theParent), myFeatureAttributeID(theFeatureAttributeID)
+{
+  myGroupBox = new QGroupBox(theTitle, theParent);
+  QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
+  aGroupLay->setContentsMargins(0, 0, 0, 0);
+  aGroupLay->setColumnStretch(1, 1);
+  {
+    QLabel* aLabel = new QLabel(myGroupBox);
+    aLabel->setText("X");
+    aLabel->setPixmap(QPixmap(":pictures/x_point.png"));
+    aGroupLay->addWidget(aLabel, 0, 0);
+
+    myXSpin = new QDoubleSpinBox(myGroupBox);
+    myXSpin->setMinimum(-DBL_MAX);
+    myXSpin->setMaximum(DBL_MAX);
+    myXSpin->setToolTip("X");
+    aGroupLay->addWidget(myXSpin, 0, 1);
+    
+    connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+  }
+  {
+    QLabel* aLabel = new QLabel(myGroupBox);
+    aLabel->setText("Y");
+    aLabel->setPixmap(QPixmap(":pictures/y_point.png"));
+    aGroupLay->addWidget(aLabel, 1, 0);
+
+    myYSpin = new QDoubleSpinBox(myGroupBox);
+    myYSpin->setMinimum(-DBL_MAX);
+    myYSpin->setMaximum(DBL_MAX);
+    myYSpin->setToolTip("X");
+    aGroupLay->addWidget(myYSpin, 1, 1);
+
+    connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+  }
+}
+
+ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
+{
+}
+
+void ModuleBase_WidgetPoint2D::store(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myFeatureAttributeID));
+
+  aPoint->setValue(myXSpin->value(), myYSpin->value());
+}
+
+QWidget* ModuleBase_WidgetPoint2D::getControl() const
+{
+  return myGroupBox;
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h
new file mode 100644 (file)
index 0000000..a973ef6
--- /dev/null
@@ -0,0 +1,50 @@
+// File:        ModuleBase_WidgetPoint2D.h
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_WidgetPoint2D_H
+#define ModuleBase_WidgetPoint2D_H
+
+#include <ModuleBase.h>
+#include "ModuleBase_WidgetCustom.h"
+
+#include <QObject>
+
+class ModelAPI_Feature;
+
+class QGroupBox;
+class QDoubleSpinBox;
+
+/**\class ModuleBase_WidgetPoint2D
+ * \ingroup GUI
+ * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
+ */
+class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_WidgetCustom
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \theParent the parent object
+  /// \theTitle the group box title
+  /// \theFeatureAttributeID the identifier of the feature attribute
+  ModuleBase_WidgetPoint2D(QWidget* theParent, QString theTitle,
+                           const std::string& theFeatureAttributeID);
+  /// Destructor
+  virtual ~ModuleBase_WidgetPoint2D();
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual void store(boost::shared_ptr<ModelAPI_Feature> theFeature);
+
+  /// Returns the internal parent wiget control, that can be shown anywhere
+  /// \returns the widget
+  QWidget* getControl() const;
+
+private:
+  std::string myFeatureAttributeID; ///< the identifier of the feature attribute
+  QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets
+  QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate
+  QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate
+};
+
+#endif
diff --git a/src/ModuleBase/ModuleBase_WidgetSwitch.cpp b/src/ModuleBase/ModuleBase_WidgetSwitch.cpp
new file mode 100644 (file)
index 0000000..3024f11
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * ModuleBase_WidgetSwitch.cpp
+ *
+ *  Created on: Apr 16, 2014
+ *      Author: sbh
+ */
+
+#include <ModuleBase_WidgetSwitch.h>
+
+#include <QComboBox>
+#include <QVBoxLayout>
+#include <QSpacerItem>
+
+ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* parent)
+: QFrame(parent)
+{
+  myMainLay = new QVBoxLayout(this);
+  myMainLay->setContentsMargins(2, 4, 2, 2);
+  myCombo = new QComboBox(this);
+  myCombo->hide();
+  myMainLay->addWidget(myCombo);
+  this->setFrameShape(QFrame::StyledPanel);
+  connect(myCombo, SIGNAL(currentIndexChanged(int)),
+          this, SLOT(setCurrentIndex(int)));
+  connect(myCombo, SIGNAL(currentIndexChanged(int)),
+          this, SIGNAL(currentPageChanged(int)));
+
+}
+
+ModuleBase_WidgetSwitch::~ModuleBase_WidgetSwitch()
+{
+}
+
+int ModuleBase_WidgetSwitch::addPage(QWidget* theWidget, const QString& theName)
+{
+  return insertPage(count(), theWidget, theName);
+}
+
+int ModuleBase_WidgetSwitch::count() const
+{
+  return myCombo->count();
+}
+
+int ModuleBase_WidgetSwitch::currentIndex() const
+{
+  return myCombo->currentIndex();
+}
+
+QWidget* ModuleBase_WidgetSwitch::currentWidget() const
+{
+  int idx = currentIndex();
+  return myCases[idx];
+}
+
+int ModuleBase_WidgetSwitch::indexOf(QWidget* theWidget) const
+{
+  return myCases.indexOf(theWidget);
+}
+
+int ModuleBase_WidgetSwitch::insertPage(int theIndex, QWidget* theWidget, const QString& theName)
+{
+  int index = theIndex < count() ? theIndex : count();
+  if(count() == 0)
+    myCombo->show();
+  myCombo->insertItem(index, theName);
+  myCases.insert(index, theWidget);
+  myMainLay->addWidget(theWidget);
+  setCurrentIndex(theIndex);
+  return index;
+}
+
+bool ModuleBase_WidgetSwitch::isPageEnabled(int index) const
+{
+  return myCases[index]->isEnabled();
+}
+
+QString ModuleBase_WidgetSwitch::pageText(int index) const
+{
+  return myCombo->itemText(index);
+}
+
+QString ModuleBase_WidgetSwitch::pageToolTip(int index) const
+{
+  return myCases[index]->toolTip();
+}
+
+void ModuleBase_WidgetSwitch::removePage(int index)
+{
+  myCombo->removeItem(index);
+  myCases.removeAt(index);
+  if (count() == 0) {
+    myCombo->hide();
+  }
+}
+
+void ModuleBase_WidgetSwitch::setPageEnabled(int index, bool enabled)
+{
+  myCases[index]->setEnabled(enabled);
+}
+
+void ModuleBase_WidgetSwitch::setPageName(int index, const QString& theName)
+{
+  myCombo->setItemText(index, theName);
+}
+
+void ModuleBase_WidgetSwitch::setPageToolTip(int index, const QString& toolTip)
+{
+  myCases[index]->setToolTip(toolTip);
+}
+
+void ModuleBase_WidgetSwitch::setCurrentIndex(int index)
+{
+  myCombo->setCurrentIndex(index);
+  refresh();
+}
+
+void ModuleBase_WidgetSwitch::refresh()
+{
+  foreach(QWidget* eachWidget, myCases) {
+    eachWidget->setVisible(false);
+  }
+  if(currentIndex() >= myCases.count())
+    return;
+  myCases[currentIndex()]->setVisible(true);
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetSwitch.h b/src/ModuleBase/ModuleBase_WidgetSwitch.h
new file mode 100644 (file)
index 0000000..08ce3bc
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * ModuleBase_WidgetSwitch.h
+ *
+ *  Created on: Apr 16, 2014
+ *      Author: sbh
+ */
+
+#ifndef ModuleBase_WidgetSwitch_H_
+#define ModuleBase_WidgetSwitch_H_
+
+#include <ModuleBase.h>
+#include <QFrame>
+
+class QComboBox;
+class QVBoxLayout;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetSwitch: public QFrame
+{
+  Q_OBJECT
+public:
+  ModuleBase_WidgetSwitch(QWidget* parent = NULL);
+  virtual ~ModuleBase_WidgetSwitch();
+
+  int addPage(QWidget * theWidget, const QString & theName);
+  int count() const;
+  int currentIndex() const;
+  QWidget * currentWidget() const;
+  int indexOf(QWidget * theWidget) const;
+  int insertPage(int index, QWidget * theWidget, const QString & theName);
+  bool isPageEnabled(int index) const;
+  QString pageText(int index) const;
+  QString pageToolTip(int index) const;
+  void removePage(int index);
+  void setPageEnabled(int index, bool enabled);
+  void setPageName(int index, const QString & text);
+  void setPageToolTip(int index, const QString & toolTip);
+
+public slots:
+  void setCurrentIndex(int index);
+
+signals:
+  void currentPageChanged(int);
+
+protected:
+  void refresh();
+
+private:
+  QVBoxLayout* myMainLay;
+  QComboBox* myCombo;
+  QWidgetList myCases;
+};
+
+#endif /* ModuleBase_WidgetSwitch_H_ */
index f8ce75a9284e361031176740707b573870993020..5a999aabae5229a06c830c01788a0ee3d81046a7 100644 (file)
@@ -7,13 +7,15 @@ SET(PROJECT_HEADERS
        PartSet.h
        PartSet_Module.h
        PartSet_OperationSketchBase.h
-    PartSet_OperationSketch.h
+       PartSet_OperationSketch.h
+       PartSet_OperationSketchLine.h
 )
 
 SET(PROJECT_SOURCES
        PartSet_Module.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
+       PartSet_OperationSketchLine.cpp
 )
 
 SET(PROJECT_RESOURCES 
index 71d0987a4bbebcec134cea5127758d8e868af099..c76792ca14cfaf19a7f16f3ca04be7afeb0d83d6 100644 (file)
@@ -1,5 +1,6 @@
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketch.h>
+#include <PartSet_OperationSketchLine.h>
 
 #include <ModuleBase_Operation.h>
 
@@ -80,7 +81,15 @@ void PartSet_Module::onFeatureTriggered()
   ModuleBase_PropPanelOperation* aPartSetOp;
   if (aCmdId == "Sketch" ) {
     aPartSetOp = new PartSet_OperationSketch(aCmdId, this);
-  } else {
+  }
+  else if(aCmdId == "SketchLine") {
+    ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+    boost::shared_ptr<ModelAPI_Feature> aSketchFeature;
+    if (anOperation)
+      aSketchFeature = anOperation->feature();
+    aPartSetOp = new PartSet_OperationSketchLine(aCmdId, this, aSketchFeature);
+  }
+  else {
     aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
   }
   aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
index c343503e2467bf22f60015430cd021df48d9c088..7eca33e4376d08d47fde5f9426dca70928480d5e 100644 (file)
@@ -82,5 +82,6 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Sh
   boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
   emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
 
-  commit();
+  //commit();
+  //SketchPlugin_Sketch::setActive(myFeature);
 }
diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp
new file mode 100644 (file)
index 0000000..7a5a781
--- /dev/null
@@ -0,0 +1,52 @@
+// File:        PartSet_OperationSketchLine.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationSketchLine.h>
+
+#include <SketchPlugin_Feature.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+using namespace std;
+
+PartSet_OperationSketchLine::PartSet_OperationSketchLine(const QString& theId,
+                                                 QObject* theParent,
+                                              boost::shared_ptr<ModelAPI_Feature> theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
+{
+}
+
+PartSet_OperationSketchLine::~PartSet_OperationSketchLine()
+{
+}
+
+bool PartSet_OperationSketchLine::isPerformedImmediately() const
+{
+  return false;
+}
+
+int PartSet_OperationSketchLine::getSelectionMode() const
+{
+  return TopAbs_FACE;
+}
+
+void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
+{
+  if (theList.IsEmpty())
+    return;
+}
+
+void PartSet_OperationSketchLine::startOperation()
+{
+  PartSet_OperationSketchBase::startOperation();
+
+  if (mySketch) {
+    boost::shared_ptr<SketchPlugin_Feature> aFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(mySketch);
+
+    aFeature->addSub(feature());
+  }
+}
diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h
new file mode 100644 (file)
index 0000000..7c228af
--- /dev/null
@@ -0,0 +1,51 @@
+// File:        PartSet_OperationSketchLine.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationSketchLine_H
+#define PartSet_OperationSketchLine_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+/*!
+ \class PartSet_OperationSketchLine
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationSketchLine : public PartSet_OperationSketchBase
+{
+  Q_OBJECT
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theFeature the parent feature
+  PartSet_OperationSketchLine(const QString& theId, QObject* theParent,
+                              boost::shared_ptr<ModelAPI_Feature> theSketchFeature);
+  /// Destructor
+  virtual ~PartSet_OperationSketchLine();
+
+  /// The sketch can not be created immediately, firstly a plane should be set
+  virtual bool isPerformedImmediately() const;
+
+  /// Returns the operation local selection mode
+  /// \return the selection mode
+  virtual int getSelectionMode() const;
+
+  /// Gives the current selected objects to be processed by the operation
+  /// \param theList a list of interactive selected shapes
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+
+protected:
+  /// \brief Virtual method called when operation is started
+  /// Virtual method called when operation started (see start() method for more description)
+  /// After the parent operation body perform, set sketch feature to the created line feature
+  virtual void startOperation();
+
+private:
+  boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
+};
+
+#endif
index 9d0ae50927de30be4efd43798e1faeab08aa0c8e..7877a719153b9917a7098c0227823cd4a82f4460 100644 (file)
@@ -38,6 +38,11 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
+  /// Adds sub-feature of the higher level feature (sub-element of the sketch)
+  /// \param theFeature sub-feature
+  SKETCHPLUGIN_EXPORT virtual const void addSub(
+    const boost::shared_ptr<ModelAPI_Feature>& theFeature) {};
+
   /// Use plugin manager for features creation
   SketchPlugin_Line();
 };
index 1149409813a5645b6b24018d974e55aa79b3f29b..ab95647eedc7b0abec58d235f20d2536a1b23dab 100644 (file)
@@ -1,5 +1,6 @@
 #include "SketchPlugin_Plugin.h"
 #include "SketchPlugin_Sketch.h"
+#include "SketchPlugin_Line.h"
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 
@@ -19,9 +20,9 @@ boost::shared_ptr<ModelAPI_Feature> SketchPlugin_Plugin::createFeature(string th
   if (theFeatureID == "Sketch") {
     return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Sketch);
   }
-  /*else if (theFeatureID == "Point") {
-    return shared_ptr<ModelAPI_Feature>(new SketchPlugin_Point);
-  }*/
+  else if (theFeatureID == "SketchLine") {
+    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Line);
+  }
   // feature of such kind is not found
   return boost::shared_ptr<ModelAPI_Feature>();
 }
index 09ac545be2f24fc6de3dd31a06b516a68cda2b50..489bf53e63972674f8dd8ee6996a7a8c623496fa 100644 (file)
@@ -2,9 +2,13 @@
   <workbench id="Sketch">
     <group id="Basic">
       <feature id="Sketch" text="New sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
-        <label text="Natasha, please provide a text for the label" tooltip="Natasha, please provide a text for the tooltip"/> 
+        <label text="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/> 
       <!--icon=":pictures/x_point.png"-->
       </feature>
+      <feature id="SketchLine" text="Line" tooltip="Create a new line" icon=":icons/line.png">
+        <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
+        <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
+      </feature>
     </group>
   </workbench>
 </plugin>
index a246e4060ebcd25ac868fb9babc49dabc0fc7bcd..106d695b7a40df170281a52fe51ae9d5d89853f2 100644 (file)
@@ -19,14 +19,12 @@ SET(PROJECT_HEADERS
        XGUI_RubberBand.h
        XGUI_Constants.h
        XGUI_ViewBackground.h
-       XGUI_WidgetFactory.h
        XGUI_DocumentDataModel.h
        XGUI_PartDataModel.h
        XGUI_ObjectsBrowser.h
        XGUI_OperationMgr.h
     XGUI_DataTreeModel.h
     XGUI_SelectionMgr.h
-    XGUI_SwitchWidget.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -47,13 +45,11 @@ SET(PROJECT_SOURCES
     XGUI_Viewer.cpp
        XGUI_RubberBand.cpp
        XGUI_ViewBackground.cpp
-       XGUI_WidgetFactory.cpp
        XGUI_DocumentDataModel.cpp
        XGUI_PartDataModel.cpp
        XGUI_ObjectsBrowser.cpp
        XGUI_OperationMgr.cpp
     XGUI_SelectionMgr.cpp
-    XGUI_SwitchWidget.cpp
 )
 
 SET(PROJECT_RESOURCES 
diff --git a/src/XGUI/XGUI_SwitchWidget.cpp b/src/XGUI/XGUI_SwitchWidget.cpp
deleted file mode 100644 (file)
index bfa71fe..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * XGUI_SwitchWidget.cpp
- *
- *  Created on: Apr 16, 2014
- *      Author: sbh
- */
-
-#include <XGUI_SwitchWidget.h>
-
-#include <QComboBox>
-#include <QVBoxLayout>
-#include <QSpacerItem>
-
-XGUI_SwitchWidget::XGUI_SwitchWidget(QWidget* parent)
-: QFrame(parent)
-{
-  myMainLay = new QVBoxLayout(this);
-  myMainLay->setContentsMargins(2, 4, 2, 2);
-  myCombo = new QComboBox(this);
-  myCombo->hide();
-  myMainLay->addWidget(myCombo);
-  this->setFrameShape(QFrame::StyledPanel);
-  connect(myCombo, SIGNAL(currentIndexChanged(int)),
-          this, SLOT(setCurrentIndex(int)));
-  connect(myCombo, SIGNAL(currentIndexChanged(int)),
-          this, SIGNAL(currentPageChanged(int)));
-
-}
-
-XGUI_SwitchWidget::~XGUI_SwitchWidget()
-{
-}
-
-int XGUI_SwitchWidget::addPage(QWidget* theWidget, const QString& theName)
-{
-  return insertPage(count(), theWidget, theName);
-}
-
-int XGUI_SwitchWidget::count() const
-{
-  return myCombo->count();
-}
-
-int XGUI_SwitchWidget::currentIndex() const
-{
-  return myCombo->currentIndex();
-}
-
-QWidget* XGUI_SwitchWidget::currentWidget() const
-{
-  int idx = currentIndex();
-  return myCases[idx];
-}
-
-int XGUI_SwitchWidget::indexOf(QWidget* theWidget) const
-{
-  return myCases.indexOf(theWidget);
-}
-
-int XGUI_SwitchWidget::insertPage(int theIndex, QWidget* theWidget, const QString& theName)
-{
-  int index = theIndex < count() ? theIndex : count();
-  if(count() == 0)
-    myCombo->show();
-  myCombo->insertItem(index, theName);
-  myCases.insert(index, theWidget);
-  myMainLay->addWidget(theWidget);
-  setCurrentIndex(theIndex);
-  return index;
-}
-
-bool XGUI_SwitchWidget::isPageEnabled(int index) const
-{
-  return myCases[index]->isEnabled();
-}
-
-QString XGUI_SwitchWidget::pageText(int index) const
-{
-  return myCombo->itemText(index);
-}
-
-QString XGUI_SwitchWidget::pageToolTip(int index) const
-{
-  return myCases[index]->toolTip();
-}
-
-void XGUI_SwitchWidget::removePage(int index)
-{
-  myCombo->removeItem(index);
-  myCases.removeAt(index);
-  if (count() == 0) {
-    myCombo->hide();
-  }
-}
-
-void XGUI_SwitchWidget::setPageEnabled(int index, bool enabled)
-{
-  myCases[index]->setEnabled(enabled);
-}
-
-void XGUI_SwitchWidget::setPageName(int index, const QString& theName)
-{
-  myCombo->setItemText(index, theName);
-}
-
-void XGUI_SwitchWidget::setPageToolTip(int index, const QString& toolTip)
-{
-  myCases[index]->setToolTip(toolTip);
-}
-
-void XGUI_SwitchWidget::setCurrentIndex(int index)
-{
-  myCombo->setCurrentIndex(index);
-  refresh();
-}
-
-void XGUI_SwitchWidget::refresh()
-{
-  foreach(QWidget* eachWidget, myCases) {
-    eachWidget->setVisible(false);
-  }
-  if(currentIndex() >= myCases.count())
-    return;
-  myCases[currentIndex()]->setVisible(true);
-}
diff --git a/src/XGUI/XGUI_SwitchWidget.h b/src/XGUI/XGUI_SwitchWidget.h
deleted file mode 100644 (file)
index 0fa6fcc..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * XGUI_SwitchWidget.h
- *
- *  Created on: Apr 16, 2014
- *      Author: sbh
- */
-
-#ifndef XGUI_SWITCHWIDGET_H_
-#define XGUI_SWITCHWIDGET_H_
-
-#include <XGUI.h>
-#include <QFrame>
-
-class QComboBox;
-class QVBoxLayout;
-
-class XGUI_EXPORT XGUI_SwitchWidget: public QFrame
-{
-  Q_OBJECT
-public:
-  XGUI_SwitchWidget(QWidget* parent = NULL);
-  virtual ~XGUI_SwitchWidget();
-
-  int addPage(QWidget * theWidget, const QString & theName);
-  int count() const;
-  int currentIndex() const;
-  QWidget * currentWidget() const;
-  int indexOf(QWidget * theWidget) const;
-  int insertPage(int index, QWidget * theWidget, const QString & theName);
-  bool isPageEnabled(int index) const;
-  QString pageText(int index) const;
-  QString pageToolTip(int index) const;
-  void removePage(int index);
-  void setPageEnabled(int index, bool enabled);
-  void setPageName(int index, const QString & text);
-  void setPageToolTip(int index, const QString & toolTip);
-
-public slots:
-  void setCurrentIndex(int index);
-
-signals:
-  void currentPageChanged(int);
-
-protected:
-  void refresh();
-
-private:
-  QVBoxLayout* myMainLay;
-  QComboBox* myCombo;
-  QWidgetList myCases;
-};
-
-#endif /* XGUI_SWITCHWIDGET_H_ */
diff --git a/src/XGUI/XGUI_WidgetFactory.cpp b/src/XGUI/XGUI_WidgetFactory.cpp
deleted file mode 100644 (file)
index 17c3ab6..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * XGUI_WidgetFactory.cpp
- *
- *  Created on: Apr 3, 2014
- *      Author: sbh
- */
-
-#include <XGUI_WidgetFactory.h>
-
-#include <XGUI_SwitchWidget.h>
-
-#include <ModuleBase_PropPanelOperation.h>
-#include <Config_Keywords.h>
-#include <Config_WidgetAPI.h>
-
-#include <QWidget>
-#include <QHBoxLayout>
-#include <QSpinBox>
-#include <QMetaProperty>
-#include <QLabel>
-#include <QPixmap>
-#include <QGroupBox>
-#include <QToolBox>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <cfloat>
-#include <climits>
-
-XGUI_WidgetFactory::XGUI_WidgetFactory(ModuleBase_PropPanelOperation* theOperation)
-    : myOperation(theOperation)
-{
-  QString aXml = myOperation->xmlRepresentation();
-  myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
-}
-
-XGUI_WidgetFactory::~XGUI_WidgetFactory()
-{
-}
-
-void XGUI_WidgetFactory::createWidget(QWidget* theParent)
-{
-  if (!myWidgetApi->toChildWidget())
-    return;
-
-  QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
-  aWidgetLay->setContentsMargins(2, 2, 2, 2);
-  do { //Iterate over each node
-    std::string aWdgType = myWidgetApi->widgetType();
-    //Create a widget (doublevalue, groupbox, toolbox, etc.
-    QWidget* aWidget = createWidgetByType(aWdgType, theParent);
-    if (aWidget) {
-      aWidgetLay->addWidget(aWidget);
-    }
-    if (myWidgetApi->isContainerWidget()) {
-      //if current widget is groupbox (container) process it's children recursively
-      QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
-      createWidget(aWidget);
-      QGroupBox* aGrBox = qobject_cast<QGroupBox*>(aWidget);
-      aGrBox->setTitle(aGroupName);
-    }
-    if (myWidgetApi->isPagedWidget()) {
-      //If current widget is toolbox or switch-casebox then fetch all
-      //it's pages recursively and setup into the widget.
-      myWidgetApi->toChildWidget();
-      do {
-        QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
-        QWidget* aPage = new QWidget(aWidget);
-        createWidget(aPage);
-        if (aWdgType == WDG_SWITCH) {
-          XGUI_SwitchWidget* aSwitch = qobject_cast<XGUI_SwitchWidget*>(aWidget);
-          aSwitch->addPage(aPage, aPageName);
-        } else if (aWdgType == WDG_TOOLBOX){
-          QToolBox* aToolbox = qobject_cast<QToolBox*>(aWidget);
-          aToolbox->addItem(aPage, aPageName);
-        }
-      } while(myWidgetApi->toNextWidget());
-    }
-  } while(myWidgetApi->toNextWidget());
-  theParent->setLayout(aWidgetLay);
-}
-
-QWidget* XGUI_WidgetFactory::labelControl(QWidget* theParent)
-{
-  QWidget* result = new QWidget(theParent);
-  QVBoxLayout* aLabelLay = new QVBoxLayout(result);
-  QLabel* aLabel = new QLabel(result);
-  aLabel->setText(qs(myWidgetApi->getProperty(INFO_WDG_TEXT)));
-  aLabel->setToolTip(qs(myWidgetApi->getProperty(INFO_WDG_TOOLTIP)));
-  aLabelLay->addWidget(aLabel);
-  aLabelLay->addStretch(1);
-  result->setLayout(aLabelLay);
-  return result;
-}
-
-QWidget* XGUI_WidgetFactory::createWidgetByType(const std::string& theType, QWidget* theParent)
-{
-  QWidget* result = NULL;
-  if (theType == WDG_DOUBLEVALUE) {
-    result = doubleSpinBoxControl();
-  } else if (theType == WDG_INFO) {
-    result = labelControl(theParent);
-  } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
-    result = createContainer(theType, theParent);
-  }
-#ifdef _DEBUG
-  else { qDebug() << "XGUI_WidgetFactory::fillWidget: find bad widget type"; }
-#endif
-  return result;
-}
-
-QWidget* XGUI_WidgetFactory::createContainer(const std::string& theType, QWidget* theParent)
-{
-  QWidget* result = NULL;
-  if (theType == WDG_GROUP || theType == WDG_CHECK_GROUP) {
-    QGroupBox* aGroupBox = new QGroupBox(theParent);
-    aGroupBox->setCheckable(theType == WDG_CHECK_GROUP);
-    result = aGroupBox;
-  } else if (theType == WDG_TOOLBOX) {
-    result = new QToolBox(theParent);
-  } else if (theType == WDG_SWITCH) {
-    result = new XGUI_SwitchWidget(theParent);
-  } else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
-    result = NULL;
-  }
-#ifdef _DEBUG
-  else { qDebug() << "XGUI_WidgetFactory::fillWidget: find bad container type"; }
-#endif
-  return result;
-}
-
-QWidget* XGUI_WidgetFactory::doubleSpinBoxControl()
-{
-  QWidget* result = new QWidget();
-  QHBoxLayout* aControlLay = new QHBoxLayout(result);
-  aControlLay->setContentsMargins(0, 0, 0, 0);
-  QString aLabelText = qs(myWidgetApi->widgetLabel());
-  QString aLabelIcon = qs(myWidgetApi->widgetIcon());
-  QLabel* aLabel = new QLabel(aLabelText);
-  aLabel->setPixmap(QPixmap(aLabelIcon));
-
-  aControlLay->addWidget(aLabel);
-  QDoubleSpinBox* aBox = new QDoubleSpinBox(result);
-  QString anObjName = QString::fromStdString(myWidgetApi->widgetId());
-  aBox->setObjectName(anObjName);
-  bool isOk = false;
-  std::string aProp = myWidgetApi->getProperty(DOUBLE_WDG_MIN);
-  double aMinVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setMinimum(aMinVal);
-  } else {
-    aBox->setMinimum(-DBL_MAX);
-  }
-  aProp = myWidgetApi->getProperty(DOUBLE_WDG_MAX);
-  double aMaxVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setMaximum(aMaxVal);
-  } else {
-    aBox->setMaximum(DBL_MAX);
-  }
-  aProp = myWidgetApi->getProperty(DOUBLE_WDG_STEP);
-  double aStepVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setSingleStep(aStepVal);
-  }
-  aProp = myWidgetApi->getProperty(DOUBLE_WDG_DFLT);
-  double aDefVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setValue(aDefVal);
-  }
-  QString aTTip = qs(myWidgetApi->widgetTooltip());
-  aBox->setToolTip(aTTip);
-  aControlLay->addWidget(aBox);
-  aControlLay->setStretch(1, 1);
-  result->setLayout(aControlLay);
-  connectWidget(aBox, WDG_DOUBLEVALUE);
-  return result;
-}
-
-bool XGUI_WidgetFactory::connectWidget(QWidget* theWidget,  const QString& theType)
-{
-  bool result = false;
-  if (theType == WDG_DOUBLEVALUE) {
-    result = QObject::connect(theWidget, SIGNAL(valueChanged(double)), 
-                              myOperation, SLOT(storeReal(double)));
-  }
-  return result;
-}
-
-QString XGUI_WidgetFactory::qs(const std::string& theStdString) const
-{
-  return QString::fromStdString(theStdString);
-}
diff --git a/src/XGUI/XGUI_WidgetFactory.h b/src/XGUI/XGUI_WidgetFactory.h
deleted file mode 100644 (file)
index d83d8fb..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * XGUI_WidgetFactory.h
- *
- *  Created on: Apr 3, 2014
- *      Author: sbh
- */
-
-#ifndef XGUI_WIDGETFACTORY_H_
-#define XGUI_WIDGETFACTORY_H_
-
-#include "XGUI.h"
-#include <QString>
-
-class QWidget;
-class Config_WidgetAPI;
-class ModuleBase_PropPanelOperation;
-
-class XGUI_EXPORT XGUI_WidgetFactory
-{
-public:
-  XGUI_WidgetFactory(ModuleBase_PropPanelOperation*);
-  virtual ~XGUI_WidgetFactory();
-
-  void createWidget(QWidget* theParent);
-
-protected:
-  //Widgets
-  QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
-  QWidget* labelControl(QWidget* theParent);
-  QWidget* doubleSpinBoxControl();
-  QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
-
-  bool connectWidget(QWidget*, const QString&);
-  QString qs(const std::string& theStdString) const;
-
-private:
-  Config_WidgetAPI* myWidgetApi;
-  ModuleBase_PropPanelOperation*   myOperation;
-
-
-};
-
-#endif /* XGUI_WIDGETFACTORY_H_ */
index cbc3ce14610a781abcc743f987fb50b11f665ba3..6518d05e7618e72d3cbc295ac6fba3c4978fe96d 100644 (file)
@@ -8,7 +8,7 @@
 #include "XGUI_Workbench.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_Viewer.h"
-#include "XGUI_WidgetFactory.h"
+#include "ModuleBase_WidgetFactory.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_Displayer.h"
@@ -187,7 +187,7 @@ void XGUI_Workshop::onOperationStarted()
 
     myMainWindow->showPropertyPanel();
 
-    XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation);
+    ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
     aFactory.createWidget(aPropWidget);
     myMainWindow->setPropertyPannelTitle(aOperation->description());
   }