Skip to content
Snippets Groups Projects
Commit e42b01e0 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

[m.0] Set limits for rectangle mask spinboxes (#1049) (Closes #1049)

Merging branch 'm.0'  into 'main'.

See merge request !2791
parents e3240b9f 5f487b0d
No related branches found
No related tags found
1 merge request!2791Set limits for rectangle mask spinboxes (#1049)
Pipeline #179112 failed
...@@ -29,7 +29,7 @@ Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius, ...@@ -29,7 +29,7 @@ Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius,
, m_yr(yradius) , m_yr(yradius)
, m_theta(theta) , m_theta(theta)
{ {
if (xradius <= 0.0 || yradius <= 0.0) if (xradius < 0.0 || yradius < 0.0)
throw std::runtime_error( throw std::runtime_error(
"Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius) " "Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius) "
"-> Error. Radius cannot be negative\n"); "-> Error. Radius cannot be negative\n");
......
...@@ -25,16 +25,16 @@ Rectangle::Rectangle(double xlow, double ylow, double xup, double yup, bool inve ...@@ -25,16 +25,16 @@ Rectangle::Rectangle(double xlow, double ylow, double xup, double yup, bool inve
: IShape2D("Rectangle") : IShape2D("Rectangle")
, m_inverted(inverted) , m_inverted(inverted)
{ {
if (xup <= xlow) { if (xup < xlow) {
std::ostringstream message; std::ostringstream message;
message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. "; message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. ";
message << " xup <= xlow" << std::endl; message << " xup < xlow" << std::endl;
throw std::runtime_error(message.str()); throw std::runtime_error(message.str());
} }
if (yup <= ylow) { if (yup < ylow) {
std::ostringstream message; std::ostringstream message;
message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. "; message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. ";
message << " yup <= ylow" << std::endl; message << " yup < ylow" << std::endl;
throw std::runtime_error(message.str()); throw std::runtime_error(message.str());
} }
m_xlow = xlow; m_xlow = xlow;
......
...@@ -31,6 +31,13 @@ void addSpinBox(MaskItem* mask, QFormLayout* layout, DoubleProperty& property) ...@@ -31,6 +31,13 @@ void addSpinBox(MaskItem* mask, QFormLayout* layout, DoubleProperty& property)
auto* spinbox = new DSpinBox(&property); auto* spinbox = new DSpinBox(&property);
layout->addRow(property.label() + ":", spinbox); layout->addRow(property.label() + ":", spinbox);
QObject::connect(spinbox, &DSpinBox::valueChanged, [mask](double) { QObject::connect(spinbox, &DSpinBox::valueChanged, [mask](double) {
// set dynamic limits for rectangle
if (auto* rect = dynamic_cast<RectangleItem*>(mask)) {
rect->xLow().setLimits(RealLimits::upperLimited(rect->xUp().dVal()));
rect->xUp().setLimits(RealLimits::lowerLimited(rect->xLow().dVal()));
rect->yLow().setLimits(RealLimits::upperLimited(rect->yUp().dVal()));
rect->yUp().setLimits(RealLimits::lowerLimited(rect->yLow().dVal()));
}
gDoc->setModified(); gDoc->setModified();
ASSERT(mask); ASSERT(mask);
emit mask->maskGeometryChanged(); emit mask->maskGeometryChanged();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment