diff layer/TimeValueLayer.cpp @ 513:1341e95eeae9

* Make drawing segment divisions optional in segmentation plot style of time value layer * Don't follow playback when Alt is held down (complements use of Alt as peek modifier)
author Chris Cannam
date Thu, 26 Feb 2009 16:58:25 +0000
parents b3140e9e0665
children ff1dc4f302bd
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Thu Feb 26 14:05:13 2009 +0000
+++ b/layer/TimeValueLayer.cpp	Thu Feb 26 16:58:25 2009 +0000
@@ -52,6 +52,7 @@
     m_colourMap(0),
     m_plotStyle(PlotConnectedPoints),
     m_verticalScale(AutoAlignScale),
+    m_drawSegmentDivisions(true),
     m_scaleMinimum(0),
     m_scaleMaximum(0)
 {
@@ -88,6 +89,7 @@
     list.push_back("Plot Type");
     list.push_back("Vertical Scale");
     list.push_back("Scale Units");
+    list.push_back("Draw Segment Division Lines");
     return list;
 }
 
@@ -97,6 +99,7 @@
     if (name == "Plot Type") return tr("Plot Type");
     if (name == "Vertical Scale") return tr("Vertical Scale");
     if (name == "Scale Units") return tr("Scale Units");
+    if (name == "Draw Segment Division Lines") return tr("Draw Segment Division Lines");
     return SingleColourLayer::getPropertyLabel(name);
 }
 
@@ -107,6 +110,7 @@
     if (name == "Vertical Scale") return ValueProperty;
     if (name == "Scale Units") return UnitsProperty;
     if (name == "Colour" && m_plotStyle == PlotSegmentation) return ValueProperty;
+    if (name == "Draw Segment Division Lines") return ToggleProperty;
     return SingleColourLayer::getPropertyType(name);
 }
 
@@ -116,6 +120,9 @@
     if (name == "Vertical Scale" || name == "Scale Units") {
         return tr("Scale");
     }
+    if (name == "Plot Type" || name == "Draw Segment Division Lines") {
+        return tr("Plot Type");
+    }
     return SingleColourLayer::getPropertyGroupName(name);
 }
 
@@ -157,6 +164,13 @@
                 (m_model->getScaleUnits());
         }
 
+    } else if (name == "Draw Segment Division Lines") {
+
+        if (min) *min = 0;
+        if (max) *max = 0;
+        if (deflt) *deflt = 1;
+        val = (m_drawSegmentDivisions ? 1.0 : 0.0);
+
     } else {
 	
 	val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt);
@@ -208,6 +222,8 @@
                 (UnitDatabase::getInstance()->getUnitById(value));
             emit modelChanged();
         }
+    } else if (name == "Draw Segment Division Lines") {
+        setDrawSegmentDivisions(value > 0.5);
     } else {
         SingleColourLayer::setProperty(name, value);
     }
@@ -242,6 +258,14 @@
     emit layerParametersChanged();
 }
 
+void
+TimeValueLayer::setDrawSegmentDivisions(bool draw)
+{
+    if (m_drawSegmentDivisions == draw) return;
+    m_drawSegmentDivisions = draw;
+    emit layerParametersChanged();
+}
+
 bool
 TimeValueLayer::isLayerScrollable(const View *v) const
 {
@@ -886,9 +910,12 @@
 	    
 	    if (nx <= x) continue;
 
-	    if (illuminateFrame != p.frame &&
-		(nx < x + 5 || x >= v->width() - 1)) {
-		paint.setPen(Qt::NoPen);
+            if (illuminateFrame != p.frame) {
+                if (!m_drawSegmentDivisions ||
+                    nx < x + 5 ||
+                    x >= v->width() - 1) {
+                    paint.setPen(Qt::NoPen);
+                }
 	    }
 
 	    paint.drawRect(x, -1, nx - x, v->height() + 1);
@@ -1623,12 +1650,13 @@
 {
     SingleColourLayer::toXml(stream, indent,
                              extraAttributes +
-                             QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\" scaleMinimum=\"%4\" scaleMaximum=\"%5\" ")
+                             QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\" scaleMinimum=\"%4\" scaleMaximum=\"%5\" drawDivisions=\"%6\" ")
                              .arg(m_colourMap)
                              .arg(m_plotStyle)
                              .arg(m_verticalScale)
                              .arg(m_scaleMinimum)
-                             .arg(m_scaleMaximum));
+                             .arg(m_scaleMaximum)
+                             .arg(m_drawSegmentDivisions ? "true" : "false"));
 }
 
 void
@@ -1649,6 +1677,9 @@
 	attributes.value("verticalScale").toInt(&ok);
     if (ok) setVerticalScale(scale);
 
+    bool draw = (attributes.value("drawDivisions").trimmed() == "true");
+    setDrawSegmentDivisions(draw);
+
     float min = attributes.value("scaleMinimum").toFloat(&ok);
     float max = attributes.value("scaleMaximum").toFloat(&alsoOk);
     if (ok && alsoOk) setDisplayExtents(min, max);