L
L
Lepidozavr2020-09-21 16:32:37
User interface
Lepidozavr, 2020-09-21 16:32:37

How to implement graphic (MB logical) objects nested in each other (windows in windows (like nesting dolls))? Python? C++? ??

How it should work.
I imagine the functionality as follows: on a two-dimensional plane, you can create boundaries (fences, bubbles - separating / enclosing the desired area of ​​\u200b\u200bthe plane). Moreover, the fenced area can already contain other "sectors" (squares) - like nesting dolls, only one can sit several at once.
Each area can be zoomed in (with the mouse wheel, for example), and create more separate structures / bubbles / areas there.
"Bubbles" cannot cross each other's boundaries.

What for?
The idea of ​​sorting data/records/notes. Perhaps an alternative to the desktop / nested folders.

I know the basic skills of Python, it turns out to understand libraries, OOP, but I don’t even understand in which direction to google. Let it be implemented in another language, but at least tell me in which direction to google. If this has already been implemented and you can tinker with this code, I will be glad for tips.

This is my hobby. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2020-09-21
@wataru

OOP. The object is a frame. Should contain a list of all child frames (but not grandchildren - only those that are contained directly in the top, but not in anything else).
When drawing a new frame, descend recursively through this object tree until you get the element that contains the entire new frame.
When descending, if you see that the current object does not intersect with the frame - just go back. If you see what intersects, then return an error - by condition, the new frame cannot intersect. If it lies strictly inside, then continue the search.
If you see that all the children of the current object do not intersect with the frame, then you have found the frame - the parent of your new object. Add a new border to the children of this object. Now go through all the children and, if they are completely inside the new frame, transfer them to the children of this new object.
How to draw? Again, a recursive tree pass cuts off all elements that do not intersect with the visible area. Those that intersect are saved in some kind of list for drawing.
This is if there are not too many frames, say up to 1000. Otherwise, you will have to tinker and fence all sorts of BSP-trees, kd-trees to quickly search for objects, but you don’t seem to need this. It will be too difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question