Commit 9255f397 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

pqLinePropertyWidget: handle 1D bounds

pqLinePropertyWidget now correctly handle resetting line along one of
the axes when the reference bounds are 1D.

Fixes #19075.
parent 21a0bb18
......@@ -196,61 +196,24 @@ vtkBoundingBox pqLinePropertyWidget::referenceBounds() const
}
//-----------------------------------------------------------------------------
void pqLinePropertyWidget::useXAxis()
void pqLinePropertyWidget::useAxis(int axis)
{
vtkSMNewWidgetRepresentationProxy* wdgProxy = this->widgetProxy();
vtkBoundingBox bbox = this->referenceBounds();
if (bbox.IsValid())
{
double center[3];
bbox.GetCenter(center);
center[0] -= bbox.GetLength(0) * 0.5;
vtkSMPropertyHelper(wdgProxy, "Point1WorldPosition").Set(center, 3);
bbox.GetCenter(center);
center[0] += bbox.GetLength(0) * 0.5;
vtkSMPropertyHelper(wdgProxy, "Point2WorldPosition").Set(center, 3);
wdgProxy->UpdateVTKObjects();
emit this->changeAvailable();
this->render();
}
}
const auto delta =
0.5 * (bbox.GetLength(axis) > 0 ? bbox.GetLength(axis) : bbox.GetDiagonalLength());
//-----------------------------------------------------------------------------
void pqLinePropertyWidget::useYAxis()
{
vtkSMNewWidgetRepresentationProxy* wdgProxy = this->widgetProxy();
vtkBoundingBox bbox = this->referenceBounds();
if (bbox.IsValid())
{
double center[3];
bbox.GetCenter(center);
center[1] -= bbox.GetLength(1) * 0.5;
vtkSMPropertyHelper(wdgProxy, "Point1WorldPosition").Set(center, 3);
bbox.GetCenter(center);
center[1] += bbox.GetLength(1) * 0.5;
vtkSMPropertyHelper(wdgProxy, "Point2WorldPosition").Set(center, 3);
wdgProxy->UpdateVTKObjects();
emit this->changeAvailable();
this->render();
}
}
//-----------------------------------------------------------------------------
void pqLinePropertyWidget::useZAxis()
{
vtkSMNewWidgetRepresentationProxy* wdgProxy = this->widgetProxy();
vtkBoundingBox bbox = this->referenceBounds();
if (bbox.IsValid())
{
double center[3];
bbox.GetCenter(center);
center[2] -= bbox.GetLength(2) * 0.5;
center[axis] -= delta;
vtkSMPropertyHelper(wdgProxy, "Point1WorldPosition").Set(center, 3);
bbox.GetCenter(center);
center[2] += bbox.GetLength(2) * 0.5;
center[axis] += delta;
vtkSMPropertyHelper(wdgProxy, "Point2WorldPosition").Set(center, 3);
wdgProxy->UpdateVTKObjects();
emit this->changeAvailable();
......
......@@ -65,9 +65,9 @@ public:
~pqLinePropertyWidget() override;
public slots:
void useXAxis();
void useYAxis();
void useZAxis();
void useXAxis() { this->useAxis(0); }
void useYAxis() { this->useAxis(1); }
void useZAxis() { this->useAxis(2); }
void centerOnBounds();
/**
......@@ -98,6 +98,8 @@ private:
class pqInternals;
QScopedPointer<pqInternals> Internals;
vtkBoundingBox referenceBounds() const;
void useAxis(int axis);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment