#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()
{
{
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.);
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)
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
}
-
// 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);
};
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);
};
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
};
*/
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_ */
*/
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_ */