All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CompositionModeDialog.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/layer/utils/CompositionModeDialog.cpp
22 
23  \brief This file defines a class for a CompositionModeDialog.
24 */
25 
26 // TerraLib
27 #include "../../../../maptools/Enums.h"
28 #include "CompositionModeDialog.h"
29 #include "ui_CompositionModeDialogForm.h"
30 
32  : QDialog(parent, f),
33  m_ui(new Ui::CompositionModeDialogForm)
34 {
35 //build form
36  m_ui->setupUi(this);
37 
38  m_ui->m_imgLabel->setPixmap(QIcon::fromTheme("layer-compose-hint").pixmap(112,48));
39 
40 //connects
41  connect(m_ui->m_clearRadioButton, SIGNAL(clicked(bool)), this, SLOT(onClearRadioButtonClicked(bool)));
42  connect(m_ui->m_srcRadioButton, SIGNAL(clicked(bool)), this, SLOT( onSourceRadioButtonClicked(bool)));
43  connect(m_ui->m_dstRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDestinationRadioButtonClicked(bool)));
44  connect(m_ui->m_srcOverRadioButton, SIGNAL(clicked(bool)), this, SLOT( onSourceOverRadioButtonClicked(bool)));
45  connect(m_ui->m_dstOverRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDestinationOverRadioButtonClicked(bool)));
46  connect(m_ui->m_srcInRadioButton, SIGNAL(clicked(bool)), this, SLOT( onSourceInRadioButtonClicked(bool)));
47  connect(m_ui->m_dstInRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDestinationInRadioButtonClicked(bool)));
48  connect(m_ui->m_srcOutRadioButton, SIGNAL(clicked(bool)), this, SLOT( onSourceOutRadioButtonClicked(bool)));
49  connect(m_ui->m_dstOutRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDestinationOutRadioButtonClicked(bool)));
50  connect(m_ui->m_srcAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT( onSourceAtTopRadioButtonClicked(bool)));
51  connect(m_ui->m_dstAtTopRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDestinationAtTopRadioButtonClicked(bool)));
52  connect(m_ui->m_xorRadioButton, SIGNAL(clicked(bool)), this, SLOT( onXorRadioButtonClicked(bool)));
53  connect(m_ui->m_plusRadioButton, SIGNAL(clicked(bool)), this, SLOT( onPlusRadioButtonClicked(bool)));
54  connect(m_ui->m_multRadioButton, SIGNAL(clicked(bool)), this, SLOT( onMultiplyRadioButtonClicked(bool)));
55  connect(m_ui->m_screenRadioButton, SIGNAL(clicked(bool)), this, SLOT( onScreenRadioButtonClicked(bool)));
56  connect(m_ui->m_overlayRadioButton, SIGNAL(clicked(bool)), this, SLOT( onOverlayRadioButtonClicked(bool)));
57  connect(m_ui->m_darkenRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDarkenRadioButtonClicked(bool)));
58  connect(m_ui->m_lightenRadioButton, SIGNAL(clicked(bool)), this, SLOT( onLightenRadioButtonClicked(bool)));
59  connect(m_ui->m_colorDodgeRadioButton, SIGNAL(clicked(bool)), this, SLOT( onColorDodgeRadioButtonClicked(bool)));
60  connect(m_ui->m_colorBurnRadioButton, SIGNAL(clicked(bool)), this, SLOT( onColorBurnRadioButtonClicked(bool)));
61  connect(m_ui->m_hardLightRadioButton, SIGNAL(clicked(bool)), this, SLOT( onHardLightRadioButtonClicked(bool)));
62  connect(m_ui->m_softLightRadioButton, SIGNAL(clicked(bool)), this, SLOT( onSoftLightRadioButtonClicked(bool)));
63  connect(m_ui->m_diffRadioButton, SIGNAL(clicked(bool)), this, SLOT( onDifferenceRadioButtonClicked(bool)));
64  connect(m_ui->m_exclusionRadioButton, SIGNAL(clicked(bool)), this, SLOT( onExclusionRadioButtonClicked(bool)));
65 
66 // help info
67  m_ui->m_helpPushButton->setNameSpace("dpi.inpe.br.plugins");
68  m_ui->m_helpPushButton->setPageReference("widgets/layer/compositionMode_dialog.html");
69 }
70 
72 {
73 }
74 
76 {
77  m_layer = layer;
78 
79  te::map::CompositionMode cm = m_layer->getCompositionMode();
80 
81  if(cm == te::map::Clear)
82  {
83  m_ui->m_clearRadioButton->setChecked(true);
84 
85  onClearRadioButtonClicked(true);
86  }
87  else if(cm == te::map::Source)
88  {
89  m_ui->m_srcRadioButton->setChecked(true);
90 
91  onSourceRadioButtonClicked(true);
92  }
93  else if(cm == te::map::Destination)
94  {
95  m_ui->m_dstRadioButton->setChecked(true);
96 
97  onDestinationRadioButtonClicked(true);
98  }
99  else if(cm == te::map::SourceOver)
100  {
101  m_ui->m_srcOverRadioButton->setChecked(true);
102 
103  onSourceOverRadioButtonClicked(true);
104  }
105  else if(cm == te::map::DestinationOver)
106  {
107  m_ui->m_dstOverRadioButton->setChecked(true);
108 
109  onDestinationOverRadioButtonClicked(true);
110  }
111  else if(cm == te::map::SourceIn)
112  {
113  m_ui->m_srcInRadioButton->setChecked(true);
114 
115  onSourceInRadioButtonClicked(true);
116  }
117  else if(cm == te::map::DestinationIn)
118  {
119  m_ui->m_dstInRadioButton->setChecked(true);
120 
121  onDestinationInRadioButtonClicked(true);
122  }
123  else if(cm == te::map::SourceOut)
124  {
125  m_ui->m_srcOutRadioButton->setChecked(true);
126 
127  onSourceOutRadioButtonClicked(true);
128  }
129  else if(cm == te::map::DestinationOut)
130  {
131  m_ui->m_dstOutRadioButton->setChecked(true);
132 
133  onDestinationOutRadioButtonClicked(true);
134  }
135  else if(cm == te::map::SourceAtop)
136  {
137  m_ui->m_srcAtTopRadioButton->setChecked(true);
138 
139  onSourceAtTopRadioButtonClicked(true);
140  }
141  else if(cm == te::map::DestinationAtop)
142  {
143  m_ui->m_dstAtTopRadioButton->setChecked(true);
144 
145  onDestinationAtTopRadioButtonClicked(true);
146  }
147  else if(cm == te::map::Xor)
148  {
149  m_ui->m_xorRadioButton->setChecked(true);
150 
151  onXorRadioButtonClicked(true);
152  }
153  else if(cm == te::map::Plus)
154  {
155  m_ui->m_plusRadioButton->setChecked(true);
156 
157  onPlusRadioButtonClicked(true);
158  }
159  else if(cm == te::map::Multiply)
160  {
161  m_ui->m_multRadioButton->setChecked(true);
162 
163  onMultiplyRadioButtonClicked(true);
164  }
165  else if(cm == te::map::Screen)
166  {
167  m_ui->m_screenRadioButton->setChecked(true);
168 
169  onScreenRadioButtonClicked(true);
170  }
171  else if(cm == te::map::Overlay)
172  {
173  m_ui->m_overlayRadioButton->setChecked(true);
174 
175  onOverlayRadioButtonClicked(true);
176  }
177  else if(cm == te::map::Darken)
178  {
179  m_ui->m_darkenRadioButton->setChecked(true);
180 
181  onDarkenRadioButtonClicked(true);
182  }
183  else if(cm == te::map::Lighten)
184  {
185  m_ui->m_lightenRadioButton->setChecked(true);
186 
187  onLightenRadioButtonClicked(true);
188  }
189  else if(cm == te::map::ColorDodge)
190  {
191  m_ui->m_colorDodgeRadioButton->setChecked(true);
192 
193  onColorDodgeRadioButtonClicked(true);
194  }
195  else if(cm == te::map::ColorBurn)
196  {
197  m_ui->m_colorBurnRadioButton->setChecked(true);
198 
199  onColorBurnRadioButtonClicked(true);
200  }
201  else if(cm == te::map::HardLight)
202  {
203  m_ui->m_hardLightRadioButton->setChecked(true);
204 
205  onHardLightRadioButtonClicked(true);
206  }
207  else if(cm == te::map::SoftLight)
208  {
209  m_ui->m_softLightRadioButton->setChecked(true);
210 
211  onSoftLightRadioButtonClicked(true);
212  }
213  else if(cm == te::map::Difference)
214  {
215  m_ui->m_diffRadioButton->setChecked(true);
216 
217  onDifferenceRadioButtonClicked(true);
218  }
219  else if(cm == te::map::Exclusion)
220  {
221  m_ui->m_exclusionRadioButton->setChecked(true);
222 
223  onExclusionRadioButtonClicked(true);
224  }
225 }
226 
228 {
229  return m_ui->m_applyPushButton;
230 }
231 
233 {
234  if(m_layer.get() && flag)
235  {
236  m_layer->setCompositionMode(te::map::Clear);
237 
238  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-clear").pixmap(128,128));
239 
240  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The pixels in the destination are cleared (set to fully transparent) independent of the source."));
241  }
242 }
243 
245 {
246  if(m_layer.get() && flag)
247  {
248  m_layer->setCompositionMode(te::map::Source);
249 
250  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src").pixmap(128,128));
251 
252  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the source pixel. (This means a basic copy operation and is identical to SourceOver when the source pixel is opaque)."));
253  }
254 }
255 
257 {
258  if(m_layer.get() && flag)
259  {
260  m_layer->setCompositionMode(te::map::Destination);
261 
262  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst").pixmap(128,128));
263 
264  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the destination pixel. This means that the blending has no effect. This mode is the inverse of Source."));
265  }
266 }
267 
269 {
270  if(m_layer.get() && flag)
271  {
272  m_layer->setCompositionMode(te::map::SourceOver);
273 
274  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-over").pixmap(128,128));
275 
276  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("This is the default mode. The alpha of the source is used to blend the pixel on top of the destination."));
277  }
278 }
279 
281 {
282  if(m_layer.get() && flag)
283  {
284  m_layer->setCompositionMode(te::map::DestinationOver);
285 
286  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-over").pixmap(128,128));
287 
288  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The alpha of the destination is used to blend it on top of the source pixels. This mode is the inverse of Source Over."));
289  }
290 }
291 
293 {
294  if(m_layer.get() && flag)
295  {
296  m_layer->setCompositionMode(te::map::SourceIn);
297 
298  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-in").pixmap(128,128));
299 
300  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the source, where the alpha is reduced by that of the destination."));
301  }
302 }
303 
305 {
306  if(m_layer.get() && flag)
307  {
308  m_layer->setCompositionMode(te::map::DestinationIn);
309 
310  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-in").pixmap(128,128));
311 
312  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the destination, where the alpha is reduced by that of the source. This mode is the inverse of Source In."));
313  }
314 }
315 
317 {
318  if(m_layer.get() && flag)
319  {
320  m_layer->setCompositionMode(te::map::SourceOut);
321 
322  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-out").pixmap(128,128));
323 
324  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the source, where the alpha is reduced by the inverse of destination."));
325  }
326 }
327 
329 {
330  if(m_layer.get() && flag)
331  {
332  m_layer->setCompositionMode(te::map::DestinationOut);
333 
334  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-out").pixmap(128,128));
335 
336  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the destination, where the alpha is reduced by the inverse of the source. This mode is the inverse of Source Out."));
337  }
338 }
339 
341 {
342  if(m_layer.get() && flag)
343  {
344  m_layer->setCompositionMode(te::map::SourceAtop);
345 
346  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-atop").pixmap(128,128));
347 
348  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The source pixel is blended on top of the destination, with the alpha of the source pixel reduced by the alpha of the destination pixel."));
349  }
350 }
351 
353 {
354  if(m_layer.get() && flag)
355  {
356  m_layer->setCompositionMode(te::map::DestinationAtop);
357 
358  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-atop").pixmap(128,128));
359 
360  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The destination pixel is blended on top of the source, with the alpha of the destination pixel is reduced by the alpha of the destination pixel. This mode is the inverse of Source A top."));
361  }
362 }
363 
365 {
366  if(m_layer.get() && flag)
367  {
368  m_layer->setCompositionMode(te::map::Xor);
369 
370  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-xor").pixmap(128,128));
371 
372  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The source, whose alpha is reduced with the inverse of the destination alpha, is merged with the destination, whose alpha is reduced by the inverse of the source alpha. Xor is not the same as the bitwise Xor."));
373  }
374 }
375 
377 {
378  if(m_layer.get() && flag)
379  {
380  m_layer->setCompositionMode(te::map::Plus);
381 
382  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
383 
384  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Both the alpha and color of the source and destination pixels are added together."));
385  }
386 }
387 
389 {
390  if(m_layer.get() && flag)
391  {
392  m_layer->setCompositionMode(te::map::Multiply);
393 
394  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
395 
396  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the source color multiplied by the destination. Multiplying a color with white leaves the color unchanged, while multiplying a color with black produces black."));
397  }
398 }
399 
401 {
402  if(m_layer.get() && flag)
403  {
404  m_layer->setCompositionMode(te::map::Screen);
405 
406  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
407 
408  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The source and destination colors are inverted and then multiplied. Screening a color with white produces white, whereas screening a color with black leaves the color unchanged."));
409  }
410 }
411 
413 {
414  if(m_layer.get() && flag)
415  {
416  m_layer->setCompositionMode(te::map::Overlay);
417 
418  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
419 
420  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Multiplies or screens the colors depending on the destination color. The destination color is mixed with the source color to reflect the lightness or darkness of the destination."));
421  }
422 }
423 
425 {
426  if(m_layer.get() && flag)
427  {
428  m_layer->setCompositionMode(te::map::Darken);
429 
430  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
431 
432  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The darker of the source and destination colors is selected."));
433  }
434 }
435 
437 {
438  if(m_layer.get() && flag)
439  {
440  m_layer->setCompositionMode(te::map::Lighten);
441 
442  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
443 
444  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The lighter of the source and destination colors is selected."));
445  }
446 }
447 
449 {
450  if(m_layer.get() && flag)
451  {
452  m_layer->setCompositionMode(te::map::ColorDodge);
453 
454  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
455 
456  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The destination color is brightened to reflect the source color. A black source color leaves the destination color unchanged."));
457  }
458 }
459 
461 {
462  if(m_layer.get() && flag)
463  {
464  m_layer->setCompositionMode(te::map::ColorBurn);
465 
466  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
467 
468  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The destination color is darkened to reflect the source color. A white source color leaves the destination color unchanged."));
469  }
470 }
471 
473 {
474  if(m_layer.get() && flag)
475  {
476  m_layer->setCompositionMode(te::map::HardLight);
477 
478  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
479 
480  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Multiplies or screens the colors depending on the source color. A light source color will lighten the destination color, whereas a dark source color will darken the destination color."));
481  }
482 }
483 
485 {
486  if(m_layer.get() && flag)
487  {
488  m_layer->setCompositionMode(te::map::SoftLight);
489 
490  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
491 
492  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Darkens or lightens the colors depending on the source color. Similar to Hard Light."));
493  }
494 }
495 
497 {
498  if(m_layer.get() && flag)
499  {
500  m_layer->setCompositionMode(te::map::Difference);
501 
502  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
503 
504  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Subtracts the darker of the colors from the lighter. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged."));
505  }
506 }
507 
509 {
510  if(m_layer.get() && flag)
511  {
512  m_layer->setCompositionMode(te::map::Exclusion);
513 
514  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
515 
516  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Similar to Difference, but with a lower contrast. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged."));
517  }
518 }
CompositionMode
The composition mode used to render the canvas.
Definition: Enums.h:174
This file defines a class for a CompositionModeDialog.
void setLayer(te::map::AbstractLayerPtr layer)
Set the layer that can be used.
CompositionModeDialog(QWidget *parent=0, Qt::WindowFlags f=0)
std::auto_ptr< Ui::CompositionModeDialogForm > m_ui
Qt component.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr