[qet] qet/qet: [5863] Diagram editor : when user add a polygon, if the last point is at the same position of the first, then the polygon is closed. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [5863] Diagram editor : when user add a polygon, if the last point is at the same position of the first, then the polygon is closed.
- From: subversion@xxxxxxxxxxxxx
- Date: Thu, 16 May 2019 19:38:14 +0200
Revision: 5863
Author: blacksun
Date: 2019-05-16 19:38:13 +0200 (Thu, 16 May 2019)
Log Message:
-----------
Diagram editor : when user add a polygon, if the last point is at the same position of the first, then the polygon is closed.
Undo commit 5862
Modified Paths:
--------------
trunk/sources/diagramevent/diagrameventaddshape.cpp
trunk/sources/qetdiagrameditor.cpp
Modified: trunk/sources/diagramevent/diagrameventaddshape.cpp
===================================================================
--- trunk/sources/diagramevent/diagrameventaddshape.cpp 2019-05-16 16:06:42 UTC (rev 5862)
+++ trunk/sources/diagramevent/diagrameventaddshape.cpp 2019-05-16 17:38:13 UTC (rev 5863)
@@ -182,6 +182,15 @@
//<double clic is used to finish polyline, but they also add two points at the same pos
//<(double clic is a double press event), so we remove the last point of polyline
m_shape_item->removePoints();
+
+ //If the last is at the same pos of the first point
+ //that mean user want a closed polygon, so we remove the last point and close polygon
+ QPolygonF polygon = m_shape_item->polygon();
+ if (polygon.first() == polygon.last())
+ {
+ m_shape_item->removePoints();
+ m_shape_item->setClosed(true);
+ }
m_diagram->undoStack().push (new AddItemCommand<QetShapeItem *> (m_shape_item, m_diagram));
m_shape_item = nullptr; //< set to nullptr for create new shape at next left clic
event->setAccepted(true);
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2019-05-16 16:06:42 UTC (rev 5862)
+++ trunk/sources/qetdiagrameditor.cpp 2019-05-16 17:38:13 UTC (rev 5863)
@@ -601,7 +601,7 @@
add_rectangle->setData("rectangle");
add_ellipse ->setData("ellipse");
add_polyline ->setData("polyline");
-
+
for(QAction *action : m_add_item_actions_group.actions()) {
action->setCheckable(true);
}
@@ -1300,11 +1300,8 @@
diagram_event = new DiagramEventAddShape (d, QetShapeItem::Rectangle);
else if (value == "ellipse")
diagram_event = new DiagramEventAddShape (d, QetShapeItem::Ellipse);
- else if (value == "polyline") {
+ else if (value == "polyline")
diagram_event = new DiagramEventAddShape (d, QetShapeItem::Polygon);
- setToolTip(tr("Double-click pour terminer la forme"));
- setToolTipDuration(2000);
- }
else if (value == "image")
{
DiagramEventAddImage *deai = new DiagramEventAddImage(d);