1 /* -*- C++ -*- 2 * 3 * This file is part of RawTherapee. 4 * 5 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com> 6 * 7 * RawTherapee is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * RawTherapee is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #ifndef _OPTIONS_ 21 #define _OPTIONS_ 22 23 #include <set> 24 #include <gtkmm.h> 25 #include "../rtengine/rtengine.h" 26 #include <exception> 27 28 #define STARTUPDIR_CURRENT 0 29 #define STARTUPDIR_HOME 1 30 #define STARTUPDIR_CUSTOM 2 31 #define STARTUPDIR_LAST 3 32 33 #define THEMEREGEXSTR "^(.+)-GTK3-(\\d{1,2})?_(\\d{1,2})?\\.css$" 34 35 // Profile name to use for internal values' profile 36 #define DEFPROFILE_INTERNAL "Neutral" 37 // Special name for the Dynamic profile 38 #define DEFPROFILE_DYNAMIC "Dynamic" 39 // Default bundled profile name to use for Standard images 40 #define DEFPROFILE_IMG DEFPROFILE_INTERNAL 41 // Default bundled profile name to use for Raw images 42 #define DEFPROFILE_RAW DEFPROFILE_DYNAMIC 43 44 struct SaveFormat { SaveFormatSaveFormat45 SaveFormat( 46 const Glib::ustring& _format, 47 int _png_bits, 48 int _jpeg_quality, 49 int _jpeg_sub_samp, 50 int _tiff_bits, 51 bool _tiff_float, 52 bool _tiff_uncompressed, 53 bool _save_params 54 ) : 55 format(_format), 56 pngBits(_png_bits), 57 jpegQuality(_jpeg_quality), 58 jpegSubSamp(_jpeg_sub_samp), 59 tiffBits(_tiff_bits), 60 tiffFloat(_tiff_float), 61 tiffUncompressed(_tiff_uncompressed), 62 saveParams(_save_params) 63 { 64 } SaveFormatSaveFormat65 SaveFormat( 66 const Glib::ustring& _format, 67 int _png_bits, 68 int _tiff_bits, 69 bool _tiff_float 70 ) : 71 SaveFormat( 72 _format, 73 _png_bits, 74 90, 75 2, 76 _tiff_bits, 77 _tiff_float, 78 true, 79 true 80 ) 81 { 82 } SaveFormatSaveFormat83 SaveFormat() : 84 SaveFormat("jpg", 8, 8, false) 85 { 86 } 87 88 Glib::ustring format; 89 int pngBits; 90 int jpegQuality; 91 int jpegSubSamp; // 1=best compression, 3=best quality 92 int tiffBits; 93 bool tiffFloat; 94 bool tiffUncompressed; 95 bool saveParams; 96 }; 97 98 enum ThFileType {FT_Invalid = -1, FT_None = 0, FT_Raw = 1, FT_Jpeg = 2, FT_Tiff = 3, FT_Png = 4, FT_Custom = 5, FT_Tiff16 = 6, FT_Png16 = 7, FT_Custom16 = 8}; 99 enum PPLoadLocation {PLL_Cache = 0, PLL_Input = 1}; 100 enum CPBKeyType {CPBKT_TID = 0, CPBKT_NAME = 1, CPBKT_TID_NAME = 2}; 101 enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0}; 102 103 class Options { 104 public: 105 class Error: public std::exception { 106 public: Error(const Glib::ustring & msg)107 explicit Error (const Glib::ustring &msg): msg_ (msg) {} what()108 const char *what() const throw() override 109 { 110 return msg_.c_str(); 111 } get_msg()112 const Glib::ustring &get_msg() const throw() 113 { 114 return msg_; 115 } 116 117 private: 118 Glib::ustring msg_; 119 }; 120 121 private: 122 enum class DefProfError : short { 123 defProfRawMissing = 1 << 0, 124 bundledDefProfRawMissing = 1 << 1, 125 defProfImgMissing = 1 << 2, 126 bundledDefProfImgMissing = 1 << 3 127 }; 128 short defProfError; 129 Glib::ustring userProfilePath; 130 Glib::ustring globalProfilePath; 131 bool checkProfilePath (Glib::ustring &path); 132 bool checkDirPath (Glib::ustring &path, Glib::ustring errString); 133 void updatePaths(); 134 int getString (const char* src, char* dst); 135 void error (int line); 136 /** 137 * Safely reads a directory from the configuration file and only applies it 138 * to the provided destination variable if there is a non-empty string in 139 * the configuration. 140 * 141 * @param keyFile file to read configuration from 142 * @param section name of the section in the configuration file 143 * @param entryName name of the entry in the configuration file 144 * @param destination destination variable to store to 145 * @return @c true if @p destination was changed 146 */ 147 bool safeDirGet (const Glib::KeyFile& keyFile, const Glib::ustring& section, 148 const Glib::ustring& entryName, Glib::ustring& destination); 149 150 public: 151 152 enum class NavigatorUnit { 153 PERCENT, 154 R0_255, 155 R0_1, 156 _COUNT 157 }; 158 159 enum class ScopeType { 160 NONE = -1, 161 HISTOGRAM, 162 HISTOGRAM_RAW, 163 PARADE, 164 VECTORSCOPE_HC, 165 VECTORSCOPE_HS, 166 WAVEFORM 167 }; 168 169 enum class ThumbnailOrder { 170 FILENAME, 171 DATE, 172 DATE_REV, 173 MODTIME, 174 MODTIME_REV, 175 PROCTIME, 176 PROCTIME_REV 177 }; 178 179 SaveFormat saveFormat; 180 SaveFormat saveFormatBatch; 181 Glib::ustring savePathTemplate; 182 Glib::ustring savePathFolder; 183 bool saveUsePathTemplate; 184 Glib::ustring defProfRaw; 185 Glib::ustring defProfImg; 186 Glib::ustring dateFormat; 187 int adjusterMinDelay; 188 int adjusterMaxDelay; 189 int startupDir; 190 Gtk::SortType dirBrowserSortType; 191 Glib::ustring startupPath; 192 Glib::ustring profilePath; // can be an absolute or relative path; depending on this value, bundled profiles may not be found 193 bool useBundledProfiles; // only used if multiUser == true 194 Glib::ustring lastCopyMovePath; 195 Glib::ustring loadSaveProfilePath; 196 Glib::ustring lastSaveAsPath; 197 int saveAsDialogWidth; 198 int saveAsDialogHeight; 199 int toolPanelWidth; 200 int browserToolPanelWidth; 201 int browserToolPanelHeight; 202 bool browserToolPanelOpened; 203 bool browserDirPanelOpened; 204 bool editorFilmStripOpened; 205 bool inspectorDirPanelOpened; 206 int historyPanelWidth; 207 int windowX; 208 int windowY; 209 int windowWidth; 210 int windowHeight; 211 bool windowMaximized; 212 int windowMonitor; 213 int meowMonitor; 214 bool meowFullScreen; 215 bool meowMaximized; 216 int meowWidth; 217 int meowHeight; 218 int meowX; 219 int meowY; 220 int detailWindowWidth; 221 int detailWindowHeight; 222 int dirBrowserWidth; 223 int dirBrowserHeight; 224 int preferencesWidth; 225 int preferencesHeight; 226 int lastScale; 227 int panAccelFactor; 228 Glib::ustring fontFamily; // RT's main font family 229 int fontSize; // RT's main font size (units: pt) 230 Glib::ustring CPFontFamily; // ColorPicker font family 231 int CPFontSize; // ColorPicker font size (units: pt) 232 bool pseudoHiDPISupport; 233 bool fbShowDateTime; 234 bool fbShowBasicExif; 235 bool fbShowExpComp; 236 bool fbShowHidden; 237 NavigatorUnit navRGBUnit; 238 NavigatorUnit navLCHUnit; 239 bool multiUser; 240 static Glib::ustring rtdir; 241 Glib::ustring version; 242 int thumbSize; 243 int thumbSizeTab; 244 int thumbSizeQueue; 245 bool sameThumbSize; // Will use only one thumb size for the file browser and the single editor tab, and avoid recomputing them 246 ThumbnailOrder thumbnailOrder; 247 bool showHistory; 248 bool showInfo; 249 bool mainNBVertical; // main notebook vertical tabs? 250 bool showClippedHighlights; 251 bool showClippedShadows; 252 int highlightThreshold; 253 int shadowThreshold; 254 int bgcolor; 255 Glib::ustring language; 256 bool languageAutoDetect; 257 Glib::ustring theme; 258 static Glib::ustring cacheBaseDir; 259 bool autoSuffix; 260 bool forceFormatOpts; 261 int saveMethodNum; 262 bool saveParamsFile; 263 bool saveParamsCache; 264 PPLoadLocation paramsLoadLocation; 265 bool params_out_embed; 266 bool params_sidecar_strip_extension; 267 268 bool procQueueEnabled; 269 Glib::ustring gimpDir; 270 Glib::ustring psDir; 271 Glib::ustring customEditorProg; 272 Glib::ustring CPBPath; // Custom Profile Builder's path 273 CPBKeyType CPBKeys; // Custom Profile Builder's key type 274 int editorToSendTo; 275 enum EditorOutDir { 276 EDITOR_OUT_DIR_TEMP, 277 EDITOR_OUT_DIR_CURRENT, 278 EDITOR_OUT_DIR_CUSTOM 279 }; 280 EditorOutDir editor_out_dir; // output directory for "open in external editor" 281 Glib::ustring editor_custom_out_dir; 282 bool editor_float32; 283 bool editor_bypass_output_profile; 284 285 int maxThumbnailHeight; 286 int maxThumbnailWidth; 287 std::size_t maxCacheEntries; 288 int thumbInterp; // 0: nearest, 1: bilinear 289 std::vector<Glib::ustring> parseExtensions; // List containing all extensions type 290 std::vector<int> parseExtensionsEnabled; // List of bool to retain extension or not 291 std::vector<Glib::ustring> parsedExtensions; // List containing all retained extensions (lowercase) 292 std::set<std::string> parsedExtensionsSet; // Set containing all retained extensions (lowercase) 293 std::vector<int> tpOpen; 294 bool autoSaveTpOpen; 295 rtengine::Settings rtSettings; 296 297 std::vector<Glib::ustring> favoriteDirs; 298 bool internalThumbIfUntouched; 299 bool overwriteOutputFile; 300 301 std::vector<double> thumbnailZoomRatios; 302 bool overlayedFileNames; 303 bool filmStripOverlayedFileNames; 304 bool showFileNames; 305 bool filmStripShowFileNames; 306 bool tabbedUI; 307 bool rememberZoomAndPan; 308 int multiDisplayMode; // 0=none, 1=Edit panels on other display 309 std::vector<double> cutOverlayBrush; // Red;Green;Blue;Alpha , all ranging 0..1 310 std::vector<double> navGuideBrush; // Red;Green;Blue;Alpha , all ranging 0..1 311 312 Glib::ustring sndBatchQueueDone; 313 Glib::ustring sndLngEditProcDone; 314 double sndLngEditProcDoneSecs; // Minimum processing time seconds till the sound is played 315 bool sndEnable; 316 317 int histogramPosition; // 0=disabled, 1=left pane, 2=right pane 318 bool histogramRed; 319 bool histogramGreen; 320 bool histogramBlue; 321 bool histogramLuma; 322 bool histogramChroma; 323 //bool histogramRAW; 324 bool histogramBar; 325 int histogramHeight; 326 int histogramDrawMode; 327 double histogram_scaling_factor; 328 ScopeType histogramScopeType; 329 bool histogramShowOptionButtons; 330 float histogramTraceBrightness; 331 332 bool FileBrowserToolbarSingleRow; 333 bool hideTPVScrollbar; 334 int whiteBalanceSpotSize; 335 int curvebboxpos; // 0=above, 1=right, 2=below, 3=left 336 337 bool showFilmStripToolBar; 338 339 // cropping options 340 int cropPPI; 341 342 // Performance options 343 Glib::ustring clutsDir; 344 int rgbDenoiseThreadLimit; // maximum number of threads for the denoising tool ; 0 = use the maximum available 345 int maxInspectorBuffers; // maximum number of buffers (i.e. images) for the Inspector feature 346 int inspectorDelay; 347 int clutCacheSize; 348 int thumb_update_thread_limit; 349 bool thumb_delay_update; 350 bool thumb_lazy_caching; 351 bool filledProfile; // Used as reminder for the ProfilePanel "mode" 352 prevdemo_t prevdemo; // Demosaicing method used for the <100% preview 353 bool serializeTiffRead; 354 bool denoiseZoomedOut; 355 enum WBPreviewMode { 356 WB_AFTER, // apply WB after demosaicing (faster) 357 WB_BEFORE, // always apply WB before demosaicing 358 WB_BEFORE_HIGH_DETAIL // apply WB before demosaicing only at 1:1 359 }; 360 WBPreviewMode wb_preview_mode; 361 362 bool menuGroupRank; 363 bool menuGroupLabel; 364 bool menuGroupFileOperations; 365 bool menuGroupProfileOperations; 366 bool menuGroupExtProg; 367 368 // ICC Profile Creator 369 Glib::ustring ICCPC_primariesPreset; 370 double ICCPC_redPrimaryX; 371 double ICCPC_redPrimaryY; 372 double ICCPC_greenPrimaryX; 373 double ICCPC_greenPrimaryY; 374 double ICCPC_bluePrimaryX; 375 double ICCPC_bluePrimaryY; 376 Glib::ustring ICCPC_gammaPreset; 377 double ICCPC_gamma; 378 double ICCPC_slope; 379 Glib::ustring ICCPC_profileVersion; 380 Glib::ustring ICCPC_illuminant; 381 Glib::ustring ICCPC_description; 382 Glib::ustring ICCPC_copyright; 383 bool ICCPC_appendParamsToDesc; 384 385 // fast export options 386 bool fastexport_bypass_sharpening; 387 bool fastexport_bypass_defringe; 388 bool fastexport_bypass_dirpyrDenoise; 389 bool fastexport_bypass_localContrast; 390 Glib::ustring fastexport_raw_bayer_method; 391 bool fastexport_bypass_raw_bayer_dcb_iterations; 392 bool fastexport_bypass_raw_bayer_dcb_enhance; 393 bool fastexport_bypass_raw_bayer_lmmse_iterations; 394 bool fastexport_bypass_raw_bayer_linenoise; 395 bool fastexport_bypass_raw_bayer_greenthresh; 396 Glib::ustring fastexport_raw_xtrans_method; 397 bool fastexport_bypass_raw_ccSteps; 398 bool fastexport_bypass_raw_ca; 399 bool fastexport_bypass_raw_df; 400 bool fastexport_bypass_raw_ff; 401 Glib::ustring fastexport_icm_input_profile; 402 Glib::ustring fastexport_icm_working_profile; 403 Glib::ustring fastexport_icm_output_profile; 404 rtengine::RenderingIntent fastexport_icm_outputIntent; 405 bool fastexport_icm_outputBPC; 406 Glib::ustring fastexport_icm_custom_output_profile; 407 bool fastexport_resize_enabled; 408 double fastexport_resize_scale; 409 Glib::ustring fastexport_resize_appliesTo; 410 int fastexport_resize_dataspec; 411 int fastexport_resize_width; 412 int fastexport_resize_height; 413 bool fastexport_use_fast_pipeline; 414 415 std::vector<Glib::ustring> favorites; 416 // Dialog settings 417 Glib::ustring lastIccDir; 418 Glib::ustring lastDarkframeDir; 419 Glib::ustring lastFlatfieldDir; 420 Glib::ustring lastRgbCurvesDir; 421 Glib::ustring lastLabCurvesDir; 422 Glib::ustring lastPFCurvesDir; 423 Glib::ustring lastHsvCurvesDir; 424 Glib::ustring lastToneCurvesDir; 425 Glib::ustring lastColorToningCurvesDir; 426 Glib::ustring lastProfilingReferenceDir; 427 Glib::ustring lastLensProfileDir; 428 Glib::ustring lastICCProfCreatorDir; 429 bool gimpPluginShowInfoDialog; 430 431 size_t maxRecentFolders; // max. number of recent folders stored in options file 432 std::vector<Glib::ustring> recentFolders; // List containing all recent folders 433 434 enum class ThumbnailRatingMode { 435 PROCPARAMS, // store ranking and color labels in procparams sidecars 436 XMP // store in FILENAME.xmp for FILENAME.raw 437 }; 438 ThumbnailRatingMode thumbnail_rating_mode; 439 440 bool thumbnail_inspector_zoom_fit; 441 bool thumbnail_inspector_show_info; 442 bool thumbnail_inspector_enable_cms; 443 int browser_width_for_inspector; 444 bool thumbnail_inspector_show_histogram; 445 bool thumbnail_inspector_hover; 446 447 Glib::ustring batch_queue_profile_path; 448 bool batch_queue_use_profile; 449 450 bool toolpanels_disable; 451 bool adjuster_force_linear; 452 453 int error_message_duration; // in milliseconds 454 int max_error_messages; 455 456 // maps a IRE value to a false color 457 // taken from 458 // https://www.premiumbeat.com/blog/how-to-use-false-color-nail-skin-tone-exposure/ 459 std::map<int, std::string> falseColorsMap; 460 461 struct RenameOptions { 462 Glib::ustring pattern; 463 Glib::ustring sidecars; 464 int name_norm; 465 int ext_norm; 466 bool allow_whitespace; 467 int on_existing; 468 int progressive_number; 469 470 RenameOptions(); 471 }; 472 RenameOptions renaming; 473 474 int sidecar_autosave_interval; // in seconds 475 476 Options(); 477 478 Options *copyFrom(Options *other); 479 void filterOutParsedExtensions(); 480 void setDefaults(); 481 void readFromFile(Glib::ustring fname); 482 void saveToFile(Glib::ustring fname); 483 static void load(bool lightweight=false, int verbose=-1); 484 static void save(); 485 486 // if multiUser=false, send back the global profile path 487 Glib::ustring getPreferredProfilePath(); 488 Glib::ustring getUserProfilePath(); 489 Glib::ustring getGlobalProfilePath(); 490 Glib::ustring findProfilePath (Glib::ustring &profName); 491 bool is_parse_extention(Glib::ustring fname); 492 bool has_retained_extention(const Glib::ustring& fname); 493 bool is_new_version(); 494 bool is_extention_enabled(const Glib::ustring& ext); 495 bool is_defProfRawMissing(); 496 bool is_bundledDefProfRawMissing(); 497 bool is_defProfImgMissing(); 498 bool is_bundledDefProfImgMissing(); 499 void setDefProfRawMissing(bool value); 500 void setBundledDefProfRawMissing(bool value); 501 void setDefProfImgMissing(bool value); 502 void setBundledDefProfImgMissing(bool value); 503 static Glib::ustring getICCProfileCopyright(); 504 505 Glib::ustring getParamFile(const Glib::ustring &fname); 506 Glib::ustring getXmpSidecarFile(const Glib::ustring &fname); 507 }; 508 509 extern Options options; 510 extern Glib::ustring argv0; 511 extern Glib::ustring argv1; 512 extern bool simpleEditor; 513 extern bool gimpPlugin; 514 extern bool remote; 515 extern Glib::ustring versionString; 516 extern Glib::ustring paramFileExtension; 517 518 #endif 519