Changeset View
Changeset View
Standalone View
Standalone View
plugins/tools/basictools/kis_tool_multihand.cpp
Show All 10 Lines | |||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | | ||||
20 | #include "kis_tool_multihand.h" | 19 | #include "kis_tool_multihand.h" | ||
21 | 20 | | |||
22 | #include <QTransform> | 21 | #include <QTransform> | ||
23 | 22 | | |||
24 | #include <QPushButton> | 23 | #include <QPushButton> | ||
25 | #include <QComboBox> | 24 | #include <QComboBox> | ||
26 | #include <QFormLayout> | 25 | #include <QFormLayout> | ||
27 | #include <QStackedWidget> | 26 | #include <QStackedWidget> | ||
Show All 20 Lines | 46 | KisToolMultihand::KisToolMultihand(KoCanvasBase *canvas) | |||
48 | : KisToolBrush(canvas), | 47 | : KisToolBrush(canvas), | ||
49 | m_transformMode(SYMMETRY), | 48 | m_transformMode(SYMMETRY), | ||
50 | m_angle(0), | 49 | m_angle(0), | ||
51 | m_handsCount(6), | 50 | m_handsCount(6), | ||
52 | m_mirrorVertically(false), | 51 | m_mirrorVertically(false), | ||
53 | m_mirrorHorizontally(false), | 52 | m_mirrorHorizontally(false), | ||
54 | m_showAxes(false), | 53 | m_showAxes(false), | ||
55 | m_translateRadius(100), | 54 | m_translateRadius(100), | ||
56 | m_setupAxesFlag(false) | 55 | m_setupAxesFlag(false), | ||
56 | m_addSubbrushesMode(false) | ||||
57 | , customUI(0) | 57 | , customUI(0) | ||
58 | { | 58 | { | ||
59 | 59 | | |||
60 | 60 | | |||
61 | m_helper = | 61 | m_helper = | ||
62 | new KisToolMultihandHelper(paintingInformationBuilder(), | 62 | new KisToolMultihandHelper(paintingInformationBuilder(), | ||
63 | kundo2_i18n("Multibrush Stroke")); | 63 | kundo2_i18n("Multibrush Stroke")); | ||
64 | resetHelper(m_helper); | 64 | resetHelper(m_helper); | ||
65 | if (image()) { | 65 | if (image()) { | ||
66 | m_axesPoint = QPointF(0.5 * image()->width(), 0.5 * image()->height()); | 66 | m_axesPoint = QPointF(0.5 * image()->width(), 0.5 * image()->height()); | ||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | KisToolMultihand::~KisToolMultihand() | 71 | KisToolMultihand::~KisToolMultihand() | ||
72 | { | 72 | { | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | | ||||
76 | | ||||
77 | void KisToolMultihand::beginPrimaryAction(KoPointerEvent *event) | 75 | void KisToolMultihand::beginPrimaryAction(KoPointerEvent *event) | ||
78 | { | 76 | { | ||
79 | if(m_setupAxesFlag) { | 77 | if(m_setupAxesFlag) { | ||
80 | setMode(KisTool::OTHER); | 78 | setMode(KisTool::OTHER); | ||
81 | m_axesPoint = convertToPixelCoord(event->point); | 79 | m_axesPoint = convertToPixelCoord(event->point); | ||
82 | requestUpdateOutline(event->point, 0); | 80 | requestUpdateOutline(event->point, 0); | ||
83 | updateCanvas(); | 81 | updateCanvas(); | ||
84 | } | 82 | } | ||
83 | else if (m_addSubbrushesMode){ | ||||
84 | QPointF newPoint = convertToPixelCoord(event->point); | ||||
85 | m_subbrOriginalLocations << newPoint; | ||||
rempt: Before we push, we should get rid of temporary debug messages. | |||||
86 | requestUpdateOutline(event->point, 0); | ||||
87 | updateCanvas(); | ||||
88 | } | ||||
85 | else { | 89 | else { | ||
86 | initTransformations(); | 90 | initTransformations(); | ||
87 | KisToolFreehand::beginPrimaryAction(event); | 91 | KisToolFreehand::beginPrimaryAction(event); | ||
88 | } | 92 | } | ||
89 | } | 93 | } | ||
90 | 94 | | |||
91 | void KisToolMultihand::continuePrimaryAction(KoPointerEvent *event) | 95 | void KisToolMultihand::continuePrimaryAction(KoPointerEvent *event) | ||
92 | { | 96 | { | ||
93 | if(mode() == KisTool::OTHER) { | 97 | if(mode() == KisTool::OTHER) { | ||
94 | m_axesPoint = convertToPixelCoord(event->point); | 98 | m_axesPoint = convertToPixelCoord(event->point); | ||
95 | requestUpdateOutline(event->point, 0); | 99 | requestUpdateOutline(event->point, 0); | ||
96 | updateCanvas(); | 100 | updateCanvas(); | ||
97 | } | 101 | } | ||
98 | else { | 102 | else { | ||
103 | requestUpdateOutline(event->point, 0); | ||||
99 | KisToolFreehand::continuePrimaryAction(event); | 104 | KisToolFreehand::continuePrimaryAction(event); | ||
100 | } | 105 | } | ||
101 | } | 106 | } | ||
102 | 107 | | |||
103 | void KisToolMultihand::endPrimaryAction(KoPointerEvent *event) | 108 | void KisToolMultihand::endPrimaryAction(KoPointerEvent *event) | ||
104 | { | 109 | { | ||
105 | if(mode() == KisTool::OTHER) { | 110 | if(mode() == KisTool::OTHER) { | ||
106 | setMode(KisTool::HOVER_MODE); | 111 | setMode(KisTool::HOVER_MODE); | ||
107 | requestUpdateOutline(event->point, 0); | 112 | requestUpdateOutline(event->point, 0); | ||
108 | finishAxesSetup(); | 113 | finishAxesSetup(); | ||
109 | } | 114 | } | ||
110 | else { | 115 | else { | ||
111 | KisToolFreehand::endPrimaryAction(event); | 116 | KisToolFreehand::endPrimaryAction(event); | ||
112 | } | 117 | } | ||
113 | } | 118 | } | ||
114 | 119 | | |||
120 | void KisToolMultihand::beginAlternateAction(KoPointerEvent* event, AlternateAction action) | ||||
121 | { | ||||
122 | if (action != ChangeSize || m_transformMode != COPYTRANSLATE || !m_addSubbrushesMode) { | ||||
123 | KisToolBrush::beginAlternateAction(event, action); | ||||
124 | return; | ||||
125 | } | ||||
126 | setMode(KisTool::OTHER_1); | ||||
127 | m_axesPoint = convertToPixelCoord(event->point); | ||||
128 | requestUpdateOutline(event->point, 0); | ||||
129 | updateCanvas(); | ||||
130 | } | ||||
131 | | ||||
132 | void KisToolMultihand::continueAlternateAction(KoPointerEvent* event, AlternateAction action) | ||||
133 | { | ||||
134 | if (action != ChangeSize || m_transformMode != COPYTRANSLATE || !m_addSubbrushesMode) { | ||||
135 | KisToolBrush::continueAlternateAction(event, action); | ||||
136 | return; | ||||
137 | } | ||||
138 | if (mode() == KisTool::OTHER_1) { | ||||
139 | m_axesPoint = convertToPixelCoord(event->point); | ||||
140 | requestUpdateOutline(event->point, 0); | ||||
141 | updateCanvas(); | ||||
142 | } | ||||
143 | } | ||||
144 | | ||||
145 | void KisToolMultihand::endAlternateAction(KoPointerEvent* event, AlternateAction action) | ||||
146 | { | ||||
147 | if (action != ChangeSize || m_transformMode != COPYTRANSLATE || !m_addSubbrushesMode) { | ||||
148 | KisToolBrush::continueAlternateAction(event, action); | ||||
149 | return; | ||||
150 | } | ||||
151 | if (mode() == KisTool::OTHER_1) { | ||||
152 | setMode(KisTool::HOVER_MODE); | ||||
153 | } | ||||
154 | } | ||||
155 | | ||||
156 | void KisToolMultihand::mouseMoveEvent(KoPointerEvent* event) | ||||
157 | { | ||||
158 | if (mode() == HOVER_MODE) { | ||||
159 | m_lastToolPos=convertToPixelCoord(event->point); | ||||
160 | } | ||||
161 | KisToolBrush::mouseMoveEvent(event); | ||||
162 | } | ||||
163 | | ||||
115 | void KisToolMultihand::paint(QPainter& gc, const KoViewConverter &converter) | 164 | void KisToolMultihand::paint(QPainter& gc, const KoViewConverter &converter) | ||
116 | { | 165 | { | ||
166 | QPainterPath path; | ||||
167 | if (m_transformMode == COPYTRANSLATE) { | ||||
168 | for (QPointF dPos : m_subbrOriginalLocations) { | ||||
169 | if (m_addSubbrushesMode) { | ||||
170 | path.addEllipse(dPos, 10, 10); // Show subbrush reference locations | ||||
171 | path.moveTo(dPos.x() - 15, dPos.y()); | ||||
172 | path.lineTo(dPos.x() + 15, dPos.y()); | ||||
173 | path.moveTo(dPos.x(), dPos.y() - 15); | ||||
174 | path.lineTo(dPos.x(), dPos.y() + 15); | ||||
175 | } | ||||
176 | else { | ||||
177 | // Show where subbrush strokes are predicted to land | ||||
178 | path += m_currentOutline.translated(dPos - m_axesPoint); | ||||
179 | } | ||||
180 | } | ||||
181 | if (m_addSubbrushesMode) { | ||||
182 | // add a cross shape to the main tool outline as well | ||||
183 | | ||||
184 | path.moveTo(m_lastToolPos.x() - 15, m_lastToolPos.y()); | ||||
185 | path.lineTo(m_lastToolPos.x() + 15, m_lastToolPos.y()); | ||||
186 | path.moveTo(m_lastToolPos.x(), m_lastToolPos.y() - 15); | ||||
187 | path.lineTo(m_lastToolPos.x(), m_lastToolPos.y() + 15); | ||||
188 | } | ||||
189 | } | ||||
117 | if(m_setupAxesFlag) { | 190 | if(m_setupAxesFlag) { | ||
118 | int diagonal = (currentImage()->height() + currentImage()->width()); | 191 | int diagonal = (currentImage()->height() + currentImage()->width()); | ||
119 | 192 | | |||
120 | QPainterPath path; | | |||
121 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle), m_axesPoint.y()-diagonal*sin(m_angle)); | 193 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle), m_axesPoint.y()-diagonal*sin(m_angle)); | ||
122 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle), m_axesPoint.y()+diagonal*sin(m_angle)); | 194 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle), m_axesPoint.y()+diagonal*sin(m_angle)); | ||
123 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()-diagonal*sin(m_angle+M_PI_2)); | 195 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()-diagonal*sin(m_angle+M_PI_2)); | ||
124 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()+diagonal*sin(m_angle+M_PI_2)); | 196 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()+diagonal*sin(m_angle+M_PI_2)); | ||
125 | paintToolOutline(&gc, pixelToView(path)); | | |||
126 | } | 197 | } | ||
127 | else { | 198 | else { | ||
128 | KisToolFreehand::paint(gc, converter); | 199 | KisToolFreehand::paint(gc, converter); | ||
129 | if(m_showAxes){ | 200 | // Force paint axeslines of "origin" point when in COPYTRANSLATE addSubbrushes mode. | ||
201 | if(m_showAxes || (m_transformMode == COPYTRANSLATE && m_addSubbrushesMode)){ | ||||
130 | int diagonal = (currentImage()->height() + currentImage()->width()); | 202 | int diagonal = (currentImage()->height() + currentImage()->width()); | ||
131 | 203 | | |||
132 | QPainterPath path; | | |||
133 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle), m_axesPoint.y()-diagonal*sin(m_angle)); | 204 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle), m_axesPoint.y()-diagonal*sin(m_angle)); | ||
134 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle), m_axesPoint.y()+diagonal*sin(m_angle)); | 205 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle), m_axesPoint.y()+diagonal*sin(m_angle)); | ||
135 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()-diagonal*sin(m_angle+M_PI_2)); | 206 | path.moveTo(m_axesPoint.x()-diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()-diagonal*sin(m_angle+M_PI_2)); | ||
136 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()+diagonal*sin(m_angle+M_PI_2)); | 207 | path.lineTo(m_axesPoint.x()+diagonal*cos(m_angle+M_PI_2), m_axesPoint.y()+diagonal*sin(m_angle+M_PI_2)); | ||
137 | paintToolOutline(&gc, pixelToView(path)); | | |||
138 | } | 208 | } | ||
139 | } | 209 | } | ||
210 | paintToolOutline(&gc, pixelToView(path)); | ||||
140 | } | 211 | } | ||
141 | 212 | | |||
142 | void KisToolMultihand::initTransformations() | 213 | void KisToolMultihand::initTransformations() | ||
143 | { | 214 | { | ||
144 | QVector<QTransform> transformations; | 215 | QVector<QTransform> transformations; | ||
145 | QTransform m; | 216 | QTransform m; | ||
146 | 217 | | |||
147 | if(m_transformMode == SYMMETRY) { | 218 | if(m_transformMode == SYMMETRY) { | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 283 | } else { | |||
217 | m.translate(-m_axesPoint.x(), -m_axesPoint.y()); | 288 | m.translate(-m_axesPoint.x(), -m_axesPoint.y()); | ||
218 | 289 | | |||
219 | transformations << m; | 290 | transformations << m; | ||
220 | m.reset(); | 291 | m.reset(); | ||
221 | angle += angleStep*2; | 292 | angle += angleStep*2; | ||
222 | } | 293 | } | ||
223 | } | 294 | } | ||
224 | } | 295 | } | ||
225 | else /* if(m_transformationNode == TRANSLATE) */ { | 296 | else if(m_transformMode == TRANSLATE) { | ||
226 | /** | 297 | /** | ||
227 | * TODO: currently, the seed is the same for all the | 298 | * TODO: currently, the seed is the same for all the | ||
228 | * strokes | 299 | * strokes | ||
229 | */ | 300 | */ | ||
230 | for (int i = 0; i < m_handsCount; i++){ | 301 | for (int i = 0; i < m_handsCount; i++){ | ||
231 | qreal angle = drand48() * M_PI * 2; | 302 | qreal angle = drand48() * M_PI * 2; | ||
232 | qreal length = drand48(); | 303 | qreal length = drand48(); | ||
233 | 304 | | |||
234 | // convert the Polar coordinates to Cartesian coordinates | 305 | // convert the Polar coordinates to Cartesian coordinates | ||
235 | qreal nx = (m_translateRadius * cos(angle) * length); | 306 | qreal nx = (m_translateRadius * cos(angle) * length); | ||
236 | qreal ny = (m_translateRadius * sin(angle) * length); | 307 | qreal ny = (m_translateRadius * sin(angle) * length); | ||
237 | 308 | | |||
238 | m.translate(m_axesPoint.x(),m_axesPoint.y()); | 309 | m.translate(m_axesPoint.x(),m_axesPoint.y()); | ||
239 | m.rotateRadians(m_angle); | 310 | m.rotateRadians(m_angle); | ||
240 | m.translate(nx,ny); | 311 | m.translate(nx,ny); | ||
241 | m.rotateRadians(-m_angle); | 312 | m.rotateRadians(-m_angle); | ||
242 | m.translate(-m_axesPoint.x(), -m_axesPoint.y()); | 313 | m.translate(-m_axesPoint.x(), -m_axesPoint.y()); | ||
243 | transformations << m; | 314 | transformations << m; | ||
244 | m.reset(); | 315 | m.reset(); | ||
245 | } | 316 | } | ||
317 | } else if (m_transformMode == COPYTRANSLATE) { | ||||
318 | transformations << m; | ||||
319 | for (QPointF dPos : m_subbrOriginalLocations) { | ||||
320 | QPointF resPos = dPos-m_axesPoint; // Calculate the difference between subbrush reference position and "origin" reference | ||||
321 | m.translate(resPos.x(), resPos.y()); | ||||
322 | transformations << m; | ||||
323 | m.reset(); | ||||
324 | } | ||||
246 | } | 325 | } | ||
247 | 326 | | |||
248 | m_helper->setupTransformations(transformations); | 327 | m_helper->setupTransformations(transformations); | ||
249 | } | 328 | } | ||
250 | 329 | | |||
251 | QWidget* KisToolMultihand::createOptionWidget() | 330 | QWidget* KisToolMultihand::createOptionWidget() | ||
252 | { | 331 | { | ||
253 | QWidget *widget = KisToolBrush::createOptionWidget(); | 332 | QWidget *widget = KisToolBrush::createOptionWidget(); | ||
254 | 333 | | |||
255 | customUI = new KisToolMultiHandConfigWidget(); | 334 | customUI = new KisToolMultiHandConfigWidget(); | ||
256 | 335 | | |||
257 | // brush smoothing option. | 336 | // brush smoothing option. | ||
258 | customUI->layout()->addWidget(widget); | 337 | //customUI->layout()->addWidget(widget); | ||
259 | customUI->smoothingOptionsLayout->addWidget(widget); | 338 | customUI->smoothingOptionsLayout->addWidget(widget); | ||
260 | 339 | | |||
261 | 340 | | |||
262 | // setup common parameters that all of the modes will see | 341 | // setup common parameters that all of the modes will see | ||
263 | connect(customUI->showAxesCheckbox, SIGNAL(toggled(bool)), this, SLOT(slotSetAxesVisible(bool))); | 342 | connect(customUI->showAxesCheckbox, SIGNAL(toggled(bool)), this, SLOT(slotSetAxesVisible(bool))); | ||
264 | customUI->showAxesCheckbox->setChecked((bool)m_configGroup.readEntry("showAxes", false)); | 343 | customUI->showAxesCheckbox->setChecked((bool)m_configGroup.readEntry("showAxes", false)); | ||
265 | 344 | | |||
266 | connect(image(), SIGNAL(sigSizeChanged(QPointF,QPointF)), this, SLOT(resetAxes())); | 345 | connect(image(), SIGNAL(sigSizeChanged(QPointF,QPointF)), this, SLOT(resetAxes())); | ||
267 | 346 | | |||
268 | customUI->moveOriginButton->setCheckable(true); | 347 | customUI->moveOriginButton->setCheckable(true); | ||
269 | connect(customUI->moveOriginButton, SIGNAL(clicked(bool)),this, SLOT(activateAxesPointModeSetup())); | 348 | connect(customUI->moveOriginButton, SIGNAL(clicked(bool)),this, SLOT(activateAxesPointModeSetup())); | ||
270 | 349 | | |||
271 | connect(customUI->resetOriginButton, SIGNAL(released()), this, SLOT(resetAxes())); | 350 | connect(customUI->resetOriginButton, SIGNAL(released()), this, SLOT(resetAxes())); | ||
272 | 351 | | |||
273 | customUI->multihandTypeCombobox->addItem(i18n("Symmetry"),int(SYMMETRY)); // axis mode | 352 | customUI->multihandTypeCombobox->addItem(i18n("Symmetry"),int(SYMMETRY)); // axis mode | ||
274 | customUI->multihandTypeCombobox->addItem(i18n("Mirror"),int(MIRROR)); | 353 | customUI->multihandTypeCombobox->addItem(i18n("Mirror"),int(MIRROR)); | ||
275 | customUI->multihandTypeCombobox->addItem(i18n("Translate"),int(TRANSLATE)); | 354 | customUI->multihandTypeCombobox->addItem(i18n("Translate"),int(TRANSLATE)); | ||
276 | customUI->multihandTypeCombobox->addItem(i18n("Snowflake"),int(SNOWFLAKE)); | 355 | customUI->multihandTypeCombobox->addItem(i18n("Snowflake"),int(SNOWFLAKE)); | ||
356 | customUI->multihandTypeCombobox->addItem(i18n("Copy Translate"),int(COPYTRANSLATE)); | ||||
277 | connect(customUI->multihandTypeCombobox,SIGNAL(currentIndexChanged(int)),this, SLOT(slotSetTransformMode(int))); | 357 | connect(customUI->multihandTypeCombobox,SIGNAL(currentIndexChanged(int)),this, SLOT(slotSetTransformMode(int))); | ||
278 | customUI->multihandTypeCombobox->setCurrentIndex(m_configGroup.readEntry("transformMode", 0)); | 358 | customUI->multihandTypeCombobox->setCurrentIndex(m_configGroup.readEntry("transformMode", 0)); | ||
279 | slotSetTransformMode(customUI->multihandTypeCombobox->currentIndex()); | 359 | slotSetTransformMode(customUI->multihandTypeCombobox->currentIndex()); | ||
280 | 360 | | |||
281 | 361 | | |||
282 | customUI->axisRotationSpinbox->setSuffix(QChar(Qt::Key_degree)); // origin rotation | 362 | customUI->axisRotationSpinbox->setSuffix(QChar(Qt::Key_degree)); // origin rotation | ||
283 | customUI->axisRotationSpinbox->setSingleStep(0.5); | 363 | customUI->axisRotationSpinbox->setSingleStep(0.5); | ||
284 | customUI->axisRotationSpinbox->setRange(0.0, 90.0, 1); | 364 | customUI->axisRotationSpinbox->setRange(0.0, 90.0, 1); | ||
285 | customUI->axisRotationSpinbox->setValue(m_configGroup.readEntry("axesAngle", 0.0)); | 365 | customUI->axisRotationSpinbox->setValue(m_configGroup.readEntry("axesAngle", 0.0)); | ||
286 | connect( customUI->axisRotationSpinbox, SIGNAL(valueChanged(qreal)),this, SLOT(slotSetAxesAngle(qreal))); | 366 | connect( customUI->axisRotationSpinbox, SIGNAL(valueChanged(qreal)),this, SLOT(slotSetAxesAngle(qreal))); | ||
287 | 367 | | |||
288 | 368 | | |||
289 | | ||||
290 | | ||||
291 | // symmetry mode options | 369 | // symmetry mode options | ||
292 | customUI->brushCountSpinBox->setRange(1, MAXIMUM_BRUSHES); | 370 | customUI->brushCountSpinBox->setRange(1, MAXIMUM_BRUSHES); | ||
293 | connect(customUI->brushCountSpinBox, SIGNAL(valueChanged(int)),this, SLOT(slotSetHandsCount(int))); | 371 | connect(customUI->brushCountSpinBox, SIGNAL(valueChanged(int)),this, SLOT(slotSetHandsCount(int))); | ||
294 | customUI->brushCountSpinBox->setValue(m_configGroup.readEntry("handsCount", 4)); | 372 | customUI->brushCountSpinBox->setValue(m_configGroup.readEntry("handsCount", 4)); | ||
295 | 373 | | |||
296 | // mirror mode specific options | 374 | // mirror mode specific options | ||
297 | connect(customUI->horizontalCheckbox, SIGNAL(toggled(bool)), this, SLOT(slotSetMirrorHorizontally(bool))); | 375 | connect(customUI->horizontalCheckbox, SIGNAL(toggled(bool)), this, SLOT(slotSetMirrorHorizontally(bool))); | ||
298 | customUI->horizontalCheckbox->setChecked((bool)m_configGroup.readEntry("mirrorHorizontally", false)); | 376 | customUI->horizontalCheckbox->setChecked((bool)m_configGroup.readEntry("mirrorHorizontally", false)); | ||
299 | 377 | | |||
300 | connect(customUI->verticalCheckbox, SIGNAL(toggled(bool)), this, SLOT(slotSetMirrorVertically(bool))); | 378 | connect(customUI->verticalCheckbox, SIGNAL(toggled(bool)), this, SLOT(slotSetMirrorVertically(bool))); | ||
301 | customUI->verticalCheckbox->setChecked((bool)m_configGroup.readEntry("mirrorVertically", false)); | 379 | customUI->verticalCheckbox->setChecked((bool)m_configGroup.readEntry("mirrorVertically", false)); | ||
302 | 380 | | |||
303 | // translate mode options | 381 | // translate mode options | ||
304 | customUI->translationRadiusSpinbox->setRange(0, 200); | 382 | customUI->translationRadiusSpinbox->setRange(0, 200); | ||
305 | customUI->translationRadiusSpinbox->setSuffix(i18n(" px")); | 383 | customUI->translationRadiusSpinbox->setSuffix(i18n(" px")); | ||
306 | customUI->translationRadiusSpinbox->setValue(m_configGroup.readEntry("translateRadius", 0)); | 384 | customUI->translationRadiusSpinbox->setValue(m_configGroup.readEntry("translateRadius", 0)); | ||
307 | 385 | | |||
308 | connect(customUI->translationRadiusSpinbox,SIGNAL(valueChanged(int)),this,SLOT(slotSetTranslateRadius(int))); | 386 | connect(customUI->translationRadiusSpinbox,SIGNAL(valueChanged(int)),this,SLOT(slotSetTranslateRadius(int))); | ||
309 | 387 | | |||
388 | // Copy translate mode options and actions | ||||
389 | connect(customUI->addSubbrushButton, &QPushButton::clicked, this, &KisToolMultihand::slotAddSubbrushesMode); | ||||
390 | connect(customUI->removeSubbrushButton, &QPushButton::clicked, this, &KisToolMultihand::slotRemoveAllSubbrushes); | ||||
310 | 391 | | |||
311 | // snowflake re-uses the existing options, so there is no special parameters for that... | 392 | // snowflake re-uses the existing options, so there is no special parameters for that... | ||
312 | 393 | | |||
313 | 394 | | |||
314 | return static_cast<QWidget*>(customUI); // keeping it in the native class until the end allows us to access the UI components | 395 | return static_cast<QWidget*>(customUI); // keeping it in the native class until the end allows us to access the UI components | ||
315 | } | 396 | } | ||
316 | 397 | | |||
317 | void KisToolMultihand::activateAxesPointModeSetup() | 398 | void KisToolMultihand::activateAxesPointModeSetup() | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 446 | { | |||
369 | 450 | | |||
370 | // hide all of the UI elements by default | 451 | // hide all of the UI elements by default | ||
371 | customUI->horizontalCheckbox->setVisible(false); | 452 | customUI->horizontalCheckbox->setVisible(false); | ||
372 | customUI->verticalCheckbox->setVisible(false); | 453 | customUI->verticalCheckbox->setVisible(false); | ||
373 | customUI->translationRadiusSpinbox->setVisible(false); | 454 | customUI->translationRadiusSpinbox->setVisible(false); | ||
374 | customUI->radiusLabel->setVisible(false); | 455 | customUI->radiusLabel->setVisible(false); | ||
375 | customUI->brushCountSpinBox->setVisible(false); | 456 | customUI->brushCountSpinBox->setVisible(false); | ||
376 | customUI->brushesLabel->setVisible(false); | 457 | customUI->brushesLabel->setVisible(false); | ||
458 | customUI->subbrushLabel->setVisible(false); | ||||
459 | customUI->addSubbrushButton->setVisible(false); | ||||
460 | customUI->removeSubbrushButton->setVisible(false); | ||||
377 | 461 | | |||
378 | // turn on what we need | 462 | // turn on what we need | ||
379 | if (index == int(MIRROR)) { | 463 | if (index == MIRROR) { | ||
380 | customUI->horizontalCheckbox->setVisible(true); | 464 | customUI->horizontalCheckbox->setVisible(true); | ||
381 | customUI->verticalCheckbox->setVisible(true); | 465 | customUI->verticalCheckbox->setVisible(true); | ||
382 | } | 466 | } | ||
383 | 467 | | |||
384 | if (index == int(TRANSLATE)) { | 468 | else if (index == TRANSLATE) { | ||
385 | customUI->translationRadiusSpinbox->setVisible(true); | 469 | customUI->translationRadiusSpinbox->setVisible(true); | ||
386 | customUI->radiusLabel->setVisible(true); | 470 | customUI->radiusLabel->setVisible(true); | ||
471 | customUI->brushCountSpinBox->setVisible(true); | ||||
472 | customUI->brushesLabel->setVisible(true); | ||||
387 | } | 473 | } | ||
388 | 474 | | |||
389 | if (index == int(SYMMETRY) || index == int(SNOWFLAKE) || index == int(TRANSLATE) ) { | 475 | else if (index == SYMMETRY || index == SNOWFLAKE || index == TRANSLATE ) { | ||
390 | customUI->brushCountSpinBox->setVisible(true); | 476 | customUI->brushCountSpinBox->setVisible(true); | ||
391 | customUI->brushesLabel->setVisible(true); | 477 | customUI->brushesLabel->setVisible(true); | ||
392 | } | 478 | } | ||
393 | 479 | | |||
480 | else if (index == COPYTRANSLATE) { | ||||
481 | customUI->subbrushLabel->setVisible(true); | ||||
482 | customUI->addSubbrushButton->setVisible(true); | ||||
483 | customUI->removeSubbrushButton->setVisible(true); | ||||
484 | } | ||||
485 | | ||||
394 | } | 486 | } | ||
395 | 487 | | |||
396 | void KisToolMultihand::slotSetAxesVisible(bool vis) | 488 | void KisToolMultihand::slotSetAxesVisible(bool vis) | ||
397 | { | 489 | { | ||
398 | m_showAxes = vis; | 490 | m_showAxes = vis; | ||
399 | updateCanvas(); | 491 | updateCanvas(); | ||
400 | m_configGroup.writeEntry("showAxes", vis); | 492 | m_configGroup.writeEntry("showAxes", vis); | ||
401 | } | 493 | } | ||
Show All 12 Lines | |||||
414 | } | 506 | } | ||
415 | 507 | | |||
416 | void KisToolMultihand::slotSetTranslateRadius(int radius) | 508 | void KisToolMultihand::slotSetTranslateRadius(int radius) | ||
417 | { | 509 | { | ||
418 | m_translateRadius = radius; | 510 | m_translateRadius = radius; | ||
419 | m_configGroup.writeEntry("translateRadius", radius); | 511 | m_configGroup.writeEntry("translateRadius", radius); | ||
420 | } | 512 | } | ||
421 | 513 | | |||
514 | void KisToolMultihand::slotAddSubbrushesMode(bool checked) | ||||
515 | { | ||||
516 | m_addSubbrushesMode = checked; | ||||
517 | updateCanvas(); | ||||
518 | } | ||||
519 | | ||||
520 | void KisToolMultihand::slotRemoveAllSubbrushes() | ||||
521 | { | ||||
522 | m_subbrOriginalLocations.clear(); | ||||
523 | updateCanvas(); | ||||
524 | } | ||||
525 | |
Before we push, we should get rid of temporary debug messages.