예제 #1
0
파일: main.cpp 프로젝트: aldoxtor/openrw
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    ViewerWindow viewer;
    viewer.show();

    return app.exec();
}
ViewerWindow *
ViewerSubjectProxyFactory::CreateViewerWindow(int windowIndex)
{
    ViewerWindow *win = ViewerFactoryUI::CreateViewerWindow(windowIndex);

    // Ensure the action UI's get created before we call the window creation callback.
    win->GetActionManager()->EnableActions(ViewerWindowManager::Instance()->GetWindowAtts());

    if(createWindowCB != NULL)
        (*createWindowCB)(win, createWindowCBData);

    return win;
}
예제 #3
0
static void
DDTUpdateWindowInformation(WindowInformation *windowInfo, int flags, void *)
{ 
    ViewerWindow *win = ViewerWindowManager::Instance()->GetActiveWindow();
    if(win == NULL)
        return;

    if((flags & WINDOWINFO_SOURCE) != 0)
    {
        if(win->GetPlotList()->GetHostDatabaseName().empty())
            windowInfo->SetActiveSource("notset");
        else
        {
            windowInfo->SetActiveSource(win->GetPlotList()->GetHostDatabaseName());

            // Not using DDTManager::isDDTSim() here, as for some reason at this
            // point the EngineKey is not flagged as a simulation
            windowInfo->SetDDTSim(DDTManager::isDatabaseDDTSim(win->GetPlotList()->GetDatabaseName().c_str()));
        }
        DDTSession *session = DDTManager::getInstance()->getSessionNC();
        windowInfo->SetDDTConnected(session && session->connected());
    }

    if((flags & WINDOWINFO_ANIMATION) != 0 ||
       (flags & WINDOWINFO_TIMESLIDERS) != 0)
    {
        if (DDTManager::isDDTSim(win))
        {
            const EngineKey &key = win->GetPlotList()->GetEngineKey();
            if (key.IsSimulation())
            {
                const avtDatabaseMetaData *md = ViewerBase::GetViewerEngineManager()->GetSimulationMetaData(key);
                if (md->GetSimInfo().GetMode()==avtSimulationInformation::Running)
                    windowInfo->SetAnimationMode(3);
                else
                    windowInfo->SetAnimationMode(2);
            }
        }
    }
}
예제 #4
0
void
DDTSession::readDataFromDDT()
{
    QTextStream in(mSocket);

    QString message = in.readLine();
    while(!message.isNull())       // For each line of text received from socket
    {
        if (message=="raise")
        {
            // There could be multiple viewer windows. We don't know which one
            // corresponds to the DDT instance that sent this request, so
            // raise all of them that come from DDT-named database
            const int numWindows = ViewerWindowManager::Instance()->GetNumWindows();
            for (int i=0; i<numWindows; ++i)
            {
                ViewerWindow* win = ViewerWindowManager::Instance()->GetWindow(i);
                if (DDTManager::isDatabaseDDTSim(win->GetPlotList()->GetDatabaseName()))
                    win->ActivateWindow();
            }
        }
        else if (message=="release")
        {
            // There could be multiple viewer windows. We don't know which one
            // corresponds to the DDT instance that sent this request, so send
            // command to all of them that come from DDT-named database
            const int numWindows = ViewerWindowManager::Instance()->GetNumWindows();
            for (int i=0; i<numWindows; ++i)
            {
                ViewerWindow* win = ViewerWindowManager::Instance()->GetWindow(i);
                if (DDTManager::isDatabaseDDTSim(win->GetPlotList()->GetDatabaseName()))
                {
                    const EngineKey &key = win->GetPlotList()->GetEngineKey();
                    if (key.IsSimulation())
                        ViewerEngineManager::Instance()->SendSimulationCommand(
                                key, "DDT", "");
                }
            }
        }
        else
            Error(QString("Unrecognised message from DDT: %0").arg(message));

        message = in.readLine();
    }
}
예제 #5
0
int
main( int argc, char** argv )
{
	//std::ofstream logFile( "Log.txt" );
        //SET_LOUT( logFile );

        //D_COMMAND( std::ofstream debugFile( "Debug.txt" ); );
        //SET_DOUT( debugFile );

	//XInitThreads();
	ApplicationManager appManager;

	boost::filesystem::path executablePath(argv[0]);
	boost::filesystem::path dataDirName = GET_SETTINGS( "application.data_directory", std::string, (boost::filesystem::path(argv[0]).parent_path() / "data").string() );
	//If we cannot locate data directory - try other posiible locations
	if (!boost::filesystem::exists(dataDirName) || !boost::filesystem::is_directory(dataDirName)) {
		std::vector<boost::filesystem::path> possibleDataDirs;
		possibleDataDirs.push_back(boost::filesystem::current_path() / "data");
		possibleDataDirs.push_back(executablePath.parent_path() / "data");
		possibleDataDirs.push_back(executablePath.parent_path().parent_path() / "data");

		std::vector<boost::filesystem::path>::const_iterator it = possibleDataDirs.begin();
		bool found = false;
		LOG( "Trying to locate 'data' directory:" );
		while (!found && it != possibleDataDirs.end()) {
			LOG_CONT( "\tChecking: " << it->string() << " ... ");
			if (boost::filesystem::exists(*it) && boost::filesystem::is_directory(*it)) {
				dataDirName = *it;
				SET_SETTINGS( "application.data_directory", std::string, dataDirName.string() );
				found = true;
				LOG( "SUCCESS" );
			} else {
				LOG( "FAILED" );
			}
			++it;
		}
		if (!found) {
			BOOST_THROW_EXCEPTION( M4D::ErrorHandling::EDirNotFound() );
		}
	}
	boost::filesystem::path dirName = GET_SETTINGS( "gui.icons_directory", std::string, ( dataDirName / "icons" ).string() );
	appManager.setIconsDirectory(dirName);
	appManager.initialize( argc, argv );

	try {
		//processCommandLine( argc, argv );
		ViewerWindow viewer;
		appManager.setMainWindow( viewer );

		createModules();

		appManager.loadModules();
		viewer.showMaximized();
		return appManager.exec();
	} catch ( std::exception &e )
	{
		QMessageBox::critical ( NULL, "Exception", QString( e.what() ) );
	} 
	catch (...) {
		QMessageBox::critical ( NULL, "Exception", "Unknown error" );
	}
	
	return 1;
}