本文整理汇总了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);
}
}
示例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);
}
示例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);
}