1 /*
2  *  Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "kis_stroke_random_source.h"
20 
21 struct KisStrokeRandomSource::Private
22 {
PrivateKisStrokeRandomSource::Private23     Private()
24         : levelOfDetail(0),
25           lod0RandomSource(new KisRandomSource()),
26           lodNRandomSource(new KisRandomSource(*lod0RandomSource)),
27           lod0PerStrokeRandomSource(new KisPerStrokeRandomSource()),
28           lodNPerStrokeRandomSource(new KisPerStrokeRandomSource(*lod0PerStrokeRandomSource))
29     {
30     }
31 
32     int levelOfDetail;
33     KisRandomSourceSP lod0RandomSource;
34     KisRandomSourceSP lodNRandomSource;
35 
36     KisPerStrokeRandomSourceSP lod0PerStrokeRandomSource;
37     KisPerStrokeRandomSourceSP lodNPerStrokeRandomSource;
38 };
39 
40 
KisStrokeRandomSource()41 KisStrokeRandomSource::KisStrokeRandomSource()
42     : m_d(new Private)
43 {
44 }
45 
KisStrokeRandomSource(const KisStrokeRandomSource & rhs)46 KisStrokeRandomSource::KisStrokeRandomSource(const KisStrokeRandomSource &rhs)
47     : m_d(new Private(*rhs.m_d))
48 {
49 }
50 
operator =(const KisStrokeRandomSource & rhs)51 KisStrokeRandomSource& KisStrokeRandomSource::operator=(const KisStrokeRandomSource &rhs)
52 {
53     if (&rhs != this) {
54         *m_d = *rhs.m_d;
55     }
56 
57     return *this;
58 }
59 
~KisStrokeRandomSource()60 KisStrokeRandomSource::~KisStrokeRandomSource()
61 {
62 }
63 
source() const64 KisRandomSourceSP KisStrokeRandomSource::source() const
65 {
66     return m_d->levelOfDetail ? m_d->lodNRandomSource : m_d->lod0RandomSource;
67 }
68 
perStrokeSource() const69 KisPerStrokeRandomSourceSP KisStrokeRandomSource::perStrokeSource() const
70 {
71     return m_d->levelOfDetail ? m_d->lodNPerStrokeRandomSource : m_d->lod0PerStrokeRandomSource;
72 }
73 
74 
levelOfDetail() const75 int KisStrokeRandomSource::levelOfDetail() const
76 {
77     return m_d->levelOfDetail;
78 }
79 
setLevelOfDetail(int value)80 void KisStrokeRandomSource::setLevelOfDetail(int value)
81 {
82     m_d->levelOfDetail = value;
83 }
84