diff --git a/stuff/config/current.txt b/stuff/config/current.txt index 19e32cf..a6cd128 100644 --- a/stuff/config/current.txt +++ b/stuff/config/current.txt @@ -240,6 +240,7 @@ "STD_linearGradientFx.wave_phase" "Phase" "STD_linearGradientFx.color1" "Color 1" "STD_linearGradientFx.color2" "Color 2" + "STD_linearGradientFx.curveType" "Type" "STD_linearWaveFx" "Linear Wave" "STD_linearWaveFx.period" "Period" @@ -267,6 +268,7 @@ "STD_multiLinearGradientFx.wave_frequency" "Frequency" "STD_multiLinearGradientFx.wave_phase" "Phase" "STD_multiLinearGradientFx.colors" "Colors" + "STD_multiLinearGradientFx.curveType" "Type" "STD_localBlurFx" "Local Blur" "STD_localBlurFx.value" "Intensity" @@ -324,6 +326,7 @@ "STD_radialGradientFx.innerperiod" "Inner Size" "STD_radialGradientFx.color1" "Color 1" "STD_radialGradientFx.color2" "Color 2" + "STD_radialGradientFx.curveType" "Type" "STD_randomWaveFx" "Random Wave" @@ -358,6 +361,7 @@ "STD_multiRadialGradientFx.count" "Quantity" "STD_multiRadialGradientFx.cycle" "Cycle" "STD_multiRadialGradientFx.colors" "Colors" + "STD_multiRadialGradientFx.curveType" "Type" "STD_raylitFx" "Raylit" "STD_raylitFx.p" "Center X" diff --git a/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml b/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml index 7eeebcb..de531e5 100644 --- a/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml +++ b/stuff/profiles/layouts/fxs/STD_linearGradientFx.xml @@ -4,6 +4,7 @@ color1 color2 color1 color2 + curveType wave_amplitude wave_frequency diff --git a/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml b/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml index 988baef..8084dfc 100644 --- a/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml +++ b/stuff/profiles/layouts/fxs/STD_multiLinearGradientFx.xml @@ -4,6 +4,7 @@ count cycle colors + curveType wave_amplitude wave_frequency diff --git a/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml b/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml index 738463a..8966e16 100644 --- a/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml +++ b/stuff/profiles/layouts/fxs/STD_multiRadialGradientFx.xml @@ -4,6 +4,7 @@ count cycle colors + curveType diff --git a/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml b/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml index 9a9a0d5..a5eb1d2 100644 --- a/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml +++ b/stuff/profiles/layouts/fxs/STD_radialGradientFx.xml @@ -5,6 +5,7 @@ period color2 color1 color2 + curveType diff --git a/toonz/sources/common/tsystem/tfilepath.cpp b/toonz/sources/common/tsystem/tfilepath.cpp index 9c84c77..c7efeaf 100644 --- a/toonz/sources/common/tsystem/tfilepath.cpp +++ b/toonz/sources/common/tsystem/tfilepath.cpp @@ -687,12 +687,12 @@ TFrameId TFilePath::getFrame() const { } char letter = '\0'; if (iswalpha(str[k])) letter = str[k++] + ('a' - L'a'); - - if (number == 0 || k < i) // || letter!='\0') - throw TMalformedFrameException( - *this, - str + L": " + QObject::tr("Malformed frame name").toStdWString()); - + /* + if (number == 0 || k < i) // || letter!='\0') + throw TMalformedFrameException( + *this, + str + L": " + QObject::tr("Malformed frame name").toStdWString()); + */ int padding = 0; if (str[j + 1] == '0') padding = digits; diff --git a/toonz/sources/include/tcg/boost/zipped_range.h b/toonz/sources/include/tcg/boost/zipped_range.h deleted file mode 100644 index 1810f9d..0000000 --- a/toonz/sources/include/tcg/boost/zipped_range.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#ifndef ZIPPED_RANGE_H -#define ZIPPED_RANGE_H - -// boost includes -#include -#include - -/*! - \file zipped_range.h - - \brief Contains a range creator for boost::zip_iterator objects. - \remark Zipped ranges are currently constrained to a 2-tuple. -*/ - -namespace tcg { - -template -struct _zip_rng_traits { - typedef boost::zip_iterator< - boost::tuple::type, - typename boost::range_iterator::type>> - iterator; - typedef std::pair range; -}; - -//********************************************************************************** -// Permuted Range creator -//********************************************************************************** - -template -typename _zip_rng_traits::range zipped_range(Rng1 &rng1, - Rng2 &rng2) { - typedef typename _zip_rng_traits::range range; - typedef typename _zip_rng_traits::iterator iterator; - - return range( - iterator(boost::make_tuple(boost::begin(rng1), boost::begin(rng2))), - iterator(boost::make_tuple(boost::end(rng1), boost::end(rng2)))); -} - -} // namespace tcg - -#endif // ZIPPED_RANGE_H diff --git a/toonz/sources/include/tools/stylepicker.h b/toonz/sources/include/tools/stylepicker.h index 54f7c64..b5381bb 100644 --- a/toonz/sources/include/tools/stylepicker.h +++ b/toonz/sources/include/tools/stylepicker.h @@ -60,11 +60,12 @@ public: int pickStyleId(const TPointD &point, double radius2 = 1, int mode = 2) const; /*--- Toonz Raster LevelのToneを拾う。 ---*/ - int pickTone(const TPointD &pos); + int pickTone(const TPointD &pos) const; // per pli come sopra, ma ritorna il maincolor // per tzp e fullcolor ritorna il colore effettivo del pixel TPixel32 pickColor(const TPointD &point, double radius2 = 1) const; + TPixel32 pickAverageColor(const TRectD &rect) const; // ritorna il colore medio presente nell'area della finestra corrente openGL TPixel32 pickColor(const TRectD &area) const; diff --git a/toonz/sources/include/toonzqt/functionsheet.h b/toonz/sources/include/toonzqt/functionsheet.h index 2aa3756..acb2333 100644 --- a/toonz/sources/include/toonzqt/functionsheet.h +++ b/toonz/sources/include/toonzqt/functionsheet.h @@ -48,6 +48,8 @@ class FunctionSheetColumnHeadViewer final : public Spreadsheet::ColumnPanel { QPoint m_dragStartPosition; FunctionTreeModel::Channel *m_draggingChannel; + int m_clickedColumn = -1; + public: FunctionSheetColumnHeadViewer(FunctionSheet *parent); diff --git a/toonz/sources/stdfx/gradients.cpp b/toonz/sources/stdfx/gradients.cpp index 6fea2e4..89d516a 100644 --- a/toonz/sources/stdfx/gradients.cpp +++ b/toonz/sources/stdfx/gradients.cpp @@ -13,7 +13,8 @@ namespace { template void doComputeRadialT(TRasterPT ras, TPointD posTrasf, const TSpectrumT &spectrum, double period, - double count, double cycle, const TAffine &aff) { + double count, double cycle, const TAffine &aff, + double inner = 0.0, GradientCurveType type = Linear) { int j; double maxRadius = period * count; double freq = 1.0 / period; @@ -29,8 +30,30 @@ void doComputeRadialT(TRasterPT ras, TPointD posTrasf, t = (radius + cycle) * freq; t -= floor(t); } - // double polinomfactor=(-2*t+3)*(t*t); - *pix++ = spectrum.getPremultipliedValue(t); + + if (t <= inner) + t = 0; + else + t = (t - inner) / (1.0 - inner); + + double factor; + switch (type) { + case Linear: + factor = t; + break; + case EaseIn: + factor = t * t; + break; + case EaseOut: + factor = 1.0 - (1.0 - t) * (1.0 - t); + break; + case EaseInOut: + default: + factor = (-2 * t + 3) * (t * t); + break; + } + *pix++ = spectrum.getPremultipliedValue(factor); + posAux.x += aff.a11; posAux.y += aff.a21; } @@ -39,19 +62,20 @@ void doComputeRadialT(TRasterPT ras, TPointD posTrasf, } ras->unlock(); } -} +} // namespace //------------------------------------------------------------------ void multiRadial(const TRasterP &ras, TPointD posTrasf, const TSpectrumParamP colors, double period, double count, - double cycle, const TAffine &aff, double frame) { + double cycle, const TAffine &aff, double frame, double inner, + GradientCurveType type) { if ((TRaster32P)ras) doComputeRadialT(ras, posTrasf, colors->getValue(frame), period, - count, cycle, aff); + count, cycle, aff, inner, type); else if ((TRaster64P)ras) doComputeRadialT(ras, posTrasf, colors->getValue64(frame), period, - count, cycle, aff); + count, cycle, aff, inner, type); else throw TException("MultiRadialGradientFx: unsupported Pixel Type"); } @@ -63,7 +87,8 @@ template void doComputeLinearT(TRasterPT ras, TPointD posTrasf, const TSpectrumT &spectrum, double period, double count, double w_amplitude, double w_freq, - double w_phase, double cycle, const TAffine &aff) { + double w_phase, double cycle, const TAffine &aff, + GradientCurveType type = EaseInOut) { double shift = 0; double maxRadius = period * count / 2.; double freq = 1.0 / period; @@ -78,16 +103,32 @@ void doComputeLinearT(TRasterPT ras, TPointD posTrasf, T *endPix = pix + ras->getLx(); while (pix < endPix) { if (w_amplitude) shift = w_amplitude * sin(w_freq * posAux.y + w_phase); - double radius = posAux.x + shift; - double t = 1; + double radius = posAux.x + shift; + double t = 1; if (fabs(radius) < maxRadius) { t = (radius + maxRadius + cycle) * freq; t -= floor(t); } else if (radius < 0) - t = 0; - double polinomfactor = (-2 * t + 3) * (t * t); + t = 0; + + double factor; + switch (type) { + case Linear: + factor = t; + break; + case EaseIn: + factor = t * t; + break; + case EaseOut: + factor = 1.0 - (1.0 - t) * (1.0 - t); + break; + case EaseInOut: + default: + factor = (-2 * t + 3) * (t * t); + break; + } // pos.x += 1.0; - *pix++ = spectrum.getPremultipliedValue(polinomfactor); + *pix++ = spectrum.getPremultipliedValue(factor); posAux.x += aff.a11; posAux.y += aff.a21; } @@ -96,19 +137,19 @@ void doComputeLinearT(TRasterPT ras, TPointD posTrasf, } ras->unlock(); } -} +} // namespace //------------------------------------------------------------------ void multiLinear(const TRasterP &ras, TPointD posTrasf, const TSpectrumParamP colors, double period, double count, double amplitude, double freq, double phase, double cycle, - const TAffine &aff, double frame) { + const TAffine &aff, double frame, GradientCurveType type) { if ((TRaster32P)ras) doComputeLinearT(ras, posTrasf, colors->getValue(frame), period, - count, amplitude, freq, phase, cycle, aff); + count, amplitude, freq, phase, cycle, aff, type); else if ((TRaster64P)ras) doComputeLinearT(ras, posTrasf, colors->getValue64(frame), period, - count, amplitude, freq, phase, cycle, aff); + count, amplitude, freq, phase, cycle, aff, type); else throw TException("MultiLinearGradientFx: unsupported Pixel Type"); } diff --git a/toonz/sources/stdfx/gradients.h b/toonz/sources/stdfx/gradients.h index 411512d..2650374 100644 --- a/toonz/sources/stdfx/gradients.h +++ b/toonz/sources/stdfx/gradients.h @@ -15,17 +15,21 @@ struct MultiRAdialParams { double m_gridStep; }; +enum GradientCurveType { EaseInOut = 0, Linear, EaseIn, EaseOut }; + /*---------------------------------------------------------------------------*/ //! Deals with raster tiles and invokes multiradial functions void multiRadial(const TRasterP &ras, TPointD posTrasf, const TSpectrumParamP colors, double period, double count, - double cycle, const TAffine &aff, double frame); + double cycle, const TAffine &aff, double frame, + double inner = 0.0, GradientCurveType type = Linear); void multiLinear(const TRasterP &ras, TPointD posTrasf, const TSpectrumParamP colors, double period, double count, double amplitude, double freq, double phase, double cycle, - const TAffine &aff, double frame); + const TAffine &aff, double frame, + GradientCurveType type = EaseInOut); #endif diff --git a/toonz/sources/stdfx/iwa_bokehreffx.cpp b/toonz/sources/stdfx/iwa_bokehreffx.cpp index b11ab27..e57c2c0 100644 --- a/toonz/sources/stdfx/iwa_bokehreffx.cpp +++ b/toonz/sources/stdfx/iwa_bokehreffx.cpp @@ -43,7 +43,7 @@ void releaseAllRastersAndPlans(QList& rasterList, releaseAllRasters(rasterList); for (int p = 0; p < planList.size(); p++) kiss_fft_free(planList.at(p)); } -}; +}; // namespace //------------------------------------ BokehRefThread::BokehRefThread(int channel, kiss_fft_cpx* fftcpx_channel_before, @@ -608,7 +608,9 @@ void Iwa_BokehRefFx::retrieveLayer(const float4* source_buff, TRasterGR8P generation_buff_ras = allocateRasterAndLock( &generation_buff, TDimensionI(lx, ly)); - for (int gen = 0; gen < margin; gen++) { + // extend (margin * 2) pixels in order to enough cover when two adjacent + // layers are both blurred in the maximum radius + for (int gen = 0; gen < margin * 2; gen++) { // apply single median filter doSingleMedian(source_buff, segment_layer_buff, indexMap_mainSub, index, lx, ly, generation_buff, gen + 1); diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp index cd8499b..2f11f6c 100644 --- a/toonz/sources/stdfx/stdfx.cpp +++ b/toonz/sources/stdfx/stdfx.cpp @@ -174,6 +174,8 @@ class MultiLinearGradientFx final : public TStandardZeraryFx { TDoubleParamP m_wave_phase; TSpectrumParamP m_colors; + TIntEnumParamP m_curveType; + public: MultiLinearGradientFx() : m_period(100) // args, "Period") @@ -182,8 +184,12 @@ public: , m_wave_amplitude(0.0) // args, "Cycle") , m_wave_freq(0.0) // args, "Cycle") , m_wave_phase(0.0) // args, "Cycle") - // , m_colors (0) //args, "Colors") - { + // , m_colors (0) //args, "Colors") + , m_curveType(new TIntEnumParam(EaseInOut, "Ease In-Out")) { + m_curveType->addItem(Linear, "Linear"); + m_curveType->addItem(EaseIn, "Ease In"); + m_curveType->addItem(EaseOut, "Ease Out"); + std::vector colors = { TSpectrum::ColorKey(0, TPixel32::White), TSpectrum::ColorKey(0.33, TPixel32::Yellow), @@ -198,6 +204,8 @@ public: bindParam(this, "wave_frequency", m_wave_freq); bindParam(this, "wave_phase", m_wave_phase); bindParam(this, "colors", m_colors); + bindParam(this, "curveType", m_curveType); + m_period->setValueRange(0, (std::numeric_limits::max)()); m_cycle->setValueRange(0, (std::numeric_limits::max)()); m_wave_amplitude->setValueRange(0, (std::numeric_limits::max)()); @@ -238,6 +246,8 @@ class LinearGradientFx final : public TStandardZeraryFx { TPixelParamP m_color1; TPixelParamP m_color2; + TIntEnumParamP m_curveType; + public: LinearGradientFx() : m_period(100) // args, "Period") @@ -246,14 +256,20 @@ public: , m_wave_phase(0.0) // args, "Cycle") , m_color1(TPixel32::Black) , m_color2(TPixel32::White) - // , m_colors (0) //args, "Colors") - { + // , m_colors (0) //args, "Colors") + , m_curveType(new TIntEnumParam(EaseInOut, "Ease In-Out")) { + m_curveType->addItem(Linear, "Linear"); + m_curveType->addItem(EaseIn, "Ease In"); + m_curveType->addItem(EaseOut, "Ease Out"); + bindParam(this, "period", m_period); bindParam(this, "wave_amplitude", m_wave_amplitude); bindParam(this, "wave_frequency", m_wave_freq); bindParam(this, "wave_phase", m_wave_phase); bindParam(this, "color1", m_color1); bindParam(this, "color2", m_color2); + bindParam(this, "curveType", m_curveType); + m_period->setValueRange(0, std::numeric_limits::max()); m_wave_amplitude->setValueRange(0, std::numeric_limits::max()); m_period->setMeasureName("fxLength"); @@ -346,7 +362,8 @@ void LinearGradientFx::doCompute(TTile &tile, double frame, TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude, - w_freq, w_phase, cycle, aff, frame); + w_freq, w_phase, cycle, aff, frame, + (GradientCurveType)m_curveType->getValue()); /* if (TRaster32P ras32 = tile.getRaster()) doComputeT( @@ -380,7 +397,8 @@ void MultiLinearGradientFx::doCompute(TTile &tile, double frame, TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; multiLinear(tile.getRaster(), posTrasf, m_colors, period, count, w_amplitude, - w_freq, w_phase, cycle, aff, frame); + w_freq, w_phase, cycle, aff, frame, + (GradientCurveType)m_curveType->getValue()); /* if (TRaster32P ras32 = tile.getRaster()) doComputeT( @@ -406,20 +424,30 @@ class RadialGradientFx final : public TStandardZeraryFx { TPixelParamP m_color1; TPixelParamP m_color2; + TIntEnumParamP m_curveType; + public: RadialGradientFx() : m_period(100.0) , m_innerperiod(0.0) // args, "Period") , m_color1(TPixel32::White) , m_color2(TPixel32::Transparent) - // , m_colors (0) //args, "Colors") - { + // , m_colors (0) //args, "Colors") + , m_curveType(new TIntEnumParam()) { + m_curveType->addItem(EaseInOut, "Ease In-Out"); + m_curveType->addItem(Linear, "Linear"); + m_curveType->addItem(EaseIn, "Ease In"); + m_curveType->addItem(EaseOut, "Ease Out"); + m_curveType->setDefaultValue(Linear); + m_curveType->setValue(Linear); + m_period->setMeasureName("fxLength"); m_innerperiod->setMeasureName("fxLength"); bindParam(this, "period", m_period); bindParam(this, "innerperiod", m_innerperiod); bindParam(this, "color1", m_color1); bindParam(this, "color2", m_color2); + bindParam(this, "curveType", m_curveType); m_period->setValueRange(0.0, std::numeric_limits::max()); m_innerperiod->setValueRange(0.0, std::numeric_limits::max()); } @@ -458,13 +486,22 @@ class MultiRadialGradientFx final : public TStandardZeraryFx { TDoubleParamP m_cycle; TSpectrumParamP m_colors; + TIntEnumParamP m_curveType; + public: MultiRadialGradientFx() : m_period(100) // args, "Period") , m_count(2) // args, "Count") , m_cycle(0.0) // args, "Count") - // , m_colors (0) //args, "Colors") - { + // , m_colors (0) //args, "Colors") + , m_curveType(new TIntEnumParam()) { + m_curveType->addItem(EaseInOut, "Ease In-Out"); + m_curveType->addItem(Linear, "Linear"); + m_curveType->addItem(EaseIn, "Ease In"); + m_curveType->addItem(EaseOut, "Ease Out"); + m_curveType->setDefaultValue(Linear); + m_curveType->setValue(Linear); + m_period->setMeasureName("fxLength"); std::vector colors = { TSpectrum::ColorKey(0, TPixel32::White), @@ -477,6 +514,7 @@ public: bindParam(this, "count", m_count); bindParam(this, "cycle", m_cycle); bindParam(this, "colors", m_colors); + bindParam(this, "curveType", m_curveType); m_period->setValueRange(0, (std::numeric_limits::max)()); m_cycle->setValueRange(0, (std::numeric_limits::max)()); m_count->setValueRange(0, (std::numeric_limits::max)()); @@ -517,7 +555,7 @@ void MultiRadialGradientFx::doCompute(TTile &tile, double frame, TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff, - frame); + frame, 0.0, (GradientCurveType)m_curveType->getValue()); } //================================================================== @@ -536,13 +574,12 @@ void RadialGradientFx::doCompute(TTile &tile, double frame, inner = 1 - TConsts::epsilon; std::vector colors = { TSpectrum::ColorKey(0, m_color1->getValue(frame)), - TSpectrum::ColorKey(inner, m_color1->getValue(frame)), TSpectrum::ColorKey(1, m_color2->getValue(frame))}; TSpectrumParamP m_colors = TSpectrumParamP(colors); TAffine aff = ri.m_affine.inv(); TPointD posTrasf = aff * tile.m_pos; multiRadial(tile.getRaster(), posTrasf, m_colors, period, count, cycle, aff, - frame); + frame, inner, (GradientCurveType)m_curveType->getValue()); } //------------------------------------------------------------------ diff --git a/toonz/sources/tnztools/stylepicker.cpp b/toonz/sources/tnztools/stylepicker.cpp index a236390..b6cc05a 100644 --- a/toonz/sources/tnztools/stylepicker.cpp +++ b/toonz/sources/tnztools/stylepicker.cpp @@ -12,6 +12,8 @@ #include "tpixelutils.h" #include "tregion.h" +#include + //--------------------------------------------------------- StylePicker::StylePicker(const TImageP &image) @@ -74,7 +76,7 @@ int StylePicker::pickStyleId(const TPointD &pos, double radius2, styleId = palette->getClosestStyle(col); } else if (TVectorImageP vi = m_image) { // prima cerca lo stile della regione piu' vicina - TRegion *r = vi->getRegion(pos); + TRegion *r = vi->getRegion(pos); if (r) styleId = r->getStyle(); // poi cerca quello della stroke, ma se prima aveva trovato una regione, // richiede che @@ -101,7 +103,7 @@ int StylePicker::pickStyleId(const TPointD &pos, double radius2, //--------------------------------------------------------- /*--- Toonz Raster LevelのToneを拾う。 ---*/ -int StylePicker::pickTone(const TPointD &pos) { +int StylePicker::pickTone(const TPointD &pos) const { if (TToonzImageP ti = m_image) { TRasterCM32P ras = ti->getRaster(); if (!ras) return -1; @@ -119,6 +121,7 @@ int StylePicker::pickTone(const TPointD &pos) { TPixel32 StylePicker::pickColor(const TPointD &pos, double radius2) const { TToonzImageP ti = m_image; TRasterImageP ri = m_image; + TVectorImageP vi = m_image; if (!!ri) // !!ti || !!ri) { TRasterP raster; @@ -135,12 +138,74 @@ TPixel32 StylePicker::pickColor(const TPointD &pos, double radius2) const { TRasterGR8P rasterGR8 = raster; if (rasterGR8) return toPixel32(rasterGR8->pixels(point.y)[point.x]); - } else if (TVectorImageP vi = m_image) { + } else if (vi) { const TPalette *palette = m_palette.getPointer(); if (!palette) return TPixel32::Transparent; int styleId = pickStyleId(pos, radius2); if (0 <= styleId && styleId < palette->getStyleCount()) return palette->getStyle(styleId)->getAverageColor(); + } else if (ti) { + const TPalette *palette = m_palette.getPointer(); + if (!palette) return TPixel32::Transparent; + int paintId = pickStyleId(pos, radius2, 0); + int inkId = pickStyleId(pos, radius2, 1); + int tone = pickTone(pos); + TPixel32 ink, paint; + if (0 <= inkId && inkId < palette->getStyleCount()) + ink = palette->getStyle(inkId)->getAverageColor(); + if (0 <= paintId && paintId < palette->getStyleCount()) + paint = palette->getStyle(paintId)->getAverageColor(); + + if (tone == 0) + return ink; + else if (tone == 255) + return paint; + else + return blend(ink, paint, tone, TPixelCM32::getMaxTone()); + } + return TPixel32::Transparent; +} + +//--------------------------------------------------------- + +TPixel32 StylePicker::pickAverageColor(const TRectD &rect) const { + TRasterImageP ri = m_image; + assert(ri); + if (!!ri) { + TRasterP raster; + raster = ri->getRaster(); + + TPoint topLeft = getRasterPoint(rect.getP00()); + TPoint bottomRight = getRasterPoint(rect.getP11()); + + if (!raster->getBounds().overlaps(TRect(topLeft, bottomRight))) + return TPixel32::Transparent; + + topLeft.x = std::max(0, topLeft.x); + topLeft.y = std::max(0, topLeft.y); + bottomRight.x = std::min(raster->getLx(), bottomRight.x); + bottomRight.y = std::min(raster->getLy(), bottomRight.y); + + TRaster32P raster32 = raster; + assert(raster32); + if (raster32) { + UINT r = 0, g = 0, b = 0, m = 0, size = 0; + for (int y = topLeft.y; y < bottomRight.y; y++) { + TPixel32 *p = &raster32->pixels(y)[topLeft.x]; + for (int x = topLeft.x; x < bottomRight.x; x++, p++) { + r += p->r; + g += p->g; + b += p->b; + m += p->m; + size++; + } + } + + if (size) + return TPixel32(r / size, g / size, b / size, m / size); + else + return TPixel32::Transparent; + } } return TPixel32::Transparent; } @@ -236,7 +301,7 @@ TPixel32 getAverageColor(TStroke *stroke) { return TPixel32(buffer[0].b, buffer[0].g, buffer[0].r, 255); } -} // namspace +} // namespace //--------------------------------------------------------- diff --git a/toonz/sources/tnztools/toolutils.cpp b/toonz/sources/tnztools/toolutils.cpp index cd7832b..141845b 100644 --- a/toonz/sources/tnztools/toolutils.cpp +++ b/toonz/sources/tnztools/toolutils.cpp @@ -1526,8 +1526,8 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text, delta.x *= devPixRatio; delta.y *= devPixRatio; - textRect.moveTo(qMax(delta.x, 10 * devPixRatio + mrg), - qMax(mrg + 2 * devPixRatio, -delta.y - baseLine)); + textRect.moveTo(std::max(delta.x, 10 * devPixRatio + mrg), + std::max(mrg + 2 * devPixRatio, -delta.y - baseLine)); int y = textRect.top() + baseLine; int x0 = textRect.left() - mrg; @@ -1577,7 +1577,7 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text, } QSize size(textRect.width() + textRect.left() + mrg, - qMax(textRect.bottom() + mrg, y + delta.y) + 3 * devPixRatio); + std::max(textRect.bottom() + mrg, y + delta.y) + 3 * devPixRatio); QImage label(size.width(), size.height(), QImage::Format_ARGB32); label.fill(Qt::transparent); diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp index ec896b9..c432f36 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp +++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp @@ -1017,17 +1017,21 @@ void ToonzRasterBrushTool::drawEmptyCircle(TPointD pos, int thick, //------------------------------------------------------------------------------------------------------- -TPointD ToonzRasterBrushTool::getCenteredCursorPos(const TPointD &originalCursorPos) { - TDimension resolution = m_application->getCurrentLevel()->getSimpleLevel()->getProperties()->getImageRes(); +TPointD ToonzRasterBrushTool::getCenteredCursorPos( + const TPointD &originalCursorPos) { + if (m_isMyPaintStyleSelected) return originalCursorPos; + TXshLevelHandle *levelHandle = m_application->getCurrentLevel(); + TXshSimpleLevel *level = levelHandle ? levelHandle->getSimpleLevel() : 0; + TDimension resolution = + level ? level->getProperties()->getImageRes() : TDimension(0, 0); + bool xEven = (resolution.lx % 2 == 0); bool yEven = (resolution.ly % 2 == 0); TPointD centeredCursorPos = originalCursorPos; - if (xEven) - centeredCursorPos.x -= 0.5; - if (yEven) - centeredCursorPos.y -= 0.5; + if (xEven) centeredCursorPos.x -= 0.5; + if (yEven) centeredCursorPos.y -= 0.5; return centeredCursorPos; } @@ -1295,7 +1299,8 @@ void ToonzRasterBrushTool::leftButtonDown(const TPointD &pos, TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5); invalidateRect = convert(m_strokeSegmentRect) - rasCenter; - invalidateRect += TRectD(centeredPos - thickOffset, centeredPos + thickOffset); + invalidateRect += + TRectD(centeredPos - thickOffset, centeredPos + thickOffset); invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset); } else if (m_hardness.getValue() == 100 || m_pencil.getValue()) { @@ -1303,7 +1308,8 @@ void ToonzRasterBrushTool::leftButtonDown(const TPointD &pos, * --*/ if (!m_pencil.getValue()) thickness -= 1.0; - TThickPoint thickPoint(centeredPos + convert(ras->getCenter()), thickness); + TThickPoint thickPoint(centeredPos + convert(ras->getCenter()), + thickness); m_rasterTrack = new RasterStrokeGenerator( ras, BRUSH, NONE, m_styleId, thickPoint, drawOrder != OverAll, 0, !m_pencil.getValue(), drawOrder == PaletteOrder); @@ -1395,7 +1401,8 @@ void ToonzRasterBrushTool::leftButtonDrag(const TPointD &pos, TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5); invalidateRect = convert(m_strokeSegmentRect) - rasCenter; - invalidateRect += TRectD(centeredPos - thickOffset, centeredPos + thickOffset); + invalidateRect += + TRectD(centeredPos - thickOffset, centeredPos + thickOffset); invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset); } else if (m_rasterTrack && diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h index 9b58297..c524ad6 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.h +++ b/toonz/sources/tnztools/toonzrasterbrushtool.h @@ -227,7 +227,7 @@ protected: static void drawEmptyCircle(TPointD point, int thick, bool isLxEven, bool isLyEven, bool isPencil); - static TPointD getCenteredCursorPos(const TPointD &originalCursorPos); + TPointD getCenteredCursorPos(const TPointD &originalCursorPos); }; //------------------------------------------------------------ diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cpp index 5323e93..39deb09 100644 --- a/toonz/sources/toonz/colormodelviewer.cpp +++ b/toonz/sources/toonz/colormodelviewer.cpp @@ -198,7 +198,7 @@ void ColorModelViewer::loadImage(const TFilePath &fp) { //----------------------------------------------------------------------------- /*! Create and open the Right-click menu color model viewer. -*/ + */ void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) { /*-- Levelが取得できない場合はMenuを出さない --*/ TApp *app = TApp::instance(); @@ -258,21 +258,21 @@ void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) { //----------------------------------------------------------------------------- /*! If left button is pressed recall \b pick() in event pos. -*/ + */ void ColorModelViewer::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) pick(event->pos() * getDevPixRatio()); } //----------------------------------------------------------------------------- /*! If left button is moved recall \b pick() in event pos. -*/ + */ void ColorModelViewer::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton) pick(event->pos() * getDevPixRatio()); } //----------------------------------------------------------------------------- /*! Pick color from image and set it as current style. -*/ + */ void ColorModelViewer::pick(const QPoint &p) { TImageP img = m_imageViewer->getImage(); if (!img) return; @@ -296,7 +296,7 @@ void ColorModelViewer::pick(const QPoint &p) { カレントToolに合わせてPickモードを変更 0=Area, 1=Line, 2=Line&Areas(default) ---*/ - int styleIndex = picker.pickStyleId(pos, 1, m_mode); + int styleIndex = picker.pickStyleId(pos + TPointD(-0.5, -0.5), 1, m_mode); if (styleIndex < 0) return; @@ -366,7 +366,7 @@ void ColorModelViewer::showEvent(QShowEvent *e) { ToolHandle *toolHandle = TApp::instance()->getCurrentTool(); bool ret = connect(paletteHandle, SIGNAL(paletteSwitched()), this, SLOT(showCurrentImage())); - ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this, + ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this, SLOT(showCurrentImage())); ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this, SLOT(showCurrentImage())); @@ -487,7 +487,7 @@ void ColorModelViewer::showCurrentImage() { //----------------------------------------------------------------------------- /*! Clone current image and set it in viewer. -*/ + */ void ColorModelViewer::loadCurrentFrame() { TApp *app = TApp::instance(); TXshLevel *xl = app->getCurrentLevel()->getLevel(); @@ -535,8 +535,8 @@ void ColorModelViewer::loadCurrentFrame() { m_flipConsole->enableProgressBar(false); m_flipConsole->setProgressBarStatus(0); m_flipConsole->setFrameRange(1, 1, 1); - m_title1 = m_viewerTitle + " :: " + - m_currentRefImgPath.withoutParentDir().withFrame(fid); + m_title1 = m_viewerTitle + + " :: " + m_currentRefImgPath.withoutParentDir().withFrame(fid); m_title = " :: "; m_imageViewer->setImage(refImg); @@ -585,8 +585,8 @@ void ColorModelViewer::reloadCurrentFrame() { m_flipConsole->enableProgressBar(false); m_flipConsole->setProgressBarStatus(0); m_flipConsole->setFrameRange(1, 1, 1); - m_title1 = m_viewerTitle + " :: " + - m_currentRefImgPath.withoutParentDir().withFrame(fids[0]); + m_title1 = m_viewerTitle + + " :: " + m_currentRefImgPath.withoutParentDir().withFrame(fids[0]); m_title = " :: "; m_imageViewer->setImage(refImg); diff --git a/toonz/sources/toonz/filebrowsermodel.cpp b/toonz/sources/toonz/filebrowsermodel.cpp index 0b8a47b..dc6f523 100644 --- a/toonz/sources/toonz/filebrowsermodel.cpp +++ b/toonz/sources/toonz/filebrowsermodel.cpp @@ -51,7 +51,13 @@ TFilePath getMyDocumentsPath() { return TFilePath((const char *)[documentsDirectory cStringUsingEncoding:NSASCIIStringEncoding]); #else - return TFilePath(); + std::string path(getenv("HOME")); + if(path.empty()) return TFilePath(); + path += "/Documents"; + QString pathAsQString = QString::fromStdString(path); + QDir dir(pathAsQString); + if(!dir.exists()) return TFilePath(); + return TFilePath(path); #endif } @@ -73,7 +79,13 @@ TFilePath getDesktopPath() { return TFilePath((const char *)[desktopDirectory cStringUsingEncoding:NSASCIIStringEncoding]); #else - return TFilePath(); + std::string path(getenv("HOME")); + if(path.empty()) return TFilePath(); + path += "/Desktop"; + QString pathAsQString = QString::fromStdString(path); + QDir dir(pathAsQString); + if(!dir.exists()) return TFilePath(); + return TFilePath(path); #endif } } @@ -1491,4 +1503,4 @@ void DvDirModel::onPreferenceChanged(const QString &prefName) { if (rootNode) rootNode->updateSceneFolderNodeVisibility(priority == Preferences::ProjectFolderOnly); -} \ No newline at end of file +} diff --git a/toonz/sources/toonz/imageviewer.cpp b/toonz/sources/toonz/imageviewer.cpp index bd8d79d..2a4b206 100644 --- a/toonz/sources/toonz/imageviewer.cpp +++ b/toonz/sources/toonz/imageviewer.cpp @@ -882,10 +882,10 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { if (!m_isHistogramEnable) return; if (!m_histogramPopup->isVisible()) return; - QPoint curPos = event->pos() * getDevPixRatio(); + QPointF curPos = event->localPos() * getDevPixRatio(); // avoid to pick outside of the flip - if ((!m_image) || !rect().contains(curPos)) { + if ((!m_image) || !rect().contains(curPos.toPoint())) { // throw transparent color m_histogramPopup->updateInfo(TPixel32::Transparent, TPointD(-1, -1)); return; @@ -893,21 +893,26 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { StylePicker picker(m_image); - TPoint mousePos = TPoint(curPos.x(), height() - 1 - curPos.y()); - TRectD area = TRectD(mousePos.x, mousePos.y, mousePos.x, mousePos.y); + TPointD mousePos = TPointD(curPos.x(), height() - 1 - curPos.y()); + TRectD area = TRectD(mousePos.x, mousePos.y, mousePos.x, mousePos.y); - if (m_lutCalibrator && m_lutCalibrator->isValid()) m_fbo->bind(); + TPointD pos = + getViewAff().inv() * TPointD(curPos.x() - (qreal)(width()) / 2, + -curPos.y() + (qreal)(height()) / 2); - const TPixel32 pix = picker.pickColor(area); + TRectD imgRect = (m_image->raster()) + ? convert(TRect(m_image->raster()->getSize())) + : m_image->getBBox(); + TPointD imagePos = + TPointD(0.5 * imgRect.getLx() + pos.x, 0.5 * imgRect.getLy() + pos.y); - if (m_lutCalibrator && m_lutCalibrator->isValid()) m_fbo->release(); + TPixel32 pix; + if (m_lutCalibrator && m_lutCalibrator->isValid()) + pix = picker.pickColor(pos + TPointD(-0.5, -0.5)); + else + pix = picker.pickColor(area); - QPoint viewP = mapFrom(this, curPos); - TPointD pos = getViewAff().inv() * - TPointD(viewP.x() - width() / 2, -viewP.y() + height() / 2); - TPointD imagePos = TPointD(0.5 * m_image->getBBox().getLx() + pos.x, - 0.5 * m_image->getBBox().getLy() + pos.y); - if (m_image->getBBox().contains(imagePos)) { + if (!m_image->raster() || imgRect.contains(imagePos)) { // throw the picked color to the histogram m_histogramPopup->updateInfo(pix, imagePos); // throw it to the style editor as well @@ -923,6 +928,14 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { * specified rectangle */ void ImageViewer::rectPickColor(bool putValueToStyleEditor) { + auto isRas32 = [this]() -> bool { + TRasterImageP ri = m_image; + if (!ri) return false; + TRaster32P ras32 = ri->getRaster(); + if (!ras32) return false; + return true; + }; + if (!m_isHistogramEnable) return; if (!m_histogramPopup->isVisible()) return; @@ -938,11 +951,15 @@ void ImageViewer::rectPickColor(bool putValueToStyleEditor) { return; } - if (m_lutCalibrator && m_lutCalibrator->isValid() && m_fbo) m_fbo->bind(); - - const TPixel32 pix = picker.pickColor(area.enlarge(-1, -1)); - - if (m_lutCalibrator && m_lutCalibrator->isValid() && m_fbo) m_fbo->release(); + TPixel32 pix; + if (m_lutCalibrator && m_lutCalibrator->isValid() && isRas32()) { + TPointD start = getViewAff().inv() * TPointD(startPos.x - width() / 2, + startPos.y - height() / 2); + TPointD end = getViewAff().inv() * + TPointD(endPos.x - width() / 2, endPos.y - height() / 2); + pix = picker.pickAverageColor(TRectD(start, end)); + } else + pix = picker.pickColor(area.enlarge(-1, -1)); // throw the picked color to the histogram m_histogramPopup->updateAverageColor(pix); diff --git a/toonz/sources/toonz/ruler.cpp b/toonz/sources/toonz/ruler.cpp index c6d9d50..bd27cac 100644 --- a/toonz/sources/toonz/ruler.cpp +++ b/toonz/sources/toonz/ruler.cpp @@ -248,36 +248,44 @@ double Ruler::posToValue(const QPoint &p) const { //----------------------------------------------------------------------------- void Ruler::mousePressEvent(QMouseEvent *e) { - if (e->button() == Qt::LeftButton) { - Guides &guides = getGuides(); - double v = posToValue(e->pos()); - m_hiding = false; - m_moving = false; - int selected = -1; - double minDist2 = 0; - int i; - int count = guides.size(); - for (i = 0; i < count; i++) { - double g = guides[i] / (double)getDevPixRatio(); - double dist2 = (g - v) * (g - v); - if (selected < 0 || dist2 < minDist2) { - minDist2 = dist2; - selected = i; - } + if (e->button() != Qt::LeftButton && e->button() != Qt::RightButton) return; + Guides &guides = getGuides(); + double v = posToValue(e->pos()); + m_hiding = false; + m_moving = false; + int selected = -1; + double minDist2 = 0; + int i; + int count = guides.size(); + for (i = 0; i < count; i++) { + double g = guides[i] / (double)getDevPixRatio(); + double dist2 = (g - v) * (g - v); + if (selected < 0 || dist2 < minDist2) { + minDist2 = dist2; + selected = i; } + } + if (e->button() == Qt::LeftButton) { if (selected < 0 || minDist2 > 25) { // crea una nuova guida guides.push_back(v * getDevPixRatio()); m_viewer->update(); // aggiorna sprop!!!! - } else { - // muove la guida vecchia - if (selected < count - 1) std::swap(guides[selected], guides.back()); - // aggiorna sprop!!!! - } + } else if (selected < count - 1) + std::swap(guides[selected], guides.back()); + m_moving = true; update(); assert(guides.size() > 0); + } else if (e->button() == Qt::RightButton) { + if (selected < count - 1) std::swap(guides[selected], guides.back()); + if (count > 0 && minDist2 <= 25) { + assert(!guides.empty()); + guides.pop_back(); + update(); + m_viewer->update(); + return; + } } } @@ -293,25 +301,26 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) { return; } - Guides &guides = getGuides(); - double v = posToValue(e->pos()); - m_hiding = false; - m_moving = false; - double minDist2 = 5; - int i; + Guides &guides = getGuides(); + double v = posToValue(e->pos()); + m_hiding = false; + m_moving = false; + int count = guides.size(); - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { double g = guides[i] / (double)getDevPixRatio(); double dist2 = (g - v) * (g - v); - if (dist2 < minDist2) - setToolTip(tr("Click and drag to move guide")); - else { - if (m_vertical) - setToolTip(tr("Click to create an horizontal guide")); - else - setToolTip(tr("Click to create a vertical guide")); + if (dist2 < 25) { + setToolTip( + tr("Left click and drag to move guide. Right click to delete guide")); + return; } } + // in case no guides are found near the cursor + if (m_vertical) + setToolTip(tr("Click to create an horizontal guide")); + else + setToolTip(tr("Click to create a vertical guide")); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/xshcellmover.cpp b/toonz/sources/toonz/xshcellmover.cpp index 1f962f9..ece092c 100644 --- a/toonz/sources/toonz/xshcellmover.cpp +++ b/toonz/sources/toonz/xshcellmover.cpp @@ -660,8 +660,8 @@ void LevelMoverTool::drawCellsArea(QPainter &p) { CellRange(CellPosition(rect.y0, rect.x0), CellPosition(rect.y1 + 1, rect.x1 + 1))); else { - int newY0 = qMax(rect.y0, rect.y1); - int newY1 = qMin(rect.y0, rect.y1); + int newY0 = std::max(rect.y0, rect.y1); + int newY1 = std::min(rect.y0, rect.y1); screen = getViewer()->rangeToXYRect(CellRange( CellPosition(rect.x0, newY0), CellPosition(rect.x1 + 1, newY1 - 1))); } diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index 7105ba9..7f1c23a 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -772,6 +772,7 @@ void RenameCellField::renameCell() { if (!cellSelection) return; QList cells; + bool hasFrameZero = false; if (levelName == L"") { int r0, c0, r1, c1; @@ -817,7 +818,9 @@ void RenameCellField::renameCell() { if (fid == TFrameId::NO_FRAME) fid = (m_row - tmpRow <= 1) ? cell.m_frameId : TFrameId(0); cells.append(TXshCell(xl, fid)); - changed = true; + changed = true; + hasFrameZero = (fid.getNumber() == 0 && xl->getSimpleLevel() && + xl->getSimpleLevel()->isFid(fid)); } if (!changed) return; } else { @@ -837,9 +840,11 @@ void RenameCellField::renameCell() { } if (!xl) return; cells.append(TXshCell(xl, fid)); + hasFrameZero = (fid.getNumber() == 0 && xl->getSimpleLevel() && + xl->getSimpleLevel()->isFid(fid)); } - if (fid.getNumber() == 0) { + if (fid.getNumber() == 0 && !hasFrameZero) { TCellSelection::Range range = cellSelection->getSelectedCells(); cellSelection->deleteCells(); // revert cell selection @@ -1104,8 +1109,8 @@ void CellArea::drawCells(QPainter &p, const QRect toBeUpdated) { c0 = visible.from().layer(); c1 = visible.to().layer(); if (!m_viewer->orientation()->isVerticalTimeline()) { - int colCount = qMax(1, xsh->getColumnCount()); - c1 = qMin(c1, colCount - 1); + int colCount = std::max(1, xsh->getColumnCount()); + c1 = std::min(c1, colCount - 1); } drawNonEmptyBackground(p); @@ -1275,8 +1280,8 @@ void CellArea::drawSelectionBackground(QPainter &p) const { CellRange(CellPosition(selRow0, selCol0), CellPosition(selRow1 + 1, selCol1 + 1))); else { - int newSelCol0 = qMax(selCol0, selCol1); - int newSelCol1 = qMin(selCol0, selCol1); + int newSelCol0 = std::max(selCol0, selCol1); + int newSelCol1 = std::min(selCol0, selCol1); selectionRect = m_viewer->rangeToXYRect( CellRange(CellPosition(selRow0, newSelCol0), CellPosition(selRow1 + 1, newSelCol1 - 1))); @@ -1856,7 +1861,7 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) { else { std::string frameNumber(""); // set number - if (fid.getNumber() > 0) frameNumber = std::to_string(fid.getNumber()); + if (fid.getNumber() >= 0) frameNumber = std::to_string(fid.getNumber()); // add letter if (fid.getLetter() != 0) frameNumber.append(1, fid.getLetter()); fnum = QString::fromStdString(frameNumber); @@ -2879,7 +2884,7 @@ void CellArea::mouseMoveEvent(QMouseEvent *event) { m_viewer->getFrameNumberWithLetters(fid.getNumber()); } else { std::string frameNumber(""); - if (fid.getNumber() > 0) frameNumber = std::to_string(fid.getNumber()); + if (fid.getNumber() >= 0) frameNumber = std::to_string(fid.getNumber()); if (fid.getLetter() != 0) frameNumber.append(1, fid.getLetter()); m_tooltip = QString((frameNumber.empty()) diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index 7045c19..b605dce 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -1552,8 +1552,8 @@ void ColumnArea::paintEvent(QPaintEvent *event) { // AREA c0 = cellRange.from().layer(); c1 = cellRange.to().layer(); if (!m_viewer->orientation()->isVerticalTimeline()) { - int colCount = qMax(1, xsh->getColumnCount()); - c1 = qMin(c1, colCount - 1); + int colCount = std::max(1, xsh->getColumnCount()); + c1 = std::min(c1, colCount - 1); } ColumnFan *columnFan = xsh->getColumnFan(m_viewer->orientation()); diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp index df2aecc..4f06327 100644 --- a/toonz/sources/toonz/xsheetcmd.cpp +++ b/toonz/sources/toonz/xsheetcmd.cpp @@ -692,64 +692,93 @@ private: int m_row; int m_col; int m_count; + bool m_selected; + TCellSelection::Range m_range; + std::vector> emptyCells; + typedef std::map, int> FramesMap; + FramesMap m_frameRanges; public: - DrawingSubtitutionGroupUndo(int dir, int row, int col) - : m_direction(dir), m_col(col), m_row(row) { - m_count = 1; - TXshCell cell = TTool::getApplication() - ->getCurrentScene() - ->getScene() - ->getXsheet() - ->getCell(m_row, m_col); - if (!cell.m_level || - !(cell.m_level->getSimpleLevel() || cell.m_level->getChildLevel() || - cell.m_level->getSoundTextLevel())) - return; + DrawingSubtitutionGroupUndo(int dir, int row, int col, bool selected, + TCellSelection::Range range) + : m_direction(dir) + , m_col(col) + , m_row(row) + , m_selected(selected) + , m_range(range) { + TXsheet *xsh = + TTool::getApplication()->getCurrentScene()->getScene()->getXsheet(); + + if (!selected) { + m_range.m_c0 = col; + m_range.m_r0 = row; + m_range.m_c1 = col; + m_range.m_r1 = row; + } - TFrameId id = cell.m_frameId; - - TXshCell nextCell = TTool::getApplication() - ->getCurrentScene() - ->getScene() - ->getXsheet() - ->getCell(m_row + m_count, m_col); - if (!nextCell.m_level || - !(nextCell.m_level->getSimpleLevel() || - nextCell.m_level->getChildLevel() || - nextCell.m_level->getSoundTextLevel())) - return; + for (int c = m_range.m_c0; c <= m_range.m_c1; c++) { + for (int r = m_range.m_r0; r <= m_range.m_r1; r++) { + TXshCell baseCell = xsh->getCell(r, c); + + // Find the 1st populated cell in the column + if (baseCell.isEmpty()) continue; - TFrameId nextId = nextCell.m_frameId; + FramesMap::key_type frameBaseKey(r, c); + int frameCount = 1; + TXshCell nextCell = xsh->getCell((r + frameCount), c); + while (nextCell == baseCell || + (nextCell.isEmpty() && (r + frameCount) <= m_range.m_r1)) { + if (nextCell.isEmpty()) + emptyCells.push_back(std::make_pair((r + frameCount), c)); - while (id == nextId) { - m_count++; - nextCell = TTool::getApplication() - ->getCurrentScene() - ->getScene() - ->getXsheet() - ->getCell(m_row + m_count, m_col); - nextId = nextCell.m_frameId; + frameCount++; + nextCell = xsh->getCell((r + frameCount), c); + } + m_frameRanges.insert(std::make_pair(frameBaseKey, 0)); + m_frameRanges[frameBaseKey] = frameCount; + r = r + (frameCount - 1); // Skip frames in range we've processed + } } } void undo() const override { - int n = 1; - DrawingSubtitutionUndo::changeDrawing(-m_direction, m_row, m_col); - while (n < m_count) { - DrawingSubtitutionUndo::changeDrawing(-m_direction, m_row + n, m_col); - n++; + TXsheet *xsh = + TTool::getApplication()->getCurrentScene()->getScene()->getXsheet(); + FramesMap::const_iterator ct; + for (ct = m_frameRanges.begin(); ct != m_frameRanges.end(); ++ct) { + int n = 0; + while (n < ct->second) { + int row = ct->first.first + n; + int col = ct->first.second; + std::vector>::const_iterator it; + bool found = false; + for (it = emptyCells.begin(); it != emptyCells.end(); ++it) { + if (it->first == row && it->second == col) { + xsh->clearCells(row, col); + found = true; + } + } + + if (!found) + DrawingSubtitutionUndo::changeDrawing(-m_direction, row, col); + n++; + } } + TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); TApp::instance()->getCurrentScene()->setDirtyFlag(true); } void redo() const override { - int n = 1; - DrawingSubtitutionUndo::changeDrawing(m_direction, m_row, m_col); - while (n < m_count) { - DrawingSubtitutionUndo::changeDrawing(m_direction, m_row + n, m_col); - n++; + FramesMap::const_iterator ct; + for (ct = m_frameRanges.begin(); ct != m_frameRanges.end(); ++ct) { + int n = 0; + while (n < ct->second) { + int row = ct->first.first + n; + int col = ct->first.second; + DrawingSubtitutionUndo::changeDrawing(m_direction, row, col); + n++; + } } TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); TApp::instance()->getCurrentScene()->setDirtyFlag(true); @@ -878,15 +907,19 @@ static void drawingSubstituion(int dir) { } static void drawingSubstituionGroup(int dir) { + TCellSelection *selection = dynamic_cast( + TTool::getApplication()->getCurrentSelection()->getSelection()); + TCellSelection::Range range; + bool selected = false; + if (selection) { + range = selection->getSelectedCells(); + if (!(range.isEmpty())) selected = true; + } int row = TTool::getApplication()->getCurrentFrame()->getFrame(); int col = TTool::getApplication()->getCurrentColumn()->getColumnIndex(); - TXshCell cell = - TApp::instance()->getCurrentScene()->getScene()->getXsheet()->getCell( - row, col); - bool isEmpty = cell.isEmpty(); - if (isEmpty) return; + DrawingSubtitutionGroupUndo *undo = - new DrawingSubtitutionGroupUndo(dir, row, col); + new DrawingSubtitutionGroupUndo(dir, row, col, selected, range); TUndoManager::manager()->add(undo); undo->redo(); } diff --git a/toonz/sources/toonz/xsheetdragtool.cpp b/toonz/sources/toonz/xsheetdragtool.cpp index 312fb4a..619ac12 100644 --- a/toonz/sources/toonz/xsheetdragtool.cpp +++ b/toonz/sources/toonz/xsheetdragtool.cpp @@ -2149,8 +2149,8 @@ public: CellRange(CellPosition(rect.y0, rect.x0), CellPosition(rect.y1 + 1, rect.x1 + 1))); else { - int newY0 = qMax(rect.y0, rect.y1); - int newY1 = qMin(rect.y0, rect.y1); + int newY0 = std::max(rect.y0, rect.y1); + int newY1 = std::min(rect.y0, rect.y1); screenCell = getViewer()->rangeToXYRect(CellRange( CellPosition(rect.x0, newY0), CellPosition(rect.x1 + 1, newY1 - 1))); } diff --git a/toonz/sources/toonz/xsheetviewer.cpp b/toonz/sources/toonz/xsheetviewer.cpp index 08272c0..93111d4 100644 --- a/toonz/sources/toonz/xsheetviewer.cpp +++ b/toonz/sources/toonz/xsheetviewer.cpp @@ -653,7 +653,7 @@ void XsheetViewer::timerEvent(QTimerEvent *) { bool XsheetViewer::refreshContentSize(int dx, int dy) { QSize viewportSize = m_cellScrollArea->viewport()->size(); QPoint offset = m_cellArea->pos(); - offset = QPoint(qMin(0, offset.x() - dx), qMin(0, offset.y() - dy)); // what? + offset = QPoint(std::min(0, offset.x() - dx), std::min(0, offset.y() - dy)); // what? TXsheet *xsh = getXsheet(); int frameCount = xsh ? xsh->getFrameCount() : 0; @@ -754,7 +754,7 @@ int XsheetViewer::colToTimelineLayerAxis(int layer) const { int yBottom = o->colToLayerAxis(layer, fan) + (fan->isActive(layer) ? o->cellHeight() : o->foldedCellSize()) - 1; - int columnCount = qMax(1, xsh->getColumnCount()); + int columnCount = std::max(1, xsh->getColumnCount()); int layerHeightActual = m_columnArea->height() - 2; // o->colToLayerAxis(columnCount, fan) - 1; @@ -780,7 +780,7 @@ CellPosition XsheetViewer::xyToPosition(const QPoint &point) const { // For timeline mode, we need to base the Y axis on the bottom of the column // area // since the layers are flipped - int columnCount = qMax(1, xsh->getColumnCount()); + int columnCount = std::max(1, xsh->getColumnCount()); int colAreaHeight = o->colToLayerAxis(columnCount, fan); usePoint.setY(colAreaHeight - usePoint.y()); @@ -818,9 +818,9 @@ QPoint XsheetViewer::positionToXY(const CellPosition &pos) const { // since the layers are flipped usePoint.setY(usePoint.y() - o->cellHeight() + (fan->isActive(pos.layer()) - ? o->cellHeight() - : o->foldedCellSize())); - int columnCount = qMax(1, xsh->getColumnCount()); + ? o->cellHeight() + : o->foldedCellSize())); + int columnCount = std::max(1, xsh->getColumnCount()); int colsHeight = o->colToLayerAxis(columnCount, fan); if (colsHeight) @@ -1771,7 +1771,7 @@ int XsheetViewer::getFrameZoomAdjustment() { int adj = frameRect.width() - ((frameRect.width() * getFrameZoomFactor()) / 100) - 1; - return qMax(0, adj); + return std::max(0, adj); } void XsheetViewer::zoomOnFrame(int frame, int factor) { diff --git a/toonz/sources/toonzlib/Naa2TlvConverter.cpp b/toonz/sources/toonzlib/Naa2TlvConverter.cpp index 239516f..a00d4a9 100644 --- a/toonz/sources/toonzlib/Naa2TlvConverter.cpp +++ b/toonz/sources/toonzlib/Naa2TlvConverter.cpp @@ -344,7 +344,7 @@ void Naa2TlvConverter::findBackgroundRegions() { for (int i = 0; i < m_colors.count(); i++) { TPixel color = m_colors.at(i); int v = color.r + color.g + color.b; - int a = qMin(color.r, qMin(color.g, color.b)); + int a = std::min({color.r, color.g, color.b}); if (a < 230) continue; if (v > maxV) { bgColorIndex = i; @@ -682,8 +682,8 @@ void Naa2TlvConverter::findSuspectInks() { if (region.isInk() && 10 <= region.pixelCount && region.pixelCount < 100) { int lx = region.x1 - region.x0 + 1; int ly = region.y1 - region.y0 + 1; - int d = qMax(lx, ly); - if (qMin(lx, ly) * 2 > qMax(lx, ly) && region.pixelCount > d * d / 2) { + int d = std::max(lx, ly); + if (std::min(lx, ly) * 2 > std::max(lx, ly) && region.pixelCount > d * d / 2) { region.type = RegionInfo::Paint; } } diff --git a/toonz/sources/toonzlib/boardsettings.cpp b/toonz/sources/toonzlib/boardsettings.cpp index 16d4628..89acfff 100644 --- a/toonz/sources/toonzlib/boardsettings.cpp +++ b/toonz/sources/toonzlib/boardsettings.cpp @@ -200,7 +200,7 @@ void BoardItem::saveData(TOStream &os) { << m_rect.height(); if (m_type == Image) { - // if the path is in library folder, then save the realtive path + // if the path is in library folder, then save the relative path TFilePath libFp = ToonzFolder::getLibraryFolder(); if (libFp.isAncestorOf(m_imgPath)) os.child("imgPath") << 1 << m_imgPath - libFp; diff --git a/toonz/sources/toonzlib/cleanuppalette.cpp b/toonz/sources/toonzlib/cleanuppalette.cpp index 676ef86..2f49a2e 100644 --- a/toonz/sources/toonzlib/cleanuppalette.cpp +++ b/toonz/sources/toonzlib/cleanuppalette.cpp @@ -94,11 +94,11 @@ TPalette *createToonzPalette(TPalette *cleanupPalette, int colorParamIndex) { void TargetColors::update(TPalette *palette, bool noAntialias) { m_colors.clear(); - TargetColor tranparent(TPixel32(255, 255, 255, 0) /*TPixel32::Transparent*/, + TargetColor transparent(TPixel32(255, 255, 255, 0) /*TPixel32::Transparent*/, 0, // BackgroundStyle, 0, 0, 0, 0); - m_colors.push_back(tranparent); + m_colors.push_back(transparent); for (int i = 0; i < palette->getPage(0)->getStyleCount(); i++) { int styleId = palette->getPage(0)->getStyleId(i); diff --git a/toonz/sources/toonzlib/fxcommand.cpp b/toonz/sources/toonzlib/fxcommand.cpp index 73a07ef..aab8e07 100644 --- a/toonz/sources/toonzlib/fxcommand.cpp +++ b/toonz/sources/toonzlib/fxcommand.cpp @@ -1166,7 +1166,7 @@ void ReplaceFxUndo::initialize() { m_repColumn = new TXshZeraryFxColumn(*zcfx->getColumn()); m_repColIdx = m_colIdx; - // Substitute the column's zerary fx with the subsitute one + // Substitute the column's zerary fx with the substitute one TZeraryColumnFx *repZcfx = static_cast(m_repColumn->getFx()); repZcfx->setZeraryFx(repFx); @@ -2243,7 +2243,7 @@ void DeleteFxOrColumnUndo::redo() const { ->getParams()); // However, params stored there are NOT cloned. } // This is fine since we're deleting the column... - // Peform operation + // Perform operation FxCommandUndo::removeFxOrColumn(xsh, m_fx.getPointer(), m_colIdx); m_xshHandle->notifyXsheetChanged(); // Add the rest... diff --git a/toonz/sources/toonzlib/ikjacobian.cpp b/toonz/sources/toonzlib/ikjacobian.cpp index 94f9bea..6151a7a 100644 --- a/toonz/sources/toonzlib/ikjacobian.cpp +++ b/toonz/sources/toonzlib/ikjacobian.cpp @@ -167,7 +167,7 @@ void MatrixRmn::SetSequence(const VectorRn &d, long startRow, long startCol, } // The matrix A is loaded, in into "this" matrix, based at (0,0). -// The size of "this" matrix must be large enough to accomodate A. +// The size of "this" matrix must be large enough to accommodate A. // The rest of "this" matrix is left unchanged. It is not filled with // zeroes! @@ -188,7 +188,7 @@ void MatrixRmn::LoadAsSubmatrix(const MatrixRmn &A) { // The matrix A is loaded, in transposed order into "this" matrix, based at // (0,0). -// The size of "this" matrix must be large enough to accomodate A. +// The size of "this" matrix must be large enough to accommodate A. // The rest of "this" matrix is left unchanged. It is not filled with // zeroes! void MatrixRmn::LoadAsSubmatrixTranspose(const MatrixRmn &A) { @@ -412,7 +412,7 @@ void MatrixRmn::Solve(const VectorRn &b, VectorRn *xVec) const { // The "NoFree" version operates on the assumption that no free variable will be // found. // Algorithm uses row operations and row pivoting (only). -// Augmented matrix is correctly accomodated. Only the first square part +// Augmented matrix is correctly accommodated. Only the first square part // participates // in the main work of row operations. void MatrixRmn::ConvertToRefNoFree() { @@ -1546,7 +1546,7 @@ void Jacobian::CalcDeltaThetasSDLS() { double gamma = MaxAngleSDLS; if (N < M) { - gamma *= N / M; // Scale back maximum permissable joint angle + gamma *= N / M; // Scale back maximum permissible joint angle } // Calculate the dTheta from pure pseudoinverse considerations diff --git a/toonz/sources/toonzlib/levelupdater.cpp b/toonz/sources/toonzlib/levelupdater.cpp index bc86051..adba494 100644 --- a/toonz/sources/toonzlib/levelupdater.cpp +++ b/toonz/sources/toonzlib/levelupdater.cpp @@ -246,7 +246,7 @@ void LevelUpdater::open(const TFilePath &fp, TPropertyGroup *pg) { m_lwPath = fp; } } catch (...) { - // In this case, TLevelWriterP(..) failed, that object was never contructed, + // In this case, TLevelWriterP(..) failed, that object was never constructed, // the assignment m_lw never took place. And m_lw == 0. // Reset state and rethrow diff --git a/toonz/sources/toonzlib/movierenderer.cpp b/toonz/sources/toonzlib/movierenderer.cpp index 30cd6e3..30d4d6a 100644 --- a/toonz/sources/toonzlib/movierenderer.cpp +++ b/toonz/sources/toonzlib/movierenderer.cpp @@ -404,7 +404,7 @@ std::pair MovieRenderer::Imp::saveFrame( has64bitOutputSupport = writerA->is64bitOutputSupported(); // NOTE: If the writer could not be retrieved, the updater will throw. - // Failure will be catched then. + // Failure will be caught then. } // Prepare the images to be flushed @@ -876,7 +876,7 @@ TRenderer *MovieRenderer::getTRenderer() { // MovieRenderer instance. // Since a TRenderer is already smart-pointer-like, we could just return a // copy - however, it really - // shouln't be that way. Maybe one day we'll revert that and actually use a + // shouldn't be that way. Maybe one day we'll revert that and actually use a // smart pointer class. // For now, no use of this function seems to access the returned pointer diff --git a/toonz/sources/toonzlib/palettecmd.cpp b/toonz/sources/toonzlib/palettecmd.cpp index a133a47..48e4693 100644 --- a/toonz/sources/toonzlib/palettecmd.cpp +++ b/toonz/sources/toonzlib/palettecmd.cpp @@ -921,7 +921,7 @@ int loadRefImage(TPaletteHandle *paletteHandle, // values std::set colors; if (config.rasterPickType == PaletteCmd::PickEveryColors) { - // different colors will become sparate styles + // different colors will become separate styles TColorUtils::buildPrecisePalette(colors, raster, availableColorCount); } else { // config.rasterPickType == diff --git a/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp b/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp index 4f53721..bce69ad 100644 --- a/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/CallCircle.cpp @@ -70,7 +70,7 @@ void CCallCircle::print() { void CCallCircle::draw(UCHAR *drawB, const int lX, const int lY, const int xx, const int yy, const double r) { - double aa = 2.0 * r / 3.0; // Size of antialising + double aa = 2.0 * r / 3.0; // Size of antialiasing for (int i = 0; i < m_nb && m_c[i].w <= r; i++) { double w = m_c[i].w; diff --git a/toonz/sources/toonzlib/sandor_fxs/STPic.h b/toonz/sources/toonzlib/sandor_fxs/STPic.h index a9fa2ac..d6135e7 100644 --- a/toonz/sources/toonzlib/sandor_fxs/STPic.h +++ b/toonz/sources/toonzlib/sandor_fxs/STPic.h @@ -37,7 +37,7 @@ m_ras - stores the pointer to the original RASTER picture #define ISINPIC(x, y) (m_pic && x >= 0 && x < m_lX && y >= 0 && y < m_lY) typedef enum { - ST_NIL, // EMTY + ST_NIL, // EMPTY ST_RGBM, // UC_PIXEL ST_RGBM64 // US_PIXEL } ST_TYPE; diff --git a/toonz/sources/toonzlib/sandor_fxs/blend.cpp b/toonz/sources/toonzlib/sandor_fxs/blend.cpp index 6939ee5..f061b56 100644 --- a/toonz/sources/toonzlib/sandor_fxs/blend.cpp +++ b/toonz/sources/toonzlib/sandor_fxs/blend.cpp @@ -121,7 +121,7 @@ public: //================================================================================= -// Bitmap used to store blend color selections and pure color informations. +// Bitmap used to store blend color selections and pure color information. class SelectionRaster { SelectionArrayPtr m_selection; diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp index 987771e..622bb34 100644 --- a/toonz/sources/toonzlib/stage.cpp +++ b/toonz/sources/toonzlib/stage.cpp @@ -111,7 +111,7 @@ bool descending(int i, int j) { return (i > j); } } //============================================================================= -/*! The ZPlacement class preserve camera position informations. +/*! The ZPlacement class preserve camera position information. */ //============================================================================= @@ -207,11 +207,11 @@ public: StageBuilder(); virtual ~StageBuilder(); - /*! Add in \b players vector informations about specify cell. + /*! Add in \b players vector information about specify cell. \n Analyze cell in row \b row and column \b col of xsheet \b xsh. If level containing this cell is a simple level, \b TXshSimpleLevel, create a Pleyer - object with informations of the cell. Else if level is a child + object with information of the cell. Else if level is a child level, \b TXshChildLevel, recall \b addFrame(). */ @@ -232,7 +232,7 @@ public: void addFrame(PlayerSet &players, ToonzScene *scene, TXsheet *xsh, int row, int level, bool includeUnvisible, bool checkPreviewVisibility); - /*! Add in \b players vector informations about \b level cell with \b TFrameId + /*! Add in \b players vector information about \b level cell with \b TFrameId \b fid. \n Compute information for all cell with active onion-skin, if onion-skin is not active diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cpp index 58784ee..e62ff4b 100644 --- a/toonz/sources/toonzlib/stagevisitor.cpp +++ b/toonz/sources/toonzlib/stagevisitor.cpp @@ -1176,7 +1176,7 @@ void OpenGlPainter::onRasterImage(TRasterImage *ri, bool premultiplied = tlvFlag; // xD static std::vector - matteChan; // Wtf this is criminal. Altough probably this + matteChan; // Wtf this is criminal. Although probably this // stuff is used only in the main thread... hmmm.... TRaster32P r = (TRaster32P)ri->getRaster(); r->lock(); diff --git a/toonz/sources/toonzlib/tbinarizer.cpp b/toonz/sources/toonzlib/tbinarizer.cpp index 49ee49f..782ed75 100644 --- a/toonz/sources/toonzlib/tbinarizer.cpp +++ b/toonz/sources/toonzlib/tbinarizer.cpp @@ -53,7 +53,7 @@ else color=6; // ritorna true se i primi pixel del buffer non sono tutti opachi bool hasAlpha(const TPixel32 *buffer, int w, int h) { - int n = qMin(500, w * h); + int n = std::min(500, w * h); for (int i = 0; i < n; i++) if (buffer[i].m < 255) return true; return false; @@ -129,10 +129,10 @@ void TBinarizer::process(const TRaster32P &ras) { // conto i quadrati che hanno un "buon" background for (int y1 = 0; y1 < h1; y1++) { int ya = y1 * bsize; - int yb = qMin(h, ya + bsize) - 1; + int yb = std::min(h, ya + bsize) - 1; for (int x1 = 0; x1 < w1; x1++) { int xa = x1 * bsize; - int xb = qMin(w, xa + bsize) - 1; + int xb = std::min(w, xa + bsize) - 1; int tot = 0; std::vector histo(32, 0); @@ -140,7 +140,7 @@ void TBinarizer::process(const TRaster32P &ras) { for (int x = xa; x <= xb; x++) { int k = y * w + x; TPixel32 pix = buffer[k]; - int v = qMin(qMin(pix.r, pix.g), pix.b); + int v = std::min({pix.r, pix.g, pix.b}); vBuffer[k] = v; histo[v >> 3] += 1; tot += 1; @@ -196,16 +196,16 @@ void TBinarizer::process(const TRaster32P &ras) { // cerco i pixel sicuramente colorati e i sicuramente neri for (int y1 = 0; y1 < h1; y1++) { - int ya = qMax(1, y1 * bsize); - int yb = qMin(h - 1, ya + bsize) - 1; + int ya = std::max(1, y1 * bsize); + int yb = std::min(h - 1, ya + bsize) - 1; for (int x1 = 0; x1 < w1; x1++) { int k1 = y1 * w1 + x1; // salto i quadrati completamente bianchi if (qBuffer[k1] >= thrBuffer[k1] - thrDelta) continue; for (int y = ya + 1; y <= yb; y++) { - int xa = qMax(1, x1 * bsize); - int xb = qMin(w - 1, xa + bsize) - 1; + int xa = std::max(1, x1 * bsize); + int xb = std::min(w - 1, xa + bsize) - 1; for (int x = xa + 1; x <= xb; x++) { int k = y * w + x; diff --git a/toonz/sources/toonzlib/tcenterlineadjustments.cpp b/toonz/sources/toonzlib/tcenterlineadjustments.cpp index 45a96ee..9489fd4 100644 --- a/toonz/sources/toonzlib/tcenterlineadjustments.cpp +++ b/toonz/sources/toonzlib/tcenterlineadjustments.cpp @@ -28,7 +28,7 @@ ContourFamily *currContourFamily; //-------------------------------------- // EXPLANATION: The raw skeleton data obtained from StraightSkeletonizer -// class need to be grouped in joints and sequences before proceding with +// class need to be grouped in joints and sequences before proceeding with // conversion in quadratics - which works on single sequences. // NOTE: Due to maxHeight, we have to assume that a single SkeletonGraph can diff --git a/toonz/sources/toonzlib/tcenterlinecolors.cpp b/toonz/sources/toonzlib/tcenterlinecolors.cpp index 478fc86..57a94d9 100644 --- a/toonz/sources/toonzlib/tcenterlinecolors.cpp +++ b/toonz/sources/toonzlib/tcenterlinecolors.cpp @@ -123,10 +123,9 @@ static void sampleColor(const TRasterCM32P &ras, int threshold, Sequence &seq, std::vector params; // Meanwhile, ensure each point belong to ras. Otherwise, typically an error - // occured - // in the thinning process and it's better avoid sampling procedure. Only - // exception, when - // a point has x==ras->getLx() || y==ras->getLy(); that is accepted. + // occurred in the thinning process and it's better avoid sampling procedure. + // Only exception, when a point has + // x==ras->getLx() || y==ras->getLy(); that is accepted. { const T3DPointD &headPos = *currGraph->getNode(seq.m_head); @@ -210,9 +209,8 @@ static void sampleColor(const TRasterCM32P &ras, int threshold, Sequence &seq, } // NOTE: Extremities of a sequence are considered unreliable: they typically - // happen - // to be junction points shared between possibly different-colored - // strokes. + // happen to be junction points shared between possibly different-colored + // strokes. // Find first and last extremity-free sampled points T3DPointD first(*currGraph->getNode(seq.m_head)); @@ -385,8 +383,7 @@ void calculateSequenceColors(const TRasterP &ras, VectorizerCoreGlobals &g) { if (cm && g.currConfig->m_maxThickness > 0.0) { // singleSequence is traversed back-to-front because new, possibly splitted - // sequences - // are inserted at back - and don't have to be re-sampled. + // sequences are inserted at back - and don't have to be re-sampled. for (l = singleSequences.size() - 1; l >= 0; --l) { Sequence rear; sampleColor(ras, threshold, singleSequences[l], rear, singleSequences); diff --git a/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp b/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp index 00d877f..d829435 100644 --- a/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp +++ b/toonz/sources/toonzlib/tcenterlinepolygonizer.cpp @@ -257,7 +257,7 @@ void Signaturemap::readRasterData(const TRasterPT &ras, int threshold) { //-------------------------------------------------------------------------- -// Minority check for amiguous turning directions +// Minority check for ambiguous turning directions inline bool getMinorityCheck(const Signaturemap &ras, int x, int y) { // Assumes (x,y) is ambiguous case: 2 immediate surrounding pixels are white // and 2 black diff --git a/toonz/sources/toonzlib/tcenterlineskeletonizer.cpp b/toonz/sources/toonzlib/tcenterlineskeletonizer.cpp index 0705e75..5fdadc4 100644 --- a/toonz/sources/toonzlib/tcenterlineskeletonizer.cpp +++ b/toonz/sources/toonzlib/tcenterlineskeletonizer.cpp @@ -109,7 +109,7 @@ public: typedef std::list IndexColumn; std::vector - m_columns; //!< Countours set by 'column identifier'. + m_columns; //!< Contours set by 'column identifier'. std::vector m_identifiers; //!< Column identifiers by original contour index. @@ -1385,7 +1385,7 @@ inline void Event::processSplitEvent() { m_generator->m_next->m_prev = newLeftNode; newLeftNode->m_next = m_generator->m_next; - // Assign and calculate the new nodes' informations + // Assign and calculate the new nodes' information newLeftNode->m_edge = m_generator->m_edge; newRightNode->m_edge = m_coGenerator->m_edge; @@ -1491,7 +1491,7 @@ inline void Event::processVertexEvent() { m_generator->m_next->m_prev = newLeftNode; newLeftNode->m_next = m_generator->m_next; - // Assign and calculate the new nodes' informations + // Assign and calculate the new nodes' information newLeftNode->m_edge = m_generator->m_edge; newRightNode->m_edge = m_coGenerator->m_edge; diff --git a/toonz/sources/toonzlib/tcenterlinetostrokes.cpp b/toonz/sources/toonzlib/tcenterlinetostrokes.cpp index 9b70d2f..300b38c 100644 --- a/toonz/sources/toonzlib/tcenterlinetostrokes.cpp +++ b/toonz/sources/toonzlib/tcenterlinetostrokes.cpp @@ -371,7 +371,7 @@ void SequenceConverter::lengthOfTriplet(unsigned int i, Length &len) { T3DPointD B = middleAddedSequence[i + 1]; T3DPointD C = middleAddedSequence[i + 2]; - // We assume that this convertion is faithful, avoiding length penalty + // We assume that this conversion is faithful, avoiding length penalty len.l = 0; double d = tdistance(B, C - A, A); if (d <= 2) { @@ -684,7 +684,7 @@ bool SequenceConverter::penalty(unsigned int a, unsigned int b, Length &len) { //-------------------------------------------------------------------------- //----------------------------- -// Convertion Mains +// Conversion Mains //----------------------------- inline TStroke *convert(const Sequence &s, double penalty) { diff --git a/toonz/sources/toonzlib/tcenterlinevectP.h b/toonz/sources/toonzlib/tcenterlinevectP.h index 8a8324f..1defda0 100644 --- a/toonz/sources/toonzlib/tcenterlinevectP.h +++ b/toonz/sources/toonzlib/tcenterlinevectP.h @@ -87,7 +87,7 @@ inline bool angleLess(const TPointD &a, const TPointD &b, const TPointD &ref) { // Container append (needs reverse iterators) // NOTE: Merge could be used... but it requires operator< and we don't... -//! warning: must be I == T::Reverse_iterator; explicited because on Mac it was +//! warning: must be I == T::Reverse_iterator; explicitly because on Mac it was //! not compiling! template void append(T &cont1, T &cont2) { @@ -288,7 +288,7 @@ public: // Further node properties bool m_concave; //!< Whether the node represents a concave angle. unsigned int m_attributes, //!< Bitwise signatures of this node - m_updateTime, //!< \a Algoritmic time in which the node was updated. + m_updateTime, //!< \a Algorithmic time in which the node was updated. m_ancestor, //!< Index of the original node from which this one evolved. m_ancestorContour; //!< Contour index of the original node from which //! this one evolved. @@ -403,7 +403,7 @@ public: Sequence() : m_graphHolder(0) {} ~Sequence() {} - // Impose a property dependant only on the extremity we consider first + // Impose a property dependent only on the extremity we consider first // - so that the same sequence is not considered twice when head and tail // are exchanged bool isForward() const { @@ -467,7 +467,7 @@ typedef std::vector PointList; //! "tcenterline*.cpp" // sources. Instead than passing each variable repeatedly, it is easier to // define a Global -// class passed to each file, which gets immediatly pointed in an anonymous +// class passed to each file, which gets immediately pointed in an anonymous // namespace. class VectorizerCoreGlobals { diff --git a/toonz/sources/toonzlib/tcleanupper.cpp b/toonz/sources/toonzlib/tcleanupper.cpp index f4cd7ac..15abeaf 100644 --- a/toonz/sources/toonzlib/tcleanupper.cpp +++ b/toonz/sources/toonzlib/tcleanupper.cpp @@ -45,7 +45,7 @@ centered Post-processing include despeckling (ie removal or recoloration of little blots with - uniform color), and tones' brigthness/contrast manipulation. + uniform color), and tones' brightness/contrast manipulation. (*) The image is first overed on top of a white background @@ -501,7 +501,7 @@ bool TCleanupper::getResampleValues(const TRasterImageP &image, TAffine &aff, //------------------------------------------------------------------------------------ // this one incorporate the preprocessColors and the finalize function; used for -// swatch.(tipically on very small rasters) +// swatch.(typically on very small rasters) TRasterP TCleanupper::processColors(const TRasterP &rin) { if (m_parameters->m_lineProcessingMode == lpNone) return rin; diff --git a/toonz/sources/toonzlib/tcolumnfx.cpp b/toonz/sources/toonzlib/tcolumnfx.cpp index 4d39bf7..f865c3e 100644 --- a/toonz/sources/toonzlib/tcolumnfx.cpp +++ b/toonz/sources/toonzlib/tcolumnfx.cpp @@ -376,7 +376,7 @@ static std::vector getAllBut(std::vector &colorIds) { //! Image //! will be destroyed at the most appropriate time. You should definitely *COPY* //! all -//! necessary informations before calling it - however, since the intent was +//! necessary information before calling it - however, since the intent was //! that of //! optimizing memory usage, please avoid copying the entire image buffer... @@ -1423,7 +1423,7 @@ bool TLevelColumnFx::doGetBBox(double frame, TRectD &bBox, bBox = img->getBBox(); } - // Add the enlargement of the bbox due to Tzp render datas + // Add the enlargement of the bbox due to Tzp render data if (info.m_data.size()) { TRectD imageBBox(bBox); for (unsigned int i = 0; i < info.m_data.size(); ++i) { diff --git a/toonz/sources/toonzlib/tdistort.cpp b/toonz/sources/toonzlib/tdistort.cpp index eabe26a..c208fc3 100644 --- a/toonz/sources/toonzlib/tdistort.cpp +++ b/toonz/sources/toonzlib/tdistort.cpp @@ -315,12 +315,10 @@ PIXEL filterPixel(double a, double b, double c, double d, // Deal the magnification case, assuming that intervals have at least length // 1. This actually stands for: - // 1. Their midpoint is bilinear filtered whenever their former length wass - // less than 1 (see fractionary - // parts computing above). + // 1. Their midpoint is bilinear filtered whenever their former length was + // less than 1 (see fractionary parts computing above). // 2. This behaviour is continuous with respect to interval lengths - that - // is, we pass from supersampling to - // subsampling in a smooth manner. + // is, we pass from supersampling to subsampling in a smooth manner. if (b - a < 1) { double v = 0.5 * (a + b); a = v - 0.5; diff --git a/toonz/sources/toonzlib/tproject.cpp b/toonz/sources/toonzlib/tproject.cpp index acc3615..bddbc91 100644 --- a/toonz/sources/toonzlib/tproject.cpp +++ b/toonz/sources/toonzlib/tproject.cpp @@ -205,7 +205,7 @@ void hideOlderProjectFiles(const TFilePath &folderPath) { and Outputs. Each of this folders can be renamed using the setFolder(string name, TFilePath path) method. - Usually, the \b name parameter is choosen from inputs, drawings, scenes, + Usually, the \b name parameter is chosen from inputs, drawings, scenes, extras and outputs; the \b path parameter contains the folder that can have a different name from them. @@ -214,7 +214,7 @@ void hideOlderProjectFiles(const TFilePath &folderPath) { folder is used by every scene created in the project to save or load data. A scene dependent folder is used only by the scene - from wich the folder depends. A scene dependent folder contains the + from which the folder depends. A scene dependent folder contains the string "$scene" in its path. \code @@ -225,7 +225,7 @@ void hideOlderProjectFiles(const TFilePath &folderPath) { Drawings folder path: "...\\prodA\\episode1\\SceneA\\drawings" \endcode \n\n - By default, from the toonz installation, exist allways a toonz project + By default, from the toonz installation, exist always a toonz project called "sandbox". \see TProjectManager, TSceneProperties. */ @@ -258,7 +258,7 @@ void hideOlderProjectFiles(const TFilePath &folderPath) { /*! \fn void TProject::save() Saves the project. - Is equvalent to save(getProjectPath()). + Is equivalent to save(getProjectPath()). The project is saved as a xml file.\n Uses TProjectManager and TOStream. \note Exceptions can be thrown. @@ -276,7 +276,7 @@ TProject::~TProject() { delete m_sprop; } \code e.g. setFolder(TProject::Drawings, TFilePath("C:\\temp\\drawings")) \endcode - Usually, the \b name parameter is choosen from inputs, drawings, scenes, + Usually, the \b name parameter is chosen from inputs, drawings, scenes, extras and outputs; the \b path contains the folder that can have a different name from them. @@ -705,15 +705,15 @@ public: and folders. It is possible to handle more than one project root. - The class mantains a container this purpose. All the projects roots must - be setted by hand in the windows + The class maintains a container this purpose. All the projects roots must + be set by hand in the windows registery. By default, only one project root is created when toonz is installed.\n The project root container can be updated using addProjectsRoot(const TFilePath &root), addDefaultProjectsRoot() methods. - The class mantains also information about the current project. The class + The class maintains also information about the current project. The class provides all needed method to retrieve the current project path, name and folder. \see TProject @@ -814,7 +814,7 @@ TFilePath TProjectManager::projectPathToProjectName( //------------------------------------------------------------------- /*! Returns an absolute path of the specified \b projectName.\n - \note The returned project path is allways computed used the first + \note The returned project path is always computed used the first project root in the container.*/ TFilePath TProjectManager::projectNameToProjectPath( const TFilePath &projectName) { @@ -840,7 +840,7 @@ TFilePath TProjectManager::projectFolderToProjectPath( /*! Returns the absolute path of the specified \b projectName only if the project already exist.\n Returns TFilePath() if a project with the specified \b projectName - doesn't exsist.\n + doesn't exist.\n \note \b projectName must be a relative path.*/ TFilePath TProjectManager::getProjectPathByName(const TFilePath &projectName) { assert(!TProject::isAProjectPath(projectName)); @@ -912,9 +912,9 @@ void TProjectManager::setCurrentProjectPath(const TFilePath &fp) { //------------------------------------------------------------------- /*! Returns the current project path.\n - The project path, usually, is setted in key registry. If a current - project path isn't setted, - TProject::SandboxProjectName is setted as current project. + The project path, usually, is set in key registry. If a current + project path isn't set, + TProject::SandboxProjectName is set as current project. */ TFilePath TProjectManager::getCurrentProjectPath() { TFilePath fp(currentProjectPath); @@ -1034,13 +1034,13 @@ void TProjectManager::notifyProjectChanged() { } //------------------------------------------------------------------- -/*! Adds \b listener to the listners container.*/ +/*! Adds \b listener to the listeners container.*/ void TProjectManager::addListener(Listener *listener) { m_listeners.insert(listener); } //------------------------------------------------------------------- -/*! Removes \b listener from the listners container.*/ +/*! Removes \b listener from the listeners container.*/ void TProjectManager::removeListener(Listener *listener) { m_listeners.erase(listener); } diff --git a/toonz/sources/toonzlib/tstageobject.cpp b/toonz/sources/toonzlib/tstageobject.cpp index e51026c..5ff449d 100644 --- a/toonz/sources/toonzlib/tstageobject.cpp +++ b/toonz/sources/toonzlib/tstageobject.cpp @@ -513,7 +513,7 @@ void TStageObject::onChange(const class TParamChange &c) { // one of its parameters. This means this function gets called A LOT. // Thus, we're just SCHEDULING for a data refresh. The actual refresh happens - // whenever the scheduled datas are accessed. + // whenever the scheduled data is accessed. if (c.m_keyframeChanged) m_lazyData.invalidate(); // Both invalidate placement AND keyframes diff --git a/toonz/sources/toonzlib/txshcolumn.cpp b/toonz/sources/toonzlib/txshcolumn.cpp index fb8d5ea..2f4f6c7 100644 --- a/toonz/sources/toonzlib/txshcolumn.cpp +++ b/toonz/sources/toonzlib/txshcolumn.cpp @@ -469,7 +469,7 @@ TXshColumn::ColumnType TXshColumn::toColumnType(int levelType) { else if (levelType == MESH_XSHLEVEL) colType = TXshColumn::eMeshType; else - assert(!"Unkown level type!"); + assert(!"Unknown level type!"); return colType; } diff --git a/toonz/sources/toonzlib/txsheet.cpp b/toonz/sources/toonzlib/txsheet.cpp index 2dcd054..e89af0a 100644 --- a/toonz/sources/toonzlib/txsheet.cpp +++ b/toonz/sources/toonzlib/txsheet.cpp @@ -992,7 +992,7 @@ void TXsheet::rolldownCells(int r0, int c0, int r1, int c1) { //----------------------------------------------------------------------------- /*! Stretch cells contained in rect r0,c0,r1,c1, from r1-r0+1 to nr. - If nr>r1-r0+1 add cells, overwise remove cells. */ + If nr>r1-r0+1 add cells, otherwise remove cells. */ void TXsheet::timeStretch(int r0, int c0, int r1, int c1, int nr) { int oldNr = r1 - r0 + 1; if (nr > oldNr) /* ingrandisce */ diff --git a/toonz/sources/toonzlib/txshlevelcolumn.cpp b/toonz/sources/toonzlib/txshlevelcolumn.cpp index 0e1efd8..1bc1aae 100644 --- a/toonz/sources/toonzlib/txshlevelcolumn.cpp +++ b/toonz/sources/toonzlib/txshlevelcolumn.cpp @@ -238,7 +238,7 @@ bool TXshLevelColumn::setNumbers(int row, int rowCount, // Find a level to input. // If the first target cell is empty, search the upper cells, and lower cells - // and use a level of firsty-found ocupied neighbor cell. + // and use a level of firsty-found occupied neighbor cell. TXshLevelP currentLevel; int tmpIndex = std::min(row - m_first, (int)m_cells.size() - 1); // search upper cells diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index cee4053..6120885 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -178,7 +178,7 @@ void getIndexesRangefromFids(TXshSimpleLevel *level, } // namespace //****************************************************************************************** -// TXshSimpleLevel impementation +// TXshSimpleLevel implementation //****************************************************************************************** bool TXshSimpleLevel::m_rasterizePli = false; @@ -1404,7 +1404,7 @@ void TXshSimpleLevel::save(const TFilePath &fp, const TFilePath &oldFp, if (isAreadOnlyLevel(dDstPath)) { if (m_editableRange.empty() && - !m_temporaryHookMerged) // file interaly locked + !m_temporaryHookMerged) // file internally locked throw TSystemException( dDstPath, "The level cannot be saved: it is a read only level."); else if (getType() != OVL_XSHLEVEL) { diff --git a/toonz/sources/toonzqt/combohistogram.cpp b/toonz/sources/toonzqt/combohistogram.cpp index 7e9fa13..11400a0 100644 --- a/toonz/sources/toonzqt/combohistogram.cpp +++ b/toonz/sources/toonzqt/combohistogram.cpp @@ -40,7 +40,7 @@ void ChannelHistoGraph::setValues() { // normalize with the maximum value int maxValue = 1; for (i = 0; i < COMBOHIST_RESOLUTION_W; i++) { - int count = m_channelValuePtr[i]; + int count = m_channelValuePtr[i]; if (maxValue < count) maxValue = count; } @@ -284,7 +284,7 @@ ChannelHisto::ChannelHisto(int channelIndex, int *channelValue, //----------------------------------------------------------------------------- /*! update the picked color's channel value -*/ + */ void ChannelHisto::showCurrentChannelValue(int val) { m_histogramGraph->showCurrentChannelValue(val); } @@ -321,7 +321,6 @@ void ComboHistoRGBLabel::paintEvent(QPaintEvent *pe) { p.drawRect(bgRect); return; } - if (LutManager::instance()->isValid()) { QColor convertedColor(m_color); LutManager::instance()->convert(convertedColor); @@ -339,10 +338,11 @@ void ComboHistoRGBLabel::paintEvent(QPaintEvent *pe) { p.setPen(Qt::black); p.setBrush(Qt::NoBrush); - p.drawText(rect(), Qt::AlignCenter, tr("R:%1 G:%2 B:%3") - .arg(m_color.red()) - .arg(m_color.green()) - .arg(m_color.blue())); + p.drawText(rect(), Qt::AlignCenter, + tr("R:%1 G:%2 B:%3") + .arg(m_color.red()) + .arg(m_color.green()) + .arg(m_color.blue())); } //============================================================================= @@ -351,9 +351,9 @@ void ComboHistoRGBLabel::paintEvent(QPaintEvent *pe) { ComboHistogram::ComboHistogram(QWidget *parent) : QWidget(parent), m_raster(0), m_palette(0) { - for (int chan = 0; chan < 4; chan++) + for (int chan = 0; chan < 4; chan++) m_histograms[chan] = new ChannelHisto(chan, &m_channelValue[chan][0], this); - m_histograms[4] = new ChannelHisto(4, &m_channelValue[0][0], this); + m_histograms[4] = new ChannelHisto(4, &m_channelValue[0][0], this); // RGB label m_rgbLabel = new ComboHistoRGBLabel(QColor(128, 128, 128), this); @@ -416,7 +416,7 @@ ComboHistogram::~ComboHistogram() { void ComboHistogram::setRaster(const TRasterP &raster, const TPaletteP &palette) { if (palette.getPointer()) m_palette = palette; - m_raster = raster; + m_raster = raster; computeChannelsValue(); for (int i = 0; i < 5; i++) m_histograms[i]->refleshValue(); diff --git a/toonz/sources/toonzqt/dvtextedit.cpp b/toonz/sources/toonzqt/dvtextedit.cpp index 59d6a30..60173f7 100644 --- a/toonz/sources/toonzqt/dvtextedit.cpp +++ b/toonz/sources/toonzqt/dvtextedit.cpp @@ -38,10 +38,10 @@ qreal distanceBetweenPointandRect(const QRect &rect, const QPoint &point) { sqrt(pow((double)(point.x() - rect.bottomRight().x()), 2) + pow((double)(point.y() - rect.bottomRight().y()), 2)); - qreal topMax = qMin(topLeftDistance, topRightDistance); - qreal bottomMax = qMin(bottomLeftDistance, bottomRightDistance); + qreal topMax = std::min(topLeftDistance, topRightDistance); + qreal bottomMax = std::min(bottomLeftDistance, bottomRightDistance); - return qMin(topMax, bottomMax); + return std::min(topMax, bottomMax); } } diff --git a/toonz/sources/toonzqt/expressionfield.cpp b/toonz/sources/toonzqt/expressionfield.cpp index 1c47341..88cba01 100644 --- a/toonz/sources/toonzqt/expressionfield.cpp +++ b/toonz/sources/toonzqt/expressionfield.cpp @@ -351,7 +351,7 @@ bool ExpressionField::updateCompleterPopup() { int w = m_completerPopup->sizeHintForColumn(0) + m_completerPopup->verticalScrollBar()->sizeHint().width() + 5; int h = - (m_completerPopup->sizeHintForRow(0) * qMin(7, model->rowCount()) + 3) + + (m_completerPopup->sizeHintForRow(0) * std::min(7, model->rowCount()) + 3) + 3; QSize size(w, h); diff --git a/toonz/sources/toonzqt/functionpanel.cpp b/toonz/sources/toonzqt/functionpanel.cpp index 85535d5..bd7ed8c 100644 --- a/toonz/sources/toonzqt/functionpanel.cpp +++ b/toonz/sources/toonzqt/functionpanel.cpp @@ -1466,8 +1466,8 @@ void FunctionPanel::fitGraphToWindow(bool currentCurveOnly) { f0 = fa; f1 = fb; } else { - f0 = qMin(f0, fa); - f1 = qMax(f1, fb); + f0 = std::min(f0, fa); + f1 = std::max(f1, fb); } double v = curve->getValue(fa); if (unit) v = unit->convertTo(v); @@ -1477,8 +1477,8 @@ void FunctionPanel::fitGraphToWindow(bool currentCurveOnly) { double t = (double)j / (double)(m - 1); double v = curve->getValue((1 - t) * fa + t * fb); if (unit) v = unit->convertTo(v); - v0 = qMin(v0, v); - v1 = qMax(v1, v); + v0 = std::min(v0, v); + v1 = std::max(v1, v); } } } diff --git a/toonz/sources/toonzqt/functionsegmentviewer.cpp b/toonz/sources/toonzqt/functionsegmentviewer.cpp index fb16356..ccf09cb 100644 --- a/toonz/sources/toonzqt/functionsegmentviewer.cpp +++ b/toonz/sources/toonzqt/functionsegmentviewer.cpp @@ -756,7 +756,7 @@ void FileSegmentPage::apply() { TDoubleKeyframe::FileParams fileParams; fileParams.m_path = TFilePath(stringPath.toStdWString()); - fileParams.m_fieldIndex = qMax(0, m_fieldIndexFld->text().toInt() - 1); + fileParams.m_fieldIndex = std::max(0, m_fieldIndexFld->text().toInt() - 1); std::string unitName = m_measureFld->text().toStdString(); KeyframeSetter setter(curve, kIndex); @@ -769,7 +769,7 @@ void FileSegmentPage::getGuiValues(TDoubleKeyframe::FileParams &fileParam, QString stringPath = m_fileFld->getPath(); stringPath.replace("\\", "\\\\"); fileParam.m_path = TFilePath(stringPath.toStdWString()); - fileParam.m_fieldIndex = qMax(0, m_fieldIndexFld->text().toInt() - 1); + fileParam.m_fieldIndex = std::max(0, m_fieldIndexFld->text().toInt() - 1); unitName = m_measureFld->text().toStdString(); } diff --git a/toonz/sources/toonzqt/functionsheet.cpp b/toonz/sources/toonzqt/functionsheet.cpp index 1d60a31..4cdba4b 100644 --- a/toonz/sources/toonzqt/functionsheet.cpp +++ b/toonz/sources/toonzqt/functionsheet.cpp @@ -166,10 +166,10 @@ public: void drag(int row, int col, QMouseEvent *e) override { if (row < 0) row = 0; if (col < 0) col = 0; - int r0 = qMin(row, m_firstRow); - int r1 = qMax(row, m_firstRow); - int c0 = qMin(col, m_firstCol); - int c1 = qMax(col, m_firstCol); + int r0 = std::min(row, m_firstRow); + int r1 = std::max(row, m_firstRow); + int c0 = std::min(col, m_firstCol); + int c1 = std::max(col, m_firstCol); QRect selectedCells(c0, r0, c1 - c0 + 1, r1 - r0 + 1); m_sheet->selectCells(selectedCells); } @@ -381,7 +381,6 @@ void FunctionSheetColumnHeadViewer::mouseMoveEvent(QMouseEvent *e) { Qt::DropAction dropAction = drag->exec(); return; } - // get the column under the cursor int col = getViewer()->xyToPosition(e->pos()).layer(); FunctionTreeModel::Channel *channel = m_sheet->getChannel(col); @@ -389,41 +388,80 @@ void FunctionSheetColumnHeadViewer::mouseMoveEvent(QMouseEvent *e) { setToolTip(QString("")); } else setToolTip(channel->getExprRefName()); + + // modify selected channel by left dragging + if (m_clickedColumn >= 0 && channel && e->buttons() & Qt::LeftButton) { + int fromC = std::min(m_clickedColumn, col); + int toC = std::max(m_clickedColumn, col); + int lastKeyPos = 0; + for (int c = fromC; c <= toC; c++) { + FunctionTreeModel::Channel *tmpChan = m_sheet->getChannel(c); + if (!tmpChan) continue; + std::set frames; + tmpChan->getParam()->getKeyframes(frames); + if (!frames.empty()) + lastKeyPos = std::max(lastKeyPos, (int)*frames.rbegin()); + } + QRect rect(std::min(m_clickedColumn, col), 0, + std::abs(col - m_clickedColumn) + 1, lastKeyPos + 1); + getViewer()->selectCells(rect); + } } //----------------------------------------------------------------------------- void FunctionSheetColumnHeadViewer::mousePressEvent(QMouseEvent *e) { - QPoint pos = e->pos(); - int currentC = getViewer()->xyToPosition(pos).layer(); - FunctionTreeModel::Channel *channel; - for (int c = 0; c <= m_sheet->getChannelCount(); c++) { - channel = m_sheet->getChannel(c); - if (!channel || c != currentC) continue; - break; + QPoint pos = e->pos(); + int currentC = getViewer()->xyToPosition(pos).layer(); + FunctionTreeModel::Channel *channel = m_sheet->getChannel(currentC); + if (!channel) { + m_clickedColumn = -1; + return; } - if (channel && e->button() == Qt::MidButton) { + + if (e->button() == Qt::MidButton) { m_draggingChannel = channel; m_dragStartPosition = e->pos(); return; - } else if (channel) + } else channel->setIsCurrent(true); m_draggingChannel = 0; - if (!channel) return; - - // Open folder - FunctionTreeModel::ChannelGroup *channelGroup = channel->getChannelGroup(); - if (!channelGroup->isOpen()) - channelGroup->getModel()->setExpandedItem(channelGroup->createIndex(), - true); - // Select all segment - std::set frames; - channel->getParam()->getKeyframes(frames); - QRect rect(0, 0, 0, 0); - if (!frames.empty()) rect = QRect(currentC, 0, 1, (*frames.rbegin()) + 1); + if (e->button() == Qt::LeftButton) { + int lastKeyPos = 0; + // if the current selection does not contain the first cell in m_firstColumn + // then we assume that the selection has been modified and treat shift+click + // as normal click. + if (getViewer()->getSelectedCells().contains(m_clickedColumn, 0) && + (e->modifiers() & Qt::ShiftModifier)) { + int fromC = std::min(m_clickedColumn, currentC); + int toC = std::max(m_clickedColumn, currentC); + for (int c = fromC; c <= toC; c++) { + FunctionTreeModel::Channel *tmpChan = m_sheet->getChannel(c); + if (!tmpChan) continue; + std::set frames; + tmpChan->getParam()->getKeyframes(frames); + if (!frames.empty()) + lastKeyPos = std::max(lastKeyPos, (int)*frames.rbegin()); + } + } else { + // Open folder + FunctionTreeModel::ChannelGroup *channelGroup = + channel->getChannelGroup(); + if (!channelGroup->isOpen()) + channelGroup->getModel()->setExpandedItem(channelGroup->createIndex(), + true); + // Select all segment + std::set frames; + channel->getParam()->getKeyframes(frames); + if (!frames.empty()) lastKeyPos = (int)*frames.rbegin(); + m_clickedColumn = currentC; + } + QRect rect(std::min(m_clickedColumn, currentC), 0, + std::abs(currentC - m_clickedColumn) + 1, lastKeyPos + 1); - getViewer()->selectCells(rect); + getViewer()->selectCells(rect); + } } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonzqt/spreadsheetviewer.cpp b/toonz/sources/toonzqt/spreadsheetviewer.cpp index bcfb895..40da220 100644 --- a/toonz/sources/toonzqt/spreadsheetviewer.cpp +++ b/toonz/sources/toonzqt/spreadsheetviewer.cpp @@ -171,10 +171,10 @@ void SelectionDragTool::click(int row, int col, QMouseEvent *e) { } void SelectionDragTool::drag(int row, int col, QMouseEvent *e) { - int r0 = qMin(row, m_firstRow); - int r1 = qMax(row, m_firstRow); - int c0 = qMin(col, m_firstCol); - int c1 = qMax(col, m_firstCol); + int r0 = std::min(row, m_firstRow); + int r1 = std::max(row, m_firstRow); + int c0 = std::min(col, m_firstCol); + int c1 = std::max(col, m_firstCol); QRect selectedCells(c0, r0, c1 - c0 + 1, r1 - r0 + 1); m_viewer->selectCells(selectedCells); } @@ -708,7 +708,7 @@ bool SpreadsheetViewer::refreshContentSize(int scrollDx, int scrollDy) { QSize viewportSize = m_cellScrollArea->viewport()->size(); QPoint offset = m_cellScrollArea->widget()->pos(); offset = - QPoint(qMin(0, offset.x() - scrollDx), qMin(0, offset.y() - scrollDy)); + QPoint(std::min(0, offset.x() - scrollDx), std::min(0, offset.y() - scrollDy)); QSize contentSize(columnToX(m_columnCount + 1), rowToY(m_rowCount + 1)); @@ -736,7 +736,7 @@ void SpreadsheetViewer::showEvent(QShowEvent *) { int viewportHeight = m_cellScrollArea->height(); int contentHeight = rowToY(m_rowCount * 0 + 50); QScrollBar *vSc = m_cellScrollArea->verticalScrollBar(); - int actualContentHeight = qMax(contentHeight, vSc->value() + viewportHeight); + int actualContentHeight = std::max(contentHeight, vSc->value() + viewportHeight); m_rowScrollArea->widget()->setFixedHeight(actualContentHeight); m_cellScrollArea->widget()->setFixedHeight(actualContentHeight); if (m_frameHandle)