-
-
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
Conversation
still needs to fix snapping lines.
+ Same style.
0efb91d
to
31addf2
Compare
🎉 Ta-daaa, freshly created APKs are available for c3b8f4f: arm64-android |
src/core/vertexmodel.h
Outdated
@@ -49,6 +49,9 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |||
Q_PROPERTY( int ringCount READ ringCount NOTIFY ringCountChanged ) | |||
//! determines if the model has changes | |||
Q_PROPERTY( bool dirty READ dirty NOTIFY dirtyChanged ) | |||
|
|||
Q_PROPERTY( bool angleFonud READ angleFonud NOTIFY angleFonudChanged ) |
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.
As discussed, this should be an int property called snappedAngle.
Also, don't forget documentation.
@@ -70,6 +73,9 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |||
*/ | |||
Q_PROPERTY( int currentVertexIndex READ currentVertexIndex WRITE setCurrentVertexIndex NOTIFY currentVertexIndexChanged ) | |||
|
|||
Q_PROPERTY( int snapToCommonAngleDegrees READ snapToCommonAngleDegrees WRITE setSnapToCommonAngleDegrees NOTIFY snapToCommonAngleDegreesChanged ) |
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
src/core/vertexmodel.h
Outdated
@@ -223,6 +231,7 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |||
|
|||
//! \copydoc dirty | |||
bool dirty() const; | |||
bool angleFonud() const; |
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
src/core/vertexmodel.h
Outdated
@@ -265,6 +274,10 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel | |||
|
|||
bool canUndo(); | |||
|
|||
double calculateAngle( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c ); |
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.
If we still use this function, let's move it to GeometryUtils
src/core/vertexmodel.h
Outdated
int snapToCommonAngleDegrees() const; | ||
void setSnapToCommonAngleDegrees( int snapToCommonAngleDegrees ); |
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.
Documentaton
@@ -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 comment
The 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?
src/core/vertexmodel.cpp
Outdated
@@ -685,6 +691,31 @@ QgsPoint VertexModel::currentPoint() const | |||
{ | |||
return mVertices.value( mCurrentIndex ).point; | |||
} | |||
// Function to calculate the angle between two vectors |
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.
FYI, we don't add comments above functions, we document in the .h[eader] :)
src/core/vertexmodel.cpp
Outdated
endPoint = endPoint - vertexCount(); | ||
} | ||
|
||
double angle = calculateAngle( mVertices[startPoint].point, mVertices[mCurrentIndex].point, mVertices[endPoint].point ); |
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.
Alright, as discussed yesterday, here I think we shouldn't calculate the angle but rather the point location of the point that'd form the angle we're looking for.
Then, we will snap to that point whenever we are close to it.
src/core/vertexmodel.cpp
Outdated
|
||
qDebug() << "--------- angle = " << angle; | ||
|
||
setAngleFonud( angle > snapToCommonAngleDegrees() - 1 && angle < snapToCommonAngleDegrees() + 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.
We discussed this yesterday. This wouldn't really work as a/ we wouldn't get a perfect coordinate snapped to angle in any case, and b/ we'd allow for angle 89 and 91 😱 😉
src/core/vertexmodel.cpp
Outdated
@@ -881,6 +936,15 @@ void VertexModel::setDirty( bool dirty ) | |||
emit dirtyChanged(); | |||
} | |||
|
|||
void VertexModel::setAngleFonud( bool angleFonud ) |
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.
This becomes a int commented int he header. But also, keep the getter and setter functions together in the source code (ATM they are disjointed and it just makes the code harder to skim through).
Description:
coming soon...
Tasks Todo:
Maybe later