File indexing completed on 2025-01-26 04:05:52

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_stroke_random_source.h"
0008 
0009 struct KisStrokeRandomSource::Private
0010 {
0011     Private()
0012         : levelOfDetail(0),
0013           lod0RandomSource(new KisRandomSource()),
0014           lodNRandomSource(new KisRandomSource(*lod0RandomSource)),
0015           lod0PerStrokeRandomSource(new KisPerStrokeRandomSource()),
0016           lodNPerStrokeRandomSource(new KisPerStrokeRandomSource(*lod0PerStrokeRandomSource))
0017     {
0018     }
0019 
0020     int levelOfDetail;
0021     KisRandomSourceSP lod0RandomSource;
0022     KisRandomSourceSP lodNRandomSource;
0023 
0024     KisPerStrokeRandomSourceSP lod0PerStrokeRandomSource;
0025     KisPerStrokeRandomSourceSP lodNPerStrokeRandomSource;
0026 };
0027 
0028 
0029 KisStrokeRandomSource::KisStrokeRandomSource()
0030     : m_d(new Private)
0031 {
0032 }
0033 
0034 KisStrokeRandomSource::KisStrokeRandomSource(const KisStrokeRandomSource &rhs)
0035     : m_d(new Private(*rhs.m_d))
0036 {
0037 }
0038 
0039 KisStrokeRandomSource& KisStrokeRandomSource::operator=(const KisStrokeRandomSource &rhs)
0040 {
0041     if (&rhs != this) {
0042         *m_d = *rhs.m_d;
0043     }
0044 
0045     return *this;
0046 }
0047 
0048 KisStrokeRandomSource::~KisStrokeRandomSource()
0049 {
0050 }
0051 
0052 KisRandomSourceSP KisStrokeRandomSource::source() const
0053 {
0054     return m_d->levelOfDetail ? m_d->lodNRandomSource : m_d->lod0RandomSource;
0055 }
0056 
0057 KisPerStrokeRandomSourceSP KisStrokeRandomSource::perStrokeSource() const
0058 {
0059     return m_d->levelOfDetail ? m_d->lodNPerStrokeRandomSource : m_d->lod0PerStrokeRandomSource;
0060 }
0061 
0062 
0063 int KisStrokeRandomSource::levelOfDetail() const
0064 {
0065     return m_d->levelOfDetail;
0066 }
0067 
0068 void KisStrokeRandomSource::setLevelOfDetail(int value)
0069 {
0070     m_d->levelOfDetail = value;
0071 }