예제 #1
0
FloatFlowBuffer::FloatFlowBuffer(FlowBuffer *that)
    : FloatFlowBufferBase(that->h, that->w, true)
{
    for (int i = 0; i < that->h; i++)
    {
        for (int j = 0; j < that->w; j++)
        {
            if (!that->isElementKnown(i, j))
                continue;

            FlowElement shift = that->element(i, j);
            this->element(i, j) = FloatFlow(Vector2dd(shift.x(), shift.y()));
        }
    }
}
예제 #2
0
void PaintImageWidget::childMousePressed(QMouseEvent *event)
{
    AdvancedImageWidget::childMousePressed(event);

    if ((PaintImageWidget::PaintToolClass)mCurrentToolClass == SELECT_TOOL)
    {
        Vector2dd releasePoint = Vector2dd(event->x(), event->y());
        bool shiftPressed = event->modifiers().testFlag(Qt::ShiftModifier);
        mUi->widget->update();

        Vector2dd imagePoint = widgetToImageF(releasePoint);
        SelectableGeometryFeatures::Vertex *vertex = mFeatures.findClosest(imagePoint);
        if (vertex != NULL)
        {
            double dist = (releasePoint - imageToWidgetF(vertex->position)).l2Metric();
            if (dist < SELECTION_RADIUS)
            {
                if (!shiftPressed)
                {
                    mFeatures.deselectAll();
                }
                mFeatures.addSelection(vertex);
                if (vertex->isInPath())
                {
                    mFeatures.addSelection(vertex->ownerPath);
                }
                return;
            }
        }

        SelectableGeometryFeatures::Vertex *newVertex = mFeatures.appendNewVertex(imagePoint);
        if (!shiftPressed)
        {
            mFeatures.deselectAll();
        }
        mFeatures.addSelection(newVertex);
    }
}