Mercurial > hg > svgui
changeset 835:7792b7667f74
Introduce (but don't yet populate) the fixed layers vector; rename m_layers to m_layerStack to reflect its ordering by stacking
author | Chris Cannam |
---|---|
date | Tue, 02 Sep 2014 14:47:04 +0100 |
parents | 9ad718fdc369 |
children | 1384485650e3 |
files | view/Overview.cpp view/Pane.cpp view/View.cpp view/View.h widgets/PropertyStack.cpp |
diffstat | 5 files changed, 104 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/view/Overview.cpp Tue Sep 02 10:31:23 2014 +0100 +++ b/view/Overview.cpp Tue Sep 02 14:47:04 2014 +0100 @@ -52,8 +52,8 @@ if (!zoomChanged) { if (m_modelTestTime.elapsed() < 1000) { - for (LayerList::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (!(*i)->getModel()->isOK() || !(*i)->getModel()->isReady())) {
--- a/view/Pane.cpp Tue Sep 02 10:31:23 2014 +0100 +++ b/view/Pane.cpp Tue Sep 02 14:47:04 2014 +0100 @@ -202,7 +202,7 @@ //!!! pull out into function (presumably in View) bool haveConstraint = false; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) { haveConstraint = true; @@ -426,7 +426,7 @@ m_mouseInWidget && toolMode == ViewManager::MeasureMode) { - for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { --vi; std::vector<QRect> crosshairExtents; @@ -447,7 +447,7 @@ const Model *waveformModel = 0; // just for reporting purposes const Model *workModel = 0; - for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { --vi; if (!haveSomeTimeXAxis && (*vi)->hasTimeXAxis()) { haveSomeTimeXAxis = true; @@ -586,8 +586,8 @@ if (!hasValueExtents) { - for (LayerList::iterator vi = m_layers.end(); - vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); + vi != m_layerStack.begin(); ) { --vi; @@ -606,8 +606,8 @@ QString requireUnit = unit; - for (LayerList::iterator vi = m_layers.end(); - vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); + vi != m_layerStack.begin(); ) { --vi; @@ -738,9 +738,9 @@ int y = height() - fontHeight + fontAscent - 6; - LayerList::iterator vi = m_layers.end(); + LayerList::iterator vi = m_layerStack.end(); - if (vi != m_layers.begin()) { + if (vi != m_layerStack.begin()) { switch ((*--vi)->getPreferredFrameCountPosition()) { @@ -916,13 +916,13 @@ lly -= 20; } - if (r.y() + r.height() < lly - int(m_layers.size()) * fontHeight) { + if (r.y() + r.height() < lly - int(m_layerStack.size()) * fontHeight) { return; } QStringList texts; std::vector<QPixmap> pixmaps; - for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { texts.push_back((*i)->getLayerPresentationName()); // cerr << "Pane " << this << ": Layer presentation name for " << *i << ": " // << texts[texts.size()-1] << endl; @@ -1093,7 +1093,7 @@ if (m_scaleWidth > 0) { - for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { --vi; paint.save(); @@ -1127,7 +1127,7 @@ int formerScaleWidth = m_scaleWidth; if (m_manager && m_manager->shouldShowVerticalScale()) { - for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { --vi; QPainter paint(image); m_scaleWidth = (*vi)->getVerticalScaleWidth @@ -1164,7 +1164,7 @@ int sw = 0; if (m_manager && m_manager->shouldShowVerticalScale()) { - for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { + for (LayerList::iterator vi = m_layerStack.end(); vi != m_layerStack.begin(); ) { --vi; sw = (*vi)->getVerticalScaleWidth (this, m_manager->shouldShowVerticalColourScale(), paint); @@ -1277,10 +1277,10 @@ Layer * Pane::getTopFlexiNoteLayer() { - for (int i = int(m_layers.size()) - 1; i >= 0; --i) { - if (LayerFactory::getInstance()->getLayerType(m_layers[i]) == + for (int i = int(m_layerStack.size()) - 1; i >= 0; --i) { + if (LayerFactory::getInstance()->getLayerType(m_layerStack[i]) == LayerFactory::FlexiNotes) { - return m_layers[i]; + return m_layerStack[i]; } } return 0; @@ -1880,8 +1880,8 @@ float min, max; bool log; Layer *layer = 0; - for (LayerList::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { if ((*i)->getValueExtents(min, max, log, unit) && (*i)->getDisplayExtents(min, max)) { layer = *i; @@ -2393,7 +2393,7 @@ //!!! pull out into function (presumably in View) bool haveConstraint = false; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) { haveConstraint = true;
--- a/view/View.cpp Tue Sep 02 10:31:23 2014 +0100 +++ b/view/View.cpp Tue Sep 02 14:47:04 2014 +0100 @@ -164,7 +164,7 @@ int View::getPropertyContainerCount() const { - return m_layers.size() + 1; // the 1 is for me + return m_layerStack.size() + 1; // the 1 is for me } const PropertyContainer * @@ -178,7 +178,7 @@ View::getPropertyContainer(int i) { if (i == 0) return m_propertyContainer; - return m_layers[i-1]; + return m_layerStack[i-1]; } bool @@ -186,8 +186,8 @@ { bool have = false; - for (LayerList::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { QString layerUnit; float layerMin = 0.0, layerMax = 0.0; @@ -223,8 +223,8 @@ { std::map<int, Layer *> sortedLayers; - for (LayerList::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { if ((*i)->needsTextLabelHeight()) { sortedLayers[getObjectExportId(*i)] = *i; } @@ -259,17 +259,17 @@ Layer *selectedLayer = 0; - for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if (*i == pc) { selectedLayer = *i; - m_layers.erase(i); + m_layerStack.erase(i); break; } } if (selectedLayer) { m_haveSelectedLayer = true; - m_layers.push_back(selectedLayer); + m_layerStack.push_back(selectedLayer); update(); } else { m_haveSelectedLayer = false; @@ -468,8 +468,8 @@ Layer::ColourSignificance maxSignificance = Layer::ColourAbsent; bool mostSignificantHasDarkBackground = false; - for (LayerList::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { Layer::ColourSignificance s = (*i)->getLayerColourSignificance(); bool light = (*i)->hasLightBackground(); @@ -532,7 +532,7 @@ SingleColourLayer *scl = dynamic_cast<SingleColourLayer *>(layer); if (scl) scl->setDefaultColourFor(this); - m_layers.push_back(layer); + m_layerStack.push_back(layer); QProgressBar *pb = new QProgressBar(this); pb->setMinimum(0); @@ -599,9 +599,9 @@ delete m_cache; m_cache = 0; - for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if (*i == layer) { - m_layers.erase(i); + m_layerStack.erase(i); if (m_progressBars.find(layer) != m_progressBars.end()) { delete m_progressBars[layer].bar; delete m_progressBars[layer].cancel; @@ -641,7 +641,7 @@ if (sl && !(sl->isLayerDormant(this))) { return sl; } - if (!m_layers.empty()) { + if (!m_layerStack.empty()) { int n = getLayerCount(); while (n > 0) { --n; @@ -657,7 +657,7 @@ Layer * View::getSelectedLayer() { - if (m_haveSelectedLayer && !m_layers.empty()) { + if (m_haveSelectedLayer && !m_layerStack.empty()) { int n = getLayerCount(); while (n > 0) { --n; @@ -1182,7 +1182,7 @@ bool first = true; int startFrame = 0; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { @@ -1203,7 +1203,7 @@ bool first = true; int endFrame = 0; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { @@ -1229,7 +1229,7 @@ //!!! nah, this wants to always return the sr of the main model! - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { return (*i)->getModel()->getSampleRate(); } @@ -1272,8 +1272,8 @@ Model *alignedModel = 0; Model *goodModel = 0; - for (LayerList::const_iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { Layer *layer = *i; @@ -1335,7 +1335,7 @@ View::areLayersScrollable() const { // True iff all views are scrollable - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if (!(*i)->isLayerScrollable(this)) return false; } return true; @@ -1352,7 +1352,7 @@ LayerList scrollables; bool metUnscrollable = false; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { // SVDEBUG << "View::getScrollableBackLayers: calling isLayerDormant on layer " << *i << endl; // cerr << "(name is " << (*i)->objectName() << ")" // << endl; @@ -1388,7 +1388,7 @@ bool started = false; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->isLayerDormant(this)) continue; if (!started && (*i)->isLayerScrollable(this)) { continue; @@ -1419,7 +1419,7 @@ PowerOfSqrtTwoZoomConstraint defaultZoomConstraint; - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; @@ -1443,7 +1443,7 @@ bool View::areLayerColoursSignificant() const { - for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getLayerColourSignificance() == Layer::ColourHasMeaningfulValue) return true; if ((*i)->isLayerOpaque()) break; @@ -1454,8 +1454,8 @@ bool View::hasTopLayerTimeXAxis() const { - LayerList::const_iterator i = m_layers.end(); - if (i == m_layers.begin()) return false; + LayerList::const_iterator i = m_layerStack.end(); + if (i == m_layerStack.begin()) return false; --i; return (*i)->hasTimeXAxis(); } @@ -1653,7 +1653,7 @@ // Profiler prof("View::paintEvent", false); // cerr << "View::paintEvent: centre frame is " << m_centreFrame << endl; - if (m_layers.empty()) { + if (m_layerStack.empty()) { QFrame::paintEvent(e); return; } @@ -2333,8 +2333,8 @@ bool someLayersIncomplete = false; - for (LayerList::iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { int c = (*i)->getCompletion(this); if (c < 100) { @@ -2352,11 +2352,11 @@ while (layerCompletion < 100) { - for (LayerList::iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { int c = (*i)->getCompletion(this); - if (i == m_layers.begin() || c < layerCompletion) { + if (i == m_layerStack.begin() || c < layerCompletion) { layerCompletion = c; } } @@ -2399,8 +2399,8 @@ paint.setPen(getForeground()); paint.setBrush(Qt::NoBrush); - for (LayerList::iterator i = m_layers.begin(); - i != m_layers.end(); ++i) { + for (LayerList::iterator i = m_layerStack.begin(); + i != m_layerStack.end(); ++i) { if(!((*i)->isLayerDormant(this))){ paint.setRenderHint(QPainter::Antialiasing, false); @@ -2495,9 +2495,9 @@ "ignore") .arg(extraAttributes); - for (int i = 0; i < (int)m_layers.size(); ++i) { - bool visible = !m_layers[i]->isLayerDormant(this); - m_layers[i]->toBriefXml(stream, indent + " ", + for (int i = 0; i < (int)m_layerStack.size(); ++i) { + bool visible = !m_layerStack[i]->isLayerDormant(this); + m_layerStack[i]->toBriefXml(stream, indent + " ", QString("visible=\"%1\"") .arg(visible ? "true" : "false")); }
--- a/view/View.h Tue Sep 02 10:31:23 2014 +0100 +++ b/view/View.h Tue Sep 02 14:47:04 2014 +0100 @@ -163,7 +163,7 @@ * Return the number of layers, regardless of whether visible or * dormant, i.e. invisible, in this view. */ - virtual int getLayerCount() const { return m_layers.size(); } + virtual int getLayerCount() const { return m_layerStack.size(); } /** * Return the nth layer, counted in stacking order. That is, @@ -172,16 +172,20 @@ * dormant, i.e. invisible. */ virtual Layer *getLayer(int n) { - if (n < int(m_layers.size())) return m_layers[n]; else return 0; + if (n < int(m_layerStack.size())) return m_layerStack[n]; + else return 0; } /** - * Return the "top" layer in the view, whether visible or dormant. - * This is the same as getLayer(getLayerCount()-1) if there is at - * least one layer, and 0 otherwise. + * Return the nth layer, counted in the order they were + * added. Unlike the stacking order used in getLayer(), which + * changes each time a layer is selected, this ordering remains + * fixed. The returned layer may be visible or it may be dormant, + * i.e. invisible. */ - virtual Layer *getTopLayer() { - return m_layers.empty() ? 0 : m_layers[m_layers.size()-1]; + virtual Layer *getFixedOrderLayer(int n) { + if (n < int(m_fixedOrderLayers.size())) return m_fixedOrderLayers[n]; + else return 0; } /** @@ -192,10 +196,15 @@ virtual Layer *getInteractionLayer(); /** - * Return the layer most recently selected by the user. If the - * user has selected the pane itself more recently than any of the - * layers on it, this function will return 0. It will also return - * 0 if there are no layers in the view. + * Return the layer most recently selected by the user. This is + * the layer that any non-tool-driven commands should operate on, + * in the case where this view is the "current" one. + * + * If the user has selected the view itself more recently than any + * of the layers on it, this function will return 0, and any + * non-tool-driven layer commands should be deactivated while this + * view is current. It will also return 0 if there are no layers + * in the view. * * Note that, unlike getInteractionLayer(), this could return an * invisible (dormant) layer. @@ -204,6 +213,19 @@ virtual const Layer *getSelectedLayer() const; + /** + * Return the "top" layer in the view, whether visible or dormant. + * This is the same as getLayer(getLayerCount()-1) if there is at + * least one layer, and 0 otherwise. + * + * For most purposes involving interaction or commands, you + * probably want either getInteractionLayer() or + * getSelectedLayer() instead. + */ + virtual Layer *getTopLayer() { + return m_layerStack.empty() ? 0 : m_layerStack[m_layerStack.size()-1]; + } + virtual void setViewManager(ViewManager *m); virtual void setViewManager(ViewManager *m, int initialFrame); virtual ViewManager *getViewManager() const { return m_manager; } @@ -396,7 +418,8 @@ bool m_deleting; - LayerList m_layers; // I don't own these, but see dtor note above + LayerList m_layerStack; // I don't own these, but see dtor note above + LayerList m_fixedOrderLayers; bool m_haveSelectedLayer; QString m_lastError;
--- a/widgets/PropertyStack.cpp Tue Sep 02 10:31:23 2014 +0100 +++ b/widgets/PropertyStack.cpp Tue Sep 02 14:47:04 2014 +0100 @@ -30,7 +30,7 @@ #include <iostream> -//#define DEBUG_PROPERTY_STACK 1 +#define DEBUG_PROPERTY_STACK 1 PropertyStack::PropertyStack(QWidget *parent, View *client) : QTabWidget(parent), @@ -85,7 +85,7 @@ blockSignals(true); #ifdef DEBUG_PROPERTY_STACK - SVDEBUG << "PropertyStack::repopulate" << endl; + cerr << "PropertyStack[" << this << "]::repopulate" << endl; #endif while (count() > 0) { @@ -101,6 +101,12 @@ PropertyContainer *container = m_client->getPropertyContainer(i); QString name = container->getPropertyContainerName(); +#ifdef DEBUG_PROPERTY_STACK + cerr << "PropertyStack[" << this << "]::repopulate: client " << m_client + << " returns container " << container << " (name " << name + << ") at position " << i << endl; +#endif + PropertyBox *box = new PropertyBox(container); connect(box, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool)));