Beispiel #1
0
void YigModField::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    // Rotation happens here!
    /*
    qreal factor = -10;
    if(event->screenPos().y() < event->lastScreenPos().y())
    {
        factor *= -1;
    }

    rotationAngle += factor;

    if(rotationAngle < 0)
    {
        rotationAngle = 0;
    }

    else if(rotationAngle > 360)
    {
        rotationAngle = 359.9999;
    }*/

    rotationAngle = angleFromCenter(event->scenePos());
    setRotation(rotationAngle);
    transformOriginPoint();
    updateParameter(fmod((rotationAngle+180), 360)/360);
    QGraphicsEllipseItem::mouseMoveEvent(event);
    //redrawArc();
}
Beispiel #2
0
void YigModField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    //setCursor(Qt::ArrowCursor);
    rotationAngle = angleFromCenter(event->scenePos());
    setRotation(rotationAngle);
    transformOriginPoint();
    updateParameter(fmod((rotationAngle+180), 360)/360);
    QGraphicsEllipseItem::mouseReleaseEvent(event);
}
Beispiel #3
0
YigModField::YigModField(YigSynthGraphic *synthGraphic, float param, qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent) :
    QGraphicsEllipseItem( x, y, width, height, parent ),
    modArc(this),
    yigAttractor(this),
    modTriangle(this)
{
    //createModCircle();
    parentGraphic = synthGraphic;
    setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2);
    rotationAngle = param * 360;
    setRotation(fmod(rotationAngle+180, 360));
    transformOriginPoint();
    updateParameter(fmod((rotationAngle+180), 360)/360);
    modTriangle.setZValue(99);
    QPolygonF modPolygon;
    modPolygon.append(QPointF(0, 0));
    modPolygon.append(QPointF(5, 15));
    modPolygon.append(QPointF(-5, 15));
    modPolygon.translate(width/2, 0);
    modTriangle.setPolygon(modPolygon);
    QPen modPen(Qt::NoPen);
    modTriangle.setPen(modPen);
    QColor modColor(YigColorKit::background2);
    modColor.setAlpha(200);
    QBrush modBrush(modColor);
    modTriangle.setBrush(modBrush);
    // Mod amount
    /*
    modElectron = new QGraphicsEllipseItem(0, 0, 25, 25, this);
    modElectron->moveBy(0, (boundingRect().width()/2) - 3);
    modElectron->setFlag( QGraphicsItem::ItemIsSelectable, false );
    modElectron->setFlag( QGraphicsItem::ItemIsMovable, false );
    modElectron->setCacheMode( QGraphicsItem::ItemCoordinateCache );
    QColor modColor(YigColorKit::background2);
    modColor.setAlpha(200);
    modElectron->setPen(QPen(modColor));
    modColor.setAlpha(20);
    modElectron->setBrush(modColor);*/

    /*
    QColor modFill(YigColorKit::background2);
    modFill.setAlpha(100);
    QColor modOutline(YigColorKit::background2);
    modOutline.setAlpha(220);
    modArc.setBrush(modFill);
    modArc.setPen(Qt::NoPen);*/
    //redrawArc();
}
Beispiel #4
0
Cell* Cell::copy(Cell *cell)
{
    Cell *c = 0;
    if(!cell)
        c = new Cell();
    else
        c = cell;

    c->setStitch(stitch());
    c->setBgColor(bgColor());
    c->setColor(c->color());
    c->setTransformOriginPoint(transformOriginPoint());
    c->setRotation(0);
    c->setTransform(QTransform());
	c->setTransformations(ChartItemTools::cloneGraphicsTransformations(this));
	foreach (QGraphicsTransform* t, transformations())
		t->setParent(parentObject());

    return c;
}
int QGraphicsObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 13)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 13;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QGraphicsObject**>(_v) = parentObject(); break;
        case 1: *reinterpret_cast< qreal*>(_v) = opacity(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break;
        case 3: *reinterpret_cast< bool*>(_v) = isVisible(); break;
        case 4: *reinterpret_cast< QPointF*>(_v) = pos(); break;
        case 5: *reinterpret_cast< qreal*>(_v) = x(); break;
        case 6: *reinterpret_cast< qreal*>(_v) = y(); break;
        case 7: *reinterpret_cast< qreal*>(_v) = zValue(); break;
        case 8: *reinterpret_cast< qreal*>(_v) = rotation(); break;
        case 9: *reinterpret_cast< qreal*>(_v) = scale(); break;
        case 10: *reinterpret_cast< QPointF*>(_v) = transformOriginPoint(); break;
        case 11: *reinterpret_cast< QGraphicsEffect**>(_v) = graphicsEffect(); break;
        case 12: *reinterpret_cast< QDeclarativeListProperty<QGraphicsObject>*>(_v) = QGraphicsItem::d_func()->childrenList(); break;
        case 13: *reinterpret_cast< qreal*>(_v) = QGraphicsItem::d_func()->width(); break;
        case 14: *reinterpret_cast< qreal*>(_v) = QGraphicsItem::d_func()->height(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setParentItem(*reinterpret_cast< QGraphicsObject**>(_v)); break;
        case 1: setOpacity(*reinterpret_cast< qreal*>(_v)); break;
        case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 3: setVisible(*reinterpret_cast< bool*>(_v)); break;
        case 4: setPos(*reinterpret_cast< QPointF*>(_v)); break;
        case 5: setX(*reinterpret_cast< qreal*>(_v)); break;
        case 6: setY(*reinterpret_cast< qreal*>(_v)); break;
        case 7: setZValue(*reinterpret_cast< qreal*>(_v)); break;
        case 8: setRotation(*reinterpret_cast< qreal*>(_v)); break;
        case 9: setScale(*reinterpret_cast< qreal*>(_v)); break;
        case 10: setTransformOriginPoint(*reinterpret_cast< QPointF*>(_v)); break;
        case 11: setGraphicsEffect(*reinterpret_cast< QGraphicsEffect**>(_v)); break;
        case 13: QGraphicsItem::d_func()->setWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 14: QGraphicsItem::d_func()->setHeight(*reinterpret_cast< qreal*>(_v)); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::ResetProperty) {
        switch (_id) {
        case 13: QGraphicsItem::d_func()->resetWidth(); break;
        case 14: QGraphicsItem::d_func()->resetHeight(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 15;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}