add Python functionality for ProjectionGroups
This commit is contained in:
parent
707ef236f3
commit
42eed349ac
|
@ -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})
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
18
src/Mod/TechDraw/App/DrawProjGroupItemPy.xml
Normal file
18
src/Mod/TechDraw/App/DrawProjGroupItemPy.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DrawViewPartPy"
|
||||
Name="DrawProjGroupItemPy"
|
||||
Twin="DrawProjGroupItem"
|
||||
TwinPointer="DrawProjGroupItem"
|
||||
Include="Mod/TechDraw/App/DrawProjGroupItem.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="Mod/TechDraw/App/DrawViewPartPy.h"
|
||||
FatherNamespace="TechDraw">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for creating and manipulating component Views Technical Drawing Projection Groups</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
34
src/Mod/TechDraw/App/DrawProjGroupItemPyImp.cpp
Normal file
34
src/Mod/TechDraw/App/DrawProjGroupItemPyImp.cpp
Normal file
|
@ -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("<DrawProjGroupItem object>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PyObject *DrawProjGroupItemPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawProjGroupItemPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
33
src/Mod/TechDraw/App/DrawProjGroupPy.xml
Normal file
33
src/Mod/TechDraw/App/DrawProjGroupPy.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DrawViewCollectionPy"
|
||||
Name="DrawProjGroupPy"
|
||||
Twin="DrawProjGroup"
|
||||
TwinPointer="DrawProjGroup"
|
||||
Include="Mod/TechDraw/App/DrawProjGroup.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="Mod/TechDraw/App/DrawViewCollectionPy.h"
|
||||
FatherNamespace="TechDraw">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for creating and manipulating Technical Drawing Projection Groups</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="addProjection">
|
||||
<Documentation>
|
||||
<UserDocu>addProjection(string projectionType) - Add a new Projection Item to this Group. Returns DocObj.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeProjection">
|
||||
<Documentation>
|
||||
<UserDocu>removeProjection(string projectionType) - Remove specified Projection Item from this Group. Returns int number of views in Group.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getItemByLabel">
|
||||
<Documentation>
|
||||
<UserDocu>getItemByLabel(string projectionType) - return specified Projection Item</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
78
src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
Normal file
78
src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#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("<DrawProjGroup object>");
|
||||
}
|
||||
|
||||
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<TechDraw::DrawProjGroupItem *>( 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<TechDraw::DrawProjGroupItem *>( docObj );
|
||||
|
||||
return new DrawProjGroupItemPy(newProj);
|
||||
}
|
||||
|
||||
PyObject *DrawProjGroupPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawProjGroupPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
18
src/Mod/TechDraw/App/DrawViewCollectionPy.xml
Normal file
18
src/Mod/TechDraw/App/DrawViewCollectionPy.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DrawViewPy"
|
||||
Name="DrawViewCollectionPy"
|
||||
Twin="DrawViewCollection"
|
||||
TwinPointer="DrawViewCollection"
|
||||
Include="Mod/TechDraw/App/DrawViewCollection.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="Mod/TechDraw/App/DrawViewPy.h"
|
||||
FatherNamespace="TechDraw">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for creating and manipulating Technical Drawing View Collections</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
34
src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp
Normal file
34
src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp
Normal file
|
@ -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("<DrawViewCollection object>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PyObject *DrawViewCollectionPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawViewCollectionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -417,9 +417,10 @@ void CmdTechDrawProjGroup::activated(int iMsg)
|
|||
TechDraw::DrawProjGroup *multiView = dynamic_cast<TechDraw::DrawProjGroup *>(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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user