You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
1.8 KiB
C++

#ifndef RECTANGLE_H
#define RECTANGLE_H
//Qt
#include <QDebug>
#include <QColor>
#include <QPainter>
#include <QPainterPath>
#include <QPaintEvent>
#include <QVector>
#include <QPainterPathStroker>
#include <QPen>
#include <QWidget>
#include <QPaintEngine>
#include <qmath.h>
#include <QPixmap>
class Rectangle
{
public:
Rectangle(){
_scalex = 1;
_scaley = 1;
}
Rectangle(double scalex,double scaley){
_scalex = scalex;
_scaley = scaley;
}
void paint(QPixmap&mp, QPaintEvent *event = nullptr){
QPainter painter;
painter.begin(&mp);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.scale(_scalex,_scaley);
painter.setPen(QPen(Qt::black, 0.8));
QRect r(_topLeft,_bottomRight);
_rect = r;
painter.drawRect(_rect);
painter.end();
}
double scalex() const
{
return _scalex;
}
void setScalex(double scalex)
{
_scalex = scalex;
}
double scaley() const
{
return _scaley;
}
void setScaley(double scaley)
{
_scaley = scaley;
}
QPoint topLeft() const
{
return _topLeft;
}
void setTopLeft(const QPoint &topLeft)
{
_topLeft = topLeft;
}
QPoint bottomRight() const
{
return _bottomRight;
}
void setBottomRight(const QPoint &bottomRight)
{
_bottomRight = bottomRight;
}
QColor rectColor() const
{
return _rectColor;
}
void setRectColor(const QColor &rectColor)
{
_rectColor = rectColor;
}
private:
QPoint _topLeft;
QPoint _bottomRight;
QColor _rectColor;
double _scalex;
double _scaley;
QRect _rect;
};
#endif // RECTANGLE_H