annotate view/View.cpp @ 956:092de22db207 osx-retina

Make Retina layer rendering selectable in settings
author Chris Cannam
date Wed, 29 Apr 2015 13:28:44 +0100
parents 76b5eabd816b
children 5fdf5cd032ac
rev   line source
Chris@127 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@127 2
Chris@127 3 /*
Chris@127 4 Sonic Visualiser
Chris@127 5 An audio file viewer and annotation editor.
Chris@127 6 Centre for Digital Music, Queen Mary, University of London.
Chris@127 7 This file copyright 2006 Chris Cannam.
Chris@127 8
Chris@127 9 This program is free software; you can redistribute it and/or
Chris@127 10 modify it under the terms of the GNU General Public License as
Chris@127 11 published by the Free Software Foundation; either version 2 of the
Chris@127 12 License, or (at your option) any later version. See the file
Chris@127 13 COPYING included with this distribution for more information.
Chris@127 14 */
Chris@127 15
Chris@128 16 #include "View.h"
Chris@128 17 #include "layer/Layer.h"
Chris@128 18 #include "data/model/Model.h"
Chris@127 19 #include "base/ZoomConstraint.h"
Chris@127 20 #include "base/Profiler.h"
Chris@278 21 #include "base/Pitch.h"
Chris@338 22 #include "base/Preferences.h"
Chris@919 23 #include "ViewProxy.h"
Chris@127 24
Chris@301 25 #include "layer/TimeRulerLayer.h"
Chris@287 26 #include "layer/SingleColourLayer.h"
Chris@301 27 #include "data/model/PowerOfSqrtTwoZoomConstraint.h"
Chris@301 28 #include "data/model/RangeSummarisableTimeValueModel.h"
Chris@127 29
Chris@797 30 #include "widgets/IconLoader.h"
Chris@797 31
Chris@127 32 #include <QPainter>
Chris@127 33 #include <QPaintEvent>
Chris@127 34 #include <QRect>
Chris@127 35 #include <QApplication>
Chris@226 36 #include <QProgressDialog>
Chris@316 37 #include <QTextStream>
Chris@338 38 #include <QFont>
Chris@583 39 #include <QMessageBox>
Chris@797 40 #include <QPushButton>
Chris@956 41 #include <QSettings>
Chris@127 42
Chris@127 43 #include <iostream>
Chris@127 44 #include <cassert>
Chris@520 45 #include <cmath>
Chris@127 46
Chris@545 47 #include <unistd.h>
Chris@545 48
Chris@951 49 #define DEBUG_VIEW 1
Chris@951 50 #define DEBUG_VIEW_WIDGET_PAINT 1
Chris@127 51
Chris@682 52
Chris@127 53 View::View(QWidget *w, bool showProgress) :
Chris@127 54 QFrame(w),
Chris@127 55 m_centreFrame(0),
Chris@127 56 m_zoomLevel(1024),
Chris@127 57 m_followPan(true),
Chris@127 58 m_followZoom(true),
Chris@815 59 m_followPlay(PlaybackScrollPageWithCentre),
Chris@789 60 m_followPlayIsDetached(false),
Chris@153 61 m_playPointerFrame(0),
Chris@127 62 m_showProgress(showProgress),
Chris@127 63 m_cache(0),
Chris@952 64 m_buffer(0),
Chris@127 65 m_cacheCentreFrame(0),
Chris@127 66 m_cacheZoomLevel(1024),
Chris@127 67 m_selectionCached(false),
Chris@127 68 m_deleting(false),
Chris@127 69 m_haveSelectedLayer(false),
Chris@127 70 m_manager(0),
Chris@127 71 m_propertyContainer(new ViewPropertyContainer(this))
Chris@127 72 {
Chris@728 73 // cerr << "View::View(" << this << ")" << endl;
Chris@127 74 }
Chris@127 75
Chris@127 76 View::~View()
Chris@127 77 {
Chris@728 78 // cerr << "View::~View(" << this << ")" << endl;
Chris@127 79
Chris@127 80 m_deleting = true;
Chris@127 81 delete m_propertyContainer;
Chris@127 82 }
Chris@127 83
Chris@127 84 PropertyContainer::PropertyList
Chris@127 85 View::getProperties() const
Chris@127 86 {
Chris@127 87 PropertyContainer::PropertyList list;
Chris@127 88 list.push_back("Global Scroll");
Chris@127 89 list.push_back("Global Zoom");
Chris@127 90 list.push_back("Follow Playback");
Chris@127 91 return list;
Chris@127 92 }
Chris@127 93
Chris@127 94 QString
Chris@127 95 View::getPropertyLabel(const PropertyName &pn) const
Chris@127 96 {
Chris@127 97 if (pn == "Global Scroll") return tr("Global Scroll");
Chris@127 98 if (pn == "Global Zoom") return tr("Global Zoom");
Chris@127 99 if (pn == "Follow Playback") return tr("Follow Playback");
Chris@127 100 return "";
Chris@127 101 }
Chris@127 102
Chris@127 103 PropertyContainer::PropertyType
Chris@127 104 View::getPropertyType(const PropertyContainer::PropertyName &name) const
Chris@127 105 {
Chris@127 106 if (name == "Global Scroll") return PropertyContainer::ToggleProperty;
Chris@127 107 if (name == "Global Zoom") return PropertyContainer::ToggleProperty;
Chris@127 108 if (name == "Follow Playback") return PropertyContainer::ValueProperty;
Chris@127 109 return PropertyContainer::InvalidProperty;
Chris@127 110 }
Chris@127 111
Chris@127 112 int
Chris@127 113 View::getPropertyRangeAndValue(const PropertyContainer::PropertyName &name,
Chris@216 114 int *min, int *max, int *deflt) const
Chris@127 115 {
Chris@216 116 if (deflt) *deflt = 1;
Chris@127 117 if (name == "Global Scroll") return m_followPan;
Chris@127 118 if (name == "Global Zoom") return m_followZoom;
Chris@127 119 if (name == "Follow Playback") {
Chris@127 120 if (min) *min = 0;
Chris@127 121 if (max) *max = 2;
Chris@815 122 if (deflt) *deflt = int(PlaybackScrollPageWithCentre);
Chris@815 123 switch (m_followPlay) {
Chris@815 124 case PlaybackScrollContinuous: return 0;
Chris@815 125 case PlaybackScrollPageWithCentre: case PlaybackScrollPage: return 1;
Chris@815 126 case PlaybackIgnore: return 2;
Chris@815 127 }
Chris@127 128 }
Chris@127 129 if (min) *min = 0;
Chris@127 130 if (max) *max = 0;
Chris@216 131 if (deflt) *deflt = 0;
Chris@127 132 return 0;
Chris@127 133 }
Chris@127 134
Chris@127 135 QString
Chris@127 136 View::getPropertyValueLabel(const PropertyContainer::PropertyName &name,
Chris@127 137 int value) const
Chris@127 138 {
Chris@127 139 if (name == "Follow Playback") {
Chris@127 140 switch (value) {
Chris@127 141 default:
Chris@127 142 case 0: return tr("Scroll");
Chris@127 143 case 1: return tr("Page");
Chris@127 144 case 2: return tr("Off");
Chris@127 145 }
Chris@127 146 }
Chris@127 147 return tr("<unknown>");
Chris@127 148 }
Chris@127 149
Chris@127 150 void
Chris@127 151 View::setProperty(const PropertyContainer::PropertyName &name, int value)
Chris@127 152 {
Chris@127 153 if (name == "Global Scroll") {
Chris@127 154 setFollowGlobalPan(value != 0);
Chris@127 155 } else if (name == "Global Zoom") {
Chris@127 156 setFollowGlobalZoom(value != 0);
Chris@127 157 } else if (name == "Follow Playback") {
Chris@127 158 switch (value) {
Chris@127 159 default:
Chris@127 160 case 0: setPlaybackFollow(PlaybackScrollContinuous); break;
Chris@815 161 case 1: setPlaybackFollow(PlaybackScrollPageWithCentre); break;
Chris@127 162 case 2: setPlaybackFollow(PlaybackIgnore); break;
Chris@127 163 }
Chris@127 164 }
Chris@127 165 }
Chris@127 166
Chris@806 167 int
Chris@127 168 View::getPropertyContainerCount() const
Chris@127 169 {
Chris@908 170 return int(m_fixedOrderLayers.size()) + 1; // the 1 is for me
Chris@127 171 }
Chris@127 172
Chris@127 173 const PropertyContainer *
Chris@806 174 View::getPropertyContainer(int i) const
Chris@127 175 {
Chris@127 176 return (const PropertyContainer *)(((View *)this)->
Chris@127 177 getPropertyContainer(i));
Chris@127 178 }
Chris@127 179
Chris@127 180 PropertyContainer *
Chris@806 181 View::getPropertyContainer(int i)
Chris@127 182 {
Chris@127 183 if (i == 0) return m_propertyContainer;
Chris@837 184 return m_fixedOrderLayers[i-1];
Chris@127 185 }
Chris@127 186
Chris@127 187 bool
Chris@904 188 View::getValueExtents(QString unit, double &min, double &max, bool &log) const
Chris@127 189 {
Chris@127 190 bool have = false;
Chris@127 191
Chris@835 192 for (LayerList::const_iterator i = m_layerStack.begin();
Chris@835 193 i != m_layerStack.end(); ++i) {
Chris@127 194
Chris@127 195 QString layerUnit;
Chris@904 196 double layerMin = 0.0, layerMax = 0.0;
Chris@904 197 double displayMin = 0.0, displayMax = 0.0;
Chris@127 198 bool layerLog = false;
Chris@127 199
Chris@127 200 if ((*i)->getValueExtents(layerMin, layerMax, layerLog, layerUnit) &&
Chris@127 201 layerUnit.toLower() == unit.toLower()) {
Chris@127 202
Chris@127 203 if ((*i)->getDisplayExtents(displayMin, displayMax)) {
Chris@127 204
Chris@127 205 min = displayMin;
Chris@127 206 max = displayMax;
Chris@127 207 log = layerLog;
Chris@127 208 have = true;
Chris@127 209 break;
Chris@127 210
Chris@127 211 } else {
Chris@127 212
Chris@127 213 if (!have || layerMin < min) min = layerMin;
Chris@127 214 if (!have || layerMax > max) max = layerMax;
Chris@127 215 if (layerLog) log = true;
Chris@127 216 have = true;
Chris@127 217 }
Chris@127 218 }
Chris@127 219 }
Chris@127 220
Chris@127 221 return have;
Chris@127 222 }
Chris@127 223
Chris@127 224 int
Chris@127 225 View::getTextLabelHeight(const Layer *layer, QPainter &paint) const
Chris@127 226 {
Chris@127 227 std::map<int, Layer *> sortedLayers;
Chris@127 228
Chris@835 229 for (LayerList::const_iterator i = m_layerStack.begin();
Chris@835 230 i != m_layerStack.end(); ++i) {
Chris@127 231 if ((*i)->needsTextLabelHeight()) {
Chris@127 232 sortedLayers[getObjectExportId(*i)] = *i;
Chris@127 233 }
Chris@127 234 }
Chris@127 235
Chris@127 236 int y = 15 + paint.fontMetrics().ascent();
Chris@127 237
Chris@127 238 for (std::map<int, Layer *>::const_iterator i = sortedLayers.begin();
Chris@127 239 i != sortedLayers.end(); ++i) {
Chris@127 240 if (i->second == layer) return y;
Chris@127 241 y += paint.fontMetrics().height();
Chris@127 242 }
Chris@127 243
Chris@127 244 return y;
Chris@127 245 }
Chris@127 246
Chris@127 247 void
Chris@127 248 View::propertyContainerSelected(View *client, PropertyContainer *pc)
Chris@127 249 {
Chris@127 250 if (client != this) return;
Chris@127 251
Chris@127 252 if (pc == m_propertyContainer) {
Chris@127 253 if (m_haveSelectedLayer) {
Chris@127 254 m_haveSelectedLayer = false;
Chris@127 255 update();
Chris@127 256 }
Chris@127 257 return;
Chris@127 258 }
Chris@127 259
Chris@127 260 delete m_cache;
Chris@127 261 m_cache = 0;
Chris@127 262
Chris@127 263 Layer *selectedLayer = 0;
Chris@127 264
Chris@835 265 for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 266 if (*i == pc) {
Chris@127 267 selectedLayer = *i;
Chris@835 268 m_layerStack.erase(i);
Chris@127 269 break;
Chris@127 270 }
Chris@127 271 }
Chris@127 272
Chris@127 273 if (selectedLayer) {
Chris@127 274 m_haveSelectedLayer = true;
Chris@835 275 m_layerStack.push_back(selectedLayer);
Chris@127 276 update();
Chris@127 277 } else {
Chris@127 278 m_haveSelectedLayer = false;
Chris@127 279 }
Chris@298 280
Chris@298 281 emit propertyContainerSelected(pc);
Chris@127 282 }
Chris@127 283
Chris@127 284 void
Chris@127 285 View::toolModeChanged()
Chris@127 286 {
Chris@587 287 // SVDEBUG << "View::toolModeChanged(" << m_manager->getToolMode() << ")" << endl;
Chris@127 288 }
Chris@127 289
Chris@133 290 void
Chris@133 291 View::overlayModeChanged()
Chris@133 292 {
Chris@206 293 delete m_cache;
Chris@206 294 m_cache = 0;
Chris@133 295 update();
Chris@133 296 }
Chris@133 297
Chris@133 298 void
Chris@133 299 View::zoomWheelsEnabledChanged()
Chris@133 300 {
Chris@133 301 // subclass might override this
Chris@133 302 }
Chris@133 303
Chris@908 304 sv_frame_t
Chris@127 305 View::getStartFrame() const
Chris@127 306 {
Chris@313 307 return getFrameForX(0);
Chris@127 308 }
Chris@127 309
Chris@908 310 sv_frame_t
Chris@127 311 View::getEndFrame() const
Chris@127 312 {
Chris@127 313 return getFrameForX(width()) - 1;
Chris@127 314 }
Chris@127 315
Chris@127 316 void
Chris@908 317 View::setStartFrame(sv_frame_t f)
Chris@127 318 {
Chris@127 319 setCentreFrame(f + m_zoomLevel * (width() / 2));
Chris@127 320 }
Chris@127 321
Chris@127 322 bool
Chris@908 323 View::setCentreFrame(sv_frame_t f, bool e)
Chris@127 324 {
Chris@127 325 bool changeVisible = false;
Chris@127 326
Chris@127 327 if (m_centreFrame != f) {
Chris@127 328
Chris@908 329 int formerPixel = int(m_centreFrame / m_zoomLevel);
Chris@127 330
Chris@127 331 m_centreFrame = f;
Chris@127 332
Chris@908 333 int newPixel = int(m_centreFrame / m_zoomLevel);
Chris@127 334
Chris@127 335 if (newPixel != formerPixel) {
Chris@127 336
Chris@127 337 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 338 cout << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl;
Chris@127 339 #endif
Chris@127 340 update();
Chris@127 341
Chris@127 342 changeVisible = true;
Chris@127 343 }
Chris@127 344
Chris@333 345 if (e) {
Chris@908 346 sv_frame_t rf = alignToReference(f);
Chris@830 347 #ifdef DEBUG_VIEW
Chris@682 348 cerr << "View[" << this << "]::setCentreFrame(" << f
Chris@333 349 << "): emitting centreFrameChanged("
Chris@682 350 << rf << ")" << endl;
Chris@355 351 #endif
Chris@333 352 emit centreFrameChanged(rf, m_followPan, m_followPlay);
Chris@333 353 }
Chris@127 354 }
Chris@127 355
Chris@127 356 return changeVisible;
Chris@127 357 }
Chris@127 358
Chris@127 359 int
Chris@908 360 View::getXForFrame(sv_frame_t frame) const
Chris@127 361 {
Chris@908 362 return int((frame - getStartFrame()) / m_zoomLevel);
Chris@127 363 }
Chris@127 364
Chris@908 365 sv_frame_t
Chris@127 366 View::getFrameForX(int x) const
Chris@127 367 {
Chris@806 368 int z = m_zoomLevel;
Chris@908 369 sv_frame_t frame = m_centreFrame - (width()/2) * z;
Chris@354 370
Chris@355 371 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@587 372 SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl;
Chris@355 373 #endif
Chris@354 374
Chris@313 375 frame = (frame / z) * z; // this is start frame
Chris@313 376 return frame + x * z;
Chris@127 377 }
Chris@127 378
Chris@904 379 double
Chris@904 380 View::getYForFrequency(double frequency,
Chris@904 381 double minf,
Chris@904 382 double maxf,
Chris@127 383 bool logarithmic) const
Chris@127 384 {
Chris@382 385 Profiler profiler("View::getYForFrequency");
Chris@382 386
Chris@127 387 int h = height();
Chris@127 388
Chris@127 389 if (logarithmic) {
Chris@127 390
Chris@904 391 static double lastminf = 0.0, lastmaxf = 0.0;
Chris@904 392 static double logminf = 0.0, logmaxf = 0.0;
Chris@127 393
Chris@127 394 if (lastminf != minf) {
Chris@127 395 lastminf = (minf == 0.0 ? 1.0 : minf);
Chris@908 396 logminf = log10(minf);
Chris@127 397 }
Chris@127 398 if (lastmaxf != maxf) {
Chris@127 399 lastmaxf = (maxf < lastminf ? lastminf : maxf);
Chris@908 400 logmaxf = log10(maxf);
Chris@127 401 }
Chris@127 402
Chris@127 403 if (logminf == logmaxf) return 0;
Chris@908 404 return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf);
Chris@127 405
Chris@127 406 } else {
Chris@127 407
Chris@127 408 if (minf == maxf) return 0;
Chris@127 409 return h - (h * (frequency - minf)) / (maxf - minf);
Chris@127 410 }
Chris@127 411 }
Chris@127 412
Chris@904 413 double
Chris@127 414 View::getFrequencyForY(int y,
Chris@904 415 double minf,
Chris@904 416 double maxf,
Chris@127 417 bool logarithmic) const
Chris@127 418 {
Chris@127 419 int h = height();
Chris@127 420
Chris@127 421 if (logarithmic) {
Chris@127 422
Chris@904 423 static double lastminf = 0.0, lastmaxf = 0.0;
Chris@904 424 static double logminf = 0.0, logmaxf = 0.0;
Chris@127 425
Chris@127 426 if (lastminf != minf) {
Chris@127 427 lastminf = (minf == 0.0 ? 1.0 : minf);
Chris@908 428 logminf = log10(minf);
Chris@127 429 }
Chris@127 430 if (lastmaxf != maxf) {
Chris@127 431 lastmaxf = (maxf < lastminf ? lastminf : maxf);
Chris@908 432 logmaxf = log10(maxf);
Chris@127 433 }
Chris@127 434
Chris@127 435 if (logminf == logmaxf) return 0;
Chris@908 436 return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h);
Chris@127 437
Chris@127 438 } else {
Chris@127 439
Chris@127 440 if (minf == maxf) return 0;
Chris@127 441 return minf + ((h - y) * (maxf - minf)) / h;
Chris@127 442 }
Chris@127 443 }
Chris@127 444
Chris@127 445 int
Chris@127 446 View::getZoomLevel() const
Chris@127 447 {
Chris@127 448 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 449 // cout << "zoom level: " << m_zoomLevel << endl;
Chris@127 450 #endif
Chris@127 451 return m_zoomLevel;
Chris@127 452 }
Chris@127 453
Chris@956 454 int
Chris@956 455 View::effectiveDevicePixelRatio() const
Chris@956 456 {
Chris@956 457 #ifdef Q_OS_MAC
Chris@956 458 int dpratio = devicePixelRatio();
Chris@956 459 if (dpratio > 1) {
Chris@956 460 QSettings settings;
Chris@956 461 settings.beginGroup("Preferences");
Chris@956 462 if (!settings.value("scaledHiDpi", true).toBool()) {
Chris@956 463 dpratio = 1;
Chris@956 464 }
Chris@956 465 settings.endGroup();
Chris@956 466 }
Chris@956 467 return dpratio;
Chris@956 468 #else
Chris@956 469 return 1;
Chris@956 470 #endif
Chris@956 471 }
Chris@956 472
Chris@127 473 void
Chris@806 474 View::setZoomLevel(int z)
Chris@127 475 {
Chris@956 476 int dpratio = effectiveDevicePixelRatio();
Chris@950 477 if (z < dpratio) return;
Chris@462 478 if (z < 1) z = 1;
Chris@127 479 if (m_zoomLevel != int(z)) {
Chris@127 480 m_zoomLevel = z;
Chris@222 481 emit zoomLevelChanged(z, m_followZoom);
Chris@127 482 update();
Chris@127 483 }
Chris@127 484 }
Chris@127 485
Chris@224 486 bool
Chris@224 487 View::hasLightBackground() const
Chris@224 488 {
Chris@287 489 bool darkPalette = false;
Chris@292 490 if (m_manager) darkPalette = m_manager->getGlobalDarkBackground();
Chris@287 491
Chris@287 492 Layer::ColourSignificance maxSignificance = Layer::ColourAbsent;
Chris@287 493 bool mostSignificantHasDarkBackground = false;
Chris@287 494
Chris@835 495 for (LayerList::const_iterator i = m_layerStack.begin();
Chris@835 496 i != m_layerStack.end(); ++i) {
Chris@287 497
Chris@287 498 Layer::ColourSignificance s = (*i)->getLayerColourSignificance();
Chris@287 499 bool light = (*i)->hasLightBackground();
Chris@287 500
Chris@287 501 if (int(s) > int(maxSignificance)) {
Chris@287 502 maxSignificance = s;
Chris@287 503 mostSignificantHasDarkBackground = !light;
Chris@287 504 } else if (s == maxSignificance && !light) {
Chris@287 505 mostSignificantHasDarkBackground = true;
Chris@287 506 }
Chris@224 507 }
Chris@287 508
Chris@287 509 if (int(maxSignificance) >= int(Layer::ColourAndBackgroundSignificant)) {
Chris@287 510 return !mostSignificantHasDarkBackground;
Chris@287 511 } else {
Chris@287 512 return !darkPalette;
Chris@287 513 }
Chris@287 514 }
Chris@287 515
Chris@287 516 QColor
Chris@287 517 View::getBackground() const
Chris@287 518 {
Chris@287 519 bool light = hasLightBackground();
Chris@287 520
Chris@287 521 QColor widgetbg = palette().window().color();
Chris@287 522 bool widgetLight =
Chris@287 523 (widgetbg.red() + widgetbg.green() + widgetbg.blue()) > 384;
Chris@287 524
Chris@296 525 if (widgetLight == light) {
Chris@296 526 if (widgetLight) {
Chris@296 527 return widgetbg.light();
Chris@296 528 } else {
Chris@296 529 return widgetbg.dark();
Chris@296 530 }
Chris@296 531 }
Chris@287 532 else if (light) return Qt::white;
Chris@287 533 else return Qt::black;
Chris@287 534 }
Chris@287 535
Chris@287 536 QColor
Chris@287 537 View::getForeground() const
Chris@287 538 {
Chris@287 539 bool light = hasLightBackground();
Chris@287 540
Chris@287 541 QColor widgetfg = palette().text().color();
Chris@287 542 bool widgetLight =
Chris@287 543 (widgetfg.red() + widgetfg.green() + widgetfg.blue()) > 384;
Chris@287 544
Chris@287 545 if (widgetLight != light) return widgetfg;
Chris@287 546 else if (light) return Qt::black;
Chris@287 547 else return Qt::white;
Chris@224 548 }
Chris@224 549
Chris@127 550 void
Chris@127 551 View::addLayer(Layer *layer)
Chris@127 552 {
Chris@127 553 delete m_cache;
Chris@127 554 m_cache = 0;
Chris@127 555
Chris@287 556 SingleColourLayer *scl = dynamic_cast<SingleColourLayer *>(layer);
Chris@287 557 if (scl) scl->setDefaultColourFor(this);
Chris@287 558
Chris@836 559 m_fixedOrderLayers.push_back(layer);
Chris@835 560 m_layerStack.push_back(layer);
Chris@127 561
Chris@555 562 QProgressBar *pb = new QProgressBar(this);
Chris@555 563 pb->setMinimum(0);
Chris@555 564 pb->setMaximum(0);
Chris@555 565 pb->setFixedWidth(80);
Chris@555 566 pb->setTextVisible(false);
Chris@555 567
Chris@797 568 QPushButton *cancel = new QPushButton(this);
Chris@797 569 cancel->setIcon(IconLoader().load("fileclose"));
Chris@797 570 cancel->setFlat(true);
Chris@797 571 cancel->setFixedSize(QSize(20, 20));
Chris@797 572 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
Chris@797 573
Chris@555 574 ProgressBarRec pbr;
Chris@797 575 pbr.cancel = cancel;
Chris@555 576 pbr.bar = pb;
Chris@555 577 pbr.lastCheck = 0;
Chris@555 578 pbr.checkTimer = new QTimer();
Chris@555 579 connect(pbr.checkTimer, SIGNAL(timeout()), this,
Chris@555 580 SLOT(progressCheckStalledTimerElapsed()));
Chris@555 581
Chris@555 582 m_progressBars[layer] = pbr;
Chris@555 583
Chris@555 584 QFont f(pb->font());
Chris@339 585 int fs = Preferences::getInstance()->getViewFontSize();
Chris@339 586 f.setPointSize(std::min(fs, int(ceil(fs * 0.85))));
Chris@339 587
Chris@797 588 cancel->hide();
Chris@797 589
Chris@555 590 pb->setFont(f);
Chris@555 591 pb->hide();
Chris@127 592
Chris@127 593 connect(layer, SIGNAL(layerParametersChanged()),
Chris@127 594 this, SLOT(layerParametersChanged()));
Chris@197 595 connect(layer, SIGNAL(layerParameterRangesChanged()),
Chris@197 596 this, SLOT(layerParameterRangesChanged()));
Chris@268 597 connect(layer, SIGNAL(layerMeasurementRectsChanged()),
Chris@268 598 this, SLOT(layerMeasurementRectsChanged()));
Chris@127 599 connect(layer, SIGNAL(layerNameChanged()),
Chris@127 600 this, SLOT(layerNameChanged()));
Chris@127 601 connect(layer, SIGNAL(modelChanged()),
Chris@127 602 this, SLOT(modelChanged()));
Chris@127 603 connect(layer, SIGNAL(modelCompletionChanged()),
Chris@127 604 this, SLOT(modelCompletionChanged()));
Chris@320 605 connect(layer, SIGNAL(modelAlignmentCompletionChanged()),
Chris@320 606 this, SLOT(modelAlignmentCompletionChanged()));
Chris@908 607 connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)),
Chris@908 608 this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t)));
Chris@127 609 connect(layer, SIGNAL(modelReplaced()),
Chris@127 610 this, SLOT(modelReplaced()));
Chris@127 611
Chris@127 612 update();
Chris@127 613
Chris@127 614 emit propertyContainerAdded(layer);
Chris@127 615 }
Chris@127 616
Chris@127 617 void
Chris@127 618 View::removeLayer(Layer *layer)
Chris@127 619 {
Chris@127 620 if (m_deleting) {
Chris@127 621 return;
Chris@127 622 }
Chris@127 623
Chris@127 624 delete m_cache;
Chris@127 625 m_cache = 0;
Chris@127 626
Chris@836 627 for (LayerList::iterator i = m_fixedOrderLayers.begin();
Chris@836 628 i != m_fixedOrderLayers.end();
Chris@836 629 ++i) {
Chris@836 630 if (*i == layer) {
Chris@836 631 m_fixedOrderLayers.erase(i);
Chris@836 632 break;
Chris@836 633 }
Chris@836 634 }
Chris@836 635
Chris@836 636 for (LayerList::iterator i = m_layerStack.begin();
Chris@836 637 i != m_layerStack.end();
Chris@836 638 ++i) {
Chris@127 639 if (*i == layer) {
Chris@835 640 m_layerStack.erase(i);
Chris@127 641 if (m_progressBars.find(layer) != m_progressBars.end()) {
Chris@555 642 delete m_progressBars[layer].bar;
Chris@797 643 delete m_progressBars[layer].cancel;
Chris@555 644 delete m_progressBars[layer].checkTimer;
Chris@127 645 m_progressBars.erase(layer);
Chris@127 646 }
Chris@127 647 break;
Chris@127 648 }
Chris@127 649 }
Chris@127 650
Chris@197 651 disconnect(layer, SIGNAL(layerParametersChanged()),
Chris@197 652 this, SLOT(layerParametersChanged()));
Chris@197 653 disconnect(layer, SIGNAL(layerParameterRangesChanged()),
Chris@197 654 this, SLOT(layerParameterRangesChanged()));
Chris@197 655 disconnect(layer, SIGNAL(layerNameChanged()),
Chris@197 656 this, SLOT(layerNameChanged()));
Chris@197 657 disconnect(layer, SIGNAL(modelChanged()),
Chris@197 658 this, SLOT(modelChanged()));
Chris@197 659 disconnect(layer, SIGNAL(modelCompletionChanged()),
Chris@197 660 this, SLOT(modelCompletionChanged()));
Chris@320 661 disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()),
Chris@320 662 this, SLOT(modelAlignmentCompletionChanged()));
Chris@908 663 disconnect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)),
Chris@908 664 this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t)));
Chris@197 665 disconnect(layer, SIGNAL(modelReplaced()),
Chris@197 666 this, SLOT(modelReplaced()));
Chris@197 667
Chris@127 668 update();
Chris@127 669
Chris@127 670 emit propertyContainerRemoved(layer);
Chris@127 671 }
Chris@127 672
Chris@127 673 Layer *
Chris@834 674 View::getInteractionLayer()
Chris@834 675 {
Chris@834 676 Layer *sl = getSelectedLayer();
Chris@834 677 if (sl && !(sl->isLayerDormant(this))) {
Chris@834 678 return sl;
Chris@834 679 }
Chris@835 680 if (!m_layerStack.empty()) {
Chris@834 681 int n = getLayerCount();
Chris@834 682 while (n > 0) {
Chris@834 683 --n;
Chris@834 684 Layer *layer = getLayer(n);
Chris@834 685 if (!(layer->isLayerDormant(this))) {
Chris@834 686 return layer;
Chris@834 687 }
Chris@834 688 }
Chris@834 689 }
Chris@834 690 return 0;
Chris@834 691 }
Chris@834 692
Chris@841 693 const Layer *
Chris@841 694 View::getInteractionLayer() const
Chris@841 695 {
Chris@841 696 return const_cast<const Layer *>(const_cast<View *>(this)->getInteractionLayer());
Chris@841 697 }
Chris@841 698
Chris@834 699 Layer *
Chris@127 700 View::getSelectedLayer()
Chris@127 701 {
Chris@835 702 if (m_haveSelectedLayer && !m_layerStack.empty()) {
Chris@839 703 return getLayer(getLayerCount() - 1);
Chris@127 704 } else {
Chris@127 705 return 0;
Chris@127 706 }
Chris@127 707 }
Chris@127 708
Chris@127 709 const Layer *
Chris@127 710 View::getSelectedLayer() const
Chris@127 711 {
Chris@127 712 return const_cast<const Layer *>(const_cast<View *>(this)->getSelectedLayer());
Chris@127 713 }
Chris@127 714
Chris@127 715 void
Chris@127 716 View::setViewManager(ViewManager *manager)
Chris@127 717 {
Chris@127 718 if (m_manager) {
Chris@908 719 m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t)));
Chris@908 720 m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t)));
Chris@908 721 m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t)));
Chris@806 722 m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool)));
Chris@211 723 m_manager->disconnect(this, SLOT(toolModeChanged()));
Chris@211 724 m_manager->disconnect(this, SLOT(selectionChanged()));
Chris@211 725 m_manager->disconnect(this, SLOT(overlayModeChanged()));
Chris@211 726 m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged()));
Chris@908 727 disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode)));
Chris@806 728 disconnect(m_manager, SLOT(zoomLevelChanged(int, bool)));
Chris@127 729 }
Chris@127 730
Chris@127 731 m_manager = manager;
Chris@127 732
Chris@908 733 connect(m_manager, SIGNAL(globalCentreFrameChanged(sv_frame_t)),
Chris@908 734 this, SLOT(globalCentreFrameChanged(sv_frame_t)));
Chris@908 735 connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)),
Chris@908 736 this, SLOT(viewCentreFrameChanged(View *, sv_frame_t)));
Chris@908 737 connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)),
Chris@908 738 this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t)));
Chris@806 739
Chris@806 740 connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)),
Chris@806 741 this, SLOT(viewZoomLevelChanged(View *, int, bool)));
Chris@211 742
Chris@127 743 connect(m_manager, SIGNAL(toolModeChanged()),
Chris@127 744 this, SLOT(toolModeChanged()));
Chris@127 745 connect(m_manager, SIGNAL(selectionChanged()),
Chris@127 746 this, SLOT(selectionChanged()));
Chris@127 747 connect(m_manager, SIGNAL(inProgressSelectionChanged()),
Chris@127 748 this, SLOT(selectionChanged()));
Chris@127 749 connect(m_manager, SIGNAL(overlayModeChanged()),
Chris@133 750 this, SLOT(overlayModeChanged()));
Chris@607 751 connect(m_manager, SIGNAL(showCentreLineChanged()),
Chris@607 752 this, SLOT(overlayModeChanged()));
Chris@133 753 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()),
Chris@133 754 this, SLOT(zoomWheelsEnabledChanged()));
Chris@127 755
Chris@908 756 connect(this, SIGNAL(centreFrameChanged(sv_frame_t, bool,
Chris@211 757 PlaybackFollowMode)),
Chris@908 758 m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool,
Chris@211 759 PlaybackFollowMode)));
Chris@211 760
Chris@806 761 connect(this, SIGNAL(zoomLevelChanged(int, bool)),
Chris@806 762 m_manager, SLOT(viewZoomLevelChanged(int, bool)));
Chris@127 763
Chris@815 764 switch (m_followPlay) {
Chris@815 765
Chris@815 766 case PlaybackScrollPage:
Chris@815 767 case PlaybackScrollPageWithCentre:
Chris@364 768 setCentreFrame(m_manager->getGlobalCentreFrame(), false);
Chris@815 769 break;
Chris@815 770
Chris@815 771 case PlaybackScrollContinuous:
Chris@236 772 setCentreFrame(m_manager->getPlaybackFrame(), false);
Chris@815 773 break;
Chris@815 774
Chris@815 775 case PlaybackIgnore:
Chris@815 776 if (m_followPan) {
Chris@815 777 setCentreFrame(m_manager->getGlobalCentreFrame(), false);
Chris@815 778 }
Chris@815 779 break;
Chris@236 780 }
Chris@516 781
Chris@236 782 if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom());
Chris@236 783
Chris@511 784 movePlayPointer(getAlignedPlaybackFrame());
Chris@511 785
Chris@127 786 toolModeChanged();
Chris@127 787 }
Chris@127 788
Chris@127 789 void
Chris@908 790 View::setViewManager(ViewManager *vm, sv_frame_t initialCentreFrame)
Chris@516 791 {
Chris@516 792 setViewManager(vm);
Chris@516 793 setCentreFrame(initialCentreFrame, false);
Chris@516 794 }
Chris@516 795
Chris@516 796 void
Chris@127 797 View::setFollowGlobalPan(bool f)
Chris@127 798 {
Chris@127 799 m_followPan = f;
Chris@127 800 emit propertyContainerPropertyChanged(m_propertyContainer);
Chris@127 801 }
Chris@127 802
Chris@127 803 void
Chris@127 804 View::setFollowGlobalZoom(bool f)
Chris@127 805 {
Chris@127 806 m_followZoom = f;
Chris@127 807 emit propertyContainerPropertyChanged(m_propertyContainer);
Chris@127 808 }
Chris@127 809
Chris@127 810 void
Chris@267 811 View::drawVisibleText(QPainter &paint, int x, int y, QString text, TextStyle style) const
Chris@127 812 {
Chris@630 813 if (style == OutlinedText || style == OutlinedItalicText) {
Chris@127 814
Chris@279 815 paint.save();
Chris@279 816
Chris@630 817 if (style == OutlinedItalicText) {
Chris@630 818 QFont f(paint.font());
Chris@630 819 f.setItalic(true);
Chris@630 820 paint.setFont(f);
Chris@630 821 }
Chris@630 822
Chris@575 823 QColor penColour, surroundColour, boxColour;
Chris@279 824
Chris@287 825 penColour = getForeground();
Chris@287 826 surroundColour = getBackground();
Chris@575 827 boxColour = surroundColour;
Chris@575 828 boxColour.setAlpha(127);
Chris@575 829
Chris@575 830 paint.setPen(Qt::NoPen);
Chris@575 831 paint.setBrush(boxColour);
Chris@630 832
Chris@575 833 QRect r = paint.fontMetrics().boundingRect(text);
Chris@575 834 r.translate(QPoint(x, y));
Chris@682 835 // cerr << "drawVisibleText: r = " << r.x() << "," <<r.y() << " " << r.width() << "x" << r.height() << endl;
Chris@575 836 paint.drawRect(r);
Chris@575 837 paint.setBrush(Qt::NoBrush);
Chris@279 838
Chris@127 839 paint.setPen(surroundColour);
Chris@127 840
Chris@127 841 for (int dx = -1; dx <= 1; ++dx) {
Chris@127 842 for (int dy = -1; dy <= 1; ++dy) {
Chris@127 843 if (!(dx || dy)) continue;
Chris@127 844 paint.drawText(x + dx, y + dy, text);
Chris@127 845 }
Chris@127 846 }
Chris@127 847
Chris@127 848 paint.setPen(penColour);
Chris@127 849
Chris@127 850 paint.drawText(x, y, text);
Chris@287 851
Chris@279 852 paint.restore();
Chris@127 853
Chris@127 854 } else {
Chris@127 855
Chris@682 856 cerr << "ERROR: View::drawVisibleText: Boxed style not yet implemented!" << endl;
Chris@127 857 }
Chris@127 858 }
Chris@127 859
Chris@127 860 void
Chris@127 861 View::setPlaybackFollow(PlaybackFollowMode m)
Chris@127 862 {
Chris@127 863 m_followPlay = m;
Chris@127 864 emit propertyContainerPropertyChanged(m_propertyContainer);
Chris@127 865 }
Chris@127 866
Chris@127 867 void
Chris@127 868 View::modelChanged()
Chris@127 869 {
Chris@127 870 QObject *obj = sender();
Chris@127 871
Chris@127 872 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 873 cerr << "View(" << this << ")::modelChanged()" << endl;
Chris@127 874 #endif
Chris@127 875
Chris@127 876 // If the model that has changed is not used by any of the cached
Chris@127 877 // layers, we won't need to recreate the cache
Chris@127 878
Chris@127 879 bool recreate = false;
Chris@127 880
Chris@127 881 bool discard;
Chris@127 882 LayerList scrollables = getScrollableBackLayers(false, discard);
Chris@127 883 for (LayerList::const_iterator i = scrollables.begin();
Chris@127 884 i != scrollables.end(); ++i) {
Chris@127 885 if (*i == obj || (*i)->getModel() == obj) {
Chris@127 886 recreate = true;
Chris@127 887 break;
Chris@127 888 }
Chris@127 889 }
Chris@127 890
Chris@127 891 if (recreate) {
Chris@127 892 delete m_cache;
Chris@127 893 m_cache = 0;
Chris@127 894 }
Chris@127 895
Chris@336 896 emit layerModelChanged();
Chris@336 897
Chris@127 898 checkProgress(obj);
Chris@127 899
Chris@127 900 update();
Chris@127 901 }
Chris@127 902
Chris@127 903 void
Chris@908 904 View::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame)
Chris@127 905 {
Chris@127 906 QObject *obj = sender();
Chris@127 907
Chris@908 908 sv_frame_t myStartFrame = getStartFrame();
Chris@908 909 sv_frame_t myEndFrame = getEndFrame();
Chris@127 910
Chris@127 911 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@806 912 cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl;
Chris@127 913 #endif
Chris@127 914
Chris@908 915 if (myStartFrame > 0 && endFrame < myStartFrame) {
Chris@127 916 checkProgress(obj);
Chris@127 917 return;
Chris@127 918 }
Chris@127 919 if (startFrame > myEndFrame) {
Chris@127 920 checkProgress(obj);
Chris@127 921 return;
Chris@127 922 }
Chris@127 923
Chris@127 924 // If the model that has changed is not used by any of the cached
Chris@127 925 // layers, we won't need to recreate the cache
Chris@127 926
Chris@127 927 bool recreate = false;
Chris@127 928
Chris@127 929 bool discard;
Chris@127 930 LayerList scrollables = getScrollableBackLayers(false, discard);
Chris@127 931 for (LayerList::const_iterator i = scrollables.begin();
Chris@127 932 i != scrollables.end(); ++i) {
Chris@127 933 if (*i == obj || (*i)->getModel() == obj) {
Chris@127 934 recreate = true;
Chris@127 935 break;
Chris@127 936 }
Chris@127 937 }
Chris@127 938
Chris@127 939 if (recreate) {
Chris@127 940 delete m_cache;
Chris@127 941 m_cache = 0;
Chris@127 942 }
Chris@127 943
Chris@806 944 if (startFrame < myStartFrame) startFrame = myStartFrame;
Chris@127 945 if (endFrame > myEndFrame) endFrame = myEndFrame;
Chris@127 946
Chris@127 947 checkProgress(obj);
Chris@127 948
Chris@127 949 update();
Chris@127 950 }
Chris@127 951
Chris@127 952 void
Chris@127 953 View::modelCompletionChanged()
Chris@127 954 {
Chris@682 955 // cerr << "View(" << this << ")::modelCompletionChanged()" << endl;
Chris@301 956
Chris@127 957 QObject *obj = sender();
Chris@127 958 checkProgress(obj);
Chris@127 959 }
Chris@127 960
Chris@127 961 void
Chris@320 962 View::modelAlignmentCompletionChanged()
Chris@320 963 {
Chris@682 964 // cerr << "View(" << this << ")::modelAlignmentCompletionChanged()" << endl;
Chris@320 965
Chris@320 966 QObject *obj = sender();
Chris@320 967 checkProgress(obj);
Chris@320 968 }
Chris@320 969
Chris@320 970 void
Chris@127 971 View::modelReplaced()
Chris@127 972 {
Chris@127 973 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 974 cerr << "View(" << this << ")::modelReplaced()" << endl;
Chris@127 975 #endif
Chris@127 976 delete m_cache;
Chris@127 977 m_cache = 0;
Chris@127 978
Chris@127 979 update();
Chris@127 980 }
Chris@127 981
Chris@127 982 void
Chris@127 983 View::layerParametersChanged()
Chris@127 984 {
Chris@127 985 Layer *layer = dynamic_cast<Layer *>(sender());
Chris@127 986
Chris@127 987 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@587 988 SVDEBUG << "View::layerParametersChanged()" << endl;
Chris@127 989 #endif
Chris@127 990
Chris@127 991 delete m_cache;
Chris@127 992 m_cache = 0;
Chris@127 993 update();
Chris@127 994
Chris@127 995 if (layer) {
Chris@127 996 emit propertyContainerPropertyChanged(layer);
Chris@127 997 }
Chris@127 998 }
Chris@127 999
Chris@127 1000 void
Chris@197 1001 View::layerParameterRangesChanged()
Chris@197 1002 {
Chris@197 1003 Layer *layer = dynamic_cast<Layer *>(sender());
Chris@197 1004 if (layer) emit propertyContainerPropertyRangeChanged(layer);
Chris@197 1005 }
Chris@197 1006
Chris@197 1007 void
Chris@268 1008 View::layerMeasurementRectsChanged()
Chris@268 1009 {
Chris@268 1010 Layer *layer = dynamic_cast<Layer *>(sender());
Chris@268 1011 if (layer) update();
Chris@268 1012 }
Chris@268 1013
Chris@268 1014 void
Chris@127 1015 View::layerNameChanged()
Chris@127 1016 {
Chris@127 1017 Layer *layer = dynamic_cast<Layer *>(sender());
Chris@127 1018 if (layer) emit propertyContainerNameChanged(layer);
Chris@127 1019 }
Chris@127 1020
Chris@127 1021 void
Chris@908 1022 View::globalCentreFrameChanged(sv_frame_t rf)
Chris@127 1023 {
Chris@211 1024 if (m_followPan) {
Chris@908 1025 sv_frame_t f = alignFromReference(rf);
Chris@830 1026 #ifdef DEBUG_VIEW
Chris@682 1027 cerr << "View[" << this << "]::globalCentreFrameChanged(" << rf
Chris@682 1028 << "): setting centre frame to " << f << endl;
Chris@363 1029 #endif
Chris@333 1030 setCentreFrame(f, false);
Chris@127 1031 }
Chris@127 1032 }
Chris@127 1033
Chris@127 1034 void
Chris@908 1035 View::viewCentreFrameChanged(View *, sv_frame_t )
Chris@211 1036 {
Chris@211 1037 // We do nothing with this, but a subclass might
Chris@211 1038 }
Chris@211 1039
Chris@211 1040 void
Chris@908 1041 View::viewManagerPlaybackFrameChanged(sv_frame_t f)
Chris@127 1042 {
Chris@127 1043 if (m_manager) {
Chris@127 1044 if (sender() != m_manager) return;
Chris@127 1045 }
Chris@127 1046
Chris@830 1047 #ifdef DEBUG_VIEW
Chris@830 1048 cerr << "View::viewManagerPlaybackFrameChanged(" << f << ")" << endl;
Chris@830 1049 #endif
Chris@830 1050
Chris@301 1051 f = getAlignedPlaybackFrame();
Chris@301 1052
Chris@830 1053 #ifdef DEBUG_VIEW
Chris@951 1054 cerr << " -> aligned frame = " << f << endl;
Chris@830 1055 #endif
Chris@830 1056
Chris@511 1057 movePlayPointer(f);
Chris@511 1058 }
Chris@511 1059
Chris@511 1060 void
Chris@908 1061 View::movePlayPointer(sv_frame_t newFrame)
Chris@511 1062 {
Chris@830 1063 #ifdef DEBUG_VIEW
Chris@830 1064 cerr << "View(" << this << ")::movePlayPointer(" << newFrame << ")" << endl;
Chris@830 1065 #endif
Chris@830 1066
Chris@511 1067 if (m_playPointerFrame == newFrame) return;
Chris@511 1068 bool visibleChange =
Chris@511 1069 (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame));
Chris@908 1070 sv_frame_t oldPlayPointerFrame = m_playPointerFrame;
Chris@511 1071 m_playPointerFrame = newFrame;
Chris@511 1072 if (!visibleChange) return;
Chris@127 1073
Chris@513 1074 bool somethingGoingOn =
Chris@513 1075 ((QApplication::mouseButtons() != Qt::NoButton) ||
Chris@513 1076 (QApplication::keyboardModifiers() & Qt::AltModifier));
Chris@513 1077
Chris@789 1078 bool pointerInVisibleArea =
Chris@789 1079 long(m_playPointerFrame) >= getStartFrame() &&
Chris@789 1080 (m_playPointerFrame < getEndFrame() ||
Chris@789 1081 // include old pointer location so we know to refresh when moving out
Chris@789 1082 oldPlayPointerFrame < getEndFrame());
Chris@789 1083
Chris@127 1084 switch (m_followPlay) {
Chris@127 1085
Chris@127 1086 case PlaybackScrollContinuous:
Chris@513 1087 if (!somethingGoingOn) {
Chris@511 1088 setCentreFrame(m_playPointerFrame, false);
Chris@127 1089 }
Chris@127 1090 break;
Chris@127 1091
Chris@127 1092 case PlaybackScrollPage:
Chris@815 1093 case PlaybackScrollPageWithCentre:
Chris@789 1094
Chris@789 1095 if (!pointerInVisibleArea && somethingGoingOn) {
Chris@789 1096
Chris@789 1097 m_followPlayIsDetached = true;
Chris@789 1098
Chris@789 1099 } else if (!pointerInVisibleArea && m_followPlayIsDetached) {
Chris@789 1100
Chris@789 1101 // do nothing; we aren't tracking until the pointer comes back in
Chris@789 1102
Chris@789 1103 } else {
Chris@789 1104
Chris@789 1105 int xold = getXForFrame(oldPlayPointerFrame);
Chris@789 1106 update(xold - 4, 0, 9, height());
Chris@789 1107
Chris@908 1108 sv_frame_t w = getEndFrame() - getStartFrame();
Chris@789 1109 w -= w/5;
Chris@908 1110 sv_frame_t sf = (m_playPointerFrame / w) * w - w/8;
Chris@789 1111
Chris@789 1112 if (m_manager &&
Chris@789 1113 m_manager->isPlaying() &&
Chris@789 1114 m_manager->getPlaySelectionMode()) {
Chris@789 1115 MultiSelection::SelectionList selections = m_manager->getSelections();
Chris@789 1116 if (!selections.empty()) {
Chris@908 1117 sv_frame_t selectionStart = selections.begin()->getStartFrame();
Chris@808 1118 if (sf < selectionStart - w / 10) {
Chris@808 1119 sf = selectionStart - w / 10;
Chris@789 1120 }
Chris@789 1121 }
Chris@789 1122 }
Chris@127 1123
Chris@127 1124 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@789 1125 cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame "
Chris@789 1126 << getStartFrame() << endl;
Chris@127 1127 #endif
Chris@127 1128
Chris@789 1129 // We don't consider scrolling unless the pointer is outside
Chris@789 1130 // the central visible range already
Chris@789 1131
Chris@789 1132 int xnew = getXForFrame(m_playPointerFrame);
Chris@127 1133
Chris@127 1134 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@789 1135 cerr << "xnew = " << xnew << ", width = " << width() << endl;
Chris@127 1136 #endif
Chris@127 1137
Chris@789 1138 bool shouldScroll = (xnew > (width() * 7) / 8);
Chris@789 1139
Chris@789 1140 if (!m_followPlayIsDetached && (xnew < width() / 8)) {
Chris@789 1141 shouldScroll = true;
Chris@789 1142 }
Chris@789 1143
Chris@789 1144 if (xnew > width() / 8) {
Chris@789 1145 m_followPlayIsDetached = false;
Chris@791 1146 } else if (somethingGoingOn) {
Chris@791 1147 m_followPlayIsDetached = true;
Chris@789 1148 }
Chris@789 1149
Chris@789 1150 if (!somethingGoingOn && shouldScroll) {
Chris@908 1151 sv_frame_t offset = getFrameForX(width()/2) - getStartFrame();
Chris@908 1152 sv_frame_t newCentre = sf + offset;
Chris@789 1153 bool changed = setCentreFrame(newCentre, false);
Chris@789 1154 if (changed) {
Chris@789 1155 xold = getXForFrame(oldPlayPointerFrame);
Chris@789 1156 update(xold - 4, 0, 9, height());
Chris@789 1157 }
Chris@789 1158 }
Chris@789 1159
Chris@789 1160 update(xnew - 4, 0, 9, height());
Chris@789 1161 }
Chris@789 1162 break;
Chris@127 1163
Chris@127 1164 case PlaybackIgnore:
Chris@806 1165 if (m_playPointerFrame >= getStartFrame() &&
Chris@511 1166 m_playPointerFrame < getEndFrame()) {
Chris@127 1167 update();
Chris@127 1168 }
Chris@127 1169 break;
Chris@127 1170 }
Chris@127 1171 }
Chris@127 1172
Chris@127 1173 void
Chris@806 1174 View::viewZoomLevelChanged(View *p, int z, bool locked)
Chris@127 1175 {
Chris@244 1176 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1177 cerr << "View[" << this << "]: viewZoomLevelChanged(" << p << ", " << z << ", " << locked << ")" << endl;
Chris@244 1178 #endif
Chris@127 1179 if (m_followZoom && p != this && locked) {
Chris@222 1180 setZoomLevel(z);
Chris@127 1181 }
Chris@127 1182 }
Chris@127 1183
Chris@127 1184 void
Chris@127 1185 View::selectionChanged()
Chris@127 1186 {
Chris@127 1187 if (m_selectionCached) {
Chris@127 1188 delete m_cache;
Chris@127 1189 m_cache = 0;
Chris@127 1190 m_selectionCached = false;
Chris@127 1191 }
Chris@127 1192 update();
Chris@127 1193 }
Chris@127 1194
Chris@908 1195 sv_frame_t
Chris@222 1196 View::getFirstVisibleFrame() const
Chris@222 1197 {
Chris@908 1198 sv_frame_t f0 = getStartFrame();
Chris@908 1199 sv_frame_t f = getModelsStartFrame();
Chris@806 1200 if (f0 < 0 || f0 < f) return f;
Chris@222 1201 return f0;
Chris@222 1202 }
Chris@222 1203
Chris@908 1204 sv_frame_t
Chris@222 1205 View::getLastVisibleFrame() const
Chris@222 1206 {
Chris@908 1207 sv_frame_t f0 = getEndFrame();
Chris@908 1208 sv_frame_t f = getModelsEndFrame();
Chris@222 1209 if (f0 > f) return f;
Chris@222 1210 return f0;
Chris@222 1211 }
Chris@222 1212
Chris@908 1213 sv_frame_t
Chris@127 1214 View::getModelsStartFrame() const
Chris@127 1215 {
Chris@127 1216 bool first = true;
Chris@908 1217 sv_frame_t startFrame = 0;
Chris@127 1218
Chris@835 1219 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 1220
Chris@127 1221 if ((*i)->getModel() && (*i)->getModel()->isOK()) {
Chris@127 1222
Chris@908 1223 sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame();
Chris@127 1224
Chris@127 1225 if (first || thisStartFrame < startFrame) {
Chris@127 1226 startFrame = thisStartFrame;
Chris@127 1227 }
Chris@127 1228 first = false;
Chris@127 1229 }
Chris@127 1230 }
Chris@127 1231 return startFrame;
Chris@127 1232 }
Chris@127 1233
Chris@908 1234 sv_frame_t
Chris@127 1235 View::getModelsEndFrame() const
Chris@127 1236 {
Chris@127 1237 bool first = true;
Chris@908 1238 sv_frame_t endFrame = 0;
Chris@127 1239
Chris@835 1240 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 1241
Chris@127 1242 if ((*i)->getModel() && (*i)->getModel()->isOK()) {
Chris@127 1243
Chris@908 1244 sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame();
Chris@127 1245
Chris@127 1246 if (first || thisEndFrame > endFrame) {
Chris@127 1247 endFrame = thisEndFrame;
Chris@127 1248 }
Chris@127 1249 first = false;
Chris@127 1250 }
Chris@127 1251 }
Chris@127 1252
Chris@127 1253 if (first) return getModelsStartFrame();
Chris@127 1254 return endFrame;
Chris@127 1255 }
Chris@127 1256
Chris@908 1257 sv_samplerate_t
Chris@127 1258 View::getModelsSampleRate() const
Chris@127 1259 {
Chris@127 1260 //!!! Just go for the first, for now. If we were supporting
Chris@127 1261 // multiple samplerates, we'd probably want to do frame/time
Chris@127 1262 // conversion in the model
Chris@127 1263
Chris@159 1264 //!!! nah, this wants to always return the sr of the main model!
Chris@159 1265
Chris@835 1266 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 1267 if ((*i)->getModel() && (*i)->getModel()->isOK()) {
Chris@127 1268 return (*i)->getModel()->getSampleRate();
Chris@127 1269 }
Chris@127 1270 }
Chris@127 1271 return 0;
Chris@127 1272 }
Chris@127 1273
Chris@315 1274 View::ModelSet
Chris@315 1275 View::getModels()
Chris@315 1276 {
Chris@315 1277 ModelSet models;
Chris@315 1278
Chris@315 1279 for (int i = 0; i < getLayerCount(); ++i) {
Chris@315 1280
Chris@315 1281 Layer *layer = getLayer(i);
Chris@315 1282
Chris@315 1283 if (dynamic_cast<TimeRulerLayer *>(layer)) {
Chris@315 1284 continue;
Chris@315 1285 }
Chris@315 1286
Chris@315 1287 if (layer && layer->getModel()) {
Chris@315 1288 Model *model = layer->getModel();
Chris@315 1289 models.insert(model);
Chris@315 1290 }
Chris@315 1291 }
Chris@315 1292
Chris@315 1293 return models;
Chris@315 1294 }
Chris@315 1295
Chris@320 1296 Model *
Chris@320 1297 View::getAligningModel() const
Chris@301 1298 {
Chris@320 1299 if (!m_manager ||
Chris@320 1300 !m_manager->getAlignMode() ||
Chris@314 1301 !m_manager->getPlaybackModel()) {
Chris@320 1302 return 0;
Chris@314 1303 }
Chris@301 1304
Chris@320 1305 Model *anyModel = 0;
Chris@359 1306 Model *alignedModel = 0;
Chris@320 1307 Model *goodModel = 0;
Chris@301 1308
Chris@835 1309 for (LayerList::const_iterator i = m_layerStack.begin();
Chris@835 1310 i != m_layerStack.end(); ++i) {
Chris@320 1311
Chris@320 1312 Layer *layer = *i;
Chris@320 1313
Chris@320 1314 if (!layer) continue;
Chris@320 1315 if (dynamic_cast<TimeRulerLayer *>(layer)) continue;
Chris@301 1316
Chris@301 1317 Model *model = (*i)->getModel();
Chris@301 1318 if (!model) continue;
Chris@301 1319
Chris@359 1320 anyModel = model;
Chris@359 1321
Chris@320 1322 if (model->getAlignmentReference()) {
Chris@359 1323 alignedModel = model;
Chris@320 1324 if (layer->isLayerOpaque() ||
Chris@320 1325 dynamic_cast<RangeSummarisableTimeValueModel *>(model)) {
Chris@320 1326 goodModel = model;
Chris@320 1327 }
Chris@301 1328 }
Chris@320 1329 }
Chris@301 1330
Chris@320 1331 if (goodModel) return goodModel;
Chris@359 1332 else if (alignedModel) return alignedModel;
Chris@320 1333 else return anyModel;
Chris@320 1334 }
Chris@320 1335
Chris@908 1336 sv_frame_t
Chris@908 1337 View::alignFromReference(sv_frame_t f) const
Chris@320 1338 {
Chris@856 1339 if (!m_manager || !m_manager->getAlignMode()) return f;
Chris@320 1340 Model *aligningModel = getAligningModel();
Chris@320 1341 if (!aligningModel) return f;
Chris@320 1342 return aligningModel->alignFromReference(f);
Chris@320 1343 }
Chris@320 1344
Chris@908 1345 sv_frame_t
Chris@908 1346 View::alignToReference(sv_frame_t f) const
Chris@320 1347 {
Chris@321 1348 if (!m_manager->getAlignMode()) return f;
Chris@320 1349 Model *aligningModel = getAligningModel();
Chris@320 1350 if (!aligningModel) return f;
Chris@320 1351 return aligningModel->alignToReference(f);
Chris@320 1352 }
Chris@320 1353
Chris@908 1354 sv_frame_t
Chris@320 1355 View::getAlignedPlaybackFrame() const
Chris@320 1356 {
Chris@856 1357 if (!m_manager) return 0;
Chris@908 1358 sv_frame_t pf = m_manager->getPlaybackFrame();
Chris@321 1359 if (!m_manager->getAlignMode()) return pf;
Chris@321 1360
Chris@320 1361 Model *aligningModel = getAligningModel();
Chris@320 1362 if (!aligningModel) return pf;
Chris@830 1363
Chris@908 1364 sv_frame_t af = aligningModel->alignFromReference(pf);
Chris@301 1365
Chris@301 1366 return af;
Chris@301 1367 }
Chris@301 1368
Chris@127 1369 bool
Chris@127 1370 View::areLayersScrollable() const
Chris@127 1371 {
Chris@127 1372 // True iff all views are scrollable
Chris@835 1373 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 1374 if (!(*i)->isLayerScrollable(this)) return false;
Chris@127 1375 }
Chris@127 1376 return true;
Chris@127 1377 }
Chris@127 1378
Chris@127 1379 View::LayerList
Chris@127 1380 View::getScrollableBackLayers(bool testChanged, bool &changed) const
Chris@127 1381 {
Chris@127 1382 changed = false;
Chris@127 1383
Chris@127 1384 // We want a list of all the scrollable layers that are behind the
Chris@127 1385 // backmost non-scrollable layer.
Chris@127 1386
Chris@127 1387 LayerList scrollables;
Chris@127 1388 bool metUnscrollable = false;
Chris@127 1389
Chris@835 1390 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@587 1391 // SVDEBUG << "View::getScrollableBackLayers: calling isLayerDormant on layer " << *i << endl;
Chris@682 1392 // cerr << "(name is " << (*i)->objectName() << ")"
Chris@682 1393 // << endl;
Chris@587 1394 // SVDEBUG << "View::getScrollableBackLayers: I am " << this << endl;
Chris@127 1395 if ((*i)->isLayerDormant(this)) continue;
Chris@127 1396 if ((*i)->isLayerOpaque()) {
Chris@127 1397 // You can't see anything behind an opaque layer!
Chris@127 1398 scrollables.clear();
Chris@127 1399 if (metUnscrollable) break;
Chris@127 1400 }
Chris@127 1401 if (!metUnscrollable && (*i)->isLayerScrollable(this)) {
Chris@127 1402 scrollables.push_back(*i);
Chris@127 1403 } else {
Chris@127 1404 metUnscrollable = true;
Chris@127 1405 }
Chris@127 1406 }
Chris@127 1407
Chris@127 1408 if (testChanged && scrollables != m_lastScrollableBackLayers) {
Chris@127 1409 m_lastScrollableBackLayers = scrollables;
Chris@127 1410 changed = true;
Chris@127 1411 }
Chris@127 1412 return scrollables;
Chris@127 1413 }
Chris@127 1414
Chris@127 1415 View::LayerList
Chris@127 1416 View::getNonScrollableFrontLayers(bool testChanged, bool &changed) const
Chris@127 1417 {
Chris@127 1418 changed = false;
Chris@127 1419 LayerList nonScrollables;
Chris@127 1420
Chris@127 1421 // Everything in front of the first non-scrollable from the back
Chris@127 1422 // should also be considered non-scrollable
Chris@127 1423
Chris@127 1424 bool started = false;
Chris@127 1425
Chris@835 1426 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 1427 if ((*i)->isLayerDormant(this)) continue;
Chris@127 1428 if (!started && (*i)->isLayerScrollable(this)) {
Chris@127 1429 continue;
Chris@127 1430 }
Chris@127 1431 started = true;
Chris@127 1432 if ((*i)->isLayerOpaque()) {
Chris@127 1433 // You can't see anything behind an opaque layer!
Chris@127 1434 nonScrollables.clear();
Chris@127 1435 }
Chris@127 1436 nonScrollables.push_back(*i);
Chris@127 1437 }
Chris@127 1438
Chris@127 1439 if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) {
Chris@127 1440 m_lastNonScrollableBackLayers = nonScrollables;
Chris@127 1441 changed = true;
Chris@127 1442 }
Chris@127 1443
Chris@127 1444 return nonScrollables;
Chris@127 1445 }
Chris@127 1446
Chris@806 1447 int
Chris@806 1448 View::getZoomConstraintBlockSize(int blockSize,
Chris@127 1449 ZoomConstraint::RoundingDirection dir)
Chris@127 1450 const
Chris@127 1451 {
Chris@806 1452 int candidate = blockSize;
Chris@127 1453 bool haveCandidate = false;
Chris@127 1454
Chris@127 1455 PowerOfSqrtTwoZoomConstraint defaultZoomConstraint;
Chris@127 1456
Chris@835 1457 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@127 1458
Chris@127 1459 const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint();
Chris@127 1460 if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint;
Chris@127 1461
Chris@806 1462 int thisBlockSize =
Chris@127 1463 zoomConstraint->getNearestBlockSize(blockSize, dir);
Chris@127 1464
Chris@127 1465 // Go for the block size that's furthest from the one
Chris@127 1466 // passed in. Most of the time, that's what we want.
Chris@127 1467 if (!haveCandidate ||
Chris@127 1468 (thisBlockSize > blockSize && thisBlockSize > candidate) ||
Chris@127 1469 (thisBlockSize < blockSize && thisBlockSize < candidate)) {
Chris@127 1470 candidate = thisBlockSize;
Chris@127 1471 haveCandidate = true;
Chris@127 1472 }
Chris@127 1473 }
Chris@127 1474
Chris@127 1475 return candidate;
Chris@127 1476 }
Chris@127 1477
Chris@183 1478 bool
Chris@183 1479 View::areLayerColoursSignificant() const
Chris@183 1480 {
Chris@835 1481 for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) {
Chris@287 1482 if ((*i)->getLayerColourSignificance() ==
Chris@287 1483 Layer::ColourHasMeaningfulValue) return true;
Chris@183 1484 if ((*i)->isLayerOpaque()) break;
Chris@183 1485 }
Chris@183 1486 return false;
Chris@183 1487 }
Chris@183 1488
Chris@217 1489 bool
Chris@217 1490 View::hasTopLayerTimeXAxis() const
Chris@217 1491 {
Chris@835 1492 LayerList::const_iterator i = m_layerStack.end();
Chris@835 1493 if (i == m_layerStack.begin()) return false;
Chris@217 1494 --i;
Chris@217 1495 return (*i)->hasTimeXAxis();
Chris@217 1496 }
Chris@217 1497
Chris@127 1498 void
Chris@127 1499 View::zoom(bool in)
Chris@127 1500 {
Chris@127 1501 int newZoomLevel = m_zoomLevel;
Chris@127 1502
Chris@127 1503 if (in) {
Chris@127 1504 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1,
Chris@127 1505 ZoomConstraint::RoundDown);
Chris@127 1506 } else {
Chris@127 1507 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1,
Chris@127 1508 ZoomConstraint::RoundUp);
Chris@127 1509 }
Chris@127 1510
Chris@127 1511 if (newZoomLevel != m_zoomLevel) {
Chris@127 1512 setZoomLevel(newZoomLevel);
Chris@127 1513 }
Chris@127 1514 }
Chris@127 1515
Chris@127 1516 void
Chris@510 1517 View::scroll(bool right, bool lots, bool e)
Chris@127 1518 {
Chris@908 1519 sv_frame_t delta;
Chris@127 1520 if (lots) {
Chris@127 1521 delta = (getEndFrame() - getStartFrame()) / 2;
Chris@127 1522 } else {
Chris@127 1523 delta = (getEndFrame() - getStartFrame()) / 20;
Chris@127 1524 }
Chris@127 1525 if (right) delta = -delta;
Chris@127 1526
Chris@908 1527 if (m_centreFrame < delta) {
Chris@510 1528 setCentreFrame(0, e);
Chris@908 1529 } else if (m_centreFrame - delta >= getModelsEndFrame()) {
Chris@510 1530 setCentreFrame(getModelsEndFrame(), e);
Chris@127 1531 } else {
Chris@510 1532 setCentreFrame(m_centreFrame - delta, e);
Chris@127 1533 }
Chris@127 1534 }
Chris@127 1535
Chris@127 1536 void
Chris@797 1537 View::cancelClicked()
Chris@797 1538 {
Chris@797 1539 QPushButton *cancel = qobject_cast<QPushButton *>(sender());
Chris@797 1540 if (!cancel) return;
Chris@797 1541
Chris@797 1542 for (ProgressMap::iterator i = m_progressBars.begin();
Chris@797 1543 i != m_progressBars.end(); ++i) {
Chris@797 1544
Chris@797 1545 if (i->second.cancel == cancel) {
Chris@797 1546
Chris@797 1547 Layer *layer = i->first;
Chris@797 1548 Model *model = layer->getModel();
Chris@797 1549
Chris@797 1550 if (model) model->abandon();
Chris@797 1551 }
Chris@797 1552 }
Chris@797 1553 }
Chris@797 1554
Chris@797 1555 void
Chris@127 1556 View::checkProgress(void *object)
Chris@127 1557 {
Chris@127 1558 if (!m_showProgress) return;
Chris@127 1559
Chris@127 1560 int ph = height();
Chris@127 1561
Chris@555 1562 for (ProgressMap::iterator i = m_progressBars.begin();
Chris@127 1563 i != m_progressBars.end(); ++i) {
Chris@127 1564
Chris@555 1565 QProgressBar *pb = i->second.bar;
Chris@797 1566 QPushButton *cancel = i->second.cancel;
Chris@555 1567
Chris@127 1568 if (i->first == object) {
Chris@127 1569
Chris@555 1570 // The timer is used to test for stalls. If the progress
Chris@555 1571 // bar does not get updated for some length of time, the
Chris@555 1572 // timer prompts it to go back into "indeterminate" mode
Chris@555 1573 QTimer *timer = i->second.checkTimer;
Chris@555 1574
Chris@127 1575 int completion = i->first->getCompletion(this);
Chris@301 1576 QString text = i->first->getPropertyContainerName();
Chris@583 1577 QString error = i->first->getError(this);
Chris@583 1578
Chris@583 1579 if (error != "" && error != m_lastError) {
Chris@583 1580 QMessageBox::critical(this, tr("Layer rendering error"), error);
Chris@583 1581 m_lastError = error;
Chris@583 1582 }
Chris@301 1583
Chris@387 1584 Model *model = i->first->getModel();
Chris@387 1585 RangeSummarisableTimeValueModel *wfm =
Chris@387 1586 dynamic_cast<RangeSummarisableTimeValueModel *>(model);
Chris@387 1587
Chris@388 1588 if (completion > 0) {
Chris@555 1589 pb->setMaximum(100); // was 0, for indeterminate start
Chris@388 1590 }
Chris@388 1591
Chris@301 1592 if (completion >= 100) {
Chris@301 1593
Chris@301 1594 //!!!
Chris@326 1595 if (wfm ||
Chris@776 1596 (model &&
Chris@776 1597 (wfm = dynamic_cast<RangeSummarisableTimeValueModel *>
Chris@776 1598 (model->getSourceModel())))) {
Chris@301 1599 completion = wfm->getAlignmentCompletion();
Chris@587 1600 // SVDEBUG << "View::checkProgress: Alignment completion = " << completion << endl;
Chris@301 1601 if (completion < 100) {
Chris@301 1602 text = tr("Alignment");
Chris@301 1603 }
Chris@301 1604 }
Chris@387 1605
Chris@387 1606 } else if (wfm) {
Chris@387 1607 update(); // ensure duration &c gets updated
Chris@301 1608 }
Chris@127 1609
Chris@127 1610 if (completion >= 100) {
Chris@127 1611
Chris@555 1612 pb->hide();
Chris@797 1613 cancel->hide();
Chris@555 1614 timer->stop();
Chris@127 1615
Chris@127 1616 } else {
Chris@127 1617
Chris@682 1618 // cerr << "progress = " << completion << endl;
Chris@555 1619
Chris@555 1620 if (!pb->isVisible()) {
Chris@555 1621 i->second.lastCheck = 0;
Chris@555 1622 timer->setInterval(2000);
Chris@555 1623 timer->start();
Chris@555 1624 }
Chris@555 1625
Chris@797 1626 cancel->move(0, ph - pb->height()/2 - 10);
Chris@797 1627 cancel->show();
Chris@797 1628
Chris@555 1629 pb->setValue(completion);
Chris@797 1630 pb->move(20, ph - pb->height());
Chris@555 1631
Chris@555 1632 pb->show();
Chris@555 1633 pb->update();
Chris@555 1634
Chris@555 1635 ph -= pb->height();
Chris@127 1636 }
Chris@127 1637 } else {
Chris@555 1638 if (pb->isVisible()) {
Chris@555 1639 ph -= pb->height();
Chris@127 1640 }
Chris@127 1641 }
Chris@127 1642 }
Chris@127 1643 }
Chris@127 1644
Chris@555 1645 void
Chris@555 1646 View::progressCheckStalledTimerElapsed()
Chris@555 1647 {
Chris@555 1648 QObject *s = sender();
Chris@555 1649 QTimer *t = qobject_cast<QTimer *>(s);
Chris@555 1650 if (!t) return;
Chris@555 1651 for (ProgressMap::iterator i = m_progressBars.begin();
Chris@555 1652 i != m_progressBars.end(); ++i) {
Chris@555 1653 if (i->second.checkTimer == t) {
Chris@555 1654 int value = i->second.bar->value();
Chris@555 1655 if (value > 0 && value == i->second.lastCheck) {
Chris@555 1656 i->second.bar->setMaximum(0); // indeterminate
Chris@555 1657 }
Chris@555 1658 i->second.lastCheck = value;
Chris@555 1659 return;
Chris@555 1660 }
Chris@555 1661 }
Chris@555 1662 }
Chris@555 1663
Chris@384 1664 int
Chris@384 1665 View::getProgressBarWidth() const
Chris@384 1666 {
Chris@384 1667 for (ProgressMap::const_iterator i = m_progressBars.begin();
Chris@384 1668 i != m_progressBars.end(); ++i) {
Chris@555 1669 if (i->second.bar && i->second.bar->isVisible()) {
Chris@555 1670 return i->second.bar->width();
Chris@555 1671 }
Chris@384 1672 }
Chris@384 1673
Chris@384 1674 return 0;
Chris@384 1675 }
Chris@384 1676
Chris@127 1677 void
Chris@339 1678 View::setPaintFont(QPainter &paint)
Chris@339 1679 {
Chris@955 1680 int scaleFactor = 1;
Chris@956 1681 int dpratio = effectiveDevicePixelRatio();
Chris@955 1682 if (dpratio > 1) {
Chris@955 1683 QPaintDevice *dev = paint.device();
Chris@955 1684 if (dynamic_cast<QPixmap *>(dev) || dynamic_cast<QImage *>(dev)) {
Chris@955 1685 scaleFactor = dpratio;
Chris@955 1686 }
Chris@955 1687 }
Chris@955 1688
Chris@339 1689 QFont font(paint.font());
Chris@955 1690 font.setPointSize(Preferences::getInstance()->getViewFontSize()
Chris@955 1691 * scaleFactor);
Chris@339 1692 paint.setFont(font);
Chris@339 1693 }
Chris@339 1694
Chris@915 1695 QRect
Chris@915 1696 View::getPaintRect() const
Chris@915 1697 {
Chris@919 1698 return rect();
Chris@915 1699 }
Chris@915 1700
Chris@339 1701 void
Chris@127 1702 View::paintEvent(QPaintEvent *e)
Chris@127 1703 {
Chris@127 1704 // Profiler prof("View::paintEvent", false);
Chris@800 1705 // cerr << "View::paintEvent: centre frame is " << m_centreFrame << endl;
matthiasm@785 1706
Chris@835 1707 if (m_layerStack.empty()) {
Chris@127 1708 QFrame::paintEvent(e);
Chris@127 1709 return;
Chris@127 1710 }
Chris@127 1711
Chris@127 1712 // ensure our constraints are met
Chris@137 1713
Chris@137 1714 /*!!! Should we do this only if we have layers that can't support other
Chris@137 1715 zoom levels?
Chris@137 1716
Chris@127 1717 m_zoomLevel = getZoomConstraintBlockSize(m_zoomLevel,
Chris@127 1718 ZoomConstraint::RoundUp);
Chris@137 1719 */
Chris@127 1720
Chris@127 1721 QPainter paint;
Chris@127 1722 bool repaintCache = false;
Chris@127 1723 bool paintedCacheRect = false;
Chris@127 1724
Chris@127 1725 QRect cacheRect(rect());
Chris@127 1726
Chris@127 1727 if (e) {
Chris@127 1728 cacheRect &= e->rect();
Chris@127 1729 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1730 cerr << "paint rect " << cacheRect.width() << "x" << cacheRect.height()
Chris@682 1731 << ", my rect " << width() << "x" << height() << endl;
Chris@127 1732 #endif
Chris@127 1733 }
Chris@127 1734
Chris@127 1735 QRect nonCacheRect(cacheRect);
Chris@127 1736
Chris@956 1737 int dpratio = effectiveDevicePixelRatio();
Chris@953 1738
Chris@127 1739 // If not all layers are scrollable, but some of the back layers
Chris@127 1740 // are, we should store only those in the cache.
Chris@127 1741
Chris@127 1742 bool layersChanged = false;
Chris@127 1743 LayerList scrollables = getScrollableBackLayers(true, layersChanged);
Chris@127 1744 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged);
Chris@127 1745 bool selectionCacheable = nonScrollables.empty();
Chris@127 1746 bool haveSelections = m_manager && !m_manager->getSelections().empty();
Chris@127 1747
Chris@127 1748 // If all the non-scrollable layers are non-opaque, then we draw
Chris@127 1749 // the selection rectangle behind them and cache it. If any are
Chris@953 1750 // opaque, however, or if our device-pixel ratio is not 1 (so we
Chris@953 1751 // need to paint direct to the widget), then we can't cache.
Chris@127 1752 //
Chris@953 1753 if (dpratio == 1) {
Chris@953 1754
Chris@953 1755 if (!selectionCacheable) {
Chris@953 1756 selectionCacheable = true;
Chris@953 1757 for (LayerList::const_iterator i = nonScrollables.begin();
Chris@953 1758 i != nonScrollables.end(); ++i) {
Chris@953 1759 if ((*i)->isLayerOpaque()) {
Chris@953 1760 selectionCacheable = false;
Chris@953 1761 break;
Chris@953 1762 }
Chris@953 1763 }
Chris@953 1764 }
Chris@953 1765
Chris@953 1766 if (selectionCacheable) {
Chris@953 1767 QPoint localPos;
Chris@953 1768 bool closeToLeft, closeToRight;
Chris@953 1769 if (shouldIlluminateLocalSelection
Chris@953 1770 (localPos, closeToLeft, closeToRight)) {
Chris@953 1771 selectionCacheable = false;
Chris@953 1772 }
Chris@953 1773 }
Chris@953 1774
Chris@953 1775 } else {
Chris@953 1776
Chris@953 1777 selectionCacheable = false;
Chris@127 1778 }
Chris@127 1779
Chris@127 1780 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1781 cerr << "View(" << this << ")::paintEvent: have " << scrollables.size()
Chris@127 1782 << " scrollable back layers and " << nonScrollables.size()
Chris@682 1783 << " non-scrollable front layers" << endl;
Chris@682 1784 cerr << "haveSelections " << haveSelections << ", selectionCacheable "
Chris@682 1785 << selectionCacheable << ", m_selectionCached " << m_selectionCached << endl;
Chris@127 1786 #endif
Chris@127 1787
Chris@127 1788 if (layersChanged || scrollables.empty() ||
Chris@127 1789 (haveSelections && (selectionCacheable != m_selectionCached))) {
Chris@127 1790 delete m_cache;
Chris@127 1791 m_cache = 0;
Chris@127 1792 m_selectionCached = false;
Chris@127 1793 }
Chris@127 1794
Chris@952 1795 QSize scaledCacheSize(scaledSize(size(), dpratio));
Chris@952 1796 QRect scaledCacheRect(scaledRect(cacheRect, dpratio));
Chris@952 1797
Chris@952 1798 if (!m_buffer || scaledCacheSize != m_buffer->size()) {
Chris@952 1799 delete m_buffer;
Chris@952 1800 m_buffer = new QPixmap(scaledCacheSize);
Chris@952 1801 }
Chris@952 1802
Chris@127 1803 if (!scrollables.empty()) {
Chris@244 1804
Chris@244 1805 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1806 cerr << "View(" << this << "): cache " << m_cache << ", cache zoom "
Chris@682 1807 << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl;
Chris@244 1808 #endif
Chris@244 1809
Chris@127 1810 if (!m_cache ||
Chris@127 1811 m_cacheZoomLevel != m_zoomLevel ||
Chris@914 1812 scaledCacheSize != m_cache->size()) {
Chris@127 1813
Chris@127 1814 // cache is not valid
Chris@127 1815
Chris@127 1816 if (cacheRect.width() < width()/10) {
Chris@244 1817 delete m_cache;
Chris@244 1818 m_cache = 0;
Chris@127 1819 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1820 cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl;
Chris@127 1821 #endif
Chris@127 1822 } else {
Chris@127 1823 delete m_cache;
Chris@914 1824 m_cache = new QPixmap(scaledCacheSize);
Chris@127 1825 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1826 cerr << "View(" << this << ")::paintEvent: recreated cache" << endl;
Chris@127 1827 #endif
Chris@127 1828 cacheRect = rect();
Chris@127 1829 repaintCache = true;
Chris@127 1830 }
Chris@127 1831
Chris@127 1832 } else if (m_cacheCentreFrame != m_centreFrame) {
Chris@127 1833
Chris@806 1834 int dx =
Chris@127 1835 getXForFrame(m_cacheCentreFrame) -
Chris@127 1836 getXForFrame(m_centreFrame);
Chris@127 1837
Chris@127 1838 if (dx > -width() && dx < width()) {
Chris@127 1839 static QPixmap *tmpPixmap = 0;
Chris@914 1840 if (!tmpPixmap || tmpPixmap->size() != scaledCacheSize) {
Chris@127 1841 delete tmpPixmap;
Chris@914 1842 tmpPixmap = new QPixmap(scaledCacheSize);
Chris@127 1843 }
Chris@127 1844 paint.begin(tmpPixmap);
Chris@127 1845 paint.drawPixmap(0, 0, *m_cache);
Chris@127 1846 paint.end();
Chris@127 1847 paint.begin(m_cache);
Chris@127 1848 paint.drawPixmap(dx, 0, *tmpPixmap);
Chris@127 1849 paint.end();
Chris@127 1850 if (dx < 0) {
Chris@127 1851 cacheRect = QRect(width() + dx, 0, -dx, height());
Chris@127 1852 } else {
Chris@127 1853 cacheRect = QRect(0, 0, dx, height());
Chris@127 1854 }
Chris@127 1855 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1856 cerr << "View(" << this << ")::paintEvent: scrolled cache by " << dx << endl;
Chris@127 1857 #endif
Chris@127 1858 } else {
Chris@127 1859 cacheRect = rect();
Chris@127 1860 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1861 cerr << "View(" << this << ")::paintEvent: scrolling too far" << endl;
Chris@127 1862 #endif
Chris@127 1863 }
Chris@127 1864 repaintCache = true;
Chris@127 1865
Chris@127 1866 } else {
Chris@127 1867 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1868 cerr << "View(" << this << ")::paintEvent: cache is good" << endl;
Chris@127 1869 #endif
Chris@952 1870 paint.begin(m_buffer);
Chris@952 1871 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect);
Chris@127 1872 paint.end();
Chris@127 1873 QFrame::paintEvent(e);
Chris@127 1874 paintedCacheRect = true;
Chris@127 1875 }
Chris@127 1876
Chris@127 1877 m_cacheCentreFrame = m_centreFrame;
Chris@127 1878 m_cacheZoomLevel = m_zoomLevel;
Chris@127 1879 }
Chris@127 1880
Chris@127 1881 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@682 1882 // cerr << "View(" << this << ")::paintEvent: cacheRect " << cacheRect << ", nonCacheRect " << (nonCacheRect | cacheRect) << ", repaintCache " << repaintCache << ", paintedCacheRect " << paintedCacheRect << endl;
Chris@127 1883 #endif
Chris@127 1884
Chris@127 1885 // Scrollable (cacheable) items first
Chris@127 1886
Chris@919 1887 ViewProxy proxy(this, dpratio);
Chris@919 1888
Chris@127 1889 if (!paintedCacheRect) {
Chris@127 1890
Chris@914 1891 QRect rectToPaint;
Chris@914 1892
Chris@914 1893 if (repaintCache) {
Chris@914 1894 paint.begin(m_cache);
Chris@914 1895 rectToPaint = scaledCacheRect;
Chris@914 1896 } else {
Chris@952 1897 paint.begin(m_buffer);
Chris@952 1898 rectToPaint = scaledCacheRect;
Chris@914 1899 }
Chris@914 1900
Chris@339 1901 setPaintFont(paint);
Chris@914 1902 paint.setClipRect(rectToPaint);
Chris@287 1903
Chris@287 1904 paint.setPen(getBackground());
Chris@287 1905 paint.setBrush(getBackground());
Chris@914 1906 paint.drawRect(rectToPaint);
Chris@127 1907
Chris@287 1908 paint.setPen(getForeground());
Chris@127 1909 paint.setBrush(Qt::NoBrush);
Chris@127 1910
Chris@127 1911 for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) {
Chris@127 1912 paint.setRenderHint(QPainter::Antialiasing, false);
Chris@127 1913 paint.save();
Chris@951 1914 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@951 1915 cerr << "Painting scrollable layer " << *i << " using proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << rectToPaint.x() << "," << rectToPaint.y() << " " << rectToPaint.width() << "x" << rectToPaint.height() << endl;
Chris@951 1916 #endif
Chris@919 1917 (*i)->paint(&proxy, paint, rectToPaint);
Chris@127 1918 paint.restore();
Chris@127 1919 }
Chris@127 1920
Chris@127 1921 if (haveSelections && selectionCacheable) {
Chris@127 1922 drawSelections(paint);
Chris@127 1923 m_selectionCached = repaintCache;
Chris@127 1924 }
Chris@127 1925
Chris@127 1926 paint.end();
Chris@127 1927
Chris@127 1928 if (repaintCache) {
Chris@127 1929 cacheRect |= (e ? e->rect() : rect());
Chris@952 1930 scaledCacheRect = scaledRect(cacheRect, dpratio);
Chris@952 1931 paint.begin(m_buffer);
Chris@952 1932 paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect);
Chris@127 1933 paint.end();
Chris@127 1934 }
Chris@127 1935 }
Chris@127 1936
Chris@127 1937 // Now non-cacheable items. We always need to redraw the
Chris@127 1938 // non-cacheable items across at least the area we drew of the
Chris@127 1939 // cacheable items.
Chris@127 1940
Chris@127 1941 nonCacheRect |= cacheRect;
Chris@127 1942
Chris@952 1943 QRect scaledNonCacheRect = scaledRect(nonCacheRect, dpratio);
Chris@952 1944
Chris@952 1945 paint.begin(m_buffer);
Chris@952 1946 paint.setClipRect(scaledNonCacheRect);
Chris@339 1947 setPaintFont(paint);
Chris@127 1948 if (scrollables.empty()) {
Chris@287 1949 paint.setPen(getBackground());
Chris@287 1950 paint.setBrush(getBackground());
Chris@952 1951 paint.drawRect(scaledNonCacheRect);
Chris@127 1952 }
Chris@127 1953
Chris@287 1954 paint.setPen(getForeground());
Chris@127 1955 paint.setBrush(Qt::NoBrush);
Chris@127 1956
Chris@127 1957 for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) {
Chris@127 1958 // Profiler profiler2("View::paintEvent non-cacheable");
Chris@951 1959 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@951 1960 cerr << "Painting non-scrollable layer " << *i << " without proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << nonCacheRect.x() << "," << nonCacheRect.y() << " " << nonCacheRect.width() << "x" << nonCacheRect.height() << endl;
Chris@951 1961 #endif
Chris@952 1962 (*i)->paint(&proxy, paint, scaledNonCacheRect);
Chris@127 1963 }
Chris@127 1964
Chris@127 1965 paint.end();
Chris@953 1966
Chris@953 1967 paint.begin(this);
Chris@953 1968 QRect finalPaintRect = e ? e->rect() : rect();
Chris@953 1969 paint.drawPixmap(finalPaintRect, *m_buffer, scaledRect(finalPaintRect, dpratio));
Chris@953 1970 paint.end();
Chris@953 1971
Chris@953 1972 paint.begin(this);
Chris@339 1973 setPaintFont(paint);
Chris@953 1974 if (e) paint.setClipRect(e->rect());
Chris@127 1975 if (!m_selectionCached) {
Chris@127 1976 drawSelections(paint);
Chris@127 1977 }
Chris@127 1978 paint.end();
Chris@127 1979
Chris@211 1980 bool showPlayPointer = true;
Chris@211 1981 if (m_followPlay == PlaybackScrollContinuous) {
Chris@211 1982 showPlayPointer = false;
Chris@806 1983 } else if (m_playPointerFrame <= getStartFrame() ||
Chris@211 1984 m_playPointerFrame >= getEndFrame()) {
Chris@211 1985 showPlayPointer = false;
Chris@211 1986 } else if (m_manager && !m_manager->isPlaying()) {
Chris@211 1987 if (m_playPointerFrame == getCentreFrame() &&
Chris@787 1988 m_manager->shouldShowCentreLine() &&
Chris@211 1989 m_followPlay != PlaybackIgnore) {
Chris@787 1990 // Don't show the play pointer when it is redundant with
Chris@787 1991 // the centre line
Chris@211 1992 showPlayPointer = false;
Chris@211 1993 }
Chris@211 1994 }
Chris@952 1995
Chris@211 1996 if (showPlayPointer) {
Chris@127 1997
Chris@127 1998 paint.begin(this);
Chris@127 1999
Chris@211 2000 int playx = getXForFrame(m_playPointerFrame);
Chris@211 2001
Chris@287 2002 paint.setPen(getForeground());
Chris@211 2003 paint.drawLine(playx - 1, 0, playx - 1, height() - 1);
Chris@211 2004 paint.drawLine(playx + 1, 0, playx + 1, height() - 1);
Chris@211 2005 paint.drawPoint(playx, 0);
Chris@211 2006 paint.drawPoint(playx, height() - 1);
Chris@287 2007 paint.setPen(getBackground());
Chris@211 2008 paint.drawLine(playx, 1, playx, height() - 2);
Chris@127 2009
Chris@127 2010 paint.end();
Chris@127 2011 }
Chris@127 2012
Chris@127 2013 QFrame::paintEvent(e);
Chris@127 2014 }
Chris@127 2015
Chris@127 2016 void
Chris@127 2017 View::drawSelections(QPainter &paint)
Chris@127 2018 {
Chris@217 2019 if (!hasTopLayerTimeXAxis()) return;
Chris@217 2020
Chris@127 2021 MultiSelection::SelectionList selections;
Chris@127 2022
Chris@127 2023 if (m_manager) {
Chris@127 2024 selections = m_manager->getSelections();
Chris@127 2025 if (m_manager->haveInProgressSelection()) {
Chris@127 2026 bool exclusive;
Chris@127 2027 Selection inProgressSelection =
Chris@127 2028 m_manager->getInProgressSelection(exclusive);
Chris@127 2029 if (exclusive) selections.clear();
Chris@127 2030 selections.insert(inProgressSelection);
Chris@127 2031 }
Chris@127 2032 }
Chris@127 2033
Chris@127 2034 paint.save();
Chris@183 2035
Chris@183 2036 bool translucent = !areLayerColoursSignificant();
Chris@183 2037
Chris@183 2038 if (translucent) {
Chris@183 2039 paint.setBrush(QColor(150, 150, 255, 80));
Chris@183 2040 } else {
Chris@183 2041 paint.setBrush(Qt::NoBrush);
Chris@183 2042 }
Chris@127 2043
Chris@908 2044 sv_samplerate_t sampleRate = getModelsSampleRate();
Chris@127 2045
Chris@127 2046 QPoint localPos;
Chris@908 2047 sv_frame_t illuminateFrame = -1;
Chris@127 2048 bool closeToLeft, closeToRight;
Chris@127 2049
Chris@127 2050 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) {
Chris@127 2051 illuminateFrame = getFrameForX(localPos.x());
Chris@127 2052 }
Chris@127 2053
Chris@127 2054 const QFontMetrics &metrics = paint.fontMetrics();
Chris@127 2055
Chris@127 2056 for (MultiSelection::SelectionList::iterator i = selections.begin();
Chris@127 2057 i != selections.end(); ++i) {
Chris@127 2058
Chris@333 2059 int p0 = getXForFrame(alignFromReference(i->getStartFrame()));
Chris@333 2060 int p1 = getXForFrame(alignFromReference(i->getEndFrame()));
Chris@127 2061
Chris@127 2062 if (p1 < 0 || p0 > width()) continue;
Chris@127 2063
Chris@127 2064 #ifdef DEBUG_VIEW_WIDGET_PAINT
Chris@587 2065 SVDEBUG << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << endl;
Chris@127 2066 #endif
Chris@127 2067
Chris@127 2068 bool illuminateThis =
Chris@127 2069 (illuminateFrame >= 0 && i->contains(illuminateFrame));
Chris@127 2070
Chris@127 2071 paint.setPen(QColor(150, 150, 255));
Chris@183 2072
Chris@183 2073 if (translucent && shouldLabelSelections()) {
Chris@183 2074 paint.drawRect(p0, -1, p1 - p0, height() + 1);
Chris@183 2075 } else {
Chris@183 2076 // Make the top & bottom lines of the box visible if we
Chris@183 2077 // are lacking some of the other visual cues. There's no
Chris@183 2078 // particular logic to this, it's just a question of what
Chris@183 2079 // I happen to think looks nice.
Chris@183 2080 paint.drawRect(p0, 0, p1 - p0, height() - 1);
Chris@183 2081 }
Chris@127 2082
Chris@127 2083 if (illuminateThis) {
Chris@127 2084 paint.save();
Chris@287 2085 paint.setPen(QPen(getForeground(), 2));
Chris@127 2086 if (closeToLeft) {
Chris@127 2087 paint.drawLine(p0, 1, p1, 1);
Chris@127 2088 paint.drawLine(p0, 0, p0, height());
Chris@127 2089 paint.drawLine(p0, height() - 1, p1, height() - 1);
Chris@127 2090 } else if (closeToRight) {
Chris@127 2091 paint.drawLine(p0, 1, p1, 1);
Chris@127 2092 paint.drawLine(p1, 0, p1, height());
Chris@127 2093 paint.drawLine(p0, height() - 1, p1, height() - 1);
Chris@127 2094 } else {
Chris@127 2095 paint.setBrush(Qt::NoBrush);
Chris@127 2096 paint.drawRect(p0, 1, p1 - p0, height() - 2);
Chris@127 2097 }
Chris@127 2098 paint.restore();
Chris@127 2099 }
Chris@127 2100
Chris@127 2101 if (sampleRate && shouldLabelSelections() && m_manager &&
Chris@189 2102 m_manager->shouldShowSelectionExtents()) {
Chris@127 2103
Chris@127 2104 QString startText = QString("%1 / %2")
Chris@127 2105 .arg(QString::fromStdString
Chris@127 2106 (RealTime::frame2RealTime
Chris@127 2107 (i->getStartFrame(), sampleRate).toText(true)))
Chris@127 2108 .arg(i->getStartFrame());
Chris@127 2109
Chris@127 2110 QString endText = QString(" %1 / %2")
Chris@127 2111 .arg(QString::fromStdString
Chris@127 2112 (RealTime::frame2RealTime
Chris@127 2113 (i->getEndFrame(), sampleRate).toText(true)))
Chris@127 2114 .arg(i->getEndFrame());
Chris@127 2115
Chris@127 2116 QString durationText = QString("(%1 / %2) ")
Chris@127 2117 .arg(QString::fromStdString
Chris@127 2118 (RealTime::frame2RealTime
Chris@127 2119 (i->getEndFrame() - i->getStartFrame(), sampleRate)
Chris@127 2120 .toText(true)))
Chris@127 2121 .arg(i->getEndFrame() - i->getStartFrame());
Chris@127 2122
Chris@127 2123 int sw = metrics.width(startText),
Chris@127 2124 ew = metrics.width(endText),
Chris@127 2125 dw = metrics.width(durationText);
Chris@127 2126
Chris@127 2127 int sy = metrics.ascent() + metrics.height() + 4;
Chris@127 2128 int ey = sy;
Chris@127 2129 int dy = sy + metrics.height();
Chris@127 2130
Chris@127 2131 int sx = p0 + 2;
Chris@127 2132 int ex = sx;
Chris@127 2133 int dx = sx;
Chris@127 2134
Chris@501 2135 bool durationBothEnds = true;
Chris@501 2136
Chris@127 2137 if (sw + ew > (p1 - p0)) {
Chris@127 2138 ey += metrics.height();
Chris@127 2139 dy += metrics.height();
Chris@501 2140 durationBothEnds = false;
Chris@127 2141 }
Chris@127 2142
Chris@127 2143 if (ew < (p1 - p0)) {
Chris@127 2144 ex = p1 - 2 - ew;
Chris@127 2145 }
Chris@127 2146
Chris@127 2147 if (dw < (p1 - p0)) {
Chris@127 2148 dx = p1 - 2 - dw;
Chris@127 2149 }
Chris@127 2150
Chris@127 2151 paint.drawText(sx, sy, startText);
Chris@127 2152 paint.drawText(ex, ey, endText);
Chris@127 2153 paint.drawText(dx, dy, durationText);
Chris@501 2154 if (durationBothEnds) {
Chris@501 2155 paint.drawText(sx, dy, durationText);
Chris@501 2156 }
Chris@127 2157 }
Chris@127 2158 }
Chris@127 2159
Chris@127 2160 paint.restore();
Chris@127 2161 }
Chris@127 2162
Chris@267 2163 void
Chris@270 2164 View::drawMeasurementRect(QPainter &paint, const Layer *topLayer, QRect r,
Chris@270 2165 bool focus) const
Chris@267 2166 {
Chris@587 2167 // SVDEBUG << "View::drawMeasurementRect(" << r.x() << "," << r.y() << " "
Chris@585 2168 // << r.width() << "x" << r.height() << ")" << endl;
Chris@268 2169
Chris@267 2170 if (r.x() + r.width() < 0 || r.x() >= width()) return;
Chris@267 2171
Chris@270 2172 if (r.width() != 0 || r.height() != 0) {
Chris@270 2173 paint.save();
Chris@270 2174 if (focus) {
Chris@270 2175 paint.setPen(Qt::NoPen);
Chris@272 2176 QColor brushColour(Qt::black);
Chris@272 2177 brushColour.setAlpha(hasLightBackground() ? 15 : 40);
Chris@270 2178 paint.setBrush(brushColour);
Chris@270 2179 if (r.x() > 0) {
Chris@270 2180 paint.drawRect(0, 0, r.x(), height());
Chris@270 2181 }
Chris@270 2182 if (r.x() + r.width() < width()) {
Chris@270 2183 paint.drawRect(r.x() + r.width(), 0, width()-r.x()-r.width(), height());
Chris@270 2184 }
Chris@270 2185 if (r.y() > 0) {
Chris@270 2186 paint.drawRect(r.x(), 0, r.width(), r.y());
Chris@270 2187 }
Chris@270 2188 if (r.y() + r.height() < height()) {
Chris@270 2189 paint.drawRect(r.x(), r.y() + r.height(), r.width(), height()-r.y()-r.height());
Chris@270 2190 }
Chris@270 2191 paint.setBrush(Qt::NoBrush);
Chris@270 2192 }
Chris@270 2193 paint.setPen(Qt::green);
Chris@270 2194 paint.drawRect(r);
Chris@270 2195 paint.restore();
Chris@270 2196 } else {
Chris@270 2197 paint.save();
Chris@270 2198 paint.setPen(Qt::green);
Chris@270 2199 paint.drawPoint(r.x(), r.y());
Chris@270 2200 paint.restore();
Chris@270 2201 }
Chris@270 2202
Chris@270 2203 if (!focus) return;
Chris@270 2204
Chris@278 2205 paint.save();
Chris@278 2206 QFont fn = paint.font();
Chris@278 2207 if (fn.pointSize() > 8) {
Chris@278 2208 fn.setPointSize(fn.pointSize() - 1);
Chris@278 2209 paint.setFont(fn);
Chris@278 2210 }
Chris@278 2211
Chris@267 2212 int fontHeight = paint.fontMetrics().height();
Chris@267 2213 int fontAscent = paint.fontMetrics().ascent();
Chris@267 2214
Chris@904 2215 double v0, v1;
Chris@267 2216 QString u0, u1;
Chris@267 2217 bool b0 = false, b1 = false;
Chris@267 2218
Chris@267 2219 QString axs, ays, bxs, bys, dxs, dys;
Chris@267 2220
Chris@267 2221 int axx, axy, bxx, bxy, dxx, dxy;
Chris@267 2222 int aw = 0, bw = 0, dw = 0;
Chris@267 2223
Chris@267 2224 int labelCount = 0;
Chris@267 2225
Chris@362 2226 // top-left point, x-coord
Chris@362 2227
Chris@267 2228 if ((b0 = topLayer->getXScaleValue(this, r.x(), v0, u0))) {
Chris@267 2229 axs = QString("%1 %2").arg(v0).arg(u0);
Chris@278 2230 if (u0 == "Hz" && Pitch::isFrequencyInMidiRange(v0)) {
Chris@278 2231 axs = QString("%1 (%2)").arg(axs)
Chris@278 2232 .arg(Pitch::getPitchLabelForFrequency(v0));
Chris@278 2233 }
Chris@267 2234 aw = paint.fontMetrics().width(axs);
Chris@267 2235 ++labelCount;
Chris@267 2236 }
Chris@362 2237
Chris@362 2238 // bottom-right point, x-coord
Chris@267 2239
Chris@267 2240 if (r.width() > 0) {
Chris@267 2241 if ((b1 = topLayer->getXScaleValue(this, r.x() + r.width(), v1, u1))) {
Chris@267 2242 bxs = QString("%1 %2").arg(v1).arg(u1);
Chris@278 2243 if (u1 == "Hz" && Pitch::isFrequencyInMidiRange(v1)) {
Chris@278 2244 bxs = QString("%1 (%2)").arg(bxs)
Chris@278 2245 .arg(Pitch::getPitchLabelForFrequency(v1));
Chris@278 2246 }
Chris@267 2247 bw = paint.fontMetrics().width(bxs);
Chris@267 2248 }
Chris@267 2249 }
Chris@362 2250
Chris@362 2251 // dimension, width
Chris@267 2252
Chris@283 2253 if (b0 && b1 && v1 != v0 && u0 == u1) {
Chris@362 2254 dxs = QString("[%1 %2]").arg(fabs(v1 - v0)).arg(u1);
Chris@267 2255 dw = paint.fontMetrics().width(dxs);
Chris@267 2256 }
Chris@267 2257
Chris@267 2258 b0 = false;
Chris@267 2259 b1 = false;
Chris@267 2260
Chris@362 2261 // top-left point, y-coord
Chris@362 2262
Chris@267 2263 if ((b0 = topLayer->getYScaleValue(this, r.y(), v0, u0))) {
Chris@267 2264 ays = QString("%1 %2").arg(v0).arg(u0);
Chris@278 2265 if (u0 == "Hz" && Pitch::isFrequencyInMidiRange(v0)) {
Chris@278 2266 ays = QString("%1 (%2)").arg(ays)
Chris@278 2267 .arg(Pitch::getPitchLabelForFrequency(v0));
Chris@278 2268 }
Chris@267 2269 aw = std::max(aw, paint.fontMetrics().width(ays));
Chris@267 2270 ++labelCount;
Chris@267 2271 }
Chris@267 2272
Chris@362 2273 // bottom-right point, y-coord
Chris@362 2274
Chris@267 2275 if (r.height() > 0) {
Chris@267 2276 if ((b1 = topLayer->getYScaleValue(this, r.y() + r.height(), v1, u1))) {
Chris@267 2277 bys = QString("%1 %2").arg(v1).arg(u1);
Chris@278 2278 if (u1 == "Hz" && Pitch::isFrequencyInMidiRange(v1)) {
Chris@278 2279 bys = QString("%1 (%2)").arg(bys)
Chris@278 2280 .arg(Pitch::getPitchLabelForFrequency(v1));
Chris@278 2281 }
Chris@267 2282 bw = std::max(bw, paint.fontMetrics().width(bys));
Chris@267 2283 }
Chris@267 2284 }
Chris@274 2285
Chris@274 2286 bool bd = false;
Chris@904 2287 double dy = 0.f;
Chris@274 2288 QString du;
Chris@274 2289
Chris@362 2290 // dimension, height
Chris@362 2291
Chris@274 2292 if ((bd = topLayer->getYScaleDifference(this, r.y(), r.y() + r.height(),
Chris@283 2293 dy, du)) &&
Chris@283 2294 dy != 0) {
Chris@274 2295 if (du != "") {
Chris@362 2296 if (du == "Hz") {
Chris@362 2297 int semis;
Chris@904 2298 double cents;
Chris@362 2299 semis = Pitch::getPitchForFrequencyDifference(v0, v1, &cents);
Chris@362 2300 dys = QString("[%1 %2 (%3)]")
Chris@362 2301 .arg(dy).arg(du)
Chris@362 2302 .arg(Pitch::getLabelForPitchRange(semis, cents));
Chris@362 2303 } else {
Chris@362 2304 dys = QString("[%1 %2]").arg(dy).arg(du);
Chris@362 2305 }
Chris@274 2306 } else {
Chris@362 2307 dys = QString("[%1]").arg(dy);
Chris@274 2308 }
Chris@267 2309 dw = std::max(dw, paint.fontMetrics().width(dys));
Chris@267 2310 }
Chris@267 2311
Chris@267 2312 int mw = r.width();
Chris@267 2313 int mh = r.height();
Chris@267 2314
Chris@267 2315 bool edgeLabelsInside = false;
Chris@267 2316 bool sizeLabelsInside = false;
Chris@267 2317
Chris@267 2318 if (mw < std::max(aw, std::max(bw, dw)) + 4) {
Chris@267 2319 // defaults stand
Chris@267 2320 } else if (mw < aw + bw + 4) {
Chris@267 2321 if (mh > fontHeight * labelCount * 3 + 4) {
Chris@267 2322 edgeLabelsInside = true;
Chris@267 2323 sizeLabelsInside = true;
Chris@267 2324 } else if (mh > fontHeight * labelCount * 2 + 4) {
Chris@267 2325 edgeLabelsInside = true;
Chris@267 2326 }
Chris@267 2327 } else if (mw < aw + bw + dw + 4) {
Chris@267 2328 if (mh > fontHeight * labelCount * 3 + 4) {
Chris@267 2329 edgeLabelsInside = true;
Chris@267 2330 sizeLabelsInside = true;
Chris@267 2331 } else if (mh > fontHeight * labelCount + 4) {
Chris@267 2332 edgeLabelsInside = true;
Chris@267 2333 }
Chris@267 2334 } else {
Chris@267 2335 if (mh > fontHeight * labelCount + 4) {
Chris@267 2336 edgeLabelsInside = true;
Chris@267 2337 sizeLabelsInside = true;
Chris@267 2338 }
Chris@267 2339 }
Chris@267 2340
Chris@267 2341 if (edgeLabelsInside) {
Chris@267 2342
Chris@267 2343 axx = r.x() + 2;
Chris@267 2344 axy = r.y() + fontAscent + 2;
Chris@267 2345
Chris@267 2346 bxx = r.x() + r.width() - bw - 2;
Chris@267 2347 bxy = r.y() + r.height() - (labelCount-1) * fontHeight - 2;
Chris@267 2348
Chris@267 2349 } else {
Chris@267 2350
Chris@267 2351 axx = r.x() - aw - 2;
Chris@267 2352 axy = r.y() + fontAscent;
Chris@267 2353
Chris@267 2354 bxx = r.x() + r.width() + 2;
Chris@267 2355 bxy = r.y() + r.height() - (labelCount-1) * fontHeight;
Chris@267 2356 }
Chris@267 2357
Chris@267 2358 dxx = r.width()/2 + r.x() - dw/2;
Chris@267 2359
Chris@267 2360 if (sizeLabelsInside) {
Chris@267 2361
Chris@267 2362 dxy = r.height()/2 + r.y() - (labelCount * fontHeight)/2 + fontAscent;
Chris@267 2363
Chris@267 2364 } else {
Chris@267 2365
Chris@267 2366 dxy = r.y() + r.height() + fontAscent + 2;
Chris@267 2367 }
Chris@267 2368
Chris@267 2369 if (axs != "") {
Chris@267 2370 drawVisibleText(paint, axx, axy, axs, OutlinedText);
Chris@267 2371 axy += fontHeight;
Chris@267 2372 }
Chris@267 2373
Chris@267 2374 if (ays != "") {
Chris@267 2375 drawVisibleText(paint, axx, axy, ays, OutlinedText);
Chris@267 2376 axy += fontHeight;
Chris@267 2377 }
Chris@267 2378
Chris@267 2379 if (bxs != "") {
Chris@267 2380 drawVisibleText(paint, bxx, bxy, bxs, OutlinedText);
Chris@267 2381 bxy += fontHeight;
Chris@267 2382 }
Chris@267 2383
Chris@267 2384 if (bys != "") {
Chris@267 2385 drawVisibleText(paint, bxx, bxy, bys, OutlinedText);
Chris@267 2386 bxy += fontHeight;
Chris@267 2387 }
Chris@267 2388
Chris@267 2389 if (dxs != "") {
Chris@267 2390 drawVisibleText(paint, dxx, dxy, dxs, OutlinedText);
Chris@267 2391 dxy += fontHeight;
Chris@267 2392 }
Chris@267 2393
Chris@267 2394 if (dys != "") {
Chris@267 2395 drawVisibleText(paint, dxx, dxy, dys, OutlinedText);
Chris@267 2396 dxy += fontHeight;
Chris@267 2397 }
Chris@278 2398
Chris@278 2399 paint.restore();
Chris@267 2400 }
Chris@267 2401
Chris@227 2402 bool
Chris@908 2403 View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1)
Chris@227 2404 {
Chris@908 2405 int x0 = int(f0 / m_zoomLevel);
Chris@908 2406 int x1 = int(f1 / m_zoomLevel);
Chris@806 2407
Chris@806 2408 int w = x1 - x0;
Chris@806 2409
Chris@908 2410 sv_frame_t origCentreFrame = m_centreFrame;
Chris@227 2411
Chris@227 2412 bool someLayersIncomplete = false;
Chris@227 2413
Chris@835 2414 for (LayerList::iterator i = m_layerStack.begin();
Chris@835 2415 i != m_layerStack.end(); ++i) {
Chris@227 2416
Chris@227 2417 int c = (*i)->getCompletion(this);
Chris@227 2418 if (c < 100) {
Chris@227 2419 someLayersIncomplete = true;
Chris@227 2420 break;
Chris@227 2421 }
Chris@227 2422 }
Chris@227 2423
Chris@227 2424 if (someLayersIncomplete) {
Chris@227 2425
Chris@227 2426 QProgressDialog progress(tr("Waiting for layers to be ready..."),
Chris@227 2427 tr("Cancel"), 0, 100, this);
Chris@227 2428
Chris@227 2429 int layerCompletion = 0;
Chris@227 2430
Chris@227 2431 while (layerCompletion < 100) {
Chris@227 2432
Chris@835 2433 for (LayerList::iterator i = m_layerStack.begin();
Chris@835 2434 i != m_layerStack.end(); ++i) {
Chris@227 2435
Chris@227 2436 int c = (*i)->getCompletion(this);
Chris@835 2437 if (i == m_layerStack.begin() || c < layerCompletion) {
Chris@227 2438 layerCompletion = c;
Chris@227 2439 }
Chris@227 2440 }
Chris@227 2441
Chris@227 2442 if (layerCompletion >= 100) break;
Chris@227 2443
Chris@227 2444 progress.setValue(layerCompletion);
Chris@227 2445 qApp->processEvents();
Chris@227 2446 if (progress.wasCanceled()) {
Chris@227 2447 update();
Chris@227 2448 return false;
Chris@227 2449 }
Chris@227 2450
Chris@227 2451 usleep(50000);
Chris@227 2452 }
Chris@227 2453 }
Chris@227 2454
Chris@227 2455 QProgressDialog progress(tr("Rendering image..."),
Chris@227 2456 tr("Cancel"), 0, w / width(), this);
Chris@227 2457
Chris@806 2458 for (int x = 0; x < w; x += width()) {
Chris@227 2459
Chris@227 2460 progress.setValue(x / width());
Chris@227 2461 qApp->processEvents();
Chris@227 2462 if (progress.wasCanceled()) {
Chris@227 2463 m_centreFrame = origCentreFrame;
Chris@227 2464 update();
Chris@227 2465 return false;
Chris@227 2466 }
Chris@227 2467
Chris@229 2468 m_centreFrame = f0 + (x + width()/2) * m_zoomLevel;
Chris@227 2469
Chris@227 2470 QRect chunk(0, 0, width(), height());
Chris@227 2471
Chris@287 2472 paint.setPen(getBackground());
Chris@287 2473 paint.setBrush(getBackground());
Chris@227 2474
Chris@229 2475 paint.drawRect(QRect(xorigin + x, 0, width(), height()));
Chris@227 2476
Chris@287 2477 paint.setPen(getForeground());
Chris@227 2478 paint.setBrush(Qt::NoBrush);
Chris@227 2479
Chris@835 2480 for (LayerList::iterator i = m_layerStack.begin();
Chris@835 2481 i != m_layerStack.end(); ++i) {
Chris@919 2482 if (!((*i)->isLayerDormant(this))){
Chris@919 2483
Chris@919 2484 paint.setRenderHint(QPainter::Antialiasing, false);
Chris@919 2485
Chris@919 2486 paint.save();
Chris@919 2487 paint.translate(xorigin + x, 0);
Chris@919 2488
Chris@919 2489 cerr << "Centre frame now: " << m_centreFrame << " drawing to " << chunk.x() + x + xorigin << ", " << chunk.width() << endl;
Chris@919 2490
Chris@919 2491 (*i)->setSynchronousPainting(true);
Chris@919 2492
Chris@919 2493 (*i)->paint(this, paint, chunk);
Chris@919 2494
Chris@919 2495 (*i)->setSynchronousPainting(false);
Chris@919 2496
Chris@919 2497 paint.restore();
Chris@919 2498 }
Chris@227 2499 }
Chris@227 2500 }
Chris@227 2501
Chris@227 2502 m_centreFrame = origCentreFrame;
Chris@227 2503 update();
Chris@227 2504 return true;
Chris@227 2505 }
Chris@227 2506
Chris@227 2507 QImage *
Chris@227 2508 View::toNewImage()
Chris@227 2509 {
Chris@908 2510 sv_frame_t f0 = getModelsStartFrame();
Chris@908 2511 sv_frame_t f1 = getModelsEndFrame();
Chris@227 2512
Chris@229 2513 return toNewImage(f0, f1);
Chris@229 2514 }
Chris@229 2515
Chris@229 2516 QImage *
Chris@908 2517 View::toNewImage(sv_frame_t f0, sv_frame_t f1)
Chris@229 2518 {
Chris@908 2519 int x0 = int(f0 / getZoomLevel());
Chris@908 2520 int x1 = int(f1 / getZoomLevel());
Chris@227 2521
Chris@227 2522 QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32);
Chris@227 2523
Chris@227 2524 QPainter *paint = new QPainter(image);
Chris@229 2525 if (!render(*paint, 0, f0, f1)) {
Chris@227 2526 delete paint;
Chris@227 2527 delete image;
Chris@227 2528 return 0;
Chris@227 2529 } else {
Chris@227 2530 delete paint;
Chris@227 2531 return image;
Chris@227 2532 }
Chris@227 2533 }
Chris@227 2534
Chris@229 2535 QSize
Chris@229 2536 View::getImageSize()
Chris@229 2537 {
Chris@908 2538 sv_frame_t f0 = getModelsStartFrame();
Chris@908 2539 sv_frame_t f1 = getModelsEndFrame();
Chris@229 2540
Chris@229 2541 return getImageSize(f0, f1);
Chris@229 2542 }
Chris@229 2543
Chris@229 2544 QSize
Chris@908 2545 View::getImageSize(sv_frame_t f0, sv_frame_t f1)
Chris@229 2546 {
Chris@908 2547 int x0 = int(f0 / getZoomLevel());
Chris@908 2548 int x1 = int(f1 / getZoomLevel());
Chris@229 2549
Chris@229 2550 return QSize(x1 - x0, height());
Chris@229 2551 }
Chris@229 2552
Chris@316 2553 void
Chris@316 2554 View::toXml(QTextStream &stream,
Chris@316 2555 QString indent, QString extraAttributes) const
Chris@127 2556 {
Chris@316 2557 stream << indent;
Chris@127 2558
Chris@316 2559 stream << QString("<view "
Chris@316 2560 "centre=\"%1\" "
Chris@316 2561 "zoom=\"%2\" "
Chris@316 2562 "followPan=\"%3\" "
Chris@316 2563 "followZoom=\"%4\" "
Chris@316 2564 "tracking=\"%5\" "
Chris@316 2565 " %6>\n")
Chris@127 2566 .arg(m_centreFrame)
Chris@127 2567 .arg(m_zoomLevel)
Chris@127 2568 .arg(m_followPan)
Chris@127 2569 .arg(m_followZoom)
Chris@127 2570 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" :
Chris@815 2571 m_followPlay == PlaybackScrollPageWithCentre ? "page" :
Chris@815 2572 m_followPlay == PlaybackScrollPage ? "daw" :
Chris@815 2573 "ignore")
Chris@127 2574 .arg(extraAttributes);
Chris@127 2575
Chris@838 2576 for (int i = 0; i < (int)m_fixedOrderLayers.size(); ++i) {
Chris@838 2577 bool visible = !m_fixedOrderLayers[i]->isLayerDormant(this);
Chris@838 2578 m_fixedOrderLayers[i]->toBriefXml(stream, indent + " ",
Chris@838 2579 QString("visible=\"%1\"")
Chris@838 2580 .arg(visible ? "true" : "false"));
Chris@127 2581 }
Chris@127 2582
Chris@316 2583 stream << indent + "</view>\n";
Chris@127 2584 }
Chris@127 2585
Chris@127 2586 ViewPropertyContainer::ViewPropertyContainer(View *v) :
Chris@127 2587 m_v(v)
Chris@127 2588 {
Chris@728 2589 // cerr << "ViewPropertyContainer: " << this << " is owned by View " << v << endl;
Chris@127 2590 connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)),
Chris@127 2591 this, SIGNAL(propertyChanged(PropertyContainer::PropertyName)));
Chris@127 2592 }
Chris@127 2593
Chris@728 2594 ViewPropertyContainer::~ViewPropertyContainer()
Chris@728 2595 {
Chris@728 2596 }