Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
76:45ba0b381c5d | 77:fd348f36c0d3 |
---|---|
142 int verticalScaleWidth = 0; | 142 int verticalScaleWidth = 0; |
143 | 143 |
144 int fontHeight = paint.fontMetrics().height(); | 144 int fontHeight = paint.fontMetrics().height(); |
145 int fontAscent = paint.fontMetrics().ascent(); | 145 int fontAscent = paint.fontMetrics().ascent(); |
146 | 146 |
147 if (m_manager && | 147 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { |
148 m_manager->getOverlayMode() != ViewManager::NoOverlays) { | 148 --vi; |
149 | 149 |
150 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { | 150 if (dynamic_cast<WaveformLayer *>(*vi)) { |
151 --vi; | 151 waveformModel = (*vi)->getModel(); |
152 | 152 } |
153 if (dynamic_cast<WaveformLayer *>(*vi)) { | 153 |
154 waveformModel = (*vi)->getModel(); | 154 if (m_manager && |
155 !m_manager->isPlaying() && | |
156 m_manager->getToolMode() == ViewManager::SelectMode) { | |
157 | |
158 std::vector<QRect> crosshairExtents; | |
159 | |
160 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint, | |
161 crosshairExtents)) { | |
162 (*vi)->paintCrosshairs(this, paint, m_identifyPoint); | |
155 } | 163 } |
156 | 164 } |
157 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint); | 165 |
158 | 166 if (!m_manager || |
159 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) { | 167 m_manager->getOverlayMode() == ViewManager::NoOverlays) { |
168 break; | |
169 } | |
170 | |
171 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint); | |
172 | |
173 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) { | |
160 | 174 |
161 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); | 175 // Profiler profiler("Pane::paintEvent - painting vertical scale", true); |
162 | 176 |
163 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl; | 177 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl; |
178 paint.save(); | |
179 | |
180 paint.setPen(Qt::black); | |
181 paint.setBrush(Qt::white); | |
182 paint.drawRect(0, -1, verticalScaleWidth, height()+1); | |
183 | |
184 paint.setBrush(Qt::NoBrush); | |
185 (*vi)->paintVerticalScale | |
186 (this, paint, QRect(0, 0, verticalScaleWidth, height())); | |
187 | |
188 paint.restore(); | |
189 } | |
190 | |
191 if (m_identifyFeatures) { | |
192 | |
193 QPoint pos = m_identifyPoint; | |
194 QString desc = (*vi)->getFeatureDescription(this, pos); | |
195 | |
196 if (desc != "") { | |
197 | |
164 paint.save(); | 198 paint.save(); |
165 | 199 |
166 paint.setPen(Qt::black); | 200 int tabStop = |
167 paint.setBrush(Qt::white); | 201 paint.fontMetrics().width(tr("Some lengthy prefix:")); |
168 paint.drawRect(0, -1, verticalScaleWidth, height()+1); | 202 |
169 | 203 QRect boundingRect = |
170 paint.setBrush(Qt::NoBrush); | 204 paint.fontMetrics().boundingRect |
171 (*vi)->paintVerticalScale | 205 (rect(), |
172 (this, paint, QRect(0, 0, verticalScaleWidth, height())); | 206 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs, |
207 desc, tabStop); | |
208 | |
209 if (hasLightBackground()) { | |
210 paint.setPen(Qt::NoPen); | |
211 paint.setBrush(QColor(250, 250, 250, 200)); | |
212 } else { | |
213 paint.setPen(Qt::NoPen); | |
214 paint.setBrush(QColor(50, 50, 50, 200)); | |
215 } | |
216 | |
217 int extra = paint.fontMetrics().descent(); | |
218 paint.drawRect(width() - boundingRect.width() - 10 - extra, | |
219 10 - extra, | |
220 boundingRect.width() + 2 * extra, | |
221 boundingRect.height() + extra); | |
222 | |
223 if (hasLightBackground()) { | |
224 paint.setPen(QColor(150, 20, 0)); | |
225 } else { | |
226 paint.setPen(QColor(255, 150, 100)); | |
227 } | |
228 | |
229 QTextOption option; | |
230 option.setWrapMode(QTextOption::NoWrap); | |
231 option.setAlignment(Qt::AlignRight | Qt::AlignTop); | |
232 option.setTabStop(tabStop); | |
233 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10, | |
234 boundingRect.width(), | |
235 boundingRect.height()), | |
236 desc, | |
237 option); | |
173 | 238 |
174 paint.restore(); | 239 paint.restore(); |
175 } | 240 } |
176 | |
177 if (m_identifyFeatures) { | |
178 | |
179 QPoint pos = m_identifyPoint; | |
180 QString desc = (*vi)->getFeatureDescription(this, pos); | |
181 | |
182 if (desc != "") { | |
183 | |
184 paint.save(); | |
185 | |
186 int tabStop = | |
187 paint.fontMetrics().width(tr("Some lengthy prefix:")); | |
188 | |
189 QRect boundingRect = | |
190 paint.fontMetrics().boundingRect | |
191 (rect(), | |
192 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs, | |
193 desc, tabStop); | |
194 | |
195 if (hasLightBackground()) { | |
196 paint.setPen(Qt::NoPen); | |
197 paint.setBrush(QColor(250, 250, 250, 200)); | |
198 } else { | |
199 paint.setPen(Qt::NoPen); | |
200 paint.setBrush(QColor(50, 50, 50, 200)); | |
201 } | |
202 | |
203 int extra = paint.fontMetrics().descent(); | |
204 paint.drawRect(width() - boundingRect.width() - 10 - extra, | |
205 10 - extra, | |
206 boundingRect.width() + 2 * extra, | |
207 boundingRect.height() + extra); | |
208 | |
209 if (hasLightBackground()) { | |
210 paint.setPen(QColor(150, 20, 0)); | |
211 } else { | |
212 paint.setPen(QColor(255, 150, 100)); | |
213 } | |
214 | |
215 QTextOption option; | |
216 option.setWrapMode(QTextOption::NoWrap); | |
217 option.setAlignment(Qt::AlignRight | Qt::AlignTop); | |
218 option.setTabStop(tabStop); | |
219 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10, | |
220 boundingRect.width(), | |
221 boundingRect.height()), | |
222 desc, | |
223 option); | |
224 | |
225 paint.restore(); | |
226 } | |
227 } | |
228 | |
229 break; | |
230 } | 241 } |
242 | |
243 break; | |
231 } | 244 } |
232 | 245 |
233 int sampleRate = getModelsSampleRate(); | 246 int sampleRate = getModelsSampleRate(); |
234 paint.setBrush(Qt::NoBrush); | 247 paint.setBrush(Qt::NoBrush); |
235 | 248 |