-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
WIP: Vertex tool improvement #5797
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ab0f1d0
Detecting 90 degree angles.
mohsenD98 b11c935
Set angle in vertexModel.
mohsenD98 31addf2
Add inner line shapes, but do we actually need them ?
mohsenD98 2bf1179
Cleaner code + addressing review.
mohsenD98 c3b8f4f
Get geometryEditingVertexModel as a property.
mohsenD98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,12 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |
* The index of the currently active vertex. If no vertex is selected, this is -1. | ||
*/ | ||
Q_PROPERTY( int currentVertexIndex READ currentVertexIndex WRITE setCurrentVertexIndex NOTIFY currentVertexIndexChanged ) | ||
//! The `snappedAngle` property holds the angle that has been adjusted to the nearest multiple of `snapToCommonAngleDegrees`. | ||
//! This value is automatically updated whenever the angle is changed. | ||
Q_PROPERTY( int snappedAngle READ snappedAngle NOTIFY snappedAngleChanged ) | ||
//! The `snapToCommonAngleDegrees` property specifies the angle increment to which the original angle will be snapped. | ||
//! This value defines the common angle step for snapping. | ||
Q_PROPERTY( int snapToCommonAngleDegrees READ snapToCommonAngleDegrees WRITE setSnapToCommonAngleDegrees NOTIFY snapToCommonAngleDegreesChanged ) | ||
|
||
/** | ||
* The geometry in layer coordinates | ||
|
@@ -187,6 +193,8 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |
//! next vertex or segment | ||
Q_INVOKABLE void next(); | ||
|
||
Q_INVOKABLE QgsPoint getPoint( int index ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to expose this to QML? Should it be a private function? |
||
|
||
//! Selects the vertex at the given screen \a point within a given \a threshold | ||
Q_INVOKABLE void selectVertexAtPosition( const QPointF &point, double threshold, bool autoInsert = true ); | ||
|
||
|
@@ -265,6 +273,18 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |
|
||
bool canUndo(); | ||
|
||
//! Returns `snappedAngle` | ||
int snappedAngle() const; | ||
|
||
//! sets snapped angle | ||
void setSnappedAngle( int snappedAngle ); | ||
|
||
//! Returns `snapToCommonAngleDegrees` | ||
int snapToCommonAngleDegrees() const; | ||
|
||
//! Sets `snapToCommonAngleDegrees` | ||
void setSnapToCommonAngleDegrees( int snapToCommonAngleDegrees ); | ||
|
||
signals: | ||
//! \copydoc editingMode | ||
void editingModeChanged(); | ||
|
@@ -301,6 +321,12 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |
//! Emitted when the history has been modified | ||
void historyChanged(); | ||
|
||
//! Emitted when `snappedAngle` modified | ||
void snappedAngleChanged(); | ||
|
||
//! Emitted when new `snapToCommonAngleDegrees` modified | ||
void snapToCommonAngleDegreesChanged(); | ||
|
||
private: | ||
void refreshGeometry(); | ||
//! Add the candidates of new vertices (extending or segment) | ||
|
@@ -312,6 +338,11 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |
void updateCanPreviousNextVertex(); | ||
void setGeometryType( const Qgis::GeometryType &geometryType ); | ||
|
||
//! This function is called whenever the `currentVertexIndex` changes. It checks if there is an active vertex in editing mode. | ||
//! If no vertex is active, the `snappedAngle` will be reset to 0. This ensures that the angle snapping logic is only applied | ||
//! when there is an active vertex to work with. | ||
void updateSnappedAngle(); | ||
|
||
QList<Vertex> mVertices; | ||
|
||
//! copy of the initial geometry, in destination (layer) CRS | ||
|
@@ -349,6 +380,9 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |
int mHistoryIndex = -1; | ||
bool mHistoryTraversing = false; | ||
|
||
int mSnappedAngle = 0; | ||
int mSnapToCommonAngleDegrees = 0; | ||
|
||
friend class VertexModelTest; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Documentation