   Data Structure Help for 2D vect application
  Hello can anyone help me find the right data structure or way of storing data that will represent a window or Door ?I know this is not advanced 3D rendering, but for the life of me I can’t seem to grasp how I could store the window for example in a database or some type of data structure.The premise of the application is to allow the user ( A windows/door manufacture) to design a window or door visually. They should be able to select from a few pre-designed shapes and styles, and then work on that window or door type adding vertical and/or horizontal splitters as necessary. The user should be allowed to select a predefined window shape for example, it can be a rectangle, trapezoid, ellipse etc… and from there they should be able to define the Width and Height of the window. Once the width and height has been defined, the style of window is select for the object, meaning if the window will have two vertical splits, or if it will have 2 vertical and one horizontal split  etc…On top of that, the user will be able to add additional splits etc…The combinations of these splits should be unlimited. …. The styles of windows are picture window, casement, awning, sliding etc…The data should be saved into a ADO MS-SQL Server database/table. Or to some medium (like a text file) so that it can be stored as a blob in the database.The above is simplified, my problem is when I add two vertical splitter to a rectangular window for example and then add a horizontal splitter … the horizontal splitter can’t be as wide as the whole window because we already have two vertical splitters present so it has to find the beginning of the first vertical splitter and draw the horizontal splitter only that wide.All I know is that the more vertical and horizontal splitters I add, the more confusing it is to store the data where each splitter should be… and how to read that data back and display the window on the canvas.Help !!!!! 
  Have you thought about using linked lists to store the splits?  I don''t know excatly what you need to store per window/door, so its hard for me to give you an exact answer.As far as storing 2d rectangle data I like to store it as:float fLeft;float fTop;float fRight;float fBottom;That way the X,Y coords for any point are simple, top left corner is fLeft, fTop...etc.Hope that helps some.Matthew Sherwood ;  Hi Thanks for the reply,i store them in a linked list, and then i transfer to a database table. My problems comes from the fact that when  you add the splitters you have rule present on how you can do this, and this rule really confuses the situation for me.Rule 1) The vertical or Horizontal splitter that is dropped on the window can assume the windows width or height(Depending if it is a horizontal or vertical splitter) ...Rule 2) If you are dropping a splitter onto the window and there exists a one or more splitters of the same type(without any other types of splitters) you divide the window in as many parts as you can fit the splitters on to the window. Meaning if someone dropped two verticals or two horizontals we would end up with 3 window-slabs, since dividing a rectangle with 2 lines yields 3 glass-panes.Rule 3) IF you are dropping Vert/Hor splitter onto the window and the other type of splitter already exists, then we have to make sure the new splitter added will only be as wide as the pane we are putting it into... so from Rule 2 example we have split the window into 3 slabs of glass, if you put the horizontal splitter in the middle slab, it will only draw in the middle between the first and second vertical splitter, and won''t go across the entire width of the window.arrghhh, this is insanely complicated. ;  Couldn't you solve it with some simple collision detection and a tree-structure. Where the glassplanes are children to eachother.you drop a  splitter, find out what window you were dropped on -take a walk in the tree.when you find the right window you have two options.1) add yourself as another child to the current parent, ie dividing the parent into one more slice.2) create two children instead of the current leaf, ie dividing the current glass into two. Ok, this MIGHT work, haven't relly thought it through that much - thats your job...EDIT:the tree wouldn't be a binary tree ,of course, but a tree with as many children as required by any parent.   [edited by - JOL on February 10, 2004 11:22:10 AM];  Hi thanks for the help,When I design the window I drop a window(Rectangular) on to the canvas, then I add the splitters,You are saying that if I drop a vertical splitter onto the window, I should just create 2 windows from that one? And then maintain where the splitter is located? Either window 1 or window 2 ?In other words it would be like a jigsaw puzzle, where each time you put a Vert/Hor splitter on a window it would just add more window objects ? Or are you saying that I should just create Parent = Main Window and Child windows and from those child windows I should have a list of splitters?At this point I have a simple linked-list, no tree structure what so ever. ;  I meant that you should keep the structure as a tree - jigsaw puzzle. The drawing of the splitters could be implemented by drawing borders on the children or something like that... 