33 const double *xInitialValue,
34 const double *yInitialValue) :
35 QDialog (&mainWindow),
37 m_modelCoords (modelCoords),
38 m_modelGeneral (modelGeneral),
39 m_modelMainWindow (modelMainWindow)
43 QVBoxLayout *layout =
new QVBoxLayout;
46 setCursor (QCursor (Qt::ArrowCursor));
48 setWindowTitle (tr (
"Edit Curve Point(s)"));
50 createCoords (layout);
52 createOkCancel (layout);
54 initializeGraphCoordinates (xInitialValue,
67void DlgEditPointGraph::createCoords (QVBoxLayout *layoutOuter)
79 m_modelMainWindow.
locale());
86 m_modelMainWindow.
locale());
89 QString description = QString (
"%1 (%2, %3)%4%5%6%7%8%9 %10:")
90 .arg (tr (
"Graph Coordinates"))
93 .arg (isConstraintX || isConstraintY ?
" with " :
"")
94 .arg (isConstraintX ? QString (nameXTheta ()) :
"")
95 .arg (isConstraintX ?
" > 0" :
"")
96 .arg (isConstraintX && isConstraintY ?
" and " :
"")
97 .arg ( isConstraintY ? QString (nameYRadius ()) :
"")
98 .arg ( isConstraintY ?
" > 0" :
"")
100 QGroupBox *panel =
new QGroupBox (description,
this);
101 layoutOuter->addWidget (panel);
103 QHBoxLayout *layout =
new QHBoxLayout (panel);
104 panel->setLayout (layout);
107 QLabel *labelGraphParLeft =
new QLabel (tr (
"("),
this);
108 layout->addWidget(labelGraphParLeft, 0);
113 m_editGraphX->setValidator (m_validatorGraphX);
115 m_editGraphX->setWhatsThis (tr (
"Enter the first graph coordinate value to be applied to the graph points.\n\n"
116 "Leave this field empty if no value is to be applied to the graph points.\n\n"
117 "For cartesian plots this is the X coordinate. For polar plots this is the radius R.\n\n"
118 "The expected format of the coordinate value is determined by the locale setting. If "
119 "typed values are not recognized as expected, check the locale setting in Settings / Main Window..."));
120 layout->addWidget(m_editGraphX, 0);
121 connect (m_editGraphX, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotTextChanged (
const QString &)));
123 QLabel *labelGraphComma =
new QLabel (tr (
", "),
this);
124 layout->addWidget(labelGraphComma, 0);
129 m_editGraphY->setValidator (m_validatorGraphY);
131 m_editGraphY->setWhatsThis (tr (
"Enter the second graph coordinate value to be applied to the graph points.\n\n"
132 "Leave this field empty if no value is to be applied to the graph points.\n\n"
133 "For cartesian plots this is the Y coordinate. For polar plots this is the angle Theta.\n\n"
134 "The expected format of the coordinate value is determined by the locale setting. If "
135 "typed values are not recognized as expected, check the locale setting in Settings / Main Window..."));
136 layout->addWidget(m_editGraphY, 0);
137 connect (m_editGraphY, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotTextChanged (
const QString &)));
139 QLabel *labelGraphParRight =
new QLabel (tr (
")"),
this);
140 layout->addWidget(labelGraphParRight, 0);
143void DlgEditPointGraph::createHint (QVBoxLayout *layoutOuter)
148 QWidget *widget =
new QWidget;
149 layoutOuter->addWidget (widget, 0, Qt::AlignCenter);
151 QHBoxLayout *layout =
new QHBoxLayout;
152 widget->setLayout (layout);
155 QString hint = QString (
"%1: %2")
156 .arg (tr (
"Number format"))
158 QLabel *label =
new QLabel (hint);
159 layout->addWidget (label);
162void DlgEditPointGraph::createOkCancel (QVBoxLayout *layoutOuter)
164 QWidget *panel =
new QWidget (
this);
165 layoutOuter->addWidget (panel, 0, Qt::AlignCenter);
167 QHBoxLayout *layout =
new QHBoxLayout (panel);
168 panel->setLayout (layout);
170 m_btnOk =
new QPushButton (tr (
"Ok"),
this);
171 layout->addWidget(m_btnOk);
172 connect (m_btnOk, SIGNAL (released ()),
this, SLOT (accept ()));
174 m_btnCancel =
new QPushButton (tr (
"Cancel"),
this);
175 layout->addWidget(m_btnCancel);
176 connect (m_btnCancel, SIGNAL (released ()),
this, SLOT (reject ()));
179void DlgEditPointGraph::initializeGraphCoordinates (
const double *xInitialValue,
180 const double *yInitialValue,
185 QString xTheta, yRadius;
186 if ((xInitialValue !=
nullptr) &&
187 (yInitialValue !=
nullptr)) {
200 m_editGraphX->setText (xTheta);
201 m_editGraphY->setText (yRadius);
204bool DlgEditPointGraph::isCartesian ()
const
209QChar DlgEditPointGraph::nameXTheta ()
const
211 return (isCartesian () ? QChar (
'X') :
THETA);
214QChar DlgEditPointGraph::nameYRadius ()
const
216 return (isCartesian () ? QChar (
'Y') : QChar (
'R'));
227 QString xTextNotEmpty = QString (
"%1").arg (m_editGraphX->text().isEmpty () ?
"0" : m_editGraphX->text());
228 QString yTextNotEmpty = QString (
"%1").arg (m_editGraphY->text().isEmpty () ?
"0" : m_editGraphY->text());
237 isX = !m_editGraphX->text().isEmpty();
238 isY = !m_editGraphY->text().isEmpty();
241void DlgEditPointGraph::slotTextChanged (
const QString &)
247QString DlgEditPointGraph::unitsType (
bool isXTheta)
const
249 if (isCartesian ()) {
264void DlgEditPointGraph::updateControls ()
266 QString textX = m_editGraphX->text();
267 QString textY = m_editGraphY->text();
279 bool test2 = (!textX.isEmpty() || !textY.isEmpty());
283 if (!textX.isEmpty()) {
284 test3 &= (m_validatorGraphX->
validate(textX, posX) == QValidator::Acceptable);
286 if (!textY.isEmpty()) {
287 test3 &= (m_validatorGraphY->
validate(textY, posY) == QValidator::Acceptable);
290 m_btnOk->setEnabled (m_changed && test2 && test3);
QString coordUnitsNonPolarThetaToBriefType(CoordUnitsNonPolarTheta coordUnits)
QString coordUnitsPolarThetaToBriefType(CoordUnitsPolarTheta coordUnits)
const Qt::Alignment ALIGNMENT
const int MIN_WIDTH_TO_FIT_STRANGE_UNITS
const Qt::Alignment ALIGNMENT
const int MIN_WIDTH_TO_FIT_STRANGE_UNITS
log4cpp::Category * mainCat
QString QLocaleToString(const QLocale &locale)
Adds hover highlighting to QLineEdit.
void updateBackground()
Update background given the current state.
void posGraph(bool &isX, double &x, bool &isY, double &y) const
Return one or both coordinates. Only applies if dialog was accepted.
DlgEditPointGraph(MainWindow &mainWindow, const DocumentModelCoords &modelCoords, const DocumentModelGeneral &modelGeneral, const MainWindowModel &modelMainWindow, const Transformation &transformation, const double *xInitialValue=0, const double *yInitialValue=0)
Constructor for existing point which already has graph coordinates (which may be changed using this d...
virtual QValidator::State validate(QString &input, int &pos) const =0
Validate according to the numeric format specific to the leaf class.
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...
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...
Model for DlgSettingsCoords and CmdSettingsCoords.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordUnitsNonPolarTheta coordUnitsRadius() const
Get method for radius units.
CoordUnitsPolarTheta coordUnitsTheta() const
Get method for theta unit.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CoordUnitsNonPolarTheta coordUnitsY() const
Get method for x units.
CoordUnitsTime coordUnitsTime() const
Get method for time format when used.
CoordUnitsNonPolarTheta coordUnitsX() const
Get method for x units.
CoordsType coordsType() const
Get method for coordinates type.
CoordUnitsDate coordUnitsDate() const
Get method for date format when used.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Model for DlgSettingsMainWindow.
QLocale locale() const
Get method for locale.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
#define LOG4CPP_INFO_S(logger)