Hello,
I'm developing a typical 3D application, where a modeless dialog box allows the user to set the rendering width and height, and when the user clicks Render, a modal render progress dialog box is shown and rendering starts.
I'm opening the Progress dialog box with a ShowModal call... but I haven't found the threads combination to be able to show the progress dlg, and start rendering right away.
And there is also a View Image modeless panel which shows the image that is being rendered (the image is updated every time a 32x32 pixels bucket is rendered.) This View Image panel needs to be accesible and ready for mouse input to display information about the image itself (colors, alpha, elements, etc.)
Does anybody knows a way to handle this correctly?
thank you,
Diego
Modal and threads question Topic is solved
Modal and threads question
Last edited by ScEngMan on Wed Oct 01, 2008 2:23 pm, edited 1 time in total.
I start my threads mostly in the constructor. Sometimes I make a MyDialog::doIt(), wich first starts the thread, then calls ShowModal on itself.
Never had any problems with any of these options. The thread runs just fine, even when your window is not visble at the moment.
Third option (never used it, but should work too): Post yourself an Event at the end of your constructor. The handler starts the thread. That way your thread should start *after* the call to ShowModal().
Code: Select all
bool MyDialog::doIt ()
{
boost::thread(boost::bind(&MyDialog::thread, this)); // Should work fine with wxThread too, but I don't know how to use it
return ShowModal() == wxID_OK;
}
Third option (never used it, but should work too): Post yourself an Event at the end of your constructor. The handler starts the thread. That way your thread should start *after* the call to ShowModal().
I tried to create a Modeless View Image frame from both the Progress Dlg and Rendering Dlg, and in both cases it is created, but as soon as I call ProgressDlg::ShowModal, the View Image frame becomes inactive and is or closed or moved to the background.
Any ideas on how to make this work?
These are the main windows:
SceneViewerFrame : The app main frame
RenderingDlg : A modeless window
ProgressDlg : A modal progress dlg with Pause/Continue and Stop
ViewImageFrame : A frame that displays the image that is being rendered and allows the user to pick pixels for info.
This is the workflow (u:user a:application w:wish)
u : SceneViewerFrame > Menu > Tools > Rendering
a : Opens the RenderingDlg
u : Hit Render button
a : RenderingDlg create a thread for the renderer
a : RenderingDlg create a ProgressDlg and Shows it with ShowModal
w : RenderingDlg or ProgressDlg open a ViewImageFile frame
a : Rendering is finished and the ProgressDlg closses
w : ViewImageFile is not closed
The w items are those I wish to have working, but I can't find a way to get it done.
Thank you
Diego
Any ideas on how to make this work?
These are the main windows:
SceneViewerFrame : The app main frame
RenderingDlg : A modeless window
ProgressDlg : A modal progress dlg with Pause/Continue and Stop
ViewImageFrame : A frame that displays the image that is being rendered and allows the user to pick pixels for info.
This is the workflow (u:user a:application w:wish)
u : SceneViewerFrame > Menu > Tools > Rendering
a : Opens the RenderingDlg
u : Hit Render button
a : RenderingDlg create a thread for the renderer
a : RenderingDlg create a ProgressDlg and Shows it with ShowModal
w : RenderingDlg or ProgressDlg open a ViewImageFile frame
a : Rendering is finished and the ProgressDlg closses
w : ViewImageFile is not closed
The w items are those I wish to have working, but I can't find a way to get it done.
Thank you
Diego
Yeah, I tried many things with ShowModal and nothing worked.
Now I'm trying to Disable the main frame and the Rendering Dlg when render starts, and Enable them again when render ends.
In wx docs it says about Enable/Disable:
"Enable or disable the window for user input. Note that when a parent window is disabled, all of its children are disabled as well and they are reenabled again when the parent is."
This is true for docked windows, but my other windows are not disabled. Is there a way to force disable in everything?
Or is there a way to get all existing wxWindows in my application to use a Disable in all of them?
Thanks
Now I'm trying to Disable the main frame and the Rendering Dlg when render starts, and Enable them again when render ends.
In wx docs it says about Enable/Disable:
"Enable or disable the window for user input. Note that when a parent window is disabled, all of its children are disabled as well and they are reenabled again when the parent is."
This is true for docked windows, but my other windows are not disabled. Is there a way to force disable in everything?
Or is there a way to get all existing wxWindows in my application to use a Disable in all of them?
Thanks