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

Re: Advice on how best to structure app with V insterface



What you are asking for is not trivial. First, I don't know of V X-Y plotting class (though I have plans to convert a Windows class to V soon). The remainder can be done more easily. Distilling your msg, you want
1) communication from model class to GUI class
2) select output variables to view after a simulation

Item 1 requires you to have a global function callable from the model class, which has access to the GUI.

For item 2, if you want a table view, consider using my grid dialog class. You can download the source from http://lamar.colostate.edu/~hilinski/software/v-addons.htm

I've done most of this with the Century agro-ecosystem model developed at Colorado State Univ. (you can download the model at http://lamar.colostate.edu/~hilinski/software/cmi5.zip)

I'll try to summarize what I've done and post this to the news group soon.

Tom Hilinski
---------------------------------------------------------------------------
mail:    Dept. Soil & Crop Sciences, Colorado State University, 
         Fort Collins, CO 80523
e-mail:  hilinski@lamar.colostate.edu
WWW:     http://lamar.colostate.edu/~hilinski/
---------------------------------------------------------------------------





----- Original Message ----- 
From: Martin Waller <polytope_@hotmail.com>
To: <vgui-discuss@other.debian.org>
Sent: Wednesday, September 15, 1999 7:33 AM
Subject: Advice on how best to structure app with V insterface


| Hello,
| 
| I'm after some advice on how best to construct my V app.
| 
| I have a (vanilla) c++ class (call it base_model) that solves special types 
| of differential equations used in population biology. To use it, one derives 
| a new class defining various functions which describe the specific model you 
| wish to create (pure virtual functions in the base class).
| 
| This works fine as a console app in either win95 or X.
| 
| I've been trying to add gui functionality to it - for other models, I've 
| previously used Borland's OWL (the versions that come with BC++ 4.52 and 
| 5.01).
| 
| But now I want them to run under Linux to, so I've switched to V.
| 
| So far, I've got code to get user input (for variables, etc. used by the 
| model) and can then pass this to the model and run it by just creating an 
| instance of the model and running it.  Of course, not being 'V aware' the 
| model won't output any progress or results to the gui (running from an xterm 
| though, it will print out stuff using
| cout << variable in the xterm from which the gui app is run).
| 
| I want it to be able to comunicate it's progress and results to the gui 
| though by:
| 
| a) ideally, a progress graph (population vs. time) as the model runs and 
| then the possibilty to view other info after the model has ran
| 
| or
| 
| b) (would do) updating it's progress in a dialog, and then after it's run 
| have the ability to select what data to view
| 
| What's the best way to do this?
| 
| Without any attempt at gui stuff, this works (RunModel() runs when the 
| corresponding menuitem, or button bar button is selected, tryit is the model 
| derived from base_model):
| 
| derivedCmdWindow::RunModel()
| {
| 
|    vNoticeDialog note(this);// Used for default actions
| 
|    tryit=new model(/*various input parameters passed*/);//model *tryit is a 
| private member of derivedCmdWindow
| 
|    note.Notice("tryit created");
| 
|    tryit->run();
| 
|    note.Notice("Model ran!");
| 
|    delete tryit;
| 
| }
| 
| I thought to add gui functionality I could do one of the following:
| 
| for solution a) above:
| 
| 1. Derive base_model from vCmdWindow (then model from base_model)
| 
| 2. Derive model jointly from base_model and vCmdWindow
| 
| for solution b) above
| 
| 3. Derive base_model from vDialog
| 
| 4. derive model jointly from base_model and vDialog
| 
| 
| Deriving from vDialog has issues, as I can't create the derived model in 
| vCmdWindow's constructor (as is usual for dialogs, no?) and deriving from 
| vCmdWindow and using the following code casues crashes once the model has 
| stopped running:
| 
| derivedCmdWindow::RunModel()
| {
| 
|    vNoticeDialog note(this);// Used for default actions
| 
|    tryit=new model(/*various input parameters passed*/);//tryit * is a 
| private member of derivedCmdWindow
| file://model derived jointly from base_model and vCmdWindow
| 
|    note.Notice("tryit created");
| 
|    theApp->NewAppWin(tryit,"Title!",800,600);
| 
|    tryit->run();
| 
|    note.Notice("Model ran!");
| 
|    tryit->CloseWin();
| 
|    delete tryit;
| 
| }
| 
| Comments, advice and suggestions strongly desired!
| 
| Please help,
| 
| Martin
| 
| 
| ______________________________________________________
| Get Your Private, Free Email at http://www.hotmail.com
| 
| 
| -- 
| To UNSUBSCRIBE, email to other-vgui-discuss-request@other.debian.org
| with a subject of "unsubscribe". Trouble? Contact listmaster@other.debian.org


Reply to: