Mouse scroll wheel zooming! =o)
[mussa.git] / qui / MussaWindow.cpp
index 39d25f9db598bf69223ac14f05eb3d15cd37d411..b0342e40c0e186ba7731a28367735985f424d12d 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
@@ -87,6 +89,10 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   connect(zoom, SIGNAL(valueChanged(double)), 
           browser, SLOT(setZoom(double)));
   mussaViewTB->addWidget(zoom);
+  
+  // Mouse Wheel triggered zooming
+  connect(browser, SIGNAL(mouseWheelZoom(double)),
+          zoom, SLOT(setValue(double)));
 
   // threshold range is set in updateAnalysis  
   connect(threshold, SIGNAL(thresholdChanged(int)),
@@ -113,7 +119,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();
   }
@@ -629,14 +646,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()
@@ -731,6 +755,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());