fix problems instantiating mussa.GlSequence
authorDiane Trout <diane@caltech.edu>
Thu, 27 Jul 2006 00:33:30 +0000 (00:33 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 27 Jul 2006 00:33:30 +0000 (00:33 +0000)
with the switch to shared_ptr in the C++ code the original boost::python
GlSequence was wrong--it needed to be updated from references to shared_ptrs
and boost::python needed to be told that it's ok to have shared_ptrs to
Sequence and AnnotationColors.

And I also needed to tell boost::python about AnnotationColors, not that
I defined enough of a wrapper to use it.

py/CMakeLists.txt
py/annotation_colors.cpp [new file with mode: 0644]
py/glsequence.cpp
py/module.cpp
py/sequence.cpp

index 02ad969bb6669fa8cb4bea4ad9b19457feed69b2..58a3f600d8eaebe934a9f353bcbbc757c13d03c3 100644 (file)
@@ -12,6 +12,7 @@ INCLUDE( ${QT_USE_FILE} )
 IF(BOOST_PYTHON_LIBRARY)
   INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${QT_INCLUDES})
   SET(SOURCES 
+        annotation_colors.cpp
         conserved_path.cpp 
         glsequence.cpp
         module.cpp 
diff --git a/py/annotation_colors.cpp b/py/annotation_colors.cpp
new file mode 100644 (file)
index 0000000..259e809
--- /dev/null
@@ -0,0 +1,19 @@
+#include <boost/python.hpp>
+#include <boost/python/register_ptr_to_python.hpp>
+using namespace boost::python;
+
+#include <boost/shared_ptr.hpp>
+
+#include "alg/annotation_colors.hpp"
+
+void export_annotation_colors()
+{
+  class_<AnnotationColors>("AnnotationColors")
+    .def("clear", &AnnotationColors::clear)
+    .add_property("color", &AnnotationColors::color,
+                           &AnnotationColors::setColor,
+                           "access default color for this color mapper")
+  ;
+
+  register_ptr_to_python< boost::shared_ptr<AnnotationColors> >();
+}
index 811e0dce7245770ae57c2c1e495aab43f9e5056c..f40efa31297564b74363608bf8e63f45c2d07a64 100644 (file)
@@ -1,5 +1,6 @@
 #include <boost/python.hpp>
 using namespace boost::python;
+#include <boost/shared_ptr.hpp>
 
 #include "alg/annotation_colors.hpp"
 #include "alg/glsequence.hpp"
@@ -7,8 +8,11 @@ using namespace boost::python;
 
 void export_glsequence()
 {
-  /*
-  class_<GlSequence>("GlSequence", init<Sequence &, AnnotationColors &>())
+  class_<GlSequence>("GlSequence", 
+      init<
+        boost::shared_ptr<Sequence>, 
+        boost::shared_ptr<AnnotationColors> 
+      >())
     .def(init<GlSequence &>())
     .def("draw", &GlSequence::draw)
     .def("sequence", &GlSequence::sequence, 
@@ -17,5 +21,4 @@ void export_glsequence()
     .add_property("y", &GlSequence::y, &GlSequence::setY)
     .add_property("length", &GlSequence::length)
   ;
-  */
 }
index 448b523b89db0f516480495c20c2d9e97c37fa42..632b117fd5f5498f7832dbd14f57942aaf2fb476 100644 (file)
@@ -1,6 +1,7 @@
 #include <boost/python.hpp>
 using namespace boost::python;
 
+void export_annotation_colors();
 void export_conserved_path();
 void export_glsequence();
 void export_mussa();
@@ -10,6 +11,7 @@ void export_mussa_window();
 
 BOOST_PYTHON_MODULE(mussa)
 {
+  export_annotation_colors();
   export_conserved_path();
   export_glsequence();
   export_mussa();
index 695a8eae2e55111e2c55a9fe3f37c20157082008..2bb10ab6546a772c2ceb0f179f2c9aaee47a1ced 100644 (file)
@@ -3,8 +3,11 @@
 #include <boost/python/return_internal_reference.hpp>
 #include <boost/python/return_by_value.hpp>
 #include <boost/python/return_value_policy.hpp>
+#include <boost/python/register_ptr_to_python.hpp>
 using namespace boost::python;
 
+#include <boost/shared_ptr.hpp>
+
 #include <string>
 #include "alg/glsequence.hpp"
 
@@ -23,4 +26,6 @@ void export_sequence()
     .add_property("species", &Sequence::get_species, &Sequence::set_species)
     .def("rcseq", &Sequence::rev_comp, return_value_policy<return_by_value>())
   ;
+
+  register_ptr_to_python< boost::shared_ptr<Sequence> >();
 }