diff --git a/.gitsubprojects b/.gitsubprojects index d0bb5bc511e1e0322521f27b26972747897561ca..7f7fdc34544f967a63434005e4fc6978e9772efc 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 bbc4bd7f ) +git_subproject( SimIL https://github.com/gmrvvis/SimIL.git 5df45828 ) 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 266b12686ba6692a87025029d893fb051a95acc1..437689be8e8785cf2e78b10f128c923c66465c2f 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.3 ) +project( visimpl VERSION 1.8.4 ) set( visimpl_VERSION_ABI 6 ) SET( VISIMPL_LICENSE "GPL") diff --git a/sumrice/LoaderThread.cpp b/sumrice/LoaderThread.cpp index a94fe263161de0b5531aaeb4bb92a10e75f79b87..ed79b6bb91ddc44c64da5a8fc5e6a295a487be01 100644 --- a/sumrice/LoaderThread.cpp +++ b/sumrice/LoaderThread.cpp @@ -207,4 +207,10 @@ void LoaderThread::setRESTConfiguration(const simil::LoaderRestData::Configurati m_rest->setConfiguration(m_restConfig); } } + #endif + +std::string LoaderThread::filename() const +{ + return m_arg1; +} diff --git a/sumrice/LoaderThread.h b/sumrice/LoaderThread.h index daf5fce86be61dc9c2d6ca5a9a43d8100902fc99..8d15dbc8144ff4b1ab6dfcee36277a2f5f31eee2 100644 --- a/sumrice/LoaderThread.h +++ b/sumrice/LoaderThread.h @@ -98,6 +98,11 @@ class SUMRICE_API LoaderThread */ simil::TDataType type() const; + /** \brief Returns the name of the file loaded. + * + */ + std::string filename() const; + #ifdef SIMIL_WITH_REST_API /** \brief Sets the REST loader protocol configuration. * \param[in] o REST protocol configuration. diff --git a/visimpl/DomainManager.cpp b/visimpl/DomainManager.cpp index f3be64bddd82bd25f2a6c28fdd732d8cd7b8bdab..10816a9ac1a638c9e5140f1248187d978e6a56dc 100644 --- a/visimpl/DomainManager.cpp +++ b/visimpl/DomainManager.cpp @@ -47,8 +47,8 @@ namespace visimpl colors.emplace_back( 1.0f , glm::vec4( 0.0f , 0.0f , 1.0f , 0.5f )); TSizeFunction sizes; - sizes.emplace_back( 0.0f , 8.0f ); - sizes.emplace_back( 1.0f , 6.0f ); + sizes.emplace_back( 0.0f , 6.0f ); + sizes.emplace_back( 1.0f , 18.0f ); _selectionModel = std::make_shared< StaticGradientModel >( camera , leftPlane , rightPlane , sizes , colors , @@ -326,6 +326,9 @@ namespace visimpl _currentRenderer , _selectionModel->isClippingEnabled( )); + const TSizeFunction defaultSizes{ { 0.0f , 50.0f }, { 1.0f , 15.0f } }; + + group->getModel()->setParticleSize(defaultSizes); group->getModel( )->setAccumulativeMode( _accumulativeMode ); std::vector< uint32_t > ids; diff --git a/visimpl/MainWindow.cpp b/visimpl/MainWindow.cpp index f5a2b14e8d9949d293d7a858f161bb9e7a96c96b..5e5d534c31389281245d0c3c6feb1673d56f0b32 100644 --- a/visimpl/MainWindow.cpp +++ b/visimpl/MainWindow.cpp @@ -1581,6 +1581,18 @@ namespace visimpl void MainWindow::setCircuitSizeScaleFactor( vec3 scaleFactor ) { + _circuitScaleX->blockSignals( true ); + _circuitScaleY->blockSignals( true ); + _circuitScaleZ->blockSignals( true ); + + _circuitScaleX->setValue(scaleFactor.x); + _circuitScaleY->setValue(scaleFactor.y); + _circuitScaleZ->setValue(scaleFactor.z); + + _circuitScaleX->blockSignals( true ); + _circuitScaleY->blockSignals( true ); + _circuitScaleZ->blockSignals( true ); + _openGLWidget->circuitScaleFactor( scaleFactor ); } @@ -1608,12 +1620,7 @@ namespace visimpl void MainWindow::updateCircuitScaleValue( void ) { - auto scale = _openGLWidget->circuitScaleFactor( ); - - scale.x = _circuitScaleX->value( ); - scale.y = _circuitScaleY->value( ); - scale.z = _circuitScaleZ->value( ); - + vec3 scale{ _circuitScaleX->value( ), _circuitScaleY->value( ), _circuitScaleZ->value( )}; _openGLWidget->circuitScaleFactor( scale ); } @@ -1962,7 +1969,8 @@ namespace visimpl void MainWindow::addGroupControls( std::shared_ptr< VisualGroup > group , unsigned int currentIndex , - unsigned int size ) + unsigned int size, + QColor groupColor) { QWidget* container = new QWidget( ); auto itemLayout = new QHBoxLayout( container ); @@ -1970,15 +1978,27 @@ namespace visimpl container->setProperty( GROUP_NAME_ , QString::fromStdString( group->name( ))); - const auto colors = _openGLWidget->colorPalette( ).colors( ); - const auto paletteIdx = currentIndex % colors.size( ); - const auto color = colors[ paletteIdx ].toRgb( ); - const auto variations = generateColorPair( color ); + if(groupColor == QColor{0,0,0}) + { + const auto colors = _openGLWidget->colorPalette( ).colors( ); + const auto paletteIdx = currentIndex % colors.size( ); + const auto color = colors[ paletteIdx ].toRgb( ); + const auto variations = generateColorPair( color ); + + TTransferFunction colorVariation; + colorVariation.push_back( std::make_pair( 0.0f , variations.first )); + colorVariation.push_back( std::make_pair( 1.0f , variations.second )); + group->colorMapping( colorVariation ); + } + else + { + const auto variations = generateColorPair( groupColor ); - TTransferFunction colorVariation; - colorVariation.push_back( std::make_pair( 0.0f , variations.first )); - colorVariation.push_back( std::make_pair( 1.0f , variations.second )); - group->colorMapping( colorVariation ); + TTransferFunction colorVariation; + colorVariation.push_back( std::make_pair( 0.0f , variations.first )); + colorVariation.push_back( std::make_pair( 1.0f , variations.second )); + group->colorMapping( colorVariation ); + } auto tfWidget = new TransferFunctionWidget( container ); tfWidget->setColorPoints( group->colorMapping( )); @@ -1991,8 +2011,11 @@ namespace visimpl const auto presetName = QString( "Group selection %1" ).arg( currentIndex ); QGradientStops stops; - stops << qMakePair( 0.0 , variations.first ) - << qMakePair( 1.0 , variations.second ); + + 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( )) , @@ -2103,8 +2126,11 @@ namespace visimpl const auto group = _domainManager->createGroup( filteredGIDs , _openGLWidget->getGidPositions( ) , groupName ); + const auto color = _subsetEvents->getSubsetColor( groupName ); + QColor groupColor = QColor::fromRgbF(color.x(), color.y(), color.z()); + addGroupControls( group , _domainManager->getGroupAmount( ) - 1 , - filteredGIDs.size( )); + filteredGIDs.size( ), groupColor); visimpl::Selection selection; selection.name = groupName; @@ -2479,9 +2505,12 @@ namespace visimpl void MainWindow::onDataLoaded( ) { + setWindowTitle("SimPart"); + if ( !m_loader ) return; const auto error = m_loader->errors( ); + const auto filename = QString::fromStdString(m_loader->filename()); if ( !error.empty( )) { closeLoadingDialog( ); @@ -2509,6 +2538,8 @@ namespace visimpl player = new simil::SpikesPlayer( ); player->LoadData( spikeData ); + _subsetEvents = spikeData->subsetsEvents(); + m_loader = nullptr; } break; @@ -2558,6 +2589,9 @@ namespace visimpl m_loaderDialog->setSpikesValue( player->spikesSize( )); m_loaderDialog->repaint( ); } + + setWindowTitle("SimPart - " + filename); + _openGLWidget->setPlayer( player , dataType ); _modeSelectionWidget->setCurrentIndex( 0 ); @@ -2621,8 +2655,6 @@ namespace visimpl { bool ok = false; auto groupName = button->property( GROUP_NAME_ ).toString( ); - - if ( !ok ) return; auto group = _domainManager->getGroup( groupName.toStdString( )); groupName = QInputDialog::getText( this , tr( "Group Name" ) , @@ -3333,6 +3365,8 @@ namespace visimpl QLineEdit::Normal , tr( "New position" ) , &ok ); + if(!ok) return; // user cancelled + if ( ok && !name.isEmpty( )) { QString tempName( name ); diff --git a/visimpl/MainWindow.h b/visimpl/MainWindow.h index e46280ecbcecf2af2b3cd5f1c384795f65ab7d09..a3626ed05ac111fb0edb98b15f4e8085747f7f6b 100644 --- a/visimpl/MainWindow.h +++ b/visimpl/MainWindow.h @@ -223,7 +223,8 @@ namespace visimpl void addGroupControls( std::shared_ptr< VisualGroup > group , unsigned int index , - unsigned int size ); + unsigned int size, + QColor groupColor = QColor{0,0,0}); void clearGroups( void ); diff --git a/visimpl/OpenGLWidget.cpp b/visimpl/OpenGLWidget.cpp index 078d3f4dc3b0a045bd18878e847a6f6b9fc75776..2da90204e4c8e3fe151a9db0ae5316621e44b908 100644 --- a/visimpl/OpenGLWidget.cpp +++ b/visimpl/OpenGLWidget.cpp @@ -69,7 +69,7 @@ namespace visimpl const InitialConfig _initialConfigSimBlueConfig = std::make_tuple( 0.5f , 20.0f , 20.0f , 1.0f ); const InitialConfig _initialConfigSimH5 = - std::make_tuple( 0.005f , 20.0f , 0.1f , 500.0f ); + std::make_tuple( 0.1f , 20.0f , 1.5f , 5.0f ); const InitialConfig _initialConfigSimCSV = //std::make_tuple( 0.005f, 20.0f, 0.1f, 50000.0f ); std::make_tuple( 0.2f , 2.0f , 1.5f , 5.0f ); @@ -789,9 +789,8 @@ namespace visimpl _frameCount = 0; } - update( ); - //if ( _idleUpdate && _player ) - //update( ); + if ( _idleUpdate && _player ) + update( ); } void @@ -949,7 +948,7 @@ namespace visimpl { if ( _homePosition.isEmpty( )) { - _focusOn( _boundingBoxHome ); + _focusOn( _domainManager.getBoundingBox() ); _homePosition = cameraPosition( ).toString( ); } @@ -1010,6 +1009,8 @@ namespace visimpl _scaleFactorExternal = true; + _homePosition.clear(); // reset home position to force re-computation. + if ( update && _player ) { _updateData( true ); diff --git a/visimpl/SubsetImporter.cpp b/visimpl/SubsetImporter.cpp index 1cc86a3379d34456a9c52b152473638ba55313a0..3be9500bf0232221193236b647373aea2b798715 100644 --- a/visimpl/SubsetImporter.cpp +++ b/visimpl/SubsetImporter.cpp @@ -36,12 +36,14 @@ namespace visimpl , _subsetEventManager( nullptr ) , _buttonAccept( nullptr ) , _buttonCancel( nullptr ) + , _selectGroups{nullptr} + , _selectConnections{nullptr} { init( ); setWindowIcon(QIcon(tr(":/visimpl.png"))); setWindowTitle(tr("Import Subsets")); - setMinimumSize(400, 400); + setMinimumSize(600, 400); } void SubsetImporter::init( void ) @@ -75,20 +77,30 @@ namespace visimpl _buttonAccept = new QPushButton( tr("Accept") ); _buttonCancel = new QPushButton( tr("Cancel") ); + _selectGroups = new QPushButton(tr("Select groups")); + _selectConnections = new QPushButton(tr("Select connections")); + _selectAll = new QPushButton(tr("Select all")); auto line = new QFrame( ); line->setFrameShape( QFrame::HLine ); line->setFrameShadow( QFrame::Sunken ); - layoutBottom->addWidget( line, 0, 0, 1, 5 ); - layoutBottom->addWidget( _buttonCancel, 1, 1, 1, 1 ); - layoutBottom->addWidget( _buttonAccept, 1, 3, 1, 1 ); + layoutBottom->addWidget(_selectGroups, 0,0,1,2); + layoutBottom->addWidget(_selectConnections, 0,2,1,2); + layoutBottom->addWidget(_selectAll, 0,4,1,2); + layoutBottom->addWidget( line, 1, 0, 1, 6 ); + layoutBottom->addWidget( _buttonCancel, 2, 1, 1, 2 ); + layoutBottom->addWidget( _buttonAccept, 2, 3, 1, 2 ); layoutUpper->addWidget( gbSubsets ); layoutUpper->addWidget( foot ); connect( _buttonCancel, SIGNAL( clicked( void )), this, SLOT( reject())); connect( _buttonAccept, SIGNAL( clicked( void )), this, SLOT( accept( ))); + connect( _selectGroups, SIGNAL( clicked( void )), this, SLOT( selectSubsets())); + connect( _selectConnections, SIGNAL( clicked( void )), this, SLOT( selectSubsets( ))); + connect( _selectAll, SIGNAL( clicked( void )), this, SLOT( selectSubsets( ))); + } void SubsetImporter::reload( const simil::SubsetEventManager* subsetEventMngr ) @@ -117,7 +129,7 @@ namespace visimpl checkBox->setChecked( true ); container->setLayout( layout ); - container->setFixedHeight(30); + container->setFixedHeight(40); layout->addWidget( checkBox, 0, 0, 1, 2 ); layout->addWidget( label, 0, 2, 1, 1 ); @@ -149,4 +161,37 @@ namespace visimpl return result; } + + void SubsetImporter::selectSubsets() + { + auto button = qobject_cast<QPushButton *>(sender()); + + if(button == _selectGroups) + { + for(auto subset: _subsets) + { + auto isGroup = subset.first.find("group") != std::string::npos; + std::get< sl_checkbox >( subset.second )->setChecked(isGroup); + } + } + else + { + if(button == _selectConnections) + { + for(auto subset: _subsets) + { + auto isConnection = subset.first.find("connection") != std::string::npos; + std::get< sl_checkbox >( subset.second )->setChecked(isConnection); + } + } + else + { + for(auto subset: _subsets) + { + std::get< sl_checkbox >( subset.second )->setChecked(true); + } + } + } + } + } diff --git a/visimpl/SubsetImporter.h b/visimpl/SubsetImporter.h index a1ee7fa94982b5c864f87e9326148b18589fc303..cb086adf700e8941cbad8cf679bf4ecf51ea61e4 100644 --- a/visimpl/SubsetImporter.h +++ b/visimpl/SubsetImporter.h @@ -53,6 +53,9 @@ namespace visimpl const std::vector< std::string > selectedSubsets( void ) const; + protected slots: + void selectSubsets(); + protected: const simil::SubsetEventManager* _subsetEventManager; @@ -61,6 +64,9 @@ namespace visimpl QPushButton* _buttonAccept; QPushButton* _buttonCancel; + QPushButton* _selectGroups; + QPushButton* _selectConnections; + QPushButton* _selectAll; QListWidget* _listSubsets; diff --git a/visimpl/particlelab/StaticGradientModel.cpp b/visimpl/particlelab/StaticGradientModel.cpp index 32ea56a19d0dca5fab07d4bba0decc3b9b5662f4..69a045247d7d516d3347a115a65f7c1ef25f2114 100644 --- a/visimpl/particlelab/StaticGradientModel.cpp +++ b/visimpl/particlelab/StaticGradientModel.cpp @@ -163,7 +163,7 @@ namespace visimpl glUniform1fv( cache.getLocation( "gradientTimes" ) , maxSize , timeStamps ); glUniform4fv( cache.getLocation( "gradientColors" ) , maxSize , - ( float* ) colors ); + (float*)colors ); } glUniform1f( cache.getLocation( "particlePreVisibility" ) , @@ -194,4 +194,4 @@ namespace visimpl } } -} \ No newline at end of file +}