diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt
index 7ebb8bd97..9aea3c4b7 100644
--- a/src/Mod/TechDraw/App/CMakeLists.txt
+++ b/src/Mod/TechDraw/App/CMakeLists.txt
@@ -36,6 +36,9 @@ generate_from_xml(DrawViewSymbolPy)
generate_from_xml(DrawViewClipPy)
generate_from_xml(DrawViewDimensionPy)
generate_from_xml(DrawHatchPy)
+generate_from_xml(DrawViewCollectionPy)
+generate_from_xml(DrawProjGroupPy)
+generate_from_xml(DrawProjGroupItemPy)
SET(Draw_SRCS
DrawPage.cpp
@@ -106,7 +109,13 @@ SET(Python_SRCS
DrawViewDimensionPy.xml
DrawViewDimensionPyImp.cpp
DrawHatchPy.xml
- DrawHatchPyImp.cpp)
+ DrawHatchPyImp.cpp
+ DrawViewCollectionPy.xml
+ DrawViewCollectionPyImp.cpp
+ DrawProjGroupPy.xml
+ DrawProjGroupPyImp.cpp
+ DrawProjGroupItemPy.xml
+ DrawProjGroupItemPyImp.cpp)
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})
SOURCE_GROUP("Features" FILES ${Draw_SRCS})
diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp
index afd8cb05e..b4682b15b 100644
--- a/src/Mod/TechDraw/App/DrawProjGroup.cpp
+++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp
@@ -40,6 +40,8 @@
#include "DrawPage.h"
#include "DrawProjGroup.h"
+#include "DrawProjGroupPy.h" // generated from DrawProjGroupPy.xml
+
using namespace TechDraw;
const char* DrawProjGroup::ProjectionTypeEnums[] = {"Document",
@@ -283,7 +285,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
DrawProjGroupItem *view = NULL;
if ( checkViewProjType(viewProjType) && !hasProjection(viewProjType) ) {
- std::string FeatName = getDocument()->getUniqueObjectName("ProjGroup");
+ std::string FeatName = getDocument()->getUniqueObjectName("ProjItem");
App::DocumentObject *docObj = getDocument()->addObject("TechDraw::DrawProjGroupItem",
FeatName.c_str());
@@ -615,3 +617,12 @@ void DrawProjGroup::onDocumentRestored()
{
execute();
}
+
+PyObject *DrawProjGroup::getPyObject(void)
+{
+ if (PythonObject.is(Py::_None())) {
+ // ref counter is set to 1
+ PythonObject = Py::Object(new DrawProjGroupPy(this),true);
+ }
+ return Py::new_reference_to(PythonObject);
+}
diff --git a/src/Mod/TechDraw/App/DrawProjGroup.h b/src/Mod/TechDraw/App/DrawProjGroup.h
index 44f58cc73..62b62222f 100644
--- a/src/Mod/TechDraw/App/DrawProjGroup.h
+++ b/src/Mod/TechDraw/App/DrawProjGroup.h
@@ -101,6 +101,8 @@ public:
virtual const char* getViewProviderName(void) const {
return "TechDrawGui::ViewProviderProjGroup";
}
+ //return PyObject as DrawProjGroupPy
+ virtual PyObject *getPyObject(void);
/// Determines either "First Angle" or "Third Angle".
App::Enumeration usedProjectionType(void);
diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp
index 1896c5156..7e4cd78ab 100644
--- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp
+++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp
@@ -32,6 +32,8 @@
#include "DrawProjGroupItem.h"
+#include "DrawProjGroupItemPy.h" // generated from DrawProjGroupItemPy.xml
+
using namespace TechDraw;
const char* DrawProjGroupItem::TypeEnums[] = {"Front",
@@ -110,3 +112,11 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
return TechDraw::DrawViewPart::execute();
}*/
+PyObject *DrawProjGroupItem::getPyObject(void)
+{
+ if (PythonObject.is(Py::_None())) {
+ // ref counter is set to 1
+ PythonObject = Py::Object(new DrawProjGroupItemPy(this),true);
+ }
+ return Py::new_reference_to(PythonObject);
+}
diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.h b/src/Mod/TechDraw/App/DrawProjGroupItem.h
index 7bdaf00ef..c0de0735e 100644
--- a/src/Mod/TechDraw/App/DrawProjGroupItem.h
+++ b/src/Mod/TechDraw/App/DrawProjGroupItem.h
@@ -56,6 +56,8 @@ public:
virtual const char* getViewProviderName(void) const {
return "TechDrawGui::ViewProviderProjGroupItem";
}
+ //return PyObject as DrawProjGroupItemPy
+ virtual PyObject *getPyObject(void);
protected:
/// Called by the container when a Property was changed
diff --git a/src/Mod/TechDraw/App/DrawProjGroupItemPy.xml b/src/Mod/TechDraw/App/DrawProjGroupItemPy.xml
new file mode 100644
index 000000000..8d81eccfa
--- /dev/null
+++ b/src/Mod/TechDraw/App/DrawProjGroupItemPy.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Feature for creating and manipulating component Views Technical Drawing Projection Groups
+
+
+
+
diff --git a/src/Mod/TechDraw/App/DrawProjGroupItemPyImp.cpp b/src/Mod/TechDraw/App/DrawProjGroupItemPyImp.cpp
new file mode 100644
index 000000000..0b857ce76
--- /dev/null
+++ b/src/Mod/TechDraw/App/DrawProjGroupItemPyImp.cpp
@@ -0,0 +1,34 @@
+
+#include "PreCompiled.h"
+
+#include "Mod/TechDraw/App/DrawProjGroupItem.h"
+
+// inclusion of the generated files (generated out of DrawProjGroupItemPy.xml)
+#include "DrawProjGroupItemPy.h"
+#include "DrawProjGroupItemPy.cpp"
+
+using namespace TechDraw;
+
+// returns a string which represents the object e.g. when printed in python
+std::string DrawProjGroupItemPy::representation(void) const
+{
+ return std::string("");
+}
+
+
+
+
+
+
+
+PyObject *DrawProjGroupItemPy::getCustomAttributes(const char* /*attr*/) const
+{
+ return 0;
+}
+
+int DrawProjGroupItemPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
+{
+ return 0;
+}
+
+
diff --git a/src/Mod/TechDraw/App/DrawProjGroupPy.xml b/src/Mod/TechDraw/App/DrawProjGroupPy.xml
new file mode 100644
index 000000000..f42fe53f7
--- /dev/null
+++ b/src/Mod/TechDraw/App/DrawProjGroupPy.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+ Feature for creating and manipulating Technical Drawing Projection Groups
+
+
+
+ addProjection(string projectionType) - Add a new Projection Item to this Group. Returns DocObj.
+
+
+
+
+ removeProjection(string projectionType) - Remove specified Projection Item from this Group. Returns int number of views in Group.
+
+
+
+
+ getItemByLabel(string projectionType) - return specified Projection Item
+
+
+
+
+
diff --git a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
new file mode 100644
index 000000000..bba7328dd
--- /dev/null
+++ b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
@@ -0,0 +1,78 @@
+
+#include "PreCompiled.h"
+
+#include
+
+#include "DrawProjGroup.h"
+#include "DrawProjGroupItem.h"
+
+// inclusion of the generated files (generated out of DrawProjGroupPy.xml)
+#include "DrawProjGroupPy.h"
+#include "DrawProjGroupPy.cpp"
+
+#include "DrawProjGroupItemPy.h"
+
+using namespace TechDraw;
+
+// returns a string which represents the object e.g. when printed in python
+std::string DrawProjGroupPy::representation(void) const
+{
+ return std::string("");
+}
+
+PyObject* DrawProjGroupPy::addProjection(PyObject* args)
+{
+ const char* projType;
+
+ if (!PyArg_ParseTuple(args, "s", &projType)) {
+ Base::Console().Error("Error: DrawProjGroupPy::addProjection - Bad Arg - not string\n");
+ return NULL;
+ }
+
+ DrawProjGroup* projGroup = getDrawProjGroupPtr();
+ App::DocumentObject* docObj = projGroup->addProjection(projType);
+ TechDraw::DrawProjGroupItem* newProj = dynamic_cast( docObj );
+
+ return new DrawProjGroupItemPy(newProj);
+}
+
+PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
+{
+ const char* projType;
+
+ if (!PyArg_ParseTuple(args, "s", &projType)) {
+ Base::Console().Error("Error: DrawProjGroupPy::removeProjection - Bad Arg - not string\n");
+ return NULL;
+ }
+
+ DrawProjGroup* projGroup = getDrawProjGroupPtr();
+ int i = projGroup->removeProjection(projType);
+
+ return PyInt_FromLong((long) i);;
+}
+
+PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
+{
+ const char* projType;
+
+ if (!PyArg_ParseTuple(args, "s", &projType)) {
+ Base::Console().Error("Error: DrawProjGroupPy::getItemByLabel - Bad Arg - not string\n");
+ return NULL;
+ }
+
+ DrawProjGroup* projGroup = getDrawProjGroupPtr();
+ App::DocumentObject* docObj = projGroup->getProjObj(projType);
+ TechDraw::DrawProjGroupItem* newProj = dynamic_cast( docObj );
+
+ return new DrawProjGroupItemPy(newProj);
+}
+
+PyObject *DrawProjGroupPy::getCustomAttributes(const char* /*attr*/) const
+{
+ return 0;
+}
+
+int DrawProjGroupPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
+{
+ return 0;
+}
diff --git a/src/Mod/TechDraw/App/DrawViewCollectionPy.xml b/src/Mod/TechDraw/App/DrawViewCollectionPy.xml
new file mode 100644
index 000000000..543b0527f
--- /dev/null
+++ b/src/Mod/TechDraw/App/DrawViewCollectionPy.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ Feature for creating and manipulating Technical Drawing View Collections
+
+
+
+
diff --git a/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp b/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp
new file mode 100644
index 000000000..a215c7f43
--- /dev/null
+++ b/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp
@@ -0,0 +1,34 @@
+
+#include "PreCompiled.h"
+
+#include "Mod/TechDraw/App/DrawViewCollection.h"
+
+// inclusion of the generated files (generated out of DrawViewCollectionPy.xml)
+#include "DrawViewCollectionPy.h"
+#include "DrawViewCollectionPy.cpp"
+
+using namespace TechDraw;
+
+// returns a string which represents the object e.g. when printed in python
+std::string DrawViewCollectionPy::representation(void) const
+{
+ return std::string("");
+}
+
+
+
+
+
+
+
+PyObject *DrawViewCollectionPy::getCustomAttributes(const char* /*attr*/) const
+{
+ return 0;
+}
+
+int DrawViewCollectionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
+{
+ return 0;
+}
+
+
diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp
index d8281cc0e..6d38dea08 100644
--- a/src/Mod/TechDraw/Gui/Command.cpp
+++ b/src/Mod/TechDraw/Gui/Command.cpp
@@ -417,9 +417,10 @@ void CmdTechDrawProjGroup::activated(int iMsg)
TechDraw::DrawProjGroup *multiView = dynamic_cast(docObj);
// set the anchor
- App::DocumentObject* anchorView = multiView->addProjection("Front");
- std::string anchorName = anchorView->getNameInDocument();
- doCommand(Doc,"App.activeDocument().%s.Anchor = App.activeDocument().%s",multiViewName.c_str(),anchorName.c_str());
+ std::string anchor = "Front";
+ doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str());
+ doCommand(Doc,"App.activeDocument().%s.Anchor = App.activeDocument().%s.getItemByLabel('%s')",
+ multiViewName.c_str(),multiViewName.c_str(),anchor.c_str());
// create the rest of the desired views
Gui::Control().showDialog(new TaskDlgProjGroup(multiView));
@@ -427,7 +428,6 @@ void CmdTechDrawProjGroup::activated(int iMsg)
// add the multiView to the page
std::string PageName = page->getNameInDocument();
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
- //page->addView(getDocument()->getObject(multiViewName.c_str()));
updateActive();
commitCommand();