19#include <QGraphicsPixmapItem>
21#include <QGraphicsScene>
25#include <QRadioButton>
42 "DlgSettingsDigitizeCurve",
44 m_scenePreview (nullptr),
45 m_viewPreview (nullptr),
46 m_modelDigitizeCurveBefore (nullptr),
47 m_modelDigitizeCurveAfter (nullptr)
60void DlgSettingsDigitizeCurve::createControls (QGridLayout *layout,
65 m_boxCursor =
new QGroupBox (tr (
"Cursor"));
66 layout->addWidget (m_boxCursor, row++, 1, 1, 2);
69 QGridLayout *layoutCursor =
new QGridLayout;
70 m_boxCursor->setLayout (layoutCursor);
73 QLabel *labelCursorType =
new QLabel(QString (
"%1:").arg (tr (
"Type")));
74 layoutCursor->addWidget (labelCursorType, rowCursor, 0);
76 m_btnStandard =
new QRadioButton (tr (
"Standard cross"));
77 m_btnStandard->setWhatsThis (tr (
"Selects the standard cross cursor"));
78 layoutCursor->addWidget (m_btnStandard, rowCursor++, 1);
79 connect (m_btnStandard, SIGNAL (toggled (
bool)),
this, SLOT (slotCursorStandard(
bool)));
81 m_btnCustom =
new QRadioButton (tr (
"Custom cross"));
82 m_btnCustom->setWhatsThis (tr (
"Selects a custom cursor based on the settings selected below"));
83 layoutCursor->addWidget (m_btnCustom, rowCursor++, 1);
84 connect (m_btnCustom, SIGNAL (toggled (
bool)),
this, SLOT (slotCursorCustom(
bool)));
86 QLabel *labelSize =
new QLabel(QString (
"%1:").arg (tr (
"Size (pixels)")));
87 layoutCursor->addWidget (labelSize, rowCursor, 0);
89 m_cmbSize =
new QComboBox;
95 m_cmbSize->setWhatsThis (tr (
"Horizontal and vertical size of the cursor in pixels"));
96 layoutCursor->addWidget (m_cmbSize, rowCursor++, 1);
97 connect (m_cmbSize, SIGNAL (currentIndexChanged (
const QString &)),
this, SLOT (slotCursorSize (
const QString &)));
99 QLabel *labelInnerRadius =
new QLabel(QString (
"%1:").arg (tr (
"Inner radius (pixels)")));
100 layoutCursor->addWidget (labelInnerRadius, rowCursor, 0);
102 m_spinInnerRadius =
new QSpinBox;
104 m_spinInnerRadius->setWhatsThis (tr (
"Radius of circle at the center of the cursor that will remain empty"));
105 layoutCursor->addWidget (m_spinInnerRadius, rowCursor++, 1);
106 connect (m_spinInnerRadius, SIGNAL (valueChanged(
const QString &)),
this, SLOT (slotCursorInnerRadius (
const QString &)));
108 QLabel *labelLineWidth =
new QLabel(QString (
"%1:").arg (tr (
"Line width (pixels)")));
109 layoutCursor->addWidget (labelLineWidth, rowCursor, 0);
111 m_spinLineWidth =
new QSpinBox;
113 m_spinLineWidth->setWhatsThis (tr (
"Width of each arm of the cross of the cursor"));
114 layoutCursor->addWidget (m_spinLineWidth, rowCursor++, 1);
115 connect (m_spinLineWidth, SIGNAL (valueChanged(
const QString &)),
this, SLOT (slotCursorLineWidth (
const QString &)));
122void DlgSettingsDigitizeCurve::createPreview (QGridLayout *layout,
127 QLabel *labelPreview =
new QLabel (tr (
"Preview"));
128 layout->addWidget (labelPreview, row++, 0, 1, 4);
130 m_scenePreview =
new QGraphicsScene (
this);
131 m_scenePreview->setSceneRect(0,
139 m_viewPreview->setWhatsThis (tr (
"Preview window showing the currently selected cursor.\n\n"
140 "Drag the cursor over this area to see the effects of the current settings on the cursor shape."));
141 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
142 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
145 layout->addWidget (m_viewPreview, row++, 0, 1, 4);
152 QWidget *subPanel =
new QWidget ();
153 QGridLayout *layout =
new QGridLayout (subPanel);
154 subPanel->setLayout (layout);
156 layout->setColumnStretch (0, 1);
157 layout->setColumnStretch (1, 0);
158 layout->setColumnStretch (2, 0);
159 layout->setColumnStretch (3, 1);
162 createControls(layout, row);
163 createPreview (layout, row);
174 *m_modelDigitizeCurveBefore,
175 *m_modelDigitizeCurveAfter);
188 delete m_modelDigitizeCurveBefore;
189 delete m_modelDigitizeCurveAfter;
206 m_cmbSize->setCurrentIndex (index);
207 m_spinLineWidth->setValue (m_modelDigitizeCurveAfter->
cursorLineWidth());
221void DlgSettingsDigitizeCurve::slotCursorCustom (
bool)
230void DlgSettingsDigitizeCurve::slotCursorInnerRadius (
const QString &)
239void DlgSettingsDigitizeCurve::slotCursorLineWidth (
const QString &)
248void DlgSettingsDigitizeCurve::slotCursorSize (
const QString &)
257void DlgSettingsDigitizeCurve::slotCursorStandard (
bool)
266void DlgSettingsDigitizeCurve::updateControls()
273 m_spinInnerRadius->setEnabled (m_btnCustom->isChecked());
274 m_cmbSize->setEnabled (m_btnCustom->isChecked());
275 m_spinLineWidth->setEnabled (m_btnCustom->isChecked());
278void DlgSettingsDigitizeCurve::updatePreview()
284 m_viewPreview->setCursor (cursor);
int CursorSizeToPixels(CursorSize cursorSize)
CursorSize
Custom cursor sizes supported on all platforms for the most part, according to QCursor documentation.
const int INNER_RADIUS_MIN
const int LINE_LENGTH_MIN
const int INNER_RADIUS_MAX
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
log4cpp::Category * mainCat
Command for DlgSettingsDigitizeCurve.
Create standard cross cursor, or custom cursor, according to settings.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
Abstract base class for all Settings dialogs.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
MainWindow & mainWindow()
Get method for MainWindow.
DlgSettingsDigitizeCurve(MainWindow &mainWindow)
Single constructor.
virtual ~DlgSettingsDigitizeCurve()
virtual void handleOk()
Process slotOk.
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.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
void setCursorStandardCross(bool cursorStandardCross)
Set method for cursor type.
void setCursorLineWidth(int lineWidth)
Set method for cursor line width.
void setCursorInnerRadius(int innerRadius)
Set method for cursor inner radius.
CursorSize cursorSize() const
Get method for cursor size.
int cursorInnerRadius() const
Get method for cursor inner radius.
bool cursorStandardCross() const
Get method for cursor type.
int cursorLineWidth() const
Get method for cursor line width.
void setCursorSize(CursorSize cursorSize)
Set method for cursor size.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window,...
@ VIEW_ASPECT_RATIO_VARIABLE
#define LOG4CPP_INFO_S(logger)