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
//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
Reply to: