mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Fixed small error in the way color ellipses were drawn (wrong coordinates).
This commit is contained in:
+3
-8
@@ -238,21 +238,16 @@ void EllipseColorMapper::draw(QPainter* painter)
|
||||
std::tr1::shared_ptr<Ellipse> outputEllipse = std::tr1::static_pointer_cast<Ellipse>(outputShape);
|
||||
qreal rotation = outputEllipse->getRotation();
|
||||
qDebug() << "Rotation: " << rotation << endl;
|
||||
QRect rect = outputEllipse->getBoundingRect();
|
||||
|
||||
painter->save(); // save painter state
|
||||
painter->resetTransform();
|
||||
painter->setBrush(color->getColor());
|
||||
// painter->translate()
|
||||
//painter->translate(0, rect.height()/2);
|
||||
const QPointF& p0 = outputEllipse->getVertex(0);
|
||||
const QPointF& center = outputEllipse->getCenter();
|
||||
float rx = rect.width() / 2;
|
||||
float ry = rect.height() / 2;
|
||||
float rx = outputEllipse->getHorizontalAxis().length() / 2;
|
||||
float ry = outputEllipse->getVerticalAxis().length() / 2;
|
||||
painter->translate(center);
|
||||
painter->rotate(rotation);
|
||||
painter->drawEllipse(QPointF(0,0), rx, ry);
|
||||
// painter->translate(p0.x() + rect.width()/2, p0.y() + rect.height() / 2);
|
||||
//painter->drawEllipse(rect);
|
||||
|
||||
painter->resetTransform();
|
||||
for (int i=0; i<4; i++) {
|
||||
|
||||
@@ -214,24 +214,27 @@ public:
|
||||
virtual QString getType() const { return "ellipse"; }
|
||||
|
||||
qreal getRotation() const {
|
||||
QPointF hAxis = getHorizontalAxis();
|
||||
QVector2D hAxis = getHorizontalAxis();
|
||||
return atan2(hAxis.y(), hAxis.x()) * 180.0 / M_PI;
|
||||
}
|
||||
|
||||
QRect getBoundingRect() const {
|
||||
return QRect(0, getVerticalAxis().manhattanLength(), getHorizontalAxis().manhattanLength(), getVerticalAxis().manhattanLength());
|
||||
}
|
||||
|
||||
// QRect getBoundingRect() const {
|
||||
// return QRect(0, getVerticalAxis().manhattanLength(),
|
||||
// getHorizontalAxis().manhattanLength(), getVerticalAxis().manhattanLength());
|
||||
// }
|
||||
//
|
||||
QPointF getCenter() const {
|
||||
return getVertex(0) + (getHorizontalAxis() / 2);
|
||||
return (QVector2D(getVertex(0)) + (getHorizontalAxis() / 2)).toPointF();
|
||||
}
|
||||
|
||||
QPointF getHorizontalAxis() const {
|
||||
return getVertex(2) - getVertex(0);
|
||||
QVector2D getHorizontalAxis() const {
|
||||
return QVector2D(getVertex(2)) - QVector2D(getVertex(0));
|
||||
}
|
||||
|
||||
QVector2D getVerticalAxis() const {
|
||||
return QVector2D(getVertex(1)) - QVector2D(getVertex(3));
|
||||
}
|
||||
|
||||
QPointF getVerticalAxis() const {
|
||||
return getVertex(1) - getVertex(3);
|
||||
}
|
||||
|
||||
//protected:
|
||||
|
||||
Reference in New Issue
Block a user