Git Product home page Git Product logo

graphicsdemo's Introduction

GraphicsDemo

一个基于Qt Graphics View Framework 的绘图框架。

主要功能

可以手动绘画线段、圆、圆弧等图形,并对图形进行移动和修改等操作。

框架结构

本框架基于Qt GraphicsView框架,主要由 Entity 图元类GraphicView 视图类Action 操作类及界面相关部分组成。

Qt GraphicsView框架中存在3个坐标系,即Scene场景坐标系,View视图坐标系,Item内部坐标系。为了操作方便,本框架中图元的坐标全部使用Scene中的坐标,在进行Item交互时需要将View的坐标转换成Scene中的坐标,并替换图元的移动操作,避免使用Transform进行变换。

由View转换到Scene的坐标使用View的mapToScene函数。

Entity图元类

继承于QGraphicsObject的自定义图元,带有信号槽。

Entity图元又分为基于xEntity的基本图元、基于xRegionEntity的带范围图元、基于xInterSingleEntity的单关联图元和基于xInterCoupleEntity的双关联图元。

继承关系如下:

                  QGraphicsObject
                         |
                         V
                      xEntity
                         |
      +------------------+---------------------+
      |                  |                     |
      V                  V                     V
xRegionEntity    xInterSingleEntity    xInterCoupleEntity
  • xEntity Class

带有画笔、预定义样式和信号槽的图元虚基类,定义了所有自定义图元的一些公共接口。

  • xRegionEntity Class

基于xEntity,带有范围的图元。添加了笔刷。

  • xInterSingleEntity Class

基于xEntity,关联一个xEntityxRegionEntity的扩展图元。

  • xInterCoupleEntity Class

基于xEntity,关联一个xEntityxRegionEntity的扩展图元。

GraphicView类

继承于QGraphicsView的视图类,负责绘图及管理动作事件。

Action操作类

用于定义和操作绘图动作。

Action分为xActionDefault默认操作类、xActionInterface无预览操作类和xActionPreviewInterface预览操作类。

  • xActionDefault

负责执行对图元的移动、拉伸等操作,在没有其它Action执行时执行此类。

  • xActionInterface Class

用于无需预览层的操作类的基类。

  • xActionPreviewInterface Class

基于xActionInterface,用于需要预览层的操作类的基类。添加了确认和取消的操作。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.