~ubuntu-branches/ubuntu/saucy/ifrit/saucy

« back to all changes in this revision

Viewing changes to core/ishell.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-10-28 15:06:32 UTC
  • mfrom: (1.1.4 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061028150632-hyvuhvsv6zpmf5ev
Tags: 3.0.5-1
New upstream version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include "ishellfactory.h"
42
42
#include "ivtk.h"
43
43
 
 
44
#include <vtkTimerLog.h>
 
45
#include <vtkImageData.h>
 
46
 
44
47
//
45
48
//  Templates
46
49
//
66
69
 
67
70
iShell::iShell(int, char **) : mOptions(Option())
68
71
{
 
72
        int i;
 
73
 
69
74
        mRunning = false;
70
75
        mControlModule = 0; // control module must be created after the constructor is finished
71
76
        mOutputWindow = 0; // output window must be created after the constructor is finished
72
77
        mType = "undefined";
73
78
        mNumProcs = 0;
74
79
 
 
80
        mCurInitStep = 0;
 
81
        for(i=0; i<4; i++)
 
82
        {
 
83
                mInitSteps[i].Current = 0;
 
84
        }
 
85
        mInitSteps[0].Total = 10;               // needs to be set manually during development. How to do it automatically?
 
86
        mInitSteps[1].Total = 161;              // needs to be set manually during development. How to do it automatically?
 
87
        mInitSteps[2].Total = 1382;             // needs to be set manually during development. How to do it automatically?
 
88
        mInitSteps[3].Total = 13;               // needs to be set manually during development. How to do it automatically?
 
89
 
75
90
        //
76
91
        //  Define some basic command-line options
77
92
        //
130
145
    e = getenv("IFRIT_IMAGE_DIR");              if(e != 0) mEnvImageDir = iString(e) + this->GetDirSeparator(); else mEnvImageDir = this->GetCurrentDir() + this->GetDirSeparator();
131
146
    e = getenv("IFRIT_SCRIPT_DIR");             if(e != 0) mEnvScriptDir = iString(e) + this->GetDirSeparator(); else mEnvScriptDir = mEnvBaseDir;
132
147
    e = getenv("IFRIT_PALETTE_DIR");            if(e != 0) mEnvPaletteDir = iString(e) + this->GetDirSeparator(); else mEnvPaletteDir = mEnvBaseDir;
 
148
 
 
149
        mInitTimer = vtkTimerLog::New(); IERROR_ASSERT(mInitTimer);
 
150
        mInitTimer->StartTimer();
133
151
}
134
152
 
135
153
 
139
157
        //  This ensures that control module is deleted after the shell is deleted.
140
158
        //
141
159
//      mControlModule->Delete();
 
160
        mInitTimer->Delete();
142
161
}
143
162
 
144
163
 
185
204
                exit(0);
186
205
        }
187
206
        //
 
207
        //  Test that VTK is compiled with RTTI 
 
208
        //
 
209
        vtkDataSet *pp = vtkImageData::New();
 
210
        if(pp == 0)
 
211
        {
 
212
                tmp->OutputStartupMessage("There is not enough memory to run IFrIT.");
 
213
                exit(0);
 
214
        }
 
215
        vtkImageData *ps = dynamic_cast<vtkImageData*>(pp);
 
216
        if(ps == 0)
 
217
        {
 
218
                tmp->OutputStartupMessage("VTK has not been compiled with the RTTI (Run-Time Type Information) support.\nIFrIT needs all components to be compiled with the RTTI support.\nPlease re-compile VTK with the RTTI support enabled.");
 
219
                exit(0);
 
220
        }
 
221
        ps->Delete();
 
222
        //
188
223
        //  Create console: need the fully created "tmp->this" pointer
189
224
        //
190
225
        iConsole::CreateInstance(tmp);
213
248
        tmp->DefineSpecificCommandLineOptions();
214
249
        tmp->ParseCommandLineOptions(argc,argv);
215
250
        tmp->PrepareForConstruction();
 
251
#ifdef I_DEVEL
 
252
        tmp->InitHelper();
 
253
#endif
216
254
        //
217
255
        //  This ensures that "tmp->this" pointer is correct before a control module is created.
218
256
        //
219
 
        tmp->mControlModule = iControlModule::New(tmp); IERROR_ASSERT_NULL_POINTER(tmp->mControlModule);
220
 
        if(tmp->mNumProcs > 0) tmp->mControlModule->GetParallelManager()->ResetMaxNumberOfProcessors(tmp->mNumProcs);
 
257
        tmp->mCurInitStep = 1;
 
258
        tmp->mControlModule = iControlModule::New(tmp); IERROR_ASSERT(tmp->mControlModule);
 
259
        if(tmp->mNumProcs >= 0) tmp->mControlModule->GetParallelManager()->ResetMaxNumberOfProcessors(tmp->mNumProcs);
 
260
#ifdef I_DEVEL
 
261
        tmp->InitHelper();
 
262
#endif
221
263
        //
222
264
        //  Really construct the shell: control module needs to be fully initialized before a shell 
223
265
        //  is really constructed.
224
266
        //
 
267
        tmp->mCurInitStep = 2;
225
268
        tmp->ConstructorBody(); 
226
269
        //
227
270
        //   Load widget info into ObjectKeyHelp objects.
228
271
        //
229
 
        tmp->LoadObjectKeyHelp();
 
272
#ifdef I_DEVEL
 
273
        tmp->InitHelper();
 
274
#endif
230
275
        //
231
276
        //  Load the state file if needed
232
277
        //
 
278
        tmp->mCurInitStep = 3;
233
279
        if(tmp->mStateFileName.IsEmpty())
234
280
        {
235
281
                iString fname = tmp->mControlModule->GetFileName(_EnvironmentBase,"ifrit.ini");
239
285
        {
240
286
                tmp->LoadStateFile(tmp->mStateFileName);
241
287
        }
 
288
#ifdef I_DEVEL
 
289
        tmp->InitHelper();
 
290
#endif
242
291
        //
243
292
        //  Start the shell
244
293
        //
288
337
}
289
338
 
290
339
 
291
 
void iShell::LoadObjectKeyHelp()
292
 
{
293
 
        const iObjectKey *key;
294
 
 
295
 
        iObjectKeyRegistry::InitTraversal();
296
 
        while((key=iObjectKeyRegistry::GetNextKey()) != 0)
297
 
        {
298
 
                //
299
 
                //  We are accesing the class members directly since key->GetHelp() is const.
300
 
                //
301
 
//              this->FindWidgetForKey(key,key->mHelp->mWidgetName,key->mHelp->mWidgetDescription);
302
 
        }
303
 
}
304
 
 
305
 
 
306
340
void iShell::AddCommandLineOption(const iString &root, bool hasValue, const iString &help)
307
341
{
308
342
        Option tmp;
477
511
        return cur;
478
512
}
479
513
 
 
514
 
 
515
void iShell::OnInitAtom()
 
516
{
 
517
        mInitSteps[mCurInitStep].Current++;
 
518
        mInitTimer->StopTimer();
 
519
        if(mInitTimer->GetElapsedTime() > 0.1)
 
520
        {
 
521
                mInitTimer->StartTimer();
 
522
                this->OnInitAtomBody(true);
 
523
        }
 
524
        else
 
525
        {
 
526
                this->OnInitAtomBody(false);
 
527
        }
 
528
}
 
529
 
 
530
 
 
531
void iShell::OnInitAtomBody(bool timed)
 
532
{
 
533
}
 
534
 
 
535
 
 
536
#ifdef I_DEVEL
 
537
void iShell::InitHelper()
 
538
{
 
539
        if(mInitSteps[mCurInitStep].Current != mInitSteps[mCurInitStep].Total)
 
540
        {
 
541
                int step = mCurInitStep;
 
542
                int total = mInitSteps[mCurInitStep].Current;
 
543
                int bp = 0;
 
544
        }
 
545
}
 
546
#endif
 
547