main.cpp 1.22 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
#include <QSplashScreen>
#include "schnapps.h"
#include <QFileInfo>
4 5
#include "PythonQt.h"
#include "gui/PythonQtScriptingConsole.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);

	QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png"));
	splash->show();
	splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter);

	// init PythonQt and Python itself
	PythonQt::init();

	QStringList classNames;
	classNames.append("View");
	classNames.append("Camera");
	classNames.append("Plugin");
	classNames.append("MapHandlerGen");
	PythonQt::self()->registerQObjectClassNames(classNames);

	// get a smart pointer to the __main__ module of the Python interpreter
	PythonQtObjectPtr pythonContext = PythonQt::self()->getMainModule();

28 29
	PythonQtScriptingConsole* pythonConsole = new PythonQtScriptingConsole(NULL, pythonContext);

Sylvain Thery's avatar
Sylvain Thery committed
30
	CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, *pythonConsole);
Pierre Kraemer's avatar
Pierre Kraemer committed
31

Sylvain Thery's avatar
Sylvain Thery committed
32 33 34
	schnapps.show();

	pythonContext.addObject("schnapps", &schnapps);
35 36 37 38 39 40 41 42

	if(argc > 1)
	{
		QString filename(argv[1]);
		QFileInfo fi(filename);
		if(fi.exists())
			pythonContext.evalFile(fi.filePath());
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
43

Sylvain Thery's avatar
Sylvain Thery committed
44
	splash->finish(&schnapps);
Pierre Kraemer's avatar
Pierre Kraemer committed
45 46
	delete splash;

47
	return app.exec();;
Pierre Kraemer's avatar
Pierre Kraemer committed
48
}