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

Make the application handle Radium Picking results.

parent 97e9c61e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <Engine/Rendering/ForwardRenderer.hpp>
#include <Engine/Rendering/RenderObject.hpp>
#include <Engine/Rendering/RenderObjectManager.hpp>
#include <Gui/SelectionManager/SelectionManager.hpp>
#include <Gui/Viewer/Viewer.hpp>
#include <VolumeLoader/VolumeLoader.hpp>
......@@ -74,6 +75,34 @@ void RadiumPlayer::parseCommandLine() {
if ( parser.isSet( fileOpt ) ) { m_fileOption = parser.values( fileOpt ); }
}
void RadiumPlayer::toggleCirclePicking( bool on ) {
auto mainWindow = dynamic_cast<MainWindow*>( m_mainWindow.get() );
mainWindow->centralWidget()->setMouseTracking( on );
}
void RadiumPlayer::handlePicking(
const Ra::Engine::Rendering::Renderer::PickingResult& pickingResult ) {
Ra::Core::Utils::Index roIndex( pickingResult.m_roIdx );
Ra::Engine::RadiumEngine* engine = Ra::Engine::RadiumEngine::getInstance();
auto mainWindow = dynamic_cast<MainWindow*>( m_mainWindow.get() );
if ( roIndex.isValid() )
{
auto ro = engine->getRenderObjectManager()->getRenderObject( roIndex );
if ( ro->getType() != Ra::Engine::Rendering::RenderObjectType::UI )
{
Ra::Engine::Scene::Component* comp = ro->getComponent();
Ra::Engine::Scene::Entity* ent = comp->getEntity();
// For now we don't enable group selection.
mainWindow->getSelectionManager()->setCurrentEntry(
Ra::Engine::Scene::ItemEntry( ent, comp, roIndex ),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current );
}
}
else
{ mainWindow->getSelectionManager()->clear(); }
}
void RadiumPlayer::addConnections() {
auto mainWindow = dynamic_cast<MainWindow*>( m_mainWindow.get() );
......@@ -89,6 +118,10 @@ void RadiumPlayer::addConnections() {
connect(
this, &Ra::Gui::BaseApplication::updateFrameStats, this, &RadiumPlayer::updateFrameStats );
framesCountForStatsChanged( 25 );
connect(
m_viewer, &Ra::Gui::Viewer::toggleBrushPicking, this, &RadiumPlayer::toggleCirclePicking );
connect( m_viewer, &Ra::Gui::Viewer::rightClickPicking, this, &RadiumPlayer::handlePicking );
}
void RadiumPlayer::addPluginsDir() {
......
......@@ -42,5 +42,12 @@ class RadiumPlayer : public Ra::Gui::BaseApplication
/// Current file. First indicate that the file (second) must be loaded at startup
std::optional<QStringList> m_fileOption{std::nullopt};
private slots:
/// Allow to pick using a circle
void toggleCirclePicking( bool on );
/// Slot for the picking results from the viewer.
void handlePicking( const Ra::Engine::Rendering::Renderer::PickingResult& pickingResult );
};
} // namespace Mara
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment