It is currently Tue Jun 18, 2013 4:40 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: tooltip for vector drawn shape within canvas
PostPosted: Fri Dec 02, 2011 6:15 pm 
Offline
User
User
User avatar

Joined: Sat Sep 12, 2009 3:06 pm
Posts: 51
I was curious if it's possible to have a tool tip for items drawn within a canvas for example a circle that been drawn and when the mouse is over that circle display a tool tip?

_________________
Edward B. Howington
http://www.triplexcorp.com


Top
 Profile  
 
 Post subject: Re: tooltip for vector drawn shape within canvas
PostPosted: Fri Dec 02, 2011 6:50 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 6465
The main thing you need for that is a way to mark off and test different-shaped regions in your canvas. Your very question occurring to me some time ago is in fact the principal reason I developed this: http://www.purebasic.fr/english/viewtopic.php?f=12&t=46739 which provides the tool for the job.

_________________
Veni, vidi, vici.


Top
 Profile  
 
 Post subject: Re: tooltip for vector drawn shape within canvas
PostPosted: Fri Dec 02, 2011 8:08 pm 
Offline
User
User
User avatar

Joined: Sat Sep 12, 2009 3:06 pm
Posts: 51
seems interesting thou im going to have play with how to produce a tooltip on this lib

_________________
Edward B. Howington
http://www.triplexcorp.com


Top
 Profile  
 
 Post subject: Re: tooltip for vector drawn shape within canvas
PostPosted: Thu Dec 15, 2011 11:23 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Sep 11, 2004 11:54 am
Posts: 416
Location: UK
The following nasty solution could be considered bad practice, but it got me out of a hole when a solution was needed … “NOW”. It also fails / gets complex if you have lots of colours and / or complex drawings. I used it when the vectors were black and I wanted to distinguish between one of five pixel wide graph lines.

Simply take advantage of the eyes inability to see very small colour differences and plot each feature in a slightly different colour, it only need have a difference of 1 on R or G or B. You can then read the colour at mouse Point(x,y) , consult a table and find out which artefact you are over.

As I said not nice, but it works.


Top
 Profile  
 
 Post subject: Re: tooltip for vector drawn shape within canvas
PostPosted: Fri Dec 16, 2011 4:58 am 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2919
Location: Wales, UK
If you were coding a CAD app, then you might class each geometry element as an object, and keep a record of each object (and their relationships), in a database. So, you would store all the info about the circle, including it's diameter, it's min-max boundary (a square in the case of a circle) location, line attributes etc, and indeed tool tip text. Things that need instant access, such as tooltips, would have a unique id of some sort and generally be pre-loaded in ram, as you might do with prompts too. I think I've said enough to inspire?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: tooltip for vector drawn shape within canvas
PostPosted: Fri Dec 16, 2011 9:37 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Sep 11, 2004 11:54 am
Posts: 416
Location: UK
Random thoughts… Another path to consider…

I assume drawing a tool tip is not the problem; the challenge is to find out what entities exist at a point identified by the mouse.

Memory is generally plentiful so you could make a two dimensional map equal in size to the display area and write the identity of the entity into it as you draw the entity. That way you have a list that can be accessed without needing to compute anything at read out time… so it is very fast solution.

A down side is that you probably need to handle multiple entities that overlap. If you have a small number of entities you could pack entity identifiers into the 16/32/64 bit variables that make the entity map. Sixteen entities could be packed into a map of Quads. This is slower to write but fast to read out.

A variation of the last idea is to use bit set and clear to flag, for example, 32 entities using map of Long values. (Or 64 entities with a map of Quads)

If you have a very large numbers of overlapping entities the look up map could contain pointers to lists that could allow any number of overlapping features at the same point. This may not be too heavy on memory if the display area is mainly empty; like a typical graph with several lines.

Anyway… it will soon be Xmas and there will be lots of holiday time to ponder the ultimate solution!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye