bool UserInputListener::fireMaterialEvent( castor::String const & p_overlay, castor::String const & p_material )
	{
		bool result = false;

		if ( doHasHandlers() )
		{
			auto & cache = getEngine()->getOverlayCache();
			auto overlay = cache.find( p_overlay );

			if ( overlay )
			{
				auto material = getEngine()->getMaterialCache().find( p_material );

				if ( material )
				{
					this->m_frameListener->postEvent( makeFunctorEvent( EventType::ePreRender
						, [overlay, material]()
						{
							overlay->setMaterial( material );
						} ) );
					result = true;
				}
			}
		}
		
		return result;
	}
Beispiel #2
0
void
GeomOptimise::pipelineInitialising()
{
  if(mySettings.writeSummary)
  {
    myTableSupport.setFilename(
        common::getOutputFileStem(getEngine()->sharedData(),
            getEngine()->globalData()) + ".geomopt");
    myTableSupport.registerEngine(getEngine());
  }
}
Beispiel #3
0
void Uploader::init(GLManager *glManager)
{
  // init editorgui
  getRootScene()->addComponent<EditorGUI>();
  getRootScene()->getComponent<EditorGUI>()->rootScene = getRootScene();

  auto cam = std::make_shared<Entity>();
  cam->addComponent<OrthoCamera>(getEngine()->getWindow()->getWidth() / (float)getEngine()->getWindow()->getHeight(), 512, 0.01f, 10000.0f);
  addToScene(cam);

  auto primary_camera = cam->getComponent<OrthoCamera>();
  getEngine()->getGLManager()->setActiveCamera(primary_camera);
}
Beispiel #4
0
// new person for group follower
void TurnaroundPassenger::newGroupFollower( void )
{
	MobLogEntry _followerEntry = m_logEntry;
	TerminalMobElementBehavior* spTerminalBehavior = (TerminalMobElementBehavior *)getBehavior(MobElementBehavior::TerminalBehavior);
	for( int i=1; i< GetAdminGroupSize(); i++ )
	{
		_followerEntry.incPax();
		Person* _pFollower = new TurnaroundPassenger( _followerEntry, getEngine()  );
		
		getEngine()->m_simBobileelemList.Register( _pFollower );
		((CGroupLeaderInfo*)m_pGroupInfo)->AddFollower( _pFollower, this );		
	}
}
void SearchEnginesDialog::editEngine()
{
    QTreeWidgetItem* item = ui->treeWidget->currentItem();
    if (!item) {
        return;
    }

    SearchEngine engine = getEngine(item);

    EditSearchEngine dialog(tr("Edit Search Engine"), this);

    dialog.setName(engine.name);
    dialog.setUrl(engine.url);
    dialog.setShortcut(engine.shortcut);
    dialog.setIcon(engine.icon);

    if (dialog.exec() != QDialog::Accepted) {
        return;
    }

    engine.name = dialog.name();
    engine.url = dialog.url();
    engine.shortcut = dialog.shortcut();
    engine.icon = dialog.icon();

    if (engine.name.isEmpty() || engine.url.isEmpty()) {
        return;
    }

    setEngine(item, engine);

    changeItemToDefault(item, isDefaultEngine(item));
    item->setIcon(0, engine.icon);
    item->setText(1, engine.shortcut);
}
Beispiel #6
0
EnginePtr Widget::getEngine()
{
    auto systemWindow = getSystemWindow();
    if (systemWindow)
        return systemWindow->getEngine();
    return nullptr;
}
Beispiel #7
0
void HwSceneObject::render()
{
	reCalcWorldMatrix();
	getEngine()->getRender()->setTransform(D3DTS_WORLD, &worldTransform);

	if (func)
		func(this);
	
	for (int i = 0; i < pMaterial->getPassCount(); i++)
	{
		HwPass *pass = pMaterial->getPass(i);
		pass->Bind();
		if (pass->shaderValible())
			for (int j = 0; j < pass->getShader()->getPassCount(); j++)
			{
				HwShaderPass *spass = pass->getShader()->getPass(j);
				spass->Bind();
				draw();
				spass->UnBind();
			}
		else
			draw();

	}
}
void
SearchStoichiometries::finished(StructureDataUniquePtr data)
{
  // Register the data with our pipeline to transfer ownership
  // and save it in the buffer for sending down the pipe
  myBuffer.push_back(getEngine()->registerData(data));
}
Beispiel #9
0
void SearchEnginesDialog::accept()
{
    if (ui->treeWidget->topLevelItemCount() < 1) {
        return;
    }

    QVector<SearchEngine> allEngines;

    for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) {
        QTreeWidgetItem* item = ui->treeWidget->topLevelItem(i);
        if (!item) {
            continue;
        }

        SearchEngine engine = getEngine(item);
        allEngines.append(engine);

        if (isDefaultEngine(item)) {
            m_manager->setDefaultEngine(engine);
        }
    }

    m_manager->setAllEngines(allEngines);

    QDialog::accept();
}
TEST_F(KVDropPendingIdentReaperTest,
       AddDropPendingIdentWithDuplicateDropTimestampButDifferentIdent) {
    auto engine = getEngine();
    KVDropPendingIdentReaper reaper(engine);

    Timestamp dropTimestamp{Seconds(100), 0};
    NamespaceString nss1("test.foo");
    constexpr auto ident1 = "ident1"_sd;
    NamespaceString nss2("test.bar");
    constexpr auto ident2 = "ident2"_sd;
    reaper.addDropPendingIdent(dropTimestamp, nss1, ident1);
    reaper.addDropPendingIdent(dropTimestamp, nss2, ident2);

    // getAllIdents() returns a set of drop-pending idents known to the reaper.
    auto dropPendingIdents = reaper.getAllIdents();
    ASSERT_EQUALS(2U, dropPendingIdents.size());
    ASSERT(dropPendingIdents.find(ident1.toString()) != dropPendingIdents.cend());
    ASSERT(dropPendingIdents.find(ident2.toString()) != dropPendingIdents.cend());

    // Check earliest drop timestamp.
    ASSERT_EQUALS(dropTimestamp, *reaper.getEarliestDropTimestamp());

    // This should have no effect.
    auto opCtx = makeOpCtx();
    reaper.dropIdentsOlderThan(opCtx.get(), dropTimestamp);
    ASSERT_EQUALS(0U, engine->droppedIdents.size());

    // Drop all idents managed by reaper and confirm number of drops.
    reaper.dropIdentsOlderThan(opCtx.get(), makeTimestampWithNextInc(dropTimestamp));
    ASSERT_EQUALS(2U, engine->droppedIdents.size());
    ASSERT_EQUALS(ident1, engine->droppedIdents.front());
    ASSERT_EQUALS(ident2, engine->droppedIdents.back());
}
Beispiel #11
0
JNIEXPORT jobject JNICALL Java_org_andengine_extension_scripting_Test_test(JNIEnv* pJNIEnv, jclass pJClass) {
	Engine* engine = getEngine();
	Context* context = getContext();
	AssetManager* assetManager = context->getAssetManager();

	/* Fetch managers. */
	TextureManager* textureManager = engine->getTextureManager();
	VertexBufferObjectManager* vertexBufferObjectManager = engine->getVertexBufferObjectManager();

	/* Create texture. */
	AssetBitmapTexture texture(textureManager, assetManager, JNI_ENV()->NewStringUTF("gfx/box.png")); //, BitmapTextureFormat::RGBA_4444);
	texture.load();

	/* Extract TextureRegion. */
	TextureRegion textureRegion(&texture, 0, 0, texture.getWidth(), texture.getHeight());

	/* Create an Entity/Sprite. */
	int size = 100;
	Entity* entity = new Sprite(360 - (size / 2), 240 - (size / 2), size, size, &textureRegion, vertexBufferObjectManager);
//	Entity* entity = new Rectangle(360 - (size / 2), 240 - (size / 2), size, size, vertexBufferObjectManager);

	entity->setRotation(45);
	entity->setScale(2);

	/* Release managers. */
	delete vertexBufferObjectManager;
	delete textureManager;

	return entity->unwrap();
}
Beispiel #12
0
String Mechanoid::getRatingLevelName(RatingType type) const
{
    auto level = getRatingLevel(type);
    auto m = (detail::Message*)getEngine()->getObjects()[L"RATING." + std::to_wstring(level)];
    if (m->txt)
        return m->txt->string;
    return m->getName();
}
Beispiel #13
0
FontPtr Widget::getDefaultFont()
{
    auto engine = getEngine();
    if (!engine)
        return nullptr;

    return engine->getFontManager()->getDefaultFont();
}
Beispiel #14
0
QSharedPointer<T> BaseRecord<T>::insert()
{
	QSharedPointer<T> db_record = getEngine()->template insert<T>(columnsList(), valuesList());
	if (db_record) {
		id_ = db_record->id();
		dirty_ = false;
	}
	return db_record;
}
Beispiel #15
0
	void RenderManager::render(Camera &camera, Environment &env)
	{
		getEngine()->viewport(0, 0, camera.getWidth(), camera.getHeight());
		
		this->renderBucket(OpaqueBucket, camera, env);
		this->renderBucket(TransparentBucket, camera, env);
		this->renderBucket(SkyboxBucket, camera, env);
		this->renderBucket(ParticleBucket, camera, env);
	}
Beispiel #16
0
void CollisionSystem::calculateCollisionWithTower() {
    Engine::BoidVector &boids = getEngine().getBoids();
    size_t size = boids.size();

    // We have to do this for all boids.
    for(size_t i = 0; i < size; ++i) {

    }
}
Beispiel #17
0
bool BaseRecord<T>::remove()
{
	if (id() >= 0) {
		return getEngine()->template remove<T>(id());
	} else {
		qCritical("Tried to remove non-stored record object from database.");
		return false;
	}
}
/*
 Denna funktion omvandlar en int till
 en strang och renderar denna i fonstret.
 */
void ScoreCounter::draw()
{
    std::string str;
    std::ostringstream os;
    os << score;
    str = os.str();
    setLabelText(str);
    
    SDL_RenderCopy(getEngine()->getRenderer(), getTexture(), NULL, &rectangle);
}
Beispiel #19
0
	void IndexBuffer::cleanup()
	{
		if ( m_gpuBuffer )
		{
			getEngine()->getRenderSystem()->putBuffer( BufferType::eElementArray
				, m_accessType
				, m_accessNature
								   , GpuBufferOffset{ m_gpuBuffer, uint32_t( m_offset * sizeof( uint32_t ) ) } );
			m_gpuBuffer.reset();
		}
	}
Beispiel #20
0
void BaseRecord<T>::revert()
{
	if (isStored()) {
		if (isDirty()) {
			getEngine()->template fetchById<T>(id());
		}
		// else: don't need any action
	} else {
		// throw some error...
	}
}
void
RunPotentialParamsQueue::start()
{
  const fs::path workingDir = this->workingDir();

  while(getWork())
  {
    while(!myParamsQueue.empty())
    {
      spipe::SharedDataType & sweepSharedData = mySubpipeEngine->sharedData();

      const posix_time::ptime startTime =
          posix_time::microsec_clock::universal_time();

      myCurrentParams = myParamsQueue.front();

      // Store the potential parameters in global memory
      getEngine()->globalData().setParameters(mySettings.tag, myCurrentParams);

      const fs::path sweepPath = workingDir
          / common::generateParamDirName(myCurrentParams,
              getEngine()->globalData().getSeedName());
      // Set a directory for this set of parameters
      sweepSharedData.setWorkingDir(sweepPath);

      mySubpipeEngine->run();

      myDoneParams.push_back(myCurrentParams);
      myParamsQueue.pop();

      // Save how long it took to process that parameter set
      myWorkItemsTiming.insert(
          posix_time::microsec_clock::universal_time() - startTime);

      // Send the resultant structures down our pipe
      releaseBufferedStructures(sweepPath.string());
    }
    updateDoneParams();
    updateWorkChunkSize();
  }
}
Beispiel #22
0
void CollisionSystem::restoreBoidsPosition() {
    Engine::BoidVector &boids = getEngine().getBoids();
    size_t size = boids.size();

    // Go through each boid. If their position is different than their old
    // position, try to restore.
    for(size_t i = 0; i < size; ++i) {
        if(boids[i].position != boids[i].oldPosition) {
            std::cout << "wow, different position" << std::endl;
        }
    }
}
void
ViewerDisplayScheduler::onRenderStopped(bool /*/aborted*/)
{
    // Refresh all previews in the tree
    NodePtr effect = getOutputNode();
    
    effect->getApp()->refreshAllPreviews();
    
    if ( effect->getApp()->isGuiFrozen() ) {
        getEngine()->s_refreshAllKnobs();
    }
}
Beispiel #24
0
Predator::Predator() {
    component = new QQmlComponent(getEngine(), QUrl(QStringLiteral("qrc:/Predator.qml")));
    if(component->status() == component->Ready) {
        object = component->create(getEngine()->rootContext());
        object->setProperty("parent", QVariant::fromValue(getCanvas()));
        QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
    }
    else
        qDebug() << component->errorString();

    setY(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasHeight() - 100));
    setX(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasWidth() - 100));

    isPredator = true;

    // Randomize staring velocity to sweep
    velocity.setX(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0);
    velocity.setY(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0);

    lastVel = velocity;
}
void
RunPotentialParamsQueue::finished(StructureDataUniquePtr structure)
{

  if(!structure->properties().find(common::GlobalKeys::POTENTIAL_PARAMS))
    structure->properties()[common::GlobalKeys::POTENTIAL_PARAMS] =
        myCurrentParams;

  // Register the data with our pipeline to transfer ownership
  // Save it in the buffer for sending down the pipe
  myBuffer.push_back(getEngine()->registerData(structure));
}
Beispiel #26
0
void
Rescale::in(spl::common::Structure * const structure)
{
  if(const spl::common::UnitCell * const unitCell = structure->getUnitCell())
  {
    const spl::common::AtomsFormula & composition = structure->getComposition();
    const double naturalVolume = spl::build_cell::naturalVolume(composition,
        getEngine()->sharedData().getSpeciesDatabase(), true);
    structure->scale(myScaleFactor * naturalVolume / unitCell->getVolume());
  }

  out(structure);
}
Beispiel #27
0
TurnaroundPassenger::TurnaroundPassenger (MobLogEntry& p_entry, CARCportEngine* _pEngine ) :
    Passenger (p_entry, _pEngine )
{
	MobileElement::setBehavior( new TurnaroundPaxTerminalBehavior( this ));
	direction = ARRIVING;

	m_logMobEntry = p_entry;
	assert( m_pTerm );
    arrivingType = initType (p_entry.getArrFlight(), 'A');
	arrivingType.SetInputTerminal( m_pTerm );
    departingType = initType (p_entry.getDepFlight(), 'D');
	departingType.SetInputTerminal( m_pTerm );

    Flight *aFlight = getEngine()->m_simFlightSchedule.getItem (p_entry.getArrFlight());
	arrivingGate = aFlight->getArrGateIndex();
	m_nGate = arrivingGate;

    aFlight = getEngine()->m_simFlightSchedule.getItem (p_entry.getDepFlight());
	departingGate = aFlight->getDepGateIndex();
    departureTime = aFlight->getDepTime();
    m_type.setOtherFlightConstraint(arrivingType);

}
TEST_F(KVDropPendingIdentReaperTest, AddDropPendingIdentAcceptsNullDropTimestamp) {
    Timestamp nullDropTimestamp;
    NamespaceString nss("test.foo");
    constexpr auto ident = "myident"_sd;
    auto engine = getEngine();
    KVDropPendingIdentReaper reaper(engine);
    reaper.addDropPendingIdent(nullDropTimestamp, nss, ident);
    ASSERT_EQUALS(nullDropTimestamp, *reaper.getEarliestDropTimestamp());

    auto opCtx = makeOpCtx();
    reaper.dropIdentsOlderThan(opCtx.get(), {Seconds(100), 0});
    ASSERT_EQUALS(1U, engine->droppedIdents.size());
    ASSERT_EQUALS(ident, engine->droppedIdents.front());
}
Beispiel #29
0
int HidController::disconnectController() {
    ControllerEngine* pEngine = getEngine();

    if (!isOpen()) {
        qDebug() << "HID device" << getName() << "already closed";
        return -1;
    }

    if (pEngine != NULL) {
        pEngine->disconnectScriptEngine();
    }

    close();
    return 0;
}
Beispiel #30
0
void CollisionSystem::calculateCollisionWithGround() {
    /*
    // I think it is enough to not allow the objective boid to go lower than
    // the minimum height.
    if(getEngine().getObjectiveBoid().position.y < MinimumHeight)
        getEngine().getObjectiveBoid().position.y = MinimumHeight;
    */

    Engine::BoidVector &boids = getEngine().getBoids();
    ObjectiveBoid &obj = getEngine().getObjectiveBoid();
    size_t size = boids.size();
    float lowest = 0.0;

    // Get the lowest boid height relative to the objective boid.
    for(size_t i = 0; i < size; ++i) {
        if(boids[i].position.y < lowest)
            lowest = boids[i].position.y;
    }

    // The objective boid's height minus the lowest height can't go lower than
    // minimum height.
    if(obj.position.y + lowest < MinimumHeight)
        obj.position.y = MinimumHeight - lowest;
}