Bug 146636 - adjust levels: helper line for sliders?
Summary: adjust levels: helper line for sliders?
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Editor-Levels (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-10 15:59 UTC by Daniel Bauer
Modified: 2016-06-29 19:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.9.3


Attachments
sample of helper lines in adjust levels graph (here: red lines) (6.69 KB, image/png)
2007-06-10 16:01 UTC, Daniel Bauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bauer 2007-06-10 15:59:52 UTC
Version:           0.9.2 svn (using KDE KDE 3.5.6)
Installed from:    SuSE RPMs
OS:                Linux

some helper lines in the graph that follow the the sliders when adjusting levelswould be very useful to find the accurate position.

(I attach a screen shot with the two desired lines [red] to explain what I mean :-) )
Comment 1 Daniel Bauer 2007-06-10 16:01:19 UTC
Created attachment 20829 [details]
sample of helper lines in adjust levels graph (here: red lines)
Comment 2 caulier.gilles 2007-07-06 09:32:56 UTC
SVN commit 684115 by cgilles:

digiKam from KDE3 branch : Adjust Levels image plugin : install an event filter on all levels slider to 
display a guide over levels histogram when user perform adjustements
BUG: 146636


 M  +114 -2    adjustlevels.cpp  
 M  +2 -0      adjustlevels.h  


--- branches/extragear/kde3/graphics/digikam/imageplugins/adjustlevels/adjustlevels.cpp #684114:684115
@@ -195,6 +195,7 @@
     QWhatsThis::add( m_hGradientMinInput, i18n("<p>Select here the minimal intensity input value of the histogram."));
     QToolTip::add( m_hGradientMinInput, i18n( "Minimal intensity input." ) );
     m_hGradientMinInput->setColors( QColor( "black" ), QColor( "white" ) );
+    m_hGradientMinInput->installEventFilter(this);
 
     m_hGradientMaxInput = new KGradientSelector( KSelector::Horizontal, gboxSettings );
     m_hGradientMaxInput->setFixedHeight( 20 );
@@ -203,17 +204,20 @@
     QWhatsThis::add( m_hGradientMaxInput, i18n("<p>Select here the maximal intensity input value of the histogram."));
     QToolTip::add( m_hGradientMaxInput, i18n( "Maximal intensity input." ) );
     m_hGradientMaxInput->setColors( QColor( "black" ), QColor( "white" ) );
+    m_hGradientMaxInput->installEventFilter(this);
 
     m_minInput = new QSpinBox(0, m_histoSegments, 1, gboxSettings);
     m_minInput->setValue(0);
     QWhatsThis::add( m_minInput, i18n("<p>Select here the minimal intensity input value of the histogram."));
     QToolTip::add( m_minInput, i18n( "Minimal intensity input." ) );
+    
     m_gammaInput = new KDoubleNumInput(gboxSettings);
     m_gammaInput->setPrecision(2);
     m_gammaInput->setRange(0.1, 3.0, 0.01);
     m_gammaInput->setValue(1.0);
     QToolTip::add( m_gammaInput, i18n( "Gamma input value." ) );
     QWhatsThis::add( m_gammaInput, i18n("<p>Select here the gamma input value."));
+    
     m_maxInput = new QSpinBox(0, m_histoSegments, 1, gboxSettings);
     m_maxInput->setValue(m_histoSegments);
     QToolTip::add( m_maxInput, i18n( "Maximal intensity input." ) );
@@ -226,7 +230,8 @@
     m_hGradientMinOutput->setFixedHeight( 20 );
     m_hGradientMinOutput->setMinValue(0);
     m_hGradientMinOutput->setMaxValue(m_histoSegments);
-
+    m_hGradientMinOutput->installEventFilter(this);
+    
     m_hGradientMaxOutput = new KGradientSelector( KSelector::Horizontal, gboxSettings );
     m_hGradientMaxOutput->setColors( QColor( "black" ), QColor( "white" ) );
     QWhatsThis::add( m_hGradientMaxOutput, i18n("<p>Select here the maximal intensity output value of the histogram."));
@@ -234,11 +239,13 @@
     m_hGradientMaxOutput->setFixedHeight( 20 );
     m_hGradientMaxOutput->setMinValue(0);
     m_hGradientMaxOutput->setMaxValue(m_histoSegments);
-
+    m_hGradientMaxOutput->installEventFilter(this);
+    
     m_minOutput = new QSpinBox(0, m_histoSegments, 1, gboxSettings);
     m_minOutput->setValue(0);
     QToolTip::add( m_minOutput, i18n( "Minimal intensity output." ) );
     QWhatsThis::add( m_minOutput, i18n("<p>Select here the minimal intensity output value of the histogram."));
+    
     m_maxOutput = new QSpinBox(0, m_histoSegments, 1, gboxSettings);
     m_maxOutput->setValue(m_histoSegments);
     QToolTip::add( m_maxOutput, i18n( "Maximal intensity output." ) );
@@ -798,4 +805,109 @@
     slotChannelChanged(m_channelCB->currentItem());
 }
 
+// See B.K.O #146636: use event filter with all level slider to display a
+// guide over level histogram.
+bool AdjustLevelDialog::eventFilter(QObject *obj, QEvent *ev)
+{
+    if ( obj == m_hGradientMinInput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_minInput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_minInput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    if ( obj == m_hGradientMaxInput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_maxInput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_maxInput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    if ( obj == m_hGradientMinOutput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_minOutput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_minOutput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    if ( obj == m_hGradientMaxOutput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_maxOutput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_maxOutput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    else
+    {
+        // pass the event on to the parent class
+        return KDialogBase::eventFilter(obj, ev);
+    }
+}
+
+void AdjustLevelDialog::slotShowHistogramGuide(int v)
+{
+    Digikam::DColor color(v, v, v, v, m_originalImage.sixteenBit());
+    m_levelsHistogramWidget->setHistogramGuideByColor(color);
+}
+
 }  // NameSpace DigikamAdjustLevelsImagesPlugin
--- branches/extragear/kde3/graphics/digikam/imageplugins/adjustlevels/adjustlevels.h #684114:684115
@@ -64,6 +64,7 @@
     void resetValues();
     void finalRendering(); 
     void adjustSliders(int minIn, double gamIn, int maxIn, int minOut, int maxOut);
+    bool eventFilter(QObject *o, QEvent *e);
     
 private slots:
 
@@ -83,6 +84,7 @@
     void slotSpotColorChanged(const Digikam::DColor &color);
     void slotColorSelectedFromTarget(const Digikam::DColor &color);
     void slotPickerColorButtonActived();    
+    void slotShowHistogramGuide(int v);
 
 private:
     
Comment 3 caulier.gilles 2007-07-06 11:16:16 UTC
SVN commit 684129 by cgilles:

digiKam from trunk (KDE4) : Backport B.K.O #146636
CCBUGS: 146636


 M  +120 -6    adjustlevels.cpp  
 M  +2 -0      adjustlevels.h  


--- trunk/extragear/graphics/digikam/imageplugins/adjustlevels/adjustlevels.cpp #684128:684129
@@ -192,22 +192,26 @@
     // -------------------------------------------------------------
     
     m_hGradientMinInput = new KGradientSelector( Qt::Horizontal, gboxSettings );
-    m_hGradientMinInput->setFixedHeight( 20 );
-    m_hGradientMinInput->setMinimum(0);
-    m_hGradientMinInput->setMaximum(m_histoSegments);
+    m_hGradientMinInput->setIndent(false);
+    m_hGradientMinInput->setFixedHeight( 16 );
+    m_hGradientMinInput->setMinValue(0);
+    m_hGradientMinInput->setMaxValue(m_histoSegments);
     m_hGradientMinInput->setWhatsThis( i18n("<p>Select here the minimal intensity "
                                             "input value of the histogram."));
     m_hGradientMinInput->setToolTip( i18n( "Minimal intensity input." ) );
     m_hGradientMinInput->setColors( QColor( "black" ), QColor( "white" ) );
+    m_hGradientMinInput->installEventFilter(this);
 
     m_hGradientMaxInput = new KGradientSelector( Qt::Horizontal, gboxSettings );
-    m_hGradientMaxInput->setFixedHeight( 20 );
+    m_hGradientMaxInput->setIndent(false);
+    m_hGradientMaxInput->setFixedHeight( 16 );
     m_hGradientMaxInput->setMinimum(0);
     m_hGradientMaxInput->setMaximum(m_histoSegments);
     m_hGradientMaxInput->setWhatsThis( i18n("<p>Select here the maximal intensity input "
                                             "value of the histogram."));
     m_hGradientMaxInput->setToolTip( i18n( "Maximal intensity input." ) );
     m_hGradientMaxInput->setColors( QColor( "black" ), QColor( "white" ) );
+    m_hGradientMaxInput->installEventFilter(this);
 
     m_minInput = new QSpinBox(gboxSettings);
     m_minInput->setRange(0, m_histoSegments);
@@ -216,6 +220,7 @@
     m_minInput->setWhatsThis( i18n("<p>Select here the minimal intensity input "
                                    "value of the histogram."));
     m_minInput->setToolTip( i18n( "Minimal intensity input." ) );
+
     m_gammaInput = new KDoubleNumInput(gboxSettings);
     m_gammaInput->setPrecision(2);
     m_gammaInput->setRange(0.1, 3.0, 0.01);
@@ -236,18 +241,22 @@
     m_hGradientMinOutput->setWhatsThis(i18n("<p>Select here the minimal intensity output "
                                              "value of the histogram."));    
     m_hGradientMinOutput->setToolTip( i18n( "Minimal intensity output." ) );
-    m_hGradientMinOutput->setFixedHeight( 20 );
+    m_hGradientMinOutput->setIndent(false);
+    m_hGradientMinOutput->setFixedHeight( 16 );
     m_hGradientMinOutput->setMinimum(0);
     m_hGradientMinOutput->setMaximum(m_histoSegments);
+    m_hGradientMinOutput->installEventFilter(this);
 
     m_hGradientMaxOutput = new KGradientSelector( Qt::Horizontal, gboxSettings );
     m_hGradientMaxOutput->setColors( QColor( "black" ), QColor( "white" ) );
     m_hGradientMaxOutput->setWhatsThis(i18n("<p>Select here the maximal intensity output "
                                             "value of the histogram."));
     m_hGradientMaxOutput->setToolTip( i18n( "Maximal intensity output." ) );
-    m_hGradientMaxOutput->setFixedHeight( 20 );
+    m_hGradientMaxOutput->setIndent(false);
+    m_hGradientMaxOutput->setFixedHeight( 16 );
     m_hGradientMaxOutput->setMinimum(0);
     m_hGradientMaxOutput->setMaximum(m_histoSegments);
+    m_hGradientMaxOutput->installEventFilter(this);
 
     m_minOutput = new QSpinBox(gboxSettings);
     m_minOutput->setRange(0, m_histoSegments);
@@ -830,4 +839,109 @@
     slotChannelChanged(m_channelCB->currentIndex());
 }
 
+// See B.K.O #146636: use event filter with all level slider to display a
+// guide over level histogram.
+bool AdjustLevelDialog::eventFilter(QObject *obj, QEvent *ev)
+{
+    if ( obj == m_hGradientMinInput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_minInput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_minInput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    if ( obj == m_hGradientMaxInput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_maxInput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_maxInput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    if ( obj == m_hGradientMinOutput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_minOutput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_minOutput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    if ( obj == m_hGradientMaxOutput )
+    {
+        if ( ev->type() == QEvent::MouseButtonPress)
+        {
+            connect(m_maxOutput, SIGNAL(valueChanged(int)),
+                    this, SLOT(slotShowHistogramGuide(int)));
+            
+            return false;
+        }
+        if ( ev->type() == QEvent::MouseButtonRelease)
+        {
+            disconnect(m_maxOutput, SIGNAL(valueChanged(int)),
+                       this, SLOT(slotShowHistogramGuide(int)));
+
+            m_levelsHistogramWidget->reset();
+            return false;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    else
+    {
+        // pass the event on to the parent class
+        return KDialog::eventFilter(obj, ev);
+    }
+}
+
+void AdjustLevelDialog::slotShowHistogramGuide(int v)
+{
+    Digikam::DColor color(v, v, v, v, m_originalImage.sixteenBit());
+    m_levelsHistogramWidget->setHistogramGuideByColor(color);
+}
+
 }  // NameSpace DigikamAdjustLevelsImagesPlugin
--- trunk/extragear/graphics/digikam/imageplugins/adjustlevels/adjustlevels.h #684128:684129
@@ -64,6 +64,7 @@
     void resetValues();
     void finalRendering(); 
     void adjustSliders(int minIn, double gamIn, int maxIn, int minOut, int maxOut);
+    bool eventFilter(QObject *obj, QEvent *ev);
     
 private slots:
 
@@ -83,6 +84,7 @@
     void slotSpotColorChanged(const Digikam::DColor &color);
     void slotColorSelectedFromTarget(const Digikam::DColor &color);
     void slotPickerColorButtonActived();    
+    void slotShowHistogramGuide(int v);
 
 private:
     
Comment 4 Daniel Bauer 2007-07-07 15:44:10 UTC
Super! Thanks very much, Gilles!