7 #include "DlgEditScale.h" 8 #include "DlgValidatorAbstract.h" 9 #include "DlgValidatorFactory.h" 10 #include "DocumentAxesPointsRequired.h" 11 #include "DocumentModelCoords.h" 12 #include "DocumentModelGeneral.h" 13 #include "EngaugeAssert.h" 14 #include "FormatCoordsUnits.h" 15 #include "FormatDateTime.h" 16 #include "FormatDegreesMinutesSecondsNonPolarTheta.h" 17 #include "FormatDegreesMinutesSecondsPolarTheta.h" 19 #include "MainWindow.h" 20 #include "MainWindowModel.h" 21 #include <QGridLayout> 23 #include <QHBoxLayout> 26 #include "QtToString.h" 27 #include <QVBoxLayout> 28 #include "Transformation.h" 30 const Qt::Alignment ALIGNMENT = Qt::AlignCenter;
32 const int MIN_WIDTH_TO_FIT_STRANGE_UNITS = 200;
38 const double *scaleLength) :
39 QDialog (&mainWindow),
40 m_modelCoords (modelCoords),
41 m_modelGeneral (modelGeneral),
42 m_modelMainWindow (modelMainWindow)
44 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgEditScale::DlgEditScale";
46 QVBoxLayout *layout =
new QVBoxLayout;
49 setCursor (QCursor (Qt::ArrowCursor));
51 setWindowTitle (tr (
"Edit Axis Point"));
53 createScaleLength (layout);
55 createOkCancel (layout);
57 initializeScaleLength (scaleLength);
62 DlgEditScale::~DlgEditScale()
64 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgEditScale::~DlgEditScale";
67 void DlgEditScale::createHint (QVBoxLayout *layoutOuter)
72 QWidget *widget =
new QWidget;
73 layoutOuter->addWidget (widget, 0, Qt::AlignCenter);
75 QHBoxLayout *layout =
new QHBoxLayout;
76 widget->setLayout (layout);
78 QString locale = QLocaleToString (m_modelMainWindow.
locale ());
79 QString hint = QString (
"%1: %2")
80 .arg (tr (
"Number format"))
82 QLabel *label =
new QLabel (hint);
83 layout->addWidget (label);
86 void DlgEditScale::createOkCancel (QVBoxLayout *layoutOuter)
88 QWidget *panel =
new QWidget (
this);
89 layoutOuter->addWidget (panel, 0, Qt::AlignCenter);
91 QHBoxLayout *layout =
new QHBoxLayout (panel);
92 panel->setLayout (layout);
94 m_btnOk =
new QPushButton (tr (
"Ok"),
this);
95 layout->addWidget(m_btnOk);
96 connect (m_btnOk, SIGNAL (released ()),
this, SLOT (accept ()));
98 m_btnCancel =
new QPushButton (tr (
"Cancel"),
this);
99 layout->addWidget(m_btnCancel);
100 connect (m_btnCancel, SIGNAL (released ()),
this, SLOT (reject ()));
103 void DlgEditScale::createScaleLength (QVBoxLayout *layoutOuter)
110 QGroupBox *panel =
new QGroupBox (tr (
"Scale Length"),
this);
111 layoutOuter->addWidget (panel);
113 QHBoxLayout *layout =
new QHBoxLayout (panel);
114 panel->setLayout (layout);
117 m_editScaleLength =
new QLineEdit;
118 m_editScaleLength->setMinimumWidth(MIN_WIDTH_TO_FIT_STRANGE_UNITS);
119 m_editScaleLength->setAlignment (ALIGNMENT);
120 m_editScaleLength->setValidator (m_validatorScaleLength);
122 m_editScaleLength->setWhatsThis (tr (
"Enter the scale bar length"));
123 layout->addWidget(m_editScaleLength, 0);
124 connect (m_editScaleLength, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotTextChanged (
const QString &)));
127 void DlgEditScale::initializeScaleLength (
const double *
scaleLength)
129 if (scaleLength != 0) {
130 m_editScaleLength->setText (QString::number (*scaleLength));
136 double xTheta, yRadius;
137 const QString DUMMY_Y (
"0");
152 void DlgEditScale::slotTextChanged (
const QString &)
157 void DlgEditScale::updateControls ()
159 QString textScaleLength = m_editScaleLength->text();
164 m_btnOk->setEnabled (!textScaleLength.isEmpty () &&
165 (m_validatorScaleLength->
validate(textScaleLength, posScaleLength) == QValidator::Acceptable));
Model for DlgSettingsGeneral and CmdSettingsGeneral.
DlgValidatorAbstract * createAboveZero(const QLocale &locale) const
Factory method for generating validators for scale length which must be a number greater than zero...
virtual QValidator::State validate(QString &input, int &pos) const =0
Validate according to the numeric format specific to the leaf class.
Model for DlgSettingsMainWindow.
Model for DlgSettingsCoords and CmdSettingsCoords.
QLocale locale() const
Get method for locale.
double scaleLength() const
Return the scale bar length specified by the user. Only applies if dialog was accepted.
DlgEditScale(MainWindow &mainWindow, const DocumentModelCoords &modelCoords, const DocumentModelGeneral &modelGeneral, const MainWindowModel &modelMainWindow, const double *scaleLength=0)
Single constructor.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...