diff widgets/Pane.cpp @ 77:fd348f36c0d3

* Implement harmonic cursor in spectrogram * Implement layer export. This doesn't quite do the right thing for the SV XML layer export yet -- it doesn't include layer display information, so when imported, it only creates an invisible model. Could also do with fixing CSV file import so as to work correctly for note and text layers.
author Chris Cannam
date Mon, 10 Apr 2006 17:22:59 +0000
parents bf306158803d
children 82482231b6b1
line wrap: on
line diff
--- a/widgets/Pane.cpp	Fri Apr 07 17:50:33 2006 +0000
+++ b/widgets/Pane.cpp	Mon Apr 10 17:22:59 2006 +0000
@@ -144,90 +144,103 @@
     int fontHeight = paint.fontMetrics().height();
     int fontAscent = paint.fontMetrics().ascent();
 
-    if (m_manager &&
-        m_manager->getOverlayMode() != ViewManager::NoOverlays) {
+    for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
+        --vi;
+            
+        if (dynamic_cast<WaveformLayer *>(*vi)) {
+            waveformModel = (*vi)->getModel();
+        }
 
-        for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
-            --vi;
+        if (m_manager &&
+            !m_manager->isPlaying() &&
+            m_manager->getToolMode() == ViewManager::SelectMode) {
 
-            if (dynamic_cast<WaveformLayer *>(*vi)) {
-                waveformModel = (*vi)->getModel();
+            std::vector<QRect> crosshairExtents;
+
+            if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
+                                           crosshairExtents)) {
+                (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
             }
+        }
 
-            verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
+        if (!m_manager ||
+            m_manager->getOverlayMode() == ViewManager::NoOverlays) {
+            break;
+        }
 
-            if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
+        verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
+
+        if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
 
 //	    Profiler profiler("Pane::paintEvent - painting vertical scale", true);
 
 //	    std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl;
+            paint.save();
+            
+            paint.setPen(Qt::black);
+            paint.setBrush(Qt::white);
+            paint.drawRect(0, -1, verticalScaleWidth, height()+1);
+            
+            paint.setBrush(Qt::NoBrush);
+            (*vi)->paintVerticalScale
+                (this, paint, QRect(0, 0, verticalScaleWidth, height()));
+            
+            paint.restore();
+        }
+	
+        if (m_identifyFeatures) {
+            
+            QPoint pos = m_identifyPoint;
+            QString desc = (*vi)->getFeatureDescription(this, pos);
+	    
+            if (desc != "") {
+                
                 paint.save();
+                
+                int tabStop =
+                    paint.fontMetrics().width(tr("Some lengthy prefix:"));
+                
+                QRect boundingRect = 
+                    paint.fontMetrics().boundingRect
+                    (rect(),
+                     Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
+                     desc, tabStop);
 
-                paint.setPen(Qt::black);
-                paint.setBrush(Qt::white);
-                paint.drawRect(0, -1, verticalScaleWidth, height()+1);
+                if (hasLightBackground()) {
+                    paint.setPen(Qt::NoPen);
+                    paint.setBrush(QColor(250, 250, 250, 200));
+                } else {
+                    paint.setPen(Qt::NoPen);
+                    paint.setBrush(QColor(50, 50, 50, 200));
+                }
 
-                paint.setBrush(Qt::NoBrush);
-                (*vi)->paintVerticalScale
-                    (this, paint, QRect(0, 0, verticalScaleWidth, height()));
+                int extra = paint.fontMetrics().descent();
+                paint.drawRect(width() - boundingRect.width() - 10 - extra,
+                               10 - extra,
+                               boundingRect.width() + 2 * extra,
+                               boundingRect.height() + extra);
+
+                if (hasLightBackground()) {
+                    paint.setPen(QColor(150, 20, 0));
+                } else {
+                    paint.setPen(QColor(255, 150, 100));
+                }
+		
+                QTextOption option;
+                option.setWrapMode(QTextOption::NoWrap);
+                option.setAlignment(Qt::AlignRight | Qt::AlignTop);
+                option.setTabStop(tabStop);
+                paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
+                                      boundingRect.width(),
+                                      boundingRect.height()),
+                               desc,
+                               option);
 
                 paint.restore();
             }
-	
-            if (m_identifyFeatures) {
+        }
 
-                QPoint pos = m_identifyPoint;
-                QString desc = (*vi)->getFeatureDescription(this, pos);
-	    
-                if (desc != "") {
-
-                    paint.save();
-
-                    int tabStop =
-                        paint.fontMetrics().width(tr("Some lengthy prefix:"));
-
-                    QRect boundingRect = 
-                        paint.fontMetrics().boundingRect
-                        (rect(),
-                         Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
-                         desc, tabStop);
-
-                    if (hasLightBackground()) {
-                        paint.setPen(Qt::NoPen);
-                        paint.setBrush(QColor(250, 250, 250, 200));
-                    } else {
-                        paint.setPen(Qt::NoPen);
-                        paint.setBrush(QColor(50, 50, 50, 200));
-                    }
-
-                    int extra = paint.fontMetrics().descent();
-                    paint.drawRect(width() - boundingRect.width() - 10 - extra,
-                                   10 - extra,
-                                   boundingRect.width() + 2 * extra,
-                                   boundingRect.height() + extra);
-
-                    if (hasLightBackground()) {
-                        paint.setPen(QColor(150, 20, 0));
-                    } else {
-                        paint.setPen(QColor(255, 150, 100));
-                    }
-		
-                    QTextOption option;
-                    option.setWrapMode(QTextOption::NoWrap);
-                    option.setAlignment(Qt::AlignRight | Qt::AlignTop);
-                    option.setTabStop(tabStop);
-                    paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
-                                          boundingRect.width(),
-                                          boundingRect.height()),
-                                   desc,
-                                   option);
-
-                    paint.restore();
-                }
-            }
-
-            break;
-        }
+        break;
     }
     
     int sampleRate = getModelsSampleRate();