Commit 71a293c9 authored by Walsh, Michael's avatar Walsh, Michael Committed by Whitfield, Ross
Browse files

added rotation prop to 2DShape, gui saves to this prop

parent acc70b26
......@@ -167,6 +167,20 @@ public:
/// This method resizes the shape to fit into the new rectangle.
void setCurrentBoundingRect(const RectF &rect) { m_maskShapes.setCurrentBoundingRect(rect); }
/// Return bounding rotation of the currently selected shape in the "original"
/// coord system.
/// It doesn't depend on the zooming of the surface
double getCurrentBoundingRotation() const {
return m_maskShapes.getCurrentBoundingRotation();
}
/// Set new bounding rect of the currently selected shape in the "original"
/// coord system.
/// This method resizes the shape to fit into the new rectangle.
void setCurrentBoundingRotation(const double rotation) {
m_maskShapes.setCurrentBoundingRotation(rotation);
}
/// Initialize interactive shape creation.
/// @param type :: Type of the shape. For available types see code of
/// Shape2DCollection::createShape(const QString& type,int x,int y) const
......
......@@ -87,6 +87,10 @@ public:
virtual void adjustBoundingRect(double dx1, double dy1, double dx2, double dy2);
/// Set new bounding rect.
virtual void setBoundingRect(const RectF &rect);
/// Return the bounding rotation of the shape.
virtual double getBoundingRotation() const { return m_boundingRotation; }
/// Set new bounding rotation
virtual void setBoundingRotation(const double rotation) { m_boundingRotation = rotation; };
/// will the shape be selected if clicked at a point? By default return false.
virtual bool selectAt(const QPointF & /*unused*/) const { return false; }
/// is a point inside the shape (closed line)? By default return false.
......@@ -175,6 +179,7 @@ protected:
static const size_t NCommonCP;
static const qreal sizeCP;
RectF m_boundingRect;
double m_boundingRotation = 0.0;
QColor m_color;
QColor m_fill_color;
bool m_scalable; ///< shape can be scaled when zoomed
......
......@@ -71,6 +71,8 @@ public:
RectF getCurrentBoundingRect() const;
void setCurrentBoundingRect(const RectF &rect);
double getCurrentBoundingRotation() const;
void setCurrentBoundingRotation(const double rotation);
// double properties
QStringList getCurrentDoubleNames() const;
double getCurrentDouble(const QString &prop) const;
......
......@@ -652,6 +652,9 @@ void InstrumentWidgetMaskTab::setProperties() {
m_doublePropertyMap[prop] = name;
}
//rotation property
m_doubleManager->setValue(m_rotation, m_instrWidget->getSurface()->getCurrentBoundingRotation());
shapeChanged();
}
......@@ -673,6 +676,7 @@ void InstrumentWidgetMaskTab::doubleChanged(QtProperty *prop) {
QRectF rect(QPointF(x0, y0), QPointF(x1, y1));
m_instrWidget->getSurface()->setCurrentBoundingRect(RectF(rect));
m_instrWidget->getSurface()->setCurrentBoundingRotation(m_doubleManager->value(m_rotation));
} else {
QString name = m_doublePropertyMap[prop];
......
......@@ -634,6 +634,20 @@ void Shape2DCollection::setCurrentBoundingRect(const RectF &rect) {
}
}
double Shape2DCollection::getCurrentBoundingRotation() const {
if (m_currentShape) {
return m_currentShape->getBoundingRotation();
}
return 0.0;
}
void Shape2DCollection::setCurrentBoundingRotation(const double rotation) {
if (m_currentShape) {
m_currentShape->setBoundingRotation(rotation);
emit shapeChanged();
}
}
bool Shape2DCollection::isMasked(double x, double y) const {
QPointF p(x, y);
foreach (Shape2D *shape, m_shapes) {
......
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