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 
74 {
75  m_layer = layer;
76 
77  te::map::CompositionMode cm = m_layer->getCompositionMode();
78 
79  if(cm == te::map::Clear)
80  {
81  m_ui->m_clearRadioButton->setChecked(true);
82 
84  }
85  else if(cm == te::map::Source)
86  {
87  m_ui->m_srcRadioButton->setChecked(true);
88 
90  }
91  else if(cm == te::map::Destination)
92  {
93  m_ui->m_dstRadioButton->setChecked(true);
94 
96  }
97  else if(cm == te::map::SourceOver)
98  {
99  m_ui->m_srcOverRadioButton->setChecked(true);
100 
102  }
103  else if(cm == te::map::DestinationOver)
104  {
105  m_ui->m_dstOverRadioButton->setChecked(true);
106 
108  }
109  else if(cm == te::map::SourceIn)
110  {
111  m_ui->m_srcInRadioButton->setChecked(true);
112 
114  }
115  else if(cm == te::map::DestinationIn)
116  {
117  m_ui->m_dstInRadioButton->setChecked(true);
118 
120  }
121  else if(cm == te::map::SourceOut)
122  {
123  m_ui->m_srcOutRadioButton->setChecked(true);
124 
126  }
127  else if(cm == te::map::DestinationOut)
128  {
129  m_ui->m_dstOutRadioButton->setChecked(true);
130 
132  }
133  else if(cm == te::map::SourceAtop)
134  {
135  m_ui->m_srcAtTopRadioButton->setChecked(true);
136 
138  }
139  else if(cm == te::map::DestinationAtop)
140  {
141  m_ui->m_dstAtTopRadioButton->setChecked(true);
142 
144  }
145  else if(cm == te::map::Xor)
146  {
147  m_ui->m_xorRadioButton->setChecked(true);
148 
150  }
151  else if(cm == te::map::Plus)
152  {
153  m_ui->m_plusRadioButton->setChecked(true);
154 
156  }
157  else if(cm == te::map::Multiply)
158  {
159  m_ui->m_multRadioButton->setChecked(true);
160 
162  }
163  else if(cm == te::map::Screen)
164  {
165  m_ui->m_screenRadioButton->setChecked(true);
166 
168  }
169  else if(cm == te::map::Overlay)
170  {
171  m_ui->m_overlayRadioButton->setChecked(true);
172 
174  }
175  else if(cm == te::map::Darken)
176  {
177  m_ui->m_darkenRadioButton->setChecked(true);
178 
180  }
181  else if(cm == te::map::Lighten)
182  {
183  m_ui->m_lightenRadioButton->setChecked(true);
184 
186  }
187  else if(cm == te::map::ColorDodge)
188  {
189  m_ui->m_colorDodgeRadioButton->setChecked(true);
190 
192  }
193  else if(cm == te::map::ColorBurn)
194  {
195  m_ui->m_colorBurnRadioButton->setChecked(true);
196 
198  }
199  else if(cm == te::map::HardLight)
200  {
201  m_ui->m_hardLightRadioButton->setChecked(true);
202 
204  }
205  else if(cm == te::map::SoftLight)
206  {
207  m_ui->m_softLightRadioButton->setChecked(true);
208 
210  }
211  else if(cm == te::map::Difference)
212  {
213  m_ui->m_diffRadioButton->setChecked(true);
214 
216  }
217  else if(cm == te::map::Exclusion)
218  {
219  m_ui->m_exclusionRadioButton->setChecked(true);
220 
222  }
223 }
224 
226 {
227  return m_ui->m_applyPushButton;
228 }
229 
231 {
232  if(m_layer.get() && flag)
233  {
234  m_layer->setCompositionMode(te::map::Clear);
235 
236  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-clear").pixmap(128,128));
237 
238  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The pixels in the destination are cleared (set to fully transparent) independent of the source."));
239  }
240 }
241 
243 {
244  if(m_layer.get() && flag)
245  {
246  m_layer->setCompositionMode(te::map::Source);
247 
248  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src").pixmap(128,128));
249 
250  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)."));
251  }
252 }
253 
255 {
256  if(m_layer.get() && flag)
257  {
258  m_layer->setCompositionMode(te::map::Destination);
259 
260  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst").pixmap(128,128));
261 
262  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."));
263  }
264 }
265 
267 {
268  if(m_layer.get() && flag)
269  {
270  m_layer->setCompositionMode(te::map::SourceOver);
271 
272  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-over").pixmap(128,128));
273 
274  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."));
275  }
276 }
277 
279 {
280  if(m_layer.get() && flag)
281  {
282  m_layer->setCompositionMode(te::map::DestinationOver);
283 
284  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-over").pixmap(128,128));
285 
286  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."));
287  }
288 }
289 
291 {
292  if(m_layer.get() && flag)
293  {
294  m_layer->setCompositionMode(te::map::SourceIn);
295 
296  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-in").pixmap(128,128));
297 
298  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the source, where the alpha is reduced by that of the destination."));
299  }
300 }
301 
303 {
304  if(m_layer.get() && flag)
305  {
306  m_layer->setCompositionMode(te::map::DestinationIn);
307 
308  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-in").pixmap(128,128));
309 
310  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."));
311  }
312 }
313 
315 {
316  if(m_layer.get() && flag)
317  {
318  m_layer->setCompositionMode(te::map::SourceOut);
319 
320  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-out").pixmap(128,128));
321 
322  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The output is the source, where the alpha is reduced by the inverse of destination."));
323  }
324 }
325 
327 {
328  if(m_layer.get() && flag)
329  {
330  m_layer->setCompositionMode(te::map::DestinationOut);
331 
332  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-out").pixmap(128,128));
333 
334  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."));
335  }
336 }
337 
339 {
340  if(m_layer.get() && flag)
341  {
342  m_layer->setCompositionMode(te::map::SourceAtop);
343 
344  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-src-atop").pixmap(128,128));
345 
346  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."));
347  }
348 }
349 
351 {
352  if(m_layer.get() && flag)
353  {
354  m_layer->setCompositionMode(te::map::DestinationAtop);
355 
356  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-dst-atop").pixmap(128,128));
357 
358  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."));
359  }
360 }
361 
363 {
364  if(m_layer.get() && flag)
365  {
366  m_layer->setCompositionMode(te::map::Xor);
367 
368  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-xor").pixmap(128,128));
369 
370  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."));
371  }
372 }
373 
375 {
376  if(m_layer.get() && flag)
377  {
378  m_layer->setCompositionMode(te::map::Plus);
379 
380  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
381 
382  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Both the alpha and color of the source and destination pixels are added together."));
383  }
384 }
385 
387 {
388  if(m_layer.get() && flag)
389  {
390  m_layer->setCompositionMode(te::map::Multiply);
391 
392  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
393 
394  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."));
395  }
396 }
397 
399 {
400  if(m_layer.get() && flag)
401  {
402  m_layer->setCompositionMode(te::map::Screen);
403 
404  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
405 
406  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."));
407  }
408 }
409 
411 {
412  if(m_layer.get() && flag)
413  {
414  m_layer->setCompositionMode(te::map::Overlay);
415 
416  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
417 
418  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."));
419  }
420 }
421 
423 {
424  if(m_layer.get() && flag)
425  {
426  m_layer->setCompositionMode(te::map::Darken);
427 
428  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
429 
430  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The darker of the source and destination colors is selected."));
431  }
432 }
433 
435 {
436  if(m_layer.get() && flag)
437  {
438  m_layer->setCompositionMode(te::map::Lighten);
439 
440  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
441 
442  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("The lighter of the source and destination colors is selected."));
443  }
444 }
445 
447 {
448  if(m_layer.get() && flag)
449  {
450  m_layer->setCompositionMode(te::map::ColorDodge);
451 
452  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
453 
454  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."));
455  }
456 }
457 
459 {
460  if(m_layer.get() && flag)
461  {
462  m_layer->setCompositionMode(te::map::ColorBurn);
463 
464  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
465 
466  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."));
467  }
468 }
469 
471 {
472  if(m_layer.get() && flag)
473  {
474  m_layer->setCompositionMode(te::map::HardLight);
475 
476  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
477 
478  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."));
479  }
480 }
481 
483 {
484  if(m_layer.get() && flag)
485  {
486  m_layer->setCompositionMode(te::map::SoftLight);
487 
488  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
489 
490  m_ui->m_decriptionPlainTextEdit->setPlainText(tr("Darkens or lightens the colors depending on the source color. Similar to Hard Light."));
491  }
492 }
493 
495 {
496  if(m_layer.get() && flag)
497  {
498  m_layer->setCompositionMode(te::map::Difference);
499 
500  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
501 
502  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."));
503  }
504 }
505 
507 {
508  if(m_layer.get() && flag)
509  {
510  m_layer->setCompositionMode(te::map::Exclusion);
511 
512  m_ui->m_diagramLabel->setPixmap(QIcon::fromTheme("composition-mode-mix").pixmap(128,128));
513 
514  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."));
515  }
516 }
std::unique_ptr< Ui::CompositionModeDialogForm > m_ui
Qt component.
te::map::AbstractLayerPtr m_layer
Selected Layer.
CompositionMode
The composition mode used to render the canvas.
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)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr