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

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);
Copy link
Member

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.

QPolygonF secondPolygon = mSecondPolyline->polygon();

firstPolygon.append(secondPolygon);
secondPolygon = firstPolygon;
Copy link
Member

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);.

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

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.

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

firstPolygon.append(secondPolygon);
Copy link
Contributor

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.

Copy link
Contributor Author

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 😕

Copy link
Member

@bjorn bjorn Aug 21, 2017

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.

@bjorn
Copy link
Member

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants