Ejemplo n.º 1
0
MAdder::MAdder()
{
    hasInputs();
    hasOutput();
    wave1Input = createInput("wave1");
    wave2Input = createInput("wave2");
}
Ejemplo n.º 2
0
QuickKeysMenu::QuickKeysMenu()
{
  // add controls
  std::vector<HUDuiControl*>& controls = getControls();

  controls.push_back(createLabel("Define Quick Keys"));
  controls.push_back(createLabel("Notice: depending on platform not all keys might work"));

  controls.push_back(createLabel("Send to All"));
  controls.push_back(createLabel("Send to Team"));

  firstKeyControl = controls.size();

  int i;
  for (i=1; i < 11; i++) {
    std::string keyLabel = string_util::format("Alt-F%d", i);
    controls.push_back(createInput(keyLabel));
  }

  for (i=1; i < 11; i++) {
    std::string keyLabel = string_util::format("Ctrl-F%d", i);
    controls.push_back(createInput(keyLabel));
  }

  initNavigation(controls, firstKeyControl, controls.size()-1);
}
Ejemplo n.º 3
0
const bool V3QuteRTLClockHandler(V3NtkInput* const quteHandler, const V3NetVec& piList, V3NetVec& inputs) {
   assert (quteHandler); assert (!inputs.size() || (piList.size() == inputs.size()));
   V3BvNtk* const ntk = dynamic_cast<V3BvNtk*>(quteHandler->getNtk()); assert (ntk);
   if (V3NetUD != ntk->getClock()) {
      for (uint32_t i = 0; i < piList.size(); ++i) 
         if (ntk->getClock().id == piList[i].id) { if (inputs.size()) inputs[i] = V3NetUD; continue; }
         else if (!createInput(ntk, piList[i])) return false;
   }
   else for (uint32_t i = 0; i < piList.size(); ++i) if (!createInput(ntk, piList[i])) return false;
   assert (ntk->getInputSize() == (piList.size() - ((V3NetUD != ntk->getClock()) ? 1 : 0))); return true;
}
Ejemplo n.º 4
0
void KisColorSliderInput::init()
{
    QHBoxLayout* m_layout = new QHBoxLayout(this);
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(1);

    QString m_name;
    switch (m_type){
    case 0: m_name=i18n("Hue"); break;
    case 1: m_name=i18n("Saturation"); break;
    case 2: m_name=i18n("Value"); break;
    case 3: m_name=i18n("Hue"); break;
    case 4: m_name=i18n("Saturation"); break;
    case 5: m_name=i18n("Lightness"); break;
    case 6: m_name=i18n("Hue"); break;
    case 7: m_name=i18n("Saturation"); break;
    case 8: m_name=i18n("Intensity"); break;
    case 9: m_name=i18n("Hue"); break;
    case 10: m_name=i18n("Saturation"); break;
    case 11: m_name=i18n("Luma"); break;
    }
    
    QLabel* m_label = new QLabel(i18n("%1:", m_name), this);
    m_layout->addWidget(m_label);

    m_hsvSlider = new KisHSVSlider(Qt::Horizontal, this, m_displayRenderer, m_canvas);
    m_hsvSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    m_layout->addWidget(m_hsvSlider);
    connect (m_hsvSlider,  SIGNAL(sliderPressed()), SLOT(sliderIn()));
    connect (m_hsvSlider,  SIGNAL(sliderReleased()), SLOT(sliderOut()));

    QWidget* m_input = createInput();
    m_hsvSlider->setFixedHeight(m_input->sizeHint().height());
    m_layout->addWidget(m_input);
}
Ejemplo n.º 5
0
void Game::run()
{
	if (!ogreRoot)
		return;

	if (!ogreRoot->showConfigDialog())
		return;

	ogreRoot->initialise(true, "OgreWindow");

	createWindow();
	createSceneManager();
	createCamera();
	createViewport();
	createInput();
	setupResourceManager();

	Ogre::Entity *ogreHead = sceneManager->createEntity("OgreHead", "T80_obj.mesh");
	Ogre::SceneNode *ogreHeadNode = sceneManager->getRootSceneNode()
									->createChildSceneNode("Head Node", Ogre::Vector3(-50.0f, 30.0f, 0.0f));
	ogreHeadNode->attachObject(ogreHead);

	Ogre::Light *directionalLight = sceneManager->createLight("DirectionalLight");
	directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
	directionalLight->setDiffuseColour(Ogre::ColourValue(.4, 0, 0));
	directionalLight->setSpecularColour(Ogre::ColourValue(.4, 0, 0));
	directionalLight->setDirection(Ogre::Vector3(0, -1, 1));

	ogreRoot->addFrameListener(this);
	ogreRoot->startRendering();
}
Ejemplo n.º 6
0
InputManager::InputManager()
{
	/* Setup some default input events, this is a good a place as any. */
	createInput( sf::Keyboard::W, Inputs::FORWARD );
	createInput( sf::Keyboard::S, Inputs::BACK );
	createInput( sf::Keyboard::A, Inputs::LEFT );
	createInput( sf::Keyboard::D, Inputs::RIGHT );
	createInput( sf::Keyboard::Space, Inputs::JUMP );
	createInput( sf::Keyboard::LShift, Inputs::SPRINT );
	createInput( sf::Keyboard::F, Inputs::FLY );
	createInput( sf::Keyboard::F2, Inputs::SCREENSHOT );
	createInput( sf::Keyboard::R, Inputs::RESPAWN );
}
Ejemplo n.º 7
0
	bool BaseManager::create(int _width, int _height)
	{
		const unsigned int width = _width;
		const unsigned int height = _height;
		bool windowed = true;

		// регистрируем класс окна
		WNDCLASS wc =
		{
			0, (WNDPROC)DXWndProc, 0, 0, GetModuleHandle(NULL), LoadIcon(NULL, MAKEINTRESOURCE(1001)),
			LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, TEXT(WND_CLASS_NAME),
		};
		RegisterClass(&wc);

		// создаем главное окно
		hWnd = CreateWindow(wc.lpszClassName, TEXT("OpenGL3 Render Window"), WS_POPUP,
			0, 0, 0, 0, GetDesktopWindow(), NULL, wc.hInstance, this);
		if (!hWnd)
		{
			//OutException("fatal error!", "failed create window");
			return false;
		}

	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
		HINSTANCE instance = ::GetModuleHandleA(buf);
		HICON hIconSmall = static_cast<HICON>(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 32, 32, LR_DEFAULTSIZE));
		HICON hIconBig = static_cast<HICON>(LoadImage(instance, MAKEINTRESOURCE(1001), IMAGE_ICON, 256, 256, LR_DEFAULTSIZE));
		if (hIconSmall)
			::SendMessageA(hWnd, WM_SETICON, 0, (LPARAM)hIconSmall);
		if (hIconBig)
			::SendMessageA(hWnd, WM_SETICON, 1, (LPARAM)hIconBig);
	#endif

		hInstance = wc.hInstance;

		windowAdjustSettings(hWnd, width, height, !windowed);

		if (!createRender(width, height, windowed))
		{
			return false;
		}

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();

		return true;
	}
Ejemplo n.º 8
0
	bool BaseManager::create()
	{
		const unsigned int width = 1024;
		const unsigned int height = 768;
		bool windowed = true;

		// регистрируем класс окна
		WNDCLASS wc =
		{
			0, (WNDPROC)DXWndProc, 0, 0, GetModuleHandle(NULL), LoadIcon(NULL, MAKEINTRESOURCE(1001)),
			LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, TEXT(WND_CLASS_NAME),
		};
		RegisterClass(&wc);

		// создаем главное окно
		hWnd = CreateWindow(wc.lpszClassName, TEXT("Direct3D9 Render Window"), WS_POPUP,
			0, 0, 0, 0, GetDesktopWindow(), NULL, wc.hInstance, this);
		if (!hWnd)
		{
			//OutException("fatal error!", "failed create window");
			return false;
		}

	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		// берем имя нашего экзешника
		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
		// берем инстанс нашего модуля
		HINSTANCE instance = ::GetModuleHandleA(buf);
		// побыстрому грузим иконку
		HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
		if (hIcon)
		{
			::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
			::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
		}
	#endif

		hInstance = wc.hInstance;

		windowAdjustSettings(hWnd, width, height, !windowed);

		createRender(width, height, windowed);

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();

		return true;
	}
Ejemplo n.º 9
0
void BasisManager::createBasisManager(void) // создаем начальную точки каркаса приложения
{
	Ogre::String pluginsPath;
	// only use plugins.cfg if not static
	#ifndef OGRE_STATIC_LIB
		pluginsPath = mResourcePath + "plugins.cfg";
	#endif
	
	mRoot = new Ogre::Root(pluginsPath, mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");

	setupResources();

	if (!mRoot->restoreConfig()) { // попробуем завестись на дефолтных
		if (!mRoot->showConfigDialog()) return; // ничего не получилось, покажем диалог
	}

	mWindow = mRoot->initialise(true, "MyGUI Layout Editor");
	mWidth = mWindow->getWidth();
	mHeight = mWindow->getHeight();

	mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "BasisSceneManager");

	mCamera = mSceneMgr->createCamera("BasisCamera");
	mCamera->setNearClipDistance(5);
	mCamera->setPosition(Ogre::Vector3(200, 200, 200));
	mCamera->lookAt(Ogre::Vector3(0.0, 0.0, 0.0));

	// Create one viewport, entire window
	Ogre::Viewport * vp = mWindow->addViewport(mCamera);
	// Alter the camera aspect ratio to match the viewport
	mCamera->setAspectRatio(Ogre::Real(mWidth) / Ogre::Real(mHeight));

	// Set default mipmap level (NB some APIs ignore this)
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

	Ogre::Light* mLight = mSceneMgr->createLight("BasisLight");
	mLight->setDiffuseColour(Ogre::ColourValue::White);
	mLight->setSpecularColour(Ogre::ColourValue::White);
	mLight->setAttenuation(8000,1,0.0005,0);

	// Load resources
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	createInput();

	changeState(&mEditor);

#ifdef WIN32
	g_setMainWindowInfo("MyGUI Layout Editor", IDI_ICON);
#endif

	mRoot->startRendering();
}
Ejemplo n.º 10
0
void MLMultiContainer::publishInput(const MLPath & procName, const MLSymbol inputName, const MLSymbol alias)
{
	const int copies = (int)mCopies.size();	
	for(int i=0; i<copies; i++)
	{
		getCopyAsContainer(i)->publishInput(procName, inputName, alias);
	}
	
	// make dummy input for prepareToProcess()
	// if not allocated, make space for input pointer and zero it
	const int index = getCopyAsContainer(0)->getNumInputs();
	createInput(index);
}
Ejemplo n.º 11
0
gkLogic::gkLogic(gkScene* scene)
	: m_scene(scene), m_tree(0),
	  m_camera(scene->getMainCamera()), m_upKeyNode(0), m_downKeyNode(0),
	  m_leftKeyNode(0), m_rightKeyNode(0), m_spaceKeyNode(0), m_rKeyNode(0),
	  m_cameraNode(0), m_dKeyNode(0), m_cKeyNode(0)
{
	GK_ASSERT(m_scene);
	m_tree = gkNodeManager::getSingleton().createLogicTree(m_scene->getGroupName());

	createInput();
	createVehicle();
	createCamera();
	createDisplayProps();

	m_tree->solveOrder();
	m_camera->attachLogic(m_tree);
}
Ejemplo n.º 12
0
	bool BaseManager::create(HWND hWnd)
	{

		this->hWnd = hWnd;

		createRender();

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		windowResized();

		return true;
	}
Ejemplo n.º 13
0
    bool init(int argc, char** argv)
    {
        if (!processCmdLine(argc, argv, &m_params)) {
            fprintf(stderr, "process arguments failed.\n");
            return false;
        }
        m_output.reset(DecodeOutput::create(m_params.renderMode, m_params.renderFourcc, m_params.inputFile, m_params.outputFile.c_str()));
        if (!m_output) {
            fprintf(stderr, "DecodeOutput::create failed.\n");
            return false;
        }
        m_nativeDisplay = m_output->nativeDisplay();
        m_vppInput = createInput(m_params, m_nativeDisplay);

        if (!m_nativeDisplay || !m_vppInput) {
            fprintf(stderr, "DecodeTest init failed.\n");
            return false;
        }
        return true;
    }
Ejemplo n.º 14
0
	void BaseManager::registerWindow(HWND _hWnd, HGE* _mpHGE, bool _isWindowed) {
		hWnd = _hWnd;
		mpHGE = _mpHGE;

#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32

		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);

		HINSTANCE instance = ::GetModuleHandleA(buf);

		HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
		if (hIcon)
		{
			::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
			::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
		}
#endif

		hInstance = instance;

		RECT rect = { 0, 0, 0, 0 };
		GetClientRect(hWnd, &rect);
		int width = rect.right - rect.left;
		int height = rect.bottom - rect.top;

		windowAdjustSettings(hWnd, width, height, !_isWindowed);

		//createRender(width, height, _isWindowed);

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();
	}
Ejemplo n.º 15
0
MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent), oriRaman(NULL), pixmap(NULL), saveMenu(NULL)
{
	createFileMenu();
	createStatusBar();

	QHBoxLayout *layout = new QHBoxLayout;

	createInput();
	layout->addLayout(inputLayout);
	// 拉曼成像图显示
	scene = new QGraphicsScene(this);
	scene->setSceneRect(QRectF(0, 0, sceneWidth, sceneHeight));
	view = new QGraphicsView(scene);
	view->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(view, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(show_savemenu(const QPoint&)));
	layout->addWidget(view);

	QWidget *widget = new QWidget;
	widget->setLayout(layout);
	setCentralWidget(widget);
	setWindowTitle(tr("Raman"));
}
Ejemplo n.º 16
0
TAC_NODE* createInput(TAC_NODE* code) {
	if(code==NULL) return code;

 	return joinTacs(createTacNode(TAC_READ, code->result, NULL, NULL), createInput(code->next));
}
Ejemplo n.º 17
0
void BasisManager::createBasisManager(void) // создаем начальную точки каркаса приложения
{

	Ogre::String pluginsPath;
	// only use plugins.cfg if not static
	#ifndef OGRE_STATIC_LIB
		pluginsPath = mResourcePath + "plugins.cfg";
	#endif

    mRoot = new Ogre::Root(pluginsPath, mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");

	setupResources();

	if (!mRoot->restoreConfig()) { // попробуем завестись на дефолтных
		if (!mRoot->showConfigDialog()) return; // ничего не получилось, покажем диалог
	}

	mWindow = mRoot->initialise(true);
	mWidth = mWindow->getWidth();
	mHeight = mWindow->getHeight();

    mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "BasisSceneManager");

    mCamera = mSceneMgr->createCamera("BasisCamera");
    mCamera->setNearClipDistance(5);
	mCamera->setPosition(Ogre::Vector3(200, 200, 200));
	mCamera->lookAt(Ogre::Vector3(0.0, 0.0, 0.0));

    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(Ogre::Real(mWidth) / Ogre::Real(mHeight));

    // Set default mipmap level (NB some APIs ignore this)
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

	Ogre::Light* mLight = mSceneMgr->createLight("BasisLight");
	mLight->setDiffuseColour(Ogre::ColourValue::White);
	mLight->setSpecularColour(Ogre::ColourValue::White);
	mLight->setAttenuation(8000,1,0.0005,0);

	// Load resources
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

	mRoot->addFrameListener(this);
	Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

	createInput();

	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("wallpaper");
	if (false == material.isNull()) {
		/*Ogre::OverlayManager & manager = Ogre::OverlayManager::getSingleton();
		Ogre::Overlay * overlay = manager.create("wallpaper");
		overlay->setZOrder(0);
		overlay->show();
		Ogre::PanelOverlayElement * panel = static_cast<Ogre::PanelOverlayElement*>(manager.createOverlayElement("Panel", "wallpaper"));
		panel->setDimensions(1, 1);
		panel->setMaterialName(material->getName());
		overlay->add2D(panel);*/
	}

	createGui();

	createScene();

    mRoot->startRendering();
}
Ejemplo n.º 18
0
	bool BaseManager::init()
	{
		Ogre::String pluginsPath;

		mFrameCount = 0;
		mPickFrameCount = 0;
		mPickX = 0;
		mPickY = 0;

		#ifndef OGRE_STATIC_LIB
			pluginsPath = mResourcePath + mPluginCfgName;
		#endif

		mFastReset = false;
		mReset = false;
		mExit = false;
		
		mInputFilter = new InputFilter();

		mRoot = new Ogre::Root(pluginsPath, mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");

		Ogre::Log* plog = Ogre::LogManager::getSingleton().getDefaultLog();
		if( plog ){
			mCoutSource = new CoutSource();
			plog->addListener( mCoutSource );
		}
        
		//恢复Ogre配置,如果第一次配置启动一个Ogre配置对话框
		if (!mRoot->restoreConfig())
		{
			if (!mRoot->showConfigDialog()) return false;
		}

		mWindow = mRoot->initialise(true);

		createSceneManager();

		// Set default mipmap level (NB some APIs ignore this)
		Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

		mRoot->addFrameListener(this);
		Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

		size_t handle = 0;
		mWindow->getCustomAttribute("WINDOW", &handle);

		mSceneQuery = mSceneManager->createRayQuery( Ogre::Ray() );

		createGui();
        
		createInput(handle);

		createPointerManager(handle);
        
		createScene();

		windowResized(mWindow);

		mRoot->getRenderSystem()->_initRenderTargets();

		setPointerVisible(false);

		return true;
	}
Ejemplo n.º 19
0
	bool BaseManager::create()
	{
		const unsigned int width = 1024;
		const unsigned int height = 768;
		bool windowed = true;

		mpHGE = hgeCreate(HGE_VERSION);
		if (!mpHGE)
			return false;

		mpHGE->System_SetState(HGE_WINDOWED, windowed);
		mpHGE->System_SetState(HGE_SCREENWIDTH, width);
		mpHGE->System_SetState(HGE_SCREENHEIGHT, height);
		mpHGE->System_SetState(HGE_USESOUND, false);
		mpHGE->System_SetState(HGE_HIDEMOUSE, false);
		mpHGE->System_SetState(HGE_SHOWSPLASH, true);
		mpHGE->System_SetState(HGE_FPS, 100);
		mpHGE->System_SetState(HGE_LOGFILE, "hge.log");
		mpHGE->System_SetState(HGE_FRAMEFUNC, frame);

		if (!mpHGE->System_Initiate())
			return false;
		
		hWnd = mpHGE->System_GetState(HGE_HWND);
		//hgeSprite			*portalSprite;
		//HTEXTURE hPortal = mpHGE->Texture_Load("resources/gems.png");
		//portalSprite = new hgeSprite(hPortal, 0, 31, 32, 32);
		//portalSprite->Render(0, 0);
		/*
		
		WNDCLASS wc =
		{
			0, (WNDPROC)DXWndProc, 0, 0, GetModuleHandle(NULL), LoadIcon(NULL, MAKEINTRESOURCE(1001)),
			LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, TEXT(WND_CLASS_NAME),
		};
		RegisterClass(&wc);


		hWnd = CreateWindow(wc.lpszClassName, TEXT("Direct3D9 Render Window"), WS_POPUP,
			0, 0, 0, 0, GetDesktopWindow(), NULL, wc.hInstance, this);
		if (!hWnd)
		{
			//OutException("fatal error!", "failed create window");
			return false;
		}
		*/
	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32

		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);

		HINSTANCE instance = ::GetModuleHandleA(buf);

		HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
		if (hIcon)
		{
			::SendMessageA((HWND)hWnd, WM_SETICON, 1, (LPARAM)hIcon);
			::SendMessageA((HWND)hWnd, WM_SETICON, 0, (LPARAM)hIcon);
		}
	#endif

		hInstance = instance;

		windowAdjustSettings(hWnd, width, height, !windowed);

		createRender(width, height, windowed);

		createGui();

		createInput((size_t)hWnd);

		createPointerManager((size_t)hWnd);

		createScene();

		_windowResized();

		return true;
	}
Ejemplo n.º 20
0
void MultiAgentTest::doTest()
{
	sml::Kernel* pKernel = sml::Kernel::CreateKernelInNewThread();
	CPPUNIT_ASSERT_MESSAGE( pKernel->GetLastErrorDescription(), !pKernel->HadError() );

	// We'll require commits, just so we're testing that path
	pKernel->SetAutoCommit( false ) ;

	// Comment this in if you need to debug the messages going back and forth.
	//pKernel->SetTraceCommunications(true) ;

	CPPUNIT_ASSERT( numberAgents < MAX_AGENTS );

	std::vector< std::string > names;
	std::vector< sml::Agent* > agents;
	std::vector< std::stringstream* > trace;
	std::vector< int > callbackPrint;

	// Create the agents
	for ( int agentCounter = 0 ; agentCounter < numberAgents ; ++agentCounter )
	{
		std::stringstream name;
		name << "agent" << 1 + agentCounter;
		names.push_back( name.str() );

		sml::Agent* pAgent   = pKernel->CreateAgent( name.str().c_str() ) ;
		CPPUNIT_ASSERT( pAgent != NULL );
		CPPUNIT_ASSERT_MESSAGE( pKernel->GetLastErrorDescription(), !pKernel->HadError() );

		agents.push_back( pAgent );

		std::stringstream path;
		// TODO: use boost filesystem
		CPPUNIT_ASSERT( pAgent->LoadProductions( "test_agents/testmulti.soar" ) );
		createInput( pAgent, 0 );

		// Collect the trace output from the run
		trace.push_back( new std::stringstream() );
		callbackPrint.push_back( pAgent->RegisterForPrintEvent( sml::smlEVENT_PRINT, MultiAgentTest::MyPrintEventHandler, trace[agentCounter] ) );
	}

	pKernel->RegisterForUpdateEvent( sml::smlEVENT_AFTER_ALL_GENERATED_OUTPUT, MultiAgentTest::MyUpdateEventHandler, NULL ) ;

	// Run for a first set of output, so we can see whether that worked
	pKernel->RunAllTilOutput() ;

	// Print out some information
	reportAgentStatus( pKernel, numberAgents, trace ) ;

	// Now get serious about a decent run
	const int kFirstRun = 5 ;
	for (int i = 0 ; i < kFirstRun ; i++)
	{
		// Run for a bit
		pKernel->RunAllTilOutput() ;
	}

	reportAgentStatus(pKernel, numberAgents, trace) ;

	// Toss in an init-soar and then go on a bit further
	initAll(pKernel) ;

	// Second run
	const int kSecondRun = 5 ;
	for (int i = 0 ; i < kSecondRun ; i++)
	{
		// Run for a bit
		pKernel->RunAllTilOutput() ;
	}

	reportAgentStatus(pKernel, numberAgents, trace) ;

	for ( std::vector< std::stringstream* >::iterator iter = trace.begin(); iter != trace.end(); ++iter )
	{
		delete *iter;
	}

	//cout << "Calling shutdown on the kernel now" << endl ;
	pKernel->Shutdown() ;
	//cout << "Shutdown completed now" << endl ;

	// Delete the kernel.  If this is an embedded connection this destroys the kernel.
	// If it's a remote connection we just disconnect.
	delete pKernel ;
}
Ejemplo n.º 21
0
	bool BaseManager::create(int _width, int _height)
	{
		// initialize SDL
		if (SDL_Init(SDL_INIT_VIDEO) != 0)
		{
			std::cerr << "Failed to initialize SDL2.";
			exit(1);
		}
		// initialize SDL_image
#ifndef EMSCRIPTEN
		if (IMG_Init(~0) == 0)
		{
			std::cerr << "Failed to initialize SDL_image.";
			exit(1);
		}
#endif
		//chdir("/");
		SDL_Surface *image = nullptr;
		std::string fileName = "/MyGUI_Media/DejaVuSansFontGenerated_15.png";
		image = IMG_Load(fileName.c_str());
		if (image == nullptr)
		{
			std::cerr << "Failed to load " << fileName << " image" << std::endl;
			exit(-1);
		}
//		fileName = "test.png";
//		image = IMG_Load(fileName.c_str());
//		if (image == nullptr)
//		{
//			std::cerr << "Failed to load " << fileName << " image" << std::endl;
//			exit(-1);
//		}

		const unsigned int width = _width;
		const unsigned int height = _height;
		bool windowed = true;

		// create window and position it at the center of the screen
		SDL_DisplayMode currDisp;
		MYGUI_ASSERT(SDL_GetCurrentDisplayMode(0, &currDisp) == 0, "Failed to retrieve screen info.");
		int left = (currDisp.w - width) / 2;
		int top = (currDisp.h - height) / 2;

		mWindow = SDL_CreateWindow("OpenGLES Render Window", left, top, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
		MYGUI_ASSERT(mWindow != nullptr, "Failed to create SDL window.");
		mContext = SDL_GL_CreateContext(mWindow);
		MYGUI_ASSERT(mContext != nullptr, "Failed to create SDL context.");
		mWindowOn = true;

		if (!createRender(width, height, windowed))
		{
			return false;
		}

		createGui();

		createInput();

		createPointerManager();

		// this needs to be called before createScene() since some demos require
		// screen size to properly position the widgets
		_windowResized(width, height);

		createScene();

		return true;
	}
Ejemplo n.º 22
0
TAC_NODE* generateTacCode(ASTREE* syntaxtree) {
	int i;

	TAC_NODE* code[MAX_SONS];

	for(i=0; i < MAX_SONS; i++) {
		code[i] = NULL;
	}

	if(syntaxtree == NULL) return NULL;

	for (i=0; i < MAX_SONS; i++) {
		code[i] = generateTacCode(syntaxtree->son[i]);
	}
		
	switch (syntaxtree->type) {
		 case AST_PROGRAMA:
		 	return code[0];
		 case AST_DECLARACOES:
		 	return joinTacs(code[0], code[1]);
		 case AST_VARIAVEL:
			if(code[2]!=NULL) {
			 	return createTacNode(TAC_DECLARACAO_VARIAVEL, code[0]->result, code[2]->result, NULL);
			}
			else {
				return createTacNode(TAC_SYMBOL, code[0]->result, NULL, NULL);
			}
		 case AST_VETOR_VAZIO:
		 	return createTacNode(TAC_DECLARACAO_VETOR_VAZIO, code[0]->result, code[2]->result, NULL);
		 case AST_VETOR:
		 	return joinTacs(createTacNode(TAC_DECLARACAO_VETOR, code[0]->result, code[2]->result, NULL), initializeVector(revertTac(code[3]),code[0]->result,0));
		 case AST_INI_VETOR:
		 	return joinTacs(code[0], code[1]);
		 case AST_LISTA_LITERAIS:
		 	return joinTacs(code[0], code[1]);
		 case AST_FUNCAO:
		 	return createFunctionDeclaration(code[0]->result, code[2], code[3]);
		 case AST_PARAMETRO:
		 	return createTacNode(TAC_PARAMETRO, code[0]->result, code[1]->result, NULL);
		 case AST_LISTA_PARAMETRO:
		 	return joinTacs(code[0], code[1]);
		 case AST_COMANDOS:
		 	return joinTacs(code[0], code[1]);
		 case AST_BLOCO:
		 	return code[0];
		 case AST_LISTA_PARAM_CHAMADA:
			return joinTacs(code[0], code[1]);
		 case AST_ACESSO_VETOR:
		 	return createVectorRead(code[0]->result, code[1]);
		 case AST_CHAMADA_FUNCAO:
			return createFunctionCall(code[0]->result, code[1]);
		 case AST_EXPRESSAO_PARENTESES:
		 	return code[0];
		 case AST_OP_SOMA:
		 	return createTacOperation(TAC_OP_SOMA, code[0], code[1]);
		 case AST_OP_SUB:
		 	return createTacOperation(TAC_OP_SUB, code[0], code[1]);
		 case AST_OP_MUL:
			 return createTacOperation(TAC_OP_MUL, code[0], code[1]);
		 case AST_OP_DIV:
		 	return createTacOperation(TAC_OP_DIV, code[0], code[1]);
		 case AST_OP_MENOR:
		 	return createTacOperation(TAC_OP_MENOR, code[0], code[1]);
		 case AST_OP_MAIOR:
		 	return createTacOperation(TAC_OP_MAIOR, code[0], code[1]);
		 case AST_OP_LE:
		 	return createTacOperation(TAC_OP_LE, code[0], code[1]);
		 case AST_OP_GE:
		 	return createTacOperation(TAC_OP_GE, code[0], code[1]);
		 case AST_OP_EQ:
		 	return createTacOperation(TAC_OP_EQ, code[0], code[1]);
		 case AST_OP_NE:
		 	return createTacOperation(TAC_OP_NE, code[0], code[1]);
		 case AST_OP_AND:
		 	return createTacOperation(TAC_OP_AND, code[0], code[1]);
		 case AST_OP_OR:
		 	return createTacOperation(TAC_OP_OR, code[0], code[1]);
		 case AST_ATRIBUICAO:
		 	return joinTacs(code[1], createTacNode(TAC_ATRIBUICAO, code[0]->result, resultAtribuicao(code[1])->result, NULL));
		 case AST_ATRIBUICAO_VETOR:
		 	return createAssignVector(code[0]->result, resultAtribuicao(code[1]), resultAtribuicao(code[2]));
		 case AST_IF:
			return createIF(code[0],code[1]);
		 case AST_IF_ELSE:
			return createIF_ELSE(code[0],code[1],code[2]);
		 case AST_WHILE:
			return createWHILE(code[0], code[1]);
		 case AST_INPUT:
			return createInput(revertTac(code[0]));
		 case AST_LISTA_VARIAVEIS:
			return joinTacs(code[0], code[1]);
		 case AST_OUTPUT:
			return createOutput(revertTac(code[0]));
		 case AST_LISTA_ELEM_EXP:
			return joinTacs(code[0], code[1]);
		 case AST_LISTA_ELEM_STRING:
			return joinTacs(createTacNode(TAC_STRING, syntaxtree->symbol, NULL, NULL), code[0]);
		 case AST_RETURN:
			return joinTacs(code[0], createTacNode(TAC_RETURN, code[0]->result, NULL, NULL));
		 case AST_KW_INT:
		 	return createTacNode(TAC_KW_INT, syntaxtree->symbol, NULL, NULL);
		 case AST_KW_BOOL:
		 	return createTacNode(TAC_KW_BOOL, syntaxtree->symbol, NULL, NULL);
		 case AST_KW_REAL:
		 	return createTacNode(TAC_KW_REAL, syntaxtree->symbol, NULL, NULL);
		 case AST_KW_CHAR:
		 	return createTacNode(TAC_KW_CHAR, syntaxtree->symbol, NULL, NULL);
		 case AST_LIT_INT:
		 	return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL);
		 case AST_LIT_REAL:
		 	return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL);
		 case AST_LIT_TRUE:
		 	return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL);
		 case AST_LIT_FALSE:
		 	return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL);
		 case AST_LIT_CHAR:
		 	return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL);
		 case AST_LIT_STRING:
		 	return createTacNode(TAC_SYMBOL, syntaxtree->symbol, NULL, NULL);
		 case AST_COMANDO_VAZIO:
		 	return NULL;
		 case AST_SYMBOL_VAR:
		 	return createTacNode(TAC_SYMBOL_VAR, syntaxtree->symbol, NULL, NULL);
		 case AST_SYMBOL_VET:
		 	return createTacNode(TAC_SYMBOL_VET, syntaxtree->symbol, NULL, NULL);
		 case AST_SYMBOL_FUN:
		 	return createTacNode(TAC_SYMBOL_FUN, syntaxtree->symbol, NULL, NULL);
		 default:
		 	break;
	}
}
Ejemplo n.º 23
0
	bool BaseManager::create()
	{
		Ogre::String pluginsPath;
    
    #ifndef OGRE_STATIC_LIB
			pluginsPath = mResourcePath + mPluginCfgName;
		#endif

		mRoot = new Ogre::Root(pluginsPath, mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");

		setupResources();

		// попробуем завестись на дефолтных
		if (!mRoot->restoreConfig())
		{
			// ничего не получилось, покажем диалог
			if (!mRoot->showConfigDialog()) return false;
		}

		mWindow = mRoot->initialise(true);


		// вытаскиваем дискриптор окна
		size_t handle = getWindowHandle();

	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		// берем имя нашего экзешника
		char buf[MAX_PATH];
		::GetModuleFileNameA(0, (LPCH)&buf, MAX_PATH);
		// берем инстанс нашего модуля
		HINSTANCE instance = ::GetModuleHandleA(buf);
		// побыстрому грузим иконку
		HICON hIcon = ::LoadIcon(instance, MAKEINTRESOURCE(1001));
		if (hIcon)
		{
			::SendMessageA((HWND)handle, WM_SETICON, 1, (LPARAM)hIcon);
			::SendMessageA((HWND)handle, WM_SETICON, 0, (LPARAM)hIcon);
		}
	#endif

		mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "BaseSceneManager");

		mCamera = mSceneManager->createCamera("BaseCamera");
		mCamera->setNearClipDistance(5);
		mCamera->setPosition(400, 400, 400);
		mCamera->lookAt(0, 150, 0);

		// Create one viewport, entire window
		Ogre::Viewport* vp = mWindow->addViewport(mCamera);
		// Alter the camera aspect ratio to match the viewport
		mCamera->setAspectRatio((float)vp->getActualWidth() / (float)vp->getActualHeight());

		// Set default mipmap level (NB some APIs ignore this)
		Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);

		mSceneManager->setAmbientLight(Ogre::ColourValue::White);
		Ogre::Light* light = mSceneManager->createLight("MainLight");
		light->setType(Ogre::Light::LT_DIRECTIONAL);
		Ogre::Vector3 vec(-0.3f, -0.3f, -0.3f);
		vec.normalise();
		light->setDirection(vec);

		// Load resources
		Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

		mRoot->addFrameListener(this);
		Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);

		createGui();

		createInput(handle);

		createPointerManager(handle);

		createScene();

		windowResized(mWindow);

		return true;
	}