Data structure to save diagram, an editor developed in QT widget
-
" Hello friends, I am new to QT development, my task is to develop an editor just like Microsoft Visio where I can create diagrams like circle, ellipse and rectangular shapes. Also i need to connect these shapes using a line which I can call them relation between shapes. Apart from that I also want to drag and drop shapes inside another shape and let say when I drag a circle inside a rectangular shape, the circle should be locked inside the rectangular shape as circle become the child of rectangular shape and I should not be able to move circle out of rectangle, while allowing rectangle to resize. This application should work with touch, like I want to enable pinching and rotating of shapes being drawn on editor. I am developing this for Desktop Linux computer which also has a nice touch screen. I want you guys to share your experience and some kick of open source project with same functionalities mentioned above. Thanks in advance "
The above description is is previous posted question, I have an 50% developed editor where I can place rectangles, circle and many more shapes. I can also create relations between them by drawing line between these shapes in editor. Now let say I have draw 4 shapes and following relation exist.
Shape1 connected to shape 2
Shape3 connected to shape 4
In the same way I can draw another shape inside shape1, 2, 3 or shape 4. which apparently becomes child of the parent one. In the same way I can expand a shape and I can put as many shapes I want. Also I can create realtion between them.Now when the diagram is developed I want to save this diagram in a structure to save the diagram as a file and Import it later whenever wanted.
Now which data structure should I use in this situation, as I have to save many things like, Let me list some key points.- Parents child relation (When a shape is inside another shape)
- Parents to parent relation (When relation is between 2 parents)
- Size, shape, Id, coordinate points of each of shape.
Now my basic question which data structure to use, Where I can maintain parent child relation, Parent to parent relation (A shape is parent if its not inside another shape). Also maintaining properties of each shape,
also easily updating data structure when some is deleted or updated.Or I have to use combination of data structure. I thought about it and I came to conclusion I will have to use Link list, trees and arrays for storing this data but logically its not easy to maintain three data structure so i guess there should be some other solution like consider MS visio and other softwares like UML diagrams, what kind of data structure is used in those reliable softwares. Please I need suggestions. Thanks all