{
public:
qreal dx, dy;
qreal subtract_x, subtract_y;
qreal scale_factor;
bool test;
bool highlight_flag;
qint32 vector_color_type;
qreal snr;
qreal scale_max;
qreal dmag;
SimpleItem(qreal x_i, qreal y_i, qreal dx_i, qreal dy_i,
qreal subtract_x_i, qreal subtract_y_i,
qreal snr_i, bool test_i,
qreal scale_factor_i, qint32 vector_color_type_i,
qreal scale_max_i,
bool highlight_flag_i) {
this->setPos(x_i,y_i);
this->setAcceptHoverEvents(true);
this->setBoundingRegionGranularity(1);
dx = dx_i;
dy = dy_i;
subtract_x = subtract_x_i;
subtract_y = subtract_y_i;
snr = snr_i;
test = test_i;
highlight_flag = highlight_flag_i;
scale_factor = scale_factor_i;
vector_color_type = vector_color_type_i;
scale_max = scale_max_i;
dmag = sqrt(pow(dx-subtract_x,2) + pow(dy-subtract_y,2));
findColor();
}
{
}
{
qreal tangent = atan2 ((dy-subtract_y),(dx-subtract_x));
qreal x2 = (dx-subtract_x)*scale_factor;
qreal y2 = (dy-subtract_y)*scale_factor;
qreal pa_x = x2 - (scale_factor*dmag/6) * cos (tangent + M_PI / 7);
qreal pa_y = y2 - (scale_factor*dmag/6) * sin (tangent + M_PI / 7);
qreal pb_x = x2 - (scale_factor*dmag/6) * cos (tangent - M_PI / 7);
qreal pb_y = y2 - (scale_factor*dmag/6) * sin (tangent - M_PI / 7);
QVector<QLineF> points(3);
points
[0] = QLineF(0,
0,x2,y2
);
points
[1] = QLineF(pa_x,pa_y,x2,y2
);
points
[2] = QLineF(pb_x,pb_y,x2,y2
);
textPen.setWidth(2);
textPen.setCapStyle(Qt::RoundCap);
painter->setPen(textPen);
painter->drawLines(points);
}
};
class SimpleItem : public QGraphicsItem
{
public:
qreal dx, dy;
qreal subtract_x, subtract_y;
qreal scale_factor;
bool test;
bool highlight_flag;
qint32 vector_color_type;
qreal snr;
qreal scale_max;
QPen textPen;
QColor color;
qreal dmag;
SimpleItem(qreal x_i, qreal y_i, qreal dx_i, qreal dy_i,
qreal subtract_x_i, qreal subtract_y_i,
qreal snr_i, bool test_i,
qreal scale_factor_i, qint32 vector_color_type_i,
qreal scale_max_i,
bool highlight_flag_i) {
this->setPos(x_i,y_i);
this->setAcceptHoverEvents(true);
this->setBoundingRegionGranularity(1);
dx = dx_i;
dy = dy_i;
subtract_x = subtract_x_i;
subtract_y = subtract_y_i;
snr = snr_i;
test = test_i;
highlight_flag = highlight_flag_i;
scale_factor = scale_factor_i;
vector_color_type = vector_color_type_i;
scale_max = scale_max_i;
dmag = sqrt(pow(dx-subtract_x,2) + pow(dy-subtract_y,2));
findColor();
}
QRectF boundingRect() const
{
return QRectF(-10,-10,20,20);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
textPen = QPen(color);
qreal tangent = atan2 ((dy-subtract_y),(dx-subtract_x));
qreal x2 = (dx-subtract_x)*scale_factor;
qreal y2 = (dy-subtract_y)*scale_factor;
qreal pa_x = x2 - (scale_factor*dmag/6) * cos (tangent + M_PI / 7);
qreal pa_y = y2 - (scale_factor*dmag/6) * sin (tangent + M_PI / 7);
qreal pb_x = x2 - (scale_factor*dmag/6) * cos (tangent - M_PI / 7);
qreal pb_y = y2 - (scale_factor*dmag/6) * sin (tangent - M_PI / 7);
QVector<QLineF> points(3);
points[0] = QLineF(0,0,x2,y2);
points[1] = QLineF(pa_x,pa_y,x2,y2);
points[2] = QLineF(pb_x,pb_y,x2,y2);
textPen.setWidth(2);
textPen.setCapStyle(Qt::RoundCap);
painter->setPen(textPen);
painter->drawLines(points);
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks