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);