<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="InitializationPlugin"/>
<plugin library="SketchSolver"/>
<plugin library="GeomValidators"/>
<plugin library="DFBrowser" internal="true"/>
void ConstructionPlugin_Axis::execute()
{
- AttributePtr anAttr = data()->attribute(ConstructionPlugin_Axis::METHOD());
- AttributeStringPtr aMethodTypeAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeString>(anAttr);
+ AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD());
std::string aMethodType = aMethodTypeAttr->value();
if (aMethodType == "AxisByPointsCase") {
createAxisByTwoPoints();
/// attribute name for first point
inline static const std::string& METHOD()
{
- static const std::string METHOD_ATTR("creationMethod");
+ static const std::string METHOD_ATTR("CreationMethod");
return METHOD_ATTR;
}
/// attribute name for first point
inline static const std::string& POINT_FIRST()
{
- static const std::string POINT_ATTR_FIRST("firstPoint");
+ 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");
+ static const std::string POINT_ATTR_SECOND("SecondPoint");
return POINT_ATTR_SECOND;
}
/// attribute name for second point
inline static const std::string& CYLINDRICAL_FACE()
{
- static const std::string CYLINDRICAL_FACE_ATTR("cylindricalFace");
+ static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
return CYLINDRICAL_FACE_ATTR;
}
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_AttributeString.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAPI_Pnt2d.h>
-
-#define PLANE_SIZE 300
-
ConstructionPlugin_Plane::ConstructionPlugin_Plane()
{
}
void ConstructionPlugin_Plane::initAttributes()
{
+ data()->addAttribute(ConstructionPlugin_Plane::METHOD(), ModelAPI_AttributeString::type());
+ // Face & Distance
data()->addAttribute(ConstructionPlugin_Plane::FACE(), ModelAPI_AttributeSelection::type());
data()->addAttribute(ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble::type());
+ // General equation
+ data()->addAttribute(ConstructionPlugin_Plane::A(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Plane::B(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Plane::C(), ModelAPI_AttributeDouble::type());
+ data()->addAttribute(ConstructionPlugin_Plane::D(), ModelAPI_AttributeDouble::type());
}
void ConstructionPlugin_Plane::execute()
+{
+ AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Plane::METHOD());
+ std::string aMethodType = aMethodTypeAttr->value();
+ std::shared_ptr<GeomAPI_Shape> aPlaneFace;
+ if (aMethodType == "PlaneByFaceAndDistance") {
+ aPlaneFace = createPlaneByFaceAndDistance();
+ } else if (aMethodType == "PlaneByGeneralEquation") {
+ aPlaneFace = createPlaneByGeneralEquation();
+ }
+ if (!aPlaneFace.get())
+ return;
+ ResultConstructionPtr aConstr = document()->createConstruction(data());
+ aConstr->setShape(aPlaneFace);
+ setResult(aConstr);
+}
+
+bool ConstructionPlugin_Plane::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
+ std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+{
+ std::vector<int> aColor;
+ // get color from the attribute of the result
+ if (theResult.get() != NULL && theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
+ AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (aColorAttr.get() && aColorAttr->size()) {
+ aColor.push_back(aColorAttr->value(0));
+ aColor.push_back(aColorAttr->value(1));
+ aColor.push_back(aColorAttr->value(2));
+ }
+ }
+ if (aColor.empty())
+ aColor = Config_PropManager::color("Visualization", "construction_plane_color",
+ ConstructionPlugin_Plane::DEFAULT_COLOR());
+
+ bool isCustomized = false;
+ if (aColor.size() == 3)
+ isCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
+
+ isCustomized = thePrs->setTransparensy(0.6) || isCustomized;
+
+ return isCustomized;
+}
+
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createPlaneByFaceAndDistance()
{
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()) {
+ std::shared_ptr<GeomAPI_Shape> aPlane;
+ if ((aFaceAttr.get() != NULL) &&
+ (aDistAttr.get() != NULL) &&
+ aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {
double aDist = aDistAttr->value();
GeomShapePtr aShape = aFaceAttr->value();
std::shared_ptr<GeomAPI_Dir> aDir = aPln->direction();
aOrig->translate(aDir, aDist);
- std::shared_ptr<GeomAPI_Pln> aNewPln =
- std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aOrig, aDir));
+ std::shared_ptr<GeomAPI_Pln> aNewPln = std::shared_ptr<GeomAPI_Pln>(
+ new GeomAPI_Pln(aOrig, aDir));
// Create rectangular face close to the selected
double aXmin, aYmin, Zmin, aXmax, aYmax, Zmax;
aShape->computeSize(aXmin, aYmin, Zmin, aXmax, aYmax, Zmax);
- std::shared_ptr<GeomAPI_Pnt> aPnt1 =
- std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aXmin, aYmin, Zmin));
- std::shared_ptr<GeomAPI_Pnt> aPnt2 =
- std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aXmax, aYmax, Zmax));
+ std::shared_ptr<GeomAPI_Pnt> aPnt1 = std::shared_ptr<GeomAPI_Pnt>(
+ new GeomAPI_Pnt(aXmin, aYmin, Zmin));
+ std::shared_ptr<GeomAPI_Pnt> aPnt2 = std::shared_ptr<GeomAPI_Pnt>(
+ new GeomAPI_Pnt(aXmax, aYmax, Zmax));
std::shared_ptr<GeomAPI_Pnt2d> aPnt2d1 = aPnt1->to2D(aNewPln);
std::shared_ptr<GeomAPI_Pnt2d> aPnt2d2 = aPnt2->to2D(aNewPln);
double aWgap = aWidth * 0.1;
double aHgap = aHeight * 0.1;
- std::shared_ptr<GeomAPI_Shape> aPlane =
- GeomAlgoAPI_FaceBuilder::planarFace(aNewPln, aPnt2d1->x() - aWgap, aPnt2d1->y() - aHgap,
- aWidth + 2 * aWgap, aHeight + 2 * aHgap);
- ResultConstructionPtr aConstr = document()->createConstruction(data());
- aConstr->setShape(aPlane);
- setResult(aConstr);
+ aPlane = GeomAlgoAPI_FaceBuilder::planarFace(aNewPln,
+ aPnt2d1->x() - aWgap,
+ aPnt2d1->y() - aHgap,
+ aWidth + 2 * aWgap,
+ aHeight + 2 * aHgap);
}
}
+ return aPlane;
}
-bool ConstructionPlugin_Plane::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
+std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createPlaneByGeneralEquation()
{
- std::vector<int> aColor;
- // get color from the attribute of the result
- if (theResult.get() != NULL && theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
- AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- if (aColorAttr.get() && aColorAttr->size()) {
- aColor.push_back(aColorAttr->value(0));
- aColor.push_back(aColorAttr->value(1));
- aColor.push_back(aColorAttr->value(2));
- }
+ AttributeDoublePtr anAttrA = real(ConstructionPlugin_Plane::A());
+ AttributeDoublePtr anAttrB = real(ConstructionPlugin_Plane::B());
+ AttributeDoublePtr anAttrC = real(ConstructionPlugin_Plane::C());
+ AttributeDoublePtr anAttrD = real(ConstructionPlugin_Plane::D());
+ std::shared_ptr<GeomAPI_Shape> aPlaneFace;
+ if ((anAttrA.get() != NULL) && (anAttrB.get() != NULL) &&
+ (anAttrC.get() != NULL) && (anAttrD.get() != NULL) &&
+ anAttrA->isInitialized() && anAttrB->isInitialized() &&
+ anAttrC->isInitialized() && anAttrD->isInitialized() ) {
+ double aA = anAttrA->value(), aB = anAttrB->value(),
+ aC = anAttrC->value(), aD = anAttrD->value();
+ std::shared_ptr<GeomAPI_Pln> aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+ std::string kDefaultPlaneSize = "200";
+ double aSize = Config_PropManager::integer("Sketch planes", "planes_size", kDefaultPlaneSize);
+ aSize *= 4.;
+ aPlaneFace = GeomAlgoAPI_FaceBuilder::square(aPlane, aSize);
}
- if (aColor.empty())
- aColor = Config_PropManager::color("Visualization", "construction_plane_color",
- ConstructionPlugin_Plane::DEFAULT_COLOR());
-
- bool isCustomized = false;
- if (aColor.size() == 3)
- isCustomized = thePrs->setColor(aColor[0], aColor[1], aColor[2]);
-
- isCustomized = thePrs->setTransparensy(0.6) || isCustomized;
-
- return isCustomized;
+ return aPlaneFace;
}
+
static const std::string CONSTRUCTION_PLANE_KIND("Plane");
return CONSTRUCTION_PLANE_KIND;
}
+
+ /// attribute name for first point
+ inline static const std::string& METHOD()
+ {
+ static const std::string METHOD_ATTR("CreationMethod");
+ return METHOD_ATTR;
+ }
+
/// attribute name for base face
inline static const std::string& FACE()
{
/// Customize presentation of the feature
virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
+
+ protected:
+ std::shared_ptr<GeomAPI_Shape> createPlaneByFaceAndDistance();
+ std::shared_ptr<GeomAPI_Shape> createPlaneByGeneralEquation();
};
#endif
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
- <toolbox id="creationMethod">
+ <toolbox id="CreationMethod">
<box id="AxisByPointsCase" title="By two points">
- <shape_selector id="firstPoint"
+ <shape_selector id="FirstPoint"
label="First point"
icon=":icons/point.png"
tooltip="Select a first point"
shape_types="vertex">
<selection_filter id="NoConstructionSubShapesFilter"/>
</shape_selector>
- <shape_selector id="secondPoint"
+ <shape_selector id="SecondPoint"
label="Second point"
icon=":icons/point.png"
tooltip="Select a second point"
</shape_selector>
</box>
<box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face">
- <shape_selector id="cylindricalFace"
+ <shape_selector id="CylindricalFace"
label="Main object"
icon=":icons/circle.png"
tooltip="Select a cylindrical object"
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
+ <!--
+ <switch id="CreationMethod">
+ <case id="PlaneByFaceAndDistance">
+ -->
<shape_selector id="planeFace"
label="Plane face"
tooltip="Select a planar face"
label="Distance"
tooltip="Distance from selected face to plane"
default="0" />
+<!--
+ </case>
+ <case id="PlaneByGeneralEquation">
+ <doublevalue id="A"
+ label="A:"
+ tooltip="The A parameter from general plane equation (Ax+By+Cz+D=0)"
+ default="0" />
+ <doublevalue id="B"
+ label="B:"
+ tooltip="The B parameter from general plane equation (Ax+By+Cz+D=0)"
+ default="0" />
+ <doublevalue id="C"
+ label="C:"
+ tooltip="The C parameter from general plane equation (Ax+By+Cz+D=0)"
+ default="0" />
+ <doublevalue id="D"
+ label="D:"
+ tooltip="The D parameter from general plane equation (Ax+By+Cz+D=0)"
+ default="0" />
+ </case>
+ </switch>
+ -->
</source>
#include <BRep_Tool.hxx>
#include <Geom_Plane.hxx>
+
std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
std::shared_ptr<GeomAPI_Pnt> theCenter, std::shared_ptr<GeomAPI_Dir> theNormal,
const double theSize)
return aRes;
}
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
+ std::shared_ptr<GeomAPI_Pln> thePlane,
+ const double theSize)
+{
+ // half of the size in each direction from the center
+ BRepBuilderAPI_MakeFace aFaceBuilder(thePlane->impl<gp_Pln>(),
+ -theSize / 2., theSize / 2.,
+ -theSize / 2., theSize / 2.);
+ std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
+ return aRes;
+}
+
std::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(
std::shared_ptr<GeomAPI_Shape> theFace)
{
return aResult;
}
-
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::
- planarFace(std::shared_ptr<GeomAPI_Pln> thePlane,
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::planarFace(std::shared_ptr<GeomAPI_Pln> thePlane,
double theX, double theY,
double theWidth, double theHeight)
{
static std::shared_ptr<GeomAPI_Shape> square(std::shared_ptr<GeomAPI_Pnt> theCenter,
std::shared_ptr<GeomAPI_Dir> theNormal,
const double theSize);
+ /// Creates square planar face by given point of the center,
+ /// normal to the plane and size of square
+ static std::shared_ptr<GeomAPI_Shape> square(std::shared_ptr<GeomAPI_Pln> thePlane,
+ const double theSize);
/// Returns the plane of the planar face. If it is not planar, returns empty ptr.
static std::shared_ptr<GeomAPI_Pln> plane(std::shared_ptr<GeomAPI_Shape> theFace);
SET(PROJECT_HEADERS
InitializationPlugin.h
InitializationPlugin_Plugin.h
- InitializationPlugin_OriginPlanesFeature.h
+ #InitializationPlugin_OriginPlanesFeature.h
)
SET(PROJECT_SOURCES
InitializationPlugin_Plugin.cpp
- InitializationPlugin_OriginPlanesFeature.cpp
+ #InitializationPlugin_OriginPlanesFeature.cpp
)
-SET(XML_RESOURCES
- plugin-Initialization.xml
-)
+#SET(XML_RESOURCES
+#)
SET(PROJECT_LIBRARIES
Events
TARGET_LINK_LIBRARIES(InitializationPlugin ${PROJECT_LIBRARIES})
INSTALL(TARGETS InitializationPlugin DESTINATION plugins)
-INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
+#INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
+++ /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_ */
// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
#include <InitializationPlugin_Plugin.h>
-#include <InitializationPlugin_OriginPlanesFeature.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeString.h>
+
+
+#include <Events_Message.h>
+
+#include <ModelAPI_Events.h>
#include <ModelAPI_Session.h>
#include <memory>
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
// the only created instance of this plugin
static InitializationPlugin_Plugin* MY_INITIALIZATIONPLUGIN_INSTANCE = new InitializationPlugin_Plugin();
// register this plugin
SessionPtr aSession = ModelAPI_Session::get();
aSession->registerPlugin(this);
+
+ Events_Loop* aLoop = Events_Loop::loop();
+ const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId();
+ aLoop->registerListener(this, kDocCreatedEvent, NULL, true);
}
FeaturePtr InitializationPlugin_Plugin::createFeature(std::string theFeatureID)
{
- if(InitializationPlugin_OriginPlanesFeature::ID() == theFeatureID) {
- return FeaturePtr(new InitializationPlugin_OriginPlanesFeature);
- }
return FeaturePtr();
}
+void InitializationPlugin_Plugin::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+ const Events_ID kDocCreatedEvent = ModelAPI_DocumentCreatedMessage::eventId();
+ if (theMessage->eventID() == kDocCreatedEvent) {
+ std::shared_ptr<ModelAPI_DocumentCreatedMessage> aMessage =
+ std::dynamic_pointer_cast<ModelAPI_DocumentCreatedMessage>(theMessage);
+ DocumentPtr aDoc = aMessage->document();
+ createPoint(aDoc);
+ createPlane(aDoc, 1., 0., 0.);
+ createPlane(aDoc, 0., 1., 0.);
+ createPlane(aDoc, 0., 0., 1.);
+ } else if (theMessage.get()) {
+ #ifdef _DEBUG
+ std::cout << "InitializationPlugin_Plugin::processEvent: unhandled message caught: " << std::endl
+ << theMessage->eventID().eventText() << std::endl;
+ #endif
+ }
+}
+
+void InitializationPlugin_Plugin::createPlane(DocumentPtr theDoc, double theA, double theB, double theC)
+{
+ 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("D")->setValue(0.);
+
+ if (theA) {
+ aPlane->data()->setName("Y0Z");
+ } else if (theB) {
+ aPlane->data()->setName("X0Z");
+ } else if (theC) {
+ aPlane->data()->setName("X0Y");
+ }
+}
+
+void InitializationPlugin_Plugin::createPoint(DocumentPtr theDoc)
+{
+ std::shared_ptr<ModelAPI_Feature> aPoint = theDoc->addFeature("Point");
+ aPoint->real("x")->setValue(0.);
+ aPoint->real("y")->setValue(0.);
+ aPoint->real("z")->setValue(0.);
+ aPoint->data()->setName("Origin");
+}
+
#define INITIALIZATIONPLUGIN_PLUGIN_H_
#include <InitializationPlugin.h>
+
#include <ModelAPI_Plugin.h>
#include <ModelAPI_Feature.h>
+#include <Events_Loop.h>
+
/**\class InitializationPlugin_Plugin
* TODO: Add documentation
*/
-class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_Plugin : public ModelAPI_Plugin
+class INITIALIZATIONPLUGIN_EXPORT InitializationPlugin_Plugin : public ModelAPI_Plugin,
+ public Events_Listener
{
public:
+ InitializationPlugin_Plugin();
+ ~InitializationPlugin_Plugin() {}
/// Creates the feature object of this plugin by the feature string ID
virtual FeaturePtr createFeature(std::string theFeatureID);
+ virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
- public:
- InitializationPlugin_Plugin();
+ void createPlane(DocumentPtr theDoc, double theA, double theB, double theC);
+ void createPoint(DocumentPtr theDoc);
};
#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>
#include <Model_Application.h>
#include <Model_Document.h>
+#include <ModelAPI_Events.h>
+
IMPLEMENT_STANDARD_HANDLE(Model_Application, TDocStd_Application)
IMPLEMENT_STANDARD_RTTIEXT(Model_Application, TDocStd_Application)
std::shared_ptr<Model_Document> aNew(
new Model_Document(theDocID, theDocID == "root" ? thePartSetKind : thePartKind));
myDocs[theDocID] = aNew;
+
+ Events_ID anId = ModelAPI_DocumentCreatedMessage::eventId();
+ std::shared_ptr<ModelAPI_DocumentCreatedMessage> aMessage =
+ std::shared_ptr<ModelAPI_DocumentCreatedMessage>(new ModelAPI_DocumentCreatedMessage(anId, this));
+ aMessage->setDocument(aNew);
+ Events_Loop::loop()->send(aMessage);
// load it if it must be loaded by demand
if (myLoadedByDemand.find(theDocID) != myLoadedByDemand.end() && !myPath.empty()) {
aNew->load(myPath.c_str());
static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
bool isAutomaticChanged = false;
if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed
- isAutomatic =
- Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+ bool aPropVal =
+ Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true";
+ if (aPropVal == isAutomatic)
+ return;// nothing to
+ isAutomatic = aPropVal;
} else if (theMessage->eventID() == kRebuildEvent) { // the rebuild command
if (isAutomatic == false) {
isAutomaticChanged = true;