rawTherapee/rtgui/controlspotpanel.h
Desmis 1e4f41bc05
LA - new tool - Color appearance (Cam16 & JzCzHz) (#6377)
* Gui improvments

* Several improvments GUI Jz algo

* Change function La for lightess Jz

* SH jzazbz first

* enable Jz SH

* Clean code

* Disabled Munsell correction when Jz

* Change tooltip and Cam16 Munsell

* GUI for CzHz and HzHz curves

* Enable curves Hz(Hz) Cz(Hz)

* Improve Cz chroma

* Jz100 reference refine

* Change limit Jz100

* Refine link between jz100 and peak adaptation

* Improve GUI

* Various improvment PQ PU gamut

* Change defaults settings

* forgotten PL in gamutjz

* Small changes and comment

* Change gamujz parameter

* disabled gamut Jz too slow

* Jzazbz curve Jz(Hz)

* reenable gamutjz

* small changes

* Change tooltip

* Change labels tooltips

* Jzazbz only on advanced mode

* GUI improvments

* Change tooltip

* Change default values and tooltip

* Added tooltip Jz

* Disabled Jz gamut

* Change gamma color and light - remove exposure

* Gamma for exposure and DR

* gamma Sharp

* Gamma vibrance

* gamma optimizations

* Change tooltips

* Optimization PQ

* LA GUI for tone curve Ciecam

* LA ciecam Enable curve lightness - brightness

* LA ciecam GUI color curve

* LA ciecam enable color curve

* Change tooltip and default values

* Enable Jz curve

* Enable Cz(Cz) curve

* Enable Cz(Jz) curve

* Added Log encoding to ciecam

* Improvment algorithm remapping

* Reenable forgotten listener logencodchanged

* Change Jz tooltips

* Reenable dynamic range and exposure

* First change GUI auto ciecam

* 2nd fixed ciecam auto

* Improve GUI maskbackground curves

* Enable activspot for la ciecam

* set sensitive sliders La ciecam when auto scene conditions

* Change internal calculations see comments

* Checcbox ForceJz to 1

* Change tool position - change order CAM model

* Expander for Jzczhz

* Remove unused code

* GUI changes

* Change labels CAM16 Jzazbz

* Change slider brightness parameters

* improvment SH jz

* Some changes to brightness Jz

* Fixed scene conditions auto

* Renable forgotten change

* Prepare calculation Zcam

* Prepare Iz for zcam

* First GUI Zcam

* Improve GUI Zcam

* Calculate Qz white - brightness of the reference white

* Prepare for PQ - eventually

* Init LUT ZCAMBrightCurveJz and ZCAMBrightCurveQz

* prepare zcam achromatic variables

* First zcam

* Change algo step 5 zcam

* Another change original algo

* Another change to original algo

* first colorfullness

* Fixed bad behavior threshold and change c c2 surround parameters

* added saturation Zcam

* Change parameters surround

* Enable chroma zcam

* change chroma and lightness formula

* disable OMP for 2nd process Zcam

* Improvment zcam for some high-light images

* Change parameters overflow zcam

* Change parmeters high datas

* another change to retrieve...

* Simplify code matrix conversion xyz-jzazbz

* Adjust internam parameters zcam

* Change some parameters - clean code

* Enable PQCam16

* Enable PQ Cam16 - disable ZCAM

* remove warning compilation message

* Change GUI jzczhz

* Fixed bad behavior remaping jz

* Remove forgotten parameter - hide Jz100 - PU adaptation- chnage tooltips

* Another change to chroma parameter

* Small changes

* If verbose display in console Cam16 informations

* If verbose display in console source saturation colorfullness

* Change to La calculation for ciecam

* Change GUI cam16 - jzczhz - remove cam16 and jzczhz

* Disable exposure compensation to calculate La for all Ciecam and Log encoding

* Change label Cam16 and jzczhz

* Improve GUI Jz

* Other improvment GUI Jz Cam16

* verify nan Jz and ciecam matrix to avoid crash

* Enable La manual for Jz to change PU-adaptation

* Improve calculation to avoid crash Jz and Cam16 matrix

* Fixed crash with local contrast in cam16

* Clean code loccont

* First step GUI Cie mask

* GUI part 2 - Cie

* Build cieMask

* Gui part 3 cie

* Valid llcieMask

* Valid llcieMask

* Pass GUI curves parameters to iplocallab.cc

* 2nd pass parameters from GUI to iplocallab.cc

* Init first functions modifications

* Add expander to cam16 adjustments

* First test mask cie

* Various improvment GUI - tooltips - process

* Take into account Yb cam16 for Jz - reenable warm-cool

* Surround source Cam16 before Jz

* Improve GUI and process

* Fixed bug and bad behavior last commit

* Fixed bug chroma mask - improve GUI - Relative luminance for Jz

* Increase sensitivity mask chroma

* Improve Jz with saturation Z - improve GUI Jzczhz

* Small code improvment

* Another change mask C and enable mask for Cam16 and Jz

* Some changes

* Enable denoise chroma mask

* Small change LIM01 normchromar

* Enable Zcam matrix

* Improve chroma curves...mask and boudaries

* take into account recursive slider in settings

* Change tooltip - improvment to C curve (denoise C - best value in curves - etc.) - remove Zcam button

* Change tooltips

* First part GUI - local contrast wavelet Jz

* Passed parameters GUI local contrast wav jz to rtengine

* save config wavelet jz

* first try wavelet local contrast Jz

* Add tooltips

* Simplify code wavelet local contrast

* take into account edge wavelet performance in Wavelet Jz

* Fixed overflow jz when usig botth contradt and wavelt local jz contrast

* Adapt size winGdiHandles in filepanel to avoid crash in Windows multieditor

* First GUI part Clarity wavelet Jz

* First try wavelet Jz Cz clarity

* Added tooltips

* Small change to enable wavelet jz

* Disabled (commented) all Zcam code

* Improve behavior when SH local-contrast and Clarity are use both

* Change limit PQremap jz

* Clean and optimize code

* Reenable mjjz

* Change settings guidedfilter wavelet Jz

* Fixed crash when revory based on lum mask negative

* Change tooltip

* Fixed ad behavior auto mean and absolute luminance

* Remove warning in console

* Fixed bad behavior auto Log encoding - bad behavior curves L(H) Jz

* Fixed another bad behavior - reenable curves color and light L(H) C(H)

* first transposition Lab Jz for curves H

* Change mask boundary for Jz

* Various improvment to H curves Jz

* Add amountchrom to Hcurve Color and Light

* Improve gray boundary curves behavior

* reenable Jz curve H(H) - soft radius

* Improve guidefilter Jz H curve

* Threshold chroma Jz(Hz)

* Enable guidedfilter chroma curve H

* improve GUI curves Hz

* Checkbutton chroma for curve Jz(Hz)

* Change event selectspot

* Clean and small optimization code

* Another clean code

* Change calculation Hz references for curves Hz

* Clean code

* Various changes to GF and GUI

* Another change to Chroma for Jz(H)

* Change GUI sensitive Jz100 adapdjzcie

* Improve code for Jz100

* Change default value skin-protection to 0 instead of 50

* Clean code

* Remove BENCHFUN for ciecam

* small correction to huejz_to_huehsv2 conversion

* Added missing plum parameter for jch2xyz_ciecam02float

* another small change to huejz_to_huehsv2

* Improvment to huelab_to_huehsv2 and some double functions

* Fixed warning hide parameters in lgtm-com

* Fixed ? Missing retuen statement in lgtm-com

* Change behavior Log encoding whith PQ Cam16

* Small improvment to Jz PU adaptation

* Added forgoten to_one for Cz slider

* Replace 0.707... by RT_SQRT1_2 - change some settings chroma

* Improvment to getAutoLogloc

* Fixed crash with array in getAutoLogloc

* First try Jz Log encoding

* Forgotten Cz

* Various improvment GUI setlogscale - Jz log encoding

* Change labels tooltips Jz log

* Change wrong clipcz value

* Change tooltip auto scene conditions

* Fixed bad behavior blackevjz whiteevjz

* Small improvment to LA Log encoding std

* Avoid bad behavior Jz log when enable Relative luminance

* Change sourcegray jz calculation

* Revert last change

* Clean and comment code

* Review tooltips thanks to Wayne - harmonize response La log encoding and Jz Log encoding

* Always force Dynamic Range evaluation in full frame mode for Jz log encoding

* Remove unused code

* Small optimizations sigmoid Cam16 and Jz

* Comment code

* Change parameters deltaE for HDR

* Various improvment to Jz - La - sigmoid - log encoding

* Basic support for Sony ILCE-7M4 in camconst.json

* German translation Spot Removal (#6388)

* Filmnegative German translation (#6389)

* (Temporarily) disable `ftree-loop-vectorize` for GCC 11 because of #6384

* Added BlacEv WhiteEv to sigmoidJz

* Improve GUI for BlackEv WhiteEv

* Change location SigmoidJz in Iplocallab

* Improvment GUI and sensitivity sliders strength sigmoid

* Change labels

Co-authored-by: Thanatomanic <6567747+Thanatomanic@users.noreply.github.com>
Co-authored-by: Anna <simonanna@gmx.net>
2021-12-21 07:43:59 +01:00

462 lines
14 KiB
C++

/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
* 2018 Pierre Cabrera <pierre.cab@gmail.com>
*/
#ifndef _CONTROLSPOTPANEL_H_
#define _CONTROLSPOTPANEL_H_
#include "../rtengine/coord.h"
#include "editcallbacks.h"
#include "threadutils.h"
#include "toolpanel.h"
#include "adjuster.h"
class ControlPanelListener
{
public:
ControlPanelListener() {};
virtual ~ControlPanelListener() {};
virtual void resetToolMaskView() = 0;
virtual void spotNameChanged(const Glib::ustring &newName) = 0;
};
class ControlSpotPanel:
public ToolParamBlock,
public AdjusterListener,
public EditSubscriber,
public FoldableToolPanel
{
public:
/**
* A SpotRow structure allows exchanges from and to ControlSpotClass
*/
struct SpotRow {
Glib::ustring name;
bool isvisible;
int prevMethod; // 0 = Normal, 1 = Excluding
int shape; // 0 = Ellipse, 1 = Rectangle
int spotMethod; // 0 = Normal, 1 = Excluding
int sensiexclu;
int structexclu;
int shapeMethod; // 0 = Independent (mouse), 1 = Symmetrical (mouse), 2 = Independent (mouse + sliders), 3 = Symmetrical (mouse + sliders)
int locX;
int locXL;
int locY;
int locYT;
int centerX;
int centerY;
int circrad;
int qualityMethod; // 0 = Standard, 1 = Enhanced, 2 = Enhanced + chroma denoise
double transit;
double transitweak;
double transitgrad;
double feather;
double struc;
double thresh;
double iter;
double balan;
double balanh;
double colorde;
double colorscope;
double avoidrad;
bool hishow;
bool activ;
bool avoid;
bool avoidmun;
bool blwh;
bool recurs;
bool laplac;
bool deltae;
int scopemask;
double denoichmask;
bool shortc;
int lumask;
bool savrest;
int complexMethod; // 0 = Simple, 1 = Moderate, 2 = all
int wavMethod; // 0 = D2, 1 = D4, 2 = D6, 3 = D10, 4 = D14
};
/**
* An event type enumeration allows exchanges of spot panel event type from and to ControlSpotClass
*/
enum eventType {
None = 0,
SpotCreation = 1,
SpotDeletion = 2,
SpotSelection = 3,
SpotDuplication = 4,
SpotAllVisibilityChanged = 5
};
// Constructor and management functions
/**
* Default constructor of ControlSpotPanel class
*/
ControlSpotPanel();
/**
* Destructor of ControlSpotPanel class
*/
~ControlSpotPanel();
/**
* Implementation of setEditProvider function of toolpanel.h
*
* @param provider The EditDataProvider to be linked to the panel to manage curves
*/
void setEditProvider(EditDataProvider* provider) override;
/**
* Setter for controlPanelListener
*
* @param cpl The ControlPanelListener to be linked to the panel
*/
void setControlPanelListener(ControlPanelListener* cpl)
{
controlPanelListener = cpl;
}
/**
* Getter of the event type raised by this panel
*
* @return The raised event type (refer to eventType enumeration)
*/
int getEventType();
/**
* Getter of params of associated spot
*
* @param index The spot index to get params
* @return A SpotRow structure containing params of associated spot
*/
SpotRow* getSpot(const int index);
/**
* Getter of spots number
*
* @return The number of spots in panel
*/
int getSpotNumber();
/**
* Getter of selected spot index
*
* @return The index of selected spot in treeview (return -1 if no selected spot)
*/
int getSelectedSpot();
/**
* Setter of selected spot
*
* @param index The index of spot to be selected
* @return True if a spot corresponding to the index has been selected
*/
bool setSelectedSpot(const int index);
/**
* Setter for mask preview active indicator
*
* @param ind True is mask preview is active
*/
void setMaskPrevActive(bool ind)
{
maskPrevActive = ind;
}
/**
* Getter for deltaE preview active
*
* @return True if preview deltaE is active
*/
bool isDeltaEPrevActive();
/**
* Reset deltaE preview active state
*/
void resetDeltaEPreview();
// Control spot creation functions
/**
* Add a new spot (and its associated curve)
*
* @param newSpot A SpotRow structure containing new spot params
*/
void addControlSpot(SpotRow* newSpot);
// Control spot delete function
/**
* Delete a spot (and its associated curve)
*
* @param id The id of the spot to be deleted
*/
void deleteControlSpot(const int index);
// Panel widgets management functions
/**
* Implementation of setDefaults function of toolpanel.h
*
* @param defParams ProcParams containing default values to set to the adjusters
* @param pedited ParamsEdited containing default state values to set to the adjusters (not used because batch mode is deactivated for Locallab)
*/
void setDefaults(const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr) override;
/**
* Enable or disable the interactions with panel widgets
*
* @param cond Condition to enable interactions
*/
void setParamEditable(bool cond);
/**
* Reset expander collapse state to default one
*/
void setDefaultExpanderVisibility();
// Batch mode management
// Note: Batch mode is deactivated for Locallab
private:
// Cell renderer
void render_name(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void render_isvisible(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter);
void on_button_add();
void on_button_delete();
void on_button_duplicate();
void on_button_rename();
bool on_button_visibility(GdkEventButton* event);
bool blockTreeviewSearch(GdkEventKey* event);
bool onSpotSelectionEvent(GdkEventButton* event);
void load_ControlSpot_param();
void controlspotChanged();
void prevMethodChanged();
void shapeChanged();
void spotMethodChanged();
void shapeMethodChanged();
void qualityMethodChanged();
void complexMethodChanged();
void wavMethodChanged();
void updateParamVisibility();
void adjusterChanged(Adjuster* a, double newval) override;
void hishowChanged();
void activChanged();
void avoidChanged();
void avoidmunChanged();
void blwhChanged();
void recursChanged();
void laplacChanged();
void deltaeChanged();
void shortcChanged();
void savrestChanged();
void previewChanged();
void disableParamlistener(bool cond);
void addControlSpotCurve(Gtk::TreeModel::Row& row);
void updateControlSpotCurve(const Gtk::TreeModel::Row& row);
void deleteControlSpotCurve(Gtk::TreeModel::Row& row);
void updateCurveOpacity(const Gtk::TreeModel::Row& selectedRow);
CursorShape getCursor(int objectID, int xPos, int yPos) const override;
bool mouseOver(int modifierKey) override;
bool button1Pressed(int modifierKey) override;
bool button1Released() override;
bool drag1(int modifierKey) override;
using ToolPanel::setDefaults;
class ControlSpots:
public Gtk::TreeModel::ColumnRecord
{
public:
ControlSpots();
Gtk::TreeModelColumn<bool> mouseover; // Used to manage spot enlightening when mouse over
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn<bool> isvisible;
Gtk::TreeModelColumn<int> curveid; // Associated curve id
Gtk::TreeModelColumn<int> prevMethod; // 0 = hide, 1 = show
Gtk::TreeModelColumn<int> shape; // 0 = Ellipse, 1 = Rectangle
Gtk::TreeModelColumn<int> spotMethod; // 0 = Normal, 1 = Excluding
Gtk::TreeModelColumn<int> sensiexclu;
Gtk::TreeModelColumn<int> structexclu;
Gtk::TreeModelColumn<int> shapeMethod; // 0 = Independent (mouse), 1 = Symmetrical (mouse), 2 = Independent (mouse + sliders), 3 = Symmetrical (mouse + sliders)
Gtk::TreeModelColumn<int> locX;
Gtk::TreeModelColumn<int> locXL;
Gtk::TreeModelColumn<int> locY;
Gtk::TreeModelColumn<int> locYT;
Gtk::TreeModelColumn<int> centerX;
Gtk::TreeModelColumn<int> centerY;
Gtk::TreeModelColumn<int> circrad;
Gtk::TreeModelColumn<int> qualityMethod; // 0 = Standard, 1 = Enhanced, 2 = Enhanced + chroma denoise
Gtk::TreeModelColumn<double> transit;
Gtk::TreeModelColumn<double> transitweak;
Gtk::TreeModelColumn<double> transitgrad;
Gtk::TreeModelColumn<double> feather;
Gtk::TreeModelColumn<double> struc;
Gtk::TreeModelColumn<double> thresh;
Gtk::TreeModelColumn<double> iter;
Gtk::TreeModelColumn<double> balan;
Gtk::TreeModelColumn<double> balanh;
Gtk::TreeModelColumn<double> colorde;
Gtk::TreeModelColumn<double> colorscope;
Gtk::TreeModelColumn<double> avoidrad;
Gtk::TreeModelColumn<bool> hishow;
Gtk::TreeModelColumn<bool> activ;
Gtk::TreeModelColumn<bool> avoid;
Gtk::TreeModelColumn<bool> avoidmun;
Gtk::TreeModelColumn<bool> blwh;
Gtk::TreeModelColumn<bool> recurs;
Gtk::TreeModelColumn<bool> laplac;
Gtk::TreeModelColumn<bool> deltae;
Gtk::TreeModelColumn<int> scopemask;
Gtk::TreeModelColumn<int> denoichmask;
Gtk::TreeModelColumn<bool> shortc;
Gtk::TreeModelColumn<int> lumask;
Gtk::TreeModelColumn<bool> savrest;
Gtk::TreeModelColumn<int> complexMethod; // 0 = Simple, 1 = mod, 2 = all
Gtk::TreeModelColumn<int> wavMethod; // 0 = D2, 1 = D4, 2 = D6, 3 = D10, 4 = D14
};
class RenameDialog:
public Gtk::Dialog
{
public:
enum DialogButton {
OkButton = 1,
CancelButton = 2
};
RenameDialog(const Glib::ustring &actualname, Gtk::Window &parent);
Glib::ustring get_new_name();
private:
Gtk::Entry* const newname_;
};
ControlSpots spots_;
// Child widgets
Gtk::ScrolledWindow* const scrolledwindow_;
Gtk::TreeView* const treeview_;
sigc::connection treeviewconn_;
Glib::RefPtr<Gtk::ListStore> treemodel_;
Gtk::Button* const button_add_;
sigc::connection buttonaddconn_;
Gtk::Button* const button_delete_;
sigc::connection buttondeleteconn_;
Gtk::Button* const button_duplicate_;
sigc::connection buttonduplicateconn_;
Gtk::Button* const button_rename_;
sigc::connection buttonrenameconn_;
Gtk::Button* const button_visibility_;
sigc::connection buttonvisibilityconn_;
MyComboBoxText* const prevMethod_;
sigc::connection prevMethodconn_;
MyComboBoxText* const shape_;
sigc::connection shapeconn_;
MyComboBoxText* const spotMethod_;
sigc::connection spotMethodconn_;
MyComboBoxText* const shapeMethod_;
sigc::connection shapeMethodconn_;
MyComboBoxText* const qualityMethod_;
sigc::connection qualityMethodconn_;
MyComboBoxText* const complexMethod_;
sigc::connection complexMethodconn_;
MyComboBoxText* const wavMethod_;
sigc::connection wavMethodconn_;
Adjuster* const sensiexclu_;
Adjuster* const structexclu_;
Adjuster* const locX_;
Adjuster* const locXL_;
Adjuster* const locY_;
Adjuster* const locYT_;
Adjuster* const centerX_;
Adjuster* const centerY_;
Adjuster* const circrad_;
Adjuster* const transit_;
Adjuster* const transitweak_;
Adjuster* const transitgrad_;
Adjuster* const feather_;
Adjuster* const struc_;
Adjuster* const thresh_;
Adjuster* const iter_;
Adjuster* const balan_;
Adjuster* const balanh_;
Adjuster* const colorde_;
Adjuster* const colorscope_;
Adjuster* const avoidrad_;
Adjuster* const scopemask_;
Adjuster* const denoichmask_;
Adjuster* const lumask_;
Gtk::CheckButton* const hishow_;
sigc::connection hishowconn_;
Gtk::CheckButton* const activ_;
sigc::connection activConn_;
Gtk::CheckButton* const avoid_;
sigc::connection avoidConn_;
Gtk::CheckButton* const avoidmun_;
sigc::connection avoidmunConn_;
Gtk::CheckButton* const blwh_;
sigc::connection blwhConn_;
Gtk::CheckButton* const recurs_;
sigc::connection recursConn_;
Gtk::CheckButton* const laplac_;
sigc::connection laplacConn_;
Gtk::CheckButton* const deltae_;
sigc::connection deltaeConn_;
Gtk::CheckButton* const shortc_;
sigc::connection shortcConn_;
Gtk::CheckButton* const savrest_;
sigc::connection savrestConn_;
MyExpander* const expTransGrad_;
MyExpander* const expShapeDetect_;
MyExpander* const expSpecCases_;
MyExpander* const expMaskMerge_;
Gtk::ToggleButton* const preview_;
sigc::connection previewConn_;
Gtk::Box* const ctboxshape;
Gtk::Box* const ctboxshapemethod;
// Internal variables
ControlPanelListener* controlPanelListener;
int lastObject_;
rtengine::Coord lastCoord_;
bool nbSpotChanged_;
bool selSpotChanged_;
bool nameChanged_;
bool visibilityChanged_;
int eventType; // 0 = No event, 1 = Spot creation event, 2 = Spot deletion event, 3 = Spot selection event, 4 = Spot duplication event
Gtk::Frame* const excluFrame;
bool maskPrevActive;
// Row background color
Gdk::RGBA colorMouseover, colorNominal, colorMouseovertext;
// Treeview mutex
MyMutex mTreeview;
};
#endif // _CONTROLSPOTPANEL_H_