当前位置: 首页>>代码示例>>C++>>正文


C++ ObjectGroup::isVisible方法代码示例

本文整理汇总了C++中ObjectGroup::isVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGroup::isVisible方法的具体用法?C++ ObjectGroup::isVisible怎么用?C++ ObjectGroup::isVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectGroup的用法示例。


在下文中一共展示了ObjectGroup::isVisible方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mousePressed

void CreateObjectTool::mousePressed(const QPointF &pos,
                                    Qt::MouseButton button,
                                    Qt::KeyboardModifiers modifiers)
{
    // Check if we are already creating a new map object
    if (mNewMapObjectItem) {
        if (button == Qt::RightButton)
            cancelNewMapObject();
        return;
    }

    if (button != Qt::LeftButton)
        return;

    ObjectGroup *objectGroup = currentObjectGroup();
    if (objectGroup && objectGroup->isVisible() && !mNewMapObjectItem) {
        const MapRenderer *renderer = mMapScene->mapDocument()->renderer();

        QPointF tileCoords = renderer->pixelToTileCoords(pos);
        if (modifiers & Qt::ControlModifier)
            tileCoords = tileCoords.toPoint();

        startNewMapObject(tileCoords, objectGroup);
    }
}
开发者ID:zorbathut,项目名称:mild,代码行数:25,代码来源:createobjecttool.cpp

示例2: mousePressed

void CreateObjectTool::mousePressed(QGraphicsSceneMouseEvent *event)
{
    // Check if we are already creating a new map object
    if (mNewMapObjectItem) {
        switch (mMode) {
        case CreateArea:
            if (event->button() == Qt::RightButton)
                cancelNewMapObject();
            break;
        case CreatePolygon:
        case CreatePolyline:
            if (event->button() == Qt::RightButton) {
                // The polygon needs to have at least three points and a
                // polyline needs at least two.
                int min = mMode == CreatePolygon ? 3 : 2;
                if (mNewMapObjectItem->mapObject()->polygon().size() >= min)
                    finishNewMapObject();
                else
                    cancelNewMapObject();
            } else if (event->button() == Qt::LeftButton) {
                // Assign current overlay polygon to the new object
                QPolygonF polygon = mOverlayPolygonObject->polygon();
                mNewMapObjectItem->setPolygon(polygon);

                // Add a new editable point to the overlay
                polygon.append(polygon.last());
                mOverlayPolygonItem->setPolygon(polygon);
            }
            break;
        }
        return;
    }

    if (event->button() != Qt::LeftButton) {
        AbstractObjectTool::mousePressed(event);
        return;
    }

    ObjectGroup *objectGroup = currentObjectGroup();
    if (!objectGroup || !objectGroup->isVisible())
        return;

    const MapRenderer *renderer = mapDocument()->renderer();
    QPointF tileCoords = renderer->pixelToTileCoords(event->scenePos());

    bool snapToGrid = Preferences::instance()->snapToGrid();
    if (event->modifiers() & Qt::ControlModifier)
        snapToGrid = !snapToGrid;

    if (snapToGrid)
        tileCoords = tileCoords.toPoint();

    startNewMapObject(tileCoords, objectGroup);
}
开发者ID:Zeitmaus,项目名称:tiled,代码行数:54,代码来源:createobjecttool.cpp

示例3: mousePressed

void CreateObjectTool::mousePressed(QGraphicsSceneMouseEvent *event)
{
    // Check if we are already creating a new map object
    if (mNewMapObjectItem) {
        switch (mMode) {
        case CreateRectangle:
        case CreateTile:
        case CreateEllipse:
            if (event->button() == Qt::RightButton)
                cancelNewMapObject();
            break;
        case CreatePolygon:
        case CreatePolyline:
            if (event->button() == Qt::RightButton) {
                finishOrCancelPolygon();
            } else if (event->button() == Qt::LeftButton) {
                QPolygonF current = mNewMapObjectItem->mapObject()->polygon();
                QPolygonF next = mOverlayPolygonObject->polygon();

                // If the last position is still the same, ignore the click
                if (next.last() == current.last())
                    return;

                // Assign current overlay polygon to the new object
                mNewMapObjectItem->setPolygon(next);

                // Add a new editable point to the overlay
                next.append(next.last());
                mOverlayPolygonItem->setPolygon(next);
            }
            break;
        }
        return;
    }

    if (event->button() != Qt::LeftButton) {
        AbstractObjectTool::mousePressed(event);
        return;
    }

    ObjectGroup *objectGroup = currentObjectGroup();
    if (!objectGroup || !objectGroup->isVisible())
        return;

    const MapRenderer *renderer = mapDocument()->renderer();
    QPointF tileCoords;

    if (mMode == CreateTile) {
        if (!mTile)
            return;

        const QPointF diff(-mTile->width() / 2, mTile->height() / 2);
        tileCoords = renderer->screenToTileCoords(event->scenePos() + diff);
    } else {
        tileCoords = renderer->screenToTileCoords(event->scenePos());
    }

    bool snapToGrid = Preferences::instance()->snapToGrid();
    bool snapToFineGrid = Preferences::instance()->snapToFineGrid();
    if (event->modifiers() & Qt::ControlModifier) {
        snapToGrid = !snapToGrid;
        snapToFineGrid = false;
    }

    if (snapToFineGrid) {
        int gridFine = Preferences::instance()->gridFine();
        tileCoords = (tileCoords * gridFine).toPoint();
        tileCoords /= gridFine;
    } else if (snapToGrid)
        tileCoords = tileCoords.toPoint();
    
    const QPointF pixelCoords = renderer->tileToPixelCoords(tileCoords);

    startNewMapObject(pixelCoords, objectGroup);
}
开发者ID:071300726,项目名称:tiled,代码行数:75,代码来源:createobjecttool.cpp


注:本文中的ObjectGroup::isVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。