Load saved muway and set to muways soft threshold.
[mussa.git] / qui / MussaWindow.cpp
index 883703fd3be49d8867128640dbad020699262bf5..80d855d438089c4ead1c6ccf595190c9e801c79f 100644 (file)
@@ -69,13 +69,15 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   manualAssistant(0)
 {
   init_resources();
+  
+  default_dir.reset(new QDir(QDir::home().absolutePath()));
+  
   setupWidgets();
   setupActions();
   setupAssistant();
   setupMainMenu();
   
   setWindowIcon(QIcon(":/icons/mussa.png"));
-  default_dir.reset(new QDir(QDir::home().absolutePath()));
 
   setCentralWidget(browser);
   // well updatePosition isn't quite right as we really just need
@@ -113,7 +115,18 @@ void MussaWindow::setAnalysis(MussaRef new_analysis)
   if (new_analysis != 0) {
     // only switch mussas if we loaded without error
     clear();
+    //std::cout << "analysis soft: " << analysis->get_soft_threshold()
+    //          << " new analysis soft: " << new_analysis->get_soft_threshold()
+    //          << "\n";
     analysis.swap(new_analysis);
+    //std::cout << "after swap soft thres: " << analysis->get_soft_threshold()
+    //          << "\n";
+    threshold->disconnect(this);
+    threshold->reset(analysis->get_threshold(),
+                     analysis->get_window(),
+                     analysis->get_soft_threshold());
+    connect(threshold, SIGNAL(thresholdChanged(int)),
+          this, SLOT(setSoftThreshold(int)));
     updateTitle();
     updateAnalysis();
   }
@@ -316,6 +329,9 @@ void MussaWindow::about()
   msg += "Version: ";
   msg += mussa_version;
   msg += "\n";
+  msg += "Qt: ";
+  msg += qVersion();
+  msg += "\n";
   msg += "OpenGL: ";
   msg += (char *)glGetString(GL_VERSION);
   msg += "\n";
@@ -324,6 +340,11 @@ void MussaWindow::about()
 
 void MussaWindow::clear()
 {
+  if (motif_editor != 0) {
+    motif_editor->hide();
+    delete motif_editor;
+  }
+  
   aligned_windows.clear();
   browser->clear();
 }
@@ -459,13 +480,11 @@ bool MussaWindow::isClearingAnalysisSafe()
 
 void MussaWindow::editMotifs()
 {
-  if (motif_editor != 0) {
-    motif_editor->hide();
-    delete motif_editor;
+  if (not motif_editor) {
+    motif_editor = new MotifEditor(analysis);
+    connect(motif_editor, SIGNAL(changedMotifs()), 
+            this, SLOT(updateAnnotations()));
   }
-  motif_editor = new MotifEditor(analysis);
-  connect(motif_editor, SIGNAL(changedMotifs()), 
-          this, SLOT(updateAnnotations()));
   motif_editor->show();
 }
 
@@ -623,14 +642,21 @@ void MussaWindow::newMussaWindow()
 
 void MussaWindow::setSoftThreshold(int value)
 {
+  //std::cout << "Soft: " << analysis->get_soft_threshold()
+  //          << " Value: " << value << "\n";
   if (analysis->get_soft_threshold() != value) {
     threshold->setEnabled( false );
+    //std::cout << "Updating!!!!\n";
     analysis->set_soft_threshold(value);
     analysis->nway();
     updateLinks();
     update();
     threshold->setEnabled( true );
   }
+  //else
+  //{
+  //  std::cout << "NOT Updating!!!!\n";
+  //}
 }
 
 void MussaWindow::showMussaToolbar()
@@ -725,6 +751,7 @@ void MussaWindow::updateAnalysis()
   // but it's possible for us to not have had a chance to set out sequences
   // yet.
   threshold->setRange(analysis->get_threshold(),analysis->get_window());
+  threshold->setBasepairThreshold(analysis->get_soft_threshold());
   updateLinks();
   browser->zoomOut();
   zoom->setValue(browser->zoom());