void SinglePhotoView::mousePressEvent(QMouseEvent *event){
    QPointF qp = this->mapToScene(event->x(),event->y());

    if (event->button()==Qt::LeftButton)
        pppCur = &dstPointPaint, pppOther = &srcPointPaint;
    else
        pppCur = &srcPointPaint, pppOther = &dstPointPaint;
    int tI = pppCur->pickPointByMouse(qp);
    if (tI != -1){
        pppCur->selectPoint(tI);
        pppOther->setMirrorPoint(tI);
        //emit selectedPointUpdated(tI);
        dragging = true;
        //qDebug("Emit: %d",tI);
    }
    else if (allowAddPoints) {
        pppCur->addPoint(qp);
        pppCur->selectPoint(-1);
        pppOther->setMirrorPoint(pppCur->getSize());
        emit pointsUpdated();
//        emit selectedPointUpdated(pointPaint.getSize());
    }
    // selectedPoints.append(qp.toPoint());
    //cout<<"x: "<<selectedPoints.size()<<endl;
    // pointPaint.update();
    //cout<<selectedPoints.boundingRect()<<endl;
    // this->update();

    //QGraphicsView::mousePressEvent(event);
}
void SinglePhotoView::clearAllPoints()
{
    dstPointPaint.clear();
    srcPointPaint.clear();
    emit pointsUpdated();
    this->update();
}
void SinglePhotoView::copySrcPointsToDst()
{
    dstPointPaint.clear();
    QList< QPoint > qtemp = srcPointPaint.getPointList();
    for (int i=0;i<qtemp.size();i++)
        dstPointPaint.addPoint(QPointF(qtemp[i]));
    emit pointsUpdated();
    this->update();
}
void SinglePhotoView::setPointList(
        const QList< QPoint > &qlSrc,
        const QList< QPoint > &qlDst){
    srcPointPaint.clear();
    dstPointPaint.clear();
    int i;
    for (i=0;i<qlSrc.size();i++)
        srcPointPaint.addPoint(QPointF(qlSrc[i]));
    for (i=0;i<qlDst.size();i++)
        dstPointPaint.addPoint(QPointF(qlDst[i]));
    emit pointsUpdated();
}
Beispiel #5
0
GradientEditor::GradientEditor(QWidget *parent)
    : QWidget(parent)
{
    QVBoxLayout *vbox = new QVBoxLayout(this);
    vbox->setSpacing(1);
    vbox->setMargin(1);

    m_red_shade = new ShadeWidget(ShadeWidget::RedShade, this);
    m_green_shade = new ShadeWidget(ShadeWidget::GreenShade, this);
    m_blue_shade = new ShadeWidget(ShadeWidget::BlueShade, this);
    m_alpha_shade = new ShadeWidget(ShadeWidget::ARGBShade, this);

    vbox->addWidget(m_red_shade);
    vbox->addWidget(m_green_shade);
    vbox->addWidget(m_blue_shade);
    vbox->addWidget(m_alpha_shade);

    connect(m_red_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
    connect(m_green_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
    connect(m_blue_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
    connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated()));
}
void SinglePhotoView::mouseMoveEvent(QMouseEvent *event)
{
    if ( dragging ){
        pppCur->updateSelectedPoint(this->mapToScene(event->pos()));
        emit pointsUpdated();
        return;
    }
    QPointF qp = this->mapToScene(event->x(),event->y());
    int tI;
    tI = srcPointPaint.pickPointByMouse(qp);
    srcPointPaint.highLight(tI);
    tI = dstPointPaint.pickPointByMouse(qp);
    dstPointPaint.highLight(tI);
    QGraphicsView::mouseMoveEvent(event);
}