1st cut PyClip functionality
This commit is contained in:
parent
ccdb56c06e
commit
5bf42856fd
|
@ -32,6 +32,7 @@ generate_from_xml(DrawTemplatePy)
|
|||
generate_from_xml(DrawParametricTemplatePy)
|
||||
generate_from_xml(DrawSVGTemplatePy)
|
||||
generate_from_xml(DrawViewSymbolPy)
|
||||
generate_from_xml(DrawViewClipPy)
|
||||
|
||||
SET(Draw_SRCS
|
||||
DrawPage.cpp
|
||||
|
@ -95,6 +96,8 @@ SET(Python_SRCS
|
|||
DrawParametricTemplatePyImp.cpp
|
||||
DrawSVGTemplatePy.xml
|
||||
DrawSVGTemplatePyImp.cpp
|
||||
DrawViewClipPy.xml
|
||||
DrawViewClipPyImp.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})
|
||||
|
|
|
@ -50,7 +50,7 @@ using namespace std;
|
|||
|
||||
PROPERTY_SOURCE(TechDraw::DrawViewClip, TechDraw::DrawView)
|
||||
|
||||
DrawViewClip::DrawViewClip(void)
|
||||
DrawViewClip::DrawViewClip(void)
|
||||
{
|
||||
static const char *group = "Clip Group";
|
||||
//App::PropertyType hidden = (App::PropertyType)(App::Prop_Hidden);
|
||||
|
@ -72,11 +72,11 @@ DrawViewClip::DrawViewClip(void)
|
|||
//ScaleType.StatusBits.set(bitReadOnly, true);
|
||||
//ScaleType.StatusBits.set(bitHidden, true);
|
||||
//Scale.StatusBits.set(bitReadOnly, true);
|
||||
//Scale.StatusBits.set(bitHidden,true);
|
||||
//Scale.StatusBits.set(bitHidden,true);
|
||||
ScaleType.setStatus(App::Property::ReadOnly,true);
|
||||
ScaleType.setStatus(App::Property::Hidden,true);
|
||||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
Scale.setStatus(App::Property::Hidden,true);
|
||||
Scale.setStatus(App::Property::Hidden,true);
|
||||
}
|
||||
|
||||
DrawViewClip::~DrawViewClip()
|
||||
|
@ -164,7 +164,7 @@ namespace App {
|
|||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawViewClipPython, TechDraw::DrawViewClip)
|
||||
template<> const char* TechDraw::DrawViewClipPython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderDrawClip";
|
||||
return "TechDrawGui::ViewProviderViewClip";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderDrawClip";
|
||||
return "TechDrawGui::ViewProviderViewClip";
|
||||
}
|
||||
std::vector<std::string> getChildViewNames();
|
||||
|
||||
|
|
33
src/Mod/TechDraw/App/DrawViewClipPy.xml
Normal file
33
src/Mod/TechDraw/App/DrawViewClipPy.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="DrawViewPy"
|
||||
Name="DrawViewClipPy"
|
||||
Twin="DrawViewClip"
|
||||
TwinPointer="DrawViewClip"
|
||||
Include="Mod/TechDraw/App/DrawViewClip.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 Clip Views</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="addView">
|
||||
<Documentation>
|
||||
<UserDocu>addView(DrawView) - Add a View to this ClipView</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeView">
|
||||
<Documentation>
|
||||
<UserDocu>removeView(DrawView) - Remove specified View to this ClipView</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getChildViewNames">
|
||||
<Documentation>
|
||||
<UserDocu>getChildViewNames() - get a list of the DrawViews in this ClipView</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
100
src/Mod/TechDraw/App/DrawViewClipPyImp.cpp
Normal file
100
src/Mod/TechDraw/App/DrawViewClipPyImp.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include "Mod/TechDraw/App/DrawViewClip.h"
|
||||
#include "Mod/TechDraw/App/DrawView.h"
|
||||
#include "DrawViewPy.h"
|
||||
|
||||
// inclusion of the generated files (generated out of DrawViewClipPy.xml)
|
||||
#include "DrawViewClipPy.h"
|
||||
#include "DrawViewClipPy.cpp"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string DrawViewClipPy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawViewClip object>");
|
||||
}
|
||||
|
||||
PyObject* DrawViewClipPy::addView(PyObject* args)
|
||||
{
|
||||
//this implements iRC = pyClip.addView(pyView) -or-
|
||||
//doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
PyObject *pcDocObj;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
|
||||
Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n");
|
||||
return NULL;
|
||||
//TODO: sb PyErr??
|
||||
//PyErr_SetString(PyExc_TypeError,"addView expects a DrawView");
|
||||
//return -1;
|
||||
}
|
||||
|
||||
DrawViewClip* clip = getDrawViewClipPtr(); //get DrawViewClip for pyClip
|
||||
//TODO: argument 1 arrives as "DocumentObjectPy", not "DrawViewPy"
|
||||
//how to validate that obj is DrawView before use??
|
||||
DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj);
|
||||
DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView
|
||||
|
||||
clip->addView(view);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* DrawViewClipPy::removeView(PyObject* args)
|
||||
{
|
||||
//this implements iRC = pyClip.removeView(pyView) -or-
|
||||
//doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
PyObject *pcDocObj;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) {
|
||||
Base::Console().Error("Error: DrawViewClipPy::removeView - Bad Arg - not DocumentObject\n");
|
||||
return NULL;
|
||||
//TODO: sb PyErr??
|
||||
//PyErr_SetString(PyExc_TypeError,"removeView expects a DrawView");
|
||||
//return -1;
|
||||
}
|
||||
|
||||
DrawViewClip* clip = getDrawViewClipPtr(); //get DrawViewClip for pyClip
|
||||
//TODO: argument 1 arrives as "DocumentObjectPy", not "DrawViewPy"
|
||||
//how to validate that obj is DrawView before use??
|
||||
DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj);
|
||||
DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView
|
||||
|
||||
clip->removeView(view);
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
// std::vector<std::string> getChildViewNames();
|
||||
PyObject* DrawViewClipPy::getChildViewNames(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
|
||||
DrawViewClip* clip = getDrawViewClipPtr();
|
||||
std::vector<std::string> strings = clip->getChildViewNames();
|
||||
int stringSize = strings.size();
|
||||
|
||||
PyObject* result = PyList_New(stringSize);
|
||||
|
||||
std::vector<std::string>::iterator it = strings.begin();
|
||||
for( ; it != strings.end(); it++) {
|
||||
PyObject* pString = PyString_FromString(it->c_str()); //TODO: unicode & py3
|
||||
int rc = PyList_Append(result, pString);
|
||||
}
|
||||
|
||||
// PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject *DrawViewClipPy::getCustomAttributes(const char* attr) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawViewClipPy::setCustomAttributes(const char* attr, PyObject *obj)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -58,6 +58,8 @@ public:
|
|||
App::PropertyBool CentreLines;
|
||||
App::PropertyString FormatSpec;
|
||||
|
||||
//TODO: do we need a property for the actual dimension value? how else to access from Py?
|
||||
|
||||
short mustExecute() const;
|
||||
bool hasReferences(void) const;
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ public:
|
|||
//int removeHatch(App::DocumentObject *docObj);
|
||||
std::vector<TechDraw::DrawHatch*> getHatches(void) const;
|
||||
|
||||
//TODO: are there use-cases for Python access to TechDrawGeometry???
|
||||
|
||||
const std::vector<TechDrawGeometry::Vertex *> & getVertexGeometry() const;
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> & getEdgeGeometry() const;
|
||||
const std::vector<TechDrawGeometry::Face *> & getFaceGeometry() const;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for creating and manipulating Drawing Views</UserDocu>
|
||||
<UserDocu>Feature for creating and manipulating Technical Drawing Views</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
|
|
|
@ -88,7 +88,7 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute(void)
|
|||
{
|
||||
std::string svg = Symbol.getValue();
|
||||
const std::vector<std::string>& editText = EditableTexts.getValues();
|
||||
|
||||
|
||||
if (!editText.empty()) {
|
||||
boost::regex e1 ("<text.*?freecad:editable=\"(.*?)\".*?<tspan.*?>(.*?)</tspan>");
|
||||
string::const_iterator begin, end;
|
||||
|
@ -115,7 +115,8 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute(void)
|
|||
newsvg.insert(newsvg.end(), begin, end);
|
||||
svg = newsvg;
|
||||
}
|
||||
|
||||
//TODO: shouldn't there be a Symbol.setValue(svg) here??? -wf
|
||||
#if 0
|
||||
std::stringstream result;
|
||||
result << "<g transform=\"translate(" << X.getValue() << "," << Y.getValue() << ")"
|
||||
<< " rotate(" << Rotation.getValue() << ")"
|
||||
|
@ -126,6 +127,7 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute(void)
|
|||
// Apply the resulting fragment
|
||||
// no more ViewResult! Need to xlate SVG to Geometry object???
|
||||
//ViewResult.setValue(result.str().c_str());
|
||||
#endif
|
||||
|
||||
//return App::DocumentObject::StdReturn;
|
||||
return DrawView::execute();
|
||||
|
|
|
@ -99,7 +99,7 @@ void TechDrawGuiExport initTechDrawGui()
|
|||
TechDrawGui::ViewProviderProjGroupItem::init();
|
||||
TechDrawGui::ViewProviderProjGroup::init();
|
||||
TechDrawGui::ViewProviderViewSection::init();
|
||||
TechDrawGui::ViewProviderDrawingClip::init();
|
||||
TechDrawGui::ViewProviderViewClip::init();
|
||||
TechDrawGui::ViewProviderAnnotation::init();
|
||||
TechDrawGui::ViewProviderSymbol::init();
|
||||
TechDrawGui::ViewProviderHatch::init();
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderDrawingClip, TechDrawGui::ViewProviderDrawingView)
|
||||
PROPERTY_SOURCE(TechDrawGui::ViewProviderViewClip, TechDrawGui::ViewProviderDrawingView)
|
||||
|
||||
ViewProviderDrawingClip::ViewProviderDrawingClip()
|
||||
ViewProviderViewClip::ViewProviderViewClip()
|
||||
{
|
||||
sPixmap = "actions/techdraw-clip";
|
||||
|
||||
|
@ -59,29 +59,29 @@ ViewProviderDrawingClip::ViewProviderDrawingClip()
|
|||
DisplayMode.setStatus(App::Property::ReadOnly,true);
|
||||
}
|
||||
|
||||
ViewProviderDrawingClip::~ViewProviderDrawingClip()
|
||||
ViewProviderViewClip::~ViewProviderViewClip()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderViewClip::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
// call parent attach method
|
||||
ViewProviderDocumentObject::attach(pcFeat);
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::setDisplayMode(const char* ModeName)
|
||||
void ViewProviderViewClip::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
ViewProviderDocumentObject::setDisplayMode(ModeName);
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderDrawingClip::getDisplayModes(void) const
|
||||
std::vector<std::string> ViewProviderViewClip::getDisplayModes(void) const
|
||||
{
|
||||
// get the modes of the father
|
||||
std::vector<std::string> StrList;
|
||||
return StrList;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderDrawingClip::claimChildren(void) const
|
||||
std::vector<App::DocumentObject*> ViewProviderViewClip::claimChildren(void) const
|
||||
{
|
||||
// Collect any child views
|
||||
// for Clip, valid children are any View in Views
|
||||
|
@ -89,7 +89,7 @@ std::vector<App::DocumentObject*> ViewProviderDrawingClip::claimChildren(void) c
|
|||
return views;
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::show(void)
|
||||
void ViewProviderViewClip::show(void)
|
||||
{
|
||||
ViewProviderDrawingView::show();
|
||||
|
||||
|
@ -106,7 +106,7 @@ void ViewProviderDrawingClip::show(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::hide(void)
|
||||
void ViewProviderViewClip::hide(void)
|
||||
{
|
||||
ViewProviderDrawingView::hide();
|
||||
|
||||
|
@ -123,26 +123,26 @@ void ViewProviderDrawingClip::hide(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool ViewProviderDrawingClip::isShow(void) const
|
||||
bool ViewProviderViewClip::isShow(void) const
|
||||
{
|
||||
return Visibility.getValue();
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::startRestoring()
|
||||
void ViewProviderViewClip::startRestoring()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::finishRestoring()
|
||||
void ViewProviderViewClip::finishRestoring()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void ViewProviderDrawingClip::updateData(const App::Property*)
|
||||
void ViewProviderViewClip::updateData(const App::Property*)
|
||||
{
|
||||
}
|
||||
|
||||
TechDraw::DrawViewClip* ViewProviderDrawingClip::getObject() const
|
||||
TechDraw::DrawViewClip* ViewProviderViewClip::getObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewClip*>(pcObject);
|
||||
}
|
||||
|
|
|
@ -34,15 +34,15 @@ namespace TechDraw{
|
|||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class TechDrawGuiExport ViewProviderDrawingClip : public ViewProviderDrawingView
|
||||
class TechDrawGuiExport ViewProviderViewClip : public ViewProviderDrawingView
|
||||
{
|
||||
PROPERTY_HEADER(TechDrawGui::ViewProviderDrawingClip);
|
||||
PROPERTY_HEADER(TechDrawGui::ViewProviderViewClip);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderDrawingClip();
|
||||
ViewProviderViewClip();
|
||||
/// destructor
|
||||
virtual ~ViewProviderDrawingClip();
|
||||
virtual ~ViewProviderViewClip();
|
||||
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
|
@ -70,4 +70,3 @@ public:
|
|||
|
||||
|
||||
#endif // DRAWINGGUI_VIEWPROVIDERCLIP_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user