minimally wrap drawable
authorDiane Trout <diane@caltech.edu>
Fri, 7 Sep 2007 00:22:14 +0000 (00:22 +0000)
committerDiane Trout <diane@caltech.edu>
Fri, 7 Sep 2007 00:22:14 +0000 (00:22 +0000)
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
py/drawable.cpp [new file with mode: 0644]
py/module.cpp
py/seq_span.cpp
py/test/TestSeqSpan.py

index c47574269e1146e36ec338ca83fb522e9b345526..032a46447fa6a6cf9762a0b30e2de62309af1fa2 100644 (file)
@@ -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 (file)
index 0000000..1e926e4
--- /dev/null
@@ -0,0 +1,32 @@
+#include <boost/python.hpp>
+#include <boost/python/register_ptr_to_python.hpp>
+using namespace boost::python;
+
+#include "alg/drawable.hpp"
+
+
+void export_drawable()
+{
+  class_<Drawable>("Drawable")
+    .def(init<float, float, float, float, ColorRef>())
+         //optional<Drawable::draw_func_ptr> >())
+    .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 >();
+}
+
+  
+  
index cd98f04fc602770c0849bcd65e2e6d6615b56626..72ae38cdf655301a1603a222c3cfb4a2237646fd 100644 (file)
@@ -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();
index 74e6244b874ca5035355c6359ffef054cd996489..76f635cf540f2c6350bed60b899fee1522fc1ba5 100644 (file)
@@ -54,6 +54,7 @@ void export_seq_span()
     //                          return_value_policy<copy_const_reference>()))
     .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,
index 3a56d9264d57d84c942d5186f4ebcbea758f5854..5702c59d50e0871b37bf0a4e426b1710dfffc13d 100644 (file)
@@ -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')