void RMemoryStorage::selectEntities(const QSet<REntity::Id>& entityIds, bool add, QSet<REntity::Id>* affectedEntities) { if (!add) { // deselect all first: QHash<RObject::Id, QSharedPointer<REntity> >::iterator it; for (it = entityMap.begin(); it != entityMap.end(); ++it) { QSharedPointer<REntity> e = *it; if (!e.isNull() && e->isSelected() && !entityIds.contains(e->getId())) { setEntitySelected(e, false, affectedEntities); } } } QSet<REntity::Id>::const_iterator it; for (it = entityIds.constBegin(); it != entityIds.constEnd(); ++it) { QSharedPointer<REntity> e = queryEntityDirect(*it); if (!e.isNull() && !e->isSelected() && !isLayerLocked(e->getLayerId()) && !isLayerFrozen(e->getLayerId())) { setEntitySelected(e, true, affectedEntities); } } }
/** * Selects first the top most parent in the entity hierarchy and then * all children of it. This is necessary for attributes which are * children of block references. */ void RMemoryStorage::setEntitySelected(QSharedPointer<REntity> entity, bool on, QSet<REntity::Id>* affectedEntities, bool onlyDescend) { // disabled: // attributes can be selected individually to edit their attributes // if (!onlyDescend) { // // entity has a parent: select parent instead // // (select block ref for attribute): // REntity::Id parentId = entity->getParentId(); // QSharedPointer<REntity> parent = queryEntityDirect(parentId); // if (!parent.isNull()) { // setEntitySelected(parent, on, affectedEntities); // return; // } // } entity->setSelected(on); if (affectedEntities!=NULL) { affectedEntities->insert(entity->getId()); } // if this is a parent, select all child entities (attributes for block ref): if (hasChildEntities(entity->getId())) { QSet<REntity::Id> childIds = queryChildEntities(entity->getId()); QSet<REntity::Id>::iterator it; for (it=childIds.begin(); it!=childIds.end(); it++) { REntity::Id childId = *it; QSharedPointer<REntity> child = queryEntityDirect(childId); if (child.isNull()) { continue; } setEntitySelected(child, on, affectedEntities, true); } } }
void RMemoryStorage::deselectEntities(const QSet<REntity::Id>& entityIds, QSet<REntity::Id>* affectedEntities) { QSet<REntity::Id>::const_iterator it; for (it = entityIds.constBegin(); it != entityIds.constEnd(); ++it) { QSharedPointer<REntity> e = queryEntityDirect(*it); if (!e.isNull() && e->isSelected()) { setEntitySelected(e, false, affectedEntities); } } }
void RMemoryStorage::selectAllEntites(QSet<REntity::Id>* affectedEntities) { QHash<RObject::Id, QSharedPointer<REntity> >::iterator it; RBlock::Id currentBlock = getCurrentBlockId(); for (it = entityMap.begin(); it != entityMap.end(); ++it) { QSharedPointer<REntity> e = *it; if (!e.isNull() && !e->isSelected() && e->getBlockId()==currentBlock && e->isEditable()) { setEntitySelected(e, true, affectedEntities); } } }
void RMemoryStorage::clearEntitySelection(QSet<REntity::Id>* affectedEntities) { QHash<RObject::Id, QSharedPointer<REntity> >::iterator it; for (it = entityMap.begin(); it != entityMap.end(); ++it) { QSharedPointer<REntity> e = *it; if (!e.isNull() && e->isSelected()) { // if (affectedEntities!=NULL) { // affectedEntities->insert(e->getId()); // } // e->setSelected(false); setEntitySelected(e, false, affectedEntities); } } }
void RMemoryStorage::selectAllEntites(QSet<REntity::Id>* affectedEntities) { QHash<RObject::Id, QSharedPointer<REntity> >::iterator it; RBlock::Id currentBlock = getCurrentBlockId(); for (it = entityMap.begin(); it != entityMap.end(); ++it) { QSharedPointer<REntity> e = *it; if (!e.isNull() && !e->isSelected() && e->getBlockId()==currentBlock && e->isEditable()) { //!isLayerLocked(e->getLayerId()) && !isLayerFrozen(e->getLayerId())) { // if (affectedEntities != NULL) { // affectedEntities->insert(e->getId()); // } // e->setSelected(true); setEntitySelected(e, true, affectedEntities); } } }