Salome HOME
Construction of vertices, edges and faces from a sketch: Widget creator
authornds <nds@opencascade.com>
Fri, 27 Nov 2015 04:25:44 +0000 (07:25 +0300)
committerdbv <dbv@opencascade.com>
Tue, 8 Dec 2015 08:45:56 +0000 (11:45 +0300)
src/ModuleBase/ModuleBase_IWidgetCreator.h
src/SketchShapePlugin/CMakeLists.txt
src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp
src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h
src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.h [new file with mode: 0755]
src/SketchShapePlugin/plugin-SketchShape.xml

index 4f1e040de9ec87e3bbc8c0c2f4211e96fd6040f7..dfff4fa71ba20e762e93dd89ebbbf2bfe4319c29 100755 (executable)
@@ -5,7 +5,7 @@
 
 #include "ModuleBase.h"
 
-#include <list>
+#include <set>
 #include <string>
 
 class ModuleBase_ModelWidget;
@@ -27,7 +27,7 @@ public:
 
   /// Returns a list of possible widget types, which this creator can process
   /// \param theTypes
-  virtual void widgetTypes(std::list<std::string>& theTypes) = 0;
+  virtual const std::set<std::string>& widgetTypes() = 0;
 
    /// Create widget by its type
    /// \param theType a type
index 97cb8abc50de02153ca6ff39b18f95098dde0845..200ca71babc559ed10a08ee95bc4aa882806670c 100755 (executable)
@@ -10,6 +10,7 @@ SET(PROJECT_HEADERS
     SketchShapePlugin_Plugin.h
     SketchShapePlugin_Validators.h
     SketchShapePlugin_Tools.h
+    SketchShapePlugin_WidgetCreator.h
 )
 
 SET(PROJECT_SOURCES
@@ -18,6 +19,7 @@ SET(PROJECT_SOURCES
     SketchShapePlugin_Plugin.cpp
     SketchShapePlugin_Validators.cpp
     SketchShapePlugin_Tools.cpp
+    SketchShapePlugin_WidgetCreator.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -34,7 +36,7 @@ SET(XML_RESOURCES
   plugin-SketchShape.xml
 )
 
-ADD_DEFINITIONS(-DSKETCHSHAPEPLUGIN_EXPORTS)
+ADD_DEFINITIONS(-DSKETCHSHAPEPLUGIN_EXPORTS -DWNT)
 ADD_LIBRARY(SketchShapePlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
 TARGET_LINK_LIBRARIES(SketchShapePlugin ${PROJECT_LIBRARIES})
 
index e8f9334e19a373a2827d7722cbec5db3165e4bd7..a28cec528d1100fe5ebeb9238d51cd44d9d15d90 100755 (executable)
@@ -4,13 +4,11 @@
 // Created:     25 Nov 2015
 // Author:      Natalia ERMOLAEVA
 
-//#include <SketchShapePlugin_PageGroupBox.h>
+#include <SketchShapePlugin_PageGroupBox.h>
 
-//#include <QGridLayout>
-
-/*SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent)
+SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent)
 : ModuleBase_PageGroupBox(theParent)
 {
   setTitle("SketchShapePlugin_PageGroupBox");
-}*/
+}
 
index 4a3666c658e301fb99cb39b013a273ae63e3089c..3da8919d42dbeea5845c84d1bd5505aac3f26690 100755 (executable)
@@ -15,14 +15,14 @@ class QWidget;
  * \ingroup GUI
  * Represent a property panel's list of ModuleBase_ModelWidgets.
  */
-class SketchShapePlugin_PageGroupBox// : public ModuleBase_PageGroupBox
+class SketchShapePlugin_PageGroupBox : public ModuleBase_PageGroupBox
 {
   //Q_OBJECT
- public:
+public:
   /// Constructs a page that looks like a QGroupBox
-  SketchShapePlugin_PageGroupBox(QWidget* theParent = 0) {};
+  SketchShapePlugin_PageGroupBox(QWidget* theParent = 0);
   /// Destructs the page
-  virtual ~SketchShapePlugin_PageGroupBox() {};
+  virtual ~SketchShapePlugin_PageGroupBox() {}
 };
 
 #endif /* SKETCHSHAPEPLUGIN_PAGEGROUPBOX_H_ */
diff --git a/src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.cpp b/src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.cpp
new file mode 100755 (executable)
index 0000000..89552f1
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include "SketchShapePlugin_WidgetCreator.h"
+#include "SketchShapePlugin_PageGroupBox.h"
+
+SketchShapePlugin_WidgetCreator::SketchShapePlugin_WidgetCreator()
+: ModuleBase_IWidgetCreator()
+{
+  myTypes.insert("sketchshape_groupbox");
+}
+
+const std::set<std::string>& SketchShapePlugin_WidgetCreator::widgetTypes()
+{
+  return myTypes;
+}
+
+ModuleBase_ModelWidget* SketchShapePlugin_WidgetCreator::createWidgetByType(
+                                   const std::string& theType, QWidget* theParent)
+{
+  ModuleBase_ModelWidget* aWidget = 0;
+  if (myTypes.find(theType) != myTypes.end())
+    return aWidget;
+
+  if (theType == "sketchshape_groupbox") {
+    //aWidget = 
+      new SketchShapePlugin_PageGroupBox(theParent);
+  }
+
+  return aWidget;
+}
diff --git a/src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.h b/src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.h
new file mode 100755 (executable)
index 0000000..a812b01
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef SketchShapePlugin_WidgetCreator_H
+#define SketchShapePlugin_WidgetCreator_H
+
+#include <ModuleBase_IWidgetCreator.h>
+
+#include <string>
+#include <set>
+
+class ModuleBase_ModelWidget;
+class QWidget;
+
+/** 
+* \ingroup GUI
+* Interface to WidgetCreator which can create specific widgets by type
+*/
+class SketchShapePlugin_WidgetCreator : public ModuleBase_IWidgetCreator
+{
+public:
+  /// Default constructor
+  SketchShapePlugin_WidgetCreator();
+
+  /// Virtual destructor
+  ~SketchShapePlugin_WidgetCreator() {}
+
+  /// Returns a list of possible widget types, which this creator can process
+  /// \return theTypes
+  virtual const std::set<std::string>& widgetTypes();
+
+  /// 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);
+
+private:
+  std::set<std::string> myTypes; /// types of widgets
+};
+
+
+#endif
index 4dca7052ffbd48efb1009b61c86ffaa97fd8abdb..016198101ff79d820bae9f98bead9cb507eb45b9 100755 (executable)
@@ -6,15 +6,14 @@
       <feature id="SketchShape" title="Sketch vertices, edges and faces" tooltip="Construct vertices, edges and faces by sketch" icon=":icons/sketchshape.png">
         <sketchshape_groupbox title="Direction">
           <boolvalue id="VertexChoice" label="VERTICES" default="true" tooltip="Vertices selection on sketch"/>
-
-        <sketch_multi_selector id="VertexList"
+          <sketch_multi_selector id="VertexList"
             label=""
             tooltip="Select list of mirroring objects"
             type_choice="Vertices"
             use_external="false"
             use_choice="false">
-          <validator id="SketchShapePlugin_FeatureValidator" />
-        </sketch_multi_selector>
+            <validator id="SketchShapePlugin_FeatureValidator" />
+          </sketch_multi_selector>
         </sketchshape_groupbox>
       </feature>
     </group>