mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-04 11:30:52 +01:00
Element editor : add handler for modifie primitives
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4058 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -155,6 +155,17 @@ QVector<QPointF> QetGraphicsHandlerUtility::pointsForRect(const QRectF &rect)
|
||||
return vector;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QetGraphicsHandlerUtility::pointsForLine
|
||||
* The point that define a line in a QVector.
|
||||
* there is two points.
|
||||
* @param line
|
||||
* @return
|
||||
*/
|
||||
QVector<QPointF> QetGraphicsHandlerUtility::pointsForLine(const QLineF &line) {
|
||||
return (QVector<QPointF> {line.p1(), line.p2()});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QetGraphicsHandlerUtility::rectForPosAtIndex
|
||||
* Return a rectangle after modification of the point '@pos' at index '@index' of original rectangle '@old_rect'.
|
||||
@@ -180,3 +191,17 @@ QRectF QetGraphicsHandlerUtility::rectForPosAtIndex(const QRectF &old_rect, cons
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QetGraphicsHandlerUtility::lineForPosAtIndex
|
||||
* Return a line after modification of @pos at index @index of @old_line.
|
||||
* @param old_line
|
||||
* @param pos
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
QLineF QetGraphicsHandlerUtility::lineForPosAtIndex(const QLineF &old_line, const QPointF &pos, int index) {
|
||||
QLineF line = old_line;
|
||||
index == 0 ? line.setP1(pos) : line.setP2(pos);
|
||||
return line;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define QETGRAPHICSHANDLERUTILITY_H
|
||||
|
||||
#include <QRectF>
|
||||
#include <QLineF>
|
||||
|
||||
class QPainter;
|
||||
|
||||
@@ -47,7 +48,9 @@ class QetGraphicsHandlerUtility
|
||||
|
||||
public:
|
||||
static QVector <QPointF> pointsForRect (const QRectF &rect);
|
||||
static QVector <QPointF> pointsForLine (const QLineF &line);
|
||||
static QRectF rectForPosAtIndex (const QRectF &old_rect, const QPointF &pos, int index);
|
||||
static QLineF lineForPosAtIndex (const QLineF &old_line, const QPointF &pos, int index);
|
||||
};
|
||||
|
||||
#endif // QETGRAPHICSHANDLERUTILITY_H
|
||||
|
||||
Reference in New Issue
Block a user