bool OrbitCameraManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
	osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();

	// TODO: increase scroll factor when eye is far away from model bounding sphere
	double scroll_distance_factor = ( m_eye - m_rotate_center ).length()*0.1;

	switch( sm )
	{
		// mouse scroll up event
	case osgGA::GUIEventAdapter::SCROLL_UP:
		{
			// perform zoom
			zoomCamera( m_wheel_zoom_factor*scroll_distance_factor );
			aa.requestRedraw();
			aa.requestContinuousUpdate( isAnimating() || _thrown );
			return true;
		}

		// mouse scroll down event
	case osgGA::GUIEventAdapter::SCROLL_DOWN:
		{
			// perform zoom
			zoomCamera( -m_wheel_zoom_factor*scroll_distance_factor );
			aa.requestRedraw();
			aa.requestContinuousUpdate( isAnimating() || _thrown );
			return true;
		}

		// unhandled mouse scrolling motion
	default:
		return false;
	}
}
示例#2
0
/*!
  \internal
  \fn void SelectedItem::moveTo(GridItem *_destItem)
  Positions the SelectedItem over the given GridItem, by starting the timer that will
  gradually shift this SelectedItem. The timer will cause moveStep(int) to be
  called, periodically.
*/
void SelectedItem::moveTo(GridItem *_destItem)
{
    // Stop any previous move and any animations.
    if ( destItem ) {
        // Setting destItem to 0 means that setCurrent(...) won't be called by moveFinished,
        // which would be overkill, as it respositions the object, restarts animation, etc.
        // What WAS the destination item becomes the new current item.
        currentItem = destItem;
        destItem = 0;
    }
    if ( moveTimeLine->state() != QTimeLine::NotRunning ) {
        moveTimeLine->stop();  // triggers moveFinished
        // TODO: This is because Qt's QTimeLine has a bug which doesn't reset the frames
        // when you stop the timeline. When you restart, it acts as though it has been paused.
        // Repair when Qt bug is resolved.
        //createMoveTimeLine();
    }

    // The order is important here. It is possible that this move request is interrupting an
    // animation. If that's the case, we'll want to stop the animation - BUT that will trigger
    // animationFinished() which calls for a redraw that we don't actually want. We set destItem
    // FIRST (so it's non-zero), so that animationFinished() can check if there's a move in the
    // pipeline, and refrain from drawing.
    destItem = _destItem;

    if ( isAnimating() ) {
        stopAnimation(); // triggers animationFinished()
    }

    // Start the timer. This will cause moveStep(int) to be called, periodically.
    moveTimeLine->start();
}
示例#3
0
bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
{
#if !defined(QT_NO_MAINWINDOW)
    Q_Q(QDockWidget);

    QDockWidgetLayout *dwLayout
        = qobject_cast<QDockWidgetLayout*>(layout);

    if (!dwLayout->nativeWindowDeco()) {
        QRect titleArea = dwLayout->titleArea();

        if (event->button() != Qt::LeftButton ||
            !titleArea.contains(event->pos()) ||
            // check if the tool window is movable... do nothing if it
            // is not (but allow moving if the window is floating)
            (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
            qobject_cast<QMainWindow*>(parent) == 0 ||
            isAnimating() || state != 0) {
            return false;
        }

        initDrag(event->pos(), false);

        if (state)
            state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;

        return true;
    }

#endif // !defined(QT_NO_MAINWINDOW)
    return false;
}
示例#4
0
bool GISManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )
{
    osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();

    osg::Vec3d eye, center, up;
    getTransformation( eye, center, up );
    double altitude = eye[2];

    if ( sm == osgGA::GUIEventAdapter::SCROLL_UP ) {
        altitude /= 1.41;
    }
    else if ( sm == osgGA::GUIEventAdapter::SCROLL_DOWN ) {
        altitude *= 1.41;
    }
    else {
        return false;
    }

    eye[2] = altitude;
    center[2] = eye[2] - 1.0;
    setTransformation( eye, center, up );

    us.requestRedraw();
    us.requestContinuousUpdate( isAnimating() );
    return true;
}
// think about units deployment animation
void cStarPort::think_deployment() {
	if (!isAnimating()) {
		return; // do nothing when not animating
	}

	if (!frigateDroppedPackage) {
		if (iFrame < 0) {
            iFrame = 1;
		}

        TIMER_flag++;

        if (TIMER_flag > 70) {
            TIMER_flag = 0;

            iFrame++;
			if (iFrame > 3) {
				iFrame = 1;
			}
        }
	} else {
		// show frame with the package
        iFrame = 4;
	}
}
void cBarracks::think_animation() {
	// a barracks does not animate, so when set, set it back to false
	if (isAnimating()) {
		setAnimating(false);
	}
	cAbstractStructure::think_animation();
	cAbstractStructure::think_flag();
}
示例#7
0
/*!
  \internal
  \fn void SelectedItem::triggerItemSelected(GridItem *)
  Called when an item has been selected/invoked.
  Emits SelectedItemConnector::itemSelected() signal.
*/
void SelectedItem::triggerItemSelected(GridItem *item)
{
    if ( isAnimating() ) {
        stopAnimation();
    }

    // Cause connector to emit itemSelected(GridItem *) signal.
    mConnector->triggerItemSelected(item);
}
示例#8
0
文件: CQSVG.cpp 项目: colinw7/CSVG
void
CQSVG::
stopTimer()
{
  if (isAnimating()) {
    timer_->stop();

    setAnimating(false);
  }
}
示例#9
0
文件: CQSVG.cpp 项目: colinw7/CSVG
void
CQSVG::
startTimer()
{
  if (! isAnimating()) {
    timer_->start(dt_);

    setAnimating(true);
  }
}
示例#10
0
/*
 * Update the routine.  Take care of any state transitions also.
 */
void routine::update() {
	if (state != HIDDEN) {
		for (list<tileGroup>::iterator it = groups.begin(); it != groups.end(); it++) {
			it->update();
		}
		
		bool animating = isAnimating();
		if (state == ENTER && !animating) setState(ACTIVE);
		else if (state == EXIT && !animating) setState(HIDDEN);
	}
}
示例#11
0
void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
{
    Q_Q(QDockWidget);

    int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);

    QRect geo = q->geometry();
    QRect titleRect = q->frameGeometry();
#ifdef Q_WS_MAC
    if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
        titleRect.setTop(geo.top());
        titleRect.setBottom(geo.bottom());
        titleRect.setRight(geo.left() - 1);
    } else
#endif
    {
        titleRect.setLeft(geo.left());
        titleRect.setRight(geo.right());
        titleRect.setBottom(geo.top() - 1);
        titleRect.adjust(0, fw, 0, 0);
    }

    switch (event->type()) {
        case QEvent::NonClientAreaMouseButtonPress:
            if (!titleRect.contains(event->globalPos()))
                break;
            if (state != 0)
                break;
            if (qobject_cast<QMainWindow*>(parent) == 0)
                break;
            if (isAnimating())
                break;
            initDrag(event->pos(), true);
            if (state == 0)
                break;
            state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
            startDrag();
            break;
        case QEvent::NonClientAreaMouseMove:
            if (state == 0 || !state->dragging)
                break;
            if (state->nca) {
                endDrag();
            }
            break;
        case QEvent::NonClientAreaMouseButtonRelease:
            break;
        case QEvent::NonClientAreaMouseButtonDblClick:
            _q_toggleTopLevel();
            break;
        default:
            break;
    }
}
示例#12
0
const SVGPathByteStream& SVGPathElement::pathByteStream() const
{
    auto property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo());
    if (!property || !property->isAnimating())
        return m_pathByteStream;
    
    SVGPathByteStream* animatedPathByteStream = static_cast<SVGAnimatedPathSegListPropertyTearOff*>(property.get())->animatedPathByteStream();
    if (!animatedPathByteStream)
        return m_pathByteStream;

    return *animatedPathByteStream;
}
示例#13
0
void Player::setDestinationTile(Tile* tile)
{
    //Set the destination tile pointer
    m_DestinationTile = tile;

    if (!isAnimating())
    {
        findPath();
    }
    else
    {
        m_AbortAnimation = true;
    }
}
void cAbstractStructure::think_flag() {
	if (isAnimating()) return; // do no flag animation when animating

	TIMER_flag++;

    if (TIMER_flag > 70) {
        iFrame++;

		// switch between 0 and 1.
		if (iFrame > 1) {
            iFrame=0;
		}

        TIMER_flag=0;
    }
}
示例#15
0
void QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
{
#if !defined(QT_NO_MAINWINDOW)
    Q_Q(QDockWidget);

    QDockWidgetLayout *layout
        = qobject_cast<QDockWidgetLayout*>(q->layout());

    if (!layout->nativeWindowDeco()) {
        QRect titleArea = layout->titleArea();

        if (event->button() != Qt::LeftButton)
            return;
        if (!titleArea.contains(event->pos()))
            return;
        // check if the tool window is movable... do nothing if it is not
        if (!::hasFeature(q, QDockWidget::DockWidgetMovable))
            return;

        if (qobject_cast<QMainWindow*>(q->parentWidget()) == 0)
            return;

        if (isAnimating())
            return;

        if (state != 0)
            return;

        initDrag(event->pos(), false);

        if (state == 0)
            return;

        state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
    }

#endif // !defined(QT_NO_MAINWINDOW)
}
示例#16
0
/*!
  \internal
  \fn void SelectedItem::moveStep(int percent)
  Called periodically during a move operation. Moves this object between currentItem and
  destItem.
*/
void SelectedItem::moveStep(int n)
{
    qreal percent = n/100.0;

    // Sanity check.
    if ( !currentItem || !destItem ) {
        qWarning("SelectedItem::moveStep(...): Error - either current item missing or destination item missing.");
        return;
    }

    // Find out how where the SelectedItem box ought to be at this stage in the move, and
    // shift it accordingly.
    QRect destRect = geometry(destItem);
    QRect srcRect = geometry(currentItem); // we might be in the middle of a move, so don't use rect() here!

    qreal moveByX = (destRect.x() - srcRect.x()) * percent;
    qreal moveByY = (destRect.y() - srcRect.y()) * percent;

    if ( isAnimating() ) {
        // THis should not be happening, as we stop the movie as soon as a move starts.
        qWarning("SelectedItem::moveStep(...): Still animating when it should not be.");
        stopAnimation();
    }

    setRect(srcRect.x() + moveByX,srcRect.y() + moveByY,srcRect.width(),srcRect.height());

    // We also have to find where the 2 images are going to sit within their designated areas,
    // because SelectedItem is essentially a magnified version of an underlying GridItem, and
    // when we're moving between two, the area between them is magnified too, i.e. the dest
    // item will move TOWARDS its usual position, while the current (soon-to-be-old) item will
    // move AWAY FROM its usual position.

    // Find the "ordinary" positions of the two items, i.e. the top left-hand corners
    // of the 2 items when they are magnified as SelectedItems.
    currentX = srcRect.x();
    currentY = srcRect.y();
    destX = destRect.x();
    destY = destRect.y();

    // Find the x position of current and dest items.
    if ( currentItem->column() < destItem->column() ) {
        // Moving from left to right.
        currentX -= qRound(percent * xDrift()); // current (left) drifts away to the left over time
        destX += qRound((1-percent) * xDrift()); // destination (right) drifts in from the right over time
    } else if ( currentItem->column() > destItem->column() ) {
        // Moving from right to left.
        currentX += qRound(percent * xDrift()); // current (right) drifts away to the right over time
        destX -= qRound((1-percent) * xDrift()); // destination (left) drifts in from the left over time
    } // else, if they're equal, currentX & destX will be their usual positions

    // Find the y position of current and dest items.
    if ( currentItem->row() < destItem->row() ) {
        // Moving down.
        currentY -= qRound(percent * yDrift()); // current (top) drifts upwards over time
        destY += qRound((1-percent) * yDrift()); // destination (bottom) drifts up from below over time
    } else if ( currentItem->row() > destItem->row() ) {
        // Moving up.
        currentY += qRound(percent * yDrift()); // current (bottom) drifts downwards over time
        destY -= qRound((1-percent) * yDrift()); // destination (top) drifts down from above over time
    } // else, if they're equal, currentY & destY will be their usual positions
}
示例#17
0
void Player::update(double aDelta)
{
    std::string ammoCount = "";
    std::stringstream ammoAmount;
    ammoAmount << m_Ammo;
    ammoAmount >> ammoCount;
    m_Font->setText(ammoCount.c_str());


    //update the projectile
    for(int i = 0; i < m_Projectiles.size(); i++)
    {
        if(m_Projectiles.at(i)->getIsActive() == true)
        {
            m_Projectiles.at(i)->update(aDelta);

        }
    }
    //Tower1
    for(int i = 0; i < m_Level->getNumberOfTiles(); i++)
    {
        if(m_Level->getTileTypeForIndex(i) == TileTypeTower)
        {
            TowerTile* temp = (TowerTile*) m_Level->getTileForIndex(i);
            for(int location = 0; location < temp->getProjecticle().size(); location++)
            {
                if (temp->getProjecticle().at(location)->getIsActive())
                    temp->getProjecticle().at(location)->update(aDelta);
            }
        }
    }
    //remove aby inactive projectiles from the projectiles vectors
    int index = 0;
    while(index != m_Projectiles.size())
    {
        if(m_Projectiles.at(index)->getIsActive() == false)
        {

            //delete the projectile and remove it from the vector
            delete m_Projectiles.at(index);
            m_Projectiles.erase(m_Projectiles.begin() + index);
        }
        else
        {
            index++;
        }
    }

    if (m_PathFinder->isSearchingPath() == true)
    {
        m_PathFinder->update(aDelta);
    }

    if (isAnimating() && m_AnimationPathNodeIndex > -1)
    {
        PathNode* pathNode = m_PathFinder->getPathNodeAtIndex(m_AnimationPathNodeIndex);
        Tile* tile = pathNode != NULL ? pathNode->getTile() : NULL;

        if(tile)
        {
            float centerX = tile->getX() + (tile->getWidth() - getWidth()) / 2.0f;
            float centerY = tile->getY() + (tile->getHeight() - getHeight()) / 2.0f;
            Tile * playerTile = m_Level->getTileForPosition(getX(), getY());
            float speed = playerTile->getTileSpeed();

            float playerX = animate(getX(), centerX, aDelta, speed);
            float playerY = animate(getY(), centerY, aDelta, speed);
            setPosition(playerX, playerY);

            //change G as float for slower and faster tiles

            if (playerX == centerX && playerY == centerY)
            {
                m_AnimationPathNodeIndex++;
                m_CurrentTile->setIsPath(false);
                setCurrentTile(tile);
                if (m_AnimationPathNodeIndex >= m_PathFinder->getPathSize())
                {
                    stopAnimating();
                    m_CurrentTile->setIsPath(false);
                }

                if(m_AbortAnimation)
                {
                    m_AbortAnimation = false;

                    findPath();
                }
            }
            else
            {
                if(m_AbortAnimation == true)
                {
                    m_AbortAnimation =false;
                    findPath();
                }
            }
        }

    }
}
示例#18
0
void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
{
    Q_Q(QDockWidget);

    int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);

    QRect geo = q->geometry();
    QRect titleRect = q->frameGeometry();
#ifdef Q_WS_MAC
    if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
        titleRect.setTop(geo.top());
        titleRect.setBottom(geo.bottom());
        titleRect.setRight(geo.left() - 1);
    } else
#endif
    {
        titleRect.setLeft(geo.left());
        titleRect.setRight(geo.right());
        titleRect.setBottom(geo.top() - 1);
        titleRect.adjust(0, fw, 0, 0);
    }

    switch (event->type()) {
        case QEvent::NonClientAreaMouseButtonPress:
            if (!titleRect.contains(event->globalPos()))
                break;
            if (state != 0)
                break;
            if (qobject_cast<QMainWindow*>(parent) == 0)
                break;
            if (isAnimating())
                break;
            initDrag(event->pos(), true);
            if (state == 0)
                break;
#ifdef Q_WS_WIN
            // On Windows, NCA mouse events don't contain modifier info
            state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
#else
            state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
#endif
            startDrag();
            break;
        case QEvent::NonClientAreaMouseMove:
            if (state == 0 || !state->dragging)
                break;
            if (state->nca) {
                endDrag();
            }
#ifdef Q_OS_MAC
            else { // workaround for lack of mouse-grab on Mac
                QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
                Q_ASSERT(layout != 0);

                q->move(event->globalPos() - state->pressPos);
                if (!state->ctrlDrag)
                    layout->hover(state->widgetItem, event->globalPos());
            }
#endif
            break;
        case QEvent::NonClientAreaMouseButtonRelease:
#ifdef Q_OS_MAC
                        if (state)
                                endDrag();
#endif
                        break;
        case QEvent::NonClientAreaMouseButtonDblClick:
            _q_toggleTopLevel();
            break;
        default:
            break;
    }
}
void CCActivityIndicator::updateVisibility()
{
    if (hidesWhenStopped && !isAnimating()) {
        indicator->setVisible(false);
    }
}