From 72a0aa8a5b7f5d146cf32764f627bf0a682467f4 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 27 Nov 2015 07:25:44 +0300 Subject: [PATCH 1/1] Construction of vertices, edges and faces from a sketch: Widget creator --- src/ModuleBase/ModuleBase_IWidgetCreator.h | 4 +- src/SketchShapePlugin/CMakeLists.txt | 4 +- .../SketchShapePlugin_PageGroupBox.cpp | 8 ++-- .../SketchShapePlugin_PageGroupBox.h | 8 ++-- .../SketchShapePlugin_WidgetCreator.cpp | 30 +++++++++++++ .../SketchShapePlugin_WidgetCreator.h | 42 +++++++++++++++++++ src/SketchShapePlugin/plugin-SketchShape.xml | 7 ++-- 7 files changed, 87 insertions(+), 16 deletions(-) create mode 100755 src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.cpp create mode 100755 src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.h diff --git a/src/ModuleBase/ModuleBase_IWidgetCreator.h b/src/ModuleBase/ModuleBase_IWidgetCreator.h index 4f1e040de..dfff4fa71 100755 --- a/src/ModuleBase/ModuleBase_IWidgetCreator.h +++ b/src/ModuleBase/ModuleBase_IWidgetCreator.h @@ -5,7 +5,7 @@ #include "ModuleBase.h" -#include +#include #include 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& theTypes) = 0; + virtual const std::set& widgetTypes() = 0; /// Create widget by its type /// \param theType a type diff --git a/src/SketchShapePlugin/CMakeLists.txt b/src/SketchShapePlugin/CMakeLists.txt index 97cb8abc5..200ca71ba 100755 --- a/src/SketchShapePlugin/CMakeLists.txt +++ b/src/SketchShapePlugin/CMakeLists.txt @@ -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}) diff --git a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp index e8f9334e1..a28cec528 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp +++ b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp @@ -4,13 +4,11 @@ // Created: 25 Nov 2015 // Author: Natalia ERMOLAEVA -//#include +#include -//#include - -/*SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent) +SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent) : ModuleBase_PageGroupBox(theParent) { setTitle("SketchShapePlugin_PageGroupBox"); -}*/ +} diff --git a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h index 4a3666c65..3da8919d4 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h +++ b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h @@ -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 index 000000000..89552f187 --- /dev/null +++ b/src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.cpp @@ -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& 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 index 000000000..a812b01a2 --- /dev/null +++ b/src/SketchShapePlugin/SketchShapePlugin_WidgetCreator.h @@ -0,0 +1,42 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +#ifndef SketchShapePlugin_WidgetCreator_H +#define SketchShapePlugin_WidgetCreator_H + +#include + +#include +#include + +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& 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 myTypes; /// types of widgets +}; + + +#endif diff --git a/src/SketchShapePlugin/plugin-SketchShape.xml b/src/SketchShapePlugin/plugin-SketchShape.xml index 4dca7052f..016198101 100755 --- a/src/SketchShapePlugin/plugin-SketchShape.xml +++ b/src/SketchShapePlugin/plugin-SketchShape.xml @@ -6,15 +6,14 @@ - - - - + + -- 2.30.2