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

WIP: Vertex tool improvement #5797

Closed
wants to merge 5 commits into from
Closed

Conversation

mohsenD98
Copy link
Collaborator

@mohsenD98 mohsenD98 commented Nov 8, 2024

Description:

coming soon...

Tasks Todo:

  • Logic based on finding a point not degree.
  • Move logic to utils class.
  • Better variable names.
  • More on documentations.

Maybe later

  • Better visualization

@mohsenD98 mohsenD98 requested a review from nirvn November 8, 2024 08:57
@qfield-fairy
Copy link
Collaborator

qfield-fairy commented Nov 8, 2024

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation

@@ -223,6 +231,7 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel

//! \copydoc dirty
bool dirty() const;
bool angleFonud() const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation

@@ -265,6 +274,10 @@ class QFIELD_CORE_EXPORT VertexModel : public QAbstractListModel

bool canUndo();

double calculateAngle( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c );
Copy link
Member

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

Comment on lines 278 to 279
int snapToCommonAngleDegrees() const;
void setSnapToCommonAngleDegrees( int snapToCommonAngleDegrees );
Copy link
Member

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

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?

@@ -685,6 +691,31 @@ QgsPoint VertexModel::currentPoint() const
{
return mVertices.value( mCurrentIndex ).point;
}
// Function to calculate the angle between two vectors
Copy link
Member

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] :)

endPoint = endPoint - vertexCount();
}

double angle = calculateAngle( mVertices[startPoint].point, mVertices[mCurrentIndex].point, mVertices[endPoint].point );
Copy link
Member

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.


qDebug() << "--------- angle = " << angle;

setAngleFonud( angle > snapToCommonAngleDegrees() - 1 && angle < snapToCommonAngleDegrees() + 1 );
Copy link
Member

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 😱 😉

@@ -881,6 +936,15 @@ void VertexModel::setDirty( bool dirty )
emit dirtyChanged();
}

void VertexModel::setAngleFonud( bool angleFonud )
Copy link
Member

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

@mohsenD98 mohsenD98 self-assigned this Nov 10, 2024
@nirvn nirvn closed this Nov 15, 2024
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