-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to split polyline #1693
Option to split polyline #1693
Conversation
src/tiled/changepolygon.cpp
Outdated
mSecondPolyline->setPolygon(secondPolygon); | ||
|
||
mMapDocument->mapObjectModel()->setObjectPolygon(mFirstPolyline, firstPolygon); | ||
mFirstPolyline->setPropertyChanged(MapObject::ShapeProperty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is the undo, whether the property has been changed or not should be set back to the state it had when redo
was called.
src/tiled/changepolygon.cpp
Outdated
QPolygonF secondPolygon = mSecondPolyline->polygon(); | ||
|
||
firstPolygon.append(secondPolygon); | ||
secondPolygon = firstPolygon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please skip this assignment and just do mSecondPolyline->setPolygon(firstPolygon);
.
src/tiled/changepolygon.cpp
Outdated
: mMapDocument(mapDocument) | ||
, mFirstPolyline(mapObject) | ||
, mEdgeIndex(index) | ||
, mObjectIndex(-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than putting the new polyline as the last object in the group, it would be nice to use the index of the polyline being split + 1.
src/tiled/changepolygon.cpp
Outdated
QPolygonF firstPolygon = mFirstPolyline->polygon(); | ||
QPolygonF secondPolygon = mSecondPolyline->polygon(); | ||
|
||
firstPolygon.append(secondPolygon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang complains here:
changepolygon.cpp:102:25: error: no viable conversion from 'QPolygonF' to
'const QPointF'
firstPolygon.append(secondPolygon);
^~~~~~~~~~~~~
/opt/qt54/include/QtCore/qpoint.h:205:21: note: candidate constructor (the
implicit copy constructor) not viable: no known conversion from
'QPolygonF' to 'const QPointF &' for 1st argument
class Q_CORE_EXPORT QPointF
^
/opt/qt54/include/QtCore/qpoint.h:205:21: note: candidate constructor (the
implicit move constructor) not viable: no known conversion from
'QPolygonF' to 'QPointF &&' for 1st argument
class Q_CORE_EXPORT QPointF
^
/opt/qt54/include/QtCore/qpoint.h:270:34: note: candidate constructor not
viable: no known conversion from 'QPolygonF' to 'const QPoint &' for 1st
argument
Q_DECL_CONSTEXPR inline QPointF::QPointF(const QPoint &p) : xp(p.x()), y...
^
/opt/qt54/include/QtGui/qpolygon.h:135:5: note: candidate function
operator QVariant() const;
^
/opt/qt54/include/QtCore/qvector.h:130:26: note: passing argument to parameter
't' here
void append(const T &t);
^
1 error generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup I saw this but couldn't understand why it was happening 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's compiling against Qt 5.4, which does not have a QVector::append
overload that will append a vector. You can use the +=
operator instead:
firstPolygon += secondPolygon;
Edit: though actually, I think I'll change the Qt dependency to require at least Qt 5.6.
When you delete the first or the last segment of a polyline, it creates an additional empty polygon object. It should in this case just delete the segment. |
If two consecutive nodes are selected in a polyline and then the segment between them can be deleted to split polyline into two polylines.