Minor change : Change behavior of shape creation in diagram editor, to be same has element editor

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3580 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-12-29 23:18:00 +00:00
parent 0e3593e600
commit 991a9bfbc9
4 changed files with 142 additions and 58 deletions

View File

@@ -93,6 +93,15 @@ void QetShapeItem::setP2(QPointF P2) {
setTransformOriginPoint(boundingRect().center());
}
/**
* @brief QetShapeItem::pointCount
* @return the number of point in the polygon
*/
int QetShapeItem::pointsCount() const
{
return m_polygon.size();
}
/**
* @brief QetShapeItem::setNextPoint
* Add a new point to the curent polygon
@@ -104,6 +113,29 @@ void QetShapeItem::setNextPoint(QPointF P) {
setTransformOriginPoint(boundingRect().center());
}
/**
* @brief QetShapeItem::removePoints
* Number of point to remove on the polygon
* If @number is superior to number of polygon points-2,
* all points of polygon will be removed except the first two (minimum point for the polygon);
*/
void QetShapeItem::removePoints(int number)
{
if (pointsCount() == 2 || number < 1) return;
if ((pointsCount()-2) < number)
number = pointsCount() - 2;
int i = 0;
do
{
i++;
prepareGeometryChange();
m_polygon.pop_back();
setTransformOriginPoint(boundingRect().center());
} while (i < number);
}
/**
* @brief QetShapeItem::boundingRect
* @return the bounding rect of this item