From 1eac469f7df8510cd4883afecde38c4d35bda7a8 Mon Sep 17 00:00:00 2001 From: sbh Date: Wed, 18 Mar 2015 19:59:40 +0300 Subject: [PATCH] Code documentation and formating for initialization plugin --- .../InitializationPlugin_Plugin.cpp | 30 ++++++++++--------- .../InitializationPlugin_Plugin.h | 22 +++++++++++--- src/ModelAPI/ModelAPI_Events.h | 5 ++-- src/ModuleBase/ModuleBase_PageBase.h | 20 ++++++++++--- src/ModuleBase/ModuleBase_PageGroupBox.h | 9 +++++- src/ModuleBase/ModuleBase_PageWidget.h | 9 +++++- 6 files changed, 69 insertions(+), 26 deletions(-) diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp index 4ad9d0a95..553d22608 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.cpp +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.cpp @@ -14,7 +14,8 @@ #include // the only created instance of this plugin -static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = new InitializationPlugin_Plugin(); +static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = + new InitializationPlugin_Plugin(); InitializationPlugin_Plugin::InitializationPlugin_Plugin() { @@ -27,8 +28,8 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptreventID() == kDocCreatedEvent) { - std::shared_ptr aMessage = - std::dynamic_pointer_cast(theMessage); + std::shared_ptr aMessage = std::dynamic_pointer_cast< + ModelAPI_DocumentCreatedMessage>(theMessage); DocumentPtr aDoc = aMessage->document(); createPoint(aDoc); createPlane(aDoc, 1., 0., 0.); @@ -38,28 +39,29 @@ void InitializationPlugin_Plugin::processEvent(const std::shared_ptrflush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); } else if (theMessage.get()) { Events_Error::send( - std::string("InitializationPlugin_Plugin::processEvent: unhandled message caught: ") + - theMessage->eventID().eventText()); + std::string("InitializationPlugin_Plugin::processEvent: unhandled message caught: ") + + theMessage->eventID().eventText()); } } -void InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double theA, double theB, double theC) +void InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double theX, double theY, + double theZ) { std::shared_ptr aPlane = theDoc->addFeature("Plane"); aPlane->string("CreationMethod")->setValue("PlaneByGeneralEquation"); - aPlane->real("A")->setValue(theA); - aPlane->real("B")->setValue(theB); - aPlane->real("C")->setValue(theC); + aPlane->real("A")->setValue(theX); + aPlane->real("B")->setValue(theY); + aPlane->real("C")->setValue(theZ); aPlane->real("D")->setValue(0.); - if (theA) { + if (theX) { aPlane->data()->setName("Y0Z"); - } else if (theB) { + } else if (theY) { aPlane->data()->setName("X0Z"); - } else if (theC) { + } else if (theZ) { aPlane->data()->setName("X0Y"); } - aPlane->setInHistory(aPlane, false); // don't show automatically created feature in the features history + aPlane->setInHistory(aPlane, false); // don't show automatically created feature in the features history } void InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc) @@ -69,5 +71,5 @@ void InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc) aPoint->real("y")->setValue(0.); aPoint->real("z")->setValue(0.); aPoint->data()->setName("Origin"); - aPoint->setInHistory(aPoint, false); // don't show automatically created feature in the features history + aPoint->setInHistory(aPoint, false); // don't show automatically created feature in the features history } diff --git a/src/InitializationPlugin/InitializationPlugin_Plugin.h b/src/InitializationPlugin/InitializationPlugin_Plugin.h index bbd9e4aa0..4ddaf7609 100644 --- a/src/InitializationPlugin/InitializationPlugin_Plugin.h +++ b/src/InitializationPlugin/InitializationPlugin_Plugin.h @@ -1,4 +1,3 @@ - // Copyright (C) 2014-20xx CEA/DEN, EDF R&D #ifndef INITIALIZATIONPLUGIN_PLUGIN_H_ @@ -11,16 +10,31 @@ #include /**\class InitializationPlugin_Plugin - * TODO: Add documentation + * \ingroup Plugins + * This class is represents a plugin. + * It's aim is to fulfill the newly created documents with the "origin" + * construction point (0,0,0) and base planes (x0y, z0y, x0z) */ class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_Plugin : public Events_Listener { public: + /// Creates plug-in and registers it in the Event Loop InitializationPlugin_Plugin(); - ~InitializationPlugin_Plugin() {} + /// Destructs the plugin + virtual ~InitializationPlugin_Plugin() {} + /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document + /// from the message with origin and planes virtual void processEvent(const std::shared_ptr& theMessage); - void createPlane(DocumentPtr theDoc, double theA, double theB, double theC); + protected: + /// Creates a plane by given parameters A, B, C + /// \param theDoc - document to contain a "plane" feature + /// \param theX - determines if X is 0 or not + /// \param theY - determines if Y is 0 or not + /// \param theZ - determines if Z is 0 or not + void createPlane(DocumentPtr theDoc, double theX, double theY, double theZ); + /// Creates the origin point in (0,0,0) + /// \param theDoc - document to contain a "point" feature void createPoint(DocumentPtr theDoc); }; diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index 96395a997..20d2530bb 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -150,15 +150,16 @@ class ModelAPI_DocumentCreatedMessage : public Events_Message MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0); /// The virtual destructor MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage(); - + /// Static. Returns EventID of the message. MODELAPI_EXPORT static Events_ID eventId() { static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated"); return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID); } - + /// Returns a document stored in the message MODELAPI_EXPORT DocumentPtr document() const; + /// Sets a document to the message MODELAPI_EXPORT void setDocument(DocumentPtr theDocument); }; diff --git a/src/ModuleBase/ModuleBase_PageBase.h b/src/ModuleBase/ModuleBase_PageBase.h index 29e9dcd14..63be634d3 100644 --- a/src/ModuleBase/ModuleBase_PageBase.h +++ b/src/ModuleBase/ModuleBase_PageBase.h @@ -16,31 +16,43 @@ class QLayout; class QWidget; /*! - * Represent a property panel's list of ModuleBase_ModelWidgets. + * Represent a property panel's list of ModuleBase_ModelWidgets + * or other pages widgets derived from ModuleBase_PageBase. */ class MODULEBASE_EXPORT ModuleBase_PageBase { public: + /// Base constructor. ModuleBase_PageBase(); + /// Base virtual destructor. virtual ~ModuleBase_PageBase(); + /// Cast the page to regular QWidget QWidget* pageWidget(); - + /// Adds the given ModuleBase_ModelWidget to the page void addModelWidget(ModuleBase_ModelWidget* theWidget); + /// Adds the given ModuleBase_PageBase to the page void addPageWidget(ModuleBase_PageBase* theWidget); - + /// Removes all items from page's layout void clearPage(); + /// Passes focus from page to the first ModuleBase_ModelWidget contained on the page bool takeFocus(); + /// Returns list of ModuleBase_ModelWidgets contained on the page QList modelWidgets(); + /// Aligns top all widgets on page void alignToTop(); protected: + /// Pure Virtual. Allows to derived class to lay out the widget properly; virtual void placeModelWidget(ModuleBase_ModelWidget* theWidget) = 0; + /// Pure Virtual. Allows to derived class to lay out the page properly; virtual void placePageWidget(ModuleBase_PageBase* theWidget) = 0; + /// Pure Virtual. Returns layout of the page. virtual QLayout* pageLayout() = 0; + /// Pure Virtual. Allows to derived class to insert page stretch properly. virtual void addPageStretch() = 0; private: - QList myWidgetList; + QList myWidgetList; ///< list of widgets contained on the page }; diff --git a/src/ModuleBase/ModuleBase_PageGroupBox.h b/src/ModuleBase/ModuleBase_PageGroupBox.h index fd10f001b..ee28287ed 100644 --- a/src/ModuleBase/ModuleBase_PageGroupBox.h +++ b/src/ModuleBase/ModuleBase_PageGroupBox.h @@ -23,18 +23,25 @@ class QGridLayout; */ class MODULEBASE_EXPORT ModuleBase_PageGroupBox : public QGroupBox, public ModuleBase_PageBase { + Q_OBJECT public: + /// Constructs a page that looks like a QGroupBox explicit ModuleBase_PageGroupBox(QWidget* theParent = 0); + /// Destructs the page virtual ~ModuleBase_PageGroupBox(); protected: + /// 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(); private: - QGridLayout* myMainLayout; + QGridLayout* myMainLayout; ///< page's layout }; #endif /* MODULEBASE_PAGEGROUPBOX_H_ */ diff --git a/src/ModuleBase/ModuleBase_PageWidget.h b/src/ModuleBase/ModuleBase_PageWidget.h index eb21a6daa..33d552d5f 100644 --- a/src/ModuleBase/ModuleBase_PageWidget.h +++ b/src/ModuleBase/ModuleBase_PageWidget.h @@ -22,18 +22,25 @@ class QGridLayout; */ class MODULEBASE_EXPORT ModuleBase_PageWidget : public QFrame, public ModuleBase_PageBase { + Q_OBJECT public: + /// Constructs a page that looks like a QFrame explicit ModuleBase_PageWidget(QWidget* theParent = 0); + /// Destructs the page virtual ~ModuleBase_PageWidget(); protected: + /// 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(); private: - QGridLayout* myMainLayout; + QGridLayout* myMainLayout; ///< page's layout }; #endif /* MODULEBASE_PAGEWIDGET_H_ */ -- 2.39.2