Python functionality for ViewPart and ViewClip
This commit is contained in:
parent
5bf42856fd
commit
6d07fec219
|
@ -27,6 +27,7 @@ set(TechDrawLIBS
|
|||
|
||||
generate_from_xml(DrawPagePy)
|
||||
generate_from_xml(DrawViewPy)
|
||||
generate_from_xml(DrawViewPartPy)
|
||||
generate_from_xml(DrawViewSymbolPy)
|
||||
generate_from_xml(DrawTemplatePy)
|
||||
generate_from_xml(DrawParametricTemplatePy)
|
||||
|
@ -88,6 +89,8 @@ SET(Python_SRCS
|
|||
DrawPagePyImp.cpp
|
||||
DrawViewPy.xml
|
||||
DrawViewPyImp.cpp
|
||||
DrawViewPartPy.xml
|
||||
DrawViewPartPyImp.cpp
|
||||
DrawViewSymbolPy.xml
|
||||
DrawViewSymbolPyImp.cpp
|
||||
DrawTemplatePy.xml
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "DrawViewCollection.h"
|
||||
#include "DrawViewClip.h"
|
||||
|
||||
#include "DrawViewPy.h" // generated from DrawViewPy.xml
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
|
||||
|
@ -170,6 +172,15 @@ bool DrawView::isInClip()
|
|||
return false;
|
||||
}
|
||||
|
||||
PyObject *DrawView::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawViewPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderDrawingView";
|
||||
}
|
||||
//return PyObject as DrawViewPy
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
DrawPage* findParentPage() const;
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "DrawView.h"
|
||||
#include "DrawPage.h"
|
||||
|
||||
#include "DrawViewClipPy.h" // generated from DrawViewClipPy.xml
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
|
@ -158,6 +160,16 @@ std::vector<std::string> DrawViewClip::getChildViewNames()
|
|||
return childNames;
|
||||
}
|
||||
|
||||
PyObject *DrawViewClip::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawViewClipPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -66,6 +66,9 @@ public:
|
|||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderViewClip";
|
||||
}
|
||||
//return PyObject as DrawViewClipPy
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
std::vector<std::string> getChildViewNames();
|
||||
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@
|
|||
#include "DrawHatch.h"
|
||||
//#include "DrawViewDimension.h"
|
||||
|
||||
#include "DrawViewPartPy.h" // generated from DrawViewPartPy.xml
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
|
@ -456,6 +458,15 @@ void DrawViewPart::dumpVertexRefs(char* text) const
|
|||
}
|
||||
}
|
||||
|
||||
PyObject *DrawViewPart::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawViewPartPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderViewPart";
|
||||
}
|
||||
//return PyObject as DrawViewPartPy
|
||||
virtual PyObject *getPyObject(void);
|
||||
|
||||
void dumpVertexRefs(char* text) const;
|
||||
|
||||
|
|
|
@ -474,10 +474,7 @@ void CmdTechDrawAnnotation::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewAnnotation','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.X = 10.0",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Y = 10.0",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Scale = 7.0",FeatName.c_str());
|
||||
//TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
//page->addView(page->getDocument()->getObject(FeatName.c_str()));
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
|
@ -525,9 +522,7 @@ void CmdTechDrawClip::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().%s.Height = 30.0",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Width = 30.0",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.ShowLabels = False",FeatName.c_str());
|
||||
//TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
//page->addView(page->getDocument()->getObject(FeatName.c_str()));
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
|
@ -594,9 +589,10 @@ void CmdTechDrawClipPlus::activated(int iMsg)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string ClipName = clip->getNameInDocument();
|
||||
std::string ViewName = view->getNameInDocument();
|
||||
openCommand("ClipPlus");
|
||||
//TODO: implement Py addView for Clip
|
||||
clip->addView(view);
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",ClipName.c_str(),ViewName.c_str());
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
|
@ -662,9 +658,10 @@ void CmdTechDrawClipMinus::activated(int iMsg)
|
|||
return;
|
||||
}
|
||||
|
||||
std::string ClipName = clip->getNameInDocument();
|
||||
std::string ViewName = view->getNameInDocument();
|
||||
openCommand("ClipMinus");
|
||||
//TODO: implement Py removeView for Clip
|
||||
clip->removeView(view);
|
||||
doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",ClipName.c_str(),ViewName.c_str());
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
|
@ -718,9 +715,7 @@ void CmdTechDrawSymbol::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().%s.X = 10.0",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Y = 10.0",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Symbol = svg",FeatName.c_str());
|
||||
//TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
//page->addView(page->getDocument()->getObject(FeatName.c_str()));
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user