1 /*******************************************************************************
2 **
3 ** Photivo
4 **
5 ** Copyright (C) YEAR NAME <EMAIL>
6 **
7 ** This file is part of Photivo.
8 **
9 ** Photivo is free software: you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License version 3
11 ** as published by the Free Software Foundation.
12 **
13 ** Photivo is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with Photivo.  If not, see <http://www.gnu.org/licenses/>.
20 **
21 *******************************************************************************/
22 
23 #include "ptFilter_$FilterName$.h"
24 /*** Uncomment following line when the filter has a .ui file. ***/
25 //#include "ui_ptFilter_$FilterName$.h"
26 #include "ptCfgItem.h"
27 #include "../ptImage.h"
28 
29 //------------------------------------------------------------------------------
30 
31 const QString C$FilterName$Id = "$FilterName$";
32 
33 const QString CCfgItem1     = "CfgItem1";
34 const QString CCfgItem2     = "CfgItem2";
35 const QString CCfgItem3     = "CfgItem3";
36 
37 //------------------------------------------------------------------------------
38 
ptFilter_$FilterName$()39 ptFilter_$FilterName$::ptFilter_$FilterName$():
40   ptFilterBase()
41 {
42   /*** Uncomment as appropriate. ***/
43 //  FIsSlow = true;
44 //  FHelpUri = "http://photivo.org/something";
45   this->internalInit();
46 }
47 
48 //------------------------------------------------------------------------------
49 
create$FilterName$()50 ptFilterBase* ptFilter_$FilterName$::create$FilterName$() {
51   auto instance         = new ptFilter_$FilterName$;
52   instance->FFilterName = C$FilterName$Id;
53   instance->FCaption    = tr("GUI toolbox header");
54   return instance;
55 }
56 
57 //------------------------------------------------------------------------------
58 
doDefineControls()59 void ptFilter_$FilterName$::doDefineControls() {
60   /***
61     * Use short names that indicate what a filter/setting *does*. Be especially careful
62       when including probably obscure names of specific algorithms
63       (Good: “Wiener sharpen”. Bad: “Wiener” or “Wiener filter”).
64     * Use sentence capitalization (“Upper limit”, not “Upper Limit”)
65     * Tooltips shall amend the caption with additional and/or more accurate information
66       about a setting. *Do not* duplicate the caption! If a tooltip is unnecessary or you
67       cannot think of a great one at the moment, leave it empty.
68    ***/
69   /***
70     Each entry in a combobox needs:
71         1) a text that is displayed in the GUI
72         2) an associated integer value, preferrably an entry from an enum class
73            (Most of those are located in ptConstants.cpp. Photivo uses groups of
74            "const short" variables for historical reasons. They are deprecated
75            for new constants groups! Instead use C++11 enum classes or at least
76            plain old-style enums. The pseudo code below shows the enum class
77            version.)
78         3) a string that represents the entry as a value in PTS settings files
79   ***/
80   const ptCfgItem::TComboEntryList comboboxConfig({
81     {tr("Combo entry 1"),   static_cast<int>(enumValue1),   "ValueForPTS1"},
82     {tr("Combo entry 2"),   static_cast<int>(enumValue2),   "ValueForPTS2"},
83     {tr("Combo entry 3"),   static_cast<int>(enumValue3),   "ValueForPTS3"},
84   });
85 
86   FConfig.initStores(TCfgItemList()                                              //--- Combo: list of entries               ---//
87                                                                                  //--- Check: not available                 ---//
88     //            Id                       Type                      Default     Min           Max           Step        Decimals, commonConnect, storeable, caption, tooltip
89     << ptCfgItem({CCfgItem1,               ptCfgItem::Check,         false,                                                        true, true, tr("Name in GUI"), tr("Tooltip")})
90     << ptCfgItem({CCfgItem2,               ptCfgItem::Slider,        0.2,        0.0,          1.0,          0.05,       2,        true, true, tr("Name in GUI"), tr("Tooltip")})
91     << ptCfgItem({CCfgItem3,               ptCfgItem::Combo,         constant_1, comboboxConfig,                                   true, true, tr("Name in GUI"), tr("Tooltip")})
92   );
93 }
94 
95 //------------------------------------------------------------------------------
96 
doCheckHasActiveCfg()97 bool ptFilter_$FilterName$::doCheckHasActiveCfg() {
98   return !qFuzzyIsNull(FConfig.value(CCfgItem2).toDouble());
99 }
100 
101 //------------------------------------------------------------------------------
102 
doRunFilter(ptImage * AImage)103 void ptFilter_$FilterName$::doRunFilter(ptImage* AImage) {
104   AImage->toLab();
105   AImage->$FilterName$(FConfig.value(CCfgItem1).toBool(),
106                      FConfig.value(CCfgItem2).toDouble(),
107                      static_cast<TSomeEnumClass>(FConfig.value(CCfgItem3).toInt()) );
108 }
109 
110 //------------------------------------------------------------------------------
111 
112 /*** Uncomment following method when the filter has a .ui file. ***/
113 //QWidget* ptFilter_$FilterName$::doCreateGui() {
114 //  auto guiBody = new QWidget;
115 //  Ui_$FilterName$Form form;
116 
117 //  form.setupUi(guiBody);
118 //  this->initDesignerGui(guiBody);
119 
120 //  return guiBody;
121 //}
122 
123 //------------------------------------------------------------------------------
124 
125 RegisterHelper $FilterName$Register(&ptFilter_$FilterName$::create$FilterName$, C$FilterName$Id);
126 
127 //------------------------------------------------------------------------------
128