QVector<Point> to QVector<Point*>
This commit is contained in:
16
Canvas.cpp
16
Canvas.cpp
@@ -97,13 +97,15 @@ void Canvas::mousePressEvent(QMouseEvent* event)
|
||||
params.push_back(x1);
|
||||
params.push_back(y1);
|
||||
|
||||
points.push_back(Point(x1, y1, obj_count));
|
||||
points.push_back(Point(x2, y2, obj_count));
|
||||
points.push_back(new Point(x1, y1, obj_count));
|
||||
points.push_back(new Point(x2, y2, obj_count));
|
||||
|
||||
current_line->p1.x = x1;
|
||||
current_line->p1.y = y1;
|
||||
current_line->p2.x = x2;
|
||||
current_line->p2.y = y2;
|
||||
current_line->p1_ref = points[points.size() - 2];
|
||||
current_line->p2_ref = points[points.size() - 1];
|
||||
}
|
||||
else {
|
||||
*current_line->p2.x = scene.x();
|
||||
@@ -115,7 +117,9 @@ void Canvas::mousePressEvent(QMouseEvent* event)
|
||||
delete current_line;
|
||||
current_line = nullptr;
|
||||
|
||||
delete points.back();
|
||||
points.pop_back();
|
||||
delete points.back();
|
||||
points.pop_back();
|
||||
delete params.back();
|
||||
params.pop_back();
|
||||
@@ -237,10 +241,10 @@ void Canvas::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (draggedPoint) {
|
||||
QPointF pos = event->pos() - dragOffset;
|
||||
for (Point pair : points) {
|
||||
if (areCoincident(draggedPoint, &pair)) {
|
||||
*pair.x = pos.x();
|
||||
*pair.y = pos.y();
|
||||
for (Point* pair : points) {
|
||||
if (areCoincident(draggedPoint, pair)) {
|
||||
*pair->x = pos.x();
|
||||
*pair->y = pos.y();
|
||||
}
|
||||
}
|
||||
*draggedPoint->x = pos.x();
|
||||
|
||||
Reference in New Issue
Block a user