Esempio n. 1
0
SceneInfo Scenery3d::loadScenery3dByName(const QString& name)
{
	if (name.isEmpty())
	    return SceneInfo();

	QString id = SceneInfo::getIDFromName(name);

	if(id.isEmpty())
	{
		showMessage(QString(q_("Could not find scene ID for %1")).arg(name));
		return SceneInfo();
	}
	return loadScenery3dByID(id);
}
bool SceneManager::addScene(Scene *scene)
{
  if (!scene)
    return false;
    
  string key(scene->getName());
  
  if (infoList.contains(key))
    return false;
    
  infoList.insertKeyAndValue(key, SceneInfo(scene));
  
  return true;
}
Esempio n. 3
0
SceneInfo Scenery3d::loadScenery3dByID(const QString& id)
{
	if (id.isEmpty())
		return SceneInfo();

	SceneInfo scene;
	try
	{
		if(!SceneInfo::loadByID(id,scene))
		{
			showMessage(q_("Could not load scene info, please check log for error messages!"));
			return SceneInfo();
		}
	}
	catch (std::runtime_error& e)
	{
		//TODO do away with the exceptions if possible
		qCCritical(scenery3d) << "ERROR while loading 3D scenery with id " <<  id  << ", (" << e.what() << ")";
		return SceneInfo();
	}

	loadScene(scene);
	return scene;
}
Esempio n. 4
0
SceneInfo Scenery3d::getCurrentScene() const
{
	if(currentScene)
		return currentScene->getSceneInfo();
	return SceneInfo();
}
Esempio n. 5
0
void Scenery3d::loadSceneCompleted()
{
	S3DScene* result = currentLoadFuture.result();

	progressBar->setValue(100);
	StelApp::getInstance().removeProgressBar(progressBar);
	progressBar=Q_NULLPTR;

	if(!result)
	{
		showMessage(q_("Could not load scene, please check log for error messages!"));
		return;
	}
	else
		showMessage(q_("Scene successfully loaded."));

	//do stuff that requires the main thread
	const SceneInfo& info = result->getSceneInfo();

	//move to the location specified by the scene
	LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr);
	bool landscapeSetsLocation=lmgr->getFlagLandscapeSetsLocation();
	lmgr->setFlagLandscapeSetsLocation(true);
	lmgr->setCurrentLandscapeName(info.landscapeName, 0.); // took a second, implicitly.
	// Switched to immediate landscape loading: Else,
	// Landscape and Navigator at this time have old coordinates! But it should be possible to
	// delay rot_z computation up to this point and live without an own location section even
	// with meridian_convergence=from_grid.
	lmgr->setFlagLandscapeSetsLocation(landscapeSetsLocation); // restore


	if (info.hasLocation())
	{
		qCDebug(scenery3d) << "Setting location to given coordinates";
		StelApp::getInstance().getCore()->moveObserverTo(*info.location, 0., 0.);
	}
	else qCDebug(scenery3d) << "No coordinates given in scenery3d.ini";

	if (info.hasLookAtFOV())
	{
		qCDebug(scenery3d) << "Setting orientation";
		Vec3f lookat=currentLoadScene.lookAt_fov;
		// This vector is (az_deg, alt_deg, fov_deg)
		Vec3d v;
		StelUtils::spheToRect(lookat[0]*M_PI/180.0, lookat[1]*M_PI/180.0, v);
		mvMgr->setViewDirectionJ2000(StelApp::getInstance().getCore()->altAzToJ2000(v, StelCore::RefractionOff));
		mvMgr->zoomTo(lookat[2]);
	} else qCDebug(scenery3d) << "No orientation given in scenery3d.ini";

	//clear loading scene
	currentLoadScene = SceneInfo();
	emit loadingSceneIDChanged(QString());

	//switch scenes
	delete currentScene;
	currentScene = result;

	//show the scene
	setEnableScene(true);

	emit currentSceneChanged(info);
	emit currentSceneIDChanged(info.id);
}