1 /* 2 Copyright 2006-2019 The QElectroTech Team 3 This file is part of QElectroTech. 4 5 QElectroTech is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 2 of the License, or 8 (at your option) any later version. 9 10 QElectroTech is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 #ifndef QETGRAPHICSHANDLERUTILITY_H 19 #define QETGRAPHICSHANDLERUTILITY_H 20 21 #include <QRectF> 22 #include <QLineF> 23 #include <QColor> 24 #include <QPolygonF> 25 26 class QPainter; 27 28 /** 29 * @brief The QetGraphicsHandlerUtility class 30 * This class provide some methods to create and use handler for 31 * modify graphics shape like line rectangle etc... 32 * They also provide some conveniance static method. 33 */ 34 class QetGraphicsHandlerUtility 35 { 36 public: 37 static QVector <QPointF> pointsForRect (const QRectF &rect); 38 static QVector <QPointF> pointsForLine (const QLineF &line); 39 static QVector <QPointF> pointsForArc (const QRectF &rect, qreal start_angle, qreal span_angle); 40 static QRectF rectForPosAtIndex (const QRectF &old_rect, const QPointF &pos, int index); 41 static QRectF mirrorRectForPosAtIndex (const QRectF &old_rect, const QPointF &pos, int index); 42 static QLineF lineForPosAtIndex (const QLineF &old_line, const QPointF &pos, int index); 43 static QPolygonF polygonForInsertPoint(const QPolygonF &old_polygon, bool closed, const QPointF &pos); 44 static QVector <QPointF> pointForRadiusRect (const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize); 45 static qreal radiusForPosAtIndex (const QRectF &rect, const QPointF &pos, int index, Qt::SizeMode mode = Qt::AbsoluteSize); 46 static qreal percentageInRange(qreal min, qreal max, qreal value); 47 }; 48 49 #endif // QETGRAPHICSHANDLERUTILITY_H 50