Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgSettingsColorFilter Class Reference

Dialog for editing filtering settings. More...

#include <DlgSettingsColorFilter.h>

Inheritance diagram for DlgSettingsColorFilter:
Inheritance graph
Collaboration diagram for DlgSettingsColorFilter:
Collaboration graph

Public Slots

void slotTransferPiece (int xLeft, QImage image)
 Receive processed piece of preview image, to be inserted at xLeft to xLeft+pixmap.width().

Signals

void signalApplyFilter (ColorFilterMode colorFilterMode, double low, double high)
 Send filter parameters to DlgFilterThread and DlgFilterWorker for processing.

Public Member Functions

 DlgSettingsColorFilter (MainWindow &mainWindow)
 Single constructor.
virtual ~DlgSettingsColorFilter ()
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.
virtual void load (CmdMediator &cmdMediator)
 Load settings from Document.
virtual void setSmallDialogs (bool smallDialogs)
 If false then dialogs have a minimum size so all controls are visible.
Public Member Functions inherited from DlgSettingsAbstractBase
 DlgSettingsAbstractBase (const QString &title, const QString &dialogName, MainWindow &mainWindow)
 Single constructor.
virtual ~DlgSettingsAbstractBase ()

Protected Member Functions

virtual void handleOk ()
 Process slotOk.
Protected Member Functions inherited from DlgSettingsAbstractBase
CmdMediatorcmdMediator ()
 Provide access to Document information wrapped inside CmdMediator.
void addPixmap (QGraphicsScene &scene, const QPixmap &pixmap)
 Adds pixmap to the scene.
void createWhatsThis (QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
 Create a WhatsThis button in a grid layout.
void enableOk (bool enable)
 Let leaf subclass control the Ok button.
void finishPanel (QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
 Add Ok and Cancel buttons to subpanel to get the whole dialog.
MainWindowmainWindow ()
 Get method for MainWindow.
const MainWindowmainWindow () const
 Const get method for MainWindow.
void populateColorComboWithoutTransparent (QComboBox &combo)
 Add colors in color palette to combobox, without transparent entry at end.
void populateColorComboWithTransparent (QComboBox &combo)
 Add colors in color palette to combobox, with transparent entry at end.
void setCmdMediator (CmdMediator &cmdMediator)
 Store CmdMediator for easy access by the leaf class.
void setDisableOkAtStartup (bool disableOkAtStartup)
 Override the default Ok button behavior applied in showEvent.

Additional Inherited Members

Static Protected Attributes inherited from DlgSettingsAbstractBase
static int MINIMUM_DIALOG_WIDTH = 380
 Dialog layout constant that guarantees every widget has sufficient room. Can be increased by finishPanel.
static int MINIMUM_PREVIEW_HEIGHT = 100
 Dialog layout constant that guarantees preview has sufficent room.

Detailed Description

Dialog for editing filtering settings.

Definition at line 30 of file DlgSettingsColorFilter.h.

Constructor & Destructor Documentation

◆ DlgSettingsColorFilter()

DlgSettingsColorFilter::DlgSettingsColorFilter ( MainWindow & mainWindow)

Single constructor.

Definition at line 38 of file DlgSettingsColorFilter.cpp.

38 :
39 DlgSettingsAbstractBase (tr ("Color Filter"),
40 "DlgSettingsColorFilter",
42 m_scenePreview (nullptr),
43 m_viewPreview (nullptr),
44 m_filterThread (nullptr),
45 m_modelColorFilterBefore (nullptr),
46 m_modelColorFilterAfter (nullptr)
47{
48 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::DlgSettingsColorFilter";
49
50 QWidget *subPanel = createSubPanel ();
51 finishPanel (subPanel,
53}
const int MINIMUM_DIALOG_WIDTH_COLOR_FILTER
log4cpp::Category * mainCat
Definition Logger.cpp:14
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
MainWindow & mainWindow()
Get method for MainWindow.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~DlgSettingsColorFilter()

DlgSettingsColorFilter::~DlgSettingsColorFilter ( )
virtual

Definition at line 55 of file DlgSettingsColorFilter.cpp.

56{
57 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::~DlgSettingsColorFilter";
58
59 delete m_filterThread;
60}

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsColorFilter::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 118 of file DlgSettingsColorFilter.cpp.

119{
120}

◆ createSubPanel()

QWidget * DlgSettingsColorFilter::createSubPanel ( )
virtual

Create dialog-specific panel to which base class will add Ok and Cancel buttons.

Implements DlgSettingsAbstractBase.

Definition at line 168 of file DlgSettingsColorFilter.cpp.

169{
170 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::createSubPanel";
171
172 const int EMPTY_COLUMN_WIDTH = 40;
173
174 QWidget *subPanel = new QWidget ();
175 QGridLayout *layout = new QGridLayout (subPanel);
176 subPanel->setLayout (layout);
177
178 layout->setColumnStretch(0, 0); // Empty column
179 layout->setColumnMinimumWidth(0, EMPTY_COLUMN_WIDTH);
180 layout->setColumnStretch(1, 0); // Radio buttons
181 layout->setColumnMinimumWidth(1, 210);
182 layout->setColumnStretch(2, 0); // Empty column to put some space between previous and next columns, so they are not too close
183 layout->setColumnMinimumWidth(2, 15);
184 layout->setColumnStretch(3, 1); // Profile
185 layout->setColumnMinimumWidth(4, EMPTY_COLUMN_WIDTH); // Empty column
186 layout->setColumnStretch(4, 0);
187\
188 int row = 0;
189 createWhatsThis (layout,
190 m_btnWhatsThis,
191 row++,
192 4);
193
194 int rowLeft = row, rowRight = row;
195 createControls (layout, rowLeft);
196 createProfileAndScale (layout, rowRight);
197
198 row = qMax (rowLeft, rowRight);
199 createPreview (layout, row);
200
201 return subPanel;
202}
void createWhatsThis(QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
Create a WhatsThis button in a grid layout.

◆ handleOk()

void DlgSettingsColorFilter::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 225 of file DlgSettingsColorFilter.cpp.

226{
227 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::handleOk";
228
229 CmdSettingsColorFilter *cmd = new CmdSettingsColorFilter (mainWindow (),
230 cmdMediator ().document(),
231 *m_modelColorFilterBefore,
232 *m_modelColorFilterAfter);
233 cmdMediator ().push (cmd);
234
235 hide ();
236}
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ load()

void DlgSettingsColorFilter::load ( CmdMediator & cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 238 of file DlgSettingsColorFilter.cpp.

239{
240 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::load";
241
243
244 // Flush old data
245 delete m_modelColorFilterBefore;
246 delete m_modelColorFilterAfter;
247
248 // Save new data
249 m_modelColorFilterBefore = new DocumentModelColorFilter (cmdMediator.document().modelColorFilter());
250 m_modelColorFilterAfter = new DocumentModelColorFilter (cmdMediator.document().modelColorFilter());
251
252 // Populate controls. First load curve name combobox. The curve-specific controls get loaded in slotCurveName
253 m_cmbCurveName->clear ();
254 m_cmbCurveName->addItem (AXIS_CURVE_NAME);
255 QStringList curveNames = cmdMediator.curvesGraphsNames();
256 QStringList::const_iterator itr;
257 for (itr = curveNames.begin (); itr != curveNames.end (); itr++) {
258
259 QString curveName = *itr;
260 m_cmbCurveName->addItem (curveName);
261 }
262
263 // This sets the curve name
264 m_cmbCurveName->setCurrentText (mainWindow().selectedGraphCurve());
265 loadForCurveName();
266
267 enableOk (false); // Disable Ok button since there not yet any changes
268}
const QString AXIS_CURVE_NAME
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void enableOk(bool enable)
Let leaf subclass control the Ok button.

◆ setSmallDialogs()

void DlgSettingsColorFilter::setSmallDialogs ( bool smallDialogs)
virtual

If false then dialogs have a minimum size so all controls are visible.

Implements DlgSettingsAbstractBase.

Definition at line 301 of file DlgSettingsColorFilter.cpp.

302{
303 if (!smallDialogs) {
304 setMinimumHeight (MINIMUM_HEIGHT);
305 }
306}
const int MINIMUM_HEIGHT

◆ signalApplyFilter

void DlgSettingsColorFilter::signalApplyFilter ( ColorFilterMode colorFilterMode,
double low,
double high )
signal

Send filter parameters to DlgFilterThread and DlgFilterWorker for processing.

◆ slotTransferPiece

void DlgSettingsColorFilter::slotTransferPiece ( int xLeft,
QImage image )
slot

Receive processed piece of preview image, to be inserted at xLeft to xLeft+pixmap.width().

Definition at line 369 of file DlgSettingsColorFilter.cpp.

371{
372 // Overwrite one piece of the processed image. This approach is a bit slow because the entire QPixmap
373 // in the QGraphicsScene gets exchanged as part of each update, but that seems to be the only possible
374 // approach when using QGraphicsScene. If not fast enough or there is ugly flicker, we may replace
375 // QGraphicsScene by a simple QWidget and override the paint function - but that approach may get
376 // complicated when resizing the QGraphicsView
377 for (int xFrom = 0, xTo = xLeft; xFrom < image.width(); xFrom++, xTo++) {
378 for (int y = 0; y < image.height (); y++) {
379
380 QColor pixel = image.pixel (xFrom, y);
381 m_imagePreview.setPixel (xTo, y, pixel.rgb());
382 }
383 }
384
385 // Remove old pixmap
386 QGraphicsItem *itemPixmap = m_scenePreview->items().at(0);
387 m_scenePreview->removeItem (itemPixmap);
388 delete itemPixmap;
389
390 // Save new pixmap. Only visible change should be the area covered by the pixels in image
391 addPixmap (*m_scenePreview,
392 QPixmap::fromImage (m_imagePreview));
393}
void addPixmap(QGraphicsScene &scene, const QPixmap &pixmap)
Adds pixmap to the scene.

The documentation for this class was generated from the following files: