Skip to content
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

Merged
merged 3 commits into from Aug 24, 2017
Merged

Option to split polyline #1693

merged 3 commits into from Aug 24, 2017

Conversation

@ketanhwr
Copy link
Contributor

@ketanhwr ketanhwr commented Aug 21, 2017

If two consecutive nodes are selected in a polyline and then the segment between them can be deleted to split polyline into two polylines.

mSecondPolyline->setPolygon(secondPolygon);

mMapDocument->mapObjectModel()->setObjectPolygon(mFirstPolyline, firstPolygon);
mFirstPolyline->setPropertyChanged(MapObject::ShapeProperty);

This comment has been minimized.

@bjorn

bjorn Aug 21, 2017
Member

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.

QPolygonF secondPolygon = mSecondPolyline->polygon();

firstPolygon.append(secondPolygon);
secondPolygon = firstPolygon;

This comment has been minimized.

@bjorn

bjorn Aug 21, 2017
Member

Please skip this assignment and just do mSecondPolyline->setPolygon(firstPolygon);.

: mMapDocument(mapDocument)
, mFirstPolyline(mapObject)
, mEdgeIndex(index)
, mObjectIndex(-1)

This comment has been minimized.

@bjorn

bjorn Aug 21, 2017
Member

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.

QPolygonF firstPolygon = mFirstPolyline->polygon();
QPolygonF secondPolygon = mSecondPolyline->polygon();

firstPolygon.append(secondPolygon);

This comment has been minimized.

@Ablu

Ablu Aug 21, 2017
Contributor

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.

This comment has been minimized.

@ketanhwr

ketanhwr Aug 21, 2017
Author Contributor

Yup I saw this but couldn't understand why it was happening 😕

This comment has been minimized.

@bjorn

bjorn Aug 21, 2017
Member

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.

@bjorn
Copy link
Member

@bjorn bjorn commented Aug 24, 2017

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.

@bjorn bjorn merged commit c7925ec into mapeditor:master Aug 24, 2017
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.