├── res ├── icon.rc ├── DSV.ico ├── DSV.png ├── DSV2.ico ├── icons │ ├── DSV_logo.png │ ├── data_btn.png │ ├── trim_btn.png │ ├── xor_btn.png │ ├── angle_btn.png │ ├── bezier_btn.png │ ├── chamfer_btn.png │ ├── close_btn.png │ ├── connect_btn.png │ ├── curve_btn.png │ ├── detach_btn.png │ ├── extend_btn.png │ ├── fillet_btn.png │ ├── flipx_btn.png │ ├── flipy_btn.png │ ├── measure_btn.png │ ├── mirror_btn.png │ ├── offset_btn.png │ ├── rotate_btn.png │ ├── scale_btn.png │ ├── split_btn.png │ ├── union_btn.png │ ├── button_arrow.png │ ├── cmd_line_btn.png │ ├── combinate_btn.png │ ├── open_file_btn.png │ ├── save_file_btn.png │ ├── settings_btn.png │ ├── arc │ │ ├── 3p_arc_btn.png │ │ ├── sca_arc_btn.png │ │ ├── sea_arc_btn.png │ │ ├── ser_arc_btn.png │ │ ├── 3p_arc_btn.drawio │ │ ├── sea_arc_btn.drawio │ │ ├── ser_arc_btn.drawio │ │ └── sca_arc_btn.drawio │ ├── close_file_btn.png │ ├── difference_btn.png │ ├── intersection_btn.png │ ├── line_array_btn.png │ ├── ring_array_btn.png │ ├── circle │ │ ├── circle_btn.png │ │ ├── 2p_circle_btn.png │ │ ├── 3p_circle_btn.png │ │ ├── 2p_circle_btn.drawio │ │ ├── circle_btn.drawio │ │ └── 3p_circle_btn.drawio │ ├── ellipse │ │ ├── ellipse_btn.png │ │ ├── ellipse_arc_btn.png │ │ ├── ellipse_btn.drawio │ │ └── ellipse_arc_btn.drawio │ ├── polygon │ │ ├── polyline_btn.png │ │ ├── rectangle_btn.png │ │ ├── polygon_inscribed_btn.png │ │ ├── polygon_circumscribed_btn.png │ │ ├── polyline_btn.drawio │ │ ├── polygon_circumscribed_btn.drawio │ │ ├── polygon_inscribed_btn.drawio │ │ └── rectangle_btn.drawio │ ├── attention.svg │ ├── info.svg │ ├── button_arrow.drawio │ ├── help.svg │ ├── save_file_btn.drawio │ ├── close_file_btn.drawio │ ├── data_btn.drawio │ ├── cmd_line_btn.drawio │ ├── open_file_btn.drawio │ ├── settings_btn.drawio │ ├── connect_btn.drawio │ ├── measure_btn.drawio │ ├── bezier_btn.drawio │ ├── detach_btn.drawio │ ├── combinate_btn.drawio │ ├── union_btn.drawio │ ├── curve_btn.drawio │ ├── rotate_btn.drawio │ ├── intersection_btn.drawio │ ├── mirror_btn.drawio │ ├── flipx_btn.drawio │ ├── DSV_logo.drawio │ ├── difference_btn.drawio │ ├── split_btn.drawio │ ├── trim_btn.drawio │ ├── extend_btn.drawio │ ├── flipy_btn.drawio │ ├── fillet_btn.drawio │ ├── chamfer_btn.drawio │ ├── angle_btn.drawio │ ├── ring_array_btn.drawio │ ├── xor_btn.drawio │ ├── close_btn.drawio │ ├── line_array_btn.drawio │ ├── offset_btn.drawio │ └── scale_btn.drawio └── Icons.qrc ├── libs ├── CMakeLists.txt ├── clipper2 │ ├── clipper.version.h │ ├── LICENSE.txt │ ├── clipper.rectclip.h │ └── clipper.minkowski.h ├── EarCut │ └── LICENSE.txt ├── Parser │ ├── LICENSE │ └── Action.hpp └── libdxfrw │ ├── intern │ ├── dwgreader24.cpp │ ├── dwgreader27.cpp │ ├── dwgreader15.h │ ├── drw_dbg.h │ ├── dwgreader27.h │ ├── dwgreader24.h │ ├── dwgreader21.h │ ├── drw_textcodec.h │ ├── rscodec.h │ ├── dxfwriter.h │ ├── dwgutil.h │ ├── dxfreader.h │ ├── dwgreader18.h │ └── drw_dbg.cpp │ ├── libdwgr.h │ ├── drw_classes.h │ ├── drw_header.h │ └── drw_classes.cpp ├── DSV.desktop ├── src ├── ui │ ├── WinUITool.hpp │ ├── WinUITool.cpp │ ├── DataPanel.hpp │ ├── Setting.hpp │ ├── ActionGroup.hpp │ ├── LayersManager.hpp │ ├── MessageBox.hpp │ ├── MainWindow.hpp │ ├── MessageBox.cpp │ ├── CMDWidget.hpp │ ├── Setting.cpp │ ├── LayersManager.ui │ ├── MessageBox.ui │ └── DataPanel.cpp ├── io │ ├── TextEncoding.hpp │ ├── File.hpp │ ├── DSVParser.hpp │ ├── GlobalSetting.hpp │ ├── PLTParser.hpp │ ├── RS274DParser.hpp │ └── TextEncoding.cpp ├── main.cpp ├── CMakeLists.txt ├── draw │ └── GLSL.hpp └── base │ ├── Math.hpp │ └── Graph.hpp ├── .gitignore ├── .clang-format ├── LICENSE_bundled.txt ├── README.md └── CMakeLists.txt /res/icon.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON ICON DISCARDABLE "DSV2.ico" -------------------------------------------------------------------------------- /res/DSV.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/DSV.ico -------------------------------------------------------------------------------- /res/DSV.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/DSV.png -------------------------------------------------------------------------------- /res/DSV2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/DSV2.ico -------------------------------------------------------------------------------- /res/icons/DSV_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/DSV_logo.png -------------------------------------------------------------------------------- /res/icons/data_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/data_btn.png -------------------------------------------------------------------------------- /res/icons/trim_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/trim_btn.png -------------------------------------------------------------------------------- /res/icons/xor_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/xor_btn.png -------------------------------------------------------------------------------- /res/icons/angle_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/angle_btn.png -------------------------------------------------------------------------------- /res/icons/bezier_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/bezier_btn.png -------------------------------------------------------------------------------- /res/icons/chamfer_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/chamfer_btn.png -------------------------------------------------------------------------------- /res/icons/close_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/close_btn.png -------------------------------------------------------------------------------- /res/icons/connect_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/connect_btn.png -------------------------------------------------------------------------------- /res/icons/curve_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/curve_btn.png -------------------------------------------------------------------------------- /res/icons/detach_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/detach_btn.png -------------------------------------------------------------------------------- /res/icons/extend_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/extend_btn.png -------------------------------------------------------------------------------- /res/icons/fillet_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/fillet_btn.png -------------------------------------------------------------------------------- /res/icons/flipx_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/flipx_btn.png -------------------------------------------------------------------------------- /res/icons/flipy_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/flipy_btn.png -------------------------------------------------------------------------------- /res/icons/measure_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/measure_btn.png -------------------------------------------------------------------------------- /res/icons/mirror_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/mirror_btn.png -------------------------------------------------------------------------------- /res/icons/offset_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/offset_btn.png -------------------------------------------------------------------------------- /res/icons/rotate_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/rotate_btn.png -------------------------------------------------------------------------------- /res/icons/scale_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/scale_btn.png -------------------------------------------------------------------------------- /res/icons/split_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/split_btn.png -------------------------------------------------------------------------------- /res/icons/union_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/union_btn.png -------------------------------------------------------------------------------- /res/icons/button_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/button_arrow.png -------------------------------------------------------------------------------- /res/icons/cmd_line_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/cmd_line_btn.png -------------------------------------------------------------------------------- /res/icons/combinate_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/combinate_btn.png -------------------------------------------------------------------------------- /res/icons/open_file_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/open_file_btn.png -------------------------------------------------------------------------------- /res/icons/save_file_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/save_file_btn.png -------------------------------------------------------------------------------- /res/icons/settings_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/settings_btn.png -------------------------------------------------------------------------------- /res/icons/arc/3p_arc_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/arc/3p_arc_btn.png -------------------------------------------------------------------------------- /res/icons/arc/sca_arc_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/arc/sca_arc_btn.png -------------------------------------------------------------------------------- /res/icons/arc/sea_arc_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/arc/sea_arc_btn.png -------------------------------------------------------------------------------- /res/icons/arc/ser_arc_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/arc/ser_arc_btn.png -------------------------------------------------------------------------------- /res/icons/close_file_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/close_file_btn.png -------------------------------------------------------------------------------- /res/icons/difference_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/difference_btn.png -------------------------------------------------------------------------------- /res/icons/intersection_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/intersection_btn.png -------------------------------------------------------------------------------- /res/icons/line_array_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/line_array_btn.png -------------------------------------------------------------------------------- /res/icons/ring_array_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/ring_array_btn.png -------------------------------------------------------------------------------- /libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE sources *.cpp *.c) 2 | 3 | set(_LIBRARY_SOURCES ${sources} PARENT_SCOPE) -------------------------------------------------------------------------------- /res/icons/circle/circle_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/circle/circle_btn.png -------------------------------------------------------------------------------- /DSV.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=DSV 4 | Exec=DSV 5 | Icon=DSV 6 | Categories=Graphics; 7 | -------------------------------------------------------------------------------- /res/icons/circle/2p_circle_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/circle/2p_circle_btn.png -------------------------------------------------------------------------------- /res/icons/circle/3p_circle_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/circle/3p_circle_btn.png -------------------------------------------------------------------------------- /res/icons/ellipse/ellipse_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/ellipse/ellipse_btn.png -------------------------------------------------------------------------------- /res/icons/polygon/polyline_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/polygon/polyline_btn.png -------------------------------------------------------------------------------- /res/icons/polygon/rectangle_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/polygon/rectangle_btn.png -------------------------------------------------------------------------------- /res/icons/ellipse/ellipse_arc_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/ellipse/ellipse_arc_btn.png -------------------------------------------------------------------------------- /res/icons/polygon/polygon_inscribed_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/polygon/polygon_inscribed_btn.png -------------------------------------------------------------------------------- /res/icons/polygon/polygon_circumscribed_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen6556/DSV/HEAD/res/icons/polygon/polygon_circumscribed_btn.png -------------------------------------------------------------------------------- /src/ui/WinUITool.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace WinUITool 5 | { 6 | void set_caption_color(unsigned long long id, unsigned long color); 7 | } -------------------------------------------------------------------------------- /libs/clipper2/clipper.version.h: -------------------------------------------------------------------------------- 1 | #ifndef CLIPPER_VERSION_H 2 | #define CLIPPER_VERSION_H 3 | 4 | constexpr auto CLIPPER2_VERSION = "1.5.4"; 5 | 6 | #endif // CLIPPER_VERSION_H 7 | -------------------------------------------------------------------------------- /src/io/TextEncoding.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | namespace TextEncoding 7 | { 8 | 9 | bool is_utf8(const std::string &str); 10 | 11 | bool is_gbk(const std::string &str); 12 | 13 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /files 3 | /install 4 | /output 5 | /Testing 6 | 7 | # 排除三方库(cmake自动下载) 8 | /lib 9 | 10 | # 排除clangd缓存 11 | /.cache 12 | 13 | *.json 14 | *.yaml 15 | *.log 16 | *.tlog 17 | *.7z 18 | *.exe 19 | *.bkp 20 | 21 | 22 | /build.cmd -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ui/MainWindow.hpp" 4 | 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | QApplication a(argc, argv); 9 | a.setStyle("Fusion"); 10 | 11 | MainWindow w; 12 | 13 | w.show(); 14 | 15 | return a.exec(); 16 | } 17 | -------------------------------------------------------------------------------- /src/ui/WinUITool.cpp: -------------------------------------------------------------------------------- 1 | #include "ui/WinUITool.hpp" 2 | #ifdef _WIN64 3 | #define NOMINMAX 4 | #include 5 | #pragma comment(lib, "Dwmapi.lib") 6 | #endif 7 | 8 | 9 | void WinUITool::set_caption_color(unsigned long long id, unsigned long color) 10 | { 11 | #ifdef _WIN64 12 | DwmSetWindowAttribute((HWND)id, DWMWA_CAPTION_COLOR, &color, sizeof(unsigned long)); 13 | #endif 14 | } -------------------------------------------------------------------------------- /src/io/File.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "base/Graph.hpp" 4 | 5 | 6 | class File 7 | { 8 | private: 9 | File(){}; 10 | 11 | static void write_dsv(const std::string &path, const Graph *graph); 12 | 13 | static void write_plt(const std::string &path, const Graph *graph); 14 | 15 | public: 16 | enum FileType {DSV, PLT}; 17 | 18 | static void write(const QString &path, const Graph *graph, const FileType type); 19 | }; -------------------------------------------------------------------------------- /src/ui/DataPanel.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "base/Graph.hpp" 6 | 7 | 8 | QT_BEGIN_NAMESPACE 9 | namespace Ui { class DataPanel;} 10 | QT_END_NAMESPACE 11 | 12 | class DataPanel : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | private: 17 | Ui::DataPanel *ui = nullptr; 18 | 19 | public: 20 | DataPanel(QWidget *parent); 21 | ~DataPanel(); 22 | 23 | void load_draw_data(const Graph *graph); 24 | 25 | int exec() override; 26 | }; -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/ui _UI_SOURCES) 2 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/base _BASE_SOURCES) 3 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/draw _DRAW_SOURCES) 4 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/io _IO_SOURCES) 5 | 6 | set(_UI_SOURCES ${_UI_SOURCES} PARENT_SCOPE) 7 | set(_BASE_SOURCES ${_BASE_SOURCES} PARENT_SCOPE) 8 | set(_DRAW_SOURCES ${_DRAW_SOURCES} PARENT_SCOPE) 9 | set(_IO_SOURCES ${_IO_SOURCES} PARENT_SCOPE) -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: LLVM 4 | PointerAlignment: Right 5 | 6 | #禁止头文件重排序 7 | SortIncludes: Never 8 | 9 | #四格缩进 10 | IndentWidth: 4 11 | TabWidth: 4 12 | UseTab: Never 13 | 14 | # 大括号另起一行 15 | BreakBeforeBraces: Allman 16 | 17 | # 段落间两行空格 18 | MaxEmptyLinesToKeep: 2 19 | 20 | # 禁止将函数缩进成一行 21 | AllowShortFunctionsOnASingleLine: None 22 | 23 | # 构造列表一行,一行放不下时,以冒号开头另起一行 24 | BreakConstructorInitializers: BeforeColon 25 | 26 | # 禁用自动换行 27 | ColumnLimit: 0 -------------------------------------------------------------------------------- /src/ui/Setting.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class Setting;} 8 | QT_END_NAMESPACE 9 | 10 | class Setting : public QDialog 11 | { 12 | private: 13 | Ui::Setting *ui = nullptr; 14 | int _text_size = 24; 15 | double _down_sampling_value = 0.02; 16 | 17 | private: 18 | void init(); 19 | 20 | public slots: 21 | void accept(); 22 | 23 | public: 24 | Setting(QWidget *parent); 25 | ~Setting(); 26 | 27 | void show(); 28 | int exec(); 29 | 30 | bool update_text_vbo() const; 31 | 32 | bool update_curve_vbo() const; 33 | }; -------------------------------------------------------------------------------- /LICENSE_bundled.txt: -------------------------------------------------------------------------------- 1 | The DSV repository and source distributions bundle several libraries that are 2 | compatibly licensed. We list these here. 3 | 4 | Name: earcut.hpp 5 | Files: libs/EarCut/EarCut.hpp 6 | License: ISC 7 | For license text, see libs/EarCut/LICENSE.txt 8 | 9 | Name: ParserCombinator 10 | Files: libs/Parser/* 11 | License: MIT 12 | For license text, see libs/Parser/LICENSE 13 | 14 | Name: libdxfrw 15 | Files: libs/libdxfrw/* 16 | License: GPL-2.0 17 | For license text, see libs/libdxfrw/LICENSE.txt 18 | 19 | Name: clipper2 20 | Files: libs/clipper2/* 21 | License: BSL-1.0 22 | For license text, see libs/clipper2/LICENSE.txt -------------------------------------------------------------------------------- /src/draw/GLSL.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace GLSL 5 | { 6 | const char *base_vss = "#version 450 core\n" 7 | "layout (location = 0) in dvec3 pos;\n" 8 | "uniform int w;\n" 9 | "uniform int h;\n" 10 | "uniform dvec3 vec0;\n" 11 | "uniform dvec3 vec1;\n" 12 | "void main()\n" 13 | "{\n" 14 | " gl_Position = vec4((pos.x * vec0.x + pos.y * vec0.y + vec0.z) / w - 1.0," 15 | "1.0 - (pos.x * vec1.x + pos.y * vec1.y + vec1.z) / h, pos.z, 1.0);\n" 16 | "}\0"; 17 | 18 | const char *base_fss = "#version 450 core\n" 19 | "out vec4 FragColor;\n" 20 | "uniform vec4 color;\n" 21 | "void main()\n" 22 | "{\n" 23 | " FragColor = color;\n" 24 | "}\0"; 25 | 26 | }; -------------------------------------------------------------------------------- /libs/EarCut/LICENSE.txt: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2015, Mapbox 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose 6 | with or without fee is hereby granted, provided that the above copyright notice 7 | and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 11 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 13 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 14 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 15 | THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /res/icons/attention.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DSV 2 | DSV是一款基于Qt的自制画图程序,使用OpenGL绘图。支持圆形、多边形和多段线、曲线线条的绘制。DSV支持图层功能和自动分层功能。绘制的图形以DSV格式保存,同时也能读取部分PLT、DXF、CUT和NC格式的图形文件。DSV也支持通用快捷键,如复制、粘贴、撤销、删除。 3 | 4 | 5 | 下面列出详细功能介绍: 6 | 1. 基础绘图功能 7 | - 测量 8 | - Polyline 9 | - Polygon 10 | - Circle 11 | - Rectangle 12 | - Bezier Curve 13 | - Text 14 | - 两Polyline连接为一条Polyline 15 | - Polyline闭合为Polygon 16 | - 图形组合 17 | - 组合图形分割 18 | 2. 图形编辑 19 | - 修剪和延长 20 | - 旋转 21 | - 水平和垂直翻转 22 | - 镜像 23 | - 多边形并集、交集、差集运算 24 | - 缩放 25 | - 偏移 26 | 3. 阵列功能 27 | - 线性阵列 28 | - 圆周阵列 29 | 4. 支持的文件格式 30 | - 可以打开RS274D的CUT和NC文件 31 | - 可以打开和导出部分PLT文件 32 | - 可以打开和导出部分DXF文件 33 | - 可以打开和导出DSV文件 34 | - 追加打开文件 35 | - 文件统计数据 36 | 5. 设置参数 37 | - 显示坐标原点 38 | - 打开文件时自动分层 39 | - 记忆上次打开文件类型 40 | - 自动对齐 41 | - 捕捉距离 42 | - 可撤销次数 43 | - 文字大小 44 | - 是否显示文字 45 | - 光标捕捉只针对当前图层启用 46 | - 是否开启光标捕捉 47 | - 是否显示点 48 | 6. 图层功能 49 | - 调整图层顺序 50 | - 插入和删除图层 51 | - 隐藏图层 -------------------------------------------------------------------------------- /res/icons/info.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /res/icons/button_arrow.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/icons/help.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/ui/ActionGroup.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "./ui_MainWindow.h" 6 | 7 | 8 | class ActionGroup 9 | { 10 | public: 11 | enum class MenuType {PolygonMenu, ArcMenu, CircleMenu, EllipseMenu, CurveMenu, FilletMenu}; 12 | 13 | private: 14 | Ui::MainWindow *ui = nullptr; 15 | std::function _callback; 16 | QMenu *_polygon_menu = nullptr; 17 | QMenu *_arc_menu = nullptr; 18 | QMenu *_circle_menu = nullptr; 19 | QMenu *_ellipse_menu = nullptr; 20 | QMenu *_curve_menu = nullptr; 21 | QMenu *_fillet_menu = nullptr; 22 | 23 | public: 24 | ActionGroup(Ui::MainWindow *ui, std::function callback); 25 | 26 | private: 27 | void init(); 28 | 29 | void init_polygon_menu(); 30 | 31 | void init_arc_menu(); 32 | 33 | void init_circle_menu(); 34 | 35 | void init_ellipse_menu(); 36 | 37 | void init_curve_menu(); 38 | 39 | void init_fillet_menu(); 40 | }; -------------------------------------------------------------------------------- /res/icons/save_file_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/icons/close_file_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/icons/data_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/icons/cmd_line_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/icons/open_file_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /res/icons/settings_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /libs/Parser/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 猪饲料 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /res/icons/polygon/polyline_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/connect_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/measure_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/io/DSVParser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "base/Geometry.hpp" 6 | #include "base/Graph.hpp" 7 | 8 | 9 | namespace DSVParser 10 | { 11 | 12 | class Importer 13 | { 14 | private: 15 | Graph *_graph = nullptr; 16 | std::vector _points; 17 | std::vector _parameters; 18 | std::string _text; 19 | double _temp = 0; 20 | bool _is_combination = false; 21 | 22 | public: 23 | 24 | void x_coord(const double value); 25 | 26 | void y_coord(const double value); 27 | 28 | void parameter(const double value); 29 | 30 | void store_polygon(); 31 | 32 | void store_circle(); 33 | 34 | void store_ellipse(); 35 | 36 | void store_polyline(); 37 | 38 | void store_bezier(); 39 | 40 | void store_bspline(); 41 | 42 | void store_text(); 43 | 44 | void store_arc(); 45 | 46 | void begin_combination(); 47 | 48 | void end_combination(); 49 | 50 | void store_text(const std::string &text); 51 | 52 | void store_group(); 53 | 54 | 55 | void load_graph(Graph *g); 56 | 57 | void reset(); 58 | }; 59 | 60 | 61 | bool parse(std::string_view &stream, Graph *graph); 62 | 63 | bool parse(std::ifstream &stream, Graph *graph); 64 | } -------------------------------------------------------------------------------- /res/icons/ellipse/ellipse_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/bezier_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /res/icons/detach_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/combinate_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/union_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/curve_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /res/icons/ellipse/ellipse_arc_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/polygon/polygon_circumscribed_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/polygon/polygon_inscribed_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /res/icons/rotate_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /libs/clipper2/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /res/icons/circle/2p_circle_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ui/LayersManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "base/Editer.hpp" 10 | 11 | 12 | QT_BEGIN_NAMESPACE 13 | namespace Ui { class LayersManager;} 14 | QT_END_NAMESPACE 15 | 16 | class LayersManager : public QDialog 17 | { 18 | Q_OBJECT 19 | 20 | private: 21 | Ui::LayersManager *ui = nullptr; 22 | QMenu *_menu = nullptr; 23 | QAction *_show = nullptr; 24 | QAction *_up = nullptr; 25 | QAction *_down = nullptr; 26 | QAction *_add = nullptr; 27 | QAction *_insert = nullptr; 28 | QAction *_del = nullptr; 29 | 30 | Editer *_editer = nullptr; 31 | QStringList _layers; 32 | QStringListModel *_layers_model = nullptr; 33 | bool _append_to_last = true; 34 | 35 | private: 36 | void init(); 37 | 38 | protected: 39 | void closeEvent(QCloseEvent *event); 40 | 41 | private slots: 42 | void show_layer(); 43 | 44 | void layer_up(); 45 | 46 | void layer_down(); 47 | 48 | void add_layer(); 49 | 50 | void insert_layer(); 51 | 52 | void remove_layer(); 53 | 54 | void change_layer_name(const QModelIndex &row, const QModelIndex &col, const QList &roles); 55 | 56 | public: 57 | LayersManager(QWidget *parent); 58 | ~LayersManager(); 59 | 60 | void bind_editer(Editer *editer); 61 | 62 | void update_layers(); 63 | 64 | QStringListModel *model(); 65 | 66 | int exec() override; 67 | }; 68 | 69 | -------------------------------------------------------------------------------- /res/icons/circle/circle_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/io/GlobalSetting.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../ui/ui_MainWindow.h" 3 | 4 | 5 | class GlobalSetting 6 | { 7 | private: 8 | GlobalSetting() {} 9 | 10 | GlobalSetting(const GlobalSetting &) = delete; 11 | 12 | GlobalSetting &operator=(const GlobalSetting &) = delete; 13 | 14 | ~GlobalSetting() {}; 15 | 16 | public: 17 | Graph *graph = nullptr; 18 | Ui::MainWindow *ui = nullptr; 19 | 20 | bool translated_points = false; 21 | bool auto_aligning = false; 22 | bool auto_connect = false; 23 | bool auto_layering = false; 24 | bool auto_combinate = false; 25 | bool auto_save = false; 26 | 27 | bool catch_center = false; 28 | bool catch_foot = false; 29 | bool catch_tangency = false; 30 | bool catch_vertex = false; 31 | bool catch_intersection = false; 32 | 33 | bool ignore_M19 = true; 34 | bool multiple_select = false; 35 | bool remember_file_type = true; 36 | bool show_origin = true; 37 | bool show_cmdline = true; 38 | bool show_points = false; 39 | bool show_text = true; 40 | 41 | int backup_times = 50; 42 | int text_size = 16; 43 | int offset_join_type = 2; 44 | int offset_end_type = 0; 45 | 46 | double catch_distance = 2.0; 47 | double sampling_step = 0.01; 48 | double down_sampling = 0.02; 49 | 50 | QString file_path = "/"; 51 | QString file_type = "All Files: (*.*)"; 52 | 53 | public: 54 | static GlobalSetting &setting(); 55 | 56 | void load_setting(); 57 | 58 | void save_setting(); 59 | }; -------------------------------------------------------------------------------- /res/icons/intersection_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/ui/MessageBox.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | 6 | QT_BEGIN_NAMESPACE 7 | namespace Ui { class MessageBox;} 8 | QT_END_NAMESPACE 9 | 10 | class MessageBox : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | private: 15 | Ui::MessageBox *ui = nullptr; 16 | QDialogButtonBox::StandardButton _result = QDialogButtonBox::StandardButton::NoButton; 17 | 18 | public: 19 | MessageBox(const QDialogButtonBox::StandardButtons buttons, QWidget *parent = nullptr); 20 | 21 | MessageBox(const QString &title, const QString &text, const QDialogButtonBox::StandardButtons buttons, QWidget *parent = nullptr); 22 | 23 | QDialogButtonBox::StandardButton result() const; 24 | 25 | static QDialogButtonBox::StandardButton question(QWidget *parent, const QString &title, const QString &text, 26 | const QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::StandardButton::Yes | QDialogButtonBox::StandardButton::No); 27 | 28 | static QDialogButtonBox::StandardButton information(QWidget *parent, const QString &title, const QString &text, 29 | const QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::StandardButton::Ok | QDialogButtonBox::StandardButton::Cancel); 30 | 31 | static QDialogButtonBox::StandardButton attention(QWidget *parent, const QString &title, const QString &text, 32 | const QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::StandardButton::Ok | QDialogButtonBox::StandardButton::Cancel); 33 | 34 | private slots: 35 | void button_clicked(QAbstractButton *button); 36 | }; -------------------------------------------------------------------------------- /res/icons/arc/3p_arc_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /res/icons/mirror_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/icons/circle/3p_circle_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/icons/flipx_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/icons/DSV_logo.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /res/icons/difference_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/icons/split_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /res/icons/trim_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /res/icons/extend_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader24.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "drw_dbg.h" 19 | #include "dwgreader24.h" 20 | #include "drw_textcodec.h" 21 | #include "../libdwgr.h" 22 | 23 | 24 | bool dwgReader24::readFileHeader() { 25 | DRW_DBG("dwgReader24::readFileHeader\n"); 26 | bool ret = dwgReader18::readFileHeader(); 27 | DRW_DBG("dwgReader24::readFileHeader END\n"); 28 | return ret; 29 | } 30 | 31 | bool dwgReader24::readDwgHeader(DRW_Header& hdr){ 32 | DRW_DBG("dwgReader24::readDwgHeader\n"); 33 | bool ret = dwgReader18::readDwgHeader(hdr); 34 | DRW_DBG("dwgReader24::readDwgHeader END\n"); 35 | return ret; 36 | } 37 | 38 | bool dwgReader24::readDwgClasses(){ 39 | DRW_DBG("\ndwgReader24::readDwgClasses"); 40 | bool ret = dwgReader18::readDwgClasses(); 41 | DRW_DBG("\ndwgReader24::readDwgClasses END\n"); 42 | return ret; 43 | } 44 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader27.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "drw_dbg.h" 19 | #include "dwgreader27.h" 20 | #include "drw_textcodec.h" 21 | #include "../libdwgr.h" 22 | 23 | 24 | bool dwgReader27::readFileHeader() { 25 | DRW_DBG("dwgReader27::readFileHeader\n"); 26 | bool ret = dwgReader18::readFileHeader(); 27 | DRW_DBG("dwgReader27::readFileHeader END\n"); 28 | return ret; 29 | } 30 | 31 | bool dwgReader27::readDwgHeader(DRW_Header& hdr){ 32 | DRW_DBG("dwgReader27::readDwgHeader\n"); 33 | bool ret = dwgReader18::readDwgHeader(hdr); 34 | DRW_DBG("dwgReader27::readDwgHeader END\n"); 35 | return ret; 36 | } 37 | 38 | bool dwgReader27::readDwgClasses(){ 39 | DRW_DBG("dwgReader27::readDwgClasses"); 40 | bool ret = dwgReader18::readDwgClasses(); 41 | DRW_DBG("\ndwgReader27::readDwgClasses END\n"); 42 | return ret; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /res/icons/flipy_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/icons/arc/sea_arc_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /libs/libdxfrw/libdwgr.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef LIBDWGR_H 14 | #define LIBDWGR_H 15 | 16 | #include 17 | //#include 18 | #include "drw_entities.h" 19 | #include "drw_objects.h" 20 | #include "drw_classes.h" 21 | #include "drw_interface.h" 22 | 23 | class dwgReader; 24 | 25 | class dwgR { 26 | public: 27 | dwgR(const char* name); 28 | ~dwgR(); 29 | //read: return true if all ok 30 | bool read(DRW_Interface *interface_, bool ext); 31 | bool getPreview(); 32 | DRW::Version getVersion(){return version;} 33 | DRW::error getError(){return error;} 34 | bool testReader(); 35 | void setDebug(DRW::DBG_LEVEL lvl); 36 | 37 | private: 38 | bool openFile(std::ifstream *filestr); 39 | bool processDwg(); 40 | private: 41 | DRW::Version version; 42 | DRW::error error; 43 | std::string fileName; 44 | bool applyExt; /*apply extrusion in entities to conv in 2D?*/ 45 | std::string codePage; 46 | DRW_Interface *iface; 47 | dwgReader *reader; 48 | 49 | }; 50 | 51 | #endif // LIBDWGR_H 52 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader15.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DWGREADER15_H 14 | #define DWGREADER15_H 15 | 16 | #include 17 | #include 18 | #include "drw_textcodec.h" 19 | #include "dwgbuffer.h" 20 | #include "dwgreader.h" 21 | 22 | class dwgReader15 : public dwgReader { 23 | public: 24 | dwgReader15(std::ifstream *stream, dwgR *p):dwgReader(stream, p){ } 25 | virtual ~dwgReader15() {} 26 | bool readMetaData(); 27 | bool readFileHeader(); 28 | bool readDwgHeader(DRW_Header& hdr); 29 | bool readDwgClasses(); 30 | bool readDwgHandles(); 31 | bool readDwgTables(DRW_Header& hdr); 32 | bool readDwgBlocks(DRW_Interface& intfa); 33 | bool readDwgEntities(DRW_Interface& intfa){ 34 | bool ret = true; 35 | ret = dwgReader::readDwgEntities(intfa, fileBuf); 36 | return ret; 37 | } 38 | bool readDwgObjects(DRW_Interface& intfa){ 39 | bool ret = true; 40 | ret = dwgReader::readDwgObjects(intfa, fileBuf); 41 | return ret; 42 | } 43 | // bool readDwgEntity(objHandle& obj, DRW_Interface& intfa); 44 | }; 45 | 46 | 47 | #endif // DWGREADER15_H 48 | -------------------------------------------------------------------------------- /res/Icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | icons/arc/3p_arc_btn.png 5 | icons/button_arrow.png 6 | icons/split_btn.png 7 | icons/angle_btn.png 8 | icons/extend_btn.png 9 | icons/trim_btn.png 10 | icons/xor_btn.png 11 | icons/bezier_btn.png 12 | icons/fillet_btn.png 13 | icons/DSV_logo.png 14 | icons/ring_array_btn.png 15 | icons/line_array_btn.png 16 | icons/offset_btn.png 17 | icons/scale_btn.png 18 | icons/flipx_btn.png 19 | icons/mirror_btn.png 20 | icons/flipy_btn.png 21 | icons/rotate_btn.png 22 | icons/difference_btn.png 23 | icons/intersection_btn.png 24 | icons/union_btn.png 25 | icons/combinate_btn.png 26 | icons/connect_btn.png 27 | icons/close_btn.png 28 | DSV2.ico 29 | icons/curve_btn.png 30 | icons/measure_btn.png 31 | icons/attention.svg 32 | icons/help.svg 33 | icons/info.svg 34 | icons/detach_btn.png 35 | icons/circle/circle_btn.png 36 | icons/circle/3p_circle_btn.png 37 | icons/circle/2p_circle_btn.png 38 | icons/chamfer_btn.png 39 | icons/polygon/rectangle_btn.png 40 | icons/polygon/polygon_circumscribed_btn.png 41 | icons/polygon/polygon_inscribed_btn.png 42 | icons/polygon/polyline_btn.png 43 | icons/arc/sca_arc_btn.png 44 | icons/arc/sea_arc_btn.png 45 | icons/arc/ser_arc_btn.png 46 | icons/ellipse/ellipse_btn.png 47 | icons/ellipse/ellipse_arc_btn.png 48 | 49 | 50 | -------------------------------------------------------------------------------- /res/icons/fillet_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /res/icons/chamfer_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /res/icons/arc/ser_arc_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /res/icons/angle_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /res/icons/arc/sca_arc_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/io/PLTParser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "base/Geometry.hpp" 6 | #include "base/Graph.hpp" 7 | 8 | 9 | namespace PLTParser 10 | { 11 | 12 | class Importer 13 | { 14 | private: 15 | Graph *_graph = nullptr; 16 | std::vector _points; 17 | std::vector _polygon_cache; 18 | std::vector _parameters; 19 | Geo::Point _last_coord, _last_cmd_coord; 20 | 21 | bool _pen_down = false; 22 | bool _relative_coord = false; 23 | bool _polygon_mode = false; 24 | int _rotate_coord = 0; 25 | double _x_ratio = 0.025, _y_ratio = 0.025; 26 | double _ip[6], _sc[4]; 27 | 28 | struct Txt 29 | { 30 | std::string txt; 31 | Geo::Point pos; 32 | bool marked = false; 33 | 34 | Txt(const std::string &text, const Geo::Point &position) 35 | : txt(text), pos(position) {}; 36 | }; 37 | std::list _texts; 38 | 39 | public: 40 | static const double plotter_unit; 41 | 42 | private: 43 | void store_points(); 44 | 45 | void store_arc(); 46 | 47 | public: 48 | 49 | void x_coord(const double value); 50 | 51 | void y_coord(const double value); 52 | 53 | void parameter(const double value); 54 | 55 | void ip(); 56 | 57 | void sc(); 58 | 59 | void ro(); 60 | 61 | void pu(); 62 | 63 | void pd(); 64 | 65 | void sp(const int value); 66 | 67 | void br(); 68 | 69 | void bz(); 70 | 71 | void ci(); 72 | 73 | void pa(); 74 | 75 | void pr(); 76 | 77 | void aa(); 78 | 79 | void ar(); 80 | 81 | void at(); 82 | 83 | void ea(); 84 | 85 | void er(); 86 | 87 | void pm(const int value); 88 | 89 | void pm(); 90 | 91 | void ep(); 92 | 93 | void store_text(const std::string &text); 94 | 95 | void print_symbol(const std::string& str); 96 | 97 | void end(); 98 | 99 | 100 | void load_graph(Graph *g); 101 | 102 | void reset(); 103 | }; 104 | 105 | 106 | bool parse(std::string_view &stream, Graph *graph); 107 | 108 | bool parse(std::ifstream &stream, Graph *graph); 109 | } -------------------------------------------------------------------------------- /res/icons/ring_array_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /libs/libdxfrw/drw_classes.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DRW_CLASSES_H 14 | #define DRW_CLASSES_H 15 | 16 | 17 | #include "drw_base.h" 18 | //#include "libdwgr.h" 19 | 20 | class dxfReader; 21 | class dxfWriter; 22 | class dwgBuffer; 23 | 24 | //! Class to handle classes entries 25 | /*! 26 | * Class to handle classes table entries 27 | * TODO: verify the dxf read/write part 28 | * @author Rallaz 29 | */ 30 | class DRW_Class { 31 | public: 32 | DRW_Class() { 33 | } 34 | ~DRW_Class() { 35 | } 36 | 37 | void parseCode(int code, dxfReader *reader); 38 | void write(dxfWriter *writer, DRW::Version ver); 39 | bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf); 40 | 41 | private: 42 | void toDwgType(); 43 | public: 44 | UTF8STRING recName; /*!< record name, code 1 */ 45 | UTF8STRING className; /*!< C++ class name, code 2 */ 46 | UTF8STRING appName; /*!< app name, code 3 */ 47 | int proxyFlag; /*!< Proxy capabilities flag, code 90 */ 48 | int instanceCount; /*!< number of instances for a custom class, code 91*/ 49 | int wasaProxyFlag; /*!< proxy flag (app loaded on save), code 280 */ 50 | int entityFlag; /*!< entity flag, code 281 (0 object, 1 entity)*/ 51 | public: //only for read dwg 52 | duint16 classNum; 53 | int dwgType; 54 | }; 55 | 56 | #endif 57 | 58 | // EOF 59 | 60 | -------------------------------------------------------------------------------- /res/icons/xor_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/drw_dbg.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DRW_DBG_H 14 | #define DRW_DBG_H 15 | 16 | #include 17 | #include 18 | //#include 19 | 20 | #define DRW_DBGSL(a) DRW_dbg::getInstance()->setLevel(a) 21 | #define DRW_DBGGL DRW_dbg::getInstance()->getLevel() 22 | #define DRW_DBG(a) DRW_dbg::getInstance()->print(a) 23 | #define DRW_DBGH(a) DRW_dbg::getInstance()->printH(a) 24 | #define DRW_DBGB(a) DRW_dbg::getInstance()->printB(a) 25 | #define DRW_DBGHL(a, b, c) DRW_dbg::getInstance()->printHL(a, b ,c) 26 | #define DRW_DBGPT(a, b, c) DRW_dbg::getInstance()->printPT(a, b, c) 27 | 28 | 29 | class print_none; 30 | 31 | class DRW_dbg { 32 | public: 33 | enum LEVEL { 34 | NONE, 35 | DEBUG 36 | }; 37 | void setLevel(LEVEL lvl); 38 | LEVEL getLevel(); 39 | static DRW_dbg *getInstance(); 40 | void print(std::string s); 41 | void print(int i); 42 | void print(unsigned int i); 43 | void print(long long int i); 44 | void print(long unsigned int i); 45 | void print(long long unsigned int i); 46 | void print(double d); 47 | void printH(long long int i); 48 | void printB(int i); 49 | void printHL(int c, int s, int h); 50 | void printPT(double x, double y, double z); 51 | 52 | private: 53 | DRW_dbg(); 54 | static DRW_dbg *instance; 55 | LEVEL level; 56 | std::ios_base::fmtflags flags; 57 | print_none* prClass; 58 | }; 59 | 60 | 61 | #endif // DRW_DBG_H 62 | -------------------------------------------------------------------------------- /res/icons/polygon/rectangle_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /res/icons/close_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader27.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DWGREADER27_H 14 | #define DWGREADER27_H 15 | 16 | #include 17 | #include 18 | #include "drw_textcodec.h" 19 | #include "dwgbuffer.h" 20 | #include "dwgreader18.h" 21 | 22 | class dwgReader27 : public dwgReader18 { 23 | public: 24 | dwgReader27(std::ifstream *stream, dwgR *p):dwgReader18(stream, p){ } 25 | virtual ~dwgReader27(){} 26 | bool readFileHeader(); 27 | bool readDwgHeader(DRW_Header& hdr); 28 | bool readDwgClasses(); 29 | // bool readDwgHandles(){return false;} 30 | // bool readDwgTables(){return false;} 31 | bool readDwgBlocks(DRW_Interface& intfa){ 32 | bool ret = true; 33 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 34 | ret = dwgReader::readDwgBlocks(intfa, &dataBuf); 35 | return ret; 36 | } 37 | virtual bool readDwgEntities(DRW_Interface& intfa){ 38 | bool ret = true; 39 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 40 | ret = dwgReader::readDwgEntities(intfa, &dataBuf); 41 | return ret; 42 | } 43 | virtual bool readDwgObjects(DRW_Interface& intfa){ 44 | bool ret = true; 45 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 46 | ret = dwgReader::readDwgObjects(intfa, &dataBuf); 47 | return ret; 48 | } 49 | // bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){ 50 | // DRW_UNUSED(obj); 51 | // DRW_UNUSED(intfa); 52 | // return false;} 53 | }; 54 | 55 | #endif // DWGREADER21_H 56 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader24.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DWGREADER24_H 14 | #define DWGREADER24_H 15 | 16 | #include 17 | #include 18 | #include "drw_textcodec.h" 19 | #include "dwgbuffer.h" 20 | #include "dwgreader18.h" 21 | 22 | class dwgReader24 : public dwgReader18 { 23 | public: 24 | dwgReader24(std::ifstream *stream, dwgR *p):dwgReader18(stream, p){ } 25 | virtual ~dwgReader24(){} 26 | bool readFileHeader(); 27 | bool readDwgHeader(DRW_Header& hdr); 28 | bool readDwgClasses(); 29 | // bool readDwgHandles(){return false;} 30 | // bool readDwgTables(){return false;} 31 | bool readDwgBlocks(DRW_Interface& intfa){ 32 | bool ret = true; 33 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 34 | ret = dwgReader::readDwgBlocks(intfa, &dataBuf); 35 | return ret; 36 | } 37 | virtual bool readDwgEntities(DRW_Interface& intfa){ 38 | bool ret = true; 39 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 40 | ret = dwgReader::readDwgEntities(intfa, &dataBuf); 41 | return ret; 42 | } 43 | virtual bool readDwgObjects(DRW_Interface& intfa){ 44 | bool ret = true; 45 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 46 | ret = dwgReader::readDwgObjects(intfa, &dataBuf); 47 | return ret; 48 | } 49 | 50 | // bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){ 51 | // DRW_UNUSED(obj); 52 | // DRW_UNUSED(intfa); 53 | // return false;} 54 | }; 55 | 56 | #endif // DWGREADER24_H 57 | -------------------------------------------------------------------------------- /src/ui/MainWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "base/Editer.hpp" 10 | #include "ui/LayersManager.hpp" 11 | #include "ui/Setting.hpp" 12 | #include "ui/DataPanel.hpp" 13 | #include "ui/ActionGroup.hpp" 14 | 15 | 16 | QT_BEGIN_NAMESPACE 17 | namespace Ui { class MainWindow;} 18 | QT_END_NAMESPACE 19 | 20 | class MainWindow : public QMainWindow 21 | { 22 | Q_OBJECT 23 | 24 | private: 25 | Ui::MainWindow *ui = nullptr; 26 | Editer _editer; 27 | Setting *_setting = nullptr; 28 | std::vector _keys; 29 | QTimer _clock; 30 | QLabel *_info_labels[3] = {nullptr, nullptr, nullptr}; 31 | DataPanel *_panel = nullptr; 32 | 33 | QComboBox *_layers_cbx = nullptr; 34 | LayersManager *_layers_manager = nullptr; 35 | QToolButton *_layers_btn = nullptr; 36 | ActionGroup *_actiongroup = nullptr; 37 | QString _file_type = "All Files: (*.*)"; 38 | 39 | private: 40 | void init(); 41 | 42 | void connect_btn_to_cmd(); 43 | 44 | protected: 45 | void mousePressEvent(QMouseEvent *event); 46 | 47 | void keyPressEvent(QKeyEvent *event); 48 | 49 | void closeEvent(QCloseEvent *event); 50 | 51 | void dragEnterEvent(QDragEnterEvent *event); 52 | 53 | void dropEvent(QDropEvent *event); 54 | 55 | void resizeEvent(QResizeEvent *event); 56 | 57 | private slots: 58 | void open_file(); 59 | 60 | void close_file(); 61 | 62 | void save_file(); 63 | 64 | void auto_save(); 65 | 66 | void saveas_file(); 67 | 68 | void append_file(); 69 | 70 | void set_catch(QAction *action); 71 | 72 | void refresh_cmd(const CMDWidget::CMD cmd); 73 | 74 | void refresh_settings(); 75 | 76 | void load_settings(); 77 | 78 | void save_settings(); 79 | 80 | void show_layers_manager(); 81 | 82 | void hide_layers_manager(); 83 | 84 | void to_main_page(); 85 | 86 | void to_array_page(); 87 | 88 | void show_data_panel(); 89 | 90 | private: 91 | void open_file(const QString &path); 92 | 93 | void append_file(const QString &path); 94 | 95 | void actiongroup_callback(const ActionGroup::MenuType menu, const int index); 96 | 97 | public: 98 | MainWindow(QWidget *parent = nullptr); 99 | ~MainWindow(); 100 | }; -------------------------------------------------------------------------------- /src/ui/MessageBox.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ui/MessageBox.hpp" 3 | #include "./ui_MessageBox.h" 4 | #include "ui/WinUITool.hpp" 5 | 6 | 7 | MessageBox::MessageBox(const QDialogButtonBox::StandardButtons buttons, QWidget *parent) 8 | : QDialog(parent), ui(new Ui::MessageBox) 9 | { 10 | ui->setupUi(this); 11 | ui->buttonBox->setStandardButtons(buttons); 12 | #ifdef _WIN64 13 | WinUITool::set_caption_color(winId(), 0x3C3C3D); 14 | #endif 15 | } 16 | 17 | MessageBox::MessageBox(const QString &title, const QString &text, const QDialogButtonBox::StandardButtons buttons, QWidget *parent) 18 | : MessageBox(buttons, parent) 19 | { 20 | setWindowTitle(title); 21 | ui->lb_text->setText(text); 22 | } 23 | 24 | QDialogButtonBox::StandardButton MessageBox::result() const 25 | { 26 | return _result; 27 | } 28 | 29 | QDialogButtonBox::StandardButton MessageBox::question(QWidget *parent, const QString &title, const QString &text, const QDialogButtonBox::StandardButtons buttons) 30 | { 31 | MessageBox dialog(title, text, buttons, parent); 32 | QPixmap pixmap(":/icons/help.svg"); 33 | pixmap.scaled(dialog.ui->lb_icon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); 34 | dialog.ui->lb_icon->setPixmap(pixmap); 35 | dialog.exec(); 36 | return dialog.result(); 37 | } 38 | 39 | QDialogButtonBox::StandardButton MessageBox::information(QWidget *parent, const QString &title, const QString &text, const QDialogButtonBox::StandardButtons buttons) 40 | { 41 | MessageBox dialog(title, text, buttons, parent); 42 | QPixmap pixmap(":/icons/info.svg"); 43 | pixmap.scaled(dialog.ui->lb_icon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); 44 | dialog.ui->lb_icon->setPixmap(pixmap); 45 | dialog.exec(); 46 | return dialog.result(); 47 | } 48 | 49 | QDialogButtonBox::StandardButton MessageBox::attention(QWidget *parent, const QString &title, const QString &text, const QDialogButtonBox::StandardButtons buttons) 50 | { 51 | MessageBox dialog(title, text, buttons, parent); 52 | QPixmap pixmap(":/icons/attention.svg"); 53 | pixmap.scaled(dialog.ui->lb_icon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); 54 | dialog.ui->lb_icon->setPixmap(pixmap); 55 | dialog.exec(); 56 | return dialog.result(); 57 | } 58 | 59 | void MessageBox::button_clicked(QAbstractButton *button) 60 | { 61 | _result = ui->buttonBox->standardButton(button); 62 | return done(_result); 63 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20.0) 2 | project(DSV VERSION 0.5.1) 3 | 4 | include(CTest) 5 | enable_testing() 6 | 7 | if (MSVC) 8 | add_compile_options("/utf-8") 9 | add_compile_options("/arch:AVX2") 10 | add_compile_options("/GL") 11 | add_compile_options("/MP") 12 | add_link_options("/LTCG") 13 | add_link_options("/NODEFAULTLIB:LIBCMT.lib") 14 | elseif (CMAKE_COMPILER_IS_GNUCXX) 15 | add_compile_options("-m64") 16 | add_compile_options("-mavx2") 17 | add_compile_options("-funroll-loops") 18 | add_compile_options("-ffunction-sections") 19 | add_compile_options("-fdata-sections") 20 | endif() 21 | 22 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 23 | set(CMAKE_AUTOUIC ON) 24 | set(CMAKE_AUTOMOC ON) 25 | set(CMAKE_AUTORCC ON) 26 | 27 | set(CMAKE_CXX_STANDARD 17) 28 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 29 | 30 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output/) 31 | 32 | find_package(Qt6 REQUIRED COMPONENTS Widgets OpenGLWidgets OpenGL Gui Core) 33 | find_package(GSL REQUIRED) 34 | 35 | include_directories(libs) 36 | add_subdirectory(libs) 37 | 38 | add_subdirectory(src) 39 | include_directories(src) 40 | file(GLOB _UI_HEADS src/ui/*hpp) 41 | 42 | qt_add_executable(DSV 43 | MANUAL_FINALIZATION 44 | src/main.cpp 45 | ${_UI_HEADS} 46 | src/draw/Canvas.hpp 47 | 48 | ${_DRAW_SOURCES} 49 | ${_BASE_SOURCES} 50 | ${_UI_SOURCES} 51 | ${_IO_SOURCES} 52 | ${_LIBRARY_SOURCES} 53 | res/icon.rc 54 | res/Icons.qrc 55 | ) 56 | 57 | target_link_libraries(DSV PRIVATE Qt6::Widgets Qt6::OpenGLWidgets Qt6::OpenGL Qt6::Gui Qt6::Core GSL::gsl) 58 | target_compile_definitions(DSV PUBLIC POINTERHOLDER_TRANSITION=0) 59 | 60 | set_target_properties(DSV PROPERTIES 61 | MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com 62 | MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} 63 | MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} 64 | MACOSX_BUNDLE TRUE 65 | WIN32_EXECUTABLE TRUE 66 | ) 67 | 68 | qt_finalize_executable(DSV) 69 | 70 | set(CPACK_PROJECT_NAME ${PROJECT_NAME}) 71 | set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) 72 | include(CPack) 73 | 74 | install( 75 | TARGETS DSV 76 | # RUNTIME_DEPENDENCIES DIRECTORIES /usr/lib 77 | DESTINATION bin 78 | ) 79 | 80 | install( 81 | FILES DSV.desktop 82 | DESTINATION share/applications/ 83 | ) 84 | 85 | install( 86 | FILES res/resource/DSV.ico 87 | DESTINATION share/icons/hicolor/128x128/apps 88 | ) 89 | -------------------------------------------------------------------------------- /src/io/RS274DParser.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "base/Geometry.hpp" 7 | #include "base/Container.hpp" 8 | #include "base/Graph.hpp" 9 | 10 | 11 | namespace RS274DParser 12 | { 13 | 14 | static constexpr double UNIT_SACLES[2] = {1, 2.54}; 15 | 16 | enum class Unit 17 | { 18 | mm = 0, 19 | hectomil = 1, 20 | // mil实际上是100mil 等同于hectomil 21 | mil = 1 22 | }; 23 | 24 | enum class CurveType 25 | { 26 | Linear = 0, 27 | }; 28 | 29 | enum class Command 30 | { 31 | None, // Nothing 32 | Q, // Invalid 33 | 34 | // G Command 35 | G70, // Unit inch 36 | G71, // Unit mm 37 | 38 | // D Command 39 | D1, // Pen down 40 | D2, // Pen up 41 | 42 | // M Command 43 | M01, // 44 | M14, // Knife down 45 | M15, // Knife up 46 | M19, // Notch 47 | M31, // Text 48 | M43, // Drill2 49 | M44, // Drill1 50 | M45, // Drill3 51 | M72, // Drill3 52 | M73 // Drill4 53 | }; 54 | 55 | class Importer 56 | { 57 | private: 58 | Graph *_graph = nullptr; 59 | std::vector _points; 60 | Geo::Point _last_coord; 61 | Geo::Circle *_last_circle; 62 | Geo::Polygon *_last_polygon; 63 | 64 | int _circle_radius = 10; 65 | size_t _index = 0; 66 | 67 | bool _is_pen_down = false; 68 | bool _is_knife_down = false; 69 | bool _ignore_M19 = true; 70 | Command _command = Command::None; 71 | 72 | CurveType _curve_type = CurveType::Linear; 73 | 74 | Unit unit = Unit::mm; 75 | 76 | public: 77 | void set_x_coord(const int value); 78 | void set_y_coord(const int value); 79 | void store_points(); 80 | 81 | void draw_circle(); 82 | void set_circle_radius(const std::string &text); 83 | 84 | void set_unit_mm(); 85 | void set_unit_hectomil(); 86 | 87 | void pen_down(); 88 | void pen_up(); 89 | 90 | void knife_down(const std::string &value); 91 | void knife_up(); 92 | 93 | void load_graph(Graph *g); 94 | void reset(); 95 | 96 | void read_text(); 97 | void store_text(const std::string& text); 98 | void store_table_text(const std::string &text); 99 | 100 | void print_symbol(const std::string& str); 101 | 102 | void end(); 103 | private: 104 | inline double unit_scale(int); 105 | }; 106 | 107 | bool parse(std::string_view &stream, Graph *graph); 108 | 109 | bool parse(std::ifstream &stream, Graph *graph); 110 | }; // namespace RS274DParser -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader21.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DWGREADER21_H 14 | #define DWGREADER21_H 15 | 16 | #include 17 | #include 18 | #include "drw_textcodec.h" 19 | #include "dwgbuffer.h" 20 | #include "dwgreader.h" 21 | 22 | //reader for AC1021 aka v2007, chapter 5 23 | class dwgReader21 : public dwgReader { 24 | public: 25 | dwgReader21(std::ifstream *stream, dwgR *p):dwgReader(stream, p){ 26 | objData = NULL; 27 | dataSize = 0; 28 | } 29 | virtual ~dwgReader21(){ 30 | if (objData != NULL) 31 | delete[] objData; 32 | } 33 | bool readMetaData(); 34 | bool readFileHeader(); 35 | bool readDwgHeader(DRW_Header& hdr); 36 | bool readDwgClasses(); 37 | bool readDwgHandles(); 38 | bool readDwgTables(DRW_Header& hdr); 39 | bool readDwgBlocks(DRW_Interface& intfa); 40 | virtual bool readDwgEntities(DRW_Interface& intfa){ 41 | bool ret = true; 42 | dwgBuffer dataBuf(objData, dataSize, &decoder); 43 | ret = dwgReader::readDwgEntities(intfa, &dataBuf); 44 | return ret; 45 | } 46 | virtual bool readDwgObjects(DRW_Interface& intfa){ 47 | bool ret = true; 48 | dwgBuffer dataBuf(objData, dataSize, &decoder); 49 | ret = dwgReader::readDwgObjects(intfa, &dataBuf); 50 | return ret; 51 | } 52 | //bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){ 53 | // return false; 54 | //} 55 | 56 | private: 57 | bool parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset, duint8 *decompData); 58 | bool parseDataPage(dwgSectionInfo si, duint8 *dData); 59 | 60 | duint8 *objData; 61 | duint64 dataSize; 62 | 63 | }; 64 | 65 | #endif // DWGREADER21_H 66 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/drw_textcodec.h: -------------------------------------------------------------------------------- 1 | #ifndef DRW_TEXTCODEC_H 2 | #define DRW_TEXTCODEC_H 3 | 4 | #include 5 | 6 | class DRW_Converter; 7 | 8 | class DRW_TextCodec 9 | { 10 | public: 11 | DRW_TextCodec(); 12 | ~DRW_TextCodec(); 13 | std::string fromUtf8(const std::string &s); 14 | std::string toUtf8(const std::string &s); 15 | int getVersion(){return version;} 16 | void setVersion(std::string *v, bool dxfFormat); 17 | void setVersion(int v, bool dxfFormat); 18 | void setCodePage(std::string *c, bool dxfFormat); 19 | void setCodePage(std::string c, bool dxfFormat){setCodePage(&c, dxfFormat);} 20 | std::string getCodePage(){return cp;} 21 | 22 | private: 23 | std::string correctCodePage(const std::string& s); 24 | 25 | private: 26 | int version; 27 | std::string cp; 28 | DRW_Converter *conv; 29 | }; 30 | 31 | class DRW_Converter 32 | { 33 | public: 34 | DRW_Converter(const int *t, int l){table = t; 35 | cpLenght = l;} 36 | virtual ~DRW_Converter(){} 37 | virtual std::string fromUtf8(const std::string &s) {return s;} 38 | virtual std::string toUtf8(const std::string &s); 39 | std::string encodeText(std::string stmp); 40 | std::string decodeText(int c); 41 | std::string encodeNum(int c); 42 | int decodeNum(std::string s, int *b); 43 | const int *table; 44 | int cpLenght; 45 | }; 46 | 47 | class DRW_ConvUTF16 : public DRW_Converter { 48 | public: 49 | DRW_ConvUTF16():DRW_Converter(NULL, 0) {} 50 | std::string fromUtf8(const std::string &s) override; 51 | std::string toUtf8(const std::string &s) override; 52 | }; 53 | 54 | class DRW_ConvTable : public DRW_Converter { 55 | public: 56 | DRW_ConvTable(const int *t, int l):DRW_Converter(t, l) {} 57 | std::string fromUtf8(const std::string &s) override; 58 | std::string toUtf8(const std::string &s) override; 59 | }; 60 | 61 | class DRW_ConvDBCSTable : public DRW_Converter { 62 | public: 63 | DRW_ConvDBCSTable(const int *t, const int *lt, const int dt[][2], int l):DRW_Converter(t, l) { 64 | leadTable = lt; 65 | doubleTable = dt; 66 | } 67 | 68 | std::string fromUtf8(const std::string &s) override; 69 | std::string toUtf8(const std::string &s) override; 70 | private: 71 | const int *leadTable; 72 | const int (*doubleTable)[2]; 73 | 74 | }; 75 | 76 | class DRW_Conv932Table : public DRW_Converter { 77 | public: 78 | DRW_Conv932Table(const int *t, const int *lt, const int dt[][2], int l):DRW_Converter(t, l) { 79 | leadTable = lt; 80 | doubleTable = dt; 81 | } 82 | 83 | std::string fromUtf8(const std::string &s) override; 84 | std::string toUtf8(const std::string &s) override; 85 | private: 86 | const int *leadTable; 87 | const int (*doubleTable)[2]; 88 | 89 | }; 90 | 91 | #endif // DRW_TEXTCODEC_H 92 | -------------------------------------------------------------------------------- /src/base/Math.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | namespace Math 8 | { 9 | static const double EPSILON = 1e-14; 10 | static const double PI = 3.14159265358979323846; 11 | static const int MAX_ITERATION = 10; 12 | 13 | void error_handle(const char *reason, const char *file, int line, int gsl_errno); 14 | 15 | 16 | struct EllipseParameter 17 | { 18 | double a[2] = {0}; 19 | double b[2] = {0}; 20 | double c[2] = {0}; 21 | double d[2] = {0}; 22 | double e[2] = {0}; 23 | double f[2] = {0}; 24 | }; 25 | 26 | int ellipse_ellipse_f(const gsl_vector *x, void *params, gsl_vector *f); 27 | 28 | int ellipse_ellipse_df(const gsl_vector *x, void *params, gsl_matrix *j); 29 | 30 | int ellipse_ellipse_fdf(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *j); 31 | 32 | std::tuple solve_ellipse_ellipse_intersection(EllipseParameter ¶m, const double init_x, const double init_y); 33 | 34 | void inverse(const double *input, const size_t n, double *output); 35 | 36 | void mul(const double *mat0, const size_t m0, const size_t n0, const double *mat1, const size_t n1, double *output); 37 | 38 | void solve(const double *mat, const size_t n, const double *b, double *output); 39 | 40 | 41 | struct BezierParameter 42 | { 43 | int order = 3; 44 | const double *points = nullptr; 45 | const int *values = nullptr; 46 | }; 47 | 48 | int bezier_bezier_f(const gsl_vector *v, void *params, gsl_vector *f); 49 | 50 | struct BSplineParameter 51 | { 52 | bool is_cubic = true; 53 | size_t npts = 4; 54 | const double *points = nullptr; 55 | const double *values = nullptr; 56 | }; 57 | 58 | void rbasis(const bool is_cubic, const double t, const size_t npts, const double *x, double *output); 59 | 60 | int bspline_bspline_f(const gsl_vector *v, void *params, gsl_vector *f); 61 | 62 | struct BezierBSplineParameter 63 | { 64 | BezierParameter bezier; 65 | BSplineParameter bspline; 66 | }; 67 | 68 | int bezier_bspline_f(const gsl_vector *v, void *params, gsl_vector *f); 69 | 70 | enum class CurveIntersectType 71 | { 72 | BezierBezier, BSplineBSpline, BezierBSpline 73 | }; 74 | 75 | std::tuple solve_curve_intersection(void *param, const CurveIntersectType type, const double init_t0, const double init_t1); 76 | 77 | 78 | struct EllipseFootParameter // a * cost + b * sint + c * sint * cost = 0 79 | { 80 | double a = 0; 81 | double b = 0; 82 | double c = 0; 83 | }; 84 | 85 | double ellipse_foot_f(const double v, void *params); 86 | 87 | double solve_ellipse_foot(EllipseFootParameter ¶m, const double init_t); 88 | }; 89 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/rscodec.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2014 J.F. Soriano (Rallaz), rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | /** 14 | * Reed-Solomon codec 15 | * Reed Solomon code lifted from encoder/decoder for Reed-Solomon written by Simon Rockliff 16 | * 17 | * Original code: 18 | * This program may be freely modified and/or given to whoever wants it. 19 | * A condition of such distribution is that the author's contribution be 20 | * acknowledged by his name being left in the comments heading the program, 21 | * however no responsibility is accepted for any financial or other loss which 22 | * may result from some unforseen errors or malfunctioning of the program 23 | * during use. 24 | * Simon Rockliff, 26th June 1991 25 | */ 26 | 27 | 28 | 29 | #ifndef RSCODEC_H 30 | #define RSCODEC_H 31 | /** 32 | mm: RS code over GF(2^4) 33 | nn: nn= (2^mm) - 1 length of codeword 34 | tt: number of errors that can be corrected 35 | kk: kk = nn-2*tt 36 | pp: irreducible polynomial coeffts, pp [mm] send as int 37 | */ 38 | class RScodec { 39 | public: 40 | RScodec(unsigned int pp, int mm, int tt); 41 | 42 | ~RScodec(); 43 | // bool encode(int *data, int *parity); 44 | // int decode(int *recd); 45 | bool encode(unsigned char *data, unsigned char *parity); 46 | int decode(unsigned char *data); 47 | bool isOkey(){return isOk;} 48 | const unsigned int* indexOf() {return index_of;} 49 | const int* alphaTo() {return alpha_to;} 50 | 51 | private: 52 | void RSgenerate_gf(unsigned int pp); 53 | void RSgen_poly(); 54 | int calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc, int* z, int* err, int* reg, int bb); 55 | 56 | 57 | private: 58 | int mm; //RS code over GF(2^4) 59 | int tt; //number of errors that can be corrected 60 | int nn; //(2^mm) - 1 length of codeword 61 | int kk; //nn-2*tt length of original data 62 | 63 | int *gg; 64 | bool isOk; 65 | unsigned int *index_of; 66 | int *alpha_to; 67 | }; 68 | 69 | #endif // RSCODEC_H 70 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dxfwriter.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DXFWRITER_H 14 | #define DXFWRITER_H 15 | 16 | #include "drw_textcodec.h" 17 | 18 | class dxfWriter { 19 | public: 20 | dxfWriter(std::ofstream *stream){filestr = stream; /*count =0;*/} 21 | virtual ~dxfWriter(){} 22 | virtual bool writeString(int code, std::string text) = 0; 23 | bool writeUtf8String(int code, std::string text); 24 | bool writeUtf8Caps(int code, std::string text); 25 | std::string fromUtf8String(std::string t) {return encoder.fromUtf8(t);} 26 | virtual bool writeInt16(int code, int data) = 0; 27 | virtual bool writeInt32(int code, int data) = 0; 28 | virtual bool writeInt64(int code, unsigned long long int data) = 0; 29 | virtual bool writeDouble(int code, double data) = 0; 30 | virtual bool writeBool(int code, bool data) = 0; 31 | void setVersion(std::string *v, bool dxfFormat){encoder.setVersion(v, dxfFormat);} 32 | void setCodePage(std::string *c){encoder.setCodePage(c, true);} 33 | std::string getCodePage(){return encoder.getCodePage();} 34 | protected: 35 | std::ofstream *filestr; 36 | private: 37 | DRW_TextCodec encoder; 38 | }; 39 | 40 | class dxfWriterBinary : public dxfWriter { 41 | public: 42 | dxfWriterBinary(std::ofstream *stream):dxfWriter(stream){} 43 | virtual ~dxfWriterBinary() {} 44 | virtual bool writeString(int code, std::string text); 45 | virtual bool writeInt16(int code, int data); 46 | virtual bool writeInt32(int code, int data); 47 | virtual bool writeInt64(int code, unsigned long long int data); 48 | virtual bool writeDouble(int code, double data); 49 | virtual bool writeBool(int code, bool data); 50 | }; 51 | 52 | class dxfWriterAscii : public dxfWriter { 53 | public: 54 | dxfWriterAscii(std::ofstream *stream); 55 | virtual ~dxfWriterAscii(){} 56 | virtual bool writeString(int code, std::string text); 57 | virtual bool writeInt16(int code, int data); 58 | virtual bool writeInt32(int code, int data); 59 | virtual bool writeInt64(int code, unsigned long long int data); 60 | virtual bool writeDouble(int code, double data); 61 | virtual bool writeBool(int code, bool data); 62 | }; 63 | 64 | #endif // DXFWRITER_H 65 | -------------------------------------------------------------------------------- /src/ui/CMDWidget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "draw/CanvasOperation.hpp" 7 | 8 | 9 | QT_BEGIN_NAMESPACE 10 | namespace Ui { class CMDWidget;} 11 | QT_END_NAMESPACE 12 | 13 | 14 | class CMDWidget : public QWidget 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | enum class CMD {Error_CMD, Main_CMD, Array_CMD, 20 | Delete_CMD, Copy_CMD, Cut_CMD, Paste_CMD, Undo_CMD, SelectAll_CMD, 21 | Length_CMD, Angle_CMD, Polyline_CMD, CCircle_CMD, DCircle_CMD, PCircle_CMD, 22 | PArc_CMD, SCAArc_CMD, SEAArc_CMD, SERArc_CMD, Ellipse_CMD, EllipseArc_CMD, 23 | Rectangle_CMD, CPolygon_CMD, IPolygon_CMD, BSpline_CMD, Bezier_CMD, Text_CMD, 24 | Connect_CMD, Close_CMD, Combinate_CMD, Detach_CMD, Rotate_CMD, FlipX_CMD, FlipY_CMD, 25 | Mirror_CMD, Offset_CMD, Scale_CMD, Fillet_CMD, Chamfer_CMD, Trim_CMD, Extend_CMD, Split_CMD, 26 | Union_CMD, Intersection_CMD, Difference_CMD, XOR_CMD, LineArray_CMD, RingArray_CMD}; 27 | 28 | enum class SETTING {Absolute_SETTING, Relative_SETTING}; 29 | 30 | private: 31 | Ui::CMDWidget *ui = nullptr; 32 | 33 | QStringList _cmd_list; 34 | QCompleter *_completer = nullptr; 35 | std::unordered_map _cmd_dict; 36 | std::unordered_map _setting_dict; 37 | std::unordered_map _cmd_tool_dict; 38 | std::unordered_map _tool_cmd_dict; 39 | std::unordered_map _cmd_tips_dict; 40 | std::vector _direct_cmd_list; 41 | 42 | CMD _last_cmd = CMD::Error_CMD; 43 | CMD _current_cmd = CMD::Error_CMD; 44 | std::vector _parameters; 45 | 46 | private: 47 | void init(); 48 | 49 | private slots: 50 | void refresh_tool(const CanvasOperations::Tool tool); 51 | 52 | protected: 53 | bool eventFilter(QObject *target, QEvent *event); 54 | 55 | public: 56 | signals: 57 | void cmd_changed(const CMD); 58 | 59 | public: 60 | CMDWidget(QWidget *parent); 61 | ~CMDWidget(); 62 | 63 | void clear(); 64 | 65 | CMD cmd() const; 66 | 67 | bool empty() const; 68 | 69 | void activate(const char key); 70 | 71 | void work_last_cmd(); 72 | 73 | void show(); 74 | 75 | void hide(); 76 | 77 | 78 | bool work(); 79 | 80 | bool work(const CMD cmd); 81 | 82 | bool get_cmd(); 83 | 84 | bool get_parameter(); 85 | 86 | bool get_setting(); 87 | 88 | 89 | void read_parameters(const int count); 90 | 91 | void paste(); 92 | 93 | void delete_selected_objects(); 94 | 95 | void connect_polyline(); 96 | 97 | void close_polyline(); 98 | 99 | void combinate(); 100 | 101 | void detach(); 102 | 103 | void scale(); 104 | 105 | void offset(); 106 | 107 | void line_array(); 108 | 109 | void flip_x(); 110 | 111 | void flip_y(); 112 | 113 | void polygon_intersection(); 114 | 115 | void polygon_union(); 116 | 117 | void polygon_xor(); 118 | }; -------------------------------------------------------------------------------- /libs/clipper2/clipper.rectclip.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Author : Angus Johnson * 3 | * Date : 5 July 2024 * 4 | * Website : https://www.angusj.com * 5 | * Copyright : Angus Johnson 2010-2024 * 6 | * Purpose : FAST rectangular clipping * 7 | * License : https://www.boost.org/LICENSE_1_0.txt * 8 | *******************************************************************************/ 9 | 10 | #ifndef CLIPPER_RECTCLIP_H 11 | #define CLIPPER_RECTCLIP_H 12 | 13 | #include "clipper2/clipper.core.h" 14 | #include 15 | 16 | namespace Clipper2Lib 17 | { 18 | 19 | // Location: the order is important here, see StartLocsIsClockwise() 20 | enum class Location { Left, Top, Right, Bottom, Inside }; 21 | 22 | class OutPt2; 23 | typedef std::vector OutPt2List; 24 | 25 | class OutPt2 { 26 | public: 27 | Point64 pt; 28 | size_t owner_idx = 0; 29 | OutPt2List* edge = nullptr; 30 | OutPt2* next = nullptr; 31 | OutPt2* prev = nullptr; 32 | }; 33 | 34 | //------------------------------------------------------------------------------ 35 | // RectClip64 36 | //------------------------------------------------------------------------------ 37 | 38 | class RectClip64 { 39 | private: 40 | void ExecuteInternal(const Path64& path); 41 | Path64 GetPath(OutPt2*& op); 42 | protected: 43 | const Rect64 rect_; 44 | const Path64 rect_as_path_; 45 | const Point64 rect_mp_; 46 | Rect64 path_bounds_; 47 | std::deque op_container_; 48 | OutPt2List results_; // each path can be broken into multiples 49 | OutPt2List edges_[8]; // clockwise and counter-clockwise 50 | std::vector start_locs_; 51 | void CheckEdges(); 52 | void TidyEdges(size_t idx, OutPt2List& cw, OutPt2List& ccw); 53 | void GetNextLocation(const Path64& path, 54 | Location& loc, size_t& i, size_t highI); 55 | OutPt2* Add(Point64 pt, bool start_new = false); 56 | void AddCorner(Location prev, Location curr); 57 | void AddCorner(Location& loc, bool isClockwise); 58 | public: 59 | explicit RectClip64(const Rect64& rect) : 60 | rect_(rect), 61 | rect_as_path_(rect.AsPath()), 62 | rect_mp_(rect.MidPoint()) {} 63 | Paths64 Execute(const Paths64& paths); 64 | }; 65 | 66 | //------------------------------------------------------------------------------ 67 | // RectClipLines64 68 | //------------------------------------------------------------------------------ 69 | 70 | class RectClipLines64 : public RectClip64 { 71 | private: 72 | void ExecuteInternal(const Path64& path); 73 | Path64 GetPath(OutPt2*& op); 74 | public: 75 | explicit RectClipLines64(const Rect64& rect) : RectClip64(rect) {}; 76 | Paths64 Execute(const Paths64& paths); 77 | }; 78 | 79 | } // Clipper2Lib namespace 80 | #endif // CLIPPER_RECTCLIP_H 81 | -------------------------------------------------------------------------------- /src/ui/Setting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ui/Setting.hpp" 3 | #include "./ui_Setting.h" 4 | #include "ui/WinUITool.hpp" 5 | #include "io/GlobalSetting.hpp" 6 | 7 | 8 | Setting::Setting(QWidget *parent) 9 | :QDialog(parent), ui(new Ui::Setting) 10 | { 11 | ui->setupUi(this); 12 | } 13 | 14 | Setting::~Setting() 15 | { 16 | delete ui; 17 | } 18 | 19 | void Setting::init() 20 | { 21 | ui->offset_join_type->setView(new QListView(ui->offset_join_type)); 22 | ui->offset_join_type->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 23 | ui->offset_end_type->setView(new QListView(ui->offset_end_type)); 24 | ui->offset_end_type->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 25 | 26 | ui->catch_distance->setValue(GlobalSetting::setting().catch_distance); 27 | ui->backup_times->setValue(GlobalSetting::setting().backup_times); 28 | ui->text_size->setValue(GlobalSetting::setting().text_size); 29 | ui->sampling_step->setValue(GlobalSetting::setting().sampling_step); 30 | ui->down_sampling->setValue(GlobalSetting::setting().down_sampling); 31 | ui->offset_join_type->setCurrentIndex(GlobalSetting::setting().offset_join_type); 32 | ui->offset_end_type->setCurrentIndex(GlobalSetting::setting().offset_end_type); 33 | 34 | _text_size = ui->text_size->value(); 35 | _down_sampling_value = ui->down_sampling->value(); 36 | 37 | ui->show_text->setChecked(GlobalSetting::setting().show_text); 38 | ui->multiple_select->setChecked(GlobalSetting::setting().multiple_select); 39 | ui->show_points->setChecked(GlobalSetting::setting().show_points); 40 | ui->ignroe_M19->setChecked(GlobalSetting::setting().ignore_M19); 41 | 42 | #ifdef _WIN64 43 | WinUITool::set_caption_color(winId(), 0x3C3C3D); 44 | #endif 45 | } 46 | 47 | void Setting::accept() 48 | { 49 | GlobalSetting::setting().catch_distance = ui->catch_distance->value(); 50 | GlobalSetting::setting().backup_times = ui->backup_times->value(); 51 | GlobalSetting::setting().text_size = ui->text_size->value(); 52 | GlobalSetting::setting().sampling_step = ui->sampling_step->value(); 53 | GlobalSetting::setting().down_sampling = ui->down_sampling->value(); 54 | GlobalSetting::setting().offset_join_type = ui->offset_join_type->currentIndex(); 55 | GlobalSetting::setting().offset_end_type = ui->offset_end_type->currentIndex(); 56 | 57 | GlobalSetting::setting().show_text = ui->show_text->isChecked(); 58 | GlobalSetting::setting().multiple_select = ui->multiple_select->isChecked(); 59 | GlobalSetting::setting().show_points = ui->show_points->isChecked(); 60 | GlobalSetting::setting().ignore_M19 = ui->ignroe_M19->isChecked(); 61 | 62 | QDialog::accept(); 63 | } 64 | 65 | 66 | void Setting::show() 67 | { 68 | init(); 69 | return QDialog::show(); 70 | } 71 | 72 | int Setting::exec() 73 | { 74 | init(); 75 | return QDialog::exec(); 76 | } 77 | 78 | bool Setting::update_text_vbo() const 79 | { 80 | return _text_size == ui->text_size->value(); 81 | } 82 | 83 | bool Setting::update_curve_vbo() const 84 | { 85 | return _down_sampling_value == ui->down_sampling->value(); 86 | } -------------------------------------------------------------------------------- /src/io/TextEncoding.cpp: -------------------------------------------------------------------------------- 1 | #include "io/TextEncoding.hpp" 2 | 3 | 4 | bool TextEncoding::is_utf8(const std::string &str) 5 | { 6 | // UFT8可用1-6个字节编码,ASCII用一个字节 7 | unsigned int bytes_count = 0; 8 | unsigned char uc; 9 | bool all_ascii = true; 10 | for (char c : str) 11 | { 12 | uc = static_cast(c); 13 | // 判断是否ASCII编码,如果不是,说明有可能是UTF8,ASCII用7位编码,最高位标记为0,0xxxxxxx 14 | if (bytes_count == 0 && (uc & 0x80) != 0) 15 | { 16 | all_ascii = false; 17 | } 18 | if (bytes_count == 0) 19 | { 20 | //如果不是ASCII码,应该是多字节符,计算字节数 21 | if (uc >= 0x80) 22 | { 23 | if (uc >= 0xFC && uc <= 0xFD) 24 | { 25 | bytes_count = 6; 26 | } 27 | else if (uc >= 0xF8) 28 | { 29 | bytes_count = 5; 30 | } 31 | else if (uc >= 0xF0) 32 | { 33 | bytes_count = 4; 34 | } 35 | else if (uc >= 0xE0) 36 | { 37 | bytes_count = 3; 38 | } 39 | else if (uc >= 0xC0) 40 | { 41 | bytes_count = 2; 42 | } 43 | else 44 | { 45 | return false; 46 | } 47 | --bytes_count; 48 | } 49 | } 50 | else 51 | { 52 | // 多字节符的非首字节,应为 10xxxxxx 53 | if ((uc & 0xC0) != 0x80) 54 | { 55 | return false; 56 | } 57 | // 减到为零为止 58 | --bytes_count; 59 | } 60 | } 61 | 62 | // 违返UTF8编码规则 63 | if (bytes_count != 0) 64 | { 65 | return false; 66 | } 67 | if (all_ascii) 68 | { 69 | // 如果全部都是ASCII,也是UTF8 70 | return true; 71 | } 72 | 73 | return true; 74 | } 75 | 76 | bool TextEncoding::is_gbk(const std::string &str) 77 | { 78 | // GBK可用1 - 2个字节编码,中文两个,英文一个 79 | unsigned int bytes_count = 0; 80 | unsigned char uc; 81 | // 如果全部都是ASCII 82 | bool all_ascii = true; 83 | for (char c : str) 84 | { 85 | uc = static_cast(c); 86 | if ((uc & 0x80) != 0 && bytes_count == 0) 87 | { 88 | // 判断是否ASCII编码,如果不是,说明有可能是GBK 89 | all_ascii = false; 90 | } 91 | if (bytes_count == 0) 92 | { 93 | if (uc >= 0x80) 94 | { 95 | if (uc >= 0x81 && uc <= 0xFE) 96 | { 97 | bytes_count = 2; 98 | } 99 | else 100 | { 101 | return false; 102 | } 103 | --bytes_count; 104 | } 105 | } 106 | else 107 | { 108 | if (uc < 0x40 || uc > 0xFE) 109 | { 110 | return false; 111 | } 112 | --bytes_count; 113 | } 114 | } 115 | 116 | if (bytes_count != 0) 117 | { 118 | // 违返规则 119 | return false; 120 | } 121 | if (all_ascii) 122 | { 123 | // 如果全部都是ASCII,也是GBK 124 | return true; 125 | } 126 | 127 | return true; 128 | } -------------------------------------------------------------------------------- /res/icons/line_array_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /res/icons/offset_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /res/icons/scale_btn.drawio: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgutil.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DWGUTIL_H 14 | #define DWGUTIL_H 15 | 16 | #include "../drw_base.h" 17 | 18 | namespace DRW { 19 | std::string toHexStr(int n); 20 | } 21 | 22 | class dwgRSCodec { 23 | public: 24 | dwgRSCodec(){} 25 | ~dwgRSCodec(){} 26 | static void decode239I(duint8 *in, duint8 *out, duint32 blk); 27 | static void decode251I(duint8 *in, duint8 *out, duint32 blk); 28 | }; 29 | 30 | class dwgCompressor { 31 | public: 32 | dwgCompressor(){} 33 | ~dwgCompressor(){} 34 | 35 | void decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize); 36 | static void decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset); 37 | // static void decrypt18Data(duint8 *buf, duint32 size, duint32 offset); 38 | static void decompress21(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize); 39 | 40 | private: 41 | duint32 litLength18(); 42 | static duint32 litLength21(duint8 *cbuf, duint8 oc, duint32 *si); 43 | static void copyCompBytes21(duint8 *cbuf, duint8 *dbuf, duint32 l, duint32 si, duint32 di); 44 | static void readInstructions21(duint8 *cbuf, duint32 *si, duint8 *oc, duint32 *so, duint32 *l); 45 | 46 | duint32 longCompressionOffset(); 47 | duint32 long20CompressionOffset(); 48 | duint32 twoByteOffset(duint32 *ll); 49 | 50 | duint8 *bufC; 51 | duint8 *bufD; 52 | duint32 sizeC; 53 | duint32 sizeD; 54 | duint32 pos; 55 | duint32 rpos; 56 | 57 | }; 58 | 59 | class secEnum { 60 | public: 61 | enum DWGSection { 62 | UNKNOWNS, /*!< UNKNOWN section. */ 63 | FILEHEADER, /*!< File Header (in R3-R15*/ 64 | HEADER, /*!< AcDb:Header */ 65 | CLASSES, /*!< AcDb:Classes */ 66 | SUMARYINFO, /*!< AcDb:SummaryInfo */ 67 | PREVIEW, /*!< AcDb:Preview */ 68 | VBAPROY, /*!< AcDb:VBAProject */ 69 | APPINFO, /*!< AcDb:AppInfo */ 70 | FILEDEP, /*!< AcDb:FileDepList */ 71 | REVHISTORY, /*!< AcDb:RevHistory */ 72 | SECURITY, /*!< AcDb:Security */ 73 | OBJECTS, /*!< AcDb:AcDbObjects */ 74 | OBJFREESPACE, /*!< AcDb:ObjFreeSpace */ 75 | TEMPLATE, /*!< AcDb:Template */ 76 | HANDLES, /*!< AcDb:Handles */ 77 | PROTOTYPE, /*!< AcDb:AcDsPrototype_1b */ 78 | AUXHEADER, /*!< AcDb:AuxHeader, in (R13-R15) second file header */ 79 | SIGNATURE, /*!< AcDb:Signature */ 80 | APPINFOHISTORY, /*!< AcDb:AppInfoHistory (in ac1021 may be a renamed section?*/ 81 | EXTEDATA, /*!< Extended Entity Data */ 82 | PROXYGRAPHICS /*!< PROXY ENTITY GRAPHICS */ 83 | }; 84 | 85 | secEnum(){} 86 | ~secEnum(){} 87 | 88 | static DWGSection getEnum(std::string nameSec); 89 | }; 90 | 91 | #endif // DWGUTIL_H 92 | -------------------------------------------------------------------------------- /src/base/Graph.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "base/Container.hpp" 6 | 7 | 8 | class Graph : public Geo::Geometry 9 | { 10 | private: 11 | std::list _container_groups; 12 | 13 | public: 14 | bool modified = false; 15 | 16 | public: 17 | Graph() {}; 18 | 19 | Graph(const Graph &graph); 20 | 21 | const Geo::Type type() const override; 22 | 23 | Graph *clone() const override; 24 | 25 | void transfer(Graph &graph); 26 | 27 | void merge(Graph &graph); 28 | 29 | Graph &operator=(const Graph &graph); 30 | 31 | ContainerGroup &container_group(const size_t index = 0); 32 | 33 | const ContainerGroup &container_group(const size_t index = 0) const; 34 | 35 | std::list &container_groups(); 36 | 37 | const std::list &container_groups() const; 38 | 39 | ContainerGroup &operator[](const size_t index); 40 | 41 | const ContainerGroup &operator[](const size_t index) const; 42 | 43 | const bool empty() const override; 44 | 45 | const bool empty(const size_t index) const; 46 | 47 | const size_t size() const; 48 | 49 | const size_t count(const Geo::Type type, const bool include_combinated) const; 50 | 51 | void clear() override; 52 | 53 | void clear(const size_t index); 54 | 55 | void transform(const double a, const double b, const double c, const double d, const double e, const double f) override; 56 | 57 | void transform(const double mat[6]) override; 58 | 59 | void translate(const double tx, const double ty) override; 60 | 61 | void rotate(const double x, const double y, const double rad) override; // 弧度制 62 | 63 | void scale(const double x, const double y, const double k) override; 64 | 65 | void rescale(const double x, const double y); 66 | 67 | Geo::AABBRect bounding_rect() const override; 68 | 69 | 70 | 71 | std::list::iterator begin(); 72 | 73 | std::list::iterator end(); 74 | 75 | std::list::const_iterator begin() const; 76 | 77 | std::list::const_iterator end() const; 78 | 79 | std::list::const_iterator cbegin() const; 80 | 81 | std::list::const_iterator cend() const; 82 | 83 | std::list::reverse_iterator rbegin(); 84 | 85 | std::list::reverse_iterator rend(); 86 | 87 | std::list::const_reverse_iterator rbegin() const; 88 | 89 | std::list::const_reverse_iterator rend() const; 90 | 91 | std::list::const_reverse_iterator crbegin() const; 92 | 93 | std::list::const_reverse_iterator crend() const; 94 | 95 | ContainerGroup &front(); 96 | 97 | const ContainerGroup &front() const; 98 | 99 | ContainerGroup &back(); 100 | 101 | const ContainerGroup &back() const; 102 | 103 | 104 | 105 | void append(Geo::Geometry *object, const size_t index = 0); 106 | 107 | void append_group(); 108 | 109 | void append_group(const ContainerGroup &group); 110 | 111 | void append_group(const ContainerGroup &&group); 112 | 113 | void insert_group(const size_t index); 114 | 115 | void insert_group(const size_t index, const ContainerGroup &group); 116 | 117 | void insert_group(const size_t index, const ContainerGroup &&group); 118 | 119 | void remove_group(const size_t index); 120 | 121 | 122 | bool has_group(const QString &name) const; 123 | 124 | bool has_object(const QString &name) const; 125 | 126 | bool remove_object(const Geo::Geometry *object); 127 | 128 | 129 | void update_curve_shape(const double step, const double down_sampling_value); 130 | }; -------------------------------------------------------------------------------- /src/ui/LayersManager.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | LayersManager 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | 15 | 400 16 | 300 17 | 18 | 19 | 20 | Layers 21 | 22 | 23 | 24 | :/DSV2.ico:/DSV2.ico 25 | 26 | 27 | background-color: rgb(50, 50, 51); 28 | selection-color: rgb(230, 230, 230); 29 | selection-background-color: rgb(0, 85, 127); 30 | color: rgb(230, 230, 230); 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | Qt::ContextMenuPolicy::CustomContextMenu 40 | 41 | 42 | QFrame::Shape::Box 43 | 44 | 45 | QFrame::Shadow::Plain 46 | 47 | 48 | Qt::ScrollBarPolicy::ScrollBarAlwaysOff 49 | 50 | 51 | Qt::ScrollBarPolicy::ScrollBarAlwaysOff 52 | 53 | 54 | QAbstractItemView::EditTrigger::DoubleClicked 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | Qt::Orientation::Horizontal 64 | 65 | 66 | 67 | 40 68 | 20 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 80 78 | 24 79 | 80 | 81 | 82 | QPushButton 83 | { 84 | color:rgb(230, 230, 230); 85 | background-color:rgb(70, 70, 71); 86 | border:none; 87 | } 88 | QPushButton:hover 89 | { 90 | background-color:rgb(0, 85, 127); 91 | } 92 | QPushButton:pressed 93 | { 94 | background-color:rgb(0, 85, 127); 95 | } 96 | 97 | 98 | OK 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | pushButton 112 | clicked() 113 | LayersManager 114 | accept() 115 | 116 | 117 | 352 118 | 277 119 | 120 | 121 | 199 122 | 149 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /src/ui/MessageBox.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MessageBox 4 | 5 | 6 | 7 | 0 8 | 0 9 | 276 10 | 100 11 | 12 | 13 | 14 | 15 | 10 16 | 17 | 18 | 19 | 20 | :/DSV2.ico:/DSV2.ico 21 | 22 | 23 | QDialog{background-color: rgb(50, 50, 51); 24 | color: rgb(230, 230, 230);} 25 | QLabel{color:rgb(230, 230, 230);} 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 6 34 | 35 | 36 | 12 37 | 38 | 39 | 12 40 | 41 | 42 | 12 43 | 44 | 45 | 6 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 64 54 | 64 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 10 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | QPushButton 80 | { 81 | color:rgb(230, 230, 230); 82 | background-color:rgb(70, 70, 71); 83 | border:none; 84 | min-width:80; 85 | min-height:24; 86 | } 87 | QPushButton:hover 88 | { 89 | background-color:rgb(0, 85, 127); 90 | } 91 | QPushButton:pressed 92 | { 93 | background-color:rgb(0, 85, 127); 94 | } 95 | 96 | 97 | 98 | 99 | 100 | 101 | Qt::Orientation::Horizontal 102 | 103 | 104 | QDialogButtonBox::StandardButton::No|QDialogButtonBox::StandardButton::Yes 105 | 106 | 107 | true 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | buttonBox 119 | clicked(QAbstractButton*) 120 | MessageBox 121 | button_clicked(QAbstractButton*) 122 | 123 | 124 | 199 125 | 99 126 | 127 | 128 | 199 129 | 62 130 | 131 | 132 | 133 | 134 | 135 | button_clicked(QAbstractButton*) 136 | 137 | 138 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dxfreader.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DXFREADER_H 14 | #define DXFREADER_H 15 | 16 | #include "drw_textcodec.h" 17 | 18 | class dxfReader { 19 | public: 20 | enum TYPE { 21 | STRING, 22 | INT32, 23 | INT64, 24 | DOUBLE, 25 | BOOL, 26 | INVALID 27 | }; 28 | enum TYPE type; 29 | public: 30 | dxfReader(std::ifstream *stream){ 31 | filestr = stream; 32 | type = INVALID; 33 | } 34 | virtual ~dxfReader(){} 35 | bool readRec(int *code); 36 | 37 | std::string getString() {return strData;} 38 | int getHandleString();//Convert hex string to int 39 | std::string toUtf8String(std::string t) {return decoder.toUtf8(t);} 40 | std::string getUtf8String() {return decoder.toUtf8(strData);} 41 | double getDouble() {return doubleData;} 42 | int getInt32() {return intData;} 43 | unsigned long long int getInt64() {return int64;} 44 | bool getBool() { return (intData==0) ? false : true;} 45 | int getVersion(){return decoder.getVersion();} 46 | void setVersion(std::string *v, bool dxfFormat){decoder.setVersion(v, dxfFormat);} 47 | void setCodePage(std::string *c){decoder.setCodePage(c, true);} 48 | std::string getCodePage(){ return decoder.getCodePage();} 49 | 50 | protected: 51 | virtual bool readCode(int *code) = 0; //return true if sucesful (not EOF) 52 | virtual bool readString(std::string *text) = 0; 53 | virtual bool readString() = 0; 54 | virtual bool readInt16() = 0; 55 | virtual bool readInt32() = 0; 56 | virtual bool readInt64() = 0; 57 | virtual bool readDouble() = 0; 58 | virtual bool readBool() = 0; 59 | 60 | protected: 61 | std::ifstream *filestr; 62 | std::string strData; 63 | double doubleData; 64 | signed int intData; //32 bits integer 65 | unsigned long long int int64; //64 bits integer 66 | bool skip; //set to true for ascii dxf, false for binary 67 | private: 68 | DRW_TextCodec decoder; 69 | }; 70 | 71 | class dxfReaderBinary : public dxfReader { 72 | public: 73 | dxfReaderBinary(std::ifstream *stream):dxfReader(stream){skip = false; } 74 | virtual ~dxfReaderBinary() {} 75 | virtual bool readCode(int *code); 76 | virtual bool readString(std::string *text); 77 | virtual bool readString(); 78 | virtual bool readInt16(); 79 | virtual bool readInt32(); 80 | virtual bool readInt64(); 81 | virtual bool readDouble(); 82 | virtual bool readBool(); 83 | }; 84 | 85 | class dxfReaderAscii : public dxfReader { 86 | public: 87 | dxfReaderAscii(std::ifstream *stream):dxfReader(stream){skip = true; } 88 | virtual ~dxfReaderAscii(){} 89 | virtual bool readCode(int *code); 90 | virtual bool readString(std::string *text); 91 | virtual bool readString(); 92 | virtual bool readInt16(); 93 | virtual bool readDouble(); 94 | virtual bool readInt32(); 95 | virtual bool readInt64(); 96 | virtual bool readBool(); 97 | }; 98 | 99 | #endif // DXFREADER_H 100 | -------------------------------------------------------------------------------- /libs/libdxfrw/intern/dwgreader18.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DWGREADER18_H 14 | #define DWGREADER18_H 15 | 16 | #include 17 | #include 18 | #include "dwgreader.h" 19 | //#include "../drw_textcodec.h" 20 | #include "dwgbuffer.h" 21 | 22 | static const int DRW_magicNum18[] = { 23 | 0x29, 0x23, 0xbe, 0x84, 0xe1, 0x6c, 0xd6, 0xae, 24 | 0x52, 0x90, 0x49, 0xf1, 0xf1, 0xbb, 0xe9, 0xeb, 25 | 0xb3, 0xa6, 0xdb, 0x3c, 0x87, 0x0c, 0x3e, 0x99, 26 | 0x24, 0x5e, 0x0d, 0x1c, 0x06, 0xb7, 0x47, 0xde, 27 | 0xb3, 0x12, 0x4d, 0xc8, 0x43, 0xbb, 0x8b, 0xa6, 28 | 0x1f, 0x03, 0x5a, 0x7d, 0x09, 0x38, 0x25, 0x1f, 29 | 0x5d, 0xd4, 0xcb, 0xfc, 0x96, 0xf5, 0x45, 0x3b, 30 | 0x13, 0x0d, 0x89, 0x0a, 0x1c, 0xdb, 0xae, 0x32, 31 | 0x20, 0x9a, 0x50, 0xee, 0x40, 0x78, 0x36, 0xfd, 32 | 0x12, 0x49, 0x32, 0xf6, 0x9e, 0x7d, 0x49, 0xdc, 33 | 0xad, 0x4f, 0x14, 0xf2, 0x44, 0x40, 0x66, 0xd0, 34 | 0x6b, 0xc4, 0x30, 0xb7, 0x32, 0x3b, 0xa1, 0x22, 35 | 0xf6, 0x22, 0x91, 0x9d, 0xe1, 0x8b, 0x1f, 0xda, 36 | 0xb0, 0xca, 0x99, 0x02 37 | }; 38 | 39 | static const int DRW_magicNumEnd18[] = { 40 | 0xf8, 0x46, 0x6a, 0x04, 0x96, 0x73, 0x0e, 0xd9, 41 | 0x16, 0x2f, 0x67, 0x68, 0xd4, 0xf7, 0x4a, 0x4a, 42 | 0xd0, 0x57, 0x68, 0x76}; 43 | 44 | class dwgReader18 : public dwgReader { 45 | public: 46 | dwgReader18(std::ifstream *stream, dwgR *p):dwgReader(stream, p){ 47 | objData = NULL; 48 | } 49 | virtual ~dwgReader18(){ 50 | if (objData != NULL) 51 | delete[] objData; 52 | } 53 | bool readMetaData(); 54 | bool readFileHeader(); 55 | bool readDwgHeader(DRW_Header& hdr); 56 | bool readDwgClasses(); 57 | bool readDwgHandles(); 58 | bool readDwgTables(DRW_Header& hdr); 59 | bool readDwgBlocks(DRW_Interface& intfa){ 60 | bool ret = true; 61 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 62 | ret = dwgReader::readDwgBlocks(intfa, &dataBuf); 63 | return ret; 64 | } 65 | 66 | virtual bool readDwgEntities(DRW_Interface& intfa){ 67 | bool ret = true; 68 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 69 | ret = dwgReader::readDwgEntities(intfa, &dataBuf); 70 | return ret; 71 | } 72 | virtual bool readDwgObjects(DRW_Interface& intfa){ 73 | bool ret = true; 74 | dwgBuffer dataBuf(objData, uncompSize, &decoder); 75 | ret = dwgReader::readDwgObjects(intfa, &dataBuf); 76 | return ret; 77 | } 78 | 79 | // bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){ 80 | // bool ret = true; 81 | // return ret; 82 | // } 83 | 84 | protected: 85 | duint8 *objData; 86 | duint64 uncompSize; 87 | 88 | private: 89 | void genMagicNumber(); 90 | // dwgBuffer* bufObj; 91 | void parseSysPage(duint8 *decompSec, duint32 decompSize); //called: Section page map: 0x41630e3b 92 | bool parseDataPage(dwgSectionInfo si/*, duint8 *dData*/); //called ???: Section map: 0x4163003b 93 | duint32 checksum(duint32 seed, duint8* data, duint32 sz); 94 | 95 | private: 96 | duint32 securityFlags; 97 | }; 98 | 99 | #endif // DWGREADER18_H 100 | -------------------------------------------------------------------------------- /libs/libdxfrw/drw_header.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #ifndef DRW_HEADER_H 14 | #define DRW_HEADER_H 15 | 16 | 17 | #include 18 | #include "drw_base.h" 19 | 20 | class dxfReader; 21 | class dxfWriter; 22 | class dwgBuffer; 23 | 24 | #define SETHDRFRIENDS friend class dxfRW; \ 25 | friend class dwgReader; 26 | 27 | //! Class to handle header entries 28 | /*! 29 | * Class to handle header vars, to read iterate over "std::map vars" 30 | * to write add a DRW_Variant* into "std::map vars" (do not delete it, are cleared in dtor) 31 | * or use add* helper functions. 32 | * @author Rallaz 33 | */ 34 | class DRW_Header { 35 | SETHDRFRIENDS 36 | public: 37 | DRW_Header(); 38 | ~DRW_Header() { 39 | clearVars(); 40 | } 41 | 42 | DRW_Header(const DRW_Header& h){ 43 | this->version = h.version; 44 | this->comments = h.comments; 45 | for (std::map::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it){ 46 | this->vars[it->first] = new DRW_Variant( *(it->second) ); 47 | } 48 | this->curr = NULL; 49 | } 50 | DRW_Header& operator=(const DRW_Header &h) { 51 | if(this != &h) { 52 | clearVars(); 53 | this->version = h.version; 54 | this->comments = h.comments; 55 | for (std::map::const_iterator it=h.vars.begin(); it!=h.vars.end(); ++it){ 56 | this->vars[it->first] = new DRW_Variant( *(it->second) ); 57 | } 58 | } 59 | return *this; 60 | } 61 | 62 | void addDouble(std::string key, double value, int code); 63 | void addInt(std::string key, int value, int code); 64 | void addStr(std::string key, std::string value, int code); 65 | void addCoord(std::string key, DRW_Coord value, int code); 66 | std::string getComments() const {return comments;} 67 | void write(dxfWriter *writer, DRW::Version ver); 68 | void addComment(std::string c); 69 | 70 | protected: 71 | void parseCode(int code, dxfReader *reader); 72 | bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf, duint8 mv=0); 73 | private: 74 | bool getDouble(std::string key, double *varDouble); 75 | bool getInt(std::string key, int *varInt); 76 | bool getStr(std::string key, std::string *varStr); 77 | bool getCoord(std::string key, DRW_Coord *varStr); 78 | void clearVars(){ 79 | for (std::map::iterator it=vars.begin(); it!=vars.end(); ++it) 80 | delete it->second; 81 | 82 | vars.clear(); 83 | } 84 | 85 | public: 86 | std::map vars; 87 | private: 88 | std::string comments; 89 | std::string name; 90 | DRW_Variant* curr; 91 | int version; //to use on read 92 | 93 | duint32 linetypeCtrl; 94 | duint32 layerCtrl; 95 | duint32 styleCtrl; 96 | duint32 dimstyleCtrl; 97 | duint32 appidCtrl; 98 | duint32 blockCtrl; 99 | duint32 viewCtrl; 100 | duint32 ucsCtrl; 101 | duint32 vportCtrl; 102 | duint32 vpEntHeaderCtrl; 103 | }; 104 | 105 | #endif 106 | 107 | // EOF 108 | 109 | -------------------------------------------------------------------------------- /libs/libdxfrw/drw_classes.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #include "drw_classes.h" 14 | #include "intern/dxfreader.h" 15 | #include "intern/dxfwriter.h" 16 | #include "intern/dwgbuffer.h" 17 | #include "intern/drw_dbg.h" 18 | 19 | void DRW_Class::parseCode(int code, dxfReader *reader){ 20 | switch (code) { 21 | case 1: 22 | recName = reader->getUtf8String(); 23 | break; 24 | case 2: 25 | className = reader->getUtf8String(); 26 | break; 27 | case 3: 28 | appName = reader->getUtf8String(); 29 | break; 30 | case 90: 31 | proxyFlag = reader->getInt32(); 32 | break; 33 | case 91: 34 | instanceCount = reader->getInt32(); 35 | break; 36 | case 280: 37 | wasaProxyFlag = reader->getInt32(); 38 | break; 39 | case 281: 40 | entityFlag = reader->getInt32(); 41 | break; 42 | default: 43 | break; 44 | } 45 | } 46 | 47 | bool DRW_Class::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf){ 48 | DRW_DBG("\n***************************** parsing Class *********************************************\n"); 49 | 50 | classNum = buf->getBitShort(); 51 | DRW_DBG("Class number: "); DRW_DBG(classNum); 52 | proxyFlag = buf->getBitShort(); //in dwg specs says "version" 53 | 54 | appName = strBuf->getVariableText(version, false); 55 | className = strBuf->getVariableText(version, false); 56 | recName = strBuf->getVariableText(version, false); 57 | 58 | DRW_DBG("\napp name: "); DRW_DBG(appName.c_str()); 59 | DRW_DBG("\nclass name: "); DRW_DBG(className.c_str()); 60 | DRW_DBG("\ndxf rec name: "); DRW_DBG(recName.c_str()); 61 | wasaProxyFlag = buf->getBit(); //in dwg says wasazombie 62 | entityFlag = buf->getBitShort(); 63 | entityFlag = entityFlag == 0x1F2 ? 1: 0; 64 | 65 | DRW_DBG("\nProxy capabilities flag: "); DRW_DBG(proxyFlag); 66 | DRW_DBG(", proxy flag (280): "); DRW_DBG(wasaProxyFlag); 67 | DRW_DBG(", entity flag: "); DRW_DBGH(entityFlag); 68 | 69 | if (version > DRW::AC1015) {//2004+ 70 | instanceCount = buf->getBitLong(); 71 | DRW_DBG("\nInstance Count: "); DRW_DBG(instanceCount); 72 | duint32 dwgVersion = buf->getBitLong(); 73 | DRW_DBG("\nDWG version: "); DRW_DBG(dwgVersion); 74 | DRW_DBG("\nmaintenance version: "); DRW_DBG(buf->getBitLong()); 75 | DRW_DBG("\nunknown 1: "); DRW_DBG(buf->getBitLong()); 76 | DRW_DBG("\nunknown 2: "); DRW_DBG(buf->getBitLong()); 77 | } 78 | DRW_DBG("\n"); 79 | toDwgType(); 80 | return buf->isGood(); 81 | } 82 | 83 | void DRW_Class::write(dxfWriter *writer, DRW::Version ver){ 84 | if (ver > DRW::AC1009) { 85 | writer->writeString(0, "CLASS"); 86 | writer->writeString(1, recName); 87 | writer->writeString(2, className); 88 | writer->writeString(3, appName); 89 | writer->writeInt32(90, proxyFlag); 90 | if (ver > DRW::AC1015) { //2004+ 91 | writer->writeInt32(91, instanceCount); 92 | } 93 | writer->writeInt16(280, wasaProxyFlag); 94 | writer->writeInt16(281, entityFlag); 95 | } 96 | } 97 | 98 | void DRW_Class::toDwgType(){ 99 | if (recName == "LWPOLYLINE") 100 | dwgType = 77; 101 | else if (recName == "HATCH") 102 | dwgType = 78; 103 | else if (recName == "GROUP") 104 | dwgType = 72; 105 | /* else if (recName == "GROUP") 106 | dwgType = 72;*/ 107 | else if (recName == "LAYOUT") 108 | dwgType = 82; 109 | else if (recName == "IMAGE") 110 | dwgType = 101; 111 | else if (recName == "IMAGEDEF") 112 | dwgType = 102; 113 | else 114 | dwgType =0; 115 | } 116 | -------------------------------------------------------------------------------- /libs/clipper2/clipper.minkowski.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Author : Angus Johnson * 3 | * Date : 1 November 2023 * 4 | * Website : https://www.angusj.com * 5 | * Copyright : Angus Johnson 2010-2023 * 6 | * Purpose : Minkowski Sum and Difference * 7 | * License : https://www.boost.org/LICENSE_1_0.txt * 8 | *******************************************************************************/ 9 | 10 | #ifndef CLIPPER_MINKOWSKI_H 11 | #define CLIPPER_MINKOWSKI_H 12 | 13 | #include "clipper2/clipper.core.h" 14 | 15 | namespace Clipper2Lib 16 | { 17 | 18 | namespace detail 19 | { 20 | inline Paths64 Minkowski(const Path64& pattern, const Path64& path, bool isSum, bool isClosed) 21 | { 22 | size_t delta = isClosed ? 0 : 1; 23 | size_t patLen = pattern.size(), pathLen = path.size(); 24 | if (patLen == 0 || pathLen == 0) return Paths64(); 25 | Paths64 tmp; 26 | tmp.reserve(pathLen); 27 | 28 | if (isSum) 29 | { 30 | for (const Point64& p : path) 31 | { 32 | Path64 path2(pattern.size()); 33 | std::transform(pattern.cbegin(), pattern.cend(), 34 | path2.begin(), [p](const Point64& pt2) {return p + pt2; }); 35 | tmp.emplace_back(std::move(path2)); 36 | } 37 | } 38 | else 39 | { 40 | for (const Point64& p : path) 41 | { 42 | Path64 path2(pattern.size()); 43 | std::transform(pattern.cbegin(), pattern.cend(), 44 | path2.begin(), [p](const Point64& pt2) {return p - pt2; }); 45 | tmp.emplace_back(std::move(path2)); 46 | } 47 | } 48 | 49 | Paths64 result; 50 | result.reserve((pathLen - delta) * patLen); 51 | size_t g = isClosed ? pathLen - 1 : 0; 52 | for (size_t h = patLen - 1, i = delta; i < pathLen; ++i) 53 | { 54 | for (size_t j = 0; j < patLen; j++) 55 | { 56 | Path64 quad; 57 | quad.reserve(4); 58 | { 59 | quad.emplace_back(tmp[g][h]); 60 | quad.emplace_back(tmp[i][h]); 61 | quad.emplace_back(tmp[i][j]); 62 | quad.emplace_back(tmp[g][j]); 63 | }; 64 | if (!IsPositive(quad)) 65 | std::reverse(quad.begin(), quad.end()); 66 | result.emplace_back(std::move(quad)); 67 | h = j; 68 | } 69 | g = i; 70 | } 71 | return result; 72 | } 73 | 74 | inline Paths64 Union(const Paths64& subjects, FillRule fillrule) 75 | { 76 | Paths64 result; 77 | Clipper64 clipper; 78 | clipper.AddSubject(subjects); 79 | clipper.Execute(ClipType::Union, fillrule, result); 80 | return result; 81 | } 82 | 83 | } // namespace internal 84 | 85 | inline Paths64 MinkowskiSum(const Path64& pattern, const Path64& path, bool isClosed) 86 | { 87 | return detail::Union(detail::Minkowski(pattern, path, true, isClosed), FillRule::NonZero); 88 | } 89 | 90 | inline PathsD MinkowskiSum(const PathD& pattern, const PathD& path, bool isClosed, int decimalPlaces = 2) 91 | { 92 | int error_code = 0; 93 | double scale = pow(10, decimalPlaces); 94 | Path64 pat64 = ScalePath(pattern, scale, error_code); 95 | Path64 path64 = ScalePath(path, scale, error_code); 96 | Paths64 tmp = detail::Union(detail::Minkowski(pat64, path64, true, isClosed), FillRule::NonZero); 97 | return ScalePaths(tmp, 1 / scale, error_code); 98 | } 99 | 100 | inline Paths64 MinkowskiDiff(const Path64& pattern, const Path64& path, bool isClosed) 101 | { 102 | return detail::Union(detail::Minkowski(pattern, path, false, isClosed), FillRule::NonZero); 103 | } 104 | 105 | inline PathsD MinkowskiDiff(const PathD& pattern, const PathD& path, bool isClosed, int decimalPlaces = 2) 106 | { 107 | int error_code = 0; 108 | double scale = pow(10, decimalPlaces); 109 | Path64 pat64 = ScalePath(pattern, scale, error_code); 110 | Path64 path64 = ScalePath(path, scale, error_code); 111 | Paths64 tmp = detail::Union(detail::Minkowski(pat64, path64, false, isClosed), FillRule::NonZero); 112 | return ScalePaths(tmp, 1 / scale, error_code); 113 | } 114 | 115 | } // Clipper2Lib namespace 116 | 117 | #endif // CLIPPER_MINKOWSKI_H 118 | -------------------------------------------------------------------------------- /src/ui/DataPanel.cpp: -------------------------------------------------------------------------------- 1 | #include "ui/DataPanel.hpp" 2 | #include "./ui_DataPanel.h" 3 | #include "ui/WinUITool.hpp" 4 | 5 | 6 | DataPanel::DataPanel(QWidget *parent) 7 | : QDialog(parent), ui(new Ui::DataPanel) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | DataPanel::~DataPanel() 13 | { 14 | delete ui; 15 | } 16 | 17 | 18 | void DataPanel::load_draw_data(const Graph *graph) 19 | { 20 | size_t point_count = 0, polyline_count = 0, bezier_count = 0, bspline_count = 0, 21 | polygon_count = 0, circle_count = 0, ellipse_count = 0, text_count = 0; 22 | for (const ContainerGroup &group : *graph) 23 | { 24 | for (const Geo::Geometry *object : group) 25 | { 26 | switch (object->type()) 27 | { 28 | case Geo::Type::TEXT: 29 | ++text_count; 30 | break; 31 | case Geo::Type::POLYGON: 32 | ++polygon_count; 33 | point_count += static_cast(object)->size(); 34 | break; 35 | case Geo::Type::CIRCLE: 36 | ++circle_count; 37 | point_count += static_cast(object)->shape().size(); 38 | break; 39 | case Geo::Type::ELLIPSE: 40 | ++ellipse_count; 41 | point_count += static_cast(object)->shape().size(); 42 | break; 43 | case Geo::Type::POLYLINE: 44 | ++polyline_count; 45 | point_count += static_cast(object)->size(); 46 | break; 47 | case Geo::Type::BEZIER: 48 | ++bezier_count; 49 | point_count += static_cast(object)->shape().size(); 50 | break; 51 | case Geo::Type::BSPLINE: 52 | ++bspline_count; 53 | point_count += static_cast(object)->shape().size(); 54 | break; 55 | case Geo::Type::COMBINATION: 56 | for (Geo::Geometry *obj : *dynamic_cast(object)) 57 | { 58 | switch (obj->type()) 59 | { 60 | case Geo::Type::TEXT: 61 | ++text_count; 62 | break; 63 | case Geo::Type::POLYGON: 64 | ++polygon_count; 65 | point_count += static_cast(obj)->size(); 66 | break; 67 | case Geo::Type::CIRCLE: 68 | ++circle_count; 69 | point_count += static_cast(obj)->shape().size(); 70 | break; 71 | case Geo::Type::ELLIPSE: 72 | ++ellipse_count; 73 | point_count += static_cast(obj)->shape().size(); 74 | break; 75 | case Geo::Type::POLYLINE: 76 | ++polyline_count; 77 | point_count += static_cast(obj)->size(); 78 | break; 79 | case Geo::Type::BEZIER: 80 | ++bezier_count; 81 | point_count += static_cast(obj)->shape().size(); 82 | break; 83 | case Geo::Type::BSPLINE: 84 | ++bspline_count; 85 | point_count += static_cast(obj)->shape().size(); 86 | break; 87 | default: 88 | break; 89 | } 90 | } 91 | break; 92 | default: 93 | break; 94 | } 95 | } 96 | } 97 | 98 | ui->point_label->setText(QString::number(point_count)); 99 | ui->polyline_label->setText(QString::number(polyline_count)); 100 | ui->polygon_label->setText(QString::number(polygon_count)); 101 | ui->bezier_label->setText(QString::number(bezier_count)); 102 | ui->bspline_label->setText(QString::number(bspline_count)); 103 | ui->circle_label->setText(QString::number(circle_count)); 104 | ui->ellipse_label->setText(QString::number(ellipse_count)); 105 | ui->text_label->setText(QString::number(text_count)); 106 | 107 | const Geo::AABBRect rect(graph->bounding_rect()); 108 | ui->width_label->setText(QString::number(rect.width())); 109 | ui->height_label->setText(QString::number(rect.height())); 110 | ui->area_label->setText(QString::number(rect.area(), 'f', 4)); 111 | } 112 | 113 | int DataPanel::exec() 114 | { 115 | #ifdef _WIN64 116 | WinUITool::set_caption_color(winId(), 0x3C3C3D); 117 | #endif 118 | return QDialog::exec(); 119 | } -------------------------------------------------------------------------------- /libs/Parser/Action.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | 6 | template 7 | struct Action 8 | { 9 | std::function func; 10 | 11 | Action() {}; 12 | 13 | Action(const Action &action) 14 | : func(action.func) {}; 15 | 16 | template 17 | Action(T *s, void (T::*f)(const N &)) 18 | : func(std::bind(f, s)) {}; 19 | 20 | Action(const std::function f) 21 | : func(f) {}; 22 | 23 | inline void operator()(const N &value) const 24 | { 25 | return func(value); 26 | } 27 | 28 | Action &operator=(const std::function &f) 29 | { 30 | func = f; 31 | return *this; 32 | } 33 | 34 | operator bool() const 35 | { 36 | return bool(func); 37 | } 38 | }; 39 | 40 | template <> 41 | struct Action 42 | { 43 | std::function func; 44 | 45 | Action() {}; 46 | 47 | Action(const Action &action) 48 | : func(action.func) {}; 49 | 50 | template 51 | Action(T *s, void (T::*f)(void)) 52 | : func(std::bind(f, s)) {}; 53 | 54 | Action(const std::function f) 55 | : func(f) {}; 56 | 57 | inline void operator()() const 58 | { 59 | return func(); 60 | } 61 | 62 | Action &operator=(const std::function &f) 63 | { 64 | func = f; 65 | return *this; 66 | } 67 | 68 | operator bool() const 69 | { 70 | return bool(func); 71 | } 72 | }; 73 | 74 | template <> 75 | struct Action 76 | { 77 | std::function func; 78 | 79 | Action() {}; 80 | 81 | Action(const Action &action) 82 | : func(action.func) {}; 83 | 84 | template 85 | Action(T *s, void (T::*f)(const std::string &)) 86 | : func(std::bind(f, s, std::placeholders::_1)) {}; 87 | 88 | Action(const std::function f) 89 | : func(f) {}; 90 | 91 | inline void operator()(const std::string &value) const 92 | { 93 | return func(value); 94 | } 95 | 96 | Action &operator=(const std::function &f) 97 | { 98 | func = f; 99 | return *this; 100 | } 101 | 102 | operator bool() const 103 | { 104 | return bool(func); 105 | } 106 | }; 107 | 108 | template <> 109 | struct Action 110 | { 111 | std::function func; 112 | 113 | Action() {}; 114 | 115 | Action(const Action &action) 116 | : func(action.func) {}; 117 | 118 | template 119 | Action(T *s, void (T::*f)(const char)) 120 | : func(std::bind(f, s, std::placeholders::_1)) {}; 121 | 122 | Action(const std::function f) 123 | : func(f) {}; 124 | 125 | inline void operator()(const char value) const 126 | { 127 | return func(value); 128 | } 129 | 130 | Action &operator=(const std::function &f) 131 | { 132 | func = f; 133 | return *this; 134 | } 135 | 136 | operator bool() const 137 | { 138 | return bool(func); 139 | } 140 | }; 141 | 142 | template <> 143 | struct Action 144 | { 145 | std::function func; 146 | 147 | Action() {}; 148 | 149 | Action(const Action &action) 150 | : func(action.func) {}; 151 | 152 | template 153 | Action(T *s, void (T::*f)(const double)) 154 | : func(std::bind(f, s, std::placeholders::_1)) {}; 155 | 156 | Action(const std::function f) 157 | : func(f) {}; 158 | 159 | inline void operator()(const double value) const 160 | { 161 | return func(value); 162 | } 163 | 164 | Action &operator=(const std::function &f) 165 | { 166 | func = f; 167 | return *this; 168 | } 169 | 170 | operator bool() const 171 | { 172 | return bool(func); 173 | } 174 | }; 175 | 176 | template <> 177 | struct Action 178 | { 179 | std::function func; 180 | 181 | Action() {}; 182 | 183 | Action(const Action &action) 184 | : func(action.func) {}; 185 | 186 | template 187 | Action(T *s, void (T::*f)(const int)) 188 | : func(std::bind(f, s, std::placeholders::_1)) {}; 189 | 190 | Action(const std::function f) 191 | : func(f) {}; 192 | 193 | inline void operator()(const int value) const 194 | { 195 | return func(value); 196 | } 197 | 198 | Action &operator=(const std::function &f) 199 | { 200 | func = f; 201 | return *this; 202 | } 203 | 204 | operator bool() const 205 | { 206 | return bool(func); 207 | } 208 | }; -------------------------------------------------------------------------------- /libs/libdxfrw/intern/drw_dbg.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** libDXFrw - Library to read/write DXF files (ascii & binary) ** 3 | ** ** 4 | ** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com ** 5 | ** ** 6 | ** This library is free software, licensed under the terms of the GNU ** 7 | ** General Public License as published by the Free Software Foundation, ** 8 | ** either version 2 of the License, or (at your option) any later version. ** 9 | ** You should have received a copy of the GNU General Public License ** 10 | ** along with this program. If not, see . ** 11 | ******************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include "drw_dbg.h" 16 | 17 | DRW_dbg *DRW_dbg::instance= NULL; 18 | 19 | /*********private clases*************/ 20 | class print_none { 21 | public: 22 | virtual void printS(std::string s){(void)s;} 23 | virtual void printI(long long int i){(void)i;} 24 | virtual void printUI(long long unsigned int i){(void)i;} 25 | virtual void printD(double d){(void)d;} 26 | virtual void printH(long long int i){(void)i;} 27 | virtual void printB(int i){(void)i;} 28 | virtual void printHL(int c, int s, int h){(void)c;(void)s;(void)h;} 29 | virtual void printPT(double x, double y, double z){(void)x;(void)y;(void)z;} 30 | print_none(){} 31 | virtual ~print_none(){} 32 | }; 33 | 34 | class print_debug : public print_none { 35 | public: 36 | virtual void printS(std::string s); 37 | virtual void printI(long long int i); 38 | virtual void printUI(long long unsigned int i); 39 | virtual void printD(double d); 40 | virtual void printH(long long int i); 41 | virtual void printB(int i); 42 | virtual void printHL(int c, int s, int h); 43 | virtual void printPT(double x, double y, double z); 44 | print_debug(); 45 | virtual ~print_debug(){} 46 | private: 47 | std::ios_base::fmtflags flags; 48 | }; 49 | 50 | /********* debug class *************/ 51 | DRW_dbg *DRW_dbg::getInstance(){ 52 | if (instance == NULL){ 53 | instance = new DRW_dbg; 54 | } 55 | return instance; 56 | } 57 | 58 | DRW_dbg::DRW_dbg(){ 59 | level = NONE; 60 | prClass = new print_none; 61 | flags = std::cerr.flags(); 62 | } 63 | 64 | void DRW_dbg::setLevel(LEVEL lvl){ 65 | level = lvl; 66 | delete prClass; 67 | switch (level){ 68 | case DEBUG: 69 | prClass = new print_debug; 70 | break; 71 | default: 72 | prClass = new print_none; 73 | } 74 | } 75 | 76 | DRW_dbg::LEVEL DRW_dbg::getLevel(){ 77 | return level; 78 | } 79 | 80 | void DRW_dbg::print(std::string s){ 81 | prClass->printS(s); 82 | } 83 | 84 | void DRW_dbg::print(int i){ 85 | prClass->printI(i); 86 | } 87 | 88 | void DRW_dbg::print(unsigned int i){ 89 | prClass->printUI(i); 90 | } 91 | 92 | void DRW_dbg::print(long long int i){ 93 | prClass->printI(i); 94 | } 95 | 96 | void DRW_dbg::print(long unsigned int i){ 97 | prClass->printUI(i); 98 | } 99 | 100 | void DRW_dbg::print(long long unsigned int i){ 101 | prClass->printUI(i); 102 | } 103 | 104 | void DRW_dbg::print(double d){ 105 | prClass->printD(d); 106 | } 107 | 108 | void DRW_dbg::printH(long long int i){ 109 | prClass->printH(i); 110 | } 111 | 112 | void DRW_dbg::printB(int i){ 113 | prClass->printB(i); 114 | } 115 | void DRW_dbg::printHL(int c, int s, int h){ 116 | prClass->printHL(c, s, h); 117 | } 118 | 119 | void DRW_dbg::printPT(double x, double y, double z){ 120 | prClass->printPT(x, y, z); 121 | } 122 | 123 | print_debug::print_debug(){ 124 | flags = std::cerr.flags(); 125 | } 126 | 127 | void print_debug::printS(std::string s){ 128 | std::cerr << s; 129 | } 130 | 131 | void print_debug::printI(long long int i){ 132 | std::cerr << i; 133 | } 134 | 135 | void print_debug::printUI(long long unsigned int i){ 136 | std::cerr << i; 137 | } 138 | 139 | void print_debug::printD(double d){ 140 | std::cerr << std::fixed << d; 141 | } 142 | 143 | void print_debug::printH(long long i){ 144 | std::cerr << "0x" << std::setw(2) << std::setfill('0'); 145 | std::cerr << std::hex << i; 146 | std::cerr.flags(flags); 147 | } 148 | 149 | void print_debug::printB(int i){ 150 | std::cerr << std::setw(8) << std::setfill('0'); 151 | std::cerr << std::setbase(2) << i; 152 | std::cerr.flags(flags); 153 | } 154 | 155 | void print_debug::printHL(int c, int s, int h){ 156 | std::cerr << c << '.' << s << '.'; 157 | std::cerr << "0x" << std::setw(2) << std::setfill('0'); 158 | std::cerr << std::hex << h; 159 | std::cerr.flags(flags); 160 | } 161 | 162 | void print_debug::printPT(double x, double y, double z){ 163 | std::cerr << std::fixed << "x: " << x << ", y: " << y << ", z: "<< z; 164 | } 165 | --------------------------------------------------------------------------------