一、配置多线程渲染
配置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
暂无评论内容