21#include <QGraphicsPixmapItem>
23#include <QGraphicsScene>
27#include <QRadioButton>
45 "DlgSettingsDigitizeCurve",
47 m_scenePreview (nullptr),
48 m_viewPreview (nullptr),
49 m_modelDigitizeCurveBefore (nullptr),
50 m_modelDigitizeCurveAfter (nullptr)
63void DlgSettingsDigitizeCurve::createControls (QGridLayout *layout,
68 m_boxCursor =
new QGroupBox (tr (
"Cursor"));
69 layout->addWidget (m_boxCursor, row, 1, 1, 2);
77 QGridLayout *layoutCursor =
new QGridLayout;
78 m_boxCursor->setLayout (layoutCursor);
81 QLabel *labelCursorType =
new QLabel(QString (
"%1:").arg (tr (
"Type")));
82 layoutCursor->addWidget (labelCursorType, rowCursor, 0);
84 m_btnStandard =
new QRadioButton (tr (
"Standard cross"));
85 m_btnStandard->setWhatsThis (tr (
"Selects the standard cross cursor"));
86 layoutCursor->addWidget (m_btnStandard, rowCursor++, 1);
87 connect (m_btnStandard, SIGNAL (toggled (
bool)),
this, SLOT (slotCursorStandard(
bool)));
89 m_btnCustom =
new QRadioButton (tr (
"Custom cross"));
90 m_btnCustom->setWhatsThis (tr (
"Selects a custom cursor based on the settings selected below"));
91 layoutCursor->addWidget (m_btnCustom, rowCursor++, 1);
92 connect (m_btnCustom, SIGNAL (toggled (
bool)),
this, SLOT (slotCursorCustom(
bool)));
94 QLabel *labelSize =
new QLabel(QString (
"%1:").arg (tr (
"Size (pixels)")));
95 layoutCursor->addWidget (labelSize, rowCursor, 0);
97 m_cmbSize =
new QComboBox;
103 m_cmbSize->setWhatsThis (tr (
"Horizontal and vertical size of the cursor in pixels"));
104 layoutCursor->addWidget (m_cmbSize, rowCursor++, 1);
105 connect (m_cmbSize, SIGNAL (currentIndexChanged (
const QString &)),
this, SLOT (slotCursorSize (
const QString &)));
107 QLabel *labelInnerRadius =
new QLabel(QString (
"%1:").arg (tr (
"Inner radius (pixels)")));
108 layoutCursor->addWidget (labelInnerRadius, rowCursor, 0);
110 m_spinInnerRadius =
new QSpinBox;
112 m_spinInnerRadius->setWhatsThis (tr (
"Radius of circle at the center of the cursor that will remain empty"));
113 layoutCursor->addWidget (m_spinInnerRadius, rowCursor++, 1);
114 connect (m_spinInnerRadius, SIGNAL (valueChanged(
const QString &)),
this, SLOT (slotCursorInnerRadius (
const QString &)));
116 QLabel *labelLineWidth =
new QLabel(QString (
"%1:").arg (tr (
"Line width (pixels)")));
117 layoutCursor->addWidget (labelLineWidth, rowCursor, 0);
119 m_spinLineWidth =
new QSpinBox;
121 m_spinLineWidth->setWhatsThis (tr (
"Width of each arm of the cross of the cursor"));
122 layoutCursor->addWidget (m_spinLineWidth, rowCursor++, 1);
123 connect (m_spinLineWidth, SIGNAL (valueChanged(
const QString &)),
this, SLOT (slotCursorLineWidth (
const QString &)));
130void DlgSettingsDigitizeCurve::createPreview (QGridLayout *layout,
135 QLabel *labelPreview =
new QLabel (tr (
"Preview"));
136 layout->addWidget (labelPreview, row++, 0, 1, 4);
138 m_scenePreview =
new QGraphicsScene (
this);
139 m_scenePreview->setSceneRect(0,
147 m_viewPreview->setWhatsThis (tr (
"Preview window showing the currently selected cursor.\n\n"
148 "Drag the cursor over this area to see the effects of the current settings on the cursor shape."));
149 m_viewPreview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
150 m_viewPreview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
153 layout->addWidget (m_viewPreview, row++, 0, 1, 4);
160 QWidget *subPanel =
new QWidget ();
161 QGridLayout *layout =
new QGridLayout (subPanel);
162 subPanel->setLayout (layout);
164 layout->setColumnStretch (0, 1);
165 layout->setColumnStretch (1, 0);
166 layout->setColumnStretch (2, 0);
167 layout->setColumnStretch (3, 1);
170 createControls(layout, row);
171 createPreview (layout, row);
182 *m_modelDigitizeCurveBefore,
183 *m_modelDigitizeCurveAfter);
196 delete m_modelDigitizeCurveBefore;
197 delete m_modelDigitizeCurveAfter;
210 m_btnStandard->setChecked (m_modelDigitizeCurveAfter->cursorStandardCross());
211 m_btnCustom->setChecked (!m_modelDigitizeCurveAfter->cursorStandardCross());
212 m_spinInnerRadius->setValue (m_modelDigitizeCurveAfter->cursorInnerRadius());
213 int index = m_cmbSize->findData (QVariant (m_modelDigitizeCurveAfter->cursorSize()));
214 m_cmbSize->setCurrentIndex (index);
215 m_spinLineWidth->setValue (m_modelDigitizeCurveAfter->cursorLineWidth());
229void DlgSettingsDigitizeCurve::slotCursorCustom (
bool)
238void DlgSettingsDigitizeCurve::slotCursorInnerRadius (
const QString &)
242 m_modelDigitizeCurveAfter->setCursorInnerRadius (m_spinInnerRadius->value());
247void DlgSettingsDigitizeCurve::slotCursorLineWidth (
const QString &)
251 m_modelDigitizeCurveAfter->setCursorLineWidth (m_spinLineWidth->value());
256void DlgSettingsDigitizeCurve::slotCursorSize (
const QString &)
260 m_modelDigitizeCurveAfter->setCursorSize (
static_cast<CursorSize> (m_cmbSize->currentData().toInt()));
265void DlgSettingsDigitizeCurve::slotCursorStandard (
bool)
269 m_modelDigitizeCurveAfter->setCursorStandardCross(
true);
274void DlgSettingsDigitizeCurve::slotWhatsThis ()
276 QWhatsThis::enterWhatsThisMode();
279void DlgSettingsDigitizeCurve::updateControls()
282 bool isGoodState = 2 * (m_modelDigitizeCurveAfter->cursorInnerRadius() +
LINE_LENGTH_MIN) <=
286 m_spinInnerRadius->setEnabled (m_btnCustom->isChecked());
287 m_cmbSize->setEnabled (m_btnCustom->isChecked());
288 m_spinLineWidth->setEnabled (m_btnCustom->isChecked());
291void DlgSettingsDigitizeCurve::updatePreview()
295 CursorFactory cursorFactory;
296 QCursor cursor = cursorFactory.
generate (*m_modelDigitizeCurveAfter);
297 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.
log4cpp::Category * mainCat
Command for DlgSettingsDigitizeCurve.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
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 createWhatsThis(QGridLayout *layout, ButtonWhatsThis *button, int row, int column)
Create a WhatsThis button in a grid layout.
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.
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)