Skip to content
Snippets Groups Projects
Commit 32bcf492 authored by Mathias Paulin's avatar Mathias Paulin :speech_balloon:
Browse files

Sync to Radium PR #717

parent b15effec
Branches
No related tags found
No related merge requests found
......@@ -126,23 +126,10 @@ Viewer* MainWindow::getViewer() {
void MainWindow::onFrameComplete() {}
void MainWindow::postLoadFile( const std::string& filename ) {
m_viewer->makeCurrent();
m_viewer->getRenderer()->buildAllRenderTechniques();
m_viewer->doneCurrent();
m_selectionManager->clear();
auto romgr = Ra::Engine::RadiumEngine::getInstance()->getRenderObjectManager();
auto polyCount = romgr->getNumFaces();
auto vertexCount = romgr->getNumVertices();
auto objectCount = romgr->getRenderObjectsCount();
auto sceneStats = std::make_tuple( objectCount, polyCount, vertexCount );
m_controlWindow->setFileInfo( filename, sceneStats );
// TODO : find a better way to activate loaded camera
// If a camera is in the loaded scene, use it, else, use default
std::string loadedEntityName = Ra::Core::Utils::getBaseName( filename, false );
void MainWindow::activateCamera( const std::string& sceneName ) {
// If a camera is in the given scene, use it, else, use default
std::string loadedEntityName = Ra::Core::Utils::getBaseName( sceneName, false );
auto rootEntity =
Ra::Engine::RadiumEngine::getInstance()->getEntityManager()->getEntity( loadedEntityName );
if ( rootEntity != nullptr )
......@@ -155,20 +142,18 @@ void MainWindow::postLoadFile( const std::string& filename ) {
{
LOG( Ra::Core::Utils::logINFO ) << "Activating camera " << ( *fc )->getName();
const auto systemEntity = SystemEntity::getInstance();
const auto systemEntity = Ra::Engine::Scene::SystemEntity::getInstance();
systemEntity->removeComponent( "CAMERA_DEFAULT" );
m_initialCamera = static_cast<Camera*>( ( *fc ).get() );
auto c = m_initialCamera->duplicate( systemEntity, "CAMERA_DEFAULT" );
c->resize( m_viewer->width(), m_viewer->height() );
m_viewer->getCameraManipulator()->setCamera( c );
emit frameUpdate();
auto camera = static_cast<Ra::Engine::Scene::Camera*>( ( *fc ).get() );
m_viewer->getCameraManipulator()->setCamera(
camera->duplicate( systemEntity, "CAMERA_DEFAULT" ) );
}
else
{ fitCamera(); }
}
else
{ fitCamera(); }
}
void MainWindow::prepareDisplay() {
if ( m_viewer->prepareDisplay() ) { emit frameUpdate(); }
}
void MainWindow::addControl( const QString& tabName, const QKeySequence& shortcut ) {
......@@ -225,7 +210,16 @@ void MainWindow::loadFile() {
{
emit fileLoading( file );
}
auto romgr = Ra::Engine::RadiumEngine::getInstance()->getRenderObjectManager();
auto polyCount = romgr->getNumFaces();
auto vertexCount = romgr->getNumVertices();
auto objectCount = romgr->getRenderObjectsCount();
auto sceneStats = std::make_tuple( objectCount, polyCount, vertexCount );
m_controlWindow->setFileInfo( pathList.first().toStdString(), sceneStats );
activateCamera( pathList.first().toStdString() );
}
}
void MainWindow::setROVisible( Ra::Core::Utils::Index roIndex, bool visible ) {
......
......@@ -82,8 +82,9 @@ class MainWindow : public Ra::Gui::MainWindowInterface, private Ui::MainWindow
void timeFlow( bool state );
public slots:
/// Call after loading a new file to let the window resetview for instance.
void postLoadFile( const std::string& filename ) override;
/// Called when a scene is ready to display to parameterize the application window and the
/// viewer.
void prepareDisplay() override;
/// Cleanup resources.
void cleanup() override;
......@@ -136,6 +137,10 @@ class MainWindow : public Ra::Gui::MainWindowInterface, private Ui::MainWindow
/// create the UI connections
void createConnections();
/// After loading a file, set the first camera loaded (if any) as the active camera.
/// if multiple files are loaded, use the first camera of the first loaded file
void activateCamera( const std::string& sceneName );
/// viewer widget
std::unique_ptr<Ra::Gui::Viewer> m_viewer;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment