Chris@58: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@59: Sonic Visualiser Chris@59: An audio file viewer and annotation editor. Chris@59: Centre for Digital Music, Queen Mary, University of London. Chris@182: This file copyright 2006 Chris Cannam and QMUL. Chris@0: Chris@59: This program is free software; you can redistribute it and/or Chris@59: modify it under the terms of the GNU General Public License as Chris@59: published by the Free Software Foundation; either version 2 of the Chris@59: License, or (at your option) any later version. See the file Chris@59: COPYING included with this distribution for more information. Chris@0: */ Chris@0: Chris@0: #include "Colour3DPlotLayer.h" Chris@0: Chris@0: #include "base/Profiler.h" Chris@197: #include "base/LogRange.h" Chris@444: #include "base/RangeMapper.h" Chris@1077: Chris@376: #include "ColourMapper.h" Chris@1077: #include "LayerGeometryProvider.h" Chris@1078: #include "PaintAssistant.h" Chris@1077: Chris@1100: #include "data/model/Dense3DModelPeakCache.h" Chris@1100: Chris@1077: #include "view/ViewManager.h" Chris@0: Chris@0: #include Chris@0: #include Chris@0: #include Chris@316: #include Chris@1018: #include Chris@0: Chris@0: #include Chris@0: Chris@0: #include Chris@0: Chris@903: using std::vector; Chris@903: Chris@353: //#define DEBUG_COLOUR_3D_PLOT_LAYER_PAINT 1 Chris@125: Chris@0: Chris@44: Colour3DPlotLayer::Colour3DPlotLayer() : Chris@0: m_model(0), Chris@1105: m_colourScale(ColourScaleType::Linear), Chris@461: m_colourScaleSet(false), Chris@197: m_colourMap(0), Chris@534: m_gain(1.0), Chris@1103: m_binScale(BinScale::Linear), Chris@1104: m_normalization(ColumnNormalization::None), Chris@1104: m_normalizeVisibleArea(false), Chris@444: m_invertVertical(false), Chris@465: m_opaque(false), Chris@535: m_smooth(false), Chris@805: m_peakResolution(256), Chris@444: m_miny(0), Chris@1100: m_maxy(0), Chris@1101: m_synchronous(false), Chris@1100: m_peakCache(0), Chris@1100: m_peakCacheDivisor(8) Chris@0: { Chris@1018: QSettings settings; Chris@1018: settings.beginGroup("Preferences"); Chris@1018: setColourMap(settings.value("colour-3d-plot-colour", ColourMapper::Green).toInt()); Chris@1018: settings.endGroup(); Chris@0: } Chris@0: Chris@0: Colour3DPlotLayer::~Colour3DPlotLayer() Chris@0: { Chris@1107: invalidateRenderers(); Chris@1100: delete m_peakCache; Chris@0: } Chris@0: Chris@1105: ColourScaleType Chris@1104: Colour3DPlotLayer::convertToColourScale(int value) Chris@1104: { Chris@1104: switch (value) { Chris@1104: default: Chris@1105: case 0: return ColourScaleType::Linear; Chris@1105: case 1: return ColourScaleType::Log; Chris@1105: case 2: return ColourScaleType::PlusMinusOne; Chris@1105: case 3: return ColourScaleType::Absolute; Chris@1104: } Chris@1104: } Chris@1104: Chris@1104: int Chris@1105: Colour3DPlotLayer::convertFromColourScale(ColourScaleType scale) Chris@1104: { Chris@1104: switch (scale) { Chris@1105: case ColourScaleType::Linear: return 0; Chris@1105: case ColourScaleType::Log: return 1; Chris@1105: case ColourScaleType::PlusMinusOne: return 2; Chris@1105: case ColourScaleType::Absolute: return 3; Chris@1104: Chris@1105: case ColourScaleType::Meter: Chris@1105: case ColourScaleType::Phase: Chris@1104: default: return 0; Chris@1104: } Chris@1104: } Chris@1104: Chris@1104: std::pair Chris@1104: Colour3DPlotLayer::convertToColumnNorm(int value) Chris@1104: { Chris@1104: switch (value) { Chris@1104: default: Chris@1104: case 0: return { ColumnNormalization::None, false }; Chris@1104: case 1: return { ColumnNormalization::Max1, false }; Chris@1104: case 2: return { ColumnNormalization::None, true }; // visible area Chris@1104: case 3: return { ColumnNormalization::Hybrid, false }; Chris@1104: } Chris@1104: } Chris@1104: Chris@1104: int Chris@1104: Colour3DPlotLayer::convertFromColumnNorm(ColumnNormalization norm, bool visible) Chris@1104: { Chris@1104: if (visible) return 2; Chris@1104: switch (norm) { Chris@1104: case ColumnNormalization::None: return 0; Chris@1104: case ColumnNormalization::Max1: return 1; Chris@1104: case ColumnNormalization::Hybrid: return 3; Chris@1104: Chris@1104: case ColumnNormalization::Sum1: Chris@1104: default: return 0; Chris@1104: } Chris@1104: } Chris@1104: Chris@0: void Chris@1101: Colour3DPlotLayer::setSynchronousPainting(bool synchronous) Chris@1101: { Chris@1101: m_synchronous = synchronous; Chris@1101: } Chris@1101: Chris@1101: void Chris@0: Colour3DPlotLayer::setModel(const DenseThreeDimensionalModel *model) Chris@0: { Chris@193: if (m_model == model) return; Chris@193: const DenseThreeDimensionalModel *oldModel = m_model; Chris@0: m_model = model; Chris@0: if (!m_model || !m_model->isOK()) return; Chris@0: Chris@320: connectSignals(m_model); Chris@0: Chris@461: connect(m_model, SIGNAL(modelChanged()), this, SLOT(modelChanged())); Chris@908: connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), Chris@908: this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); Chris@0: Chris@474: m_peakResolution = 256; Chris@474: if (model->getResolution() > 512) { Chris@474: m_peakResolution = 16; Chris@474: } else if (model->getResolution() > 128) { Chris@474: m_peakResolution = 64; Chris@474: } else if (model->getResolution() > 2) { Chris@474: m_peakResolution = 128; Chris@474: } Chris@1100: Chris@1100: delete m_peakCache; Chris@1100: m_peakCache = 0; Chris@1100: Chris@1107: invalidateRenderers(); Chris@474: Chris@0: emit modelReplaced(); Chris@193: emit sliceableModelReplaced(oldModel, model); Chris@0: } Chris@0: Chris@0: void Chris@0: Colour3DPlotLayer::cacheInvalid() Chris@0: { Chris@1107: invalidateRenderers(); Chris@1107: } Chris@1102: Chris@1107: void Chris@1107: Colour3DPlotLayer::cacheInvalid(sv_frame_t /* startFrame */, Chris@1107: sv_frame_t /* endFrame */) Chris@1107: { Chris@1107: //!!! should do this only if the range is visible Chris@1107: delete m_peakCache; Chris@1108: m_peakCache = 0; Chris@1108: Chris@1107: invalidateRenderers(); Chris@1107: } Chris@1107: Chris@1107: void Chris@1107: Colour3DPlotLayer::invalidateRenderers() Chris@1107: { Chris@1102: for (ViewRendererMap::iterator i = m_renderers.begin(); Chris@1102: i != m_renderers.end(); ++i) { Chris@1102: delete i->second; Chris@1102: } Chris@1102: m_renderers.clear(); Chris@0: } Chris@0: Chris@1100: Dense3DModelPeakCache * Chris@1100: Colour3DPlotLayer::getPeakCache() const Chris@1100: { Chris@1100: if (!m_peakCache) { Chris@1100: m_peakCache = new Dense3DModelPeakCache(m_model, m_peakCacheDivisor); Chris@1100: } Chris@1100: return m_peakCache; Chris@1100: } Chris@1100: Chris@461: void Chris@461: Colour3DPlotLayer::modelChanged() Chris@461: { Chris@1105: if (!m_colourScaleSet && m_colourScale == ColourScaleType::Linear) { Chris@461: if (m_model) { Chris@461: if (m_model->shouldUseLogValueScale()) { Chris@1105: setColourScale(ColourScaleType::Log); Chris@461: } else { Chris@461: m_colourScaleSet = true; Chris@461: } Chris@461: } Chris@461: } Chris@0: cacheInvalid(); Chris@0: } Chris@0: Chris@461: void Chris@908: Colour3DPlotLayer::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) Chris@461: { Chris@1105: if (!m_colourScaleSet && m_colourScale == ColourScaleType::Linear) { Chris@461: if (m_model && m_model->getWidth() > 50) { Chris@461: if (m_model->shouldUseLogValueScale()) { Chris@1105: setColourScale(ColourScaleType::Log); Chris@461: } else { Chris@461: m_colourScaleSet = true; Chris@461: } Chris@461: } Chris@461: } Chris@461: cacheInvalid(startFrame, endFrame); Chris@461: } Chris@461: Chris@159: Layer::PropertyList Chris@159: Colour3DPlotLayer::getProperties() const Chris@159: { Chris@159: PropertyList list; Chris@197: list.push_back("Colour"); Chris@159: list.push_back("Colour Scale"); Chris@1104: list.push_back("Normalization"); Chris@534: list.push_back("Gain"); Chris@531: list.push_back("Bin Scale"); Chris@357: list.push_back("Invert Vertical Scale"); Chris@465: list.push_back("Opaque"); Chris@535: list.push_back("Smooth"); Chris@159: return list; Chris@159: } Chris@159: Chris@159: QString Chris@159: Colour3DPlotLayer::getPropertyLabel(const PropertyName &name) const Chris@159: { Chris@197: if (name == "Colour") return tr("Colour"); Chris@197: if (name == "Colour Scale") return tr("Scale"); Chris@1104: if (name == "Normalization") return tr("Normalization"); Chris@357: if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); Chris@534: if (name == "Gain") return tr("Gain"); Chris@465: if (name == "Opaque") return tr("Always Opaque"); Chris@535: if (name == "Smooth") return tr("Smooth"); Chris@531: if (name == "Bin Scale") return tr("Bin Scale"); Chris@159: return ""; Chris@159: } Chris@159: Chris@346: QString Chris@346: Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const Chris@346: { Chris@357: if (name == "Invert Vertical Scale") return "invert-vertical"; Chris@465: if (name == "Opaque") return "opaque"; Chris@535: if (name == "Smooth") return "smooth"; Chris@346: return ""; Chris@346: } Chris@346: Chris@159: Layer::PropertyType Chris@159: Colour3DPlotLayer::getPropertyType(const PropertyName &name) const Chris@159: { Chris@534: if (name == "Gain") return RangeProperty; Chris@357: if (name == "Invert Vertical Scale") return ToggleProperty; Chris@465: if (name == "Opaque") return ToggleProperty; Chris@535: if (name == "Smooth") return ToggleProperty; Chris@1198: if (name == "Colour") return ColourMapProperty; Chris@159: return ValueProperty; Chris@159: } Chris@159: Chris@159: QString Chris@159: Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const Chris@159: { Chris@1104: if (name == "Normalization" || Chris@1104: name == "Colour Scale" || Chris@534: name == "Gain") return tr("Scale"); Chris@531: if (name == "Bin Scale" || Chris@531: name == "Invert Vertical Scale") return tr("Bins"); Chris@465: if (name == "Opaque" || Chris@535: name == "Smooth" || Chris@465: name == "Colour") return tr("Colour"); Chris@159: return QString(); Chris@159: } Chris@159: Chris@159: int Chris@159: Colour3DPlotLayer::getPropertyRangeAndValue(const PropertyName &name, Chris@216: int *min, int *max, int *deflt) const Chris@159: { Chris@216: int val = 0; Chris@159: Chris@216: int garbage0, garbage1, garbage2; Chris@159: if (!min) min = &garbage0; Chris@159: if (!max) max = &garbage1; Chris@216: if (!deflt) deflt = &garbage2; Chris@159: Chris@534: if (name == "Gain") { Chris@534: Chris@534: *min = -50; Chris@534: *max = 50; Chris@534: Chris@902: *deflt = int(lrint(log10(1.0) * 20.0)); Chris@534: if (*deflt < *min) *deflt = *min; Chris@534: if (*deflt > *max) *deflt = *max; Chris@534: Chris@902: val = int(lrint(log10(m_gain) * 20.0)); Chris@534: if (val < *min) val = *min; Chris@534: if (val > *max) val = *max; Chris@534: Chris@534: } else if (name == "Colour Scale") { Chris@159: Chris@1099: // linear, log, +/-1, abs Chris@159: *min = 0; Chris@509: *max = 3; Chris@1099: *deflt = 0; Chris@159: Chris@1104: val = convertFromColourScale(m_colourScale); Chris@159: Chris@197: } else if (name == "Colour") { Chris@197: Chris@197: *min = 0; Chris@197: *max = ColourMapper::getColourMapCount() - 1; Chris@216: *deflt = 0; Chris@197: Chris@216: val = m_colourMap; Chris@197: Chris@1099: } else if (name == "Normalization") { Chris@197: Chris@1099: *min = 0; Chris@1099: *max = 3; Chris@1104: *deflt = 0; Chris@1104: Chris@1104: val = convertFromColumnNorm(m_normalization, m_normalizeVisibleArea); Chris@197: Chris@357: } else if (name == "Invert Vertical Scale") { Chris@357: Chris@357: *deflt = 0; Chris@357: val = (m_invertVertical ? 1 : 0); Chris@357: Chris@531: } else if (name == "Bin Scale") { Chris@531: Chris@531: *min = 0; Chris@531: *max = 1; Chris@1103: *deflt = int(BinScale::Linear); Chris@531: val = (int)m_binScale; Chris@531: Chris@465: } else if (name == "Opaque") { Chris@465: Chris@465: *deflt = 0; Chris@465: val = (m_opaque ? 1 : 0); Chris@465: Chris@535: } else if (name == "Smooth") { Chris@535: Chris@535: *deflt = 0; Chris@535: val = (m_smooth ? 1 : 0); Chris@535: Chris@159: } else { Chris@216: val = Layer::getPropertyRangeAndValue(name, min, max, deflt); Chris@159: } Chris@159: Chris@216: return val; Chris@159: } Chris@159: Chris@159: QString Chris@159: Colour3DPlotLayer::getPropertyValueLabel(const PropertyName &name, Chris@159: int value) const Chris@159: { Chris@197: if (name == "Colour") { Chris@197: return ColourMapper::getColourMapName(value); Chris@197: } Chris@159: if (name == "Colour Scale") { Chris@159: switch (value) { Chris@159: default: Chris@198: case 0: return tr("Linear"); Chris@198: case 1: return tr("Log"); Chris@198: case 2: return tr("+/-1"); Chris@509: case 3: return tr("Absolute"); Chris@159: } Chris@159: } Chris@1099: if (name == "Normalization") { Chris@1209: switch(value) { Chris@1209: default: Chris@1209: case 0: return tr("None"); Chris@1209: case 1: return tr("Col"); Chris@1209: case 2: return tr("View"); Chris@1209: case 3: return tr("Hybrid"); Chris@1209: } Chris@1209: // return ""; // icon only Chris@1099: } Chris@531: if (name == "Bin Scale") { Chris@531: switch (value) { Chris@531: default: Chris@531: case 0: return tr("Linear"); Chris@531: case 1: return tr("Log"); Chris@531: } Chris@531: } Chris@159: return tr(""); Chris@159: } Chris@159: Chris@1099: QString Chris@1099: Colour3DPlotLayer::getPropertyValueIconName(const PropertyName &name, Chris@1099: int value) const Chris@1099: { Chris@1099: if (name == "Normalization") { Chris@1099: switch(value) { Chris@1099: default: Chris@1099: case 0: return "normalise-none"; Chris@1099: case 1: return "normalise-columns"; Chris@1099: case 2: return "normalise"; Chris@1099: case 3: return "normalise-hybrid"; Chris@1099: } Chris@1099: } Chris@1099: return ""; Chris@1099: } Chris@1099: Chris@534: RangeMapper * Chris@534: Colour3DPlotLayer::getNewPropertyRangeMapper(const PropertyName &name) const Chris@534: { Chris@534: if (name == "Gain") { Chris@534: return new LinearRangeMapper(-50, 50, -25, 25, tr("dB")); Chris@534: } Chris@534: return 0; Chris@534: } Chris@534: Chris@159: void Chris@159: Colour3DPlotLayer::setProperty(const PropertyName &name, int value) Chris@159: { Chris@534: if (name == "Gain") { Chris@902: setGain(float(pow(10, value/20.0))); Chris@534: } else if (name == "Colour Scale") { Chris@1104: setColourScale(convertToColourScale(value)); Chris@197: } else if (name == "Colour") { Chris@197: setColourMap(value); Chris@357: } else if (name == "Invert Vertical Scale") { Chris@357: setInvertVertical(value ? true : false); Chris@465: } else if (name == "Opaque") { Chris@465: setOpaque(value ? true : false); Chris@535: } else if (name == "Smooth") { Chris@535: setSmooth(value ? true : false); Chris@531: } else if (name == "Bin Scale") { Chris@531: switch (value) { Chris@531: default: Chris@1103: case 0: setBinScale(BinScale::Linear); break; Chris@1103: case 1: setBinScale(BinScale::Log); break; Chris@531: } Chris@1099: } else if (name == "Normalization") { Chris@1104: auto n = convertToColumnNorm(value); Chris@1104: setNormalization(n.first); Chris@1104: setNormalizeVisibleArea(n.second); Chris@159: } Chris@159: } Chris@159: Chris@159: void Chris@1105: Colour3DPlotLayer::setColourScale(ColourScaleType scale) Chris@159: { Chris@159: if (m_colourScale == scale) return; Chris@159: m_colourScale = scale; Chris@461: m_colourScaleSet = true; Chris@1107: invalidateRenderers(); Chris@159: emit layerParametersChanged(); Chris@159: } Chris@159: Chris@197: void Chris@197: Colour3DPlotLayer::setColourMap(int map) Chris@197: { Chris@197: if (m_colourMap == map) return; Chris@197: m_colourMap = map; Chris@1107: invalidateRenderers(); Chris@197: emit layerParametersChanged(); Chris@197: } Chris@197: Chris@197: void Chris@534: Colour3DPlotLayer::setGain(float gain) Chris@534: { Chris@534: if (m_gain == gain) return; Chris@534: m_gain = gain; Chris@1107: invalidateRenderers(); Chris@534: emit layerParametersChanged(); Chris@534: } Chris@534: Chris@534: float Chris@534: Colour3DPlotLayer::getGain() const Chris@534: { Chris@534: return m_gain; Chris@534: } Chris@534: Chris@534: void Chris@1103: Colour3DPlotLayer::setBinScale(BinScale binScale) Chris@531: { Chris@531: if (m_binScale == binScale) return; Chris@531: m_binScale = binScale; Chris@1107: invalidateRenderers(); Chris@531: emit layerParametersChanged(); Chris@531: } Chris@531: Chris@1103: BinScale Chris@531: Colour3DPlotLayer::getBinScale() const Chris@531: { Chris@531: return m_binScale; Chris@531: } Chris@531: Chris@531: void Chris@1104: Colour3DPlotLayer::setNormalization(ColumnNormalization n) Chris@197: { Chris@1099: if (m_normalization == n) return; Chris@1099: Chris@1099: m_normalization = n; Chris@1107: invalidateRenderers(); Chris@1099: Chris@197: emit layerParametersChanged(); Chris@197: } Chris@197: Chris@1104: ColumnNormalization Chris@1099: Colour3DPlotLayer::getNormalization() const Chris@197: { Chris@1099: return m_normalization; Chris@197: } Chris@197: Chris@357: void Chris@1104: Colour3DPlotLayer::setNormalizeVisibleArea(bool n) Chris@1104: { Chris@1104: if (m_normalizeVisibleArea == n) return; Chris@1104: Chris@1104: m_normalizeVisibleArea = n; Chris@1107: invalidateRenderers(); Chris@1104: Chris@1104: emit layerParametersChanged(); Chris@1104: } Chris@1104: Chris@1104: bool Chris@1104: Colour3DPlotLayer::getNormalizeVisibleArea() const Chris@1104: { Chris@1104: return m_normalizeVisibleArea; Chris@1104: } Chris@1104: Chris@1104: void Chris@357: Colour3DPlotLayer::setInvertVertical(bool n) Chris@357: { Chris@357: if (m_invertVertical == n) return; Chris@357: m_invertVertical = n; Chris@1107: invalidateRenderers(); Chris@357: emit layerParametersChanged(); Chris@357: } Chris@357: Chris@465: void Chris@465: Colour3DPlotLayer::setOpaque(bool n) Chris@465: { Chris@465: if (m_opaque == n) return; Chris@465: m_opaque = n; Chris@1107: invalidateRenderers(); Chris@465: emit layerParametersChanged(); Chris@465: } Chris@465: Chris@535: void Chris@535: Colour3DPlotLayer::setSmooth(bool n) Chris@535: { Chris@535: if (m_smooth == n) return; Chris@535: m_smooth = n; Chris@1107: invalidateRenderers(); Chris@535: emit layerParametersChanged(); Chris@535: } Chris@535: Chris@357: bool Chris@357: Colour3DPlotLayer::getInvertVertical() const Chris@357: { Chris@357: return m_invertVertical; Chris@357: } Chris@357: Chris@25: bool Chris@465: Colour3DPlotLayer::getOpaque() const Chris@465: { Chris@465: return m_opaque; Chris@465: } Chris@465: Chris@535: bool Chris@535: Colour3DPlotLayer::getSmooth() const Chris@535: { Chris@535: return m_smooth; Chris@535: } Chris@535: Chris@475: void Chris@916: Colour3DPlotLayer::setLayerDormant(const LayerGeometryProvider *v, bool dormant) Chris@475: { Chris@475: if (dormant) { Chris@475: Chris@475: #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT Chris@812: cerr << "Colour3DPlotLayer::setLayerDormant(" << dormant << ")" Chris@585: << endl; Chris@475: #endif Chris@475: Chris@475: if (isLayerDormant(v)) { Chris@475: return; Chris@475: } Chris@475: Chris@475: Layer::setLayerDormant(v, true); Chris@475: Chris@475: cacheInvalid(); Chris@475: Chris@475: } else { Chris@475: Chris@475: Layer::setLayerDormant(v, false); Chris@475: } Chris@475: } Chris@475: Chris@465: bool Chris@1150: Colour3DPlotLayer::isLayerScrollable(const LayerGeometryProvider * /* v */) const Chris@25: { Chris@1104: if (m_normalizeVisibleArea) { Chris@812: return false; Chris@812: } Chris@1121: //!!! ah hang on, if we're potentially rendering incrementally Chris@1121: //!!! they we can't be scrollable Chris@1121: return false; Chris@1121: // if (getRenderer(v)->willRenderOpaque(v)) { Chris@1121: // return true; Chris@1121: // } Chris@1121: // QPoint discard; Chris@1121: // return !v->shouldIlluminateLocalFeatures(this, discard); Chris@25: } Chris@25: Chris@444: bool Chris@904: Colour3DPlotLayer::getValueExtents(double &min, double &max, Chris@444: bool &logarithmic, QString &unit) const Chris@444: { Chris@444: if (!m_model) return false; Chris@444: Chris@444: min = 0; Chris@904: max = double(m_model->getHeight()); Chris@444: Chris@444: logarithmic = false; Chris@444: unit = ""; Chris@444: Chris@444: return true; Chris@444: } Chris@444: Chris@444: bool Chris@904: Colour3DPlotLayer::getDisplayExtents(double &min, double &max) const Chris@444: { Chris@444: if (!m_model) return false; Chris@444: Chris@904: double hmax = double(m_model->getHeight()); Chris@902: Chris@904: min = m_miny; Chris@904: max = m_maxy; Chris@444: if (max <= min) { Chris@444: min = 0; Chris@902: max = hmax; Chris@444: } Chris@444: if (min < 0) min = 0; Chris@902: if (max > hmax) max = hmax; Chris@444: Chris@444: return true; Chris@444: } Chris@444: Chris@444: bool Chris@904: Colour3DPlotLayer::setDisplayExtents(double min, double max) Chris@444: { Chris@444: if (!m_model) return false; Chris@444: Chris@904: m_miny = int(lrint(min)); Chris@904: m_maxy = int(lrint(max)); Chris@444: Chris@1133: invalidateRenderers(); Chris@1133: Chris@444: emit layerParametersChanged(); Chris@444: return true; Chris@444: } Chris@444: Chris@725: bool Chris@916: Colour3DPlotLayer::getYScaleValue(const LayerGeometryProvider *, int, Chris@904: double &, QString &) const Chris@725: { Chris@725: return false;//!!! Chris@725: } Chris@725: Chris@444: int Chris@444: Colour3DPlotLayer::getVerticalZoomSteps(int &defaultStep) const Chris@444: { Chris@444: if (!m_model) return 0; Chris@444: Chris@444: defaultStep = 0; Chris@444: int h = m_model->getHeight(); Chris@444: return h; Chris@444: } Chris@444: Chris@444: int Chris@444: Colour3DPlotLayer::getCurrentVerticalZoomStep() const Chris@444: { Chris@444: if (!m_model) return 0; Chris@444: Chris@904: double min, max; Chris@444: getDisplayExtents(min, max); Chris@904: return m_model->getHeight() - int(lrint(max - min)); Chris@444: } Chris@444: Chris@444: void Chris@444: Colour3DPlotLayer::setVerticalZoomStep(int step) Chris@444: { Chris@444: if (!m_model) return; Chris@444: Chris@587: // SVDEBUG << "Colour3DPlotLayer::setVerticalZoomStep(" <getHeight(); Chris@532: getDisplayExtents(mn, mx); Chris@916: double h = v->getPaintHeight(); Chris@1103: if (m_binScale == BinScale::Linear) { Chris@532: y = h - (((bin - mn) * h) / (mx - mn)); Chris@532: } else { Chris@904: double logmin = mn + 1, logmax = mx + 1; Chris@532: LogRange::mapRange(logmin, logmax); Chris@532: y = h - (((LogRange::map(bin + 1) - logmin) * h) / (logmax - logmin)); Chris@532: } Chris@532: return y; Chris@532: } Chris@532: Chris@904: double Chris@1113: Colour3DPlotLayer::getBinForY(const LayerGeometryProvider *v, double y) const Chris@532: { Chris@904: double bin = y; Chris@532: if (!m_model) return bin; Chris@904: double mn = 0, mx = m_model->getHeight(); Chris@532: getDisplayExtents(mn, mx); Chris@916: double h = v->getPaintHeight(); Chris@1103: if (m_binScale == BinScale::Linear) { Chris@1220: // Arrange that the first bin (mn) appears as the exact result Chris@1220: // for the first pixel (which is pixel h-1) and the first Chris@1220: // out-of-range bin (mx) would appear as the exact result for Chris@1220: // the first out-of-range pixel (which would be pixel -1) Chris@1220: bin = mn + ((h - y - 1) * (mx - mn)) / h; Chris@532: } else { Chris@904: double logmin = mn + 1, logmax = mx + 1; Chris@532: LogRange::mapRange(logmin, logmax); Chris@1220: bin = LogRange::unmap(logmin + ((h - y - 1) * (logmax - logmin)) / h) - 1; Chris@532: } Chris@532: return bin; Chris@532: } Chris@532: Chris@25: QString Chris@916: Colour3DPlotLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const Chris@25: { Chris@25: if (!m_model) return ""; Chris@25: Chris@25: int x = pos.x(); Chris@25: int y = pos.y(); Chris@25: Chris@902: sv_frame_t modelStart = m_model->getStartFrame(); Chris@805: int modelResolution = m_model->getResolution(); Chris@25: Chris@902: double srRatio = Chris@902: v->getViewManager()->getMainModelSampleRate() / Chris@902: m_model->getSampleRate(); Chris@159: Chris@902: int sx0 = int((double(v->getFrameForX(x)) / srRatio - double(modelStart)) / Chris@812: modelResolution); Chris@25: Chris@160: int f0 = sx0 * modelResolution; Chris@160: int f1 = f0 + modelResolution; Chris@160: Chris@447: int sh = m_model->getHeight(); Chris@447: Chris@447: int symin = m_miny; Chris@447: int symax = m_maxy; Chris@447: if (symax <= symin) { Chris@447: symin = 0; Chris@447: symax = sh; Chris@447: } Chris@447: if (symin < 0) symin = 0; Chris@447: if (symax > sh) symax = sh; Chris@447: Chris@916: // double binHeight = double(v->getPaintHeight()) / (symax - symin); Chris@916: // int sy = int((v->getPaintHeight() - y) / binHeight) + symin; Chris@534: Chris@903: int sy = getIBinForY(v, y); Chris@25: Chris@812: if (sy < 0 || sy >= m_model->getHeight()) { Chris@812: return ""; Chris@812: } Chris@812: Chris@357: if (m_invertVertical) sy = m_model->getHeight() - sy - 1; Chris@357: Chris@160: float value = m_model->getValueAt(sx0, sy); Chris@159: Chris@682: // cerr << "bin value (" << sx0 << "," << sy << ") is " << value << endl; Chris@25: Chris@25: QString binName = m_model->getBinName(sy); Chris@25: if (binName == "") binName = QString("[%1]").arg(sy + 1); Chris@25: else binName = QString("%1 [%2]").arg(binName).arg(sy + 1); Chris@25: Chris@25: QString text = tr("Time:\t%1 - %2\nBin:\t%3\nValue:\t%4") Chris@160: .arg(RealTime::frame2RealTime(f0, m_model->getSampleRate()) Chris@25: .toText(true).c_str()) Chris@160: .arg(RealTime::frame2RealTime(f1, m_model->getSampleRate()) Chris@25: .toText(true).c_str()) Chris@25: .arg(binName) Chris@25: .arg(value); Chris@25: Chris@25: return text; Chris@25: } Chris@25: Chris@25: int Chris@969: Colour3DPlotLayer::getColourScaleWidth(QPainter &p) const Chris@159: { Chris@969: // Font is rotated Chris@969: int cw = p.fontMetrics().height(); Chris@159: return cw; Chris@159: } Chris@159: Chris@159: int Chris@916: Colour3DPlotLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const Chris@25: { Chris@25: if (!m_model) return 0; Chris@25: Chris@160: QString sampleText = QString("[%1]").arg(m_model->getHeight()); Chris@25: int tw = paint.fontMetrics().width(sampleText); Chris@98: bool another = false; Chris@25: Chris@805: for (int i = 0; i < m_model->getHeight(); ++i) { Chris@25: if (m_model->getBinName(i).length() > sampleText.length()) { Chris@25: sampleText = m_model->getBinName(i); Chris@98: another = true; Chris@25: } Chris@25: } Chris@98: if (another) { Chris@25: tw = std::max(tw, paint.fontMetrics().width(sampleText)); Chris@25: } Chris@25: Chris@159: return tw + 13 + getColourScaleWidth(paint); Chris@25: } Chris@25: Chris@25: void Chris@916: Colour3DPlotLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const Chris@25: { Chris@25: if (!m_model) return; Chris@25: Chris@25: int h = rect.height(), w = rect.width(); Chris@25: Chris@159: int cw = getColourScaleWidth(paint); Chris@159: Chris@159: int ch = h - 20; Chris@1107: if (ch > 20) { Chris@159: Chris@1131: double min = m_viewMags[v->getId()].getMin(); Chris@1131: double max = m_viewMags[v->getId()].getMax(); Chris@447: Chris@1131: if (max <= min) max = min + 0.1; Chris@447: Chris@287: paint.setPen(v->getForeground()); Chris@447: paint.drawRect(4, 10, cw - 8, ch+1); Chris@159: Chris@446: for (int y = 0; y < ch; ++y) { Chris@904: double value = ((max - min) * (double(ch-y) - 1.0)) / double(ch) + min; Chris@1131: paint.setPen(getRenderer(v)->getColour(value)); Chris@1131: paint.drawLine(5, 11 + y, cw - 5, 11 + y); Chris@159: } Chris@446: Chris@446: QString minstr = QString("%1").arg(min); Chris@446: QString maxstr = QString("%1").arg(max); Chris@446: Chris@446: paint.save(); Chris@446: Chris@446: QFont font = paint.font(); Chris@1053: if (font.pixelSize() > 0) { Chris@1053: int newSize = int(font.pixelSize() * 0.65); Chris@1053: if (newSize < 6) newSize = 6; Chris@1053: font.setPixelSize(newSize); Chris@1053: paint.setFont(font); Chris@1053: } Chris@446: Chris@446: int msw = paint.fontMetrics().width(maxstr); Chris@446: Chris@446: QMatrix m; Chris@446: m.translate(cw - 6, ch + 10); Chris@446: m.rotate(-90); Chris@446: Chris@446: paint.setWorldMatrix(m); Chris@446: Chris@1078: PaintAssistant::drawVisibleText(v, paint, 2, 0, minstr, PaintAssistant::OutlinedText); Chris@446: Chris@446: m.translate(ch - msw - 2, 0); Chris@446: paint.setWorldMatrix(m); Chris@446: Chris@1078: PaintAssistant::drawVisibleText(v, paint, 0, 0, maxstr, PaintAssistant::OutlinedText); Chris@446: Chris@446: paint.restore(); Chris@159: } Chris@159: Chris@287: paint.setPen(v->getForeground()); Chris@159: Chris@445: int sh = m_model->getHeight(); Chris@445: Chris@445: int symin = m_miny; Chris@445: int symax = m_maxy; Chris@445: if (symax <= symin) { Chris@445: symin = 0; Chris@445: symax = sh; Chris@445: } Chris@445: if (symin < 0) symin = 0; Chris@445: if (symax > sh) symax = sh; Chris@445: Chris@532: paint.save(); Chris@456: Chris@533: int py = h; Chris@25: Chris@969: int defaultFontHeight = paint.fontMetrics().height(); Chris@969: Chris@805: for (int i = symin; i <= symax; ++i) { Chris@98: Chris@532: int y0; Chris@534: Chris@903: y0 = getIYForBin(v, i); Chris@532: int h = py - y0; Chris@532: Chris@532: if (i > symin) { Chris@532: if (paint.fontMetrics().height() >= h) { Chris@969: if (h >= defaultFontHeight * 0.8) { Chris@532: QFont tf = paint.font(); Chris@973: tf.setPixelSize(int(h * 0.8)); Chris@532: paint.setFont(tf); Chris@532: } else { Chris@532: continue; Chris@532: } Chris@532: } Chris@532: } Chris@25: Chris@532: py = y0; Chris@532: Chris@534: if (i < symax) { Chris@534: paint.drawLine(cw, y0, w, y0); Chris@534: } Chris@25: Chris@532: if (i > symin) { Chris@534: Chris@805: int idx = i - 1; Chris@534: if (m_invertVertical) idx = m_model->getHeight() - idx - 1; Chris@534: Chris@534: QString text = m_model->getBinName(idx); Chris@534: if (text == "") text = QString("[%1]").arg(idx + 1); Chris@534: Chris@534: int ty = y0 + (h/2) - (paint.fontMetrics().height()/2) + Chris@534: paint.fontMetrics().ascent() + 1; Chris@534: Chris@534: paint.drawText(cw + 5, ty, text); Chris@457: } Chris@25: } Chris@456: Chris@456: paint.restore(); Chris@25: } Chris@25: Chris@467: DenseThreeDimensionalModel::Column Chris@805: Colour3DPlotLayer::getColumn(int col) const Chris@197: { Chris@812: Profiler profiler("Colour3DPlotLayer::getColumn"); Chris@812: Chris@467: DenseThreeDimensionalModel::Column values = m_model->getColumn(col); Chris@1019: values.resize(m_model->getHeight(), 0.f); Chris@1104: if (m_normalization != ColumnNormalization::Max1 && Chris@1104: m_normalization != ColumnNormalization::Hybrid) { Chris@1099: return values; Chris@1099: } Chris@461: Chris@904: double colMax = 0.f, colMin = 0.f; Chris@904: double min = 0.f, max = 0.f; Chris@197: Chris@1019: int nv = int(values.size()); Chris@1019: Chris@461: min = m_model->getMinimumLevel(); Chris@461: max = m_model->getMaximumLevel(); Chris@461: Chris@1019: for (int y = 0; y < nv; ++y) { Chris@467: if (y == 0 || values.at(y) > colMax) colMax = values.at(y); Chris@467: if (y == 0 || values.at(y) < colMin) colMin = values.at(y); Chris@197: } Chris@461: if (colMin == colMax) colMax = colMin + 1; Chris@197: Chris@1019: for (int y = 0; y < nv; ++y) { Chris@461: Chris@904: double value = values.at(y); Chris@904: double norm = (value - colMin) / (colMax - colMin); Chris@904: double newvalue = min + (max - min) * norm; Chris@197: Chris@904: if (value != newvalue) values[y] = float(newvalue); Chris@468: } Chris@468: Chris@1104: if (m_normalization == ColumnNormalization::Hybrid Chris@1099: && (colMax > 0.0)) { Chris@904: double logmax = log10(colMax); Chris@1019: for (int y = 0; y < nv; ++y) { Chris@904: values[y] = float(values[y] * logmax); Chris@719: } Chris@719: } Chris@719: Chris@468: return values; Chris@197: } Chris@1114: Chris@1100: Colour3DPlotRenderer * Chris@1113: Colour3DPlotLayer::getRenderer(const LayerGeometryProvider *v) const Chris@1100: { Chris@1100: if (m_renderers.find(v->getId()) == m_renderers.end()) { Chris@1100: Chris@1100: Colour3DPlotRenderer::Sources sources; Chris@1100: sources.verticalBinLayer = this; Chris@1100: sources.fft = 0; Chris@1100: sources.source = m_model; Chris@1212: sources.peakCaches.push_back(getPeakCache()); Chris@1100: Chris@1100: ColourScale::Parameters cparams; Chris@1100: cparams.colourMap = m_colourMap; Chris@1137: cparams.scaleType = m_colourScale; Chris@1100: cparams.gain = m_gain; Chris@1100: Chris@1131: if (m_normalization == ColumnNormalization::None) { Chris@1131: cparams.minValue = m_model->getMinimumLevel(); Chris@1131: cparams.maxValue = m_model->getMaximumLevel(); Chris@1131: } else if (m_normalization == ColumnNormalization::Hybrid) { Chris@1131: cparams.minValue = 0; Chris@1131: cparams.maxValue = log10(m_model->getMaximumLevel() + 1.0); Chris@1131: } Chris@1131: Chris@1131: if (cparams.maxValue <= cparams.minValue) { Chris@1131: cparams.maxValue = cparams.minValue + 0.1; Chris@1131: } Chris@1131: Chris@1100: Colour3DPlotRenderer::Parameters params; Chris@1100: params.colourScale = ColourScale(cparams); Chris@1100: params.normalization = m_normalization; Chris@1100: params.binScale = m_binScale; Chris@1100: params.alwaysOpaque = m_opaque; Chris@1100: params.invertVertical = m_invertVertical; Chris@1100: params.interpolate = m_smooth; Chris@1100: Chris@1100: m_renderers[v->getId()] = new Colour3DPlotRenderer(sources, params); Chris@1100: } Chris@1100: Chris@1100: return m_renderers[v->getId()]; Chris@1100: } Chris@1100: Chris@197: void Chris@1107: Colour3DPlotLayer::paintWithRenderer(LayerGeometryProvider *v, Chris@1107: QPainter &paint, QRect rect) const Chris@1101: { Chris@1101: Colour3DPlotRenderer *renderer = getRenderer(v); Chris@1101: Chris@1121: Colour3DPlotRenderer::RenderResult result; Chris@1123: MagnitudeRange magRange; Chris@1123: int viewId = v->getId(); Chris@1123: Chris@1123: if (!renderer->geometryChanged(v)) { Chris@1123: magRange = m_viewMags[viewId]; Chris@1123: } Chris@1121: Chris@1101: if (m_synchronous) { Chris@1121: Chris@1121: result = renderer->render(v, paint, rect); Chris@1121: Chris@1121: } else { Chris@1121: Chris@1121: result = renderer->renderTimeConstrained(v, paint, rect); Chris@1121: Chris@1121: QRect uncached = renderer->getLargestUncachedRect(v); Chris@1121: if (uncached.width() > 0) { Chris@1121: v->updatePaintRect(uncached); Chris@1121: } Chris@1101: } Chris@1121: Chris@1123: magRange.sample(result.range); Chris@1101: Chris@1123: if (magRange.isSet()) { Chris@1123: if (!(m_viewMags[viewId] == magRange)) { Chris@1123: m_viewMags[viewId] = magRange; Chris@1123: //!!! now need to do the normalise-visible thing Chris@1123: } Chris@1123: } Chris@1101: Chris@1221: SVDEBUG << "Colour3DPlotRenderer::paintWithRenderer: mag range in this view: " Chris@1221: << m_viewMags[v->getId()].getMin() Chris@1221: << " -> " Chris@1221: << m_viewMags[v->getId()].getMax() Chris@1221: << endl; Chris@1101: } Chris@1101: Chris@1101: void Chris@916: Colour3DPlotLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const Chris@0: { Chris@514: /* Chris@443: if (m_model) { Chris@587: SVDEBUG << "Colour3DPlotLayer::paint: model says shouldUseLogValueScale = " << m_model->shouldUseLogValueScale() << endl; Chris@443: } Chris@514: */ Chris@466: Profiler profiler("Colour3DPlotLayer::paint"); Chris@125: #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT Chris@812: cerr << "Colour3DPlotLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", rect is (" << rect.x() << "," << rect.y() << ") " << rect.width() << "x" << rect.height() << endl; Chris@125: #endif Chris@0: Chris@0: int completion = 0; Chris@0: if (!m_model || !m_model->isOK() || !m_model->isReady(&completion)) { Chris@0: if (completion > 0) { Chris@916: paint.fillRect(0, 10, v->getPaintWidth() * completion / 100, Chris@0: 10, QColor(120, 120, 120)); Chris@0: } Chris@0: return; Chris@0: } Chris@0: Chris@1053: if (m_model->getWidth() == 0) { Chris@1053: #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT Chris@1053: cerr << "Colour3DPlotLayer::paint(): model width == 0, " Chris@1053: << "nothing to paint (yet)" << endl; Chris@1053: #endif Chris@1053: return; Chris@1053: } Chris@1101: Chris@1101: //!!!??? Chris@1053: Chris@1104: if (m_normalizeVisibleArea) { Chris@1099: rect = v->getPaintRect(); Chris@1099: } Chris@197: Chris@1107: //!!! why is the setLayerDormant(false) found here in Chris@1107: //!!! SpectrogramLayer not present in Colour3DPlotLayer? Chris@1107: //!!! unnecessary? vestigial? forgotten? Chris@1107: Chris@1107: paintWithRenderer(v, paint, rect); Chris@1107: } Chris@1107: Chris@28: bool Chris@916: Colour3DPlotLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, Chris@805: int &resolution, Chris@28: SnapType snap) const Chris@24: { Chris@24: if (!m_model) { Chris@44: return Layer::snapToFeatureFrame(v, frame, resolution, snap); Chris@24: } Chris@24: Chris@130: resolution = m_model->getResolution(); Chris@904: sv_frame_t left = (frame / resolution) * resolution; Chris@904: sv_frame_t right = left + resolution; Chris@28: Chris@28: switch (snap) { Chris@28: case SnapLeft: frame = left; break; Chris@28: case SnapRight: frame = right; break; Chris@28: case SnapNearest: Chris@28: case SnapNeighbouring: Chris@28: if (frame - left > right - frame) frame = right; Chris@28: else frame = left; Chris@28: break; Chris@28: } Chris@24: Chris@28: return true; Chris@24: } Chris@24: Chris@316: void Chris@316: Colour3DPlotLayer::toXml(QTextStream &stream, Chris@316: QString indent, QString extraAttributes) const Chris@197: { Chris@316: QString s = QString("scale=\"%1\" " Chris@316: "colourScheme=\"%2\" " Chris@1099: "minY=\"%3\" " Chris@1099: "maxY=\"%4\" " Chris@1099: "invertVertical=\"%5\" " Chris@1099: "opaque=\"%6\" %7") Chris@1104: .arg(convertFromColourScale(m_colourScale)) Chris@197: .arg(m_colourMap) Chris@445: .arg(m_miny) Chris@465: .arg(m_maxy) Chris@465: .arg(m_invertVertical ? "true" : "false") Chris@534: .arg(m_opaque ? "true" : "false") Chris@536: .arg(QString("binScale=\"%1\" smooth=\"%2\" gain=\"%3\" ") Chris@1103: .arg(int(m_binScale)) Chris@536: .arg(m_smooth ? "true" : "false") Chris@536: .arg(m_gain)); Chris@535: Chris@1099: // New-style normalization attributes, allowing for more types of Chris@1099: // normalization in future: write out the column normalization Chris@1099: // type separately, and then whether we are normalizing visible Chris@1099: // area as well afterwards Chris@1099: Chris@1099: s += QString("columnNormalization=\"%1\" ") Chris@1104: .arg(m_normalization == ColumnNormalization::Max1 ? "peak" : Chris@1104: m_normalization == ColumnNormalization::Hybrid ? "hybrid" : "none"); Chris@1099: Chris@1099: // Old-style normalization attribute, for backward compatibility Chris@1099: Chris@1099: s += QString("normalizeColumns=\"%1\" ") Chris@1104: .arg(m_normalization == ColumnNormalization::Max1 ? "true" : "false"); Chris@1099: Chris@1099: // And this applies to both old- and new-style attributes Chris@1099: Chris@1099: s += QString("normalizeVisibleArea=\"%1\" ") Chris@1104: .arg(m_normalizeVisibleArea ? "true" : "false"); Chris@1099: Chris@316: Layer::toXml(stream, indent, extraAttributes + " " + s); Chris@197: } Chris@197: Chris@197: void Chris@197: Colour3DPlotLayer::setProperties(const QXmlAttributes &attributes) Chris@197: { Chris@445: bool ok = false, alsoOk = false; Chris@197: Chris@1105: ColourScaleType colourScale = convertToColourScale Chris@1099: (attributes.value("colourScale").toInt(&ok)); Chris@1099: if (ok) setColourScale(colourScale); Chris@197: Chris@197: int colourMap = attributes.value("colourScheme").toInt(&ok); Chris@197: if (ok) setColourMap(colourMap); Chris@197: Chris@1103: BinScale binScale = (BinScale) Chris@1099: attributes.value("binScale").toInt(&ok); Chris@1099: if (ok) setBinScale(binScale); Chris@445: Chris@465: bool invertVertical = Chris@465: (attributes.value("invertVertical").trimmed() == "true"); Chris@465: setInvertVertical(invertVertical); Chris@465: Chris@465: bool opaque = Chris@465: (attributes.value("opaque").trimmed() == "true"); Chris@535: setOpaque(opaque); Chris@535: Chris@535: bool smooth = Chris@535: (attributes.value("smooth").trimmed() == "true"); Chris@535: setSmooth(smooth); Chris@465: Chris@536: float gain = attributes.value("gain").toFloat(&ok); Chris@536: if (ok) setGain(gain); Chris@536: Chris@445: float min = attributes.value("minY").toFloat(&ok); Chris@445: float max = attributes.value("maxY").toFloat(&alsoOk); Chris@445: if (ok && alsoOk) setDisplayExtents(min, max); Chris@1099: Chris@1099: bool haveNewStyleNormalization = false; Chris@1099: Chris@1099: QString columnNormalization = attributes.value("columnNormalization"); Chris@1099: Chris@1099: if (columnNormalization != "") { Chris@1099: Chris@1099: haveNewStyleNormalization = true; Chris@1099: Chris@1099: if (columnNormalization == "peak") { Chris@1104: setNormalization(ColumnNormalization::Max1); Chris@1099: } else if (columnNormalization == "hybrid") { Chris@1104: setNormalization(ColumnNormalization::Hybrid); Chris@1099: } else if (columnNormalization == "none") { Chris@1104: setNormalization(ColumnNormalization::None); Chris@1099: } else { Chris@1099: cerr << "NOTE: Unknown or unsupported columnNormalization attribute \"" Chris@1099: << columnNormalization << "\"" << endl; Chris@1099: } Chris@1099: } Chris@1099: Chris@1099: if (!haveNewStyleNormalization) { Chris@1099: Chris@1104: setNormalization(ColumnNormalization::None); Chris@1104: Chris@1099: bool normalizeColumns = Chris@1099: (attributes.value("normalizeColumns").trimmed() == "true"); Chris@1099: if (normalizeColumns) { Chris@1104: setNormalization(ColumnNormalization::Max1); Chris@1099: } Chris@1099: Chris@1099: bool normalizeHybrid = Chris@1099: (attributes.value("normalizeHybrid").trimmed() == "true"); Chris@1099: if (normalizeHybrid) { Chris@1104: setNormalization(ColumnNormalization::Hybrid); Chris@1099: } Chris@1099: } Chris@1099: Chris@1099: bool normalizeVisibleArea = Chris@1099: (attributes.value("normalizeVisibleArea").trimmed() == "true"); Chris@1104: setNormalizeVisibleArea(normalizeVisibleArea); Chris@1099: Chris@1099: //!!! todo: check save/reload scaling, compare with Chris@1099: //!!! SpectrogramLayer, compare with prior SV versions, compare Chris@1099: //!!! with Tony v1 and v2 and their save files Chris@197: } Chris@197: