19 #include <QGraphicsPixmapItem>
20 #include <QGridLayout>
21 #include <QGraphicsScene>
25 #include <QRadioButton>
42 "DlgSettingsDigitizeCurve",
44 m_scenePreview (nullptr),
45 m_viewPreview (nullptr),
46 m_modelDigitizeCurveBefore (nullptr),
47 m_modelDigitizeCurveAfter (nullptr)
60 void 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 &)));
122 void 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;
196 ENGAUGE_ASSERT (INNER_RADIUS_MIN <= m_modelDigitizeCurveAfter->cursorInnerRadius ());
198 ENGAUGE_ASSERT (LINE_WIDTH_MIN <= m_modelDigitizeCurveAfter->cursorLineWidth ());
205 int index = m_cmbSize->findData (QVariant (m_modelDigitizeCurveAfter->
cursorSize()));
206 m_cmbSize->setCurrentIndex (index);
207 m_spinLineWidth->setValue (m_modelDigitizeCurveAfter->
cursorLineWidth());
221 void DlgSettingsDigitizeCurve::slotCursorCustom (
bool)
230 void DlgSettingsDigitizeCurve::slotCursorInnerRadius (
const QString &)
239 void DlgSettingsDigitizeCurve::slotCursorLineWidth (
const QString &)
248 void DlgSettingsDigitizeCurve::slotCursorSize (
const QString &)
252 m_modelDigitizeCurveAfter->
setCursorSize (static_cast<CursorSize> (m_cmbSize->currentData().toInt()));
257 void DlgSettingsDigitizeCurve::slotCursorStandard (
bool)
266 void DlgSettingsDigitizeCurve::updateControls()
273 m_spinInnerRadius->setEnabled (m_btnCustom->isChecked());
274 m_cmbSize->setEnabled (m_btnCustom->isChecked());
275 m_spinLineWidth->setEnabled (m_btnCustom->isChecked());
278 void DlgSettingsDigitizeCurve::updatePreview()
283 QCursor cursor = cursorFactory.
generate (*m_modelDigitizeCurveAfter);
284 m_viewPreview->setCursor (cursor);
DlgSettingsDigitizeCurve(MainWindow &mainWindow)
Single constructor.
int cursorLineWidth() const
Get method for cursor line width.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
Create standard cross cursor, or custom cursor, according to settings.
void setCursorLineWidth(int lineWidth)
Set method for cursor line width.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
virtual ~DlgSettingsDigitizeCurve()
virtual void handleOk()
Process slotOk.
#define LOG4CPP_INFO_S(logger)
bool cursorStandardCross() const
Get method for cursor type.
const int LINE_LENGTH_MIN
const int INNER_RADIUS_MAX
void setCursorSize(CursorSize cursorSize)
Set method for cursor size.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Class that modifies QGraphicsView to automatically expand/shrink the view to fit the window...
int cursorInnerRadius() const
Get method for cursor inner radius.
void setCursorInnerRadius(int innerRadius)
Set method for cursor inner radius.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
log4cpp::Category * mainCat
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
int CursorSizeToPixels(CursorSize cursorSize)
CursorSize cursorSize() const
Get method for cursor size.
Command for DlgSettingsDigitizeCurve.
Abstract base class for all Settings dialogs.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void setCursorStandardCross(bool cursorStandardCross)
Set method for cursor type.
const int INNER_RADIUS_MIN
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.