예제 #1
0
void ScreeniePixmapItem::transformPixmap(QGraphicsSceneMouseEvent *event)
{
    int deltaX, deltaY;
    switch (event->buttons()) {
    case Qt::RightButton:
        deltaX = event->lastScreenPos().x() - event->screenPos().x();
        rotate(deltaX);
        event->accept();
        break;

     case Qt::MiddleButton:
        deltaY = event->lastScreenPos().y() - event->screenPos().y();
        addDistance(deltaY);
        event->accept();
        break;

    case Qt::LeftButton:
        // Welcome to the Exception To The Rule "Modify model via Controller"!
        // moving items requires quite some logic, and we re-use that logic
        // (the Qt implementation of handling move events, to be specific)
        // So first we update the View, and THEN we update the Model.
        // (see #itemChange above)
        // As we get a signal by the model nevertheless we ignore it my raising
        // a flag, because we already updated the View ourselves
        d->ignoreUpdates = true;
        selectExclusive();
        QGraphicsPixmapItem::mouseMoveEvent(event);
        break;

     default:
        event->ignore();
        break;
    }
}
예제 #2
0
void ScreenieControl::frenchConnection()
{
    connect(&d->screenieScene, SIGNAL(distanceChanged()),
            this, SLOT(handleDistanceChanged()));
    connect(&d->screenieScene, SIGNAL(modelAdded(ScreenieModelInterface &)),
            this, SLOT(handleModelAdded(ScreenieModelInterface &)));
    connect(&d->screenieScene, SIGNAL(modelRemoved(ScreenieModelInterface &)),
            this, SLOT(handleModelRemoved(ScreenieModelInterface &)));
    connect(&d->screenieScene, SIGNAL(backgroundChanged()),
            this, SLOT(handleBackgroundChanged()));
    connect(&d->screenieGraphicsScene, SIGNAL(imagesDropped(QList<QImage>, QPointF)),
            this, SLOT(handleImageDrop(QList<QImage>, QPointF)));
    connect(&d->screenieGraphicsScene, SIGNAL(filePathsDropped(QStringList, QPointF)),
            this, SLOT(handleFilePathsDrop(QStringList, QPointF)));
    connect(&d->screenieGraphicsScene, SIGNAL(rotate(int)),
            this, SLOT(rotate(int)));
    connect(&d->screenieGraphicsScene, SIGNAL(addDistance(qreal)),
            this, SLOT(addDistance(qreal)));
    connect(&d->screenieGraphicsScene, SIGNAL(translate(qreal, qreal)),
            this, SLOT(translate(qreal, qreal)));
    connect(&d->qualityTimer, SIGNAL(timeout()),
            this, SLOT(restoreRenderQuality()));
}
예제 #3
0
void ScreeniePixmapItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{
    int value;
    // On Windows 7 pinch gestures are mapped to wheel events with CTRL pressed,
    // also refer to: http://msdn.microsoft.com/en-us/library/dd940543%28v=vs.85%29.aspx
    if (Qt::ControlModifier & event->modifiers()) {
        value = -event->delta() / 12;
    } else {
        value = event->delta() / 12;
    }
    if (isInsidePixmap(event->pos())) {
        addDistance(value);
    } else {
        addReflectionOpacity(value);
    }
    event->accept();
}
예제 #4
0
//Mouse scroll callback for Edit Mode
void glfwEditScroll(GLFWwindow *window, double xOffset, double yOffset) {
   //Change dup num if N is pressed
   if(eKeysPressed['N'] == 1) {
      changeDupNumBy(yOffset);
   }
   //Change scale if F is being held along with scroll wheel
   if(eKeysPressed['F'] == 1) {
      //Scale in Z
      if(eKeysPressed['Z'] == 1) {
         if(eKeysPressed[341]) {
            scaleSelectedEntityZ(yOffset * 0.5);
         }
         else {
            scaleSelectedEntityZ(yOffset * 0.05);
         }
      }
      //Scale in X
      if(eKeysPressed['X'] == 1) {
         if(eKeysPressed[341]) {
            scaleSelectedEntityX(yOffset * 0.5);
         }
         else {
            scaleSelectedEntityX(yOffset * 0.05);
         }
      }
      //Scale in Y
      if(eKeysPressed['C'] == 1) {
         if(eKeysPressed[341]) {
            scaleSelectedEntityY(yOffset * 0.5);
         }
         else {
            scaleSelectedEntityY(yOffset * 0.05);
         }
      }
      //Else uniformly scaled
      else if(!eKeysPressed['Z'] && !eKeysPressed['X'] && !eKeysPressed['C']){
         scaleSelectedEntity(glm::vec3(yOffset * 0.05, yOffset * 0.05, yOffset * 0.05));
      }
   }
   //Change rotation if E is being held along with scroll wheel
   else if(eKeysPressed['E'] == 1) {
      //If left shift, change line rotation
      if(eKeysPressed[340]) {
         rotateLineAngle(yOffset);
      }
      //If left control, change spacing inbetween each selected entity
      else if(eKeysPressed[341]) {
         changeCESpacing(yOffset * 0.1);
      }
      //else rotate the model selected
      else {
         rotateSelectedEntities(yOffset);
      }
   }
   //If the change will be in range
   else if(getDistance() + yOffset * 0.1 <= 70.0 && getDistance() + yOffset * 0.1 >= 1.0) {
      //printf("getDistance %f\n", getDistance());
      //If l-shift increment by a tiny amount
      if(eKeysPressed[340] == 1) {
         addDistance(0.1 * yOffset);
      }
      //else if all other keys that involve scroll wheel weren't pressed
      else if(!eKeysPressed['N'] && !eKeysPressed['F'] && !eKeysPressed['E']) {
         addDistance(0.5 * yOffset);
      }
   }
}