Exemplo n.º 1
0
/**
 * Sets the current entity to the given entity and calls \ref exportEntity().
 * Note that entity is a temporary clone.
 */
void RExporter::exportEntity(REntity& entity, bool preview, bool allBlocks, bool forceSelected) {
    RDocument* doc = entity.getDocument();
    if (doc==NULL) {
        doc = document;
    }

    // entity not on current block and allBlocks==false, break:
    if (!allBlocks && doc->getCurrentBlockId()!=entity.getBlockId()) {
        //unexportEntity(entity.getId());
        return;
    }

    entityStack.push(&entity);

    // find layer of the current entity
    QSharedPointer<RLayer> layer;
    if (layerSource!=NULL) {
        RLayer::Id layerId = entity.getLayerId();
        layer = layerSource->queryLayerDirect(layerId);
        Q_ASSERT(!layer.isNull());
    }
    else {
        layer = doc->queryLayerDirect(entity.getLayerId());
        if (layer.isNull()) {
            qDebug() << "Document: " << *doc;
            qDebug() << "Layer ID: " << entity.getLayerId();
            Q_ASSERT_X(false, "RExporter::exportEntity", "layer is NULL");
        }
    }
    if (!layer.isNull()) {
        currentLayer = layer.data();
    }

    // find block reference of the current entity, ignore this entity:
    bool blockRefOrViewportSet = false;
    // check if this entity is a block reference:
    RBlockReferenceEntity* blockRef = dynamic_cast<RBlockReferenceEntity*>(&entity);
    if (blockRef!=NULL) {
        blockRefStack.push(blockRef);
        blockRefOrViewportSet = true;
    }
    // check if this entity is a viewport:
    RViewportEntity* viewPort = dynamic_cast<RViewportEntity*>(&entity);
    if (viewPort!=NULL) {
        blockRefStack.push(viewPort);
        blockRefOrViewportSet = true;
    }

    startEntity(/* topLevelEntity = */ blockRefOrViewportSet || blockRefStack.isEmpty());
    exportCurrentEntity(preview, forceSelected);
    endEntity();

    if (blockRefOrViewportSet) {
        blockRefStack.pop();
        //blockRefBS.clear();
    }
    currentLayer = NULL;

    entityStack.pop();
}
Exemplo n.º 2
0
QList<RVector> REntity::getIntersectionPoints(
        const REntity& other, bool limited, const RBox& queryBox, bool ignoreComplex) const {

    bool same = false;

    // avoid intersection finding for intersections of interpolated entities
    // (e.g. splines) with themselves:
    if (getId()!=INVALID_ID && getId()==other.getId() && getDocument()==other.getDocument()) {
        const RShape* shape = getData().castToConstShape();
        if (shape!=NULL && shape->isInterpolated()) {
            same = true;
        }

        const RPolyline* pl = dynamic_cast<const RPolyline*>(shape);
        if (pl!=NULL) {
            same = true;
        }
    }

    return getData().getIntersectionPoints(other.getData(), limited, same, queryBox, ignoreComplex);
}