本文整理汇总了C++中ObjectGroup类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGroup类的具体用法?C++ ObjectGroup怎么用?C++ ObjectGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void PropertyBrowser::applyObjectGroupValue(PropertyId id, const QVariant &val)
{
ObjectGroup *objectGroup = static_cast<ObjectGroup*>(mObject);
QUndoCommand *command = 0;
switch (id) {
case ColorProperty: {
QColor color = val.value<QColor>();
if (color == Qt::gray)
color = QColor();
command = new ChangeObjectGroupProperties(mMapDocument,
objectGroup,
color,
objectGroup->drawOrder());
break;
}
case DrawOrderProperty: {
ObjectGroup::DrawOrder drawOrder = static_cast<ObjectGroup::DrawOrder>(val.toInt());
command = new ChangeObjectGroupProperties(mMapDocument,
objectGroup,
objectGroup->color(),
drawOrder);
break;
}
default:
break;
}
if (command)
mMapDocument->undoStack()->push(command);
}
示例2: cancelNewMapObject
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);
}
}
示例3: tileObjectGroupChanged
void TileCollisionDock::tileObjectGroupChanged(Tile *tile)
{
if (mTile != tile)
return;
if (mApplyingChanges)
return;
mSynchronizing = true;
mDummyMapDocument->undoStack()->clear();
auto selectedTool = mToolManager->selectedTool();
LayerModel *layerModel = mDummyMapDocument->layerModel();
delete layerModel->takeLayerAt(nullptr, 1);
ObjectGroup *objectGroup;
if (tile->objectGroup())
objectGroup = tile->objectGroup()->clone();
else
objectGroup = new ObjectGroup;
objectGroup->setDrawOrder(ObjectGroup::IndexOrder);
layerModel->insertLayer(nullptr, 1, objectGroup);
mDummyMapDocument->setCurrentLayer(objectGroup);
mToolManager->selectTool(selectedTool);
mSynchronizing = false;
}
示例4: QRect
void MapDocument::resizeMap(const QSize &size, const QPoint &offset, bool removeObjects)
{
const QRegion movedSelection = mSelectedArea.translated(offset);
const QRect newArea = QRect(-offset, size);
const QRectF visibleArea = mRenderer->boundingRect(newArea);
const QPointF origin = mRenderer->tileToPixelCoords(QPointF());
const QPointF newOrigin = mRenderer->tileToPixelCoords(-offset);
const QPointF pixelOffset = origin - newOrigin;
// Resize the map and each layer
QUndoCommand *command = new QUndoCommand(tr("Resize Map"));
LayerIterator iterator(mMap);
while (Layer *layer = iterator.next()) {
switch (layer->layerType()) {
case Layer::TileLayerType: {
TileLayer *tileLayer = static_cast<TileLayer*>(layer);
new ResizeTileLayer(this, tileLayer, size, offset, command);
break;
}
case Layer::ObjectGroupType: {
ObjectGroup *objectGroup = static_cast<ObjectGroup*>(layer);
for (MapObject *o : objectGroup->objects()) {
if (removeObjects && !visibleIn(visibleArea, o, mRenderer)) {
// Remove objects that will fall outside of the map
new RemoveMapObject(this, o, command);
} else {
QPointF oldPos = o->position();
QPointF newPos = oldPos + pixelOffset;
new MoveMapObject(this, o, newPos, oldPos, command);
}
}
break;
}
case Layer::ImageLayerType: {
// Adjust image layer by changing its offset
auto imageLayer = static_cast<ImageLayer*>(layer);
new SetLayerOffset(this, layer,
imageLayer->offset() + pixelOffset,
command);
break;
}
case Layer::GroupLayerType: {
// Recursion handled by LayerIterator
break;
}
}
}
new ResizeMap(this, size, command);
new ChangeSelectedArea(this, movedSelection, command);
mUndoStack->push(command);
// TODO: Handle layers that don't match the map size correctly
}
示例5: finishGC
void
GlobalHelperThreadState::mergeParseTaskCompartment(JSRuntime* rt, ParseTask* parseTask,
Handle<GlobalObject*> global,
JSCompartment* dest)
{
// After we call LeaveParseTaskZone() it's not safe to GC until we have
// finished merging the contents of the parse task's compartment into the
// destination compartment. Finish any ongoing incremental GC first and
// assert that no allocation can occur.
gc::AutoFinishGC finishGC(rt);
JS::AutoAssertNoAlloc noAlloc(rt);
LeaveParseTaskZone(rt, parseTask);
{
gc::ZoneCellIter iter(parseTask->cx->zone(), gc::AllocKind::OBJECT_GROUP);
// Generator functions don't have Function.prototype as prototype but a
// different function object, so the IdentifyStandardPrototype trick
// below won't work. Just special-case it.
JSObject* parseTaskStarGenFunctionProto =
parseTask->exclusiveContextGlobal->as<GlobalObject>().getStarGeneratorFunctionPrototype();
// Point the prototypes of any objects in the script's compartment to refer
// to the corresponding prototype in the new compartment. This will briefly
// create cross compartment pointers, which will be fixed by the
// MergeCompartments call below.
for (; !iter.done(); iter.next()) {
ObjectGroup* group = iter.get<ObjectGroup>();
TaggedProto proto(group->proto());
if (!proto.isObject())
continue;
JSObject* protoObj = proto.toObject();
JSObject* newProto;
if (protoObj == parseTaskStarGenFunctionProto) {
newProto = global->getStarGeneratorFunctionPrototype();
} else {
JSProtoKey key = JS::IdentifyStandardPrototype(protoObj);
if (key == JSProto_Null)
continue;
MOZ_ASSERT(key == JSProto_Object || key == JSProto_Array ||
key == JSProto_Function || key == JSProto_RegExp ||
key == JSProto_Iterator);
newProto = GetBuiltinPrototypePure(global, key);
}
MOZ_ASSERT(newProto);
group->setProtoUnchecked(TaggedProto(newProto));
}
}
// Move the parsed script and all its contents into the desired compartment.
gc::MergeCompartments(parseTask->cx->compartment(), dest);
}
示例6: switch
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);
}
示例7: Q_ASSERT
Layer *ObjectGroup::mergedWith(Layer *other) const
{
Q_ASSERT(canMergeWith(other));
const ObjectGroup *og = static_cast<ObjectGroup*>(other);
ObjectGroup *merged = static_cast<ObjectGroup*>(clone());
for (const MapObject *mapObject : og->objects())
merged->addObject(mapObject->clone());
return merged;
}
示例8: computeRanges
static Ranges computeRanges(const QList<MapObject *> &objects)
{
Ranges ranges;
for (MapObject *object : objects) {
ObjectGroup *group = object->objectGroup();
auto &set = ranges[group];
set.insert(group->objects().indexOf(object));
}
return ranges;
}
示例9: ChangeTileObjectGroup
void TileCollisionDock::applyChanges()
{
if (mSynchronizing)
return;
ObjectGroup *objectGroup = static_cast<ObjectGroup*>(mDummyMapDocument->map()->layerAt(1));
ObjectGroup *clonedGroup = objectGroup->clone();
QUndoStack *undoStack = mTilesetDocument->undoStack();
mApplyingChanges = true;
undoStack->push(new ChangeTileObjectGroup(mTilesetDocument, mTile, clonedGroup));
mApplyingChanges = false;
}
示例10: Q_UNUSED
void MapDocument::onMapObjectModelRowsInsertedOrRemoved(const QModelIndex &parent,
int first, int last)
{
Q_UNUSED(first)
ObjectGroup *objectGroup = mMapObjectModel->toObjectGroup(parent);
if (!objectGroup)
return;
// Inserting or removing objects changes the index of any that come after
const int lastIndex = objectGroup->objectCount() - 1;
if (last < lastIndex)
emit objectsIndexChanged(objectGroup, last + 1, lastIndex);
}
示例11: layerChanged
void ObjectSelectionItem::layerChanged(int index)
{
ObjectGroup *objectGroup = mMapDocument->map()->layerAt(index)->asObjectGroup();
if (!objectGroup)
return;
// If labels for all objects are visible, some labels may need to be added
// removed based on layer visibility.
if (Preferences::instance()->objectLabelVisibility() == Preferences::AllObjectLabels)
addRemoveObjectLabels();
// If an object layer changed, that means its offset may have changed,
// which affects the outlines of selected objects on that layer and the
// positions of any name labels that are shown.
syncOverlayItems(objectGroup->objects());
}
示例12: Q_ASSERT
MapObject *CreateObjectTool::clearNewMapObjectItem()
{
Q_ASSERT(mNewMapObjectItem);
MapObject *newMapObject = mNewMapObjectItem->mapObject();
ObjectGroup *objectGroup = newMapObject->objectGroup();
objectGroup->removeObject(newMapObject);
delete mNewMapObjectItem;
mNewMapObjectItem = 0;
delete mOverlayPolygonItem;
mOverlayPolygonItem = 0;
return newMapObject;
}
示例13: MOZ_ASSERT
void
gc::TraceCycleCollectorChildren(JS::CallbackTracer* trc, ObjectGroup* group)
{
MOZ_ASSERT(trc->isCallbackTracer());
// Early return if this group is not required to be in an ObjectGroup chain.
if (!group->maybeUnboxedLayout())
return group->traceChildren(trc);
ObjectGroupCycleCollectorTracer groupTracer(trc->asCallbackTracer());
group->traceChildren(&groupTracer);
while (!groupTracer.worklist.empty()) {
ObjectGroup* innerGroup = groupTracer.worklist.popCopy();
innerGroup->traceChildren(&groupTracer);
}
}
示例14: if
/**
* Convenience method to copy the current selection to the clipboard.
* Deals with either tile selection or object selection.
*/
void ClipboardManager::copySelection(const MapDocument *mapDocument)
{
const Layer *currentLayer = mapDocument->currentLayer();
if (!currentLayer)
return;
const Map *map = mapDocument->map();
const QRegion &selectedArea = mapDocument->selectedArea();
const QList<MapObject*> &selectedObjects = mapDocument->selectedObjects();
const TileLayer *tileLayer = dynamic_cast<const TileLayer*>(currentLayer);
Layer *copyLayer = nullptr;
if (!selectedArea.isEmpty() && tileLayer) {
const QRegion area = selectedArea.intersected(tileLayer->bounds());
// Copy the selected part of the layer
copyLayer = tileLayer->copy(area.translated(-tileLayer->position()));
copyLayer->setPosition(area.boundingRect().topLeft());
} else if (!selectedObjects.isEmpty()) {
// Create a new object group with clones of the selected objects
ObjectGroup *objectGroup = new ObjectGroup;
for (const MapObject *mapObject : selectedObjects)
objectGroup->addObject(mapObject->clone());
copyLayer = objectGroup;
} else {
return;
}
// Create a temporary map to write to the clipboard
Map copyMap(map->orientation(),
0, 0,
map->tileWidth(), map->tileHeight());
copyMap.setRenderOrder(map->renderOrder());
// Resolve the set of tilesets used by this layer
foreach (const SharedTileset &tileset, copyLayer->usedTilesets())
copyMap.addTileset(tileset);
copyMap.addLayer(copyLayer);
setMap(copyMap);
}
示例15: toVariant
QVariant MapToVariantConverter::toVariant(const ObjectGroup &objectGroup) const
{
QVariantMap objectGroupVariant;
objectGroupVariant[QLatin1String("type")] = QLatin1String("objectgroup");
if (objectGroup.color().isValid())
objectGroupVariant[QLatin1String("color")] = colorToString(objectGroup.color());
objectGroupVariant[QLatin1String("draworder")] = drawOrderToString(objectGroup.drawOrder());
addLayerAttributes(objectGroupVariant, objectGroup);
QVariantList objectVariants;
for (const MapObject *object : objectGroup.objects())
objectVariants << toVariant(*object);
objectGroupVariant[QLatin1String("objects")] = objectVariants;
return objectGroupVariant;
}