bool OrbitCameraManipulator::handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa); if( !view ) return false; if( ea.getButtonMask() == 0 ) { double timeSinceLastRecordEvent = _ga_t0.valid() ? (ea.getTime() - _ga_t0->getTime()) : DBL_MAX; if( timeSinceLastRecordEvent > 0.02 ) { flushMouseEventStack(); } if( isMouseMoving() ) { if( performMovement( ea, aa ) && _allowThrow ) { aa.requestRedraw(); aa.requestContinuousUpdate( true ); _thrown = true; // TODO: fade out throw animation } return true; } } if( !m_pointer_push_drag ) { // select object bool intersection_geometry_found = intersectSceneSelect( ea, view ); if( !intersection_geometry_found ) { // click to background -> unselect all if( m_system != nullptr ) { m_system->clearSelection(); } } } m_pointer_push_drag = false; flushMouseEventStack(); addMouseEvent( ea ); if( performMovement( ea, aa ) ) { aa.requestRedraw(); } aa.requestContinuousUpdate( false ); _thrown = false; return true; }
void Ut_PagedPanning::testWhenTriedToPanThePagePositionWillNotChangeWhenPanningIsDisabled() { QSignalSpy spyPositionChange(m_subject, SIGNAL(positionChanged(QPointF))); m_subject->currentPage = 0; m_subject->setPosition(QPointF(0, 0)); m_subject->setEnabled(false); performMovement(120, false, 0); QCOMPARE(spyPositionChange.count(), 0); m_subject->setEnabled(true); performMovement(120, false, 1); QVERIFY(spyPositionChange.count() > 0); }
void FormulaCursor::move( CursorDirection direction ) { FormulaCursor oldcursor(*this); m_direction = direction; if (performMovement(oldcursor)==false) { (*this)=oldcursor; } m_direction=NoDirection; }
bool OrbitCameraManipulator::handleMouseDrag( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { addMouseEvent( ea ); m_pointer_push_drag = true; if( performMovement( ea, aa ) ) { aa.requestRedraw(); } aa.requestContinuousUpdate( false ); _thrown = false; return true; }
void Ut_PagedPanning::testMovement(int currentPage, qreal moveAmount, bool leftToRight, int targetPage, qreal speed) { int pageCount = m_subject->pageCount(); qreal rangeStart = 0.0; qreal rangeEnd = (pageCount - 1) * DEFAULT_PAGE_WIDTH; qreal pageWidth = (rangeEnd - rangeStart) / qMax(1, pageCount - 1); qreal currentPosition = currentPage * pageWidth; m_subject->currentPage = currentPage; m_subject->setPosition(QPointF(currentPosition, 0)); int pageCrossings = std::abs(targetPage - currentPage); if (m_subject->pageWrapMode()) { pageCrossings = (qreal)moveAmount / pageWidth; } QSignalSpy spy(m_subject, SIGNAL(pageChanged(int))); performMovement(moveAmount, leftToRight, targetPage, speed); QCOMPARE(m_subject->position().x(), targetPage * DEFAULT_PAGE_WIDTH); QCOMPARE(spy.count(), pageCrossings); if (pageCrossings > 0) { QList<QVariant> arguments = spy.takeLast(); QCOMPARE(arguments.at(0).toInt(), targetPage); } }
/// Handles GUIEventAdapter::FRAME event. bool OrbitCameraManipulator::handleFrame( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { double current_frame_time = ea.getTime(); _delta_frame_time = current_frame_time - _last_frame_time; _last_frame_time = current_frame_time; if( _thrown && performMovement( ea, aa ) ) { aa.requestRedraw(); } if( m_animation_data && m_animation_data->_isAnimating ) { if( m_animation_data->_startTime < 0 ) { // animation has been started from some location without acces to a GUIEventAdapter object, so no start time could be set. Do it now. m_animation_data->start( current_frame_time ); } performAnimationMovement( ea, aa ); } return false; }