1 /*
2  *  Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@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 #ifndef KIS_EXPERIMENTOP_OPTION_H
19 #define KIS_EXPERIMENTOP_OPTION_H
20 
21 #include <kis_paintop_option.h>
22 class KisPaintopLodLimitations;
23 
24 const QString EXPERIMENT_DISPLACEMENT_ENABLED = "Experiment/displacementEnabled";
25 const QString EXPERIMENT_DISPLACEMENT_VALUE = "Experiment/displacement";
26 const QString EXPERIMENT_SMOOTHING_ENABLED = "Experiment/smoothing";
27 const QString EXPERIMENT_SMOOTHING_VALUE = "Experiment/smoothingValue";
28 const QString EXPERIMENT_SPEED_ENABLED = "Experiment/speedEnabled";
29 const QString EXPERIMENT_SPEED_VALUE = "Experiment/speed";
30 const QString EXPERIMENT_WINDING_FILL = "Experiment/windingFill";
31 const QString EXPERIMENT_HARD_EDGE = "Experiment/hardEdge";
32 const QString EXPERIMENT_FILL_TYPE = "Experiment/fillType";
33 
34 
35 enum ExperimentFillType {
36     SolidColor,
37     Pattern
38 };
39 
40 
41 class KisExperimentOpOptionsWidget;
42 
43 class KisExperimentOpOption : public KisPaintOpOption
44 {
45     Q_OBJECT
46 public:
47     KisExperimentOpOption();
48     ~KisExperimentOpOption() override;
49 
50     void writeOptionSetting(KisPropertiesConfigurationSP setting) const override;
51     void readOptionSetting(const KisPropertiesConfigurationSP setting) override;
52 
53     void lodLimitations(KisPaintopLodLimitations *l) const override;
54 
55 private Q_SLOTS:
56     void enableSpeed(qreal value);
57     void enableSmooth(qreal value);
58     void enableDisplacement(qreal value);
59 
60 private:
61     KisExperimentOpOptionsWidget * m_options;
62 
63 };
64 
65 class ExperimentOption
66 {
67 
68 public:
69     bool isDisplacementEnabled;
70     qreal displacement;
71     bool isSpeedEnabled;
72     qreal speed;
73     bool isSmoothingEnabled;
74     qreal smoothing;
75     bool windingFill;
76     bool hardEdge;
77     ExperimentFillType fillType;
78 
readOptionSetting(const KisPropertiesConfigurationSP setting)79     void readOptionSetting(const KisPropertiesConfigurationSP setting) {
80         isDisplacementEnabled = setting->getBool(EXPERIMENT_DISPLACEMENT_ENABLED);
81         displacement = setting->getDouble(EXPERIMENT_DISPLACEMENT_VALUE, 50.0);
82         isSpeedEnabled = setting->getBool(EXPERIMENT_SPEED_ENABLED);
83         speed = setting->getDouble(EXPERIMENT_SPEED_VALUE, 50.0);
84         isSmoothingEnabled = setting->getBool(EXPERIMENT_SMOOTHING_ENABLED);
85         smoothing = setting->getDouble(EXPERIMENT_SMOOTHING_VALUE, 20.0);
86         windingFill = setting->getBool(EXPERIMENT_WINDING_FILL);
87         hardEdge = setting->getBool(EXPERIMENT_HARD_EDGE);
88         fillType = (ExperimentFillType)setting->getInt(EXPERIMENT_FILL_TYPE, 0); // default to solid color
89     }
90 
writeOptionSetting(KisPropertiesConfigurationSP setting)91     void writeOptionSetting(KisPropertiesConfigurationSP setting) const {
92         setting->setProperty(EXPERIMENT_DISPLACEMENT_ENABLED, isDisplacementEnabled);
93         setting->setProperty(EXPERIMENT_DISPLACEMENT_VALUE, displacement);
94         setting->setProperty(EXPERIMENT_SPEED_ENABLED, isSpeedEnabled);
95         setting->setProperty(EXPERIMENT_SPEED_VALUE, speed);
96         setting->setProperty(EXPERIMENT_SMOOTHING_ENABLED, isSmoothingEnabled);
97         setting->setProperty(EXPERIMENT_SMOOTHING_VALUE, smoothing);
98         setting->setProperty(EXPERIMENT_WINDING_FILL, windingFill);
99         setting->setProperty(EXPERIMENT_HARD_EDGE, hardEdge);
100         setting->setProperty(EXPERIMENT_FILL_TYPE, fillType);
101     }
102 
103 
104 
105 };
106 
107 #endif
108