"initialize" section in Flowchart

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
GlobeMaker
Posts: 216
Joined: 30.10.2005
With us: 19 years

"initialize" section in Flowchart

Post #1by GlobeMaker » 29.12.2005, 18:52

December 29, 2005, Rev. 4

An unofficial flowchart for Celestia is being developed, and the box
called "initialize" is being explained in this forum thread. In a
different thread, the "update" box was discussed, so that some
familiarity would be gained with the C++ open source software.

http://www.celestiaproject.net/forum/viewtopic.php?t=8522

This has involved reading the source code. A future, second style
for familiarization will be to use a compiler IDE to single-step through
programs. That is an integrated development environment where
class views are really pretty.

Here is the flowchart where the "initialize" box resides :
Image
Refresh your browser to see the latest version.

The initialization takes place on one of three types of operating systems:
Apple OS X, Linux class, and Microsoft Windows. For my PC system,
the first program is called winmain.cpp . Here is the sequence of
events to initialize :

INITIALIZE

Step 1 Declare prototypes, templates, structures, operators, variables
Step 2 Instantiate classes as objects (here are examples) :
static CelestiaCore* appCore = NULL;
static SolarSystemBrowser* solarSystemBrowser = NULL;

HWND CreateOpenGLWindow(int x, int y, int widt ...
{HWND hwnd = CreateWindow(AppName, ...
return hwnd;}

implement "default setting" classes

Step 3 Start executing main function !!!!!!!!!!!!!!!!!!!!!!!
int APIENTRY WinMain(HINSTANCE hInstance,

Step 4 Check if a celestia.exe is already running

Step 5 Specify some default values in case registry keys are not found.

Step 6 appCore = new CelestiaCore();

Step 7 appCore->setAlerter(new WinAlerter());

Step 8,9 if (!appCore->initSimulation(altConfig, &extrasDirectories))
{
return 1;
}


The step above calls celestiacore.cpp initSimulation (See below the line)


Step 10 UpdateWindow(mainWindow);
This draws the screen before the loop starts.

Step 11 // Set values saved in registry: renderFlags, visualMagnitude, labelMode and timezone bias.
appCore->getSimulation()->setFaintestVisible(prefs.visualMagnitude)...etc.

Step 12 appCore->getSimulation()->getActiveObserver()->setDisplayedSurface(prefs.altSurfaceName);
appCore->getRenderer()->setResolution(prefs.textureResolution);

Step 13 appCore->start((double) time(NULL) / 86400.0 +
(double) astro::Date(1970, 1, 1));

Step 14 MSG msg;
PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);

End of initialization in winmain.cpp
_______________________________________________________

Step 15 Begin celestiacore.cpp initialization description

CelestiaCore::CelestiaCore() : config(NULL),...
{
/* Get a renderer here so it may be queried for capabilities of the
underlying engine even before rendering is enabled. Its initRenderer()
routine will be called much later. */
renderer = new Renderer();
timer = CreateTimer();

execEnv = new CoreExecutionEnvironment(*this);



Step 16 initSimulation calls SolarSystemLoader and other loaders
bool CelestiaCore::initSimulation(const string* configFileName,
const vector<string>* extrasDirs)
{...
universe = new Universe();
sim = new Simulation(universe); ...}
...
// First read the solar system files listed individually in the
// config file.
{
SolarSystemCatalog* solarSystemCatalog = new SolarSystemCatalog();
universe->setSolarSystemCatalog(solarSystemCatalog);
for (vector<string>::const_iterator iter = config->solarSystemFiles.begin();
iter != config->solarSystemFiles.end();
iter++)
{
ifstream solarSysFile(iter->c_str(), ios::in);
if (!solarSysFile.good())
{
warning(_("Error opening solar system catalog.\n"));
}
else
{
LoadSolarSystemObjects(solarSysFile, *universe, "");
}
}
}

// Next, read all the solar system files in the extras directories
{
for (vector<string>::const_iterator iter = config->extrasDirs.begin();
iter != config->extrasDirs.end(); iter++)
{
if (*iter != "")
{
Directory* dir = OpenDirectory(*iter);

SolarSystemLoader loader(universe);
loader.pushDir(*iter);
dir->enumFiles(loader, true);
...
// We'll first read a very large DSO catalog from a bundled file:
if (config->deepSkyCatalog != "")
{
ifstream dsoFile(config->deepSkyCatalog.c_str(), ios::in);
// Next, read all the deep sky files in the extras directories
// Load asterisms: (still in initSimulation)




class SolarSystemLoader : public EnumFilesHandler
{
public:
Universe* universe;
SolarSystemLoader(Universe* u) : universe(u) {};
bool process(const string& filename)
{
if (DetermineFileType(filename) == Content_CelestiaCatalog)
{
string fullname = getPath() + '/' + filename;
clog << _("Loading solar system catalog: ") << fullname << '\n';
...}

It is loading the catalog. I traced what called that, but not where the catalog is used.




void CelestiaCore::start(double t)
{
if (config->initScriptFile != "")
{
// using the KdeAlerter in runScript would create an infinite loop,
// break it here by resetting config->initScriptFile:
string filename = config->initScriptFile;
config->initScriptFile = "";
runScript(filename);
}
// Set the simulation starting time to the current system time
sim->setTime(t);
sim->update(0.0);

___________________________________________

Conclusion : please make corrections and improvements to
the flowchart and to the explanations of the software.
This will help people to become familiar with the open source
software. In particular, point out the branches and loops that
are not described in the text, so a flowchart can be drawn.
There must be loops to initialize various types of similar
objects. Some branching may occur, but it usually leads into
"the frame rate loop" of the top level flowchart.
Your wish is my command line.

Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 2 months
Location: Pordenone/Italy

Post #2by Paolo » 30.12.2005, 08:17

Hi Globemaker

Your effort should be quite interesting and I don't want to discourage you but form many reasons I think that you'll get only a non positive feedback by the developer community. Probably the answer will be some sort of: /Celestia code is quite complex and advanced so only very experienced programmers will be able to deal with it effectively. Very experienced programmers can read the code as is and don't need a flowchart that shows the internal logic of the software/.

Beside this pessimistic thoughts I think that your initiative is good but you are using the wrong tool.
To do this kind of job you need some sort of UML tool like:

Code: Select all


MagicDraw UML 10.5
Unleash the Power of Full UML 2.0: Samples, Viewlets & Free Edition
www.magicdraw.com

Free UML Modeling Tool
Model, Code, Deploy, Rose & XMI, Roundtrip Engine & CRC Cards & More
www.visual-paradigm.com

Download a free UML tool
Poseidon for UML is a fully fledged tool with a free Community Edition
www.gentleware.com

Free UML Knowledge
Get practical software analysis knowledge on UML, UP, OO, MDA, ER
www.methodsandtools.com
 
ADS By Google



Moreover you have not to focus on the operative system, Celestia is a multiplatform software, so it is important to keep the model as general as possible and do not mention procedures or calls to the operative system.

Kind regards
Remember: Time always flows, it is the most precious thing that we have.
My Celestia - Celui


Return to “Development”