Engauge Digitizer  2
DlgSettingsColorFilter.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef DLG_SETTINGS_COLOR_FILTER_H
8 #define DLG_SETTINGS_COLOR_FILTER_H
9 
10 #include "ColorFilterMode.h"
11 #include "DlgSettingsAbstractBase.h"
12 #include <QColor>
13 #include <QImage>
14 #include <QPixmap>
15 
16 class DlgFilterThread;
18 class QComboBox;
19 class QGraphicsScene;
20 class QGridLayout;
21 class QLabel;
22 class QRadioButton;
23 class ViewPreview;
24 class ViewProfile;
25 class ViewProfileDivider;
26 class ViewProfileScale;
27 
30 {
31  Q_OBJECT;
32 
33 public:
36  virtual ~DlgSettingsColorFilter();
37 
38  virtual void createOptionalSaveDefault (QHBoxLayout *layout);
39  virtual QWidget *createSubPanel ();
40  virtual void load (CmdMediator &cmdMediator);
41 
42 public slots:
44  void slotTransferPiece (int xLeft,
45  QImage image);
46 
47 signals:
49  void signalApplyFilter (ColorFilterMode colorFilterMode,
50  double low,
51  double high);
52 
53 private slots:
54  void slotCurveName(const QString &curveName);
55  void slotDividerHigh (double);
56  void slotDividerLow (double);
57  void slotForeground();
58  void slotHue();
59  void slotIntensity();
60  void slotSaturation();
61  void slotValue();
62 
63 protected:
64  virtual void handleOk ();
65 
66 private:
67 
68  void createControls (QGridLayout *layout, int &row);
69  void createPreview (QGridLayout *layout, int &row);
70  void createProfileAndScale (QGridLayout *layout, int &row);
71  QRgb createThread (); // Returns background color
72  void loadForCurveName();
73  static int PROFILE_HEIGHT_IN_ROWS () { return 6; }
74  static int PROFILE_SCENE_WIDTH () { return 100; }
75  static int PROFILE_SCENE_HEIGHT () { return 100; }
76  void updateHistogram();
77  void updatePreview();
78 
79  QComboBox *m_cmbCurveName;
80 
81  QRadioButton *m_btnIntensity;
82  QRadioButton *m_btnForeground;
83  QRadioButton *m_btnHue;
84  QRadioButton *m_btnSaturation;
85  QRadioButton *m_btnValue;
86 
87  QGraphicsScene *m_sceneProfile;
88  ViewProfile *m_viewProfile;
89  ViewProfileScale *m_scale;
90 
91  QGraphicsScene *m_scenePreview;
92  ViewPreview *m_viewPreview;
93  ViewProfileDivider *m_dividerLow;
94  ViewProfileDivider *m_dividerHigh;
95 
96  // Apply filter parameters to preview image in a separate thread so dragging the dividers in the profile
97  // will not be slowed down by the filter parameter processing
98  DlgFilterThread *m_filterThread;
99 
100  QImage m_imagePreview;
101 
102  DocumentModelColorFilter *m_modelColorFilterBefore;
103  DocumentModelColorFilter *m_modelColorFilterAfter;
104 };
105 
106 #endif // DLG_SETTINGS_COLOR_FILTER_H
void slotTransferPiece(int xLeft, QImage image)
Receive processed piece of preview image, to be inserted at xLeft to xLeft+pixmap.width().
virtual void handleOk()
Process slotOk.
void signalApplyFilter(ColorFilterMode colorFilterMode, double low, double high)
Send filter parameters to DlgFilterThread and DlgFilterWorker for processing.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
Dialog for editing filtering settings.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
Definition: ViewPreview.h:14
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Linear horizontal scale, with the spectrum reflecting the active filter parameter.
Divider that can be dragged, in a dialog QGraphicsView.
Class for processing new filter settings. This is based on http://blog.debao.me/2013/08/how-to-use-qt...
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
Command queue stack.
Definition: CmdMediator.h:23
DlgSettingsColorFilter(MainWindow &mainWindow)
Single constructor.
Abstract base class for all Settings dialogs.
Class that modifies QGraphicsView to present a two-dimensional profile, with movable dividers for sel...
Definition: ViewProfile.h:15
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:83
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.