DicomViewer (添加模型类)3

背景

上一篇新建了目录,这一篇读取dcm文件,先从模型开始。

.h 也加入到SRC

diff 复制代码
ubuntu@LAPTOP-IAHSQH9B:~/xcyxiner/DicomViewer$ git diff HEAD gen_src.py

diff --git a/gen_src.py b/gen_src.py
index 974a548..86dfdb5 100644
--- a/gen_src.py
+++ b/gen_src.py
@@ -3,7 +3,7 @@ import os
 src = []
 for root, _, files in os.walk("source"):
     for f in files:
-        if f.endswith(".cpp"):
+        if f.endswith((".cpp",".h")):
             src.append(os.path.join(root, f))

 with open("source_list.cmake", "w") as f:

新的生成工具

之前的生成的是基于QT对象的,现在需要纯c对象的。

新增new_c_class.py

ini 复制代码
#!/usr/bin/env python3
import sys
import pathlib

CLASS_NAME = sys.argv[1]

HEADER = f"""
#pragma once

class {CLASS_NAME}
{{
public:
    explicit {CLASS_NAME}();
    ~{CLASS_NAME}()=default;
}};
"""

CPP = f"""
#include "{CLASS_NAME}.h"

{CLASS_NAME}::{CLASS_NAME}()
{{
}}
"""

pathlib.Path(f"{CLASS_NAME}.h").write_text(HEADER)
pathlib.Path(f"{CLASS_NAME}.cpp").write_text(CPP)

print(f"✅ Generated {CLASS_NAME}.h / {CLASS_NAME}.cpp")

更新dcmtk的类库链接 以及包含头文件

makefile 复制代码
target_include_directories(DicomViewer_exe PRIVATE
/opt/dcmtk/include
)

  
DCMTK::ofstd
DCMTK::oflog
DCMTK::dcmdata
DCMTK::dcmimgle
DCMTK::dcmimage
DCMTK::dcmjpeg
DCMTK::dcmnet
DCMTK::dcmsr

更新.clangd

arduino 复制代码
- "-I/opt/dcmtk/include"

添加依赖的时候好找一点

新建文件

使用new_c_class.py创建模型和控制类 使用new_qt_object.py创建文件导入类

bash 复制代码
python ~/xcyxiner/DicomViewer/tools/new_c_class.py Patient
python ~/xcyxiner/DicomViewer/tools/new_c_class.py Study
python ~/xcyxiner/DicomViewer/tools/new_c_class.py Series
python ~/xcyxiner/DicomViewer/tools/new_c_class.py Image
python ~/xcyxiner/DicomViewer/tools/new_c_class.py DicomReader
python ~/xcyxiner/DicomViewer/tools/new_c_class.py CoreRepository
python ~/xcyxiner/DicomViewer/tools/new_c_class.py CoreController
python ~/xcyxiner/DicomViewer/tools/new_qt_object.py FilesImporter QThread
css 复制代码
.
├── core
│   ├── controller
│   │   ├── CoreController.cpp
│   │   └── CoreController.h
│   ├── lib
│   │   ├── DicomReader.cpp
│   │   └── DicomReader.h
│   └── model
│       ├── CoreRepository.cpp
│       ├── CoreRepository.h
│       ├── Image.cpp
│       ├── Image.h
│       ├── Patient.cpp
│       ├── Patient.h
│       ├── Series.cpp
│       ├── Series.h
│       ├── Study.cpp
│       └── Study.h
├── gui
│   ├── GUICenter.cpp
│   └── GUICenter.h
├── lib
│   ├── FilesImporter.cpp
│   └── FilesImporter.h
├── main.cpp
├── menu
│   ├── FileMenu.cpp
│   └── FileMenu.h
└── window
    ├── GUIWindow.cpp
    └── GUIWindow.h

9 directories, 23 files

QThread 不能使用QWidget,改为parent类型为QObject,需要修改.h和.cpp

arduino 复制代码
#include "FilesImporter.h"

#include "qglobal.h"
#include "qobject.h"

FilesImporter::FilesImporter(QObject* parent)
    : QThread(Q_NULLPTR)
{
}

#pragma once
#include <QThread>

#include "qobject.h"

class FilesImporter : public QThread
{
  Q_OBJECT
public:
  explicit FilesImporter(QObject* parent = nullptr);
};

编译测试没问题先提交

添加模型类以及控制器

未完待续

相关推荐
秋田君1 天前
QT_网络编程体系
网络·arm开发·qt
Quz1 天前
QML TextArea 实战(下):大文本加载与性能优化
qt
Quz1 天前
QML TextArea 实战(中):Markdown 渲染与保持滚动
qt
C++ 老炮儿的技术栈2 天前
基于Qt实现轻量化本地音乐播放器
开发语言·c++·qt·c·播放器·音乐
我不是疯子是傻子2 天前
Qt 实时曲线卡顿优化:从QPainter到OpenGL的3级加速实战
开发语言·qt
秋田君2 天前
QT_XML文件操作
xml·数据库·qt
我不是疯子是傻子2 天前
串口通信数据帧粘包拆包再进化:基于 Qt 的滑动窗口与 CRC 校验实战
开发语言·qt
程序员老陆2 天前
Qt中实现窗口真全屏(覆盖Windows任务栏)
开发语言·windows·qt
CodeKwang2 天前
【三维TSP可视化】1000个点以内的最优路径:最近邻 + 2-opt + 3-opt 组合算法实战(Qt实现)
qt·算法
艾莉丝努力练剑2 天前
【QT:解决问题】Qt5Core.dll:无法定位程序输入点
java·开发语言·qt·学习·面试