initialize the motif_editor with analysis motifs
authorDiane Trout <diane@caltech.edu>
Tue, 10 Oct 2006 23:22:35 +0000 (23:22 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 10 Oct 2006 23:22:35 +0000 (23:22 +0000)
ticket:139 the motif editor dialog wasn't actually looking at the
motifs stored in the analysis to initialize its model with. So
when one either closed the window or tried initializing from a file
the dialog wouldn't reflect what was actually on the screen.

qui/motif_editor/MotifEditor.cpp
qui/motif_editor/MotifEditor.hpp
qui/motif_editor/MotifModel.cpp
qui/motif_editor/MotifModel.hpp

index 93178d673faf069bfea426f025f3ca85c47c8436..ea10650ee84aea7cfdf68fcd55e78e81ef334e66 100644 (file)
@@ -21,7 +21,7 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent)
   vector<Sequence> motif_seq(motif.begin(), motif.end());
 
   applyButton->setFocusPolicy(Qt::StrongFocus);
-  connect(applyButton, SIGNAL(clicked()), this, SLOT(updateMotifs()));
+  connect(applyButton, SIGNAL(clicked()), this, SLOT(updateAnalysisMotifs()));
   button_layout->addStretch();
   button_layout->addWidget(applyButton);
   
@@ -37,10 +37,8 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent)
 
 void MotifEditor::updateModel()
 {
-  MotifModel *new_model = new MotifModel();
+  MotifModel *new_model = new MotifModel(analysis);
    
-  new_model->push_empty();
-
   // if there was an old model, delete it
   if (model) {
     delete model;
@@ -51,7 +49,7 @@ void MotifEditor::updateModel()
   updateView();
 }
 
-void MotifEditor::updateMotifs()
+void MotifEditor::updateAnalysisMotifs()
 {
   // This function is _sooo_ not thread safe
   // erase motifs
index e8055bb264b09ccccdac50e81666a1bdd07c6297..6efe8767b64b44856bf56b9fd70f6cc794b503f2 100644 (file)
@@ -27,8 +27,8 @@ public:
 public slots:
   //! create model and attach it to the table view  
   void updateModel();
-  //! called to apply motif changes
-  void updateMotifs();
+  //! called to apply motif changes to the analysis
+  void updateAnalysisMotifs();
 
 signals:
   //! emitted when the use has applied the motif changes
index 1bb05e471a3b1db5d62a48601986262eb7efda58..81bd954c5fc02a42cd2b4407c18761588a615976 100644 (file)
@@ -2,9 +2,25 @@
 
 #include <QColor>
 
-MotifModel::MotifModel(QObject *parent) 
+MotifModel::MotifModel(MussaRef m, QObject *parent) 
   : QAbstractTableModel(parent)
 {
+  const std::set<Sequence>& motif_set = m->motifs();
+  boost::shared_ptr<AnnotationColors> cm = m->colorMapper();
+  
+  if (motif_set.size() == 0) {
+    push_empty();
+  } else {
+    std::set<Sequence>::const_iterator motif_i;
+    for(motif_i = motif_set.begin();
+        motif_i != motif_set.end();
+        ++motif_i)
+    {
+      // ideally we'd know what the motif color was?
+      MotifElement new_element(*motif_i, cm->lookup("motif", motif_i->get_sequence()));
+      push_back(new_element);
+    }
+  }
 }
 
 void MotifModel::assign(
index 02ffe7cde176cca23e985f71396f86c0589d4c40..b077cdcb5d8de92dee7c1d25493b3afe5e6c5f60 100644 (file)
@@ -2,6 +2,7 @@
 #define _MOTIF_MODEL_HPP_
 
 #include "alg/sequence.hpp"
+#include "alg/mussa.hpp"
 #include "qui/motif_editor/MotifElement.hpp"
 #include "qui/motif_editor/MotifEditorDelegate.hpp"
 
@@ -14,7 +15,7 @@ class MotifModel : public QAbstractTableModel
   Q_OBJECT
 
   public:
-    MotifModel(QObject *parent = 0);
+    MotifModel(MussaRef m, QObject *parent = 0);
 
     typedef std::vector<MotifElement> model_type;
     typedef model_type::size_type size_type;