Raise an error message box on ascii stl
This commit is contained in:
parent
236a203320
commit
428aff52a5
4 changed files with 22 additions and 4 deletions
|
@ -8,10 +8,16 @@ Loader::Loader(QObject* parent, const QString& filename)
|
|||
|
||||
void Loader::run()
|
||||
{
|
||||
QTime timer;
|
||||
timer.start();
|
||||
emit got_mesh(Mesh::load_stl(filename));
|
||||
qDebug() << "Time taken:" << timer.elapsed();
|
||||
{ // Verify that this isn't an ascii stl file
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (file.read(5) == "solid")
|
||||
{
|
||||
emit error_ascii_stl();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
emit got_mesh(Mesh::load_stl(filename));
|
||||
emit loaded_file(filename);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
signals:
|
||||
void loaded_file(QString filename);
|
||||
void got_mesh(Mesh* m);
|
||||
void error_ascii_stl();
|
||||
|
||||
private:
|
||||
const QString filename;
|
||||
|
|
|
@ -69,6 +69,14 @@ void Window::on_about()
|
|||
" style=\"color: #93a1a1;\">matt.j.keeter@gmail.com</a></p>");
|
||||
}
|
||||
|
||||
void Window::on_ascii_stl()
|
||||
{
|
||||
QMessageBox::critical(this, "Error",
|
||||
"<b>Error:</b><br>"
|
||||
"Cannot open ASCII <code>.stl</code> file<br>"
|
||||
"Please convert to binary <code>.stl</code> and retry");
|
||||
}
|
||||
|
||||
void Window::enable_open()
|
||||
{
|
||||
open_action->setEnabled(true);
|
||||
|
@ -91,6 +99,8 @@ bool Window::load_stl(const QString& filename)
|
|||
|
||||
connect(loader, &Loader::got_mesh,
|
||||
canvas, &Canvas::load_mesh);
|
||||
connect(loader, &Loader::error_ascii_stl,
|
||||
this, &Window::on_ascii_stl);
|
||||
|
||||
connect(loader, &Loader::finished,
|
||||
loader, &Loader::deleteLater);
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
public slots:
|
||||
void on_open();
|
||||
void on_about();
|
||||
void on_ascii_stl();
|
||||
|
||||
void enable_open();
|
||||
void disable_open();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue