Mercurial > hg > svgui
changeset 1266:a34a2a25907c
Untabify
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/Colour3DPlotLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -148,7 +148,7 @@ connect(m_model, SIGNAL(modelChanged()), this, SLOT(modelChanged())); connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); m_peakResolution = 256; if (model->getResolution() > 512) { @@ -324,36 +324,36 @@ if (name == "Gain") { - *min = -50; - *max = 50; + *min = -50; + *max = 50; *deflt = int(lrint(log10(1.0) * 20.0)); - if (*deflt < *min) *deflt = *min; - if (*deflt > *max) *deflt = *max; + if (*deflt < *min) *deflt = *min; + if (*deflt > *max) *deflt = *max; - val = int(lrint(log10(m_gain) * 20.0)); - if (val < *min) val = *min; - if (val > *max) val = *max; + val = int(lrint(log10(m_gain) * 20.0)); + if (val < *min) val = *min; + if (val > *max) val = *max; } else if (name == "Colour Scale") { // linear, log, +/-1, abs - *min = 0; - *max = 3; + *min = 0; + *max = 3; *deflt = 0; - val = convertFromColourScale(m_colourScale); + val = convertFromColourScale(m_colourScale); } else if (name == "Colour") { - *min = 0; - *max = ColourMapper::getColourMapCount() - 1; + *min = 0; + *max = ColourMapper::getColourMapCount() - 1; *deflt = 0; - val = m_colourMap; + val = m_colourMap; } else if (name == "Normalization") { - + *min = 0; *max = 3; *deflt = 0; @@ -361,29 +361,29 @@ val = convertFromColumnNorm(m_normalization, m_normalizeVisibleArea); } else if (name == "Invert Vertical Scale") { - + *deflt = 0; - val = (m_invertVertical ? 1 : 0); + val = (m_invertVertical ? 1 : 0); } else if (name == "Bin Scale") { - *min = 0; - *max = 1; + *min = 0; + *max = 1; *deflt = int(BinScale::Linear); - val = (int)m_binScale; + val = (int)m_binScale; } else if (name == "Opaque") { - + *deflt = 0; - val = (m_opaque ? 1 : 0); + val = (m_opaque ? 1 : 0); } else if (name == "Smooth") { - + *deflt = 0; - val = (m_smooth ? 1 : 0); + val = (m_smooth ? 1 : 0); } else { - val = Layer::getPropertyRangeAndValue(name, min, max, deflt); + val = Layer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -391,19 +391,19 @@ QString Colour3DPlotLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { if (name == "Colour") { return ColourMapper::getColourMapName(value); } if (name == "Colour Scale") { - switch (value) { - default: - case 0: return tr("Linear"); - case 1: return tr("Log"); - case 2: return tr("+/-1"); - case 3: return tr("Absolute"); - } + switch (value) { + default: + case 0: return tr("Linear"); + case 1: return tr("Log"); + case 2: return tr("+/-1"); + case 3: return tr("Absolute"); + } } if (name == "Normalization") { switch(value) { @@ -416,11 +416,11 @@ // return ""; // icon only } if (name == "Bin Scale") { - switch (value) { - default: - case 0: return tr("Linear"); - case 1: return tr("Log"); - } + switch (value) { + default: + case 0: return tr("Linear"); + case 1: return tr("Log"); + } } return tr("<unknown>"); } @@ -454,23 +454,23 @@ Colour3DPlotLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(float(pow(10, value/20.0))); + setGain(float(pow(10, value/20.0))); } else if (name == "Colour Scale") { setColourScale(convertToColourScale(value)); } else if (name == "Colour") { setColourMap(value); } else if (name == "Invert Vertical Scale") { - setInvertVertical(value ? true : false); + setInvertVertical(value ? true : false); } else if (name == "Opaque") { - setOpaque(value ? true : false); + setOpaque(value ? true : false); } else if (name == "Smooth") { - setSmooth(value ? true : false); + setSmooth(value ? true : false); } else if (name == "Bin Scale") { - switch (value) { - default: - case 0: setBinScale(BinScale::Linear); break; - case 1: setBinScale(BinScale::Log); break; - } + switch (value) { + default: + case 0: setBinScale(BinScale::Linear); break; + case 1: setBinScale(BinScale::Log); break; + } } else if (name == "Normalization") { auto n = convertToColumnNorm(value); setNormalization(n.first); @@ -624,7 +624,7 @@ Layer::setLayerDormant(v, true); cacheInvalid(); - + } else { Layer::setLayerDormant(v, false); @@ -835,12 +835,12 @@ else binName = QString("%1 [%2]").arg(binName).arg(sy + 1); QString text = tr("Time:\t%1 - %2\nBin:\t%3\nValue:\t%4") - .arg(RealTime::frame2RealTime(f0, m_model->getSampleRate()) - .toText(true).c_str()) - .arg(RealTime::frame2RealTime(f1, m_model->getSampleRate()) - .toText(true).c_str()) - .arg(binName) - .arg(value); + .arg(RealTime::frame2RealTime(f0, m_model->getSampleRate()) + .toText(true).c_str()) + .arg(RealTime::frame2RealTime(f1, m_model->getSampleRate()) + .toText(true).c_str()) + .arg(binName) + .arg(value); return text; } @@ -863,13 +863,13 @@ bool another = false; for (int i = 0; i < m_model->getHeight(); ++i) { - if (m_model->getBinName(i).length() > sampleText.length()) { - sampleText = m_model->getBinName(i); + if (m_model->getBinName(i).length() > sampleText.length()) { + sampleText = m_model->getBinName(i); another = true; - } + } } if (another) { - tw = std::max(tw, paint.fontMetrics().width(sampleText)); + tw = std::max(tw, paint.fontMetrics().width(sampleText)); } return tw + 13 + getColourScaleWidth(paint); @@ -969,7 +969,7 @@ } } } - + py = y0; if (i < symax) { @@ -1123,11 +1123,11 @@ int completion = 0; if (!m_model || !m_model->isOK() || !m_model->isReady(&completion)) { - if (completion > 0) { - paint.fillRect(0, 10, v->getPaintWidth() * completion / 100, - 10, QColor(120, 120, 120)); - } - return; + if (completion > 0) { + paint.fillRect(0, 10, v->getPaintWidth() * completion / 100, + 10, QColor(120, 120, 120)); + } + return; } if (m_model->getWidth() == 0) { @@ -1143,11 +1143,11 @@ bool Colour3DPlotLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const + int &resolution, + SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); @@ -1159,9 +1159,9 @@ case SnapRight: frame = right; break; case SnapNearest: case SnapNeighbouring: - if (frame - left > right - frame) frame = right; - else frame = left; - break; + if (frame - left > right - frame) frame = right; + else frame = left; + break; } return true; @@ -1177,7 +1177,7 @@ "maxY=\"%4\" " "invertVertical=\"%5\" " "opaque=\"%6\" %7") - .arg(convertFromColourScale(m_colourScale)) + .arg(convertFromColourScale(m_colourScale)) .arg(m_colourMap) .arg(m_miny) .arg(m_maxy) @@ -1200,7 +1200,7 @@ // Old-style normalization attribute, for backward compatibility s += QString("normalizeColumns=\"%1\" ") - .arg(m_normalization == ColumnNormalization::Range01 ? "true" : "false"); + .arg(m_normalization == ColumnNormalization::Range01 ? "true" : "false"); // And this applies to both old- and new-style attributes @@ -1223,7 +1223,7 @@ if (ok) setColourMap(colourMap); BinScale binScale = (BinScale) - attributes.value("binScale").toInt(&ok); + attributes.value("binScale").toInt(&ok); if (ok) setBinScale(binScale); bool invertVertical =
--- a/layer/Colour3DPlotLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/Colour3DPlotLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -59,8 +59,8 @@ virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant); @@ -82,7 +82,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual QString getPropertyValueIconName(const PropertyName &, int value) const; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
--- a/layer/Colour3DPlotRenderer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/Colour3DPlotRenderer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -464,21 +464,21 @@ psx = sx; } - sv_frame_t fx = sx * modelResolution + modelStart; + sv_frame_t fx = sx * modelResolution + modelStart; - if (fx + modelResolution <= modelStart || fx > modelEnd) continue; + if (fx + modelResolution <= modelStart || fx > modelEnd) continue; int rx0 = v->getXForFrame(int(double(fx) * rateRatio)); - int rx1 = v->getXForFrame(int(double(fx + modelResolution + 1) * rateRatio)); + int rx1 = v->getXForFrame(int(double(fx + modelResolution + 1) * rateRatio)); - int rw = rx1 - rx0; - if (rw < 1) rw = 1; + int rw = rx1 - rx0; + if (rw < 1) rw = 1; - bool showLabel = (rw > 10 && - paint.fontMetrics().width("0.000000") < rw - 3 && - paint.fontMetrics().height() < (h / sh)); + bool showLabel = (rw > 10 && + paint.fontMetrics().width("0.000000") < rw - 3 && + paint.fontMetrics().height() < (h / sh)); - for (int sy = minbin; sy < minbin + nbins; ++sy) { + for (int sy = minbin; sy < minbin + nbins; ++sy) { int ry0 = m_sources.verticalBinLayer->getIYForBin(v, sy); int ry1 = m_sources.verticalBinLayer->getIYForBin(v, sy + 1); @@ -501,30 +501,30 @@ continue; } - QColor pen(255, 255, 255, 80); - QColor brush(colour); + QColor pen(255, 255, 255, 80); + QColor brush(colour); if (rw > 3 && r.height() > 3) { brush.setAlpha(160); } - paint.setPen(Qt::NoPen); - paint.setBrush(brush); + paint.setPen(Qt::NoPen); + paint.setBrush(brush); - if (illuminate) { - if (r.contains(illuminatePos)) { - paint.setPen(v->getForeground()); - } - } + if (illuminate) { + if (r.contains(illuminatePos)) { + paint.setPen(v->getForeground()); + } + } #ifdef DEBUG_COLOUR_PLOT_REPAINT // SVDEBUG << "rect " << r.x() << "," << r.y() << " " // << r.width() << "x" << r.height() << endl; #endif - paint.drawRect(r); + paint.drawRect(r); - if (showLabel) { + if (showLabel) { double value = model->getValueAt(sx, sy); snprintf(labelbuf, buflen, "%06f", value); QString text(labelbuf); @@ -535,8 +535,8 @@ ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), text, PaintAssistant::OutlinedText); - } - } + } + } } return magRange; @@ -598,7 +598,7 @@ const DenseThreeDimensionalModel *model = m_sources.source; if (!model || !model->isOK() || !model->isReady()) { - throw std::logic_error("no source model provided, or model not ready"); + throw std::logic_error("no source model provided, or model not ready"); } int h = v->getPaintHeight(); @@ -739,7 +739,7 @@ const DenseThreeDimensionalModel *model = m_sources.source; if (!model || !model->isOK() || !model->isReady()) { - throw std::logic_error("no source model provided, or model not ready"); + throw std::logic_error("no source model provided, or model not ready"); } // The draw buffer will contain a fragment at bin resolution. We
--- a/layer/Colour3DPlotRenderer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/Colour3DPlotRenderer.h Thu Mar 01 18:02:22 2018 +0000 @@ -53,18 +53,18 @@ // These must all outlive this class const VerticalBinLayer *verticalBinLayer; // always - const DenseThreeDimensionalModel *source; // always - const FFTModel *fft; // optionally - std::vector<Dense3DModelPeakCache *> peakCaches; // zero or more + const DenseThreeDimensionalModel *source; // always + const FFTModel *fft; // optionally + std::vector<Dense3DModelPeakCache *> peakCaches; // zero or more }; struct Parameters { - Parameters() : - colourScale(ColourScale::Parameters()), - normalization(ColumnNormalization::None), - binDisplay(BinDisplay::AllBins), + Parameters() : + colourScale(ColourScale::Parameters()), + normalization(ColumnNormalization::None), + binDisplay(BinDisplay::AllBins), binScale(BinScale::Linear), - alwaysOpaque(false), + alwaysOpaque(false), interpolate(false), invertVertical(false), scaleFactor(1.0), @@ -73,32 +73,32 @@ /** A complete ColourScale object by value, used for colour * map conversion. Note that the final display gain setting is * also encapsulated here. */ - ColourScale colourScale; + ColourScale colourScale; /** Type of column normalization. */ - ColumnNormalization normalization; + ColumnNormalization normalization; /** Selection of bins to display. */ - BinDisplay binDisplay; + BinDisplay binDisplay; /** Scale for vertical bin spacing (linear or logarithmic). */ - BinScale binScale; + BinScale binScale; /** Whether cells should always be opaque. If false, then * large cells (when zoomed in a long way) will be rendered * translucent in order not to obscure anything in a layer * beneath. */ - bool alwaysOpaque; + bool alwaysOpaque; /** Whether to apply smoothing when rendering cells at more * than one pixel per cell. !!! todo: decide about separating * out x-interpolate and y-interpolate as the spectrogram * actually does (or used to) */ - bool interpolate; + bool interpolate; /** Whether to render the whole caboodle upside-down. */ - bool invertVertical; + bool invertVertical; /** Initial scale factor (e.g. for FFT scaling). This factor * is applied to all values read from the underlying model @@ -112,7 +112,7 @@ Colour3DPlotRenderer(Sources sources, Parameters parameters) : m_sources(sources), - m_params(parameters), + m_params(parameters), m_secondsPerXPixel(0.0), m_secondsPerXPixelValid(false) { }
--- a/layer/ColourDatabase.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ColourDatabase.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -160,7 +160,7 @@ { int index = -1; if (colourSpec != "") { - QColor colour(colourSpec); + QColor colour(colourSpec); index = getColourIndex(colour); if (index < 0) { index = addColour(colour,
--- a/layer/ColourScale.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ColourScale.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -32,7 +32,7 @@ if (m_params.minValue >= m_params.maxValue) { SVCERR << "ERROR: ColourScale::ColourScale: minValue = " << m_params.minValue << ", maxValue = " << m_params.maxValue << endl; - throw std::logic_error("maxValue must be greater than minValue"); + throw std::logic_error("maxValue must be greater than minValue"); } m_mappedMin = m_params.minValue; @@ -62,19 +62,19 @@ if (m_mappedMin < m_mappedMax + threshold) { m_mappedMin = m_mappedMax + threshold; } - + } else if (m_params.scaleType == ColourScaleType::PlusMinusOne) { - - m_mappedMin = -1.0; - m_mappedMax = 1.0; + + m_mappedMin = -1.0; + m_mappedMax = 1.0; } else if (m_params.scaleType == ColourScaleType::Absolute) { - m_mappedMin = fabs(m_mappedMin); - m_mappedMax = fabs(m_mappedMax); - if (m_mappedMin >= m_mappedMax) { - std::swap(m_mappedMin, m_mappedMax); - } + m_mappedMin = fabs(m_mappedMin); + m_mappedMax = fabs(m_mappedMax); + if (m_mappedMin >= m_mappedMax) { + std::swap(m_mappedMin, m_mappedMax); + } } if (m_mappedMin >= m_mappedMax) { @@ -84,7 +84,7 @@ << ", scale = " << int(m_params.scaleType) << " resulting in mapped minValue = " << m_mappedMin << ", mapped maxValue = " << m_mappedMax << endl; - throw std::logic_error("maxValue must be greater than minValue [after mapping]"); + throw std::logic_error("maxValue must be greater than minValue [after mapping]"); } } @@ -104,7 +104,7 @@ double maxPixF = m_maxPixel; if (m_params.scaleType == ColourScaleType::Phase) { - double half = (maxPixF - 1.f) / 2.f; + double half = (maxPixF - 1.f) / 2.f; int pixel = 1 + int((value * half) / M_PI + half); // SVCERR << "phase = " << value << " pixel = " << pixel << endl; return pixel; @@ -117,21 +117,21 @@ double mapped = value; if (m_params.scaleType == ColourScaleType::Log) { - mapped = LogRange::map(value); + mapped = LogRange::map(value); } else if (m_params.scaleType == ColourScaleType::PlusMinusOne) { - if (mapped < -1.f) mapped = -1.f; - if (mapped > 1.f) mapped = 1.f; + if (mapped < -1.f) mapped = -1.f; + if (mapped > 1.f) mapped = 1.f; } else if (m_params.scaleType == ColourScaleType::Absolute) { - if (mapped < 0.f) mapped = -mapped; + if (mapped < 0.f) mapped = -mapped; } mapped *= m_params.multiple; if (mapped < m_mappedMin) { - mapped = m_mappedMin; + mapped = m_mappedMin; } if (mapped > m_mappedMax) { - mapped = m_mappedMax; + mapped = m_mappedMax; } double proportion = (mapped - m_mappedMin) / (m_mappedMax - m_mappedMin); @@ -139,16 +139,16 @@ int pixel = 0; if (m_params.scaleType == ColourScaleType::Meter) { - pixel = AudioLevel::multiplier_to_preview(proportion, m_maxPixel-1) + 1; + pixel = AudioLevel::multiplier_to_preview(proportion, m_maxPixel-1) + 1; } else { - pixel = int(proportion * maxPixF) + 1; + pixel = int(proportion * maxPixF) + 1; } if (pixel < 0) { - pixel = 0; + pixel = 0; } if (pixel > m_maxPixel) { - pixel = m_maxPixel; + pixel = m_maxPixel; } return pixel; } @@ -157,21 +157,21 @@ ColourScale::getColourForPixel(int pixel, int rotation) const { if (pixel < 0) { - pixel = 0; + pixel = 0; } if (pixel > m_maxPixel) { - pixel = m_maxPixel; + pixel = m_maxPixel; } if (pixel == 0) { - if (m_mapper.hasLightBackground()) { - return Qt::white; - } else { - return Qt::black; - } + if (m_mapper.hasLightBackground()) { + return Qt::white; + } else { + return Qt::black; + } } else { - int target = int(pixel) + rotation; - while (target < 1) target += m_maxPixel; - while (target > m_maxPixel) target -= m_maxPixel; - return m_mapper.map(double(target)); + int target = int(pixel) + rotation; + while (target < 1) target += m_maxPixel; + while (target > m_maxPixel) target -= m_maxPixel; + return m_mapper.map(double(target)); } }
--- a/layer/ColourScale.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ColourScale.h Thu Mar 01 18:02:22 2018 +0000 @@ -35,28 +35,28 @@ { public: struct Parameters { - Parameters() : colourMap(0), scaleType(ColourScaleType::Linear), - minValue(0.0), maxValue(1.0), - threshold(0.0), gain(1.0), multiple(1.0) { } + Parameters() : colourMap(0), scaleType(ColourScaleType::Linear), + minValue(0.0), maxValue(1.0), + threshold(0.0), gain(1.0), multiple(1.0) { } - /** A colour map index as used by ColourMapper */ - int colourMap; - - /** Distribution for the scale */ - ColourScaleType scaleType; - - /** Minimum value in source range */ - double minValue; - - /** Maximum value in source range. Must be > minValue */ - double maxValue; + /** A colour map index as used by ColourMapper */ + int colourMap; + + /** Distribution for the scale */ + ColourScaleType scaleType; + + /** Minimum value in source range */ + double minValue; + + /** Maximum value in source range. Must be > minValue */ + double maxValue; - /** Threshold below which every value is mapped to background - pixel 0 */ - double threshold; + /** Threshold below which every value is mapped to background + pixel 0 */ + double threshold; - /** Gain to apply before thresholding, mapping, and clamping */ - double gain; + /** Gain to apply before thresholding, mapping, and clamping */ + double gain; /** Multiple to apply after thresholding and mapping. In most * cases the gain parameter is the one you want instead of @@ -106,7 +106,7 @@ * equivalent to getColourForPixel(getPixel(value), rotation). */ QColor getColour(double value, int rotation) const { - return getColourForPixel(getPixel(value), rotation); + return getColourForPixel(getPixel(value), rotation); } private:
--- a/layer/ImageLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ImageLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -91,14 +91,14 @@ int ImageLayer::getPropertyRangeAndValue(const PropertyName &name, - int *min, int *max, int *deflt) const + int *min, int *max, int *deflt) const { return Layer::getPropertyRangeAndValue(name, min, max, deflt); } QString ImageLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { return Layer::getPropertyValueLabel(name, value); } @@ -133,10 +133,10 @@ ImageModel::PointList rv; for (ImageModel::PointList::const_iterator i = points.begin(); - i != points.end(); ) { + i != points.end(); ) { - const ImageModel::Point &p(*i); - int px = v->getXForFrame(p.frame); + const ImageModel::Point &p(*i); + int px = v->getXForFrame(p.frame); if (px > x) break; ++i; @@ -178,11 +178,11 @@ ImageModel::PointList points = getLocalPoints(v, x, pos.y()); if (points.empty()) { - if (!m_model->isReady()) { - return tr("In progress"); - } else { - return ""; - } + if (!m_model->isReady()) { + return tr("In progress"); + } else { + return ""; + } } // int useFrame = points.begin()->frame; @@ -192,14 +192,14 @@ QString text; /* if (points.begin()->label == "") { - text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) - .arg(rt.toText(true).c_str()) - .arg(points.begin()->height) - .arg(points.begin()->label); + text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) + .arg(rt.toText(true).c_str()) + .arg(points.begin()->height) + .arg(points.begin()->label); } pos = QPoint(v->getXForFrame(useFrame), - getYForHeight(v, points.begin()->height)); + getYForHeight(v, points.begin()->height)); */ return text; } @@ -209,22 +209,22 @@ bool ImageLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const + int &resolution, + SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); ImageModel::PointList points; if (snap == SnapNeighbouring) { - - points = getLocalPoints(v, v->getXForFrame(frame), -1); - if (points.empty()) return false; - frame = points.begin()->frame; - return true; + + points = getLocalPoints(v, v->getXForFrame(frame), -1); + if (points.empty()) return false; + frame = points.begin()->frame; + return true; } points = m_model->getPoints(frame, frame); @@ -232,47 +232,47 @@ bool found = false; for (ImageModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame > frame) { - snapped = i->frame; - found = true; - break; - } + if (i->frame > frame) { + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame <= frame) { - snapped = i->frame; - found = true; // don't break, as the next may be better - } else { - break; - } + if (i->frame <= frame) { + snapped = i->frame; + found = true; // don't break, as the next may be better + } else { + break; + } - } else { // nearest + } else { // nearest - ImageModel::PointList::const_iterator j = i; - ++j; + ImageModel::PointList::const_iterator j = i; + ++j; - if (j == points.end()) { + if (j == points.end()) { - snapped = i->frame; - found = true; - break; + snapped = i->frame; + found = true; + break; - } else if (j->frame >= frame) { + } else if (j->frame >= frame) { - if (j->frame - frame < frame - i->frame) { - snapped = j->frame; - } else { - snapped = i->frame; - } - found = true; - break; - } - } + if (j->frame - frame < frame - i->frame) { + snapped = j->frame; + } else { + snapped = i->frame; + } + found = true; + break; + } + } } frame = snapped; @@ -316,11 +316,11 @@ paint.setRenderHint(QPainter::Antialiasing, true); for (ImageModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const ImageModel::Point &p(*i); + const ImageModel::Point &p(*i); - int x = v->getXForFrame(p.frame); + int x = v->getXForFrame(p.frame); int nx = x + 2000; ImageModel::PointList::const_iterator j = i; @@ -559,8 +559,8 @@ // SVDEBUG << "ImageLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; if (!m_model) { - SVDEBUG << "ImageLayer::drawStart: no model" << endl; - return; + SVDEBUG << "ImageLayer::drawStart: no model" << endl; + return; } sv_frame_t frame = v->getFrameForX(e->x()); @@ -605,10 +605,10 @@ checkAddSource(dialog.getImage()); - ImageModel::ChangeImageCommand *command = - new ImageModel::ChangeImageCommand + ImageModel::ChangeImageCommand *command = + new ImageModel::ChangeImageCommand (m_model, m_editingPoint, dialog.getImage(), dialog.getLabel()); - m_editingCommand->addCommand(command); + m_editingCommand->addCommand(command); } else { m_editingCommand->deletePoint(m_editingPoint); } @@ -652,8 +652,8 @@ m_originalPoint = m_editingPoint; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -671,7 +671,7 @@ frame = (frame / m_model->getResolution()) * m_model->getResolution(); if (!m_editingCommand) { - m_editingCommand = new ImageModel::EditCommand(m_model, tr("Move Image")); + m_editingCommand = new ImageModel::EditCommand(m_model, tr("Move Image")); } m_editingCommand->deletePoint(m_editingPoint); @@ -686,7 +686,7 @@ if (!m_model || !m_editing) return; if (m_editingCommand) { - finish(m_editingCommand); + finish(m_editingCommand); } m_editingCommand = 0; @@ -712,8 +712,8 @@ checkAddSource(dialog.getImage()); - ImageModel::ChangeImageCommand *command = - new ImageModel::ChangeImageCommand + ImageModel::ChangeImageCommand *command = + new ImageModel::ChangeImageCommand (m_model, *points.begin(), dialog.getImage(), dialog.getLabel()); CommandHistory::getInstance()->addCommand(command); @@ -728,20 +728,20 @@ if (!m_model) return; ImageModel::EditCommand *command = - new ImageModel::EditCommand(m_model, tr("Drag Selection")); + new ImageModel::EditCommand(m_model, tr("Drag Selection")); ImageModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (ImageModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { - ImageModel::Point newPoint(*i); - newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); - command->deletePoint(*i); - command->addPoint(newPoint); - } + if (s.contains(i->frame)) { + ImageModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -753,29 +753,29 @@ if (!m_model) return; ImageModel::EditCommand *command = - new ImageModel::EditCommand(m_model, tr("Resize Selection")); + new ImageModel::EditCommand(m_model, tr("Resize Selection")); ImageModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); double ratio = - double(newSize.getEndFrame() - newSize.getStartFrame()) / - double(s.getEndFrame() - s.getStartFrame()); + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); for (ImageModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { + if (s.contains(i->frame)) { - double target = double(i->frame); - target = double(newSize.getStartFrame()) + - target - double(s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; - ImageModel::Point newPoint(*i); - newPoint.frame = lrint(target); - command->deletePoint(*i); - command->addPoint(newPoint); - } + ImageModel::Point newPoint(*i); + newPoint.frame = lrint(target); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -787,14 +787,14 @@ if (!m_model) return; ImageModel::EditCommand *command = - new ImageModel::EditCommand(m_model, tr("Delete Selection")); + new ImageModel::EditCommand(m_model, tr("Delete Selection")); ImageModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (ImageModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) command->deletePoint(*i); + i != points.end(); ++i) { + if (s.contains(i->frame)) command->deletePoint(*i); } finish(command); @@ -806,11 +806,11 @@ if (!m_model) return; ImageModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (ImageModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) { + i != points.end(); ++i) { + if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->label); point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); @@ -845,7 +845,7 @@ } ImageModel::EditCommand *command = - new ImageModel::EditCommand(m_model, tr("Paste")); + new ImageModel::EditCommand(m_model, tr("Paste")); for (Clipboard::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -925,7 +925,7 @@ const ImageModel::PointList &points(m_model->getPoints()); for (ImageModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { checkAddSource((*i).image); }
--- a/layer/ImageLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ImageLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -43,8 +43,8 @@ virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual void drawStart(LayerGeometryProvider *v, QMouseEvent *); virtual void drawDrag(LayerGeometryProvider *v, QMouseEvent *); @@ -73,7 +73,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); virtual ColourSignificance getLayerColourSignificance() const {
--- a/layer/Layer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/Layer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -52,10 +52,10 @@ this, SIGNAL(modelChanged())); connect(model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); + this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(model, SIGNAL(completionChanged()), - this, SIGNAL(modelCompletionChanged())); + this, SIGNAL(modelCompletionChanged())); connect(model, SIGNAL(alignmentCompletionChanged()), this, SIGNAL(modelAlignmentCompletionChanged())); @@ -65,7 +65,7 @@ Layer::getPropertyContainerIconName() const { return LayerFactory::getInstance()->getLayerIconName - (LayerFactory::getInstance()->getLayerType(this)); + (LayerFactory::getInstance()->getLayerType(this)); } void @@ -85,14 +85,14 @@ QString modelName; if (getModel()) modelName = getModel()->objectName(); - + QString text; if (modelName != "") { - text = QString("%1: %2").arg(modelName).arg(layerName); + text = QString("%1: %2").arg(modelName).arg(layerName); } else { - text = layerName; + text = layerName; } - + return text; } @@ -109,7 +109,7 @@ // cerr << "Layer (" << this << ", " << objectName() << ")::getPlayParameters: model is "<< getModel() << endl; const Model *model = getModel(); if (model) { - return PlayParameterRepository::getInstance()->getPlayParameters(model); + return PlayParameterRepository::getInstance()->getPlayParameters(model); } return 0; } @@ -600,12 +600,12 @@ } stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5") - .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName + .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName (LayerFactory::getInstance()->getLayerType(this)))) - .arg(getObjectExportId(this)) - .arg(encodeEntities(objectName())) - .arg(getObjectExportId(getModel())) - .arg(extraAttributes); + .arg(getObjectExportId(this)) + .arg(encodeEntities(objectName())) + .arg(getObjectExportId(getModel())) + .arg(extraAttributes); if (m_measureRects.empty()) { stream << QString("/>\n"); @@ -634,11 +634,11 @@ } stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") - .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName + .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName (LayerFactory::getInstance()->getLayerType(this)))) - .arg(getObjectExportId(this)) - .arg(encodeEntities(objectName())) - .arg(getObjectExportId(getModel())) + .arg(getObjectExportId(this)) + .arg(encodeEntities(objectName())) + .arg(getObjectExportId(getModel())) .arg(extraAttributes); }
--- a/layer/Layer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/Layer.h Thu Mar 01 18:02:22 2018 +0000 @@ -51,7 +51,7 @@ */ class Layer : public PropertyContainer, - public XmlExportable + public XmlExportable { Q_OBJECT @@ -61,7 +61,7 @@ virtual const Model *getModel() const = 0; Model *getModel() { - return const_cast<Model *>(const_cast<const Layer *>(this)->getModel()); + return const_cast<Model *>(const_cast<const Layer *>(this)->getModel()); } /** @@ -106,13 +106,13 @@ virtual void setSynchronousPainting(bool /* synchronous */) { } enum VerticalPosition { - PositionTop, PositionMiddle, PositionBottom + PositionTop, PositionMiddle, PositionBottom }; virtual VerticalPosition getPreferredTimeRulerPosition() const { - return PositionMiddle; + return PositionMiddle; } virtual VerticalPosition getPreferredFrameCountPosition() const { - return PositionBottom; + return PositionBottom; } virtual bool hasLightBackground() const { return true; @@ -122,7 +122,7 @@ virtual QString getPropertyContainerName() const { if (m_presentationName != "") return m_presentationName; - else return objectName(); + else return objectName(); } virtual void setPresentationName(QString name); @@ -149,7 +149,7 @@ QPoint now) const; virtual QString getFeatureDescription(LayerGeometryProvider *, QPoint &) const { - return ""; + return ""; } virtual QString getLabelPreceding(sv_frame_t /* frame */) const { @@ -157,10 +157,10 @@ } enum SnapType { - SnapLeft, - SnapRight, - SnapNearest, - SnapNeighbouring + SnapLeft, + SnapRight, + SnapNearest, + SnapNeighbouring }; /** @@ -183,11 +183,11 @@ * the resolution of the model in this layer in sample frames. */ virtual bool snapToFeatureFrame(LayerGeometryProvider * /* v */, - sv_frame_t & /* frame */, - int &resolution, - SnapType /* snap */) const { - resolution = 1; - return false; + sv_frame_t & /* frame */, + int &resolution, + SnapType /* snap */) const { + resolution = 1; + return false; } /** @@ -210,8 +210,8 @@ sv_frame_t & /* source frame */, int &resolution, SnapType /* snap */) const { - resolution = 1; - return false; + resolution = 1; + return false; } // Draw, erase, and edit modes:
--- a/layer/LayerFactory.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/LayerFactory.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -84,14 +84,14 @@ case Slice: return Layer::tr("Time Slice"); case MelodicRangeSpectrogram: - // The user can change all the parameters of this after the - // fact -- there's nothing permanently melodic-range about it - // that should be encoded in its name - return Layer::tr("Spectrogram"); + // The user can change all the parameters of this after the + // fact -- there's nothing permanently melodic-range about it + // that should be encoded in its name + return Layer::tr("Spectrogram"); case PeakFrequencySpectrogram: - // likewise - return Layer::tr("Spectrogram"); + // likewise + return Layer::tr("Spectrogram"); case UnknownLayer: default: @@ -139,47 +139,47 @@ LayerTypeSet types; if (dynamic_cast<DenseThreeDimensionalModel *>(model)) { - types.insert(Colour3DPlot); + types.insert(Colour3DPlot); types.insert(Slice); } if (dynamic_cast<RangeSummarisableTimeValueModel *>(model)) { - types.insert(Waveform); + types.insert(Waveform); } if (dynamic_cast<DenseTimeValueModel *>(model)) { - types.insert(Spectrogram); - types.insert(MelodicRangeSpectrogram); - types.insert(PeakFrequencySpectrogram); + types.insert(Spectrogram); + types.insert(MelodicRangeSpectrogram); + types.insert(PeakFrequencySpectrogram); } if (dynamic_cast<SparseOneDimensionalModel *>(model)) { - types.insert(TimeInstants); + types.insert(TimeInstants); } if (dynamic_cast<SparseTimeValueModel *>(model)) { - types.insert(TimeValues); + types.insert(TimeValues); } if (dynamic_cast<NoteModel *>(model)) { - types.insert(Notes); + types.insert(Notes); } // NOTE: GF: types is a set, so order of insertion does not matter if (dynamic_cast<FlexiNoteModel *>(model)) { - types.insert(FlexiNotes); + types.insert(FlexiNotes); } if (dynamic_cast<RegionModel *>(model)) { - types.insert(Regions); + types.insert(Regions); } if (dynamic_cast<TextModel *>(model)) { - types.insert(Text); + types.insert(Text); } if (dynamic_cast<ImageModel *>(model)) { - types.insert(Image); + types.insert(Image); } if (dynamic_cast<DenseTimeValueModel *>(model)) { @@ -304,47 +304,47 @@ LayerFactory::setModel(Layer *layer, Model *model) { // if (trySetModel<WaveformLayer, RangeSummarisableTimeValueModel>(layer, model)) -// return; - +// return; + if (trySetModel<WaveformLayer, WaveFileModel>(layer, model)) - return; + return; if (trySetModel<WaveformLayer, WritableWaveFileModel>(layer, model)) - return; + return; if (trySetModel<SpectrogramLayer, DenseTimeValueModel>(layer, model)) - return; + return; if (trySetModel<TimeRulerLayer, Model>(layer, model)) - return; + return; if (trySetModel<TimeInstantLayer, SparseOneDimensionalModel>(layer, model)) - return; + return; if (trySetModel<TimeValueLayer, SparseTimeValueModel>(layer, model)) - return; + return; if (trySetModel<NoteLayer, NoteModel>(layer, model)) - return; + return; // GF: added FlexiNoteLayer if (trySetModel<FlexiNoteLayer, FlexiNoteModel>(layer, model)) - return; - + return; + if (trySetModel<RegionLayer, RegionModel>(layer, model)) - return; + return; if (trySetModel<TextLayer, TextModel>(layer, model)) - return; + return; if (trySetModel<ImageLayer, ImageModel>(layer, model)) - return; + return; if (trySetModel<Colour3DPlotLayer, DenseThreeDimensionalModel>(layer, model)) - return; + return; if (trySetModel<SpectrogramLayer, DenseTimeValueModel>(layer, model)) - return; + return; if (trySetModel<SpectrumLayer, DenseTimeValueModel>(layer, model)) return; @@ -357,21 +357,21 @@ LayerFactory::createEmptyModel(LayerType layerType, Model *baseModel) { if (layerType == TimeInstants) { - return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1); + return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1); } else if (layerType == TimeValues) { - return new SparseTimeValueModel(baseModel->getSampleRate(), 1, true); + return new SparseTimeValueModel(baseModel->getSampleRate(), 1, true); } else if (layerType == FlexiNotes) { - return new FlexiNoteModel(baseModel->getSampleRate(), 1, true); + return new FlexiNoteModel(baseModel->getSampleRate(), 1, true); } else if (layerType == Notes) { - return new NoteModel(baseModel->getSampleRate(), 1, true); + return new NoteModel(baseModel->getSampleRate(), 1, true); } else if (layerType == Regions) { - return new RegionModel(baseModel->getSampleRate(), 1, true); + return new RegionModel(baseModel->getSampleRate(), 1, true); } else if (layerType == Text) { - return new TextModel(baseModel->getSampleRate(), 1, true); + return new TextModel(baseModel->getSampleRate(), 1, true); } else if (layerType == Image) { - return new ImageModel(baseModel->getSampleRate(), 1, true); + return new ImageModel(baseModel->getSampleRate(), 1, true); } else { - return 0; + return 0; } } @@ -379,10 +379,10 @@ LayerFactory::getChannel(Layer *layer) { if (dynamic_cast<WaveformLayer *>(layer)) { - return dynamic_cast<WaveformLayer *>(layer)->getChannel(); + return dynamic_cast<WaveformLayer *>(layer)->getChannel(); } if (dynamic_cast<SpectrogramLayer *>(layer)) { - return dynamic_cast<SpectrogramLayer *>(layer)->getChannel(); + return dynamic_cast<SpectrogramLayer *>(layer)->getChannel(); } return -1; } @@ -391,16 +391,16 @@ LayerFactory::setChannel(Layer *layer, int channel) { if (dynamic_cast<WaveformLayer *>(layer)) { - dynamic_cast<WaveformLayer *>(layer)->setChannel(channel); - return; + dynamic_cast<WaveformLayer *>(layer)->setChannel(channel); + return; } if (dynamic_cast<SpectrogramLayer *>(layer)) { - dynamic_cast<SpectrogramLayer *>(layer)->setChannel(channel); - return; + dynamic_cast<SpectrogramLayer *>(layer)->setChannel(channel); + return; } if (dynamic_cast<SpectrumLayer *>(layer)) { - dynamic_cast<SpectrumLayer *>(layer)->setChannel(channel); - return; + dynamic_cast<SpectrumLayer *>(layer)->setChannel(channel); + return; } } @@ -412,48 +412,48 @@ switch (type) { case Waveform: - layer = new WaveformLayer; - break; + layer = new WaveformLayer; + break; case Spectrogram: - layer = new SpectrogramLayer; - break; + layer = new SpectrogramLayer; + break; case TimeRuler: - layer = new TimeRulerLayer; - break; + layer = new TimeRulerLayer; + break; case TimeInstants: - layer = new TimeInstantLayer; - break; + layer = new TimeInstantLayer; + break; case TimeValues: - layer = new TimeValueLayer; - break; + layer = new TimeValueLayer; + break; case FlexiNotes: - layer = new FlexiNoteLayer; - break; + layer = new FlexiNoteLayer; + break; case Notes: - layer = new NoteLayer; - break; + layer = new NoteLayer; + break; case Regions: - layer = new RegionLayer; - break; + layer = new RegionLayer; + break; case Text: - layer = new TextLayer; - break; + layer = new TextLayer; + break; case Image: - layer = new ImageLayer; - break; + layer = new ImageLayer; + break; case Colour3DPlot: - layer = new Colour3DPlotLayer; - break; + layer = new Colour3DPlotLayer; + break; case Spectrum: layer = new SpectrumLayer; @@ -464,12 +464,12 @@ break; case MelodicRangeSpectrogram: - layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange); - break; + layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange); + break; case PeakFrequencySpectrogram: - layer = new SpectrogramLayer(SpectrogramLayer::MelodicPeaks); - break; + layer = new SpectrogramLayer(SpectrogramLayer::MelodicPeaks); + break; case UnknownLayer: default: @@ -478,12 +478,12 @@ } if (!layer) { - cerr << "LayerFactory::createLayer: Unknown layer type " - << type << endl; + cerr << "LayerFactory::createLayer: Unknown layer type " + << type << endl; } else { -// SVDEBUG << "LayerFactory::createLayer: Setting object name " -// << getLayerPresentationName(type) << " on " << layer << endl; - layer->setObjectName(getLayerPresentationName(type)); +// SVDEBUG << "LayerFactory::createLayer: Setting object name " +// << getLayerPresentationName(type) << " on " << layer << endl; + layer->setObjectName(getLayerPresentationName(type)); setLayerDefaultProperties(type, layer); }
--- a/layer/LayerFactory.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/LayerFactory.h Thu Mar 01 18:02:22 2018 +0000 @@ -28,27 +28,27 @@ public: enum LayerType { - // Standard layers - Waveform, - Spectrogram, - TimeRuler, - TimeInstants, - TimeValues, - Notes, - FlexiNotes, - Regions, - Text, + // Standard layers + Waveform, + Spectrogram, + TimeRuler, + TimeInstants, + TimeValues, + Notes, + FlexiNotes, + Regions, + Text, Image, - Colour3DPlot, + Colour3DPlot, Spectrum, Slice, - // Layers with different initial parameters - MelodicRangeSpectrogram, - PeakFrequencySpectrogram, + // Layers with different initial parameters + MelodicRangeSpectrogram, + PeakFrequencySpectrogram, - // Not-a-layer-type - UnknownLayer = 255 + // Not-a-layer-type + UnknownLayer = 255 }; static LayerFactory *getInstance(); @@ -89,12 +89,12 @@ protected: template <typename LayerClass, typename ModelClass> bool trySetModel(Layer *layerBase, Model *modelBase) { - LayerClass *layer = dynamic_cast<LayerClass *>(layerBase); - if (!layer) return false; - ModelClass *model = dynamic_cast<ModelClass *>(modelBase); - if (!model) return false; - layer->setModel(model); - return true; + LayerClass *layer = dynamic_cast<LayerClass *>(layerBase); + if (!layer) return false; + ModelClass *model = dynamic_cast<ModelClass *>(modelBase); + if (!model) return false; + layer->setModel(model); + return true; } static LayerFactory *m_instance;
--- a/layer/LinearColourScale.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/LinearColourScale.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -24,18 +24,18 @@ int LinearColourScale::getWidth(LayerGeometryProvider *, - QPainter &paint) + QPainter &paint) { return paint.fontMetrics().width("-000.00") + 15; } void LinearColourScale::paintVertical(LayerGeometryProvider *v, - const ColourScaleLayer *layer, - QPainter &paint, - int /* x0 */, - double min, - double max) + const ColourScaleLayer *layer, + QPainter &paint, + int /* x0 */, + double min, + double max) { int h = v->getPaintHeight(); @@ -58,9 +58,9 @@ paint.save(); for (int y = 0; y < boxh; ++y) { - double val = ((boxh - y) * (max - min)) / boxh + min; - paint.setPen(layer->getColourForValue(v, val)); - paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); + double val = ((boxh - y) * (max - min)) / boxh + min; + paint.setPen(layer->getColourForValue(v, val)); + paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); } paint.restore(); @@ -78,19 +78,19 @@ for (int i = 0; i < n; ++i) { - int y, ty; + int y, ty; - y = boxy + int(boxh - ((val - min) * boxh) / (max - min)); + y = boxy + int(boxh - ((val - min) * boxh) / (max - min)); - ty = y - paint.fontMetrics().height() + - paint.fontMetrics().ascent() + 2; + ty = y - paint.fontMetrics().height() + + paint.fontMetrics().ascent() + 2; - snprintf(buffer, buflen, "%.*f", dp, val); - QString label = QString(buffer); + snprintf(buffer, buflen, "%.*f", dp, val); + QString label = QString(buffer); - paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y); - paint.drawText(tx, ty, label); + paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y); + paint.drawText(tx, ty, label); - val += inc; + val += inc; } }
--- a/layer/LinearNumericalScale.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/LinearNumericalScale.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -26,18 +26,18 @@ int LinearNumericalScale::getWidth(LayerGeometryProvider *, - QPainter &paint) + QPainter &paint) { return paint.fontMetrics().width("-000.00") + 10; } void LinearNumericalScale::paintVertical(LayerGeometryProvider *v, - const VerticalScaleLayer *layer, - QPainter &paint, - int x0, - double minf, - double maxf) + const VerticalScaleLayer *layer, + QPainter &paint, + int x0, + double minf, + double maxf) { int n = 10; auto ticks = ScaleTickIntervals::linear({ minf, maxf, n }); @@ -49,30 +49,30 @@ for (int i = 0; i < n; ++i) { - int y, ty; + int y, ty; bool drawText = true; - if (i == n-1 && - v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { - if (layer->getScaleUnits() != "") drawText = false; - } + if (i == n-1 && + v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { + if (layer->getScaleUnits() != "") drawText = false; + } double val = ticks[i].value; QString label = QString::fromStdString(ticks[i].label); - y = layer->getYForValue(v, val); + y = layer->getYForValue(v, val); - ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; - - if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { - continue; + ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; + + if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { + continue; } - paint.drawLine(w - 5, y, w, y); + paint.drawLine(w - 5, y, w, y); if (drawText) { - paint.drawText(w - paint.fontMetrics().width(label) - 6, - ty, label); + paint.drawText(w - paint.fontMetrics().width(label) - 6, + ty, label); } prevy = y;
--- a/layer/LogColourScale.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/LogColourScale.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -26,18 +26,18 @@ int LogColourScale::getWidth(LayerGeometryProvider *, - QPainter &paint) + QPainter &paint) { return paint.fontMetrics().width("-000.00") + 15; } void LogColourScale::paintVertical(LayerGeometryProvider *v, - const ColourScaleLayer *layer, - QPainter &paint, - int /* x0 */, - double minlog, - double maxlog) + const ColourScaleLayer *layer, + QPainter &paint, + int /* x0 */, + double minlog, + double maxlog) { int h = v->getPaintHeight(); @@ -60,9 +60,9 @@ paint.save(); for (int y = 0; y < boxh; ++y) { - double val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog; - paint.setPen(layer->getColourForValue(v, LogRange::unmap(val))); - paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); + double val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog; + paint.setPen(layer->getColourForValue(v, LogRange::unmap(val))); + paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); } paint.restore(); @@ -75,24 +75,24 @@ for (int i = 0; i < n; ++i) { - int y, ty; + int y, ty; - y = boxy + int(boxh - ((val - minlog) * boxh) / (maxlog - minlog)); + y = boxy + int(boxh - ((val - minlog) * boxh) / (maxlog - minlog)); - ty = y - paint.fontMetrics().height() + - paint.fontMetrics().ascent() + 2; + ty = y - paint.fontMetrics().height() + + paint.fontMetrics().ascent() + 2; - double dv = LogRange::unmap(val); - int digits = int(trunc(log10(dv))); - int sf = dp + (digits > 0 ? digits : 0); - if (sf < 2) sf = 2; - snprintf(buffer, buflen, "%.*g", sf, dv); + double dv = LogRange::unmap(val); + int digits = int(trunc(log10(dv))); + int sf = dp + (digits > 0 ? digits : 0); + if (sf < 2) sf = 2; + snprintf(buffer, buflen, "%.*g", sf, dv); - QString label = QString(buffer); + QString label = QString(buffer); - paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y); - paint.drawText(tx, ty, label); + paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y); + paint.drawText(tx, ty, label); - val += inc; + val += inc; } }
--- a/layer/LogNumericalScale.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/LogNumericalScale.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -28,18 +28,18 @@ int LogNumericalScale::getWidth(LayerGeometryProvider *, - QPainter &paint) + QPainter &paint) { return paint.fontMetrics().width("-000.00") + 10; } void LogNumericalScale::paintVertical(LayerGeometryProvider *v, - const VerticalScaleLayer *layer, - QPainter &paint, - int x0, - double minlog, - double maxlog) + const VerticalScaleLayer *layer, + QPainter &paint, + int x0, + double minlog, + double maxlog) { int n = 10; auto ticks = ScaleTickIntervals::logarithmicAlready({ minlog, maxlog, n }); @@ -51,30 +51,30 @@ for (int i = 0; i < n; ++i) { - int y, ty; + int y, ty; bool drawText = true; - if (i == n-1 && - v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { - if (layer->getScaleUnits() != "") drawText = false; - } + if (i == n-1 && + v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { + if (layer->getScaleUnits() != "") drawText = false; + } double val = ticks[i].value; QString label = QString::fromStdString(ticks[i].label); - y = layer->getYForValue(v, val); + y = layer->getYForValue(v, val); - ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; - - if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { - continue; + ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; + + if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { + continue; } - paint.drawLine(w - 5, y, w, y); + paint.drawLine(w - 5, y, w, y); if (drawText) { - paint.drawText(w - paint.fontMetrics().width(label) - 6, - ty, label); + paint.drawText(w - paint.fontMetrics().width(label) - 6, + ty, label); } prevy = y;
--- a/layer/NoteLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/NoteLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -61,12 +61,12 @@ m_scaleMinimum(0), m_scaleMaximum(0) { - SVDEBUG << "constructed NoteLayer" << endl; + SVDEBUG << "constructed NoteLayer" << endl; } void NoteLayer::setModel(NoteModel *model) -{ +{ if (m_model == model) return; m_model = model; @@ -128,12 +128,12 @@ int val = 0; if (name == "Vertical Scale") { - - if (min) *min = 0; - if (max) *max = 3; + + if (min) *min = 0; + if (max) *max = 3; if (deflt) *deflt = int(AutoAlignScale); - - val = int(m_verticalScale); + + val = int(m_verticalScale); } else if (name == "Scale Units") { @@ -145,7 +145,7 @@ } else { - val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); + val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -156,13 +156,13 @@ int value) const { if (name == "Vertical Scale") { - switch (value) { - default: - case 0: return tr("Auto-Align"); - case 1: return tr("Linear"); - case 2: return tr("Log"); - case 3: return tr("MIDI Notes"); - } + switch (value) { + default: + case 0: return tr("Auto-Align"); + case 1: return tr("Linear"); + case 2: return tr("Log"); + case 3: return tr("MIDI Notes"); + } } return SingleColourLayer::getPropertyValueLabel(name, value); } @@ -171,7 +171,7 @@ NoteLayer::setProperty(const PropertyName &name, int value) { if (name == "Vertical Scale") { - setVerticalScale(VerticalScale(value)); + setVerticalScale(VerticalScale(value)); } else if (name == "Scale Units") { if (m_model) { m_model->setScaleUnits @@ -397,36 +397,36 @@ sv_frame_t frame = v->getFrameForX(x); NoteModel::PointList onPoints = - m_model->getPoints(frame); + m_model->getPoints(frame); if (!onPoints.empty()) { - return onPoints; + return onPoints; } NoteModel::PointList prevPoints = - m_model->getPreviousPoints(frame); + m_model->getPreviousPoints(frame); NoteModel::PointList nextPoints = - m_model->getNextPoints(frame); + m_model->getNextPoints(frame); NoteModel::PointList usePoints = prevPoints; if (prevPoints.empty()) { - usePoints = nextPoints; + usePoints = nextPoints; } else if (int(prevPoints.begin()->frame) < v->getStartFrame() && - !(nextPoints.begin()->frame > v->getEndFrame())) { - usePoints = nextPoints; + !(nextPoints.begin()->frame > v->getEndFrame())) { + usePoints = nextPoints; } else if (int(nextPoints.begin()->frame) - frame < - frame - int(prevPoints.begin()->frame)) { - usePoints = nextPoints; + frame - int(prevPoints.begin()->frame)) { + usePoints = nextPoints; } if (!usePoints.empty()) { - int fuzz = 2; - int px = v->getXForFrame(usePoints.begin()->frame); - if ((px > x && px - x > fuzz) || - (px < x && x - px > fuzz + 1)) { - usePoints.clear(); - } + int fuzz = 2; + int px = v->getXForFrame(usePoints.begin()->frame); + if ((px > x && px - x > fuzz) || + (px < x && x - px > fuzz + 1)) { + usePoints.clear(); + } } return usePoints; @@ -470,11 +470,11 @@ NoteModel::PointList points = getLocalPoints(v, x); if (points.empty()) { - if (!m_model->isReady()) { - return tr("In progress"); - } else { - return tr("No local points"); - } + if (!m_model->isReady()) { + return tr("In progress"); + } else { + return tr("No local points"); + } } Note note(0); @@ -482,26 +482,26 @@ for (i = points.begin(); i != points.end(); ++i) { - int y = getYForValue(v, i->value); - int h = 3; + int y = getYForValue(v, i->value); + int h = 3; - if (m_model->getValueQuantization() != 0.0) { - h = y - getYForValue(v, i->value + m_model->getValueQuantization()); - if (h < 3) h = 3; - } + if (m_model->getValueQuantization() != 0.0) { + h = y - getYForValue(v, i->value + m_model->getValueQuantization()); + if (h < 3) h = 3; + } - if (pos.y() >= y - h && pos.y() <= y) { - note = *i; - break; - } + if (pos.y() >= y - h && pos.y() <= y) { + note = *i; + break; + } } if (i == points.end()) return tr("No local points"); RealTime rt = RealTime::frame2RealTime(note.frame, - m_model->getSampleRate()); + m_model->getSampleRate()); RealTime rd = RealTime::frame2RealTime(note.duration, - m_model->getSampleRate()); + m_model->getSampleRate()); QString pitchText; @@ -530,41 +530,41 @@ QString text; if (note.label == "") { - text = QString(tr("Time:\t%1\nPitch:\t%2\nDuration:\t%3\nNo label")) - .arg(rt.toText(true).c_str()) - .arg(pitchText) - .arg(rd.toText(true).c_str()); + text = QString(tr("Time:\t%1\nPitch:\t%2\nDuration:\t%3\nNo label")) + .arg(rt.toText(true).c_str()) + .arg(pitchText) + .arg(rd.toText(true).c_str()); } else { - text = QString(tr("Time:\t%1\nPitch:\t%2\nDuration:\t%3\nLabel:\t%4")) - .arg(rt.toText(true).c_str()) - .arg(pitchText) - .arg(rd.toText(true).c_str()) - .arg(note.label); + text = QString(tr("Time:\t%1\nPitch:\t%2\nDuration:\t%3\nLabel:\t%4")) + .arg(rt.toText(true).c_str()) + .arg(pitchText) + .arg(rd.toText(true).c_str()) + .arg(note.label); } pos = QPoint(v->getXForFrame(note.frame), - getYForValue(v, note.value)); + getYForValue(v, note.value)); return text; } bool NoteLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const + int &resolution, + SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); NoteModel::PointList points; if (snap == SnapNeighbouring) { - - points = getLocalPoints(v, v->getXForFrame(frame)); - if (points.empty()) return false; - frame = points.begin()->frame; - return true; + + points = getLocalPoints(v, v->getXForFrame(frame)); + if (points.empty()) return false; + frame = points.begin()->frame; + return true; } points = m_model->getPoints(frame, frame); @@ -572,47 +572,47 @@ bool found = false; for (NoteModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame > frame) { - snapped = i->frame; - found = true; - break; - } + if (i->frame > frame) { + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame <= frame) { - snapped = i->frame; - found = true; // don't break, as the next may be better - } else { - break; - } + if (i->frame <= frame) { + snapped = i->frame; + found = true; // don't break, as the next may be better + } else { + break; + } - } else { // nearest + } else { // nearest - NoteModel::PointList::const_iterator j = i; - ++j; + NoteModel::PointList::const_iterator j = i; + ++j; - if (j == points.end()) { + if (j == points.end()) { - snapped = i->frame; - found = true; - break; + snapped = i->frame; + found = true; + break; - } else if (j->frame >= frame) { + } else if (j->frame >= frame) { - if (j->frame - frame < frame - i->frame) { - snapped = j->frame; - } else { - snapped = i->frame; - } - found = true; - break; - } - } + if (j->frame - frame < frame - i->frame) { + snapped = j->frame; + } else { + snapped = i->frame; + } + found = true; + break; + } + } } frame = snapped; @@ -764,7 +764,7 @@ brushColour.setAlpha(80); // SVDEBUG << "NoteLayer::paint: resolution is " -// << m_model->getResolution() << " frames" << endl; +// << m_model->getResolution() << " frames" << endl; double min = m_model->getValueMinimum(); double max = m_model->getValueMaximum(); @@ -783,25 +783,25 @@ paint.setRenderHint(QPainter::Antialiasing, false); for (NoteModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const NoteModel::Point &p(*i); + const NoteModel::Point &p(*i); - int x = v->getXForFrame(p.frame); - int y = getYForValue(v, p.value); - int w = v->getXForFrame(p.frame + p.duration) - x; - int h = 3; - - if (m_model->getValueQuantization() != 0.0) { - h = y - getYForValue(v, p.value + m_model->getValueQuantization()); - if (h < 3) h = 3; - } + int x = v->getXForFrame(p.frame); + int y = getYForValue(v, p.value); + int w = v->getXForFrame(p.frame + p.duration) - x; + int h = 3; + + if (m_model->getValueQuantization() != 0.0) { + h = y - getYForValue(v, p.value + m_model->getValueQuantization()); + if (h < 3) h = 3; + } - if (w < 1) w = 1; - paint.setPen(getBaseQColor()); - paint.setBrush(brushColour); + if (w < 1) w = 1; + paint.setPen(getBaseQColor()); + paint.setBrush(brushColour); - if (shouldIlluminate && + if (shouldIlluminate && // "illuminatePoint == p" !NoteModel::Point::Comparator()(illuminatePoint, p) && !NoteModel::Point::Comparator()(p, illuminatePoint)) { @@ -822,9 +822,9 @@ x, y - h/2 - paint.fontMetrics().descent() - 2, hlabel, PaintAssistant::OutlinedText); - } - - paint.drawRect(x, y - h/2, w, h); + } + + paint.drawRect(x, y - h/2, w, h); } paint.restore(); @@ -900,7 +900,7 @@ if (m_editingCommand) finish(m_editingCommand); m_editingCommand = new NoteModel::EditCommand(m_model, - tr("Draw Point")); + tr("Draw Point")); m_editingCommand->addPoint(m_editingPoint); m_editing = true; @@ -953,8 +953,8 @@ if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -999,8 +999,8 @@ m_dragPointY = getYForValue(v, m_editingPoint.value); if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -1027,8 +1027,8 @@ double value = getValueForY(v, newy); if (!m_editingCommand) { - m_editingCommand = new NoteModel::EditCommand(m_model, - tr("Drag Point")); + m_editingCommand = new NoteModel::EditCommand(m_model, + tr("Drag Point")); } m_editingCommand->deletePoint(m_editingPoint); @@ -1045,20 +1045,20 @@ if (m_editingCommand) { - QString newName = m_editingCommand->getName(); + QString newName = m_editingCommand->getName(); - if (m_editingPoint.frame != m_originalPoint.frame) { - if (m_editingPoint.value != m_originalPoint.value) { - newName = tr("Edit Point"); - } else { - newName = tr("Relocate Point"); - } - } else { - newName = tr("Change Point Value"); - } + if (m_editingPoint.frame != m_originalPoint.frame) { + if (m_editingPoint.value != m_originalPoint.value) { + newName = tr("Edit Point"); + } else { + newName = tr("Relocate Point"); + } + } else { + newName = tr("Change Point Value"); + } - m_editingCommand->setName(newName); - finish(m_editingCommand); + m_editingCommand->setName(newName); + finish(m_editingCommand); } m_editingCommand = 0; @@ -1113,20 +1113,20 @@ if (!m_model) return; NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Drag Selection")); + new NoteModel::EditCommand(m_model, tr("Drag Selection")); NoteModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (NoteModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { - NoteModel::Point newPoint(*i); - newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); - command->deletePoint(*i); - command->addPoint(newPoint); - } + if (s.contains(i->frame)) { + NoteModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -1138,34 +1138,34 @@ if (!m_model) return; NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Resize Selection")); + new NoteModel::EditCommand(m_model, tr("Resize Selection")); NoteModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); double ratio = - double(newSize.getEndFrame() - newSize.getStartFrame()) / - double(s.getEndFrame() - s.getStartFrame()); + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); for (NoteModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { + if (s.contains(i->frame)) { - double targetStart = double(i->frame); - targetStart = double(newSize.getStartFrame()) + - targetStart - double(s.getStartFrame()) * ratio; + double targetStart = double(i->frame); + targetStart = double(newSize.getStartFrame()) + + targetStart - double(s.getStartFrame()) * ratio; - double targetEnd = double(i->frame + i->duration); - targetEnd = double(newSize.getStartFrame()) + - targetEnd - double(s.getStartFrame()) * ratio; + double targetEnd = double(i->frame + i->duration); + targetEnd = double(newSize.getStartFrame()) + + targetEnd - double(s.getStartFrame()) * ratio; - NoteModel::Point newPoint(*i); - newPoint.frame = lrint(targetStart); - newPoint.duration = lrint(targetEnd - targetStart); - command->deletePoint(*i); - command->addPoint(newPoint); - } + NoteModel::Point newPoint(*i); + newPoint.frame = lrint(targetStart); + newPoint.duration = lrint(targetEnd - targetStart); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -1177,13 +1177,13 @@ if (!m_model) return; NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); + new NoteModel::EditCommand(m_model, tr("Delete Selected Points")); NoteModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (NoteModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { if (s.contains(i->frame)) { command->deletePoint(*i); @@ -1199,11 +1199,11 @@ if (!m_model) return; NoteModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (NoteModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) { + i != points.end(); ++i) { + if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); @@ -1238,7 +1238,7 @@ } NoteModel::EditCommand *command = - new NoteModel::EditCommand(m_model, tr("Paste")); + new NoteModel::EditCommand(m_model, tr("Paste")); for (Clipboard::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -1350,7 +1350,7 @@ bool ok, alsoOk; VerticalScale scale = (VerticalScale) - attributes.value("verticalScale").toInt(&ok); + attributes.value("verticalScale").toInt(&ok); if (ok) setVerticalScale(scale); float min = attributes.value("scaleMinimum").toFloat(&ok);
--- a/layer/NoteLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/NoteLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -43,8 +43,8 @@ virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual void drawStart(LayerGeometryProvider *v, QMouseEvent *); virtual void drawDrag(LayerGeometryProvider *v, QMouseEvent *); @@ -78,7 +78,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); enum VerticalScale {
--- a/layer/PaintAssistant.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/PaintAssistant.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -29,7 +29,7 @@ void PaintAssistant::paintVerticalLevelScale(QPainter &paint, QRect rect, - double minVal, double maxVal, + double minVal, double maxVal, Scale scale, int &mult, std::vector<int> *vy) { @@ -243,18 +243,18 @@ paint.drawRect(r); paint.setBrush(Qt::NoBrush); - paint.setPen(surroundColour); + paint.setPen(surroundColour); - for (int dx = -1; dx <= 1; ++dx) { - for (int dy = -1; dy <= 1; ++dy) { - if (!(dx || dy)) continue; - paint.drawText(x + dx, y + dy, text); - } - } + for (int dx = -1; dx <= 1; ++dx) { + for (int dy = -1; dy <= 1; ++dy) { + if (!(dx || dy)) continue; + paint.drawText(x + dx, y + dy, text); + } + } - paint.setPen(penColour); + paint.setPen(penColour); - paint.drawText(x, y, text); + paint.drawText(x, y, text); paint.restore();
--- a/layer/PaintAssistant.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/PaintAssistant.h Thu Mar 01 18:02:22 2018 +0000 @@ -39,8 +39,8 @@ int minY, int height); enum TextStyle { - BoxedText, - OutlinedText, + BoxedText, + OutlinedText, OutlinedItalicText };
--- a/layer/PianoScale.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/PianoScale.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -28,10 +28,10 @@ void PianoScale::paintPianoVertical(LayerGeometryProvider *v, - QPainter &paint, - QRect r, - double minf, - double maxf) + QPainter &paint, + QRect r, + double minf, + double maxf) { int x0 = r.x(), y0 = r.y(), x1 = r.x() + r.width(), y1 = r.y() + r.height(); @@ -42,47 +42,47 @@ for (int i = 0; i < 128; ++i) { - double f = Pitch::getFrequencyForPitch(i); - int y = int(lrint(v->getYForFrequency(f, minf, maxf, true))); + double f = Pitch::getFrequencyForPitch(i); + int y = int(lrint(v->getYForFrequency(f, minf, maxf, true))); - if (y < y0 - 2) break; - if (y > y1 + 2) { - continue; - } - - int n = (i % 12); - - if (n == 1) { - // C# -- fill the C from here - QColor col = Qt::gray; - if (i == 61) { // filling middle C - col = Qt::blue; - col = col.light(150); - } - if (ppy - y > 2) { - paint.fillRect(x0 + 1, - y, - x1 - x0, - (py + ppy) / 2 - y, - col); - } - } - - if (n == 1 || n == 3 || n == 6 || n == 8 || n == 10) { - // black notes - paint.drawLine(x0 + 1, y, x1, y); - int rh = ((py - y) / 4) * 2; - if (rh < 2) rh = 2; - paint.drawRect(x0 + 1, y - (py-y)/4, (x1 - x0) / 2, rh); - } else if (n == 0 || n == 5) { - // C, F - if (py < y1) { - paint.drawLine(x0 + 1, (y + py) / 2, x1, (y + py) / 2); - } - } - - ppy = py; - py = y; + if (y < y0 - 2) break; + if (y > y1 + 2) { + continue; + } + + int n = (i % 12); + + if (n == 1) { + // C# -- fill the C from here + QColor col = Qt::gray; + if (i == 61) { // filling middle C + col = Qt::blue; + col = col.light(150); + } + if (ppy - y > 2) { + paint.fillRect(x0 + 1, + y, + x1 - x0, + (py + ppy) / 2 - y, + col); + } + } + + if (n == 1 || n == 3 || n == 6 || n == 8 || n == 10) { + // black notes + paint.drawLine(x0 + 1, y, x1, y); + int rh = ((py - y) / 4) * 2; + if (rh < 2) rh = 2; + paint.drawRect(x0 + 1, y - (py-y)/4, (x1 - x0) / 2, rh); + } else if (n == 0 || n == 5) { + // C, F + if (py < y1) { + paint.drawLine(x0 + 1, (y + py) / 2, x1, (y + py) / 2); + } + } + + ppy = py; + py = y; } }
--- a/layer/RegionLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/RegionLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -138,20 +138,20 @@ val = m_colourMap; } else if (name == "Plot Type") { - - if (min) *min = 0; - if (max) *max = 1; + + if (min) *min = 0; + if (max) *max = 1; if (deflt) *deflt = 0; - - val = int(m_plotStyle); + + val = int(m_plotStyle); } else if (name == "Vertical Scale") { - - if (min) *min = 0; - if (max) *max = 3; + + if (min) *min = 0; + if (max) *max = 3; if (deflt) *deflt = int(EqualSpaced); - - val = int(m_verticalScale); + + val = int(m_verticalScale); } else if (name == "Scale Units") { @@ -163,7 +163,7 @@ } else { - val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); + val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -177,20 +177,20 @@ return ColourMapper::getColourMapName(value); } else if (name == "Plot Type") { - switch (value) { - default: - case 0: return tr("Bars"); - case 1: return tr("Segmentation"); - } + switch (value) { + default: + case 0: return tr("Bars"); + case 1: return tr("Segmentation"); + } } else if (name == "Vertical Scale") { - switch (value) { - default: - case 0: return tr("Auto-Align"); - case 1: return tr("Equal Spaced"); - case 2: return tr("Linear"); - case 3: return tr("Log"); - } + switch (value) { + default: + case 0: return tr("Auto-Align"); + case 1: return tr("Equal Spaced"); + case 2: return tr("Linear"); + case 3: return tr("Log"); + } } return SingleColourLayer::getPropertyValueLabel(name, value); } @@ -201,9 +201,9 @@ if (name == "Colour" && m_plotStyle == PlotSegmentation) { setFillColourMap(value); } else if (name == "Plot Type") { - setPlotStyle(PlotStyle(value)); + setPlotStyle(PlotStyle(value)); } else if (name == "Vertical Scale") { - setVerticalScale(VerticalScale(value)); + setVerticalScale(VerticalScale(value)); } else if (name == "Scale Units") { if (m_model) { m_model->setScaleUnits @@ -310,36 +310,36 @@ sv_frame_t frame = v->getFrameForX(x); RegionModel::PointList onPoints = - m_model->getPoints(frame); + m_model->getPoints(frame); if (!onPoints.empty()) { - return onPoints; + return onPoints; } RegionModel::PointList prevPoints = - m_model->getPreviousPoints(frame); + m_model->getPreviousPoints(frame); RegionModel::PointList nextPoints = - m_model->getNextPoints(frame); + m_model->getNextPoints(frame); RegionModel::PointList usePoints = prevPoints; if (prevPoints.empty()) { - usePoints = nextPoints; + usePoints = nextPoints; } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && - !(nextPoints.begin()->frame > v->getEndFrame())) { - usePoints = nextPoints; + !(nextPoints.begin()->frame > v->getEndFrame())) { + usePoints = nextPoints; } else if (long(nextPoints.begin()->frame) - frame < - frame - long(prevPoints.begin()->frame)) { - usePoints = nextPoints; + frame - long(prevPoints.begin()->frame)) { + usePoints = nextPoints; } if (!usePoints.empty()) { - int fuzz = 2; - int px = v->getXForFrame(usePoints.begin()->frame); - if ((px > x && px - x > fuzz) || - (px < x && x - px > fuzz + 1)) { - usePoints.clear(); - } + int fuzz = 2; + int px = v->getXForFrame(usePoints.begin()->frame); + if ((px > x && px - x > fuzz) || + (px < x && x - px > fuzz + 1)) { + usePoints.clear(); + } } return usePoints; @@ -393,11 +393,11 @@ RegionModel::PointList points = getLocalPoints(v, x); if (points.empty()) { - if (!m_model->isReady()) { - return tr("In progress"); - } else { - return tr("No local points"); - } + if (!m_model->isReady()) { + return tr("In progress"); + } else { + return tr("No local points"); + } } RegionRec region(0); @@ -408,26 +408,26 @@ for (i = points.begin(); i != points.end(); ++i) { - int y = getYForValue(v, i->value); - int h = 3; + int y = getYForValue(v, i->value); + int h = 3; - if (m_model->getValueQuantization() != 0.0) { - h = y - getYForValue(v, i->value + m_model->getValueQuantization()); - if (h < 3) h = 3; - } + if (m_model->getValueQuantization() != 0.0) { + h = y - getYForValue(v, i->value + m_model->getValueQuantization()); + if (h < 3) h = 3; + } - if (pos.y() >= y - h && pos.y() <= y) { - region = *i; - break; - } + if (pos.y() >= y - h && pos.y() <= y) { + region = *i; + break; + } } if (i == points.end()) return tr("No local points"); RealTime rt = RealTime::frame2RealTime(region.frame, - m_model->getSampleRate()); + m_model->getSampleRate()); RealTime rd = RealTime::frame2RealTime(region.duration, - m_model->getSampleRate()); + m_model->getSampleRate()); QString valueText; @@ -436,20 +436,20 @@ QString text; if (region.label == "") { - text = QString(tr("Time:\t%1\nValue:\t%2\nDuration:\t%3\nNo label")) - .arg(rt.toText(true).c_str()) - .arg(valueText) - .arg(rd.toText(true).c_str()); + text = QString(tr("Time:\t%1\nValue:\t%2\nDuration:\t%3\nNo label")) + .arg(rt.toText(true).c_str()) + .arg(valueText) + .arg(rd.toText(true).c_str()); } else { - text = QString(tr("Time:\t%1\nValue:\t%2\nDuration:\t%3\nLabel:\t%4")) - .arg(rt.toText(true).c_str()) - .arg(valueText) - .arg(rd.toText(true).c_str()) - .arg(region.label); + text = QString(tr("Time:\t%1\nValue:\t%2\nDuration:\t%3\nLabel:\t%4")) + .arg(rt.toText(true).c_str()) + .arg(valueText) + .arg(rd.toText(true).c_str()) + .arg(region.label); } pos = QPoint(v->getXForFrame(region.frame), - getYForValue(v, region.value)); + getYForValue(v, region.value)); return text; } @@ -459,18 +459,18 @@ SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); RegionModel::PointList points; if (snap == SnapNeighbouring) { - - points = getLocalPoints(v, v->getXForFrame(frame)); - if (points.empty()) return false; - frame = points.begin()->frame; - return true; + + points = getLocalPoints(v, v->getXForFrame(frame)); + if (points.empty()) return false; + frame = points.begin()->frame; + return true; } points = m_model->getPoints(frame, frame); @@ -478,15 +478,15 @@ bool found = false; for (RegionModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (snap == SnapRight) { + if (snap == SnapRight) { // The best frame to snap to is the end frame of whichever // feature we would have snapped to the start frame of if // we had been snapping left. - if (i->frame <= frame) { + if (i->frame <= frame) { if (i->frame + i->duration > frame) { snapped = i->frame + i->duration; found = true; // don't break, as the next may be better @@ -499,37 +499,37 @@ break; } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame <= frame) { - snapped = i->frame; - found = true; // don't break, as the next may be better - } else { - break; - } + if (i->frame <= frame) { + snapped = i->frame; + found = true; // don't break, as the next may be better + } else { + break; + } - } else { // nearest + } else { // nearest - RegionModel::PointList::const_iterator j = i; - ++j; + RegionModel::PointList::const_iterator j = i; + ++j; - if (j == points.end()) { + if (j == points.end()) { - snapped = i->frame; - found = true; - break; + snapped = i->frame; + found = true; + break; - } else if (j->frame >= frame) { + } else if (j->frame >= frame) { - if (j->frame - frame < frame - i->frame) { - snapped = j->frame; - } else { - snapped = i->frame; - } - found = true; - break; - } - } + if (j->frame - frame < frame - i->frame) { + snapped = j->frame; + } else { + snapped = i->frame; + } + found = true; + break; + } + } } frame = snapped; @@ -542,7 +542,7 @@ SnapType snap) const { if (!m_model) { - return Layer::snapToSimilarFeature(v, frame, resolution, snap); + return Layer::snapToSimilarFeature(v, frame, resolution, snap); } resolution = m_model->getResolution(); @@ -586,29 +586,29 @@ } } - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame > matchframe && + if (i->frame > matchframe && fabs(i->value - matchvalue) < epsilon) { - snapped = i->frame; - found = true; - break; - } + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame < matchframe) { + if (i->frame < matchframe) { if (fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; // don't break, as the next may be better } - } else if (found || distant) { - break; - } + } else if (found || distant) { + break; + } - } else { + } else { // no other snap types supported - } + } ++i; } @@ -889,7 +889,7 @@ brushColour.setAlpha(80); // SVDEBUG << "RegionLayer::paint: resolution is " -// << m_model->getResolution() << " frames" << endl; +// << m_model->getResolution() << " frames" << endl; double min = m_model->getValueMinimum(); double max = m_model->getValueMaximum(); @@ -916,33 +916,33 @@ int fontHeight = paint.fontMetrics().height(); for (RegionModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const RegionModel::Point &p(*i); + const RegionModel::Point &p(*i); - int x = v->getXForFrame(p.frame); - int y = getYForValue(v, p.value); - int w = v->getXForFrame(p.frame + p.duration) - x; - int h = 9; - int ex = x + w; + int x = v->getXForFrame(p.frame); + int y = getYForValue(v, p.value); + int w = v->getXForFrame(p.frame + p.duration) - x; + int h = 9; + int ex = x + w; RegionModel::PointList::const_iterator j = i; - ++j; + ++j; - if (j != points.end()) { - const RegionModel::Point &q(*j); - int nx = v->getXForFrame(q.frame); + if (j != points.end()) { + const RegionModel::Point &q(*j); + int nx = v->getXForFrame(q.frame); if (nx < ex) ex = nx; } - if (m_model->getValueQuantization() != 0.0) { - h = y - getYForValue(v, p.value + m_model->getValueQuantization()); - if (h < 3) h = 3; - } + if (m_model->getValueQuantization() != 0.0) { + h = y - getYForValue(v, p.value + m_model->getValueQuantization()); + if (h < 3) h = 3; + } - if (w < 1) w = 1; + if (w < 1) w = 1; - if (m_plotStyle == PlotSegmentation) { + if (m_plotStyle == PlotSegmentation) { paint.setPen(getForegroundQColor(v->getView())); paint.setBrush(getColourForValue(v, p.value)); } else { @@ -950,9 +950,9 @@ paint.setBrush(brushColour); } - if (m_plotStyle == PlotSegmentation) { + if (m_plotStyle == PlotSegmentation) { - if (ex <= x) continue; + if (ex <= x) continue; if (!shouldIlluminate || // "illuminatePoint != p" @@ -967,9 +967,9 @@ paint.setPen(QPen(getForegroundQColor(v->getView()), 2)); } - paint.drawRect(x, -1, ex - x, v->getPaintHeight() + 2); + paint.drawRect(x, -1, ex - x, v->getPaintHeight() + 2); - } else { + } else { if (shouldIlluminate && // "illuminatePoint == p" @@ -1005,16 +1005,16 @@ int lastLabelY = 0; for (RegionModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const RegionModel::Point &p(*i); + const RegionModel::Point &p(*i); - int x = v->getXForFrame(p.frame); - int y = getYForValue(v, p.value); + int x = v->getXForFrame(p.frame); + int y = getYForValue(v, p.value); bool illuminated = false; - if (m_plotStyle != PlotSegmentation) { + if (m_plotStyle != PlotSegmentation) { if (shouldIlluminate && // "illuminatePoint == p" @@ -1194,8 +1194,8 @@ if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -1244,8 +1244,8 @@ m_originalPoint = m_editingPoint; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -1278,8 +1278,8 @@ double value = getValueForY(v, newy, avoid); if (!m_editingCommand) { - m_editingCommand = new RegionModel::EditCommand(m_model, - tr("Drag Region")); + m_editingCommand = new RegionModel::EditCommand(m_model, + tr("Drag Region")); } m_editingCommand->deletePoint(m_editingPoint); @@ -1296,20 +1296,20 @@ if (m_editingCommand) { - QString newName = m_editingCommand->getName(); + QString newName = m_editingCommand->getName(); - if (m_editingPoint.frame != m_originalPoint.frame) { - if (m_editingPoint.value != m_originalPoint.value) { - newName = tr("Edit Region"); - } else { - newName = tr("Relocate Region"); - } - } else { - newName = tr("Change Point Value"); - } + if (m_editingPoint.frame != m_originalPoint.frame) { + if (m_editingPoint.value != m_originalPoint.value) { + newName = tr("Edit Region"); + } else { + newName = tr("Relocate Region"); + } + } else { + newName = tr("Change Point Value"); + } - m_editingCommand->setName(newName); - finish(m_editingCommand); + m_editingCommand->setName(newName); + finish(m_editingCommand); } m_editingCommand = 0; @@ -1364,20 +1364,20 @@ if (!m_model) return; RegionModel::EditCommand *command = - new RegionModel::EditCommand(m_model, tr("Drag Selection")); + new RegionModel::EditCommand(m_model, tr("Drag Selection")); RegionModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (RegionModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { - RegionModel::Point newPoint(*i); - newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); - command->deletePoint(*i); - command->addPoint(newPoint); - } + if (s.contains(i->frame)) { + RegionModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -1390,34 +1390,34 @@ if (!m_model) return; RegionModel::EditCommand *command = - new RegionModel::EditCommand(m_model, tr("Resize Selection")); + new RegionModel::EditCommand(m_model, tr("Resize Selection")); RegionModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); double ratio = - double(newSize.getEndFrame() - newSize.getStartFrame()) / - double(s.getEndFrame() - s.getStartFrame()); + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); for (RegionModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { + if (s.contains(i->frame)) { - double targetStart = double(i->frame); - targetStart = double(newSize.getStartFrame()) + - targetStart - double(s.getStartFrame()) * ratio; + double targetStart = double(i->frame); + targetStart = double(newSize.getStartFrame()) + + targetStart - double(s.getStartFrame()) * ratio; - double targetEnd = double(i->frame + i->duration); - targetEnd = double(newSize.getStartFrame()) + - targetEnd - double(s.getStartFrame()) * ratio; + double targetEnd = double(i->frame + i->duration); + targetEnd = double(newSize.getStartFrame()) + + targetEnd - double(s.getStartFrame()) * ratio; - RegionModel::Point newPoint(*i); - newPoint.frame = lrint(targetStart); - newPoint.duration = lrint(targetEnd - targetStart); - command->deletePoint(*i); - command->addPoint(newPoint); - } + RegionModel::Point newPoint(*i); + newPoint.frame = lrint(targetStart); + newPoint.duration = lrint(targetEnd - targetStart); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -1430,13 +1430,13 @@ if (!m_model) return; RegionModel::EditCommand *command = - new RegionModel::EditCommand(m_model, tr("Delete Selected Points")); + new RegionModel::EditCommand(m_model, tr("Delete Selected Points")); RegionModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (RegionModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { if (s.contains(i->frame)) { command->deletePoint(*i); @@ -1453,11 +1453,11 @@ if (!m_model) return; RegionModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (RegionModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) { + i != points.end(); ++i) { + if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->value, i->duration, i->label); point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); @@ -1492,7 +1492,7 @@ } RegionModel::EditCommand *command = - new RegionModel::EditCommand(m_model, tr("Paste")); + new RegionModel::EditCommand(m_model, tr("Paste")); for (Clipboard::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -1563,10 +1563,10 @@ bool ok; VerticalScale scale = (VerticalScale) - attributes.value("verticalScale").toInt(&ok); + attributes.value("verticalScale").toInt(&ok); if (ok) setVerticalScale(scale); PlotStyle style = (PlotStyle) - attributes.value("plotStyle").toInt(&ok); + attributes.value("plotStyle").toInt(&ok); if (ok) setPlotStyle(style); }
--- a/layer/RegionLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/RegionLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -48,8 +48,8 @@ virtual QString getLabelPreceding(sv_frame_t) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual bool snapToSimilarFeature(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -86,7 +86,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); void setFillColourMap(int); @@ -103,8 +103,8 @@ VerticalScale getVerticalScale() const { return m_verticalScale; } enum PlotStyle { - PlotLines, - PlotSegmentation + PlotLines, + PlotSegmentation }; void setPlotStyle(PlotStyle style);
--- a/layer/RenderTimer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/RenderTimer.h Thu Mar 01 18:02:22 2018 +0000 @@ -21,16 +21,16 @@ { public: enum Type { - /// A normal rendering operation with normal responsiveness demands - FastRender, + /// A normal rendering operation with normal responsiveness demands + FastRender, - /// An operation that the user might accept being slower - SlowRender, + /// An operation that the user might accept being slower + SlowRender, - /// An operation that should always complete, i.e. as if there - /// were no RenderTimer in use, but without having to change - /// client code structurally - NoTimeout + /// An operation that should always complete, i.e. as if there + /// were no RenderTimer in use, but without having to change + /// client code structurally + NoTimeout }; /** @@ -41,19 +41,19 @@ * happened. */ RenderTimer(Type t) : - m_start(std::chrono::steady_clock::now()), - m_haveLimits(true), - m_minFraction(0.1), - m_softLimit(0.1), - m_hardLimit(0.2), - m_softLimitOverridden(false) { + m_start(std::chrono::steady_clock::now()), + m_haveLimits(true), + m_minFraction(0.1), + m_softLimit(0.1), + m_hardLimit(0.2), + m_softLimitOverridden(false) { - if (t == NoTimeout) { - m_haveLimits = false; - } else if (t == SlowRender) { - m_softLimit = 0.2; - m_hardLimit = 0.4; - } + if (t == NoTimeout) { + m_haveLimits = false; + } else if (t == SlowRender) { + m_softLimit = 0.2; + m_hardLimit = 0.4; + } } @@ -66,36 +66,36 @@ */ bool outOfTime(double fractionComplete) { - if (!m_haveLimits || fractionComplete < m_minFraction) { - return false; - } - - auto t = std::chrono::steady_clock::now(); - double elapsed = std::chrono::duration<double>(t - m_start).count(); - - if (elapsed > m_hardLimit) { - return true; - } else if (!m_softLimitOverridden && elapsed > m_softLimit) { - if (fractionComplete > 0.6) { - // If we're significantly more than half way by the - // time we reach the soft limit, ignore it (though - // always respect the hard limit, above). Otherwise - // respect the soft limit and report out of time now. - m_softLimitOverridden = true; - } else { - return true; - } - } + if (!m_haveLimits || fractionComplete < m_minFraction) { + return false; + } + + auto t = std::chrono::steady_clock::now(); + double elapsed = std::chrono::duration<double>(t - m_start).count(); + + if (elapsed > m_hardLimit) { + return true; + } else if (!m_softLimitOverridden && elapsed > m_softLimit) { + if (fractionComplete > 0.6) { + // If we're significantly more than half way by the + // time we reach the soft limit, ignore it (though + // always respect the hard limit, above). Otherwise + // respect the soft limit and report out of time now. + m_softLimitOverridden = true; + } else { + return true; + } + } - return false; + return false; } double secondsPerItem(int itemsRendered) const { if (itemsRendered == 0) return 0.0; - auto t = std::chrono::steady_clock::now(); - double elapsed = std::chrono::duration<double>(t - m_start).count(); + auto t = std::chrono::steady_clock::now(); + double elapsed = std::chrono::duration<double>(t - m_start).count(); return elapsed / itemsRendered; }
--- a/layer/ScrollableImageCache.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ScrollableImageCache.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -28,43 +28,43 @@ static HitCount count("ScrollableImageCache: scrolling"); int dx = (v->getXForFrame(m_startFrame) - - v->getXForFrame(newStartFrame)); + v->getXForFrame(newStartFrame)); #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE cerr << "ScrollableImageCache::scrollTo: start frame " << m_startFrame - << " -> " << newStartFrame << ", dx = " << dx << endl; + << " -> " << newStartFrame << ", dx = " << dx << endl; #endif if (m_startFrame == newStartFrame) { - // haven't moved + // haven't moved count.hit(); return; } - + m_startFrame = newStartFrame; - + if (!isValid()) { count.miss(); - return; + return; } int w = m_image.width(); if (dx == 0) { - // haven't moved visibly (even though start frame may have changed) + // haven't moved visibly (even though start frame may have changed) count.hit(); - return; + return; } if (dx <= -w || dx >= w) { - // scrolled entirely off - invalidate(); + // scrolled entirely off + invalidate(); count.miss(); - return; + return; } count.partial(); - + // dx is in range, cache is scrollable int dxp = dx; @@ -72,38 +72,38 @@ int copylen = (w - dxp) * int(sizeof(QRgb)); for (int y = 0; y < m_image.height(); ++y) { - QRgb *line = (QRgb *)m_image.scanLine(y); - if (dx < 0) { - memmove(line, line + dxp, copylen); - } else { - memmove(line + dxp, line, copylen); - } + QRgb *line = (QRgb *)m_image.scanLine(y); + if (dx < 0) { + memmove(line, line + dxp, copylen); + } else { + memmove(line + dxp, line, copylen); + } } - + // update valid area int px = m_validLeft; int pw = m_validWidth; - + px += dx; - + if (dx < 0) { - // we scrolled left - if (px < 0) { - pw += px; - px = 0; - if (pw < 0) { - pw = 0; - } - } + // we scrolled left + if (px < 0) { + pw += px; + px = 0; + if (pw < 0) { + pw = 0; + } + } } else { - // we scrolled right - if (px + pw > w) { - pw = w - px; - if (pw < 0) { - pw = 0; - } - } + // we scrolled right + if (px + pw > w) { + pw = w - px; + if (pw < 0) { + pw = 0; + } + } } m_validLeft = px; @@ -112,7 +112,7 @@ void ScrollableImageCache::adjustToTouchValidArea(int &left, int &width, - bool &isLeftOfValidArea) const + bool &isLeftOfValidArea) const { #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE cerr << "ScrollableImageCache::adjustToTouchValidArea: left " << left @@ -121,18 +121,18 @@ << ", width " << m_validWidth << " so right " << (m_validLeft + m_validWidth) << endl; #endif if (left < m_validLeft) { - isLeftOfValidArea = true; - if (left + width <= m_validLeft + m_validWidth) { - width = m_validLeft - left; - } + isLeftOfValidArea = true; + if (left + width <= m_validLeft + m_validWidth) { + width = m_validLeft - left; + } #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE cerr << "ScrollableImageCache: we're left of valid area, adjusted width to " << width << endl; #endif } else { - isLeftOfValidArea = false; - width = left + width - (m_validLeft + m_validWidth); - left = m_validLeft + m_validWidth; - if (width < 0) width = 0; + isLeftOfValidArea = false; + width = left + width - (m_validLeft + m_validWidth); + left = m_validLeft + m_validWidth; + if (width < 0) width = 0; #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE cerr << "ScrollableImageCache: we're right of valid area, adjusted left to " << left << ", width to " << width << endl; #endif @@ -141,80 +141,80 @@ void ScrollableImageCache::drawImage(int left, - int width, - QImage image, - int imageLeft, - int imageWidth) + int width, + QImage image, + int imageLeft, + int imageWidth) { if (image.height() != m_image.height()) { - cerr << "ScrollableImageCache::drawImage: ERROR: Supplied image height " - << image.height() << " does not match cache height " - << m_image.height() << endl; - throw std::logic_error("Image height must match cache height in ScrollableImageCache::drawImage"); + cerr << "ScrollableImageCache::drawImage: ERROR: Supplied image height " + << image.height() << " does not match cache height " + << m_image.height() << endl; + throw std::logic_error("Image height must match cache height in ScrollableImageCache::drawImage"); } if (left < 0 || width < 0 || left + width > m_image.width()) { - cerr << "ScrollableImageCache::drawImage: ERROR: Target area (left = " - << left << ", width = " << width << ", so right = " << left + width + cerr << "ScrollableImageCache::drawImage: ERROR: Target area (left = " + << left << ", width = " << width << ", so right = " << left + width << ") out of bounds for cache of width " << m_image.width() << endl; - throw std::logic_error("Target area out of bounds in ScrollableImageCache::drawImage"); + throw std::logic_error("Target area out of bounds in ScrollableImageCache::drawImage"); } if (imageLeft < 0 || imageWidth < 0 || - imageLeft + imageWidth > image.width()) { - cerr << "ScrollableImageCache::drawImage: ERROR: Source area (left = " - << imageLeft << ", width = " << imageWidth << ", so right = " + imageLeft + imageWidth > image.width()) { + cerr << "ScrollableImageCache::drawImage: ERROR: Source area (left = " + << imageLeft << ", width = " << imageWidth << ", so right = " << imageLeft + imageWidth << ") out of bounds for image of " - << "width " << image.width() << endl; - throw std::logic_error("Source area out of bounds in ScrollableImageCache::drawImage"); + << "width " << image.width() << endl; + throw std::logic_error("Source area out of bounds in ScrollableImageCache::drawImage"); } - + QPainter painter(&m_image); painter.drawImage(QRect(left, 0, width, m_image.height()), - image, - QRect(imageLeft, 0, imageWidth, image.height())); + image, + QRect(imageLeft, 0, imageWidth, image.height())); painter.end(); if (!isValid()) { - m_validLeft = left; - m_validWidth = width; - return; + m_validLeft = left; + m_validWidth = width; + return; } - + if (left < m_validLeft) { - if (left + width > m_validLeft + m_validWidth) { - // new image completely contains the old valid area -- - // use the new area as is - m_validLeft = left; - m_validWidth = width; - } else if (left + width < m_validLeft) { - // new image completely off left of old valid area -- - // we can't extend the valid area because the bit in - // between is not valid, so must use the new area only - m_validLeft = left; - m_validWidth = width; - } else { - // new image overlaps old valid area on left side -- - // use new left edge, and extend width to existing - // right edge - m_validWidth = (m_validLeft + m_validWidth) - left; - m_validLeft = left; - } + if (left + width > m_validLeft + m_validWidth) { + // new image completely contains the old valid area -- + // use the new area as is + m_validLeft = left; + m_validWidth = width; + } else if (left + width < m_validLeft) { + // new image completely off left of old valid area -- + // we can't extend the valid area because the bit in + // between is not valid, so must use the new area only + m_validLeft = left; + m_validWidth = width; + } else { + // new image overlaps old valid area on left side -- + // use new left edge, and extend width to existing + // right edge + m_validWidth = (m_validLeft + m_validWidth) - left; + m_validLeft = left; + } } else { - if (left > m_validLeft + m_validWidth) { - // new image completely off right of old valid area -- - // we can't extend the valid area because the bit in - // between is not valid, so must use the new area only - m_validLeft = left; - m_validWidth = width; - } else if (left + width > m_validLeft + m_validWidth) { - // new image overlaps old valid area on right side -- - // use existing left edge, and extend width to new - // right edge - m_validWidth = (left + width) - m_validLeft; - // (m_validLeft unchanged) - } else { - // new image completely contained within old valid - // area -- leave the old area unchanged - } + if (left > m_validLeft + m_validWidth) { + // new image completely off right of old valid area -- + // we can't extend the valid area because the bit in + // between is not valid, so must use the new area only + m_validLeft = left; + m_validWidth = width; + } else if (left + width > m_validLeft + m_validWidth) { + // new image overlaps old valid area on right side -- + // use existing left edge, and extend width to new + // right edge + m_validWidth = (left + width) - m_validLeft; + // (m_validLeft unchanged) + } else { + // new image completely contained within old valid + // area -- leave the old area unchanged + } } }
--- a/layer/ScrollableImageCache.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ScrollableImageCache.h Thu Mar 01 18:02:22 2018 +0000 @@ -38,22 +38,22 @@ { public: ScrollableImageCache() : - m_validLeft(0), - m_validWidth(0), - m_startFrame(0), - m_zoomLevel(0) + m_validLeft(0), + m_validWidth(0), + m_startFrame(0), + m_zoomLevel(0) {} void invalidate() { - m_validWidth = 0; + m_validWidth = 0; } bool isValid() const { - return m_validWidth > 0; + return m_validWidth > 0; } QSize getSize() const { - return m_image.size(); + return m_image.size(); } /** @@ -66,25 +66,25 @@ invalidate(); } } - + int getValidLeft() const { - return m_validLeft; + return m_validLeft; } int getValidWidth() const { - return m_validWidth; + return m_validWidth; } int getValidRight() const { - return m_validLeft + m_validWidth; + return m_validLeft + m_validWidth; } QRect getValidArea() const { - return QRect(m_validLeft, 0, m_validWidth, m_image.height()); + return QRect(m_validLeft, 0, m_validWidth, m_image.height()); } int getZoomLevel() const { - return m_zoomLevel; + return m_zoomLevel; } /** @@ -101,7 +101,7 @@ } sv_frame_t getStartFrame() const { - return m_startFrame; + return m_startFrame; } /** @@ -118,7 +118,7 @@ } const QImage &getImage() const { - return m_image; + return m_image; } /** @@ -137,7 +137,7 @@ * modify anything about the cache, only about the arguments. */ void adjustToTouchValidArea(int &left, int &width, - bool &isLeftOfValidArea) const; + bool &isLeftOfValidArea) const; /** * Draw from an image onto the cache. The supplied image must have @@ -147,10 +147,10 @@ * the source region of the image. */ void drawImage(int left, - int width, - QImage image, - int imageLeft, - int imageWidth); + int width, + QImage image, + int imageLeft, + int imageWidth); private: QImage m_image;
--- a/layer/ScrollableMagRangeCache.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ScrollableMagRangeCache.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -23,20 +23,20 @@ void ScrollableMagRangeCache::scrollTo(const LayerGeometryProvider *v, - sv_frame_t newStartFrame) -{ + sv_frame_t newStartFrame) +{ static HitCount count("ScrollableMagRangeCache: scrolling"); int dx = (v->getXForFrame(m_startFrame) - - v->getXForFrame(newStartFrame)); + v->getXForFrame(newStartFrame)); #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE cerr << "ScrollableMagRangeCache::scrollTo: start frame " << m_startFrame - << " -> " << newStartFrame << ", dx = " << dx << endl; + << " -> " << newStartFrame << ", dx = " << dx << endl; #endif if (m_startFrame == newStartFrame) { - // haven't moved + // haven't moved count.hit(); return; } @@ -44,51 +44,51 @@ m_startFrame = newStartFrame; if (dx == 0) { - // haven't moved visibly (even though start frame may have changed) + // haven't moved visibly (even though start frame may have changed) count.hit(); - return; + return; } - + int w = int(m_ranges.size()); if (dx <= -w || dx >= w) { - // scrolled entirely off - invalidate(); + // scrolled entirely off + invalidate(); count.miss(); - return; + return; } count.partial(); - + // dx is in range, cache is scrollable if (dx < 0) { - // The new start frame is to the left of the old start - // frame. We need to add some empty ranges at the left (start) - // end and clip the right end. Assemble -dx new values, then - // w+dx old values starting at index 0. + // The new start frame is to the left of the old start + // frame. We need to add some empty ranges at the left (start) + // end and clip the right end. Assemble -dx new values, then + // w+dx old values starting at index 0. - auto newRanges = vector<MagnitudeRange>(-dx); - newRanges.insert(newRanges.end(), - m_ranges.begin(), m_ranges.begin() + (w + dx)); - m_ranges = newRanges; - + auto newRanges = vector<MagnitudeRange>(-dx); + newRanges.insert(newRanges.end(), + m_ranges.begin(), m_ranges.begin() + (w + dx)); + m_ranges = newRanges; + } else { - // The new start frame is to the right of the old start - // frame. We want to clip the left (start) end and add some - // empty ranges at the right end. Assemble w-dx old values - // starting at index dx, then dx new values. + // The new start frame is to the right of the old start + // frame. We want to clip the left (start) end and add some + // empty ranges at the right end. Assemble w-dx old values + // starting at index dx, then dx new values. - auto newRanges = vector<MagnitudeRange>(dx); - newRanges.insert(newRanges.begin(), - m_ranges.begin() + dx, m_ranges.end()); - m_ranges = newRanges; + auto newRanges = vector<MagnitudeRange>(dx); + newRanges.insert(newRanges.begin(), + m_ranges.begin() + dx, m_ranges.end()); + m_ranges = newRanges; } #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE cerr << "maxes (" << m_ranges.size() << ") now: "; for (int i = 0; in_range_for(m_ranges, i); ++i) { - cerr << m_ranges[i].getMax() << " "; + cerr << m_ranges[i].getMax() << " "; } cerr << endl; #endif @@ -102,7 +102,7 @@ cerr << "ScrollableMagRangeCache::getRange(" << x << ", " << count << ")" << endl; #endif for (int i = 0; i < count; ++i) { - r.sample(m_ranges.at(x + i)); + r.sample(m_ranges.at(x + i)); } return r; } @@ -111,12 +111,12 @@ ScrollableMagRangeCache::sampleColumn(int column, const MagnitudeRange &r) { if (!in_range_for(m_ranges, column)) { - cerr << "ERROR: ScrollableMagRangeCache::sampleColumn: column " << column - << " is out of range for cache of width " << m_ranges.size() - << " (with start frame " << m_startFrame << ")" << endl; - throw logic_error("column out of range"); + cerr << "ERROR: ScrollableMagRangeCache::sampleColumn: column " << column + << " is out of range for cache of width " << m_ranges.size() + << " (with start frame " << m_startFrame << ")" << endl; + throw logic_error("column out of range"); } else { - m_ranges[column].sample(r); + m_ranges[column].sample(r); } }
--- a/layer/ScrollableMagRangeCache.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/ScrollableMagRangeCache.h Thu Mar 01 18:02:22 2018 +0000 @@ -36,16 +36,16 @@ { public: ScrollableMagRangeCache() : - m_startFrame(0), - m_zoomLevel(0) + m_startFrame(0), + m_zoomLevel(0) {} void invalidate() { - m_ranges = std::vector<MagnitudeRange>(m_ranges.size()); + m_ranges = std::vector<MagnitudeRange>(m_ranges.size()); } int getWidth() const { - return int(m_ranges.size()); + return int(m_ranges.size()); } /** @@ -54,12 +54,12 @@ */ void resize(int newWidth) { if (getWidth() != newWidth) { - m_ranges = std::vector<MagnitudeRange>(newWidth); + m_ranges = std::vector<MagnitudeRange>(newWidth); } } - + int getZoomLevel() const { - return m_zoomLevel; + return m_zoomLevel; } /** @@ -76,7 +76,7 @@ } sv_frame_t getStartFrame() const { - return m_startFrame; + return m_startFrame; } /** @@ -93,21 +93,21 @@ } bool isColumnSet(int column) const { - return in_range_for(m_ranges, column) && m_ranges.at(column).isSet(); + return in_range_for(m_ranges, column) && m_ranges.at(column).isSet(); } bool areColumnsSet(int x, int count) const { - for (int i = 0; i < count; ++i) { - if (!isColumnSet(x + i)) return false; - } - return true; + for (int i = 0; i < count; ++i) { + if (!isColumnSet(x + i)) return false; + } + return true; } /** * Get the magnitude range for a single column. */ MagnitudeRange getRange(int column) const { - return m_ranges.at(column); + return m_ranges.at(column); } /**
--- a/layer/SingleColourLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SingleColourLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -103,7 +103,7 @@ val = m_colour; } else { - val = Layer::getPropertyRangeAndValue(name, min, max, deflt); + val = Layer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -111,7 +111,7 @@ QString SingleColourLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { if (name == "Colour") { ColourDatabase *db = ColourDatabase::getInstance(); @@ -283,7 +283,7 @@ s += QString("colourName=\"%1\" " "colour=\"%2\" " "darkBackground=\"%3\" ") - .arg(colourName) + .arg(colourName) .arg(colourSpec) .arg(darkbg);
--- a/layer/SingleColourLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SingleColourLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -62,7 +62,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; virtual void setProperty(const PropertyName &, int value);
--- a/layer/SliceLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SliceLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -507,7 +507,7 @@ { int width; if (m_energyScale == LinearScale || m_energyScale == AbsoluteScale) { - width = std::max(paint.fontMetrics().width("0.0") + 13, + width = std::max(paint.fontMetrics().width("0.0") + 13, paint.fontMetrics().width("x10-10")); } else { width = std::max(paint.fontMetrics().width(tr("0dB")), @@ -625,32 +625,32 @@ if (name == "Gain") { - *min = -50; - *max = 50; + *min = -50; + *max = 50; *deflt = 0; // cerr << "gain is " << m_gain << ", mode is " << m_samplingMode << endl; - val = int(lrint(log10(m_gain) * 20.0)); - if (val < *min) val = *min; - if (val > *max) val = *max; + val = int(lrint(log10(m_gain) * 20.0)); + if (val < *min) val = *min; + if (val > *max) val = *max; } else if (name == "Threshold") { - *min = -80; - *max = 0; + *min = -80; + *max = 0; *deflt = int(lrint(AudioLevel::multiplier_to_dB(m_initialThreshold))); - if (*deflt < *min) *deflt = *min; - if (*deflt > *max) *deflt = *max; + if (*deflt < *min) *deflt = *min; + if (*deflt > *max) *deflt = *max; - val = int(lrint(AudioLevel::multiplier_to_dB(m_threshold))); - if (val < *min) val = *min; - if (val > *max) val = *max; + val = int(lrint(AudioLevel::multiplier_to_dB(m_threshold))); + if (val < *min) val = *min; + if (val > *max) val = *max; } else if (name == "Normalize") { - - val = (m_normalize ? 1 : 0); + + val = (m_normalize ? 1 : 0); *deflt = 0; } else if (name == "Colour" && m_plotStyle == PlotFilledBlocks) { @@ -663,19 +663,19 @@ } else if (name == "Scale") { - *min = 0; - *max = 3; + *min = 0; + *max = 3; *deflt = (int)dBScale; - val = (int)m_energyScale; + val = (int)m_energyScale; } else if (name == "Sampling Mode") { - *min = 0; - *max = 2; + *min = 0; + *max = 2; *deflt = (int)SampleMean; - val = (int)m_samplingMode; + val = (int)m_samplingMode; } else if (name == "Plot Type") { @@ -695,7 +695,7 @@ val = (int)m_binScale; } else { - val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); + val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -703,44 +703,44 @@ QString SliceLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { if (name == "Colour" && m_plotStyle == PlotFilledBlocks) { return ColourMapper::getColourMapName(value); } if (name == "Scale") { - switch (value) { - default: - case 0: return tr("Linear"); - case 1: return tr("Meter"); - case 2: return tr("Log"); - case 3: return tr("Absolute"); - } + switch (value) { + default: + case 0: return tr("Linear"); + case 1: return tr("Meter"); + case 2: return tr("Log"); + case 3: return tr("Absolute"); + } } if (name == "Sampling Mode") { - switch (value) { - default: - case 0: return tr("Any"); - case 1: return tr("Mean"); - case 2: return tr("Peak"); - } + switch (value) { + default: + case 0: return tr("Any"); + case 1: return tr("Mean"); + case 2: return tr("Peak"); + } } if (name == "Plot Type") { - switch (value) { - default: - case 0: return tr("Lines"); - case 1: return tr("Steps"); - case 2: return tr("Blocks"); - case 3: return tr("Colours"); - } + switch (value) { + default: + case 0: return tr("Lines"); + case 1: return tr("Steps"); + case 2: return tr("Blocks"); + case 3: return tr("Colours"); + } } if (name == "Bin Scale") { - switch (value) { - default: - case 0: return tr("Linear"); - case 1: return tr("Log"); - case 2: return tr("Rev Log"); - } + switch (value) { + default: + case 0: return tr("Linear"); + case 1: return tr("Log"); + case 2: return tr("Rev Log"); + } } return SingleColourLayer::getPropertyValueLabel(name, value); } @@ -761,38 +761,38 @@ SliceLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(powf(10, float(value)/20.0f)); + setGain(powf(10, float(value)/20.0f)); } else if (name == "Threshold") { - if (value == -80) setThreshold(0.0f); - else setThreshold(float(AudioLevel::dB_to_multiplier(value))); + if (value == -80) setThreshold(0.0f); + else setThreshold(float(AudioLevel::dB_to_multiplier(value))); } else if (name == "Colour" && m_plotStyle == PlotFilledBlocks) { setFillColourMap(value); } else if (name == "Scale") { - switch (value) { - default: - case 0: setEnergyScale(LinearScale); break; - case 1: setEnergyScale(MeterScale); break; - case 2: setEnergyScale(dBScale); break; - case 3: setEnergyScale(AbsoluteScale); break; - } + switch (value) { + default: + case 0: setEnergyScale(LinearScale); break; + case 1: setEnergyScale(MeterScale); break; + case 2: setEnergyScale(dBScale); break; + case 3: setEnergyScale(AbsoluteScale); break; + } } else if (name == "Plot Type") { - setPlotStyle(PlotStyle(value)); + setPlotStyle(PlotStyle(value)); } else if (name == "Sampling Mode") { - switch (value) { - default: - case 0: setSamplingMode(NearestSample); break; - case 1: setSamplingMode(SampleMean); break; - case 2: setSamplingMode(SamplePeak); break; - } + switch (value) { + default: + case 0: setSamplingMode(NearestSample); break; + case 1: setSamplingMode(SampleMean); break; + case 2: setSamplingMode(SamplePeak); break; + } } else if (name == "Bin Scale") { - switch (value) { - default: - case 0: setBinScale(LinearBins); break; - case 1: setBinScale(LogBins); break; - case 2: setBinScale(InvertedLogBins); break; - } + switch (value) { + default: + case 0: setBinScale(LinearBins); break; + case 1: setBinScale(LogBins); break; + case 2: setBinScale(InvertedLogBins); break; + } } else if (name == "Normalize") { - setNormalize(value ? true : false); + setNormalize(value ? true : false); } else { SingleColourLayer::setProperty(name, value); } @@ -890,7 +890,7 @@ QString s; s += QString("colourScheme=\"%1\" " - "energyScale=\"%2\" " + "energyScale=\"%2\" " "samplingMode=\"%3\" " "plotStyle=\"%4\" " "binScale=\"%5\" " @@ -898,7 +898,7 @@ "threshold=\"%7\" " "normalize=\"%8\" %9") .arg(m_colourMap) - .arg(m_energyScale) + .arg(m_energyScale) .arg(m_samplingMode) .arg(m_plotStyle) .arg(m_binScale) @@ -921,22 +921,22 @@ SingleColourLayer::setProperties(attributes); EnergyScale scale = (EnergyScale) - attributes.value("energyScale").toInt(&ok); + attributes.value("energyScale").toInt(&ok); if (ok) setEnergyScale(scale); SamplingMode mode = (SamplingMode) - attributes.value("samplingMode").toInt(&ok); + attributes.value("samplingMode").toInt(&ok); if (ok) setSamplingMode(mode); int colourMap = attributes.value("colourScheme").toInt(&ok); if (ok) setFillColourMap(colourMap); PlotStyle s = (PlotStyle) - attributes.value("plotStyle").toInt(&ok); + attributes.value("plotStyle").toInt(&ok); if (ok) setPlotStyle(s); BinScale b = (BinScale) - attributes.value("binScale").toInt(&ok); + attributes.value("binScale").toInt(&ok); if (ok) setBinScale(b); float gain = attributes.value("gain").toFloat(&ok);
--- a/layer/SliceLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SliceLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -57,7 +57,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; virtual void setProperty(const PropertyName &, int value); virtual void setProperties(const QXmlAttributes &);
--- a/layer/SpectrogramLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SpectrogramLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -49,7 +49,7 @@ */ class SpectrogramLayer : public VerticalBinLayer, - public PowerOfSqrtTwoZoomConstraint + public PowerOfSqrtTwoZoomConstraint { Q_OBJECT @@ -74,8 +74,8 @@ virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *); @@ -91,7 +91,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual QString getPropertyValueIconName(const PropertyName &, int value) const; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; @@ -189,7 +189,7 @@ int getColourRotation() const; virtual VerticalPosition getPreferredFrameCountPosition() const { - return PositionTop; + return PositionTop; } virtual bool isLayerOpaque() const { return true; } @@ -287,11 +287,11 @@ bool getYBinSourceRange(LayerGeometryProvider *v, int y, double &freqMin, double &freqMax) const; bool getAdjustedYBinSourceRange(LayerGeometryProvider *v, int x, int y, - double &freqMin, double &freqMax, - double &adjFreqMin, double &adjFreqMax) const; + double &freqMin, double &freqMax, + double &adjFreqMin, double &adjFreqMax) const; bool getXBinSourceRange(LayerGeometryProvider *v, int x, RealTime &timeMin, RealTime &timeMax) const; bool getXYBinSourceRange(LayerGeometryProvider *v, int x, int y, double &min, double &max, - double &phaseMin, double &phaseMax) const; + double &phaseMin, double &phaseMax) const; int getWindowIncrement() const { if (m_windowHopLevel == 0) return m_windowSize;
--- a/layer/SpectrumLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SpectrumLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -166,7 +166,7 @@ SpectrumLayer::getPropertyGroupName(const PropertyName &name) const { if (name == "Window Size" || - name == "Window Increment") return tr("Window"); + name == "Window Increment") return tr("Window"); if (name == "Show Peak Frequencies") return tr("Bins"); return SliceLayer::getPropertyGroupName(name); } @@ -184,20 +184,20 @@ if (name == "Window Size") { - *min = 0; - *max = 15; + *min = 0; + *max = 15; *deflt = 5; - - val = 0; - int ws = m_windowSize; - while (ws > 32) { ws >>= 1; val ++; } + + val = 0; + int ws = m_windowSize; + while (ws > 32) { ws >>= 1; val ++; } } else if (name == "Window Increment") { - - *min = 0; - *max = 5; + + *min = 0; + *max = 5; *deflt = 2; - + val = m_windowHopLevel; } else if (name == "Show Peak Frequencies") { @@ -214,21 +214,21 @@ QString SpectrumLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { if (name == "Window Size") { - return QString("%1").arg(32 << value); + return QString("%1").arg(32 << value); } if (name == "Window Increment") { - switch (value) { - default: - case 0: return tr("None"); - case 1: return tr("25 %"); - case 2: return tr("50 %"); - case 3: return tr("75 %"); - case 4: return tr("87.5 %"); - case 5: return tr("93.75 %"); - } + switch (value) { + default: + case 0: return tr("None"); + case 1: return tr("25 %"); + case 2: return tr("50 %"); + case 3: return tr("75 %"); + case 4: return tr("87.5 %"); + case 5: return tr("93.75 %"); + } } return SliceLayer::getPropertyValueLabel(name, value); } @@ -243,7 +243,7 @@ SpectrumLayer::setProperty(const PropertyName &name, int value) { if (name == "Window Size") { - setWindowSize(32 << value); + setWindowSize(32 << value); } else if (name == "Window Increment") { setWindowHopLevel(value); } else if (name == "Show Peak Frequencies") {
--- a/layer/SpectrumLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/SpectrumLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -51,7 +51,7 @@ virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override; virtual VerticalPosition getPreferredFrameCountPosition() const override { - return PositionTop; + return PositionTop; } virtual PropertyList getProperties() const override; @@ -62,7 +62,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const override; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const override; + int value) const override; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override; virtual void setProperty(const PropertyName &, int value) override; virtual void setProperties(const QXmlAttributes &) override;
--- a/layer/TextLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TextLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -77,14 +77,14 @@ int TextLayer::getPropertyRangeAndValue(const PropertyName &name, - int *min, int *max, int *deflt) const + int *min, int *max, int *deflt) const { return SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } QString TextLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { return SingleColourLayer::getPropertyValueLabel(name, value); } @@ -123,31 +123,31 @@ QFontMetrics metrics = QFontMetrics(QFont()); for (TextModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const TextModel::Point &p(*i); + const TextModel::Point &p(*i); - int px = v->getXForFrame(p.frame); - int py = getYForHeight(v, p.height); + int px = v->getXForFrame(p.frame); + int py = getYForHeight(v, p.height); - QString label = p.label; - if (label == "") { - label = tr("<no text>"); - } + QString label = p.label; + if (label == "") { + label = tr("<no text>"); + } - QRect rect = metrics.boundingRect - (QRect(0, 0, 150, 200), - Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label); + QRect rect = metrics.boundingRect + (QRect(0, 0, 150, 200), + Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label); - if (py + rect.height() > v->getPaintHeight()) { - if (rect.height() > v->getPaintHeight()) py = 0; - else py = v->getPaintHeight() - rect.height() - 1; - } + if (py + rect.height() > v->getPaintHeight()) { + if (rect.height() > v->getPaintHeight()) py = 0; + else py = v->getPaintHeight() - rect.height() - 1; + } - if (x >= px && x < px + rect.width() && - y >= py && y < py + rect.height()) { - rv.insert(p); - } + if (x >= px && x < px + rect.width() && + y >= py && y < py + rect.height()) { + rv.insert(p); + } } return rv; @@ -191,11 +191,11 @@ TextModel::PointList points = getLocalPoints(v, x, pos.y()); if (points.empty()) { - if (!m_model->isReady()) { - return tr("In progress"); - } else { - return ""; - } + if (!m_model->isReady()) { + return tr("In progress"); + } else { + return ""; + } } sv_frame_t useFrame = points.begin()->frame; @@ -205,14 +205,14 @@ QString text; if (points.begin()->label == "") { - text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) - .arg(rt.toText(true).c_str()) - .arg(points.begin()->height) - .arg(points.begin()->label); + text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3")) + .arg(rt.toText(true).c_str()) + .arg(points.begin()->height) + .arg(points.begin()->label); } pos = QPoint(v->getXForFrame(useFrame), - getYForHeight(v, points.begin()->height)); + getYForHeight(v, points.begin()->height)); return text; } @@ -221,22 +221,22 @@ bool TextLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const + int &resolution, + SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); TextModel::PointList points; if (snap == SnapNeighbouring) { - - points = getLocalPoints(v, v->getXForFrame(frame), -1); - if (points.empty()) return false; - frame = points.begin()->frame; - return true; + + points = getLocalPoints(v, v->getXForFrame(frame), -1); + if (points.empty()) return false; + frame = points.begin()->frame; + return true; } points = m_model->getPoints(frame, frame); @@ -244,47 +244,47 @@ bool found = false; for (TextModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame > frame) { - snapped = i->frame; - found = true; - break; - } + if (i->frame > frame) { + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame <= frame) { - snapped = i->frame; - found = true; // don't break, as the next may be better - } else { - break; - } + if (i->frame <= frame) { + snapped = i->frame; + found = true; // don't break, as the next may be better + } else { + break; + } - } else { // nearest + } else { // nearest - TextModel::PointList::const_iterator j = i; - ++j; + TextModel::PointList::const_iterator j = i; + ++j; - if (j == points.end()) { + if (j == points.end()) { - snapped = i->frame; - found = true; - break; + snapped = i->frame; + found = true; + break; - } else if (j->frame >= frame) { + } else if (j->frame >= frame) { - if (j->frame - frame < frame - i->frame) { - snapped = j->frame; - } else { - snapped = i->frame; - } - found = true; - break; - } - } + if (j->frame - frame < frame - i->frame) { + snapped = j->frame; + } else { + snapped = i->frame; + } + found = true; + break; + } + } } frame = snapped; @@ -332,7 +332,7 @@ penColour = v->getForeground(); // SVDEBUG << "TextLayer::paint: resolution is " -// << m_model->getResolution() << " frames" << endl; +// << m_model->getResolution() << " frames" << endl; QPoint localPos; TextModel::Point illuminatePoint(0); @@ -350,58 +350,58 @@ paint.setClipRect(rect.x(), 0, rect.width() + boxMaxWidth, v->getPaintHeight()); for (TextModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const TextModel::Point &p(*i); + const TextModel::Point &p(*i); - int x = v->getXForFrame(p.frame); - int y = getYForHeight(v, p.height); + int x = v->getXForFrame(p.frame); + int y = getYForHeight(v, p.height); if (!shouldIlluminate || // "illuminatePoint != p" TextModel::Point::Comparator()(illuminatePoint, p) || TextModel::Point::Comparator()(p, illuminatePoint)) { - paint.setPen(penColour); - paint.setBrush(brushColour); + paint.setPen(penColour); + paint.setBrush(brushColour); } else { - paint.setBrush(penColour); + paint.setBrush(penColour); paint.setPen(v->getBackground()); - } + } - QString label = p.label; - if (label == "") { - label = tr("<no text>"); - } + QString label = p.label; + if (label == "") { + label = tr("<no text>"); + } - QRect boxRect = paint.fontMetrics().boundingRect - (QRect(0, 0, boxMaxWidth, boxMaxHeight), - Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label); + QRect boxRect = paint.fontMetrics().boundingRect + (QRect(0, 0, boxMaxWidth, boxMaxHeight), + Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label); - QRect textRect = QRect(3, 2, boxRect.width(), boxRect.height()); - boxRect = QRect(0, 0, boxRect.width() + 6, boxRect.height() + 2); + QRect textRect = QRect(3, 2, boxRect.width(), boxRect.height()); + boxRect = QRect(0, 0, boxRect.width() + 6, boxRect.height() + 2); - if (y + boxRect.height() > v->getPaintHeight()) { - if (boxRect.height() > v->getPaintHeight()) y = 0; - else y = v->getPaintHeight() - boxRect.height() - 1; - } + if (y + boxRect.height() > v->getPaintHeight()) { + if (boxRect.height() > v->getPaintHeight()) y = 0; + else y = v->getPaintHeight() - boxRect.height() - 1; + } - boxRect = QRect(x, y, boxRect.width(), boxRect.height()); - textRect = QRect(x + 3, y + 2, textRect.width(), textRect.height()); + boxRect = QRect(x, y, boxRect.width(), boxRect.height()); + textRect = QRect(x + 3, y + 2, textRect.width(), textRect.height()); -// boxRect = QRect(x, y, boxRect.width(), boxRect.height()); -// textRect = QRect(x + 3, y + 2, textRect.width(), textRect.height()); +// boxRect = QRect(x, y, boxRect.width(), boxRect.height()); +// textRect = QRect(x + 3, y + 2, textRect.width(), textRect.height()); - paint.setRenderHint(QPainter::Antialiasing, false); - paint.drawRect(boxRect); + paint.setRenderHint(QPainter::Antialiasing, false); + paint.drawRect(boxRect); - paint.setRenderHint(QPainter::Antialiasing, true); - paint.drawText(textRect, - Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, - label); + paint.setRenderHint(QPainter::Antialiasing, true); + paint.drawText(textRect, + Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, + label); -/// if (p.label != "") { -/// paint.drawText(x + 5, y - paint.fontMetrics().height() + paint.fontMetrics().ascent(), p.label); -/// } +/// if (p.label != "") { +/// paint.drawText(x + 5, y - paint.fontMetrics().height() + paint.fontMetrics().ascent(), p.label); +/// } } paint.restore(); @@ -416,8 +416,8 @@ // SVDEBUG << "TextLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; if (!m_model) { - SVDEBUG << "TextLayer::drawStart: no model" << endl; - return; + SVDEBUG << "TextLayer::drawStart: no model" << endl; + return; } sv_frame_t frame = v->getFrameForX(e->x()); @@ -463,13 +463,13 @@ bool ok = false; QString label = QInputDialog::getText(v->getView(), tr("Enter label"), - tr("Please enter a new label:"), - QLineEdit::Normal, "", &ok); + tr("Please enter a new label:"), + QLineEdit::Normal, "", &ok); if (ok) { - TextModel::RelabelCommand *command = - new TextModel::RelabelCommand(m_model, m_editingPoint, label); - m_editingCommand->addCommand(command); + TextModel::RelabelCommand *command = + new TextModel::RelabelCommand(m_model, m_editingPoint, label); + m_editingCommand->addCommand(command); } else { m_editingCommand->deletePoint(m_editingPoint); } @@ -487,8 +487,8 @@ if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -535,8 +535,8 @@ m_originalPoint = m_editingPoint; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -560,7 +560,7 @@ // double height = getHeightForY(v, e->y()); if (!m_editingCommand) { - m_editingCommand = new TextModel::EditCommand(m_model, tr("Drag Label")); + m_editingCommand = new TextModel::EditCommand(m_model, tr("Drag Label")); } m_editingCommand->deletePoint(m_editingPoint); @@ -577,20 +577,20 @@ if (m_editingCommand) { - QString newName = m_editingCommand->getName(); + QString newName = m_editingCommand->getName(); - if (m_editingPoint.frame != m_originalPoint.frame) { - if (m_editingPoint.height != m_originalPoint.height) { - newName = tr("Move Label"); - } else { - newName = tr("Move Label Horizontally"); - } - } else { - newName = tr("Move Label Vertically"); - } + if (m_editingPoint.frame != m_originalPoint.frame) { + if (m_editingPoint.height != m_originalPoint.height) { + newName = tr("Move Label"); + } else { + newName = tr("Move Label Horizontally"); + } + } else { + newName = tr("Move Label Vertically"); + } - m_editingCommand->setName(newName); - finish(m_editingCommand); + m_editingCommand->setName(newName); + finish(m_editingCommand); } m_editingCommand = 0; @@ -609,12 +609,12 @@ bool ok = false; label = QInputDialog::getText(v->getView(), tr("Enter label"), - tr("Please enter a new label:"), - QLineEdit::Normal, label, &ok); + tr("Please enter a new label:"), + QLineEdit::Normal, label, &ok); if (ok && label != text.label) { - TextModel::RelabelCommand *command = - new TextModel::RelabelCommand(m_model, text, label); - CommandHistory::getInstance()->addCommand(command); + TextModel::RelabelCommand *command = + new TextModel::RelabelCommand(m_model, text, label); + CommandHistory::getInstance()->addCommand(command); } return true; @@ -626,20 +626,20 @@ if (!m_model) return; TextModel::EditCommand *command = - new TextModel::EditCommand(m_model, tr("Drag Selection")); + new TextModel::EditCommand(m_model, tr("Drag Selection")); TextModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (TextModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { - TextModel::Point newPoint(*i); - newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); - command->deletePoint(*i); - command->addPoint(newPoint); - } + if (s.contains(i->frame)) { + TextModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -651,29 +651,29 @@ if (!m_model) return; TextModel::EditCommand *command = - new TextModel::EditCommand(m_model, tr("Resize Selection")); + new TextModel::EditCommand(m_model, tr("Resize Selection")); TextModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); double ratio = - double(newSize.getEndFrame() - newSize.getStartFrame()) / - double(s.getEndFrame() - s.getStartFrame()); + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); for (TextModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { + if (s.contains(i->frame)) { - double target = double(i->frame); - target = double(newSize.getStartFrame()) + - target - double(s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; - TextModel::Point newPoint(*i); - newPoint.frame = lrint(target); - command->deletePoint(*i); - command->addPoint(newPoint); - } + TextModel::Point newPoint(*i); + newPoint.frame = lrint(target); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -685,14 +685,14 @@ if (!m_model) return; TextModel::EditCommand *command = - new TextModel::EditCommand(m_model, tr("Delete Selection")); + new TextModel::EditCommand(m_model, tr("Delete Selection")); TextModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (TextModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) command->deletePoint(*i); + i != points.end(); ++i) { + if (s.contains(i->frame)) command->deletePoint(*i); } finish(command); @@ -704,11 +704,11 @@ if (!m_model) return; TextModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (TextModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) { + i != points.end(); ++i) { + if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->height, i->label); point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); @@ -743,7 +743,7 @@ } TextModel::EditCommand *command = - new TextModel::EditCommand(m_model, tr("Paste")); + new TextModel::EditCommand(m_model, tr("Paste")); double valueMin = 0.0, valueMax = 1.0; for (Clipboard::PointList::const_iterator i = points.begin();
--- a/layer/TextLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TextLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -37,8 +37,8 @@ virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual void drawStart(LayerGeometryProvider *v, QMouseEvent *); virtual void drawDrag(LayerGeometryProvider *v, QMouseEvent *); @@ -71,7 +71,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); virtual bool isLayerScrollable(const LayerGeometryProvider *v) const;
--- a/layer/TimeInstantLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TimeInstantLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -101,16 +101,16 @@ int val = 0; if (name == "Plot Type") { - - if (min) *min = 0; - if (max) *max = 1; + + if (min) *min = 0; + if (max) *max = 1; if (deflt) *deflt = 0; - - val = int(m_plotStyle); + + val = int(m_plotStyle); } else { - - val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); + + val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -121,11 +121,11 @@ int value) const { if (name == "Plot Type") { - switch (value) { - default: - case 0: return tr("Instants"); - case 1: return tr("Segmentation"); - } + switch (value) { + default: + case 0: return tr("Instants"); + case 1: return tr("Segmentation"); + } } return SingleColourLayer::getPropertyValueLabel(name, value); } @@ -134,7 +134,7 @@ TimeInstantLayer::setProperty(const PropertyName &name, int value) { if (name == "Plot Type") { - setPlotStyle(PlotStyle(value)); + setPlotStyle(PlotStyle(value)); } else { SingleColourLayer::setProperty(name, value); } @@ -167,36 +167,36 @@ sv_frame_t frame = v->getFrameForX(x); SparseOneDimensionalModel::PointList onPoints = - m_model->getPoints(frame); + m_model->getPoints(frame); if (!onPoints.empty()) { - return onPoints; + return onPoints; } SparseOneDimensionalModel::PointList prevPoints = - m_model->getPreviousPoints(frame); + m_model->getPreviousPoints(frame); SparseOneDimensionalModel::PointList nextPoints = - m_model->getNextPoints(frame); + m_model->getNextPoints(frame); SparseOneDimensionalModel::PointList usePoints = prevPoints; if (prevPoints.empty()) { - usePoints = nextPoints; + usePoints = nextPoints; } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && - !(nextPoints.begin()->frame > v->getEndFrame())) { - usePoints = nextPoints; + !(nextPoints.begin()->frame > v->getEndFrame())) { + usePoints = nextPoints; } else if (nextPoints.begin()->frame - frame < - frame - prevPoints.begin()->frame) { - usePoints = nextPoints; + frame - prevPoints.begin()->frame) { + usePoints = nextPoints; } if (!usePoints.empty()) { - int fuzz = 2; - int px = v->getXForFrame(usePoints.begin()->frame); - if ((px > x && px - x > fuzz) || - (px < x && x - px > fuzz + 1)) { - usePoints.clear(); - } + int fuzz = 2; + int px = v->getXForFrame(usePoints.begin()->frame); + if ((px > x && px - x > fuzz) || + (px < x && x - px > fuzz + 1)) { + usePoints.clear(); + } } return usePoints; @@ -224,11 +224,11 @@ SparseOneDimensionalModel::PointList points = getLocalPoints(v, x); if (points.empty()) { - if (!m_model->isReady()) { - return tr("In progress"); - } else { - return tr("No local points"); - } + if (!m_model->isReady()) { + return tr("In progress"); + } else { + return tr("No local points"); + } } sv_frame_t useFrame = points.begin()->frame; @@ -238,12 +238,12 @@ QString text; if (points.begin()->label == "") { - text = QString(tr("Time:\t%1\nNo label")) - .arg(rt.toText(true).c_str()); + text = QString(tr("Time:\t%1\nNo label")) + .arg(rt.toText(true).c_str()); } else { - text = QString(tr("Time:\t%1\nLabel:\t%2")) - .arg(rt.toText(true).c_str()) - .arg(points.begin()->label); + text = QString(tr("Time:\t%1\nLabel:\t%2")) + .arg(rt.toText(true).c_str()) + .arg(points.begin()->label); } pos = QPoint(v->getXForFrame(useFrame), pos.y()); @@ -252,22 +252,22 @@ bool TimeInstantLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const + int &resolution, + SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); SparseOneDimensionalModel::PointList points; if (snap == SnapNeighbouring) { - - points = getLocalPoints(v, v->getXForFrame(frame)); - if (points.empty()) return false; - frame = points.begin()->frame; - return true; + + points = getLocalPoints(v, v->getXForFrame(frame)); + if (points.empty()) return false; + frame = points.begin()->frame; + return true; } points = m_model->getPoints(frame, frame); @@ -275,47 +275,47 @@ bool found = false; for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame >= frame) { - snapped = i->frame; - found = true; - break; - } + if (i->frame >= frame) { + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame <= frame) { - snapped = i->frame; - found = true; // don't break, as the next may be better - } else { - break; - } + if (i->frame <= frame) { + snapped = i->frame; + found = true; // don't break, as the next may be better + } else { + break; + } - } else { // nearest + } else { // nearest - SparseOneDimensionalModel::PointList::const_iterator j = i; - ++j; + SparseOneDimensionalModel::PointList::const_iterator j = i; + ++j; - if (j == points.end()) { + if (j == points.end()) { - snapped = i->frame; - found = true; - break; + snapped = i->frame; + found = true; + break; - } else if (j->frame >= frame) { + } else if (j->frame >= frame) { - if (j->frame - frame < frame - i->frame) { - snapped = j->frame; - } else { - snapped = i->frame; - } - found = true; - break; - } - } + if (j->frame - frame < frame - i->frame) { + snapped = j->frame; + } else { + snapped = i->frame; + } + found = true; + break; + } + } } frame = snapped; @@ -335,12 +335,12 @@ sv_frame_t frame1 = v->getFrameForX(x1); SparseOneDimensionalModel::PointList points(m_model->getPoints - (frame0, frame1)); + (frame0, frame1)); bool odd = false; if (m_plotStyle == PlotSegmentation && !points.empty()) { - int index = m_model->getIndexOf(*points.begin()); - odd = ((index % 2) == 1); + int index = m_model->getIndexOf(*points.begin()); + odd = ((index % 2) == 1); } paint.setPen(getBaseQColor()); @@ -351,119 +351,119 @@ QColor oddBrushColour(brushColour); if (m_plotStyle == PlotSegmentation) { - if (getBaseQColor() == Qt::black) { - oddBrushColour = Qt::gray; - } else if (getBaseQColor() == Qt::darkRed) { - oddBrushColour = Qt::red; - } else if (getBaseQColor() == Qt::darkBlue) { - oddBrushColour = Qt::blue; - } else if (getBaseQColor() == Qt::darkGreen) { - oddBrushColour = Qt::green; - } else { - oddBrushColour = oddBrushColour.light(150); - } - oddBrushColour.setAlpha(100); + if (getBaseQColor() == Qt::black) { + oddBrushColour = Qt::gray; + } else if (getBaseQColor() == Qt::darkRed) { + oddBrushColour = Qt::red; + } else if (getBaseQColor() == Qt::darkBlue) { + oddBrushColour = Qt::blue; + } else if (getBaseQColor() == Qt::darkGreen) { + oddBrushColour = Qt::green; + } else { + oddBrushColour = oddBrushColour.light(150); + } + oddBrushColour.setAlpha(100); } // SVDEBUG << "TimeInstantLayer::paint: resolution is " -// << m_model->getResolution() << " frames" << endl; +// << m_model->getResolution() << " frames" << endl; QPoint localPos; sv_frame_t illuminateFrame = -1; if (v->shouldIlluminateLocalFeatures(this, localPos)) { - SparseOneDimensionalModel::PointList localPoints = - getLocalPoints(v, localPos.x()); - if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; + SparseOneDimensionalModel::PointList localPoints = + getLocalPoints(v, localPos.x()); + if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; } - + int prevX = -1; int textY = v->getTextLabelHeight(this, paint); for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - const SparseOneDimensionalModel::Point &p(*i); - SparseOneDimensionalModel::PointList::const_iterator j = i; - ++j; + const SparseOneDimensionalModel::Point &p(*i); + SparseOneDimensionalModel::PointList::const_iterator j = i; + ++j; - int x = v->getXForFrame(p.frame); + int x = v->getXForFrame(p.frame); if (x == prevX && m_plotStyle == PlotInstants && p.frame != illuminateFrame) continue; - int iw = v->getXForFrame(p.frame + m_model->getResolution()) - x; - if (iw < 2) { - if (iw < 1) { - iw = 2; - if (j != points.end()) { - int nx = v->getXForFrame(j->frame); - if (nx < x + 3) iw = 1; - } - } else { - iw = 2; - } - } - - if (p.frame == illuminateFrame) { - paint.setPen(getForegroundQColor(v->getView())); - } else { - paint.setPen(brushColour); - } + int iw = v->getXForFrame(p.frame + m_model->getResolution()) - x; + if (iw < 2) { + if (iw < 1) { + iw = 2; + if (j != points.end()) { + int nx = v->getXForFrame(j->frame); + if (nx < x + 3) iw = 1; + } + } else { + iw = 2; + } + } + + if (p.frame == illuminateFrame) { + paint.setPen(getForegroundQColor(v->getView())); + } else { + paint.setPen(brushColour); + } - if (m_plotStyle == PlotInstants) { - if (iw > 1) { - paint.drawRect(x, 0, iw - 1, v->getPaintHeight() - 1); - } else { - paint.drawLine(x, 0, x, v->getPaintHeight() - 1); - } - } else { + if (m_plotStyle == PlotInstants) { + if (iw > 1) { + paint.drawRect(x, 0, iw - 1, v->getPaintHeight() - 1); + } else { + paint.drawLine(x, 0, x, v->getPaintHeight() - 1); + } + } else { - if (odd) paint.setBrush(oddBrushColour); - else paint.setBrush(brushColour); - - int nx; - - if (j != points.end()) { - const SparseOneDimensionalModel::Point &q(*j); - nx = v->getXForFrame(q.frame); - } else { - nx = v->getXForFrame(m_model->getEndFrame()); - } + if (odd) paint.setBrush(oddBrushColour); + else paint.setBrush(brushColour); + + int nx; + + if (j != points.end()) { + const SparseOneDimensionalModel::Point &q(*j); + nx = v->getXForFrame(q.frame); + } else { + nx = v->getXForFrame(m_model->getEndFrame()); + } - if (nx >= x) { - - if (illuminateFrame != p.frame && - (nx < x + 5 || x >= v->getPaintWidth() - 1)) { - paint.setPen(Qt::NoPen); - } + if (nx >= x) { + + if (illuminateFrame != p.frame && + (nx < x + 5 || x >= v->getPaintWidth() - 1)) { + paint.setPen(Qt::NoPen); + } paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); - } + } - odd = !odd; - } + odd = !odd; + } - paint.setPen(getBaseQColor()); - - if (p.label != "") { + paint.setPen(getBaseQColor()); + + if (p.label != "") { - // only draw if there's enough room from here to the next point + // only draw if there's enough room from here to the next point - int lw = paint.fontMetrics().width(p.label); - bool good = true; + int lw = paint.fontMetrics().width(p.label); + bool good = true; - if (j != points.end()) { - int nx = v->getXForFrame(j->frame); - if (nx >= x && nx - x - iw - 3 <= lw) good = false; - } + if (j != points.end()) { + int nx = v->getXForFrame(j->frame); + if (nx >= x && nx - x - iw - 3 <= lw) good = false; + } - if (good) { + if (good) { PaintAssistant::drawVisibleText(v, paint, x + iw + 2, textY, p.label, PaintAssistant::OutlinedText); -// paint.drawText(x + iw + 2, textY, p.label); - } - } +// paint.drawText(x + iw + 2, textY, p.label); + } + } - prevX = x; + prevX = x; } } @@ -484,7 +484,7 @@ if (m_editingCommand) finish(m_editingCommand); m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model, - tr("Draw Point")); + tr("Draw Point")); m_editingCommand->addPoint(m_editingPoint); m_editing = true; @@ -515,9 +515,9 @@ #endif if (!m_model || !m_editing) return; QString newName = tr("Add Point at %1 s") - .arg(RealTime::frame2RealTime(m_editingPoint.frame, - m_model->getSampleRate()) - .toText(false).c_str()); + .arg(RealTime::frame2RealTime(m_editingPoint.frame, + m_model->getSampleRate()) + .toText(false).c_str()); m_editingCommand->setName(newName); finish(m_editingCommand); m_editingCommand = 0; @@ -535,8 +535,8 @@ m_editingPoint = *points.begin(); if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -583,8 +583,8 @@ m_editingPoint = *points.begin(); if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -604,8 +604,8 @@ frame = frame / m_model->getResolution() * m_model->getResolution(); if (!m_editingCommand) { - m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model, - tr("Drag Point")); + m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model, + tr("Drag Point")); } m_editingCommand->deletePoint(m_editingPoint); @@ -621,12 +621,12 @@ #endif if (!m_model || !m_editing) return; if (m_editingCommand) { - QString newName = tr("Move Point to %1 s") - .arg(RealTime::frame2RealTime(m_editingPoint.frame, - m_model->getSampleRate()) - .toText(false).c_str()); - m_editingCommand->setName(newName); - finish(m_editingCommand); + QString newName = tr("Move Point to %1 s") + .arg(RealTime::frame2RealTime(m_editingPoint.frame, + m_model->getSampleRate()) + .toText(false).c_str()); + m_editingCommand->setName(newName); + finish(m_editingCommand); } m_editingCommand = 0; m_editing = false; @@ -673,21 +673,21 @@ if (!m_model) return; SparseOneDimensionalModel::EditCommand *command = - new SparseOneDimensionalModel::EditCommand(m_model, - tr("Drag Selection")); + new SparseOneDimensionalModel::EditCommand(m_model, + tr("Drag Selection")); SparseOneDimensionalModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { - SparseOneDimensionalModel::Point newPoint(*i); - newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); - command->deletePoint(*i); - command->addPoint(newPoint); - } + if (s.contains(i->frame)) { + SparseOneDimensionalModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -699,30 +699,30 @@ if (!m_model) return; SparseOneDimensionalModel::EditCommand *command = - new SparseOneDimensionalModel::EditCommand(m_model, - tr("Resize Selection")); + new SparseOneDimensionalModel::EditCommand(m_model, + tr("Resize Selection")); SparseOneDimensionalModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); double ratio = - double(newSize.getEndFrame() - newSize.getStartFrame()) / - double(s.getEndFrame() - s.getStartFrame()); + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { + if (s.contains(i->frame)) { - double target = double(i->frame); - target = double(newSize.getStartFrame()) + - target - double(s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; - SparseOneDimensionalModel::Point newPoint(*i); - newPoint.frame = lrint(target); - command->deletePoint(*i); - command->addPoint(newPoint); - } + SparseOneDimensionalModel::Point newPoint(*i); + newPoint.frame = lrint(target); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -734,15 +734,15 @@ if (!m_model) return; SparseOneDimensionalModel::EditCommand *command = - new SparseOneDimensionalModel::EditCommand(m_model, - tr("Delete Selection")); + new SparseOneDimensionalModel::EditCommand(m_model, + tr("Delete Selection")); SparseOneDimensionalModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) command->deletePoint(*i); + i != points.end(); ++i) { + if (s.contains(i->frame)) command->deletePoint(*i); } finish(command); @@ -754,11 +754,11 @@ if (!m_model) return; SparseOneDimensionalModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) { + i != points.end(); ++i) { + if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->label); point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); @@ -793,7 +793,7 @@ } SparseOneDimensionalModel::EditCommand *command = - new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); + new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); for (Clipboard::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -861,7 +861,7 @@ bool ok; PlotStyle style = (PlotStyle) - attributes.value("plotStyle").toInt(&ok); + attributes.value("plotStyle").toInt(&ok); if (ok) setPlotStyle(style); }
--- a/layer/TimeInstantLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TimeInstantLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -39,8 +39,8 @@ virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual void drawStart(LayerGeometryProvider *v, QMouseEvent *); virtual void drawDrag(LayerGeometryProvider *v, QMouseEvent *); @@ -73,12 +73,12 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); enum PlotStyle { - PlotInstants, - PlotSegmentation + PlotInstants, + PlotSegmentation }; void setPlotStyle(PlotStyle style);
--- a/layer/TimeRulerLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TimeRulerLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -167,28 +167,28 @@ quarterTicks = false; if (rtGap.sec > 0) { - incms = 1000; - int s = rtGap.sec; - if (s > 0) { incms *= 5; s /= 5; } - if (s > 0) { incms *= 2; s /= 2; } - if (s > 0) { incms *= 6; s /= 6; quarterTicks = true; } - if (s > 0) { incms *= 5; s /= 5; quarterTicks = false; } - if (s > 0) { incms *= 2; s /= 2; } - if (s > 0) { incms *= 6; s /= 6; quarterTicks = true; } - while (s > 0) { - incms *= 10; - s /= 10; - quarterTicks = false; - } + incms = 1000; + int s = rtGap.sec; + if (s > 0) { incms *= 5; s /= 5; } + if (s > 0) { incms *= 2; s /= 2; } + if (s > 0) { incms *= 6; s /= 6; quarterTicks = true; } + if (s > 0) { incms *= 5; s /= 5; quarterTicks = false; } + if (s > 0) { incms *= 2; s /= 2; } + if (s > 0) { incms *= 6; s /= 6; quarterTicks = true; } + while (s > 0) { + incms *= 10; + s /= 10; + quarterTicks = false; + } } else { - incms = 1; - int ms = rtGap.msec(); + incms = 1; + int ms = rtGap.msec(); // cerr << "rtGap.msec = " << ms << ", rtGap = " << rtGap << ", count = " << count << endl; // cerr << "startFrame = " << startFrame << ", endFrame = " << endFrame << " rtStart = " << rtStart << ", rtEnd = " << rtEnd << endl; - if (ms > 0) { incms *= 10; ms /= 10; } - if (ms > 0) { incms *= 10; ms /= 10; } - if (ms > 0) { incms *= 5; ms /= 5; } - if (ms > 0) { incms *= 2; ms /= 2; } + if (ms > 0) { incms *= 10; ms /= 10; } + if (ms > 0) { incms *= 10; ms /= 10; } + if (ms > 0) { incms *= 5; ms /= 5; } + if (ms > 0) { incms *= 2; ms /= 2; } } return incms; @@ -199,7 +199,7 @@ { #ifdef DEBUG_TIME_RULER_LAYER SVDEBUG << "TimeRulerLayer::paint (" << rect.x() << "," << rect.y() - << ") [" << rect.width() << "x" << rect.height() << "]" << endl; + << ") [" << rect.width() << "x" << rect.height() << "]" << endl; #endif if (!m_model || !m_model->isOK()) return; @@ -233,7 +233,7 @@ int incX = int(incFrame / v->getZoomLevel()); int ticks = 10; if (incX < minPixelSpacing * 2) { - ticks = quarter ? 4 : 5; + ticks = quarter ? 4 : 5; } QColor greyColour = getPartialShades(v)[1]; @@ -279,7 +279,7 @@ break; } - if (x >= rect.x() - 50 && ms >= minlabel) { + if (x >= rect.x() - 50 && ms >= minlabel) { RealTime rt = RealTime::fromMilliseconds(ms); @@ -331,9 +331,9 @@ } } - paint.setPen(greyColour); + paint.setPen(greyColour); - for (int i = 1; i < ticks; ++i) { + for (int i = 1; i < ticks; ++i) { dms = ms + (i * double(incms)) / ticks; frame = lrint((dms * sampleRate) / 1000.0); @@ -353,21 +353,21 @@ cerr << "tick " << i << " in range, drawing at " << x << endl; #endif - int sz = 5; - if (ticks == 10) { - if ((i % 2) == 1) { - if (i == 5) { - paint.drawLine(x, 0, x, v->getPaintHeight()); - } else sz = 3; - } else { - sz = 7; - } - } - paint.drawLine(x, 0, x, sz); - paint.drawLine(x, v->getPaintHeight() - sz - 1, x, v->getPaintHeight() - 1); - } + int sz = 5; + if (ticks == 10) { + if ((i % 2) == 1) { + if (i == 5) { + paint.drawLine(x, 0, x, v->getPaintHeight()); + } else sz = 3; + } else { + sz = 7; + } + } + paint.drawLine(x, 0, x, sz); + paint.drawLine(x, v->getPaintHeight() - sz - 1, x, v->getPaintHeight() - 1); + } - ms += incms; + ms += incms; } paint.restore();
--- a/layer/TimeValueLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TimeValueLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -160,7 +160,7 @@ int TimeValueLayer::getPropertyRangeAndValue(const PropertyName &name, - int *min, int *max, int *deflt) const + int *min, int *max, int *deflt) const { int val = 0; @@ -173,20 +173,20 @@ val = m_colourMap; } else if (name == "Plot Type") { - - if (min) *min = 0; - if (max) *max = 6; + + if (min) *min = 0; + if (max) *max = 6; if (deflt) *deflt = int(PlotConnectedPoints); - - val = int(m_plotStyle); + + val = int(m_plotStyle); } else if (name == "Vertical Scale") { - - if (min) *min = 0; - if (max) *max = 3; + + if (min) *min = 0; + if (max) *max = 3; if (deflt) *deflt = int(AutoAlignScale); - - val = int(m_verticalScale); + + val = int(m_verticalScale); } else if (name == "Scale Units") { @@ -211,8 +211,8 @@ val = (m_derivative ? 1.0 : 0.0); } else { - - val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); + + val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -220,29 +220,29 @@ QString TimeValueLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { if (name == "Colour" && m_plotStyle == PlotSegmentation) { return ColourMapper::getColourMapName(value); } else if (name == "Plot Type") { - switch (value) { - default: - case 0: return tr("Points"); - case 1: return tr("Stems"); - case 2: return tr("Connected Points"); - case 3: return tr("Lines"); - case 4: return tr("Curve"); - case 5: return tr("Segmentation"); - case 6: return tr("Discrete Curves"); - } + switch (value) { + default: + case 0: return tr("Points"); + case 1: return tr("Stems"); + case 2: return tr("Connected Points"); + case 3: return tr("Lines"); + case 4: return tr("Curve"); + case 5: return tr("Segmentation"); + case 6: return tr("Discrete Curves"); + } } else if (name == "Vertical Scale") { - switch (value) { - default: - case 0: return tr("Auto-Align"); - case 1: return tr("Linear"); - case 2: return tr("Log"); - case 3: return tr("+/-1"); - } + switch (value) { + default: + case 0: return tr("Auto-Align"); + case 1: return tr("Linear"); + case 2: return tr("Log"); + case 3: return tr("+/-1"); + } } return SingleColourLayer::getPropertyValueLabel(name, value); } @@ -253,9 +253,9 @@ if (name == "Colour" && m_plotStyle == PlotSegmentation) { setFillColourMap(value); } else if (name == "Plot Type") { - setPlotStyle(PlotStyle(value)); + setPlotStyle(PlotStyle(value)); } else if (name == "Vertical Scale") { - setVerticalScale(VerticalScale(value)); + setVerticalScale(VerticalScale(value)); } else if (name == "Scale Units") { if (m_model) { m_model->setScaleUnits @@ -323,7 +323,7 @@ // they're always scrollable if (m_plotStyle == PlotLines || - m_plotStyle == PlotCurve || + m_plotStyle == PlotCurve || m_plotStyle == PlotDiscreteCurves) return true; QPoint discard; @@ -538,38 +538,38 @@ sv_frame_t frame = v->getFrameForX(x); SparseTimeValueModel::PointList onPoints = - m_model->getPoints(frame); + m_model->getPoints(frame); if (!onPoints.empty()) { - return onPoints; + return onPoints; } SparseTimeValueModel::PointList prevPoints = - m_model->getPreviousPoints(frame); + m_model->getPreviousPoints(frame); SparseTimeValueModel::PointList nextPoints = - m_model->getNextPoints(frame); + m_model->getNextPoints(frame); SparseTimeValueModel::PointList usePoints = prevPoints; if (prevPoints.empty()) { - usePoints = nextPoints; + usePoints = nextPoints; } else if (nextPoints.empty()) { // stick with prevPoints } else if (prevPoints.begin()->frame < v->getStartFrame() && - !(nextPoints.begin()->frame > v->getEndFrame())) { - usePoints = nextPoints; + !(nextPoints.begin()->frame > v->getEndFrame())) { + usePoints = nextPoints; } else if (nextPoints.begin()->frame - frame < - frame - prevPoints.begin()->frame) { - usePoints = nextPoints; + frame - prevPoints.begin()->frame) { + usePoints = nextPoints; } if (!usePoints.empty()) { - int fuzz = 2; - int px = v->getXForFrame(usePoints.begin()->frame); - if ((px > x && px - x > fuzz) || - (px < x && x - px > fuzz + 3)) { - usePoints.clear(); - } + int fuzz = 2; + int px = v->getXForFrame(usePoints.begin()->frame); + if ((px > x && px - x > fuzz) || + (px < x && x - px > fuzz + 3)) { + usePoints.clear(); + } } return usePoints; @@ -597,11 +597,11 @@ SparseTimeValueModel::PointList points = getLocalPoints(v, x); if (points.empty()) { - if (!m_model->isReady()) { - return tr("In progress"); - } else { - return tr("No local points"); - } + if (!m_model->isReady()) { + return tr("In progress"); + } else { + return tr("No local points"); + } } sv_frame_t useFrame = points.begin()->frame; @@ -626,39 +626,39 @@ QString text; if (points.begin()->label == "") { - text = QString(tr("Time:\t%1\nValue:\t%2\nNo label")) - .arg(rt.toText(true).c_str()) - .arg(valueText); + text = QString(tr("Time:\t%1\nValue:\t%2\nNo label")) + .arg(rt.toText(true).c_str()) + .arg(valueText); } else { - text = QString(tr("Time:\t%1\nValue:\t%2\nLabel:\t%4")) - .arg(rt.toText(true).c_str()) - .arg(valueText) - .arg(points.begin()->label); + text = QString(tr("Time:\t%1\nValue:\t%2\nLabel:\t%4")) + .arg(rt.toText(true).c_str()) + .arg(valueText) + .arg(points.begin()->label); } pos = QPoint(v->getXForFrame(useFrame), - getYForValue(v, points.begin()->value)); + getYForValue(v, points.begin()->value)); return text; } bool TimeValueLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const + int &resolution, + SnapType snap) const { if (!m_model) { - return Layer::snapToFeatureFrame(v, frame, resolution, snap); + return Layer::snapToFeatureFrame(v, frame, resolution, snap); } resolution = m_model->getResolution(); SparseTimeValueModel::PointList points; if (snap == SnapNeighbouring) { - - points = getLocalPoints(v, v->getXForFrame(frame)); - if (points.empty()) return false; - frame = points.begin()->frame; - return true; + + points = getLocalPoints(v, v->getXForFrame(frame)); + if (points.empty()) return false; + frame = points.begin()->frame; + return true; } points = m_model->getPoints(frame, frame); @@ -666,47 +666,47 @@ bool found = false; for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame > frame) { - snapped = i->frame; - found = true; - break; - } + if (i->frame > frame) { + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame <= frame) { - snapped = i->frame; - found = true; // don't break, as the next may be better - } else { - break; - } + if (i->frame <= frame) { + snapped = i->frame; + found = true; // don't break, as the next may be better + } else { + break; + } - } else { // nearest + } else { // nearest - SparseTimeValueModel::PointList::const_iterator j = i; - ++j; + SparseTimeValueModel::PointList::const_iterator j = i; + ++j; - if (j == points.end()) { + if (j == points.end()) { - snapped = i->frame; - found = true; - break; + snapped = i->frame; + found = true; + break; - } else if (j->frame >= frame) { + } else if (j->frame >= frame) { - if (j->frame - frame < frame - i->frame) { - snapped = j->frame; - } else { - snapped = i->frame; - } - found = true; - break; - } - } + if (j->frame - frame < frame - i->frame) { + snapped = j->frame; + } else { + snapped = i->frame; + } + found = true; + break; + } + } } frame = snapped; @@ -719,7 +719,7 @@ SnapType snap) const { if (!m_model) { - return Layer::snapToSimilarFeature(v, frame, resolution, snap); + return Layer::snapToSimilarFeature(v, frame, resolution, snap); } resolution = m_model->getResolution(); @@ -763,29 +763,29 @@ } } - if (snap == SnapRight) { + if (snap == SnapRight) { - if (i->frame > matchframe && + if (i->frame > matchframe && fabs(i->value - matchvalue) < epsilon) { - snapped = i->frame; - found = true; - break; - } + snapped = i->frame; + found = true; + break; + } - } else if (snap == SnapLeft) { + } else if (snap == SnapLeft) { - if (i->frame < matchframe) { + if (i->frame < matchframe) { if (fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; // don't break, as the next may be better } - } else if (found || distant) { - break; - } + } else if (found || distant) { + break; + } - } else { + } else { // no other snap types supported - } + } ++i; } @@ -926,7 +926,7 @@ if (m_derivative) --frame0; SparseTimeValueModel::PointList points(m_model->getPoints - (frame0, frame1)); + (frame0, frame1)); if (points.empty()) return; paint.setPen(getBaseQColor()); @@ -937,7 +937,7 @@ #ifdef DEBUG_TIME_VALUE_LAYER cerr << "TimeValueLayer::paint: resolution is " - << m_model->getResolution() << " frames" << endl; + << m_model->getResolution() << " frames" << endl; #endif double min = m_model->getValueMinimum(); @@ -945,23 +945,23 @@ if (max == min) max = min + 1.0; int origin = int(nearbyint(v->getPaintHeight() - - (-min * v->getPaintHeight()) / (max - min))); + (-min * v->getPaintHeight()) / (max - min))); QPoint localPos; sv_frame_t illuminateFrame = -1; if (v->shouldIlluminateLocalFeatures(this, localPos)) { - SparseTimeValueModel::PointList localPoints = - getLocalPoints(v, localPos.x()); + SparseTimeValueModel::PointList localPoints = + getLocalPoints(v, localPos.x()); #ifdef DEBUG_TIME_VALUE_LAYER cerr << "TimeValueLayer: " << localPoints.size() << " local points" << endl; #endif - if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; + if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame; } int w = - v->getXForFrame(frame0 + m_model->getResolution()) - - v->getXForFrame(frame0); + v->getXForFrame(frame0 + m_model->getResolution()) - + v->getXForFrame(frame0); if (m_plotStyle == PlotStems) { if (w < 2) w = 2; @@ -990,11 +990,11 @@ sv_frame_t prevFrame = 0; for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { if (m_derivative && i == points.begin()) continue; - const SparseTimeValueModel::Point &p(*i); + const SparseTimeValueModel::Point &p(*i); double value = p.value; if (m_derivative) { @@ -1003,8 +1003,8 @@ value -= j->value; } - int x = v->getXForFrame(p.frame); - int y = getYForValue(v, value); + int x = v->getXForFrame(p.frame); + int y = getYForValue(v, value); bool gap = false; if (m_plotStyle == PlotDiscreteCurves) { @@ -1024,23 +1024,23 @@ } } - bool haveNext = false; + bool haveNext = false; double nvalue = 0.f; sv_frame_t nf = v->getModelsEndFrame(); - int nx = v->getXForFrame(nf); - int ny = y; + int nx = v->getXForFrame(nf); + int ny = y; - SparseTimeValueModel::PointList::const_iterator j = i; - ++j; + SparseTimeValueModel::PointList::const_iterator j = i; + ++j; - if (j != points.end()) { - const SparseTimeValueModel::Point &q(*j); + if (j != points.end()) { + const SparseTimeValueModel::Point &q(*j); nvalue = q.value; if (m_derivative) nvalue -= p.value; nf = q.frame; - nx = v->getXForFrame(nf); - ny = getYForValue(v, nvalue); - haveNext = true; + nx = v->getXForFrame(nf); + ny = getYForValue(v, nvalue); + haveNext = true; } // cout << "frame = " << p.frame << ", x = " << x << ", haveNext = " << haveNext @@ -1055,43 +1055,43 @@ } else if (m_plotStyle == PlotSegmentation) { pen = QPen(getForegroundQColor(v)); brush = QBrush(getColourForValue(v, value)); - } else if (m_plotStyle == PlotLines || - m_plotStyle == PlotCurve) { + } else if (m_plotStyle == PlotLines || + m_plotStyle == PlotCurve) { brush = QBrush(Qt::NoBrush); - } + } paint.setPen(PaintAssistant::scalePen(pen)); paint.setBrush(brush); - if (m_plotStyle == PlotStems) { - if (y < origin - 1) { - paint.drawLine(x + w/2, y + 1, x + w/2, origin); - } else if (y > origin + 1) { - paint.drawLine(x + w/2, origin, x + w/2, y - 1); - } - } + if (m_plotStyle == PlotStems) { + if (y < origin - 1) { + paint.drawLine(x + w/2, y + 1, x + w/2, origin); + } else if (y > origin + 1) { + paint.drawLine(x + w/2, origin, x + w/2, y - 1); + } + } bool illuminate = false; - if (illuminateFrame == p.frame) { + if (illuminateFrame == p.frame) { - // not equipped to illuminate the right section in line - // or curve mode + // not equipped to illuminate the right section in line + // or curve mode - if (m_plotStyle != PlotCurve && + if (m_plotStyle != PlotCurve && m_plotStyle != PlotDiscreteCurves && - m_plotStyle != PlotLines) { + m_plotStyle != PlotLines) { illuminate = true; } } - if (m_plotStyle != PlotLines && - m_plotStyle != PlotCurve && + if (m_plotStyle != PlotLines && + m_plotStyle != PlotCurve && m_plotStyle != PlotDiscreteCurves && - m_plotStyle != PlotSegmentation) { + m_plotStyle != PlotSegmentation) { if (illuminate) { paint.save(); - paint.setPen(PaintAssistant::scalePen(getForegroundQColor(v))); + paint.setPen(PaintAssistant::scalePen(getForegroundQColor(v))); paint.setBrush(getForegroundQColor(v)); } if (m_plotStyle != PlotStems || @@ -1101,38 +1101,38 @@ if (illuminate) { paint.restore(); } - } + } - if (m_plotStyle == PlotConnectedPoints || - m_plotStyle == PlotLines || + if (m_plotStyle == PlotConnectedPoints || + m_plotStyle == PlotLines || m_plotStyle == PlotDiscreteCurves || - m_plotStyle == PlotCurve) { + m_plotStyle == PlotCurve) { - if (haveNext) { + if (haveNext) { - if (m_plotStyle == PlotConnectedPoints) { - + if (m_plotStyle == PlotConnectedPoints) { + paint.save(); - paint.setPen(PaintAssistant::scalePen(brushColour)); - paint.drawLine(x + w, y, nx, ny); + paint.setPen(PaintAssistant::scalePen(brushColour)); + paint.drawLine(x + w, y, nx, ny); paint.restore(); - } else if (m_plotStyle == PlotLines) { + } else if (m_plotStyle == PlotLines) { if (pointCount == 0) { path.moveTo(x + w/2, y); } -// paint.drawLine(x + w/2, y, nx + w/2, ny); +// paint.drawLine(x + w/2, y, nx + w/2, ny); path.lineTo(nx + w/2, ny); - } else { + } else { - double x0 = x + double(w)/2; - double x1 = nx + double(w)/2; - - double y0 = y; - double y1 = ny; + double x0 = x + double(w)/2; + double x1 = nx + double(w)/2; + + double y0 = y; + double y1 = ny; if (m_plotStyle == PlotDiscreteCurves) { bool nextGap = @@ -1144,33 +1144,33 @@ } } - if (pointCount == 0 || gap) { - path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); - } + if (pointCount == 0 || gap) { + path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); + } - if (nx - x > 5) { - path.cubicTo(x0, y0, - x0, y0, - (x0 + x1) / 2, (y0 + y1) / 2); + if (nx - x > 5) { + path.cubicTo(x0, y0, + x0, y0, + (x0 + x1) / 2, (y0 + y1) / 2); - // // or - // path.quadTo(x0, y0, (x0 + x1) / 2, (y0 + y1) / 2); + // // or + // path.quadTo(x0, y0, (x0 + x1) / 2, (y0 + y1) / 2); - } else { + } else { path.lineTo(x0, y0); - path.lineTo((x0 + x1) / 2, (y0 + y1) / 2); - } - } - } - } + path.lineTo((x0 + x1) / 2, (y0 + y1) / 2); + } + } + } + } - if (m_plotStyle == PlotSegmentation) { + if (m_plotStyle == PlotSegmentation) { #ifdef DEBUG_TIME_VALUE_LAYER cerr << "drawing rect" << endl; #endif - - if (nx <= x) continue; + + if (nx <= x) continue; paint.setPen(PaintAssistant::scalePen(QPen(getForegroundQColor(v), 2))); @@ -1180,10 +1180,10 @@ x >= v->getPaintWidth() - 1) { paint.setPen(Qt::NoPen); } - } + } - paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); - } + paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); + } if (v->shouldShowFeatureLabels()) { @@ -1222,11 +1222,11 @@ if (m_plotStyle == PlotDiscreteCurves) { paint.setRenderHint(QPainter::Antialiasing, true); - paint.drawPath(path); + paint.drawPath(path); } else if ((m_plotStyle == PlotCurve || m_plotStyle == PlotLines) && !path.isEmpty()) { - paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->getPaintWidth()); - paint.drawPath(path); + paint.setRenderHint(QPainter::Antialiasing, pointCount <= v->getPaintWidth()); + paint.drawPath(path); } paint.restore(); @@ -1349,7 +1349,7 @@ if (m_editingCommand) finish(m_editingCommand); m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, - tr("Draw Point")); + tr("Draw Point")); if (!havePoint) { m_editingCommand->addPoint(m_editingPoint); } @@ -1442,8 +1442,8 @@ m_editingPoint = *points.begin(); if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -1492,8 +1492,8 @@ m_originalPoint = m_editingPoint; if (m_editingCommand) { - finish(m_editingCommand); - m_editingCommand = 0; + finish(m_editingCommand); + m_editingCommand = 0; } m_editing = true; @@ -1515,8 +1515,8 @@ double value = getValueForY(v, e->y()); if (!m_editingCommand) { - m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, - tr("Drag Point")); + m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, + tr("Drag Point")); } m_editingCommand->deletePoint(m_editingPoint); @@ -1535,20 +1535,20 @@ if (m_editingCommand) { - QString newName = m_editingCommand->getName(); + QString newName = m_editingCommand->getName(); - if (m_editingPoint.frame != m_originalPoint.frame) { - if (m_editingPoint.value != m_originalPoint.value) { - newName = tr("Edit Point"); - } else { - newName = tr("Relocate Point"); - } - } else { - newName = tr("Change Point Value"); - } + if (m_editingPoint.frame != m_originalPoint.frame) { + if (m_editingPoint.value != m_originalPoint.value) { + newName = tr("Edit Point"); + } else { + newName = tr("Relocate Point"); + } + } else { + newName = tr("Change Point Value"); + } - m_editingCommand->setName(newName); - finish(m_editingCommand); + m_editingCommand->setName(newName); + finish(m_editingCommand); } m_editingCommand = 0; @@ -1600,21 +1600,21 @@ if (!m_model) return; SparseTimeValueModel::EditCommand *command = - new SparseTimeValueModel::EditCommand(m_model, - tr("Drag Selection")); + new SparseTimeValueModel::EditCommand(m_model, + tr("Drag Selection")); SparseTimeValueModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (SparseTimeValueModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { - SparseTimeValueModel::Point newPoint(*i); - newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); - command->deletePoint(*i); - command->addPoint(newPoint); - } + if (s.contains(i->frame)) { + SparseTimeValueModel::Point newPoint(*i); + newPoint.frame = i->frame + newStartFrame - s.getStartFrame(); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -1626,30 +1626,30 @@ if (!m_model) return; SparseTimeValueModel::EditCommand *command = - new SparseTimeValueModel::EditCommand(m_model, - tr("Resize Selection")); + new SparseTimeValueModel::EditCommand(m_model, + tr("Resize Selection")); SparseTimeValueModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); double ratio = - double(newSize.getEndFrame() - newSize.getStartFrame()) / - double(s.getEndFrame() - s.getStartFrame()); + double(newSize.getEndFrame() - newSize.getStartFrame()) / + double(s.getEndFrame() - s.getStartFrame()); for (SparseTimeValueModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { - if (s.contains(i->frame)) { + if (s.contains(i->frame)) { - double target = double(i->frame); - target = double(newSize.getStartFrame()) + - target - double(s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; - SparseTimeValueModel::Point newPoint(*i); - newPoint.frame = lrint(target); - command->deletePoint(*i); - command->addPoint(newPoint); - } + SparseTimeValueModel::Point newPoint(*i); + newPoint.frame = lrint(target); + command->deletePoint(*i); + command->addPoint(newPoint); + } } finish(command); @@ -1661,14 +1661,14 @@ if (!m_model) return; SparseTimeValueModel::EditCommand *command = - new SparseTimeValueModel::EditCommand(m_model, - tr("Delete Selected Points")); + new SparseTimeValueModel::EditCommand(m_model, + tr("Delete Selected Points")); SparseTimeValueModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (SparseTimeValueModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { + i != points.end(); ++i) { if (s.contains(i->frame)) { command->deletePoint(*i); @@ -1684,11 +1684,11 @@ if (!m_model) return; SparseTimeValueModel::PointList points = - m_model->getPoints(s.getStartFrame(), s.getEndFrame()); + m_model->getPoints(s.getStartFrame(), s.getEndFrame()); for (SparseTimeValueModel::PointList::iterator i = points.begin(); - i != points.end(); ++i) { - if (s.contains(i->frame)) { + i != points.end(); ++i) { + if (s.contains(i->frame)) { Clipboard::Point point(i->frame, i->value, i->label); point.setReferenceFrame(alignToReference(v, i->frame)); to.addPoint(point); @@ -1724,7 +1724,7 @@ } SparseTimeValueModel::EditCommand *command = - new SparseTimeValueModel::EditCommand(m_model, tr("Paste")); + new SparseTimeValueModel::EditCommand(m_model, tr("Paste")); enum ValueAvailability { UnknownAvailability, @@ -1928,11 +1928,11 @@ if (ok) setFillColourMap(cmap); PlotStyle style = (PlotStyle) - attributes.value("plotStyle").toInt(&ok); + attributes.value("plotStyle").toInt(&ok); if (ok) setPlotStyle(style); VerticalScale scale = (VerticalScale) - attributes.value("verticalScale").toInt(&ok); + attributes.value("verticalScale").toInt(&ok); if (ok) setVerticalScale(scale); bool draw = (attributes.value("drawDivisions").trimmed() == "true");
--- a/layer/TimeValueLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/TimeValueLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -46,8 +46,8 @@ virtual QString getLabelPreceding(sv_frame_t) const; virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, - int &resolution, - SnapType snap) const; + int &resolution, + SnapType snap) const; virtual bool snapToSimilarFeature(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -85,19 +85,19 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); void setFillColourMap(int); int getFillColourMap() const { return m_colourMap; } enum PlotStyle { - PlotPoints, - PlotStems, - PlotConnectedPoints, - PlotLines, - PlotCurve, - PlotSegmentation, + PlotPoints, + PlotStems, + PlotConnectedPoints, + PlotLines, + PlotCurve, + PlotSegmentation, PlotDiscreteCurves };
--- a/layer/WaveformLayer.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/WaveformLayer.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -135,7 +135,7 @@ { if (name == "Gain" || name == "Normalize Visible Area" || - name == "Scale") return tr("Scale"); + name == "Scale") return tr("Scale"); return QString(); } @@ -152,13 +152,13 @@ if (name == "Gain") { - *min = -50; - *max = 50; + *min = -50; + *max = 50; *deflt = 0; - val = int(lrint(log10(m_gain) * 20.0)); - if (val < *min) val = *min; - if (val > *max) val = *max; + val = int(lrint(log10(m_gain) * 20.0)); + if (val < *min) val = *min; + if (val > *max) val = *max; } else if (name == "Normalize Visible Area") { @@ -176,14 +176,14 @@ } else if (name == "Scale") { - *min = 0; - *max = 2; + *min = 0; + *max = 2; *deflt = 0; - val = (int)m_scale; + val = (int)m_scale; } else { - val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); + val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt); } return val; @@ -191,15 +191,15 @@ QString WaveformLayer::getPropertyValueLabel(const PropertyName &name, - int value) const + int value) const { if (name == "Scale") { - switch (value) { - default: - case 0: return tr("Linear"); - case 1: return tr("Meter"); - case 2: return tr("dB"); - } + switch (value) { + default: + case 0: return tr("Linear"); + case 1: return tr("Meter"); + case 2: return tr("dB"); + } } if (name == "Channels") { switch (value) { @@ -225,7 +225,7 @@ WaveformLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(float(pow(10, float(value)/20.0))); + setGain(float(pow(10, float(value)/20.0))); } else if (name == "Normalize Visible Area") { setAutoNormalize(value ? true : false); } else if (name == "Channels") { @@ -233,12 +233,12 @@ else if (value == 2) setChannelMode(MergeChannels); else setChannelMode(SeparateChannels); } else if (name == "Scale") { - switch (value) { - default: - case 0: setScale(LinearScale); break; - case 1: setScale(MeterScale); break; - case 2: setScale(dBScale); break; - } + switch (value) { + default: + case 0: setScale(LinearScale); break; + case 1: setScale(MeterScale); break; + case 2: setScale(dBScale); break; + } } else { SingleColourLayer::setProperty(name, value); } @@ -378,19 +378,19 @@ int rawChannels = channels; if (m_channel == -1) { - min = 0; - if (m_channelMode == MergeChannels || + min = 0; + if (m_channelMode == MergeChannels || m_channelMode == MixChannels) { - max = 0; - channels = 1; - } else { - max = channels - 1; - } + max = 0; + channels = 1; + } else { + max = channels - 1; + } } else { - min = m_channel; - max = m_channel; - rawChannels = 1; - channels = 1; + min = m_channel; + max = m_channel; + rawChannels = 1; + channels = 1; } merging = (m_channelMode == MergeChannels && rawChannels > 1); @@ -479,7 +479,7 @@ WaveformLayer::paint(LayerGeometryProvider *v, QPainter &viewPainter, QRect rect) const { if (!m_model || !m_model->isOK()) { - return; + return; } int zoomLevel = v->getZoomLevel(); @@ -487,7 +487,7 @@ #ifdef DEBUG_WAVEFORM_PAINT Profiler profiler("WaveformLayer::paint", true); cerr << "WaveformLayer::paint (" << rect.x() << "," << rect.y() - << ") [" << rect.width() << "x" << rect.height() << "]: zoom " << zoomLevel << endl; + << ") [" << rect.width() << "x" << rect.height() << "]: zoom " << zoomLevel << endl; #endif int channels = 0, minChannel = 0, maxChannel = 0; @@ -509,37 +509,37 @@ cerr << "WaveformLayer::paint: aggressive is true" << endl; #endif - if (m_cacheValid && (zoomLevel != m_cacheZoomLevel)) { - m_cacheValid = false; - } + if (m_cacheValid && (zoomLevel != m_cacheZoomLevel)) { + m_cacheValid = false; + } - if (!m_cache || m_cache->width() != w || m_cache->height() != h) { + if (!m_cache || m_cache->width() != w || m_cache->height() != h) { #ifdef DEBUG_WAVEFORM_PAINT if (m_cache) { cerr << "WaveformLayer::paint: cache size " << m_cache->width() << "x" << m_cache->height() << " differs from view size " << w << "x" << h << ": regenerating aggressive cache" << endl; } #endif - delete m_cache; - m_cache = new QPixmap(w, h); + delete m_cache; + m_cache = new QPixmap(w, h); m_cacheValid = false; - } + } - if (m_cacheValid) { - viewPainter.drawPixmap(rect, *m_cache, rect); - return; - } + if (m_cacheValid) { + viewPainter.drawPixmap(rect, *m_cache, rect); + return; + } - paint = new QPainter(m_cache); + paint = new QPainter(m_cache); - paint->setPen(Qt::NoPen); - paint->setBrush(getBackgroundQColor(v)); - paint->drawRect(rect); + paint->setPen(Qt::NoPen); + paint->setBrush(getBackgroundQColor(v)); + paint->drawRect(rect); - paint->setPen(getForegroundQColor(v)); - paint->setBrush(Qt::NoBrush); + paint->setPen(getForegroundQColor(v)); + paint->setBrush(Qt::NoBrush); } else { - paint = &viewPainter; + paint = &viewPainter; } paint->setRenderHint(QPainter::Antialiasing, false); @@ -597,11 +597,11 @@ QColor midColour = baseColour; if (midColour == Qt::black) { - midColour = Qt::gray; + midColour = Qt::gray; } else if (v->hasLightBackground()) { - midColour = midColour.light(150); + midColour = midColour.light(150); } else { - midColour = midColour.light(50); + midColour = midColour.light(50); } while ((int)m_effectiveGains.size() <= maxChannel) { @@ -610,8 +610,8 @@ for (int ch = minChannel; ch <= maxChannel; ++ch) { - int prevRangeBottom = -1, prevRangeTop = -1; - QColor prevRangeBottomColour = baseColour, prevRangeTopColour = baseColour; + int prevRangeBottom = -1, prevRangeTop = -1; + QColor prevRangeBottomColour = baseColour, prevRangeTopColour = baseColour; m_effectiveGains[ch] = m_gain; @@ -621,14 +621,14 @@ double gain = m_effectiveGains[ch]; - int m = (h / channels) / 2; - int my = m + (((ch - minChannel) * h) / channels); + int m = (h / channels) / 2; + int my = m + (((ch - minChannel) * h) / channels); -#ifdef DEBUG_WAVEFORM_PAINT - cerr << "ch = " << ch << ", channels = " << channels << ", m = " << m << ", my = " << my << ", h = " << h << endl; +#ifdef DEBUG_WAVEFORM_PAINT + cerr << "ch = " << ch << ", channels = " << channels << ", m = " << m << ", my = " << my << ", h = " << h << endl; #endif - if (my - m > y1 || my + m < y0) continue; + if (my - m > y1 || my + m < y0) continue; if ((m_scale == dBScale || m_scale == MeterScale) && m_channelMode != MergeChannels) { @@ -636,8 +636,8 @@ my = m + (((ch - minChannel) * h) / channels); } - paint->setPen(greys[1]); - paint->drawLine(x0, my, x1, my); + paint->setPen(greys[1]); + paint->drawLine(x0, my, x1, my); int n = 10; int py = -1; @@ -694,7 +694,7 @@ cerr << "channel " << ch << ": " << ranges->size() << " ranges from " << frame0 << " to " << frame1 << " at zoom level " << modelZoomLevel << endl; #endif - if (mergingChannels || mixingChannels) { + if (mergingChannels || mixingChannels) { if (m_model->getChannelCount() > 1) { if (!otherChannelRanges) { otherChannelRanges = @@ -707,11 +707,11 @@ if (otherChannelRanges != ranges) delete otherChannelRanges; otherChannelRanges = ranges; } - } + } - for (int x = x0; x <= x1; ++x) { + for (int x = x0; x <= x1; ++x) { - range = RangeSummarisableTimeValueModel::Range(); + range = RangeSummarisableTimeValueModel::Range(); sv_frame_t f0, f1; if (!getSourceFramesForX(v, x, modelZoomLevel, f0, f1)) continue; @@ -733,50 +733,50 @@ cerr << "WaveformLayer::paint: ERROR: i1 " << i1 << " > i0 " << i0 << " plus one (zoom = " << zoomLevel << ", model zoom = " << modelZoomLevel << ")" << endl; } - if (ranges && i0 < (sv_frame_t)ranges->size()) { + if (ranges && i0 < (sv_frame_t)ranges->size()) { - range = (*ranges)[size_t(i0)]; + range = (*ranges)[size_t(i0)]; - if (i1 > i0 && i1 < (int)ranges->size()) { - range.setMax(std::max(range.max(), + if (i1 > i0 && i1 < (int)ranges->size()) { + range.setMax(std::max(range.max(), (*ranges)[size_t(i1)].max())); - range.setMin(std::min(range.min(), + range.setMin(std::min(range.min(), (*ranges)[size_t(i1)].min())); - range.setAbsmean((range.absmean() + range.setAbsmean((range.absmean() + (*ranges)[size_t(i1)].absmean()) / 2); - } + } - } else { + } else { #ifdef DEBUG_WAVEFORM_PAINT cerr << "No (or not enough) ranges for i0 = " << i0 << endl; #endif - continue; - } + continue; + } - int rangeBottom = 0, rangeTop = 0, meanBottom = 0, meanTop = 0; + int rangeBottom = 0, rangeTop = 0, meanBottom = 0, meanTop = 0; - if (mergingChannels) { + if (mergingChannels) { - if (otherChannelRanges && i0 < (sv_frame_t)otherChannelRanges->size()) { + if (otherChannelRanges && i0 < (sv_frame_t)otherChannelRanges->size()) { - range.setMax(fabsf(range.max())); - range.setMin(-fabsf((*otherChannelRanges)[size_t(i0)].max())); - range.setAbsmean + range.setMax(fabsf(range.max())); + range.setMin(-fabsf((*otherChannelRanges)[size_t(i0)].max())); + range.setAbsmean ((range.absmean() + (*otherChannelRanges)[size_t(i0)].absmean()) / 2); - if (i1 > i0 && i1 < (sv_frame_t)otherChannelRanges->size()) { - // let's not concern ourselves about the mean - range.setMin + if (i1 > i0 && i1 < (sv_frame_t)otherChannelRanges->size()) { + // let's not concern ourselves about the mean + range.setMin (std::min (range.min(), -fabsf((*otherChannelRanges)[size_t(i1)].max()))); - } - } + } + } - } else if (mixingChannels) { + } else if (mixingChannels) { - if (otherChannelRanges && i0 < (sv_frame_t)otherChannelRanges->size()) { + if (otherChannelRanges && i0 < (sv_frame_t)otherChannelRanges->size()) { range.setMax((range.max() + (*otherChannelRanges)[size_t(i0)].max()) / 2); @@ -787,19 +787,19 @@ } } - int greyLevels = 1; - if (m_greyscale && (m_scale == LinearScale)) greyLevels = 4; + int greyLevels = 1; + if (m_greyscale && (m_scale == LinearScale)) greyLevels = 4; - switch (m_scale) { + switch (m_scale) { - case LinearScale: - rangeBottom = int(double(m * greyLevels) * range.min() * gain); - rangeTop = int(double(m * greyLevels) * range.max() * gain); - meanBottom = int(double(-m) * range.absmean() * gain); - meanTop = int(double(m) * range.absmean() * gain); - break; + case LinearScale: + rangeBottom = int(double(m * greyLevels) * range.min() * gain); + rangeTop = int(double(m * greyLevels) * range.max() * gain); + meanBottom = int(double(-m) * range.absmean() * gain); + meanTop = int(double(m) * range.absmean() * gain); + break; - case dBScale: + case dBScale: if (!mergingChannels) { int db0 = dBscale(range.min() * gain, m); int db1 = dBscale(range.max() * gain, m); @@ -814,9 +814,9 @@ meanBottom = -dBscale(range.absmean() * gain, m); meanTop = dBscale(range.absmean() * gain, m); } - break; + break; - case MeterScale: + case MeterScale: if (!mergingChannels) { int r0 = abs(AudioLevel::multiplier_to_preview(range.min() * gain, m)); int r1 = abs(AudioLevel::multiplier_to_preview(range.max() * gain, m)); @@ -832,73 +832,73 @@ meanTop = AudioLevel::multiplier_to_preview(range.absmean() * gain, m); } break; - } + } - rangeBottom = my * greyLevels - rangeBottom; - rangeTop = my * greyLevels - rangeTop; - meanBottom = my - meanBottom; - meanTop = my - meanTop; + rangeBottom = my * greyLevels - rangeBottom; + rangeTop = my * greyLevels - rangeTop; + meanBottom = my - meanBottom; + meanTop = my - meanTop; - int topFill = (rangeTop % greyLevels); - if (topFill > 0) topFill = greyLevels - topFill; + int topFill = (rangeTop % greyLevels); + if (topFill > 0) topFill = greyLevels - topFill; - int bottomFill = (rangeBottom % greyLevels); + int bottomFill = (rangeBottom % greyLevels); - rangeTop = rangeTop / greyLevels; - rangeBottom = rangeBottom / greyLevels; + rangeTop = rangeTop / greyLevels; + rangeBottom = rangeBottom / greyLevels; - bool clipped = false; + bool clipped = false; - if (rangeTop < my - m) { rangeTop = my - m; } - if (rangeTop > my + m) { rangeTop = my + m; } - if (rangeBottom < my - m) { rangeBottom = my - m; } - if (rangeBottom > my + m) { rangeBottom = my + m; } + if (rangeTop < my - m) { rangeTop = my - m; } + if (rangeTop > my + m) { rangeTop = my + m; } + if (rangeBottom < my - m) { rangeBottom = my - m; } + if (rangeBottom > my + m) { rangeBottom = my + m; } - if (range.max() <= -1.0 || - range.max() >= 1.0) clipped = true; - - if (meanBottom > rangeBottom) meanBottom = rangeBottom; - if (meanTop < rangeTop) meanTop = rangeTop; + if (range.max() <= -1.0 || + range.max() >= 1.0) clipped = true; + + if (meanBottom > rangeBottom) meanBottom = rangeBottom; + if (meanTop < rangeTop) meanTop = rangeTop; - bool drawMean = m_showMeans; - if (meanTop == rangeTop) { - if (meanTop < meanBottom) ++meanTop; - else drawMean = false; - } - if (meanBottom == rangeBottom && m_scale == LinearScale) { - if (meanBottom > meanTop) --meanBottom; - else drawMean = false; - } + bool drawMean = m_showMeans; + if (meanTop == rangeTop) { + if (meanTop < meanBottom) ++meanTop; + else drawMean = false; + } + if (meanBottom == rangeBottom && m_scale == LinearScale) { + if (meanBottom > meanTop) --meanBottom; + else drawMean = false; + } - if (x != x0 && prevRangeBottom != -1) { - if (prevRangeBottom > rangeBottom + 1 && - prevRangeTop > rangeBottom + 1) { -// paint->setPen(midColour); - paint->setPen(baseColour); - paint->drawLine(x-1, prevRangeTop, x, rangeBottom + 1); - paint->setPen(prevRangeTopColour); - paint->drawPoint(x-1, prevRangeTop); - } else if (prevRangeBottom < rangeTop - 1 && - prevRangeTop < rangeTop - 1) { -// paint->setPen(midColour); - paint->setPen(baseColour); - paint->drawLine(x-1, prevRangeBottom, x, rangeTop - 1); - paint->setPen(prevRangeBottomColour); - paint->drawPoint(x-1, prevRangeBottom); - } - } + if (x != x0 && prevRangeBottom != -1) { + if (prevRangeBottom > rangeBottom + 1 && + prevRangeTop > rangeBottom + 1) { +// paint->setPen(midColour); + paint->setPen(baseColour); + paint->drawLine(x-1, prevRangeTop, x, rangeBottom + 1); + paint->setPen(prevRangeTopColour); + paint->drawPoint(x-1, prevRangeTop); + } else if (prevRangeBottom < rangeTop - 1 && + prevRangeTop < rangeTop - 1) { +// paint->setPen(midColour); + paint->setPen(baseColour); + paint->drawLine(x-1, prevRangeBottom, x, rangeTop - 1); + paint->setPen(prevRangeBottomColour); + paint->drawPoint(x-1, prevRangeBottom); + } + } - if (ready) { - if (clipped /*!!! || - range.min() * gain <= -1.0 || - range.max() * gain >= 1.0 */) { - paint->setPen(Qt::red); //!!! getContrastingColour - } else { - paint->setPen(baseColour); - } - } else { - paint->setPen(midColour); - } + if (ready) { + if (clipped /*!!! || + range.min() * gain <= -1.0 || + range.max() * gain >= 1.0 */) { + paint->setPen(Qt::red); //!!! getContrastingColour + } else { + paint->setPen(baseColour); + } + } else { + paint->setPen(midColour); + } #ifdef DEBUG_WAVEFORM_PAINT cerr << "range " << rangeBottom << " -> " << rangeTop << ", means " << meanBottom << " -> " << meanTop << ", raw range " << range.min() << " -> " << range.max() << endl; @@ -910,36 +910,36 @@ paint->drawLine(x, rangeBottom, x, rangeTop); } - prevRangeTopColour = baseColour; - prevRangeBottomColour = baseColour; + prevRangeTopColour = baseColour; + prevRangeBottomColour = baseColour; - if (m_greyscale && (m_scale == LinearScale) && ready) { - if (!clipped) { - if (rangeTop < rangeBottom) { - if (topFill > 0 && - (!drawMean || (rangeTop < meanTop - 1))) { - paint->setPen(greys[topFill - 1]); - paint->drawPoint(x, rangeTop); - prevRangeTopColour = greys[topFill - 1]; - } - if (bottomFill > 0 && - (!drawMean || (rangeBottom > meanBottom + 1))) { - paint->setPen(greys[bottomFill - 1]); - paint->drawPoint(x, rangeBottom); - prevRangeBottomColour = greys[bottomFill - 1]; - } - } - } - } + if (m_greyscale && (m_scale == LinearScale) && ready) { + if (!clipped) { + if (rangeTop < rangeBottom) { + if (topFill > 0 && + (!drawMean || (rangeTop < meanTop - 1))) { + paint->setPen(greys[topFill - 1]); + paint->drawPoint(x, rangeTop); + prevRangeTopColour = greys[topFill - 1]; + } + if (bottomFill > 0 && + (!drawMean || (rangeBottom > meanBottom + 1))) { + paint->setPen(greys[bottomFill - 1]); + paint->drawPoint(x, rangeBottom); + prevRangeBottomColour = greys[bottomFill - 1]; + } + } + } + } - if (drawMean) { - paint->setPen(midColour); - paint->drawLine(x, meanBottom, x, meanTop); - } + if (drawMean) { + paint->setPen(midColour); + paint->drawLine(x, meanBottom, x, meanTop); + } - prevRangeBottom = rangeBottom; - prevRangeTop = rangeTop; - } + prevRangeBottom = rangeBottom; + prevRangeTop = rangeTop; + } } if (m_middleLineHeight != 0.5) { @@ -948,13 +948,13 @@ if (m_aggressive) { - if (ready && rect == v->getPaintRect()) { - m_cacheValid = true; - m_cacheZoomLevel = zoomLevel; - } - paint->end(); - delete paint; - viewPainter.drawPixmap(rect, *m_cache, rect); + if (ready && rect == v->getPaintRect()) { + m_cacheValid = true; + m_cacheZoomLevel = zoomLevel; + } + paint->end(); + delete paint; + viewPainter.drawPixmap(rect, *m_cache, rect); } if (otherChannelRanges != ranges) delete otherChannelRanges; @@ -981,12 +981,12 @@ RealTime rt1 = RealTime::frame2RealTime(f1, m_model->getSampleRate()); if (f1 != f0 + 1 && (rt0.sec != rt1.sec || rt0.msec() != rt1.msec())) { - text += tr("Time:\t%1 - %2") - .arg(rt0.toText(true).c_str()) - .arg(rt1.toText(true).c_str()); + text += tr("Time:\t%1 - %2") + .arg(rt0.toText(true).c_str()) + .arg(rt1.toText(true).c_str()); } else { - text += tr("Time:\t%1") - .arg(rt0.toText(true).c_str()); + text += tr("Time:\t%1") + .arg(rt0.toText(true).c_str()); } int channels = 0, minChannel = 0, maxChannel = 0; @@ -998,20 +998,20 @@ for (int ch = minChannel; ch <= maxChannel; ++ch) { - int blockSize = v->getZoomLevel(); - RangeSummarisableTimeValueModel::RangeBlock ranges; + int blockSize = v->getZoomLevel(); + RangeSummarisableTimeValueModel::RangeBlock ranges; m_model->getSummaries(ch, f0, f1 - f0, ranges, blockSize); - if (ranges.empty()) continue; - - RangeSummarisableTimeValueModel::Range range = ranges[0]; - - QString label = tr("Level:"); - if (minChannel != maxChannel) { - if (ch == 0) label = tr("Left:"); - else if (ch == 1) label = tr("Right:"); - else label = tr("Channel %1").arg(ch + 1); - } + if (ranges.empty()) continue; + + RangeSummarisableTimeValueModel::Range range = ranges[0]; + + QString label = tr("Level:"); + if (minChannel != maxChannel) { + if (ch == 0) label = tr("Left:"); + else if (ch == 1) label = tr("Right:"); + else label = tr("Channel %1").arg(ch + 1); + } bool singleValue = false; double min, max; @@ -1028,17 +1028,17 @@ max = double(imax)/10000; } - int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()), - fabsf(range.max()))) - * 100); + int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()), + fabsf(range.max()))) + * 100); - if (!singleValue) { - text += tr("\n%1\t%2 - %3 (%4 dB peak)") - .arg(label).arg(min).arg(max).arg(double(db)/100); - } else { - text += tr("\n%1\t%2 (%3 dB peak)") - .arg(label).arg(min).arg(double(db)/100); - } + if (!singleValue) { + text += tr("\n%1\t%2 - %3 (%4 dB peak)") + .arg(label).arg(min).arg(max).arg(double(db)/100); + } else { + text += tr("\n%1\t%2 (%3 dB peak)") + .arg(label).arg(min).arg(double(db)/100); + } } return text; @@ -1057,7 +1057,7 @@ int h = v->getPaintHeight(); int m = (h / channels) / 2; - + if ((m_scale == dBScale || m_scale == MeterScale) && m_channelMode != MergeChannels) { m = (h / channels); @@ -1201,10 +1201,10 @@ WaveformLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const { if (m_scale == LinearScale) { - return paint.fontMetrics().width("0.0") + 13; + return paint.fontMetrics().width("0.0") + 13; } else { - return std::max(paint.fontMetrics().width(tr("0dB")), - paint.fontMetrics().width(Strings::minus_infinity)) + 13; + return std::max(paint.fontMetrics().width(tr("0dB")), + paint.fontMetrics().width(Strings::minus_infinity)) + 13; } } @@ -1212,7 +1212,7 @@ WaveformLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const { if (!m_model || !m_model->isOK()) { - return; + return; } int channels = 0, minChannel = 0, maxChannel = 0; @@ -1230,23 +1230,23 @@ for (int ch = minChannel; ch <= maxChannel; ++ch) { - int lastLabelledY = -1; + int lastLabelledY = -1; if (ch < (int)m_effectiveGains.size()) gain = m_effectiveGains[ch]; int n = 10; - for (int i = 0; i <= n; ++i) { + for (int i = 0; i <= n; ++i) { double val = 0.0, nval = 0.0; - QString text = ""; + QString text = ""; switch (m_scale) { case LinearScale: val = (i * gain) / n; - text = QString("%1").arg(double(i) / n); - if (i == 0) text = "0.0"; + text = QString("%1").arg(double(i) / n); + if (i == 0) text = "0.0"; else { nval = -val; if (i == n) text = "1.0"; @@ -1255,22 +1255,22 @@ case MeterScale: val = AudioLevel::dB_to_multiplier(meterdbs[i]) * gain; - text = QString("%1").arg(meterdbs[i]); - if (i == n) text = tr("0dB"); - if (i == 0) { + text = QString("%1").arg(meterdbs[i]); + if (i == n) text = tr("0dB"); + if (i == 0) { text = Strings::minus_infinity; val = 0.0; - } + } break; case dBScale: val = AudioLevel::dB_to_multiplier(-(10*n) + i * 10) * gain; - text = QString("%1").arg(-(10*n) + i * 10); - if (i == n) text = tr("0dB"); - if (i == 0) { + text = QString("%1").arg(-(10*n) + i * 10); + if (i == n) text = tr("0dB"); + if (i == 0) { text = Strings::minus_infinity; val = 0.0; - } + } break; } @@ -1325,7 +1325,7 @@ paint.drawLine(w - 4, y, w, y); if (ny != y) paint.drawLine(w - 4, ny, w, ny); } - } + } } } @@ -1340,22 +1340,22 @@ (m_colour, colourName, colourSpec, darkbg); s += QString("gain=\"%1\" " - "showMeans=\"%2\" " - "greyscale=\"%3\" " - "channelMode=\"%4\" " - "channel=\"%5\" " + "showMeans=\"%2\" " + "greyscale=\"%3\" " + "channelMode=\"%4\" " + "channel=\"%5\" " "scale=\"%6\" " "middleLineHeight=\"%7\" " - "aggressive=\"%8\" " + "aggressive=\"%8\" " "autoNormalize=\"%9\"") - .arg(m_gain) - .arg(m_showMeans) - .arg(m_greyscale) - .arg(m_channelMode) - .arg(m_channel) - .arg(m_scale) + .arg(m_gain) + .arg(m_showMeans) + .arg(m_greyscale) + .arg(m_channelMode) + .arg(m_channel) + .arg(m_scale) .arg(m_middleLineHeight) - .arg(m_aggressive) + .arg(m_aggressive) .arg(m_autoNormalize); SingleColourLayer::toXml(stream, indent, extraAttributes + " " + s); @@ -1372,15 +1372,15 @@ if (ok) setGain(gain); bool showMeans = (attributes.value("showMeans") == "1" || - attributes.value("showMeans") == "true"); + attributes.value("showMeans") == "true"); setShowMeans(showMeans); bool greyscale = (attributes.value("greyscale") == "1" || - attributes.value("greyscale") == "true"); + attributes.value("greyscale") == "true"); setUseGreyscale(greyscale); ChannelMode channelMode = (ChannelMode) - attributes.value("channelMode").toInt(&ok); + attributes.value("channelMode").toInt(&ok); if (ok) setChannelMode(channelMode); int channel = attributes.value("channel").toInt(&ok); @@ -1393,7 +1393,7 @@ if (ok) setMiddleLineHeight(middleLineHeight); bool aggressive = (attributes.value("aggressive") == "1" || - attributes.value("aggressive") == "true"); + attributes.value("aggressive") == "true"); setUseGreyscale(aggressive); bool autoNormalize = (attributes.value("autoNormalize") == "1" ||
--- a/layer/WaveformLayer.h Thu Mar 01 14:43:53 2018 +0000 +++ b/layer/WaveformLayer.h Thu Mar 01 18:02:22 2018 +0000 @@ -59,7 +59,7 @@ virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; virtual void setProperty(const PropertyName &, int value);
--- a/view/AlignmentView.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/view/AlignmentView.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -43,10 +43,10 @@ { View::viewCentreFrameChanged(v, f); if (v == m_above) { - m_centreFrame = f; - update(); + m_centreFrame = f; + update(); } else if (v == m_below) { - update(); + update(); } } @@ -73,16 +73,16 @@ AlignmentView::setViewAbove(View *v) { if (m_above) { - disconnect(m_above, 0, this, 0); + disconnect(m_above, 0, this, 0); } m_above = v; if (m_above) { - connect(m_above, - SIGNAL(zoomLevelChanged(int, bool)), - this, - SLOT(viewAboveZoomLevelChanged(int, bool))); + connect(m_above, + SIGNAL(zoomLevelChanged(int, bool)), + this, + SLOT(viewAboveZoomLevelChanged(int, bool))); } } @@ -90,16 +90,16 @@ AlignmentView::setViewBelow(View *v) { if (m_below) { - disconnect(m_below, 0, this, 0); + disconnect(m_below, 0, this, 0); } m_below = v; if (m_below) { - connect(m_below, - SIGNAL(zoomLevelChanged(int, bool)), - this, - SLOT(viewBelowZoomLevelChanged(int, bool))); + connect(m_below, + SIGNAL(zoomLevelChanged(int, bool)), + this, + SLOT(viewBelowZoomLevelChanged(int, bool))); } } @@ -130,11 +130,11 @@ vector<sv_frame_t> keyFrames = getKeyFrames(); foreach (sv_frame_t f, keyFrames) { - int ax = m_above->getXForFrame(f); - sv_frame_t rf = m_above->alignToReference(f); - sv_frame_t bf = m_below->alignFromReference(rf); - int bx = m_below->getXForFrame(bf); - paint.drawLine(ax, 0, bx, height()); + int ax = m_above->getXForFrame(f); + sv_frame_t rf = m_above->alignToReference(f); + sv_frame_t bf = m_below->alignFromReference(rf); + int bx = m_below->getXForFrame(bf); + paint.drawLine(ax, 0, bx, height()); } paint.end(); @@ -144,31 +144,31 @@ AlignmentView::getKeyFrames() { if (!m_above) { - return getDefaultKeyFrames(); + return getDefaultKeyFrames(); } SparseOneDimensionalModel *m = 0; // get the topmost such for (int i = 0; i < m_above->getLayerCount(); ++i) { - if (qobject_cast<TimeInstantLayer *>(m_above->getLayer(i))) { - SparseOneDimensionalModel *mm = - qobject_cast<SparseOneDimensionalModel *> - (m_above->getLayer(i)->getModel()); - if (mm) m = mm; - } + if (qobject_cast<TimeInstantLayer *>(m_above->getLayer(i))) { + SparseOneDimensionalModel *mm = + qobject_cast<SparseOneDimensionalModel *> + (m_above->getLayer(i)->getModel()); + if (mm) m = mm; + } } if (!m) { - return getDefaultKeyFrames(); + return getDefaultKeyFrames(); } vector<sv_frame_t> keyFrames; const SparseOneDimensionalModel::PointList pp = m->getPoints(); for (SparseOneDimensionalModel::PointList::const_iterator pi = pp.begin(); - pi != pp.end(); ++pi) { - keyFrames.push_back(pi->frame); + pi != pp.end(); ++pi) { + keyFrames.push_back(pi->frame); } return keyFrames; @@ -185,9 +185,9 @@ if (rate == 0) return keyFrames; for (sv_frame_t f = m_above->getModelsStartFrame(); - f <= m_above->getModelsEndFrame(); - f += sv_frame_t(rate * 5 + 0.5)) { - keyFrames.push_back(f); + f <= m_above->getModelsEndFrame(); + f += sv_frame_t(rate * 5 + 0.5)) { + keyFrames.push_back(f); } return keyFrames;
--- a/view/Overview.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/view/Overview.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -50,7 +50,7 @@ int zoomLevel = int(frameCount / width()); if (zoomLevel < 1) zoomLevel = 1; zoomLevel = getZoomConstraintBlockSize(zoomLevel, - ZoomConstraint::RoundUp); + ZoomConstraint::RoundUp); if (zoomLevel != m_zoomLevel) { zoomChanged = true; } @@ -118,7 +118,7 @@ cerr << "Overview[" << this << "]::viewCentreFrameChanged(" << v << "): " << f << endl; #endif if (m_views.find(v) != m_views.end()) { - update(); + update(); } } @@ -127,7 +127,7 @@ { if (v == this) return; if (m_views.find(v) != m_views.end()) { - update(); + update(); } } @@ -182,26 +182,26 @@ int zoomLevel = int(frameCount / width()); if (zoomLevel < 1) zoomLevel = 1; zoomLevel = getZoomConstraintBlockSize(zoomLevel, - ZoomConstraint::RoundUp); + ZoomConstraint::RoundUp); if (zoomLevel != m_zoomLevel) { - m_zoomLevel = zoomLevel; - emit zoomLevelChanged(m_zoomLevel, m_followZoom); + m_zoomLevel = zoomLevel; + emit zoomLevelChanged(m_zoomLevel, m_followZoom); } sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); if (centreFrame > (startFrame + getModelsEndFrame())/2) { - centreFrame = (startFrame + getModelsEndFrame())/2; + centreFrame = (startFrame + getModelsEndFrame())/2; } if (centreFrame != m_centreFrame) { #ifdef DEBUG_OVERVIEW cerr << "Overview::paintEvent: Centre frame changed from " << m_centreFrame << " to " << centreFrame << " and thus start frame from " << getStartFrame(); #endif - m_centreFrame = centreFrame; + m_centreFrame = centreFrame; #ifdef DEBUG_OVERVIEW cerr << " to " << getStartFrame() << endl; #endif - emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); + emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); } View::paintEvent(e); @@ -224,12 +224,12 @@ int y = 0; for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { - if (!*i) continue; + if (!*i) continue; - View *w = (View *)*i; + View *w = (View *)*i; - sv_frame_t f0 = w->getFrameForX(0); - sv_frame_t f1 = w->getFrameForX(w->width()); + sv_frame_t f0 = w->getFrameForX(0); + sv_frame_t f1 = w->getFrameForX(w->width()); if (f0 >= 0) { sv_frame_t rf0 = w->alignToReference(f0); @@ -240,16 +240,16 @@ f1 = alignFromReference(rf1); } - int x0 = getXForFrame(f0); - int x1 = getXForFrame(f1); + int x0 = getXForFrame(f0); + int x1 = getXForFrame(f1); - if (x1 <= x0) x1 = x0 + 1; + if (x1 <= x0) x1 = x0 + 1; std::pair<int, int> extent(x0, x1); if (extents.find(extent) == extents.end()) { - y += height() / 10 + 1; + y += height() / 10 + 1; extents.insert(extent); QRect vr(x0, y, x1 - x0, height() - 2 * y); @@ -287,7 +287,7 @@ m_clickedInRange = true; for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { - if (*i && (*i)->getAligningModel() == getAligningModel()) { + if (*i && (*i)->getAligningModel() == getAligningModel()) { m_dragCentreFrame = (*i)->getCentreFrame(); break; } @@ -298,7 +298,7 @@ Overview::mouseReleaseEvent(QMouseEvent *e) { if (m_clickedInRange) { - mouseMoveEvent(e); + mouseMoveEvent(e); } m_clickedInRange = false; } @@ -313,20 +313,20 @@ sv_frame_t newCentreFrame = m_dragCentreFrame; if (frameOff > 0) { - newCentreFrame += frameOff; + newCentreFrame += frameOff; } else if (newCentreFrame >= -frameOff) { - newCentreFrame += frameOff; + newCentreFrame += frameOff; } else { - newCentreFrame = 0; + newCentreFrame = 0; } if (newCentreFrame >= getModelsEndFrame()) { - newCentreFrame = getModelsEndFrame(); - if (newCentreFrame > 0) --newCentreFrame; + newCentreFrame = getModelsEndFrame(); + if (newCentreFrame > 0) --newCentreFrame; } if (std::max(m_centreFrame, newCentreFrame) - - std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { + std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { sv_frame_t rf = alignToReference(newCentreFrame); #ifdef DEBUG_OVERVIEW cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl;
--- a/view/Pane.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/view/Pane.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -1892,11 +1892,11 @@ } double ratio = double(w) / double(width()); -// cerr << "ratio: " << ratio << endl; +// cerr << "ratio: " << ratio << endl; int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); if (newZoomLevel < 1) newZoomLevel = 1; -// cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; +// cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << endl; setZoomLevel(getZoomConstraintBlockSize(newZoomLevel)); setStartFrame(newStartFrame); @@ -2116,8 +2116,8 @@ layer->snapToFeatureFrame(this, snapFrameRight, resolution, Layer::SnapRight); } - -// cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; + +// cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << endl; if (snapFrameLeft < 0) snapFrameLeft = 0; if (snapFrameRight < 0) snapFrameRight = 0;
--- a/view/Pane.h Thu Mar 01 14:43:53 2018 +0000 +++ b/view/Pane.h Thu Mar 01 18:02:22 2018 +0000 @@ -40,10 +40,10 @@ virtual QString getPropertyContainerIconName() const override { return "pane"; } virtual bool shouldIlluminateLocalFeatures(const Layer *layer, - QPoint &pos) const override; + QPoint &pos) const override; virtual bool shouldIlluminateLocalSelection(QPoint &pos, - bool &closeToLeft, - bool &closeToRight) const override; + bool &closeToLeft, + bool &closeToRight) const override; void setCentreLineVisible(bool visible); bool getCentreLineVisible() const { return m_centreLineVisible; }
--- a/view/PaneStack.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/view/PaneStack.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -131,11 +131,11 @@ QWidget *properties = 0; if (suppressPropertyBox) { - properties = new QFrame(); + properties = new QFrame(); } else { - properties = new PropertyStack(frame, pane); - connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), - this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); + properties = new PropertyStack(frame, pane); + connect(properties, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), + this, SLOT(propertyContainerSelected(View *, PropertyContainer *))); connect(properties, SIGNAL(viewSelected(View *)), this, SLOT(viewSelected(View *))); connect(properties, SIGNAL(contextHelpChanged(const QString &)), @@ -163,11 +163,11 @@ m_splitter->insertWidget(index, frame); connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), - this, SLOT(propertyContainerAdded(PropertyContainer *))); + this, SLOT(propertyContainerAdded(PropertyContainer *))); connect(pane, SIGNAL(propertyContainerRemoved(PropertyContainer *)), - this, SLOT(propertyContainerRemoved(PropertyContainer *))); + this, SLOT(propertyContainerRemoved(PropertyContainer *))); connect(pane, SIGNAL(paneInteractedWith()), - this, SLOT(paneInteractedWith())); + this, SLOT(paneInteractedWith())); connect(pane, SIGNAL(rightButtonMenuRequested(QPoint)), this, SLOT(rightButtonMenuRequested(QPoint))); connect(pane, SIGNAL(dropAccepted(QStringList)), @@ -181,7 +181,7 @@ emit paneAdded(); if (!m_currentPane) { - setCurrentPane(pane); + setCurrentPane(pane); } showOrHidePaneAccessories(); @@ -294,29 +294,29 @@ QWidget *stack = 0; for (i = m_panes.begin(); i != m_panes.end(); ++i) { - if (i->pane == pane) { + if (i->pane == pane) { stack = i->propertyStack; - m_panes.erase(i); - found = true; - break; - } + m_panes.erase(i); + found = true; + break; + } } if (!found) { - for (i = m_hiddenPanes.begin(); i != m_hiddenPanes.end(); ++i) { - if (i->pane == pane) { + for (i = m_hiddenPanes.begin(); i != m_hiddenPanes.end(); ++i) { + if (i->pane == pane) { stack = i->propertyStack; - m_hiddenPanes.erase(i); - found = true; - break; - } - } + m_hiddenPanes.erase(i); + found = true; + break; + } + } - if (!found) { - cerr << "WARNING: PaneStack::deletePane(" << pane << "): Pane not found in visible or hidden panes, not deleting" << endl; - return; - } + if (!found) { + cerr << "WARNING: PaneStack::deletePane(" << pane << "): Pane not found in visible or hidden panes, not deleting" << endl; + return; + } } emit paneAboutToBeDeleted(pane); @@ -337,11 +337,11 @@ delete pane->parent(); if (m_currentPane == pane) { - if (m_panes.size() > 0) { + if (m_panes.size() > 0) { setCurrentPane(m_panes[0].pane); - } else { - setCurrentPane(0); - } + } else { + setCurrentPane(0); + } } showOrHidePaneAccessories(); @@ -381,28 +381,28 @@ std::vector<PaneRec>::iterator i = m_panes.begin(); while (i != m_panes.end()) { - if (i->pane == pane) { + if (i->pane == pane) { - m_hiddenPanes.push_back(*i); - m_panes.erase(i); + m_hiddenPanes.push_back(*i); + m_panes.erase(i); - QWidget *pw = dynamic_cast<QWidget *>(pane->parent()); - if (pw) pw->hide(); + QWidget *pw = dynamic_cast<QWidget *>(pane->parent()); + if (pw) pw->hide(); - if (m_currentPane == pane) { - if (m_panes.size() > 0) { - setCurrentPane(m_panes[0].pane); - } else { - setCurrentPane(0); - } - } - + if (m_currentPane == pane) { + if (m_panes.size() > 0) { + setCurrentPane(m_panes[0].pane); + } else { + setCurrentPane(0); + } + } + showOrHidePaneAccessories(); emit paneHidden(pane); emit paneHidden(); - return; - } - ++i; + return; + } + ++i; } relinkAlignmentViews(); @@ -416,19 +416,19 @@ std::vector<PaneRec>::iterator i = m_hiddenPanes.begin(); while (i != m_hiddenPanes.end()) { - if (i->pane == pane) { - m_panes.push_back(*i); - m_hiddenPanes.erase(i); - QWidget *pw = dynamic_cast<QWidget *>(pane->parent()); - if (pw) pw->show(); + if (i->pane == pane) { + m_panes.push_back(*i); + m_hiddenPanes.erase(i); + QWidget *pw = dynamic_cast<QWidget *>(pane->parent()); + if (pw) pw->show(); - //!!! update current pane + //!!! update current pane showOrHidePaneAccessories(); - return; - } - ++i; + return; + } + ++i; } relinkAlignmentViews(); @@ -456,23 +456,23 @@ bool found = false; while (i != m_panes.end()) { - if (i->pane == pane) { - i->currentIndicator->setPixmap(selectedMap); + if (i->pane == pane) { + i->currentIndicator->setPixmap(selectedMap); if (m_layoutStyle != PropertyStackPerPaneLayout) { m_propertyStackStack->setCurrentWidget(i->propertyStack); } - found = true; - } else { - i->currentIndicator->setPixmap(unselectedMap); - } - ++i; + found = true; + } else { + i->currentIndicator->setPixmap(unselectedMap); + } + ++i; } if (found || pane == 0) { - m_currentPane = pane; - emit currentPaneChanged(m_currentPane); + m_currentPane = pane; + emit currentPaneChanged(m_currentPane); } else { - cerr << "WARNING: PaneStack::setCurrentPane(" << pane << "): pane is not a visible pane in this stack" << endl; + cerr << "WARNING: PaneStack::setCurrentPane(" << pane << "): pane is not a visible pane in this stack" << endl; } } @@ -483,28 +483,28 @@ if (m_currentPane) { - std::vector<PaneRec>::iterator i = m_panes.begin(); + std::vector<PaneRec>::iterator i = m_panes.begin(); - while (i != m_panes.end()) { + while (i != m_panes.end()) { - if (i->pane == pane) { - PropertyStack *stack = dynamic_cast<PropertyStack *> - (i->propertyStack); - if (stack) { - if (stack->containsContainer(layer)) { - stack->setCurrentIndex(stack->getContainerIndex(layer)); - emit currentLayerChanged(pane, layer); - } else { - stack->setCurrentIndex - (stack->getContainerIndex - (pane->getPropertyContainer(0))); - emit currentLayerChanged(pane, 0); - } - } - break; - } - ++i; - } + if (i->pane == pane) { + PropertyStack *stack = dynamic_cast<PropertyStack *> + (i->propertyStack); + if (stack) { + if (stack->containsContainer(layer)) { + stack->setCurrentIndex(stack->getContainerIndex(layer)); + emit currentLayerChanged(pane, layer); + } else { + stack->setCurrentIndex + (stack->getContainerIndex + (pane->getPropertyContainer(0))); + emit currentLayerChanged(pane, 0); + } + } + break; + } + ++i; + } } } @@ -532,14 +532,14 @@ std::vector<PaneRec>::iterator i = m_panes.begin(); while (i != m_panes.end()) { - PropertyStack *stack = dynamic_cast<PropertyStack *>(i->propertyStack); - if (stack && - stack->getClient() == client && - stack->containsContainer(pc)) { - setCurrentPane(i->pane); - break; - } - ++i; + PropertyStack *stack = dynamic_cast<PropertyStack *>(i->propertyStack); + if (stack && + stack->getClient() == client && + stack->containsContainer(pc)) { + setCurrentPane(i->pane); + break; + } + ++i; } Layer *layer = dynamic_cast<Layer *>(pc); @@ -578,17 +578,17 @@ if (m_propertyStackMinWidth > 0) maxMinWidth = m_propertyStackMinWidth; for (int i = 0; i < (int)m_panes.size(); ++i) { - if (!m_panes[i].propertyStack) continue; + if (!m_panes[i].propertyStack) continue; #ifdef DEBUG_PANE_STACK - SVDEBUG << "PaneStack::sizePropertyStacks: " << i << ": min " - << m_panes[i].propertyStack->minimumSizeHint().width() << ", hint " + SVDEBUG << "PaneStack::sizePropertyStacks: " << i << ": min " + << m_panes[i].propertyStack->minimumSizeHint().width() << ", hint " << m_panes[i].propertyStack->sizeHint().width() << ", current " - << m_panes[i].propertyStack->width() << endl; + << m_panes[i].propertyStack->width() << endl; #endif - if (m_panes[i].propertyStack->sizeHint().width() > maxMinWidth) { - maxMinWidth = m_panes[i].propertyStack->sizeHint().width(); - } + if (m_panes[i].propertyStack->sizeHint().width() > maxMinWidth) { + maxMinWidth = m_panes[i].propertyStack->sizeHint().width(); + } } #ifdef DEBUG_PANE_STACK @@ -600,8 +600,8 @@ m_propertyStackStack->setMaximumWidth(setWidth + 10); for (int i = 0; i < (int)m_panes.size(); ++i) { - if (!m_panes[i].propertyStack) continue; - m_panes[i].propertyStack->setMinimumWidth(setWidth); + if (!m_panes[i].propertyStack) continue; + m_panes[i].propertyStack->setMinimumWidth(setWidth); } emit propertyStacksResized(setWidth); @@ -627,7 +627,7 @@ { QObject *s = sender(); for (int i = 0; i < (int)m_panes.size(); ++i) { - if (m_panes[i].xButton == s) { + if (m_panes[i].xButton == s) { emit paneDeleteButtonClicked(m_panes[i].pane); } } @@ -639,7 +639,7 @@ QObject *s = sender(); for (int i = 0; i < (int)m_panes.size(); ++i) { - if (m_panes[i].currentIndicator == s) { + if (m_panes[i].currentIndicator == s) { setCurrentPane(m_panes[i].pane); return; }
--- a/view/PaneStack.h Thu Mar 01 14:43:53 2018 +0000 +++ b/view/PaneStack.h Thu Mar 01 18:02:22 2018 +0000 @@ -117,10 +117,10 @@ struct PaneRec { - Pane *pane; - QWidget *propertyStack; + Pane *pane; + QWidget *propertyStack; QPushButton *xButton; - QLabel *currentIndicator; + QLabel *currentIndicator; QFrame *frame; QGridLayout *layout; AlignmentView *alignmentView;
--- a/view/View.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/view/View.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -114,14 +114,14 @@ int View::getPropertyRangeAndValue(const PropertyContainer::PropertyName &name, - int *min, int *max, int *deflt) const + int *min, int *max, int *deflt) const { if (deflt) *deflt = 1; if (name == "Global Scroll") return m_followPan; if (name == "Global Zoom") return m_followZoom; if (name == "Follow Playback") { - if (min) *min = 0; - if (max) *max = 2; + if (min) *min = 0; + if (max) *max = 2; if (deflt) *deflt = int(PlaybackScrollPageWithCentre); switch (m_followPlay) { case PlaybackScrollContinuous: return 0; @@ -137,15 +137,15 @@ QString View::getPropertyValueLabel(const PropertyContainer::PropertyName &name, - int value) const + int value) const { if (name == "Follow Playback") { - switch (value) { - default: - case 0: return tr("Scroll"); - case 1: return tr("Page"); - case 2: return tr("Off"); - } + switch (value) { + default: + case 0: return tr("Scroll"); + case 1: return tr("Page"); + case 2: return tr("Off"); + } } return tr("<unknown>"); } @@ -154,16 +154,16 @@ View::setProperty(const PropertyContainer::PropertyName &name, int value) { if (name == "Global Scroll") { - setFollowGlobalPan(value != 0); + setFollowGlobalPan(value != 0); } else if (name == "Global Zoom") { - setFollowGlobalZoom(value != 0); + setFollowGlobalZoom(value != 0); } else if (name == "Follow Playback") { - switch (value) { - default: - case 0: setPlaybackFollow(PlaybackScrollContinuous); break; - case 1: setPlaybackFollow(PlaybackScrollPageWithCentre); break; - case 2: setPlaybackFollow(PlaybackIgnore); break; - } + switch (value) { + default: + case 0: setPlaybackFollow(PlaybackScrollContinuous); break; + case 1: setPlaybackFollow(PlaybackScrollPageWithCentre); break; + case 2: setPlaybackFollow(PlaybackIgnore); break; + } } } @@ -177,7 +177,7 @@ View::getPropertyContainer(int i) const { return (const PropertyContainer *)(((View *)this)-> - getPropertyContainer(i)); + getPropertyContainer(i)); } PropertyContainer * @@ -253,11 +253,11 @@ if (client != this) return; if (pc == m_propertyContainer) { - if (m_haveSelectedLayer) { - m_haveSelectedLayer = false; - update(); - } - return; + if (m_haveSelectedLayer) { + m_haveSelectedLayer = false; + update(); + } + return; } delete m_cache; @@ -266,19 +266,19 @@ Layer *selectedLayer = 0; for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if (*i == pc) { - selectedLayer = *i; - m_layerStack.erase(i); - break; - } + if (*i == pc) { + selectedLayer = *i; + m_layerStack.erase(i); + break; + } } if (selectedLayer) { - m_haveSelectedLayer = true; - m_layerStack.push_back(selectedLayer); - update(); + m_haveSelectedLayer = true; + m_layerStack.push_back(selectedLayer); + update(); } else { - m_haveSelectedLayer = false; + m_haveSelectedLayer = false; } emit propertyContainerSelected(pc); @@ -329,23 +329,23 @@ if (m_centreFrame != f) { - int formerPixel = int(m_centreFrame / m_zoomLevel); - - m_centreFrame = f; - - int newPixel = int(m_centreFrame / m_zoomLevel); - - if (newPixel != formerPixel) { + int formerPixel = int(m_centreFrame / m_zoomLevel); + + m_centreFrame = f; + + int newPixel = int(m_centreFrame / m_zoomLevel); + + if (newPixel != formerPixel) { #ifdef DEBUG_VIEW_WIDGET_PAINT - cout << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; + cout << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; #endif - update(); - - changeVisible = true; - } - - if (e) { + update(); + + changeVisible = true; + } + + if (e) { sv_frame_t rf = alignToReference(f); #ifdef DEBUG_VIEW cerr << "View[" << this << "]::setCentreFrame(" << f @@ -383,9 +383,9 @@ double View::getYForFrequency(double frequency, - double minf, - double maxf, - bool logarithmic) const + double minf, + double maxf, + bool logarithmic) const { Profiler profiler("View::getYForFrequency"); @@ -393,57 +393,57 @@ if (logarithmic) { - static double lastminf = 0.0, lastmaxf = 0.0; - static double logminf = 0.0, logmaxf = 0.0; - - if (lastminf != minf) { - lastminf = (minf == 0.0 ? 1.0 : minf); - logminf = log10(minf); - } - if (lastmaxf != maxf) { - lastmaxf = (maxf < lastminf ? lastminf : maxf); - logmaxf = log10(maxf); - } - - if (logminf == logmaxf) return 0; - return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf); + static double lastminf = 0.0, lastmaxf = 0.0; + static double logminf = 0.0, logmaxf = 0.0; + + if (lastminf != minf) { + lastminf = (minf == 0.0 ? 1.0 : minf); + logminf = log10(minf); + } + if (lastmaxf != maxf) { + lastmaxf = (maxf < lastminf ? lastminf : maxf); + logmaxf = log10(maxf); + } + + if (logminf == logmaxf) return 0; + return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf); } else { - - if (minf == maxf) return 0; - return h - (h * (frequency - minf)) / (maxf - minf); + + if (minf == maxf) return 0; + return h - (h * (frequency - minf)) / (maxf - minf); } } double View::getFrequencyForY(double y, - double minf, - double maxf, - bool logarithmic) const + double minf, + double maxf, + bool logarithmic) const { double h = height(); if (logarithmic) { - static double lastminf = 0.0, lastmaxf = 0.0; - static double logminf = 0.0, logmaxf = 0.0; - - if (lastminf != minf) { - lastminf = (minf == 0.0 ? 1.0 : minf); - logminf = log10(minf); - } - if (lastmaxf != maxf) { - lastmaxf = (maxf < lastminf ? lastminf : maxf); - logmaxf = log10(maxf); - } - - if (logminf == logmaxf) return 0; - return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h); + static double lastminf = 0.0, lastmaxf = 0.0; + static double logminf = 0.0, logmaxf = 0.0; + + if (lastminf != minf) { + lastminf = (minf == 0.0 ? 1.0 : minf); + logminf = log10(minf); + } + if (lastmaxf != maxf) { + lastmaxf = (maxf < lastminf ? lastminf : maxf); + logmaxf = log10(maxf); + } + + if (logminf == logmaxf) return 0; + return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h); } else { - if (minf == maxf) return 0; - return minf + ((h - y) * (maxf - minf)) / h; + if (minf == maxf) return 0; + return minf + ((h - y) * (maxf - minf)) / h; } } @@ -451,7 +451,7 @@ View::getZoomLevel() const { #ifdef DEBUG_VIEW_WIDGET_PAINT -// cout << "zoom level: " << m_zoomLevel << endl; +// cout << "zoom level: " << m_zoomLevel << endl; #endif return m_zoomLevel; } @@ -482,9 +482,9 @@ if (z < dpratio) return; if (z < 1) z = 1; if (m_zoomLevel != int(z)) { - m_zoomLevel = z; - emit zoomLevelChanged(z, m_followZoom); - update(); + m_zoomLevel = z; + emit zoomLevelChanged(z, m_followZoom); + update(); } } @@ -596,23 +596,23 @@ pb->hide(); connect(layer, SIGNAL(layerParametersChanged()), - this, SLOT(layerParametersChanged())); + this, SLOT(layerParametersChanged())); connect(layer, SIGNAL(layerParameterRangesChanged()), - this, SLOT(layerParameterRangesChanged())); + this, SLOT(layerParameterRangesChanged())); connect(layer, SIGNAL(layerMeasurementRectsChanged()), - this, SLOT(layerMeasurementRectsChanged())); + this, SLOT(layerMeasurementRectsChanged())); connect(layer, SIGNAL(layerNameChanged()), - this, SLOT(layerNameChanged())); + this, SLOT(layerNameChanged())); connect(layer, SIGNAL(modelChanged()), - this, SLOT(modelChanged())); + this, SLOT(modelChanged())); connect(layer, SIGNAL(modelCompletionChanged()), - this, SLOT(modelCompletionChanged())); + this, SLOT(modelCompletionChanged())); connect(layer, SIGNAL(modelAlignmentCompletionChanged()), - this, SLOT(modelAlignmentCompletionChanged())); + this, SLOT(modelAlignmentCompletionChanged())); connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), - this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(layer, SIGNAL(modelReplaced()), - this, SLOT(modelReplaced())); + this, SLOT(modelReplaced())); update(); @@ -623,7 +623,7 @@ View::removeLayer(Layer *layer) { if (m_deleting) { - return; + return; } delete m_cache; @@ -632,8 +632,8 @@ for (LayerList::iterator i = m_fixedOrderLayers.begin(); i != m_fixedOrderLayers.end(); ++i) { - if (*i == layer) { - m_fixedOrderLayers.erase(i); + if (*i == layer) { + m_fixedOrderLayers.erase(i); break; } } @@ -641,16 +641,16 @@ for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if (*i == layer) { - m_layerStack.erase(i); - if (m_progressBars.find(layer) != m_progressBars.end()) { - delete m_progressBars[layer].bar; + if (*i == layer) { + m_layerStack.erase(i); + if (m_progressBars.find(layer) != m_progressBars.end()) { + delete m_progressBars[layer].bar; delete m_progressBars[layer].cancel; - delete m_progressBars[layer].checkTimer; - m_progressBars.erase(layer); - } - break; - } + delete m_progressBars[layer].checkTimer; + m_progressBars.erase(layer); + } + break; + } } disconnect(layer, SIGNAL(layerParametersChanged()), @@ -707,7 +707,7 @@ if (m_haveSelectedLayer && !m_layerStack.empty()) { return getLayer(getLayerCount() - 1); } else { - return 0; + return 0; } } @@ -721,36 +721,36 @@ View::setViewManager(ViewManager *manager) { if (m_manager) { - m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t))); - m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); - m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); - m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool))); + m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t))); + m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); + m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); + m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool))); m_manager->disconnect(this, SLOT(toolModeChanged())); m_manager->disconnect(this, SLOT(selectionChanged())); m_manager->disconnect(this, SLOT(overlayModeChanged())); m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged())); disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); - disconnect(m_manager, SLOT(zoomLevelChanged(int, bool))); + disconnect(m_manager, SLOT(zoomLevelChanged(int, bool))); } m_manager = manager; connect(m_manager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), - this, SLOT(globalCentreFrameChanged(sv_frame_t))); + this, SLOT(globalCentreFrameChanged(sv_frame_t))); connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)), - this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); + this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)), - this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); + this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), - this, SLOT(viewZoomLevelChanged(View *, int, bool))); + this, SLOT(viewZoomLevelChanged(View *, int, bool))); connect(m_manager, SIGNAL(toolModeChanged()), - this, SLOT(toolModeChanged())); + this, SLOT(toolModeChanged())); connect(m_manager, SIGNAL(selectionChanged()), - this, SLOT(selectionChanged())); + this, SLOT(selectionChanged())); connect(m_manager, SIGNAL(inProgressSelectionChanged()), - this, SLOT(selectionChanged())); + this, SLOT(selectionChanged())); connect(m_manager, SIGNAL(overlayModeChanged()), this, SLOT(overlayModeChanged())); connect(m_manager, SIGNAL(showCentreLineChanged()), @@ -764,7 +764,7 @@ PlaybackFollowMode))); connect(this, SIGNAL(zoomLevelChanged(int, bool)), - m_manager, SLOT(viewZoomLevelChanged(int, bool))); + m_manager, SLOT(viewZoomLevelChanged(int, bool))); switch (m_followPlay) { @@ -836,16 +836,16 @@ bool discard; LayerList scrollables = getScrollableBackLayers(false, discard); for (LayerList::const_iterator i = scrollables.begin(); - i != scrollables.end(); ++i) { - if (*i == obj || (*i)->getModel() == obj) { - recreate = true; - break; - } + i != scrollables.end(); ++i) { + if (*i == obj || (*i)->getModel() == obj) { + recreate = true; + break; + } } if (recreate) { - delete m_cache; - m_cache = 0; + delete m_cache; + m_cache = 0; } emit layerModelChanged(); @@ -868,12 +868,12 @@ #endif if (myStartFrame > 0 && endFrame < myStartFrame) { - checkProgress(obj); - return; + checkProgress(obj); + return; } if (startFrame > myEndFrame) { - checkProgress(obj); - return; + checkProgress(obj); + return; } // If the model that has changed is not used by any of the cached @@ -884,16 +884,16 @@ bool discard; LayerList scrollables = getScrollableBackLayers(false, discard); for (LayerList::const_iterator i = scrollables.begin(); - i != scrollables.end(); ++i) { - if (*i == obj || (*i)->getModel() == obj) { - recreate = true; - break; - } + i != scrollables.end(); ++i) { + if (*i == obj || (*i)->getModel() == obj) { + recreate = true; + break; + } } if (recreate) { - delete m_cache; - m_cache = 0; + delete m_cache; + m_cache = 0; } if (startFrame < myStartFrame) startFrame = myStartFrame; @@ -948,7 +948,7 @@ update(); if (layer) { - emit propertyContainerPropertyChanged(layer); + emit propertyContainerPropertyChanged(layer); } } @@ -996,7 +996,7 @@ View::viewManagerPlaybackFrameChanged(sv_frame_t f) { if (m_manager) { - if (sender() != m_manager) return; + if (sender() != m_manager) return; } #ifdef DEBUG_VIEW @@ -1031,7 +1031,7 @@ (QApplication::keyboardModifiers() & Qt::AltModifier)); bool pointerInVisibleArea = - long(m_playPointerFrame) >= getStartFrame() && + long(m_playPointerFrame) >= getStartFrame() && (m_playPointerFrame < getEndFrame() || // include old pointer location so we know to refresh when moving out oldPlayPointerFrame < getEndFrame()); @@ -1039,10 +1039,10 @@ switch (m_followPlay) { case PlaybackScrollContinuous: - if (!somethingGoingOn) { - setCentreFrame(m_playPointerFrame, false); - } - break; + if (!somethingGoingOn) { + setCentreFrame(m_playPointerFrame, false); + } + break; case PlaybackScrollPage: case PlaybackScrollPageWithCentre: @@ -1117,11 +1117,11 @@ break; case PlaybackIgnore: - if (m_playPointerFrame >= getStartFrame() && + if (m_playPointerFrame >= getStartFrame() && m_playPointerFrame < getEndFrame()) { - update(); - } - break; + update(); + } + break; } } @@ -1140,9 +1140,9 @@ View::selectionChanged() { if (m_selectionCached) { - delete m_cache; - m_cache = 0; - m_selectionCached = false; + delete m_cache; + m_cache = 0; + m_selectionCached = false; } update(); } @@ -1173,15 +1173,15 @@ for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if ((*i)->getModel() && (*i)->getModel()->isOK()) { - - sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame(); - - if (first || thisStartFrame < startFrame) { - startFrame = thisStartFrame; - } - first = false; - } + if ((*i)->getModel() && (*i)->getModel()->isOK()) { + + sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame(); + + if (first || thisStartFrame < startFrame) { + startFrame = thisStartFrame; + } + first = false; + } } return startFrame; } @@ -1194,15 +1194,15 @@ for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if ((*i)->getModel() && (*i)->getModel()->isOK()) { - - sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame(); - - if (first || thisEndFrame > endFrame) { - endFrame = thisEndFrame; - } - first = false; - } + if ((*i)->getModel() && (*i)->getModel()->isOK()) { + + sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame(); + + if (first || thisEndFrame > endFrame) { + endFrame = thisEndFrame; + } + first = false; + } } if (first) return getModelsStartFrame(); @@ -1219,9 +1219,9 @@ //!!! nah, this wants to always return the sr of the main model! for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if ((*i)->getModel() && (*i)->getModel()->isOK()) { - return (*i)->getModel()->getSampleRate(); - } + if ((*i)->getModel() && (*i)->getModel()->isOK()) { + return (*i)->getModel()->getSampleRate(); + } } return 0; } @@ -1326,7 +1326,7 @@ { // True iff all views are scrollable for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if (!(*i)->isLayerScrollable(this)) return false; + if (!(*i)->isLayerScrollable(this)) return false; } return true; } @@ -1347,13 +1347,13 @@ // cerr << "(name is " << (*i)->objectName() << ")" // << endl; // SVDEBUG << "View::getScrollableBackLayers: I am " << this << endl; - if ((*i)->isLayerDormant(this)) continue; - if ((*i)->isLayerOpaque()) { - // You can't see anything behind an opaque layer! - scrollables.clear(); + if ((*i)->isLayerDormant(this)) continue; + if ((*i)->isLayerOpaque()) { + // You can't see anything behind an opaque layer! + scrollables.clear(); if (metUnscrollable) break; - } - if (!metUnscrollable && (*i)->isLayerScrollable(this)) { + } + if (!metUnscrollable && (*i)->isLayerScrollable(this)) { scrollables.push_back(*i); } else { metUnscrollable = true; @@ -1361,8 +1361,8 @@ } if (testChanged && scrollables != m_lastScrollableBackLayers) { - m_lastScrollableBackLayers = scrollables; - changed = true; + m_lastScrollableBackLayers = scrollables; + changed = true; } return scrollables; } @@ -1379,21 +1379,21 @@ bool started = false; for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if ((*i)->isLayerDormant(this)) continue; - if (!started && (*i)->isLayerScrollable(this)) { - continue; - } - started = true; - if ((*i)->isLayerOpaque()) { - // You can't see anything behind an opaque layer! - nonScrollables.clear(); - } - nonScrollables.push_back(*i); + if ((*i)->isLayerDormant(this)) continue; + if (!started && (*i)->isLayerScrollable(this)) { + continue; + } + started = true; + if ((*i)->isLayerOpaque()) { + // You can't see anything behind an opaque layer! + nonScrollables.clear(); + } + nonScrollables.push_back(*i); } if (testChanged && nonScrollables != m_lastNonScrollableBackLayers) { - m_lastNonScrollableBackLayers = nonScrollables; - changed = true; + m_lastNonScrollableBackLayers = nonScrollables; + changed = true; } return nonScrollables; @@ -1401,7 +1401,7 @@ int View::getZoomConstraintBlockSize(int blockSize, - ZoomConstraint::RoundingDirection dir) + ZoomConstraint::RoundingDirection dir) const { int candidate = blockSize; @@ -1411,20 +1411,20 @@ for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); - if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; - - int thisBlockSize = - zoomConstraint->getNearestBlockSize(blockSize, dir); - - // Go for the block size that's furthest from the one - // passed in. Most of the time, that's what we want. - if (!haveCandidate || - (thisBlockSize > blockSize && thisBlockSize > candidate) || - (thisBlockSize < blockSize && thisBlockSize < candidate)) { - candidate = thisBlockSize; - haveCandidate = true; - } + const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); + if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; + + int thisBlockSize = + zoomConstraint->getNearestBlockSize(blockSize, dir); + + // Go for the block size that's furthest from the one + // passed in. Most of the time, that's what we want. + if (!haveCandidate || + (thisBlockSize > blockSize && thisBlockSize > candidate) || + (thisBlockSize < blockSize && thisBlockSize < candidate)) { + candidate = thisBlockSize; + haveCandidate = true; + } } return candidate; @@ -1434,7 +1434,7 @@ View::areLayerColoursSignificant() const { for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { - if ((*i)->getLayerColourSignificance() == + if ((*i)->getLayerColourSignificance() == Layer::ColourHasMeaningfulValue) return true; if ((*i)->isLayerOpaque()) break; } @@ -1456,15 +1456,15 @@ int newZoomLevel = m_zoomLevel; if (in) { - newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1, - ZoomConstraint::RoundDown); + newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1, + ZoomConstraint::RoundDown); } else { - newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1, - ZoomConstraint::RoundUp); + newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1, + ZoomConstraint::RoundUp); } if (newZoomLevel != m_zoomLevel) { - setZoomLevel(newZoomLevel); + setZoomLevel(newZoomLevel); } } @@ -1473,18 +1473,18 @@ { sv_frame_t delta; if (lots) { - delta = (getEndFrame() - getStartFrame()) / 2; + delta = (getEndFrame() - getStartFrame()) / 2; } else { - delta = (getEndFrame() - getStartFrame()) / 20; + delta = (getEndFrame() - getStartFrame()) / 20; } if (right) delta = -delta; if (m_centreFrame < delta) { - setCentreFrame(0, e); + setCentreFrame(0, e); } else if (m_centreFrame - delta >= getModelsEndFrame()) { - setCentreFrame(getModelsEndFrame(), e); + setCentreFrame(getModelsEndFrame(), e); } else { - setCentreFrame(m_centreFrame - delta, e); + setCentreFrame(m_centreFrame - delta, e); } } @@ -1495,7 +1495,7 @@ if (!cancel) return; for (ProgressMap::iterator i = m_progressBars.begin(); - i != m_progressBars.end(); ++i) { + i != m_progressBars.end(); ++i) { if (i->second.cancel == cancel) { @@ -1515,19 +1515,19 @@ int ph = height(); for (ProgressMap::iterator i = m_progressBars.begin(); - i != m_progressBars.end(); ++i) { + i != m_progressBars.end(); ++i) { QProgressBar *pb = i->second.bar; QPushButton *cancel = i->second.cancel; - if (i->first == object) { + if (i->first == object) { // The timer is used to test for stalls. If the progress // bar does not get updated for some length of time, the // timer prompts it to go back into "indeterminate" mode QTimer *timer = i->second.checkTimer; - int completion = i->first->getCompletion(this); + int completion = i->first->getCompletion(this); QString text = i->first->getPropertyContainerName(); QString error = i->first->getError(this); @@ -1562,13 +1562,13 @@ update(); // ensure duration &c gets updated } - if (completion >= 100) { - - pb->hide(); + if (completion >= 100) { + + pb->hide(); cancel->hide(); timer->stop(); - } else { + } else { // cerr << "progress = " << completion << endl; @@ -1581,19 +1581,19 @@ cancel->move(0, ph - pb->height()/2 - 10); cancel->show(); - pb->setValue(completion); - pb->move(20, ph - pb->height()); - - pb->show(); - pb->update(); - - ph -= pb->height(); - } - } else { - if (pb->isVisible()) { - ph -= pb->height(); - } - } + pb->setValue(completion); + pb->move(20, ph - pb->height()); + + pb->show(); + pb->update(); + + ph -= pb->height(); + } + } else { + if (pb->isVisible()) { + ph -= pb->height(); + } + } } } @@ -1620,7 +1620,7 @@ View::getProgressBarWidth() const { for (ProgressMap::const_iterator i = m_progressBars.begin(); - i != m_progressBars.end(); ++i) { + i != m_progressBars.end(); ++i) { if (i->second.bar && i->second.bar->isVisible()) { return i->second.bar->width(); } @@ -1660,8 +1660,8 @@ // cerr << "View::paintEvent: centre frame is " << m_centreFrame << endl; if (m_layerStack.empty()) { - QFrame::paintEvent(e); - return; + QFrame::paintEvent(e); + return; } // ensure our constraints are met @@ -1670,7 +1670,7 @@ zoom levels? m_zoomLevel = getZoomConstraintBlockSize(m_zoomLevel, - ZoomConstraint::RoundUp); + ZoomConstraint::RoundUp); */ QPainter paint; @@ -1680,10 +1680,10 @@ QRect cacheRect(rect()); if (e) { - cacheRect &= e->rect(); + cacheRect &= e->rect(); #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "paint rect " << cacheRect.width() << "x" << cacheRect.height() - << ", my rect " << width() << "x" << height() << endl; + cerr << "paint rect " << cacheRect.width() << "x" << cacheRect.height() + << ", my rect " << width() << "x" << height() << endl; #endif } @@ -1734,17 +1734,17 @@ #ifdef DEBUG_VIEW_WIDGET_PAINT cerr << "View(" << this << ")::paintEvent: have " << scrollables.size() - << " scrollable back layers and " << nonScrollables.size() - << " non-scrollable front layers" << endl; + << " scrollable back layers and " << nonScrollables.size() + << " non-scrollable front layers" << endl; cerr << "haveSelections " << haveSelections << ", selectionCacheable " - << selectionCacheable << ", m_selectionCached " << m_selectionCached << endl; + << selectionCacheable << ", m_selectionCached " << m_selectionCached << endl; #endif if (layersChanged || scrollables.empty() || - (haveSelections && (selectionCacheable != m_selectionCached))) { - delete m_cache; - m_cache = 0; - m_selectionCached = false; + (haveSelections && (selectionCacheable != m_selectionCached))) { + delete m_cache; + m_cache = 0; + m_selectionCached = false; } QSize scaledCacheSize(scaledSize(size(), dpratio)); @@ -1762,75 +1762,75 @@ << m_cacheZoomLevel << ", zoom " << m_zoomLevel << endl; #endif - if (!m_cache || - m_cacheZoomLevel != m_zoomLevel || + if (!m_cache || + m_cacheZoomLevel != m_zoomLevel || scaledCacheSize != m_cache->size()) { - // cache is not valid - - if (cacheRect.width() < width()/10) { - delete m_cache; + // cache is not valid + + if (cacheRect.width() < width()/10) { + delete m_cache; m_cache = 0; #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl; + cerr << "View(" << this << ")::paintEvent: small repaint, not bothering to recreate cache" << endl; #endif - } else { - delete m_cache; - m_cache = new QPixmap(scaledCacheSize); + } else { + delete m_cache; + m_cache = new QPixmap(scaledCacheSize); #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "View(" << this << ")::paintEvent: recreated cache" << endl; + cerr << "View(" << this << ")::paintEvent: recreated cache" << endl; #endif - cacheRect = rect(); - repaintCache = true; - } - - } else if (m_cacheCentreFrame != m_centreFrame) { - - int dx = - getXForFrame(m_cacheCentreFrame) - - getXForFrame(m_centreFrame); - - if (dx > -width() && dx < width()) { - static QPixmap *tmpPixmap = 0; - if (!tmpPixmap || tmpPixmap->size() != scaledCacheSize) { - delete tmpPixmap; - tmpPixmap = new QPixmap(scaledCacheSize); - } - paint.begin(tmpPixmap); - paint.drawPixmap(0, 0, *m_cache); - paint.end(); - paint.begin(m_cache); - paint.drawPixmap(dx, 0, *tmpPixmap); - paint.end(); - if (dx < 0) { - cacheRect = QRect(width() + dx, 0, -dx, height()); - } else { - cacheRect = QRect(0, 0, dx, height()); - } + cacheRect = rect(); + repaintCache = true; + } + + } else if (m_cacheCentreFrame != m_centreFrame) { + + int dx = + getXForFrame(m_cacheCentreFrame) - + getXForFrame(m_centreFrame); + + if (dx > -width() && dx < width()) { + static QPixmap *tmpPixmap = 0; + if (!tmpPixmap || tmpPixmap->size() != scaledCacheSize) { + delete tmpPixmap; + tmpPixmap = new QPixmap(scaledCacheSize); + } + paint.begin(tmpPixmap); + paint.drawPixmap(0, 0, *m_cache); + paint.end(); + paint.begin(m_cache); + paint.drawPixmap(dx, 0, *tmpPixmap); + paint.end(); + if (dx < 0) { + cacheRect = QRect(width() + dx, 0, -dx, height()); + } else { + cacheRect = QRect(0, 0, dx, height()); + } #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "View(" << this << ")::paintEvent: scrolled cache by " << dx << endl; + cerr << "View(" << this << ")::paintEvent: scrolled cache by " << dx << endl; #endif - } else { - cacheRect = rect(); + } else { + cacheRect = rect(); #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "View(" << this << ")::paintEvent: scrolling too far" << endl; + cerr << "View(" << this << ")::paintEvent: scrolling too far" << endl; #endif - } - repaintCache = true; - - } else { + } + repaintCache = true; + + } else { #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "View(" << this << ")::paintEvent: cache is good" << endl; + cerr << "View(" << this << ")::paintEvent: cache is good" << endl; #endif - paint.begin(m_buffer); - paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); - paint.end(); - QFrame::paintEvent(e); - paintedCacheRect = true; - } - - m_cacheCentreFrame = m_centreFrame; - m_cacheZoomLevel = m_zoomLevel; + paint.begin(m_buffer); + paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); + paint.end(); + QFrame::paintEvent(e); + paintedCacheRect = true; + } + + m_cacheCentreFrame = m_centreFrame; + m_cacheZoomLevel = m_zoomLevel; } #ifdef DEBUG_VIEW_WIDGET_PAINT @@ -1845,7 +1845,7 @@ QRect rectToPaint; - if (repaintCache) { + if (repaintCache) { paint.begin(m_cache); rectToPaint = scaledCacheRect; } else { @@ -1854,39 +1854,39 @@ } setPaintFont(paint); - paint.setClipRect(rectToPaint); + paint.setClipRect(rectToPaint); paint.setPen(getBackground()); paint.setBrush(getBackground()); - paint.drawRect(rectToPaint); - - paint.setPen(getForeground()); - paint.setBrush(Qt::NoBrush); - - for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { - paint.setRenderHint(QPainter::Antialiasing, false); - paint.save(); + paint.drawRect(rectToPaint); + + paint.setPen(getForeground()); + paint.setBrush(Qt::NoBrush); + + for (LayerList::iterator i = scrollables.begin(); i != scrollables.end(); ++i) { + paint.setRenderHint(QPainter::Antialiasing, false); + paint.save(); #ifdef DEBUG_VIEW_WIDGET_PAINT cerr << "Painting scrollable layer " << *i << " using proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << rectToPaint.x() << "," << rectToPaint.y() << " " << rectToPaint.width() << "x" << rectToPaint.height() << endl; #endif (*i)->paint(&proxy, paint, rectToPaint); - paint.restore(); - } - - if (haveSelections && selectionCacheable) { - drawSelections(paint); - m_selectionCached = repaintCache; - } - - paint.end(); - - if (repaintCache) { - cacheRect |= (e ? e->rect() : rect()); + paint.restore(); + } + + if (haveSelections && selectionCacheable) { + drawSelections(paint); + m_selectionCached = repaintCache; + } + + paint.end(); + + if (repaintCache) { + cacheRect |= (e ? e->rect() : rect()); scaledCacheRect = scaledRect(cacheRect, dpratio); - paint.begin(m_buffer); - paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); - paint.end(); - } + paint.begin(m_buffer); + paint.drawPixmap(scaledCacheRect, *m_cache, scaledCacheRect); + paint.end(); + } } // Now non-cacheable items. We always need to redraw the @@ -1903,20 +1903,20 @@ if (scrollables.empty()) { paint.setPen(getBackground()); paint.setBrush(getBackground()); - paint.drawRect(scaledNonCacheRect); + paint.drawRect(scaledNonCacheRect); } - + paint.setPen(getForeground()); paint.setBrush(Qt::NoBrush); - + for (LayerList::iterator i = nonScrollables.begin(); i != nonScrollables.end(); ++i) { // Profiler profiler2("View::paintEvent non-cacheable"); #ifdef DEBUG_VIEW_WIDGET_PAINT cerr << "Painting non-scrollable layer " << *i << " without proxy with repaintCache = " << repaintCache << ", dpratio = " << dpratio << ", rectToPaint = " << nonCacheRect.x() << "," << nonCacheRect.y() << " " << nonCacheRect.width() << "x" << nonCacheRect.height() << endl; #endif - (*i)->paint(&proxy, paint, scaledNonCacheRect); + (*i)->paint(&proxy, paint, scaledNonCacheRect); } - + paint.end(); paint.begin(this); @@ -1928,7 +1928,7 @@ setPaintFont(paint); if (e) paint.setClipRect(e->rect()); if (!m_selectionCached) { - drawSelections(paint); + drawSelections(paint); } paint.end(); @@ -1950,7 +1950,7 @@ if (showPlayPointer) { - paint.begin(this); + paint.begin(this); int playx = getXForFrame(m_playPointerFrame); @@ -1962,7 +1962,7 @@ paint.setPen(getBackground()); paint.drawLine(playx, 1, playx, height() - 2); - paint.end(); + paint.end(); } QFrame::paintEvent(e); @@ -1976,14 +1976,14 @@ MultiSelection::SelectionList selections; if (m_manager) { - selections = m_manager->getSelections(); - if (m_manager->haveInProgressSelection()) { - bool exclusive; - Selection inProgressSelection = - m_manager->getInProgressSelection(exclusive); - if (exclusive) selections.clear(); - selections.insert(inProgressSelection); - } + selections = m_manager->getSelections(); + if (m_manager->haveInProgressSelection()) { + bool exclusive; + Selection inProgressSelection = + m_manager->getInProgressSelection(exclusive); + if (exclusive) selections.clear(); + selections.insert(inProgressSelection); + } } paint.save(); @@ -2003,27 +2003,27 @@ bool closeToLeft, closeToRight; if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { - illuminateFrame = getFrameForX(localPos.x()); + illuminateFrame = getFrameForX(localPos.x()); } const QFontMetrics &metrics = paint.fontMetrics(); for (MultiSelection::SelectionList::iterator i = selections.begin(); - i != selections.end(); ++i) { - - int p0 = getXForFrame(alignFromReference(i->getStartFrame())); - int p1 = getXForFrame(alignFromReference(i->getEndFrame())); - - if (p1 < 0 || p0 > width()) continue; + i != selections.end(); ++i) { + + int p0 = getXForFrame(alignFromReference(i->getStartFrame())); + int p1 = getXForFrame(alignFromReference(i->getEndFrame())); + + if (p1 < 0 || p0 > width()) continue; #ifdef DEBUG_VIEW_WIDGET_PAINT - SVDEBUG << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << endl; + SVDEBUG << "View::drawSelections: " << p0 << ",-1 [" << (p1-p0) << "x" << (height()+1) << "]" << endl; #endif - bool illuminateThis = - (illuminateFrame >= 0 && i->contains(illuminateFrame)); - - paint.setPen(QColor(150, 150, 255)); + bool illuminateThis = + (illuminateFrame >= 0 && i->contains(illuminateFrame)); + + paint.setPen(QColor(150, 150, 255)); if (translucent && shouldLabelSelections()) { paint.drawRect(p0, -1, p1 - p0, height() + 1); @@ -2035,73 +2035,73 @@ paint.drawRect(p0, 0, p1 - p0, height() - 1); } - if (illuminateThis) { - paint.save(); + if (illuminateThis) { + paint.save(); paint.setPen(QPen(getForeground(), 2)); - if (closeToLeft) { - paint.drawLine(p0, 1, p1, 1); - paint.drawLine(p0, 0, p0, height()); - paint.drawLine(p0, height() - 1, p1, height() - 1); - } else if (closeToRight) { - paint.drawLine(p0, 1, p1, 1); - paint.drawLine(p1, 0, p1, height()); - paint.drawLine(p0, height() - 1, p1, height() - 1); - } else { - paint.setBrush(Qt::NoBrush); - paint.drawRect(p0, 1, p1 - p0, height() - 2); - } - paint.restore(); - } - - if (sampleRate && shouldLabelSelections() && m_manager && + if (closeToLeft) { + paint.drawLine(p0, 1, p1, 1); + paint.drawLine(p0, 0, p0, height()); + paint.drawLine(p0, height() - 1, p1, height() - 1); + } else if (closeToRight) { + paint.drawLine(p0, 1, p1, 1); + paint.drawLine(p1, 0, p1, height()); + paint.drawLine(p0, height() - 1, p1, height() - 1); + } else { + paint.setBrush(Qt::NoBrush); + paint.drawRect(p0, 1, p1 - p0, height() - 2); + } + paint.restore(); + } + + if (sampleRate && shouldLabelSelections() && m_manager && m_manager->shouldShowSelectionExtents()) { - - QString startText = QString("%1 / %2") - .arg(QString::fromStdString - (RealTime::frame2RealTime - (i->getStartFrame(), sampleRate).toText(true))) - .arg(i->getStartFrame()); - - QString endText = QString(" %1 / %2") - .arg(QString::fromStdString - (RealTime::frame2RealTime - (i->getEndFrame(), sampleRate).toText(true))) - .arg(i->getEndFrame()); - - QString durationText = QString("(%1 / %2) ") - .arg(QString::fromStdString - (RealTime::frame2RealTime - (i->getEndFrame() - i->getStartFrame(), sampleRate) - .toText(true))) - .arg(i->getEndFrame() - i->getStartFrame()); - - int sw = metrics.width(startText), - ew = metrics.width(endText), - dw = metrics.width(durationText); - - int sy = metrics.ascent() + metrics.height() + 4; - int ey = sy; - int dy = sy + metrics.height(); - - int sx = p0 + 2; - int ex = sx; - int dx = sx; + + QString startText = QString("%1 / %2") + .arg(QString::fromStdString + (RealTime::frame2RealTime + (i->getStartFrame(), sampleRate).toText(true))) + .arg(i->getStartFrame()); + + QString endText = QString(" %1 / %2") + .arg(QString::fromStdString + (RealTime::frame2RealTime + (i->getEndFrame(), sampleRate).toText(true))) + .arg(i->getEndFrame()); + + QString durationText = QString("(%1 / %2) ") + .arg(QString::fromStdString + (RealTime::frame2RealTime + (i->getEndFrame() - i->getStartFrame(), sampleRate) + .toText(true))) + .arg(i->getEndFrame() - i->getStartFrame()); + + int sw = metrics.width(startText), + ew = metrics.width(endText), + dw = metrics.width(durationText); + + int sy = metrics.ascent() + metrics.height() + 4; + int ey = sy; + int dy = sy + metrics.height(); + + int sx = p0 + 2; + int ex = sx; + int dx = sx; bool durationBothEnds = true; - if (sw + ew > (p1 - p0)) { - ey += metrics.height(); - dy += metrics.height(); + if (sw + ew > (p1 - p0)) { + ey += metrics.height(); + dy += metrics.height(); durationBothEnds = false; - } - - if (ew < (p1 - p0)) { - ex = p1 - 2 - ew; - } - - if (dw < (p1 - p0)) { - dx = p1 - 2 - dw; - } + } + + if (ew < (p1 - p0)) { + ex = p1 - 2 - ew; + } + + if (dw < (p1 - p0)) { + dx = p1 - 2 - dw; + } PaintAssistant::drawVisibleText(this, paint, sx, sy, startText, PaintAssistant::OutlinedText); @@ -2113,7 +2113,7 @@ PaintAssistant::drawVisibleText(this, paint, sx, dy, durationText, PaintAssistant::OutlinedText); } - } + } } paint.restore(); @@ -2431,12 +2431,12 @@ paint.setPen(getBackground()); paint.setBrush(getBackground()); - paint.drawRect(QRect(xorigin + x, 0, width(), height())); - - paint.setPen(getForeground()); - paint.setBrush(Qt::NoBrush); - - for (LayerList::iterator i = m_layerStack.begin(); + paint.drawRect(QRect(xorigin + x, 0, width(), height())); + + paint.setPen(getForeground()); + paint.setBrush(Qt::NoBrush); + + for (LayerList::iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if (!((*i)->isLayerDormant(this))){ @@ -2455,7 +2455,7 @@ paint.restore(); } - } + } } m_centreFrame = origCentreFrame; @@ -2551,15 +2551,15 @@ "followZoom=\"%4\" " "tracking=\"%5\" " " %6>\n") - .arg(m_centreFrame) - .arg(m_zoomLevel) - .arg(m_followPan) - .arg(m_followZoom) - .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : - m_followPlay == PlaybackScrollPageWithCentre ? "page" : - m_followPlay == PlaybackScrollPage ? "daw" : + .arg(m_centreFrame) + .arg(m_zoomLevel) + .arg(m_followPan) + .arg(m_followZoom) + .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : + m_followPlay == PlaybackScrollPageWithCentre ? "page" : + m_followPlay == PlaybackScrollPage ? "daw" : "ignore") - .arg(extraAttributes); + .arg(extraAttributes); for (int i = 0; i < (int)m_fixedOrderLayers.size(); ++i) { bool visible = !m_fixedOrderLayers[i]->isLayerDormant(this); @@ -2576,7 +2576,7 @@ { // cerr << "ViewPropertyContainer: " << this << " is owned by View " << v << endl; connect(m_v, SIGNAL(propertyChanged(PropertyContainer::PropertyName)), - this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); + this, SIGNAL(propertyChanged(PropertyContainer::PropertyName))); } ViewPropertyContainer::~ViewPropertyContainer()
--- a/view/View.h Thu Mar 01 14:43:53 2018 +0000 +++ b/view/View.h Thu Mar 01 18:02:22 2018 +0000 @@ -51,7 +51,7 @@ */ class View : public QFrame, - public XmlExportable, + public XmlExportable, public LayerGeometryProvider { Q_OBJECT @@ -136,7 +136,7 @@ * Not thread-safe in logarithmic mode. Call only from GUI thread. */ double getYForFrequency(double frequency, double minFreq, double maxFreq, - bool logarithmic) const; + bool logarithmic) const; /** * Return the closest frequency to the given pixel y-coordinate, @@ -273,10 +273,10 @@ return m_manager && m_manager->shouldShowFeatureLabels(); } virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const { - return false; + return false; } virtual bool shouldIlluminateLocalSelection(QPoint &, bool &, bool &) const { - return false; + return false; } virtual void setPlaybackFollow(PlaybackFollowMode m); @@ -292,12 +292,12 @@ virtual QString getPropertyLabel(const PropertyName &) const; virtual PropertyContainer::PropertyType getPropertyType(const PropertyName &) const; virtual int getPropertyRangeAndValue(const PropertyName &, - int *min, int *max, int *deflt) const; + int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, - int value) const; + int value) const; virtual void setProperty(const PropertyName &, int value); virtual QString getPropertyContainerName() const { - return objectName(); + return objectName(); } virtual QString getPropertyContainerIconName() const = 0; @@ -457,8 +457,8 @@ LayerList getScrollableBackLayers(bool testChanged, bool &changed) const; LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const; int getZoomConstraintBlockSize(int blockSize, - ZoomConstraint::RoundingDirection dir = - ZoomConstraint::RoundNearest) const; + ZoomConstraint::RoundingDirection dir = + ZoomConstraint::RoundNearest) const; // True if the top layer(s) use colours for meaningful things. If // this is the case, selections will be shown using unfilled boxes @@ -539,25 +539,25 @@ return m_v->getPropertyLabel(n); } PropertyType getPropertyType(const PropertyName &n) const { - return m_v->getPropertyType(n); + return m_v->getPropertyType(n); } int getPropertyRangeAndValue(const PropertyName &n, int *min, int *max, int *deflt) const { - return m_v->getPropertyRangeAndValue(n, min, max, deflt); + return m_v->getPropertyRangeAndValue(n, min, max, deflt); } QString getPropertyValueLabel(const PropertyName &n, int value) const { - return m_v->getPropertyValueLabel(n, value); + return m_v->getPropertyValueLabel(n, value); } QString getPropertyContainerName() const { - return m_v->getPropertyContainerName(); + return m_v->getPropertyContainerName(); } QString getPropertyContainerIconName() const { - return m_v->getPropertyContainerIconName(); + return m_v->getPropertyContainerIconName(); } public slots: virtual void setProperty(const PropertyName &n, int value) { - m_v->setProperty(n, value); + m_v->setProperty(n, value); } protected:
--- a/view/ViewManager.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/view/ViewManager.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -165,7 +165,7 @@ cout << "ViewManager::getPlaybackFrame(recording) -> " << m_playbackFrame << endl; #endif } else if (isPlaying()) { - m_playbackFrame = m_playSource->getCurrentPlayingFrame(); + m_playbackFrame = m_playSource->getCurrentPlayingFrame(); #ifdef DEBUG_VIEW_MANAGER cout << "ViewManager::getPlaybackFrame(playing) -> " << m_playbackFrame << endl; #endif @@ -185,11 +185,11 @@ #endif if (f < 0) f = 0; if (m_playbackFrame != f) { - m_playbackFrame = f; - emit playbackFrameChanged(f); - if (isPlaying()) { - m_playSource->play(f); - } + m_playbackFrame = f; + emit playbackFrameChanged(f); + if (isPlaying()) { + m_playSource->play(f); + } } } @@ -359,7 +359,7 @@ } ViewManager::SetSelectionCommand::SetSelectionCommand(ViewManager *vm, - const MultiSelection &ms) : + const MultiSelection &ms) : m_vm(vm), m_oldSelection(vm->m_selections), m_newSelection(ms) @@ -509,7 +509,7 @@ ViewManager::getDeviceSampleRate() const { if (m_playSource) { - return m_playSource->getDeviceSampleRate(); + return m_playSource->getDeviceSampleRate(); } return 0; } @@ -518,7 +518,7 @@ ViewManager::setAudioPlaySource(AudioPlaySource *source) { if (!m_playSource) { - QTimer::singleShot(100, this, SLOT(checkPlayStatus())); + QTimer::singleShot(100, this, SLOT(checkPlayStatus())); } m_playSource = source; } @@ -527,7 +527,7 @@ ViewManager::setAudioRecordTarget(AudioRecordTarget *target) { if (!m_recordTarget) { - QTimer::singleShot(100, this, SLOT(checkPlayStatus())); + QTimer::singleShot(100, this, SLOT(checkPlayStatus())); } m_recordTarget = target; } @@ -555,56 +555,56 @@ { if (isRecording()) { - float left = 0, right = 0; - if (m_recordTarget->getInputLevels(left, right)) { - if (left != m_lastLeft || right != m_lastRight) { - emit monitoringLevelsChanged(left, right); - m_lastLeft = left; - m_lastRight = right; - } - } + float left = 0, right = 0; + if (m_recordTarget->getInputLevels(left, right)) { + if (left != m_lastLeft || right != m_lastRight) { + emit monitoringLevelsChanged(left, right); + m_lastLeft = left; + m_lastRight = right; + } + } - m_playbackFrame = m_recordTarget->getRecordDuration(); + m_playbackFrame = m_recordTarget->getRecordDuration(); #ifdef DEBUG_VIEW_MANAGER - cerr << "ViewManager::checkPlayStatus: Recording, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; + cerr << "ViewManager::checkPlayStatus: Recording, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; #endif - emit playbackFrameChanged(m_playbackFrame); + emit playbackFrameChanged(m_playbackFrame); - QTimer::singleShot(500, this, SLOT(checkPlayStatus())); + QTimer::singleShot(500, this, SLOT(checkPlayStatus())); } else if (isPlaying()) { - float left = 0, right = 0; - if (m_playSource->getOutputLevels(left, right)) { - if (left != m_lastLeft || right != m_lastRight) { - emit monitoringLevelsChanged(left, right); - m_lastLeft = left; - m_lastRight = right; - } - } + float left = 0, right = 0; + if (m_playSource->getOutputLevels(left, right)) { + if (left != m_lastLeft || right != m_lastRight) { + emit monitoringLevelsChanged(left, right); + m_lastLeft = left; + m_lastRight = right; + } + } - m_playbackFrame = m_playSource->getCurrentPlayingFrame(); + m_playbackFrame = m_playSource->getCurrentPlayingFrame(); #ifdef DEBUG_VIEW_MANAGER - cerr << "ViewManager::checkPlayStatus: Playing, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; + cerr << "ViewManager::checkPlayStatus: Playing, frame " << m_playbackFrame << ", levels " << m_lastLeft << "," << m_lastRight << endl; #endif - emit playbackFrameChanged(m_playbackFrame); + emit playbackFrameChanged(m_playbackFrame); - QTimer::singleShot(20, this, SLOT(checkPlayStatus())); + QTimer::singleShot(20, this, SLOT(checkPlayStatus())); } else { - if (m_lastLeft != 0.0 || m_lastRight != 0.0) { - emit monitoringLevelsChanged(0.0, 0.0); - m_lastLeft = 0.0; - m_lastRight = 0.0; - } + if (m_lastLeft != 0.0 || m_lastRight != 0.0) { + emit monitoringLevelsChanged(0.0, 0.0); + m_lastLeft = 0.0; + m_lastRight = 0.0; + } #ifdef DEBUG_VIEW_MANAGER - cerr << "ViewManager::checkPlayStatus: Not playing or recording" << endl; + cerr << "ViewManager::checkPlayStatus: Not playing or recording" << endl; #endif } } @@ -668,16 +668,16 @@ } if (isPlaying()) { - sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame(); - sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame); - if (diff > 20000) { - m_playbackFrame = f; - m_playSource->play(f); + sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame(); + sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame); + if (diff > 20000) { + m_playbackFrame = f; + m_playSource->play(f); #ifdef DEBUG_VIEW_MANAGER - cerr << "ViewManager::seek: reseeking from " << playFrame << " to " << f << endl; + cerr << "ViewManager::seek: reseeking from " << playFrame << " to " << f << endl; #endif emit playbackFrameChanged(f); - } + } } else { if (m_playbackFrame != f) { m_playbackFrame = f; @@ -699,7 +699,7 @@ //!!! emit zoomLevelChanged(); if (locked) { - m_globalZoom = z; + m_globalZoom = z; } #ifdef DEBUG_VIEW_MANAGER
--- a/view/ViewManager.h Thu Mar 01 14:43:53 2018 +0000 +++ b/view/ViewManager.h Thu Mar 01 18:02:22 2018 +0000 @@ -130,13 +130,13 @@ Clipboard &getClipboard() { return m_clipboard; } enum ToolMode { - NavigateMode, - SelectMode, + NavigateMode, + SelectMode, EditMode, - DrawMode, - EraseMode, - MeasureMode, - NoteEditMode //GF: Tonioni: this tool mode will be context sensitive. + DrawMode, + EraseMode, + MeasureMode, + NoteEditMode //GF: Tonioni: this tool mode will be context sensitive. }; ToolMode getToolMode() const { return m_toolMode; } void setToolMode(ToolMode mode); @@ -348,16 +348,16 @@ class SetSelectionCommand : public Command { public: - SetSelectionCommand(ViewManager *vm, const MultiSelection &ms); - virtual ~SetSelectionCommand(); - virtual void execute(); - virtual void unexecute(); - virtual QString getName() const; + SetSelectionCommand(ViewManager *vm, const MultiSelection &ms); + virtual ~SetSelectionCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString getName() const; protected: - ViewManager *m_vm; - MultiSelection m_oldSelection; - MultiSelection m_newSelection; + ViewManager *m_vm; + MultiSelection m_oldSelection; + MultiSelection m_newSelection; }; OverlayMode m_overlayMode;
--- a/view/ViewProxy.h Thu Mar 01 14:43:53 2018 +0000 +++ b/view/ViewProxy.h Thu Mar 01 18:02:22 2018 +0000 @@ -21,23 +21,23 @@ { public: ViewProxy(View *view, int scaleFactor) : - m_view(view), m_scaleFactor(scaleFactor) { } + m_view(view), m_scaleFactor(scaleFactor) { } virtual int getId() const { return m_view->getId(); } virtual sv_frame_t getStartFrame() const { - return m_view->getStartFrame(); + return m_view->getStartFrame(); } virtual sv_frame_t getCentreFrame() const { - return m_view->getCentreFrame(); + return m_view->getCentreFrame(); } virtual sv_frame_t getEndFrame() const { - return m_view->getEndFrame(); + return m_view->getEndFrame(); } virtual int getXForFrame(sv_frame_t frame) const { //!!! not actually correct, if frame lies between view's pixels - return m_scaleFactor * m_view->getXForFrame(frame); + return m_scaleFactor * m_view->getXForFrame(frame); } virtual sv_frame_t getFrameForX(int x) const { sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor); @@ -52,43 +52,43 @@ return x / m_scaleFactor; } virtual sv_frame_t getModelsStartFrame() const { - return m_view->getModelsStartFrame(); + return m_view->getModelsStartFrame(); } virtual sv_frame_t getModelsEndFrame() const { - return m_view->getModelsEndFrame(); + return m_view->getModelsEndFrame(); } virtual double getYForFrequency(double frequency, - double minFreq, double maxFreq, + double minFreq, double maxFreq, bool logarithmic) const { - return m_scaleFactor * - m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); + return m_scaleFactor * + m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); } virtual double getFrequencyForY(double y, double minFreq, double maxFreq, - bool logarithmic) const { + bool logarithmic) const { return m_view->getFrequencyForY (y / m_scaleFactor, minFreq, maxFreq, logarithmic); } virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { - return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); + return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); } virtual bool getValueExtents(QString unit, double &min, double &max, bool &log) const { - return m_view->getValueExtents(unit, min, max, log); + return m_view->getValueExtents(unit, min, max, log); } virtual int getZoomLevel() const { - int z = m_view->getZoomLevel(); -// cerr << "getZoomLevel: from " << z << " to "; - z = z / m_scaleFactor; -// cerr << z << endl; + int z = m_view->getZoomLevel(); +// cerr << "getZoomLevel: from " << z << " to "; + z = z / m_scaleFactor; +// cerr << z << endl; if (z < 1) z = 1; - return z; + return z; } virtual QRect getPaintRect() const { - QRect r = m_view->getPaintRect(); - return QRect(r.x() * m_scaleFactor, - r.y() * m_scaleFactor, - r.width() * m_scaleFactor, - r.height() * m_scaleFactor); + QRect r = m_view->getPaintRect(); + return QRect(r.x() * m_scaleFactor, + r.y() * m_scaleFactor, + r.width() * m_scaleFactor, + r.height() * m_scaleFactor); } virtual QSize getPaintSize() const { return getPaintRect().size(); @@ -100,33 +100,33 @@ return getPaintRect().height(); } virtual bool hasLightBackground() const { - return m_view->hasLightBackground(); + return m_view->hasLightBackground(); } virtual QColor getForeground() const { - return m_view->getForeground(); + return m_view->getForeground(); } virtual QColor getBackground() const { - return m_view->getBackground(); + return m_view->getBackground(); } virtual ViewManager *getViewManager() const { - return m_view->getViewManager(); + return m_view->getViewManager(); } - + virtual bool shouldIlluminateLocalFeatures(const Layer *layer, QPoint &point) const { QPoint p; - bool should = m_view->shouldIlluminateLocalFeatures(layer, p); + bool should = m_view->shouldIlluminateLocalFeatures(layer, p); point = QPoint(p.x() * m_scaleFactor, p.y() * m_scaleFactor); return should; } virtual bool shouldShowFeatureLabels() const { - return m_view->shouldShowFeatureLabels(); + return m_view->shouldShowFeatureLabels(); } virtual void drawMeasurementRect(QPainter &p, const Layer *layer, QRect rect, bool focus) const { - m_view->drawMeasurementRect(p, layer, rect, focus); + m_view->drawMeasurementRect(p, layer, rect, focus); } virtual void updatePaintRect(QRect r) {
--- a/widgets/AudioDial.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/AudioDial.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -122,23 +122,23 @@ QPainter paint; double angle = AUDIO_DIAL_MIN // offset - + (AUDIO_DIAL_RANGE * - (double(QDial::value() - QDial::minimum()) / - (double(QDial::maximum() - QDial::minimum())))); + + (AUDIO_DIAL_RANGE * + (double(QDial::value() - QDial::minimum()) / + (double(QDial::maximum() - QDial::minimum())))); int degrees = int(angle * 180.0 / M_PI); int ns = notchSize(); int numTicks = 1 + (maximum() + ns - minimum()) / ns; - + QColor knobColor(m_knobColor); if (knobColor == Qt::black) - knobColor = palette().window().color(); + knobColor = palette().window().color(); QColor meterColor(m_meterColor); if (!isEnabled()) - meterColor = palette().mid().color(); + meterColor = palette().mid().color(); else if (m_meterColor == Qt::white) - meterColor = palette().highlight().color(); + meterColor = palette().highlight().color(); int m_size = width() < height() ? width() : height(); int scale = 1; @@ -157,7 +157,7 @@ pen.setColor(knobColor); pen.setWidth(scale * 2); pen.setCapStyle(Qt::FlatCap); - + paint.setPen(pen); paint.setBrush(c); @@ -169,30 +169,30 @@ int pos = indent-1 + (width-2*indent) / 20; int darkWidth = (width-2*indent) * 3 / 4; while (darkWidth) { - c = c.light(102); - pen.setColor(c); - paint.setPen(pen); - paint.drawEllipse(pos, pos, darkWidth, darkWidth); - if (!--darkWidth) break; - paint.drawEllipse(pos, pos, darkWidth, darkWidth); - if (!--darkWidth) break; - paint.drawEllipse(pos, pos, darkWidth, darkWidth); - ++pos; --darkWidth; + c = c.light(102); + pen.setColor(c); + paint.setPen(pen); + paint.drawEllipse(pos, pos, darkWidth, darkWidth); + if (!--darkWidth) break; + paint.drawEllipse(pos, pos, darkWidth, darkWidth); + if (!--darkWidth) break; + paint.drawEllipse(pos, pos, darkWidth, darkWidth); + ++pos; --darkWidth; } // Tick notches... if ( notchesVisible() ) { -// cerr << "Notches visible" << endl; - pen.setColor(palette().dark().color()); - pen.setWidth(scale); - paint.setPen(pen); - for (int i = 0; i < numTicks; ++i) { - int div = numTicks; - if (div > 1) --div; - drawTick(paint, AUDIO_DIAL_MIN + (AUDIO_DIAL_MAX - AUDIO_DIAL_MIN) * i / div, - width, true); - } +// cerr << "Notches visible" << endl; + pen.setColor(palette().dark().color()); + pen.setWidth(scale); + paint.setPen(pen); + for (int i = 0; i < numTicks; ++i) { + int div = numTicks; + if (div > 1) --div; + drawTick(paint, AUDIO_DIAL_MIN + (AUDIO_DIAL_MAX - AUDIO_DIAL_MIN) * i / div, + width, true); + } } // The bright metering bit... @@ -208,7 +208,7 @@ if (arcLen == 0) arcLen = -16; paint.drawArc(indent/2, indent/2, - width-indent, width-indent, (180 + 45) * 16, arcLen); + width-indent, width-indent, (180 + 45) * 16, arcLen); paint.setBrush(Qt::NoBrush); @@ -222,13 +222,13 @@ int shadowAngle = -720; c = knobColor.dark(); for (int arc = 120; arc < 2880; arc += 240) { - pen.setColor(c); - paint.setPen(pen); - paint.drawArc(indent, indent, - width-2*indent, width-2*indent, shadowAngle + arc, 240); - paint.drawArc(indent, indent, - width-2*indent, width-2*indent, shadowAngle - arc, 240); - c = c.light(110); + pen.setColor(c); + paint.setPen(pen); + paint.drawArc(indent, indent, + width-2*indent, width-2*indent, shadowAngle + arc, 240); + paint.drawArc(indent, indent, + width-2*indent, width-2*indent, shadowAngle - arc, 240); + c = c.light(110); } // Scale shadow, omitting the bottom part... @@ -236,21 +236,21 @@ shadowAngle = 2160; c = palette().shadow().color(); for (int i = 0; i < 5; ++i) { - pen.setColor(c); - paint.setPen(pen); + pen.setColor(c); + paint.setPen(pen); int arc = i * 240 + 120; - paint.drawArc(scale/2, scale/2, - width-scale, width-scale, shadowAngle + arc, 240); - c = c.light(110); + paint.drawArc(scale/2, scale/2, + width-scale, width-scale, shadowAngle + arc, 240); + c = c.light(110); } c = palette().shadow().color(); for (int i = 0; i < 12; ++i) { - pen.setColor(c); - paint.setPen(pen); + pen.setColor(c); + paint.setPen(pen); int arc = i * 240 + 120; - paint.drawArc(scale/2, scale/2, - width-scale, width-scale, shadowAngle - arc, 240); - c = c.light(110); + paint.drawArc(scale/2, scale/2, + width-scale, width-scale, shadowAngle - arc, 240); + c = c.light(110); } // Scale ends... @@ -259,11 +259,11 @@ pen.setWidth(scale); paint.setPen(pen); for (int i = 0; i < numTicks; ++i) { - if (i != 0 && i != numTicks - 1) continue; - int div = numTicks; - if (div > 1) --div; - drawTick(paint, AUDIO_DIAL_MIN + (AUDIO_DIAL_MAX - AUDIO_DIAL_MIN) * i / div, - width, false); + if (i != 0 && i != numTicks - 1) continue; + int div = numTicks; + if (div > 1) --div; + drawTick(paint, AUDIO_DIAL_MIN + (AUDIO_DIAL_MAX - AUDIO_DIAL_MIN) * i / div, + width, false); } // Pointer notch... @@ -289,7 +289,7 @@ void AudioDial::drawTick(QPainter &paint, - double angle, int size, bool internal) + double angle, int size, bool internal) { double hyp = double(size) / 2.0; double x0 = hyp - (hyp - 1) * sin(angle); @@ -299,19 +299,19 @@ if (internal) { - double len = hyp / 4; - double x1 = hyp - (hyp - len) * sin(angle); - double y1 = hyp + (hyp - len) * cos(angle); - - paint.drawLine(int(x0), int(y0), int(x1), int(y1)); + double len = hyp / 4; + double x1 = hyp - (hyp - len) * sin(angle); + double y1 = hyp + (hyp - len) * cos(angle); + + paint.drawLine(int(x0), int(y0), int(x1), int(y1)); } else { - double len = hyp / 4; - double x1 = hyp - (hyp + len) * sin(angle); - double y1 = hyp + (hyp + len) * cos(angle); + double len = hyp / 4; + double x1 = hyp - (hyp + len) * sin(angle); + double y1 = hyp + (hyp + len) * cos(angle); - paint.drawLine(int(x0), int(y0), int(x1), int(y1)); + paint.drawLine(int(x0), int(y0), int(x1), int(y1)); } } @@ -452,14 +452,14 @@ void AudioDial::mousePressEvent(QMouseEvent *mouseEvent) { if (m_mouseDial) { - QDial::mousePressEvent(mouseEvent); + QDial::mousePressEvent(mouseEvent); } else if (mouseEvent->button() == Qt::MidButton || ((mouseEvent->button() == Qt::LeftButton) && (mouseEvent->modifiers() & Qt::ControlModifier))) { setToDefault(); } else if (mouseEvent->button() == Qt::LeftButton) { - m_mousePressed = true; - m_posMouse = mouseEvent->pos(); + m_mousePressed = true; + m_posMouse = mouseEvent->pos(); } } @@ -469,7 +469,7 @@ //!!! needs a common base class with Thumbwheel if (m_mouseDial) { - QDial::mouseDoubleClickEvent(mouseEvent); + QDial::mouseDoubleClickEvent(mouseEvent); } else if (mouseEvent->button() != Qt::LeftButton) { return; } @@ -541,19 +541,19 @@ void AudioDial::mouseMoveEvent(QMouseEvent *mouseEvent) { if (m_mouseDial) { - QDial::mouseMoveEvent(mouseEvent); + QDial::mouseMoveEvent(mouseEvent); } else if (m_mousePressed) { - const QPoint& posMouse = mouseEvent->pos(); - int v = QDial::value() - + (posMouse.x() - m_posMouse.x()) - + (m_posMouse.y() - posMouse.y()); - if (v > QDial::maximum()) - v = QDial::maximum(); - else - if (v < QDial::minimum()) - v = QDial::minimum(); - m_posMouse = posMouse; - QDial::setValue(v); + const QPoint& posMouse = mouseEvent->pos(); + int v = QDial::value() + + (posMouse.x() - m_posMouse.x()) + + (m_posMouse.y() - posMouse.y()); + if (v > QDial::maximum()) + v = QDial::maximum(); + else + if (v < QDial::minimum()) + v = QDial::minimum(); + m_posMouse = posMouse; + QDial::setValue(v); } } @@ -561,9 +561,9 @@ void AudioDial::mouseReleaseEvent(QMouseEvent *mouseEvent) { if (m_mouseDial) { - QDial::mouseReleaseEvent(mouseEvent); + QDial::mouseReleaseEvent(mouseEvent); } else if (m_mousePressed) { - m_mousePressed = false; + m_mousePressed = false; } }
--- a/widgets/CSVFormatDialog.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/CSVFormatDialog.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -49,7 +49,7 @@ int row = 0; layout->addWidget(new QLabel(tr("Please select the correct data format for this file.")), - row++, 0, 1, 4); + row++, 0, 1, 4); QFrame *exampleFrame = new QFrame; exampleFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); @@ -136,7 +136,7 @@ layout->addWidget(m_timingTypeCombo, row++, 1, 1, 2); connect(m_timingTypeCombo, SIGNAL(activated(int)), - this, SLOT(timingTypeChanged(int))); + this, SLOT(timingTypeChanged(int))); m_initialTimingOption = TimingImplicit; if (m_format.getTimingType() == CSVFormat::ExplicitTiming) { @@ -157,14 +157,14 @@ layout->addWidget(m_sampleRateLabel, row, 0); int sampleRates[] = { - 8000, 11025, 12000, 22050, 24000, 32000, - 44100, 48000, 88200, 96000, 176400, 192000 + 8000, 11025, 12000, 22050, 24000, 32000, + 44100, 48000, 88200, 96000, 176400, 192000 }; m_sampleRateCombo = new QComboBox; for (int i = 0; i < int(sizeof(sampleRates) / sizeof(sampleRates[0])); ++i) { - m_sampleRateCombo->addItem(QString("%1").arg(sampleRates[i])); - if (sampleRates[i] == m_format.getSampleRate()) { + m_sampleRateCombo->addItem(QString("%1").arg(sampleRates[i])); + if (sampleRates[i] == m_format.getSampleRate()) { m_sampleRateCombo->setCurrentIndex(i); } } @@ -172,18 +172,18 @@ layout->addWidget(m_sampleRateCombo, row++, 1); connect(m_sampleRateCombo, SIGNAL(activated(QString)), - this, SLOT(sampleRateChanged(QString))); + this, SLOT(sampleRateChanged(QString))); connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)), - this, SLOT(sampleRateChanged(QString))); + this, SLOT(sampleRateChanged(QString))); m_windowSizeLabel = new QLabel(tr("Frame increment between rows:")); layout->addWidget(m_windowSizeLabel, row, 0); m_windowSizeCombo = new QComboBox; for (int i = 0; i <= 16; ++i) { - int value = 1 << i; - m_windowSizeCombo->addItem(QString("%1").arg(value)); - if (value == int(m_format.getWindowSize())) { + int value = 1 << i; + m_windowSizeCombo->addItem(QString("%1").arg(value)); + if (value == int(m_format.getWindowSize())) { m_windowSizeCombo->setCurrentIndex(i); } } @@ -191,9 +191,9 @@ layout->addWidget(m_windowSizeCombo, row++, 1); connect(m_windowSizeCombo, SIGNAL(activated(QString)), - this, SLOT(windowSizeChanged(QString))); + this, SLOT(windowSizeChanged(QString))); connect(m_windowSizeCombo, SIGNAL(editTextChanged(QString)), - this, SLOT(windowSizeChanged(QString))); + this, SLOT(windowSizeChanged(QString))); m_modelLabel = new QLabel; QFont f(m_modelLabel->font()); @@ -419,24 +419,24 @@ switch (TimingOption(m_timingTypeCombo->currentIndex())) { case TimingExplicitSeconds: - m_format.setTimingType(CSVFormat::ExplicitTiming); - m_format.setTimeUnits(CSVFormat::TimeSeconds); - break; + m_format.setTimingType(CSVFormat::ExplicitTiming); + m_format.setTimeUnits(CSVFormat::TimeSeconds); + break; case TimingExplicitMsec: - m_format.setTimingType(CSVFormat::ExplicitTiming); - m_format.setTimeUnits(CSVFormat::TimeMilliseconds); - break; + m_format.setTimingType(CSVFormat::ExplicitTiming); + m_format.setTimeUnits(CSVFormat::TimeMilliseconds); + break; case TimingExplicitSamples: - m_format.setTimingType(CSVFormat::ExplicitTiming); - m_format.setTimeUnits(CSVFormat::TimeAudioFrames); - break; + m_format.setTimingType(CSVFormat::ExplicitTiming); + m_format.setTimeUnits(CSVFormat::TimeAudioFrames); + break; case TimingImplicit: - m_format.setTimingType(CSVFormat::ImplicitTiming); - m_format.setTimeUnits(CSVFormat::TimeWindows); - break; + m_format.setTimingType(CSVFormat::ImplicitTiming); + m_format.setTimeUnits(CSVFormat::TimeWindows); + break; } bool haveStartTime = false;
--- a/widgets/ColourComboBox.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/ColourComboBox.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -40,7 +40,7 @@ this, SLOT(rebuild())); if (count() < 20 && count() > maxVisibleItems()) { - setMaxVisibleItems(count()); + setMaxVisibleItems(count()); } } @@ -48,9 +48,9 @@ ColourComboBox::comboActivated(int index) { if (!m_withAddNewColourEntry || - index < int(ColourDatabase::getInstance()->getColourCount())) { - emit colourChanged(index); - return; + index < int(ColourDatabase::getInstance()->getColourCount())) { + emit colourChanged(index); + return; } QColor newColour = QColorDialog::getColor(); @@ -65,10 +65,10 @@ ColourDatabase *db = ColourDatabase::getInstance(); int index = db->addColour(newColour, dialog.getColourName()); db->setUseDarkBackground(index, dialog.isDarkBackgroundChecked()); - // addColour will have called back on rebuild(), and the new - // colour will be at the index previously occupied by Add New - // Colour, which is our current index - emit colourChanged(currentIndex()); + // addColour will have called back on rebuild(), and the new + // colour will be at the index previously occupied by Add New + // Colour, which is our current index + emit colourChanged(currentIndex()); } } @@ -86,12 +86,12 @@ ColourDatabase *db = ColourDatabase::getInstance(); for (int i = 0; i < db->getColourCount(); ++i) { - QString name = db->getColourName(i); - addItem(db->getExamplePixmap(i, QSize(size, size)), name); + QString name = db->getColourName(i); + addItem(db->getExamplePixmap(i, QSize(size, size)), name); } if (m_withAddNewColourEntry) { - addItem(tr("Add New Colour...")); + addItem(tr("Add New Colour...")); } setCurrentIndex(ix);
--- a/widgets/ColourMapComboBox.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/ColourMapComboBox.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -35,7 +35,7 @@ connect(this, SIGNAL(activated(int)), this, SLOT(comboActivated(int))); if (count() < 20 && count() > maxVisibleItems()) { - setMaxVisibleItems(count()); + setMaxVisibleItems(count()); } }
--- a/widgets/ColourNameDialog.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/ColourNameDialog.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -25,8 +25,8 @@ #include <QPushButton> ColourNameDialog::ColourNameDialog(QString title, QString message, - QColor colour, QString defaultName, - QWidget *parent) : + QColor colour, QString defaultName, + QWidget *parent) : QDialog(parent), m_colour(colour) {
--- a/widgets/ColourNameDialog.h Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/ColourNameDialog.h Thu Mar 01 18:02:22 2018 +0000 @@ -31,8 +31,8 @@ public: ColourNameDialog(QString title, QString message, QColor colour, - QString defaultName, - QWidget *parent = 0); + QString defaultName, + QWidget *parent = 0); void showDarkBackgroundCheckbox(QString text);
--- a/widgets/CommandHistory.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/CommandHistory.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -70,7 +70,7 @@ m_undoMenu = new QMenu(tr("&Undo")); m_undoMenuAction->setMenu(m_undoMenu); connect(m_undoMenu, SIGNAL(triggered(QAction *)), - this, SLOT(undoActivated(QAction*))); + this, SLOT(undoActivated(QAction*))); m_redoAction = new QAction(redoIcon, tr("Re&do"), this); m_redoAction->setShortcut(tr("Ctrl+Shift+Z")); @@ -83,7 +83,7 @@ m_redoMenu = new QMenu(tr("Re&do")); m_redoMenuAction->setMenu(m_redoMenu); connect(m_redoMenu, SIGNAL(triggered(QAction *)), - this, SLOT(redoActivated(QAction*))); + this, SLOT(redoActivated(QAction*))); } CommandHistory::~CommandHistory() @@ -136,8 +136,8 @@ if (!command) return; if (m_currentCompound) { - addToCompound(command, m_executeCompound); - return; + addToCompound(command, m_executeCompound); + return; } addCommand(command, true); @@ -153,15 +153,15 @@ #endif if (m_currentCompound) { - addToCompound(command, execute); - return; + addToCompound(command, execute); + return; } if (bundle) { - addToBundle(command, execute); - return; + addToBundle(command, execute); + return; } else if (m_currentBundle) { - closeBundle(); + closeBundle(); } #ifdef DEBUG_COMMAND_HISTORY @@ -180,7 +180,7 @@ clipCommands(); if (execute) { - command->execute(); + command->execute(); } // Emit even if we aren't executing the command, because @@ -196,13 +196,13 @@ CommandHistory::addToBundle(Command *command, bool execute) { if (m_currentBundle) { - if (!command || (command->getName() != m_currentBundleName)) { + if (!command || (command->getName() != m_currentBundleName)) { #ifdef DEBUG_COMMAND_HISTORY cerr << "CommandHistory::addToBundle: " << command->getName() << ": closing current bundle" << endl; #endif - closeBundle(); - } + closeBundle(); + } } if (!command) return; @@ -214,14 +214,14 @@ << ": creating new bundle" << endl; #endif - // need to addCommand before setting m_currentBundle, as addCommand - // with bundle false will reset m_currentBundle to 0 - MacroCommand *mc = new BundleCommand(command->getName()); + // need to addCommand before setting m_currentBundle, as addCommand + // with bundle false will reset m_currentBundle to 0 + MacroCommand *mc = new BundleCommand(command->getName()); m_bundling = true; - addCommand(mc, false); + addCommand(mc, false); m_bundling = false; - m_currentBundle = mc; - m_currentBundleName = command->getName(); + m_currentBundle = mc; + m_currentBundleName = command->getName(); } #ifdef DEBUG_COMMAND_HISTORY @@ -272,7 +272,7 @@ CommandHistory::addToCompound(Command *command, bool execute) { if (!m_currentCompound) { - cerr << "CommandHistory::addToCompound: ERROR: no compound operation in progress!" << endl; + cerr << "CommandHistory::addToCompound: ERROR: no compound operation in progress!" << endl; return; } @@ -288,8 +288,8 @@ CommandHistory::startCompoundOperation(QString name, bool execute) { if (m_currentCompound) { - cerr << "CommandHistory::startCompoundOperation: ERROR: compound operation already in progress!" << endl; - cerr << "(name is " << m_currentCompound->getName() << ")" << endl; + cerr << "CommandHistory::startCompoundOperation: ERROR: compound operation already in progress!" << endl; + cerr << "(name is " << m_currentCompound->getName() << ")" << endl; return; } @@ -307,7 +307,7 @@ CommandHistory::endCompoundOperation() { if (!m_currentCompound) { - cerr << "CommandHistory::endCompoundOperation: ERROR: no compound operation in progress!" << endl; + cerr << "CommandHistory::endCompoundOperation: ERROR: no compound operation in progress!" << endl; return; } @@ -433,7 +433,7 @@ CommandHistory::clipCommands() { if (int(m_undoStack.size()) > m_undoLimit) { - m_savedAt -= (int(m_undoStack.size()) - m_undoLimit); + m_savedAt -= (int(m_undoStack.size()) - m_undoLimit); } clipStack(m_undoStack, m_undoLimit); @@ -447,23 +447,23 @@ if ((int)stack.size() > limit) { - CommandStack tempStack; + CommandStack tempStack; - for (i = 0; i < limit; ++i) { + for (i = 0; i < limit; ++i) { #ifdef DEBUG_COMMAND_HISTORY - Command *command = stack.top(); - cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName() << " at " << command << endl; + Command *command = stack.top(); + cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName() << " at " << command << endl; #endif - tempStack.push(stack.top()); - stack.pop(); - } + tempStack.push(stack.top()); + stack.pop(); + } - clearStack(stack); + clearStack(stack); - for (i = 0; i < m_undoLimit; ++i) { - stack.push(tempStack.top()); - tempStack.pop(); - } + for (i = 0; i < m_undoLimit; ++i) { + stack.push(tempStack.top()); + tempStack.pop(); + } } } @@ -471,13 +471,13 @@ CommandHistory::clearStack(CommandStack &stack) { while (!stack.empty()) { - Command *command = stack.top(); - // Not safe to call getName() on a command about to be deleted + Command *command = stack.top(); + // Not safe to call getName() on a command about to be deleted #ifdef DEBUG_COMMAND_HISTORY - cerr << "CommandHistory::clearStack: About to delete command " << command << endl; + cerr << "CommandHistory::clearStack: About to delete command " << command << endl; #endif - delete command; - stack.pop(); + delete command; + stack.pop(); } } @@ -486,7 +486,7 @@ { int pos = m_actionCounts[action]; for (int i = 0; i <= pos; ++i) { - undo(); + undo(); } } @@ -495,7 +495,7 @@ { int pos = m_actionCounts[action]; for (int i = 0; i <= pos; ++i) { - redo(); + redo(); } } @@ -506,62 +506,62 @@ for (int undo = 0; undo <= 1; ++undo) { - QAction *action(undo ? m_undoAction : m_redoAction); - QAction *menuAction(undo ? m_undoMenuAction : m_redoMenuAction); - QMenu *menu(undo ? m_undoMenu : m_redoMenu); - CommandStack &stack(undo ? m_undoStack : m_redoStack); + QAction *action(undo ? m_undoAction : m_redoAction); + QAction *menuAction(undo ? m_undoMenuAction : m_redoMenuAction); + QMenu *menu(undo ? m_undoMenu : m_redoMenu); + CommandStack &stack(undo ? m_undoStack : m_redoStack); - if (stack.empty()) { + if (stack.empty()) { - QString text(undo ? tr("Nothing to undo") : tr("Nothing to redo")); + QString text(undo ? tr("Nothing to undo") : tr("Nothing to redo")); - action->setEnabled(false); - action->setText(text); + action->setEnabled(false); + action->setText(text); - menuAction->setEnabled(false); - menuAction->setText(text); + menuAction->setEnabled(false); + menuAction->setText(text); - } else { + } else { - action->setEnabled(true); - menuAction->setEnabled(true); + action->setEnabled(true); + menuAction->setEnabled(true); - QString commandName = stack.top()->getName(); - commandName.replace(QRegExp("&"), ""); + QString commandName = stack.top()->getName(); + commandName.replace(QRegExp("&"), ""); - QString text = (undo ? tr("&Undo %1") : tr("Re&do %1")) - .arg(commandName); + QString text = (undo ? tr("&Undo %1") : tr("Re&do %1")) + .arg(commandName); - action->setText(text); - menuAction->setText(text); - } + action->setText(text); + menuAction->setText(text); + } - menu->clear(); + menu->clear(); - CommandStack tempStack; - int j = 0; + CommandStack tempStack; + int j = 0; - while (j < m_menuLimit && !stack.empty()) { + while (j < m_menuLimit && !stack.empty()) { - Command *command = stack.top(); - tempStack.push(command); - stack.pop(); + Command *command = stack.top(); + tempStack.push(command); + stack.pop(); - QString commandName = command->getName(); - commandName.replace(QRegExp("&"), ""); + QString commandName = command->getName(); + commandName.replace(QRegExp("&"), ""); - QString text; - if (undo) text = tr("&Undo %1").arg(commandName); - else text = tr("Re&do %1").arg(commandName); - - QAction *action = menu->addAction(text); - m_actionCounts[action] = j++; - } + QString text; + if (undo) text = tr("&Undo %1").arg(commandName); + else text = tr("Re&do %1").arg(commandName); + + QAction *action = menu->addAction(text); + m_actionCounts[action] = j++; + } - while (!tempStack.empty()) { - stack.push(tempStack.top()); - tempStack.pop(); - } + while (!tempStack.empty()) { + stack.push(tempStack.top()); + tempStack.pop(); + } } }
--- a/widgets/Fader.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/Fader.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -59,25 +59,25 @@ QString background_path = ":/icons/fader_background.png"; bool ok = m_back.load(background_path); if (ok == false) { - cerr << "Fader: Error loading pixmap" << endl; + cerr << "Fader: Error loading pixmap" << endl; } QString leds_path = ":/icons/fader_leds.png"; ok = m_leds.load(leds_path); if (ok == false) { - cerr << "Error loading pixmap" << endl; + cerr << "Error loading pixmap" << endl; } QString knob_path = ":/icons/fader_knob.png"; ok = m_knob.load(knob_path); if (ok == false) { - cerr << "Error loading pixmap" << endl; + cerr << "Error loading pixmap" << endl; } QString clip_path = ":/icons/fader_knob_red.png"; ok = m_clip.load(clip_path); if (ok == false) { - cerr << "Error loading pixmap" << endl; + cerr << "Error loading pixmap" << endl; } } @@ -111,7 +111,7 @@ if (vx < 0) vx = 0; float fval = (float)AudioLevel::fader_to_multiplier - (vx, getMaxX(), AudioLevel::LongFader); + (vx, getMaxX(), AudioLevel::LongFader); setValue(fval); emit valueChanged(fval); @@ -179,9 +179,9 @@ //!!! needs improvement if (ev->delta() > 0) { - setValue(m_value * 1.f); + setValue(m_value * 1.f); } else { - setValue(m_value / 1.f); + setValue(m_value / 1.f); } update(); @@ -206,27 +206,27 @@ float max = (float)AudioLevel::dB_to_multiplier(10.0); if (v > max) { - v = max; + v = max; } else if (v < 0.0) { - v = 0.0; + v = 0.0; } if (m_value != v) { - m_value = v; - float db = (float)AudioLevel::multiplier_to_dB(m_value); + m_value = v; + float db = (float)AudioLevel::multiplier_to_dB(m_value); QString text; - if (db <= AudioLevel::DB_FLOOR) { + if (db <= AudioLevel::DB_FLOOR) { text = tr("Level: Off"); - } else { + } else { text = tr("Level: %1%2.%3%4 dB") .arg(db < 0.0 ? "-" : "") .arg(abs(int(db))) .arg(abs(int(db * 10.0) % 10)) .arg(abs(int(db * 100.0) % 10)); - } + } cerr << "Fader: setting tooltip to \"" << text << "\"" << endl; QWidget::setToolTip(text); - update(); + update(); } } @@ -243,8 +243,8 @@ Fader::setPeakLeft(float peak) { if (this->m_peakLeft != peak) { - this->m_peakLeft = peak; - update(); + this->m_peakLeft = peak; + update(); } } @@ -253,8 +253,8 @@ Fader::setPeakRight(float peak) { if (this->m_peakRight != peak) { - this->m_peakRight = peak; - update(); + this->m_peakRight = peak; + update(); } } @@ -268,30 +268,30 @@ painter.drawPixmap(rect(), m_back, QRect(0, 0, 116, 23)); int offset_L = AudioLevel::multiplier_to_fader(m_peakLeft, 116, - AudioLevel::IEC268LongMeter); + AudioLevel::IEC268LongMeter); painter.drawPixmap(QRect(0, 0, offset_L, 11), m_leds, - QRect(0, 0, offset_L, 11)); + QRect(0, 0, offset_L, 11)); int offset_R = AudioLevel::multiplier_to_fader(m_peakRight, 116, - AudioLevel::IEC268LongMeter); + AudioLevel::IEC268LongMeter); painter.drawPixmap(QRect(0, 11, offset_R, 11), m_leds, - QRect(0, 11, offset_R, 11)); + QRect(0, 11, offset_R, 11)); if (m_withoutKnob == false) { - static const uint knob_width = 29; - static const uint knob_height = 9; + static const uint knob_width = 29; + static const uint knob_height = 9; - int x = AudioLevel::multiplier_to_fader(m_value, 116 - knob_width, - AudioLevel::LongFader); + int x = AudioLevel::multiplier_to_fader(m_value, 116 - knob_width, + AudioLevel::LongFader); - bool clipping = (m_peakLeft > 1.0 || m_peakRight > 1.0); + bool clipping = (m_peakLeft > 1.0 || m_peakRight > 1.0); - painter.drawPixmap(QRect(x, 7, knob_width, knob_height), - clipping ? m_clip : m_knob, - QRect(0, 0, knob_width, knob_height)); + painter.drawPixmap(QRect(x, 7, knob_width, knob_height), + clipping ? m_clip : m_knob, + QRect(0, 0, knob_width, knob_height)); } }
--- a/widgets/IconLoader.h Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/IconLoader.h Thu Mar 01 18:02:22 2018 +0000 @@ -38,4 +38,4 @@ #endif - +
--- a/widgets/LEDButton.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LEDButton.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -88,10 +88,10 @@ cerr << "LEDButton(" << this << ")::mousePressEvent" << endl; if (e->buttons() & Qt::LeftButton) { - toggle(); - bool newState = state(); - SVDEBUG << "emitting new state " << newState << endl; - emit stateChanged(newState); + toggle(); + bool newState = state(); + SVDEBUG << "emitting new state " << newState << endl; + emit stateChanged(newState); } } @@ -114,17 +114,17 @@ QColor color; QBrush brush; QPen pen; - + // First of all we want to know what area should be updated // Initialize coordinates, width, and height of the LED - int width = this->width(); + int width = this->width(); // Make sure the LED is round! if (width > this->height()) - width = this->height(); + width = this->height(); width -= 2; // leave one pixel border if (width < 0) - width = 0; + width = 0; paint.begin(this); @@ -154,25 +154,25 @@ int light_width = width; light_width *= 2; light_width /= 3; - + // Calculate the LED´s "light factor": int light_quote = (130*2/(light_width?light_width:1))+100; // Now draw the bright spot on the LED: while (light_width) { - color = color.light( light_quote ); // make color lighter - pen.setColor( color ); // set color as pen color - paint.setPen( pen ); // select the pen for drawing - paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle) - light_width--; - if (!light_width) - break; - paint.drawEllipse( pos, pos, light_width, light_width ); - light_width--; - if (!light_width) - break; - paint.drawEllipse( pos, pos, light_width, light_width ); - pos++; light_width--; + color = color.light( light_quote ); // make color lighter + pen.setColor( color ); // set color as pen color + paint.setPen( pen ); // select the pen for drawing + paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle) + light_width--; + if (!light_width) + break; + paint.drawEllipse( pos, pos, light_width, light_width ); + light_width--; + if (!light_width) + break; + paint.drawEllipse( pos, pos, light_width, light_width ); + pos++; light_width--; } paint.drawPoint(pos, pos); @@ -192,13 +192,13 @@ color = palette().light().color(); for (int arc = 120; arc < 2880; arc += 240) { - pen.setColor(color); - paint.setPen(pen); - int w = width - pen.width()/2; - paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle + arc, 240); - paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle - arc, 240); - color = color.dark(110); //FIXME: this should somehow use the contrast value - } // end for ( angle = 720; angle < 6480; angle += 160 ) + pen.setColor(color); + paint.setPen(pen); + int w = width - pen.width()/2; + paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle + arc, 240); + paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle - arc, 240); + color = color.dark(110); //FIXME: this should somehow use the contrast value + } // end for ( angle = 720; angle < 6480; angle += 160 ) paint.end(); } @@ -220,8 +220,8 @@ { if (led_state != state) { - led_state = state; - update(); + led_state = state; + update(); } } @@ -237,9 +237,9 @@ LEDButton::setColor(const QColor& col) { if(led_color!=col) { - led_color = col; - d->offcolor = col.dark(d->dark_factor); - update(); + led_color = col; + d->offcolor = col.dark(d->dark_factor); + update(); } } @@ -247,9 +247,9 @@ LEDButton::setDarkFactor(int darkfactor) { if (d->dark_factor != darkfactor) { - d->dark_factor = darkfactor; - d->offcolor = led_color.dark(darkfactor); - update(); + d->dark_factor = darkfactor; + d->offcolor = led_color.dark(darkfactor); + update(); } }
--- a/widgets/LabelCounterInputDialog.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LabelCounterInputDialog.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -22,7 +22,7 @@ #include <QDialogButtonBox> LabelCounterInputDialog::LabelCounterInputDialog(Labeller *labeller, - QWidget *parent) : + QWidget *parent) : QDialog(parent), m_labeller(labeller) {
--- a/widgets/LayerTree.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LayerTree.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -220,14 +220,14 @@ QVariant ModelMetadataModel::headerData(int section, - Qt::Orientation orientation, - int role) const + Qt::Orientation orientation, + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - if (section == m_modelTypeColumn) return QVariant(tr("Type")); - else if (section == m_modelNameColumn) return QVariant(tr("Name")); - else if (section == m_modelMakerColumn) return QVariant(tr("Maker")); - else if (section == m_modelSourceColumn) return QVariant(tr("Source")); + if (section == m_modelTypeColumn) return QVariant(tr("Type")); + else if (section == m_modelNameColumn) return QVariant(tr("Name")); + else if (section == m_modelMakerColumn) return QVariant(tr("Maker")); + else if (section == m_modelSourceColumn) return QVariant(tr("Source")); } return QVariant(); @@ -238,7 +238,7 @@ { if (!parent.isValid()) { if (row >= (int)m_models.size()) return QModelIndex(); - return createIndex(row, column, (void *)0); + return createIndex(row, column, (void *)0); } return QModelIndex(); @@ -507,14 +507,14 @@ QVariant LayerTreeModel::headerData(int section, - Qt::Orientation orientation, - int role) const + Qt::Orientation orientation, + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - if (section == m_layerNameColumn) return QVariant(tr("Layer")); + if (section == m_layerNameColumn) return QVariant(tr("Layer")); else if (section == m_layerVisibleColumn) return QVariant(tr("Shown")); else if (section == m_layerPlayedColumn) return QVariant(tr("Played")); - else if (section == m_modelNameColumn) return QVariant(tr("Model")); + else if (section == m_modelNameColumn) return QVariant(tr("Model")); } return QVariant(); @@ -531,7 +531,7 @@ if (!parent.isValid()) { if (row >= m_stack->getPaneCount() || column > 0) return QModelIndex(); - return createIndex(row, column, m_stack); + return createIndex(row, column, m_stack); } QObject *obj = static_cast<QObject *>(parent.internalPointer());
--- a/widgets/LevelPanToolButton.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LevelPanToolButton.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -141,10 +141,10 @@ LevelPanToolButton::selfLevelChanged(float level) { if (level > 0.f) { - m_muted = false; + m_muted = false; } else { - m_muted = true; - m_savedLevel = 1.f; + m_muted = true; + m_savedLevel = 1.f; } update(); } @@ -153,14 +153,14 @@ LevelPanToolButton::selfClicked() { if (m_muted) { - m_muted = false; - m_lpw->setLevel(m_savedLevel); - emit levelChanged(m_savedLevel); + m_muted = false; + m_lpw->setLevel(m_savedLevel); + emit levelChanged(m_savedLevel); } else { - m_savedLevel = m_lpw->getLevel(); - m_muted = true; - m_lpw->setLevel(0.f); - emit levelChanged(0.f); + m_savedLevel = m_lpw->getLevel(); + m_muted = true; + m_lpw->setLevel(0.f); + emit levelChanged(0.f); } update(); }
--- a/widgets/LevelPanToolButton.h Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LevelPanToolButton.h Thu Mar 01 18:02:22 2018 +0000 @@ -37,9 +37,9 @@ bool includesMute() const; void setImageSize(int pixels); - + void setBigImageSize(int pixels); - + public slots: /// Set level in the range [0,1] -- will be rounded void setLevel(float);
--- a/widgets/LevelPanWidget.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LevelPanWidget.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -124,12 +124,12 @@ { int level = audioLevelToLevel(flevel, m_includeMute); if (level != m_level) { - m_level = level; - float convertsTo = getLevel(); - if (fabsf(convertsTo - flevel) > 1e-5) { - emitLevelChanged(); - } - update(); + m_level = level; + float convertsTo = getLevel(); + if (fabsf(convertsTo - flevel) > 1e-5) { + emitLevelChanged(); + } + update(); } } @@ -247,15 +247,15 @@ int level, pan; toCell(rect(), e->pos(), level, pan); if (level == m_level && pan == m_pan) { - return; + return; } if (level != m_level) { - m_level = level; - emitLevelChanged(); + m_level = level; + emitLevelChanged(); } if (pan != m_pan) { - m_pan = pan; - emitPanChanged(); + m_pan = pan; + emitPanChanged(); } update(); } @@ -264,33 +264,33 @@ LevelPanWidget::wheelEvent(QWheelEvent *e) { if (e->modifiers() & Qt::ControlModifier) { - if (e->delta() > 0) { - if (m_pan < maxPan) { - ++m_pan; - emitPanChanged(); - update(); - } - } else { - if (m_pan > -maxPan) { - --m_pan; - emitPanChanged(); - update(); - } - } + if (e->delta() > 0) { + if (m_pan < maxPan) { + ++m_pan; + emitPanChanged(); + update(); + } + } else { + if (m_pan > -maxPan) { + --m_pan; + emitPanChanged(); + update(); + } + } } else { - if (e->delta() > 0) { - if (m_level < maxLevel) { - ++m_level; - emitLevelChanged(); - update(); - } - } else { - if (m_level > 0) { - --m_level; - emitLevelChanged(); - update(); - } - } + if (e->delta() > 0) { + if (m_level < maxLevel) { + ++m_level; + emitLevelChanged(); + update(); + } + } else { + if (m_level > 0) { + --m_level; + emitLevelChanged(); + update(); + } + } } } @@ -328,7 +328,7 @@ { QSizeF cs = cellSize(rect); return QPointF(rect.x() + cs.width() * (pan + maxPan) + cs.width() / 2., - rect.y() + rect.height() - cs.height() * (level + 1) + cs.height() / 2.); + rect.y() + rect.height() - cs.height() * (level + 1) + cs.height() / 2.); } QSizeF @@ -346,9 +346,9 @@ QSizeF cls = cellLightSize(rect); QPointF cc = cellCentre(rect, level, pan); return QRectF(cc.x() - cls.width() / 2., - cc.y() - cls.height() / 2., - cls.width(), - cls.height()); + cc.y() - cls.height() / 2., + cls.width(), + cls.height()); } double @@ -388,7 +388,7 @@ paint.setBrush(Qt::NoBrush); for (int pan = -maxPan; pan <= maxPan; ++pan) { - paint.drawLine(cellCentre(rect, 0, pan), cellCentre(rect, maxLevel, pan)); + paint.drawLine(cellCentre(rect, 0, pan), cellCentre(rect, maxLevel, pan)); } if (m_monitorLeft > 0.f || m_monitorRight > 0.f) { @@ -413,9 +413,9 @@ } if (isEnabled()) { - pen.setColor(Qt::black); + pen.setColor(Qt::black); } else { - pen.setColor(Qt::darkGray); + pen.setColor(Qt::darkGray); } if (!asIfEditable && m_includeMute && m_level == 0) { @@ -434,16 +434,16 @@ paint.setPen(pen); for (int level = 0; level <= m_level; ++level) { - if (isEnabled()) { - paint.setBrush(level_to_colour(level)); - } - QRectF clr = cellLightRect(rect, level, m_pan); - if (m_includeMute && m_level == 0) { - paint.drawLine(clr.topLeft(), clr.bottomRight()); - paint.drawLine(clr.bottomLeft(), clr.topRight()); - } else { - paint.drawEllipse(clr); - } + if (isEnabled()) { + paint.setBrush(level_to_colour(level)); + } + QRectF clr = cellLightRect(rect, level, m_pan); + if (m_includeMute && m_level == 0) { + paint.drawLine(clr.topLeft(), clr.bottomRight()); + paint.drawLine(clr.bottomLeft(), clr.topRight()); + } else { + paint.drawEllipse(clr); + } } }
--- a/widgets/ListInputDialog.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/ListInputDialog.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -24,8 +24,8 @@ #include <QDialogButtonBox> ListInputDialog::ListInputDialog(QWidget *parent, const QString &title, - const QString &labelText, const QStringList &list, - int current) : + const QString &labelText, const QStringList &list, + int current) : QDialog(parent), m_strings(list) {
--- a/widgets/PluginParameterDialog.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/PluginParameterDialog.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -43,7 +43,7 @@ #include "base/Debug.h" PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin, - QWidget *parent) : + QWidget *parent) : QDialog(parent), m_plugin(plugin), m_channel(-1),
--- a/widgets/PropertyBox.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/PropertyBox.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -62,7 +62,7 @@ { #ifdef DEBUG_PROPERTY_BOX cerr << "PropertyBox[" << this << "(\"" << - container->getPropertyContainerName() << "\" at " << container << ")]::PropertyBox" << endl; + container->getPropertyContainerName() << "\" at " << container << ")]::PropertyBox" << endl; #endif m_mainBox = new QVBoxLayout; @@ -98,7 +98,7 @@ size_t i; for (i = 0; i < properties.size(); ++i) { - updatePropertyEditor(properties[i]); + updatePropertyEditor(properties[i]); } blockSignals(false); @@ -128,18 +128,18 @@ #endif if (m_viewPlayFrame) { - delete m_viewPlayFrame; - m_viewPlayFrame = 0; + delete m_viewPlayFrame; + m_viewPlayFrame = 0; } if (!m_container) return; Layer *layer = dynamic_cast<Layer *>(m_container); if (layer) { - disconnect(layer, SIGNAL(modelReplaced()), + disconnect(layer, SIGNAL(modelReplaced()), this, SLOT(populateViewPlayFrame())); - connect(layer, SIGNAL(modelReplaced()), - this, SLOT(populateViewPlayFrame())); + connect(layer, SIGNAL(modelReplaced()), + this, SLOT(populateViewPlayFrame())); } PlayParameters *params = m_container->getPlayParameters(); @@ -169,14 +169,14 @@ m_playButton->setToolTip(tr("Click to toggle playback")); m_playButton->setChecked(!params->isPlayMuted()); m_playButton->setFixedSize(buttonSize); - connect(m_playButton, SIGNAL(toggled(bool)), - this, SLOT(playAudibleButtonChanged(bool))); + connect(m_playButton, SIGNAL(toggled(bool)), + this, SLOT(playAudibleButtonChanged(bool))); connect(m_playButton, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(m_playButton, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); - connect(params, SIGNAL(playAudibleChanged(bool)), - this, SLOT(playAudibleChanged(bool))); + connect(params, SIGNAL(playAudibleChanged(bool)), + this, SLOT(playAudibleChanged(bool))); LevelPanToolButton *levelPan = new LevelPanToolButton; levelPan->setFixedSize(buttonSize); @@ -195,7 +195,7 @@ connect(levelPan, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); - layout->addWidget(m_playButton, 0, col++, Qt::AlignCenter); + layout->addWidget(m_playButton, 0, col++, Qt::AlignCenter); if (params->getPlayClipId() != "") { NotifyingToolButton *playParamButton = new NotifyingToolButton; @@ -216,13 +216,13 @@ if (layer) { - QLabel *showLabel = new QLabel(tr("Show")); - layout->addWidget(showLabel, 0, col++, Qt::AlignVCenter | Qt::AlignRight); + QLabel *showLabel = new QLabel(tr("Show")); + layout->addWidget(showLabel, 0, col++, Qt::AlignVCenter | Qt::AlignRight); - m_showButton = new LEDButton(palette().highlight().color()); - layout->addWidget(m_showButton, 0, col++, Qt::AlignVCenter | Qt::AlignLeft); - connect(m_showButton, SIGNAL(stateChanged(bool)), - this, SIGNAL(showLayer(bool))); + m_showButton = new LEDButton(palette().highlight().color()); + layout->addWidget(m_showButton, 0, col++, Qt::AlignVCenter | Qt::AlignLeft); + connect(m_showButton, SIGNAL(stateChanged(bool)), + this, SIGNAL(showLayer(bool))); connect(m_showButton, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(m_showButton, SIGNAL(mouseLeft()), @@ -241,7 +241,7 @@ value = m_container->getPropertyRangeAndValue(name, &min, &max, &deflt); bool have = (m_propertyControllers.find(name) != - m_propertyControllers.end()); + m_propertyControllers.end()); QString groupName = m_container->getPropertyGroupName(name); QString propertyLabel = m_container->getPropertyLabel(name); @@ -249,11 +249,11 @@ #ifdef DEBUG_PROPERTY_BOX cerr << "PropertyBox[" << this - << "(\"" << m_container->getPropertyContainerName() - << "\")]"; + << "(\"" << m_container->getPropertyContainerName() + << "\")]"; cerr << "::updatePropertyEditor(\"" << name << "\"):"; cerr << " value " << value << ", have " << have << ", group \"" - << groupName << "\"" << endl; + << groupName << "\"" << endl; #endif QString groupLabel = groupName; @@ -300,9 +300,9 @@ { QAbstractButton *button; - if (!(button = qobject_cast<QAbstractButton *>(existing))) { + if (!(button = qobject_cast<QAbstractButton *>(existing))) { #ifdef DEBUG_PROPERTY_BOX - cerr << "PropertyBox: creating new checkbox" << endl; + cerr << "PropertyBox: creating new checkbox" << endl; #endif if (iconName != "") { button = new NotifyingPushButton(); @@ -315,8 +315,8 @@ button = new NotifyingCheckBox(); button->setObjectName(name); } - connect(button, SIGNAL(toggled(bool)), - this, SLOT(propertyControllerChanged(bool))); + connect(button, SIGNAL(toggled(bool)), + this, SLOT(propertyControllerChanged(bool))); connect(button, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(button, SIGNAL(mouseLeft()), @@ -330,22 +330,22 @@ groupLayout->addWidget(button, 0, groupLayout->columnCount()); } - m_propertyControllers[name] = button; - } + m_propertyControllers[name] = button; + } if (button->isChecked() != (value > 0)) { - button->blockSignals(true); - button->setChecked(value > 0); - button->blockSignals(false); - } - break; + button->blockSignals(true); + button->setChecked(value > 0); + button->blockSignals(false); + } + break; } case PropertyContainer::RangeProperty: { - AudioDial *dial; + AudioDial *dial; - if ((dial = qobject_cast<AudioDial *>(existing))) { + if ((dial = qobject_cast<AudioDial *>(existing))) { if (rangeChanged) { dial->blockSignals(true); dial->setMinimum(min); @@ -355,21 +355,21 @@ } } else { #ifdef DEBUG_PROPERTY_BOX - cerr << "PropertyBox: creating new dial" << endl; + cerr << "PropertyBox: creating new dial" << endl; #endif - dial = new AudioDial(); - dial->setObjectName(name); - dial->setMinimum(min); - dial->setMaximum(max); - dial->setPageStep(1); - dial->setNotchesVisible((max - min) <= 12); + dial = new AudioDial(); + dial->setObjectName(name); + dial->setMinimum(min); + dial->setMaximum(max); + dial->setPageStep(1); + dial->setNotchesVisible((max - min) <= 12); // important to set the range mapper before the default, // because the range mapper is used to map the default dial->setRangeMapper(m_container->getNewPropertyRangeMapper(name)); - dial->setDefaultValue(deflt); + dial->setDefaultValue(deflt); dial->setShowToolTip(true); - connect(dial, SIGNAL(valueChanged(int)), - this, SLOT(propertyControllerChanged(int))); + connect(dial, SIGNAL(valueChanged(int)), + this, SLOT(propertyControllerChanged(int))); connect(dial, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(dial, SIGNAL(mouseLeft()), @@ -385,31 +385,31 @@ groupLayout->addWidget(dial, 0, groupLayout->columnCount()); } - m_propertyControllers[name] = dial; - } + m_propertyControllers[name] = dial; + } - if (dial->value() != value) { - dial->blockSignals(true); - dial->setValue(value); - dial->blockSignals(false); - } - break; + if (dial->value() != value) { + dial->blockSignals(true); + dial->setValue(value); + dial->blockSignals(false); + } + break; } case PropertyContainer::ColourProperty: { ColourComboBox *cb; - if (!(cb = qobject_cast<ColourComboBox *>(existing))) { + if (!(cb = qobject_cast<ColourComboBox *>(existing))) { #ifdef DEBUG_PROPERTY_BOX - cerr << "PropertyBox: creating new colour combobox" << endl; + cerr << "PropertyBox: creating new colour combobox" << endl; #endif cb = new ColourComboBox(true); cb->setObjectName(name); - connect(cb, SIGNAL(colourChanged(int)), - this, SLOT(propertyControllerChanged(int))); + connect(cb, SIGNAL(colourChanged(int)), + this, SLOT(propertyControllerChanged(int))); connect(cb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(cb, SIGNAL(mouseLeft()), @@ -424,8 +424,8 @@ groupLayout->addWidget(cb, 0, groupLayout->columnCount()); } - m_propertyControllers[name] = cb; - } + m_propertyControllers[name] = cb; + } if (cb->currentIndex() != value) { cb->blockSignals(true); @@ -442,13 +442,13 @@ if (!(cb = qobject_cast<ColourMapComboBox *>(existing))) { #ifdef DEBUG_PROPERTY_BOX - cerr << "PropertyBox: creating new colourmap combobox" << endl; + cerr << "PropertyBox: creating new colourmap combobox" << endl; #endif cb = new ColourMapComboBox(false); cb->setObjectName(name); - connect(cb, SIGNAL(colourMapChanged(int)), - this, SLOT(propertyControllerChanged(int))); + connect(cb, SIGNAL(colourMapChanged(int)), + this, SLOT(propertyControllerChanged(int))); connect(cb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(cb, SIGNAL(mouseLeft()), @@ -463,8 +463,8 @@ groupLayout->addWidget(cb, 0, groupLayout->columnCount()); } - m_propertyControllers[name] = cb; - } + m_propertyControllers[name] = cb; + } if (cb->currentIndex() != value) { cb->blockSignals(true); @@ -478,14 +478,14 @@ case PropertyContainer::ValueProperty: case PropertyContainer::UnitsProperty: { - NotifyingComboBox *cb; + NotifyingComboBox *cb; - if (!(cb = qobject_cast<NotifyingComboBox *>(existing))) { + if (!(cb = qobject_cast<NotifyingComboBox *>(existing))) { #ifdef DEBUG_PROPERTY_BOX - cerr << "PropertyBox: creating new combobox" << endl; + cerr << "PropertyBox: creating new combobox" << endl; #endif - cb = new NotifyingComboBox(); - cb->setObjectName(name); + cb = new NotifyingComboBox(); + cb->setObjectName(name); cb->setDuplicatesEnabled(false); } @@ -522,8 +522,8 @@ } if (!have) { - connect(cb, SIGNAL(activated(int)), - this, SLOT(propertyControllerChanged(int))); + connect(cb, SIGNAL(activated(int)), + this, SLOT(propertyControllerChanged(int))); connect(cb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(cb, SIGNAL(mouseLeft()), @@ -531,8 +531,8 @@ cb->setToolTip(propertyLabel); groupLayout->addWidget(cb, 0, groupLayout->columnCount()); - m_propertyControllers[name] = cb; - } else if (existing != cb) { + m_propertyControllers[name] = cb; + } else if (existing != cb) { groupLayout->replaceWidget(existing, cb); delete existing; } @@ -555,12 +555,12 @@ } cb->blockSignals(false); - break; + break; } case PropertyContainer::InvalidProperty: default: - break; + break; } } @@ -579,7 +579,7 @@ blockSignals(true); for (i = 0; i < properties.size(); ++i) { - updatePropertyEditor(properties[i]); + updatePropertyEditor(properties[i]); } blockSignals(false); @@ -592,7 +592,7 @@ PropertyContainer::PropertyList properties = m_container->getProperties(); for (size_t i = 0; i < properties.size(); ++i) { - updatePropertyEditor(properties[i], true); + updatePropertyEditor(properties[i], true); } blockSignals(false); @@ -634,7 +634,7 @@ QString name = obj->objectName(); #ifdef DEBUG_PROPERTY_BOX - SVDEBUG << "PropertyBox::propertyControllerChanged(" << name << ", " << value << ")" << endl; + SVDEBUG << "PropertyBox::propertyControllerChanged(" << name << ", " << value << ")" << endl; #endif PropertyContainer::PropertyType type = m_container->getPropertyType(name); @@ -652,7 +652,7 @@ } else if (type != PropertyContainer::InvalidProperty) { - c = m_container->getSetPropertyCommand(name, value); + c = m_container->getSetPropertyCommand(name, value); } if (c) CommandHistory::getInstance()->addCommand(c, true, true);
--- a/widgets/PropertyStack.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/PropertyStack.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -54,25 +54,25 @@ repopulate(); connect(this, SIGNAL(currentChanged(int)), - this, SLOT(selectedContainerChanged(int))); + this, SLOT(selectedContainerChanged(int))); connect(m_client, SIGNAL(propertyContainerAdded(PropertyContainer *)), - this, SLOT(propertyContainerAdded(PropertyContainer *))); + this, SLOT(propertyContainerAdded(PropertyContainer *))); connect(m_client, SIGNAL(propertyContainerRemoved(PropertyContainer *)), - this, SLOT(propertyContainerRemoved(PropertyContainer *))); + this, SLOT(propertyContainerRemoved(PropertyContainer *))); connect(m_client, SIGNAL(propertyContainerPropertyChanged(PropertyContainer *)), - this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); + this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); connect(m_client, SIGNAL(propertyContainerPropertyRangeChanged(PropertyContainer *)), - this, SLOT(propertyContainerPropertyRangeChanged(PropertyContainer *))); + this, SLOT(propertyContainerPropertyRangeChanged(PropertyContainer *))); connect(m_client, SIGNAL(propertyContainerNameChanged(PropertyContainer *)), - this, SLOT(propertyContainerNameChanged(PropertyContainer *))); + this, SLOT(propertyContainerNameChanged(PropertyContainer *))); connect(this, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), - m_client, SLOT(propertyContainerSelected(View *, PropertyContainer *))); + m_client, SLOT(propertyContainerSelected(View *, PropertyContainer *))); } PropertyStack::~PropertyStack() @@ -89,27 +89,27 @@ #endif while (count() > 0) { - removeTab(0); + removeTab(0); } for (size_t i = 0; i < m_boxes.size(); ++i) { - delete m_boxes[i]; + delete m_boxes[i]; } m_boxes.clear(); for (int i = 0; i < m_client->getPropertyContainerCount(); ++i) { - PropertyContainer *container = m_client->getPropertyContainer(i); - QString name = container->getPropertyContainerName(); - + 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); + PropertyBox *box = new PropertyBox(container); - connect(box, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool))); + connect(box, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool))); connect(box, SIGNAL(contextHelpChanged(const QString &)), this, SIGNAL(contextHelpChanged(const QString &))); @@ -131,20 +131,20 @@ bool nameDiffers = (name != shortName); shortName = QString("&%1 %2").arg(i + 1).arg(shortName); - QString iconName = container->getPropertyContainerIconName(); + QString iconName = container->getPropertyContainerIconName(); QIcon icon(IconLoader().load(iconName)); - if (icon.isNull()) { - addTab(box, shortName); + if (icon.isNull()) { + addTab(box, shortName); if (nameDiffers) { setTabToolTip(i, name); } - } else { - addTab(box, icon, QString("&%1").arg(i + 1)); - setTabToolTip(i, name); - } + } else { + addTab(box, icon, QString("&%1").arg(i + 1)); + setTabToolTip(i, name); + } - m_boxes.push_back(box); + m_boxes.push_back(box); } blockSignals(false); @@ -154,8 +154,8 @@ PropertyStack::containsContainer(PropertyContainer *pc) const { for (int i = 0; i < m_client->getPropertyContainerCount(); ++i) { - PropertyContainer *container = m_client->getPropertyContainer(i); - if (pc == container) return true; + PropertyContainer *container = m_client->getPropertyContainer(i); + if (pc == container) return true; } return false; @@ -173,8 +173,8 @@ // box list, not in the view. for (int i = 0; in_range_for(m_boxes, i); ++i) { - PropertyContainer *container = m_boxes[i]->getContainer(); - if (pc == container) { + PropertyContainer *container = m_boxes[i]->getContainer(); + if (pc == container) { return i; } } @@ -201,13 +201,13 @@ { Layer *layer = dynamic_cast<Layer *>(pc); for (unsigned int i = 0; i < m_boxes.size(); ++i) { - if (pc == m_boxes[i]->getContainer()) { - m_boxes[i]->propertyContainerPropertyChanged(pc); + if (pc == m_boxes[i]->getContainer()) { + m_boxes[i]->propertyContainerPropertyChanged(pc); if (layer) { m_boxes[i]->layerVisibilityChanged (!layer->isLayerDormant(m_client)); } - } + } } } @@ -215,9 +215,9 @@ PropertyStack::propertyContainerPropertyRangeChanged(PropertyContainer *pc) { for (unsigned int i = 0; i < m_boxes.size(); ++i) { - if (pc == m_boxes[i]->getContainer()) { - m_boxes[i]->propertyContainerPropertyRangeChanged(pc); - } + if (pc == m_boxes[i]->getContainer()) { + m_boxes[i]->propertyContainerPropertyRangeChanged(pc); + } } } @@ -234,15 +234,15 @@ QObject *obj = sender(); for (unsigned int i = 0; i < m_boxes.size(); ++i) { - if (obj == m_boxes[i]) { - Layer *layer = dynamic_cast<Layer *>(m_boxes[i]->getContainer()); - if (layer) { + if (obj == m_boxes[i]) { + Layer *layer = dynamic_cast<Layer *>(m_boxes[i]->getContainer()); + if (layer) { CommandHistory::getInstance()->addCommand (new ShowLayerCommand(m_client, layer, show, tr("Change Layer Visibility"))); - return; - } - } + return; + } + } } }
--- a/widgets/Thumbwheel.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/Thumbwheel.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -29,7 +29,7 @@ #include <iostream> Thumbwheel::Thumbwheel(Qt::Orientation orientation, - QWidget *parent) : + QWidget *parent) : QWidget(parent), m_min(0), m_max(100), @@ -244,9 +244,9 @@ if (step == 0) step = 1; if (up) { - setValue(m_value + step); + setValue(m_value + step); } else { - setValue(m_value - step); + setValue(m_value - step); } emit valueChanged(getValue()); @@ -430,9 +430,9 @@ if (step == 0) step = 1; if (e->delta() > 0) { - setValue(m_value + step); + setValue(m_value + step); } else { - setValue(m_value - step); + setValue(m_value - step); } emit valueChanged(getValue());
--- a/widgets/TipDialog.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/TipDialog.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -276,10 +276,10 @@ TipDialog::TipFileParser::error(const QXmlParseException &exception) { QString errorString = - QString("ERROR: TipFileParser: %1 at line %2, column %3") - .arg(exception.message()) - .arg(exception.lineNumber()) - .arg(exception.columnNumber()); + QString("ERROR: TipFileParser: %1 at line %2, column %3") + .arg(exception.message()) + .arg(exception.lineNumber()) + .arg(exception.columnNumber()); cerr << errorString << endl; return QXmlDefaultHandler::error(exception); } @@ -288,10 +288,10 @@ TipDialog::TipFileParser::fatalError(const QXmlParseException &exception) { QString errorString = - QString("FATAL ERROR: TipFileParser: %1 at line %2, column %3") - .arg(exception.message()) - .arg(exception.lineNumber()) - .arg(exception.columnNumber()); + QString("FATAL ERROR: TipFileParser: %1 at line %2, column %3") + .arg(exception.message()) + .arg(exception.lineNumber()) + .arg(exception.columnNumber()); cerr << errorString << endl; return QXmlDefaultHandler::fatalError(exception); }
--- a/widgets/UnitConverter.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/UnitConverter.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -59,7 +59,7 @@ m_freq->setMaximum(1e6); m_freq->setValue(440); connect(m_freq, SIGNAL(valueChanged(double)), - this, SLOT(freqChanged())); + this, SLOT(freqChanged())); // The min and max range values for all the remaining controls are // determined by the min and max Hz above @@ -68,20 +68,20 @@ m_midi->setMinimum(-156); m_midi->setMaximum(203); connect(m_midi, SIGNAL(valueChanged(int)), - this, SLOT(midiChanged())); + this, SLOT(midiChanged())); m_note = new QComboBox; for (int i = 0; i < 12; ++i) { - m_note->addItem(pianoNotes[i]); + m_note->addItem(pianoNotes[i]); } connect(m_note, SIGNAL(currentIndexChanged(int)), - this, SLOT(noteChanged())); + this, SLOT(noteChanged())); m_octave = new QSpinBox; m_octave->setMinimum(-14); m_octave->setMaximum(15); connect(m_octave, SIGNAL(valueChanged(int)), - this, SLOT(octaveChanged())); + this, SLOT(octaveChanged())); m_cents = new QDoubleSpinBox; m_cents->setSuffix(tr(" cents")); @@ -89,7 +89,7 @@ m_cents->setMinimum(-50); m_cents->setMaximum(50); connect(m_cents, SIGNAL(valueChanged(double)), - this, SLOT(centsChanged())); + this, SLOT(centsChanged())); int row = 0; @@ -130,9 +130,9 @@ ++row; grid->addWidget - (new QLabel(tr("Note that only pitches in the range 0 to 127 are valid " - "in the MIDI protocol.")), - row, 0, 1, 9); + (new QLabel(tr("Note that only pitches in the range 0 to 127 are valid " + "in the MIDI protocol.")), + row, 0, 1, 9); ++row; @@ -149,7 +149,7 @@ m_samples->setMaximum(1e8); m_samples->setValue(22050); connect(m_samples, SIGNAL(valueChanged(double)), - this, SLOT(samplesChanged())); + this, SLOT(samplesChanged())); m_period = new QDoubleSpinBox; m_period->setSuffix(QString(" ms")); @@ -158,7 +158,7 @@ m_period->setMaximum(100000); m_period->setValue(500); connect(m_period, SIGNAL(valueChanged(double)), - this, SLOT(periodChanged())); + this, SLOT(periodChanged())); m_bpm = new QDoubleSpinBox; m_bpm->setSuffix(QString(" bpm")); @@ -167,7 +167,7 @@ m_bpm->setMaximum(1e6); m_bpm->setValue(120); connect(m_bpm, SIGNAL(valueChanged(double)), - this, SLOT(bpmChanged())); + this, SLOT(bpmChanged())); m_tempofreq = new QDoubleSpinBox; m_tempofreq->setSuffix(QString(" beats/sec")); @@ -177,24 +177,24 @@ m_tempofreq->setValue(0.5); connect(m_tempofreq, SIGNAL(valueChanged(double)), - this, SLOT(tempofreqChanged())); - + this, SLOT(tempofreqChanged())); + m_samplerate = new QComboBox; QList<int> rates; rates << 8000; for (int i = 1; i <= 16; i *= 2) { - rates << 11025 * i << 12000 * i; + rates << 11025 * i << 12000 * i; } foreach (int r, rates) { - m_samplerate->addItem(QString("%1 Hz").arg(r)); + m_samplerate->addItem(QString("%1 Hz").arg(r)); } connect(m_samplerate, SIGNAL(currentIndexChanged(int)), - this, SLOT(samplerateChanged())); + this, SLOT(samplerateChanged())); m_samplerate->setCurrentText("44100 Hz"); connect(Preferences::getInstance(), - SIGNAL(propertyChanged(PropertyContainer::PropertyName)), - this, SLOT(preferenceChanged(PropertyContainer::PropertyName))); + SIGNAL(propertyChanged(PropertyContainer::PropertyName)), + this, SLOT(preferenceChanged(PropertyContainer::PropertyName))); row = 0; @@ -236,11 +236,11 @@ { box->blockSignals(true); if (value < box->minimum() || value > box->maximum()) { - QPalette p; - p.setColor(QPalette::Text, Qt::red); - box->setPalette(p); + QPalette p; + p.setColor(QPalette::Text, Qt::red); + box->setPalette(p); } else { - box->setPalette(QPalette()); + box->setPalette(QPalette()); } box->setValue(value); box->blockSignals(false); @@ -251,11 +251,11 @@ { box->blockSignals(true); if (value < box->minimum() || value > box->maximum()) { - QPalette p; - p.setColor(QPalette::Text, Qt::red); - box->setPalette(p); + QPalette p; + p.setColor(QPalette::Text, Qt::red); + box->setPalette(p); } else { - box->setPalette(QPalette()); + box->setPalette(QPalette()); } box->setValue(value); box->blockSignals(false); @@ -272,11 +272,11 @@ UnitConverter::updatePitchPrefsLabel() { m_pitchPrefsLabel->setText - (tr("With concert-A tuning frequency at %1 Hz, and " - "middle C residing in octave %2.\n" - "(These can be changed in the application preferences.)") - .arg(Preferences::getInstance()->getTuningFrequency()) - .arg(Preferences::getInstance()->getOctaveOfMiddleC())); + (tr("With concert-A tuning frequency at %1 Hz, and " + "middle C residing in octave %2.\n" + "(These can be changed in the application preferences.)") + .arg(Preferences::getInstance()->getTuningFrequency()) + .arg(Preferences::getInstance()->getOctaveOfMiddleC())); } void @@ -296,7 +296,7 @@ UnitConverter::noteChanged() { int pitch = Pitch::getPitchForNoteAndOctave(m_note->currentIndex(), - m_octave->value()); + m_octave->value()); double freq = Pitch::getFrequencyForPitch(pitch, m_cents->value()); m_freq->setValue(freq); } @@ -305,7 +305,7 @@ UnitConverter::octaveChanged() { int pitch = Pitch::getPitchForNoteAndOctave(m_note->currentIndex(), - m_octave->value()); + m_octave->value()); double freq = Pitch::getFrequencyForPitch(pitch, m_cents->value()); m_freq->setValue(freq); }