diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index 850e433f7a3441cd127add716e235faa1d5a414d..0317c46e662ae34256a2b294d372ac14ffaeaea8 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -22,6 +22,7 @@ #include <QFileDialog> #include <QMessageBox> #include <QObject> +#include <QScreen> #include <QSettings> #include <QSignalMapper> #ifndef NDEBUG @@ -306,12 +307,9 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) : QMainWindow(parent) // Get info on screens geometry(ies) _vtkWidget.reset(visualizationWidget->vtkWidget); - QDesktopWidget* desktopWidget = QApplication::desktop(); - const unsigned int screenCount = desktopWidget->screenCount(); - for (std::size_t i = 0; i < screenCount; ++i) + for (auto const& screen : QGuiApplication::screens()) { - _screenGeometries.push_back( - desktopWidget->availableGeometry(static_cast<int>(i))); + _screenGeometries.push_back(screen->availableGeometry()); } // Setup import files menu @@ -839,48 +837,33 @@ void MainWindow::about() QMenu* MainWindow::createImportFilesMenu() { - auto* signal_mapper = new QSignalMapper(this); // owned by MainWindow QMenu* importFiles = new QMenu("&Import Files", this); - QAction* feflowFiles = importFiles->addAction("&FEFLOW Files..."); - connect(feflowFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(feflowFiles, ImportFileType::FEFLOW); - QAction* gmsFiles = importFiles->addAction("G&MS Files..."); - connect(gmsFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(gmsFiles, ImportFileType::GMS); - QAction* gmshFiles = importFiles->addAction("&GMSH Files..."); - connect(gmshFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(gmshFiles, ImportFileType::GMSH); - QAction* gocadTsFiles = importFiles->addAction("&Gocad TSurface..."); - connect(gocadTsFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(gocadTsFiles, ImportFileType::GOCAD_TSURF); + importFiles->addAction("&FEFLOW Files...", + [=] { open(ImportFileType::FEFLOW); }); + importFiles->addAction("G&MS Files...", + [=] { open(ImportFileType::GMS); }); + importFiles->addAction("&GMSH Files...", + [=] { open(ImportFileType::GMSH); }); + importFiles->addAction("&Gocad TSurface...", + [=] { open(ImportFileType::GOCAD_TSURF); }); #ifdef OGS_USE_NETCDF - QAction* netcdfFiles = importFiles->addAction("&NetCDF Files..."); - connect(netcdfFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(netcdfFiles, ImportFileType::NETCDF); + importFiles->addAction("&NetCDF Files...", + [=] { open(ImportFileType::NETCDF); }); #endif // OGS_USE_NETCDF - QAction* petrelFiles = importFiles->addAction("&Petrel Files..."); - connect(petrelFiles, SIGNAL(triggered()), this, SLOT(loadPetrelFiles())); - QAction* rasterFiles = importFiles->addAction("&Raster Files..."); - connect(rasterFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(rasterFiles, ImportFileType::RASTER); + importFiles->addAction("&Petrel Files...", + [=] { loadPetrelFiles(); }); + importFiles->addAction("&Raster Files...", + [=] { open(ImportFileType::RASTER); }); #if defined VTKFBXCONVERTER_FOUND - QAction* rasterPolyFiles = importFiles->addAction("R&aster Files as PolyData..."); - connect(rasterPolyFiles, SIGNAL(triggered()), this, SLOT(map())); - _signal_mapper->setMapping(rasterPolyFiles, ImportFileType::POLYRASTER); + importFiles->addAction("R&aster Files as PolyData...", + [=] { open(ImportFileType::POLYRASTER); }); #endif - QAction* shapeFiles = importFiles->addAction("&Shape Files..."); - connect(shapeFiles, SIGNAL(triggered()), signal_mapper, SLOT(map())); - signal_mapper->setMapping(shapeFiles, ImportFileType::SHAPE); - QAction* tetgenFiles = importFiles->addAction("&TetGen Files..."); - connect( tetgenFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()) ); - signal_mapper->setMapping(tetgenFiles, ImportFileType::TETGEN); - - QAction* vtkFiles = importFiles->addAction("&VTK Files..."); - connect( vtkFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()) ); - signal_mapper->setMapping(vtkFiles, ImportFileType::VTK); - - connect(signal_mapper, SIGNAL(mapped(int)), this, SLOT(open(int))); - + importFiles->addAction("&Shape Files...", + [=] { open(ImportFileType::SHAPE); }); + importFiles->addAction("&TetGen Files...", + [=] { open(ImportFileType::TETGEN); }); + importFiles->addAction("&VTK Files...", + [=] { open(ImportFileType::VTK); }); return importFiles; } @@ -1107,6 +1090,10 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, fname = fname.substr(0, pos); } gmsh_command += " -o " + fname + ".msh"; + // Newer gmsh versions write a newer file format for meshes + // per default. At the moment we can't read this new format. + // This is a switch for gmsh to write the 'old' file format. + gmsh_command += " -format msh22"; auto const return_value = std::system(gmsh_command.c_str()); if (return_value != 0) { diff --git a/Applications/FileIO/Legacy/createSurface.cpp b/Applications/FileIO/Legacy/createSurface.cpp index 79ffd930734743c8f402f188cef7a81ece13e918..68f778734336433298d95f1d97f93c3d1ca4fbc0 100644 --- a/Applications/FileIO/Legacy/createSurface.cpp +++ b/Applications/FileIO/Legacy/createSurface.cpp @@ -87,6 +87,10 @@ bool createSurface(GeoLib::Polyline const& ply, std::string gmsh_command = gmsh_binary + " -2 -algo meshadapt \"" + file_base_name + ".geo\""; gmsh_command += " -o \"" + file_base_name + ".msh\""; + // Newer gmsh versions write a newer file format for meshes per default. At + // the moment we can't read this new format. This is a switch for gmsh to + // write the 'old' file format. + gmsh_command += " -format msh22"; int const gmsh_return_value = std::system(gmsh_command.c_str()); if (gmsh_return_value != 0) { diff --git a/MeshLib/MeshEditing/RemoveMeshComponents.cpp b/MeshLib/MeshEditing/RemoveMeshComponents.cpp index 3d2d7b99388c99190c7592044ca6189efd969136..88e93361e3a44628e7fcdf58a33995b2d3465e52 100644 --- a/MeshLib/MeshEditing/RemoveMeshComponents.cpp +++ b/MeshLib/MeshEditing/RemoveMeshComponents.cpp @@ -18,17 +18,16 @@ namespace MeshLib { - namespace details { - std::vector<MeshLib::Element*> excludeElementCopy( std::vector<MeshLib::Element*> const& vec_src_eles, std::vector<std::size_t> const& vec_removed) { - std::vector<MeshLib::Element*> vec_dest_eles(vec_src_eles.size()-vec_removed.size()); + std::vector<MeshLib::Element*> vec_dest_eles(vec_src_eles.size() - + vec_removed.size()); - unsigned cnt (0); + unsigned cnt(0); for (std::size_t i = 0; i < vec_removed[0]; ++i) { vec_dest_eles[cnt++] = vec_src_eles[i]; @@ -50,7 +49,10 @@ std::vector<MeshLib::Element*> excludeElementCopy( } // namespace details -MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, const std::vector<std::size_t> &removed_element_ids, const std::string &new_mesh_name) +MeshLib::Mesh* removeElements( + const MeshLib::Mesh& mesh, + const std::vector<std::size_t>& removed_element_ids, + const std::string& new_mesh_name) { if (removed_element_ids.empty()) { @@ -59,27 +61,28 @@ MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, const std::vector<std:: } INFO("Removing total %d elements...", removed_element_ids.size()); - std::vector<MeshLib::Element*> tmp_elems = details::excludeElementCopy( - mesh.getElements(), - removed_element_ids - ); + std::vector<MeshLib::Element*> tmp_elems = + details::excludeElementCopy(mesh.getElements(), removed_element_ids); INFO("%d elements remain in mesh.", tmp_elems.size()); // copy node and element objects - std::vector<MeshLib::Node*> new_nodes = MeshLib::copyNodeVector(mesh.getNodes()); - std::vector<MeshLib::Element*> new_elems = MeshLib::copyElementVector(tmp_elems, new_nodes); + std::vector<MeshLib::Node*> new_nodes = + MeshLib::copyNodeVector(mesh.getNodes()); + std::vector<MeshLib::Element*> new_elems = + MeshLib::copyElementVector(tmp_elems, new_nodes); // delete unused nodes NodeSearch ns(mesh); ns.searchNodesConnectedToOnlyGivenElements(removed_element_ids); - auto &removed_node_ids(ns.getSearchedNodeIDs()); + auto& removed_node_ids(ns.getSearchedNodeIDs()); INFO("Removing total %d nodes...", removed_node_ids.size()); for (auto nodeid : removed_node_ids) { delete new_nodes[nodeid]; new_nodes[nodeid] = nullptr; } - new_nodes.erase(std::remove(new_nodes.begin(), new_nodes.end(), nullptr), new_nodes.end()); + new_nodes.erase(std::remove(new_nodes.begin(), new_nodes.end(), nullptr), + new_nodes.end()); if (!new_elems.empty()) { @@ -94,7 +97,9 @@ MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, const std::vector<std:: return nullptr; } -MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::size_t> &del_nodes_idx, const std::string &new_mesh_name) +MeshLib::Mesh* removeNodes(const MeshLib::Mesh& mesh, + const std::vector<std::size_t>& del_nodes_idx, + const std::string& new_mesh_name) { if (del_nodes_idx.empty()) { @@ -102,8 +107,10 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz } // copy node and element objects - std::vector<MeshLib::Node*> new_nodes = MeshLib::copyNodeVector(mesh.getNodes()); - std::vector<MeshLib::Element*> new_elems = MeshLib::copyElementVector(mesh.getElements(), new_nodes); + std::vector<MeshLib::Node*> new_nodes = + MeshLib::copyNodeVector(mesh.getNodes()); + std::vector<MeshLib::Element*> new_elems = + MeshLib::copyElementVector(mesh.getElements(), new_nodes); // delete elements MeshLib::ElementSearch es(mesh); @@ -114,11 +121,13 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz delete new_elems[eid]; new_elems[eid] = nullptr; } - new_elems.erase(std::remove(new_elems.begin(), new_elems.end(), nullptr), new_elems.end()); + new_elems.erase(std::remove(new_elems.begin(), new_elems.end(), nullptr), + new_elems.end()); // check unused nodes due to element deletion std::vector<bool> node_delete_flag(new_nodes.size(), true); - for (auto e : new_elems) { + for (auto e : new_elems) + { for (unsigned i = 0; i < e->getNumberOfNodes(); i++) { node_delete_flag[e->getNodeIndex(i)] = false; @@ -126,7 +135,7 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz } // delete unused nodes - for (std::size_t i=0; i<new_nodes.size(); i++) + for (std::size_t i = 0; i < new_nodes.size(); i++) { if (!node_delete_flag[i]) { @@ -135,7 +144,8 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz delete new_nodes[i]; new_nodes[i] = nullptr; } - new_nodes.erase(std::remove(new_nodes.begin(), new_nodes.end(), nullptr), new_nodes.end()); + new_nodes.erase(std::remove(new_nodes.begin(), new_nodes.end(), nullptr), + new_nodes.end()); if (!new_elems.empty()) { @@ -148,5 +158,5 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz return nullptr; } -} // end namespace MeshLib +} // end namespace MeshLib diff --git a/MeshLib/MeshEditing/RemoveMeshComponents.h b/MeshLib/MeshEditing/RemoveMeshComponents.h index 5a36429a98de40c99bed4dd67cf558d334b471a8..4641dd67d3fe55bb94521ed3e77c57a26c082764 100644 --- a/MeshLib/MeshEditing/RemoveMeshComponents.h +++ b/MeshLib/MeshEditing/RemoveMeshComponents.h @@ -25,8 +25,10 @@ class Element; * @param new_mesh_name a new mesh name * @return a new mesh object */ -MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, - const std::vector<std::size_t> &removed_element_ids, const std::string &new_mesh_name); +MeshLib::Mesh* removeElements( + const MeshLib::Mesh& mesh, + const std::vector<std::size_t>& removed_element_ids, + const std::string& new_mesh_name); /** * Removes the mesh nodes (and connected elements) given in the nodes-list from