SVN commit 489659 by cgilles:
Digikam from trunk : image histogram sidebar : prepare to use separate thread to load image using future implementation of Marcel Wiesweg CCMAIL: [hidden email], [hidden email] M +38 -37 imageproperties/imagepropertieshistogramtab.cpp M +3 -1 imageproperties/imagepropertieshistogramtab.h M +2 -5 widgets/histogramwidget.cpp M +2 -2 widgets/histogramwidget.h --- trunk/extragear/graphics/digikam/libs/imageproperties/imagepropertieshistogramtab.cpp #489658:489659 @@ -259,9 +259,12 @@ connect(m_histogramWidget, SIGNAL(signalMouseReleased( int )), this, SLOT(slotUpdateMaxInterv(int))); - connect(m_histogramWidget, SIGNAL(signalHistogramComputationDone()), - this, SLOT(slotRefreshOptions())); - + connect(m_histogramWidget, SIGNAL(signalHistogramComputationDone(bool)), + this, SLOT(slotRefreshOptions(bool))); + + connect(m_histogramWidget, SIGNAL(signalHistogramComputationFailed(void)), + this, SLOT(slotHistogramComputationFailed(void))); + connect(m_minInterv, SIGNAL(valueChanged (int)), m_histogramWidget, SLOT(slotMinValueChanged(int))); @@ -329,37 +332,7 @@ if (!imageData && !imageWidth && !imageHeight) { - - m_image = DImg(url.path()); - - if ( !m_image.isNull() ) - { - // If a selection area is done in Image Editor and if the current image is the same - // in Image Editor, then compute too the histogram for this selection. - - if (m_selectionArea) - { - m_imageSelection = m_image.copy(*m_selectionArea); - m_histogramWidget->updateData(m_image.bits(), m_image.width(), m_image.height(), - m_image.sixteenBit(), - m_imageSelection.bits(), m_imageSelection.width(), - m_imageSelection.height()); - m_regionBG->show(); - m_maxInterv->setMaxValue(m_image.sixteenBit() ? 65535 : 255); - } - else - { - m_histogramWidget->updateData(m_image.bits(), m_image.width(), m_image.height(), - m_image.sixteenBit()); - m_regionBG->hide(); - m_maxInterv->setMaxValue(m_image.sixteenBit() ? 65535 : 255); - } - } - else - { - m_imageSelection.reset(); - m_histogramWidget->updateData(0L, 0, 0, false); - } + loadDataFromUrl(url); } else { @@ -388,12 +361,30 @@ } else { - m_imageSelection.reset(); - m_histogramWidget->updateData(0L, 0, 0, false); + slotHistogramComputationFailed(); } } } +void ImagePropertiesHistogramTab::loadDataFromUrl(const KURL& url) +{ + // TODO : use a separate thread to load image. + + m_image = DImg(url.path()); + + if ( !m_image.isNull() ) + { + m_histogramWidget->updateData(m_image.bits(), m_image.width(), m_image.height(), + m_image.sixteenBit()); + m_regionBG->hide(); + m_maxInterv->setMaxValue(m_image.sixteenBit() ? 65535 : 255); + } + else + { + slotHistogramComputationFailed(); + } +} + void ImagePropertiesHistogramTab::setSelection(QRect *selectionArea) { // This is necessary to stop computation because m_image.bits() is currently used by @@ -416,8 +407,11 @@ } } -void ImagePropertiesHistogramTab::slotRefreshOptions() +void ImagePropertiesHistogramTab::slotRefreshOptions(bool sixteenBit) { + m_minInterv->setValue(0); + m_maxInterv->setValue(sixteenBit ? 65535 : 255); + m_maxInterv->setMaxValue(sixteenBit ? 65535 : 255); slotChannelChanged(m_channelCB->currentItem()); slotScaleChanged(m_scaleBG->selectedId()); slotColorsChanged(m_colorsCB->currentItem()); @@ -426,6 +420,13 @@ slotRenderingChanged(m_regionBG->selectedId()); } +void ImagePropertiesHistogramTab::slotHistogramComputationFailed() +{ + m_imageSelection.reset(); + m_image.reset(); + m_histogramWidget->updateData(0L, 0, 0, false); +} + void ImagePropertiesHistogramTab::slotChannelChanged(int channel) { switch(channel) --- trunk/extragear/graphics/digikam/libs/imageproperties/imagepropertieshistogramtab.h #489658:489659 @@ -71,11 +71,13 @@ private: + void loadDataFromUrl(const KURL& url); void updateInformation(); private slots: - void slotRefreshOptions(); + void slotRefreshOptions(bool sixteenBit); + void slotHistogramComputationFailed(void); void slotChannelChanged(int channel); void slotScaleChanged(int scale); void slotColorsChanged(int color); --- trunk/extragear/graphics/digikam/libs/widgets/histogramwidget.cpp #489658:489659 @@ -180,10 +180,7 @@ { // No current selection. Do not using ImageHistogram::getHistogramSegment() // method here because histogram haven't yet computed. - if (m_sixteenBits) - emit signalMouseReleased( 65535 ); - else - emit signalMouseReleased( 255 ); + emit signalMouseReleased( m_sixteenBits ? 65535 : 255 ); } else { @@ -192,7 +189,7 @@ emit signalMouseReleased( m_xmax ); } - emit signalHistogramComputationDone(); + emit signalHistogramComputationDone(m_sixteenBits); } else { --- trunk/extragear/graphics/digikam/libs/widgets/histogramwidget.h #489658:489659 @@ -145,8 +145,8 @@ void signalMousePressed( int ); void signalMouseReleased( int ); - void signalHistogramComputationDone(void); - void signalHistogramComputationFailed(void); + void signalHistogramComputationDone( bool ); + void signalHistogramComputationFailed( void ); public slots: _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |