Engauge Digitizer  2
Public Member Functions | Protected Member Functions | List of all members
DlgSettingsSegments Class Reference

Dialog for editing Segments settings, for DigitizeStateSegment. More...

#include <DlgSettingsSegments.h>

Inheritance diagram for DlgSettingsSegments:
Inheritance graph
Collaboration diagram for DlgSettingsSegments:
Collaboration graph

Public Member Functions

 DlgSettingsSegments (MainWindow &mainWindow)
 Single constructor. More...
 
virtual ~DlgSettingsSegments ()
 
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 Segments settings, for DigitizeStateSegment.

Definition at line 26 of file DlgSettingsSegments.h.

Constructor & Destructor Documentation

◆ DlgSettingsSegments()

DlgSettingsSegments::DlgSettingsSegments ( MainWindow mainWindow)

Single constructor.

Definition at line 39 of file DlgSettingsSegments.cpp.

39  :
40  DlgSettingsAbstractBase (tr ("Segment Fill"),
41  "DlgSettingsSegments",
42  mainWindow),
43  m_scenePreview (nullptr),
44  m_viewPreview (nullptr),
45  m_modelSegmentsBefore (nullptr),
46  m_modelSegmentsAfter (nullptr),
47  m_loading (false)
48 {
49  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::DlgSettingsSegments";
50 
51  QWidget *subPanel = createSubPanel ();
52  finishPanel (subPanel);
53 }

◆ ~DlgSettingsSegments()

DlgSettingsSegments::~DlgSettingsSegments ( )
virtual

Definition at line 55 of file DlgSettingsSegments.cpp.

56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::~DlgSettingsSegments";
58 }

Member Function Documentation

◆ createOptionalSaveDefault()

void DlgSettingsSegments::createOptionalSaveDefault ( QHBoxLayout *  layout)
virtual

Let subclass define an optional Save As Default button.

Implements DlgSettingsAbstractBase.

Definition at line 133 of file DlgSettingsSegments.cpp.

134 {
135 }

◆ createSubPanel()

QWidget * DlgSettingsSegments::createSubPanel ( )
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 216 of file DlgSettingsSegments.cpp.

217 {
218  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::createSubPanel";
219 
220  QWidget *subPanel = new QWidget ();
221  QGridLayout *layout = new QGridLayout (subPanel);
222  subPanel->setLayout (layout);
223 
224  layout->setColumnStretch (0, 1); // Empty first column
225  layout->setColumnStretch (1, 0); // Labels
226  layout->setColumnStretch (2, 0); // User controls
227  layout->setColumnStretch (3, 1); // Empty last column
228 
229  int row = 0;
230  createControls(layout, row);
231  createPreview (layout, row);
232  QPixmap pixmap = QPixmap::fromImage (createPreviewImage());
233  m_scenePreview->addPixmap (pixmap);
234 
235  return subPanel;
236 }

◆ handleOk()

void DlgSettingsSegments::handleOk ( )
protectedvirtual

Process slotOk.

Implements DlgSettingsAbstractBase.

Definition at line 238 of file DlgSettingsSegments.cpp.

239 {
240  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::handleOk";
241 
243  cmdMediator ().document(),
244  *m_modelSegmentsBefore,
245  *m_modelSegmentsAfter);
246  cmdMediator ().push (cmd);
247 
248  hide ();
249 }

◆ load()

void DlgSettingsSegments::load ( CmdMediator cmdMediator)
virtual

Load settings from Document.

Implements DlgSettingsAbstractBase.

Definition at line 251 of file DlgSettingsSegments.cpp.

252 {
253  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::load";
254 
255  // Loading starts here
256  m_loading = true;
257 
259 
260  // Flush old data
261  delete m_modelSegmentsBefore;
262  delete m_modelSegmentsAfter;
263 
264  // Save new data
265  m_modelSegmentsBefore = new DocumentModelSegments (cmdMediator.document());
266  m_modelSegmentsAfter = new DocumentModelSegments (cmdMediator.document());
267 
268  // Sanity checks. Incoming defaults must be acceptable to the local limits
269  ENGAUGE_ASSERT (MIN_LENGTH_MIN <= m_modelSegmentsAfter->minLength ());
270  ENGAUGE_ASSERT (MIN_LENGTH_MAX >= m_modelSegmentsAfter->minLength ());
271  ENGAUGE_ASSERT (POINT_SEPARATION_MIN <= m_modelSegmentsAfter->pointSeparation());
272  ENGAUGE_ASSERT (POINT_SEPARATION_MAX >= m_modelSegmentsAfter->pointSeparation());
273 
274  // Populate controls
275  m_spinPointSeparation->setValue (qFloor (m_modelSegmentsAfter->pointSeparation()));
276  m_spinMinLength->setValue (qFloor (m_modelSegmentsAfter->minLength()));
277  m_chkFillCorners->setChecked (m_modelSegmentsAfter->fillCorners ());
278  m_spinLineWidth->setValue (qFloor (m_modelSegmentsAfter->lineWidth()));
279 
280  int indexLineColor = m_cmbLineColor->findData(QVariant (m_modelSegmentsAfter->lineColor()));
281  ENGAUGE_ASSERT (indexLineColor >= 0);
282  m_cmbLineColor->setCurrentIndex(indexLineColor);
283 
284  // Loading finishes here
285  m_loading = false;
286 
287  updateControls();
288  enableOk (false); // Disable Ok button since there not yet any changes
289  updatePreview();
290 }

◆ setSmallDialogs()

void DlgSettingsSegments::setSmallDialogs ( bool  smallDialogs)
virtual

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

Implements DlgSettingsAbstractBase.

Definition at line 292 of file DlgSettingsSegments.cpp.

293 {
294  if (!smallDialogs) {
295  setMinimumHeight (MINIMUM_HEIGHT);
296  }
297 }

The documentation for this class was generated from the following files:
DocumentModelSegments::lineColor
ColorPalette lineColor() const
Get method for line color.
Definition: DocumentModelSegments.cpp:63
DlgSettingsSegments::createSubPanel
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
Definition: DlgSettingsSegments.cpp:216
DlgSettingsAbstractBase::mainWindow
MainWindow & mainWindow()
Get method for MainWindow.
Definition: DlgSettingsAbstractBase.cpp:122
DlgSettingsAbstractBase
Abstract base class for all Settings dialogs.
Definition: DlgSettingsAbstractBase.h:19
MIN_LENGTH_MAX
const int MIN_LENGTH_MAX
Definition: DlgSettingsSegments.cpp:28
DocumentModelSegments::fillCorners
bool fillCorners() const
Get method for fill corners.
Definition: DocumentModelSegments.cpp:58
CmdSettingsSegments
Command for DlgSettingsSegments.
Definition: CmdSettingsSegments.h:15
DlgSettingsAbstractBase::finishPanel
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
Definition: DlgSettingsAbstractBase.cpp:57
MINIMUM_HEIGHT
const int MINIMUM_HEIGHT
Definition: DlgSettingsSegments.cpp:26
DlgSettingsAbstractBase::setCmdMediator
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
Definition: DlgSettingsAbstractBase.cpp:165
DocumentModelSegments::minLength
double minLength() const
Get method for min length.
Definition: DocumentModelSegments.cpp:94
CmdMediator::document
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
DocumentModelSegments
Model for DlgSettingsSegments and CmdSettingsSegments.
Definition: DocumentModelSegments.h:16
DocumentModelSegments::pointSeparation
double pointSeparation() const
Get method for point separation.
Definition: DocumentModelSegments.cpp:99
POINT_SEPARATION_MAX
const int POINT_SEPARATION_MAX
Definition: DlgSettingsSegments.cpp:30
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
DlgSettingsAbstractBase::enableOk
void enableOk(bool enable)
Let leaf subclass control the Ok button.
Definition: DlgSettingsAbstractBase.cpp:52
DocumentModelSegments::lineWidth
double lineWidth() const
Get method for line width.
Definition: DocumentModelSegments.cpp:68
DlgSettingsAbstractBase::cmdMediator
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
Definition: DlgSettingsAbstractBase.cpp:45
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:19