Пример #1
0
QScriptValue PHIBaseItem::rotateOut( quint8 axis, qint32 start, qint32 duration, const QString &ease )
{
    QEasingCurve::Type curve=PHI::toEasingCurveType( ease );
    _effect->setRotateOut( axis, start, duration, curve );
    if ( !isClientItem() ) return self();
    QParallelAnimationGroup *group=new QParallelAnimationGroup( this );
    if ( axis & 0x1 ) {
        setXRotation( 0 );
        QPropertyAnimation *xrot=new QPropertyAnimation( this, BL( "_xRotation" ), group );
        xrot->setEndValue( 90. );
        xrot->setDuration( duration );
        xrot->setEasingCurve( curve );
        group->addAnimation( xrot );
    }
    if ( axis & 0x2 ) {
        setYRotation( 0 );
        QPropertyAnimation *yrot=new QPropertyAnimation( this, BL( "_yRotation" ), group );
        yrot->setEndValue( 90. );
        yrot->setDuration( duration );
        yrot->setEasingCurve( curve );
        group->addAnimation( yrot );
    }
    connect( group, &QAbstractAnimation::finished, this, &PHIBaseItem::privateHide );
    connect( group, &QAbstractAnimation::finished, group, &QAbstractAnimation::deleteLater );
    QTimer::singleShot( start, group, SLOT( start() ) );
    return self();
}
Пример #2
0
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton)
    {
        if (isRotate)
        {
            setXRotation(xRot + 8 * dy);
            setYRotation(yRot + 8 * dx);
        }
        else if (isScale)
            setupScale(dx, dy);
        else if (isTranslate)
            setupTranslate(dx, dy);
    }
    else if (event->buttons() & Qt::RightButton)
    {
        if (isRotate)
        {
            setXRotation(xRot + 8 * dy);
            setZRotation(zRot + 8 * dx);
        }
        /*else if (isScale)
        {
            scale /= 1.05;
            updateGL();
        }*/
    }
    lastPos = event->pos();
}
Пример #3
0
void GLWidget::setBottomView()
{
    makeCurrent();
    setXRotation(0);
    setYRotation(180*16);
    setZRotation(0);
}
Пример #4
0
void GLWidget::setTopFrontLeftView()
{
    makeCurrent();
    setXRotation(290*16);
    setYRotation(0);
    setZRotation(30*16);
}
Пример #5
0
void GLWidget::setRightView()
{
    makeCurrent();
    setXRotation(270*16);
    setYRotation(0);
    setZRotation(270*16);
}
Пример #6
0
void GLWidget::setTopView()
{
    makeCurrent();
    setXRotation(0);
    setYRotation(0);
    setZRotation(0);
}
Пример #7
0
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
        // Es canvien els angles de visio de la camera segons el desplacament
        // Si hi ha un desplacament en X del viewport, es canviara l angle Y
        // Si hi ha un desplacament en Y del viewport, es canviara l angle X
        setYRotation( 8 * dx);
        setXRotation( 8 * dy);

    } else if (event->buttons() & Qt::RightButton) {

        // panning
        pan(dx, dy);

    } else if (event->buttons() & Qt::MidButton) {

        // zoom
        if (lastPos.y() > event->y())
            zoom(-0.05, dy);
        else
            zoom(0.05, dy);
    }

    lastPos = event->pos();
}
Пример #8
0
 void GLWidget::mouseMoveEvent(QMouseEvent *event)
 {
     // Dedicated to the rotation.
     int dx = event->x() - m_lastPosRotation.x() ;
     int dy = event->y() - m_lastPosRotation.y() ;

     if (event->buttons() & Qt::LeftButton)
     {
         setXRotation(m_xRot + 8 * dy) ;
         setYRotation(m_yRot + 8 * dx) ;
     }
     else if (event->buttons() & Qt::RightButton)
     {
         setXRotation(m_xRot + 8 * dy) ;
         setZRotation(m_zRot + 8 * dx) ;
     }
     m_lastPosRotation = event->pos() ;

     // Dedicated to the cursor.
     double xOpenGL=0, yOpenGL=0, zOpenGL=0 ;
     calculateOpenGLPositionFromScreenCoordinate( event->pos(), xOpenGL, yOpenGL, zOpenGL ) ;
     m_xCursor = xOpenGL ;
     m_yCursor = yOpenGL ;
     m_zCursor = zOpenGL ;

     updateGL() ;
 }
Пример #9
0
void CompassWidget::setAllRotations(float xAngle, float yAngle, float zAngle)
{
// 	setXRotation( (int) (xAngle*16) );
// 	setYRotation( (int) (yAngle*16) );
// 	setZRotation( (int) (zAngle*16) );
	setXRotation( xAngle );
	setYRotation( yAngle );
	setZRotation( zAngle );
}
Пример #10
0
void	GLWidget::mouseMoveEvent(QMouseEvent * event){
	int	dx	=	event->x()-lastPos.x();
	int	dy	=	event->y()-lastPos.y();

	if(event->buttons() & Qt::LeftButton){
		setXRotation(xRot+8*dy);
		setYRotation(yRot+8*dx);
	}

	lastPos	=	event->pos();
}
Пример #11
0
void CompasWidget::mouseMoveEvent(QMouseEvent *event){
	int dx = event->x() - m_lastPos.x();
	int dy = event->y() - m_lastPos.y();

	if (event->buttons() & Qt::LeftButton) {
		setXRotation(m_xRot + 8 * dy);
		setYRotation(m_yRot + 8 * dx);
	} else if (event->buttons() & Qt::RightButton) {
		setXRotation(m_xRot + 8 * dy);
		setZRotation(m_zRot + 8 * dx);
	}
	m_lastPos = event->pos();
}
//! [10]
void Visualizer::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(xRot + 8 * dy);
        setYRotation(yRot + 8 * dx);
    } else if (event->buttons() & Qt::RightButton) {
        setXRotation(xRot + 8 * dy);
        setZRotation(zRot + 8 * dx);
    }
    lastPos = event->pos();
}
Пример #13
0
//metodo que responde al movimiento del raton
void graficos::mouseMoveEvent(QMouseEvent *event){
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
		setXRotation(xRot + 8 * dx);
        setYRotation(yRot + 8 * dy);
    } /*else if (event->buttons() & Qt::RightButton) {
		pcamara[1] = 10*sin(dy*PI/360);
		pcamara[2] = 10*cos(dx*PI/360);
    }*/

    lastPos = event->pos();
}
Пример #14
0
void PainelOpenGL::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(xRot + 8 * dy);
        setYRotation(yRot + 8 * dx);
    } else if (event->buttons() & Qt::RightButton) {
        setXRotation(xRot + 8 * dy);
        setZRotation(zRot + 8 * dx);
    }
    //glFrustum();
    lastPos = event->pos();
}
Пример #15
0
//! [10]
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{

    if (event->buttons() & Qt::LeftButton) {
    	int dx = event->x() - lastPos.x();
    	int dy = event->y() - lastPos.y();
        setXRotation(xRot + 8 * dy);
        setYRotation(yRot + 8 * dx);
    } else if (event->buttons() & Qt::RightButton) {
		float ratio = 2.0/scale;
		xMove += ratio * (float)(event->x() - lastPos.x())/this->size().width();
		yMove -= ratio * (float)(event->y() - lastPos.y())/this->size().height();
		updateGL();
    }
    lastPos = event->pos();
}
Пример #16
0
//! [10]
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(xRot +  dy);
        setYRotation(yRot +  dx);
    } else if (event->buttons() & Qt::RightButton) {
        setXRotation(xRot + 8 * dy);
        setZRotation(zRot + 8 * dx);
    }
    lastPos = event->pos();

    rotation = QQuaternion::fromAxisAndAngle(0,0,1, 8*dx) * rotation;
    rotation = QQuaternion::fromAxisAndAngle(0,1,0, 8*dy) *rotation;
}
Пример #17
0
void Camera::OnMouseMove(int x, int y) 
{ 	
	// The movement
	int dx = x - m_lastPosX;
	int dy = y - m_lastPosY;

	float divAngle = 5000.0f;

	m_xMov = (float)dx / divAngle;
	m_yMov = (float)dy / divAngle;

	setYRotation(m_yMov);
	setXRotation(m_xMov);
			
	m_lastPosX = x;	
	m_lastPosY = y;
}
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    // 鼠标拖动的旋转速率
    //默认为8
    double rotateRate = 8;

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(xRot + rotateRate * dy);
        setYRotation(yRot + rotateRate * dx);
    } else if (event->buttons() & Qt::RightButton) {
        setXRotation(xRot + rotateRate * dy);
        setZRotation(zRot + rotateRate * dx);
    }
    lastPos = event->pos();
}
Пример #19
0
/*
 * Mouse displacement handler (within the framebuffer)
 *
 * Mouse rotation is modified X/Y on left-click, X/Z on right-click
 * (user must hold down the button to acheive this behavior)
 */
void GLWidget::mouseMoveEvent( QMouseEvent *event )
{
        int dx = event->x() - lastPos.x();
        int dy = event->y() - lastPos.y();

        if (event->buttons() & Qt::LeftButton) {
                setXRotation( xRot + 8 * dy );
                setYRotation( yRot + 8 * dx );
        }
        else {
                setXRotation( xRot + 8 * dy );
                setZRotation( zRot + 8 * dx );
        }

        // Update lastPos with the new position so subsequent moves
        // will be handled based off of the present location.
        lastPos = event->pos();
}
Пример #20
0
int InputView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: xRotationChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: yRotationChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: zRotationChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: setXRotation((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: setYRotation((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 5: setZRotation((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 6;
    }
    return _id;
}
Пример #21
0
void OpenGLContainer::mouseMoveEvent(QMouseEvent *event) {
  // Size of dx and dy represent the speed of movement along the respective axis
  int dx = event->x() - lastPos.x();
  int dy = event->y() - lastPos.y();

  if(event->buttons() & Qt::LeftButton) {
    setXRotation(xRot + 8. * dy);
    setYRotation(yRot + 8. * dx);
  }
  else if (event->buttons() & Qt::RightButton) {
    setXRotation(xRot + 8. * dy);
    setZRotation(zRot + 8. * dx);
  }

  lastPos = event->pos();

  // Translate camera horizontally and vertically
  if(toggleTranslation) setXYTranslation(dx, dy);
}
Пример #22
0
void GLWidget::mouseMoveEvent(QMouseEvent *event) {

    int dx = event->x() - lastPos_.x();
    int dy = event->y() - lastPos_.y();

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(xRot_ + 8 * dy);
        setYRotation(yRot_ + 8 * dx);
    } else if (event->buttons() & Qt::RightButton) {
        setXRotation(xRot_ + 8 * dy);
        setZRotation(zRot_ + 8 * dx);
    }
    else if (event -> buttons() & Qt::MiddleButton) {
        //std::cerr<<"tup\n";
        setXTranslate(xTranslate_ + 0.002*dx/scale_);
        setYTranslate(yTranslate_ - 0.002*dy/scale_);
    }

    lastPos_ = event->pos();
}
Пример #23
0
void Simulator::mouseMoveEvent(QMouseEvent* event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() && Qt::LeftButton)
    {
        setXRotation(xRot + 8*dy);
        setYRotation(yRot + 8*dx);
    }
    else if (event->buttons() && Qt::RightButton)
    {
        setXRotation(xRot + 8*dy);
        setZRotation(zRot + 8*dx);
    }

    lastPos = event->pos();

    if (!timerID)
        updateGL();
}
Пример #24
0
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(rotation[0] + 8 * dy);
        setYRotation(rotation[1] + 8 * dx);

        theta += dx/2;
        phi += dy/2;

        theta %= 360;
        phi %=360;

    } else if (event->buttons() & Qt::RightButton) {
        setXRotation(rotation[0] + 8 * dy);
        setZRotation(rotation[2] + 8 * dx);
    }
    lastPos = event->pos();
}
Пример #25
0
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
    int dx = event->x() - lastPos.x();
    int dy = event->y() - lastPos.y();

    if (event->buttons() & Qt::LeftButton) {
        setXRotation(xRot + 8 * dy);
        setYRotation(yRot + 8 * dx);

		cam->OnMouseMove(event->x(),event->y());

		updateGL();
    } else if (event->buttons() & Qt::RightButton) {
        //setXRotation(xRot + 8 * dy);
        //setZRotation(zRot + 8 * dx);
		cam->OnMouseMove(event->x(),event->y());

		updateGL();
    }
    lastPos = event->pos();
	
}
Пример #26
0
void FLGLWidget::mouseMoveEvent(QMouseEvent *event)
{
   int dx = event->x() - lastPos.x();
   int dy = event->y() - lastPos.y();

   if (event->buttons() & Qt::LeftButton) {
      setXRotation(xRot + 8 * dy);
      setYRotation(yRot + 8 * dx);
   } else if (event->buttons() & Qt::RightButton) {
      setXRotation(xRot + 8 * dy);
      setZRotation(zRot + 8 * dx);
   }
   lastPos = event->pos();
    
    QMatrix4x4 a,b;
    a.perspective(60.f, 1., .1f, 10.f);
    b.rotate(zRot / 16., QVector3D(0,0,1));
    b.rotate(yRot / 16., QVector3D(0,1,0));
    b.rotate(xRot / 16., QVector3D(1,0,0));
    for(size_t v = 0; v < 3; v++)
        pts_[v] = a * b * points_[v];
    m_vertexBuffer.allocate( pts_, 3 * 4 * sizeof( float ) );
}
Пример #27
0
//------------------------------------------------------------------------------
// onYRotate() -- updates the Y rotation value (rad)
//------------------------------------------------------------------------------
bool Rotators::onYRotate(const Basic::Angle* const rotation)
{
    if (rotation != nullptr)
        return setYRotation(static_cast<LCreal>(Basic::Radians::convertStatic(*rotation)));
    return false;
}
Пример #28
0
/*
 * Constructor to setup the scene
 */
GLWidget::GLWidget( QWidget *parent ) :
                QGLWidget( QGLFormat( QGL::SampleBuffers ), parent )
{
        // We'll start WITHOUT a logo first because it's put in by 
        // GLWidget::initializeGL() anyway.
        logo = 0;

        ///////////////////////////////////////
        // Attempt to load whatever asset
        ///////////////////////////////////////
        asset = new Asset3ds("models/elecloco/Locomotive chs4 072.3DS");


        std::cerr << "Loaded a new asset" << std::endl ;

        // Look dead-on at the scene to start (no initial rotations)
        setXRotation( 0 );
        setYRotation( 0 );
        setZRotation( 0 );

        // Position Offset Initializer
        xPos = yPos = 0;

        // Push model BACK a bit to start. This is important because
        // some are ungodly huge and need to be visible at least in some
        // fashion right away, less the user thinks something failed.
        zPos = -20.0;

        // Initialize motion state bools
        moveUp_ = moveDn_ = moveRight_ = moveLeft_ = false;

        // These colors must be generated via CMYK values otherwise
        // it seems lighting will simply NOT WORK.
        qtGreen = QColor::fromCmykF( 0.2, 0.1, 0.9, 0.3 );
        qtPurple = QColor::fromCmykF( 0.4, 0.4, 0.0, 0.1 );
        qtGray = QColor::fromCmykF( 0.0, 0.0, 0.0, 0.75 );
        qtRed = QColor::fromCmykF( 0.1, 0.7, 0.9, 0.2 );
        qtDark = QColor::fromCmykF( 0.0, 0.0, 0.0, 0.85 );

        // Initially going to say the ambient light is on
        // (as is the movable light)
        ambientLight = true;
        flashlightOn = true;
        oppositeOn   = true;

        // The starting values for the variable color light
        auxRed(10);
        auxGreen(10);
        auxBlue(10);
        
        // Make the default on instantiation be perspective projection
        p_Perspective();

        // Default size of orthographic projection mode
        // (These are changed with the mouse wheel when in PROJECTION).
        ortho_left = ortho_top = -3.0;
        ortho_bottom = ortho_right = 3.0;

        // Begin the updating of the GLwidget using the QTimerEvent here
        startTimer( 20 );
}
Пример #29
0
//------------------------------------------------------------------------------
// onYRotate() -- updates the Y rotation value (rad)
//------------------------------------------------------------------------------
bool Rotators::onYRotate(const Basic::Number* const rotation)
{
    if (rotation != 0) return setYRotation( rotation->getReal() );
    return false;
}
Пример #30
0
//------------------------------------------------------------------------------
// onYRotate() -- updates the Y rotation value (rad)
//------------------------------------------------------------------------------
bool Rotators::onYRotate(const Basic::Angle* const rotation)
{
    if (rotation != 0) return setYRotation( (LCreal)Basic::Radians::convertStatic( *rotation ) );
    return false;
}