锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 英语翻译 / GeoIO库:基于文档视图结构的2D绘图软件
服务方向
ɋ¹¤ׇŜ˽¾ݴ¦m
ɋ¹¤ׇŜƠѵ
kaldi˽¾ޗ¼±¸
СԯזԯӴʶ±�>
ԯӴʶ±𲫗¢
ԯӴʶ±񏶍³
ԯӴʶ±񗫎ŗԼ/a>
kaldi¿ª·¢¼¼˵·�>
ɭ¼�/dt>
Ջ¶¯¿ٖƿ¨ʏλ»�
»�¹¤ɭ¼�/dd>
ɭ¼�ᑵ
Java °²׿ӆ¶¯¿ª·¢
VC++
C#ɭ¼�/dd>
»㲠ºΆƽຯa>
Ƚ¶¯¿ª·¢
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。”需要全文内容也请联系孙老师。

2D Drawing - Doc/View architecture

2D绘图 - 文档/视图结构

Introduction介绍

GeoIO lib is a simple geometry library that encapsulates the drawing of various geometrical entities (like lines, circle, arc, text etc), storing them in a list with support for undo/redo operations. There is a sample application called Cad2D attached which exposes some of the basic drawing and serilaization functionality of the GeoIO library. 

GeoIO LIB是一个简单的几何体库,封装了各种几何实体的图纸(如线,圆,弧,文本等),将它们存储在列表里,支持撤消/重做操作。有一个叫Cad2D示例应用程序,它演示了一些GeoIO库的基本绘图和序列化功能。

Background背景 

Couple of developers/programmers have come across a situation to develop simple application to draw 2-Dimensional geometry entities. However they are blocked due to many reasons like lack of time, unwilling to explore OpenGL, develop the module from base etc. The MFC set of classes (DeviceContext) gives some good functionality to draw simple entities like lines, circles, rectangles etc, but a first timer may take sometime to learn, understand and experiment it. GeoIO library has encapsulated the complete functionality of MFC into set of core geometry classes. All that you have to do is add this module into your project and start with it. The module also supports drawing, dragging operation OnMouseMove handler and serialization.

许多开发商/程序员遇到的情况,开发简单的应用程序绘制2维几何实体。但是他们由于很多原因被阻塞,像缺乏时间,不愿探索的OpenGL,从基本模块开发等。MFC集合类(DeviceContext)给出了一些很好的功能,像画线,圆,矩形等简单的实体,但第一个定时器可能需要一段时间来学习,理解和试验它。 GeoIO库封装了完整的MFC功能集成到一套核心的几何类。所有你需要做的就是将此模块添加到你的项目,并启动它。该模块还支持绘图,拖拽操作的OnMouseMove处理程序,系列化。

Using the code使用代码

GeoIO is simple MFC DLL. Add this as dynamic-linked or static-linked to your project. Initially the usage of this module might look difficult, but once you read the below fundamental concepts you should sail through easily. Open the sample project Cad2D (SDI MFC application) which uses GeoIO to draw 2D basic geometry objects. Please explore this sample project to learn and understand the usage of GeoIO.

GeoIO是简单的MFC DLL。将其以动态链接或静态链接加入到您的项目。最初,这个模块的使用可能看起来很难,但一旦你阅读下面的基本概念,你就能轻松驾驭它。打开示例项目Cad2D(SDI MFC应用程序),它使用GeoIO绘制二维基本几何对象。请探索这个示例项目学习和理解GeoIO的使用。

Cad2D

NOTE: The project has .vcproj and .vcxproj files so it should open in VS2010 and earlier versions of Visual Studio. 注:该项目有.vcproj和.vcxproj文件,因此它应该在VS2010和更早版本的Visual Studio打开。

Geometry classes in GeoIO:

CPrimitive - the principle base class for all the below mentioned classes.

CGeoArc - class to draw and serialize an arc

CGeoCircle - class to draw and serialize a circle

CGeoLine - class to draw and serialize a line

CGeoPolybezier - class to draw and serialize a polybezier

CGeoPolygon  - class to draw and serialize a polygon

CGeoRectangle - class to draw and serialize a rectangle

CGeoText - class to draw and serialize a string

几何类GeoIO:

CPrimitive - 所有下面提到类的原则基础类。

CGeoArc - 类绘制和序列化的弧形

CGeoCircle - 类绘制和序列化一个圆

CGeoLine - 类绘制和序列化线

CGeoPolybezier - 类绘制和序列化polybezier

CGeoPolygon - 类绘制和序列化多边形

CGeoRectangle - 类绘制和序列化一个矩形

CGeoText - 类绘制和序列化的字符串

Note: Some drawing logic have been inspired from various online articles.

注意:有些绘图逻辑都已经激发了各种网上的文章。

Collection classes:

CEntityList - class to hold objects of CPrimitive (like CGeoArc, CGeoLine, CGeoRectangle, etc).

CLayerList - class to hold objects of CLayer

CLayer - class stores an instance of CEntityList. A CLayer object is identified by a layer ID.

集合类:

CEntityList - 类持有CPrimitive的对象(如CGeoArc,CGeoLine,CGeoRectangle等)。

CLayerList - 类持有CLAYER对象

CLAYER - 类存储CEntityList的一个实例。一个CLAYER对象是由一个层ID。所以,在你的应用程序遵循以下步骤:

So, in your application follow the below procedure:

所以,在你的应用程序遵循以下步骤:


              CLayer *pLayer = new CLayer(); // member variable of your window class
              CPrimitive *pEntity = new CGeoLine(); // create an entity of time line
              pEntity->m_StPnt = CPoint(10, 10); 
              // set the start point of the line 
              pEntity->m_EndPoint =  CPoint(100, 100); // set the end point of the line 
              pEntity->m_clr = RGB(255, 255, 255); // set the color of the line
              pLayer->AddEntityToLayer(pEntity); // store it to the layer class  
            

In the OnDraw(CDC *pDC) method of your window class, call the

在你的窗口类的OnDraw(CDC * PDC)方法,调用


              pLayer->DrawLayer(pDC); 
              // NOTE: pLayer should be a member of your window class that is created in the constructor. 

Also note that in the example above I have hard-coded the pEntity->m_StPnt and pEntity->m_EndPnt to some random CPoint values. Ideally this should be done in the OnLButtonDown handler which gives you the CPoint data as a parameter. 

另外请注意,在上面的例子中我已经硬编码pEntity-> m_StPnt和pEntity-> m_EndPnt一些随机连接点的值。理想情况下,应在OnLButtonDown处理程序,让你的连接点数据作为参数来完成。

Concept of layers

In your application, you can create 'N' number layers and maintain them in the CLayerList class. In the OnDraw() method of your window class, you can select which CLayer to be drawn. If you wish to draw all the layers then iterate each layer in the CLayerList and then call DrawLayer() method of the CLayer.

层的概念

在您的应用程序,你可以创建'N'层数并在CLayerList类维护他们。在你的窗口类的OnDraw()方法,您可以选择要绘制的CLayer。如果你想画所有图层,就迭代ClayerList的每一层,然后调用CLayer 的DrawLayer()方法。

All_Layers

History

Initial upload: 14 July 2012.

历史

最初上传:2012年7月14日。

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
许可

这篇文章,以及任何相关的源代码和文件,是根据代码项目开放许可(CPOL)
About the Author

关于作者

Sunil P V

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内