selection in a windows app

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
ArthurH
In need of some credit
In need of some credit
Posts: 2
Joined: Sat Feb 19, 2011 9:38 pm

selection in a windows app

Post by ArthurH »

My question is about getting a general overview of a selection function in a graphics app using wxWidgets. Currently I'm re-inventing the wheel (for fun) and writing yet another CAD app using wxWidgets and OpenGL (wxGLCanvas). I'm at a point where I've coded and tested the picking algorithm spec'd out in OpenGL and it works ok. What I'm trying to do now is write a user function that will call a selection function twice, eg. select-curve(), 'return' the two curves and use them as inputs to an intersection function. An example in AutoCad would be the trim command. It lets the user select a curve, then another, and then performs a trim operation on the selected curves. How is this process implemented in an event-driven app in general (or specially in a wxApp)? The parallel would be the dialog function. I could write a user function to add two numbers. It would consist of two calls to a dialog function eg. get-a-number(), 'return' the values and call a sum function. It's the fact that the dialog is modal that lets the user function 'wait' for the user input before it makes the call to the sum function. Analogously, how would you do a 'modal' selection function?
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

I'm not familiar with CAD so I'm not sure I've been following you all along.
But you can simply derive a class from wxDialog, add anything you need to this class; then your function can create that wxDialog on the stack, call ShowModal, then after ShowModal retrieve the values entered by the user. This way the function will not return until the user closed the dialog
"Keyboard not detected. Press F1 to continue"
-- Windows
ArthurH
In need of some credit
In need of some credit
Posts: 2
Joined: Sat Feb 19, 2011 9:38 pm

Post by ArthurH »

Right now my picking scheme consists of processing mouse events sent to wxGLCanvas. ShowModal ( when I tried it) has two effects. First,it seems to hold up execution of the calling function ( like you said and which is what I want), but secondly, it seems to block all events to the parent window (WxGLCanvas) , that is, only mouse events to the dialog window get sent and processed. Is it possible to have mouse events passed on from the dialog window to the WxGLCanvas window for processing?
CAD is Computer Aided Design software. At the moment my query is not related to that specifically, but rather to windows application or event loops in general.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

If you don't want the frame to be blocked by the dialog, then Modal is not what you want.

Can you perhaps change your design so that you no more depend on a function not returning? GUI programming is generally event-based, and this seems to be appropriate in this case; simply show the dialog, and when the dialog closed event is fired, do the rest of what you wanted to do
"Keyboard not detected. Press F1 to continue"
-- Windows
Post Reply