QCAD Framework

QCAD Framework

QCAD框架由三部分组成:Qt Application Framework提供桌面应用程序最一般的,底层的功能实现;QCAD Application Framework提供了专业的CAD功能实现;ECMAScript则是将Qt Application FrameworkQCAD Application Framework整合到一起,提供用户接口和业务逻辑功能的实现。

qt_qcad_functionality

QCAD 开发模式

扩展开发模式

基于现有的QCAD应用程序进行插件开发和工具菜单开发。
在这里插入图片描述

全新开发模式

基于底层的QCAD Application Framework开发自定义的应用程序。
在这里插入图片描述

QCAD Application Framework

Document

QCAD RDoument提供编辑和可视化的数据支持。

// Creating the storage underneath the document:
var storage = new RMemoryStorage();
 
// Creating the spatial index:
var spatialIndex = new RSpatialIndexNavel();
 
// Creating the document:
var document = new RDocument(storage, spatialIndex);
 
// Creating the document interface 
// (required for import / export, graphics scenes and views):
var documentInterface = new RDocumentInterface(document);
Interaction

交互包括对数据文档(RDocument)的可视化和用户输入(RACtion)响应。RDocumtnInterface是可视化和用户输入两者的核心。

Visualization

典型的模型视图结构

在这里插入图片描述

var graphicsScene = new RGraphicsSceneQt(documentInterface)
var graphicsView = new RGraphicsViewQt();
graphicsView.setScene(graphicsScene);
User Input

RAction继承于RGuiAction处理用户输入相应,用于菜单和工具的创建。
在这里插入图片描述

Importers

导入外部文件(dxf)到内存对象(RDocument)。
在这里插入图片描述

Exporters

将内存对象(RDocument)的图形数据保存到外部文件、打印设备和图形显示设备(painter pathsOpenGL context)。
在这里插入图片描述

Misc
  • 3rdparty Module:/src/3rdparty

    包含第三方库,dxflibproj4QXlsx等等。

  • Core Module : /src/core

    包含用来扩展的一些抽象基类和一些基本的核心类。

  • Math Module : /src/core/math
    包含用来进行如向量、矩阵等数学计算的概念以及一些点、线图形基类。

  • CustomWidgets Module: /src/customwidgets
    包含一些用于CAD的自定义控件。

  • Entity Module : /src/entity
    包含QCAD应用框架中所有CAD实体的实现。

  • GUI Module: /src/gui
    基于Qt的窗口部件,图形视图和图形场景。

  • Grid Module: /src/grid
    实现正交网格。

  • IO Module:/src/io
    实现读写dxf的接口。

  • Operations:/src/operations
    实现ROperation接口。它提供一个方便的API预览,将一般的更新应用到一个绘制文档上(增加实体,改变实体,删除实体)

  • Snap Module:/src/snap
    实现对象和格原型

  • Spatialindex Module : /src/spatialindex
    空间索引库。

  • Main Module :/src/run
    执行ECMAScript 代码,将应用程序编译为可执行程序,main函数入口。

  • Stemmer Module:/src/stemmer

    英语词干提取工具。

  • Scripts Module:/src/scripts

    EcmaJavascripts脚本。

  • Scripting:/src/scripting

    将底层的C++模块类,转换成EcmaJavascript环境的执行代码。

创建图层
// add a layer 'MyLayer':
    QSharedPointer<RLayer> layer = 
        QSharedPointer<RLayer>(
            new RLayer(document, "MyLayer")
        );
    //设置图层线形
    layer->setLinetypeId(document->getLinetypeId("continuous"));
    //线粗
    layer->setLineweight(RLineweight::Weight025);
    layer->setColor(RColor(255,0,0));
绘制线
// create and add a line entity:
    QSharedPointer<RLineEntity> lineEntity = 
        QSharedPointer<RLineEntity>(
            new RLineEntity(document, RLineData(RVector(0,0), RVector(100,0)))
        );

    // set attributes:
    lineEntity->setLayerId(layerId);
    lineEntity->setColor(RColor(0,128,255));
    lineEntity->setLinetypeId(document->getLinetypeId("dashed"));
    lineEntity->setLineweight(RLineweight::Weight100);

    // set a custom property:
    lineEntity->setCustomProperty("MyApp", "MyIntProperty", 77);
    lineEntity->setCustomProperty("MyApp", "MyStringProperty", "Some text");

    op = new RAddObjectOperation(
        lineEntity, 
        false       // false: don't use current attributes but 
                    //        custom attributes set above
    );

    // add the line entity to the drawing:
    documentInterface->applyOperation(op);
绘制点
    RAddObjectsOperation*op=new RAddObjectsOperation();
    QSharedPointer<RPointEntity> pointEntity =
            QSharedPointer<RPointEntity>(new RPointEntity(this->getDocument(), RPointData(_point)));
    op->addObject(pointEntity);
    this->documentInterface->applyOperation(op);
获取当前激活视图
var di = this.getDocumentInterface();
var view = di.getLastKnownViewWithFocus();
view = view.getRGraphicsView();
UML类图

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值