1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
/*
* Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
* Copyright (c) 2010 José Luis Vergara <pentalis@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_hatching_paintop_settings.h"
#include <kis_paint_action_type_option.h>
#include <QDomDocument>
#include <QDomElement>
const QString HATCHING_VERSION = "Hatching/Version";
struct KisHatchingPaintOpSettings::Private
{
QList<KisUniformPaintOpPropertyWSP> uniformProperties;
};
KisHatchingPaintOpSettings::KisHatchingPaintOpSettings()
: m_d(new Private)
{
setProperty(HATCHING_VERSION, "2");
}
KisHatchingPaintOpSettings::~KisHatchingPaintOpSettings()
{
}
void KisHatchingPaintOpSettings::initializeTwin(KisPaintOpSettingsSP settings) const
{
// XXX: this is a nice way to reinvent the copy constructor?
/*--------DO NOT REMOVE please, use this to review the XML config tree
QMap<QString, QVariant> rofl = QMap<QString, QVariant>(getProperties());
QMap<QString, QVariant>::const_iterator i;
for (i = rofl.constBegin(); i != rofl.constEnd(); ++i)
dbgKrita << i.key() << ":" << i.value();
/----------DO NOT REMOVE----------------*/
KisHatchingPaintOpSettings *convenienttwin = static_cast<KisHatchingPaintOpSettings*>(settings.data());
convenienttwin->enabledcurvecrosshatching = getBool("PressureCrosshatching");
convenienttwin->enabledcurveopacity = getBool("PressureOpacity");
convenienttwin->enabledcurveseparation = getBool("PressureSeparation");
convenienttwin->enabledcurvesize = getBool("PressureSize");
convenienttwin->enabledcurvethickness = getBool("PressureThickness");
convenienttwin->angle = getDouble("Hatching/angle");
convenienttwin->separation = getDouble("Hatching/separation");
convenienttwin->thickness = getDouble("Hatching/thickness");
convenienttwin->origin_x = getDouble("Hatching/origin_x");
convenienttwin->origin_y = getDouble("Hatching/origin_y");
convenienttwin->nocrosshatching = getBool("Hatching/bool_nocrosshatching");
convenienttwin->perpendicular = getBool("Hatching/bool_perpendicular");
convenienttwin->minusthenplus = getBool("Hatching/bool_minusthenplus");
convenienttwin->plusthenminus = getBool("Hatching/bool_plusthenminus");
convenienttwin->moirepattern = getBool("Hatching/bool_moirepattern");
convenienttwin->separationintervals = getInt("Hatching/separationintervals");
//convenienttwin->trigonometryalgebra = getBool("Hatching/bool_trigonometryalgebra");
//convenienttwin->scratchoff = getBool("Hatching/bool_scratchoff");
convenienttwin->antialias = getBool("Hatching/bool_antialias");
convenienttwin->opaquebackground = getBool("Hatching/bool_opaquebackground");
convenienttwin->subpixelprecision = getBool("Hatching/bool_subpixelprecision");
if (getBool("Hatching/bool_nocrosshatching"))
convenienttwin->crosshatchingstyle = 0;
else if (getBool("Hatching/bool_perpendicular"))
convenienttwin->crosshatchingstyle = 1;
else if (getBool("Hatching/bool_minusthenplus"))
convenienttwin->crosshatchingstyle = 2;
else if (getBool("Hatching/bool_plusthenminus"))
convenienttwin->crosshatchingstyle = 3;
if (getBool("Hatching/bool_moirepattern"))
convenienttwin->crosshatchingstyle = 4;
}
void KisHatchingPaintOpSettings::fromXML(const QDomElement& elt)
{
setProperty(HATCHING_VERSION, "1"); // This make sure that fromXML will override HAIRY_VERSION with 2, or will default to 1
KisBrushBasedPaintOpSettings::fromXML(elt);
QVariant v;
if (!getProperty(HATCHING_VERSION, v) || v == "1") {
setProperty("Hatching/thickness", 2.0 * getDouble("Hatching/thickness"));
}
setProperty(HATCHING_VERSION, "2"); // make sure it's saved as version 2 next time
}
#include <brushengine/kis_slider_based_paintop_property.h>
#include "kis_paintop_preset.h"
#include "kis_paintop_settings_update_proxy.h"
#include "kis_hatching_options.h"
QList<KisUniformPaintOpPropertySP> KisHatchingPaintOpSettings::uniformProperties(KisPaintOpSettingsSP settings)
{
QList<KisUniformPaintOpPropertySP> props =
listWeakToStrong(m_d->uniformProperties);
if (props.isEmpty()) {
{
KisDoubleSliderBasedPaintOpPropertyCallback *prop =
new KisDoubleSliderBasedPaintOpPropertyCallback(
KisDoubleSliderBasedPaintOpPropertyCallback::Double,
"hatching_angle",
i18n("Hatching Angle"),
settings, 0);
const QString degree = QChar(Qt::Key_degree);
prop->setRange(-90, 90);
prop->setSingleStep(0.01);
prop->setDecimals(2);
prop->setSuffix(degree);
prop->setReadCallback(
[](KisUniformPaintOpProperty *prop) {
HatchingOption option;
option.readOptionSetting(prop->settings().data());
prop->setValue(option.angle);
});
prop->setWriteCallback(
[](KisUniformPaintOpProperty *prop) {
HatchingOption option;
option.readOptionSetting(prop->settings().data());
option.angle = prop->value().toReal();
option.writeOptionSetting(prop->settings().data());
});
QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
prop->requestReadValue();
props << toQShared(prop);
}
{
KisDoubleSliderBasedPaintOpPropertyCallback *prop =
new KisDoubleSliderBasedPaintOpPropertyCallback(
KisDoubleSliderBasedPaintOpPropertyCallback::Double,
"hatching_separation",
i18n("Separation"),
settings, 0);
prop->setRange(1.0, 30);
prop->setSingleStep(0.01);
prop->setDecimals(2);
prop->setSuffix(i18n(" px"));
prop->setReadCallback(
[](KisUniformPaintOpProperty *prop) {
HatchingOption option;
option.readOptionSetting(prop->settings().data());
prop->setValue(option.separation);
});
prop->setWriteCallback(
[](KisUniformPaintOpProperty *prop) {
HatchingOption option;
option.readOptionSetting(prop->settings().data());
option.separation = prop->value().toReal();
option.writeOptionSetting(prop->settings().data());
});
QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
prop->requestReadValue();
props << toQShared(prop);
}
{
KisDoubleSliderBasedPaintOpPropertyCallback *prop =
new KisDoubleSliderBasedPaintOpPropertyCallback(
KisDoubleSliderBasedPaintOpPropertyCallback::Double,
"hatching_thickness",
i18n("Thickness"),
settings, 0);
prop->setRange(1.0, 30);
prop->setSingleStep(0.01);
prop->setDecimals(2);
prop->setSuffix(i18n(" px"));
prop->setReadCallback(
[](KisUniformPaintOpProperty *prop) {
HatchingOption option;
option.readOptionSetting(prop->settings().data());
prop->setValue(option.thickness);
});
prop->setWriteCallback(
[](KisUniformPaintOpProperty *prop) {
HatchingOption option;
option.readOptionSetting(prop->settings().data());
option.thickness = prop->value().toReal();
option.writeOptionSetting(prop->settings().data());
});
QObject::connect(preset()->updateProxy(), SIGNAL(sigSettingsChanged()), prop, SLOT(requestReadValue()));
prop->requestReadValue();
props << toQShared(prop);
}
}
return KisPaintOpSettings::uniformProperties(settings) + props;
}
|