├── bin ├── test.exe ├── test.exp ├── test.iobj ├── test.ipdb ├── test.lib └── QGraphicsItems.dll ├── image ├── line.png ├── rect.png ├── text.png ├── time.png ├── curve.png ├── marker.png ├── pencil.png ├── distance.png ├── ellipse.png ├── innerdegree.png └── outterdegree.png ├── temp ├── main.obj ├── widget.obj ├── moc_widget.obj ├── qrc_widget.obj ├── test.tlog │ ├── CL.read.1.tlog │ ├── CL.write.1.tlog │ ├── link.read.1.tlog │ ├── CL.command.1.tlog │ ├── link.command.1.tlog │ ├── link.write.1.tlog │ ├── custombuild.read.1.tlog │ ├── custombuild.write.1.tlog │ ├── custombuild.command.1.tlog │ └── test.lastbuildstate └── test.log ├── widget.qrc ├── lib ├── bin │ ├── QGraphicsItems.dll │ ├── QGraphicsItems.exp │ └── QGraphicsItems.lib └── include │ ├── items_export.h │ ├── ToolAttribute.h │ ├── GraphicsView.h │ └── ItemAttribute.h ├── main.cpp ├── test.vcxproj.user ├── test.sln ├── README.md ├── GeneratedFiles ├── qrc_widget.cpp ├── Release │ └── moc_widget.cpp └── ui_widget.h ├── test.vcxproj.filters ├── widget.h ├── widget.cpp ├── test.vcxproj └── widget.ui /bin/test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/bin/test.exe -------------------------------------------------------------------------------- /bin/test.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/bin/test.exp -------------------------------------------------------------------------------- /bin/test.iobj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/bin/test.iobj -------------------------------------------------------------------------------- /bin/test.ipdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/bin/test.ipdb -------------------------------------------------------------------------------- /bin/test.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/bin/test.lib -------------------------------------------------------------------------------- /image/line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/line.png -------------------------------------------------------------------------------- /image/rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/rect.png -------------------------------------------------------------------------------- /image/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/text.png -------------------------------------------------------------------------------- /image/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/time.png -------------------------------------------------------------------------------- /temp/main.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/main.obj -------------------------------------------------------------------------------- /image/curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/curve.png -------------------------------------------------------------------------------- /image/marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/marker.png -------------------------------------------------------------------------------- /image/pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/pencil.png -------------------------------------------------------------------------------- /temp/widget.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/widget.obj -------------------------------------------------------------------------------- /widget.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /image/distance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/distance.png -------------------------------------------------------------------------------- /image/ellipse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/ellipse.png -------------------------------------------------------------------------------- /temp/moc_widget.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/moc_widget.obj -------------------------------------------------------------------------------- /temp/qrc_widget.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/qrc_widget.obj -------------------------------------------------------------------------------- /image/innerdegree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/innerdegree.png -------------------------------------------------------------------------------- /bin/QGraphicsItems.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/bin/QGraphicsItems.dll -------------------------------------------------------------------------------- /image/outterdegree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/image/outterdegree.png -------------------------------------------------------------------------------- /lib/bin/QGraphicsItems.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/lib/bin/QGraphicsItems.dll -------------------------------------------------------------------------------- /lib/bin/QGraphicsItems.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/lib/bin/QGraphicsItems.exp -------------------------------------------------------------------------------- /lib/bin/QGraphicsItems.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/lib/bin/QGraphicsItems.lib -------------------------------------------------------------------------------- /temp/test.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/custombuild.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/custombuild.read.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/custombuild.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/custombuild.write.1.tlog -------------------------------------------------------------------------------- /temp/test.tlog/custombuild.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyoung1992/GraphicsItem/HEAD/temp/test.tlog/custombuild.command.1.tlog -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | Widget w; 8 | w.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /temp/test.tlog/test.lastbuildstate: -------------------------------------------------------------------------------- 1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 2 | Release|x64|D:\dev\work\GraphicsItemTest\test\| 3 | -------------------------------------------------------------------------------- /lib/include/items_export.h: -------------------------------------------------------------------------------- 1 | #ifndef _ITEMS_EXPORT_H_ 2 | #define _ITEMS_EXPORT_H_ 3 | 4 | #if defined(COMPONENT_BUILD) 5 | #if defined(WIN32) 6 | 7 | #if defined(ITEMS_IMPLEMENTATION) 8 | #define ITEMS_EXPORT __declspec(dllexport) 9 | #else 10 | #define ITEMS_EXPORT __declspec(dllimport) 11 | #endif // defined(ITEMS_IMPLEMENTATION) 12 | 13 | #else // defined(WIN32) 14 | #if defined(ITEMS_IMPLEMENTATION) 15 | #define ITEMS_EXPORT __attribute__((visibility("default"))) 16 | #else 17 | #define ITEMS_EXPORT 18 | #endif 19 | #endif 20 | 21 | #else // defined(COMPONENT_BUILD) 22 | #define ITEMS_EXPORT __declspec(dllexport) 23 | #endif 24 | #endif // !_ITEMS_EXPORT_H_ 25 | -------------------------------------------------------------------------------- /test.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | D:\Qt\Qt5.6.0\5.6\msvc2015_64 6 | PATH=$(QTDIR)\bin%3b$(PATH) 7 | 8 | 9 | D:\Qt\Qt5.6.0\5.6\msvc2015_64 10 | PATH=$(QTDIR)\bin%3b$(PATH) 11 | 12 | -------------------------------------------------------------------------------- /test.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 15 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 16 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 17 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /temp/test.log: -------------------------------------------------------------------------------- 1 | C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(367,5): warning MSB8004: Intermediate Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Intermediate Directory. 2 | C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(368,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory. 3 | Moc'ing widget.h... 4 | Uic'ing widget.ui... 5 | Rcc'ing widget.qrc... 6 | RCC : warning : No resources in 'D:\dev\work\GraphicsItemTest\test\widget.qrc'. 7 | 8 | qrc_widget.cpp 9 | moc_widget.cpp 10 | widget.cpp 11 | 正在生成代码 12 | 1 of 142 functions ( 0.7%) were compiled, the rest were copied from previous compilation. 13 | 0 functions were new in current compilation 14 | 45 functions had inline decision re-evaluated but remain unchanged 15 | 已完成代码的生成 16 | test.vcxproj -> D:\dev\work\GraphicsItemTest\test\bin\test.exe 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GraphicsItem 2 | 基于Qt GraphicsView绘制图形(长方形、角度、圆等) 3 | ### 简介 4 | 基于Qt GraphicsView 实现图形的绘制,可以自定义图形绘制在view上。可用于各种图形处理程序中做图形绘制展示和基础测量! 5 | 6 | ### 使用方法 7 | 使用方法很简单,在你的项目中直接引入lib库,你的界面QGraphicsView提升为GraphicsView就可以实现对图片的绘制! 8 | 9 | ### Example 10 | 直接下载或者clone项目,这里包含了所有图形绘制示例!喜欢的朋友请 star 或者 fork! 11 | 12 | ### TODO 13 | 正在开发 14 | 15 | ### 效果图 16 | ##### 1.曲线 17 | ![曲线绘制(基于贝塞尔曲线算法)](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/curve.png) 18 | 19 | ##### 2.测量尺 20 | ![测量尺](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/distance.png) 21 | 22 | ##### 3.椭圆 23 | ![椭圆)](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/ellipse.png) 24 | 25 | ##### 4.内角 26 | ![内角](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/innerdegree.png) 27 | ##### 5.外角 28 | ![外角](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/outterdegree.png) 29 | 30 | ##### 6.直线 31 | ![直线](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/line.png) 32 | 33 | ##### 7.标记笔 34 | ![标记笔](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/marker.png) 35 | 36 | ##### 8.矩形 37 | ![矩形](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/rect.png) 38 | 39 | ##### 9.计时器 40 | ![计时器](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/time.png) 41 | 42 | ##### 10.铅笔 43 | ![铅笔](https://raw.githubusercontent.com/liyoung1992/GraphicsItem/master/image/pencil.png) 44 | 45 | -------------------------------------------------------------------------------- /GeneratedFiles/qrc_widget.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Resource object code 3 | ** 4 | ** Created by: The Resource Compiler for Qt version 5.6.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #ifdef QT_NAMESPACE 10 | # define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name 11 | # define QT_RCC_MANGLE_NAMESPACE0(x) x 12 | # define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b 13 | # define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) 14 | # define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ 15 | QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) 16 | #else 17 | # define QT_RCC_PREPEND_NAMESPACE(name) name 18 | # define QT_RCC_MANGLE_NAMESPACE(name) name 19 | #endif 20 | 21 | #ifdef QT_NAMESPACE 22 | namespace QT_NAMESPACE { 23 | #endif 24 | 25 | #ifdef QT_NAMESPACE 26 | } 27 | #endif 28 | 29 | int QT_RCC_MANGLE_NAMESPACE(qInitResources_widget)(); 30 | int QT_RCC_MANGLE_NAMESPACE(qInitResources_widget)() 31 | { 32 | return 1; 33 | } 34 | 35 | int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_widget)(); 36 | int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_widget)() 37 | { 38 | return 1; 39 | } 40 | 41 | namespace { 42 | struct initializer { 43 | initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_widget)(); } 44 | ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_widget)(); } 45 | } dummy; 46 | } 47 | -------------------------------------------------------------------------------- /test.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 14 | qrc;* 15 | false 16 | 17 | 18 | {99349809-55BA-4b9d-BF79-8FDBB0286EB3} 19 | ui 20 | 21 | 22 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 23 | qrc;* 24 | false 25 | 26 | 27 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 28 | moc;h;cpp 29 | False 30 | 31 | 32 | {0a94324c-eb53-48c3-b264-38281c7ca241} 33 | cpp;moc 34 | False 35 | 36 | 37 | {903ce7a2-55d6-43b9-8d81-5d1fcf849fdb} 38 | cpp;moc 39 | False 40 | 41 | 42 | 43 | 44 | Source Files 45 | 46 | 47 | Source Files 48 | 49 | 50 | Generated Files\Debug 51 | 52 | 53 | Generated Files\Release 54 | 55 | 56 | Generated Files 57 | 58 | 59 | 60 | 61 | Header Files 62 | 63 | 64 | Form Files 65 | 66 | 67 | Resource Files 68 | 69 | 70 | 71 | 72 | Generated Files 73 | 74 | 75 | -------------------------------------------------------------------------------- /widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | //#include "QGraphicsPartitionItem.h" 5 | #include "GraphicsView.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | namespace Ui { 12 | class Widget; 13 | } 14 | 15 | //For test 16 | class CurrentFrame 17 | { 18 | public: 19 | CurrentFrame() 20 | { 21 | width=640; 22 | height=480; 23 | mImage = new QPixmap(640,480); 24 | QPainter painter; 25 | painter.begin(mImage); 26 | QPen pen; 27 | pen.setWidth(1); 28 | pen.setColor(QColor(255,0,0)); 29 | QBrush brush; 30 | brush.setColor(QColor(128,128,128)); 31 | painter.setPen(pen); 32 | painter.setBrush(brush); 33 | painter.fillRect(QRect(0,0,640,480),QBrush(QColor(255,255,255))); 34 | // painter.drawRect(QRect(0,0,639,479)); 35 | //painter.fillRect(QRect(100,100,50,50),QBrush(QColor(255,0,0))); 36 | painter.end(); 37 | mImage->save("bg.bmp"); 38 | } 39 | ~CurrentFrame() 40 | { 41 | delete mImage; 42 | } 43 | 44 | int width; 45 | int height; 46 | QPixmap* mImage; 47 | }; 48 | 49 | class Widget : public QWidget 50 | { 51 | Q_OBJECT 52 | 53 | public: 54 | explicit Widget(QWidget *parent = 0); 55 | ~Widget(); 56 | protected: 57 | void flipImage(); 58 | private slots: 59 | 60 | void on_Marker_clicked(); 61 | 62 | void on_SelectItem_clicked(); 63 | 64 | void on_DrawLine_clicked(); 65 | 66 | void on_Pencil_clicked(); 67 | 68 | void on_Text_clicked(); 69 | 70 | void on_Image_clicked(); 71 | 72 | void on_Curve_clicked(); 73 | 74 | void on_DrawRect_clicked(); 75 | 76 | void on_Ellipse_clicked(); 77 | 78 | void on_Time_clicked(); 79 | 80 | void on_Distance_clicked(); 81 | 82 | void on_InnerDegree_clicked(); 83 | 84 | void on_OutterDegree_clicked(); 85 | 86 | void on_CloneRect_clicked(); 87 | 88 | //void on_Horizontal_clicked(); 89 | 90 | //void on_Vertical_clicked(); 91 | 92 | void on_MakerPen_clicked(); 93 | 94 | void on_Color_clicked(); 95 | 96 | void on_font_clicked(); 97 | 98 | void on_opacity_valueChanged(int value); 99 | 100 | void on_lineStyle_currentIndexChanged(const QString &arg1); 101 | 102 | void on_LineWidth_currentIndexChanged(int index); 103 | 104 | void on_brushColor_clicked(); 105 | 106 | void on_delete_2_clicked(); 107 | 108 | void on_copy_clicked(); 109 | 110 | void on_setOrder_clicked(); 111 | 112 | void on_SetAsScale_clicked(); 113 | 114 | void on_paste_clicked(); 115 | 116 | void on_save_clicked(); 117 | 118 | void on_load_clicked(); 119 | 120 | void on_cut_clicked(); 121 | 122 | 123 | 124 | void on_Zoom_clicked(); 125 | 126 | void on_Move_clicked(); 127 | 128 | void on_HFlip_stateChanged(int arg1); 129 | 130 | void on_VFlip_stateChanged(int arg1); 131 | 132 | 133 | 134 | private: 135 | Ui::Widget *ui; 136 | CurrentFrame cf; 137 | QGraphicsPixmapItem * curFrame; 138 | QGraphicsScene* myscene; 139 | }; 140 | 141 | #endif // WIDGET_H 142 | -------------------------------------------------------------------------------- /lib/include/ToolAttribute.h: -------------------------------------------------------------------------------- 1 | #ifndef _TOOL_ATTRIBUTE_H 2 | #define _TOOL_ATTRIBUTE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "items_export.h" 13 | //绘制工具使用的属性 14 | class ITEMS_EXPORT ToolAtrribute 15 | { 16 | public: 17 | enum ArrowType 18 | { 19 | LINE,//普通直线 20 | LEFT_ARROW,//带左箭头直线 21 | RIGHT_ARROW,//带右箭头直线 22 | BOTH_ARROW//双向箭头直线 23 | }; 24 | private: 25 | int width;//线宽 26 | QColor penColor;//画笔颜色 27 | QColor brushColor;//填充颜色 28 | ArrowType arrow;//线条类型 29 | QFont itemFont;//字体 30 | float itemOpacity;//取值为0至1,透明度,1表示完全不透明 31 | bool widthEnable;//线宽是否修改 32 | bool penEnable;//画笔颜色是否修改 33 | bool brushEnable;//填充画刷是否可修改 34 | bool arrowEnable;//箭头是否修改,即是否可以调整线形 35 | bool fontEnable;//字体是否可以修改 36 | bool opacityEnable; 37 | public: 38 | void SetArrow(const ArrowType arrow){ 39 | this->arrow = arrow; 40 | } 41 | ArrowType Arrow()const{ 42 | return arrow; 43 | } 44 | 45 | bool ArrowEnable()const{ 46 | return arrowEnable; 47 | } 48 | void SetArrowEnable(const bool b){ 49 | this->arrowEnable = b; 50 | } 51 | 52 | void SetFontEnable(const bool b){ 53 | this->fontEnable = b; 54 | } 55 | bool FontEnable()const{ 56 | return fontEnable; 57 | } 58 | 59 | QFont ItemFont()const{ 60 | return itemFont; 61 | } 62 | void SetItemFont(const QFont font){ 63 | this->itemFont = font; 64 | } 65 | 66 | void SetWidthEnable(const bool b){ 67 | this->widthEnable = b; 68 | } 69 | bool WidthEnable()const{ 70 | return widthEnable; 71 | } 72 | 73 | void SetWidth(const int width){ 74 | this->width = width; 75 | } 76 | int Width()const{ 77 | return width; 78 | } 79 | 80 | QColor PenColor()const{ 81 | return penColor; 82 | } 83 | void SetPenColor(const QColor color){ 84 | this->penColor = color; 85 | } 86 | 87 | void SetPenEnable(const bool b){ 88 | this->penEnable = b; 89 | } 90 | bool PenEnable()const{ 91 | return penEnable; 92 | } 93 | 94 | QColor BrushColor()const{ 95 | return brushColor; 96 | } 97 | void SetBrushColor(const QColor color){ 98 | this->brushColor = color; 99 | } 100 | 101 | void SetBrushEnble(const bool b){ 102 | this->brushEnable = b; 103 | } 104 | bool BrushEnable()const{ 105 | return brushEnable; 106 | } 107 | 108 | float ItemOpacity()const{ 109 | return itemOpacity; 110 | } 111 | void SetItemOpacity(const float opacity){ 112 | if (itemOpacity < 0) 113 | this->itemOpacity = 0; 114 | else if (itemOpacity >1) 115 | this->itemOpacity = 1; 116 | else 117 | this->itemOpacity = opacity; 118 | } 119 | 120 | void SetOpacityEnable(int b){ 121 | opacityEnable = b; 122 | } 123 | bool OpacityEnable()const{ 124 | return opacityEnable; 125 | } 126 | 127 | const ToolAtrribute& operator =(const ToolAtrribute& attr) 128 | { 129 | arrow = attr.Arrow();//箭头,即线形 130 | arrowEnable = attr.ArrowEnable();// 131 | itemFont = attr.ItemFont();//字体 132 | fontEnable = attr.FontEnable(); 133 | width = attr.Width();//线宽 134 | widthEnable = attr.WidthEnable(); 135 | penColor = attr.PenColor();//画笔颜色 136 | penEnable = attr.PenEnable(); 137 | brushColor = attr.BrushColor();//填充颜色 138 | brushEnable = attr.BrushEnable(); 139 | itemOpacity = attr.ItemOpacity();//取值为0至100,透明度 140 | opacityEnable = attr.OpacityEnable(); 141 | 142 | return *this; 143 | } 144 | 145 | explicit ToolAtrribute(const ToolAtrribute &attr) 146 | { 147 | arrow = attr.Arrow();//箭头,即线形 148 | arrowEnable = attr.ArrowEnable();// 149 | itemFont = attr.ItemFont();//字体 150 | fontEnable = attr.FontEnable(); 151 | width = attr.Width();//线宽 152 | widthEnable = attr.WidthEnable(); 153 | penColor = attr.PenColor();//画笔颜色 154 | penEnable = attr.PenEnable(); 155 | brushColor = attr.BrushColor();//填充颜色 156 | brushEnable = attr.BrushEnable(); 157 | itemOpacity = attr.ItemOpacity();//取值为0至100,透明度 158 | opacityEnable = attr.OpacityEnable(); 159 | } 160 | 161 | ToolAtrribute(int _width = 3,//线宽 162 | QColor _penColor = QColor(Qt::blue),//画笔颜色 163 | QColor _brushColor = QColor(Qt::green),//填充颜色 164 | ArrowType _arrow = LINE,//线条类型 165 | QFont _font = QFont("宋体"),//字体 166 | float _opacity = 1, 167 | bool _widthEnable = true,//线宽是否修改 168 | bool _penEnable = true,//画笔颜色是否修改 169 | bool _brushEnable = true,//画刷是否可修改 170 | bool _arrowEnable = true,//箭头是否修改,即是否可以调整线形 171 | bool _fontEnable = true,//字体是否可以修改 172 | bool _opacityEnable = true 173 | ) :width(_width) 174 | , penColor(_penColor) 175 | , brushColor(_brushColor) 176 | , arrow(_arrow) 177 | , itemFont(_font) 178 | , itemOpacity(_opacity) 179 | , widthEnable(_widthEnable) 180 | , penEnable(_penEnable) 181 | , brushEnable(_brushEnable) 182 | , arrowEnable(_arrowEnable) 183 | , fontEnable(_fontEnable) 184 | , opacityEnable(_opacityEnable) 185 | {} 186 | }; 187 | 188 | 189 | 190 | #endif 191 | -------------------------------------------------------------------------------- /lib/include/GraphicsView.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICSVIEW_H 2 | #define GRAPHICSVIEW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | //#include "QGraphicsPartitionItem.h" 10 | #include "ToolAttribute.h" 11 | #include "items_export.h" 12 | 13 | typedef std::map ITEMS; 14 | typedef ITEMS::iterator ITEMS_ITERATOR; 15 | class ITEMS_EXPORT GraphicsView : public QGraphicsView { 16 | public: 17 | enum Mode//设置当前所有模式 18 | { 19 | ITEM_NONE, //默认空模式 20 | ITEM_MARKERPEN, //标记笔 21 | ITEM_PENCIL, //铅笔 22 | ITEM_TEXT, //文本 23 | ITEM_IMAGE, //图像 24 | ITEM_MARKER, //十字标记 25 | ITEM_DRAWLINE, //绘制直线模式 26 | ITEM_CURVE, //曲线 27 | ITEM_DRAWRECT, //矩形/正方形 28 | ITEM_CIRCLE, //椭圆形 29 | ITEM_TIME, //时间 30 | ITEM_SCALE, //距离 31 | ITEM_INNERDEGREE,//内角角度 32 | ITEM_OUTTERDEGREE,//外角角度 33 | ITEM_CLONERECT, //复制矩形 34 | ITEM_HORIZONTAL, //水平线 35 | ITEM_VERTICAL, //垂直线 36 | 37 | GLOBAL_MOVE, //全局移动模式 38 | GLOBAL_ZOOM, //全局缩放模式 39 | GLOBAL_HFLIP, //水平翻转 40 | GLOBAL_VFLIP //垂直翻转 41 | }; 42 | public: 43 | //定义了粘贴板 44 | QVector > clipBoard; 45 | //当前正在绘制的对象 46 | QGraphicsItem* mCurEditItem; 47 | //当前模式 48 | Mode mCurMode; 49 | //容器,存放所有的Item 50 | std::map allItems; 51 | QList Allitems() { 52 | QList result; 53 | for (std::map::iterator iter = allItems.begin(); 54 | iter != allItems.end(); iter++) { 55 | result.push_back(iter->second); 56 | } 57 | return result; 58 | } 59 | //当前时间戳,其决定了所有item的状态 60 | qint64 curTime; 61 | 62 | //默认构造函数 63 | GraphicsView(QWidget * parent = 0); 64 | //设置当前的模式,决定了如何响应鼠标键盘操作 65 | void setCurrentMode(Mode mode); 66 | //获取当前的模式 67 | Mode getCurrentMode(); 68 | //设置view的当前属性,同时更新所有item 69 | void setCurTime(qint64 ct) { curTime = ct; setAllItemsCurrentTime(ct); } 70 | 71 | //当观察矩形移动时,更新矩形的位置在视频区域 72 | void updateTranslateRect(); 73 | //当缩放观察矩形时,更新矩形的位置在视频区域 74 | void updateTranslateScaleRect(); 75 | public: 76 | //获取所有的选中的item 77 | QList getSelectedItem() const 78 | { 79 | return this->scene()->selectedItems(); 80 | } 81 | //更行所有item的当前时间 82 | void setAllItemsCurrentTime(qint64 time); 83 | //显示所有item 84 | void showAllItems(); 85 | //隐藏所有item 86 | void hideAllItems(); 87 | //h为true表示水平翻转,v为true表示垂直翻转 88 | void FlipAllItems(bool h, bool v); 89 | 90 | //剪切板是否为空. 返回值 1:表示空;0:表示非空; 91 | bool ClipBoardEmpty() { return clipBoard.empty(); } 92 | //粘贴 93 | int Paste(); 94 | //将当前场景中选中的对象copy至剪贴板 95 | int Copy(); 96 | //读取当前剪贴板的对象 97 | QList GetCopy(); 98 | //清空剪切板 99 | void ClearClipBoard() { clipBoard.clear(); } 100 | //删除所有选中的Item 101 | int deleteAllSelected(); 102 | //删除所有的item 103 | int deleteAll(); 104 | //剪切 105 | int Cut(); 106 | //撤销 107 | void Redo() {}; 108 | //重做 109 | void Undo() {} 110 | 111 | //选中item的z值+1, 112 | int setSelectedItemZOrder(); 113 | //设置选中item的画笔 114 | int setSelectedItemPenColor(QColor color); 115 | //设置选中item的画刷 116 | int setSelectedItemBrushColor(QColor color); 117 | //设置选中item的字体 118 | int setSelectedItemFont(QFont font); 119 | //设置选中item的线宽 120 | int setSelectedItemWidth(const int width); 121 | //设置选中item的箭头类型 122 | int setSelectedItemLineStyle(ToolAtrribute::ArrowType style); 123 | //设置选中item的透明度 124 | int setSelectedItemOpacity(int value); 125 | void setToolAttribute(ToolAtrribute*); 126 | //将比例尺设为参考操作 127 | void setScale(); 128 | //设置图片工具所需的图片 129 | void setItemImage(QString); 130 | 131 | //保存 132 | int saveItems(); 133 | //载入 134 | int loadItems(); 135 | 136 | 137 | // 重设定时器处理函数 138 | void TimerReset(); 139 | // 开始计时处理函数 140 | void StartTimer(); 141 | // 结束定时处理函数 142 | void StopTimer(); 143 | 144 | //点击放大与缩小 145 | void ZoomParam(bool); 146 | 147 | 148 | private: 149 | //true表示水平翻转 150 | bool mHFlip; 151 | //true表示垂直翻转 152 | bool mVFlip; 153 | //开始拖放时的全局坐标 154 | QPointF mStartScenePoint; 155 | //开始拖放时观察矩形的坐标 156 | QRectF mStartRect; 157 | 158 | 159 | ToolAtrribute* toolAttribute; 160 | QGraphicsItem* parent_rect_; 161 | 162 | //图片工具所指图片的路径 163 | QString imgPath; 164 | protected: 165 | void mousePressEvent(QMouseEvent* event) override; 166 | void mouseMoveEvent(QMouseEvent* event) override; 167 | void mouseDoubleClickEvent(QMouseEvent* event) override; 168 | void mouseReleaseEvent(QMouseEvent* event) override; 169 | void wheelEvent(QWheelEvent* event) override; 170 | void dragEnterEvent(QDragEnterEvent* event) override; 171 | void dragMoveEvent(QDragMoveEvent* event) override; 172 | void keyPressEvent(QKeyEvent* event) override; 173 | void OnMouseMove(QMouseEvent* event); 174 | }; 175 | 176 | #endif // GRAPHICSVIEW_H 177 | -------------------------------------------------------------------------------- /lib/include/ItemAttribute.h: -------------------------------------------------------------------------------- 1 | #ifndef _ITEM_ATTRIBUTE_H_ 2 | #define _ITEM_ATTRIBUTE_H_ 3 | 4 | #include "ToolAttribute.h" 5 | #include "QGraphicsScene.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "QGraphicsPathItem" 13 | #include "items_export.h" 14 | typedef std::map > TrackData; 15 | typedef TrackData::iterator ITERATOR; 16 | 17 | /* 18 | * 这个类封装了所有绘制项一些基本属性和操作 19 | */ 20 | class ITEMS_EXPORT ItemAttribute 21 | { 22 | private: 23 | int startTime;//item出现的时间 24 | int endTime;//item消失的时间 25 | int fadeIn;//淡入时间 26 | int fadeInDuration;//淡入持续时间 27 | int fadeOut;//淡出时间 28 | int fadeOutDuration;//淡出持续时间 29 | 30 | 31 | 32 | public: 33 | qint64 curTime;//当前时间 34 | ToolAtrribute attr; //工具的属性 35 | public: 36 | ItemAttribute(int _startTime = -1//item出现的时间 37 | , int _endTime = -1//item消失的时间 38 | , int _fadeIn = -1//淡入时间 39 | , int _fadeOut = -1//淡出时间 40 | , int _fadeInDuration = 0//淡入持续时间 41 | , int _fadeOutDuration = 0//淡出持续时间 42 | ) :startTime(_startTime) 43 | , endTime(_endTime) 44 | , fadeIn(_fadeIn) 45 | , fadeInDuration(_fadeInDuration) 46 | , fadeOut(_fadeOut) 47 | , fadeOutDuration(_fadeOutDuration) 48 | , curTime(0) { 49 | 50 | } 51 | 52 | virtual ~ItemAttribute() {} 53 | 54 | const ItemAttribute& operator=(const ItemAttribute& attribute) 55 | { 56 | startTime = attribute.StartTime();//item出现的时间 57 | endTime = attribute.EndTime();//item消失的时间 58 | fadeIn = attribute.FadeIn();//淡入时间 59 | fadeInDuration = attribute.FadeInDuration();//淡入持续时间 60 | fadeOut = attribute.FadeOut();//淡出时间 61 | fadeOutDuration = attribute.FadeOutDuration();//淡出持续时间 62 | 63 | return *this; 64 | } 65 | explicit ItemAttribute(const ItemAttribute& attribute) 66 | { 67 | attr = attribute.attr; 68 | startTime = attribute.StartTime();//item出现的时间 69 | endTime = attribute.EndTime();//item消失的时间 70 | fadeIn = attribute.FadeIn();//淡入时间 71 | fadeInDuration = attribute.FadeInDuration();//淡入持续时间 72 | fadeOut = attribute.FadeOut();//淡出时间 73 | fadeOutDuration = attribute.FadeOutDuration();//淡出持续时间 74 | } 75 | void setToolAttribute(const ToolAtrribute& toolAtt) 76 | { 77 | attr.SetArrow(toolAtt.Arrow()); 78 | attr.SetArrowEnable(toolAtt.ArrowEnable()); 79 | 80 | attr.SetBrushColor(toolAtt.BrushColor()); 81 | attr.SetBrushEnble(toolAtt.BrushEnable()); 82 | 83 | attr.SetItemFont(toolAtt.ItemFont()); 84 | attr.SetFontEnable(toolAtt.FontEnable()); 85 | 86 | attr.SetItemOpacity(toolAtt.ItemOpacity()); 87 | attr.SetOpacityEnable(toolAtt.OpacityEnable()); 88 | 89 | attr.SetPenColor(toolAtt.PenColor()); 90 | attr.SetPenEnable(toolAtt.PenEnable()); 91 | 92 | attr.SetWidth(toolAtt.Width()); 93 | attr.SetWidthEnable(toolAtt.WidthEnable()); 94 | } 95 | 96 | int StartTime()const{ 97 | return startTime; 98 | } 99 | void SetStartTime(const int time){ 100 | startTime = time; 101 | } 102 | int EndTime()const{ 103 | return endTime; 104 | } 105 | void SetEndTime(const int time){ 106 | endTime = time; 107 | } 108 | int FadeIn()const{ 109 | return fadeIn; 110 | } 111 | void SetFadeIn(const int time){ 112 | fadeIn = time; 113 | } 114 | int FadeInDuration()const{ 115 | return fadeInDuration; 116 | } 117 | void SetFadeInDuration(const int time){ 118 | fadeInDuration = time; 119 | } 120 | int FadeOut()const{ 121 | return fadeOut; 122 | } 123 | void SetFadeOut(const int time){ 124 | fadeOut = time; 125 | } 126 | int FadeOutDuration()const{ 127 | return fadeOutDuration; 128 | } 129 | void SetFadeOutDuration(const int time){ 130 | fadeOutDuration = time; 131 | } 132 | float CurrentOpacity() 133 | { 134 | int fi = FadeIn(); 135 | int fid = FadeInDuration(); 136 | int fo = FadeOut(); 137 | int fod = FadeOutDuration(); 138 | float opacity = attr.ItemOpacity(); 139 | qint64 ct = CurTime(); 140 | 141 | //判断是否为立即淡入淡出 142 | if (fid == 0 && fi != -1) 143 | opacity = attr.ItemOpacity(); 144 | if (fod == 0 && fo != -1) 145 | opacity = 0; 146 | //先淡入后淡出 147 | if (fi <= fo&&fo != -1){ 148 | if (ct >= fi - fid&&ct <= fi&&fid != 0) 149 | opacity = (1 + (float)(ct - fi) / fid)*attr.ItemOpacity(); 150 | else if (ct > fi&&ct= fo&&ct <= fo + fod&&fod != 0) 153 | opacity = (1 - (float)(ct - fo) / fod)*attr.ItemOpacity(); 154 | if (ct <= fi - fid || ct >= fo + fod)//淡入前和淡出后不透明度都是0 155 | opacity = 0; 156 | } 157 | //先淡出后淡入 158 | else if (fi > fo&&fi != -1){ 159 | if (ct > fo&&ct <= fo + fod&&fod != 0)//当某时刻既有淡入又有淡出时,淡出优先级高于淡入 160 | opacity = (1 - (float)(ct - fo) / fod)*attr.ItemOpacity(); 161 | else if (ct >= fi - fid&&ct < fi&&fid != 0) 162 | opacity = (1 + (float)(ct - fi) / fid)*attr.ItemOpacity(); 163 | if (ct>fo + fod&&ct < fi - fid)//淡出后和淡入前的不透明度为0 164 | opacity = 0; 165 | if (ct <= fo || ct >= fi)//淡出前和淡入后都是原先的不透明度 166 | opacity = attr.ItemOpacity(); 167 | } 168 | return opacity; 169 | } 170 | const ToolAtrribute& ToolAtrribute()const{ 171 | return attr; 172 | } 173 | qint64 CurTime()const 174 | { 175 | return curTime; 176 | } 177 | void setCurTime(const qint64& ct) 178 | { 179 | curTime = ct; 180 | } 181 | public: 182 | //提供一些接口函数 183 | //添加到场景 184 | virtual void addToScene(QGraphicsScene* scene) = 0; 185 | //从场景删除 186 | virtual void removeFromScene(QGraphicsScene* scene) = 0; 187 | virtual void setItemPenColor(const QColor penColor){ attr.SetPenColor(penColor); }//画笔颜色 188 | virtual void setItemBrushColor(const QColor color){ attr.SetBrushColor(color); }//画刷颜色 189 | virtual void setItemFont(const QFont font){ attr.SetItemFont(font); }//字体 190 | virtual void setItemWidth(const int width){ attr.SetWidth(width); }//线宽 191 | virtual void setItemLineStyle(const ToolAtrribute::ArrowType style){ attr.SetArrow(style); }//线形 192 | virtual void setItemOpacity(const float opacity){ attr.SetItemOpacity(opacity); }//透明度取值为0至1 193 | virtual void updateAttribute() = 0; 194 | virtual QString className() = 0; 195 | virtual void save(QTextStream &steam) = 0; 196 | virtual void load(QTextStream &steam) = 0; 197 | virtual void showCtrlRect() = 0; 198 | virtual void hideCtrlRect() = 0; 199 | virtual bool Equals(const ItemAttribute* other) const { 200 | return other == this; 201 | } 202 | virtual ItemAttribute* MainItem() { 203 | return this; 204 | } 205 | }; 206 | #endif 207 | -------------------------------------------------------------------------------- /widget.cpp: -------------------------------------------------------------------------------- 1 | #include "widget.h" 2 | #include "ui_widget.h" 3 | 4 | // #include "QGraphicsSegment.h" 5 | // #include "QGraphicsCircleItem.h" 6 | // #include "QGraphicsPartitionItem.h" 7 | 8 | 9 | Widget::Widget(QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::Widget) 12 | { 13 | ui->setupUi(this); 14 | 15 | myscene = new QGraphicsScene(0,0,255,255); 16 | ui->graphicsView->setScene(myscene); 17 | ui->graphicsView->setSceneRect(0,0,255,255); 18 | 19 | 20 | //创建一个640x480的图像用于测试 21 | //CurrentFrame cf; 22 | curFrame = myscene->addPixmap(*cf.mImage); 23 | int VideoWidth = cf.width; 24 | int VideoHeight = cf.height; 25 | 26 | //根据视频大小,设置场景区域 27 | myscene->setSceneRect(0,0,VideoWidth,VideoHeight); 28 | 29 | //根据视频显示区域的大小,缩放视口的大小和位置 30 | //设置到视频显示区域 31 | ui->graphicsView->setParent(ui->label_3); 32 | //获取视频显示区域的大小 33 | int height = ui->label_3->height(); 34 | int width = ui->label_3->width(); 35 | qDebug("%d %d",height,width); 36 | //调整为合适的大小,放置到正中央 37 | int vHeight = height-4;//边框设置了1个像素,为了显示区别,还空了1个像素,因此-4 38 | int vWidth = vHeight*4/3; 39 | int vTop = 2; 40 | int vLeft = (width-vWidth)/2; 41 | ui->graphicsView->setGeometry(vLeft,vTop,vWidth,vHeight); 42 | ui->graphicsView->setSceneRect(0,0,640,480); 43 | //根据视频大小,进行缩放映射 44 | ui->graphicsView->resetTransform(); 45 | float s = (float)(vWidth-2)/(float)VideoWidth; //默认具有1个像素边框,因此-2 46 | ui->graphicsView->scale(s,s); 47 | ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 48 | ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 49 | 50 | 51 | ui->label_5->setText(QString("100")); 52 | } 53 | 54 | Widget::~Widget() 55 | { 56 | delete ui; 57 | } 58 | 59 | void Widget::on_Marker_clicked() 60 | { 61 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_MARKER); 62 | } 63 | 64 | void Widget::on_SelectItem_clicked() 65 | { 66 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_NONE); 67 | } 68 | 69 | void Widget::on_DrawLine_clicked() 70 | { 71 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_DRAWLINE); 72 | } 73 | 74 | void Widget::on_Pencil_clicked() 75 | { 76 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_PENCIL); 77 | } 78 | 79 | void Widget::on_Text_clicked() 80 | { 81 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_TEXT); 82 | } 83 | 84 | void Widget::on_Image_clicked() 85 | { 86 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_IMAGE); 87 | } 88 | 89 | void Widget::on_Curve_clicked() 90 | { 91 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_CURVE); 92 | } 93 | 94 | void Widget::on_DrawRect_clicked() 95 | { 96 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_DRAWRECT); 97 | } 98 | 99 | void Widget::on_Ellipse_clicked() 100 | { 101 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_CIRCLE); 102 | } 103 | 104 | void Widget::on_Time_clicked() 105 | { 106 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_TIME); 107 | } 108 | 109 | void Widget::on_Distance_clicked() 110 | { 111 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_SCALE); 112 | } 113 | 114 | void Widget::on_InnerDegree_clicked() 115 | { 116 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_INNERDEGREE); 117 | } 118 | 119 | void Widget::on_OutterDegree_clicked() 120 | { 121 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_OUTTERDEGREE); 122 | } 123 | 124 | void Widget::on_CloneRect_clicked() 125 | { 126 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_CLONERECT); 127 | } 128 | 129 | 130 | /* 131 | void Widget::on_Horizontal_clicked() 132 | { 133 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_HORIZONTAL); 134 | } 135 | 136 | void Widget::on_Vertical_clicked() 137 | { 138 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_VERTICAL); 139 | } 140 | */ 141 | void Widget::on_MakerPen_clicked() 142 | { 143 | ui->graphicsView->setCurrentMode(GraphicsView::ITEM_MARKERPEN); 144 | } 145 | 146 | void Widget::on_Color_clicked()//color 147 | { 148 | const QColor color = QColorDialog::getColor(Qt::green, this, "Select Color"); 149 | 150 | if (color.isValid()) { 151 | ui->graphicsView->setSelectedItemPenColor(color); 152 | } 153 | } 154 | 155 | void Widget::on_font_clicked() 156 | { 157 | bool ok; 158 | QFont font = QFontDialog::getFont(&ok, this); 159 | if (ok) { 160 | qDebug()<<"font:"<graphicsView->setSelectedItemFont(font); 162 | } 163 | } 164 | void Widget::on_opacity_valueChanged(int value) 165 | { 166 | ui->graphicsView->setSelectedItemOpacity(value); 167 | ui->label_5->setText(QString::number(value)); 168 | } 169 | 170 | void Widget::on_lineStyle_currentIndexChanged(const QString &arg) 171 | { 172 | if (arg == QString("直线")) 173 | { 174 | ui->graphicsView->setSelectedItemLineStyle(ToolAtrribute::LINE); 175 | } 176 | else if (arg == QString("左箭头")) 177 | { 178 | ui->graphicsView->setSelectedItemLineStyle(ToolAtrribute::LEFT_ARROW); 179 | }else if (arg == QString("右箭头")) 180 | { 181 | ui->graphicsView->setSelectedItemLineStyle(ToolAtrribute::RIGHT_ARROW); 182 | }else if (arg == QString("双向箭头")) 183 | { 184 | ui->graphicsView->setSelectedItemLineStyle(ToolAtrribute::BOTH_ARROW); 185 | } 186 | } 187 | 188 | void Widget::on_LineWidth_currentIndexChanged(int index) 189 | { 190 | ui->graphicsView->setSelectedItemWidth(index); 191 | } 192 | 193 | void Widget::on_brushColor_clicked() 194 | { 195 | const QColor color = QColorDialog::getColor(Qt::green, this, "Select Color"); 196 | 197 | if (color.isValid()) { 198 | qDebug()<<"color:"<graphicsView->setSelectedItemBrushColor(color); 200 | } 201 | 202 | } 203 | 204 | void Widget::on_copy_clicked() 205 | { 206 | ui->graphicsView->Copy(); 207 | } 208 | 209 | void Widget::on_setOrder_clicked() 210 | { 211 | ui->graphicsView->setSelectedItemZOrder(); 212 | } 213 | 214 | void Widget::on_SetAsScale_clicked() 215 | { 216 | try{ 217 | ui->graphicsView->setScale(); 218 | } 219 | catch(...) 220 | { 221 | qDebug()<<"set scale failed."; 222 | } 223 | } 224 | 225 | void Widget::on_delete_2_clicked() 226 | { 227 | ui->graphicsView->deleteAllSelected(); 228 | } 229 | 230 | void Widget::on_paste_clicked() 231 | { 232 | ui->graphicsView->Paste(); 233 | } 234 | //json输入 235 | void Widget::on_save_clicked() 236 | { 237 | ui->graphicsView->saveItems(); 238 | } 239 | 240 | //json解析 241 | void Widget::on_load_clicked() 242 | { 243 | ui->graphicsView->loadItems(); 244 | } 245 | 246 | void Widget::on_cut_clicked() 247 | { 248 | ui->graphicsView->Cut(); 249 | } 250 | 251 | 252 | 253 | void Widget::flipImage() 254 | { 255 | bool vflip = ui->VFlip->isChecked(); 256 | bool hflip = ui->HFlip->isChecked(); 257 | QPixmap temp = cf.mImage->copy(); 258 | QPixmap img = QPixmap::fromImage(temp.toImage().mirrored(hflip,vflip)); 259 | curFrame->setPixmap(img); 260 | } 261 | 262 | void Widget::on_Zoom_clicked() 263 | { 264 | ui->graphicsView->setCurrentMode(GraphicsView::GLOBAL_ZOOM); 265 | } 266 | 267 | void Widget::on_Move_clicked() 268 | { 269 | ui->graphicsView->setCurrentMode(GraphicsView::GLOBAL_MOVE); 270 | } 271 | 272 | void Widget::on_HFlip_stateChanged(int ) 273 | { 274 | flipImage(); 275 | ui->graphicsView->FlipAllItems(true,false); 276 | } 277 | 278 | void Widget::on_VFlip_stateChanged(int ) 279 | { 280 | flipImage(); 281 | ui->graphicsView->FlipAllItems(false,true); 282 | } 283 | 284 | 285 | 286 | -------------------------------------------------------------------------------- /test.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | {B12702AD-ABFB-343A-A199-8E24837244A3} 15 | Qt4VSv1.0 16 | 8.1 17 | 18 | 19 | 20 | Application 21 | v140 22 | 23 | 24 | Application 25 | v140 26 | true 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | $(SolutionDir)$(Platform)\$(Configuration)\ 35 | 36 | 37 | $(SolutionDir)bin 38 | $(SolutionDir)temp 39 | 40 | 41 | 42 | UNICODE;WIN32;WIN64;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 43 | .\GeneratedFiles;D:\dev\work\include;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 44 | Disabled 45 | ProgramDatabase 46 | MultiThreadedDebugDLL 47 | true 48 | 49 | 50 | Windows 51 | $(OutDir)\$(ProjectName).exe 52 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 53 | true 54 | qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Widgetsd.lib;%(AdditionalDependencies) 55 | 56 | 57 | 58 | 59 | UNICODE;WIN32;WIN64;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 60 | .\GeneratedFiles;.\lib\include;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 61 | 62 | MultiThreadedDLL 63 | true 64 | 65 | 66 | Windows 67 | $(OutDir)\$(ProjectName).exe 68 | $(QTDIR)\lib;.\lib\bin;%(AdditionalLibraryDirectories) 69 | false 70 | qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;QGraphicsItems.lib;%(AdditionalDependencies) 71 | 72 | 73 | 74 | 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | true 85 | 86 | 87 | 88 | 89 | 90 | 91 | $(QTDIR)\bin\moc.exe;%(FullPath) 92 | Moc%27ing widget.h... 93 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 94 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-ID:\dev\work\include" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" 95 | $(QTDIR)\bin\moc.exe;%(FullPath) 96 | Moc%27ing widget.h... 97 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 98 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I.\lib\include" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" 99 | 100 | 101 | 102 | 103 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 104 | Uic%27ing %(Identity)... 105 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 106 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 107 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 108 | Uic%27ing %(Identity)... 109 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 110 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | %(FullPath);%(AdditionalInputs) 119 | Rcc%27ing %(Identity)... 120 | .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) 121 | "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp 122 | %(FullPath);%(AdditionalInputs) 123 | Rcc%27ing %(Identity)... 124 | .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) 125 | "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /GeneratedFiles/Release/moc_widget.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Meta object code from reading C++ file 'widget.h' 3 | ** 4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.6.0) 5 | ** 6 | ** WARNING! All changes made in this file will be lost! 7 | *****************************************************************************/ 8 | 9 | #include "../../widget.h" 10 | #include 11 | #include 12 | #if !defined(Q_MOC_OUTPUT_REVISION) 13 | #error "The header file 'widget.h' doesn't include ." 14 | #elif Q_MOC_OUTPUT_REVISION != 67 15 | #error "This file was generated using the moc from 5.6.0. It" 16 | #error "cannot be used with the include files from this version of Qt." 17 | #error "(The moc has changed too much.)" 18 | #endif 19 | 20 | QT_BEGIN_MOC_NAMESPACE 21 | struct qt_meta_stringdata_Widget_t { 22 | QByteArrayData data[38]; 23 | char stringdata0[679]; 24 | }; 25 | #define QT_MOC_LITERAL(idx, ofs, len) \ 26 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ 27 | qptrdiff(offsetof(qt_meta_stringdata_Widget_t, stringdata0) + ofs \ 28 | - idx * sizeof(QByteArrayData)) \ 29 | ) 30 | static const qt_meta_stringdata_Widget_t qt_meta_stringdata_Widget = { 31 | { 32 | QT_MOC_LITERAL(0, 0, 6), // "Widget" 33 | QT_MOC_LITERAL(1, 7, 17), // "on_Marker_clicked" 34 | QT_MOC_LITERAL(2, 25, 0), // "" 35 | QT_MOC_LITERAL(3, 26, 21), // "on_SelectItem_clicked" 36 | QT_MOC_LITERAL(4, 48, 19), // "on_DrawLine_clicked" 37 | QT_MOC_LITERAL(5, 68, 17), // "on_Pencil_clicked" 38 | QT_MOC_LITERAL(6, 86, 15), // "on_Text_clicked" 39 | QT_MOC_LITERAL(7, 102, 16), // "on_Image_clicked" 40 | QT_MOC_LITERAL(8, 119, 16), // "on_Curve_clicked" 41 | QT_MOC_LITERAL(9, 136, 19), // "on_DrawRect_clicked" 42 | QT_MOC_LITERAL(10, 156, 18), // "on_Ellipse_clicked" 43 | QT_MOC_LITERAL(11, 175, 15), // "on_Time_clicked" 44 | QT_MOC_LITERAL(12, 191, 19), // "on_Distance_clicked" 45 | QT_MOC_LITERAL(13, 211, 22), // "on_InnerDegree_clicked" 46 | QT_MOC_LITERAL(14, 234, 23), // "on_OutterDegree_clicked" 47 | QT_MOC_LITERAL(15, 258, 20), // "on_CloneRect_clicked" 48 | QT_MOC_LITERAL(16, 279, 19), // "on_MakerPen_clicked" 49 | QT_MOC_LITERAL(17, 299, 16), // "on_Color_clicked" 50 | QT_MOC_LITERAL(18, 316, 15), // "on_font_clicked" 51 | QT_MOC_LITERAL(19, 332, 23), // "on_opacity_valueChanged" 52 | QT_MOC_LITERAL(20, 356, 5), // "value" 53 | QT_MOC_LITERAL(21, 362, 32), // "on_lineStyle_currentIndexChanged" 54 | QT_MOC_LITERAL(22, 395, 4), // "arg1" 55 | QT_MOC_LITERAL(23, 400, 32), // "on_LineWidth_currentIndexChanged" 56 | QT_MOC_LITERAL(24, 433, 5), // "index" 57 | QT_MOC_LITERAL(25, 439, 21), // "on_brushColor_clicked" 58 | QT_MOC_LITERAL(26, 461, 19), // "on_delete_2_clicked" 59 | QT_MOC_LITERAL(27, 481, 15), // "on_copy_clicked" 60 | QT_MOC_LITERAL(28, 497, 19), // "on_setOrder_clicked" 61 | QT_MOC_LITERAL(29, 517, 21), // "on_SetAsScale_clicked" 62 | QT_MOC_LITERAL(30, 539, 16), // "on_paste_clicked" 63 | QT_MOC_LITERAL(31, 556, 15), // "on_save_clicked" 64 | QT_MOC_LITERAL(32, 572, 15), // "on_load_clicked" 65 | QT_MOC_LITERAL(33, 588, 14), // "on_cut_clicked" 66 | QT_MOC_LITERAL(34, 603, 15), // "on_Zoom_clicked" 67 | QT_MOC_LITERAL(35, 619, 15), // "on_Move_clicked" 68 | QT_MOC_LITERAL(36, 635, 21), // "on_HFlip_stateChanged" 69 | QT_MOC_LITERAL(37, 657, 21) // "on_VFlip_stateChanged" 70 | 71 | }, 72 | "Widget\0on_Marker_clicked\0\0" 73 | "on_SelectItem_clicked\0on_DrawLine_clicked\0" 74 | "on_Pencil_clicked\0on_Text_clicked\0" 75 | "on_Image_clicked\0on_Curve_clicked\0" 76 | "on_DrawRect_clicked\0on_Ellipse_clicked\0" 77 | "on_Time_clicked\0on_Distance_clicked\0" 78 | "on_InnerDegree_clicked\0on_OutterDegree_clicked\0" 79 | "on_CloneRect_clicked\0on_MakerPen_clicked\0" 80 | "on_Color_clicked\0on_font_clicked\0" 81 | "on_opacity_valueChanged\0value\0" 82 | "on_lineStyle_currentIndexChanged\0arg1\0" 83 | "on_LineWidth_currentIndexChanged\0index\0" 84 | "on_brushColor_clicked\0on_delete_2_clicked\0" 85 | "on_copy_clicked\0on_setOrder_clicked\0" 86 | "on_SetAsScale_clicked\0on_paste_clicked\0" 87 | "on_save_clicked\0on_load_clicked\0" 88 | "on_cut_clicked\0on_Zoom_clicked\0" 89 | "on_Move_clicked\0on_HFlip_stateChanged\0" 90 | "on_VFlip_stateChanged" 91 | }; 92 | #undef QT_MOC_LITERAL 93 | 94 | static const uint qt_meta_data_Widget[] = { 95 | 96 | // content: 97 | 7, // revision 98 | 0, // classname 99 | 0, 0, // classinfo 100 | 33, 14, // methods 101 | 0, 0, // properties 102 | 0, 0, // enums/sets 103 | 0, 0, // constructors 104 | 0, // flags 105 | 0, // signalCount 106 | 107 | // slots: name, argc, parameters, tag, flags 108 | 1, 0, 179, 2, 0x08 /* Private */, 109 | 3, 0, 180, 2, 0x08 /* Private */, 110 | 4, 0, 181, 2, 0x08 /* Private */, 111 | 5, 0, 182, 2, 0x08 /* Private */, 112 | 6, 0, 183, 2, 0x08 /* Private */, 113 | 7, 0, 184, 2, 0x08 /* Private */, 114 | 8, 0, 185, 2, 0x08 /* Private */, 115 | 9, 0, 186, 2, 0x08 /* Private */, 116 | 10, 0, 187, 2, 0x08 /* Private */, 117 | 11, 0, 188, 2, 0x08 /* Private */, 118 | 12, 0, 189, 2, 0x08 /* Private */, 119 | 13, 0, 190, 2, 0x08 /* Private */, 120 | 14, 0, 191, 2, 0x08 /* Private */, 121 | 15, 0, 192, 2, 0x08 /* Private */, 122 | 16, 0, 193, 2, 0x08 /* Private */, 123 | 17, 0, 194, 2, 0x08 /* Private */, 124 | 18, 0, 195, 2, 0x08 /* Private */, 125 | 19, 1, 196, 2, 0x08 /* Private */, 126 | 21, 1, 199, 2, 0x08 /* Private */, 127 | 23, 1, 202, 2, 0x08 /* Private */, 128 | 25, 0, 205, 2, 0x08 /* Private */, 129 | 26, 0, 206, 2, 0x08 /* Private */, 130 | 27, 0, 207, 2, 0x08 /* Private */, 131 | 28, 0, 208, 2, 0x08 /* Private */, 132 | 29, 0, 209, 2, 0x08 /* Private */, 133 | 30, 0, 210, 2, 0x08 /* Private */, 134 | 31, 0, 211, 2, 0x08 /* Private */, 135 | 32, 0, 212, 2, 0x08 /* Private */, 136 | 33, 0, 213, 2, 0x08 /* Private */, 137 | 34, 0, 214, 2, 0x08 /* Private */, 138 | 35, 0, 215, 2, 0x08 /* Private */, 139 | 36, 1, 216, 2, 0x08 /* Private */, 140 | 37, 1, 219, 2, 0x08 /* Private */, 141 | 142 | // slots: parameters 143 | QMetaType::Void, 144 | QMetaType::Void, 145 | QMetaType::Void, 146 | QMetaType::Void, 147 | QMetaType::Void, 148 | QMetaType::Void, 149 | QMetaType::Void, 150 | QMetaType::Void, 151 | QMetaType::Void, 152 | QMetaType::Void, 153 | QMetaType::Void, 154 | QMetaType::Void, 155 | QMetaType::Void, 156 | QMetaType::Void, 157 | QMetaType::Void, 158 | QMetaType::Void, 159 | QMetaType::Void, 160 | QMetaType::Void, QMetaType::Int, 20, 161 | QMetaType::Void, QMetaType::QString, 22, 162 | QMetaType::Void, QMetaType::Int, 24, 163 | QMetaType::Void, 164 | QMetaType::Void, 165 | QMetaType::Void, 166 | QMetaType::Void, 167 | QMetaType::Void, 168 | QMetaType::Void, 169 | QMetaType::Void, 170 | QMetaType::Void, 171 | QMetaType::Void, 172 | QMetaType::Void, 173 | QMetaType::Void, 174 | QMetaType::Void, QMetaType::Int, 22, 175 | QMetaType::Void, QMetaType::Int, 22, 176 | 177 | 0 // eod 178 | }; 179 | 180 | void Widget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) 181 | { 182 | if (_c == QMetaObject::InvokeMetaMethod) { 183 | Widget *_t = static_cast(_o); 184 | Q_UNUSED(_t) 185 | switch (_id) { 186 | case 0: _t->on_Marker_clicked(); break; 187 | case 1: _t->on_SelectItem_clicked(); break; 188 | case 2: _t->on_DrawLine_clicked(); break; 189 | case 3: _t->on_Pencil_clicked(); break; 190 | case 4: _t->on_Text_clicked(); break; 191 | case 5: _t->on_Image_clicked(); break; 192 | case 6: _t->on_Curve_clicked(); break; 193 | case 7: _t->on_DrawRect_clicked(); break; 194 | case 8: _t->on_Ellipse_clicked(); break; 195 | case 9: _t->on_Time_clicked(); break; 196 | case 10: _t->on_Distance_clicked(); break; 197 | case 11: _t->on_InnerDegree_clicked(); break; 198 | case 12: _t->on_OutterDegree_clicked(); break; 199 | case 13: _t->on_CloneRect_clicked(); break; 200 | case 14: _t->on_MakerPen_clicked(); break; 201 | case 15: _t->on_Color_clicked(); break; 202 | case 16: _t->on_font_clicked(); break; 203 | case 17: _t->on_opacity_valueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; 204 | case 18: _t->on_lineStyle_currentIndexChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; 205 | case 19: _t->on_LineWidth_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break; 206 | case 20: _t->on_brushColor_clicked(); break; 207 | case 21: _t->on_delete_2_clicked(); break; 208 | case 22: _t->on_copy_clicked(); break; 209 | case 23: _t->on_setOrder_clicked(); break; 210 | case 24: _t->on_SetAsScale_clicked(); break; 211 | case 25: _t->on_paste_clicked(); break; 212 | case 26: _t->on_save_clicked(); break; 213 | case 27: _t->on_load_clicked(); break; 214 | case 28: _t->on_cut_clicked(); break; 215 | case 29: _t->on_Zoom_clicked(); break; 216 | case 30: _t->on_Move_clicked(); break; 217 | case 31: _t->on_HFlip_stateChanged((*reinterpret_cast< int(*)>(_a[1]))); break; 218 | case 32: _t->on_VFlip_stateChanged((*reinterpret_cast< int(*)>(_a[1]))); break; 219 | default: ; 220 | } 221 | } 222 | } 223 | 224 | const QMetaObject Widget::staticMetaObject = { 225 | { &QWidget::staticMetaObject, qt_meta_stringdata_Widget.data, 226 | qt_meta_data_Widget, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} 227 | }; 228 | 229 | 230 | const QMetaObject *Widget::metaObject() const 231 | { 232 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; 233 | } 234 | 235 | void *Widget::qt_metacast(const char *_clname) 236 | { 237 | if (!_clname) return Q_NULLPTR; 238 | if (!strcmp(_clname, qt_meta_stringdata_Widget.stringdata0)) 239 | return static_cast(const_cast< Widget*>(this)); 240 | return QWidget::qt_metacast(_clname); 241 | } 242 | 243 | int Widget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) 244 | { 245 | _id = QWidget::qt_metacall(_c, _id, _a); 246 | if (_id < 0) 247 | return _id; 248 | if (_c == QMetaObject::InvokeMetaMethod) { 249 | if (_id < 33) 250 | qt_static_metacall(this, _c, _id, _a); 251 | _id -= 33; 252 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { 253 | if (_id < 33) 254 | *reinterpret_cast(_a[0]) = -1; 255 | _id -= 33; 256 | } 257 | return _id; 258 | } 259 | QT_END_MOC_NAMESPACE 260 | -------------------------------------------------------------------------------- /GeneratedFiles/ui_widget.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | ** Form generated from reading UI file 'widget.ui' 3 | ** 4 | ** Created by: Qt User Interface Compiler version 5.6.0 5 | ** 6 | ** WARNING! All changes made in this file will be lost when recompiling UI file! 7 | ********************************************************************************/ 8 | 9 | #ifndef UI_WIDGET_H 10 | #define UI_WIDGET_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | QT_BEGIN_NAMESPACE 29 | 30 | class Ui_Widget 31 | { 32 | public: 33 | GraphicsView *graphicsView; 34 | QGroupBox *groupBox; 35 | QRadioButton *Marker; 36 | QRadioButton *Pencil; 37 | QRadioButton *Text; 38 | QRadioButton *Image; 39 | QRadioButton *MakerPen; 40 | QRadioButton *DrawLine; 41 | QRadioButton *Curve; 42 | QRadioButton *DrawRect; 43 | QRadioButton *Ellipse; 44 | QRadioButton *Time; 45 | QRadioButton *Distance; 46 | QRadioButton *InnerDegree; 47 | QRadioButton *OutterDegree; 48 | QRadioButton *SelectItem; 49 | QRadioButton *Zoom; 50 | QRadioButton *Move; 51 | QToolButton *toolButton; 52 | QLabel *label; 53 | QLabel *label_3; 54 | QPushButton *Color; 55 | QPushButton *font; 56 | QComboBox *LineWidth; 57 | QSlider *opacity; 58 | QLabel *label_2; 59 | QComboBox *lineStyle; 60 | QLabel *label_4; 61 | QLabel *label_5; 62 | QPushButton *brushColor; 63 | QCheckBox *Horizontal; 64 | QCheckBox *Vertical; 65 | QCheckBox *HFlip; 66 | QCheckBox *VFlip; 67 | 68 | void setupUi(QWidget *Widget) 69 | { 70 | if (Widget->objectName().isEmpty()) 71 | Widget->setObjectName(QStringLiteral("Widget")); 72 | Widget->resize(780, 469); 73 | graphicsView = new GraphicsView(Widget); 74 | graphicsView->setObjectName(QStringLiteral("graphicsView")); 75 | graphicsView->setGeometry(QRect(130, 20, 261, 361)); 76 | groupBox = new QGroupBox(Widget); 77 | groupBox->setObjectName(QStringLiteral("groupBox")); 78 | groupBox->setGeometry(QRect(10, 10, 101, 361)); 79 | Marker = new QRadioButton(groupBox); 80 | Marker->setObjectName(QStringLiteral("Marker")); 81 | Marker->setGeometry(QRect(10, 20, 89, 16)); 82 | Pencil = new QRadioButton(groupBox); 83 | Pencil->setObjectName(QStringLiteral("Pencil")); 84 | Pencil->setGeometry(QRect(10, 40, 89, 16)); 85 | Text = new QRadioButton(groupBox); 86 | Text->setObjectName(QStringLiteral("Text")); 87 | Text->setGeometry(QRect(10, 60, 89, 16)); 88 | Image = new QRadioButton(groupBox); 89 | Image->setObjectName(QStringLiteral("Image")); 90 | Image->setGeometry(QRect(10, 80, 89, 16)); 91 | MakerPen = new QRadioButton(groupBox); 92 | MakerPen->setObjectName(QStringLiteral("MakerPen")); 93 | MakerPen->setGeometry(QRect(10, 100, 89, 16)); 94 | DrawLine = new QRadioButton(groupBox); 95 | DrawLine->setObjectName(QStringLiteral("DrawLine")); 96 | DrawLine->setGeometry(QRect(10, 120, 89, 16)); 97 | Curve = new QRadioButton(groupBox); 98 | Curve->setObjectName(QStringLiteral("Curve")); 99 | Curve->setGeometry(QRect(10, 140, 89, 16)); 100 | DrawRect = new QRadioButton(groupBox); 101 | DrawRect->setObjectName(QStringLiteral("DrawRect")); 102 | DrawRect->setGeometry(QRect(10, 160, 89, 16)); 103 | Ellipse = new QRadioButton(groupBox); 104 | Ellipse->setObjectName(QStringLiteral("Ellipse")); 105 | Ellipse->setGeometry(QRect(10, 180, 89, 16)); 106 | Time = new QRadioButton(groupBox); 107 | Time->setObjectName(QStringLiteral("Time")); 108 | Time->setGeometry(QRect(10, 200, 89, 16)); 109 | Distance = new QRadioButton(groupBox); 110 | Distance->setObjectName(QStringLiteral("Distance")); 111 | Distance->setGeometry(QRect(10, 220, 89, 16)); 112 | InnerDegree = new QRadioButton(groupBox); 113 | InnerDegree->setObjectName(QStringLiteral("InnerDegree")); 114 | InnerDegree->setGeometry(QRect(10, 240, 89, 16)); 115 | OutterDegree = new QRadioButton(groupBox); 116 | OutterDegree->setObjectName(QStringLiteral("OutterDegree")); 117 | OutterDegree->setGeometry(QRect(10, 260, 89, 16)); 118 | SelectItem = new QRadioButton(groupBox); 119 | SelectItem->setObjectName(QStringLiteral("SelectItem")); 120 | SelectItem->setGeometry(QRect(10, 320, 89, 16)); 121 | SelectItem->setChecked(true); 122 | Zoom = new QRadioButton(groupBox); 123 | Zoom->setObjectName(QStringLiteral("Zoom")); 124 | Zoom->setGeometry(QRect(10, 280, 61, 16)); 125 | Move = new QRadioButton(groupBox); 126 | Move->setObjectName(QStringLiteral("Move")); 127 | Move->setGeometry(QRect(10, 300, 51, 16)); 128 | toolButton = new QToolButton(groupBox); 129 | toolButton->setObjectName(QStringLiteral("toolButton")); 130 | toolButton->setGeometry(QRect(250, 140, 37, 18)); 131 | label = new QLabel(Widget); 132 | label->setObjectName(QStringLiteral("label")); 133 | label->setGeometry(QRect(500, 420, 61, 16)); 134 | label_3 = new QLabel(Widget); 135 | label_3->setObjectName(QStringLiteral("label_3")); 136 | label_3->setGeometry(QRect(130, 20, 640, 360)); 137 | label_3->setFrameShape(QFrame::Panel); 138 | Color = new QPushButton(Widget); 139 | Color->setObjectName(QStringLiteral("Color")); 140 | Color->setGeometry(QRect(410, 440, 51, 23)); 141 | font = new QPushButton(Widget); 142 | font->setObjectName(QStringLiteral("font")); 143 | font->setGeometry(QRect(460, 440, 41, 23)); 144 | LineWidth = new QComboBox(Widget); 145 | LineWidth->setObjectName(QStringLiteral("LineWidth")); 146 | LineWidth->setGeometry(QRect(500, 440, 69, 22)); 147 | LineWidth->setMinimumSize(QSize(69, 22)); 148 | LineWidth->setMaximumSize(QSize(69, 22)); 149 | LineWidth->setMaxVisibleItems(30); 150 | opacity = new QSlider(Widget); 151 | opacity->setObjectName(QStringLiteral("opacity")); 152 | opacity->setGeometry(QRect(580, 440, 160, 19)); 153 | opacity->setMinimumSize(QSize(160, 19)); 154 | opacity->setMinimum(1); 155 | opacity->setMaximum(100); 156 | opacity->setPageStep(2); 157 | opacity->setValue(100); 158 | opacity->setOrientation(Qt::Horizontal); 159 | opacity->setTickPosition(QSlider::TicksBelow); 160 | label_2 = new QLabel(Widget); 161 | label_2->setObjectName(QStringLiteral("label_2")); 162 | label_2->setGeometry(QRect(580, 420, 61, 16)); 163 | lineStyle = new QComboBox(Widget); 164 | lineStyle->setObjectName(QStringLiteral("lineStyle")); 165 | lineStyle->setGeometry(QRect(298, 440, 61, 22)); 166 | label_4 = new QLabel(Widget); 167 | label_4->setObjectName(QStringLiteral("label_4")); 168 | label_4->setGeometry(QRect(300, 420, 61, 16)); 169 | label_5 = new QLabel(Widget); 170 | label_5->setObjectName(QStringLiteral("label_5")); 171 | label_5->setGeometry(QRect(630, 420, 54, 12)); 172 | brushColor = new QPushButton(Widget); 173 | brushColor->setObjectName(QStringLiteral("brushColor")); 174 | brushColor->setGeometry(QRect(360, 440, 51, 23)); 175 | Horizontal = new QCheckBox(Widget); 176 | Horizontal->setObjectName(QStringLiteral("Horizontal")); 177 | Horizontal->setGeometry(QRect(100, 390, 81, 16)); 178 | Vertical = new QCheckBox(Widget); 179 | Vertical->setObjectName(QStringLiteral("Vertical")); 180 | Vertical->setGeometry(QRect(100, 420, 71, 16)); 181 | HFlip = new QCheckBox(Widget); 182 | HFlip->setObjectName(QStringLiteral("HFlip")); 183 | HFlip->setGeometry(QRect(200, 390, 71, 16)); 184 | VFlip = new QCheckBox(Widget); 185 | VFlip->setObjectName(QStringLiteral("VFlip")); 186 | VFlip->setGeometry(QRect(200, 420, 71, 16)); 187 | 188 | retranslateUi(Widget); 189 | 190 | QMetaObject::connectSlotsByName(Widget); 191 | } // setupUi 192 | 193 | void retranslateUi(QWidget *Widget) 194 | { 195 | Widget->setWindowTitle(QApplication::translate("Widget", "Widget", 0)); 196 | groupBox->setTitle(QApplication::translate("Widget", "GroupBox", 0)); 197 | Marker->setText(QApplication::translate("Widget", "Marker", 0)); 198 | Pencil->setText(QApplication::translate("Widget", "Pencil", 0)); 199 | Text->setText(QApplication::translate("Widget", "Text", 0)); 200 | Image->setText(QApplication::translate("Widget", "Image", 0)); 201 | MakerPen->setText(QApplication::translate("Widget", "MarkerPen", 0)); 202 | DrawLine->setText(QApplication::translate("Widget", "DrawLine", 0)); 203 | Curve->setText(QApplication::translate("Widget", "Curve", 0)); 204 | DrawRect->setText(QApplication::translate("Widget", "DrawRect", 0)); 205 | Ellipse->setText(QApplication::translate("Widget", "Ellipse", 0)); 206 | Time->setText(QApplication::translate("Widget", "Time", 0)); 207 | Distance->setText(QApplication::translate("Widget", "Distance", 0)); 208 | InnerDegree->setText(QApplication::translate("Widget", "InnerDegree", 0)); 209 | OutterDegree->setText(QApplication::translate("Widget", "OutterDegree", 0)); 210 | SelectItem->setText(QApplication::translate("Widget", "\351\200\211\346\213\251", 0)); 211 | Zoom->setText(QApplication::translate("Widget", "Zoom", 0)); 212 | Move->setText(QApplication::translate("Widget", "Move", 0)); 213 | toolButton->setText(QApplication::translate("Widget", "...", 0)); 214 | label->setText(QApplication::translate("Widget", "\347\272\277\345\256\275\346\265\213\350\257\225\357\274\232", 0)); 215 | label_3->setText(QString()); 216 | Color->setText(QApplication::translate("Widget", "\351\242\234\350\211\262", 0)); 217 | font->setText(QApplication::translate("Widget", "\345\255\227\344\275\223", 0)); 218 | LineWidth->clear(); 219 | LineWidth->insertItems(0, QStringList() 220 | << QApplication::translate("Widget", "1", 0) 221 | << QApplication::translate("Widget", "2", 0) 222 | << QApplication::translate("Widget", "3", 0) 223 | << QApplication::translate("Widget", "4", 0) 224 | << QApplication::translate("Widget", "5", 0) 225 | << QApplication::translate("Widget", "6", 0) 226 | << QApplication::translate("Widget", "7", 0) 227 | << QApplication::translate("Widget", "8", 0) 228 | << QApplication::translate("Widget", "9", 0) 229 | << QApplication::translate("Widget", "10", 0) 230 | << QApplication::translate("Widget", "11", 0) 231 | << QApplication::translate("Widget", "12", 0) 232 | << QApplication::translate("Widget", "13", 0) 233 | << QApplication::translate("Widget", "14", 0) 234 | << QApplication::translate("Widget", "15", 0) 235 | << QApplication::translate("Widget", "16", 0) 236 | << QApplication::translate("Widget", "17", 0) 237 | << QApplication::translate("Widget", "18", 0) 238 | << QApplication::translate("Widget", "19", 0) 239 | << QApplication::translate("Widget", "20", 0) 240 | << QApplication::translate("Widget", "21", 0) 241 | << QApplication::translate("Widget", "22", 0) 242 | << QApplication::translate("Widget", "23", 0) 243 | << QApplication::translate("Widget", "24", 0) 244 | << QApplication::translate("Widget", "25", 0) 245 | << QApplication::translate("Widget", "\346\226\260\345\273\272\351\241\271\347\233\256", 0) 246 | ); 247 | label_2->setText(QApplication::translate("Widget", "\351\200\217\346\230\216\345\272\246:", 0)); 248 | lineStyle->clear(); 249 | lineStyle->insertItems(0, QStringList() 250 | << QApplication::translate("Widget", "\347\233\264\347\272\277", 0) 251 | << QApplication::translate("Widget", "\345\267\246\347\256\255\345\244\264", 0) 252 | << QApplication::translate("Widget", "\345\217\263\347\256\255\345\244\264", 0) 253 | << QApplication::translate("Widget", "\345\217\214\345\220\221\347\256\255\345\244\264", 0) 254 | ); 255 | label_4->setText(QApplication::translate("Widget", "\347\272\277\345\275\242\346\265\213\350\257\225", 0)); 256 | label_5->setText(QApplication::translate("Widget", "100", 0)); 257 | brushColor->setText(QApplication::translate("Widget", "\345\241\253\345\205\205", 0)); 258 | Horizontal->setText(QApplication::translate("Widget", "Horizontal", 0)); 259 | Vertical->setText(QApplication::translate("Widget", "Vertical", 0)); 260 | HFlip->setText(QApplication::translate("Widget", "HFlip", 0)); 261 | VFlip->setText(QApplication::translate("Widget", "VFlip", 0)); 262 | } // retranslateUi 263 | 264 | }; 265 | 266 | namespace Ui { 267 | class Widget: public Ui_Widget {}; 268 | } // namespace Ui 269 | 270 | QT_END_NAMESPACE 271 | 272 | #endif // UI_WIDGET_H 273 | -------------------------------------------------------------------------------- /widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 780 10 | 469 11 | 12 | 13 | 14 | Widget 15 | 16 | 17 | 18 | 19 | 130 20 | 20 21 | 261 22 | 361 23 | 24 | 25 | 26 | 27 | 28 | 29 | 10 30 | 10 31 | 101 32 | 361 33 | 34 | 35 | 36 | GroupBox 37 | 38 | 39 | 40 | 41 | 10 42 | 20 43 | 89 44 | 16 45 | 46 | 47 | 48 | Marker 49 | 50 | 51 | 52 | 53 | 54 | 10 55 | 40 56 | 89 57 | 16 58 | 59 | 60 | 61 | Pencil 62 | 63 | 64 | 65 | 66 | 67 | 10 68 | 60 69 | 89 70 | 16 71 | 72 | 73 | 74 | Text 75 | 76 | 77 | 78 | 79 | 80 | 10 81 | 80 82 | 89 83 | 16 84 | 85 | 86 | 87 | Image 88 | 89 | 90 | 91 | 92 | 93 | 10 94 | 100 95 | 89 96 | 16 97 | 98 | 99 | 100 | MarkerPen 101 | 102 | 103 | 104 | 105 | 106 | 10 107 | 120 108 | 89 109 | 16 110 | 111 | 112 | 113 | DrawLine 114 | 115 | 116 | 117 | 118 | 119 | 10 120 | 140 121 | 89 122 | 16 123 | 124 | 125 | 126 | Curve 127 | 128 | 129 | 130 | 131 | 132 | 10 133 | 160 134 | 89 135 | 16 136 | 137 | 138 | 139 | DrawRect 140 | 141 | 142 | 143 | 144 | 145 | 10 146 | 180 147 | 89 148 | 16 149 | 150 | 151 | 152 | Ellipse 153 | 154 | 155 | 156 | 157 | 158 | 10 159 | 200 160 | 89 161 | 16 162 | 163 | 164 | 165 | Time 166 | 167 | 168 | 169 | 170 | 171 | 10 172 | 220 173 | 89 174 | 16 175 | 176 | 177 | 178 | Distance 179 | 180 | 181 | 182 | 183 | 184 | 10 185 | 240 186 | 89 187 | 16 188 | 189 | 190 | 191 | InnerDegree 192 | 193 | 194 | 195 | 196 | 197 | 10 198 | 260 199 | 89 200 | 16 201 | 202 | 203 | 204 | OutterDegree 205 | 206 | 207 | 208 | 209 | 210 | 10 211 | 320 212 | 89 213 | 16 214 | 215 | 216 | 217 | 选择 218 | 219 | 220 | true 221 | 222 | 223 | 224 | 225 | 226 | 10 227 | 280 228 | 61 229 | 16 230 | 231 | 232 | 233 | Zoom 234 | 235 | 236 | 237 | 238 | 239 | 10 240 | 300 241 | 51 242 | 16 243 | 244 | 245 | 246 | Move 247 | 248 | 249 | 250 | 251 | 252 | 250 253 | 140 254 | 37 255 | 18 256 | 257 | 258 | 259 | ... 260 | 261 | 262 | 263 | 264 | 265 | 266 | 500 267 | 420 268 | 61 269 | 16 270 | 271 | 272 | 273 | 线宽测试: 274 | 275 | 276 | 277 | 278 | 279 | 130 280 | 20 281 | 640 282 | 360 283 | 284 | 285 | 286 | QFrame::Panel 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 410 296 | 440 297 | 51 298 | 23 299 | 300 | 301 | 302 | 颜色 303 | 304 | 305 | 306 | 307 | 308 | 460 309 | 440 310 | 41 311 | 23 312 | 313 | 314 | 315 | 字体 316 | 317 | 318 | 319 | 320 | 321 | 500 322 | 440 323 | 69 324 | 22 325 | 326 | 327 | 328 | 329 | 69 330 | 22 331 | 332 | 333 | 334 | 335 | 69 336 | 22 337 | 338 | 339 | 340 | 30 341 | 342 | 343 | 344 | 1 345 | 346 | 347 | 348 | 349 | 2 350 | 351 | 352 | 353 | 354 | 3 355 | 356 | 357 | 358 | 359 | 4 360 | 361 | 362 | 363 | 364 | 5 365 | 366 | 367 | 368 | 369 | 6 370 | 371 | 372 | 373 | 374 | 7 375 | 376 | 377 | 378 | 379 | 8 380 | 381 | 382 | 383 | 384 | 9 385 | 386 | 387 | 388 | 389 | 10 390 | 391 | 392 | 393 | 394 | 11 395 | 396 | 397 | 398 | 399 | 12 400 | 401 | 402 | 403 | 404 | 13 405 | 406 | 407 | 408 | 409 | 14 410 | 411 | 412 | 413 | 414 | 15 415 | 416 | 417 | 418 | 419 | 16 420 | 421 | 422 | 423 | 424 | 17 425 | 426 | 427 | 428 | 429 | 18 430 | 431 | 432 | 433 | 434 | 19 435 | 436 | 437 | 438 | 439 | 20 440 | 441 | 442 | 443 | 444 | 21 445 | 446 | 447 | 448 | 449 | 22 450 | 451 | 452 | 453 | 454 | 23 455 | 456 | 457 | 458 | 459 | 24 460 | 461 | 462 | 463 | 464 | 25 465 | 466 | 467 | 468 | 469 | 新建项目 470 | 471 | 472 | 473 | 474 | 475 | 476 | 580 477 | 440 478 | 160 479 | 19 480 | 481 | 482 | 483 | 484 | 160 485 | 19 486 | 487 | 488 | 489 | 1 490 | 491 | 492 | 100 493 | 494 | 495 | 2 496 | 497 | 498 | 100 499 | 500 | 501 | Qt::Horizontal 502 | 503 | 504 | QSlider::TicksBelow 505 | 506 | 507 | 508 | 509 | 510 | 580 511 | 420 512 | 61 513 | 16 514 | 515 | 516 | 517 | 透明度: 518 | 519 | 520 | 521 | 522 | 523 | 298 524 | 440 525 | 61 526 | 22 527 | 528 | 529 | 530 | 531 | 直线 532 | 533 | 534 | 535 | 536 | 左箭头 537 | 538 | 539 | 540 | 541 | 右箭头 542 | 543 | 544 | 545 | 546 | 双向箭头 547 | 548 | 549 | 550 | 551 | 552 | 553 | 300 554 | 420 555 | 61 556 | 16 557 | 558 | 559 | 560 | 线形测试 561 | 562 | 563 | 564 | 565 | 566 | 630 567 | 420 568 | 54 569 | 12 570 | 571 | 572 | 573 | 100 574 | 575 | 576 | 577 | 578 | 579 | 360 580 | 440 581 | 51 582 | 23 583 | 584 | 585 | 586 | 填充 587 | 588 | 589 | 590 | 591 | 592 | 100 593 | 390 594 | 81 595 | 16 596 | 597 | 598 | 599 | Horizontal 600 | 601 | 602 | 603 | 604 | 605 | 100 606 | 420 607 | 71 608 | 16 609 | 610 | 611 | 612 | Vertical 613 | 614 | 615 | 616 | 617 | 618 | 200 619 | 390 620 | 71 621 | 16 622 | 623 | 624 | 625 | HFlip 626 | 627 | 628 | 629 | 630 | 631 | 200 632 | 420 633 | 71 634 | 16 635 | 636 | 637 | 638 | VFlip 639 | 640 | 641 | 642 | 643 | 644 | 645 | GraphicsView 646 | QGraphicsView 647 |
graphicsview.h
648 |
649 |
650 | 651 | 652 |
653 | --------------------------------------------------------------------------------