Markers on wxPanel/wxWidgets

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
janjan
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Mar 13, 2005 12:15 pm

Markers on wxPanel/wxWidgets

Post by janjan » Sun Mar 13, 2005 1:08 pm

(The topic isn't that descriptive, if one of the mods knows a better one, please rename it)

I'm currently writing an application for image/volume registration. It was first written in Matlab but this language kind of su*** when it comes to interface design. So I ported it over to C++/wxWidgets. The problem is, that I must duplicate some dialogs/controls which are not available in wxWidgets.

For those who don't know what image registration is about: You have two images (or volumes) which aren't aligned properly. For example one of those is rotated and translated with respect to the other. The are several methods to move one of the images in a way, that afterwards on image fits perfect above the other. One of these methods uses landmarks. In both images corresponding points are marked (let's say there is a car in both images, so you mark the tires and the doors) and with their help the proper alignement can be calculated.

One of these Matlab controls has something to do with placing these landmarks in an image. It's called 'cpselect' (click here for an image and description)


So my problem is:
I have
- a wxImage which is painted on a control derived from wxPanel.
- some landmark coords in the form P1(x,y), P2(x,y), P3(x,y)

Painting these landmarks isn't a problem, the task is, to move these landmarks around with the mouse.

Currently I have no intelligent idea of how to do this. I think it is something in the direction of:
- Capture left mouse button down. If it hits a landmark remeber the landmark.
- Capure mous move. If there is a landmark move it in some way
- Capture left mouse button up. If there was an landmark, remove it from memory

Has someone ever done something with such markers on an image? I think the problem is very common in the field of paint programms and stuff.

Or has anyone some sample code or a page where I can look for some 'mouse-moveable-custom-controls'?

Thanks for your help in advance :)

mjs
Experienced Solver
Experienced Solver
Posts: 93
Joined: Wed Feb 09, 2005 3:53 am
Contact:

Post by mjs » Sat Mar 19, 2005 12:38 pm

Maybe you can do something different:

Don't draw it into the image itself but draw it "on" the image (non-persistent).
Then you have to redraw it always when the image will be repainted but you don't need to remember the contents of the image under the landmark.

When you move a landmark, create a region where the landmark was and let the image repaint for the old position. Then redraw the landmark yourself.

Regards,
Mark

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Sat Mar 19, 2005 1:04 pm

Hi!
Maybe the source code of http://de.geocities.com/markusgreither/resizec.htm might be of some help.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

janjan
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Mar 13, 2005 12:15 pm

Post by janjan » Sat Mar 19, 2005 1:06 pm

I didn't thought of 'Don't draw it into the image itself'-approach, so thank you for this :)


But unfortunately this is only the smaller part of my problem. The problem with the marker movement ist still there. I created something that seems to work sometimes but the code is really ugly. So I'm searching for an example where someone hast done this before:

You have:
- a panel
- some marker coords in the form P1(x,y), P2(x,y)... (and of course their width and height)

What should be done:
- paint the marker 'on the fly' (this isn't the problem)
- be able to move the markers with the mouse

As said before, I've created something, but it has big problems when the cursor leaves the window while the mouse button is still pressed.




edit:
@upCASE:
I didn't see your post before I started this one. Thanks for the hint, I will take a look at this

Post Reply