Skip to content

Commit

Permalink
Tide 1.2.1 bugfix release
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael Dumusc committed Dec 16, 2016
1 parent d58749b commit 16c005d
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .gitsubprojects
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- mode: cmake -*-
git_subproject(ZeroEQ https://github.com/HBPVIS/ZeroEQ.git 1420ab9)
git_subproject(ZeroEQ https://github.com/HBPVIS/ZeroEQ.git 9b7ca61)
git_subproject(Deflect https://github.com/BlueBrain/Deflect.git 76526f0)
git_subproject(TUIO https://github.com/BlueBrain/TUIO.git fdf5cf7)
git_subproject(VirtualKeyboard https://github.com/rdumusc/QtFreeVirtualKeyboard.git b2f79e3)
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Raphael Dumusc <[email protected]>

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(Tide VERSION 1.2.0)
project(Tide VERSION 1.2.1)
set(Tide_VERSION_ABI 1)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake
Expand Down
12 changes: 12 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changelog {#changelog}
============

# Release 1.2.1 (16-12-2016)

* [113](https://github.com/BlueBrain/Tide/pull/113):
Fixed several issues linked to ZeroEQ with the 1.2 release:
- The REST interface was constantly polling, causing a 100% idle CPU load.
- This caused troubles with window animations in headless mode, resulting in
touch events hitting the background or some other window.
- cmake -DINSTALL_PACKAGES=1 did not install cppnetlib's dependencies.
Additionnally, the REST "open" command can be given a directory path to open
all the contents inside it. This feature was previously inaccessible in
headless mode.

# Release 1.2 (09-12-2016)

* [111](https://github.com/BlueBrain/Tide/pull/111):
Expand Down
53 changes: 53 additions & 0 deletions tide/master/ContentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "scene/ContentWindow.h"
#include "scene/ContentFactory.h"

#include <QDir>

ContentLoader::ContentLoader( DisplayGroupPtr displayGroup )
: _displayGroup( displayGroup )
{
Expand Down Expand Up @@ -89,6 +91,57 @@ bool ContentLoader::load( const QString& filename,
return true;
}


QSize _estimateGridSize( const int numElem )
{
if( numElem <= 0 )
return QSize();

const auto w = int( ceil( sqrt( numElem )));
return { w, ( w * ( w-1 ) >= numElem ) ? w-1 : w };
}

size_t ContentLoader::loadDir( const QString& dirName, QSize gridSize )
{
put_flog( LOG_INFO, "opening directory: '%s'",
dirName.toLocal8Bit().constData( ));

QDir directory( dirName );
directory.setFilter( QDir::Files );
directory.setNameFilters( ContentFactory::getSupportedFilesFilter( ));

const auto list = directory.entryInfoList();
if( list.empty( ))
return 0;

if( gridSize.isEmpty( ))
gridSize = _estimateGridSize( list.size( ));

const QSizeF win( _displayGroup->width() / (qreal)gridSize.width(),
_displayGroup->height() / (qreal)gridSize.height( ));

int contentIndex = 0;
for( const auto& fileinfo : list )
{
const auto filename = fileinfo.absoluteFilePath();
const auto x = contentIndex % gridSize.width();
const auto y = contentIndex / gridSize.width();
const auto position = QPointF{ x * win.width() + 0.5 * win.width(),
y * win.height() + 0.5 * win.height() };

if( load( filename, position, win ))
++contentIndex;

if( contentIndex >= gridSize.width() * gridSize.height( ))
break; // should not happen if grid size is correct
}

put_flog( LOG_INFO, "done opening %d contents from directory: '%s'",
contentIndex, dirName.toLocal8Bit().constData( ));

return contentIndex;
}

bool ContentLoader::isAlreadyOpen( const QString& filename ) const
{
for( const auto& window : _displayGroup->getContentWindows( ))
Expand Down
12 changes: 12 additions & 0 deletions tide/master/ContentLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ class ContentLoader
const QPointF& windowCenterPosition = QPointF(),
const QSizeF& windowSize = QSizeF( ));

/**
* Load all the supported files from a directory.
*
* The contents are automatically arranged in a grid accross the entire
* DisplayGroup.
* @param dirName path to a directory
* @param gridSize size of the grid for the contents, will be automatically
* determined if left empty.
* @return the number of contents that could be loaded
*/
size_t loadDir( const QString& dirName, QSize gridSize = QSize{} );

/**
* Check if a content is already open.
*
Expand Down
5 changes: 5 additions & 0 deletions tide/master/MasterApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,15 @@ void MasterApplication::_initRestInterface()

connect( _restInterface.get(), &RestInterface::open, [this]( QString uri )
{
if( uri.isEmpty( ))
return;

auto loader = ContentLoader{ _displayGroup };
auto window = loader.findWindow( uri );
if( window )
_displayGroup->moveToFront( window );
else if( QDir{ uri }.exists( ))
loader.loadDir( uri );
else
loader.load( uri );
});
Expand Down
12 changes: 8 additions & 4 deletions tide/master/rest/RestServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ const uint32_t TIMEOUT = 0; // non-blocking receive

RestServer::RestServer()
{
_socketNotifier.connect( &_socketNotifier, &QSocketNotifier::activated,
[this]() { _httpServer.receive( TIMEOUT ); });
_init();
}

RestServer::RestServer( const int port )
: _httpServer{ zeroeq::URI { QString(":%1").arg( port ).toStdString( )}}
{
_socketNotifier.connect( &_socketNotifier, &QSocketNotifier::activated,
[this]() { _httpServer.receive( TIMEOUT ); });
_init();
}

int RestServer::getPort() const
Expand All @@ -68,3 +66,9 @@ zeroeq::http::Server& RestServer::get()
{
return _httpServer;
}

void RestServer::_init()
{
_socketNotifier.connect( &_socketNotifier, &QSocketNotifier::activated,
[this]() { _httpServer.receive( TIMEOUT ); });
}
3 changes: 2 additions & 1 deletion tide/master/rest/RestServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class RestServer
private:
zeroeq::http::Server _httpServer;
QSocketNotifier _socketNotifier{ _httpServer.getSocketDescriptor(),
QSocketNotifier::Write };
QSocketNotifier::Read };
void _init();
};

#endif
51 changes: 7 additions & 44 deletions tide/master/ui/MasterWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ void MasterWindow::_openContent()
}

void MasterWindow::_addContentDirectory( const QString& directoryName,
unsigned int gridX,
unsigned int gridY )
const QSize& gridSize )
{
QDir directory( directoryName );
directory.setFilter( QDir::Files );
Expand All @@ -408,39 +407,14 @@ void MasterWindow::_addContentDirectory( const QString& directoryName,
QString::number( list.size( )) +
" content elements. Are you sure you want to continue?";

typedef QMessageBox::StandardButton button;
const button reply = QMessageBox::question( this, "Warning", msg,
QMessageBox::Yes |
QMessageBox::No );
if ( reply != QMessageBox::Yes )
const auto reply = QMessageBox::question( this, "Warning", msg,
QMessageBox::Yes |
QMessageBox::No );
if( reply != QMessageBox::Yes )
return;
}

// If grid size is unspecified, compute one large enough to hold all the
// elements
if ( gridX == 0 || gridY == 0 )
_estimateGridSize( list.size(), gridX, gridY );

unsigned int contentIndex = 0;

const QSizeF win( _displayGroup->width() / (qreal)gridX,
_displayGroup->height() / (qreal)gridY );

ContentLoader contentLoader( _displayGroup );

for( int i = 0; i < list.size() && contentIndex < gridX * gridY; ++i )
{
const QFileInfo& fileInfo = list.at(i);
const QString& filename = fileInfo.absoluteFilePath();

const unsigned int x_coord = contentIndex % gridX;
const unsigned int y_coord = contentIndex / gridX;
const QPointF position( x_coord * win.width() + 0.5 * win.width(),
y_coord * win.height() + 0.5 * win.height( ));

if( contentLoader.load( filename, position, win ))
++contentIndex;
}
ContentLoader{ _displayGroup }.loadDir( directoryName, gridSize );
}

void MasterWindow::_openContentsDirectory()
Expand All @@ -456,9 +430,7 @@ void MasterWindow::_openContentsDirectory()
"Grid X dimension", 0, 0 );
const int gridY = QInputDialog::getInt( this, "Grid Y dimension",
"Grid Y dimension", 0, 0 );
assert( gridX >= 0 && gridY >= 0 );

_addContentDirectory( dirName, gridX, gridY );
_addContentDirectory( dirName, { gridX, gridY } );
}

void MasterWindow::_openSession()
Expand Down Expand Up @@ -507,15 +479,6 @@ void MasterWindow::_openAboutWidget()
QMessageBox::about( this, "About Tide", aboutMsg.str().c_str( ));
}

void MasterWindow::_estimateGridSize( unsigned int numElem, unsigned int& gridX,
unsigned int& gridY )
{
assert( numElem > 0 );
gridX = (unsigned int)( ceil( sqrt( numElem )));
assert( gridX > 0 );
gridY = ( gridX * ( gridX-1 ) >= numElem ) ? gridX-1 : gridX;
}

QStringList MasterWindow::_extractValidContentUrls( const QMimeData* mimeData )
{
QStringList pathList;
Expand Down
5 changes: 1 addition & 4 deletions tide/master/ui/MasterWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MasterWindow : public QMainWindow

void _openContent();
void _addContentDirectory( const QString& directoryName,
unsigned int gridX = 0, unsigned int gridY = 0 );
const QSize& gridSize = QSize( ));
void _openContentsDirectory();

void _openSession();
Expand All @@ -96,9 +96,6 @@ class MasterWindow : public QMainWindow

void _openAboutWidget();

void _estimateGridSize( unsigned int numElem, unsigned int& gridX,
unsigned int& gridY );

QStringList _extractValidContentUrls( const QMimeData* mimeData );
QStringList _extractFolderUrls( const QMimeData* mimeData );
QString _extractSessionFile( const QMimeData* mimeData );
Expand Down

0 comments on commit 16c005d

Please sign in to comment.