Engauge Digitizer  2
Public Member Functions | Protected Member Functions | List of all members
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. More...
 
virtual ~DlgSettingsPointMatch ()
 
virtual void createOptionalSaveDefault (QHBoxLayout *layout)
 Let subclass define an optional Save As Default button. More...
 
virtual QWidget * createSubPanel ()
 Create dialog-specific panel to which base class will add Ok and Cancel buttons. More...
 
virtual void load (CmdMediator &cmdMediator)
 Load settings from Document. More...
 
virtual void setSmallDialogs (bool smallDialogs)
 If false then dialogs have a minimum size so all controls are visible. More...
 
- Public Member Functions inherited from DlgSettingsAbstractBase
 DlgSettingsAbstractBase (const QString &title, const QString &dialogName, MainWindow &mainWindow)
 Single constructor. More...
 
virtual ~DlgSettingsAbstractBase ()
 

Protected Member Functions

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

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. More...
 
static int MINIMUM_PREVIEW_HEIGHT = 100
 Dialog layout constant that guarantees preview has sufficent room. More...
 

Detailed Description

Dialog for editing point match settings, for DigitizeStatePointMatch.

Definition at line 24 of file DlgSettingsPointMatch.h.

Constructor & Destructor Documentation

◆ DlgSettingsPointMatch()

DlgSettingsPointMatch::DlgSettingsPointMatch ( MainWindow mainWindow)

Single constructor.

Definition at line 29 of file DlgSettingsPointMatch.cpp.

29  :
30  DlgSettingsAbstractBase (tr ("Point Match"),
31  "DlgSettingsPointMatch",
32  mainWindow),
33  m_scenePreview (nullptr),
34  m_viewPreview (nullptr),
35  m_circle (nullptr),
36  m_modelPointMatchBefore (nullptr),
37  m_modelPointMatchAfter (nullptr)
38 {
39  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::DlgSettingsPointMatch";
40 
41  QWidget *subPanel = createSubPanel ();
42  finishPanel (subPanel);
43 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Abstract base class for all Settings dialogs.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
MainWindow & mainWindow()
Get method for MainWindow.

◆ ~DlgSettingsPointMatch()

DlgSettingsPointMatch::~DlgSettingsPointMatch ( )
virtual

Definition at line 45 of file DlgSettingsPointMatch.cpp.

46 {
47  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::~DlgSettingsPointMatch";
48 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsPointMatch::createOptionalSaveDefault ( QHBoxLayout *  layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 126 of file DlgSettingsPointMatch.cpp.

127 {
128 }

◆ createSubPanel()

QWidget * DlgSettingsPointMatch::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 153 of file DlgSettingsPointMatch.cpp.

154 {
155  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::createSubPanel";
156 
157  QWidget *subPanel = new QWidget ();
158  QGridLayout *layout = new QGridLayout (subPanel);
159  subPanel->setLayout (layout);
160 
161  layout->setColumnStretch(0, 1); // Empty column
162  layout->setColumnStretch(1, 0); // Labels
163  layout->setColumnStretch(2, 0); // Controls
164  layout->setColumnStretch(3, 1); // Empty column
165 
166  int row = 0;
167  createControls (layout, row);
168  createPreview (layout, row);
169  createTemplate ();
170 
171  return subPanel;
172 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ handleOk()

void DlgSettingsPointMatch::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 186 of file DlgSettingsPointMatch.cpp.

187 {
188  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::handleOk";
189 
191  cmdMediator ().document(),
192  *m_modelPointMatchBefore,
193  *m_modelPointMatchAfter);
194  cmdMediator ().push (cmd);
195 
196  hide ();
197 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Command for DlgSettingsPointMatch.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
MainWindow & mainWindow()
Get method for MainWindow.
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 207 of file DlgSettingsPointMatch.cpp.

208 {
209  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsPointMatch::load";
210 
212 
213  // Flush old data
214  delete m_modelPointMatchBefore;
215  delete m_modelPointMatchAfter;
216 
217  // Save new data
218  m_modelPointMatchBefore = new DocumentModelPointMatch (cmdMediator.document());
219  m_modelPointMatchAfter = new DocumentModelPointMatch (cmdMediator.document());
220 
221  // Sanity checks. Incoming defaults must be acceptable to the local limits
222  ENGAUGE_ASSERT (POINT_SIZE_MIN <= m_modelPointMatchAfter->maxPointSize());
223  ENGAUGE_ASSERT (POINT_SIZE_MAX > m_modelPointMatchAfter->maxPointSize());
224 
225  // Populate controls
226  m_spinPointSize->setValue(qFloor (m_modelPointMatchAfter->maxPointSize()));
227 
228  int indexAccepted = m_cmbAcceptedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorAccepted()));
229  ENGAUGE_ASSERT (indexAccepted >= 0);
230  m_cmbAcceptedPointColor->setCurrentIndex(indexAccepted);
231 
232  int indexCandidate = m_cmbCandidatePointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorCandidate()));
233  ENGAUGE_ASSERT (indexCandidate >= 0);
234  m_cmbCandidatePointColor->setCurrentIndex(indexCandidate);
235 
236  int indexRejected = m_cmbRejectedPointColor->findData(QVariant(m_modelPointMatchAfter->paletteColorRejected()));
237  ENGAUGE_ASSERT (indexRejected >= 0);
238  m_cmbRejectedPointColor->setCurrentIndex(indexRejected);
239 
240  initializeBox ();
241 
242  // Fix the preview size using an invisible boundary
243  QGraphicsRectItem *boundary = m_scenePreview->addRect (QRect (0,
244  0,
245  cmdMediator.document().pixmap().width (),
246  cmdMediator.document().pixmap().height ()));
247  boundary->setVisible (false);
248 
249  m_scenePreview->addPixmap (cmdMediator.document().pixmap());
250 
251  updateControls();
252  enableOk (false); // Disable Ok button since there not yet any changes
253  updatePreview();
254 }
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
const int POINT_SIZE_MAX
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
ColorPalette paletteColorCandidate() const
Get method for candidate color.
ColorPalette paletteColorAccepted() const
Get method for accepted color.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void enableOk(bool enable)
Let leaf subclass control the Ok button.
QPixmap pixmap() const
Return the image that is being digitized.
Definition: Document.cpp:817
ColorPalette paletteColorRejected() const
Get method for rejected color.
double maxPointSize() const
Get method for max point size.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:20

◆ 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 263 of file DlgSettingsPointMatch.cpp.

264 {
265  if (!smallDialogs) {
266  setMinimumHeight (MINIMUM_HEIGHT);
267  }
268 }
const int MINIMUM_HEIGHT

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