"Fossies" - the Fresh Open Source Software Archive

Member "rawtherapee-5.7/rtgui/sharpenedge.cc" (10 Sep 2019, 5894 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 "sharpenedge.cc" 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 #include <cmath>
   20 #include <sstream>
   21 
   22 #include "sharpenedge.h"
   23 
   24 #include "guiutils.h"
   25 #include "options.h"
   26 
   27 #include "../rtengine/procparams.h"
   28 
   29 using namespace rtengine;
   30 using namespace rtengine::procparams;
   31 
   32 
   33 SharpenEdge::SharpenEdge () : FoldableToolPanel(this, "sharpenedge", M("TP_SHARPENEDGE_LABEL"), true, true)
   34 {
   35 
   36     passes = Gtk::manage(new Adjuster (M("TP_SHARPENEDGE_PASSES"), 1, 4, 1, 2));
   37     passes->setAdjusterListener (this);
   38 
   39     if (passes->delay < options.adjusterMaxDelay) {
   40         passes->delay = options.adjusterMaxDelay;
   41     }
   42 
   43     amount = Gtk::manage(new Adjuster (M("TP_SHARPENEDGE_AMOUNT"), 0, 100, 1, 50));
   44     amount->setAdjusterListener (this);
   45 
   46     if (amount->delay < options.adjusterMaxDelay) {
   47         amount->delay = options.adjusterMaxDelay;
   48     }
   49 
   50     threechannels = Gtk::manage(new Gtk::CheckButton((M("TP_SHARPENEDGE_THREE"))));// L + a + b
   51     threechannels->set_active (false);
   52     pack_start( *passes, Gtk::PACK_SHRINK, 0);//passes
   53     pack_start( *amount, Gtk::PACK_SHRINK, 0);//amount
   54     pack_start( *threechannels, Gtk::PACK_SHRINK, 0);//one or 3 channels Lab
   55 
   56     chanthreeconn = threechannels->signal_toggled().connect( sigc::mem_fun(*this, &SharpenEdge::chanthree_toggled) );
   57 }
   58 
   59 void SharpenEdge::read(const ProcParams* pp, const ParamsEdited* pedited)
   60 {
   61     disableListener ();
   62 
   63     if(pedited ) {
   64         passes->setEditedState          (pedited->sharpenEdge.passes ? Edited : UnEdited);
   65         amount->setEditedState          (pedited->sharpenEdge.amount ? Edited : UnEdited);
   66         set_inconsistent                (multiImage && !pedited->sharpenEdge.enabled);
   67         threechannels->set_inconsistent (!pedited->sharpenEdge.threechannels);
   68     }
   69 
   70     setEnabled(pp->sharpenEdge.enabled);
   71 
   72     chanthreeconn.block (true);
   73     threechannels->set_active (pp->sharpenEdge.threechannels);
   74     chanthreeconn.block (false);
   75     lastchanthree = pp->sharpenEdge.threechannels;
   76 
   77     passes->setValue (pp->sharpenEdge.passes);
   78     amount->setValue (pp->sharpenEdge.amount);
   79 
   80     enableListener ();
   81 }
   82 
   83 void SharpenEdge::write( ProcParams* pp, ParamsEdited* pedited)
   84 {
   85     pp->sharpenEdge.enabled       = getEnabled();
   86     pp->sharpenEdge.passes        = (int)passes->getValue();
   87     pp->sharpenEdge.amount        = amount->getValue ();
   88     pp->sharpenEdge.threechannels = threechannels->get_active ();
   89 
   90     if (pedited) {
   91         pedited->sharpenEdge.enabled       = !get_inconsistent();
   92         pedited->sharpenEdge.passes        = passes->getEditedState ();
   93         pedited->sharpenEdge.amount        = amount->getEditedState ();
   94         pedited->sharpenEdge.threechannels = !threechannels->get_inconsistent();
   95     }
   96 
   97 }
   98 
   99 void SharpenEdge::enabledChanged ()
  100 {
  101     if (listener) {
  102         if (get_inconsistent()) {
  103             listener->panelChanged (EvSharpenEdgeEnabled, M("GENERAL_UNCHANGED"));
  104         } else if (getEnabled()) {
  105             listener->panelChanged (EvSharpenEdgeEnabled, M("GENERAL_ENABLED"));
  106         } else {
  107             listener->panelChanged (EvSharpenEdgeEnabled, M("GENERAL_DISABLED"));
  108         }
  109     }
  110 }
  111 
  112 void SharpenEdge::chanthree_toggled ()
  113 {
  114 
  115     if (batchMode) {
  116         if (threechannels->get_inconsistent()) {
  117             threechannels->set_inconsistent (false);
  118             chanthreeconn.block (true);
  119             threechannels->set_active (false);
  120             chanthreeconn.block (false);
  121         } else if (lastchanthree) {
  122             threechannels->set_inconsistent (true);
  123         }
  124 
  125         lastchanthree = threechannels->get_active ();
  126     }
  127 
  128     if (listener && getEnabled()) {
  129         if (threechannels->get_active ()) {
  130             listener->panelChanged (EvSharpenEdgeThreechannels, M("GENERAL_ENABLED"));
  131         } else {
  132             listener->panelChanged (EvSharpenEdgeThreechannels, M("GENERAL_DISABLED"));
  133         }
  134     }
  135 }
  136 
  137 void SharpenEdge::adjusterChanged(Adjuster* a, double newval)
  138 {
  139     if (listener && getEnabled()) {
  140         Glib::ustring value = a->getTextValue();
  141 
  142         if (a == passes ) {
  143             listener->panelChanged (EvSharpenEdgePasses,   value );
  144         } else if (a == amount) {
  145             listener->panelChanged (EvSharpenEdgeAmount, value );
  146         }
  147     }
  148 }
  149 
  150 void SharpenEdge::setBatchMode(bool batchMode)
  151 {
  152     passes->showEditedCB   ();
  153     amount->showEditedCB ();
  154 }
  155 
  156 void SharpenEdge::setDefaults(const ProcParams* defParams, const ParamsEdited* pedited)
  157 {
  158     passes->setDefault (defParams->sharpenEdge.passes);
  159     amount->setDefault (defParams->sharpenEdge.amount);
  160 
  161     if (pedited) {
  162         passes->setDefaultEditedState   (pedited->sharpenEdge.passes ? Edited : UnEdited);
  163         amount->setDefaultEditedState (pedited->sharpenEdge.amount ? Edited : UnEdited);
  164 
  165     } else {
  166         passes->setDefaultEditedState   (Irrelevant);
  167         amount->setDefaultEditedState (Irrelevant);
  168 
  169     }
  170 }
  171 
  172 void SharpenEdge::setAdjusterBehavior (bool amountadd, bool passadd)
  173 {
  174     amount->setAddMode (amountadd);
  175     passes->setAddMode (passadd);
  176 }
  177 
  178 void SharpenEdge::trimValues (ProcParams* pp)
  179 {
  180     amount->trimValue (pp->sharpenEdge.amount);
  181     passes->trimValue (pp->sharpenEdge.passes);
  182 
  183 }