19 #include <QGridLayout>
22 #include <QMessageBox>
23 #include <QPushButton>
25 static void EmitWarning(
const QString &message,
const QString &title)
28 QMessageBox::warning(
nullptr, title, message);
33 return std::log10(std::abs(value)) + 1.0 <= std::numeric_limits<double>::digits10;
39 if (!hasValidPrecision)
40 EmitWarning(QString(
"Point set %1 coordinate is outside double precision range.").arg(name),
41 "Invalid point set input");
43 return hasValidPrecision;
46 struct QmitkEditPointDialogData
57 : QDialog(parent, f), d(new QmitkEditPointDialogData)
59 this->setWindowTitle(
"Edit Point Dialog");
60 d->m_PointSet =
nullptr;
62 d->m_XCoord =
new QLineEdit;
63 d->m_YCoord =
new QLineEdit;
64 d->m_ZCoord =
new QLineEdit;
65 QPushButton *_OKButton =
new QPushButton(
"OK");
68 auto layout =
new QGridLayout;
69 layout->addWidget(
new QLabel(
"X: "), 0, 0, 1, 1);
70 layout->addWidget(
d->m_XCoord, 0, 1, 1, 1);
71 layout->addWidget(
new QLabel(
"Y: "), 1, 0, 1, 1);
72 layout->addWidget(
d->m_YCoord, 1, 1, 1, 1);
73 layout->addWidget(
new QLabel(
"Z: "), 2, 0, 1, 1);
74 layout->addWidget(
d->m_ZCoord, 2, 1, 1, 1);
75 layout->addWidget(_OKButton, 3, 0, 2, 1);
76 this->setLayout(layout);
86 d->m_PointSet = _PointSet;
87 d->m_PointId = _PointId;
88 d->m_Timestep = timestep;
90 d->m_XCoord->setText(QString::number(p.GetElement(0),
'f', 3));
91 d->m_YCoord->setText(QString::number(p.GetElement(1),
'f', 3));
92 d->m_ZCoord->setText(QString::number(p.GetElement(2),
'f', 3));
97 if (
d->m_PointSet ==
nullptr)
103 auto x =
d->m_XCoord->text().toDouble();
104 auto y =
d->m_YCoord->text().toDouble();
105 auto z =
d->m_ZCoord->text().toDouble();
109 auto point =
d->m_PointSet->GetPoint(
d->m_PointId,
d->m_Timestep);
110 point.SetElement(0, x);
111 point.SetElement(1, y);
112 point.SetElement(2, z);
113 d->m_PointSet->SetPoint(
d->m_PointId, point);
QmitkEditPointDialogData * d
DataType::PointIdentifier PointIdentifier
Data structure which stores a set of points. Superclass of mitk::Mesh.
static bool ValidatePrecision(double value)
virtual ~QmitkEditPointDialog()
static bool ValidateCoordinate(const QString &name, double value)
static void EmitWarning(const QString &message, const QString &title)
QmitkEditPointDialog(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
void OnOkButtonClicked(bool)
void SetPoint(mitk::PointSet *_PointSet, mitk::PointSet::PointIdentifier _PointId, int timestep=0)