comparison layer/RegionLayer.cpp @ 412:d332ad1ca66b

* Add segmentation plot type to region layer (plotting not implemented yet)
author Chris Cannam
date Fri, 19 Sep 2008 12:55:35 +0000
parents 96e4d7b9e165
children f71752646f97
comparison
equal deleted inserted replaced
411:96e4d7b9e165 412:d332ad1ca66b
42 m_model(0), 42 m_model(0),
43 m_editing(false), 43 m_editing(false),
44 m_originalPoint(0, 0.0, 0, tr("New Point")), 44 m_originalPoint(0, 0.0, 0, tr("New Point")),
45 m_editingPoint(0, 0.0, 0, tr("New Point")), 45 m_editingPoint(0, 0.0, 0, tr("New Point")),
46 m_editingCommand(0), 46 m_editingCommand(0),
47 m_verticalScale(AutoAlignScale) 47 m_verticalScale(AutoAlignScale),
48 m_plotStyle(PlotLines)
48 { 49 {
49 50
50 } 51 }
51 52
52 void 53 void
66 RegionLayer::getProperties() const 67 RegionLayer::getProperties() const
67 { 68 {
68 PropertyList list = SingleColourLayer::getProperties(); 69 PropertyList list = SingleColourLayer::getProperties();
69 list.push_back("Vertical Scale"); 70 list.push_back("Vertical Scale");
70 list.push_back("Scale Units"); 71 list.push_back("Scale Units");
72 list.push_back("Plot Type");
71 return list; 73 return list;
72 } 74 }
73 75
74 QString 76 QString
75 RegionLayer::getPropertyLabel(const PropertyName &name) const 77 RegionLayer::getPropertyLabel(const PropertyName &name) const
76 { 78 {
77 if (name == "Vertical Scale") return tr("Vertical Scale"); 79 if (name == "Vertical Scale") return tr("Vertical Scale");
78 if (name == "Scale Units") return tr("Scale Units"); 80 if (name == "Scale Units") return tr("Scale Units");
81 if (name == "Plot Type") return tr("Plot Type");
79 return SingleColourLayer::getPropertyLabel(name); 82 return SingleColourLayer::getPropertyLabel(name);
80 } 83 }
81 84
82 Layer::PropertyType 85 Layer::PropertyType
83 RegionLayer::getPropertyType(const PropertyName &name) const 86 RegionLayer::getPropertyType(const PropertyName &name) const
84 { 87 {
85 if (name == "Scale Units") return UnitsProperty; 88 if (name == "Scale Units") return UnitsProperty;
86 if (name == "Vertical Scale") return ValueProperty; 89 if (name == "Vertical Scale") return ValueProperty;
90 if (name == "Plot Type") return ValueProperty;
87 return SingleColourLayer::getPropertyType(name); 91 return SingleColourLayer::getPropertyType(name);
88 } 92 }
89 93
90 QString 94 QString
91 RegionLayer::getPropertyGroupName(const PropertyName &name) const 95 RegionLayer::getPropertyGroupName(const PropertyName &name) const
100 RegionLayer::getPropertyRangeAndValue(const PropertyName &name, 104 RegionLayer::getPropertyRangeAndValue(const PropertyName &name,
101 int *min, int *max, int *deflt) const 105 int *min, int *max, int *deflt) const
102 { 106 {
103 int val = 0; 107 int val = 0;
104 108
105 if (name == "Vertical Scale") { 109 if (name == "Plot Type") {
110
111 if (min) *min = 0;
112 if (max) *max = 1;
113 if (deflt) *deflt = 0;
114
115 val = int(m_plotStyle);
116
117 } else if (name == "Vertical Scale") {
106 118
107 if (min) *min = 0; 119 if (min) *min = 0;
108 if (max) *max = 3; 120 if (max) *max = 3;
109 if (deflt) *deflt = int(AutoAlignScale); 121 if (deflt) *deflt = int(AutoAlignScale);
110 122
128 140
129 QString 141 QString
130 RegionLayer::getPropertyValueLabel(const PropertyName &name, 142 RegionLayer::getPropertyValueLabel(const PropertyName &name,
131 int value) const 143 int value) const
132 { 144 {
133 if (name == "Vertical Scale") { 145 if (name == "Plot Type") {
146
147 switch (value) {
148 default:
149 case 0: return tr("Lines");
150 case 1: return tr("Segmentation");
151 }
152
153 } else if (name == "Vertical Scale") {
134 switch (value) { 154 switch (value) {
135 default: 155 default:
136 case 0: return tr("Auto-Align"); 156 case 0: return tr("Auto-Align");
137 case 1: return tr("Linear"); 157 case 1: return tr("Linear");
138 case 2: return tr("Log"); 158 case 2: return tr("Log");
142 } 162 }
143 163
144 void 164 void
145 RegionLayer::setProperty(const PropertyName &name, int value) 165 RegionLayer::setProperty(const PropertyName &name, int value)
146 { 166 {
147 if (name == "Vertical Scale") { 167 if (name == "Plot Type") {
168 setPlotStyle(PlotStyle(value));
169 } else if (name == "Vertical Scale") {
148 setVerticalScale(VerticalScale(value)); 170 setVerticalScale(VerticalScale(value));
149 } else if (name == "Scale Units") { 171 } else if (name == "Scale Units") {
150 if (m_model) { 172 if (m_model) {
151 m_model->setScaleUnits 173 m_model->setScaleUnits
152 (UnitDatabase::getInstance()->getUnitById(value)); 174 (UnitDatabase::getInstance()->getUnitById(value));
153 emit modelChanged(); 175 emit modelChanged();
154 } 176 }
155 } else { 177 } else {
156 return SingleColourLayer::setProperty(name, value); 178 return SingleColourLayer::setProperty(name, value);
157 } 179 }
180 }
181
182 void
183 RegionLayer::setPlotStyle(PlotStyle style)
184 {
185 if (m_plotStyle == style) return;
186 m_plotStyle = style;
187 emit layerParametersChanged();
158 } 188 }
159 189
160 void 190 void
161 RegionLayer::setVerticalScale(VerticalScale scale) 191 RegionLayer::setVerticalScale(VerticalScale scale)
162 { 192 {
956 void 986 void
957 RegionLayer::toXml(QTextStream &stream, 987 RegionLayer::toXml(QTextStream &stream,
958 QString indent, QString extraAttributes) const 988 QString indent, QString extraAttributes) const
959 { 989 {
960 SingleColourLayer::toXml(stream, indent, extraAttributes + 990 SingleColourLayer::toXml(stream, indent, extraAttributes +
961 QString(" verticalScale=\"%1\"") 991 QString(" verticalScale=\"%1\" plotStyle=\"%2\"")
962 .arg(m_verticalScale)); 992 .arg(m_verticalScale)
993 .arg(m_plotStyle));
963 } 994 }
964 995
965 void 996 void
966 RegionLayer::setProperties(const QXmlAttributes &attributes) 997 RegionLayer::setProperties(const QXmlAttributes &attributes)
967 { 998 {
969 1000
970 bool ok; 1001 bool ok;
971 VerticalScale scale = (VerticalScale) 1002 VerticalScale scale = (VerticalScale)
972 attributes.value("verticalScale").toInt(&ok); 1003 attributes.value("verticalScale").toInt(&ok);
973 if (ok) setVerticalScale(scale); 1004 if (ok) setVerticalScale(scale);
974 } 1005 PlotStyle style = (PlotStyle)
975 1006 attributes.value("plotStyle").toInt(&ok);
976 1007 if (ok) setPlotStyle(style);
1008 }
1009
1010