Skip to content

Commit

Permalink
extract getSelectedObjects()
Browse files Browse the repository at this point in the history
  • Loading branch information
HeiJuli authored and endJunction committed Oct 9, 2023
1 parent 2fb9389 commit 7036941
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 50 deletions.
2 changes: 2 additions & 0 deletions Applications/DataExplorer/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Source files
set(SOURCES
Utils.cpp
OGSError.cpp
QNonScalableGraphicsTextItem.cpp
RecentFiles.cpp
Expand All @@ -14,6 +15,7 @@ set(SOURCES
# Header files
set(HEADERS
LastSavedFileDirectory.h
Utils.h
OGSError.h
QNonScalableGraphicsTextItem.h
TreeItem.h
Expand Down
22 changes: 22 additions & 0 deletions Applications/DataExplorer/Base/Utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/

#include "Base/Utils.h"

namespace Utils
{
std::vector<std::string> getSelectedObjects(QStringList const& list)
{
std::vector<std::string> indexList;
std::transform(list.begin(), list.end(), std::back_inserter(indexList),
[](auto const& index) { return index.toStdString(); });
return indexList;
}
} // namespace Utils
18 changes: 18 additions & 0 deletions Applications/DataExplorer/Base/Utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* \file
* \copyright
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/

#include <QStringList>
#include <string>
#include <vector>

namespace Utils
{
std::vector<std::string> getSelectedObjects(QStringList const& list);
}
14 changes: 2 additions & 12 deletions Applications/DataExplorer/DataView/AddFaultsToVoxelGridDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,11 @@
#include <string>

#include "Base/OGSError.h"
#include "Base/Utils.h"
#include "MeshLib/Mesh.h"
#include "MeshModel.h"
#include "MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.h"

namespace
{
std::vector<std::string> getSelectedObjects(QStringList const& list)
{
std::vector<std::string> indexList;
std::transform(list.begin(), list.end(), std::back_inserter(indexList),
[](auto const& index) { return index.toStdString(); });
return indexList;
}
} // namespace

QString no_voxel_str = "[No voxel grid available.]";

AddFaultsToVoxelGridDialog::AddFaultsToVoxelGridDialog(MeshModel& mesh_model,
Expand Down Expand Up @@ -131,7 +121,7 @@ void AddFaultsToVoxelGridDialog::accept()
}

std::vector<std::string> const selected_faults =
getSelectedObjects(_selFaults.stringList());
Utils::getSelectedObjects(_selFaults.stringList());

if (this->_selFaults.rowCount() == 0)
{
Expand Down
13 changes: 3 additions & 10 deletions Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Base/OGSError.h"
#include "Base/StrictDoubleValidator.h"
#include "Base/StrictIntValidator.h"
#include "Base/Utils.h"
#include "GMSHPrefsDialog.h"
#include "GeoLib/GEOObjects.h"

Expand Down Expand Up @@ -147,7 +148,7 @@ void GMSHPrefsDialog::accept()
}

std::vector<std::string> selectedObjects =
this->getSelectedObjects(_selGeo->stringList());
Utils::getSelectedObjects(_selGeo->stringList());
unsigned max_number_of_points_in_quadtree_leaf(10);
double mesh_density_scaling_pnts(0.5);
double mesh_density_scaling_stations(0.05);
Expand Down Expand Up @@ -191,12 +192,4 @@ void GMSHPrefsDialog::accept()
void GMSHPrefsDialog::reject()
{
this->done(QDialog::Rejected);
}

std::vector<std::string> GMSHPrefsDialog::getSelectedObjects(QStringList list)
{
std::vector<std::string> indexList;
std::transform(list.begin(), list.end(), std::back_inserter(indexList),
[](auto const& index) { return index.toStdString(); });
return indexList;
}
}
16 changes: 3 additions & 13 deletions Applications/DataExplorer/DataView/Layers2GridDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,14 @@
#include <QStringListModel>

#include "Base/StrictDoubleValidator.h"
#include "Base/Utils.h"
#include "GeoLib/AABB.h"
#include "MeshLib/IO/writeMeshToFile.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"
#include "MeshModel.h"
#include "MeshToolsLib/MeshGenerators/VoxelGridFromLayeredMeshes.h"

namespace
{
std::vector<std::string> getSelectedObjects(QStringList const& list)
{
std::vector<std::string> indexList;
std::transform(list.begin(), list.end(), std::back_inserter(indexList),
[](auto const& index) { return index.toStdString(); });
return indexList;
}
} // namespace

Layers2GridDialog::Layers2GridDialog(MeshModel& mesh_model, QDialog* parent)
: QDialog(parent), _mesh_model(mesh_model)
{
Expand Down Expand Up @@ -127,7 +117,7 @@ void Layers2GridDialog::updateExpectedVoxel()
}

std::vector<std::string> layered_meshes =
getSelectedObjects(_layeredMeshes.stringList());
Utils::getSelectedObjects(_layeredMeshes.stringList());
auto* const mesh_top = _mesh_model.getMesh(layered_meshes.front());
auto* const mesh_bottom = _mesh_model.getMesh(layered_meshes.back());
auto const& nodes_top = mesh_top->getNodes();
Expand Down Expand Up @@ -194,7 +184,7 @@ void Layers2GridDialog::accept()
double const zinput = (zin.toDouble(&ok)) ? zin.toDouble() : xin.toDouble();

std::vector<std::string> layered_meshes =
getSelectedObjects(_layeredMeshes.stringList());
Utils::getSelectedObjects(_layeredMeshes.stringList());

std::vector<const MeshLib::Mesh*> layers;
layers.reserve(layered_meshes.size());
Expand Down
15 changes: 2 additions & 13 deletions Applications/DataExplorer/DataView/TranslateDataDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,14 @@
#include <QStringList>

#include "Base/StrictDoubleValidator.h"
#include "Base/Utils.h"
#include "GEOModels.h"
#include "GeoLib/AABB.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"
#include "MeshModel.h"
#include "MeshToolsLib/MeshEditing/moveMeshNodes.h"

namespace
{
std::vector<std::string> getSelectedObjects(
QStringList const& list)
{
std::vector<std::string> indexList;
std::transform(list.begin(), list.end(), std::back_inserter(indexList),
[](auto const& index) { return index.toStdString(); });
return indexList;
}
} // namespace

TranslateDataDialog::TranslateDataDialog(MeshModel* mesh_model,
GEOModels* geo_models,
QDialog* parent)
Expand Down Expand Up @@ -163,7 +152,7 @@ void TranslateDataDialog::accept()
displacement[2]);

std::vector<std::string> const selectedData =
getSelectedObjects(_selData.stringList());
Utils::getSelectedObjects(_selData.stringList());

auto const geoNames = _geo_models->getGeometryNames();

Expand Down
4 changes: 2 additions & 2 deletions MeshToolsLib/MeshGenerators/AddFaultToVoxelGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ bool isVoxelGrid(MeshLib::Mesh const& mesh)
return false;
}
return true;
} // namespace
} // namespace
}
} // namespace MeshToolsLib::MeshGenerator::AddFaultToVoxelGrid
namespace MeshToolsLib::MeshGenerator::AddFaultToVoxelGrid
{
bool addFaultToVoxelGrid(MeshLib::Mesh* mesh,
Expand Down

0 comments on commit 7036941

Please sign in to comment.