VRUT::BaseApp Class Reference

Base application class. More...

#include <app.h>

List of all members.

Public Member Functions

 BaseApp ()
 Class constructor.
virtual ~BaseApp ()
 Class destructor.

Protected Member Functions

virtual bool OnInit ()
 Initializations - wxApp overload.
virtual int OnExit ()
 Deinitializations - wxApp overload.
virtual void OnInitCmdLine (wxCmdLineParser &parser)
 Initialize command line options.
virtual bool OnCmdLineHelp (wxCmdLineParser &WXUNUSED(parser))
 Show usage - overload due to wxWidgets incompatible options used.
virtual bool OnCmdLineError (wxCmdLineParser &parser)
 Show cmdline parse error - overload due to wxWidgets incompatible options used.
virtual bool OnCmdLineParsed (wxCmdLineParser &parser)
 Parse and process command line options/commands.

Private Member Functions

 DECLARE_DYNAMIC_CLASS (BaseApp)


Detailed Description

Base application class.

Definition at line 23 of file app.h.


Constructor & Destructor Documentation

BaseApp::BaseApp (  ) 

Class constructor.

Definition at line 27 of file app.cpp.

00027                  : wxApp()
00028 {
00029 }

BaseApp::~BaseApp (  )  [virtual]

Class destructor.

Definition at line 32 of file app.cpp.

00033 {
00034 }


Member Function Documentation

VRUT::BaseApp::DECLARE_DYNAMIC_CLASS ( BaseApp   )  [private]

bool BaseApp::OnInit (  )  [protected, virtual]

Initializations - wxApp overload.

Parse command line

Magic fix for wxWidgets event processing

Definition at line 37 of file app.cpp.

00038 {
00039        wxInitAllImageHandlers();
00040        MainWindow * mainWin = new MainWindow( wxT("VRUT"), wxDefaultPosition, wxSize(800, 800));
00041 
00042        Kernel::Instantiate(mainWin);
00043        KERNEL->Initialize();
00044        KERNEL->GetMessageSink()->RegisterListener(mainWin, Event::EVT_LOG_LEVEL_SET);
00045        KERNEL->GetMessageSink()->RegisterListener(mainWin, Event::EVT_RENDER_FRAMERATE);
00046        KERNEL->GetMessageSink()->RegisterListener(mainWin, Event::EVT_GUI_PANE_SHOW);
00047 
00048        SetTopWindow(mainWin);
00049        mainWin->SetFocus();
00050        mainWin->Show();
00051 
00052        LOGDEBUG(wxT("<BaseApp>DEBUG MODE"));
00053 
00055        bool ret = wxApp::OnInit();
00056 
00058        wxKeyEvent evk;
00059        KERNEL->GetMessageSink()->ProcessEvent(evk);
00060 
00061        return ret;
00062 }

int BaseApp::OnExit (  )  [protected, virtual]

Deinitializations - wxApp overload.

Definition at line 65 of file app.cpp.

00066 {
00067        return wxApp::OnExit();
00068 }

void BaseApp::OnInitCmdLine ( wxCmdLineParser &  parser  )  [protected, virtual]

Initialize command line options.

Must refuse '/' as parameter starter or cannot use "/path" style path

Definition at line 71 of file app.cpp.

00072 {
00073        parser.AddSwitch(wxT("h"), wxT("help"), wxEmptyString, wxCMD_LINE_OPTION_HELP);
00074        parser.AddSwitch(wxT("t"), wxT("test"));
00075        parser.AddParam(wxT("script_filenames"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL);
00076        parser.AddOption(wxT("D"));
00078        parser.SetSwitchChars(wxT("-"));
00079 }

bool BaseApp::OnCmdLineHelp ( wxCmdLineParser &  WXUNUSEDparser  )  [protected, virtual]

Show usage - overload due to wxWidgets incompatible options used.

Definition at line 82 of file app.cpp.

00083 {
00084        wxMessageOutput * msgOut = wxMessageOutput::Get();
00085        if (msgOut)
00086        {
00087               wxString usage;
00088               usage << wxT("Usage: vrut [-h] [-t] [-D<param>=<value>] [<script_filenames>...]\n");
00089               usage << wxT(" -h, --help             \tdisplay help on the command line parameters\n");
00090               usage << wxT(" -t, --test             \tdo automatic tests and exit\n");
00091               usage << wxT(" -D<owner.param>=<value>\tdefine parameter value,\n");
00092               usage << wxT("                        \tif parameter belongs to module use $moduleName.$paramName=$value (eg. '-DRenderGL.drawBVH=1' )\n");
00093               usage << wxT("                        \tif parameter belongs to kernel use kernel.$paramName=$value (eg. '-Dkernel.evtsPerIteration=256' )\n");
00094               msgOut->Printf(usage);
00095        }
00096        return false;
00097 }

bool BaseApp::OnCmdLineError ( wxCmdLineParser &  parser  )  [protected, virtual]

Show cmdline parse error - overload due to wxWidgets incompatible options used.

Definition at line 100 of file app.cpp.

00101 {
00102        return OnCmdLineHelp(parser);
00103 }

bool BaseApp::OnCmdLineParsed ( wxCmdLineParser &  parser  )  [protected, virtual]

Parse and process command line options/commands.

Run autoexec script

Definition at line 106 of file app.cpp.

00107 {
00108        #ifdef USE_TEST
00109        if (parser.Found(wxT("t")))
00110        {
00111               runToolkitTest();
00112               delete mainWin;
00113        }
00114        #endif
00115 
00116        for (int i = 1; i < argc; i++)
00117        {
00118               wxString parval;
00119               if (wxString(argv[i]).StartsWith(wxT("-D"), &parval))
00120               {
00121                      Parameter::ParameterIdentificator pi = Parameter::ParameterIdentificator::FromParamName(parval.BeforeFirst('='));
00122                      if (pi.IsValid())
00123                             KERNEL->environment.SetParam(pi, parval.AfterFirst('='), true);
00124                      else
00125                             LOGERROR(wxString::Format(wxT("<BaseApp>Set parameter command line argument error. Invalid parameter name: '%s'"), parval.BeforeFirst('=').c_str()));
00126               }
00127        }
00128 
00130        if (!KERNEL->interpreter.ExecuteScriptFile(wxT("autoexec.cfg")))
00131               LOGWARNING(wxT("Could not execute 'autoexec.cfg' script file"));
00132 
00133        for (size_t i = 0; i < parser.GetParamCount(); i++)
00134               if (!KERNEL->interpreter.ExecuteScriptFile(parser.GetParam(i)))
00135                      LOGWARNING((wxString::Format(wxT("Could not execute '%s' script file")), parser.GetParam(i).c_str()));
00136 
00137     return true;
00138 }


The documentation for this class was generated from the following files:

Generated on Tue Mar 10 14:41:40 2009 for VRUT by  doxygen 1.5.5