wu :: forums
« wu :: forums - rectangle overlapping »

Welcome, Guest. Please Login or Register.
Jan 6th, 2025, 7:41pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: towr, Eigenray, ThudnBlunder, SMQ, william wu, Icarus, Grimbal)
   rectangle overlapping
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: rectangle overlapping  (Read 1046 times)
cuckoo
Junior Member
**





   


Gender: male
Posts: 57
rectangle overlapping  
« on: Aug 7th, 2007, 5:47am »
Quote Quote Modify Modify

I come across the following problem on other bbs, it seems related to some mechanism of windows. I am a bit confused, can somebody give some advice? Thank you!
 
problem:
Given a diagram which contains rectangles of different sizes that may overlap with each other and rectangles may be hidden. Discuss the data structures to use to support this funcionality: When a rectangle is clicked, it should come into view on top of others, if it is hidden already. The overall aim is to reduce the amount of repainting to be done everytime the user clicks on a rectangle.
IP Logged
sk
Newbie
*





   


Posts: 45
Re: rectangle overlapping  
« Reply #1 on: Aug 14th, 2007, 8:22pm »
Quote Quote Modify Modify

Have a list of windows, with each window having rectangle co-ordinates and another list which will have all the overlapping windows with other windows.
 
these are better illustrated with the help of code
struct window
{
  int left,top,right,bottom;
  struct window *IntersectingWindows;
  boolean minimized;
}
 
when u create a window, scroll thru the list to see if there are any overalppings. if so calculate the intersecting rectangles and update both the overlapping windows. this will be done in O(n). so every new window will have O(n) to search thru entire list.
 
the list is maintained as a queue, ordered by their creation time. If u click on any window, then u search thru the list and make that node as the head of the node and paint only the intersecting rectangles if minimized == false;
 
this is better than painting the entire window. u can also split the intersecting windows further, if there are multiple intersections, but it will get costly to search through.
 
the list will ensure that even if u click on a point which is common to multiple rectangles, only the latest window will be displayed.  
 
 
IP Logged
sumantbhardvaj
Newbie
*





   


Posts: 20
Re: rectangle overlapping  
« Reply #2 on: Aug 16th, 2007, 11:20pm »
Quote Quote Modify Modify

As far as i got from your explanation, you are making a list of windows where each window will have a seperate list of windows overlapping with it. So whenever we make a add a new window we update the both the overlapping windows.
 
but i could not understand this part ..
Quote:
If u click on any window, then u search thru the list and make that node as the head of the node and paint only the intersecting rectangles if minimized == false;  

 
What is the minimized variable doing there ?? and why to make that node the head ?? plz explain..
IP Logged
gotit
Uberpuzzler
*****





   
Email

Gender: male
Posts: 804
Re: rectangle overlapping  
« Reply #3 on: Aug 19th, 2007, 6:59am »
Quote Quote Modify Modify

I assume that there is someway to differentiate the rectangles e.g by assigning numbers to them.
Create a hash table in which each entry corresponds to a rectangle and is identified by the rectangle number.An entry corresponding to rect i contains the following information:
 
i) the color of rectangle i
ii) a list  in which each entry contains info about a overlap e.g. if rect j ovelaps rect i, then their will be an entry in the list corresponding to rect j. This info will contain the rect number that overlaps rect i (j in this case)and the portion of rect i that it overlaps.Likewise there will be an entry corresponding to all such overlaps.
 
When you click on rectangle i, the following steps are taken.
 
i) Traverse the list corresponding to rectangle i. For an entry corresponding to rectangle j in this list, goto the list for j and insert an entry corresponding to rect i(bcoz now rect j will be covered by rectangle i). Do this for all entries in the list of rect i.
 
ii) When the list for rect i has been completely traversed,delete the list completely.(An empty list for  a rectangle means that it is not overlapped by any other rectangle).
« Last Edit: Aug 19th, 2007, 7:02am by gotit » IP Logged

All signatures are false.
sk
Newbie
*





   


Posts: 45
Re: rectangle overlapping  
« Reply #4 on: Sep 2nd, 2007, 3:59pm »
Quote Quote Modify Modify

minimized..is a flag to check if it minimized. e.g. if the rectangle co-ordinates are 10,10,20,20 and u click on any point within this, then it should be displayed only if the rectangle is not minimized.
IP Logged
sk
Newbie
*





   


Posts: 45
Re: rectangle overlapping  
« Reply #5 on: Sep 2nd, 2007, 4:01pm »
Quote Quote Modify Modify

and u make it the head, because the most recent one is always at the head. that is how u determine, the window focus hierarchy.
given a point, it can belong to any window, but hwich window are u going to highlight. the most recent one.
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board