Ejemplo n.º 1
0
QPair<QVariant, RPropertyAttributes> REntity::getProperty(
        RPropertyTypeId propertyTypeId,
        bool humanReadable, bool noAttributes) {

    if (propertyTypeId == PropertyType) {
        return qMakePair(QVariant(RS::EntityUnknown), RPropertyAttributes());
    } else if (propertyTypeId == PropertyBlock) {
        return qMakePair(QVariant(getData().getBlockId()),
                         RPropertyAttributes());
    }else if (propertyTypeId == PropertyLayer) {
        if (humanReadable) {
            RDocument* document = getData().getDocument();
            if (document != NULL) {
                RPropertyAttributes attr;
                if (!noAttributes) {
                    // TODO: filter out locked layers:
                    attr.setChoices(document->getLayerNames());
                }
                return qMakePair(QVariant(document->getLayerName(
                        getData().getLayerId())), attr);
            }
        } else {
            return qMakePair(QVariant(getData().getLayerId()),
                    RPropertyAttributes());
        }
    } else if (propertyTypeId == PropertyLinetype) {
        if (humanReadable) {
            RDocument* document = getData().getDocument();
            if (document != NULL) {
                QVariant var;
                QSharedPointer<RLinetype> linetype = document->queryLinetype(
                        getData().getLinetypeId());
                var.setValue<RLinetype> (*linetype.data());
                return qMakePair(var, RPropertyAttributes());
            }
        } else {
            return qMakePair(QVariant(getData().getLinetypeId()),
                    RPropertyAttributes());
        }
    } else if (propertyTypeId == PropertyLineweight) {
        QVariant v;
        v.setValue<RLineweight::Lineweight>(getData().getLineweight());
        return qMakePair(v, RPropertyAttributes());
    } else if (propertyTypeId == PropertyColor) {
        QVariant var;
        var.setValue<RColor> (getData().getColor());
        return qMakePair(var, RPropertyAttributes());
    } else if (propertyTypeId == PropertyDrawOrder) {
        return qMakePair(QVariant(getData().getDrawOrder()), RPropertyAttributes());
    }

    return RObject::getProperty(propertyTypeId, humanReadable, noAttributes);
}
Ejemplo n.º 2
0
QSharedPointer<RLinetype> RClipboardOperation::copyLinetype(
        RLinetype::Id linetypeId,
        RDocument& src, RDocument& dest,
        bool overwriteLinetypes,
        RTransaction& transaction) const {

    // add linetype of entity, if the linetype exists it is overwritten
    // if overwriteLinetypes is true:
    QSharedPointer<RLinetype> srcLinetype = src.queryLinetype(linetypeId);
    if (srcLinetype.isNull()) {
        qWarning("RClipboardOperation::copyLinetype: "
                 "linetype is NULL.");
        return QSharedPointer<RLinetype>();
    }
    QString srcLinetypeName = srcLinetype->getName().toLower();
    QSharedPointer<RLinetype> destLinetype;
    if (copiedLinetypes.contains(srcLinetypeName)) {
        destLinetype = copiedLinetypes.value(srcLinetypeName);
        Q_ASSERT(!destLinetype.isNull());
    }
    else {
        if (!dest.hasLinetype(srcLinetypeName) || overwriteLinetypes) {
            destLinetype = QSharedPointer<RLinetype>(srcLinetype->clone());
            destLinetype->setDocument(&dest);
            if (destLinetype->getDocument()!=srcLinetype->getDocument()) {
                dest.getStorage().setObjectId(*destLinetype.data(), RObject::INVALID_ID);
                dest.getStorage().setObjectHandle(*destLinetype.data(), RObject::INVALID_HANDLE);
            }
            transaction.addObject(destLinetype);
        }
        else {
            destLinetype = dest.queryLinetype(srcLinetypeName);
            Q_ASSERT(!destLinetype.isNull());
        }

        copiedLinetypes.insert(srcLinetypeName, destLinetype);
    }

    return destLinetype;
}
Ejemplo n.º 3
0
void RExporter::setLinetypeId(RLinetype::Id ltId) {
    RDocument* doc = NULL;
    if (getEntity()!=NULL) {
        doc = getEntity()->getDocument();
    }
    if (doc == NULL) {
        doc = document;
    }

    QSharedPointer<RLinetype> lt = doc->queryLinetype(ltId);

    if (!lt.isNull()) {
        currentLinetypePattern = lt->getPattern();
    }
}