From 745bd381b0472a38a1e49bba52676c80eba52709 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Fri, 7 Sep 2007 00:22:14 +0000 Subject: [PATCH] minimally wrap drawable this probably isn't so useful without some way of handling draw_func_ptr's. Either creating them from python or at least selecting from some kind of list. --- py/CMakeLists.txt | 1 + py/drawable.cpp | 32 ++++++++++++++++++++++++++++++++ py/module.cpp | 2 ++ py/seq_span.cpp | 1 + py/test/TestSeqSpan.py | 10 ++++++++++ 5 files changed, 46 insertions(+) create mode 100644 py/drawable.cpp diff --git a/py/CMakeLists.txt b/py/CMakeLists.txt index c475742..032a464 100644 --- a/py/CMakeLists.txt +++ b/py/CMakeLists.txt @@ -16,6 +16,7 @@ IF(BOOST_PYTHON_LIBRARY) annotation_colors.cpp annotations.cpp conserved_path.cpp + drawable.cpp flp.cpp glsequence.cpp module.cpp diff --git a/py/drawable.cpp b/py/drawable.cpp new file mode 100644 index 0000000..1e926e4 --- /dev/null +++ b/py/drawable.cpp @@ -0,0 +1,32 @@ +#include +#include +using namespace boost::python; + +#include "alg/drawable.hpp" + + +void export_drawable() +{ + class_("Drawable") + .def(init()) + //optional >()) + .add_property("x", &Drawable::x, &Drawable::setX, + "starting x (horizontal) coordinate") + .add_property("y", &Drawable::y, &Drawable::setY, + "starting y (vertical) coordinate") + .add_property("z", &Drawable::z, &Drawable::setZ, + "starting z (depth into/out of screen) coordinate") + .add_property("h", &Drawable::height, &Drawable::setHeight, + "how 'tall' our rectangle should be") + .add_property("color", &Drawable::color, &Drawable::setColor, + "color for this object") + + //void setDrawFunction(draw_func_ptr d) { draw_func = d; } + //draw_func_ptr drawFunction() const { return draw_func; } + ; + + register_ptr_to_python< DrawableRef >(); +} + + + diff --git a/py/module.cpp b/py/module.cpp index cd98f04..72ae38c 100644 --- a/py/module.cpp +++ b/py/module.cpp @@ -7,6 +7,7 @@ void export_annotation_colors(); void export_annotations(); void export_container_exceptions(); void export_conserved_path(); +void export_drawable(); void export_flps(); void export_glsequence(); void export_mussa(); @@ -23,6 +24,7 @@ BOOST_PYTHON_MODULE(mussa) export_annotation_colors(); export_annotations(); export_conserved_path(); + export_drawable(); export_flps(); export_seq_span(); export_sequence(); diff --git a/py/seq_span.cpp b/py/seq_span.cpp index 74e6244..76f635c 100644 --- a/py/seq_span.cpp +++ b/py/seq_span.cpp @@ -54,6 +54,7 @@ void export_seq_span() // return_value_policy())) .add_property("annotations", &SeqSpan::annotations, &SeqSpan::setAnnotations) + .add_property("drawable", &SeqSpan::drawable, &SeqSpan::setDrawable) .add_property("start", &SeqSpan::start, &SeqSpan::setStart, "start position relative to root sequence") .add_property("stop", &SeqSpan::stop, &SeqSpan::setStop, diff --git a/py/test/TestSeqSpan.py b/py/test/TestSeqSpan.py index 3a56d92..5702c59 100644 --- a/py/test/TestSeqSpan.py +++ b/py/test/TestSeqSpan.py @@ -55,6 +55,16 @@ class TestSeqSpan(unittest.TestCase): s.annotations[term_key] = term self.failUnlessEqual(s.annotations[term_key], term) + def testDrawable(self): + # ok this is a boring test... + seq_text = "AAAAAG" + s = mussa.SeqSpan(seq_text) + d = mussa.Drawable() + s.drawable = d + + self.failUnless(s.drawable is d) + + def suite(): return unittest.makeSuite(TestSeqSpan, 'test') -- 2.30.2