예제 #1
0
void WatchVector::attachFpData(PixelBox *f, QString name)
{
    int idx;

    if (!f) {
        return;
    }

    if (!getNumFreeMappings()) {
        return;
    }

    if (getIndexFromPixelBox(f) != -1) {
        return;
    }
    
    /* Fill empty slot with attachment */
    idx = getFirstFreeMapping();
    m_pData[idx] = f;
    m_qName[idx] = name;
    m_nActiveMappings++;

    connect(f, SIGNAL(dataChanged()), this, SLOT(updateData()));
    connect(f, SIGNAL(dataDeleted()), this, SLOT(detachData()));
    connect(this->m_pImageView, SIGNAL(minMaxAreaChanged(const QRect&)), 
        f, SLOT(setMinMaxArea(const QRect&)));
    connect(this->m_pImageView, SIGNAL(setMappingBounds()), this,
        SLOT(updateAllMinMax()));        
    connect(f, SIGNAL(minMaxAreaChanged()), this, SLOT(onMinMaxAreaChanged()));


    addMappingOptions(idx);
    updateGUI();
}
예제 #2
0
void ImageView::setMouseMode(int mouseMode)
{
    m_mouseMode = mouseMode;
    switch (m_mouseMode) {
        case MM_ZOOM:
            setCustomCursor(":/cursors/cursors/zoom-in.png");
            break;
        case MM_PICK:
            setCustomCursor(":/cursors/cursors/pick.png");
            break;
        case MM_MINMAX:
            setCustomCursor(":/cursors/cursors/min-max.png");
            break;
        default:
            break;
    }

    if (m_mouseMode != MM_MINMAX) {
        this->m_minMaxLens->setGeometry(QRect());
        this->m_minMaxLens->setVisible(false);
        emit minMaxAreaChanged(this->m_minMaxLens->geometry());
        this->repaint(0, 0, -1, -1);
    }
}
예제 #3
0
void PixelBox::setMinMaxArea(const QRect& minMaxArea)
{
	this->m_minMaxArea = minMaxArea;
	emit minMaxAreaChanged();
}
예제 #4
0
void ImageView::mouseReleaseEvent(QMouseEvent *event)
{
    switch (m_mouseMode) {
        case MM_ZOOM:	
            m_rubberBand->hide();
            if (m_rubberBand->geometry().isNull()) {
                /* Zoom step. */
                int newCenterX, newCenterY;
                int x = event->x();
                int y = event->y();

                if (event->modifiers() & Qt::ControlModifier) {
                    this->zoomOut();
                    if (m_zoomLevel != 1) {
                        newCenterX = (int)(x * (this->m_zoomLevel - 1.0) 
                            / this->m_zoomLevel);
                        newCenterY = (int)(y * (this->m_zoomLevel - 1.0) 
                            / this->m_zoomLevel);
                        emit viewCenterChanged(newCenterX, newCenterY);
                        if (visibleRegion().contains(event->pos())) {
                            this->canvasToImage(x, y);
                            emit mousePosChanged(x, y);
                        } else {
                            emit mousePosChanged(-1, -1);
                        }
                    }
                } else if (event->modifiers() == Qt::ShiftModifier) {
                    this->setZoomLevel(1.0f);
                } else {
                    this->zoomIn();
                    newCenterX = (int)(x * (this->m_zoomLevel + 1.0) 
                        / this->m_zoomLevel);
                    newCenterY = (int)(y * (this->m_zoomLevel + 1.0) 
                        / this->m_zoomLevel);
                    emit viewCenterChanged(newCenterX, newCenterY);
                    if (visibleRegion().contains(event->pos())) {
                        this->canvasToImage(x, y);
                        emit mousePosChanged(x, y);
                    } else {
                        emit mousePosChanged(-1, -1);
                    }
                }

            } else {
                /* Lasso zoom. */
                if (!(event->modifiers() & Qt::ControlModifier)) {
                    zoomRegion(m_rubberBand->geometry());
                }
            }
            break;
        case MM_MINMAX: 
            {
                QRect selRect = this->m_minMaxLens->geometry();
                //QRect visRect = this->visibleRegion().boundingRect();
                selRect.moveLeft(selRect.left() / this->m_zoomLevel);
                selRect.moveTop(selRect.top() / this->m_zoomLevel);
                selRect.setWidth(::ceilf(static_cast<float>(selRect.width()) 
                            / this->m_zoomLevel));
                selRect.setHeight(::ceilf(static_cast<float>(selRect.height()) 
                            / this->m_zoomLevel));
                emit minMaxAreaChanged(selRect);
                this->m_minMaxLens->setVisible(false);
                if (event->modifiers() & Qt::ControlModifier) {
                    emit setMappingBounds();
                }
            } break;
        default:
            break;
    }
}