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
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2004-08-26
* Description : a digikam image editor plugin to
* simulate charcoal drawing.
*
* Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot 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, 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.
*
* ============================================================ */
// TQt includes.
#include <tqlabel.h>
#include <tqwhatsthis.h>
#include <tqlayout.h>
// KDE includes.
#include <tdeconfig.h>
#include <tdelocale.h>
#include <tdeaboutdata.h>
#include <kiconloader.h>
#include <tdeapplication.h>
#include <kstandarddirs.h>
// LibKDcraw includes.
#include <libkdcraw/rnuminput.h>
// Local includes.
#include "daboutdata.h"
#include "ddebug.h"
#include "dimg.h"
#include "imageiface.h"
#include "imagepanelwidget.h"
#include "editortoolsettings.h"
#include "charcoal.h"
#include "charcoaltool.h"
#include "charcoaltool.moc"
using namespace KDcrawIface;
using namespace Digikam;
namespace DigikamCharcoalImagesPlugin
{
CharcoalTool::CharcoalTool(TQObject* parent)
: EditorToolThreaded(parent)
{
setName("charcoal");
setToolName(i18n("Charcoal"));
setToolIcon(SmallIcon("charcoaltool"));
// -------------------------------------------------------------
m_gboxSettings = new EditorToolSettings(EditorToolSettings::Default|
EditorToolSettings::Ok|
EditorToolSettings::Cancel|
EditorToolSettings::Try,
EditorToolSettings::PanIcon);
TQGridLayout* grid = new TQGridLayout( m_gboxSettings->plainPage(), 4, 1);
TQLabel *label1 = new TQLabel(i18n("Pencil size:"), m_gboxSettings->plainPage());
m_pencilInput = new RIntNumInput(m_gboxSettings->plainPage());
m_pencilInput->setRange(1, 100, 1);
m_pencilInput->setDefaultValue(5);
TQWhatsThis::add( m_pencilInput, i18n("<p>Set here the charcoal pencil size used to simulate the drawing."));
// -------------------------------------------------------------
TQLabel *label2 = new TQLabel(i18n("Smooth:"), m_gboxSettings->plainPage());
m_smoothInput = new RIntNumInput(m_gboxSettings->plainPage());
m_smoothInput->setRange(1, 100, 1);
m_smoothInput->setDefaultValue(10);
TQWhatsThis::add( m_smoothInput, i18n("<p>This value controls the smoothing effect of the pencil "
"under the canvas."));
grid->addMultiCellWidget(label1, 0, 0, 0, 1);
grid->addMultiCellWidget(m_pencilInput, 1, 1, 0, 1);
grid->addMultiCellWidget(label2, 2, 2, 0, 1);
grid->addMultiCellWidget(m_smoothInput, 3, 3, 0, 1);
grid->setRowStretch(4, 10);
grid->setMargin(m_gboxSettings->spacingHint());
grid->setSpacing(m_gboxSettings->spacingHint());
setToolSettings(m_gboxSettings);
// -------------------------------------------------------------
m_previewWidget = new ImagePanelWidget(470, 350, "charcoal Tool", m_gboxSettings->panIconView());
setToolView(m_previewWidget);
init();
// -------------------------------------------------------------
connect(m_pencilInput, TQ_SIGNAL(valueChanged(int)),
this, TQ_SLOT(slotTimer()));
connect(m_smoothInput, TQ_SIGNAL(valueChanged(int)),
this, TQ_SLOT(slotTimer()));
}
CharcoalTool::~CharcoalTool()
{
}
void CharcoalTool::renderingFinished()
{
m_pencilInput->setEnabled(true);
m_smoothInput->setEnabled(true);
}
void CharcoalTool::readSettings()
{
TDEConfig* config = kapp->config();
config->setGroup("charcoal Tool");
m_pencilInput->blockSignals(true);
m_smoothInput->blockSignals(true);
m_pencilInput->setValue(config->readNumEntry("PencilAjustment", m_pencilInput->defaultValue()));
m_smoothInput->setValue(config->readNumEntry("SmoothAjustment", m_smoothInput->defaultValue()));
m_pencilInput->blockSignals(false);
m_smoothInput->blockSignals(false);
}
void CharcoalTool::writeSettings()
{
TDEConfig* config = kapp->config();
config->setGroup("charcoal Tool");
config->writeEntry("PencilAjustment", m_pencilInput->value());
config->writeEntry("SmoothAjustment", m_smoothInput->value());
m_previewWidget->writeSettings();
config->sync();
}
void CharcoalTool::slotResetSettings()
{
m_pencilInput->blockSignals(true);
m_smoothInput->blockSignals(true);
m_pencilInput->slotReset();
m_smoothInput->slotReset();
m_pencilInput->blockSignals(false);
m_smoothInput->blockSignals(false);
}
void CharcoalTool::prepareEffect()
{
m_pencilInput->setEnabled(false);
m_smoothInput->setEnabled(false);
double pencil = (double)m_pencilInput->value()/10.0;
double smooth = (double)m_smoothInput->value();
DImg image = m_previewWidget->getOriginalRegionImage();
setFilter(dynamic_cast<DImgThreadedFilter*>(new Charcoal(&image, this, pencil, smooth)));
}
void CharcoalTool::prepareFinal()
{
m_pencilInput->setEnabled(false);
m_smoothInput->setEnabled(false);
double pencil = (double)m_pencilInput->value()/10.0;
double smooth = (double)m_smoothInput->value();
ImageIface iface(0, 0);
setFilter(dynamic_cast<DImgThreadedFilter*>(new Charcoal(iface.getOriginalImg(), this, pencil, smooth)));
}
void CharcoalTool::putPreviewData()
{
m_previewWidget->setPreviewImage(filter()->getTargetImage());
}
void CharcoalTool::putFinalData()
{
ImageIface iface(0, 0);
iface.putOriginalImage(i18n("Charcoal"), filter()->getTargetImage().bits());
}
} // NameSpace DigikamCharcoalImagesPlugin
|