Example #1
0
bool EventHandler<C>::handleEvent(eq::EventICommand command)
{
    switch (command.getEventType())
    {
    case HISTOGRAM_DATA:
    {
        const Histogram& histogram = command.read<Histogram>();
        const float area = command.read<float>();
        const uint32_t id = command.read<uint32_t>();
        _impl->gatherHistogram(histogram, area, id);
        return false;
    }

    case VOLUME_INFO:
        command >> _impl->config.getVolumeInformation();
        return false;

    case REDRAW:
        _impl->config.postRedraw();
        return true;
    }

    if (!eq::Config::handleEvent(command))
        return false;

    _impl->config.postRedraw();
    return true;
}
Example #2
0
bool Config::handleEvent( eq::EventICommand command )
{
    switch( command.getEventType( ))
    {
        case DATA_CHANGED:
        {
            _registerData( command );
            if( _readyToCommit() )
                _frameData.commit();    // broadcast changed data to all clients
            return false;
        }

        case PROXY_CHANGED:
        {
            _updateData( command );
            if( _readyToCommit() )
            {
                _updateSimulation();    // update the simulation every nth frame
                _frameData.commit();    // broadcast changed data to all clients
            }
            return false;
        }

        case eq::Event::KEY_PRESS:
        {
            const eq::Event& event = command.get< eq::Event >();
            if( _handleKeyEvent( event.keyPress ))
            {
                _redraw = true;
                return true;
            }
            break;
        }

        case eq::Event::WINDOW_EXPOSE:
        case eq::Event::WINDOW_RESIZE:
        case eq::Event::WINDOW_CLOSE:
        case eq::Event::VIEW_RESIZE:
            _redraw = true;
            break;

        default:
            break;
    }

    _redraw |= eq::Config::handleEvent( command );
    return _redraw;
}
Example #3
0
bool Config::handleEvent( eq::EventICommand command )
{
    const float moveSpeed = .1f;

    const eq::Event& event = command.get< eq::Event >();
    switch( command.getEventType( ))
    {
        // set mMoveDirection to a null vector after a key is released
        // so that the updating of the camera position stops
        case eq::Event::KEY_RELEASE:
            if ( event.keyPress.key >= 261 &&
                 event.keyPress.key <= 266 )
                _moveDirection = eq::Vector3f( 0, 0, 0 );
        break;

        // change mMoveDirection when the appropriate key is pressed
        case eq::Event::KEY_PRESS:
            switch ( event.keyPress.key )
            {
                case eq::KC_LEFT:
                    _moveDirection = vmml::normalize( orthographicVector(
                                     _cameraWalkingVector )) * moveSpeed;
                    return true;

                case eq::KC_UP:
                    _moveDirection.y() = moveSpeed;
                    return true;

                case eq::KC_RIGHT:
                    _moveDirection = -vmml::normalize( orthographicVector(
                                     _cameraWalkingVector )) * moveSpeed;
                    return true;

                case eq::KC_DOWN:
                    _moveDirection.y() = -moveSpeed;
                    return true;

                case eq::KC_PAGE_UP:
                    _moveDirection = vmml::normalize( _cameraWalkingVector )
                                     * moveSpeed;
                    return true;

                case eq::KC_PAGE_DOWN:
                    _moveDirection = -vmml::normalize( _cameraWalkingVector ) *
                                      moveSpeed;
                    return true;

                case 's':
                    _frameData.toggleStatistics();
            }
            break;

        // turn left and right, up and down with mouse pointer
        case eq::Event::CHANNEL_POINTER_MOTION:
            if ( event.pointerMotion.buttons == eq::PTR_BUTTON1 &&
                 event.pointerMotion.x <= event.context.pvp.w &&
                 event.pointerMotion.x >= 0 &&
                 event.pointerMotion.y <= event.context.pvp.h &&
                 event.pointerMotion.y >= 0 )
            {
                _pointerXDiff += event.pointerMotion.dx;
                _pointerYDiff += event.pointerMotion.dy;
                return true;
            }
            break;
    }

    // let Equalizer handle any events we don't handle ourselves here, like the
    // escape key for closing the application.
    return eq::Config::handleEvent( command );
}
Example #4
0
bool Config::handleEvent( eq::EventICommand command )
{
    switch( command.getEventType( ))
    {
        case eq::Event::KEY_PRESS:
        {
            const eq::Event& event = command.get< eq::Event >();
            if( _handleKeyEvent( event.keyPress ))
            {
                _redraw = true;
                return true;
            }
            break;
        }

        case eq::Event::CHANNEL_POINTER_BUTTON_PRESS:
        {
            const eq::Event& event = command.get< eq::Event >();
            const eq::uint128_t& viewID = event.context.view.identifier;
            _frameData.setCurrentViewID( viewID );
            if( viewID == 0 )
            {
                _currentCanvas = 0;
                return false;
            }

            const View* view = _getCurrentView();
            const eq::Layout* layout = view->getLayout();
            const eq::Canvases& canvases = getCanvases();
            for( eq::CanvasesCIter i = canvases.begin();
                 i != canvases.end(); ++i )
            {
                eq::Canvas* canvas = *i;
                const eq::Layout* canvasLayout = canvas->getActiveLayout();

                if( canvasLayout == layout )
                {
                    _currentCanvas = canvas;
                    return true;
                }
            }
            return true;
        }

        case eq::Event::CHANNEL_POINTER_BUTTON_RELEASE:
        {
            const eq::Event& event = command.get< eq::Event >();
            const eq::PointerEvent& releaseEvent =
                event.pointerButtonRelease;
            if( releaseEvent.buttons == eq::PTR_BUTTON_NONE)
            {
                if( releaseEvent.button == eq::PTR_BUTTON1 )
                {
                    _spinX = releaseEvent.dy;
                    _spinY = releaseEvent.dx;
                    _redraw = true;
                    return true;
                }
                if( releaseEvent.button == eq::PTR_BUTTON2 )
                {
                    _advance = -releaseEvent.dy;
                    _redraw = true;
                    return true;
                }
            }
            break;
        }
        case eq::Event::CHANNEL_POINTER_MOTION:
        {
            const eq::Event& event = command.get< eq::Event >();
            switch( event.pointerMotion.buttons )
            {
              case eq::PTR_BUTTON1:
                  _spinX = 0;
                  _spinY = 0;

                  if( _frameData.usePilotMode())
                      _frameData.spinCamera(
                          -0.005f * event.pointerMotion.dy,
                          -0.005f * event.pointerMotion.dx );
                  else
                      _frameData.spinModel(
                          -0.005f * event.pointerMotion.dy,
                          -0.005f * event.pointerMotion.dx, 0.f );
                  _redraw = true;
                  return true;

              case eq::PTR_BUTTON2:
                  _advance = -event.pointerMotion.dy;
                  _frameData.moveCamera( 0.f, 0.f, .005f * _advance );
                  _redraw = true;
                  return true;

              case eq::PTR_BUTTON3:
                  _frameData.moveCamera(  .0005f * event.pointerMotion.dx,
                                         -.0005f * event.pointerMotion.dy,
                                          0.f );
                  _redraw = true;
                  return true;
            }
            break;
        }

        case eq::Event::CHANNEL_POINTER_WHEEL:
        {
            const eq::Event& event = command.get< eq::Event >();
            _frameData.moveCamera( -0.05f * event.pointerWheel.yAxis,
                                   0.f,
                                   0.05f * event.pointerWheel.xAxis );
            _redraw = true;
            return true;
        }

        case eq::Event::MAGELLAN_AXIS:
        {
            const eq::Event& event = command.get< eq::Event >();
            _spinX = 0;
            _spinY = 0;
            _advance = 0;
            _frameData.spinModel( 0.0001f * event.magellan.xRotation,
                                  0.0001f * event.magellan.yRotation,
                                  0.0001f * event.magellan.zRotation );
            _frameData.moveCamera( 0.0001f * event.magellan.xAxis,
                                   0.0001f * event.magellan.yAxis,
                                   0.0001f * event.magellan.zAxis );
            _redraw = true;
            return true;
        }

        case eq::Event::MAGELLAN_BUTTON:
        {
            const eq::Event& event = command.get< eq::Event >();
            if( event.magellan.button == eq::PTR_BUTTON1 )
                _frameData.toggleColorMode();

            _redraw = true;
            return true;
        }

        case eq::Event::WINDOW_EXPOSE:
        case eq::Event::WINDOW_RESIZE:
        case eq::Event::WINDOW_CLOSE:
        case eq::Event::VIEW_RESIZE:
            _redraw = true;
            break;

        case IDLE_AA_LEFT:
            if( _useIdleAA )
            {
                const int32_t steps = command.get< int32_t >();
                _numFramesAA = LB_MAX( _numFramesAA, steps );
            }
            else
                _numFramesAA = 0;
            return false;

        default:
            break;
    }

    _redraw |= eq::Config::handleEvent( command );
    return _redraw;
}
Example #5
0
bool MasterConfig::handleEvent( eq::EventICommand command )
{
    switch( command.getEventType( ))
    {
      case eq::Event::CHANNEL_POINTER_BUTTON_PRESS:
      {
          const eq::Event& event = command.read< eq::Event >();
          _currentViewID = event.context.view.identifier;
          return true;
      }

      case eq::Event::KEY_PRESS:
      case eq::Event::KEY_RELEASE:
          if( Config::handleEvent( command ))
          {
              _redraw = true;
              LBVERB << "Redraw: requested by eq::Config" << std::endl;
          }
          // no break;
      case eq::Event::CHANNEL_POINTER_BUTTON_RELEASE:
      case eq::Event::CHANNEL_POINTER_MOTION:
      case eq::Event::CHANNEL_POINTER_WHEEL:
      case eq::Event::MAGELLAN_AXIS:
      {
          if( _currentViewID == 0 )
              return false;

          View* view = static_cast<View*>( find<eq::View>( _currentViewID ));
          if( view->handleEvent( command ))
          {
              _redraw = true;
              LBVERB << "Redraw: requested by view event handler" << std::endl;
          }
          return true;
      }

      case eq::Event::STATISTIC:
      {
          Config::handleEvent( command );
          const eq::Event& event = command.read< eq::Event >();
          if( event.statistic.type != eq::Statistic::CONFIG_FINISH_FRAME )
              return false;

          ViewUpdateVisitor viewUpdate( _redraw );
          accept( viewUpdate );
          return _redraw;
      }

      case eq::Event::WINDOW_EXPOSE:
      case eq::Event::WINDOW_RESIZE:
      case eq::Event::WINDOW_CLOSE:
      case eq::Event::VIEW_RESIZE:
          _redraw = true;
          LBVERB << "Redraw: window change" << std::endl;
          break;

      default:
          break;
    }

    if( eq::Config::handleEvent( command ))
    {
        _redraw = true;
        LBVERB << "Redraw: requested by config event handler" << std::endl;
    }
    return _redraw;
}