"Fossies" - the Fresh Open Source Software Archive

Member "rawtherapee-5.7/rtgui/thresholdadjuster.h" (10 Sep 2019, 6771 Bytes) of package /linux/misc/rawtherapee-5.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "thresholdadjuster.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.6_vs_5.7.

    1 /*
    2  *  This file is part of RawTherapee.
    3  *
    4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
    5  *
    6  *  RawTherapee is free software: you can redistribute it and/or modify
    7  *  it under the terms of the GNU General Public License as published by
    8  *  the Free Software Foundation, either version 3 of the License, or
    9  *  (at your option) any later version.
   10  *
   11  *  RawTherapee is distributed in the hope that it will be useful,
   12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *  GNU General Public License for more details.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
   18  */
   19 #ifndef _THRESHOLDADJUSTER_H_
   20 #define _THRESHOLDADJUSTER_H_
   21 
   22 #include <gtkmm.h>
   23 #include "editedstate.h"
   24 #include "guiutils.h"
   25 #include "thresholdselector.h"
   26 
   27 class ThresholdAdjuster;
   28 
   29 /*
   30  * TODO: Maybe we could just send back the history string instead of the individual values?
   31  */
   32 class ThresholdAdjusterListener
   33 {
   34 
   35 public:
   36     virtual ~ThresholdAdjusterListener() = default;
   37     // to be used by listener that has created a ThresholdAdjuster with with single threshold and precision > 0
   38     virtual void adjusterChanged(ThresholdAdjuster* a, double newBottom, double newTop) = 0;
   39     // to be used by listener that has created a ThresholdAdjuster with with double threshold and precision > 0
   40     virtual void adjusterChanged(ThresholdAdjuster* a, double newBottomLeft, double newTopLeft, double newBottomRight, double newTopRight) = 0;
   41     // to be used by listener that has created a ThresholdAdjuster with with single threshold and precision == 0
   42     virtual void adjusterChanged(ThresholdAdjuster* a, int newBottom, int newTop) = 0;
   43     // to be used by listener that has created a ThresholdAdjuster with with double threshold and precision == 0
   44     virtual void adjusterChanged(ThresholdAdjuster* a, int newBottomLeft, int newTopLeft, int newBottomRight, int newTopRight) = 0;
   45     virtual void adjusterChanged2(ThresholdAdjuster* a, int newBottomL, int newTopL, int newBottomR, int newTopR) = 0;
   46 };
   47 
   48 
   49 class ThresholdAdjuster : public Gtk::VBox
   50 {
   51 
   52 protected:
   53     Gtk::HBox* hbox;
   54     Gtk::Label* label;
   55     ThresholdSelector tSelector;
   56     //MySpinButton* spin;
   57     Gtk::Button* reset;
   58     ThresholdAdjusterListener* adjusterListener;
   59     sigc::connection delayConnection;
   60     //sigc::connection spinChange;
   61     sigc::connection selectorChange;
   62     sigc::connection editedChange;
   63     double initialDefaultVal[4];    // default value at construction time
   64     EditedState editedState;
   65     EditedState defEditedState;
   66     Gtk::CheckButton* editedCheckBox;
   67     bool afterReset;
   68     bool blocked;
   69     bool addMode;
   70     bool separatedMode;
   71     int delay;
   72 
   73     double shapeValue (double a);
   74     void refreshLabelStyle ();
   75     void initObject (Glib::ustring label, bool editedcb);
   76     void sendToListener ();
   77 
   78 public:
   79 
   80     // Custom Threshold widget with 2 cursors (Top and Bottom) and a custom curve provided by the instanciator,
   81     // each cursor having his own range, default value and precision
   82     ThresholdAdjuster (Glib::ustring label,
   83                        double minValueBottom, double maxValueBottom, double defBottom, Glib::ustring labelBottom, unsigned int precisionBottom,
   84                        double minValueTop,    double maxValueTop,    double defTop,    Glib::ustring labelTop,    unsigned int precisionTop,
   85                        ThresholdCurveProvider* curveProvider, bool editedCheckBox = false);
   86     // Simple Threshold widget with 2 linked sliders (0->1 or 1->0)
   87     ThresholdAdjuster (Glib::ustring label, double minValue, double maxValue, double defBottom,
   88                        double defTop, unsigned int precision, bool startAtOne, bool editedCheckBox = false);
   89     // Simple Threshold widget with 4 linked sliders by pairs (0->1->0 or 1->0->1)
   90     ThresholdAdjuster (Glib::ustring label, double minValue, double maxValue, double defBottomLeft,
   91                        double defTopLeft, double defBottomRight, double defTopRight, unsigned int precision,
   92                        bool startAtOne, bool editedCheckBox = false);
   93 
   94     ~ThresholdAdjuster () override;
   95     void setAdjusterListener (ThresholdAdjusterListener* alistener)
   96     {
   97         adjusterListener = alistener;
   98     }
   99 
  100     void setBgCurveProvider (ThresholdCurveProvider* provider);
  101     ThresholdSelector* getThresholdSelector()
  102     {
  103         return &tSelector;
  104     };
  105 
  106     template <typename T>
  107     rtengine::procparams::Threshold<T> getValue ()
  108     {
  109         return tSelector.getPositions<T>();
  110     }
  111     void getValue (double& bottom, double& top);
  112     void getValue (double& bottomLeft, double& topLeft, double& bottomRight, double& topRight);
  113     void getValue (int& bottom, int& top);
  114     void getValue (int& bottomLeft, int& topLeft, int& bottomRight, int& topRight);
  115     void getValue (Glib::ustring& bottom, Glib::ustring& top);
  116     void getValue (Glib::ustring& bottomLeft, Glib::ustring& topLeft, Glib::ustring& bottomRight, Glib::ustring& topRight);
  117     template <class T>
  118     void setValue (const rtengine::procparams::Threshold<T> &tValues)
  119     {
  120         tSelector.setPositions<T>(tValues);
  121     }
  122     void setValue (double bottom, double top);
  123     void setValue (double bottomLeft, double topLeft, double bottomRight, double topRight);
  124     void setEnabled (bool enabled);
  125     template <typename T>
  126     void setDefault (const rtengine::procparams::Threshold<T> &tresh)
  127     {
  128         tSelector.setDefaults<T>(tresh);
  129     }
  130     void setDefault (double defBottom, double defTop);
  131     void setDefault (double defBottomLeft, double defTopLeft, double defBottomRight, double defTopRight);
  132     void setEditedState (EditedState eState);
  133     EditedState getEditedState ();
  134     void setDefaultEditedState (EditedState eState);
  135     void showEditedCB ();
  136     void block(bool isBlocked)
  137     {
  138         blocked = isBlocked;
  139     }
  140     void setBgGradient (const std::vector<GradientMilestone> &milestones)
  141     {
  142         tSelector.coloredBar.setBgGradient (milestones);
  143     }
  144     void setBgColorProvider (ColorProvider *cp, int i)
  145     {
  146         tSelector.coloredBar.setColorProvider(cp, i);
  147     }
  148     void setUpdatePolicy (eUpdatePolicy policy)
  149     {
  150         tSelector.setUpdatePolicy(policy);
  151     }
  152 
  153     //void spinChanged ();
  154     void selectorChanged ();
  155     bool notifyListener ();
  156     void resetPressed (GdkEventButton* event);
  157     void editedToggled ();
  158     Glib::ustring getHistoryString ();
  159     void set_tooltip_markup(const Glib::ustring& markup);
  160     // this set_tooltip_text method is to set_tooltip_markup, and text can contain markups
  161     void set_tooltip_text(const Glib::ustring& text);
  162 };
  163 
  164 #endif