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
CmdMediator & cmdMediator ()
 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...
 
MainWindow & mainWindow ()
 Get method for MainWindow. More...
 
const MainWindow & mainWindow () 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 27 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 }
#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.

◆ ~DlgSettingsSegments()

DlgSettingsSegments::~DlgSettingsSegments ( )
virtual

Definition at line 55 of file DlgSettingsSegments.cpp.

56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::~DlgSettingsSegments";
58 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ 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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Command for DlgSettingsSegments.
MainWindow & mainWindow()
Get method for MainWindow.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.

◆ 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 }
double pointSeparation() const
Get method for point separation.
double lineWidth() const
Get method for line width.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
double minLength() const
Get method for min length.
bool fillCorners() const
Get method for fill corners.
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void enableOk(bool enable)
Let leaf subclass control the Ok button.
const int POINT_SEPARATION_MAX
ColorPalette lineColor() const
Get method for line color.
Model for DlgSettingsSegments and CmdSettingsSegments.
const int MIN_LENGTH_MAX
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 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 }
const int MINIMUM_HEIGHT

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