ADD_SUBDIRECTORY (src/GeomApp)
ADD_SUBDIRECTORY (src/ExchangePlugin)
ADD_SUBDIRECTORY (src/GeomValidators)
+ADD_SUBDIRECTORY (src/InitializationPlugin)
IF(${HAVE_SALOME})
ADD_SUBDIRECTORY (src/NewGeom)
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
<plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
+ <plugin library="InitializationPlugin" configuration="plugin-Initialization.xml"/>
<plugin library="SketchSolver"/>
<plugin library="GeomValidators"/>
<plugin library="DFBrowser" internal="true"/>
using namespace std;
-static const double MINIMAL_LENGTH = 1.e-5;
-
ConstructionPlugin_Axis::ConstructionPlugin_Axis()
{
}
void ConstructionPlugin_Axis::initAttributes()
{
- data()->addAttribute(POINT_ATTR_FIRST, ModelAPI_AttributeSelection::type());
- data()->addAttribute(POINT_ATTR_SECOND, ModelAPI_AttributeSelection::type());
+ data()->addAttribute(ConstructionPlugin_Axis::POINT_FIRST(),
+ ModelAPI_AttributeSelection::type());
+ data()->addAttribute(ConstructionPlugin_Axis::POINT_SECOND(),
+ ModelAPI_AttributeSelection::type());
}
void ConstructionPlugin_Axis::execute()
{
- AttributeSelectionPtr aRef1 = data()->selection(POINT_ATTR_FIRST);
- AttributeSelectionPtr aRef2 = data()->selection(POINT_ATTR_SECOND);
+ AttributeSelectionPtr aRef1 = data()->selection(ConstructionPlugin_Axis::POINT_FIRST());
+ AttributeSelectionPtr aRef2 = data()->selection(ConstructionPlugin_Axis::POINT_SECOND());
if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) {
GeomShapePtr aShape1 = aRef1->value();
GeomShapePtr aShape2 = aRef2->value();
if (aShape1->isVertex() && aShape2->isVertex() && (!aShape1->isEqual(aShape2))) {
std::shared_ptr<GeomAPI_Pnt> aStart = GeomAlgoAPI_PointBuilder::point(aShape1);
std::shared_ptr<GeomAPI_Pnt> anEnd = GeomAlgoAPI_PointBuilder::point(aShape2);
- if (aStart->distance(anEnd) > MINIMAL_LENGTH) {
+ if (aStart->distance(anEnd) > ConstructionPlugin_Axis::MINIMAL_LENGTH()) {
std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
ResultConstructionPtr aConstr = document()->createConstruction(data());
thePrs->setColor(0, 0, 0);
thePrs->setLineStyle(3);
thePrs->redisplay();
-}
\ No newline at end of file
+}
#include <GeomAPI_ICustomPrs.h>
-/// Point kind
-const std::string CONSTRUCTION_AXIS_KIND("Axis");
-
-/// attribute name for first point
-const std::string POINT_ATTR_FIRST = "firstPoint";
-
-/// attribute name for second point
-const std::string POINT_ATTR_SECOND = "secondPoint";
-
/**\class ConstructionPlugin_Axis
* \ingroup Plugins
* \brief Feature for creation of the new axis in PartSet.
/// Returns the kind of a feature
CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
{
- static std::string MY_KIND = CONSTRUCTION_AXIS_KIND;
+ static std::string MY_KIND = ConstructionPlugin_Axis::ID();
return MY_KIND;
}
+ /// Axis kind
+ inline static const std::string& ID()
+ {
+ static const std::string CONSTRUCTION_AXIS_KIND("Axis");
+ return CONSTRUCTION_AXIS_KIND;
+ }
+ /// attribute name for first point
+ inline static const std::string& POINT_FIRST()
+ {
+ static const std::string POINT_ATTR_FIRST("firstPoint");
+ return POINT_ATTR_FIRST;
+ }
+ /// attribute name for second point
+ inline static const std::string& POINT_SECOND()
+ {
+ static const std::string POINT_ATTR_SECOND("secondPoint");
+ return POINT_ATTR_SECOND;
+ }
+
+ inline static const double MINIMAL_LENGTH() { return 1.e-5; }
+
/// Creates a new part document if needed
CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
};
-#endif
\ No newline at end of file
+#endif
void ConstructionPlugin_Plane::initAttributes()
{
- data()->addAttribute(FACE_ATTR, ModelAPI_AttributeSelection::type());
- data()->addAttribute(DISTANCE_ATTR, ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Plane::FACE(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::type());
}
void ConstructionPlugin_Plane::execute()
{
- AttributeSelectionPtr aFaceAttr = data()->selection(FACE_ATTR);
- AttributeDoublePtr aDistAttr = data()->real(DISTANCE_ATTR);
+ AttributeSelectionPtr aFaceAttr = data()->selection(ConstructionPlugin_Plane::FACE());
+ AttributeDoublePtr aDistAttr = data()->real(ConstructionPlugin_Plane::DISTANCE());
if ((aFaceAttr.get() != NULL) && (aDistAttr.get() != NULL) &&
aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {
{
thePrs->setColor(50, 255, 50);
thePrs->setTransparensy(0.6);
-}
\ No newline at end of file
+}
#include <ModelAPI_Feature.h>
#include <GeomAPI_ICustomPrs.h>
-/// Point kind
-const std::string CONSTRUCTION_PLANE_KIND("Plane");
-/// attribute name for base face
-const std::string FACE_ATTR = "planeFace";
-
-/// attribute name for distance
-const std::string DISTANCE_ATTR = "distance";
/**\class ConstructionPlugin_Plane
* \ingroup Plugins
/// Returns the kind of a feature
CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
{
- static std::string MY_KIND = CONSTRUCTION_PLANE_KIND;
+ static std::string MY_KIND = ConstructionPlugin_Plane::ID();
return MY_KIND;
}
+ /// Plane kind
+ inline static const std::string& ID()
+ {
+ static const std::string CONSTRUCTION_PLANE_KIND("Plane");
+ return CONSTRUCTION_PLANE_KIND;
+ }
+ /// attribute name for base face
+ inline static const std::string& FACE()
+ {
+ static const std::string FACE_ATTR("planeFace");
+ return FACE_ATTR;
+ }
+ /// attribute name for distance
+ inline static const std::string& DISTANCE()
+ {
+ static const std::string DISTANCE_ATTR("distance");
+ return DISTANCE_ATTR;
+ }
+
+ /// the a parameter for the general equation of a plane (ax+by+cz+d=0)
+ inline static const std::string& A()
+ {
+ static const std::string PARAM_A_ATTR("A");
+ return PARAM_A_ATTR;
+ }
+ /// the b parameter for the general equation of a plane (ax+by+cz+d=0)
+ inline static const std::string& B()
+ {
+ static const std::string PARAM_B_ATTR("B");
+ return PARAM_B_ATTR;
+ }
+ /// the c parameter for the general equation of a plane (ax+by+cz+d=0)
+ inline static const std::string& C()
+ {
+ static const std::string PARAM_C_ATTR("C");
+ return PARAM_C_ATTR;
+ }
+ /// the d parameter for the general equation of a plane (ax+by+cz+d=0)
+ inline static const std::string& D()
+ {
+ static const std::string PARAM_D_ATTR("D");
+ return PARAM_D_ATTR;
+ }
+
/// Creates a new part document if needed
CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
/// Request for initialization of data model of the feature: adding all attributes
CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
- /// Construction result is allways recomuted on the fly
+ /// Construction result is always recomputed on the fly
CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
/// Use plugin manager for features creation
virtual void customisePresentation(AISObjectPtr thePrs);
};
-#endif
\ No newline at end of file
+#endif
FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
{
- if (theFeatureID == CONSTRUCTION_POINT_KIND) {
+ if (theFeatureID == ConstructionPlugin_Point::ID()) {
return FeaturePtr(new ConstructionPlugin_Point);
}
- else if (theFeatureID == CONSTRUCTION_AXIS_KIND) {
+ else if (theFeatureID == ConstructionPlugin_Axis::ID()) {
return FeaturePtr(new ConstructionPlugin_Axis);
}
- else if (theFeatureID == CONSTRUCTION_PLANE_KIND) {
+ else if (theFeatureID == ConstructionPlugin_Plane::ID()) {
return FeaturePtr(new ConstructionPlugin_Plane);
}
// feature of such kind is not found
{
}
+const std::string& ConstructionPlugin_Point::getKind()
+{
+ static std::string MY_KIND = ConstructionPlugin_Point::ID();
+ return MY_KIND;
+}
+
void ConstructionPlugin_Point::initAttributes()
{
- data()->addAttribute(POINT_ATTR_X, ModelAPI_AttributeDouble::type());
- data()->addAttribute(POINT_ATTR_Y, ModelAPI_AttributeDouble::type());
- data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble::type());
}
void ConstructionPlugin_Point::execute()
{
std::shared_ptr<GeomAPI_Pnt> aPnt(
- new GeomAPI_Pnt(data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(),
- data()->real(POINT_ATTR_Z)->value()));
+ new GeomAPI_Pnt(data()->real(ConstructionPlugin_Point::X())->value(),
+ data()->real(ConstructionPlugin_Point::Y())->value(),
+ data()->real(ConstructionPlugin_Point::Z())->value()));
std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
#include "ConstructionPlugin.h"
#include <ModelAPI_Feature.h>
-/// Point kind
-const std::string CONSTRUCTION_POINT_KIND("Point");
-
-/// attribute name for X coordinate
-const std::string POINT_ATTR_X = "x";
-/// attribute name for Y coordinate
-const std::string POINT_ATTR_Y = "y";
-/// attribute name for Z coordinate
-const std::string POINT_ATTR_Z = "z";
-
/**\class ConstructionPlugin_Point
* \ingroup Plugins
* \brief Feature for creation of the new part in PartSet.
{
public:
/// Returns the kind of a feature
- CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
+ CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind();
+
+ inline static const std::string& ID()
+ {
+ static const std::string CONSTRUCTION_POINT_KIND("Point");
+ return CONSTRUCTION_POINT_KIND;
+ }
+
+ /// attribute name for X coordinate
+ inline static const std::string& X()
+ {
+ static const std::string POINT_ATTR_X("x");
+ return POINT_ATTR_X;
+ }
+ /// attribute name for Y coordinate
+ inline static const std::string& Y()
+ {
+ static const std::string POINT_ATTR_Y("y");
+ return POINT_ATTR_Y;
+ }
+ /// attribute name for Z coordinate
+ inline static const std::string& Z()
{
- static std::string MY_KIND = CONSTRUCTION_POINT_KIND;
- return MY_KIND;
+ static const std::string POINT_ATTR_Z("z");
+ return POINT_ATTR_Z;
}
/// Creates a new part document if needed
--- /dev/null
+
+INCLUDE(Common)
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/Config
+ ${PROJECT_SOURCE_DIR}/src/ModelAPI
+)
+
+SET(PROJECT_HEADERS
+ InitializationPlugin.h
+ InitializationPlugin_Plugin.h
+ InitializationPlugin_OriginPlanesFeature.h
+)
+
+SET(PROJECT_SOURCES
+ InitializationPlugin_Plugin.cpp
+ InitializationPlugin_OriginPlanesFeature.cpp
+)
+
+SET(XML_RESOURCES
+ plugin-Initialization.xml
+)
+
+SET(PROJECT_LIBRARIES
+ Events
+ Config
+ ModelAPI
+)
+
+ADD_DEFINITIONS(-DINITIALIZATIONPLUGIN_EXPORTS)
+ADD_LIBRARY(InitializationPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+
+TARGET_LINK_LIBRARIES(InitializationPlugin ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS InitializationPlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
--- /dev/null
+
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef INITIALIZATIONPLUGIN_H
+#define INITIALIZATIONPLUGIN_H
+
+#if defined INITIALIZATIONPLUGIN_EXPORTS
+#if defined WIN32
+#define INITIALIZATIONPLUGIN_EXPORT __declspec( dllexport )
+#else
+#define INITIALIZATIONPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define INITIALIZATIONPLUGIN_EXPORT __declspec( dllimport )
+#else
+#define INITIALIZATIONPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * InitializationPlugin_OriginPlanesFeature.cpp
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#include <InitializationPlugin_OriginPlanesFeature.h>
+
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeDouble.h>
+
+InitializationPlugin_OriginPlanesFeature::InitializationPlugin_OriginPlanesFeature()
+: ModelAPI_Feature()
+{
+}
+
+InitializationPlugin_OriginPlanesFeature::~InitializationPlugin_OriginPlanesFeature()
+{
+}
+
+/*
+ * Request for initialization of data model of the feature: adding all attributes
+ */
+void InitializationPlugin_OriginPlanesFeature::initAttributes()
+{
+}
+
+/*
+ * Computes or recomputes the results
+ */
+void InitializationPlugin_OriginPlanesFeature::execute()
+{
+ std::shared_ptr<ModelAPI_Session> aSession = ModelAPI_Session::get();
+ std::shared_ptr<ModelAPI_Document> aDoc = aSession->activeDocument();
+ aSession->startOperation();
+ createPoint(aDoc);
+
+ //std::shared_ptr<ModelAPI_Feature> aPlane = aDoc->addFeature(ConstructionPlugin_Plane::ID());
+
+ aSession->finishOperation();
+}
+
+void InitializationPlugin_OriginPlanesFeature
+::createPoint(const std::shared_ptr<ModelAPI_Document>& aDoc)
+{
+ std::shared_ptr<ModelAPI_Feature> aPoint = aDoc->addFeature("Point");
+ aPoint->real("x")->setValue(0.);
+ aPoint->real("y")->setValue(0.);
+ aPoint->real("z")->setValue(0.);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef INITIALIZATIONPLUGIN_ORIGINPLANESFEATURE_H_
+#define INITIALIZATIONPLUGIN_ORIGINPLANESFEATURE_H_
+
+#include <InitializationPlugin.h>
+#include <ModelAPI_Feature.h>
+
+#include <map>
+
+class InitializationPlugin_OriginPlanesFeature : public ModelAPI_Feature
+{
+ public:
+ explicit InitializationPlugin_OriginPlanesFeature();
+ virtual ~InitializationPlugin_OriginPlanesFeature();
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_ORIGIN_PLANES_ID("OriginAndPlanes");
+ return MY_ORIGIN_PLANES_ID;
+ }
+
+ INITIALIZATIONPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = InitializationPlugin_OriginPlanesFeature::ID();
+ return MY_KIND;
+ }
+
+ INITIALIZATIONPLUGIN_EXPORT virtual void initAttributes();
+
+ INITIALIZATIONPLUGIN_EXPORT virtual void execute();
+
+ INITIALIZATIONPLUGIN_EXPORT virtual bool isInHistory()
+ {
+ return false;
+ }
+
+ protected:
+ void createPoint(const std::shared_ptr<ModelAPI_Document>& aDoc);
+};
+
+#endif /* IMPORT_IMPORTFEATURE_H_ */
--- /dev/null
+
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include <InitializationPlugin_Plugin.h>
+#include <InitializationPlugin_OriginPlanesFeature.h>
+
+#include <ModelAPI_Session.h>
+
+#include <memory>
+
+// the only created instance of this plugin
+static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = new InitializationPlugin_Plugin();
+
+InitializationPlugin_Plugin::InitializationPlugin_Plugin()
+{
+ // register this plugin
+ SessionPtr aSession = ModelAPI_Session::get();
+ aSession->registerPlugin(this);
+}
+
+FeaturePtr InitializationPlugin_Plugin::createFeature(std::string theFeatureID)
+{
+ if(InitializationPlugin_OriginPlanesFeature::ID() == theFeatureID) {
+ return FeaturePtr(new InitializationPlugin_OriginPlanesFeature);
+ }
+ return FeaturePtr();
+}
+
--- /dev/null
+
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef INITIALIZATIONPLUGIN_PLUGIN_H_
+#define INITIALIZATIONPLUGIN_PLUGIN_H_
+
+#include <InitializationPlugin.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+/**\class InitializationPlugin_Plugin
+ * TODO: Add documentation
+ */
+class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_Plugin : public ModelAPI_Plugin
+{
+ public:
+ /// Creates the feature object of this plugin by the feature string ID
+ virtual FeaturePtr createFeature(std::string theFeatureID);
+
+ public:
+ InitializationPlugin_Plugin();
+};
+
+#endif
+
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugin>
+ <workbench id="Features">
+ <group id="Basic">
+ <!-- <feature id="OriginAndPlanes" title="Add default planes" tooltip="Do not touch" icon=":pictures/wnd_close.png"> -->
+ <feature id="OriginAndPlanes" internal="true">
+ </feature>
+ </group>
+ </workbench>
+</plugin>
return result;
}
+
+ModelAPI_DocumentCreatedMessage::ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender)
+: Events_Message(theID, theSender)
+{
+
+}
+
+ModelAPI_DocumentCreatedMessage::~ModelAPI_DocumentCreatedMessage()
+{
+
+}
+
+DocumentPtr ModelAPI_DocumentCreatedMessage::document() const
+{
+ return myDocument;
+}
+
+void ModelAPI_DocumentCreatedMessage::setDocument(DocumentPtr theDocument)
+{
+ myDocument = theDocument;
+}
#include <ModelAPI_Object.h>
#include <ModelAPI_Feature.h>
#include <Events_MessageGroup.h>
+#include <Events_Loop.h>
#include <memory>
#include <string>
std::map<std::string, bool> myFeatureState;
};
+/// Message that document (Part, PartSet) was created
+class MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage : public Events_Message
+{
+ DocumentPtr myDocument;
+
+ public:
+ /// Creates an empty message
+ ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0);
+ /// The virtual destructor
+ virtual ~ModelAPI_DocumentCreatedMessage();
+
+ static Events_ID eventId()
+ {
+ static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated");
+ return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID);
+ }
+
+
+ DocumentPtr document() const;
+ void setDocument(DocumentPtr theDocument);
+};
+
#endif