21 #include <QDoubleValidator> 22 #include <QGridLayout> 24 #include <QHBoxLayout> 29 #include <QVBoxLayout> 46 const double *xInitialValue,
47 const double *yInitialValue) :
48 QDialog (&mainWindow),
49 m_documentAxesPointsRequired (documentAxesPointsRequired),
50 m_modelCoords (modelCoords),
51 m_modelGeneral (modelGeneral),
52 m_modelMainWindow (modelMainWindow)
60 QVBoxLayout *layout =
new QVBoxLayout;
63 setCursor (QCursor (Qt::ArrowCursor));
65 setWindowTitle (tr (
"Edit Axis Point"));
67 createCoords (layout);
69 documentAxesPointsRequired);
70 createOkCancel (layout);
72 initializeGraphCoordinates (xInitialValue,
86 void DlgEditPointAxis::createCoords (QVBoxLayout *layoutOuter)
98 m_modelMainWindow.
locale());
105 m_modelMainWindow.
locale());
108 QString description = QString (
"%1 (%2, %3)%4%5%6%7%8%9 %10 (%11, %12):")
109 .arg (tr (
"Graph Coordinates"))
111 .arg (nameYRadius ())
112 .arg (isConstraintX || isConstraintY ?
" with " :
"")
113 .arg (isConstraintX ? QString (nameXTheta ()) :
"")
114 .arg (isConstraintX ?
" > 0" :
"")
115 .arg (isConstraintX && isConstraintY ?
" and " :
"")
116 .arg ( isConstraintY ? QString (nameYRadius ()) :
"")
117 .arg ( isConstraintY ?
" > 0" :
"")
121 QGroupBox *panel =
new QGroupBox (description,
this);
122 layoutOuter->addWidget (panel);
124 QHBoxLayout *layout =
new QHBoxLayout (panel);
125 panel->setLayout (layout);
128 QLabel *labelGraphParLeft =
new QLabel (tr (
"("),
this);
129 layout->addWidget(labelGraphParLeft, 0);
131 m_editGraphX =
new QLineEdit;
134 m_editGraphX->setValidator (m_validatorGraphX);
136 m_editGraphX->setWhatsThis (tr (
"Enter the first graph coordinate of the axis point.\n\n" 137 "For cartesian plots this is X. For polar plots this is the angle Theta.\n\n" 138 "The expected format of the coordinate value is determined by the locale setting. If " 139 "typed values are not recognized as expected, check the locale setting in Settings / Main Window..."));
140 layout->addWidget(m_editGraphX, 0);
141 connect (m_editGraphX, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotTextChanged (
const QString &)));
143 QLabel *labelGraphComma =
new QLabel (tr (
", "),
this);
144 layout->addWidget(labelGraphComma, 0);
146 m_editGraphY =
new QLineEdit;
149 m_editGraphY->setValidator (m_validatorGraphY);
151 m_editGraphY->setWhatsThis (tr (
"Enter the second graph coordinate of the axis point.\n\n" 152 "For cartesian plots this is Y. For polar plots this is the radius R.\n\n" 153 "The expected format of the coordinate value is determined by the locale setting. If " 154 "typed values are not recognized as expected, check the locale setting in Settings / Main Window..."));
155 layout->addWidget(m_editGraphY, 0);
156 connect (m_editGraphY, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotTextChanged (
const QString &)));
158 QLabel *labelGraphParRight =
new QLabel (tr (
")"),
this);
159 layout->addWidget(labelGraphParRight, 0);
162 void DlgEditPointAxis::createHints (QVBoxLayout *layoutOuter,
172 QWidget *widget =
new QWidget;
173 layoutOuter->addWidget (widget, 0, Qt::AlignCenter);
175 QGridLayout *layout =
new QGridLayout;
176 widget->setLayout (layout);
180 QLabel *labelNumberCoordinates =
new QLabel (tr (
"Number of coordinates per axis point:"));
181 layout->addWidget (labelNumberCoordinates, row, 0, 1, 1);
182 QLineEdit *editNumberCoordinates =
new QLineEdit;
183 editNumberCoordinates->setWhatsThis (tr (
"Three axis points with two coordinates each are normally used. " 184 "If each axis point has only one known coordinate, then start over " 185 "with File / Import (Advanced) / 4 Axis Points."));
186 editNumberCoordinates->setReadOnly (
true);
191 layout->addWidget (editNumberCoordinates, row++, 1, 1, 1);
194 QLabel *labelLocale =
new QLabel (tr (
"Number format:"));
195 layout->addWidget (labelLocale, row, 0, 1, 1);
196 QLineEdit *editLocale =
new QLineEdit;
197 editLocale->setWhatsThis (tr (
"Locale which determines the allowed number formats. This is set by Settings / Main Window."));
198 editLocale->setReadOnly (
true);
200 editLocale->setText (locale);
202 layout->addWidget (editLocale, row++, 1, 1, 1);
205 void DlgEditPointAxis::createOkCancel (QVBoxLayout *layoutOuter)
207 QWidget *panel =
new QWidget (
this);
208 layoutOuter->addWidget (panel, 0, Qt::AlignCenter);
210 QHBoxLayout *layout =
new QHBoxLayout (panel);
211 panel->setLayout (layout);
213 m_btnOk =
new QPushButton (tr (
"Ok"),
this);
214 layout->addWidget(m_btnOk);
215 connect (m_btnOk, SIGNAL (released ()),
this, SLOT (accept ()));
217 m_btnCancel =
new QPushButton (tr (
"Cancel"),
this);
218 layout->addWidget(m_btnCancel);
219 connect (m_btnCancel, SIGNAL (released ()),
this, SLOT (reject ()));
222 void DlgEditPointAxis::initializeGraphCoordinates (
const double *xInitialValue,
223 const double *yInitialValue,
230 QString xTheta, yRadius;
231 if ((xInitialValue !=
nullptr) &&
232 (yInitialValue !=
nullptr)) {
246 m_editGraphX->setText (xTheta);
248 m_editGraphX->setText (
"");
252 m_editGraphY->setText (yRadius);
254 m_editGraphY->setText (
"");
258 bool DlgEditPointAxis::isCartesian ()
const 263 QChar DlgEditPointAxis::nameXTheta ()
const 265 return (isCartesian () ? QChar (
'X') :
THETA);
268 QChar DlgEditPointAxis::nameYRadius ()
const 270 return (isCartesian () ? QChar (
'Y') : QChar (
'R'));
275 double xTheta, yRadius;
280 m_editGraphY->text(),
287 isXOnly = m_editGraphY->text().isEmpty();
289 return QPointF (xTheta,
293 void DlgEditPointAxis::slotTextChanged (
const QString &)
298 QString DlgEditPointAxis::unitsType (
bool isXTheta)
const 300 if (isCartesian ()) {
315 void DlgEditPointAxis::updateControls ()
317 QString textX = m_editGraphX->text();
318 QString textY = m_editGraphY->text();
324 bool gotX = (!textX.isEmpty() &&
325 (m_validatorGraphX->
validate(textX, posX) == QValidator::Acceptable));
326 bool gotY = (!textY.isEmpty() &&
327 (m_validatorGraphY->
validate(textY, posY) == QValidator::Acceptable));
330 m_btnOk->setEnabled ((textX.isEmpty() && gotY) ||
331 (textY.isEmpty() && gotX));
334 m_editGraphX->setEnabled (!gotY);
335 m_editGraphY->setEnabled (!gotX);
340 m_btnOk->setEnabled (!textX.isEmpty () &&
342 (m_validatorGraphX->
validate(textX, posX) == QValidator::Acceptable) &&
343 (m_validatorGraphY->
validate(textY, posY) == QValidator::Acceptable));
Model for DlgSettingsGeneral and CmdSettingsGeneral.
CoordUnitsNonPolarTheta coordUnitsRadius() const
Get method for radius units.
CoordUnitsNonPolarTheta coordUnitsY() const
Get method for x units.
virtual QValidator::State validate(QString &input, int &pos) const =0
Validate according to the numeric format specific to the leaf class.
#define LOG4CPP_INFO_S(logger)
CoordUnitsPolarTheta coordUnitsTheta() const
Get method for theta unit.
const bool IS_NOT_X_THETA
DlgEditPointAxis(MainWindow &mainWindow, const DocumentModelCoords &modelCoords, const DocumentModelGeneral &modelGeneral, const MainWindowModel &modelMainWindow, const Transformation &transformation, DocumentAxesPointsRequired documentAxesPointsRequired, bool isXOnly=false, const double *xInitialValue=0, const double *yInitialValue=0)
Constructor for existing point which already has graph coordinates (which may be changed using this d...
QPointF posGraph(bool &isXOnly) const
Return the graph coordinates position specified by the user. Only applies if dialog was accepted...
CoordUnitsTime coordUnitsTime() const
Get method for time format when used.
Model for DlgSettingsMainWindow.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CoordUnitsDate coordUnitsDate() const
Get method for date format when used.
Model for DlgSettingsCoords and CmdSettingsCoords.
const int MIN_WIDTH_TO_FIT_STRANGE_UNITS
const Qt::Alignment ALIGNMENT
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
QLocale locale() const
Get method for locale.
log4cpp::Category * mainCat
DlgValidatorAbstract * createCartesianOrPolarWithNonPolarPolar(CoordScale coordScale, bool isCartesian, CoordUnitsNonPolarTheta coordUnitsCartesian, CoordUnitsNonPolarTheta coordUnitsPolar, CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QLocale &locale) const
Factory method for generating validators for either cartesian or polar case, when polar format is spe...
CoordsType coordsType() const
Get method for coordinates type.
QString coordUnitsPolarThetaToBriefType(CoordUnitsPolarTheta coordUnits)
QString coordUnitsNonPolarThetaToBriefType(CoordUnitsNonPolarTheta coordUnits)
CoordUnitsNonPolarTheta coordUnitsX() const
Get method for x units.
DocumentAxesPointsRequired
QString QLocaleToString(const QLocale &locale)
DlgValidatorAbstract * createCartesianOrPolarWithPolarPolar(CoordScale coordScale, bool isCartesian, CoordUnitsNonPolarTheta coordUnitsCartesian, CoordUnitsPolarTheta coordUnitsPolar, CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QLocale &locale) const
Factory method for generating validators for either cartesian or polar case, when polar format is spe...
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...