QCAD渲染效率问题

一、配置多线程渲染
配置QCAD3.ini

[GraphicsView] 
Multithreading=true 
Threads=10
 QList<REntity::Id> list = document->getStorage().orderBackToFront(ids);
int slice = int(floor(double(list.length())/painterThread.length()));
QList<QFuture<void> > futureThread;
for (int threadId=0; threadId<painterThread.length(); threadId++) {
    int start = threadId*slice;
    int end = (threadId+1)*slice;
    if (threadId==painterThread.length()-1) {
        end = list.length();
    }
    //qDebug() << "slice:" << start << end;
    futureThread.append(QtConcurrent::run(this, &RGraphicsViewImage::paintEntitiesThread, threadId, list, start, end));
}
//RDebug::stopTimer(100, "launch threads");

//RDebug::startTimer(100);
for (int i=0; i<futureThread.length(); i++) {
    futureThread[i].waitForFinished();
}
void RGraphicsViewImage::paintEntitiesThread(int threadId, QList<REntity::Id>& list, int start, int end) {
    for (int i=start; i<end; i++) {
        paintEntityThread(threadId, list[i]);
    }
}

二、文件渲染
渲染为路径效率较高。

[TextRendering] 
RenderAs=Paths

[TextRendering] 
RenderAs=Text
bool RSettings::isTextRenderedAsText() {
    if (textRenderedAsText==-1) {
        textRenderedAsText = getStringValue("TextRendering/RenderAs", "Text") == "Text";
    }
    return textRenderedAsText;
}
void RTextBasedEntity::exportEntity(RExporter& e, bool preview, bool forceSelected) const {
    Q_UNUSED(preview)

    // TODO: use transforms:
    RTextBasedData data = getData();

    if (e.isTextRenderedAsText()) {
        // export text as text and return part that cannot be rendered as text as paths:
        QList<RPainterPath> paths = e.exportText(data, forceSelected);
        // export part of text that can only be rendered as painter paths (CAD fonts):
        e.exportPainterPaths(paths, getPosition().z);
    }
    else {
        e.exportPainterPathSource(data, getPosition().z);
    }
}

三、 块实体实时的渲染

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片