Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Implement #23: Launcher feature using coverflow for directory and sup…
Browse files Browse the repository at this point in the history
…ported files, including touch interaction, navigation and item selection
  • Loading branch information
tribal-tec committed Aug 6, 2013
1 parent f02fdf0 commit 9cae66e
Show file tree
Hide file tree
Showing 16 changed files with 2,067 additions and 63 deletions.
118 changes: 61 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,62 @@ find_package(Boost REQUIRED COMPONENTS serialization date_time)
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND LIBS ${Boost_LIBRARIES})

# DisplayCluster library
if(BUILD_DISPLAYCLUSTER_LIBRARY)
set(DISPLAYCLUSTER_LIBRARY_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
set(DISPLAYCLUSTER_LIBRARY_LIBS ${DISPLAYCLUSTER_LIBRARY_LIBS} ${LibJpegTurbo_LIBRARIES})

set(DISPLAYCLUSTER_LIBRARY_SRCS
src/log.cpp
src/lib/dcStream.cpp
)

set(DISPLAYCLUSTER_LIBRARY_PUBLIC_HEADERS
src/lib/dcStream.h
)

add_library(DisplayClusterLibrary SHARED ${DISPLAYCLUSTER_LIBRARY_SRCS})
target_link_libraries(DisplayClusterLibrary ${DISPLAYCLUSTER_LIBRARY_LIBS})
set_target_properties(DisplayClusterLibrary PROPERTIES
VERSION ${VERSION} SOVERSION ${VERSION_ABI} OUTPUT_NAME DisplayCluster)

# install library
INSTALL(TARGETS DisplayClusterLibrary
ARCHIVE DESTINATION lib COMPONENT dev
RUNTIME DESTINATION bin COMPONENT lib
LIBRARY DESTINATION lib COMPONENT lib)

# install headers
install(FILES ${DISPLAYCLUSTER_LIBRARY_PUBLIC_HEADERS} DESTINATION include)


# SimpleStreamer example application
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
set(SIMPLESTREAMER_LIBS ${OPENGL_LIBRARIES})

find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
set(SIMPLESTREAMER_LIBS ${SIMPLESTREAMER_LIBS} ${GLUT_LIBRARIES})

include_directories(src/lib)
set(SIMPLESTREAMER_LIBS ${SIMPLESTREAMER_LIBS} DisplayClusterLibrary)

set(SIMPLESTREAMER_SRCS
apps/SimpleStreamer/src/main.cpp
)

add_executable(simplestreamer ${SIMPLESTREAMER_SRCS})

target_link_libraries(simplestreamer ${SIMPLESTREAMER_LIBS})

# install executable
INSTALL(TARGETS simplestreamer
RUNTIME DESTINATION bin
)
endif()


find_package(OpenGL)
find_package(MPI)
find_package(FFMPEG)
Expand Down Expand Up @@ -159,6 +215,7 @@ if(OPENGL_FOUND AND MPI_FOUND AND FFMPEG_FOUND)
src/DisplayGroupGraphicsViewProxy.cpp
src/DisplayGroupGraphicsView.cpp
src/DisplayGroupListWidgetProxy.cpp
src/Dock.cpp
src/DynamicTexture.cpp
src/DynamicTextureContent.cpp
src/FactoryObject.cpp
Expand All @@ -173,6 +230,7 @@ if(OPENGL_FOUND AND MPI_FOUND AND FFMPEG_FOUND)
src/Options.cpp
src/ParallelPixelStream.cpp
src/ParallelPixelStreamContent.cpp
src/Pictureflow.cpp
src/PixelStream.cpp
src/PixelStreamContent.cpp
src/PixelStreamSource.cpp
Expand All @@ -190,19 +248,21 @@ if(OPENGL_FOUND AND MPI_FOUND AND FFMPEG_FOUND)
src/DisplayGroupInterface.h
src/DisplayGroupGraphicsViewProxy.h
src/DisplayGroupListWidgetProxy.h
src/Dock.h
src/MainWindow.h
src/Marker.h
src/NetworkListener.h
src/NetworkListenerThread.h
src/Options.h
src/Pictureflow.h
)

# add OPTIONS hacks for Qt's MOC processing of Boost headers, for compiler errors with some versions of Boost
qt4_wrap_cpp(MOC_OUTFILES ${MOC_HEADERS} OPTIONS -DPOSIX_TIME_HPP___ -DPOSIX_TIME_SERIALIZE_HPP___ -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED)

add_executable(displaycluster ${SRCS} ${MOC_OUTFILES})

target_link_libraries(displaycluster ${LIBS})
target_link_libraries(displaycluster ${LIBS} DisplayClusterLibrary)

# build Python module if Python support is enabled
if(ENABLE_PYTHON_SUPPORT)
Expand Down Expand Up @@ -239,62 +299,6 @@ if(OPENGL_FOUND AND MPI_FOUND AND FFMPEG_FOUND)
endif()


# DisplayCluster library
if(BUILD_DISPLAYCLUSTER_LIBRARY)
set(DISPLAYCLUSTER_LIBRARY_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
set(DISPLAYCLUSTER_LIBRARY_LIBS ${DISPLAYCLUSTER_LIBRARY_LIBS} ${LibJpegTurbo_LIBRARIES})

set(DISPLAYCLUSTER_LIBRARY_SRCS
src/log.cpp
src/lib/dcStream.cpp
)

set(DISPLAYCLUSTER_LIBRARY_PUBLIC_HEADERS
src/lib/dcStream.h
)

add_library(DisplayClusterLibrary SHARED ${DISPLAYCLUSTER_LIBRARY_SRCS})
target_link_libraries(DisplayClusterLibrary ${DISPLAYCLUSTER_LIBRARY_LIBS})
set_target_properties(DisplayClusterLibrary PROPERTIES
VERSION ${VERSION} SOVERSION ${VERSION_ABI} OUTPUT_NAME DisplayCluster)

# install library
INSTALL(TARGETS DisplayClusterLibrary
ARCHIVE DESTINATION lib COMPONENT dev
RUNTIME DESTINATION bin COMPONENT lib
LIBRARY DESTINATION lib COMPONENT lib)

# install headers
install(FILES ${DISPLAYCLUSTER_LIBRARY_PUBLIC_HEADERS} DESTINATION include)


# SimpleStreamer example application
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
set(SIMPLESTREAMER_LIBS ${OPENGL_LIBRARIES})

find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
set(SIMPLESTREAMER_LIBS ${SIMPLESTREAMER_LIBS} ${GLUT_LIBRARIES})

include_directories(src/lib)
set(SIMPLESTREAMER_LIBS ${SIMPLESTREAMER_LIBS} DisplayClusterLibrary)

set(SIMPLESTREAMER_SRCS
apps/SimpleStreamer/src/main.cpp
)

add_executable(simplestreamer ${SIMPLESTREAMER_SRCS})

target_link_libraries(simplestreamer ${SIMPLESTREAMER_LIBS})

# install executable
INSTALL(TARGETS simplestreamer
RUNTIME DESTINATION bin
)
endif()


# DesktopStreamer app
if(BUILD_DESKTOPSTREAMER)
set(DESKTOP_STREAMER_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY})
Expand Down
12 changes: 12 additions & 0 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ Configuration::Configuration(const char * filename)
fullscreen_ = 0;
}

// dock start directory
query_.setQuery("string(/configuration/dock/@directory)");
query_.evaluateTo(&dockStartDir_);
dockStartDir_.remove(QRegExp("[\\n\\t\\r]"));
if( dockStartDir_.isEmpty( ))
dockStartDir_ = QDir::homePath();

put_flog(LOG_INFO, "dimensions: numTilesWidth = %i, numTilesHeight = %i, screenWidth = %i, screenHeight = %i, mullionWidth = %i, mullionHeight = %i. fullscreen = %i", numTilesWidth_, numTilesHeight_, screenWidth_, screenHeight_, mullionWidth_, mullionHeight_, fullscreen_);

// get tile parameters (if we're not rank 0)
Expand Down Expand Up @@ -224,6 +231,11 @@ std::string Configuration::getMyDisplay()
return display_;
}

QString Configuration::getDockStartDir() const
{
return dockStartDir_;
}

int Configuration::getMyNumTiles()
{
return myNumTiles_;
Expand Down
2 changes: 2 additions & 0 deletions src/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Configuration {

std::string getMyHost();
std::string getMyDisplay();
QString getDockStartDir() const;

int getMyNumTiles();
int getTileX(int i);
Expand All @@ -81,6 +82,7 @@ class Configuration {

std::string host_;
std::string display_;
QString dockStartDir_;

int myNumTiles_;
std::vector<int> tileX_;
Expand Down
7 changes: 6 additions & 1 deletion src/Content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Content::Content(std::string uri)
blockAdvance_ = false;
}

std::string Content::getURI()
const std::string& Content::getURI() const
{
return uri_;
}
Expand All @@ -74,6 +74,11 @@ void Content::setDimensions(int width, int height)
emit(dimensionsChanged(width_, height_));
}

bool Content::isDock() const
{
return getURI() == "menu";
}

void Content::render(boost::shared_ptr<ContentWindowManager> window)
{
// get parameters from window
Expand Down
3 changes: 2 additions & 1 deletion src/Content.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Content : public QObject {

Content(std::string uri = "");

std::string getURI();
const std::string& getURI() const;

virtual CONTENT_TYPE getType() = 0;

Expand All @@ -77,6 +77,7 @@ class Content : public QObject {
virtual void getFactoryObjectDimensions(int &width, int &height) = 0;
void render(boost::shared_ptr<ContentWindowManager> window);
void blockAdvance( bool block ) { blockAdvance_ = block; }
bool isDock() const;

// virtual method for implementing actions on advancing to a new frame
// useful when a process has multiple GLWindows
Expand Down
44 changes: 41 additions & 3 deletions src/ContentWindowGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "DisplayGroupGraphicsView.h"
#include "main.h"
#include "Gestures.h"
#include "Dock.h"
#include "Pictureflow.h"

qreal ContentWindowGraphicsItem::zCounter_ = 0;

Expand Down Expand Up @@ -324,6 +326,13 @@ void ContentWindowGraphicsItem::pan( PanGesture* gesture )
const double dx = delta.x() / g_configuration->getTotalWidth();
const double dy = delta.y() / g_configuration->getTotalHeight();

if( getContentWindowManager()->getContent()->isDock( ))
{
const int offs = delta.x()/4;
g_dock->getFlow()->showSlide( g_dock->getFlow()->centerIndex() + offs );
return;
}

if( selected_ )
{
const double centerX = centerX_ - 2.*dx / zoom_;
Expand All @@ -348,8 +357,11 @@ void ContentWindowGraphicsItem::pan( PanGesture* gesture )

void ContentWindowGraphicsItem::pinch( QPinchGesture* gesture )
{
if( getContentWindowManager()->getContent()->isDock( ))
return;

const qreal factor = (gesture->scaleFactor() - 1.) * 0.2f + 1.f;
if( std::isnan( factor) || std::isinf( factor ))
if( std::isnan( factor ) || std::isinf( factor ))
return;

if( selected_ )
Expand All @@ -374,16 +386,41 @@ void ContentWindowGraphicsItem::tap( QTapGesture* gesture )
{
if( gesture->state() != Qt::GestureFinished )
return;

if( !getContentWindowManager()->getContent()->isDock( ))
return;

const int xPos = gesture->position().x() - (x_*g_configuration->getTotalWidth());
const int mid = (w_*g_configuration->getTotalWidth())/2;
const int slideMid = g_dock->getFlow()->slideSize().width()/2;

if( xPos > mid-slideMid && xPos < mid+slideMid )
{
g_dock->onItem();
return;
}

if( xPos > mid )
g_dock->getFlow()->showNext();
else
g_dock->getFlow()->showPrevious();
}

void ContentWindowGraphicsItem::doubleTap( DoubleTapGesture* gesture )
{
if( getContentWindowManager()->getContent()->isDock( ))
return;

if( gesture->state() == Qt::GestureFinished )
adjustSize( getSizeState() == SIZE_FULLSCREEN ? SIZE_1TO1 : SIZE_FULLSCREEN );
adjustSize( getSizeState() == SIZE_FULLSCREEN ? SIZE_1TO1 :
SIZE_FULLSCREEN );
}

void ContentWindowGraphicsItem::tapAndHold( QTapAndHoldGesture* gesture )
{
if( getContentWindowManager()->getContent()->isDock( ))
return;

if( gesture->state() == Qt::GestureFinished )
setSelected( !selected_ );
}
Expand Down Expand Up @@ -552,7 +589,8 @@ void ContentWindowGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * eve
{
resizing_ = false;
moving_ = false;
getContentWindowManager()->getContent()->blockAdvance( false );
if( getContentWindowManager( ))
getContentWindowManager()->getContent()->blockAdvance( false );

QGraphicsItem::mouseReleaseEvent(event);
}
Expand Down
22 changes: 21 additions & 1 deletion src/DisplayGroupGraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#include "DisplayGroupGraphicsView.h"
#include "DisplayGroupGraphicsScene.h"
#include "main.h"
#include "ContentWindowManager.h"
#include "ContentWindowGraphicsItem.h"
#include "Dock.h"

DisplayGroupGraphicsView::DisplayGroupGraphicsView()
{
Expand All @@ -53,8 +56,13 @@ DisplayGroupGraphicsView::DisplayGroupGraphicsView()
setDragMode(QGraphicsView::RubberBandDrag);
setAcceptDrops(true);

grabGestures();
}

void DisplayGroupGraphicsView::grabGestures()
{
//viewport()->grabGesture(Qt::TapGesture);
//viewport()->grabGesture(Qt::TapAndHoldGesture);
viewport()->grabGesture(Qt::TapAndHoldGesture);
//viewport()->grabGesture(Qt::PanGesture);
//viewport()->grabGesture(Qt::PinchGesture);
//viewport()->grabGesture(Qt::SwipeGesture);
Expand Down Expand Up @@ -123,6 +131,18 @@ void DisplayGroupGraphicsView::tapAndHold( QTapAndHoldGesture* gesture )
{
if( gesture->state() != Qt::GestureFinished )
return;

const QPoint widgetPos = mapFromGlobal( QPoint( gesture->hotSpot().x(),
gesture->hotSpot().y( )));
const QPointF pos = mapToScene( widgetPos );
QGraphicsItem* item = scene()->itemAt( pos );
if( dynamic_cast< ContentWindowGraphicsItem* >( item ))
return;

if( !g_dock )
g_dock = new Dock;
g_dock->open();
g_dock->setPos( pos );
}

void DisplayGroupGraphicsView::resizeEvent(QResizeEvent * event)
Expand Down
2 changes: 2 additions & 0 deletions src/DisplayGroupGraphicsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class DisplayGroupGraphicsView : public QGraphicsView {

DisplayGroupGraphicsView();

void grabGestures();

protected:

bool viewportEvent( QEvent* event );
Expand Down
6 changes: 6 additions & 0 deletions src/DisplayGroupGraphicsViewProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ void DisplayGroupGraphicsViewProxy::removeContentWindowManager(boost::shared_ptr
}
}
}

// Qt WAR: when all items with grabbed gestures are removed, the viewport
// also looses any registered gestures, which harms our dock to open...
// <qt-source>/qgraphicsscene.cpp::ungrabGesture called in removeItemHelper()
if( getContentWindowManagers().empty( ))
graphicsView_->grabGestures();
}

void DisplayGroupGraphicsViewProxy::moveContentWindowManagerToFront(boost::shared_ptr<ContentWindowManager> contentWindowManager, DisplayGroupInterface * source)
Expand Down
Loading

0 comments on commit 9cae66e

Please sign in to comment.