From: Diane Trout Date: Tue, 10 Oct 2006 23:22:35 +0000 (+0000) Subject: initialize the motif_editor with analysis motifs X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=commitdiff_plain;h=9526360687d8a092ad5583d8c7de789b5bf0ba9b initialize the motif_editor with analysis motifs 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. --- diff --git a/qui/motif_editor/MotifEditor.cpp b/qui/motif_editor/MotifEditor.cpp index 93178d6..ea10650 100644 --- a/qui/motif_editor/MotifEditor.cpp +++ b/qui/motif_editor/MotifEditor.cpp @@ -21,7 +21,7 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent) vector 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 diff --git a/qui/motif_editor/MotifEditor.hpp b/qui/motif_editor/MotifEditor.hpp index e8055bb..6efe876 100644 --- a/qui/motif_editor/MotifEditor.hpp +++ b/qui/motif_editor/MotifEditor.hpp @@ -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 diff --git a/qui/motif_editor/MotifModel.cpp b/qui/motif_editor/MotifModel.cpp index 1bb05e4..81bd954 100644 --- a/qui/motif_editor/MotifModel.cpp +++ b/qui/motif_editor/MotifModel.cpp @@ -2,9 +2,25 @@ #include -MotifModel::MotifModel(QObject *parent) +MotifModel::MotifModel(MussaRef m, QObject *parent) : QAbstractTableModel(parent) { + const std::set& motif_set = m->motifs(); + boost::shared_ptr cm = m->colorMapper(); + + if (motif_set.size() == 0) { + push_empty(); + } else { + std::set::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( diff --git a/qui/motif_editor/MotifModel.hpp b/qui/motif_editor/MotifModel.hpp index 02ffe7c..b077cdc 100644 --- a/qui/motif_editor/MotifModel.hpp +++ b/qui/motif_editor/MotifModel.hpp @@ -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 model_type; typedef model_type::size_type size_type;