Salome HOME
Code documentation and formating for initialization plugin
authorsbh <sergey.belash@opencascade.com>
Wed, 18 Mar 2015 16:59:40 +0000 (19:59 +0300)
committersbh <sergey.belash@opencascade.com>
Wed, 18 Mar 2015 16:59:40 +0000 (19:59 +0300)
src/InitializationPlugin/InitializationPlugin_Plugin.cpp
src/InitializationPlugin/InitializationPlugin_Plugin.h
src/ModelAPI/ModelAPI_Events.h
src/ModuleBase/ModuleBase_PageBase.h
src/ModuleBase/ModuleBase_PageGroupBox.h
src/ModuleBase/ModuleBase_PageWidget.h

index 4ad9d0a95edfbbf51a5c45f7ec92992c3af317b6..553d22608a543eeb2383630dd31fbda269e4cd18 100644 (file)
@@ -14,7 +14,8 @@
 #include <memory>
 
 // 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_ptr<Events_Mess
 {
   const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId();
   if (theMessage->eventID() == kDocCreatedEvent) {
-    std::shared_ptr<ModelAPI_DocumentCreatedMessage> aMessage =
-        std::dynamic_pointer_cast<ModelAPI_DocumentCreatedMessage>(theMessage);
+    std::shared_ptr<ModelAPI_DocumentCreatedMessage> 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_ptr<Events_Mess
     Events_Loop::loop()->flush(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<ModelAPI_Feature> 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
 }
index bbd9e4aa02ad6922f40febfb252f08904daf61d7..4ddaf76098bdf0166b7e8c938090e550c7f3db2d 100644 (file)
@@ -1,4 +1,3 @@
-
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
 #ifndef INITIALIZATIONPLUGIN_PLUGIN_H_
 #include <Events_Loop.h>
 
 /**\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<Events_Message>& 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);
 };
 
index 96395a997f9407c668521c29ba3624a79c7dfa43..20d2530bb1c9ddf12d3bf35642b0acbf9cc18998 100644 (file)
@@ -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);
 };
 
index 29e9dcd1457f55a36fd898655325ea1206e52dc8..63be634d3996e1ef547fb3bdfec3ab58b706e92a 100644 (file)
@@ -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<ModuleBase_ModelWidget*> 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<ModuleBase_ModelWidget*> myWidgetList;
+  QList<ModuleBase_ModelWidget*> myWidgetList; ///< list of widgets contained on the page
 
 };
 
index fd10f001b23ec99f5185488d7c6e7c0790d78f67..ee28287ed1bac16b19cdc2a91f86fbb3cd8caa43 100644 (file)
@@ -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_ */
index eb21a6daac9dab25ecc7ce56a3682db78bdd714a..33d552d5fcb318a7963c951357b8428ec0c669a5 100644 (file)
@@ -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_ */