]> Shamusworld >> Repos - architektonas/blob - src/base/rs_python_wrappers.cpp.bak
Scrubbed out all references to RS2::qtToRsButton(). Gone!
[architektonas] / src / base / rs_python_wrappers.cpp.bak
1 /***************************************************************************
2 ** $Id
3 **
4 ** Python language bindings for QCad II
5 **
6 ** Copyright (C) 2003 Markus Meyer <meyer@mesw.de>
7 **
8 ** Permission to copy, use, modify, sell and distribute this file is granted
9 ** provided this copyright notice is not removed or altered.
10 ** This software is provided "as is" without express or implied
11 ** warranty, and with no claim as to its suitability for any purpose.
12 **
13 ***************************************************************************/
14
15 /** 
16   * TODO:
17   * - Complete block support
18   * - Support for hatches, dimensions, text, solids
19   * - Support for user interactions
20   * - Support for more than one document
21   */
22 #ifdef RS_OPT_PYTHON
23
24 #include <boost/python.hpp>
25 using namespace boost::python;
26
27 #include "rs_python_wrappers.h"
28 #include "rs_python.h"
29
30 #include "rs.h"
31 #include "rs_arc.h"
32 #include "rs_atomicentity.h"
33 #include "rs_block.h"
34 #include "rs_blocklist.h"
35 #include "rs_circle.h"
36 #include "rs_color.h"
37 #include "rs_constructionline.h"
38 #include "rs_document.h"
39 #include "rs_ellipse.h"
40 #include "rs_entitycontainer.h"
41 #include "rs_entity.h"
42 #include "rs_flags.h"
43 #include "rs_graphic.h"
44 #include "rs_image.h"
45 #include "rs_insert.h"
46 #include "rs_layer.h"
47 #include "rs_layerlist.h"
48 #include "rs_line.h"
49 #include "rs_pen.h"
50 #include "rs_point.h"
51 #include "rs_polyline.h"
52 #include "rs_vector.h"
53
54 /* Global root functions */
55 RS_Graphic* currentGraphic() { return RS_PYTHON->getGraphic(); }
56
57     /* more to be added later (access to global properties, all documents,
58        creation of new documents, ... */
59
60 /* To/From Python string conversion logic for string management */
61 namespace RS_String_Python_Conversions {
62     namespace {
63         struct RS_String_to_python_str
64         {
65             static PyObject* convert(RS_String const& s)
66             {
67                 return boost::python::incref(boost::python::object((const char*)s).ptr());
68             }
69         };
70
71         struct RS_String_from_python_str
72         {
73             RS_String_from_python_str()
74             {
75                 boost::python::converter::registry::push_back(
76                     &convertible,
77                     &construct,
78                     boost::python::type_id<RS_String>());
79             }
80
81             static void* convertible(PyObject* obj_ptr)
82             {
83                 if (!PyString_Check(obj_ptr)) return 0;
84                 return obj_ptr;
85             }
86
87             static void construct(
88                 PyObject* obj_ptr,
89                 boost::python::converter::rvalue_from_python_stage1_data* data)
90             {
91                 const char* value = PyString_AsString(obj_ptr);
92                 if (!value)
93                     boost::python::throw_error_already_set();
94                 void* storage = (
95                     (boost::python::converter::rvalue_from_python_storage<RS_String>*)
96                     data)->storage.bytes;
97                 new (storage) RS_String(value);
98                 data->convertible = storage;
99             }
100         };
101
102         void registerConversions()
103         {
104             using namespace boost::python;
105
106             boost::python::to_python_converter<
107                 RS_String, RS_String_to_python_str>();
108
109             RS_String_from_python_str();
110         }
111     }
112 }
113
114 /* Transfer of ownership is done by using auto pointers */
115 /* These are the helper functions needed for this mechanism */
116
117 #define TRANSFER_OWNERSHIP_FUNCTION(fname, container, addfunc, entity) \
118    void fname(container& cont, std::auto_ptr<entity> obj) \
119    { cont.addfunc(obj.get()); obj.release(); }
120
121 TRANSFER_OWNERSHIP_FUNCTION(RS_Graphic_addLayer, RS_Graphic, addLayer, RS_Layer)
122 TRANSFER_OWNERSHIP_FUNCTION(RS_LayerList_add, RS_LayerList, add, RS_Layer)
123
124 #define ADDVERTEX_FUNCTION(fname, entity) \
125    TRANSFER_OWNERSHIP_FUNCTION(fname, RS_EntityContainer, addEntity, entity)
126
127 ADDVERTEX_FUNCTION(RS_EntityContainer_addArc, RS_Arc)
128 ADDVERTEX_FUNCTION(RS_EntityContainer_addBlock, RS_Block)
129 ADDVERTEX_FUNCTION(RS_EntityContainer_addCircle, RS_Circle)
130 ADDVERTEX_FUNCTION(RS_EntityContainer_addConstructionLine, RS_ConstructionLine)
131 ADDVERTEX_FUNCTION(RS_EntityContainer_addEllipse, RS_Ellipse)
132 ADDVERTEX_FUNCTION(RS_EntityContainer_addImage, RS_Image)
133 ADDVERTEX_FUNCTION(RS_EntityContainer_addLine, RS_Line)
134 ADDVERTEX_FUNCTION(RS_EntityContainer_addPoint, RS_Point)
135 ADDVERTEX_FUNCTION(RS_EntityContainer_addPolyline, RS_Polyline)
136
137 /* Overloaded functions helpers */
138 void (RS_LayerList::*RS_LayerList_activate_string)(const RS_String&) = &RS_LayerList::activate;
139 void (RS_LayerList::*RS_LayerList_activate_layer)(RS_Layer*) = &RS_LayerList::activate;
140 void (RS_LayerList::*RS_LayerList_toggle_string)(const RS_String&) = &RS_LayerList::toggle;
141 void (RS_LayerList::*RS_LayerList_toggle_layer)(const RS_String&) = &RS_LayerList::toggle;
142 void (RS_Graphic::*RS_Graphic_toggleLayer_string)(const RS_String&) = &RS_Graphic::toggleLayer;
143 void (RS_Graphic::*RS_Graphic_toggleLayer_layer)(RS_Layer*) = &RS_Graphic::toggleLayer;
144 void (RS_Entity::*RS_Entity_setLayer_string)(const RS_String&) = &RS_Entity::setLayer;
145 void (RS_Entity::*RS_Entity_setLayer_layer)(RS_Layer*) = &RS_Entity::setLayer;
146
147 /**
148   * The main python module
149   */
150   
151 BOOST_PYTHON_MODULE(qcad)
152 {
153     /* Initialization code */
154     RS_String_Python_Conversions::registerConversions();
155     
156     /* Unbound functions */
157     
158     def("currentGraphic", currentGraphic, return_value_policy<reference_existing_object>());
159
160     /* Enums */
161     enum_<RS2::Flags>("Flag")
162         .value("Undone", RS2::FlagUndone)
163         .value("Visible", RS2::FlagVisible)
164         .value("ByLayer", RS2::FlagByLayer)
165         .value("ByBlock", RS2::FlagByBlock)
166         .value("Frozen", RS2::FlagFrozen)
167         .value("DefFrozen", RS2::FlagDefFrozen)
168         .value("Locked", RS2::FlagLocked)
169         .value("Invalid", RS2::FlagInvalid)
170         .value("Selected", RS2::FlagSelected)
171         .value("Closed", RS2::FlagClosed)
172         .value("Temp", RS2::FlagTemp)
173         .value("Processed", RS2::FlagProcessed)
174         .value("Selected1", RS2::FlagSelected1)
175         .value("Selected2", RS2::FlagSelected2)
176     ;
177
178     enum_<RS2::VariableType>("VariableType")
179         .value("String", RS2::VariableString)
180         .value("Int", RS2::VariableInt)
181         .value("Double", RS2::VariableDouble)
182         .value("Vector", RS2::VariableVector)
183         .value("Void", RS2::VariableVoid)
184     ;
185
186     enum_<RS2::EntityType>("EntityType")
187         .value("Unknown", RS2::EntityUnknown)
188         .value("Container", RS2::EntityContainer)
189         .value("Block", RS2::EntityBlock)
190         .value("FontChar", RS2::EntityFontChar)
191         .value("Insert", RS2::EntityInsert)
192         .value("Graphic", RS2::EntityGraphic)
193         .value("Point", RS2::EntityPoint)
194         .value("Line", RS2::EntityLine)
195         .value("Polyline", RS2::EntityPolyline)
196         .value("Vertex", RS2::EntityVertex)
197         .value("Arc", RS2::EntityArc)
198         .value("Circle", RS2::EntityCircle)
199         .value("Ellipse", RS2::EntityEllipse)
200         .value("Solid", RS2::EntitySolid)
201         .value("ConstructionLine", RS2::EntityConstructionLine)
202         .value("Text", RS2::EntityText)
203         .value("DimAligned", RS2::EntityDimAligned)
204         .value("DimLinear", RS2::EntityDimLinear)
205         .value("DimRadial", RS2::EntityDimRadial)
206         .value("DimDiametric", RS2::EntityDimDiametric)
207         .value("DimAngular", RS2::EntityDimAngular)
208         .value("DimLeader", RS2::EntityDimLeader)
209         .value("Hatch", RS2::EntityHatch)
210         .value("Image", RS2::EntityImage)
211     ;
212
213     enum_<RS2::LineType>("LineType")
214         .value("NoPen", RS2::NoPen)
215         .value("SolidLine", RS2::SolidLine)
216         .value("DotLine", RS2::DotLine)
217         .value("DotLine2", RS2::DotLine2)
218         .value("DotLineX2", RS2::DotLineX2)
219         .value("DashLine", RS2::DashLine)
220         .value("DashLine2", RS2::DashLine2)
221         .value("DashLineX2", RS2::DashLineX2)
222         .value("DashDotLine", RS2::DashDotLine)
223         .value("DashDotLine2", RS2::DashDotLine2)
224         .value("DashDotLineX2", RS2::DashDotLineX2)
225         .value("DivideLine", RS2::DivideLine)
226         .value("DivideLine2", RS2::DivideLine2)
227         .value("DivideLineX2", RS2::DivideLineX2)
228         .value("CenterLine", RS2::CenterLine)
229         .value("CenterLine2", RS2::CenterLine2)
230         .value("CenterLineX2", RS2::CenterLineX2)
231         .value("BorderLine", RS2::BorderLine)
232         .value("BorderLine2", RS2::BorderLine2)
233         .value("BorderLineX2", RS2::BorderLineX2)
234         .value("ByLayer", RS2::LineByLayer)
235         .value("ByBlock", RS2::LineByBlock)
236     ;
237
238     enum_<RS2::LineWidth>("LineWidth")
239         .value("Width00", RS2::Width00)
240         .value("Width01", RS2::Width01)
241         .value("Width02", RS2::Width02)
242         .value("Width03", RS2::Width03)
243         .value("Width04", RS2::Width04)
244         .value("Width05", RS2::Width05)
245         .value("Width06", RS2::Width06)
246         .value("Width07", RS2::Width07)
247         .value("Width08", RS2::Width08)
248         .value("Width09", RS2::Width09)
249         .value("Width10", RS2::Width10)
250         .value("Width11", RS2::Width11)
251         .value("Width12", RS2::Width12)
252         .value("Width13", RS2::Width13)
253         .value("Width14", RS2::Width14)
254         .value("Width15", RS2::Width15)
255         .value("Width16", RS2::Width16)
256         .value("Width17", RS2::Width17)
257         .value("Width18", RS2::Width18)
258         .value("Width19", RS2::Width19)
259         .value("Width20", RS2::Width20)
260         .value("Width21", RS2::Width21)
261         .value("Width22", RS2::Width22)
262         .value("Width23", RS2::Width23)
263         .value("ByLayer", RS2::WidthByLayer)
264         .value("ByBlock", RS2::WidthByBlock)
265         .value("Default", RS2::WidthDefault)
266     ;
267
268     /* "Small" classes */
269
270     class_<RS_Flags>("Flags")
271         .def(init<int>())
272         .add_property("flags", &RS_Flags::getFlags, &RS_Flags::setFlags)
273         .def("resetFlags", &RS_Flags::resetFlags)
274         .def("setFlag", &RS_Flags::setFlag)
275         .def("delFlag", &RS_Flags::delFlag)
276         .def("toggleFlag", &RS_Flags::toggleFlag)
277         .def("getFlag", &RS_Flags::getFlag)
278     ;
279
280     class_<RS_Color, bases<RS_Flags> >("Color")
281         .def(init<int, int, int>())
282         .def(init<int>())
283         .def("stripFlags", &RS_Color::stripFlags)
284         .add_property("byLayer", &RS_Color::isByLayer)
285         .add_property("byBlock", &RS_Color::isByBlock)
286     ;
287
288     class_<RS_Vector>("Vector")
289         .def(init<double, double, optional<double> >())
290         .def("set", &RS_Vector::set)
291         .def("setPolar", &RS_Vector::setPolar)
292         .def("distanceTo", &RS_Vector::distanceTo)
293         .def("angle", &RS_Vector::angle)
294         .def("angleTo", &RS_Vector::angleTo)
295         .def("magnitude", &RS_Vector::magnitude)
296         .def("move", &RS_Vector::move)
297         .def_readwrite("x", &RS_Vector::x)
298         .def_readwrite("y", &RS_Vector::y)
299         .def_readwrite("z", &RS_Vector::z)
300         .def_readwrite("valid", &RS_Vector::valid)
301     ;
302
303     class_<RS_Pen, bases<RS_Flags> >("Pen")
304         .def(init<const RS_Color&, RS2::LineWidth, RS2::LineType>())
305         .add_property("lineType", &RS_Pen::getLineType, &RS_Pen::setLineType)
306         .add_property("width", &RS_Pen::getWidth, &RS_Pen::setWidth)
307         .add_property("screenWidth", &RS_Pen::getScreenWidth, &RS_Pen::setScreenWidth)
308         .add_property("color", make_function(&RS_Pen::getColor, return_value_policy<reference_existing_object>()), &RS_Pen::setColor)
309         .add_property("valid", &RS_Pen::isValid)
310     ;
311
312     /* Common stuff */
313     
314     class_<RS_EntityContainer>("EntityContainer", init<RS_EntityContainer*, optional<bool> >())
315         /* Wrapper functions for ownership transfer */
316         .def("addEntity", RS_EntityContainer_addArc)
317         .def("addEntity", RS_EntityContainer_addBlock)
318         .def("addEntity", RS_EntityContainer_addCircle)
319         .def("addEntity", RS_EntityContainer_addConstructionLine)
320         .def("addEntity", RS_EntityContainer_addEllipse)
321         .def("addEntity", RS_EntityContainer_addImage)
322         .def("addEntity", RS_EntityContainer_addLine)
323         .def("addEntity", RS_EntityContainer_addPoint)
324         .def("addEntity", RS_EntityContainer_addPolyline)
325         
326         /** Owner-Containers will automatically delete entities upon removing,
327           * so no problem here. Other containers are not allowed in Python at the moment.
328           */
329         .def("removeEntity", &RS_EntityContainer::removeEntity)
330
331         /* Standard wrappers */
332         .def("clear", &RS_EntityContainer::clear)
333         .add_property("empty", &RS_EntityContainer::isEmpty)
334         .def("entityAt", &RS_EntityContainer::entityAt, return_value_policy<reference_existing_object>())
335
336         /* Iterators */
337         .def("firstEntity", &RS_EntityContainer::firstEntity, return_value_policy<reference_existing_object>())
338         .def("lastEntity", &RS_EntityContainer::lastEntity, return_value_policy<reference_existing_object>())
339         .def("nextEntity", &RS_EntityContainer::nextEntity, return_value_policy<reference_existing_object>())
340     ;
341
342     class_<RS_LayerData>("LayerData")
343         .def(init<const RS_String&, const RS_Pen&, bool>())
344         .def_readwrite("name", &RS_LayerData::name)
345         .def_readwrite("pen", &RS_LayerData::pen)
346         .def_readwrite("frozen", &RS_LayerData::frozen)
347     ;
348
349     class_<RS_Layer, std::auto_ptr<RS_Layer> >("Layer", init<const RS_String&>())
350         .add_property("name", &RS_Layer::getName, &RS_Layer::setName)
351         .add_property("pen", &RS_Layer::getPen, &RS_Layer::setPen)
352         .add_property("frozen", &RS_Layer::isFrozen, &RS_Layer::freeze)
353         .add_property("toggle", &RS_Layer::toggle)
354     ;
355
356     class_<RS_LayerList>("LayerList")
357         .def("clear", &RS_LayerList::clear)
358         .def("count", &RS_LayerList::count)
359         .def("at", &RS_LayerList::at, return_value_policy<reference_existing_object>())
360         .add_property("active", make_function(&RS_LayerList::getActive, return_value_policy<reference_existing_object>()),
361                                 RS_LayerList_activate_layer)
362         .def("activate", RS_LayerList_activate_string)
363         .def("activate", RS_LayerList_activate_layer)
364         .def("add", RS_LayerList_add)
365         .def("remove", &RS_LayerList::remove)
366         .def("edit", &RS_LayerList::edit)
367         .def("find", &RS_LayerList::find, return_value_policy<reference_existing_object>())
368         .def("toggle", RS_LayerList_toggle_string)
369         .def("toggle", RS_LayerList_toggle_layer)
370         .def("freezeAll", &RS_LayerList::freezeAll)
371     ;
372
373     class_<RS_Document, bases<RS_EntityContainer>, boost::noncopyable >("Document", no_init)
374         .add_property("layerList", make_function(&RS_Document::getLayerList, return_value_policy<reference_existing_object>()))
375         .add_property("blockList", make_function(&RS_Document::getBlockList, return_value_policy<reference_existing_object>()))
376         .def("newDoc", &RS_Document::newDoc)
377         .def("save", &RS_Document::save)
378         .def("saveAs", &RS_Document::saveAs)
379         .def("open", &RS_Document::open)
380         .add_property("modified", &RS_Document::isModified)
381         .add_property("activePen", &RS_Document::getActivePen, &RS_Document::setActivePen)
382         .add_property("filename", &RS_Document::getFilename)
383     ;
384     
385     class_<RS_Graphic, bases<RS_Document> >("Graphic", init<RS_EntityContainer*>())
386         .def("count", &RS_Graphic::count)
387         .def("findLayer", &RS_Graphic::findLayer, return_value_policy<reference_existing_object>())
388         .def("editLayer", &RS_Graphic::editLayer)
389         .def("addLayer", RS_Graphic_addLayer)
390         .def("removeLayer", &RS_Graphic::removeLayer)
391         .def("toggleLayer", RS_Graphic_toggleLayer_string)
392         .def("toggleLayer", RS_Graphic_toggleLayer_layer)
393         .def("clearLayers", &RS_Graphic::clearLayers)
394         .def("freezeAllLayers", &RS_Graphic::freezeAllLayers)
395     ;
396
397     /* Entity types */
398
399     class_<RS_Entity, boost::noncopyable>("Entity", no_init)
400         .def("init", &RS_Entity::init)
401         .def("initId", &RS_Entity::initId)
402         .def("clone", &RS_Entity::clone, return_value_policy<reference_existing_object>())
403         .def("reparent", &RS_Entity::reparent)
404         .def("resetBorders", &RS_Entity::resetBorders)
405         .add_property("id", &RS_Entity::getId)
406         .add_property("count", &RS_Entity::count)
407         .add_property("parent", make_function(&RS_Entity::getParent, return_value_policy<reference_existing_object>()), &RS_Entity::setParent)
408         .add_property("graphic", make_function(&RS_Entity::getGraphic, return_value_policy<reference_existing_object>()))
409         .add_property("block", make_function(&RS_Entity::getBlock, return_value_policy<reference_existing_object>()))
410         .add_property("insert", make_function(&RS_Entity::getInsert, return_value_policy<reference_existing_object>()))
411         .add_property("blockOrInsert", make_function(&RS_Entity::getBlockOrInsert, return_value_policy<reference_existing_object>()))
412         .add_property("document", make_function(&RS_Entity::getDocument, return_value_policy<reference_existing_object>()))
413         .add_property("layer", make_function(&RS_Entity::getLayer, return_value_policy<reference_existing_object>()),
414                       RS_Entity_setLayer_layer)
415         .def("setLayer", RS_Entity_setLayer_string)
416         .def("setLayer", RS_Entity_setLayer_layer)
417         .def("setLayerToActive", &RS_Entity::setLayerToActive)
418         .add_property("isContainer", &RS_Entity::isContainer)
419         .add_property("isAtomic", &RS_Entity::isAtomic)
420         .add_property("isEdge", &RS_Entity::isEdge)
421         .add_property("isDocument", &RS_Entity::isDocument)
422         .add_property("selected", &RS_Entity::isSelected, &RS_Entity::setSelected)
423         .def("toggleSelected", &RS_Entity::toggleSelected)
424         .add_property("processed", &RS_Entity::isProcessed, &RS_Entity::setProcessed)
425         .add_property("visible", &RS_Entity::isVisible, &RS_Entity::setVisible)
426         .add_property("min", &RS_Entity::getMin)
427         .add_property("max", &RS_Entity::getMax)
428         .add_property("size", &RS_Entity::getSize)
429         .def("move", &RS_Entity::move)
430         .def("rotate", &RS_Entity::rotate)
431         .def("calculateBorders", &RS_Entity::calculateBorders)
432     ;
433
434     class_<RS_AtomicEntity, bases<RS_Entity>, boost::noncopyable>("AtomicEntity", no_init)
435         .add_property("startpointSelected", &RS_AtomicEntity::isStartpointSelected)
436         .add_property("endpointSelected", &RS_AtomicEntity::isEndpointSelected)
437         .def("moveStartpoint", &RS_AtomicEntity::moveStartpoint)
438         .def("moveEndpoint", &RS_AtomicEntity::moveEndpoint)
439         .add_property("trimPoint", &RS_AtomicEntity::getTrimPoint)
440         .def("reverse", &RS_AtomicEntity::reverse)
441     ;
442
443     /* Entities Data */
444
445     class_<RS_ArcData>("ArcData")
446         .def(init<RS_Vector&, double, double, double, bool>())
447         .def("reset", &RS_ArcData::reset)
448         .add_property("valid", &RS_ArcData::isValid)
449         .def_readwrite("center", &RS_ArcData::center)
450         .def_readwrite("radius", &RS_ArcData::radius)
451         .def_readwrite("angle1", &RS_ArcData::angle1)
452         .def_readwrite("angle2", &RS_ArcData::angle2)
453         .def_readwrite("reversed", &RS_ArcData::reversed)
454     ;
455
456     class_<RS_BlockData>("BlockData")
457         .def(init<RS_String&, const RS_Vector&, bool>())
458         .add_property("valid", &RS_BlockData::isValid)
459         .def_readwrite("name", &RS_BlockData::name)
460         .def_readwrite("basePoint", &RS_BlockData::basePoint)
461         .def_readwrite("frozen", &RS_BlockData::frozen)
462     ;
463
464     class_<RS_CircleData>("CircleData")
465         .def(init<RS_Vector&, double>())
466         .def("reset", &RS_CircleData::reset)
467         .add_property("valid", &RS_CircleData::isValid)
468         .def_readwrite("center", &RS_CircleData::center)
469         .def_readwrite("radius", &RS_CircleData::radius)
470     ;
471
472     class_<RS_ConstructionLineData>("ConstructionLineData")
473         .def(init<RS_Vector&, RS_Vector&>())
474     ;
475
476     class_<RS_EllipseData>("EllipseData", init<const RS_Vector&, const RS_Vector&, double, double, double, bool>())
477     ;
478
479     class_<RS_ImageData>("ImageData")
480         .def(init<int, const RS_Vector&, const RS_Vector&, const RS_Vector&, const RS_Vector&, const RS_String&, int, int, int>())
481         .def_readwrite("handle", &RS_ImageData::handle)
482         .def_readwrite("insertionPoint", &RS_ImageData::insertionPoint)
483         .def_readwrite("uVector", &RS_ImageData::uVector)
484         .def_readwrite("vVector", &RS_ImageData::vVector)
485         .def_readwrite("size", &RS_ImageData::size)
486         .def_readwrite("file", &RS_ImageData::file)
487         .def_readwrite("brightness", &RS_ImageData::brightness)
488         .def_readwrite("contrast", &RS_ImageData::contrast)
489         .def_readwrite("fade", &RS_ImageData::fade)
490     ;
491
492     class_<RS_LineData>("LineData")
493         .def(init<RS_Vector&, RS_Vector&>())
494         .def_readwrite("startpoint", &RS_LineData::startpoint)
495         .def_readwrite("endpoint", &RS_LineData::endpoint)
496     ;
497
498     class_<RS_PointData>("PointData", init<const RS_Vector&>())
499     ;
500
501     class_<RS_PolylineData>("PolylineData")
502         .def(init<const RS_Vector&, const RS_Vector&, bool>())
503     ;
504
505     /* Entities */
506
507     class_<RS_Arc, bases<RS_AtomicEntity>, std::auto_ptr<RS_Arc> >("Arc", init<RS_EntityContainer*, RS_ArcData&>())
508         .add_property("data", &RS_Arc::getData, &RS_Arc::setData)
509         .add_property("center", &RS_Arc::getCenter, &RS_Arc::setCenter)
510         .add_property("radius", &RS_Arc::getRadius, &RS_Arc::setRadius)
511         .add_property("angle1", &RS_Arc::getAngle1, &RS_Arc::setAngle1)
512         .add_property("angle2", &RS_Arc::getAngle2, &RS_Arc::setAngle2)
513         .add_property("direction1", &RS_Arc::getDirection1)
514         .add_property("direction2", &RS_Arc::getDirection2)
515         .add_property("reversed", &RS_Arc::isReversed, &RS_Arc::setReversed)
516         .add_property("middlepoint", &RS_Arc::getMiddlepoint)
517         .add_property("angleLength", &RS_Arc::getAngleLength)
518         .add_property("length", &RS_Arc::getLength)
519         .add_property("bulge", &RS_Arc::getBulge)
520         .def("createFrom3P", &RS_Arc::createFrom3P)
521     ;
522
523     class_<RS_Block, bases<RS_Document>, std::auto_ptr<RS_Block> >("Block", init<RS_EntityContainer*, const RS_BlockData&>())
524         .add_property("name", &RS_Block::getName, &RS_Block::setName)
525         .add_property("basePoint", &RS_Block::getBasePoint)
526         .add_property("frozen", &RS_Block::isFrozen, &RS_Block::freeze)
527         .def("toggle", &RS_Block::toggle)
528     ;
529
530     class_<RS_Circle, bases<RS_AtomicEntity>, std::auto_ptr<RS_Circle> >("Circle", init<RS_EntityContainer*, const RS_CircleData&>())
531         .add_property("data", &RS_Circle::getData)
532         .add_property("center", &RS_Circle::getCenter, &RS_Circle::setCenter)
533         .add_property("radius", &RS_Circle::getRadius, &RS_Circle::setRadius)
534         .add_property("angleLength", &RS_Circle::getAngleLength)
535         .def("createFromCR", &RS_Circle::createFromCR)
536         .def("createFrom2P", &RS_Circle::createFrom2P)
537         .def("createFrom3P", &RS_Circle::createFrom3P)
538     ;
539
540     class_<RS_ConstructionLine, bases<RS_AtomicEntity>, std::auto_ptr<RS_ConstructionLine> >
541             ("ConstructionLine", init<RS_EntityContainer*, const RS_ConstructionLineData&>())
542         .add_property("data", &RS_ConstructionLine::getData)
543         .add_property("point1", &RS_ConstructionLine::getPoint1)
544         .add_property("point2", &RS_ConstructionLine::getPoint2)
545     ;
546
547     class_<RS_Ellipse, bases<RS_AtomicEntity>, std::auto_ptr<RS_Ellipse> >
548             ("Ellipse", init<RS_EntityContainer*, const RS_EllipseData&>())
549         .add_property("data", &RS_Ellipse::getData)
550         .add_property("reversed", &RS_Ellipse::isReversed, &RS_Ellipse::setReversed)
551         .add_property("angle", &RS_Ellipse::getAngle)
552         .add_property("angle1", &RS_Ellipse::getAngle1, &RS_Ellipse::setAngle1)
553         .add_property("angle2", &RS_Ellipse::getAngle2, &RS_Ellipse::setAngle2)
554         .add_property("center", &RS_Ellipse::getCenter, &RS_Ellipse::setCenter)
555         .add_property("majorP", &RS_Ellipse::getMajorP, &RS_Ellipse::setMajorP)
556         .add_property("ratio", &RS_Ellipse::getRatio, &RS_Ellipse::setRatio)
557         .add_property("majorRadius", &RS_Ellipse::getMajorRadius)
558         .add_property("minorRadius", &RS_Ellipse::getMinorRadius)
559     ;
560
561     class_<RS_Image, bases<RS_AtomicEntity>, std::auto_ptr<RS_Image> >
562             ("Image", init<RS_EntityContainer*, const RS_ImageData&>())
563         .add_property("data", &RS_Image::getData)
564         .add_property("insertionPoint", &RS_Image::getInsertionPoint, &RS_Image::setInsertionPoint)
565         .add_property("file", &RS_Image::getFile, &RS_Image::setFile)
566         .add_property("uVector", &RS_Image::getUVector)
567         .add_property("vVector", &RS_Image::getVVector)
568         .add_property("width", &RS_Image::getWidth)
569         .add_property("height", &RS_Image::getHeight)
570         .add_property("brightness", &RS_Image::getBrightness)
571         .add_property("contrast", &RS_Image::getContrast)
572         .add_property("fade", &RS_Image::getFade)
573         .add_property("handle", &RS_Image::getHandle, &RS_Image::setHandle)
574         .add_property("imageWidth", &RS_Image::getImageWidth)
575         .add_property("imageHeight", &RS_Image::getImageHeight)
576     ;
577
578     class_<RS_Line, bases<RS_AtomicEntity>, std::auto_ptr<RS_Line> >
579             ("Line", init<RS_EntityContainer*, const RS_LineData&>())
580         .add_property("data", &RS_Line::getData)
581         .add_property("startpoint", &RS_Line::getStartpoint, &RS_Line::setStartpoint)
582         .add_property("endpoint", &RS_Line::getEndpoint, &RS_Line::setEndpoint)
583     ;
584
585     class_<RS_Point, bases<RS_AtomicEntity>, std::auto_ptr<RS_Point> >
586             ("Point", init<RS_EntityContainer*, const RS_PointData&>())
587         .add_property("pos", &RS_Point::getPos, &RS_Point::setPos)
588     ;
589
590     class_<RS_Polyline, bases<RS_EntityContainer>, std::auto_ptr<RS_Polyline> >
591             ("Polyline", init<RS_EntityContainer*, const RS_PolylineData&>())
592         .def(init<RS_EntityContainer*>())
593         .add_property("startpoint", &RS_Polyline::getStartpoint, &RS_Polyline::setStartpoint)
594         .add_property("endpoint", &RS_Polyline::getEndpoint)
595         .add_property("closed", &RS_Polyline::isClosed)
596         .def("addVertex", &RS_Polyline::addVertex, return_value_policy<reference_existing_object>())
597         .def("createVertex", &RS_Polyline::createVertex, return_value_policy<reference_existing_object>())
598         .def("endPolyline", &RS_Polyline::endPolyline)
599     ;
600 }
601
602 #endif