ADD_SUBDIRECTORY (src/PartSetPlugin)
ADD_SUBDIRECTORY (src/ConstructionPlugin)
ADD_SUBDIRECTORY (src/FeaturesPlugin)
+ADD_SUBDIRECTORY (src/SamplePanelPlugin)
ADD_SUBDIRECTORY (src/SketcherPrs)
ADD_SUBDIRECTORY (src/SketchPlugin)
ADD_SUBDIRECTORY (src/SketchSolver)
{
std::string result = "";
if (!hasChild(theNode)) {
+ // feature which has the next property should be dumped itself
+ std::string anOwnPanel = getProperty(theNode, PROPERTY_PANEL_ID);
+ if (!anOwnPanel.empty()) {
+ xmlBufferPtr buffer = xmlBufferCreate();
+ int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 0);
+ result = std::string((char*) (buffer->content));
+ xmlBufferFree(buffer);
+ }
return result;
}
//Replace all "source" nodes with content;
~ModuleBase_IWidgetCreator();
/// Returns a container of possible page types, which this creator can process
+ /// The default implementation is empty
/// \param theTypes a list of type names
virtual void panelTypes(std::set<std::string>& theTypes) {}
/// Returns a container of possible page types, which this creator can process
+ /// The default implementation is empty
/// \param a list of type names
virtual void pageTypes(std::set<std::string>& theTypes) {}
virtual void widgetTypes(std::set<std::string>& theTypes) {}
/// Create panel control by its type.
+ /// The default implementation is empty
/// \param theType a panel type
/// \param theParent a parent widget
/// \return created widget or null
QWidget* theParent);
/// Create page by its type
+ /// The default implementation is empty
/// \param theType a type
/// \param theParent a parent widget
/// \param theData a low-level API for reading xml definitions of widgets
Config_WidgetAPI* theWidgetApi);
/// Create widget by its type
+ /// The default implementation is empty
/// \param theType a type
/// \param theParent a parent widget
/// \param theData a low-level API for reading xml definitions of widgets
QWidget* aPanel = createPanel(thePage->pageWidget());
if (aPanel) {
thePage->addWidget(aPanel);
+ thePage->alignToTop();
return;
}
}
--- /dev/null
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+INCLUDE(UnitTest)
+
+SET(PROJECT_HEADERS
+ SamplePanelPlugin.h
+ SamplePanelPlugin_Feature.h
+ SamplePanelPlugin_Panel.h
+ SamplePanelPlugin_Plugin.h
+ SamplePanelPlugin_WidgetCreator.h
+)
+
+SET(PROJECT_SOURCES
+ SamplePanelPlugin_Feature.cpp
+ SamplePanelPlugin_Panel.cpp
+ SamplePanelPlugin_Plugin.cpp
+ SamplePanelPlugin_WidgetCreator.cpp
+)
+
+SET(PROJECT_LIBRARIES
+ Config
+ Events
+ ModelAPI
+ ModuleBase
+ ${QT_LIBRARIES}
+)
+
+SET(XML_RESOURCES
+ plugin-SamplePanel.xml
+)
+
+ADD_DEFINITIONS(-DSAMPLEPANELPLUGIN_EXPORTS -DWNT)
+ADD_LIBRARY(SamplePanelPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+TARGET_LINK_LIBRARIES(SamplePanelPlugin ${PROJECT_LIBRARIES})
+
+INCLUDE_DIRECTORIES(
+ ../Config
+ ../Events
+ ../ModelAPI
+ ../ModuleBase
+)
+
+INSTALL(TARGETS SamplePanelPlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#ifndef SAMPLEPANELPLUGIN_H
+#define SAMPLEPANELPLUGIN_H
+
+#if defined SAMPLEPANELPLUGIN_EXPORTS
+#if defined WIN32
+#define SAMPLEPANELPLUGIN_EXPORT __declspec( dllexport )
+#else
+#define SAMPLEPANELPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define SAMPLEPANELPLUGIN_EXPORT __declspec( dllimport )
+#else
+#define SAMPLEPANELPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SamplePanelPlugin_Feature.cpp
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#include "SamplePanelPlugin_Feature.h"
+
+SamplePanelPlugin_Feature::SamplePanelPlugin_Feature()
+: ModelAPI_Feature()
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SamplePanelPlugin_Feature.h
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef SAMPLEPANELPLUGIN_FEATURE_H_
+#define SAMPLEPANELPLUGIN_FEATURE_H_
+
+#include "SamplePanelPlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/**\class SamplePanelPlugin_Feature
+ * \ingroup Plugins
+ * \brief Sample feature to be filled by the panel.
+ */
+class SamplePanelPlugin_Feature : public ModelAPI_Feature
+{
+ public:
+ /// SketchShape feature kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_SAMPLE_PANEL_FEATURE_ID("SamplePanelFeature");
+ return MY_SAMPLE_PANEL_FEATURE_ID;
+ }
+
+ /// Request for initialization of data model of the object: adding all attributes
+ virtual void initAttributes() {};
+
+ /// Returns the unique kind of a feature
+ virtual const std::string& getKind() {
+ static std::string MY_KIND = SamplePanelPlugin_Feature::ID();
+ return MY_KIND;
+ };
+
+ /// Computes or recomputes the results
+ virtual void execute() {}
+
+ /// Use plugin manager for features creation
+ SamplePanelPlugin_Feature();
+};
+
+typedef std::shared_ptr<SamplePanelPlugin_Feature> SamplePanelFeaturePtr;
+
+#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SamplePanelPlugin_PageGroupBox.h
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#include <SamplePanelPlugin_Panel.h>
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QComboBox>
+
+SamplePanelPlugin_Panel::SamplePanelPlugin_Panel(QWidget* theParent)
+ : QWidget(theParent)
+{
+ QGridLayout* aLayout = new QGridLayout(this);
+ aLayout->addWidget(new QLabel("Values:"), 0, 0);
+
+ QComboBox* aComboBox = new QComboBox(this);
+ aComboBox->addItem("Value_1");
+ aComboBox->addItem("Value_2");
+ aComboBox->addItem("Value_3");
+
+ aLayout->addWidget(aComboBox, 0, 1);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SamplePanelPlugin_PageGroupBox.h
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef SAMPLEPANELPLUGIN_PANEL_H_
+#define SAMPLEPANELPLUGIN_PANEL_H_
+
+#include <QWidget>
+
+/*!
+ * \ingroup GUI
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class SamplePanelPlugin_Panel : public QWidget
+{
+public:
+ /// Constructs a panel page
+ SamplePanelPlugin_Panel(QWidget* theParent);
+ /// Destructs the page
+ virtual ~SamplePanelPlugin_Panel() {}
+};
+
+#endif /* SAMPLEPANELPLUGIN_PANEL_H_ */
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SamplePanelPlugin_Plugin.cpp
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#include <SamplePanelPlugin_Plugin.h>
+#include <SamplePanelPlugin_Feature.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Validator.h>
+
+#include <ModuleBase_WidgetCreatorFactory.h>
+#include <SamplePanelPlugin_WidgetCreator.h>
+
+// the only created instance of this plugin
+static SamplePanelPlugin_Plugin* MY_SAMPLE_PANEL_PLUGIN_INSTANCE = new SamplePanelPlugin_Plugin();
+
+SamplePanelPlugin_Plugin::SamplePanelPlugin_Plugin()
+{
+ SessionPtr aMgr = ModelAPI_Session::get();
+
+ WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get();
+ aWidgetCreatorFactory->registerCreator(
+ std::shared_ptr<SamplePanelPlugin_WidgetCreator>(new SamplePanelPlugin_WidgetCreator()));
+
+ // register this plugin
+ ModelAPI_Session::get()->registerPlugin(this);
+}
+
+FeaturePtr SamplePanelPlugin_Plugin::createFeature(std::string theFeatureID)
+{
+ if (theFeatureID == SamplePanelPlugin_Feature::ID()) {
+ return FeaturePtr(new SamplePanelPlugin_Feature);
+ }
+ // feature of such kind is not found
+ return FeaturePtr();
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: SamplePanelPlugin_Plugin.hxx
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef SAMPLEPANELPLUGIN_PLUGIN_H_
+#define SAMPLEPANELPLUGIN_PLUGIN_H_
+
+#include <SamplePanelPlugin.h>
+#include <ModelAPI_Plugin.h>
+//#include <ModuleBase_IWidgetCreator.h>
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Events.h>
+
+class ModuleBase_ModelWidget;
+class QWidget;
+
+/**\class SamplePanelPlugin_Plugin
+ * \ingroup Plugins
+ * \brief Interface common for any plugin: allows to use plugin by the plugins manager.
+ */
+//, public ModuleBase_IWidgetCreator
+class SamplePanelPlugin_Plugin : public ModelAPI_Plugin
+{
+public:
+ /// Creates the feature object of this plugin by the feature string ID
+ virtual FeaturePtr createFeature(std::string theFeatureID);
+
+ public:
+ SamplePanelPlugin_Plugin();
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SamplePanelPlugin_WidgetCreator.cpp
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#include "SamplePanelPlugin_WidgetCreator.h"
+
+#include "SamplePanelPlugin_Panel.h"
+
+SamplePanelPlugin_WidgetCreator::SamplePanelPlugin_WidgetCreator()
+: ModuleBase_IWidgetCreator()
+{
+ myPanelTypes.insert("SampePanel");
+}
+
+void SamplePanelPlugin_WidgetCreator::panelTypes(std::set<std::string>& theTypes)
+{
+ theTypes = myPanelTypes;
+}
+
+QWidget* SamplePanelPlugin_WidgetCreator::createPanelByType(const std::string& theType,
+ QWidget* theParent)
+{
+ QWidget* aWidget = 0;
+ if (myPanelTypes.find(theType) == myPanelTypes.end())
+ return aWidget;
+
+ if (theType == "SampePanel") {
+ aWidget = new SamplePanelPlugin_Panel(theParent);
+ }
+
+ return aWidget;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SamplePanelPlugin_WidgetCreator.h
+// Created: 29 Mar 2015
+// Author: Natalia ERMOLAEVA
+
+#ifndef SamplePanelPlugin_WidgetCreator_H
+#define SamplePanelPlugin_WidgetCreator_H
+
+#include "SamplePanelPlugin.h"
+
+#include <ModuleBase_IWidgetCreator.h>
+
+#include <string>
+#include <set>
+
+class QWidget;
+
+/**
+* \ingroup GUI
+* Interface to WidgetCreator which can create specific widgets by type
+*/
+class SamplePanelPlugin_WidgetCreator : public ModuleBase_IWidgetCreator
+{
+public:
+ /// Default constructor
+ SamplePanelPlugin_WidgetCreator();
+
+ /// Virtual destructor
+ ~SamplePanelPlugin_WidgetCreator() {}
+
+ /// Returns a container of possible page types, which this creator can process
+ /// \param theTypes a list of type names
+ virtual void panelTypes(std::set<std::string>& theTypes);
+
+ /// Create panel control by its type.
+ /// \param theType a panel type
+ /// \param theParent a parent widget
+ /// \return created widget or null
+ virtual QWidget* createPanelByType(const std::string& theType,
+ QWidget* theParent);
+private:
+ std::set<std::string> myPanelTypes; /// types of panels
+};
+
+typedef std::shared_ptr<SamplePanelPlugin_WidgetCreator> SamplePanelWidgetCreatorPtr;
+
+#endif
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugin>
+ <workbench id="Sample">
+ <group id="Features">
+ <feature id="SamplePanelFeature" property_panel_id="SampePanel" title="Sample Panel Feature"/>
+ </group>
+ </workbench>
+</plugin>
{
bool isAccepted = false;
ModuleBase_Operation* aOperation = currentOperation();
+ if (!aOperation)
+ return false;
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
// only property panel enter is processed in order to do not process enter in application dialogs
bool isPPChild = isChildObject(theObject, aPanel);