ModelHighAPI_Macro.h
ModelHighAPI_RefAttr.h
ModelHighAPI_Selection.h
+ ModelHighAPI_Services.h
ModelHighAPI_Tools.h
)
ModelHighAPI_Interface.cpp
ModelHighAPI_RefAttr.cpp
ModelHighAPI_Selection.cpp
+ ModelHighAPI_Services.cpp
ModelHighAPI_Tools.cpp
)
%include "ModelHighAPI_Interface.h"
%include "ModelHighAPI_RefAttr.h"
%include "ModelHighAPI_Selection.h"
+%include "ModelHighAPI_Services.h"
%include "ModelHighAPI_Macro.h"
%include "ModelHighAPI_Tools.h"
--- /dev/null
+// Name : ModelHighAPI_Services.cpp
+// Purpose:
+//
+// History:
+// 17/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI_Services.h"
+//--------------------------------------------------------------------------------------
+#include <GeomAPI_Ax3.h>
+#include <GeomAPI_Pnt.h>
+#include <ModelAPI_Session.h>
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_Document> moduleDocument()
+{
+ return ModelAPI_Session::get()->moduleDocument();
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_Document> activeDocument()
+{
+ return ModelAPI_Session::get()->activeDocument();
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<GeomAPI_Ax3> defaultPlane( const std::string& theName )
+{
+ std::shared_ptr<GeomAPI_Pnt> o(new GeomAPI_Pnt(0, 0, 0));
+ std::shared_ptr<GeomAPI_Dir> n, x;
+ if (theName == "XOY") {
+ n.reset(new GeomAPI_Dir(0, 0, 1));
+ x.reset(new GeomAPI_Dir(1, 0, 0));
+ } else if (theName == "XOZ") {
+ n.reset(new GeomAPI_Dir(0, -1, 0));
+ x.reset(new GeomAPI_Dir(1, 0, 0));
+ } else if (theName == "YOZ") {
+ n.reset(new GeomAPI_Dir(1, 0, 0));
+ x.reset(new GeomAPI_Dir(0, 1, 0));
+ }
+
+ return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(o, x, n));
+}
+
+//--------------------------------------------------------------------------------------
+void begin()
+{
+ ModelAPI_Session::get()->startOperation();
+}
+void end()
+{
+ ModelAPI_Session::get()->finishOperation();
+}
+void apply()
+{
+ auto aSession = ModelAPI_Session::get();
+ aSession->finishOperation();
+ aSession->startOperation();
+}
+
+//--------------------------------------------------------------------------------------
+void undo()
+{
+ ModelAPI_Session::get()->undo();
+}
+void redo()
+{
+ ModelAPI_Session::get()->redo();
+}
+
+//--------------------------------------------------------------------------------------
+void reset()
+{
+ ModelAPI_Session::get()->closeAll();
+}
+
+//--------------------------------------------------------------------------------------
--- /dev/null
+// Name : ModelHighAPI_Services.h
+// Purpose:
+//
+// History:
+// 17/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_SERVICES_H_
+#define SRC_MODELHIGHAPI_MODELHIGHAPI_SERVICES_H_
+
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI.h"
+
+#include <memory>
+#include <string>
+//--------------------------------------------------------------------------------------
+class GeomAPI_Ax3;
+class ModelAPI_Document;
+//--------------------------------------------------------------------------------------
+/// Return the main document (the Partset) created or open from the Modeler.
+MODELHIGHAPI_EXPORT
+std::shared_ptr<ModelAPI_Document> moduleDocument();
+
+/** Return the active document.
+ *
+ * This document can be either the main application document (i.e. the Partset) or one of documents
+ * referred to by the main document (a Part).
+ */
+MODELHIGHAPI_EXPORT
+std::shared_ptr<ModelAPI_Document> activeDocument();
+
+/** Return one of the three planes defined by the global coordinate system.
+ *
+ * These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0).
+ */
+MODELHIGHAPI_EXPORT
+std::shared_ptr<GeomAPI_Ax3> defaultPlane(const std::string & theName);
+
+/** Start a data structure transaction.
+ *
+ * Make a control point for being able to discard or undo
+ * all operations done during this transaction.
+ */
+MODELHIGHAPI_EXPORT
+void begin();
+
+/** Commit the data structure transaction.
+ *
+ * Make all operations done since the last control point undo-able.
+ */
+MODELHIGHAPI_EXPORT
+void end();
+
+/** Commit the data structure transaction and start the new one.
+ *
+ * Make all operations done since the last control point undo-able
+ * and continue with the new transaction.
+ */
+MODELHIGHAPI_EXPORT
+void apply();
+
+/// Roll-back the data structure to the previous control point.
+MODELHIGHAPI_EXPORT
+void undo();
+
+/// Restore the data structure rolled-back by the last undo.
+MODELHIGHAPI_EXPORT
+void redo();
+
+/// Reset the data structure to initial state.
+MODELHIGHAPI_EXPORT
+void reset();
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SERVICES_H_ */
#include "ModelHighAPI_Macro.h"
#include "ModelHighAPI_RefAttr.h"
#include "ModelHighAPI_Selection.h"
+ #include "ModelHighAPI_Services.h"
#include "ModelHighAPI_Tools.h"
#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_SWIG_H_ */
+++ /dev/null
-"""General purpose Interface
-Author: Daniel Brunier-Coulin
-Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-"""
-
-import ModelAPI
-import GeomAPI
-
-def moduleDocument ():
- """Return the main document (the Partset) created or open from the Modeler.
-
- This document is unique in the application session.
- """
- return ModelAPI.ModelAPI_Session.get().moduleDocument()
-
-
-def activeDocument ():
- """Return the active document.
-
- This document can be either the main application document (i.e. the Partset) or one of documents
- referred to by the main document (a Part).
- """
- return ModelAPI.ModelAPI_Session.get().activeDocument()
-
-
-def defaultPlane (name):
- """Return one of the three planes defined by the global coordinate system.
-
- These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0).
- """
- # Temporary implementation before the availability of default planes.
- o = GeomAPI.GeomAPI_Pnt(0, 0, 0)
- if name == "XOY":
- n = GeomAPI.GeomAPI_Dir(0, 0, 1)
- x = GeomAPI.GeomAPI_Dir(1, 0, 0)
- elif name == "XOZ":
- n = GeomAPI.GeomAPI_Dir(0, -1, 0)
- x = GeomAPI.GeomAPI_Dir(1, 0, 0)
- elif name == "YOZ":
- n = GeomAPI.GeomAPI_Dir(1, 0, 0)
- x = GeomAPI.GeomAPI_Dir(0, 1, 0)
-
- return GeomAPI.GeomAPI_Ax3(o, x, n)
-
-
-def begin ():
- """Start a data structure transaction.
-
- Make a control point for being able to discard or undo
- all operations done during this transaction.
- """
- ModelAPI.ModelAPI_Session.get().startOperation()
-
-
-def end ():
- """Commit the data structure transaction.
-
- Make all operations done since the last control point undo-able.
- """
- ModelAPI.ModelAPI_Session.get().finishOperation()
-
-
-def do ():
- """Commit the data structure transaction and start the new one.
-
- Make all operations done since the last control point undo-able
- and continue with the new transaction.
- """
- session = ModelAPI.ModelAPI_Session.get()
- session.finishOperation()
- session.startOperation()
-
-
-def undo ():
- """Roll-back the data structure to the previous control point."""
- ModelAPI.ModelAPI_Session.get().undo()
-
-
-def redo ():
- """Restore the data structure rolled-back by the last undo."""
- ModelAPI.ModelAPI_Session.get().redo()
-
-
-def reset ():
- """Reset the data structure to initial state."""
- ModelAPI.ModelAPI_Session.get().closeAll()
--- /dev/null
+"""Package for services for the Parametric Geometry API of the Modeler.
+"""
+
+from ModelHighAPI import moduleDocument, activeDocument
+from ModelHighAPI import defaultPlane
+from ModelHighAPI import begin, end
+from ModelHighAPI import apply as do
+from ModelHighAPI import undo, redo
+from ModelHighAPI import reset
\ No newline at end of file