-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlowStone2-MainWindow.cpp
More file actions
42 lines (36 loc) · 1.25 KB
/
Copy pathFlowStone2-MainWindow.cpp
File metadata and controls
42 lines (36 loc) · 1.25 KB
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
42
// FlowStone2-MainWindow.cpp
#include "FlowStone2-MainWindow.h"
#include "ModelHandler.h"
#include <QFileDialog>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
FlowStone2MainWindow::FlowStone2MainWindow(QWidget* parent)
: QMainWindow(parent) {
// 创建UI控件
QWidget* centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
QVBoxLayout* layout = new QVBoxLayout(centralWidget);
QPushButton* loadButton = new QPushButton("Load Model", this);
layout->addWidget(loadButton);
connect(loadButton, &QPushButton::clicked, this, &FlowStone2MainWindow::onLoadModelClicked);
}
// 文件加载槽函数
void FlowStone2MainWindow::onLoadModelClicked() {
// 选择文件
QString filePath = QFileDialog::getOpenFileName(this, "Open Model", "", "STL Files (*.stl);;STEP Files (*.step)");
if (filePath.isEmpty()) {
return;
}
ModelHandler modelHandler;
if (filePath.endsWith(".stl", Qt::CaseInsensitive)) {
modelHandler.loadSTLModel(filePath, this);
}
else if (filePath.endsWith(".step", Qt::CaseInsensitive)) {
modelHandler.loadSTEPModel(filePath, this);
}
else {
// 不支持的文件格式
QMessageBox::warning(this, "Error", "Unsupported file format.");
}
}