Commit dcdea5fe 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 49f1451e
...@@ -171,6 +171,20 @@ public: ...@@ -171,6 +171,20 @@ public:
m_maskShapes.setCurrentBoundingRect(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. /// Initialize interactive shape creation.
/// @param type :: Type of the shape. For available types see code of /// @param type :: Type of the shape. For available types see code of
/// Shape2DCollection::createShape(const QString& type,int x,int y) const /// Shape2DCollection::createShape(const QString& type,int x,int y) const
......
...@@ -88,6 +88,10 @@ public: ...@@ -88,6 +88,10 @@ public:
double dy2); double dy2);
/// Set new bounding rect. /// Set new bounding rect.
virtual void setBoundingRect(const RectF &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. /// will the shape be selected if clicked at a point? By default return false.
virtual bool selectAt(const QPointF & /*unused*/) const { return false; } virtual bool selectAt(const QPointF & /*unused*/) const { return false; }
/// is a point inside the shape (closed line)? By default return false. /// is a point inside the shape (closed line)? By default return false.
...@@ -179,6 +183,7 @@ protected: ...@@ -179,6 +183,7 @@ protected:
static const size_t NCommonCP; static const size_t NCommonCP;
static const qreal sizeCP; static const qreal sizeCP;
RectF m_boundingRect; RectF m_boundingRect;
double m_boundingRotation = 0.0;
QColor m_color; QColor m_color;
QColor m_fill_color; QColor m_fill_color;
bool m_scalable; ///< shape can be scaled when zoomed bool m_scalable; ///< shape can be scaled when zoomed
......
...@@ -71,6 +71,8 @@ public: ...@@ -71,6 +71,8 @@ public:
RectF getCurrentBoundingRect() const; RectF getCurrentBoundingRect() const;
void setCurrentBoundingRect(const RectF &rect); void setCurrentBoundingRect(const RectF &rect);
double getCurrentBoundingRotation() const;
void setCurrentBoundingRotation(const double rotation);
// double properties // double properties
QStringList getCurrentDoubleNames() const; QStringList getCurrentDoubleNames() const;
double getCurrentDouble(const QString &prop) const; double getCurrentDouble(const QString &prop) const;
......
...@@ -721,6 +721,9 @@ void InstrumentWidgetMaskTab::setProperties() { ...@@ -721,6 +721,9 @@ void InstrumentWidgetMaskTab::setProperties() {
m_doublePropertyMap[prop] = name; m_doublePropertyMap[prop] = name;
} }
//rotation property
m_doubleManager->setValue(m_rotation, m_instrWidget->getSurface()->getCurrentBoundingRotation());
shapeChanged(); shapeChanged();
} }
...@@ -748,6 +751,7 @@ void InstrumentWidgetMaskTab::doubleChanged(QtProperty *prop) { ...@@ -748,6 +751,7 @@ void InstrumentWidgetMaskTab::doubleChanged(QtProperty *prop) {
QRectF rect(QPointF(x0, y0), QPointF(x1, y1)); QRectF rect(QPointF(x0, y0), QPointF(x1, y1));
m_instrWidget->getSurface()->setCurrentBoundingRect(RectF(rect)); m_instrWidget->getSurface()->setCurrentBoundingRect(RectF(rect));
m_instrWidget->getSurface()->setCurrentBoundingRotation(m_doubleManager->value(m_rotation));
} else { } else {
QString name = m_doublePropertyMap[prop]; QString name = m_doublePropertyMap[prop];
......
...@@ -645,6 +645,20 @@ void Shape2DCollection::setCurrentBoundingRect(const RectF &rect) { ...@@ -645,6 +645,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 { bool Shape2DCollection::isMasked(double x, double y) const {
QPointF p(x, y); QPointF p(x, y);
foreach (Shape2D *shape, m_shapes) { 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