Engauge Digitizer  2
DlgSettingsSegments.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef DLG_SETTINGS_SEGMENTS_H
8 #define DLG_SETTINGS_SEGMENTS_H
9 
10 #include "DlgSettingsAbstractBase.h"
11 #include "GraphicsPoint.h"
12 #include <QImage>
13 #include <QList>
14 
16 class QCheckBox;
17 class QComboBox;
18 class QGridLayout;
19 class QGraphicsScene;
20 class QSpinBox;
21 class Segment;
22 class ViewPreview;
23 
24 typedef QList<GraphicsPoint*> GraphicsPoints;
25 
28 {
29  Q_OBJECT;
30 
31 public:
34  virtual ~DlgSettingsSegments();
35 
36  virtual void createOptionalSaveDefault (QHBoxLayout *layout);
37  virtual QWidget *createSubPanel ();
38  virtual void load (CmdMediator &cmdMediator);
39  virtual void setSmallDialogs (bool smallDialogs);
40 
41 private slots:
42  void slotFillCorners (int state);
43  void slotLineColor (const QString &);
44  void slotLineWidth (int);
45  void slotMinLength (const QString &);
46  void slotPointSeparation (const QString &);
47 
48 protected:
49  virtual void handleOk ();
50 
51 private:
52 
53  void clearPoints();
54  void createControls (QGridLayout *layout, int &row);
55  void createPreview (QGridLayout *layout, int &row);
56  QImage createPreviewImage () const;
57  void updateControls();
58  void updatePreview();
59 
60  QSpinBox *m_spinMinLength;
61  QSpinBox *m_spinPointSeparation;
62  QCheckBox *m_chkFillCorners;
63  QSpinBox *m_spinLineWidth;
64  QComboBox *m_cmbLineColor;
65 
66  QGraphicsScene *m_scenePreview;
67  ViewPreview *m_viewPreview;
68 
69  DocumentModelSegments *m_modelSegmentsBefore;
70  DocumentModelSegments *m_modelSegmentsAfter;
71 
72  QList<Segment*> m_segments; // Segments extracted from image
73  GraphicsPoints m_points; // Points spread along the segments
74 
75  bool m_loading; // Flag that prevents multiple preview updates during loading while controls get loaded
76 };
77 
78 #endif // DLG_SETTINGS_SEGMENTS_H
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
Dialog for editing Segments settings, for DigitizeStateSegment.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
Definition: ViewPreview.h:14
Selectable piecewise-defined line that follows a filtered line in the image.
Definition: Segment.h:21
Command queue stack.
Definition: CmdMediator.h:23
DlgSettingsSegments(MainWindow &mainWindow)
Single constructor.
Model for DlgSettingsSegments and CmdSettingsSegments.
Abstract base class for all Settings dialogs.
virtual void handleOk()
Process slotOk.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:89
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.