~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/imageplugins/hotpixels/imageeffect_hotpixels.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Description : a digiKam image plugin for fixing dots produced by
8
8
 *               hot/stuck/dead pixels from a CCD.
9
9
 * 
10
 
 * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 * Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
11
 * Copyright (C) 2005-2006 by Unai Garro <ugarro at users dot sourceforge dot net>
12
12
 * 
13
13
 * This program is free software; you can redistribute it
41
41
#include <kapplication.h>
42
42
#include <kstandarddirs.h>
43
43
#include <kfiledialog.h>
 
44
#include <kprogress.h>
44
45
 
45
46
// Local includes.
46
47
 
49
50
#include "dimg.h"
50
51
#include "imageiface.h"
51
52
#include "imagewidget.h"
 
53
#include "imagedialog.h"
52
54
#include "blackframelistview.h"
53
55
#include "imageeffect_hotpixels.h"
54
56
#include "imageeffect_hotpixels.moc"
63
65
{
64
66
    // No need Abort button action.
65
67
    showButton(User1, false); 
66
 
    
 
68
 
67
69
    QString whatsThis;
68
70
 
69
71
    KAboutData* about = new KAboutData("digikam",
72
74
                                       I18N_NOOP("A digiKam image plugin for fixing dots produced by "
73
75
                                                 "hot/stuck/dead pixels from a CCD."),
74
76
                                       KAboutData::License_GPL,
75
 
                                       "(c) 2005-2007, Unai Garro and Gilles Caulier", 
 
77
                                       "(c) 2005-2006, Unai Garro\n(c) 2005-2008, Gilles Caulier", 
76
78
                                       0,
77
79
                                       "http://www.digikam.org");
78
 
                
 
80
 
79
81
    about->addAuthor("Unai Garro", I18N_NOOP("Author and maintainer"),
80
82
                     "ugarro at sourceforge dot net");
81
 
    
 
83
 
82
84
    about->addAuthor("Gilles Caulier", I18N_NOOP("Developer"),
83
85
                     "caulier dot gilles at gmail dot com");
84
 
        
 
86
 
85
87
    setAboutData(about);
86
 
    
 
88
 
87
89
    // -------------------------------------------------------------
88
 
    
 
90
 
89
91
    QWidget *gboxSettings     = new QWidget(m_imagePreviewWidget);
90
 
    QGridLayout* gridSettings = new QGridLayout( gboxSettings, 2, 2, 0, spacingHint());
91
 
    
 
92
    QGridLayout* gridSettings = new QGridLayout(gboxSettings, 3, 2, 0, spacingHint());
 
93
 
92
94
    QLabel *filterMethodLabel = new QLabel(i18n("Filter:"), gboxSettings);
93
95
    m_filterMethodCombo       = new QComboBox(gboxSettings);
94
96
    m_filterMethodCombo->insertItem(i18n("Average"));
100
102
    setButtonWhatsThis( Apply, i18n("<p>Use this button to add a new black frame file which will "
101
103
                                    "be used by the hot pixels removal filter.") );  
102
104
 
103
 
    gridSettings->addMultiCellWidget(filterMethodLabel, 0, 0, 0, 0);
104
 
    gridSettings->addMultiCellWidget(m_filterMethodCombo, 0, 0, 1, 1);
105
 
    gridSettings->addMultiCellWidget(m_blackFrameButton, 0, 0, 2, 2);    
106
 
    
107
105
    m_blackFrameListView = new BlackFrameListView(gboxSettings);
 
106
    m_progressBar        = new KProgress(100, gboxSettings);
 
107
    m_progressBar->setValue(0);
 
108
    m_progressBar->hide();
 
109
 
 
110
    gridSettings->addMultiCellWidget(filterMethodLabel,    0, 0, 0, 0);
 
111
    gridSettings->addMultiCellWidget(m_filterMethodCombo,  0, 0, 1, 1);
 
112
    gridSettings->addMultiCellWidget(m_blackFrameButton,   0, 0, 2, 2);
108
113
    gridSettings->addMultiCellWidget(m_blackFrameListView, 1, 2, 0, 2);
109
 
    
 
114
    gridSettings->addMultiCellWidget(m_progressBar,        3, 3, 0, 2);
 
115
 
110
116
    m_imagePreviewWidget->setUserAreaWidget(gboxSettings);
111
117
 
112
118
    // -------------------------------------------------------------
113
 
    
 
119
 
114
120
    connect(m_filterMethodCombo, SIGNAL(activated(int)),
115
121
            this, SLOT(slotEffect()));
116
122
 
117
123
    connect(m_blackFrameButton, SIGNAL(clicked()),
118
124
            this, SLOT(slotAddBlackFrame()));
119
 
                                                  
 
125
 
120
126
    connect(m_blackFrameListView, SIGNAL(blackFrameSelected(QValueList<HotPixel>, const KURL&)),
121
127
            this, SLOT(slotBlackFrame(QValueList<HotPixel>, const KURL&))); 
122
128
}
125
131
{
126
132
}
127
133
 
128
 
void ImageEffect_HotPixels::readUserSettings(void)
 
134
void ImageEffect_HotPixels::readUserSettings()
129
135
{
130
136
    KConfig *config = kapp->config();
131
137
    config->setGroup("hotpixels Tool Dialog");
132
138
    m_blackFrameURL = KURL(config->readEntry("Last Black Frame File", QString()));
133
139
    m_filterMethodCombo->setCurrentItem(config->readNumEntry("Filter Method",
134
140
                                        HotPixelFixer::QUADRATIC_INTERPOLATION));
135
 
    
 
141
 
136
142
    if (m_blackFrameURL.isValid())
137
 
        new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
 
143
    {
 
144
        BlackFrameListViewItem *item = new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
 
145
 
 
146
        connect(item, SIGNAL(signalLoadingProgress(float)),
 
147
                this, SLOT(slotLoadingProgress(float)));
 
148
 
 
149
        connect(item, SIGNAL(signalLoadingComplete()),
 
150
                this, SLOT(slotLoadingComplete()));
 
151
    }
138
152
}
139
153
 
140
 
void ImageEffect_HotPixels::writeUserSettings(void)
 
154
void ImageEffect_HotPixels::writeUserSettings()
141
155
{
142
156
    KConfig *config = kapp->config();
143
157
    config->setGroup("hotpixels Tool Dialog");
146
160
    config->sync();
147
161
}
148
162
 
149
 
void ImageEffect_HotPixels::resetValues(void)
 
163
void ImageEffect_HotPixels::resetValues()
150
164
{
151
165
    m_filterMethodCombo->blockSignals(true);
152
166
    m_filterMethodCombo->setCurrentItem(HotPixelFixer::QUADRATIC_INTERPOLATION);
155
169
 
156
170
void ImageEffect_HotPixels::slotAddBlackFrame()
157
171
{
158
 
    KFileDialog fileSelectDialog(QString(), KImageIO::pattern(), this, "", true);
159
 
    fileSelectDialog.setCaption(i18n("Select Black Frame Image"));
160
 
    fileSelectDialog.setURL(m_blackFrameURL.path());
161
 
    
162
 
    if (fileSelectDialog.exec() != QDialog::Rejected)
 
172
    KURL url = Digikam::ImageDialog::getImageURL(this, m_blackFrameURL,
 
173
                                                 i18n("Select Black Frame Image"));
 
174
 
 
175
    if (!url.isEmpty())
163
176
    {
164
 
       //Load the selected file and insert into the list
165
 
        
166
 
       m_blackFrameURL = fileSelectDialog.selectedURL();
167
 
       m_blackFrameListView->clear();
168
 
       new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
 
177
        // Load the selected file and insert into the list.
 
178
 
 
179
        m_blackFrameURL = url;
 
180
        m_blackFrameListView->clear();
 
181
        BlackFrameListViewItem *item = new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
 
182
 
 
183
        connect(item, SIGNAL(signalLoadingProgress(float)),
 
184
                this, SLOT(slotLoadingProgress(float)));
 
185
 
 
186
        connect(item, SIGNAL(signalLoadingComplete()),
 
187
                this, SLOT(slotLoadingComplete()));
169
188
    }
170
189
}
171
190
 
172
 
void ImageEffect_HotPixels::renderingFinished(void)
 
191
void ImageEffect_HotPixels::slotLoadingProgress(float v)
 
192
{
 
193
    m_progressBar->show();
 
194
    m_progressBar->setValue((int)(v*100));
 
195
}
 
196
 
 
197
void ImageEffect_HotPixels::slotLoadingComplete()
 
198
{
 
199
    m_progressBar->hide();
 
200
}
 
201
 
 
202
void ImageEffect_HotPixels::renderingFinished()
173
203
{
174
204
    m_filterMethodCombo->setEnabled(true);
175
205
    m_blackFrameListView->setEnabled(true);
176
 
    enableButton(Apply, true);     
 
206
    enableButton(Apply, true);
177
207
}
178
208
 
179
209
void ImageEffect_HotPixels::prepareEffect()
217
247
                       new HotPixelFixer(iface.getOriginalImg(), this,m_hotPixelsList,interpolationMethod));
218
248
}
219
249
 
220
 
void ImageEffect_HotPixels::putPreviewData(void)
 
250
void ImageEffect_HotPixels::putPreviewData()
221
251
{
222
252
    m_imagePreviewWidget->setPreviewImage(m_threadedFilter->getTargetImage());
223
253
}
224
254
 
225
 
void ImageEffect_HotPixels::putFinalData(void)
 
255
void ImageEffect_HotPixels::putFinalData()
226
256
{
227
257
    Digikam::ImageIface iface(0, 0);
228
258
    iface.putOriginalImage(i18n("Hot Pixels Correction"), m_threadedFilter->getTargetImage().bits());