QCAD加载数据到渲染流程
外部数据加载
读入dxf
到QCAD
实体对象REntity
,同时建立空间索引。
准备工作
创建存储库,空间索引和文档对象。
var storage = new RMemoryStorage();
var spatialIndex = createSpatialIndex();
var document = new RDocument(storage, spatialIndex);
var documentInterface = new RDocumentInterface(document);
实体对象入库
读入图层、点、线等实体对象,生成唯一索引和空间索引。
RDocumentInterface::importFile(fileName, nameFilter);
RDxfImpoDrter::importFile()
RImporter::startImport();
//继承dxflib 接口
RDxfImporter::addLayer(const DL_LayerData& data);
RDxfImporter::addPoint(const DL_PointData& data);
RDxfImporter::addLine(const DL_LineData& data);
...
...
...
//生成REntity
RDxfImporter::importEntity(QSharedPointer<REntity> entity);
//生成RObject
RImporter::importObjectP(QSharedPointer<RObject> object);
//事务操作入库
RTransaction::addObject(QSharedPointer<RObject> object,...);
//对象的唯一索引
RStorage::setObjectId(RObject& object, RObject::Id objectId);
RStorage::saveObject(QSharedPointer<RObject> object, ...);
//重建空间索引,框选空间查询可用
RDocument::rebuildSpatialIndex()
RImporter::endImport();
构建显示设备
构建窗体
创建子窗体,一个子窗体对应一个文档对象接口。
var mdiChild = new RMdiChildQt();
mdiChild.setDocumentInterface(documentInterface);
var appWin = EAction.getMainWindow();
var mdiArea = appWin.centralWidget();
mdiArea.addSubWindow(mdiChild);
var viewports = ViewportWidget.getViewports(mdiChild, documentInterface);
mdiChild.viewports = viewports;
//从xxx.ui文件初始化viewport控件
ViewportWidget.initializeViewports(viewports, uiFile, graphicsSceneClass);
//激活并请求数据
appWin.subWindowActivated(mdiChild);
构建图形显示控件
ViewportWidget.initializeViewports
创建Scene
和View
对象。
//scene&view
this.graphicsView = this.ViewPortWidget.findChild("GraphicsView");
var scene = new RGraphicsSceneQt(this.documentInterface);
this.graphicsView.setScene(scene);
实体对象生成可绘制对象
从文档对象输出REntity
,遍历每一个REntity
对象,生成对应的可绘制的RGraphicsSceneDrawable
。
RMainWindowQt::updateScenes();
RDocumentInterface::regenerateScenes();
RGraphicsScene::regenerate();
//
RGraphicsScene::exportEntities()||RExporter::exportEntities();
RExporter::exportEntity();
RExporter::exportCurrentEntity();
//
REntity::exportEntity();
RPointEntity::exportEntity(RExporter& e,...);
RLineEntity::exportEntity(RExporter& e,...);
...
...
...
RGraphicsSceneQt::exportPoint(const RPoint& point,...);
RGraphicsSceneQt::exportLine(const RLine& line,...);
...
...
RGraphicsSceneQt::beginPath();
RGraphicsSceneQt::addDrawable(REntity::Id entityId, RGraphicsSceneDrawable& drawable,...);
RGraphicsSceneQt::endPath();
重绘制显示
多线程绘制窗口内的可绘制对象。
RGraphicsScene::regenerateViews();
RGraphicsScene::repaintViews();
RGraphicsViewImage::regenerate();
RGraphicsViewImage::updateImage();
//绘制文档,包含网格、刻度等等
RGraphicsViewImage::paintDocument();
RGraphicsViewImage::paintEntitiesMulti();
//查询需要绘制的实体
RDocument::queryIntersectedEntitiesXYFast(const RBox& box);
//多线程绘制对象
RGraphicsViewImage::paintEntitiesThread();