provide a user interface to edit motifs
[mussa.git] / qui / MussaWindow.cpp
index c179b90b8b96d4d40911077552e8968041c73214..0dddbd8588cc8592826c27ec7605e7da8f89deb8 100644 (file)
@@ -20,6 +20,7 @@ using namespace std;
 MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) :
   QMainWindow(parent),
   analysis(analysis_),
+  motif_editor(0),
   browser(this),
   mussaViewTB("Path Views"),
   zoomBox(),
@@ -35,6 +36,9 @@ MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) :
   // opengl widget.
   //scene->setWhatsThis(tr("Mussa in OpenGL!"));
   setCentralWidget(&browser);
+  // well updatePosition isn't quite right as we really just need
+  // to call update()
+  connect(this, SIGNAL(changedAnnotations()), &browser, SLOT(update()));
 
   mussaViewTB.addAction(toggleMotifsAction);
   
@@ -91,6 +95,9 @@ void MussaWindow::setupActions()
   connect(createSubAnalysisAction, SIGNAL(triggered()), 
           this, SLOT(createSubAnalysis()));
 
+  editMotifsAction = new QAction(tr("Edit Motifs"), this);;
+  connect(editMotifsAction, SIGNAL(triggered()), this, SLOT(editMotifs()));
+  
   loadMotifListAction = new QAction(tr("Load Motif List"), this);
   connect(loadMotifListAction, SIGNAL(triggered()), 
           this, SLOT(loadMotifList()));
@@ -162,6 +169,7 @@ void MussaWindow::setupMainMenu()
   newMenu->addAction(closeAction);
 
   newMenu = menuBar()->addMenu(tr("&View"));
+  newMenu->addAction(editMotifsAction);
   newMenu->addAction(viewMussaAlignmentAction);
   newMenu->addAction(showMussaViewToolbarAction);
 
@@ -189,6 +197,17 @@ void MussaWindow::createSubAnalysis()
   NotImplementedBox();
 }
 
+void MussaWindow::editMotifs()
+{
+  if (motif_editor != 0) {
+    motif_editor->hide();
+    delete motif_editor;
+  }
+  motif_editor = new MotifEditor(analysis);
+  connect(motif_editor, SIGNAL(changedMotifs()), 
+          this, SLOT(updateAnnotations()));
+  motif_editor->show();
+}
 
 void MussaWindow::loadMotifList()
 {
@@ -313,7 +332,10 @@ void MussaWindow::viewMussaAlignment()
                          QObject::tr("you should probably select some paths "
                                      "first"));
   } else {
-    MussaAlignedWindow *ma_win = new MussaAlignedWindow(*analysis, selected_paths);
+    MussaAlignedWindow *ma_win = new MussaAlignedWindow(*analysis, 
+                                                        selected_paths);
+    connect(this, SIGNAL(changedAnnotations()), 
+            ma_win, SLOT(update()));
     aligned_windows.push_back(ma_win);
     ma_win->show();
   }
@@ -339,6 +361,14 @@ void MussaWindow::updateAnalysis()
   zoomBox.setValue(browser.zoom());
 }
 
+void MussaWindow::updateAnnotations()
+{
+  // motifs were changed in the sequences by 
+  // Mussa::update_sequences_motifs
+  emit changedAnnotations();
+  browser.update();
+}
+
 void MussaWindow::updateLinks()
 {
   browser.clear_links();