Example #1
0
void RArcEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);
    Q_UNUSED(forceSelected);

    e.setBrush(Qt::NoBrush);
    e.exportArc(data);
}
Example #2
0
void RPolylineEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);
    Q_UNUSED(forceSelected);

    e.setBrush(Qt::NoBrush);

    e.exportPolyline(data, data.getPolylineGen());
}
Example #3
0
void RPolylineEntity::exportEntity(RExporter& e, bool preview) const {
    Q_UNUSED(preview);

    e.setBrush(Qt::NoBrush);

    // temp for painter path testing:
//    RPainterPath pp(data.toPainterPath());
//    pp.setPen(QPen(Qt::white));
//    e.exportPainterPaths(QList<RPainterPath>() << pp);

    e.exportPolyline(data);
}
Example #4
0
void RAttributeEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);
    Q_UNUSED(forceSelected);

    if (!isInvisible()) {
        if (RSettings::isTextRenderedAsText()) {
            QList<RPainterPath> paths = e.exportText(getData(), forceSelected);
            e.exportPainterPaths(paths);
        }
        else {
            e.exportPainterPathSource(getData());
        }
    }
}
Example #5
0
void RAttributeEntity::exportEntity(RExporter& e, bool preview) const {
    Q_UNUSED(preview);

    RAttributeData data = getData();

    e.exportPainterPathSource(data);
}
void RBlockReferenceEntity::exportEntity(RExporter& e, bool preview) const {
    const RDocument* document = getDocument();
    if (document==NULL) {
        qWarning() << "RBlockReferenceEntity::exportEntity: document is NULL";
        return;
    }

    static int recursionDepth = 0;
    if (recursionDepth++>16) {
        recursionDepth--;
        qWarning() << "RBlockReferenceEntity::exportEntity: "
            << "maximum recursion depth reached";
        data.groundReferencedBlockId();
        return;
    }

    data.update();

    QSet<REntity::Id> ids = document->queryBlockEntities(data.referencedBlockId);
//    QSet<REntity::Id> ids = document->queryBlockReferenceEntities(getId());
    //QSet<REntity::Id> idsAttr = document->queryAttributes(objectId);
    //ids.unite(idsAttr);

    QList<REntity::Id> list = document->getStorage().orderBackToFront(ids);
    int i;
    QList<REntity::Id>::iterator it;
    for (it = list.begin(), i = 0; it != list.end(); it++, i++) {
        if (preview && i>RSettings::getPreviewEntities()) {
            break;
        }

        QSharedPointer<REntity> entity = data.queryEntity(*it);
        if (entity.isNull()) {
            continue;
        }
        e.exportEntity(*entity, preview, true);
    }

    // too slow:
//    RDebug::startTimer(4);

//    if (preview) {
//        // TODO: if we interrupted to limit the preview, add bounding box to preview
//        RBox bb = data.getBoundingBox();
//        QList<RLine> l = bb.getLines2d();
//        for (int k=0; k<l.count(); ++k) {
//            e.exportLine(l[k]);
//        }
//    }

//    RDebug::stopTimer(4, "bb");

    recursionDepth--;
}
Example #7
0
void RSolidEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);
    Q_UNUSED(forceSelected);

    // note that order of fourth and third vertex is swapped:
    RPolyline pl;
    pl.appendVertex(data.getVertexAt(0));
    pl.appendVertex(data.getVertexAt(1));
    if (data.countVertices()>3) {
        pl.appendVertex(data.getVertexAt(3));
    }
    pl.appendVertex(data.getVertexAt(2));
    pl.setClosed(true);

    e.exportPolyline(pl);
}
Example #8
0
void RHatchEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);
    Q_UNUSED(forceSelected);

    e.exportPainterPathSource(data);
}
Example #9
0
void RImageEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);

    e.exportImage(data, forceSelected);
}
Example #10
0
void REllipseEntity::exportEntity(RExporter& e, bool preview) const {
    Q_UNUSED(preview);

    e.setBrush(Qt::NoBrush);
    e.exportEllipse(data);
}
Example #11
0
void RViewportEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview);
    Q_UNUSED(forceSelected);

    RDocument* doc = (RDocument*)getDocument();
    if (doc==NULL) {
        return;
    }

    RBox viewportBox(data.position, data.width, data.height);

    // if layer is visible, export viewport frame
    // viewport contents is always exported (unless viewport if off):
    if (isVisible()) {
        // export viewport frame to layer of viewport:
        e.setBrush(Qt::NoBrush);
        QList<RLine> lines = viewportBox.getLines2d();
        for (int i=0; i<lines.length(); i++) {
            e.exportLine(lines[i]);
        }
    }

    // if viewport is off, we're done:
    if (isOff()) {
        return;
    }

    // clip rectangle export
    e.exportClipRectangle(viewportBox);

    RVector offset(0,0);
    offset -= data.viewCenter * data.scale;
    offset -= data.viewTarget * data.scale;

    // create temporary block reference to model space block:
    RBlockReferenceData modelSpaceData(
        doc,
        RBlockReferenceData(
            doc->getModelSpaceBlockId(),
            data.position + offset,
            RVector(data.scale, data.scale),
            0.0
        )
    );
    modelSpaceData.update();

    // start clipping from here:
    e.setClipping(true);

    // render model space block reference into viewport:
    QSet<REntity::Id> ids = doc->queryBlockEntities(doc->getModelSpaceBlockId());
    QList<REntity::Id> list = doc->getStorage().orderBackToFront(ids);
    int i;
    QList<REntity::Id>::iterator it;
    for (it = list.begin(), i = 0; it != list.end(); it++) {
        if (preview && i>RSettings::getPreviewEntities()) {
            break;
        }

        QSharedPointer<REntity> entity = modelSpaceData.queryEntity(*it);
        if (entity.isNull()) {
            continue;
        }

        entity->rotate(data.rotation, data.position);

        // prevent recursions:
        if (entity->getType()==RS::EntityViewport) {
            continue;
        }

        RBox bb = entity->getBoundingBox();
        if (!viewportBox.intersects(bb)) {
            continue;
        }

        entity->scaleVisualProperties(data.scale);

        e.exportEntity(*entity, preview, true);

        i++;
    }

    e.setClipping(false);
}