I'm developing application which would allow user to upload an image of a rock crack and apply spline approximation to that crack.
For that purpose i have QGraphicsView
, that displays an uploaded image.
Once image is uploaded, user has an option to draw points on a scene
, which i want to be consistenly connected with lines. Those connected points would make a curve, which i want to be interactive. By interactive i mean that i want user to be able to drag points without breaking the curve, making lines, that connect points, move with the point. I also want to make user able to delete selected points so that adjacent points stay connected. Those are not all the features i want, but i think you get the idea.
What i've done is i've created a class MeasurePoint
that inherits from QGraphicsItem
and contains all the information about one individual point. It has the following fields:
int xPos;
int yPos;
int index;
bool movable;
bool selected;
That class also has several methods for managing those points (getter and setter functions for the fields, etc). But i don't implement connection feature in that class because it only contains information about individual point, and not further. I like the way points behave if i simply add them to the scene. But now i need to connect them the way i described earlier and i can't really figure out how to do it.
What's the best way to store the points? How exactly should i implement connections between points? Any possible help is appreciated.
P.s. if my implementation of class MeasurePoint
is needed in this question, i'll edit it.