comparison 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
comparison
equal deleted inserted replaced
512:ed65126e503d 513:1341e95eeae9
50 m_editingPoint(0, 0.0, tr("New Point")), 50 m_editingPoint(0, 0.0, tr("New Point")),
51 m_editingCommand(0), 51 m_editingCommand(0),
52 m_colourMap(0), 52 m_colourMap(0),
53 m_plotStyle(PlotConnectedPoints), 53 m_plotStyle(PlotConnectedPoints),
54 m_verticalScale(AutoAlignScale), 54 m_verticalScale(AutoAlignScale),
55 m_drawSegmentDivisions(true),
55 m_scaleMinimum(0), 56 m_scaleMinimum(0),
56 m_scaleMaximum(0) 57 m_scaleMaximum(0)
57 { 58 {
58 59
59 } 60 }
86 { 87 {
87 PropertyList list = SingleColourLayer::getProperties(); 88 PropertyList list = SingleColourLayer::getProperties();
88 list.push_back("Plot Type"); 89 list.push_back("Plot Type");
89 list.push_back("Vertical Scale"); 90 list.push_back("Vertical Scale");
90 list.push_back("Scale Units"); 91 list.push_back("Scale Units");
92 list.push_back("Draw Segment Division Lines");
91 return list; 93 return list;
92 } 94 }
93 95
94 QString 96 QString
95 TimeValueLayer::getPropertyLabel(const PropertyName &name) const 97 TimeValueLayer::getPropertyLabel(const PropertyName &name) const
96 { 98 {
97 if (name == "Plot Type") return tr("Plot Type"); 99 if (name == "Plot Type") return tr("Plot Type");
98 if (name == "Vertical Scale") return tr("Vertical Scale"); 100 if (name == "Vertical Scale") return tr("Vertical Scale");
99 if (name == "Scale Units") return tr("Scale Units"); 101 if (name == "Scale Units") return tr("Scale Units");
102 if (name == "Draw Segment Division Lines") return tr("Draw Segment Division Lines");
100 return SingleColourLayer::getPropertyLabel(name); 103 return SingleColourLayer::getPropertyLabel(name);
101 } 104 }
102 105
103 Layer::PropertyType 106 Layer::PropertyType
104 TimeValueLayer::getPropertyType(const PropertyName &name) const 107 TimeValueLayer::getPropertyType(const PropertyName &name) const
105 { 108 {
106 if (name == "Plot Type") return ValueProperty; 109 if (name == "Plot Type") return ValueProperty;
107 if (name == "Vertical Scale") return ValueProperty; 110 if (name == "Vertical Scale") return ValueProperty;
108 if (name == "Scale Units") return UnitsProperty; 111 if (name == "Scale Units") return UnitsProperty;
109 if (name == "Colour" && m_plotStyle == PlotSegmentation) return ValueProperty; 112 if (name == "Colour" && m_plotStyle == PlotSegmentation) return ValueProperty;
113 if (name == "Draw Segment Division Lines") return ToggleProperty;
110 return SingleColourLayer::getPropertyType(name); 114 return SingleColourLayer::getPropertyType(name);
111 } 115 }
112 116
113 QString 117 QString
114 TimeValueLayer::getPropertyGroupName(const PropertyName &name) const 118 TimeValueLayer::getPropertyGroupName(const PropertyName &name) const
115 { 119 {
116 if (name == "Vertical Scale" || name == "Scale Units") { 120 if (name == "Vertical Scale" || name == "Scale Units") {
117 return tr("Scale"); 121 return tr("Scale");
122 }
123 if (name == "Plot Type" || name == "Draw Segment Division Lines") {
124 return tr("Plot Type");
118 } 125 }
119 return SingleColourLayer::getPropertyGroupName(name); 126 return SingleColourLayer::getPropertyGroupName(name);
120 } 127 }
121 128
122 int 129 int
154 if (deflt) *deflt = 0; 161 if (deflt) *deflt = 0;
155 if (m_model) { 162 if (m_model) {
156 val = UnitDatabase::getInstance()->getUnitId 163 val = UnitDatabase::getInstance()->getUnitId
157 (m_model->getScaleUnits()); 164 (m_model->getScaleUnits());
158 } 165 }
166
167 } else if (name == "Draw Segment Division Lines") {
168
169 if (min) *min = 0;
170 if (max) *max = 0;
171 if (deflt) *deflt = 1;
172 val = (m_drawSegmentDivisions ? 1.0 : 0.0);
159 173
160 } else { 174 } else {
161 175
162 val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); 176 val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt);
163 } 177 }
206 if (m_model) { 220 if (m_model) {
207 m_model->setScaleUnits 221 m_model->setScaleUnits
208 (UnitDatabase::getInstance()->getUnitById(value)); 222 (UnitDatabase::getInstance()->getUnitById(value));
209 emit modelChanged(); 223 emit modelChanged();
210 } 224 }
225 } else if (name == "Draw Segment Division Lines") {
226 setDrawSegmentDivisions(value > 0.5);
211 } else { 227 } else {
212 SingleColourLayer::setProperty(name, value); 228 SingleColourLayer::setProperty(name, value);
213 } 229 }
214 } 230 }
215 231
237 void 253 void
238 TimeValueLayer::setVerticalScale(VerticalScale scale) 254 TimeValueLayer::setVerticalScale(VerticalScale scale)
239 { 255 {
240 if (m_verticalScale == scale) return; 256 if (m_verticalScale == scale) return;
241 m_verticalScale = scale; 257 m_verticalScale = scale;
258 emit layerParametersChanged();
259 }
260
261 void
262 TimeValueLayer::setDrawSegmentDivisions(bool draw)
263 {
264 if (m_drawSegmentDivisions == draw) return;
265 m_drawSegmentDivisions = draw;
242 emit layerParametersChanged(); 266 emit layerParametersChanged();
243 } 267 }
244 268
245 bool 269 bool
246 TimeValueLayer::isLayerScrollable(const View *v) const 270 TimeValueLayer::isLayerScrollable(const View *v) const
884 908
885 // std::cerr << "drawing rect" << std::endl; 909 // std::cerr << "drawing rect" << std::endl;
886 910
887 if (nx <= x) continue; 911 if (nx <= x) continue;
888 912
889 if (illuminateFrame != p.frame && 913 if (illuminateFrame != p.frame) {
890 (nx < x + 5 || x >= v->width() - 1)) { 914 if (!m_drawSegmentDivisions ||
891 paint.setPen(Qt::NoPen); 915 nx < x + 5 ||
916 x >= v->width() - 1) {
917 paint.setPen(Qt::NoPen);
918 }
892 } 919 }
893 920
894 paint.drawRect(x, -1, nx - x, v->height() + 1); 921 paint.drawRect(x, -1, nx - x, v->height() + 1);
895 } 922 }
896 923
1621 TimeValueLayer::toXml(QTextStream &stream, 1648 TimeValueLayer::toXml(QTextStream &stream,
1622 QString indent, QString extraAttributes) const 1649 QString indent, QString extraAttributes) const
1623 { 1650 {
1624 SingleColourLayer::toXml(stream, indent, 1651 SingleColourLayer::toXml(stream, indent,
1625 extraAttributes + 1652 extraAttributes +
1626 QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\" scaleMinimum=\"%4\" scaleMaximum=\"%5\" ") 1653 QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\" scaleMinimum=\"%4\" scaleMaximum=\"%5\" drawDivisions=\"%6\" ")
1627 .arg(m_colourMap) 1654 .arg(m_colourMap)
1628 .arg(m_plotStyle) 1655 .arg(m_plotStyle)
1629 .arg(m_verticalScale) 1656 .arg(m_verticalScale)
1630 .arg(m_scaleMinimum) 1657 .arg(m_scaleMinimum)
1631 .arg(m_scaleMaximum)); 1658 .arg(m_scaleMaximum)
1659 .arg(m_drawSegmentDivisions ? "true" : "false"));
1632 } 1660 }
1633 1661
1634 void 1662 void
1635 TimeValueLayer::setProperties(const QXmlAttributes &attributes) 1663 TimeValueLayer::setProperties(const QXmlAttributes &attributes)
1636 { 1664 {
1647 1675
1648 VerticalScale scale = (VerticalScale) 1676 VerticalScale scale = (VerticalScale)
1649 attributes.value("verticalScale").toInt(&ok); 1677 attributes.value("verticalScale").toInt(&ok);
1650 if (ok) setVerticalScale(scale); 1678 if (ok) setVerticalScale(scale);
1651 1679
1680 bool draw = (attributes.value("drawDivisions").trimmed() == "true");
1681 setDrawSegmentDivisions(draw);
1682
1652 float min = attributes.value("scaleMinimum").toFloat(&ok); 1683 float min = attributes.value("scaleMinimum").toFloat(&ok);
1653 float max = attributes.value("scaleMaximum").toFloat(&alsoOk); 1684 float max = attributes.value("scaleMaximum").toFloat(&alsoOk);
1654 if (ok && alsoOk) setDisplayExtents(min, max); 1685 if (ok && alsoOk) setDisplayExtents(min, max);
1655 } 1686 }
1656 1687