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

Dialog for editing point match settings, for DigitizeStatePointMatch. More...

#include <DlgSettingsPointMatch.h>

Inheritance diagram for DlgSettingsPointMatch:
Inheritance graph
Collaboration diagram for DlgSettingsPointMatch:
Collaboration graph

Public Member Functions

 DlgSettingsPointMatch (MainWindow &mainWindow)
 Single constructor.
virtual ~DlgSettingsPointMatch ()
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 point match settings, for DigitizeStatePointMatch.

Definition at line 25 of file DlgSettingsPointMatch.h.

Constructor & Destructor Documentation

◆ DlgSettingsPointMatch()

DlgSettingsPointMatch::DlgSettingsPointMatch ( MainWindow & mainWindow)

Single constructor.

Definition at line 31 of file DlgSettingsPointMatch.cpp.

31 :
32 DlgSettingsAbstractBase (tr ("Point Match"),
33 "DlgSettingsPointMatch",
35 m_scenePreview (nullptr),
36 m_viewPreview (nullptr),
37 m_circle (nullptr),
38 m_modelPointMatchBefore (nullptr),
39 m_modelPointMatchAfter (nullptr)
40{
41 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::DlgSettingsPointMatch";
42
43 QWidget *subPanel = createSubPanel ();
44 finishPanel (subPanel);
45}
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

◆ ~DlgSettingsPointMatch()

DlgSettingsPointMatch::~DlgSettingsPointMatch ( )
virtual

Definition at line 47 of file DlgSettingsPointMatch.cpp.

48{
49 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::~DlgSettingsPointMatch";
50}

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsPointMatch::createOptionalSaveDefault ( QHBoxLayout * layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 128 of file DlgSettingsPointMatch.cpp.

129{
130}

◆ createSubPanel()

QWidget * DlgSettingsPointMatch::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 155 of file DlgSettingsPointMatch.cpp.

156{
157 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::createSubPanel";
158
159 QWidget *subPanel = new QWidget ();
160 QGridLayout *layout = new QGridLayout (subPanel);
161 subPanel->setLayout (layout);
162
163 layout->setColumnStretch(0, 1); // Empty column
164 layout->setColumnStretch(1, 0); // Labels
165 layout->setColumnStretch(2, 0); // Controls
166 layout->setColumnStretch(3, 1); // Empty column
167
168 int row = 0;
169
170 createWhatsThis (layout,
171 m_btnWhatsThis,
172 row++,
173 3);
174
175 createControls (layout, row);
176 createPreview (layout, row);
177 createTemplate ();
178
179 return subPanel;
180}
void createWhatsThis(QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
Create a WhatsThis button in a grid layout.

◆ handleOk()

void DlgSettingsPointMatch::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 194 of file DlgSettingsPointMatch.cpp.

195{
196 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::handleOk";
197
198 CmdSettingsPointMatch *cmd = new CmdSettingsPointMatch (mainWindow (),
199 cmdMediator ().document(),
200 *m_modelPointMatchBefore,
201 *m_modelPointMatchAfter);
202 cmdMediator ().push (cmd);
203
204 hide ();
205}
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ load()

void DlgSettingsPointMatch::load ( CmdMediator & cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 215 of file DlgSettingsPointMatch.cpp.

216{
217 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::load";
218
220
221 // Flush old data
222 delete m_modelPointMatchBefore;
223 delete m_modelPointMatchAfter;
224
225 // Save new data
226 m_modelPointMatchBefore = new DocumentModelPointMatch (cmdMediator.document());
227 m_modelPointMatchAfter = new DocumentModelPointMatch (cmdMediator.document());
228
229 // Sanity checks. Incoming defaults must be acceptable to the local limits
231 ENGAUGE_ASSERT (POINT_SIZE_MAX > m_modelPointMatchAfter->maxPointSize());
232
233 // Populate controls
234 m_spinPointSize->setValue(qFloor (m_modelPointMatchAfter->maxPointSize()));
235
236 int indexAccepted = m_cmbAcceptedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorAccepted()));
237 ENGAUGE_ASSERT (indexAccepted >= 0);
238 m_cmbAcceptedPointColor->setCurrentIndex(indexAccepted);
239
240 int indexCandidate = m_cmbCandidatePointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorCandidate()));
241 ENGAUGE_ASSERT (indexCandidate >= 0);
242 m_cmbCandidatePointColor->setCurrentIndex(indexCandidate);
243
244 int indexRejected = m_cmbRejectedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorRejected()));
245 ENGAUGE_ASSERT (indexRejected >= 0);
246 m_cmbRejectedPointColor->setCurrentIndex(indexRejected);
247
248 initializeBox ();
249
250 // Fix the preview size using an invisible boundary
251 QGraphicsRectItem *boundary = m_scenePreview->addRect (QRect (0,
252 0,
253 cmdMediator.document().pixmap().width (),
254 cmdMediator.document().pixmap().height ()));
255 boundary->setVisible (false);
256
257 addPixmap (*m_scenePreview,
258 cmdMediator.document().pixmap());
259
260 updateControls();
261 enableOk (false); // Disable Ok button since there not yet any changes
262 updatePreview();
263}
const int POINT_SIZE_MIN
const int POINT_SIZE_MAX
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void addPixmap(QGraphicsScene &scene, const QPixmap &pixmap)
Adds pixmap to the scene.
void enableOk(bool enable)
Let leaf subclass control the Ok button.

◆ setSmallDialogs()

void DlgSettingsPointMatch::setSmallDialogs ( bool smallDialogs)
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 272 of file DlgSettingsPointMatch.cpp.

273{
274 if (!smallDialogs) {
275 setMinimumHeight (MINIMUM_HEIGHT);
276 }
277}
const int MINIMUM_HEIGHT

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