19 #include <QPainterPath> 38 QVector<QPointF> vector;
40 vector << rect.topLeft();
41 point = rect.center();
42 point.setY(rect.top());
44 vector << rect.topRight();
45 point = rect.center();
46 point.setX(rect.left());
48 point.setX(rect.right());
50 vector << rect.bottomLeft();
51 point = rect.center();
52 point.setY(rect.bottom());
54 vector << rect.bottomRight();
66 return (QVector<QPointF> {line.p1(), line.p2()});
80 QVector<QPointF> vector;
82 path.arcTo(rect, start_angle, 0);
83 vector.append(path.currentPosition());
84 path.arcTo(rect, start_angle, span_angle);
85 vector.append(path.currentPosition());
101 if (index < 0 || index > 7)
return old_rect;
103 QRectF rect = old_rect;
104 if (index == 0) rect.setTopLeft(pos);
105 else if (index == 1) rect.setTop(pos.y());
106 else if (index == 2) rect.setTopRight(pos);
107 else if (index == 3) rect.setLeft(pos.x());
108 else if (index == 4) rect.setRight(pos.x());
109 else if (index == 5) rect.setBottomLeft(pos);
110 else if (index == 6) rect.setBottom(pos.y());
111 else if (index == 7) rect.setBottomRight(pos);
128 if (index < 0 || index > 7)
return old_rect;
130 QRectF rect = old_rect;
131 QPointF center = rect.center();
134 qreal x = pos.x() + (pos.x() - rect.topLeft().x());
135 qreal y = pos.y() + (pos.y() - rect.topLeft().y());
136 rect.setTopLeft(QPointF(x,y));
138 else if (index == 1) {
139 qreal y = pos.y() + (pos.y() - rect.topLeft().y());
142 else if (index == 2) {
143 qreal x = pos.x() + (pos.x() - rect.topRight().x());
144 qreal y = pos.y() + (pos.y() - rect.topLeft().y());
145 rect.setTopRight(QPointF(x,y));
147 else if (index == 3) {
148 qreal x = pos.x() + (pos.x() - rect.left());
151 else if (index == 4) {
152 qreal x = pos.x() + (pos.x() - rect.right());
155 else if (index == 5) {
156 qreal x = pos.x() + (pos.x() - rect.bottomLeft().x());
157 qreal y = pos.y() + (pos.y() - rect.bottomLeft().y());
158 rect.setBottomLeft(QPointF(x,y));
160 else if (index == 6) {
161 qreal y = pos.y() + (pos.y() - rect.bottom());
164 else if (index == 7) {
165 qreal x = pos.x() + (pos.x() - rect.bottomRight().x());
166 qreal y = pos.y() + (pos.y() - rect.bottomRight().y());
167 rect.setBottomRight(QPointF(x,y));
170 rect.moveCenter(center);
183 QLineF line = old_line;
184 index == 0 ? line.setP1(pos) : line.setP2(pos);
200 for (
int i=1 ; i<old_polygon.size() ; i++)
202 QPointF A = old_polygon.at(i-1);
203 QPointF B = old_polygon.at(i);
204 QLineF line_a(A, pos);
205 QLineF line_b(pos, B);
206 qreal angle = line_a.angleTo(line_b);
215 if (angle > max_angle)
224 QLineF line_a(old_polygon.last(), pos);
225 QLineF line_b(pos, old_polygon.first());
227 qreal angle = line_a.angleTo(line_b);
231 if (angle > max_angle)
234 index=old_polygon.size();
238 QPolygonF polygon = old_polygon;
239 polygon.insert(index, pos);
257 if(mode == Qt::AbsoluteSize)
259 QPointF X = rect.topRight();
263 QPointF Y = rect.topRight();
269 qreal half_width = rect.width()/2;
270 qreal x_percent = std::min(xRadius, 100.00)/100;
271 QPointF X(rect.right() - half_width*x_percent,
275 qreal half_height = rect.height()/2;
276 qreal y_percent = std::min(yRadius, 100.00)/100;
277 QPointF Y(rect.right(),
278 rect.top()+ half_height*y_percent);
295 if (mode == Qt::AbsoluteSize)
299 QPointF
tr = rect.topRight();
300 qreal x =
tr.x() - pos.x();
304 else if (x > rect.width()/2) {
312 QPointF
tr = rect.topRight();
313 qreal y = pos.y() -
tr.y();
317 else if (y > rect.height()/2) {
331 if (pos.x() < rect.center().x()) {
334 else if (pos.x() > rect.right()) {
343 if (pos.y() < rect.top()) {
346 else if (pos.y() > rect.center().y()) {
360 return ((value - min) * 100) / (max - min);
static QVector< QPointF > pointsForArc(const QRectF &rect, qreal start_angle, qreal span_angle)
QetGraphicsHandlerUtility::pointsForArc Return the points for the given arc. The first value in the v...
static QVector< QPointF > pointForRadiusRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
QetGraphicsHandlerUtility::pointForRadiusRect.
static qreal radiusForPosAtIndex(const QRectF &rect, const QPointF &pos, int index, Qt::SizeMode mode=Qt::AbsoluteSize)
QetGraphicsHandlerUtility::radiusForPosAtIndex.
static QLineF lineForPosAtIndex(const QLineF &old_line, const QPointF &pos, int index)
QetGraphicsHandlerUtility::lineForPosAtIndex Return a line after modification of at index of ...
static QPolygonF polygonForInsertPoint(const QPolygonF &old_polygon, bool closed, const QPointF &pos)
QetGraphicsHandlerUtility::polygonForInsertPoint.
static QRectF mirrorRectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::mirrorRectForPosAtIndex Return a rectangle after modification of the point...
static QRectF rectForPosAtIndex(const QRectF &old_rect, const QPointF &pos, int index)
QetGraphicsHandlerUtility::rectForPosAtIndex Return a rectangle after modification of the point '' at...
static QVector< QPointF > pointsForRect(const QRectF &rect)
QetGraphicsHandlerUtility::pointsForRect Return the keys points of the rectangle, stored in a vector...
static QVector< QPointF > pointsForLine(const QLineF &line)
QetGraphicsHandlerUtility::pointsForLine The point that define a line in a QVector. there is two points.
static qreal percentageInRange(qreal min, qreal max, qreal value)