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);
}
" 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);
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);