Skip to content

Commit

Permalink
Merge pull request #585 from rdumusc/master
Browse files Browse the repository at this point in the history
Adjust to Deflect 0.12 v5 API, handle new PAN event
  • Loading branch information
Raphael Dumusc authored Sep 28, 2016
2 parents 29f8508 + a861ba2 commit bf0ba1a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .gitsubprojects
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ git_subproject(Pression https://github.com/Eyescale/Pression.git 8ce1a32)
git_subproject(hwsd https://github.com/Eyescale/hwsd.git 04c7cd9)
git_subproject(Collage https://github.com/Eyescale/Collage.git 625e3ac)
git_subproject(GLStats https://github.com/Eyescale/GLStats.git 840c29d)
git_subproject(Deflect https://github.com/BlueBrain/Deflect.git 37a42c4)
git_subproject(Deflect https://github.com/BlueBrain/Deflect.git 07711c1)
4 changes: 4 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changelog {#Changelog}

# Release 1.13 (git master)

* [585](https://github.com/Eyescale/Equalizer/pull/585):
Deflect proxy: update to Deflect 0.12 v5 API, use new PAN event to move
camera instead of switching between pan/rotate with TAP_AND_HOLD event,
handle new pinch event to zoom.
* [584](https://github.com/Eyescale/Equalizer/pull/584):
Removed broken CUDA/ComputeContext support
* [578](https://github.com/Eyescale/Equalizer/pull/578):
Expand Down
22 changes: 1 addition & 21 deletions eq/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,27 +409,7 @@ void Channel::frameViewFinish( const uint128_t& frameID )
_impl->frameViewFinish( *this );
}

void Channel::frameDrawOverlay( const uint128_t& )
{
applyOverlayState();

#ifdef EQUALIZER_USE_DEFLECT
if( _impl->_deflectProxy && _impl->_deflectProxy->isRunning( ))
{
const eq::PixelViewport& pvp = getPixelViewport();
const eq::Viewport& vp = getViewport();

const float width = pvp.w / vp.w;
const float height = pvp.h / vp.h;
const float xOffset = vp.x * width;

glRasterPos3f( 10.f - xOffset, height - 30.f, 0.99f );
getWindow()->getMediumFont()->draw( _impl->_deflectProxy->getHelp( ));
}
#endif

resetOverlayState();
}
void Channel::frameDrawOverlay( const uint128_t& ) { /* nop */ }

void Channel::setupAssemblyState()
{
Expand Down
66 changes: 36 additions & 30 deletions eq/deflect/eventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace
typedef std::vector< EventHandler* > EventHandlers;
static lunchbox::PerThread< EventHandlers > _eventHandlers;

const float wheelFactor = 1.f / 40.f;

// Values come from QtCore/qnamespace.h, but don't want to depend on Qt just for that
uint32_t _getKey( const int key )
{
Expand Down Expand Up @@ -87,6 +89,18 @@ uint32_t _getKey( const int key )
default: return key+32;
}
}

uint32_t _getButtons( const ::deflect::Event& deflectEvent )
{
uint32_t buttons = 0;
if( deflectEvent.mouseLeft )
buttons |= PTR_BUTTON1;
if( deflectEvent.mouseMiddle )
buttons |= PTR_BUTTON2;
if( deflectEvent.mouseRight )
buttons |= PTR_BUTTON3;
return buttons;
}
}

EventHandler::EventHandler( Proxy* proxy )
Expand Down Expand Up @@ -171,9 +185,6 @@ void EventHandler::_processEvents( const Proxy* proxy )
const float x = deflectEvent.mouseX * pvp.w;
const float y = deflectEvent.mouseY * pvp.h;

if( _proxy-> getNavigationMode() == Proxy::MODE_PAN )
std::swap( deflectEvent.mouseLeft, deflectEvent.mouseRight );

switch( deflectEvent.type )
{
case ::deflect::Event::EVT_KEY_PRESS:
Expand All @@ -189,31 +200,24 @@ void EventHandler::_processEvents( const Proxy* proxy )
Event::CHANNEL_POINTER_BUTTON_RELEASE;
event.pointerButtonPress.x = x;
event.pointerButtonPress.y = y;

if( deflectEvent.mouseLeft )
event.pointerButtonPress.buttons |= PTR_BUTTON1;
if( deflectEvent.mouseMiddle )
event.pointerButtonPress.buttons |= PTR_BUTTON2;
if( deflectEvent.mouseRight )
event.pointerButtonPress.buttons |= PTR_BUTTON3;
event.pointerButtonPress.buttons = _getButtons( deflectEvent );
event.pointerButtonPress.button = event.pointerButtonPress.buttons;
_computePointerDelta( event );
break;
case ::deflect::Event::EVT_DOUBLECLICK:
break;
case ::deflect::Event::EVT_MOVE:
case ::deflect::Event::EVT_PAN:
event.type = Event::CHANNEL_POINTER_MOTION;
event.pointerMotion.x = x;
event.pointerMotion.y = y;

if( deflectEvent.mouseLeft )
event.pointerButtonPress.buttons |= PTR_BUTTON1;
if( deflectEvent.mouseMiddle )
event.pointerButtonPress.buttons |= PTR_BUTTON2;
if( deflectEvent.mouseRight )
event.pointerButtonPress.buttons |= PTR_BUTTON3;

if( deflectEvent.type == ::deflect::Event::EVT_PAN )
event.pointerButtonPress.buttons = PTR_BUTTON3;
else
event.pointerButtonPress.buttons = _getButtons( deflectEvent );
event.pointerMotion.button = event.pointerMotion.buttons;

event.pointerMotion.dx = deflectEvent.dx * pvp.w;
event.pointerMotion.dy = deflectEvent.dy * pvp.h;
break;
Expand All @@ -222,23 +226,25 @@ void EventHandler::_processEvents( const Proxy* proxy )
event.pointerWheel.x = x;
event.pointerWheel.y = pvp.h - y;
event.pointerWheel.buttons = PTR_BUTTON_NONE;
event.pointerWheel.xAxis = deflectEvent.dx / 40.f;
event.pointerWheel.yAxis = deflectEvent.dy / 40.f;
event.pointerWheel.xAxis = deflectEvent.dx * wheelFactor;
event.pointerWheel.yAxis = deflectEvent.dy * wheelFactor;
event.pointerMotion.dx = -deflectEvent.dx;
event.pointerMotion.dy = -deflectEvent.dy;
break;
case ::deflect::Event::EVT_TAP_AND_HOLD:
case ::deflect::Event::EVT_PINCH:
{
const Proxy::NavigationMode mode =
_proxy->getNavigationMode() == Proxy::MODE_PAN
? Proxy::MODE_ROTATE : Proxy::MODE_PAN;
_proxy->setNavigationMode( mode );
Event windowEvent;
windowEvent.originator = window->getID();
windowEvent.serial = window->getSerial();
windowEvent.type = Event::WINDOW_EXPOSE;
window->processEvent( windowEvent );
} break;
event.type = Event::CHANNEL_POINTER_WHEEL;
event.pointerWheel.x = x;
event.pointerWheel.y = pvp.h - y;
event.pointerWheel.buttons = PTR_BUTTON_NONE;
const auto dx = deflectEvent.dx * pvp.w;
const auto dy = deflectEvent.dy * pvp.h;
const auto sign = dx + dy;
const auto zoom = std::copysign( std::sqrt( dx*dx + dy*dy ), sign );
event.pointerWheel.xAxis = 0.f;
event.pointerWheel.yAxis = zoom * wheelFactor;
break;
}
case ::deflect::Event::EVT_NONE:
default:
break;
Expand Down
26 changes: 1 addition & 25 deletions eq/deflect/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace deflect

::deflect::Stream::Future make_ready_future( const bool value )
{
boost::promise< bool > promise;
std::promise< bool > promise;
promise.set_value( value );
return promise.get_future();
}
Expand All @@ -53,7 +53,6 @@ class Proxy::Impl : public boost::noncopyable
: _channel( channel )
, _sendFuture( make_ready_future( false ))
, _running( false )
, _navigationMode( Proxy::MODE_ROTATE )
{
const DrawableConfig& dc = _channel.getDrawableConfig();
if( dc.colorBits != 8 )
Expand Down Expand Up @@ -121,7 +120,6 @@ class Proxy::Impl : public boost::noncopyable
lunchbox::Bufferb _buffer;
::deflect::Stream::Future _sendFuture;
bool _running;
Proxy::NavigationMode _navigationMode;
};

Proxy::Proxy( Channel& channel )
Expand Down Expand Up @@ -177,27 +175,5 @@ ::deflect::Event Proxy::getEvent() const
return _impl->_stream->getEvent();
}

void Proxy::setNavigationMode( Proxy::NavigationMode mode )
{
_impl->_navigationMode = mode;
}

Proxy::NavigationMode Proxy::getNavigationMode() const
{
return _impl->_navigationMode;
}

std::string Proxy::getHelp() const
{
switch( _impl->_navigationMode )
{
case MODE_PAN:
return "Pan mode";
case MODE_ROTATE:
default:
return "Rotate mode";
}
}

}
}
15 changes: 0 additions & 15 deletions eq/deflect/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ class Proxy : public ResultImageListener
/** @return the latest window Event. @sa hasNewEvent() */
::deflect::Event getEvent() const;

enum NavigationMode
{
MODE_PAN,
MODE_ROTATE
};

/** Set the navigation mode for received mouse events. */
void setNavigationMode( NavigationMode mode );

/** @return the current set navigation mode. */
NavigationMode getNavigationMode() const;

/** @return a help text which can be printed as an overlay. */
std::string getHelp() const;

private:
class Impl;
std::unique_ptr< Impl > _impl;
Expand Down

0 comments on commit bf0ba1a

Please sign in to comment.