[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GUI-Model communication



Tom Hilinski wrote:
> 
> Martin Waller recently posted a question regarding methods used to communicate between a simulation class instance and a controlling GUI. I have done this recently for a model, in which the model updates a progress bar, displays a message in a text canvas displaying the simulation time and recent actions, and accepts a "cancel" request generated by the user pressing a "cancel" button on the progress bar dialog.
> 
> I have attached a short HTML document explaining how I did this. The method is a bit more involved than I like, but I could not think of a briefer method. (If you have suggestions to make the process less complex, please post them for us.)
> 
> Essentially it works like this:
> 
> 1. The GUI class makes an instance of the simulation class, and gives it pointers to global functions to which will either send or receive messages from the simulation instance.
> 
> 2. The GUI class tells the simulation to run, and concurrently displays a progress bar with a Cancel button.
> 
> 3. The simulation has a time-step loop, within which it sends a message to the progress bar dialog containing the simulation time, sends messages as needed to be displayed to the user, and checks for received ("posted") messages at each time step.
> 
> Tom Hilinski
> e-mail:  hilinski@lamar.colostate.edu
> 
>   ------------------------------------------------------------------------
>                                     Name: Century-GUI Communication.HTM
>    Century-GUI Communication.HTM    Type: Hypertext Markup Language (text/html)
>                                 Encoding: quoted-printable


Perhaps I'm missing something here, but it seems to me that this general
class of
problem could be solved with the MVC model. It seems to me the running
simulations
could send a message to the appropriate views with vApp::UpdateAllViews,
and provide
the necessary information in the hint parameter. See the MVC
documentation under
vApp in the documentation.

But, this whole thing might be more complicated than I'm seeing from a
very quick
read of this info.

-- 

Bruce E. Wampler, Ph.D.

Author of the V C++ GUI Framework

e-mail: mailto:bruce@objectcentral.com
web:    http://www.objectcentral.com


Reply to: