diff --git a/.gitsubprojects b/.gitsubprojects index 7f7fdc34544f967a63434005e4fc6978e9772efc..e59ed03553e15b6160eaff53de7047d2dc0054d1 100644 --- a/.gitsubprojects +++ b/.gitsubprojects @@ -4,7 +4,7 @@ #git_subproject( gmrvlex https://github.com/vg-lab/gmrvlex.git c20b194 ) #git_subproject( Brion https://github.com/BlueBrain/Brion.git 073f356 ) git_subproject( ReTo https://github.com/gmrvvis/ReTo.git bd0c110 ) -git_subproject( SimIL https://github.com/gmrvvis/SimIL.git 5df45828 ) +git_subproject( SimIL https://github.com/gmrvvis/SimIL.git 4cce8fc8 ) git_subproject( scoop https://github.com/gmrvvis/scoop.git b3326cd ) git_subproject( plab https://github.com/vg-lab/particlelab.git f7fecd1 ) git_subproject( acuterecorder https://github.com/vg-lab/AcuteRecorder.git e17cce7 ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e6fb5d58cfacc95a28db3c14a6a83fd89385ff9..0215bc1d5b8a73a819f2aa0a11006e438af3130e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required( VERSION 3.1 FATAL_ERROR ) # visimpl project and version -project( visimpl VERSION 1.8.6 ) +project( visimpl VERSION 1.8.7 ) set( visimpl_VERSION_ABI 6 ) SET( VISIMPL_LICENSE "GPL") diff --git a/stackviz/MainWindow.cpp b/stackviz/MainWindow.cpp index de3b2da66ef676fbc11f30d2aa572741d4018db9..c4923b1adb6cf37424e01e8b448dbd8ab6b50384 100644 --- a/stackviz/MainWindow.cpp +++ b/stackviz/MainWindow.cpp @@ -27,17 +27,24 @@ #include <zeroeq/version.h> #endif #ifdef VISIMPL_USE_RETO + #include <reto/version.h> + #endif #ifdef VISIMPL_USE_SCOOP + #include <scoop/version.h> + #endif #ifdef VISIMPL_USE_SIMIL + #include <simil/version.h> + #endif #ifdef VISIMPL_USE_PREFR #include <prefr/version.h> #endif + #include <stackviz/version.h> #include "MainWindow.h" @@ -65,64 +72,72 @@ using namespace stackviz; -template<class T> void ignore( const T& ) { } +template< class T > +void ignore( const T& ) +{ } + constexpr int SLIDER_MAX = 1000; MainWindow::MainWindow( QWidget* parent_ ) -: QMainWindow( parent_ ) -, _ui( new Ui::MainWindow ) -, _simulationType( simil::TSimNetwork ) -, _summary( nullptr ) -, _player( nullptr ) -, _subsetEventManager( nullptr ) -, _autoCalculateCorrelations( false ) -, _dockSimulation( nullptr ) -, _playButton( nullptr ) -, _simSlider( nullptr ) -, _repeatButton( nullptr ) -, _goToButton( nullptr ) -, _playing( false ) -, _playIcon(":/icons/play.svg") -, _pauseIcon(":/icons/pause.svg") -, _startTimeLabel( nullptr ) -, _endTimeLabel( nullptr ) -, _displayManager( nullptr ) -, m_loader{nullptr} -, m_loaderDialog{nullptr} -, m_dataInspector{nullptr} -, _recorder{nullptr} + : QMainWindow( parent_ ) + , _ui( new Ui::MainWindow ) + , _simulationType( simil::TSimNetwork ) + , _summary( nullptr ) + , _player( nullptr ) + , _subsetEventManager( nullptr ) + , _autoCalculateCorrelations( false ) + , _dockSimulation( nullptr ) + , _playButton( nullptr ) + , _simSlider( nullptr ) + , _repeatButton( nullptr ) + , _goToButton( nullptr ) + , _playing( false ) + , _playIcon( ":/icons/play.svg" ) + , _pauseIcon( ":/icons/pause.svg" ) + , _startTimeLabel( nullptr ) + , _endTimeLabel( nullptr ) + , _displayManager( nullptr ) + , m_loader{ nullptr } + , m_loaderDialog{ nullptr } + , m_dataInspector{ nullptr } + , _recorder{ nullptr } +#ifdef SIMIL_WITH_REST_API + , _restConnectionInformation( ) + , _alreadyConnected( false ) +#endif { _ui->setupUi( this ); - auto recorderAction = RecorderUtils::recorderAction(); - _ui->menuTools->insertAction(_ui->menuTools->actions().first(), recorderAction); - _ui->toolBar->addAction(recorderAction); + auto recorderAction = RecorderUtils::recorderAction( ); + _ui->menuTools->insertAction( _ui->menuTools->actions( ).first( ) , + recorderAction ); + _ui->toolBar->addAction( recorderAction ); - connect(recorderAction, SIGNAL(triggered(bool)), - this, SLOT(openRecorder())); + connect( recorderAction , SIGNAL( triggered( bool )) , + this , SLOT( openRecorder( ))); - #ifdef VISIMPL_USE_SIMIL - _ui->actionOpenBlueConfig->setEnabled( true ); - #else - _ui->actionOpenBlueConfig->setEnabled( false ); - #endif +#ifdef VISIMPL_USE_SIMIL + _ui->actionOpenBlueConfig->setEnabled( true ); +#else + _ui->actionOpenBlueConfig->setEnabled( false ); +#endif - connect( _ui->actionQuit, SIGNAL( triggered( void )), - QApplication::instance(), SLOT( quit( void ))); + connect( _ui->actionQuit , SIGNAL( triggered( void )) , + QApplication::instance( ) , SLOT( quit( void ))); // Connect about dialog - connect( _ui->actionAbout, SIGNAL( triggered( void )), - this, SLOT( aboutDialog( void ))); + connect( _ui->actionAbout , SIGNAL( triggered( void )) , + this , SLOT( aboutDialog( void ))); #ifdef SIMIL_WITH_REST_API - _ui->actionConnectRESTserver->setEnabled(true); + _ui->actionConnectRESTserver->setEnabled( true ); #endif - m_dataInspector = new DataInspector(""); - m_dataInspector->hide(); + m_dataInspector = new DataInspector( "" ); + m_dataInspector->hide( ); } -void MainWindow::init( const std::string &session ) +void MainWindow::init( const std::string& session ) { #ifdef VISIMPL_USE_ZEROEQ const auto session_ = session.empty() ? zeroeq::DEFAULT_SESSION : session; @@ -154,37 +169,40 @@ void MainWindow::init( const std::string &session ) } #endif - connect( _ui->actionOpenBlueConfig, SIGNAL( triggered( void )), - this, SLOT( openBlueConfigThroughDialog( void ))); + connect( _ui->actionOpenBlueConfig , SIGNAL( triggered( void )) , + this , SLOT( openBlueConfigThroughDialog( void ))); + + connect( _ui->actionOpenCSVFiles , SIGNAL( triggered( void )) , + this , SLOT( openCSVFilesThroughDialog( void ))); - connect( _ui->actionOpenCSVFiles, SIGNAL( triggered( void )), - this, SLOT( openCSVFilesThroughDialog( void ))); + connect( _ui->actionOpenH5Files , SIGNAL( triggered( void )) , + this , SLOT( openH5FilesThroughDialog( void ))); - connect( _ui->actionOpenH5Files, SIGNAL( triggered( void )), - this, SLOT( openH5FilesThroughDialog( void ))); + connect( _ui->actionConnectRESTserver , SIGNAL( triggered( void )) , this , + SLOT( openRESTThroughDialog( ))); - connect( _ui->actionOpenSubsetEventsFile, SIGNAL( triggered( void )), - this, SLOT( openSubsetEventsFileThroughDialog( void ))); - - connect( _ui->actionOpenGroupsFile, SIGNAL( triggered( void )), - this, SLOT( openGroupsThroughDialog( void ))); + connect( _ui->actionOpenSubsetEventsFile , SIGNAL( triggered( void )) , + this , SLOT( openSubsetEventsFileThroughDialog( void ))); - connect( _ui->actionCloseData, SIGNAL(triggered(bool)), - this, SLOT(closeData())); + connect( _ui->actionOpenGroupsFile , SIGNAL( triggered( void )) , + this , SLOT( openGroupsThroughDialog( void ))); - _ui->actionOpenSubsetEventsFile->setEnabled(false); - _ui->actionOpenGroupsFile->setEnabled(false); + connect( _ui->actionCloseData , SIGNAL( triggered( bool )) , + this , SLOT( closeData( ))); + + _ui->actionOpenSubsetEventsFile->setEnabled( false ); + _ui->actionOpenGroupsFile->setEnabled( false ); initPlaybackDock( ); - connect( _dockSimulation->toggleViewAction( ), SIGNAL( toggled( bool )), - _ui->actionTogglePlaybackDock, SLOT( setChecked( bool ))); + connect( _dockSimulation->toggleViewAction( ) , SIGNAL( toggled( bool )) , + _ui->actionTogglePlaybackDock , SLOT( setChecked( bool ))); - connect( _ui->actionTogglePlaybackDock, SIGNAL( triggered( void )), - this, SLOT( togglePlaybackDock( void ))); + connect( _ui->actionTogglePlaybackDock , SIGNAL( triggered( void )) , + this , SLOT( togglePlaybackDock( void ))); - connect( _ui->actionShowDataManager, SIGNAL( triggered( void )), - this, SLOT( showDisplayManagerWidget( void ))); + connect( _ui->actionShowDataManager , SIGNAL( triggered( void )) , + this , SLOT( showDisplayManagerWidget( void ))); #ifdef VISIMPL_USE_ZEROEQ auto &zInst = visimpl::ZeroEQConfig::instance(); @@ -195,14 +213,14 @@ void MainWindow::init( const std::string &session ) #else // to avoid compilation warnings about unused parameter. - ignore(session); + ignore( session ); #endif - _ui->toolBar->setContextMenuPolicy(Qt::PreventContextMenu); - _ui->menubar->setContextMenuPolicy(Qt::PreventContextMenu); + _ui->toolBar->setContextMenuPolicy( Qt::PreventContextMenu ); + _ui->menubar->setContextMenuPolicy( Qt::PreventContextMenu ); - _ui->actionShowDataManager->setEnabled(false); - _ui->actionCloseData->setEnabled(false); + _ui->actionShowDataManager->setEnabled( false ); + _ui->actionCloseData->setEnabled( false ); } MainWindow::~MainWindow( void ) @@ -220,51 +238,54 @@ MainWindow::~MainWindow( void ) #endif } -void MainWindow::showStatusBarMessage ( const QString& message ) +void MainWindow::showStatusBarMessage( const QString& message ) { _ui->statusbar->showMessage( message ); } -void MainWindow::openSubsetEventFile(const std::string &filePath, bool append) +void +MainWindow::openSubsetEventFile( const std::string& filePath , bool append ) { - if (filePath.empty() || !_subsetEventManager) return; + if ( filePath.empty( ) || !_subsetEventManager ) return; - QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor( Qt::WaitCursor ); - if (!append) _subsetEventManager->clear(); + if ( !append ) _subsetEventManager->clear( ); - _summary->clearEvents(); + _summary->clearEvents( ); QString errorText; try { - if (filePath.find("json") != std::string::npos) + if ( filePath.find( "json" ) != std::string::npos ) { - _subsetEventManager->loadJSON(filePath); + _subsetEventManager->loadJSON( filePath ); + } + else if ( filePath.find( "h5" ) != std::string::npos || + filePath.find( "hdf5" ) != std::string::npos ) + { + _subsetEventManager->loadH5( filePath ); + _autoCalculateCorrelations = true; } else - if (filePath.find("h5") != std::string::npos || filePath.find("hdf5") != std::string::npos) - { - _subsetEventManager->loadH5(filePath); - _autoCalculateCorrelations = true; - } - else - { - errorText = tr("Subset Events file not found: %1").arg(QString::fromStdString(filePath)); - } + { + errorText = tr( "Subset Events file not found: %1" ).arg( + QString::fromStdString( filePath )); + } } - catch(const std::exception &e) + catch ( const std::exception& e ) { - if(_subsetEventManager) _subsetEventManager->clear(); + if ( _subsetEventManager ) _subsetEventManager->clear( ); - errorText = QString::fromLocal8Bit(e.what()); + errorText = QString::fromLocal8Bit( e.what( )); } - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor( ); - if(!errorText.isEmpty()) + if ( !errorText.isEmpty( )) { - QMessageBox::critical(this, tr("Error loading Events file"), errorText, QMessageBox::Ok); + QMessageBox::critical( this , tr( "Error loading Events file" ) , + errorText , QMessageBox::Ok ); return; } } @@ -273,94 +294,101 @@ void MainWindow::openBlueConfigThroughDialog( void ) { #ifdef VISIMPL_USE_SIMIL - const QString filename = QFileDialog::getOpenFileName( - this, tr( "Open BlueConfig" ), _lastOpenedFileNamePath, - tr( "BlueConfig ( BlueConfig CircuitConfig);; All files (*)" ), - nullptr, QFileDialog::DontUseNativeDialog ); - - if( !filename.isEmpty( )) - { - bool ok1, ok2; - QInputDialog simTypeDialog; - simil::TSimulationType simType; - const QStringList items = {"Spikes"};//, "Voltages"}; - - QString text = QInputDialog::getItem( - this, tr( "Please select simulation type" ), - tr( "Type:" ), items, 0, false, &ok1 ); - - if( !ok1 ) - return; - - if( text == items[0] ) - { - simType = simil::TSimSpikes; - ok2 = true; - } - else - { - simType = simil::TSimVoltages; - - text = QInputDialog::getText( - this, tr( "Please select report" ), - tr( "Report:" ), QLineEdit::Normal, - "soma", &ok2 ); - } - - if(!ok1 || !ok2 || text.isEmpty()) return; - - const auto target = QInputDialog::getText(this, tr("Target"), tr("BlueConfig Target:"), QLineEdit::Normal, "", &ok1); - - if(ok1 && !target.isEmpty()) - { - _lastOpenedFileNamePath = QFileInfo(filename).path( ); - loadData(simil::TBlueConfig, filename.toStdString(), target.toStdString(), simType ); - } - } + const QString filename = QFileDialog::getOpenFileName( + this , tr( "Open BlueConfig" ) , _lastOpenedFileNamePath , + tr( "BlueConfig ( BlueConfig CircuitConfig);; All files (*)" ) , + nullptr , QFileDialog::DontUseNativeDialog ); + + if ( !filename.isEmpty( )) + { + bool ok1 , ok2; + QInputDialog simTypeDialog; + simil::TSimulationType simType; + const QStringList items = { "Spikes" };//, "Voltages"}; + + QString text = QInputDialog::getItem( + this , tr( "Please select simulation type" ) , + tr( "Type:" ) , items , 0 , false , &ok1 ); + + if ( !ok1 ) + return; + + if ( text == items[ 0 ] ) + { + simType = simil::TSimSpikes; + ok2 = true; + } + else + { + simType = simil::TSimVoltages; + + text = QInputDialog::getText( + this , tr( "Please select report" ) , + tr( "Report:" ) , QLineEdit::Normal , + "soma" , &ok2 ); + } + + if ( !ok1 || !ok2 || text.isEmpty( )) return; + + const auto target = QInputDialog::getText( this , tr( "Target" ) , + tr( "BlueConfig Target:" ) , + QLineEdit::Normal , "" , &ok1 ); + + if ( ok1 && !target.isEmpty( )) + { + _lastOpenedFileNamePath = QFileInfo( filename ).path( ); + loadData( simil::TBlueConfig , filename.toStdString( ) , + target.toStdString( ) , simType ); + } + } #endif } void MainWindow::openCSVFilesThroughDialog( void ) { - const QString networkFilename = QFileDialog::getOpenFileName( - this, tr( "Open CSV Network description file" ), _lastOpenedFileNamePath, - tr( "CSV (*.csv);; All files (*)" ), - nullptr, QFileDialog::DontUseNativeDialog ); + const QString networkFilename = QFileDialog::getOpenFileName( + this , tr( "Open CSV Network description file" ) , _lastOpenedFileNamePath , + tr( "CSV (*.csv);; All files (*)" ) , + nullptr , QFileDialog::DontUseNativeDialog ); - if( !networkFilename.isEmpty( )) + if ( !networkFilename.isEmpty( )) { const QString activityFilename = QFileDialog::getOpenFileName( - this, tr( "Open CSV Activity file" ), _lastOpenedFileNamePath, - tr( "CSV (*.csv);; All files (*)" ), - nullptr, QFileDialog::DontUseNativeDialog ); + this , tr( "Open CSV Activity file" ) , _lastOpenedFileNamePath , + tr( "CSV (*.csv);; All files (*)" ) , + nullptr , QFileDialog::DontUseNativeDialog ); if ( !activityFilename.isEmpty( )) { _lastOpenedFileNamePath = QFileInfo( networkFilename ).path( ); - loadData(simil::TCSV, networkFilename.toStdString(), activityFilename.toStdString(), simil::TSimSpikes); + loadData( simil::TCSV , networkFilename.toStdString( ) , + activityFilename.toStdString( ) , simil::TSimSpikes ); } } } void MainWindow::openSubsetEventsFileThroughDialog( void ) { - const QString eventsFilename = QFileDialog::getOpenFileName(this, - tr( "Open file containing subsets/events data" ), - _lastOpenedSubsetsFileName, - tr( "JSON (*.json);; hdf5 (*.h5 *.hdf5);; All files (*)" ), - nullptr, QFileDialog::DontUseNativeDialog ); - - if( !eventsFilename.isEmpty( )) + const QString eventsFilename = QFileDialog::getOpenFileName( this , + tr( + "Open file containing subsets/events data" ) , + _lastOpenedSubsetsFileName , + tr( + "JSON (*.json);; hdf5 (*.h5 *.hdf5);; All files (*)" ) , + nullptr , + QFileDialog::DontUseNativeDialog ); + + if ( !eventsFilename.isEmpty( )) { _lastOpenedSubsetsFileName = QFileInfo( eventsFilename ).path( ); - openSubsetEventFile( eventsFilename.toStdString( ), false ); + openSubsetEventFile( eventsFilename.toStdString( ) , false ); _summary->generateEventsRep( ); _summary->importSubsetsFromSubsetMngr( ); - if( _displayManager ) + if ( _displayManager ) _displayManager->refresh( ); } } @@ -368,12 +396,12 @@ void MainWindow::openSubsetEventsFileThroughDialog( void ) void MainWindow::configurePlayer( void ) { _startTimeLabel->setText( - QString::number(_player->startTime(), 'f', 3)); + QString::number( _player->startTime( ) , 'f' , 3 )); _endTimeLabel->setText( - QString::number(_player->endTime(), 'f', 3)); + QString::number( _player->endTime( ) , 'f' , 3 )); - m_dataInspector->setSimPlayer(_player); + m_dataInspector->setSimPlayer( _player ); #ifdef SIMIL_USE_ZEROEQ try @@ -407,37 +435,39 @@ void MainWindow::configurePlayer( void ) #endif } -void MainWindow::togglePlaybackDock(void) +void MainWindow::togglePlaybackDock( void ) { - if (_ui->actionTogglePlaybackDock->isChecked()) - _dockSimulation->show(); + if ( _ui->actionTogglePlaybackDock->isChecked( )) + _dockSimulation->show( ); else - _dockSimulation->close(); + _dockSimulation->close( ); - update(); + update( ); } void MainWindow::showDisplayManagerWidget( void ) { - if(!_summary) return; + if ( !_summary ) return; - if( !_displayManager) + if ( !_displayManager ) { _displayManager = new visimpl::DisplayManagerWidget( ); - _displayManager->init( _summary->eventWidgets(), + _displayManager->init( _summary->eventWidgets( ) , _summary->histogramWidgets( )); - connect( _displayManager, SIGNAL( eventVisibilityChanged( unsigned int, bool )), - _summary, SLOT( eventVisibility( unsigned int, bool ))); + connect( _displayManager , + SIGNAL( eventVisibilityChanged( unsigned int , bool )) , + _summary , SLOT( eventVisibility( unsigned int , bool ))); - connect( _displayManager, SIGNAL( subsetVisibilityChanged( unsigned int, bool )), - _summary, SLOT( subsetVisibility( unsigned int, bool ))); + connect( _displayManager , + SIGNAL( subsetVisibilityChanged( unsigned int , bool )) , + _summary , SLOT( subsetVisibility( unsigned int , bool ))); - connect( _displayManager, SIGNAL( removeEvent( unsigned int )), - _summary, SLOT( removeEvent( unsigned int ))); + connect( _displayManager , SIGNAL( removeEvent( unsigned int )) , + _summary , SLOT( removeEvent( unsigned int ))); - connect( _displayManager, SIGNAL( removeHistogram( unsigned int )), - _summary, SLOT( removeSubset( unsigned int ))); + connect( _displayManager , SIGNAL( removeHistogram( unsigned int )) , + _summary , SLOT( removeSubset( unsigned int ))); } @@ -450,7 +480,7 @@ void MainWindow::initPlaybackDock( ) { _dockSimulation = new QDockWidget( ); _dockSimulation->setMinimumHeight( 100 ); - _dockSimulation->setSizePolicy( QSizePolicy::MinimumExpanding, + _dockSimulation->setSizePolicy( QSizePolicy::MinimumExpanding , QSizePolicy::MinimumExpanding ); _playing = false; @@ -463,109 +493,110 @@ void MainWindow::initPlaybackDock( ) _simSlider = new CustomSlider( Qt::Horizontal ); _simSlider->setMinimum( 0 ); _simSlider->setMaximum( SLIDER_MAX ); - _simSlider->setSizePolicy( QSizePolicy::Preferred, + _simSlider->setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Preferred ); - _playButton = new QPushButton(_playIcon, tr("") ); - _playButton->setSizePolicy( QSizePolicy::MinimumExpanding, + _playButton = new QPushButton( _playIcon , tr( "" )); + _playButton->setSizePolicy( QSizePolicy::MinimumExpanding , QSizePolicy::MinimumExpanding ); - auto stopButton = new QPushButton(QIcon(":/icons/stop.svg"), tr("")); - auto nextButton = new QPushButton(QIcon(":/icons/next.svg"), tr("")); - auto prevButton = new QPushButton(QIcon(":/icons/previous.svg"), tr("")); + auto stopButton = new QPushButton( QIcon( ":/icons/stop.svg" ) , tr( "" )); + auto nextButton = new QPushButton( QIcon( ":/icons/next.svg" ) , tr( "" )); + auto prevButton = new QPushButton( QIcon( ":/icons/previous.svg" ) , + tr( "" )); - _repeatButton = new QPushButton(QIcon(":/icons/repeat.svg"), tr("")); - _repeatButton->setCheckable(true); - _repeatButton->setChecked(false); + _repeatButton = new QPushButton( QIcon( ":/icons/repeat.svg" ) , tr( "" )); + _repeatButton->setCheckable( true ); + _repeatButton->setChecked( false ); - _goToButton = new QPushButton(); - _goToButton->setText(QString("Play at...")); + _goToButton = new QPushButton( ); + _goToButton->setText( QString( "Play at..." )); _startTimeLabel = new QLabel( "" ); - _startTimeLabel->setSizePolicy( QSizePolicy::MinimumExpanding, + _startTimeLabel->setSizePolicy( QSizePolicy::MinimumExpanding , QSizePolicy::Preferred ); _endTimeLabel = new QLabel( "" ); - _endTimeLabel->setSizePolicy( QSizePolicy::Preferred, + _endTimeLabel->setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Preferred ); unsigned int row = 2; - dockLayout->addWidget(_startTimeLabel, row, 0, 1, 2); - dockLayout->addWidget(_simSlider, row, 1, 1, totalHSpan - 3); - dockLayout->addWidget(_endTimeLabel, row, totalHSpan - 2, 1, 1, Qt::AlignRight); + dockLayout->addWidget( _startTimeLabel , row , 0 , 1 , 2 ); + dockLayout->addWidget( _simSlider , row , 1 , 1 , totalHSpan - 3 ); + dockLayout->addWidget( _endTimeLabel , row , totalHSpan - 2 , 1 , 1 , + Qt::AlignRight ); row++; - dockLayout->addWidget(_repeatButton, row, 7, 1, 1); - dockLayout->addWidget(prevButton, row, 8, 1, 1); - dockLayout->addWidget(_playButton, row, 9, 2, 2); - dockLayout->addWidget(stopButton, row, 11, 1, 1); - dockLayout->addWidget(nextButton, row, 12, 1, 1); - dockLayout->addWidget(_goToButton, row, 13, 1, 1); + dockLayout->addWidget( _repeatButton , row , 7 , 1 , 1 ); + dockLayout->addWidget( prevButton , row , 8 , 1 , 1 ); + dockLayout->addWidget( _playButton , row , 9 , 2 , 2 ); + dockLayout->addWidget( stopButton , row , 11 , 1 , 1 ); + dockLayout->addWidget( nextButton , row , 12 , 1 , 1 ); + dockLayout->addWidget( _goToButton , row , 13 , 1 , 1 ); - connect( _playButton, SIGNAL( clicked( )), - this, SLOT( PlayPause( ))); + connect( _playButton , SIGNAL( clicked( )) , + this , SLOT( PlayPause( ))); - connect( stopButton, SIGNAL( clicked( )), - this, SLOT( Stop( ))); + connect( stopButton , SIGNAL( clicked( )) , + this , SLOT( Stop( ))); - connect( nextButton, SIGNAL( clicked( )), - this, SLOT( GoToEnd( ))); + connect( nextButton , SIGNAL( clicked( )) , + this , SLOT( GoToEnd( ))); - connect( prevButton, SIGNAL( clicked( )), - this, SLOT( Restart( ))); + connect( prevButton , SIGNAL( clicked( )) , + this , SLOT( Restart( ))); - connect( _repeatButton, SIGNAL( clicked( )), - this, SLOT( Repeat( ))); + connect( _repeatButton , SIGNAL( clicked( )) , + this , SLOT( Repeat( ))); - connect( _simSlider, SIGNAL( sliderPressed( )), - this, SLOT( PlayAtPosition( ))); + connect( _simSlider , SIGNAL( sliderPressed( )) , + this , SLOT( PlayAtPosition( ))); - connect( _goToButton, SIGNAL( clicked( )), - this, SLOT( playAtButtonClicked( ))); + connect( _goToButton , SIGNAL( clicked( )) , + this , SLOT( playAtButtonClicked( ))); _dockSimulation->setWidget( content ); - this->addDockWidget( Qt::BottomDockWidgetArea, - _dockSimulation ); + this->addDockWidget( Qt::BottomDockWidgetArea , + _dockSimulation ); - _dockSimulation->setEnabled(false); + _dockSimulation->setEnabled( false ); } void MainWindow::initSummaryWidget( ) { - _summary = new visimpl::Summary( this, visimpl::T_STACK_EXPANDABLE ); + _summary = new visimpl::Summary( this , visimpl::T_STACK_EXPANDABLE ); - if( _simulationType == simil::TSimSpikes ) + if ( _simulationType == simil::TSimSpikes || + _simulationType == simil::TSimNetwork ) { - auto spikesPlayer = dynamic_cast< simil::SpikesPlayer* >( _player ); - - _summary->Init( spikesPlayer->data( )); + _summary->Init( _player->data( )); _summary->simulationPlayer( _player ); } - if(centralWidget()) + if ( centralWidget( )) { - auto toRemove = centralWidget(); - layout()->removeWidget(toRemove); + auto toRemove = centralWidget( ); + layout( )->removeWidget( toRemove ); delete toRemove; } this->setCentralWidget( _summary ); - connect( _ui->actionAutoNamingSelections, SIGNAL( triggered( )), - _summary, SLOT( toggleAutoNameSelections( ))); + connect( _ui->actionAutoNamingSelections , SIGNAL( triggered( )) , + _summary , SLOT( toggleAutoNameSelections( ))); _ui->actionFill_Plots->setChecked( true ); - connect( _ui->actionFill_Plots, SIGNAL( triggered( bool )), - _summary, SLOT( fillPlots( bool ))); + connect( _ui->actionFill_Plots , SIGNAL( triggered( bool )) , + _summary , SLOT( fillPlots( bool ))); - connect(_ui->actionShowPanels, SIGNAL(triggered(bool)), - _summary, SLOT( showConfigPanels(bool))); + connect( _ui->actionShowPanels , SIGNAL( triggered( bool )) , + _summary , SLOT( showConfigPanels( bool ))); - connect( _summary, SIGNAL( histogramClicked( float )), - this, SLOT( PlayAtPercentage( float ))); + connect( _summary , SIGNAL( histogramClicked( float )) , + this , SLOT( PlayAtPercentage( float ))); - connect( m_dataInspector, SIGNAL( simDataChanged()), - _summary, SLOT( UpdateHistograms())); + connect( m_dataInspector , SIGNAL( simDataChanged( )) , + _summary , SLOT( UpdateHistograms( ))); - connect( m_dataInspector, SIGNAL( simDataChanged()), - this, SLOT( onDataUpdated())); + connect( m_dataInspector , SIGNAL( simDataChanged( )) , + this , SLOT( onDataUpdated( ))); #ifdef VISIMPL_USE_ZEROEQ connect( _summary, SIGNAL( histogramClicked( visimpl::HistogramWidget* )), @@ -573,53 +604,54 @@ void MainWindow::initSummaryWidget( ) #endif _ui->actionFocusOnPlayhead->setVisible( true ); - connect( _ui->actionFocusOnPlayhead, SIGNAL( triggered( )), - _summary, SLOT( focusPlayback( ))); + connect( _ui->actionFocusOnPlayhead , SIGNAL( triggered( )) , + _summary , SLOT( focusPlayback( ))); - if( _autoCalculateCorrelations ) + if ( _autoCalculateCorrelations ) { calculateCorrelations( ); } - QTimer::singleShot( 0, _summary, SLOT( adjustSplittersSize( ))); + QTimer::singleShot( 0 , _summary , SLOT( adjustSplittersSize( ))); } -void MainWindow::PlayPause(bool notify) +void MainWindow::PlayPause( bool notify ) { - if (_playing) - Pause(notify); + if ( _playing ) + Pause( notify ); else - Play(notify); + Play( notify ); } void MainWindow::Play( bool notify ) { - if( _player ) + if ( _player ) { - _player->Play( ); - _playButton->setIcon( _pauseIcon ); - _playing = true; + _player->Play( ); + _playButton->setIcon( _pauseIcon ); + _playing = true; - if( notify ) - { + if ( notify ) + { #ifdef VISIMPL_USE_GMRVLEX - sendZeroEQPlaybackOperation(zeroeq::gmrv::PLAY); + sendZeroEQPlaybackOperation(zeroeq::gmrv::PLAY); #endif - } + } } } void MainWindow::Pause( bool notify ) { - if( _player ) + if ( _player ) { _player->Pause( ); _playButton->setIcon( _playIcon ); _playing = false; - _startTimeLabel->setText(QString::number(_player->currentTime(), 'f', 3)); + _startTimeLabel->setText( + QString::number( _player->currentTime( ) , 'f' , 3 )); - if( notify ) + if ( notify ) { #ifdef VISIMPL_USE_GMRVLEX sendZeroEQPlaybackOperation(zeroeq::gmrv::PAUSE); @@ -630,14 +662,14 @@ void MainWindow::Pause( bool notify ) void MainWindow::Stop( bool notify ) { - if( _player ) + if ( _player ) { _player->Stop( ); _playButton->setIcon( _playIcon ); _startTimeLabel->setText( - QString::number( _player ->startTime(), 'f', 3)); + QString::number( _player->startTime( ) , 'f' , 3 )); _playing = false; - if( notify ) + if ( notify ) { #ifdef VISIMPL_USE_GMRVLEX sendZeroEQPlaybackOperation(zeroeq::gmrv::STOP); @@ -648,12 +680,12 @@ void MainWindow::Stop( bool notify ) void MainWindow::Repeat( bool notify ) { - if( _player ) + if ( _player ) { const bool repeat = _repeatButton->isChecked( ); _player->loop( repeat ); - if( notify ) + if ( notify ) { #ifdef VISIMPL_USE_GMRVLEX const auto op = repeat ? zeroeq::gmrv::ENABLE_LOOP : zeroeq::gmrv::DISABLE_LOOP; @@ -663,42 +695,43 @@ void MainWindow::Repeat( bool notify ) } } -void MainWindow::PlayAtPosition(bool notify) +void MainWindow::PlayAtPosition( bool notify ) { - if (_player) + if ( _player ) { - PlayAtPosition(_simSlider->sliderPosition(), notify); + PlayAtPosition( _simSlider->sliderPosition( ) , notify ); } } -void MainWindow::PlayAtPercentage(float percentage, bool notify) +void MainWindow::PlayAtPercentage( float percentage , bool notify ) { - if (_player) + if ( _player ) { - const auto tBegin = _player->startTime(); - const auto tEnd = _player->endTime(); - const auto timePos = (percentage * (tEnd-tBegin)) + tBegin; + const auto tBegin = _player->startTime( ); + const auto tEnd = _player->endTime( ); + const auto timePos = ( percentage * ( tEnd - tBegin )) + tBegin; - PlayAtTime(timePos, notify); + PlayAtTime( timePos , notify ); } } -void MainWindow::PlayAtPosition( int sliderPosition, bool notify ) +void MainWindow::PlayAtPosition( int sliderPosition , bool notify ) { - if( _player ) + if ( _player ) { - PlayAtPercentage( static_cast<float>(sliderPosition) / SLIDER_MAX , notify); + PlayAtPercentage( static_cast<float>(sliderPosition) / SLIDER_MAX , + notify ); } } -void MainWindow::PlayAtTime(float timePos, bool notify) +void MainWindow::PlayAtTime( float timePos , bool notify ) { - if(_player) + if ( _player ) { - const auto tBegin = _player->startTime(); - const auto tEnd = _player->endTime(); - const auto newTimePos = std::max(tBegin, std::min(tEnd, timePos)); - const auto percentage = (newTimePos - tBegin) / (tEnd - tBegin); + const auto tBegin = _player->startTime( ); + const auto tEnd = _player->endTime( ); + const auto newTimePos = std::max( tBegin , std::min( tEnd , timePos )); + const auto percentage = ( newTimePos - tBegin ) / ( tEnd - tBegin ); _simSlider->setSliderPosition( percentage * SLIDER_MAX ); @@ -706,11 +739,12 @@ void MainWindow::PlayAtTime(float timePos, bool notify) _playing = true; - _player->PlayAtTime(newTimePos); + _player->PlayAtTime( newTimePos ); - _startTimeLabel->setText(QString::number(_player->currentTime(), 'f', 3)); + _startTimeLabel->setText( + QString::number( _player->currentTime( ) , 'f' , 3 )); - if( notify ) + if ( notify ) { #ifdef VISIMPL_USE_ZEROEQ try @@ -743,22 +777,22 @@ void MainWindow::PlayAtTime(float timePos, bool notify) void MainWindow::Restart( bool notify ) { - if( _player ) + if ( _player ) { bool playing = _playing; _player->Stop( ); _playing = false; - if( playing ) + if ( playing ) { - _player->Play( ); - _playing = true; + _player->Play( ); + _playing = true; } - if( _playing ) + if ( _playing ) _playButton->setIcon( _pauseIcon ); else _playButton->setIcon( _playIcon ); - if( notify ) + if ( notify ) { #ifdef VISIMPL_USE_GMRVLEX sendZeroEQPlaybackOperation(zeroeq::gmrv::BEGIN); @@ -769,11 +803,11 @@ void MainWindow::Restart( bool notify ) void MainWindow::GoToEnd( bool notify ) { - if( _player ) + if ( _player ) { //TODO implement GOTOEND - if( notify ) + if ( notify ) { #ifdef VISIMPL_USE_GMRVLEX sendZeroEQPlaybackOperation(zeroeq::gmrv::END); @@ -782,24 +816,25 @@ void MainWindow::GoToEnd( bool notify ) } } -void MainWindow::UpdateSimulationSlider(float position) +void MainWindow::UpdateSimulationSlider( float position ) { // NOTE: this method receives the position in time, not percentage. - const auto tBegin = _player->startTime(); - const auto tEnd = _player->endTime(); - const auto newPosition = std::min(tEnd, std::max(tBegin, position)); - const auto isOverflow = (std::abs(newPosition - position) > std::numeric_limits<float>::epsilon()); + const auto tBegin = _player->startTime( ); + const auto tEnd = _player->endTime( ); + const auto newPosition = std::min( tEnd , std::max( tBegin , position )); + const auto isOverflow = ( std::abs( newPosition - position ) > + std::numeric_limits< float >::epsilon( )); - PlayAtTime( newPosition, isOverflow ); + PlayAtTime( newPosition , isOverflow ); - if(isOverflow) - Pause(true); + if ( isOverflow ) + Pause( true ); - if (_summary) - _summary->repaintHistograms(); + if ( _summary ) + _summary->repaintHistograms( ); - if (_ui->actionFollowPlayhead->isChecked()) - _summary->focusPlayback(); + if ( _ui->actionFollowPlayhead->isChecked( )) + _summary->focusPlayback( ); } #ifdef VISIMPL_USE_ZEROEQ @@ -895,60 +930,66 @@ void MainWindow::_onSelectionEvent(lexis::data::ConstSelectedIDsPtr selected) #endif -void MainWindow::playAtButtonClicked(void) +void MainWindow::playAtButtonClicked( void ) { bool ok; - const double result = QInputDialog::getDouble(this, tr("Set simulation time to play:"), - tr("Simulation time"), static_cast<double>(_player->currentTime()), - static_cast<double>(_player->startTime()), - static_cast<double>(_player->endTime()), 3, &ok, Qt::Popup); - - if (ok) + const double result = QInputDialog::getDouble( this , tr( + "Set simulation time to play:" ) , + tr( "Simulation time" ) , + static_cast<double>(_player->currentTime( )) , + static_cast<double>(_player->startTime( )) , + static_cast<double>(_player->endTime( )) , + 3 , &ok , Qt::Popup ); + + if ( ok ) { - float percentage = (result - _player->startTime()) / - (_player->endTime() - _player->startTime()); + float percentage = ( result - _player->startTime( )) / + ( _player->endTime( ) - _player->startTime( )); - percentage = std::max(0.0f, std::min(1.0f, percentage)); + percentage = std::max( 0.0f , std::min( 1.0f , percentage )); - PlayAtPercentage(percentage); + PlayAtPercentage( percentage ); } } -void MainWindow::loadComplete(void) +void MainWindow::loadComplete( void ) { - _summary->showMarker(false); + _summary->showMarker( false ); } -void MainWindow::addCorrelation(const std::string &subset) +void MainWindow::addCorrelation( const std::string& subset ) { - _correlations.push_back(subset); + _correlations.push_back( subset ); } -void MainWindow::calculateCorrelations(void) +void MainWindow::calculateCorrelations( void ) { - if(!_subsetEventManager) return; + if ( !_subsetEventManager ) return; - visimpl::CorrelationComputer cc(dynamic_cast<simil::SpikeData*>(_player->data())); + // TODO: mirar @gael. + auto pdata = dynamic_cast<simil::SpikeData*>(_player->data( ).get( )); + visimpl::CorrelationComputer cc( pdata ); - const auto eventNames = _subsetEventManager->eventNames(); + const auto eventNames = _subsetEventManager->eventNames( ); constexpr double deltaTime = 0.125; - cc.configureEvents(eventNames, deltaTime); + cc.configureEvents( eventNames , deltaTime ); - auto correlateSubsets = [&eventNames, &cc](const std::string &event) + auto correlateSubsets = [ &eventNames , &cc ]( const std::string& event ) { - cc.correlateSubset( event, eventNames, deltaTime, 2600, 2900 ); + cc.correlateSubset( event , eventNames , deltaTime , 2600 , 2900 ); }; - std::for_each(_correlations.cbegin(), _correlations.cend(), correlateSubsets); + std::for_each( _correlations.cbegin( ) , _correlations.cend( ) , + correlateSubsets ); - const auto names = cc.correlationNames(); + const auto names = cc.correlationNames( ); - auto addHistogram = [this, &cc](const std::string &name) + auto addHistogram = [ this , &cc ]( const std::string& name ) { auto correlation = cc.correlation( name ); - if( !correlation ) return; + if ( !correlation ) return; visimpl::Selection selection; selection.name = correlation->fullName; @@ -956,7 +997,7 @@ void MainWindow::calculateCorrelations(void) _summary->AddNewHistogram( selection ); }; - std::for_each(names.cbegin(), names.cend(), addHistogram); + std::for_each( names.cbegin( ) , names.cend( ) , addHistogram ); } void MainWindow::aboutDialog( void ) @@ -965,144 +1006,158 @@ void MainWindow::aboutDialog( void ) QString( "<h2>ViSimpl - StackViz</h2>" ) + tr( "A multi-view visual analyzer of brain simulation data. " ) + "<br>" + tr( "Version " ) + stackviz::Version::getString( ).c_str( ) + - tr( " rev (%1)<br>").arg(stackviz::Version::getRevision( )) + + tr( " rev (%1)<br>" ).arg( stackviz::Version::getRevision( )) + "<a href='https://vg-lab.es/visimpl/'>https://vg-lab.es/visimpl</a>" + "<h4>" + tr( "Build info:" ) + "</h4>" + "<ul><li>Qt " + QT_VERSION_STR + -#ifdef VISIMPL_USE_GMRVLEX + #ifdef VISIMPL_USE_GMRVLEX "</li><li>GmrvLex " + GMRVLEX_REV_STRING + -#else - "</li><li>GmrvLex " + tr ("support not built.") + -#endif + #else + "</li><li>GmrvLex " + tr( "support not built." ) + + #endif -#ifdef VISIMPL_USE_PREFR + #ifdef VISIMPL_USE_PREFR "</li><li>prefr " + PREFR_REV_STRING + -#else - "</li><li>prefr " + tr ("support not built.") + -#endif + #else + "</li><li>prefr " + tr( "support not built." ) + + #endif -#ifdef VISIMPL_USE_RETO + #ifdef VISIMPL_USE_RETO "</li><li>ReTo " + RETO_REV_STRING + -#else + #else "</li><li>ReTo " + tr ("support not built.") + -#endif + #endif -#ifdef VISIMPL_USE_SCOOP + #ifdef VISIMPL_USE_SCOOP "</li><li>Scoop " + SCOOP_REV_STRING + -#else + #else "</li><li>Scoop " + tr ("support not built.") + -#endif + #endif -#ifdef VISIMPL_USE_SIMIL + #ifdef VISIMPL_USE_SIMIL "</li><li>SimIL " + SIMIL_REV_STRING + -#else + #else "</li><li>SimIL " + tr ("support not built.") + -#endif + #endif -#ifdef VISIMPL_USE_ZEROEQ + #ifdef VISIMPL_USE_ZEROEQ "</li><li>ZeroEQ " + zeroeq::Version::getRevString().c_str() + -#else - "</li><li>ZeroEQ " + tr ("support not built.") + -#endif + #else + "</li><li>ZeroEQ " + tr( "support not built." ) + + #endif "</li><li>AcuteRecorder " + ACUTERECORDER_REV_STRING + - "</li></ul>" + "<h4>" + tr( "Developed by:" ) + "</h4>" + - "VG-Lab / URJC / UPM" - "<br><a href='https://vg-lab.es'>https://vg-lab.es</a>" - "<br>(C) 2015-" + QString::number(QDateTime::currentDateTime().date().year()) + "<br><br>" - "<a href='https://vg-lab.es'><img src=':/icons/logoVGLab.png'/></a>" - " " - "<a href='https://www.urjc.es'><img src=':/icons/logoURJC.png' /></a>" - " " - "<a href='https://www.upm.es'><img src=':/icons/logoUPM.png' /></a>"; - - QMessageBox::about(this, tr( "About StackViz" ), msj ); + "</li></ul>" + "<h4>" + tr( "Developed by:" ) + "</h4>" + + "VG-Lab / URJC / UPM" + "<br><a href='https://vg-lab.es'>https://vg-lab.es</a>" + "<br>(C) 2015-" + + QString::number( QDateTime::currentDateTime( ).date( ).year( )) + "<br><br>" + "<a href='https://vg-lab.es'><img src=':/icons/logoVGLab.png'/></a>" + " " + "<a href='https://www.urjc.es'><img src=':/icons/logoURJC.png' /></a>" + " " + "<a href='https://www.upm.es'><img src=':/icons/logoUPM.png' /></a>"; + + QMessageBox::about( this , tr( "About StackViz" ) , msj ); } -void MainWindow::openH5FilesThroughDialog(void) +void MainWindow::openH5FilesThroughDialog( void ) { - const auto networkFilename = QFileDialog::getOpenFileName(this, tr("Open a HDF5 network file"), - _lastOpenedFileNamePath, - tr("hdf5 ( *.h5 *.hdf5);; All files (*)"), nullptr, - QFileDialog::DontUseNativeDialog); - - if (networkFilename.isEmpty()) return; - - const auto activityFilename = QFileDialog::getOpenFileName(this, tr("Open a HDF5 activity file"), - _lastOpenedFileNamePath, - tr("hdf5 ( *.h5 *.hdf5);; All files (*)"), - nullptr, QFileDialog::DontUseNativeDialog); - - if (activityFilename.isEmpty()) return; - - loadData(simil::THDF5, networkFilename.toStdString(), activityFilename.toStdString(), simil::TSimSpikes); + const auto networkFilename = QFileDialog::getOpenFileName( this , tr( + "Open a HDF5 network file" ) , + _lastOpenedFileNamePath , + tr( + "hdf5 ( *.h5 *.hdf5);; All files (*)" ) , + nullptr , + QFileDialog::DontUseNativeDialog ); + + if ( networkFilename.isEmpty( )) return; + + const auto activityFilename = QFileDialog::getOpenFileName( this , tr( + "Open a HDF5 activity file" ) , + _lastOpenedFileNamePath , + tr( + "hdf5 ( *.h5 *.hdf5);; All files (*)" ) , + nullptr , + QFileDialog::DontUseNativeDialog ); + + if ( activityFilename.isEmpty( )) return; + + loadData( simil::THDF5 , networkFilename.toStdString( ) , + activityFilename.toStdString( ) , simil::TSimSpikes ); } -void MainWindow::updateUIonOpen(const std::string &eventsFile) +void MainWindow::updateUIonOpen( const std::string& eventsFile ) { configurePlayer( ); initSummaryWidget( ); - openSubsetEventFile( eventsFile, true ); + openSubsetEventFile( eventsFile , true ); _summary->generateEventsRep( ); _summary->importSubsetsFromSubsetMngr( ); - if( _displayManager ) + if ( _displayManager ) _displayManager->refresh( ); - _ui->actionShowDataManager->setEnabled(true); - _ui->actionOpenSubsetEventsFile->setEnabled(true); - _ui->actionOpenGroupsFile->setEnabled(true); - _ui->actionCloseData->setEnabled(true); + _ui->actionShowDataManager->setEnabled( true ); + _ui->actionOpenSubsetEventsFile->setEnabled( true ); + _ui->actionOpenGroupsFile->setEnabled( true ); + _ui->actionCloseData->setEnabled( true ); - _dockSimulation->setEnabled(true); + _dockSimulation->setEnabled( true ); } -void stackviz::MainWindow::loadData(const simil::TDataType type, - const std::string &arg1, const std::string &arg2, - const simil::TSimulationType simType, const std::string &subsetEventFile) +void stackviz::MainWindow::loadData( const simil::TDataType type , + const std::string& arg1 , + const std::string& arg2 , + const simil::TSimulationType simType , + const std::string& subsetEventFile ) { - updateGeometry(); + updateGeometry( ); - Q_ASSERT(type != simil::TDataType::TREST); - m_dataInspector->setUpdatesEnabled(false); - _ui->actionConfigureRESTconnection->setEnabled(false); - _ui->actionConnectRESTserver->setEnabled(false); + Q_ASSERT( type != simil::TDataType::TREST ); + m_dataInspector->setUpdatesEnabled( false ); + _ui->actionConfigureRESTconnection->setEnabled( false ); + _ui->actionConnectRESTserver->setEnabled( false ); _simulationType = simType; m_subsetEventFile = subsetEventFile; - QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor( Qt::WaitCursor ); - closeLoadingDialog(); + closeLoadingDialog( ); - m_loaderDialog = new LoadingDialog(this); - m_loaderDialog->show(); + m_loaderDialog = new LoadingDialog( this ); + m_loaderDialog->show( ); - m_loader = std::make_shared<LoaderThread>(); - m_loader->setData(type, arg1, arg2); + m_loader = std::make_shared< LoaderThread >( ); + m_loader->setData( type , arg1 , arg2 ); - connect(m_loader.get(), SIGNAL(finished()), this, SLOT(onLoadFinished())); - connect(m_loader.get(), SIGNAL(progress(int)), m_loaderDialog, SLOT(setProgress(int))); - connect(m_loader.get(), SIGNAL(network(unsigned int)), m_loaderDialog, SLOT(setNetwork(unsigned int))); - connect(m_loader.get(), SIGNAL(spikes(unsigned int)), m_loaderDialog, SLOT(setSpikesValue(unsigned int))); + connect( m_loader.get( ) , SIGNAL( finished( )) , this , + SLOT( onLoadFinished( ))); + connect( m_loader.get( ) , SIGNAL( progress( int )) , m_loaderDialog , + SLOT( setProgress( int ))); + connect( m_loader.get( ) , SIGNAL( network( unsigned int )) , m_loaderDialog , + SLOT( setNetwork( unsigned int ))); + connect( m_loader.get( ) , SIGNAL( spikes( unsigned int )) , m_loaderDialog , + SLOT( setSpikesValue( unsigned int ))); - m_loader->start(); + m_loader->start( ); } void MainWindow::openRecorder( void ) { - auto action = qobject_cast<QAction *>(sender()); + auto action = qobject_cast< QAction* >( sender( )); // The button stops the recorder if found. - if( _recorder != nullptr ) + if ( _recorder != nullptr ) { - if(action) action->setDisabled( true ); + if ( action ) action->setDisabled( true ); - RecorderUtils::stopAndWait(_recorder, this); + RecorderUtils::stopAndWait( _recorder , this ); _recorder = nullptr; return; } @@ -1113,7 +1168,7 @@ void MainWindow::openRecorder( void ) params.includeScreens = false; params.stabilizeFramerate = true; - if(!_ui->actionAdvancedRecorderOptions->isChecked()) + if ( !_ui->actionAdvancedRecorderOptions->isChecked( )) { params.showWorker = false; params.showWidgetSourceMode = false; @@ -1123,110 +1178,111 @@ void MainWindow::openRecorder( void ) RecorderDialog dialog( nullptr , params , true ); dialog.setWindowIcon( QIcon( ":/visimpl.png" )); dialog.setFixedSize( 800 , 600 ); - if ( dialog.exec( ) == QDialog::Accepted) + if ( dialog.exec( ) == QDialog::Accepted ) { _recorder = dialog.getRecorder( ); connect( _recorder , SIGNAL( finished( )) , _recorder , SLOT( deleteLater( ))); connect( _recorder , SIGNAL( finished( )) , this , SLOT( finishRecording( ))); - if(action) action->setChecked( true ); - } else + if ( action ) action->setChecked( true ); + } + else { - if(action) action->setChecked( false ); + if ( action ) action->setChecked( false ); } } void MainWindow::finishRecording( ) { - auto action = _ui->menuTools->actions().first(); + auto action = _ui->menuTools->actions( ).first( ); action->setEnabled( true ); action->setChecked( false ); } -void stackviz::MainWindow::onLoadFinished() +void stackviz::MainWindow::onLoadFinished( ) { - if(m_loader) + if ( m_loader ) { - const auto errors = m_loader->errors(); - if(!errors.empty()) + const auto errors = m_loader->errors( ); + if ( !errors.empty( )) { - closeLoadingDialog(); - _player->Clear(); + closeLoadingDialog( ); + _player->Clear( ); _subsetEventManager = nullptr; - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor( ); - const auto message = QString::fromStdString(errors); - QMessageBox::critical(this, tr("Error loading data"), message, QMessageBox::Ok); + const auto message = QString::fromStdString( errors ); + QMessageBox::critical( this , tr( "Error loading data" ) , message , + QMessageBox::Ok ); m_loader = nullptr; return; } } - const auto dataType = m_loader->type(); + const auto dataType = m_loader->type( ); - switch(dataType) + switch ( dataType ) { case simil::TBlueConfig: case simil::TCSV: case simil::THDF5: - { - const auto spikeData = m_loader->simulationData(); + { + const auto spikeData = m_loader->simulationData( ); - _player = new simil::SpikesPlayer(); - _player->LoadData(spikeData); + _player = new simil::SpikesPlayer( ); + _player->LoadData( spikeData ); - m_loader = nullptr; - } + m_loader = nullptr; + } break; case simil::TREST: - { + { #ifdef SIMIL_WITH_REST_API - const auto netData = m_loader->network(); - const auto simData = m_loader->simulationData(); + const auto netData = m_loader->network( ); + const auto simData = m_loader->simulationData( ); + + _player = new simil::SpikesPlayer( ); + _player->LoadData( netData , simData ); - _player = new simil::SpikesPlayer(); - _player->LoadData(netData, simData); + m_loader = nullptr; - // NOTE: loader doesn't get destroyed. - const auto waitTime = m_loader->RESTLoader()->getConfiguration().waitTime; - m_dataInspector->setCheckTimer(waitTime); - m_dataInspector->setUpdatesEnabled(true); - _ui->actionConfigureRESTconnection->setEnabled(true); #endif - } + } break; case simil::TDataUndefined: default: - { - m_loader = nullptr; - closeLoadingDialog(); - QMessageBox::critical(this, tr("Error loading data"), tr("Data type is undefined after loading"), QMessageBox::Ok); + { + m_loader = nullptr; + closeLoadingDialog( ); + QMessageBox::critical( this , tr( "Error loading data" ) , + tr( "Data type is undefined after loading" ) , + QMessageBox::Ok ); - return; - } + return; + } break; } - if(m_loaderDialog) + if ( m_loaderDialog ) { - const auto gids = _player->gidsSize(); - const auto spikes = reinterpret_cast<simil::SpikesPlayer *>(_player)->spikesSize(); - m_loaderDialog->setNetwork(gids); - m_loaderDialog->setSpikesValue(spikes); + const auto gids = _player->gidsSize( ); + const auto spikes = reinterpret_cast<simil::SpikesPlayer*>(_player)->spikesSize( ); + m_loaderDialog->setNetwork( gids ); + m_loaderDialog->setSpikesValue( spikes ); } - _subsetEventManager = _player->data()->subsetsEvents(); + _subsetEventManager = _player->data( )->subsetsEvents( ); - updateUIonOpen(m_subsetEventFile); + updateUIonOpen( m_subsetEventFile ); - closeLoadingDialog(); + closeLoadingDialog( ); - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor( ); } -void stackviz::MainWindow::sendZeroEQPlaybackOperation(const unsigned int op) +void stackviz::MainWindow::sendZeroEQPlaybackOperation( const unsigned int op ) { #ifdef SIMIL_USE_ZEROEQ try @@ -1247,72 +1303,100 @@ void stackviz::MainWindow::sendZeroEQPlaybackOperation(const unsigned int op) << __FILE__ << ":" << __LINE__ << std::endl; } #else - ignore(op); // c++17 [[maybe_unused]] + ignore( op ); // c++17 [[maybe_unused]] #endif } -void stackviz::MainWindow::onDataUpdated() +void stackviz::MainWindow::onDataUpdated( ) { - const float tBegin = _player->startTime(); - const float tEnd = _player->endTime(); - const float tCurrent = _player->currentTime(); + const float tBegin = _player->startTime( ); + const float tEnd = _player->endTime( ); + const float tCurrent = _player->currentTime( ); - if(tEnd > tBegin) + if ( tEnd > tBegin ) { - _startTimeLabel->setText(QString::number(tCurrent, 'f', 3)); - _endTimeLabel->setText(QString::number(tEnd, 'f', 3)); + _startTimeLabel->setText( QString::number( tCurrent , 'f' , 3 )); + _endTimeLabel->setText( QString::number( tEnd , 'f' , 3 )); - const float percentage = static_cast<float>(tCurrent - tBegin) / (tEnd - tBegin); + const float percentage = + static_cast<float>(tCurrent - tBegin) / ( tEnd - tBegin ); _simSlider->setValue( percentage * SLIDER_MAX ); } } -void stackviz::MainWindow::closeEvent(QCloseEvent *e) +void stackviz::MainWindow::closeEvent( QCloseEvent* e ) { - if(_recorder) + if ( _recorder ) { - QMessageBox msgBox(this); - msgBox.setWindowTitle(tr("Exit StackViz")); + QMessageBox msgBox( this ); + msgBox.setWindowTitle( tr( "Exit StackViz" )); msgBox.setWindowIcon( QIcon( ":/visimpl.png" )); - msgBox.setText(tr("A recording is being made. Do you really want to exit StackViz?")); - msgBox.setStandardButtons(QMessageBox::Cancel|QMessageBox::Yes); + msgBox.setText( + tr( "A recording is being made. Do you really want to exit StackViz?" )); + msgBox.setStandardButtons( QMessageBox::Cancel | QMessageBox::Yes ); - if(msgBox.exec() != QMessageBox::Yes) + if ( msgBox.exec( ) != QMessageBox::Yes ) { - e->ignore(); + e->ignore( ); return; } - RecorderUtils::stopAndWait(_recorder, this); + RecorderUtils::stopAndWait( _recorder , this ); _recorder = nullptr; } - QMainWindow::closeEvent(e); + QMainWindow::closeEvent( e ); } -void stackviz::MainWindow::openRESTThroughDialog() +void stackviz::MainWindow::openRESTThroughDialog( ) { #ifdef SIMIL_WITH_REST_API - ConnectRESTDialog dialog(this); + + if ( _alreadyConnected && _player != nullptr ) + { + ReconnectRESTDialog dialog( this ); + if ( dialog.exec( ) == QDialog::Rejected ) + return; + + if ( dialog.getSelection( ) != + ReconnectRESTDialog::Selection::NEW_CONNECTION ) + { + _restConnectionInformation.network = + dialog.getSelection( ) == + ReconnectRESTDialog::Selection::SPIKES_AND_NETWORK + ? std::weak_ptr< simil::Network >( ) + : _player->getNetwork( ); + + loadRESTData( _restConnectionInformation ); + return; + } + } + + ConnectRESTDialog dialog( this ); + ConnectRESTDialog::Connection connection; - dialog.setRESTConnection(connection); + dialog.setRESTConnection( connection ); - if (QDialog::Accepted == dialog.exec()) + if ( QDialog::Accepted == dialog.exec( )) { - connection = dialog.getRESTConnection(); - const auto restOpt = dialog.getRESTOptions(); + connection = dialog.getRESTConnection( ); + const auto restOpt = dialog.getRESTOptions( ); simil::LoaderRestData::Configuration config; - config.api = connection.protocol.compare("NEST", Qt::CaseInsensitive) == 0 ? - simil::LoaderRestData::Rest_API::NEST : - simil::LoaderRestData::Rest_API::ARBOR; + config.api = + connection.protocol.compare( "NEST" , Qt::CaseInsensitive ) == 0 ? + simil::LoaderRestData::Rest_API::NEST : + simil::LoaderRestData::Rest_API::ARBOR; config.port = connection.port; - config.url = connection.url.toStdString(); + config.url = connection.url.toStdString( ); config.waitTime = restOpt.waitTime; config.failTime = restOpt.failTime; config.spikesSize = restOpt.spikesSize; - loadRESTData(config); + _restConnectionInformation = config; + _alreadyConnected = true; + + loadRESTData( config ); } #else const auto title = tr("Connect REST API"); @@ -1321,35 +1405,36 @@ void stackviz::MainWindow::openRESTThroughDialog() #endif } -void stackviz::MainWindow::configureREST() +void stackviz::MainWindow::configureREST( ) { #ifdef SIMIL_WITH_REST_API - if (!m_loader) + if ( !m_loader ) { - const QString message = tr("There is no REST connection!"); - QMessageBox::warning(this, tr("REST API Options"), message, QMessageBox::Ok); + const QString message = tr( "There is no REST connection!" ); + QMessageBox::warning( this , tr( "REST API Options" ) , message , + QMessageBox::Ok ); return; } - auto loader = m_loader->RESTLoader(); - auto options = loader->getConfiguration(); + auto loader = m_loader->RESTLoader( ); + auto options = loader->getConfiguration( ); RESTConfigurationWidget::Options dialogOptions; dialogOptions.waitTime = options.waitTime; dialogOptions.failTime = options.failTime; dialogOptions.spikesSize = options.spikesSize; - ConfigureRESTDialog dialog(this, Qt::WindowFlags(), dialogOptions); - if (QDialog::Accepted == dialog.exec()) + ConfigureRESTDialog dialog( this , Qt::WindowFlags( ) , dialogOptions ); + if ( QDialog::Accepted == dialog.exec( )) { - dialogOptions = dialog.getRESTOptions(); + dialogOptions = dialog.getRESTOptions( ); simil::LoaderRestData::Configuration config; config.waitTime = dialogOptions.waitTime; config.failTime = dialogOptions.failTime; config.spikesSize = dialogOptions.spikesSize; - loader->setConfiguration(config); + loader->setConfiguration( config ); } #else const auto title = tr("Configure REST API"); @@ -1358,94 +1443,94 @@ void stackviz::MainWindow::configureREST() #endif } -void stackviz::MainWindow::closeData() +void stackviz::MainWindow::closeData( ) { #ifdef SIMIL_WITH_REST_API - if(m_loader && m_loader->type() == simil::TREST) + _alreadyConnected = false; + if ( m_loader && m_loader->type( ) == simil::TREST ) { - CloseDataDialog dialog(this); - const auto result = dialog.exec(); + CloseDataDialog dialog( this ); + const auto result = dialog.exec( ); - if(result == QDialog::Rejected) return; + if ( result == QDialog::Rejected ) return; - if(dialog.keepNetwork()) + if ( dialog.keepNetwork( )) { - QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor( Qt::WaitCursor ); - Stop(); + Stop( ); - m_dataInspector->setCheckUpdates(false); + m_dataInspector->setCheckUpdates( false ); - auto rest = m_loader->RESTLoader(); - rest->resetSpikes(); + _summary->UpdateHistograms( ); - _summary->UpdateHistograms(); + m_dataInspector->update( ); + m_dataInspector->setCheckUpdates( true ); - m_dataInspector->update(); - m_dataInspector->setCheckUpdates(true); + _simSlider->setSliderPosition( 0 ); - _simSlider->setSliderPosition(0); + repaint( ); - repaint(); + QApplication::processEvents( ); - QApplication::processEvents(); - - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor( ); return; } } #endif - QApplication::setOverrideCursor(Qt::WaitCursor); - _player->Clear(); + QApplication::setOverrideCursor( Qt::WaitCursor ); + _player->Clear( ); _subsetEventManager = nullptr; // remove histograms - if(_summary) + if ( _summary ) { - layout()->removeWidget(_summary); - _summary->deleteLater(); + layout( )->removeWidget( _summary ); + _summary->deleteLater( ); _summary = nullptr; - setCentralWidget(new QWidget()); + setCentralWidget( new QWidget( )); } - if(_displayManager) + if ( _displayManager ) { - if(_displayManager->isVisible()) _displayManager->hide(); - _displayManager->deleteLater(); + if ( _displayManager->isVisible( )) _displayManager->hide( ); + _displayManager->deleteLater( ); _displayManager = nullptr; } - _correlations.clear(); + _correlations.clear( ); - _ui->actionCloseData->setEnabled(false); - _dockSimulation->setEnabled(false); + _ui->actionCloseData->setEnabled( false ); + _dockSimulation->setEnabled( false ); - m_dataInspector->setUpdatesEnabled(false); - m_dataInspector->setSimPlayer(nullptr); + m_dataInspector->setUpdatesEnabled( false ); + m_dataInspector->setSimPlayer( nullptr ); - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor( ); } -void stackviz::MainWindow::closeLoadingDialog() +void stackviz::MainWindow::closeLoadingDialog( ) { - if(m_loaderDialog) + if ( m_loaderDialog ) { - m_loaderDialog->close(); + m_loaderDialog->close( ); delete m_loaderDialog; m_loaderDialog = nullptr; } } #ifdef SIMIL_WITH_REST_API -void stackviz::MainWindow::loadRESTData(const simil::LoaderRestData::Configuration &config) + +void stackviz::MainWindow::loadRESTData( + const simil::LoaderRestData::Configuration& config ) { - closeLoadingDialog(); + closeLoadingDialog( ); - QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor( Qt::WaitCursor ); - m_dataInspector->setCheckUpdates(false); + m_dataInspector->setCheckUpdates( false ); m_loaderDialog = new LoadingDialog( this ); m_loaderDialog->show( ); @@ -1453,126 +1538,133 @@ void stackviz::MainWindow::loadRESTData(const simil::LoaderRestData::Configurati QApplication::processEvents( ); m_loader = std::make_shared< LoaderThread >( ); - m_loader->setRESTConfiguration(config); + m_loader->setRESTConfiguration( config ); - connect( m_loader.get( ) , SIGNAL( finished( )), - this, SLOT( onDataLoaded( )) ); - connect( m_loader.get( ) , SIGNAL( progress( int )), - m_loaderDialog , SLOT( setProgress( int )) ); + connect( m_loader.get( ) , SIGNAL( finished( )) , + this , SLOT( onLoadFinished( ))); + connect( m_loader.get( ) , SIGNAL( progress( int )) , + m_loaderDialog , SLOT( setProgress( int ))); connect( m_loader.get( ) , SIGNAL( network( unsigned int )) , - m_loaderDialog , SLOT( setNetwork( unsigned int )) ); + m_loaderDialog , SLOT( setNetwork( unsigned int ))); connect( m_loader.get( ) , SIGNAL( spikes( unsigned int )) , - m_loaderDialog , SLOT( setSpikesValue( unsigned int )) ); + m_loaderDialog , SLOT( setSpikesValue( unsigned int ))); m_loader->start( ); } + #endif -void MainWindow::openGroupsThroughDialog() +void MainWindow::openGroupsThroughDialog( ) { - const auto title = tr("Load Groups"); + const auto title = tr( "Load Groups" ); - const QString groupsFilename = QFileDialog::getOpenFileName(this, title, - _lastOpenedGroupsFileName, - tr("Json files (*.json)"), - nullptr, QFileDialog::ReadOnly | QFileDialog::DontUseNativeDialog); + const QString groupsFilename = QFileDialog::getOpenFileName( this , title , + _lastOpenedGroupsFileName , + tr( + "Json files (*.json)" ) , + nullptr , + QFileDialog::ReadOnly | + QFileDialog::DontUseNativeDialog ); - if (groupsFilename.isEmpty()) + if ( groupsFilename.isEmpty( )) return; - QFile file{groupsFilename}; - if (!file.open(QIODevice::ReadOnly)) + QFile file{ groupsFilename }; + if ( !file.open( QIODevice::ReadOnly )) { - const auto message = tr("Couldn't open file %1").arg(groupsFilename); - - QMessageBox msgbox(this); - msgbox.setWindowTitle(title); - msgbox.setIcon(QMessageBox::Icon::Critical); - msgbox.setText(message); - msgbox.setWindowIcon(QIcon(":/visimpl.png")); - msgbox.setStandardButtons(QMessageBox::Ok); - msgbox.exec(); + const auto message = tr( "Couldn't open file %1" ).arg( groupsFilename ); + + QMessageBox msgbox( this ); + msgbox.setWindowTitle( title ); + msgbox.setIcon( QMessageBox::Icon::Critical ); + msgbox.setText( message ); + msgbox.setWindowIcon( QIcon( ":/visimpl.png" )); + msgbox.setStandardButtons( QMessageBox::Ok ); + msgbox.exec( ); return; } - const auto contents = file.readAll(); + const auto contents = file.readAll( ); QJsonParseError jsonError; - const auto jsonDoc = QJsonDocument::fromJson(contents, &jsonError); - if (jsonDoc.isNull() || !jsonDoc.isObject()) + const auto jsonDoc = QJsonDocument::fromJson( contents , &jsonError ); + if ( jsonDoc.isNull( ) || !jsonDoc.isObject( )) { - const auto message = tr("Couldn't read the contents of %1 or parsing error.").arg(groupsFilename); - - QMessageBox msgbox{this}; - msgbox.setWindowTitle(title); - msgbox.setIcon(QMessageBox::Icon::Critical); - msgbox.setText(message); - msgbox.setWindowIcon(QIcon(":/visimpl.png")); - msgbox.setStandardButtons(QMessageBox::Ok); - msgbox.setDetailedText(jsonError.errorString()); - msgbox.exec(); + const auto message = tr( + "Couldn't read the contents of %1 or parsing error." ).arg( + groupsFilename ); + + QMessageBox msgbox{ this }; + msgbox.setWindowTitle( title ); + msgbox.setIcon( QMessageBox::Icon::Critical ); + msgbox.setText( message ); + msgbox.setWindowIcon( QIcon( ":/visimpl.png" )); + msgbox.setStandardButtons( QMessageBox::Ok ); + msgbox.setDetailedText( jsonError.errorString( )); + msgbox.exec( ); return; } - const auto jsonObj = jsonDoc.object(); - if (jsonObj.isEmpty()) + const auto jsonObj = jsonDoc.object( ); + if ( jsonObj.isEmpty( )) { - const auto message = tr("Error parsing the contents of %1.").arg(groupsFilename); - - QMessageBox msgbox{this}; - msgbox.setWindowTitle(title); - msgbox.setIcon(QMessageBox::Icon::Critical); - msgbox.setText(message); - msgbox.setWindowIcon(QIcon(":/visimpl.png")); - msgbox.setStandardButtons(QMessageBox::Ok); - msgbox.exec(); + const auto message = tr( "Error parsing the contents of %1." ).arg( + groupsFilename ); + + QMessageBox msgbox{ this }; + msgbox.setWindowTitle( title ); + msgbox.setIcon( QMessageBox::Icon::Critical ); + msgbox.setText( message ); + msgbox.setWindowIcon( QIcon( ":/visimpl.png" )); + msgbox.setStandardButtons( QMessageBox::Ok ); + msgbox.exec( ); return; } - QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor( Qt::WaitCursor ); - const auto jsonGroups = jsonObj.value("groups").toArray(); - for (const auto group : jsonGroups) + const auto jsonGroups = jsonObj.value( "groups" ).toArray( ); + for ( const auto group: jsonGroups ) { - const auto o = group.toObject(); + const auto o = group.toObject( ); - const auto name = o.value("name").toString(); - const auto gidsStrings = o.value("gids").toString().split(","); + const auto name = o.value( "name" ).toString( ); + const auto gidsStrings = o.value( "gids" ).toString( ).split( "," ); visimpl::GIDUSet gids; - auto addGids = [&gids](const QString s) + auto addGids = [ &gids ]( const QString s ) { - if (s.contains(":")) + if ( s.contains( ":" )) { - auto limits = s.split(":"); - for (unsigned int id = limits.first().toUInt(); - id <= limits.last().toUInt(); ++id) - gids.insert(id); + auto limits = s.split( ":" ); + for ( unsigned int id = limits.first( ).toUInt( ); + id <= limits.last( ).toUInt( ); ++id ) + gids.insert( id ); } else { - gids.insert(s.toUInt()); + gids.insert( s.toUInt( )); } }; - std::for_each(gidsStrings.cbegin(), gidsStrings.cend(), addGids); + std::for_each( gidsStrings.cbegin( ) , gidsStrings.cend( ) , addGids ); visimpl::Selection selection; selection.gids = gids; - selection.name = name.toStdString(); + selection.name = name.toStdString( ); #ifdef VISIMPL_USE_ZEROEQ _summary->AddNewHistogram(selection, false); #else - _summary->AddNewHistogram(selection); + _summary->AddNewHistogram( selection ); #endif } - _summary->UpdateHistograms(); + _summary->UpdateHistograms( ); - if (_displayManager) + if ( _displayManager ) { - _displayManager->dirtyHistograms(); - _displayManager->refresh(); + _displayManager->dirtyHistograms( ); + _displayManager->refresh( ); } - QApplication::restoreOverrideCursor(); + QApplication::restoreOverrideCursor( ); } diff --git a/stackviz/MainWindow.h b/stackviz/MainWindow.h index 3b22f3963002304c221890c48a1dd8268bbc35aa..2e9f84fb9f85b1fa2c84a1c616e6a3cfe4ecd7a3 100644 --- a/stackviz/MainWindow.h +++ b/stackviz/MainWindow.h @@ -222,6 +222,13 @@ namespace stackviz // Recorder Recorder* _recorder; + +#ifdef SIMIL_WITH_REST_API + + simil::LoaderRestData::Configuration _restConnectionInformation; + bool _alreadyConnected; + +#endif }; diff --git a/stackviz/stackviz.ui b/stackviz/stackviz.ui index 5ad539b2f887b7a46f4cbc5c2fb133df9ec197fb..6fd77ded02847e463d1ca4d35812d2ea4a103908 100644 --- a/stackviz/stackviz.ui +++ b/stackviz/stackviz.ui @@ -100,6 +100,8 @@ <addaction name="separator"/> <addaction name="actionOpenSubsetEventsFile"/> <addaction name="separator"/> + <addaction name="actionCloseData"/> + <addaction name="separator"/> <addaction name="actionTogglePlaybackDock"/> <addaction name="actionShowDataManager"/> <addaction name="actionShowPanels"/> diff --git a/sumrice/CMakeLists.txt b/sumrice/CMakeLists.txt index e0958f04780bcb2e832a9416401f9a95da670696..928a5f5d7c27d9e0166783185bddeff9d1bdcd6b 100644 --- a/sumrice/CMakeLists.txt +++ b/sumrice/CMakeLists.txt @@ -10,14 +10,14 @@ set(CMAKE_AUTOMOC ON) set(SUMRICE_PUBLIC_HEADERS EditorTF/Gradient.h EditorTF/ColorPoints.h - EditorTF/TransferFunctionEditor.h + EditorTF/TransferFunctionEditor.h Summary.h Histogram.h FocusFrame.h CustomSlider.h TransferFunctionWidget.h log.h - EventWidget.h + EventWidget.h CorrelationComputer.h Utils.h LoaderThread.h @@ -29,6 +29,7 @@ set(SUMRICE_PUBLIC_HEADERS ConnectRESTDialog.h CloseDataDialog.h ColorInterpolator.h + ReconnectRESTDialog.h ) set(SUMRICE_HEADERS @@ -54,6 +55,7 @@ set(SUMRICE_SOURCES ConnectRESTDialog.cpp CloseDataDialog.cpp ColorInterpolator.cpp + ReconnectRESTDialog.cpp ) set(SUMRICE_LINK_LIBRARIES diff --git a/sumrice/ConnectRESTDialog.h b/sumrice/ConnectRESTDialog.h index 8756585090f958e03d3a31e1ef93754a29321fb8..22ccbee552b3cbdd00ae3d816b3a315202378533 100644 --- a/sumrice/ConnectRESTDialog.h +++ b/sumrice/ConnectRESTDialog.h @@ -61,7 +61,7 @@ class SUMRICE_API ConnectRESTDialog QString url; unsigned int port; - Connection(): protocol("NEST"), url("localhost"), port(28080) {}; + Connection(): protocol("NEST"), url("localhost"), port(52056) {}; }; /** \brief Sets the connection values. diff --git a/sumrice/LoaderThread.cpp b/sumrice/LoaderThread.cpp index ed79b6bb91ddc44c64da5a8fc5e6a295a487be01..46eef71626fa0e688a2c559944d70c6dad2c19de 100644 --- a/sumrice/LoaderThread.cpp +++ b/sumrice/LoaderThread.cpp @@ -21,142 +21,148 @@ */ // Sumrice +#include <future> #include <simil/Network.h> #include <simil/SimulationData.h> #include <simil/SpikeData.h> #include <sumrice/LoaderThread.h> #ifdef SIMIL_WITH_REST_API + #include <simil/loaders/LoaderRestData.h> #endif -LoaderThread::LoaderThread() -: QThread{nullptr} -, m_type{simil::TDataType::TDataUndefined} -, m_network{nullptr} -, m_data{nullptr} +LoaderThread::LoaderThread( ) + : QThread{ nullptr } + , m_type{ simil::TDataType::TDataUndefined } + , m_network{ nullptr } + , m_data{ nullptr } #ifdef SIMIL_WITH_REST_API -, m_rest{nullptr} + , m_rest{ nullptr } #endif { } -LoaderThread::~LoaderThread() -{ -#ifdef SIMIL_WITH_REST_API - if(m_rest) delete m_rest; -#endif -} - -void LoaderThread::setData(const simil::TDataType type, - const std::string &arg1, - const std::string &arg2) +void LoaderThread::setData( const simil::TDataType type , + const std::string& arg1 , + const std::string& arg2 ) { - assert(type != simil::TDataType::TREST); + assert( type != simil::TDataType::TREST ); m_type = type; m_arg1 = arg1; m_arg2 = arg2; } -simil::Network* LoaderThread::network() const +std::shared_ptr< simil::Network > +LoaderThread::network( ) const { return m_network; } -simil::SimulationData* LoaderThread::simulationData() const +std::shared_ptr< simil::SimulationData > +LoaderThread::simulationData( ) const { return m_data; } -std::string LoaderThread::errors() const +std::string LoaderThread::errors( ) const { return m_errors; } -simil::TDataType LoaderThread::type() const +simil::TDataType LoaderThread::type( ) const { return m_type; } -void LoaderThread::run() +void LoaderThread::run( ) { - emit progress(25); + emit progress( 25 ); try { - switch(m_type) + switch ( m_type ) { case simil::TDataType::TBlueConfig: case simil::TDataType::TCSV: case simil::TDataType::THDF5: - { - auto spikesData = new simil::SpikeData(m_arg1, m_type, m_arg2); - spikesData->reduceDataToGIDS(); - m_data = spikesData; + { + auto spikesData = new simil::SpikeData( m_arg1 , m_type , m_arg2 ); + spikesData->reduceDataToGIDS( ); + m_data = std::unique_ptr< simil::SimulationData >( spikesData ); - emit progress(50); + emit progress( 50 ); - emit network(m_data->positions().size()); - emit spikes(spikesData->spikes().size()); - } + emit network( m_data->positions( ).size( )); + emit spikes( spikesData->spikes( ).size( )); + + } break; case simil::TDataType::TREST: - { + { #ifdef SIMIL_WITH_REST_API - m_rest = new simil::LoaderRestData(); - m_rest->setConfiguration(m_restConfig); + if ( m_rest == nullptr ) + { + m_rest = std::make_unique< Loader >( ); + } - const auto url = m_restConfig.url; - const auto port = std::to_string(m_restConfig.port); - const auto version = m_rest->getVersion(url, m_restConfig.port); + m_rest->setConfiguration( m_restConfig ); - if(version.api.empty() || version.insite.empty()) - { - m_errors = std::string("Unknown protocol connecting to ") - + m_restConfig.url + ":" + std::to_string(m_restConfig.port); - break; - } - - m_network = m_rest->loadNetwork(url, port); - m_data = m_rest->loadSimulationData(url, port); - - unsigned int oldSpikes = 0; - unsigned int oldNetwork = 0; - unsigned int count = 0; - while(count < 5 || oldNetwork < 2) + const auto url = m_restConfig.url; + const auto port = std::to_string( m_restConfig.port ); + const auto version = m_rest->getVersion( url , m_restConfig.port ); + + if ( version.api.empty( ) || version.insite.empty( )) + { + m_errors = std::string( "Unknown protocol connecting to " ) + + m_restConfig.url + ":" + + std::to_string( m_restConfig.port ); + break; + } + + + std::packaged_task< std::unique_ptr< simil::SimulationData >( ) > + simulationTask( + [ this , url , port ]( ) { - QThread::sleep(1); - const auto newNetwork = m_network->gidsSize(); - if(newNetwork != oldNetwork && newNetwork > 2) - { - oldNetwork = newNetwork; - emit network(newNetwork); - } + return m_rest->loadSimulationData( url , port ); + } ); - const auto newSpikes = dynamic_cast<simil::SpikeData *>(m_data)->spikes().size(); - if(oldSpikes != newSpikes) + auto simulationDataFuture = simulationTask.get_future( ); + std::thread simulationThread( std::move( simulationTask )); + + if ( m_network == nullptr ) + { + // The override network is not defined. + // Let's load it! + std::packaged_task< std::unique_ptr< simil::Network >( ) > networkTask( + [ this , url , port ]( ) { - oldSpikes = newSpikes; - emit spikes(newSpikes); - } + return m_rest->loadNetwork( url , port ); + } ); + + auto networkFuture = networkTask.get_future( ); + std::thread networkThread( std::move( networkTask )); + networkThread.join( ); + m_network = networkFuture.get( ); + } - ++count; + simulationThread.join( ); + m_data = simulationDataFuture.get( ); - if(count > 60) - { - m_errors = std::string("Unable to connect to ") - + m_restConfig.url + ":" + std::to_string(m_restConfig.port); - break; - } - } + emit progress( 50 ); + emit network( m_data->positions( ).size( )); - emit progress(50); + if ( auto* ptr = dynamic_cast<simil::SpikeData*>(m_data.get( ))) + { + emit spikes( ptr->spikes( ).size( )); + } #else - m_errors = "REST data loading is unsupported."; + m_errors = "REST data loading is unsupported."; #endif - } + } break; default: case simil::TDataType::TCONE: @@ -165,52 +171,59 @@ void LoaderThread::run() break; } } - catch(const std::exception &ex) + catch ( const std::exception& ex ) { - m_errors = std::string("sumrice::LoaderThread::run() -> ") + std::string(ex.what()); + m_errors = std::string( "sumrice::LoaderThread::run() -> " ) + + std::string( ex.what( )); } - catch(...) + catch ( ... ) { - m_errors = std::string("sumrice::LoaderThread::run() -> Un-handled exception when loading data. "); + m_errors = std::string( + "sumrice::LoaderThread::run() -> Un-handled exception when loading data. " ); } - emit progress(75); + emit progress( 75 ); - if(!m_errors.empty() && m_type != simil::TDataType::TREST) + if ( !m_errors.empty( ) && m_type != simil::TDataType::TREST ) { - m_errors += std::string("\ndata type: ") + std::to_string(static_cast<int>(m_type)); - m_errors += std::string(" argument 1: ") + m_arg1; - m_errors += std::string(" argument 2: ") + m_arg2; + m_errors += std::string( "\ndata type: " ) + + std::to_string( static_cast<int>(m_type)); + m_errors += std::string( " argument 1: " ) + m_arg1; + m_errors += std::string( " argument 2: " ) + m_arg2; } - emit progress(100); + emit progress( 100 ); } #ifdef SIMIL_WITH_REST_API -simil::LoaderRestData *LoaderThread::RESTLoader() + +simil::LoaderRestData* LoaderThread::RESTLoader( ) const { - if(m_type != simil::TDataType::TREST) + if ( m_type != simil::TDataType::TREST ) { - throw std::logic_error("No REST data loader!"); + throw std::logic_error( "No REST data loader!" ); } - return m_rest; + return m_rest.get( ); } -void LoaderThread::setRESTConfiguration(const simil::LoaderRestData::Configuration &config) +void LoaderThread::setRESTConfiguration( + const simil::LoaderRestData::Configuration& config ) { m_type = simil::TDataType::TREST; m_restConfig = config; - if(m_rest) + m_network = config.network.lock(); + + if ( m_rest ) { - m_rest->setConfiguration(m_restConfig); + m_rest->setConfiguration( m_restConfig ); } } #endif -std::string LoaderThread::filename() const +std::string LoaderThread::filename( ) const { return m_arg1; } diff --git a/sumrice/LoaderThread.h b/sumrice/LoaderThread.h index 8d15dbc8144ff4b1ab6dfcee36277a2f5f31eee2..5ff49ebd5bdbfbb50a856c7d53e0f0764a1dd738 100644 --- a/sumrice/LoaderThread.h +++ b/sumrice/LoaderThread.h @@ -39,6 +39,7 @@ // C++ #include <string> +#include <memory> namespace simil { @@ -61,11 +62,6 @@ class SUMRICE_API LoaderThread */ LoaderThread(); - /** \brief LoaderThread virtual destructor. - * - */ - virtual ~LoaderThread(); - /** \brief Set the information for the data to load. If data * is REST use setRESTConfiguration(). * \param[in] type Data origin type. @@ -81,12 +77,12 @@ class SUMRICE_API LoaderThread /** \brief Returns the loaded network data. Only valid after finished() signal. * */ - simil::Network *network() const; + std::shared_ptr<simil::Network> network() const; /** \brief Returns the simulation data. Only valid after finished() signal. * */ - simil::SimulationData* simulationData() const; + std::shared_ptr<simil::SimulationData> simulationData() const; /** \brief Returns an error string or emtpy if success. * @@ -113,7 +109,7 @@ class SUMRICE_API LoaderThread /** \brief Returns the REST loader. * */ - simil::LoaderRestData *RESTLoader(); + simil::LoaderRestData *RESTLoader() const; #endif protected: @@ -128,15 +124,17 @@ class SUMRICE_API LoaderThread simil::TDataType m_type; /** data origin type. */ std::string m_arg1; /** argument 1, meaning depends on type. */ std::string m_arg2; /** argument 2, meaning depends on type. */ - simil::Network* m_network; /** loaded network. */ - simil::SimulationData* m_data; /** loaded data. */ + + std::shared_ptr<simil::Network> m_network; /** loaded network. */ + std::shared_ptr<simil::SimulationData> m_data; /** loaded data. */ + #ifdef SIMIL_WITH_REST_API using Loader = simil::LoaderRestData; - Loader* m_rest; /** rest data importer. */ - Loader::Configuration m_restConfig; /** rest connnection configuration. */ + std::unique_ptr<Loader> m_rest; /** rest data importer. */ + Loader::Configuration m_restConfig; /** rest connnection configuration. */ #endif - std::string m_errors; /** error messages or empty if success. */ + std::string m_errors; /** error messages or empty if success. */ }; #endif /* SUMRICE_LOADERTHREAD_H_ */ diff --git a/sumrice/ReconnectRESTDialog.cpp b/sumrice/ReconnectRESTDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d8b305a01ca3b15d2934886300769d6be2533f5 --- /dev/null +++ b/sumrice/ReconnectRESTDialog.cpp @@ -0,0 +1,43 @@ +// +// Created by grial on 22/02/23. +// + +#include "ReconnectRESTDialog.h" + +#include <QVBoxLayout> +#include <QSplitter> +#include <QDialogButtonBox> + +ReconnectRESTDialog::ReconnectRESTDialog( QWidget* parent , Qt::WindowFlags f ) + : QDialog( parent , f ) +{ + + _spikes = new QRadioButton( "Reload spikes" ); + _both = new QRadioButton( "Reload network and spikes" ); + _newConnection = new QRadioButton( "Create a new connection" ); + + _spikes->setChecked( true ); + + auto* layout = new QVBoxLayout( ); + + layout->addWidget( _spikes ); + layout->addWidget( _both ); + layout->addWidget( _newConnection ); + + auto buttons = new QDialogButtonBox( + QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); + connect( buttons , &QDialogButtonBox::accepted , this , &QDialog::accept ); + connect( buttons , &QDialogButtonBox::rejected , this , &QDialog::reject ); + layout->addWidget( buttons , 0 ); + + setLayout( layout ); + setSizeGripEnabled( false ); + setModal( true ); +} + +ReconnectRESTDialog::Selection ReconnectRESTDialog::getSelection( ) const +{ + if ( _spikes->isChecked( )) return Selection::SPIKES; + if ( _both->isChecked( )) return Selection::SPIKES_AND_NETWORK; + return Selection::NEW_CONNECTION; +} \ No newline at end of file diff --git a/sumrice/ReconnectRESTDialog.h b/sumrice/ReconnectRESTDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..ea7d4299d0907a2783d74410d5c7169e5cdbc7b8 --- /dev/null +++ b/sumrice/ReconnectRESTDialog.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015-2023 VG-Lab/URJC. + * + * Authors: Gael Rial Costas <gael.rial.costas@urjc.es> + * + * This file is part of ViSimpl <https://github.com/vg-lab/visimpl> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3.0 as published + * by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +// +// Created by grial on 22/02/23. +// + +#ifndef VISIMPL_RECONNECTRESTDIALOG_H +#define VISIMPL_RECONNECTRESTDIALOG_H + +#include "ConnectRESTDialog.h" + +#include <QDialog> +#include <QRadioButton> + + +#include <simil/loaders/LoaderRestData.h> + +class ReconnectRESTDialog : public QDialog +{ + +public: + + enum class Selection + { + SPIKES , + SPIKES_AND_NETWORK , + NEW_CONNECTION + }; + +private: + +Q_OBJECT + + QRadioButton* _spikes; + QRadioButton* _both; + QRadioButton* _newConnection; + +public: + + explicit ReconnectRESTDialog( QWidget* parent = nullptr , + Qt::WindowFlags f = Qt::WindowFlags( )); + + Selection getSelection( ) const; + +}; + + +#endif //VISIMPL_RECONNECTRESTDIALOG_H diff --git a/sumrice/StackViz.cpp b/sumrice/StackViz.cpp index 22e4df0d2fb11271bd3876dccf2dabd1f6790616..657e9e6f237e32b4b034c77650fbd3f663195fca 100644 --- a/sumrice/StackViz.cpp +++ b/sumrice/StackViz.cpp @@ -199,7 +199,7 @@ void StackViz::calculateCorrelations(void) { if(!_player || !_subsetEventManager) return; - visimpl::CorrelationComputer cc(dynamic_cast<simil::SpikeData*>(_player->data())); + visimpl::CorrelationComputer cc(dynamic_cast<simil::SpikeData*>(_player->data()->get())); const auto eventNames = _subsetEventManager->eventNames(); diff --git a/sumrice/Summary.cpp b/sumrice/Summary.cpp index dfe0c2da1d237f6bb5a98aa13f6453dd14269120..f1984ee3f09033fd7f7b3829a6b8be508032a5ae 100644 --- a/sumrice/Summary.cpp +++ b/sumrice/Summary.cpp @@ -157,7 +157,7 @@ namespace visimpl this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); } - void Summary::Init( simil::SimulationData* data_ ) + void Summary::Init( std::shared_ptr<simil::SimulationData> data_ ) { _simData = data_; @@ -167,7 +167,7 @@ namespace visimpl { case simil::TSimSpikes: { - auto *spikeData = dynamic_cast< simil::SpikeData * >( _simData ); + auto spikeData = std::dynamic_pointer_cast< simil::SpikeData >( _simData ); _spikeReport = spikeData; break; diff --git a/sumrice/Summary.h b/sumrice/Summary.h index d536a61fc3062a3cdea9cafab985554a9e18c631..d58b76aaa46a068c63712ca4141e0eda0cd63ea9 100644 --- a/sumrice/Summary.h +++ b/sumrice/Summary.h @@ -23,7 +23,9 @@ #ifndef __SIMULATIONSUMMARYWIDGET_H__ #define __SIMULATIONSUMMARYWIDGET_H__ +#include <memory> #include <simil/simil.h> +#include <memory> #include <scoop/scoop.h> #include <sumrice/api.h> @@ -83,7 +85,7 @@ namespace visimpl Summary( QWidget* parent = nullptr, TStackType stackType = T_STACK_FIXED); virtual ~Summary( ){}; - void Init( simil::SimulationData* data_ ); + void Init( std::shared_ptr<simil::SimulationData> data_ ); void AddNewHistogram( const visimpl::Selection& selection #ifdef VISIMPL_USE_ZEROEQ @@ -305,8 +307,8 @@ namespace visimpl unsigned int _gridLinesNumber; - simil::SimulationData* _simData; - simil::SpikeData* _spikeReport; + std::shared_ptr<simil::SimulationData> _simData; + std::shared_ptr<simil::SpikeData> _spikeReport; simil::SimulationPlayer* _player; diff --git a/visimpl/MainWindow.cpp b/visimpl/MainWindow.cpp index cb9706a57612a31ab6c854127ab4693945b035fa..642f850d1269dc4d308bba1be554e125a027f5c0 100644 --- a/visimpl/MainWindow.cpp +++ b/visimpl/MainWindow.cpp @@ -20,6 +20,11 @@ * */ +#include "simil/Network.h" +#include "sumrice/ReconnectRESTDialog.h" +#include <memory> +#include <qdialog.h> + #ifdef VISIMPL_USE_GMRVLEX #include <gmrvlex/version.h> @@ -163,6 +168,10 @@ namespace visimpl , _recorder( nullptr ) , m_loader{ nullptr } , m_loaderDialog{ nullptr } +#ifdef SIMIL_WITH_REST_API + , _restConnectionInformation( ) + , _alreadyConnected( false ) +#endif { _ui->setupUi( this ); @@ -172,7 +181,7 @@ namespace visimpl _ui->toolBar->addAction( recorderAction ); connect( recorderAction , SIGNAL( triggered( bool )) , - this , SLOT( openRecorder( )) ); + this , SLOT( openRecorder( ))); _ui->actionUpdateOnIdle->setChecked( updateOnIdle ); _ui->actionShowFPSOnIdleUpdate->setChecked( false ); @@ -231,42 +240,42 @@ namespace visimpl _openGLWidget->idleUpdate( _ui->actionUpdateOnIdle->isChecked( )); connect( _ui->actionUpdateOnIdle , SIGNAL( triggered( void )) , - _openGLWidget , SLOT( toggleUpdateOnIdle( void )) ); + _openGLWidget , SLOT( toggleUpdateOnIdle( void ))); connect( _ui->actionBackgroundColor , SIGNAL( triggered( void )) , - _openGLWidget , SLOT( changeClearColor( void )) ); + _openGLWidget , SLOT( changeClearColor( void ))); connect( _openGLWidget , SIGNAL( planesColorChanged( const QColor & )) , this , SLOT( changePlanesColor( - const QColor & )) ); + const QColor & ))); connect( _ui->actionShowFPSOnIdleUpdate , SIGNAL( triggered( void )) , - _openGLWidget , SLOT( toggleShowFPS( void )) ); + _openGLWidget , SLOT( toggleShowFPS( void ))); connect( _ui->actionShowEventsActivity , SIGNAL( triggered( bool )) , - _openGLWidget , SLOT( showEventsActivityLabels( bool )) ); + _openGLWidget , SLOT( showEventsActivityLabels( bool ))); connect( _ui->actionShowCurrentTime , SIGNAL( triggered( bool )) , - _openGLWidget , SLOT( showCurrentTimeLabel( bool )) ); + _openGLWidget , SLOT( showCurrentTimeLabel( bool ))); connect( _ui->actionOpenBlueConfig , SIGNAL( triggered( void )) , this , - SLOT( openBlueConfigThroughDialog( void )) ); + SLOT( openBlueConfigThroughDialog( void ))); connect( _ui->actionOpenCSVFiles , SIGNAL( triggered( void )) , this , - SLOT( openCSVFilesThroughDialog( void )) ); + SLOT( openCSVFilesThroughDialog( void ))); connect( _ui->actionOpenH5Files , SIGNAL( triggered( void )) , this , - SLOT( openHDF5ThroughDialog( void )) ); + SLOT( openHDF5ThroughDialog( void ))); connect( _ui->actionConnectREST , SIGNAL( triggered( void )) , this , - SLOT( openRESTThroughDialog( )) ); + SLOT( openRESTThroughDialog( ))); connect( _ui->actionConfigureREST , SIGNAL( triggered( )) , this , - SLOT( configureREST( )) ); + SLOT( configureREST( ))); connect( _ui->actionOpenSubsetEventsFile , SIGNAL( triggered( void )) , - this , SLOT( openSubsetEventsFileThroughDialog( void )) ); + this , SLOT( openSubsetEventsFileThroughDialog( void ))); _ui->actionOpenSubsetEventsFile->setEnabled( false ); @@ -275,44 +284,44 @@ namespace visimpl #endif connect( _ui->actionCloseData , SIGNAL( triggered( void )) , this , - SLOT( closeData( void )) ); + SLOT( closeData( void ))); connect( _ui->actionQuit , SIGNAL( triggered( void )) , this , - SLOT( close( )) ); + SLOT( close( ))); connect( _ui->actionAbout , SIGNAL( triggered( void )) , this , - SLOT( dialogAbout( void )) ); + SLOT( dialogAbout( void ))); connect( _ui->actionHome , SIGNAL( triggered( void )) , _openGLWidget , - SLOT( home( void )) ); + SLOT( home( void ))); connect( _openGLWidget , SIGNAL( stepCompleted( void )) , this , - SLOT( completedStep( void )) ); + SLOT( completedStep( void ))); connect( _openGLWidget , SIGNAL( pickedSingle( unsigned int )) , this , - SLOT( updateSelectedStatsPickingSingle( unsigned int )) ); + SLOT( updateSelectedStatsPickingSingle( unsigned int ))); connect( _ui->actionAdd_camera_position , SIGNAL( triggered( bool )) , this , - SLOT( addCameraPosition( )) ); + SLOT( addCameraPosition( ))); connect( _ui->actionRemove_camera_position , SIGNAL( triggered( bool )) , this , - SLOT( removeCameraPosition( )) ); + SLOT( removeCameraPosition( ))); connect( _ui->actionLoad_camera_positions , SIGNAL( triggered( bool )) , this , - SLOT( loadCameraPositions( )) ); + SLOT( loadCameraPositions( ))); connect( _ui->actionSave_camera_positions , SIGNAL( triggered( bool )) , this , - SLOT( saveCameraPositions( )) ); + SLOT( saveCameraPositions( ))); QAction* actionTogglePause = new QAction( this ); actionTogglePause->setShortcut( Qt::Key_Space ); connect( actionTogglePause , SIGNAL( triggered( )) , this , - SLOT( PlayPause( )) ); + SLOT( PlayPause( ))); addAction( actionTogglePause ); #ifdef VISIMPL_USE_ZEROEQ @@ -538,7 +547,7 @@ namespace visimpl _subsetEvents->loadJSON( filePath ); } else if ( eventsFile.suffix( ).toLower( ).compare( "h5" ) == 0 || - eventsFile.suffix( ).toLower( ).compare( "hdf5" ) == 0) + eventsFile.suffix( ).toLower( ).compare( "hdf5" ) == 0 ) { _subsetEvents->loadH5( filePath ); h5 = true; @@ -631,11 +640,11 @@ namespace visimpl { _recorder = dialog.getRecorder( ); connect( _recorder , SIGNAL( finished( )) , - _recorder , SLOT( deleteLater( )) ); + _recorder , SLOT( deleteLater( ))); connect( _recorder , SIGNAL( finished( )) , - this , SLOT( finishRecording( )) ); + this , SLOT( finishRecording( ))); connect( _openGLWidget , SIGNAL( frameSwapped( )) , - _recorder , SLOT( takeFrame( )) ); + _recorder , SLOT( takeFrame( ))); if ( action ) action->setChecked( true ); } else @@ -647,6 +656,7 @@ namespace visimpl void MainWindow::closeData( void ) { #ifdef SIMIL_WITH_REST_API + _alreadyConnected = false; if ( m_loader && m_loader->type( ) == simil::TREST ) { CloseDataDialog dialog( this ); @@ -662,9 +672,6 @@ namespace visimpl _objectInspectorGB->setCheckUpdates( false ); - auto rest = m_loader->RESTLoader( ); - rest->resetSpikes( ); - _summary->UpdateHistograms( ); _stackViz->updateHistograms( ); @@ -831,7 +838,7 @@ namespace visimpl void MainWindow::_configurePlayer( void ) { connect( _openGLWidget , SIGNAL( updateSlider( float )) , this , - SLOT( UpdateSimulationSlider( float )) ); + SLOT( UpdateSimulationSlider( float ))); _objectInspectorGB->setSimPlayer( _openGLWidget->player( )); @@ -898,32 +905,32 @@ namespace visimpl this->addDockWidget( Qt::LeftDockWidgetArea , _stackVizDock ); connect( _objectInspectorGB , SIGNAL( simDataChanged( )) , - _stackViz , SLOT( updateHistograms( )) ); + _stackViz , SLOT( updateHistograms( ))); connect( _stackViz , SIGNAL( changedBins( const unsigned int)) , - _summary , SLOT( bins( unsigned int )) ); + _summary , SLOT( bins( unsigned int ))); connect( _ui->actionStackVizShowDataManager , SIGNAL( triggered( bool )) , - _stackViz , SLOT( showDisplayManagerWidget( )) ); + _stackViz , SLOT( showDisplayManagerWidget( ))); connect( _ui->actionStackVizShowPanels , SIGNAL( triggered( bool )) , - _stackViz , SLOT( showStackVizPanels( bool )) ); + _stackViz , SLOT( showStackVizPanels( bool ))); connect( _ui->actionStackVizShowDataManager , SIGNAL( triggered( bool )) , - _stackViz , SLOT( showDisplayManagerWidget( )) ); + _stackViz , SLOT( showDisplayManagerWidget( ))); connect( _ui->actionStackVizAutoNamingSelections , SIGNAL( triggered( )) , - _stackViz , SLOT( toggleAutoNameSelections( )) ); + _stackViz , SLOT( toggleAutoNameSelections( ))); connect( _ui->actionStackVizFillPlots , SIGNAL( triggered( bool )) , - _stackViz , SLOT( fillPlots( bool )) ); + _stackViz , SLOT( fillPlots( bool ))); connect( _ui->actionStackVizFocusOnPlayhead , SIGNAL( triggered( )) , - _stackViz , SLOT( focusPlayback( )) ); + _stackViz , SLOT( focusPlayback( ))); connect( _ui->actionStackVizFollowPlayHead , SIGNAL( triggered( bool )) , - _stackViz , SLOT( followPlayhead( bool )) ); + _stackViz , SLOT( followPlayhead( bool ))); // this avoids making the dock smaller when the stackviz config panels // hide. @@ -991,21 +998,21 @@ namespace visimpl dockLayout->addWidget( nextButton , row , 12 , 1 , 1 ); dockLayout->addWidget( _goToButton , row , 13 , 1 , 1 ); - connect( _playButton , SIGNAL( clicked( )) , this , SLOT( PlayPause( )) ); + connect( _playButton , SIGNAL( clicked( )) , this , SLOT( PlayPause( ))); - connect( stopButton , SIGNAL( clicked( )) , this , SLOT( Stop( )) ); + connect( stopButton , SIGNAL( clicked( )) , this , SLOT( Stop( ))); - connect( nextButton , SIGNAL( clicked( )) , this , SLOT( NextStep( )) ); + connect( nextButton , SIGNAL( clicked( )) , this , SLOT( NextStep( ))); - connect( prevButton , SIGNAL( clicked( )) , this , SLOT( PreviousStep( )) ); + connect( prevButton , SIGNAL( clicked( )) , this , SLOT( PreviousStep( ))); - connect( _repeatButton , SIGNAL( clicked( )) , this , SLOT( Repeat( )) ); + connect( _repeatButton , SIGNAL( clicked( )) , this , SLOT( Repeat( ))); connect( _simSlider , SIGNAL( sliderPressed( )) , this , - SLOT( PlayAtPosition( )) ); + SLOT( PlayAtPosition( ))); connect( _goToButton , SIGNAL( clicked( )) , this , - SLOT( playAtButtonClicked( )) ); + SLOT( playAtButtonClicked( ))); _summary = new visimpl::Summary( nullptr , visimpl::T_STACK_FIXED ); _summary->setMinimumHeight( 50 ); @@ -1016,7 +1023,7 @@ namespace visimpl this->addDockWidget( Qt::BottomDockWidgetArea , _simulationDock ); connect( _summary , SIGNAL( histogramClicked( float )) , this , - SLOT( PlayAtPercentage( float )) ); + SLOT( PlayAtPercentage( float ))); _simulationDock->setEnabled( false ); } @@ -1045,7 +1052,7 @@ namespace visimpl _selectionManager->setWindowIcon( QIcon( ":/visimpl.png" )); connect( _selectionManager , SIGNAL( selectionChanged( void )) , this , - SLOT( selectionManagerChanged( void )) ); + SLOT( selectionManagerChanged( void ))); _deltaTimeBox = new QDoubleSpinBox( ); _deltaTimeBox->setMinimum( 0.00000001 ); @@ -1114,7 +1121,8 @@ namespace visimpl clippingColor.name( )); _frameClippingColor->setMinimumSize( 20 , 20 ); _frameClippingColor->setMaximumSize( 20 , 20 ); - _frameClippingColor->setProperty( PLANES_COLOR_KEY_ , clippingColor.name( )); + _frameClippingColor->setProperty( PLANES_COLOR_KEY_ , + clippingColor.name( )); _buttonSelectionFromClippingPlanes = new QPushButton( "To selection" ); _buttonSelectionFromClippingPlanes->setToolTip( @@ -1375,13 +1383,13 @@ namespace visimpl _toolBoxOptions->addItem( _objectInspectorGB , tr( "Inspector" )); connect( _objectInspectorGB , SIGNAL( simDataChanged( )) , - _openGLWidget , SLOT( updateData( )) ); + _openGLWidget , SLOT( updateData( ))); connect( _objectInspectorGB , SIGNAL( simDataChanged( )) , - _summary , SLOT( UpdateHistograms( )) ); + _summary , SLOT( UpdateHistograms( ))); connect( _objectInspectorGB , SIGNAL( simDataChanged( )) , - this , SLOT( configureComponents( )) ); + this , SLOT( configureComponents( ))); verticalLayout->setAlignment( Qt::AlignTop ); verticalLayout->addWidget( _modeSelectionWidget ); @@ -1393,98 +1401,98 @@ namespace visimpl this->addDockWidget( Qt::RightDockWidgetArea , _simConfigurationDock ); connect( _modeSelectionWidget , SIGNAL( currentChanged( int )) , - _openGLWidget , SLOT( setMode( int )) ); + _openGLWidget , SLOT( setMode( int ))); connect( _openGLWidget , SIGNAL( attributeStatsComputed( void )) , this , - SLOT( updateAttributeStats( void )) ); + SLOT( updateAttributeStats( void ))); connect( _comboAttribSelection , SIGNAL( currentIndexChanged( int )) , - _openGLWidget , SLOT( selectAttrib( int )) ); + _openGLWidget , SLOT( selectAttrib( int ))); connect( comboShader , SIGNAL( currentIndexChanged( int )) , _openGLWidget , - SLOT( changeShader( int )) ); + SLOT( changeShader( int ))); connect( _tfWidget , SIGNAL( colorChanged( void )) , this , - SLOT( UpdateSimulationColorMapping( void )) ); + SLOT( UpdateSimulationColorMapping( void ))); connect( _tfWidget , SIGNAL( sizeChanged( void )) , this , - SLOT( UpdateSimulationSizeFunction( void )) ); + SLOT( UpdateSimulationSizeFunction( void ))); connect( _tfWidget , SIGNAL( previewColor( void )) , this , - SLOT( PreviewSimulationColorMapping( void )) ); + SLOT( PreviewSimulationColorMapping( void ))); connect( _tfWidget , SIGNAL( previewColor( void )) , this , - SLOT( PreviewSimulationSizeFunction( void )) ); + SLOT( PreviewSimulationSizeFunction( void ))); connect( buttonSelectionManager , SIGNAL( clicked( void )) , this , - SLOT( dialogSelectionManagement( void )) ); + SLOT( dialogSelectionManagement( void ))); connect( _circuitScaleX , SIGNAL( valueChanged( double )) , this , - SLOT( updateCircuitScaleValue( void )) ); + SLOT( updateCircuitScaleValue( void ))); connect( _circuitScaleY , SIGNAL( valueChanged( double )) , this , - SLOT( updateCircuitScaleValue( void )) ); + SLOT( updateCircuitScaleValue( void ))); connect( _circuitScaleZ , SIGNAL( valueChanged( double )) , this , - SLOT( updateCircuitScaleValue( void )) ); + SLOT( updateCircuitScaleValue( void ))); connect( _deltaTimeBox , SIGNAL( valueChanged( double )) , this , - SLOT( updateSimDeltaTime( void )) ); + SLOT( updateSimDeltaTime( void ))); connect( _timeStepsPSBox , SIGNAL( valueChanged( double )) , this , - SLOT( updateSimTimestepsPS( void )) ); + SLOT( updateSimTimestepsPS( void ))); connect( _decayBox , SIGNAL( valueChanged( double )) , this , - SLOT( updateSimulationDecayValue( void )) ); + SLOT( updateSimulationDecayValue( void ))); connect( _stepByStepDurationBox , SIGNAL( valueChanged( double )) , this , - SLOT( updateSimStepByStepDuration( void )) ); + SLOT( updateSimStepByStepDuration( void ))); connect( _alphaNormalButton , SIGNAL( toggled( bool )) , this , - SLOT( AlphaBlendingToggled( void )) ); + SLOT( AlphaBlendingToggled( void ))); // Clipping planes _checkClipping->setChecked( true ); connect( _checkClipping , SIGNAL( stateChanged( int )) , this , - SLOT( clippingPlanesActive( int )) ); + SLOT( clippingPlanesActive( int ))); _checkClipping->setChecked( false ); _checkShowPlanes->setChecked( true ); connect( _checkShowPlanes , SIGNAL( stateChanged( int )) , _openGLWidget , - SLOT( paintClippingPlanes( int )) ); + SLOT( paintClippingPlanes( int ))); connect( _buttonSelectionFromClippingPlanes , SIGNAL( clicked( void )) , - this , SLOT( selectionFromPlanes( void )) ); + this , SLOT( selectionFromPlanes( void ))); connect( _buttonResetPlanes , SIGNAL( clicked( void )) , this , - SLOT( clippingPlanesReset( void )) ); + SLOT( clippingPlanesReset( void ))); connect( _spinBoxClippingDist , SIGNAL( editingFinished( void )) , this , - SLOT( spinBoxValueChanged( void )) ); + SLOT( spinBoxValueChanged( void ))); connect( _spinBoxClippingHeight , SIGNAL( editingFinished( void )) , this , - SLOT( spinBoxValueChanged( void )) ); + SLOT( spinBoxValueChanged( void ))); connect( _spinBoxClippingWidth , SIGNAL( editingFinished( void )) , this , - SLOT( spinBoxValueChanged( void )) ); + SLOT( spinBoxValueChanged( void ))); connect( _frameClippingColor , SIGNAL( clicked( )) , this , - SLOT( colorSelectionClicked( )) ); + SLOT( colorSelectionClicked( ))); connect( _buttonClearSelection , SIGNAL( clicked( void )) , this , - SLOT( clearSelection( void )) ); + SLOT( clearSelection( void ))); connect( _buttonAddGroup , SIGNAL( clicked( void )) , this , - SLOT( addGroupFromSelection( )) ); + SLOT( addGroupFromSelection( ))); connect( _buttonImportGroups , SIGNAL( clicked( void )) , this , - SLOT( dialogSubsetImporter( void )) ); + SLOT( dialogSubsetImporter( void ))); connect( _buttonClearGroups , SIGNAL( clicked( void )) , this , - SLOT( clearGroups( void )) ); + SLOT( clearGroups( void ))); connect( _buttonLoadGroups , SIGNAL( clicked( void )) , this , - SLOT( loadGroups( )) ); + SLOT( loadGroups( ))); connect( _buttonSaveGroups , SIGNAL( clicked( void )) , this , - SLOT( saveGroups( )) ); + SLOT( saveGroups( ))); _alphaNormalButton->setChecked( true ); _simConfigurationDock->setEnabled( false ); @@ -1585,9 +1593,9 @@ namespace visimpl _circuitScaleY->blockSignals( true ); _circuitScaleZ->blockSignals( true ); - _circuitScaleX->setValue(scaleFactor.x); - _circuitScaleY->setValue(scaleFactor.y); - _circuitScaleZ->setValue(scaleFactor.z); + _circuitScaleX->setValue( scaleFactor.x ); + _circuitScaleY->setValue( scaleFactor.y ); + _circuitScaleZ->setValue( scaleFactor.z ); _circuitScaleX->blockSignals( true ); _circuitScaleY->blockSignals( true ); @@ -1620,7 +1628,8 @@ namespace visimpl void MainWindow::updateCircuitScaleValue( void ) { - vec3 scale{ _circuitScaleX->value( ), _circuitScaleY->value( ), _circuitScaleZ->value( )}; + vec3 scale{ _circuitScaleX->value( ) , _circuitScaleY->value( ) , + _circuitScaleZ->value( ) }; _openGLWidget->circuitScaleFactor( scale ); } @@ -1969,8 +1978,8 @@ namespace visimpl void MainWindow::addGroupControls( std::shared_ptr< VisualGroup > group , unsigned int currentIndex , - unsigned int size, - QColor groupColor) + unsigned int size , + QColor groupColor ) { QWidget* container = new QWidget( ); auto itemLayout = new QHBoxLayout( container ); @@ -1978,7 +1987,7 @@ namespace visimpl container->setProperty( GROUP_NAME_ , QString::fromStdString( group->name( ))); - if(groupColor == QColor{0,0,0}) + if ( groupColor == QColor{ 0 , 0 , 0 } ) { const auto colors = _openGLWidget->colorPalette( ).colors( ); const auto paletteIdx = currentIndex % colors.size( ); @@ -2012,24 +2021,25 @@ namespace visimpl const auto presetName = QString( "Group selection %1" ).arg( currentIndex ); QGradientStops stops; - const auto mapping = group->colorMapping(); - auto addColorMapping = [&stops](const visimpl::TTFColor &c){ stops << qMakePair(c.first, c.second); }; - std::for_each(mapping.cbegin(), mapping.cend(), addColorMapping); + const auto mapping = group->colorMapping( ); + auto addColorMapping = [ &stops ]( const visimpl::TTFColor& c ) + { stops << qMakePair( c.first , c.second ); }; + std::for_each( mapping.cbegin( ) , mapping.cend( ) , addColorMapping ); tfWidget->addPreset( TransferFunctionWidget::Preset( presetName , stops )); connect( tfWidget , SIGNAL( colorChanged( )) , - this , SLOT( onGroupColorChanged( )) ); + this , SLOT( onGroupColorChanged( ))); connect( tfWidget , SIGNAL( sizeChanged( )) , - this , SLOT( onGroupColorChanged( )) ); + this , SLOT( onGroupColorChanged( ))); connect( tfWidget , SIGNAL( previewColor( )) , - this , SLOT( onGroupPreview( )) ); + this , SLOT( onGroupPreview( ))); QCheckBox* visibilityCheckbox = new QCheckBox( "active" ); visibilityCheckbox->setChecked( group->active( )); connect( visibilityCheckbox , SIGNAL( clicked( )) , this , - SLOT( checkGroupsVisibility( )) ); + SLOT( checkGroupsVisibility( ))); QString numberText = QString( "# " ).append( QString::number( size )); @@ -2040,14 +2050,14 @@ namespace visimpl QString::fromStdString( group->name( ))); connect( nameButton , SIGNAL( clicked( )) , this , - SLOT( onGroupNameClicked( )) ); + SLOT( onGroupNameClicked( ))); auto deleteButton = new QPushButton( QIcon( ":/icons/close.svg" ) , "" ); deleteButton->setProperty( GROUP_NAME_ , QString::fromStdString( group->name( ))); connect( deleteButton , SIGNAL( clicked( )) , this , - SLOT( onGroupDeleteClicked( )) ); + SLOT( onGroupDeleteClicked( ))); auto firstLayout = new QHBoxLayout( ); firstLayout->setMargin( 0 ); @@ -2129,10 +2139,11 @@ namespace visimpl filteredGIDs , _openGLWidget->getGidPositions( ) , groupName ); const auto color = _subsetEvents->getSubsetColor( groupName ); - QColor groupColor = QColor::fromRgbF(color.x(), color.y(), color.z()); + QColor groupColor = QColor::fromRgbF( color.x( ) , color.y( ) , + color.z( )); addGroupControls( group , _domainManager->getGroupAmount( ) - 1 , - filteredGIDs.size( ), groupColor); + filteredGIDs.size( ) , groupColor ); visimpl::Selection selection; selection.name = groupName; @@ -2429,7 +2440,7 @@ namespace visimpl { auto groupName = tfw->property( GROUP_NAME_ ).toString( ); updateGroup( groupName.toStdString( ) , tfw->getColors( ) , - tfw->getSizeFunction( )); + tfw->getSizeFunction( )); } } @@ -2443,13 +2454,13 @@ namespace visimpl if ( !ok ) return; updateGroup( groupName.toStdString( ) , tfw->getPreviewColors( ) , - tfw->getSizePreview( )); + tfw->getSizePreview( )); } } void MainWindow::updateGroup( std::string name , const TTransferFunction& t , - const TSizeFunction& s ) + const TSizeFunction& s ) { const auto& groups = _domainManager->getGroups( ); groups.at( name )->colorMapping( t ); @@ -2481,13 +2492,13 @@ namespace visimpl m_loader->setData( type , arg_1 , arg_2 ); connect( m_loader.get( ) , SIGNAL( finished( )) , - this , SLOT( onDataLoaded( )) ); + this , SLOT( onDataLoaded( ))); connect( m_loader.get( ) , SIGNAL( progress( int )) , - m_loaderDialog , SLOT( setProgress( int )) ); + m_loaderDialog , SLOT( setProgress( int ))); connect( m_loader.get( ) , SIGNAL( network( unsigned int )) , - m_loaderDialog , SLOT( setNetwork( unsigned int )) ); + m_loaderDialog , SLOT( setNetwork( unsigned int ))); connect( m_loader.get( ) , SIGNAL( spikes( unsigned int )) , - m_loaderDialog , SLOT( setSpikesValue( unsigned int )) ); + m_loaderDialog , SLOT( setSpikesValue( unsigned int ))); _lastOpenedNetworkFileName = QString::fromStdString( arg_1 ); _lastOpenedSubsetsFileName = QString::fromStdString( subsetEventFile ); @@ -2507,12 +2518,12 @@ namespace visimpl void MainWindow::onDataLoaded( ) { - setWindowTitle("SimPart"); + setWindowTitle( "SimPart" ); if ( !m_loader ) return; const auto error = m_loader->errors( ); - const auto filename = QString::fromStdString(m_loader->filename()); + const auto filename = QString::fromStdString( m_loader->filename( )); if ( !error.empty( )) { closeLoadingDialog( ); @@ -2540,7 +2551,7 @@ namespace visimpl player = new simil::SpikesPlayer( ); player->LoadData( spikeData ); - _subsetEvents = spikeData->subsetsEvents(); + _subsetEvents = spikeData->subsetsEvents( ); m_loader = nullptr; } @@ -2555,7 +2566,7 @@ namespace visimpl _subsetEvents = netData->subsetsEvents( ); - // NOTE: loader doesn't get destroyed because has a loop for getting data. + m_loader = nullptr; } break; case simil::TDataUndefined: @@ -2592,7 +2603,7 @@ namespace visimpl m_loaderDialog->repaint( ); } - setWindowTitle("SimPart - " + filename); + setWindowTitle( "SimPart - " + filename ); _openGLWidget->setPlayer( player , dataType ); _modeSelectionWidget->setCurrentIndex( 0 ); @@ -2626,10 +2637,10 @@ namespace visimpl case simil::TDataType::TREST: { #ifdef SIMIL_WITH_REST_API - const auto waitTime = m_loader->RESTLoader( )->getConfiguration( ).waitTime; - _objectInspectorGB->setCheckTimer( waitTime ); - _objectInspectorGB->setCheckUpdates( true ); - _ui->actionConfigureREST->setEnabled( true ); + //const auto waitTime = m_loader->RESTLoader( )->getConfiguration( ).waitTime; + //_objectInspectorGB->setCheckTimer( waitTime ); + //_objectInspectorGB->setCheckUpdates( true ); + //_ui->actionConfigureREST->setEnabled( true ); #endif } break; @@ -3027,7 +3038,7 @@ namespace visimpl void MainWindow::removeVisualGroup( const QString& name ) { - auto findGroup = [ this , name ]( tGroupRow& r ) + auto findGroup = [ name ]( tGroupRow& r ) { QWidget* container = std::get< gr_container >( r ); auto groupName = container->property( GROUP_NAME_ ).toString( ); @@ -3226,7 +3237,7 @@ namespace visimpl position + ";" + radius + ";" + rotation ); connect( action , SIGNAL( triggered( bool )) , this , - SLOT( applyCameraPosition( )) ); + SLOT( applyCameraPosition( ))); _ui->actionCamera_Positions->menu( )->addAction( action ); }; @@ -3367,7 +3378,7 @@ namespace visimpl QLineEdit::Normal , tr( "New position" ) , &ok ); - if(!ok) return; // user cancelled + if ( !ok ) return; // user cancelled if ( ok && !name.isEmpty( )) { @@ -3389,7 +3400,7 @@ namespace visimpl action->setProperty( POSITION_KEY_ , position.toString( )); connect( action , SIGNAL( triggered( bool )) , this , - SLOT( applyCameraPosition( )) ); + SLOT( applyCameraPosition( ))); _ui->actionCamera_Positions->menu( )->addAction( action ); _ui->actionCamera_Positions->setEnabled( true ); _ui->actionSave_camera_positions->setEnabled( true ); @@ -3441,7 +3452,30 @@ namespace visimpl void MainWindow::openRESTThroughDialog( ) { #ifdef SIMIL_WITH_REST_API + + if ( _alreadyConnected && _openGLWidget->player( ) != nullptr ) + { + auto player = _openGLWidget->player( ); + ReconnectRESTDialog dialog( this ); + if ( dialog.exec( ) == QDialog::Rejected ) + return; + + if ( dialog.getSelection( ) != + ReconnectRESTDialog::Selection::NEW_CONNECTION ) + { + _restConnectionInformation.network = + dialog.getSelection( ) == + ReconnectRESTDialog::Selection::SPIKES_AND_NETWORK + ? std::weak_ptr< simil::Network >( ) + : player->getNetwork( ); + + loadRESTData( _restConnectionInformation ); + return; + } + } + ConnectRESTDialog dialog( this ); + ConnectRESTDialog::Connection connection; dialog.setRESTConnection( connection ); @@ -3461,6 +3495,9 @@ namespace visimpl config.failTime = restOpt.failTime; config.spikesSize = restOpt.spikesSize; + _restConnectionInformation = config; + _alreadyConnected = true; + loadRESTData( config ); } #else diff --git a/visimpl/MainWindow.h b/visimpl/MainWindow.h index ae8d8548251130dab36f9a64e6479a7b6348d1e9..3e15664e6697c9804d263bf2b76305857c4e5a10 100644 --- a/visimpl/MainWindow.h +++ b/visimpl/MainWindow.h @@ -20,6 +20,7 @@ * */ +#include "sumrice/ConnectRESTDialog.h" #ifdef WIN32 #include <winsock2.h> #endif @@ -223,8 +224,8 @@ namespace visimpl void addGroupControls( std::shared_ptr< VisualGroup > group , unsigned int index , - unsigned int size, - QColor groupColor = QColor{0,0,0}); + unsigned int size , + QColor groupColor = QColor{ 0 , 0 , 0 } ); void clearGroups( void ); @@ -266,7 +267,7 @@ namespace visimpl * \param[in] name Name of the group to remove. * */ - void removeVisualGroup(const QString &name ); + void removeVisualGroup( const QString& name ); void selectionManagerChanged( void ); @@ -362,7 +363,7 @@ namespace visimpl * */ void updateGroup( std::string name , const TTransferFunction& t , - const TSizeFunction& s ); + const TSizeFunction& s ); virtual void closeEvent( QCloseEvent* e ) override; @@ -374,16 +375,16 @@ namespace visimpl #ifdef VISIMPL_USE_ZEROEQ #ifdef VISIMPL_USE_GMRVLEX - protected slots: + protected slots: - void ApplyPlaybackOperation( unsigned int playbackOp ); + void ApplyPlaybackOperation( unsigned int playbackOp ); - void _zeqEventRepeat( bool repeat ); + void _zeqEventRepeat( bool repeat ); #endif - protected: - void _onSelectionEvent( lexis::data::ConstSelectedIDsPtr ); + protected: + void _onSelectionEvent( lexis::data::ConstSelectedIDsPtr ); #endif // VISIMPL_USE_ZEROEQ @@ -486,5 +487,13 @@ namespace visimpl std::shared_ptr< LoaderThread > m_loader; /** data loader thread. */ LoadingDialog* m_loaderDialog; /** data loader dialog. */ + +#ifdef SIMIL_WITH_REST_API + + simil::LoaderRestData::Configuration _restConnectionInformation; + bool _alreadyConnected; + +#endif + }; } // namespace visimpl