From f086660b24c3d3b4e8416e583d68b62b81c669dd Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Fri, 2 Apr 2021 20:05:49 +0200 Subject: [PATCH] clang-format Applications/DataExplorer --- .../DataExplorer/Base/CheckboxDelegate.cpp | 30 +- .../Base/ColorPickerPushButton.cpp | 10 +- Applications/DataExplorer/Base/OGSError.cpp | 7 +- .../Base/QNonScalableGraphicsTextItem.cpp | 17 +- .../DataExplorer/Base/QValueTooltipSlider.cpp | 3 +- .../DataExplorer/Base/RecentFiles.cpp | 4 +- Applications/DataExplorer/Base/TreeItem.cpp | 9 +- Applications/DataExplorer/Base/TreeModel.cpp | 73 +-- .../DataExplorer/Base/TreeModelIterator.cpp | 6 +- Applications/DataExplorer/Base/modeltest.cpp | 184 ++++--- .../DataView/AddLayerToMeshDialog.cpp | 8 +- .../DataExplorer/DataView/ColorTableModel.cpp | 39 +- .../DataExplorer/DataView/ColorTableView.cpp | 11 +- .../DataView/CondFromRasterDialog.cpp | 27 +- .../DataView/CreateStructuredGridDialog.cpp | 69 +-- .../DataView/DataExplorerSettingsDialog.cpp | 16 +- .../DataView/DiagramView/DetailWindow.cpp | 98 ++-- .../DataView/DiagramView/DiagramList.cpp | 55 +- .../DiagramView/DiagramPrefsDialog.cpp | 37 +- .../DataView/DiagramView/DiagramScene.cpp | 77 +-- .../DataView/DiagramView/DiagramView.cpp | 17 +- .../DataView/DiagramView/QArrow.cpp | 51 +- .../DataView/DiagramView/QGraphicsGrid.cpp | 87 +-- .../DataView/DirectConditionGenerator.cpp | 38 +- .../DataView/ElementTreeModel.cpp | 68 ++- .../DataExplorer/DataView/ElementTreeView.cpp | 28 +- .../DataView/FemConditionModel.cpp | 1 - .../DataView/FemConditionView.cpp | 4 +- .../DataExplorer/DataView/GEOModels.cpp | 46 +- .../DataExplorer/DataView/GMSHPrefsDialog.cpp | 49 +- .../DataView/GeoOnMeshMappingDialog.cpp | 10 +- .../DataExplorer/DataView/GeoTabWidget.cpp | 18 +- .../DataExplorer/DataView/GeoTreeModel.cpp | 120 ++-- .../DataExplorer/DataView/GeoTreeView.cpp | 167 +++--- .../DataExplorer/DataView/LicenseDialog.cpp | 88 +-- .../DataExplorer/DataView/LineEditDialog.cpp | 29 +- .../DataView/LinearEditDialog.cpp | 20 +- .../DataView/MergeGeometriesDialog.cpp | 24 +- .../DataView/MeshAnalysisDialog.cpp | 63 ++- .../DataView/MeshElementRemovalDialog.cpp | 84 ++- .../DataExplorer/DataView/MeshItem.cpp | 1 + .../DataView/MeshLayerEditDialog.cpp | 105 ++-- .../DataView/MeshMapping2DDialog.cpp | 21 +- .../DataExplorer/DataView/MeshModel.cpp | 52 +- .../DataView/MeshQualitySelectionDialog.cpp | 12 +- .../DataExplorer/DataView/MeshTabWidget.cpp | 18 +- .../DataView/MeshValueEditDialog.cpp | 16 +- .../DataExplorer/DataView/MeshView.cpp | 170 +++--- .../DataExplorer/DataView/ModelTreeItem.cpp | 4 +- .../DataView/ModellingTabWidget.cpp | 4 +- .../DataExplorer/DataView/ProcessView.cpp | 4 +- .../DataView/RasterDataToMeshDialog.cpp | 10 +- .../DataExplorer/DataView/SHPImportDialog.cpp | 53 +- .../DataExplorer/DataView/SaveMeshDialog.cpp | 27 +- .../DataView/SelectMeshDialog.cpp | 27 +- .../DataExplorer/DataView/SetNameDialog.cpp | 21 +- .../DataView/StationTabWidget.cpp | 18 +- .../DataView/StationTreeModel.cpp | 62 ++- .../DataExplorer/DataView/StationTreeView.cpp | 125 +++-- .../DataView/StratView/StratBar.cpp | 23 +- .../DataView/StratView/StratScene.cpp | 74 ++- .../DataView/StratView/StratView.cpp | 11 +- .../DataView/StratView/StratWindow.cpp | 16 +- .../DataView/SurfaceExtractionDialog.cpp | 10 +- .../VtkVis/MeshFromRasterDialog.cpp | 6 +- .../VtkVis/NetCdfConfigureDialog.cpp | 142 +++-- .../DataExplorer/VtkVis/QVtkDataSetMapper.cpp | 7 +- .../DataExplorer/VtkVis/VisPrefsDialog.cpp | 26 +- .../VtkVis/VisualizationWidget.cpp | 61 ++- .../VtkVis/VtkAddFilterDialog.cpp | 49 +- .../VtkVis/VtkAlgorithmProperties.cpp | 23 +- .../VtkVis/VtkAlgorithmPropertyCheckbox.cpp | 6 +- .../VtkVis/VtkAlgorithmPropertyLineEdit.cpp | 22 +- .../VtkVis/VtkAlgorithmPropertyVectorEdit.cpp | 24 +- .../VtkVis/VtkAppendArrayFilter.cpp | 27 +- .../DataExplorer/VtkVis/VtkBGImageSource.cpp | 34 +- .../VtkVis/VtkColorByHeightFilter.cpp | 29 +- .../VtkVis/VtkColorLookupTable.cpp | 60 +- .../VtkCompositeColorByHeightFilter.cpp | 31 +- .../VtkCompositeColormapToImageFilter.cpp | 33 +- .../VtkVis/VtkCompositeContourFilter.cpp | 25 +- .../VtkCompositeElementSelectionFilter.cpp | 55 +- .../VtkVis/VtkCompositeFilter.cpp | 17 +- .../VtkVis/VtkCompositeGeoObjectFilter.cpp | 64 +-- .../VtkCompositeImageToCylindersFilter.cpp | 24 +- .../VtkCompositeImageToPointCloudFilter.cpp | 27 +- ...VtkCompositeImageToSurfacePointsFilter.cpp | 3 +- .../VtkVis/VtkCompositeLineToTubeFilter.cpp | 22 +- .../VtkCompositeNodeSelectionFilter.cpp | 32 +- .../VtkVis/VtkCompositePointToGlyphFilter.cpp | 34 +- .../VtkCompositeTextureOnSurfaceFilter.cpp | 18 +- .../VtkVis/VtkCompositeThresholdFilter.cpp | 25 +- .../VtkVis/VtkConsoleOutputWindow.cpp | 4 +- .../VtkVis/VtkCustomInteractorStyle.cpp | 101 ++-- .../DataExplorer/VtkVis/VtkFilterFactory.cpp | 116 ++-- .../DataExplorer/VtkVis/VtkGeoImageSource.cpp | 36 +- .../VtkImageDataToLinePolyDataFilter.cpp | 12 +- .../VtkVis/VtkImageDataToPointCloudFilter.cpp | 26 +- .../VtkImageDataToSurfacePointsFilter.cpp | 15 +- .../DataExplorer/VtkVis/VtkPointsSource.cpp | 47 +- .../VtkVis/VtkPolylinesSource.cpp | 56 +- .../DataExplorer/VtkVis/VtkRaster.cpp | 146 ++--- .../DataExplorer/VtkVis/VtkStationSource.cpp | 76 +-- .../DataExplorer/VtkVis/VtkSurfacesSource.cpp | 57 +- .../VtkVis/VtkTextureOnSurfaceFilter.cpp | 94 ++-- .../DataExplorer/VtkVis/VtkVisHelper.cpp | 22 +- .../DataExplorer/VtkVis/VtkVisImageItem.cpp | 23 +- .../DataExplorer/VtkVis/VtkVisPipeline.cpp | 104 ++-- .../VtkVis/VtkVisPipelineItem.cpp | 51 +- .../VtkVis/VtkVisPipelineView.cpp | 111 ++-- .../VtkVis/VtkVisPointSetItem.cpp | 125 +++-- .../DataExplorer/VtkVis/VtkVisTabWidget.cpp | 144 ++--- Applications/DataExplorer/main.cpp | 19 +- Applications/DataExplorer/mainwindow.cpp | 513 +++++++++++------- 114 files changed, 3110 insertions(+), 2390 deletions(-) diff --git a/Applications/DataExplorer/Base/CheckboxDelegate.cpp b/Applications/DataExplorer/Base/CheckboxDelegate.cpp index 00f5b302cd8..59f7bf346e9 100644 --- a/Applications/DataExplorer/Base/CheckboxDelegate.cpp +++ b/Applications/DataExplorer/Base/CheckboxDelegate.cpp @@ -14,6 +14,7 @@ // ** INCLUDES ** #include "CheckboxDelegate.h" + #include <QApplication> #include <QCheckBox> #include <QEvent> @@ -21,15 +22,13 @@ #include <QPainter> #include <QStyleOptionButton> -CheckboxDelegate::CheckboxDelegate(QObject* parent) - : QItemDelegate(parent) -{ -} +CheckboxDelegate::CheckboxDelegate(QObject* parent) : QItemDelegate(parent) {} -void CheckboxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, +void CheckboxDelegate::paint(QPainter* painter, + const QStyleOptionViewItem& option, const QModelIndex& index) const { - if(index.isValid()) + if (index.isValid()) { bool checked = index.model()->data(index, Qt::DisplayRole).toBool(); @@ -56,7 +55,8 @@ void CheckboxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti } bool CheckboxDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, - const QStyleOptionViewItem &option, const QModelIndex &index) + const QStyleOptionViewItem& option, + const QModelIndex& index) { Q_UNUSED(option); @@ -91,8 +91,8 @@ bool CheckboxDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, return model->setData(index, !checked, Qt::EditRole); } -QSize CheckboxDelegate::sizeHint(const QStyleOptionViewItem & option, - const QModelIndex & index) const +QSize CheckboxDelegate::sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const { Q_UNUSED(index); @@ -100,14 +100,16 @@ QSize CheckboxDelegate::sizeHint(const QStyleOptionViewItem & option, return QSize(rect.width(), rect.height()); } -QRect CheckboxDelegate::checkboxRect(const QStyleOptionViewItem& viewItemStyleOptions) const +QRect CheckboxDelegate::checkboxRect( + const QStyleOptionViewItem& viewItemStyleOptions) const { QStyleOptionButton styleOptionButton; QRect rect = QApplication::style()->subElementRect( - QStyle::SE_CheckBoxIndicator, &styleOptionButton); + QStyle::SE_CheckBoxIndicator, &styleOptionButton); QPoint point(viewItemStyleOptions.rect.x() + - viewItemStyleOptions.rect.width() / 2 - rect.width() / 2, - viewItemStyleOptions.rect.y() + viewItemStyleOptions.rect.height() / 2 - - rect.height() / 2); + viewItemStyleOptions.rect.width() / 2 - rect.width() / 2, + viewItemStyleOptions.rect.y() + + viewItemStyleOptions.rect.height() / 2 - + rect.height() / 2); return QRect(point, rect.size()); } diff --git a/Applications/DataExplorer/Base/ColorPickerPushButton.cpp b/Applications/DataExplorer/Base/ColorPickerPushButton.cpp index f2aec37f3d4..399c09beb09 100644 --- a/Applications/DataExplorer/Base/ColorPickerPushButton.cpp +++ b/Applications/DataExplorer/Base/ColorPickerPushButton.cpp @@ -17,7 +17,7 @@ #include <QColorDialog> -ColorPickerPushButton::ColorPickerPushButton( QWidget* parent /*= 0*/ ) +ColorPickerPushButton::ColorPickerPushButton(QWidget* parent /*= 0*/) : QPushButton(parent) { setAutoFillBackground(true); @@ -38,7 +38,7 @@ void ColorPickerPushButton::mouseReleaseEvent(QMouseEvent* e) emit colorPicked(_color); } -QString ColorPickerPushButton::colorToCss( QColor color ) +QString ColorPickerPushButton::colorToCss(QColor color) { QString colorStr = "rgb"; colorStr.append(colorToString(color)); @@ -46,7 +46,7 @@ QString ColorPickerPushButton::colorToCss( QColor color ) return colorStr; } -QString ColorPickerPushButton::colorToString( QColor color ) +QString ColorPickerPushButton::colorToString(QColor color) { QString colorStr = "("; colorStr.append(QString::number(color.red())); @@ -59,7 +59,7 @@ QString ColorPickerPushButton::colorToString( QColor color ) return colorStr; } -void ColorPickerPushButton::setColor( QColor color ) +void ColorPickerPushButton::setColor(QColor color) { _color = color; @@ -84,7 +84,7 @@ void ColorPickerPushButton::setColor( QColor color ) this->setText(colorToString(_color)); } -void ColorPickerPushButton::setColor( double* color ) +void ColorPickerPushButton::setColor(double* color) { setColor(QColor::fromRgbF(color[0], color[1], color[2])); } diff --git a/Applications/DataExplorer/Base/OGSError.cpp b/Applications/DataExplorer/Base/OGSError.cpp index acbc5c7f23d..c5f9f7df667 100644 --- a/Applications/DataExplorer/Base/OGSError.cpp +++ b/Applications/DataExplorer/Base/OGSError.cpp @@ -20,12 +20,12 @@ OGSError::OGSError() = default; OGSError::~OGSError() = default; -void OGSError::box(const QString &e) +void OGSError::box(const QString& e) { box(e, "OpenGeoSys"); } -void OGSError::box(const QString &e, const QString &t) +void OGSError::box(const QString& e, const QString& t) { QMessageBox msgBox; msgBox.setWindowTitle(t); @@ -33,7 +33,7 @@ void OGSError::box(const QString &e, const QString &t) msgBox.exec(); } -bool OGSError::question(const QString &e, const QString &t) +bool OGSError::question(const QString& e, const QString& t) { QMessageBox msgBox; msgBox.setWindowTitle(t); @@ -43,4 +43,3 @@ bool OGSError::question(const QString &e, const QString &t) return msgBox.exec() == QMessageBox::Ok; } - diff --git a/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp b/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp index 476787a7d08..27cfd3d11a5 100644 --- a/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp +++ b/Applications/DataExplorer/Base/QNonScalableGraphicsTextItem.cpp @@ -13,11 +13,13 @@ */ #include "QNonScalableGraphicsTextItem.h" + #include <QPainter> /// Constructor using a QGraphicsTextItem. -QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(QGraphicsItem* parent) : - QGraphicsTextItem(parent) +QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem( + QGraphicsItem* parent) + : QGraphicsTextItem(parent) { setAcceptDrops(true); setAcceptHoverEvents(true); @@ -25,9 +27,9 @@ QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(QGraphicsItem* parent } /// Constructor using a QString. -QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(const QString & text, - QGraphicsItem* parent) : - QGraphicsTextItem(parent) +QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem( + const QString& text, QGraphicsItem* parent) + : QGraphicsTextItem(parent) { if (!text.isEmpty()) { @@ -45,7 +47,7 @@ void QNonScalableGraphicsTextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { - //painter->drawRect(boundingRect()); + // painter->drawRect(boundingRect()); QRectF rect = boundingRect(); painter->translate(-rect.width() / 2, -rect.height() / 2); QGraphicsTextItem::paint(painter, option, widget); @@ -55,5 +57,6 @@ void QNonScalableGraphicsTextItem::paint(QPainter* painter, QRectF QNonScalableGraphicsTextItem::boundingRect() const { QRectF rect = QGraphicsTextItem::boundingRect(); - return rect; //QRectF(rect.x()-rect.width()/2, rect.y()-rect.height()/2,rect.width(), rect.height()); + return rect; // QRectF(rect.x()-rect.width()/2, + // rect.y()-rect.height()/2,rect.width(), rect.height()); } diff --git a/Applications/DataExplorer/Base/QValueTooltipSlider.cpp b/Applications/DataExplorer/Base/QValueTooltipSlider.cpp index 672f08e05db..6c93e8915ae 100644 --- a/Applications/DataExplorer/Base/QValueTooltipSlider.cpp +++ b/Applications/DataExplorer/Base/QValueTooltipSlider.cpp @@ -19,8 +19,7 @@ #include <QString> #include <QToolTip> -QValueTooltipSlider::QValueTooltipSlider(QWidget* parent) - : QSlider(parent) +QValueTooltipSlider::QValueTooltipSlider(QWidget* parent) : QSlider(parent) { connect(this, SIGNAL(sliderMoved(int)), this, SLOT(setTooltipValue(int))); } diff --git a/Applications/DataExplorer/Base/RecentFiles.cpp b/Applications/DataExplorer/Base/RecentFiles.cpp index d8a52f4e098..12a7a329a61 100644 --- a/Applications/DataExplorer/Base/RecentFiles.cpp +++ b/Applications/DataExplorer/Base/RecentFiles.cpp @@ -43,7 +43,7 @@ QMenu* RecentFiles::menu() { return _filesMenu; } -void RecentFiles::setCurrentFile( const QString& filename ) +void RecentFiles::setCurrentFile(const QString& filename) { _currentFile = filename; @@ -81,7 +81,7 @@ void RecentFiles::updateRecentFileActions() } } -QString RecentFiles::strippedName( const QString& fullFileName ) +QString RecentFiles::strippedName(const QString& fullFileName) { return QFileInfo(fullFileName).fileName(); } diff --git a/Applications/DataExplorer/Base/TreeItem.cpp b/Applications/DataExplorer/Base/TreeItem.cpp index 412d8122c0a..98dc4c9cd89 100644 --- a/Applications/DataExplorer/Base/TreeItem.cpp +++ b/Applications/DataExplorer/Base/TreeItem.cpp @@ -12,10 +12,10 @@ * */ -#include <utility> - #include "TreeItem.h" +#include <utility> + /** * The constructor is only used to record the item's parent * and the data associated with each column. @@ -99,7 +99,7 @@ QVariant TreeItem::data(int column) const /** * Sets the data at a given column. */ -bool TreeItem::setData( int column, const QVariant &value ) +bool TreeItem::setData(int column, const QVariant& value) { if (column < 0 || column >= _itemData.size()) { @@ -118,7 +118,8 @@ TreeItem* TreeItem::parentItem() const } /** - * Removes a number of children of the TreeItem starting from the given position. + * Removes a number of children of the TreeItem starting from the given + * position. */ bool TreeItem::removeChildren(int position, int count) { diff --git a/Applications/DataExplorer/Base/TreeModel.cpp b/Applications/DataExplorer/Base/TreeModel.cpp index af3aabac9ea..e5920eaddd4 100644 --- a/Applications/DataExplorer/Base/TreeModel.cpp +++ b/Applications/DataExplorer/Base/TreeModel.cpp @@ -14,23 +14,24 @@ #include "TreeModel.h" -#include "TreeItem.h" - #include <QModelIndex> #include <QStringList> #include <QVariant> +#include "TreeItem.h" + /** * A model for the QTreeView implementing the tree as a double-linked list. */ -TreeModel::TreeModel( QObject* parent ) - : QAbstractItemModel(parent) +TreeModel::TreeModel(QObject* parent) : QAbstractItemModel(parent) { //_modelType = TREE_MODEL; QList<QVariant> rootData; - rootData << "1" << "2" << "3"; + rootData << "1" + << "2" + << "3"; _rootItem = new TreeItem(rootData, nullptr); - //setupModelData(data, _rootItem); + // setupModelData(data, _rootItem); } TreeModel::~TreeModel() @@ -40,15 +41,14 @@ TreeModel::~TreeModel() /** * Returns the index of a TreeItem given its parent and position. - * It is first checked if the model index is valid. If it is not, it is assumed that a - * top-level item is being referred to; otherwise, the data pointer from the model - * index is obtained with its internalPointer() function and is used to reference a - * TreeItem object - * \param row Row of the tree object - * \param column Column of the tree object - * \param parent Index of the parent object + * It is first checked if the model index is valid. If it is not, it is assumed + * that a top-level item is being referred to; otherwise, the data pointer from + * the model index is obtained with its internalPointer() function and is used + * to reference a TreeItem object \param row Row of the tree object \param + * column Column of the tree object \param parent Index of the parent object */ -QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const +QModelIndex TreeModel::index(int row, int column, + const QModelIndex& parent) const { if (!hasIndex(row, column, parent)) { @@ -78,7 +78,7 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con /** * Returns the model index of a TreeItem based on its index. */ -QModelIndex TreeModel::parent(const QModelIndex &index) const +QModelIndex TreeModel::parent(const QModelIndex& index) const { if (!index.isValid()) { @@ -97,10 +97,11 @@ QModelIndex TreeModel::parent(const QModelIndex &index) const } /** - * Returns the number of child items for the TreeItem that corresponds to a given - * model index, or the number of top-level items if an invalid index is specified. + * Returns the number of child items for the TreeItem that corresponds to a + * given model index, or the number of top-level items if an invalid index is + * specified. */ -int TreeModel::rowCount(const QModelIndex &parent) const +int TreeModel::rowCount(const QModelIndex& parent) const { TreeItem* parentItem; if (parent.column() > 0) @@ -123,7 +124,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const /** * Determines how many columns are present for a given model index. */ -int TreeModel::columnCount(const QModelIndex &parent) const +int TreeModel::columnCount(const QModelIndex& parent) const { if (parent.isValid()) { @@ -133,14 +134,12 @@ int TreeModel::columnCount(const QModelIndex &parent) const return _rootItem->columnCount(); } -void TreeModel::updateData() -{ -} +void TreeModel::updateData() {} /** - * Since each item manages its own columns, the column number is used to retrieve - * the data with the TreeItem::data() function + * Since each item manages its own columns, the column number is used to + * retrieve the data with the TreeItem::data() function */ -QVariant TreeModel::data(const QModelIndex &index, int role) const +QVariant TreeModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { @@ -157,7 +156,8 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const return QVariant(); } -bool TreeModel::setData( const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */ ) +bool TreeModel::setData(const QModelIndex& index, const QVariant& value, + int role /* = Qt::EditRole */) { if (!index.isValid()) { @@ -172,7 +172,7 @@ bool TreeModel::setData( const QModelIndex &index, const QVariant &value, int ro } return false; } -Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const +Qt::ItemFlags TreeModel::flags(const QModelIndex& index) const { if (!index.isValid()) { @@ -185,7 +185,7 @@ Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const /** * Returns the Item characterized by the given index. */ -TreeItem* TreeModel::getItem(const QModelIndex &index) const +TreeItem* TreeModel::getItem(const QModelIndex& index) const { if (index.isValid()) { @@ -198,7 +198,8 @@ TreeItem* TreeModel::getItem(const QModelIndex &index) const return _rootItem; } -QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant TreeModel::headerData(int section, Qt::Orientation orientation, + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { @@ -211,7 +212,7 @@ QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int rol /** * Removes item from the model. */ -bool TreeModel::removeRows(int position, int count, const QModelIndex & parent) +bool TreeModel::removeRows(int position, int count, const QModelIndex& parent) { TreeItem* parentItem = getItem(parent); bool success = true; @@ -226,7 +227,7 @@ bool TreeModel::removeRows(int position, int count, const QModelIndex & parent) /** * Test method for creating a tree model */ -void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent) +void TreeModel::setupModelData(const QStringList& lines, TreeItem* parent) { QList<TreeItem*> parents; QList<int> indentations; @@ -252,7 +253,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent) if (!lineData.isEmpty()) { // Read the column data from the rest of the line. - QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); + QStringList columnStrings = + lineData.split("\t", QString::SkipEmptyParts); QList<QVariant> columnData; for (int column = 0; column < columnStrings.count(); ++column) { @@ -266,8 +268,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent) if (parents.last()->childCount() > 0) { - parents << parents.last()->child(parents.last()->childCount( - ) - 1); + parents << parents.last()->child( + parents.last()->childCount() - 1); indentations << position; } } @@ -281,7 +283,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent) } // Append a new item to the current parent's list of children. - parents.last()->appendChild(new TreeItem(columnData, parents.last())); + parents.last()->appendChild( + new TreeItem(columnData, parents.last())); } number++; diff --git a/Applications/DataExplorer/Base/TreeModelIterator.cpp b/Applications/DataExplorer/Base/TreeModelIterator.cpp index db3539ab891..dc8d2041399 100644 --- a/Applications/DataExplorer/Base/TreeModelIterator.cpp +++ b/Applications/DataExplorer/Base/TreeModelIterator.cpp @@ -42,7 +42,7 @@ TreeModelIterator& TreeModelIterator::operator++() return *this; } -TreeItem* TreeModelIterator::next( const TreeItem* current ) +TreeItem* TreeModelIterator::next(const TreeItem* current) { if (!current) { @@ -62,7 +62,7 @@ TreeItem* TreeModelIterator::next( const TreeItem* current ) // walk the sibling TreeItem* parent = current->parentItem(); next = parent ? parent->child(_currentIndex + 1) - : _model->rootItem()->child(_currentIndex + 1); + : _model->rootItem()->child(_currentIndex + 1); while (!next && parent) { // if we had no sibling walk up the parent @@ -70,7 +70,7 @@ TreeItem* TreeModelIterator::next( const TreeItem* current ) parent = parent->parentItem(); _currentIndex = _parentIndex.pop(); next = parent ? parent->child(_currentIndex + 1) - : _model->rootItem()->child(_currentIndex + 1); + : _model->rootItem()->child(_currentIndex + 1); } if (next) { diff --git a/Applications/DataExplorer/Base/modeltest.cpp b/Applications/DataExplorer/Base/modeltest.cpp index 45ba447084a..9f6b31049ab 100644 --- a/Applications/DataExplorer/Base/modeltest.cpp +++ b/Applications/DataExplorer/Base/modeltest.cpp @@ -21,58 +21,60 @@ ** ****************************************************************************/ -#include <QtGui/QtGui> - #include "modeltest.h" +#include <QtGui/QtGui> + Q_DECLARE_METATYPE(QModelIndex) /*! - Connect to all of the models signals. Whenever anything happens recheck everything. + Connect to all of the models signals. Whenever anything happens recheck + everything. */ -ModelTest::ModelTest(QAbstractItemModel* _model, - QObject* parent) : QObject(parent), model(_model), fetchingMore(false) +ModelTest::ModelTest(QAbstractItemModel* _model, QObject* parent) + : QObject(parent), model(_model), fetchingMore(false) { Q_ASSERT(model); - connect(model, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(columnsInserted(const QModelIndex &, int, int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)), - this, SLOT(runAllTests())); - connect(model, SIGNAL(layoutAboutToBeChanged ()), this, SLOT(runAllTests())); - connect(model, SIGNAL(layoutChanged ()), this, SLOT(runAllTests())); - connect(model, SIGNAL(modelReset ()), this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), + connect(model, + SIGNAL(columnsAboutToBeInserted(const QModelIndex&, int, int)), this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), + connect(model, + SIGNAL(columnsAboutToBeRemoved(const QModelIndex&, int, int)), this, + SLOT(runAllTests())); + connect(model, SIGNAL(columnsInserted(const QModelIndex&, int, int)), this, + SLOT(runAllTests())); + connect(model, SIGNAL(columnsRemoved(const QModelIndex&, int, int)), this, + SLOT(runAllTests())); + connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + connect(model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)), this, + SLOT(runAllTests())); + connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests())); + connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests())); + connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests())); + connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)), this, SLOT(runAllTests())); - connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)), this, SLOT(runAllTests())); + connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, + SLOT(runAllTests())); + connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, + SLOT(runAllTests())); // Special checks for inserting/removing - connect(model, SIGNAL(layoutAboutToBeChanged()), - this, SLOT(layoutAboutToBeChanged())); - connect(model, SIGNAL(layoutChanged()), - this, SLOT(layoutChanged())); - - connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), - this, SLOT(rowsAboutToBeInserted(const QModelIndex &, int, int))); - connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), - this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int))); - connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(rowsInserted(const QModelIndex &, int, int))); - connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(rowsRemoved(const QModelIndex &, int, int))); + connect(model, SIGNAL(layoutAboutToBeChanged()), this, + SLOT(layoutAboutToBeChanged())); + connect(model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); + + connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)), + this, SLOT(rowsAboutToBeInserted(const QModelIndex&, int, int))); + connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)), + this, SLOT(rowsAboutToBeRemoved(const QModelIndex&, int, int))); + connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, + SLOT(rowsInserted(const QModelIndex&, int, int))); + connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, + SLOT(rowsRemoved(const QModelIndex&, int, int))); runAllTests(); } @@ -91,8 +93,9 @@ void ModelTest::runAllTests() } /*! - nonDestructiveBasicTest tries to call a number of the basic functions (not all) - to make sure the model doesn't outright segfault, testing the functions that makes sense. + nonDestructiveBasicTest tries to call a number of the basic functions (not + all) to make sure the model doesn't outright segfault, testing the functions + that makes sense. */ void ModelTest::nonDestructiveBasicTest() { @@ -128,7 +131,8 @@ void ModelTest::nonDestructiveBasicTest() } /*! - Tests model's implementation of QAbstractItemModel::rowCount() and hasChildren() + Tests model's implementation of QAbstractItemModel::rowCount() and + hasChildren() Models that are dynamically populated are not as fully tested here. */ @@ -142,8 +146,8 @@ void ModelTest::rowCount() Q_ASSERT(model->hasChildren(topIndex) == true); QModelIndex secondLevelIndex = model->index(0, 0, topIndex); - if (secondLevelIndex.isValid()) // not the top level - { // check a row count where parent is valid + if (secondLevelIndex.isValid()) // not the top level + { // check a row count where parent is valid rows = model->rowCount(secondLevelIndex); Q_ASSERT(rows >= 0); if (rows > 0) @@ -155,7 +159,8 @@ void ModelTest::rowCount() } /*! - Tests model's implementation of QAbstractItemModel::columnCount() and hasChildren() + Tests model's implementation of QAbstractItemModel::columnCount() and + hasChildren() */ void ModelTest::columnCount() { @@ -277,15 +282,15 @@ void ModelTest::parent() A model that returns an index of parent X should also return X when asking for the parent of the index. - This recursive function does pretty extensive testing on the whole model in an - effort to catch edge cases. + This recursive function does pretty extensive testing on the whole model in + an effort to catch edge cases. - This function assumes that rowCount(), columnCount() and index() already work. - If they have a bug it will point it out, but the above tests should have already - found the basic bugs because it is easier to figure out the problem in - those tests then this one. + This function assumes that rowCount(), columnCount() and index() already + work. If they have a bug it will point it out, but the above tests should + have already found the basic bugs because it is easier to figure out the + problem in those tests then this one. */ -void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) +void ModelTest::checkChildren(const QModelIndex& parent, int currentDepth) { // First just try walking back up the tree. QModelIndex p = parent; @@ -312,7 +317,8 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) if (rows > 0) Q_ASSERT(model->hasChildren(parent) == true); - //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows + // qDebug() << "parent:" << model->data(parent).toString() << "rows:" << + // rows // << "columns:" << columns << "parent column:" << parent.column(); Q_ASSERT(model->hasIndex(rows + 1, 0, parent) == false); @@ -332,7 +338,8 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) // rowCount() and columnCount() said that it existed... Q_ASSERT(index.isValid() == true); - // index() should always return the same index when called twice in a row + // index() should always return the same index when called twice in + // a row QModelIndex modifiedIndex = model->index(r, c, parent); Q_ASSERT(index == modifiedIndex); @@ -345,14 +352,17 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) Q_ASSERT(index.model() == model); Q_ASSERT(index.row() == r); Q_ASSERT(index.column() == c); - // While you can technically return a QVariant usually this is a sign - // of an bug in data() Disable if this really is ok in your model. - //Q_ASSERT(model->data(index, Qt::DisplayRole).isValid() == true); + // While you can technically return a QVariant usually this is a + // sign of an bug in data() Disable if this really is ok in your + // model. + // Q_ASSERT(model->data(index, Qt::DisplayRole).isValid() == true); - // If the next test fails here is some somewhat useful debug you play with. + // If the next test fails here is some somewhat useful debug you + // play with. /* if (model->parent(index) != parent) { - qDebug() << r << c << currentDepth << model->data(index).toString() + qDebug() << r << c << currentDepth << + model->data(index).toString() << model->data(parent).toString(); qDebug() << index << parent << model->parent(index); // And a view that you can even use to show the model. @@ -363,18 +373,21 @@ void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) // Check that we can get back our real parent. QModelIndex p = model->parent(index); - //qDebug() << "child:" << index; - //qDebug() << p; - //qDebug() << parent; + // qDebug() << "child:" << index; + // qDebug() << p; + // qDebug() << parent; Q_ASSERT(model->parent(index) == parent); // recursively go down the children - if (model->hasChildren(index) && currentDepth < 10 ) - //qDebug() << r << c << "has children" << model->rowCount(index); + if (model->hasChildren(index) && currentDepth < 10) + // qDebug() << r << c << "has children" << + // model->rowCount(index); checkChildren(index, ++currentDepth); - /* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/ + /* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; + * };*/ - // make sure that after testing the children that the index doesn't change. + // make sure that after testing the children that the index doesn't + // change. QModelIndex newerIndex = model->index(r, c, parent); Q_ASSERT(index == newerIndex); } @@ -396,7 +409,8 @@ void ModelTest::data() Q_ASSERT(model->index(0, 0).isValid()); // shouldn't be able to set data on an invalid index - Q_ASSERT(model->setData(QModelIndex(), QLatin1String("foo"), Qt::DisplayRole) == false); + Q_ASSERT(model->setData(QModelIndex(), QLatin1String("foo"), + Qt::DisplayRole) == false); // General Purpose roles that should return a QString QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); @@ -420,25 +434,23 @@ void ModelTest::data() Q_ASSERT(fontVariant.canConvert(QMetaType::QFont))); // Check that the alignment is one we know about - QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole); + QVariant textAlignmentVariant = + model->data(model->index(0, 0), Qt::TextAlignmentRole); if (textAlignmentVariant.isValid()) { int alignment = textAlignmentVariant.toInt(); - Q_ASSERT(alignment == Qt::AlignLeft || - alignment == Qt::AlignRight || - alignment == Qt::AlignHCenter || - alignment == Qt::AlignJustify || - alignment == Qt::AlignTop || - alignment == Qt::AlignBottom || - alignment == Qt::AlignVCenter || - alignment == Qt::AlignCenter || - alignment == Qt::AlignAbsolute || - alignment == Qt::AlignLeading || - alignment == Qt::AlignTrailing); + Q_ASSERT( + alignment == Qt::AlignLeft || alignment == Qt::AlignRight || + alignment == Qt::AlignHCenter || alignment == Qt::AlignJustify || + alignment == Qt::AlignTop || alignment == Qt::AlignBottom || + alignment == Qt::AlignVCenter || alignment == Qt::AlignCenter || + alignment == Qt::AlignAbsolute || alignment == Qt::AlignLeading || + alignment == Qt::AlignTrailing); } // General Purpose roles that should return a QColor - QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorRole); + QVariant colorVariant = + model->data(model->index(0, 0), Qt::BackgroundColorRole); if (colorVariant.isValid()) Q_ASSERT(colorVariant.canConvert(QMetaType::QColor))); @@ -447,12 +459,12 @@ void ModelTest::data() Q_ASSERT(colorVariant.canConvert(QMetaType::QColor))); // Check that the "check state" is one we know about. - QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateRole); + QVariant checkStateVariant = + model->data(model->index(0, 0), Qt::CheckStateRole); if (checkStateVariant.isValid()) { int state = checkStateVariant.toInt(); - Q_ASSERT(state == Qt::Unchecked || - state == Qt::PartiallyChecked || + Q_ASSERT(state == Qt::Unchecked || state == Qt::PartiallyChecked || state == Qt::Checked); } } @@ -462,7 +474,8 @@ void ModelTest::data() \sa rowsInserted() */ -void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) +void ModelTest::rowsAboutToBeInserted(const QModelIndex& parent, int start, + int end) { Q_UNUSED(end); Changing c; @@ -478,7 +491,7 @@ void ModelTest::rowsAboutToBeInserted(const QModelIndex &parent, int start, int \sa rowsAboutToBeInserted() */ -void ModelTest::rowsInserted(const QModelIndex & parent, int start, int end) +void ModelTest::rowsInserted(const QModelIndex& parent, int start, int end) { Changing c = insert.pop(); Q_ASSERT(c.parent == parent); @@ -516,7 +529,8 @@ void ModelTest::layoutChanged() \sa rowsRemoved() */ -void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) +void ModelTest::rowsAboutToBeRemoved(const QModelIndex& parent, int start, + int end) { Changing c; c.parent = parent; @@ -531,7 +545,7 @@ void ModelTest::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e \sa rowsAboutToBeRemoved() */ -void ModelTest::rowsRemoved(const QModelIndex & parent, int start, int end) +void ModelTest::rowsRemoved(const QModelIndex& parent, int start, int end) { Changing c = remove.pop(); Q_ASSERT(c.parent == parent); diff --git a/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp b/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp index cc683323ca7..26cca07ed14 100644 --- a/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp +++ b/Applications/DataExplorer/DataView/AddLayerToMeshDialog.cpp @@ -13,17 +13,16 @@ */ #include "AddLayerToMeshDialog.h" + #include "OGSError.h" #include "StrictDoubleValidator.h" - -AddLayerToMeshDialog::AddLayerToMeshDialog(QDialog* parent) -: QDialog(parent) +AddLayerToMeshDialog::AddLayerToMeshDialog(QDialog* parent) : QDialog(parent) { setupUi(this); auto* thickness_validator = new StrictDoubleValidator(0, 1000000, 7, this); - this->thicknessEdit->setValidator (thickness_validator); + this->thicknessEdit->setValidator(thickness_validator); } void AddLayerToMeshDialog::accept() @@ -47,4 +46,3 @@ void AddLayerToMeshDialog::reject() { this->done(QDialog::Rejected); } - diff --git a/Applications/DataExplorer/DataView/ColorTableModel.cpp b/Applications/DataExplorer/DataView/ColorTableModel.cpp index 09c66619230..6f8d3a74c0f 100644 --- a/Applications/DataExplorer/DataView/ColorTableModel.cpp +++ b/Applications/DataExplorer/DataView/ColorTableModel.cpp @@ -14,8 +14,9 @@ #include "ColorTableModel.h" -ColorTableModel::ColorTableModel( const std::map<std::string, DataHolderLib::Color*> &colorLookupTable, - QObject* parent /*= 0*/ ) +ColorTableModel::ColorTableModel( + const std::map<std::string, DataHolderLib::Color*>& colorLookupTable, + QObject* parent /*= 0*/) { Q_UNUSED(parent) @@ -24,15 +25,16 @@ ColorTableModel::ColorTableModel( const std::map<std::string, DataHolderLib::Col ColorTableModel::~ColorTableModel() = default; -int ColorTableModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const +int ColorTableModel::columnCount( + const QModelIndex& parent /*= QModelIndex()*/) const { Q_UNUSED(parent) return 2; } -QVariant ColorTableModel::headerData( int section, Qt::Orientation orientation, - int role /*= Qt::DisplayRole*/ ) const +QVariant ColorTableModel::headerData(int section, Qt::Orientation orientation, + int role /*= Qt::DisplayRole*/) const { if (role != Qt::DisplayRole) { @@ -43,9 +45,12 @@ QVariant ColorTableModel::headerData( int section, Qt::Orientation orientation, { switch (section) { - case 0: return "Name"; - case 1: return "Colour"; - default: return QVariant(); + case 0: + return "Name"; + case 1: + return "Colour"; + default: + return QVariant(); } } else @@ -54,7 +59,7 @@ QVariant ColorTableModel::headerData( int section, Qt::Orientation orientation, } } -QVariant ColorTableModel::data( const QModelIndex& index, int role ) const +QVariant ColorTableModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { @@ -72,18 +77,19 @@ QVariant ColorTableModel::data( const QModelIndex& index, int role ) const switch (index.column()) { - case 0: - return pair.first; - case 1: - return pair.second; - default: - return QVariant(); + case 0: + return pair.first; + case 1: + return pair.second; + default: + return QVariant(); } } return QVariant(); } -bool ColorTableModel::buildTable(const std::map<std::string, DataHolderLib::Color*> &colorLookupTable) +bool ColorTableModel::buildTable( + const std::map<std::string, DataHolderLib::Color*>& colorLookupTable) { int count = 0; beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1); @@ -110,4 +116,3 @@ bool ColorTableModel::buildTable(const std::map<std::string, DataHolderLib::Colo endInsertRows(); return true; } - diff --git a/Applications/DataExplorer/DataView/ColorTableView.cpp b/Applications/DataExplorer/DataView/ColorTableView.cpp index ffe19c6e979..cd99107b12a 100644 --- a/Applications/DataExplorer/DataView/ColorTableView.cpp +++ b/Applications/DataExplorer/DataView/ColorTableView.cpp @@ -14,10 +14,11 @@ */ #include "ColorTableView.h" + #include <QHeaderView> #include <QPainter> -ColorTableView::ColorTableView( QWidget* parent /*= 0*/ ) : QTableView(parent) +ColorTableView::ColorTableView(QWidget* parent /*= 0*/) : QTableView(parent) { this->verticalHeader()->hide(); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -26,8 +27,8 @@ ColorTableView::ColorTableView( QWidget* parent /*= 0*/ ) : QTableView(parent) } void ColorTableViewDelegate::paint(QPainter* painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const + const QStyleOptionViewItem& option, + const QModelIndex& index) const { QColor val; if (index.column() == 1) @@ -45,8 +46,8 @@ void ColorTableViewDelegate::paint(QPainter* painter, } } -QSize ColorTableViewDelegate::sizeHint( const QStyleOptionViewItem &option, - const QModelIndex &index ) const +QSize ColorTableViewDelegate::sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const { QSize s = QItemDelegate::sizeHint(option, index); if (s.isValid()) diff --git a/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp b/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp index bbc1a4b51c7..570764d7918 100644 --- a/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp +++ b/Applications/DataExplorer/DataView/CondFromRasterDialog.cpp @@ -13,13 +13,13 @@ */ #include "CondFromRasterDialog.h" -#include "Mesh.h" #include <QFileDialog> #include <QSettings> #include <utility> #include "DirectConditionGenerator.h" +#include "Mesh.h" #include "OGSError.h" #include "StrictDoubleValidator.h" @@ -32,7 +32,7 @@ CondFromRasterDialog::CondFromRasterDialog(std::vector<MeshLib::Mesh*> msh_vec, this->scalingEdit->setEnabled(false); _scale_validator = new StrictDoubleValidator(-1e+10, 1e+20, 5); this->scalingEdit->setText("1.0"); - this->scalingEdit->setValidator (_scale_validator); + this->scalingEdit->setValidator(_scale_validator); for (auto mesh : _msh_vec) { @@ -55,9 +55,10 @@ void CondFromRasterDialog::on_selectButton_pressed() #else QString geotiffExtension(""); #endif - QString fileName = QFileDialog::getOpenFileName(this, "Select raster file", - settings.value("lastOpenedRasterFileDirectory").toString(), - QString("Raster files (*.asc *.grd);;").arg(geotiffExtension)); + QString fileName = QFileDialog::getOpenFileName( + this, "Select raster file", + settings.value("lastOpenedRasterFileDirectory").toString(), + QString("Raster files (*.asc *.grd);;").arg(geotiffExtension)); if (!fileName.isEmpty()) { @@ -68,13 +69,12 @@ void CondFromRasterDialog::on_selectButton_pressed() } } - void CondFromRasterDialog::accept() { - std::string mesh_name (this->meshBox->currentText().toStdString()); - std::string raster_name (this->rasterEdit->text().toStdString()); + std::string mesh_name(this->meshBox->currentText().toStdString()); + std::string raster_name(this->rasterEdit->text().toStdString()); double scaling_factor = this->scalingEdit->text().toDouble(); - std::vector< std::pair<std::size_t,double> > direct_values; + std::vector<std::pair<std::size_t, double>> direct_values; if (mesh_name.empty()) { @@ -101,7 +101,7 @@ void CondFromRasterDialog::accept() { DirectConditionGenerator dcg; direct_values = dcg.directToSurfaceNodes(*mesh, raster_name); - //dcg.writeToFile(direct_node_name); + // dcg.writeToFile(direct_node_name); } else { @@ -112,11 +112,12 @@ void CondFromRasterDialog::accept() } auto* new_mesh = const_cast<MeshLib::Mesh*>(mesh); DirectConditionGenerator dcg; - direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name, scaling_factor); + direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name, + scaling_factor); - //dcg.writeToFile(direct_node_name); + // dcg.writeToFile(direct_node_name); } - //emit directNodesWritten(direct_node_name); + // emit directNodesWritten(direct_node_name); emit transmitDisValues(direct_values); this->done(QDialog::Accepted); } diff --git a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp index 18ecbc8e93e..f9a64d936ac 100644 --- a/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp +++ b/Applications/DataExplorer/DataView/CreateStructuredGridDialog.cpp @@ -18,12 +18,11 @@ #include "GeoLib/Point.h" #include "MeshLib/MeshGenerators/MeshGenerator.h" - -#include "StrictDoubleValidator.h" #include "OGSError.h" +#include "StrictDoubleValidator.h" - -CreateStructuredGridDialog::CreateStructuredGridDialog(QDialog* parent) : QDialog(parent) +CreateStructuredGridDialog::CreateStructuredGridDialog(QDialog* parent) + : QDialog(parent) { setupUi(this); setValidators(); @@ -32,25 +31,25 @@ CreateStructuredGridDialog::CreateStructuredGridDialog(QDialog* parent) : QDialo void CreateStructuredGridDialog::setValidators() { auto* origin_x_validator = new StrictDoubleValidator(this); - this->xOriginEdit->setValidator (origin_x_validator); + this->xOriginEdit->setValidator(origin_x_validator); auto* origin_y_validator = new StrictDoubleValidator(this); - this->yOriginEdit->setValidator (origin_y_validator); + this->yOriginEdit->setValidator(origin_y_validator); auto* origin_z_validator = new StrictDoubleValidator(this); - this->zOriginEdit->setValidator (origin_z_validator); + this->zOriginEdit->setValidator(origin_z_validator); auto* x_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); - this->xLengthEdit->setValidator (x_length_validator); + this->xLengthEdit->setValidator(x_length_validator); auto* y_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); - this->yLengthEdit->setValidator (y_length_validator); + this->yLengthEdit->setValidator(y_length_validator); auto* z_length_validator = new StrictDoubleValidator(0, 10000000, 10, this); - this->zLengthEdit->setValidator (z_length_validator); + this->zLengthEdit->setValidator(z_length_validator); auto* x_n_elem_validator = new QIntValidator(1, 10000000, this); - this->xElemEdit->setValidator (x_n_elem_validator); + this->xElemEdit->setValidator(x_n_elem_validator); auto* y_n_elem_validator = new QIntValidator(1, 10000000, this); - this->yElemEdit->setValidator (y_n_elem_validator); + this->yElemEdit->setValidator(y_n_elem_validator); auto* z_n_elem_validator = new QIntValidator(1, 10000000, this); - this->zElemEdit->setValidator (z_n_elem_validator); + this->zElemEdit->setValidator(z_n_elem_validator); } void CreateStructuredGridDialog::on_lineButton_toggled() const @@ -105,10 +104,12 @@ void CreateStructuredGridDialog::on_elemExtentButton_toggled() bool CreateStructuredGridDialog::inputIsEmpty() const { - QString const type_str = (this->meshExtentButton->isChecked()) ? "mesh" : "element"; + QString const type_str = + (this->meshExtentButton->isChecked()) ? "mesh" : "element"; if (this->xLengthEdit->text().isEmpty()) { - OGSError::box("Please specify " + type_str + "\nextent in x-direction."); + OGSError::box("Please specify " + type_str + + "\nextent in x-direction."); return true; } if (this->xElemEdit->text().isEmpty()) @@ -133,7 +134,8 @@ bool CreateStructuredGridDialog::inputIsEmpty() const { if (this->yLengthEdit->text().isEmpty()) { - OGSError::box("Please specify " + type_str + "\nextent in y-direction."); + OGSError::box("Please specify " + type_str + + "\nextent in y-direction."); return true; } if (this->yElemEdit->text().isEmpty()) @@ -147,7 +149,8 @@ bool CreateStructuredGridDialog::inputIsEmpty() const { if (this->zLengthEdit->text().isEmpty()) { - OGSError::box("Please specify " + type_str + "\nextent in z-direction."); + OGSError::box("Please specify " + type_str + + "\nextent in z-direction."); return true; } if (this->zElemEdit->text().isEmpty()) @@ -185,14 +188,15 @@ void CreateStructuredGridDialog::accept() GeoLib::Point const origin(this->xOriginEdit->text().toDouble(), this->yOriginEdit->text().toDouble(), this->zOriginEdit->text().toDouble()); - std::string const name (this->meshNameEdit->text().toStdString()); - MeshLib::Mesh* mesh (nullptr); + std::string const name(this->meshNameEdit->text().toStdString()); + MeshLib::Mesh* mesh(nullptr); if (this->lineButton->isChecked()) { if (this->meshExtentButton->isChecked()) { mesh = MeshLib::MeshGenerator::generateLineMesh( - this->xLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), origin, name); + this->xLengthEdit->text().toDouble(), + this->xElemEdit->text().toInt(), origin, name); } else { @@ -206,9 +210,10 @@ void CreateStructuredGridDialog::accept() if (this->meshExtentButton->isChecked()) { mesh = MeshLib::MeshGenerator::generateRegularTriMesh( - this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), - this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), - origin, name); + this->xLengthEdit->text().toDouble(), + this->yLengthEdit->text().toDouble(), + this->xElemEdit->text().toInt(), + this->yElemEdit->text().toInt(), origin, name); } else { @@ -224,9 +229,10 @@ void CreateStructuredGridDialog::accept() if (this->meshExtentButton->isChecked()) { mesh = MeshLib::MeshGenerator::generateRegularQuadMesh( - this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), - this->xElemEdit->text().toInt(), this->yElemEdit->text().toInt(), - origin, name); + this->xLengthEdit->text().toDouble(), + this->yLengthEdit->text().toDouble(), + this->xElemEdit->text().toInt(), + this->yElemEdit->text().toInt(), origin, name); } else { @@ -242,10 +248,12 @@ void CreateStructuredGridDialog::accept() if (this->meshExtentButton->isChecked()) { mesh = MeshLib::MeshGenerator::generateRegularPrismMesh( - this->xLengthEdit->text().toDouble(), this->yLengthEdit->text().toDouble(), - this->zLengthEdit->text().toDouble(), this->xElemEdit->text().toInt(), - this->yElemEdit->text().toInt(), this->zElemEdit->text().toInt(), - origin, name); + this->xLengthEdit->text().toDouble(), + this->yLengthEdit->text().toDouble(), + this->zLengthEdit->text().toDouble(), + this->xElemEdit->text().toInt(), + this->yElemEdit->text().toInt(), + this->zElemEdit->text().toInt(), origin, name); } else { @@ -295,4 +303,3 @@ void CreateStructuredGridDialog::accept() emit meshAdded(mesh); this->done(QDialog::Accepted); } - diff --git a/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp b/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp index ba617cf60f7..1f3c082a88a 100644 --- a/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp +++ b/Applications/DataExplorer/DataView/DataExplorerSettingsDialog.cpp @@ -17,16 +17,16 @@ #include <QFileDialog> #include <QSettings> - #include "OGSError.h" - -DataExplorerSettingsDialog::DataExplorerSettingsDialog(QDialog* parent) : QDialog(parent) +DataExplorerSettingsDialog::DataExplorerSettingsDialog(QDialog* parent) + : QDialog(parent) { setupUi(this); QSettings settings; - this->gmshPathEdit->setText(settings.value("DataExplorerGmshPath").toString()); + this->gmshPathEdit->setText( + settings.value("DataExplorerGmshPath").toString()); } DataExplorerSettingsDialog::~DataExplorerSettingsDialog() = default; @@ -34,9 +34,9 @@ DataExplorerSettingsDialog::~DataExplorerSettingsDialog() = default; void DataExplorerSettingsDialog::on_gmshPathButton_clicked() { QSettings settings; - QString file_name = QFileDialog::getOpenFileName(this, "Select path for GMSH...", - settings.value("DataExplorerGmshPath").toString(), - "*gmsh*"); + QString file_name = QFileDialog::getOpenFileName( + this, "Select path for GMSH...", + settings.value("DataExplorerGmshPath").toString(), "*gmsh*"); if (!file_name.isEmpty()) { this->gmshPathEdit->setText(file_name); @@ -49,5 +49,3 @@ void DataExplorerSettingsDialog::accept() settings.setValue("DataExplorerGmshPath", this->gmshPathEdit->text()); this->done(QDialog::Accepted); } - - diff --git a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp index 16540906975..9443448038b 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DetailWindow.cpp @@ -23,53 +23,53 @@ DetailWindow::DetailWindow(QWidget* parent) : QWidget(parent) { setupUi(this); - stationView->setRenderHints( QPainter::Antialiasing ); - -/* - DiagramList* list = new DiagramList(); - DiagramList* list2 = new DiagramList(); - - - // ================================================== - // input files should be defined in WaterML - // inserting the details below into the list-objects - // kind of simulates the information that would be - // included in a WaterML-file and is needed for - // display - // ================================================== - - // make up list-object for the first test station - list->setName("Water Level Observation Station: Halberstadt 2002"); - list->setXLabel("Time"); - list->setYLabel("Water Level"); - list->setXUnit("day"); - list->setYUnit("metres"); - list->setColor(QColor(Qt::red)); - list->readList("c:\\project\\timeseries-a.stn"); - - // make up list-object for the second test station - list2->setName("Water Level Observation Station: Oschersleben 2002"); - list2->setXLabel("Time"); - list2->setYLabel("Water Level"); - list2->setXUnit("day"); - list2->setYUnit("metres"); - list2->setColor(QColor(Qt::green)); - list2->readList("c:\\project\\timeseries-b.stn"); - - // ================================================== + stationView->setRenderHints(QPainter::Antialiasing); + + /* + DiagramList* list = new DiagramList(); + DiagramList* list2 = new DiagramList(); + + + // ================================================== + // input files should be defined in WaterML + // inserting the details below into the list-objects + // kind of simulates the information that would be + // included in a WaterML-file and is needed for + // display + // ================================================== + + // make up list-object for the first test station + list->setName("Water Level Observation Station: Halberstadt 2002"); + list->setXLabel("Time"); + list->setYLabel("Water Level"); + list->setXUnit("day"); + list->setYUnit("metres"); + list->setColor(QColor(Qt::red)); + list->readList("c:\\project\\timeseries-a.stn"); + + // make up list-object for the second test station + list2->setName("Water Level Observation Station: Oschersleben 2002"); + list2->setXLabel("Time"); + list2->setYLabel("Water Level"); + list2->setXUnit("day"); + list2->setYUnit("metres"); + list2->setColor(QColor(Qt::green)); + list2->readList("c:\\project\\timeseries-b.stn"); + + // ================================================== - stationView->addGraph(list); - stationView->addGraph(list2); + stationView->addGraph(list); + stationView->addGraph(list2); - resizeWindow(); - */ + resizeWindow(); + */ } DetailWindow::DetailWindow(QString filename, QWidget* parent) : QWidget(parent) { setupUi(this); - stationView->setRenderHints( QPainter::Antialiasing ); + stationView->setRenderHints(QPainter::Antialiasing); std::vector<DiagramList*> lists; DiagramList::readList(filename, lists); @@ -85,16 +85,17 @@ DetailWindow::DetailWindow(QString filename, QWidget* parent) : QWidget(parent) DetailWindow::DetailWindow(DiagramList* list, QWidget* parent) : QWidget(parent) { setupUi(this); - stationView->setRenderHints( QPainter::Antialiasing ); + stationView->setRenderHints(QPainter::Antialiasing); stationView->addGraph(list); resizeWindow(); } -DetailWindow::DetailWindow(std::vector<std::size_t> data, QWidget* parent) : QWidget(parent) +DetailWindow::DetailWindow(std::vector<std::size_t> data, QWidget* parent) + : QWidget(parent) { setupUi(this); std::size_t nEntries = data.size(); - std::vector< std::pair<float, float> > list_data(nEntries); + std::vector<std::pair<float, float>> list_data(nEntries); for (std::size_t i = 0; i < nEntries; i++) { @@ -107,7 +108,7 @@ DetailWindow::DetailWindow(std::vector<std::size_t> data, QWidget* parent) : QWi list->setXUnit("Value"); list->setYUnit("Amount"); list->setName("Histogram"); - stationView->setRenderHints( QPainter::Antialiasing ); + stationView->setRenderHints(QPainter::Antialiasing); stationView->addGraph(list); resizeWindow(); } @@ -122,7 +123,8 @@ void DetailWindow::on_closeButton_clicked() void DetailWindow::resizeWindow() { int width = (stationView->getWidth() > 800) ? 800 : stationView->getWidth(); - int height = (stationView->getHeight() > 600) ? 600 : stationView->getHeight(); + int height = + (stationView->getHeight() > 600) ? 600 : stationView->getHeight(); resize(width, height); } @@ -143,9 +145,10 @@ void DetailWindow::addList(DiagramList* list, QColor c) void DetailWindow::on_addDataButton_clicked() { QSettings settings; - QString fileName = QFileDialog::getOpenFileName( this, "Select data file to open", - settings.value("lastOpenedFileDirectory").toString(), - "Text files (*.txt);;All files (* *.*)"); + QString fileName = QFileDialog::getOpenFileName( + this, "Select data file to open", + settings.value("lastOpenedFileDirectory").toString(), + "Text files (*.txt);;All files (* *.*)"); if (!fileName.isEmpty()) { QDir dir = QDir(fileName); @@ -155,4 +158,3 @@ void DetailWindow::on_addDataButton_clicked() prefs->show(); } } - diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp index b33db5f1cc2..bba60cb056e 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramList.cpp @@ -13,17 +13,17 @@ */ #include "DiagramList.h" -#include "GetDateTime.h" - -#include "BaseLib/Logging.h" -#include "DateTools.h" -#include "StringTools.h" -#include "SensorData.h" #include <QFile> #include <QTextStream> #include <limits> +#include "BaseLib/Logging.h" +#include "DateTools.h" +#include "GetDateTime.h" +#include "SensorData.h" +#include "StringTools.h" + DiagramList::DiagramList() : _xLabel(""), _yLabel(""), _xUnit(""), _yUnit("") {} DiagramList::~DiagramList() = default; @@ -82,7 +82,7 @@ float DiagramList::calcMaxYValue() return max; } -bool DiagramList::getPath(QPainterPath &path, float scaleX, float scaleY) +bool DiagramList::getPath(QPainterPath& path, float scaleX, float scaleY) { QPointF p; if (getPoint(p, 0)) @@ -102,7 +102,7 @@ bool DiagramList::getPath(QPainterPath &path, float scaleX, float scaleY) return false; } -bool DiagramList::getPoint(QPointF &p, std::size_t i) +bool DiagramList::getPoint(QPointF& p, std::size_t i) { if (i < _coords.size()) { @@ -154,10 +154,10 @@ bool DiagramList::getPoint(QPointF &p, std::size_t i) return 1; }*/ -int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) +int DiagramList::readList(const QString& path, std::vector<DiagramList*>& lists) { QFile file(path); - QTextStream in( &file ); + QTextStream in(&file); if (!file.open(QIODevice::ReadOnly)) { @@ -176,16 +176,17 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) { auto* l = new DiagramList; l->setName(fields.takeFirst()); - //value = strtod(BaseLib::replaceStringreplaceString(",", ".", fields.takeFirst().toStdString()).c_str(),0); - //l->setStartDate(startDate); - //l->addNextPoint(0,value); + // value = strtod(BaseLib::replaceStringreplaceString(",", ".", + // fields.takeFirst().toStdString()).c_str(),0); + // l->setStartDate(startDate); + // l->addNextPoint(0,value); lists.push_back(l); } bool first_loop(true); QDateTime startDate; QDateTime currentDate; - unsigned line_count (1); + unsigned line_count(1); while (!in.atEnd()) { @@ -215,7 +216,7 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) ",", ".", fields.takeFirst().toStdString()) .c_str(), nullptr)); - lists[i]->addNextPoint(numberOfSecs,value); + lists[i]->addNextPoint(numberOfSecs, value); } } else @@ -244,16 +245,18 @@ int DiagramList::readList(const QString &path, std::vector<DiagramList*> &lists) return nLists; } -int DiagramList::readList(const SensorData* data, std::vector<DiagramList*> &lists) +int DiagramList::readList(const SensorData* data, + std::vector<DiagramList*>& lists) { - std::vector<SensorDataType> const& time_series_names (data->getTimeSeriesNames()); + std::vector<SensorDataType> const& time_series_names( + data->getTimeSeriesNames()); int nLists(time_series_names.size()); std::vector<std::size_t> time_steps; - if (data->getStepSize()>0) + if (data->getStepSize() > 0) { - const std::size_t start = data->getStartTime(); - const std::size_t end = data->getEndTime(); + const std::size_t start = data->getStartTime(); + const std::size_t end = data->getEndTime(); const std::size_t stepsize = data->getStepSize(); for (std::size_t i = start; i <= end; i += stepsize) { @@ -265,23 +268,25 @@ int DiagramList::readList(const SensorData* data, std::vector<DiagramList*> &lis time_steps = data->getTimeSteps(); } - bool is_date (false); + bool is_date(false); if (!(BaseLib::int2date(time_steps[0])).empty()) { is_date = true; } - std::size_t nValues (time_steps.size()); + std::size_t nValues(time_steps.size()); for (int i = 0; i < nLists; i++) { auto* l = new DiagramList; - l->setName(QString::fromStdString(SensorData::convertSensorDataType2String(time_series_names[i]))); + l->setName(QString::fromStdString( + SensorData::convertSensorDataType2String(time_series_names[i]))); l->setXLabel("Time"); lists.push_back(l); - const std::vector<float> *time_series = data->getTimeSeries(time_series_names[i]); + const std::vector<float>* time_series = + data->getTimeSeries(time_series_names[i]); if (is_date) { @@ -389,5 +394,3 @@ void DiagramList::update() _minY = calcMinYValue(); _maxY = calcMaxYValue(); } - - diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp index e739773f0b8..f70458f486d 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramPrefsDialog.cpp @@ -13,19 +13,20 @@ */ #include "DiagramPrefsDialog.h" + +#include <QCheckBox> +#include <QFileDialog> +#include <QMessageBox> + #include "DetailWindow.h" #include "DiagramList.h" #include "GetDateTime.h" #include "OGSError.h" #include "Station.h" -#include <QCheckBox> -#include <QFileDialog> -#include <QMessageBox> - DiagramPrefsDialog::DiagramPrefsDialog(const GeoLib::Station* stn, - const QString &listName, - //DatabaseConnection* db, + const QString& listName, + // DatabaseConnection* db, QDialog* parent) : QDialog(parent), _window(nullptr) { @@ -44,12 +45,13 @@ DiagramPrefsDialog::DiagramPrefsDialog(GeoLib::Station* stn, QDialog* parent) stationTypeLabel->setText(""); DiagramList::readList(stn->getSensorData(), _list); - fromDateLine->setText(QString::number(stn->getSensorData()->getStartTime())); + fromDateLine->setText( + QString::number(stn->getSensorData()->getStartTime())); toDateLine->setText(QString::number(stn->getSensorData()->getEndTime())); this->createVisibilityCheckboxes(); } -DiagramPrefsDialog::DiagramPrefsDialog(const QString &filename, +DiagramPrefsDialog::DiagramPrefsDialog(const QString& filename, DetailWindow* window, QDialog* parent) : QDialog(parent), _window(window) @@ -125,17 +127,18 @@ void DiagramPrefsDialog::reject() void DiagramPrefsDialog::on_loadFileButton_clicked() { - QString fileName = QFileDialog::getOpenFileName(this, - "Select time series file to open", - "", - "Time series files (*.stn *.txt)"); + QString fileName = + QFileDialog::getOpenFileName(this, + "Select time series file to open", + "", + "Time series files (*.stn *.txt)"); if (!fileName.isEmpty()) { loadFile(fileName); } } -int DiagramPrefsDialog::loadFile(const QString &filename) +int DiagramPrefsDialog::loadFile(const QString& filename) { if (DiagramList::readList(filename, _list)) { @@ -161,16 +164,17 @@ int DiagramPrefsDialog::loadFile(const QString &filename) return 0; } -int DiagramPrefsDialog::loadList(const std::vector< std::pair<QDateTime, float> > &coords) +int DiagramPrefsDialog::loadList( + const std::vector<std::pair<QDateTime, float>>& coords) { if (!coords.empty()) { auto* l = new DiagramList; l->setName(stationTypeLabel->text() + ": " + stationNameLabel->text()); l->setXLabel("Time"); - //l->setYLabel("Water Level"); + // l->setYLabel("Water Level"); l->setXUnit("day"); - //l->setYUnit("metres"); + // l->setYUnit("metres"); l->setColor(QColor(Qt::red)); l->setList(coords); _list.push_back(l); @@ -189,4 +193,3 @@ void DiagramPrefsDialog::createVisibilityCheckboxes() _visability.push_back(box); } } - diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp index 6bb8776674c..f781292a44f 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramScene.cpp @@ -13,8 +13,9 @@ */ #include "DiagramScene.h" -#include <limits> + #include <cmath> +#include <limits> // default size of a new window const float DEFAULTX = 500.0; @@ -26,7 +27,7 @@ const float DEFAULTY = 300.0; */ DiagramScene::DiagramScene(QObject* parent) : QGraphicsScene(parent) { - _bounds.setRect(0,0,1,1); + _bounds.setRect(0, 0, 1, 1); initialize(); } @@ -35,7 +36,8 @@ DiagramScene::DiagramScene(QObject* parent) : QGraphicsScene(parent) * \param list includes all necessary information of the graph to display. * \param parent The parent QObject. */ -DiagramScene::DiagramScene(DiagramList* list, QObject* parent) : QGraphicsScene(parent) +DiagramScene::DiagramScene(DiagramList* list, QObject* parent) + : QGraphicsScene(parent) { setDiagramBoundaries(list); initialize(); @@ -77,7 +79,8 @@ DiagramScene::~DiagramScene() _lists.clear(); } -/// Adds an arrow object to the diagram which might be used as a coordinate axis, etc. +/// Adds an arrow object to the diagram which might be used as a coordinate +/// axis, etc. QArrow* DiagramScene::addArrow(qreal length, qreal angle, QPen& pen) { auto* arrow = new QArrow(length, angle, 8, 5, pen); @@ -86,12 +89,12 @@ QArrow* DiagramScene::addArrow(qreal length, qreal angle, QPen& pen) } /// Adds a caption for a graph beneath the actual diagram. -void DiagramScene::addCaption(const QString &name, QPen &pen) +void DiagramScene::addCaption(const QString& name, QPen& pen) { auto* caption = new QGraphicsItemGroup(nullptr); - QGraphicsLineItem* l = addLine(0,0,100,0,pen); + QGraphicsLineItem* l = addLine(0, 0, 100, 0, pen); QGraphicsTextItem* t = addText(name); - l->setPos(0,0); + l->setPos(0, 0); t->setPos(110, -(t->boundingRect()).height() / 2); caption->addToGroup(l); caption->addToGroup(t); @@ -124,7 +127,8 @@ void DiagramScene::addGraph(DiagramList* list) } /// Adds a grid-object to the scene -QGraphicsGrid* DiagramScene::addGrid(const QRectF &rect, int xTicks, int yTicks, const QPen &pen) +QGraphicsGrid* DiagramScene::addGrid(const QRectF& rect, int xTicks, int yTicks, + const QPen& pen) { QGraphicsGrid* g = new QGraphicsGrid(rect, xTicks, yTicks, true, pen); addItem(g); @@ -132,8 +136,8 @@ QGraphicsGrid* DiagramScene::addGrid(const QRectF &rect, int xTicks, int yTicks, } /// Adds a non-scalable text object to the scene -QNonScalableGraphicsTextItem* DiagramScene::addNonScalableText(const QString &text, - const QFont &font) +QNonScalableGraphicsTextItem* DiagramScene::addNonScalableText( + const QString& text, const QFont& font) { auto* item = new QNonScalableGraphicsTextItem(text); item->setFont(font); @@ -141,7 +145,8 @@ QNonScalableGraphicsTextItem* DiagramScene::addNonScalableText(const QString &te return item; } -/// Resizes a given axis to "nice" dimensions and calculates an adequate number of ticks to be placed on it +/// Resizes a given axis to "nice" dimensions and calculates an adequate number +/// of ticks to be placed on it void DiagramScene::adjustAxis(qreal& min, qreal& max, int& numberOfTicks) { const int MinTicks = 4; @@ -164,10 +169,11 @@ void DiagramScene::adjustAxis(qreal& min, qreal& max, int& numberOfTicks) max = ceil(max / step) * step; } -///Calculates scaling factors to set coordinate system and graphs to default window size +/// Calculates scaling factors to set coordinate system and graphs to default +/// window size void DiagramScene::adjustScaling() { - if ( (_unscaledBounds.width() > 0) && (_unscaledBounds.height() > 0)) + if ((_unscaledBounds.width() > 0) && (_unscaledBounds.height() > 0)) { _scaleX = DEFAULTX / static_cast<float>(_unscaledBounds.width()); _scaleY = DEFAULTY / static_cast<float>(_unscaledBounds.height()); @@ -205,7 +211,8 @@ void DiagramScene::clearGrid() } } -/// Adjusts the underlying grid based on the graphs that are displayed in the diagram +/// Adjusts the underlying grid based on the graphs that are displayed in the +/// diagram void DiagramScene::constructGrid() { // be very careful with scaling parameters here! @@ -220,11 +227,10 @@ void DiagramScene::constructGrid() adjustAxis(yMin, yMax, numYTicks); // adjust boundaries of coordinate system according to scaling - _bounds.setRect( xMin * _scaleX, - yMin * _scaleY, - (xMax - xMin) * _scaleX, - (yMax - yMin) * _scaleY - ); + _bounds.setRect(xMin * _scaleX, + yMin * _scaleY, + (xMax - xMin) * _scaleX, + (yMax - yMin) * _scaleY); QPen pen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); _grid = addGrid(_bounds, numXTicks, numYTicks, pen); @@ -272,7 +278,8 @@ void DiagramScene::drawGraph(DiagramList* list) if (list->getPath(path, _scaleX, _scaleY)) { - QPen pen(list->getColor(), 2, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); + QPen pen(list->getColor(), 2, Qt::SolidLine, Qt::SquareCap, + Qt::RoundJoin); pen.setCosmetic(true); _graphs.push_back(addPath(path, pen)); addCaption(list->getName(), pen); @@ -284,10 +291,10 @@ void DiagramScene::drawGraph(DiagramList* list) * translated back to its original position */ int verticalShift = - static_cast<int>(2 * - (list->minYValue() * - _scaleY) + (_graphs[last]->boundingRect()).height()); - _graphs[last]->setTransform(QTransform(QMatrix(1,0,0,-1,0,verticalShift))); + static_cast<int>(2 * (list->minYValue() * _scaleY) + + (_graphs[last]->boundingRect()).height()); + _graphs[last]->setTransform( + QTransform(QMatrix(1, 0, 0, -1, 0, verticalShift))); } } @@ -316,7 +323,7 @@ void DiagramScene::initialize() QPen pen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); pen.setCosmetic(true); - setXAxis(addArrow(_bounds.width(), 0, pen)); + setXAxis(addArrow(_bounds.width(), 0, pen)); setYAxis(addArrow(_bounds.height(), -90, pen)); _xLabel = addNonScalableText(" "); _yLabel = addNonScalableText(" "); @@ -328,8 +335,8 @@ void DiagramScene::initialize() update(); } -/// Updates the (unscaled) boundaries of the visible coordinate system when a new -/// list is added (boundaries are rescaled in the constructGrid-method +/// Updates the (unscaled) boundaries of the visible coordinate system when a +/// new list is added (boundaries are rescaled in the constructGrid-method void DiagramScene::setDiagramBoundaries(DiagramList* list) { if (!_lists.isEmpty()) @@ -372,16 +379,18 @@ void DiagramScene::setDiagramBoundaries(DiagramList* list) */ void DiagramScene::update() { - _xAxis->setPos(_bounds.left(),getXAxisOffset()); - _yAxis->setPos(getYAxisOffset(),_bounds.bottom()); + _xAxis->setPos(_bounds.left(), getXAxisOffset()); + _yAxis->setPos(getYAxisOffset(), _bounds.bottom()); _xAxis->setLength(_bounds.width()); _yAxis->setLength(_bounds.height()); - _xLabel->setPos( _bounds.left() + _bounds.width() / 2, _bounds.bottom() + 1.5 * MARGIN ); - _yLabel->setPos( _bounds.left() - 1.5 * MARGIN, _bounds.top() + _bounds.height() / 2 ); + _xLabel->setPos(_bounds.left() + _bounds.width() / 2, + _bounds.bottom() + 1.5 * MARGIN); + _yLabel->setPos(_bounds.left() - 1.5 * MARGIN, + _bounds.top() + _bounds.height() / 2); - _xUnit->setPos( _bounds.right(), _bounds.bottom() + 1.2 * MARGIN); - _yUnit->setPos( _bounds.left(), _bounds.top() - 0.5 * MARGIN); + _xUnit->setPos(_bounds.right(), _bounds.bottom() + 1.2 * MARGIN); + _yUnit->setPos(_bounds.left(), _bounds.top() - 0.5 * MARGIN); /* update graphs and their captions */ QRectF rect; @@ -393,6 +402,6 @@ void DiagramScene::update() _graphs[i]->setPos(0, offset); rect = itemsBoundingRect(); - _graphCaptions[i]->setPos(_bounds.left(),rect.bottom() + 10); + _graphCaptions[i]->setPos(_bounds.left(), rect.bottom() + 10); } } diff --git a/Applications/DataExplorer/DataView/DiagramView/DiagramView.cpp b/Applications/DataExplorer/DataView/DiagramView/DiagramView.cpp index 840c32058c2..18ba33927c3 100644 --- a/Applications/DataExplorer/DataView/DiagramView/DiagramView.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/DiagramView.cpp @@ -13,9 +13,11 @@ */ #include "DiagramView.h" -#include <QGraphicsTextItem> + #include <math.h> +#include <QGraphicsTextItem> + DiagramView::DiagramView(QWidget* parent) : QGraphicsView(parent) { _scene = new DiagramScene(); @@ -23,7 +25,8 @@ DiagramView::DiagramView(QWidget* parent) : QGraphicsView(parent) initialize(); } -DiagramView::DiagramView(DiagramList* list, QWidget* parent) : QGraphicsView(parent) +DiagramView::DiagramView(DiagramList* list, QWidget* parent) + : QGraphicsView(parent) { _scene = new DiagramScene(list); setScene(_scene); @@ -56,8 +59,8 @@ int DiagramView::getWidth() */ void DiagramView::initialize() { - //QMatrix currentMatrix = matrix(); - //setMatrix(currentMatrix * scene->getTransformationMatrix()); + // QMatrix currentMatrix = matrix(); + // setMatrix(currentMatrix * scene->getTransformationMatrix()); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -98,9 +101,9 @@ QSize DiagramView::sizeHint() const void DiagramView::resizeEvent(QResizeEvent* event) { - Q_UNUSED (event) + Q_UNUSED(event) update(); - //keepItemAspectRatio(); + // keepItemAspectRatio(); } /** @@ -111,7 +114,7 @@ void DiagramView::resizeEvent(QResizeEvent* event) */ void DiagramView::update() { - //setResizeAnchor(QGraphicsView::AnchorViewCenter); + // setResizeAnchor(QGraphicsView::AnchorViewCenter); QRectF viewRect = _scene->itemsBoundingRect(); _scene->setSceneRect(viewRect); QRectF sceneInView(0 /*_scene->MARGIN*/, DiagramScene::MARGIN / 2, diff --git a/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp b/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp index 2f5204971b1..2eb1a2b5674 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/QArrow.cpp @@ -13,9 +13,11 @@ */ #include "QArrow.h" -#include <QPainter> + #include <math.h> +#include <QPainter> + /** * Creates an arrow as a QGraphicItem. * \param l Length of the arrow @@ -30,39 +32,38 @@ QArrow::QArrow(qreal l, qreal a, qreal hl, qreal hw, QPen& pen, : QGraphicsItem(parent) { _arrowLength = l; - _arrowAngle = a; - _headLength = hl; - _headWidth = hw; - _arrowPen = pen; + _arrowAngle = a; + _headLength = hl; + _headWidth = hw; + _arrowPen = pen; } /** - * Creates an arrow as a QGraphicItem. Length and width of the arrow head are given by default values. - * \param l Length of the arrow - * \param a Orientation of the arrow - * \param pen The pen for drawing the arrow - * \param parent The parent QGraphicsItem. + * Creates an arrow as a QGraphicItem. Length and width of the arrow head are + * given by default values. \param l Length of the arrow \param a Orientation of + * the arrow \param pen The pen for drawing the arrow \param parent The parent + * QGraphicsItem. */ QArrow::QArrow(qreal l, qreal a, QPen& pen, QGraphicsItem* parent) : QGraphicsItem(parent) { _arrowLength = l; - _arrowAngle = a; - _headLength = 8; // default headlength - _headWidth = 5; // default headwidth - _arrowPen = pen; + _arrowAngle = a; + _headLength = 8; // default headlength + _headWidth = 5; // default headwidth + _arrowPen = pen; } QArrow::~QArrow() = default; double QArrow::calcCos(double angle) { - return cos (angle * PI / 180); + return cos(angle * PI / 180); } double QArrow::calcSin(double angle) { - return sin (angle * PI / 180); + return sin(angle * PI / 180); } /// The bounding box of the arrow @@ -88,17 +89,19 @@ double QArrow::getAngle() /** * Overloaded paint-method from QGraphicsItem. - * Basically it draws a line with an arrowhead consisting of two short lines at the end + * Basically it draws a line with an arrowhead consisting of two short lines at + * the end */ -void QArrow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +void QArrow::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, + QWidget* widget) { - Q_UNUSED (option) - Q_UNUSED (widget) + Q_UNUSED(option) + Q_UNUSED(widget) - double ddeltaX = calcCos(_arrowAngle) * _arrowLength; - double ddeltaY = calcSin(_arrowAngle) * _arrowLength; - double theta = atan(ddeltaY / ddeltaX); - double theta2 = (ddeltaX < 0.0) ? (theta + PI) : theta; + double ddeltaX = calcCos(_arrowAngle) * _arrowLength; + double ddeltaY = calcSin(_arrowAngle) * _arrowLength; + double theta = atan(ddeltaY / ddeltaX); + double theta2 = (ddeltaX < 0.0) ? (theta + PI) : theta; int lengthdeltaX = -static_cast<int>(cos(theta2) * _headLength); int lengthdeltaY = -static_cast<int>(sin(theta2) * _headLength); auto widthdeltaX = static_cast<int>(sin(theta2) * _headWidth); diff --git a/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp b/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp index 3eaa741cbd1..5f692161def 100644 --- a/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp +++ b/Applications/DataExplorer/DataView/DiagramView/QGraphicsGrid.cpp @@ -13,6 +13,7 @@ */ #include "QGraphicsGrid.h" + #include <QPainter> /** @@ -23,25 +24,25 @@ * \param parent The parent QGraphicsItem. */ QGraphicsGrid::QGraphicsGrid(QRectF rect, int xCells, int yCells, - QGraphicsItem* parent) : QGraphicsItem(parent) + QGraphicsItem* parent) + : QGraphicsItem(parent) { _numberOfXCells = xCells; _numberOfYCells = yCells; - _bounds = rect; - _showTicks = false; + _bounds = rect; + _showTicks = false; initDefaultPens(); } /** - * Creates a grid by specifying its bounding rectangle using a default pen and no ticks. - * \param x X-coordinate for the lower left corner of the bounding rectangle for the grid. - * \param y Y-coordinate for the lower left corner of the bounding rectangle for the grid. - * \param width Width of the bounding rectangle. - * \param height Height of the bounding rectangle. - * \param xCells The number of grid cells in x-direction. - * \param yCells The number of grid cells in y-direction. - * \param parent The parent QGraphicsItem. + * Creates a grid by specifying its bounding rectangle using a default pen and + * no ticks. \param x X-coordinate for the lower left corner of the bounding + * rectangle for the grid. \param y Y-coordinate for the lower left corner of + * the bounding rectangle for the grid. \param width Width of the bounding + * rectangle. \param height Height of the bounding rectangle. \param xCells The + * number of grid cells in x-direction. \param yCells The number of grid cells + * in y-direction. \param parent The parent QGraphicsItem. */ QGraphicsGrid::QGraphicsGrid(int x, int y, @@ -49,12 +50,13 @@ QGraphicsGrid::QGraphicsGrid(int x, int height, int xCells, int yCells, - QGraphicsItem* parent) : QGraphicsItem(parent) + QGraphicsItem* parent) + : QGraphicsItem(parent) { _numberOfXCells = xCells; _numberOfYCells = yCells; - _bounds = QRectF(x,y,width,height); - _showTicks = false; + _bounds = QRectF(x, y, width, height); + _showTicks = false; initDefaultPens(); } @@ -73,17 +75,18 @@ QGraphicsGrid::QGraphicsGrid(QRectF rect, int yCells, bool ticks, QPen pen, - QGraphicsItem* parent) : QGraphicsItem(parent) + QGraphicsItem* parent) + : QGraphicsItem(parent) { _numberOfXCells = xCells; _numberOfYCells = yCells; - _bounds = rect; - _showTicks = ticks; + _bounds = rect; + _showTicks = ticks; _outside = pen; _outside.setCosmetic(true); - _inside = pen; + _inside = pen; QColor iColour = pen.color(); iColour.setAlpha(125); _inside.setColor(iColour); @@ -92,14 +95,13 @@ QGraphicsGrid::QGraphicsGrid(QRectF rect, } /** - * Creates a grid by specifying its bounding rectangle using a default pen and no ticks. - * \param x X-coordinate for the lower left corner of the bounding rectangle for the grid. - * \param y Y-coordinate for the lower left corner of the bounding rectangle for the grid. - * \param width Width of the bounding rectangle. - * \param height Height of the bounding rectangle. - * \param xCells The number of grid cells in x-direction. - * \param yCells The number of grid cells in y-direction. - * \param ticks Specifies if ticks are displayed for the grid. + * Creates a grid by specifying its bounding rectangle using a default pen and + * no ticks. \param x X-coordinate for the lower left corner of the bounding + * rectangle for the grid. \param y Y-coordinate for the lower left corner of + * the bounding rectangle for the grid. \param width Width of the bounding + * rectangle. \param height Height of the bounding rectangle. \param xCells The + * number of grid cells in x-direction. \param yCells The number of grid cells + * in y-direction. \param ticks Specifies if ticks are displayed for the grid. * \param pen The pen for drawing the grid. * \param parent The parent QGraphicsItem. */ @@ -111,17 +113,18 @@ QGraphicsGrid::QGraphicsGrid(int x, int yCells, bool ticks, QPen pen, - QGraphicsItem* parent) : QGraphicsItem(parent) + QGraphicsItem* parent) + : QGraphicsItem(parent) { _numberOfXCells = xCells; _numberOfYCells = yCells; - _bounds = QRectF(x,y,width,height); - _showTicks = ticks; + _bounds = QRectF(x, y, width, height); + _showTicks = ticks; _outside = pen; _outside.setCosmetic(true); - _inside = pen; + _inside = pen; QColor iColour = pen.color(); iColour.setAlpha(125); _inside.setColor(iColour); @@ -142,7 +145,7 @@ void QGraphicsGrid::initDefaultPens() { QPen in(Qt::gray, 1, Qt::DotLine, Qt::SquareCap, Qt::RoundJoin); QPen out(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); - _inside = in; + _inside = in; _outside = out; _inside.setCosmetic(true); _outside.setCosmetic(true); @@ -153,8 +156,8 @@ void QGraphicsGrid::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { - Q_UNUSED (option) - Q_UNUSED (widget) + Q_UNUSED(option) + Q_UNUSED(widget) if (!_bounds.isValid()) { @@ -182,12 +185,14 @@ void QGraphicsGrid::paint(QPainter* painter, /* draw ticks on x-axis */ if (_showTicks) { - //double label = bounds.left() + (i * bounds.width() / numberOfXCells); + // double label = bounds.left() + (i * bounds.width() / + // numberOfXCells); painter->setPen(_outside); painter->drawLine(x, static_cast<int>(_bounds.bottom()), x, static_cast<int>(_bounds.bottom()) + 5); - //painter->drawText(x - margin, bounds.bottom() + 5, 2*margin, 20, - // Qt::AlignHCenter | Qt::AlignTop, QString::number(label)); + // painter->drawText(x - margin, bounds.bottom() + 5, 2*margin, 20, + // Qt::AlignHCenter | Qt::AlignTop, + // QString::number(label)); } } @@ -207,12 +212,14 @@ void QGraphicsGrid::paint(QPainter* painter, /* draw ticks on y-axis */ if (_showTicks) { - //double label = bounds.top() + (j * bounds.height() / numberOfYCells); + // double label = bounds.top() + (j * bounds.height() / + // numberOfYCells); painter->setPen(_outside); painter->drawLine(static_cast<int>(_bounds.left()) - 5, y, static_cast<int>(_bounds.left()), y); - //painter->drawText(bounds.left() - margin, y - 10, margin - 5, 20, - // Qt::AlignRight | Qt::AlignVCenter, QString::number(label)); + // painter->drawText(bounds.left() - margin, y - 10, margin - 5, 20, + // Qt::AlignRight | Qt::AlignVCenter, + // QString::number(label)); } } } @@ -232,5 +239,5 @@ void QGraphicsGrid::setNumberOfYCells(int yCells) /// Sets the bounding rectangle of the grid. void QGraphicsGrid::setRect(int x, int y, int width, int height) { - _bounds = QRectF(x,y,width,height); + _bounds = QRectF(x, y, width, height); } diff --git a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp index 3eb26e11e63..9dd6725b95a 100644 --- a/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp +++ b/Applications/DataExplorer/DataView/DirectConditionGenerator.cpp @@ -12,22 +12,19 @@ * */ +#include "DirectConditionGenerator.h" + +#include <cmath> #include <fstream> +#include <limits> #include <memory> -#include "BaseLib/Logging.h" - -#include "DirectConditionGenerator.h" - #include "Applications/FileIO/AsciiRasterInterface.h" - -#include "Raster.h" -#include "MeshSurfaceExtraction.h" +#include "BaseLib/Logging.h" #include "Mesh.h" #include "MeshLib/Node.h" - -#include <cmath> -#include <limits> +#include "MeshSurfaceExtraction.h" +#include "Raster.h" const std::vector<std::pair<std::size_t, double>>& DirectConditionGenerator::directToSurfaceNodes(const MeshLib::Mesh& mesh, @@ -67,9 +64,12 @@ DirectConditionGenerator::directToSurfaceNodes(const MeshLib::Mesh& mesh, return _direct_values; } -const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling) +const std::vector<std::pair<std::size_t, double>>& +DirectConditionGenerator::directWithSurfaceIntegration( + MeshLib::Mesh& mesh, const std::string& filename, double scaling) { - if (!_direct_values.empty()) { + if (!_direct_values.empty()) + { ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- Data vector contains outdated values..."); return _direct_values; @@ -77,7 +77,8 @@ const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::di std::unique_ptr<GeoLib::Raster> raster( FileIO::AsciiRasterInterface::readRaster(filename)); - if (!raster) { + if (!raster) + { ERR("Error in DirectConditionGenerator::directWithSurfaceIntegration()" "- could not load raster file."); return _direct_values; @@ -87,12 +88,12 @@ const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::di double const angle(90); std::string const prop_name("bulk_node_ids"); std::unique_ptr<MeshLib::Mesh> surface_mesh( - MeshLib::MeshSurfaceExtraction::getMeshSurface( - mesh, dir, angle, prop_name)); + MeshLib::MeshSurfaceExtraction::getMeshSurface(mesh, dir, angle, + prop_name)); std::vector<double> node_area_vec = MeshLib::MeshSurfaceExtraction::getSurfaceAreaForNodes(*surface_mesh); - const std::vector<MeshLib::Node*> &surface_nodes(surface_mesh->getNodes()); + const std::vector<MeshLib::Node*>& surface_nodes(surface_mesh->getNodes()); const std::size_t nNodes(surface_mesh->getNumberOfNodes()); const double no_data(raster->getHeader().no_data); @@ -119,10 +120,9 @@ const std::vector< std::pair<std::size_t,double> >& DirectConditionGenerator::di return _direct_values; } - -int DirectConditionGenerator::writeToFile(const std::string &name) const +int DirectConditionGenerator::writeToFile(const std::string& name) const { - std::ofstream out( name.c_str(), std::ios::out ); + std::ofstream out(name.c_str(), std::ios::out); if (out) { diff --git a/Applications/DataExplorer/DataView/ElementTreeModel.cpp b/Applications/DataExplorer/DataView/ElementTreeModel.cpp index a7ff0aee23c..493ef0be3e6 100644 --- a/Applications/DataExplorer/DataView/ElementTreeModel.cpp +++ b/Applications/DataExplorer/DataView/ElementTreeModel.cpp @@ -14,15 +14,12 @@ #include "ElementTreeModel.h" +#include "GeoLib/AABB.h" +#include "MeshLib/Elements/Element.h" #include "MeshLib/Mesh.h" -#include "MeshLib/Node.h" #include "MeshLib/MeshInformation.h" -#include "MeshLib/Elements/Element.h" - -#include "GeoLib/AABB.h" - +#include "MeshLib/Node.h" #include "MeshLib/Vtk/VtkMappedMeshSource.h" - #include "TreeItem.h" namespace @@ -48,13 +45,17 @@ ElementTreeModel::ElementTreeModel(QObject* parent) : TreeModel(parent) { QList<QVariant> rootData; delete _rootItem; - rootData << "Name" << "Type" << "" << ""; + rootData << "Name" + << "Type" + << "" + << ""; _rootItem = new TreeItem(rootData, nullptr); } ElementTreeModel::~ElementTreeModel() = default; -void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, const unsigned elem_index) +void ElementTreeModel::setElement( + vtkUnstructuredGridAlgorithm const* const grid, const unsigned elem_index) { beginResetModel(); @@ -73,34 +74,42 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, const MeshLib::Element* elem = mesh->getElement(elem_index); QList<QVariant> elemData; - elemData << "Element " + QString::number(elem_index) << "" << "" << ""; + elemData << "Element " + QString::number(elem_index) << "" + << "" + << ""; auto* elemItem = new TreeItem(elemData, _rootItem); _rootItem->appendChild(elemItem); QList<QVariant> typeData; - typeData << "Element Type: " << QString::fromStdString(MeshElemType2String(elem->getGeomType())); + typeData << "Element Type: " + << QString::fromStdString( + MeshElemType2String(elem->getGeomType())); auto* typeItem = new TreeItem(typeData, elemItem); elemItem->appendChild(typeItem); auto const mat_ids = materialIDs(*mesh); - QString matIdString = !mat_ids ? QString("not defined") : QString::number((*mat_ids)[elem->getID()]); + QString matIdString = !mat_ids ? QString("not defined") + : QString::number((*mat_ids)[elem->getID()]); QList<QVariant> materialData; materialData << "MaterialID: " << matIdString; auto* matItem = new TreeItem(materialData, elemItem); elemItem->appendChild(matItem); QList<QVariant> volData; - volData << "Area/Volume: " << - QString::number(mesh->getElement(elem_index)->getContent()); + volData << "Area/Volume: " + << QString::number(mesh->getElement(elem_index)->getContent()); auto* volItem = new TreeItem(volData, elemItem); elemItem->appendChild(volItem); QList<QVariant> nodeListData; - nodeListData << "Nodes" << "" << "" << ""; + nodeListData << "Nodes" + << "" + << "" + << ""; auto* nodeListItem = new TreeItem(nodeListData, elemItem); elemItem->appendChild(nodeListItem); - //const std::vector<MeshLib::Node*> nodes_vec = grid->getNodes(); + // const std::vector<MeshLib::Node*> nodes_vec = grid->getNodes(); std::size_t nElemNodes = elem->getNumberOfBaseNodes(); for (std::size_t i = 0; i < nElemNodes; i++) { @@ -130,17 +139,22 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) this->clearView(); QList<QVariant> mesh_name; - mesh_name << "Name:" << QString::fromStdString(mesh.getName()) << "" << "" << ""; + mesh_name << "Name:" << QString::fromStdString(mesh.getName()) << "" + << "" + << ""; auto* name_item = new TreeItem(mesh_name, _rootItem); _rootItem->appendChild(name_item); QList<QVariant> nodes_number; - nodes_number << "#Nodes: " << QString::number(mesh.getNumberOfNodes()) << "" << ""; + nodes_number << "#Nodes: " << QString::number(mesh.getNumberOfNodes()) << "" + << ""; auto* nodes_item = new TreeItem(nodes_number, _rootItem); _rootItem->appendChild(nodes_item); QList<QVariant> elements_number; - elements_number << "#Elements: " << QString::number(mesh.getNumberOfElements()) << "" << ""; + elements_number << "#Elements: " + << QString::number(mesh.getNumberOfElements()) << "" + << ""; auto* elements_item = new TreeItem(elements_number, _rootItem); _rootItem->appendChild(elements_item); @@ -161,26 +175,34 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) } QList<QVariant> bounding_box; - bounding_box << "Bounding Box" << "" << "" << ""; + bounding_box << "Bounding Box" + << "" + << "" + << ""; auto* aabb_item = new TreeItem(bounding_box, _rootItem); _rootItem->appendChild(aabb_item); - const GeoLib::AABB aabb (MeshLib::MeshInformation::getBoundingBox(mesh)); + const GeoLib::AABB aabb(MeshLib::MeshInformation::getBoundingBox(mesh)); auto const& min = aabb.getMinPoint(); auto const& max = aabb.getMaxPoint(); QList<QVariant> min_aabb; - min_aabb << "Min:" << QString::number(min[0], 'f') << QString::number(min[1], 'f') << QString::number(min[2], 'f'); + min_aabb << "Min:" << QString::number(min[0], 'f') + << QString::number(min[1], 'f') << QString::number(min[2], 'f'); auto* min_item = new TreeItem(min_aabb, aabb_item); aabb_item->appendChild(min_item); QList<QVariant> max_aabb; - max_aabb << "Max:" << QString::number(max[0], 'f') << QString::number(max[1], 'f') << QString::number(max[2], 'f'); + max_aabb << "Max:" << QString::number(max[0], 'f') + << QString::number(max[1], 'f') << QString::number(max[2], 'f'); auto* max_item = new TreeItem(max_aabb, aabb_item); aabb_item->appendChild(max_item); QList<QVariant> edges; - edges << "Edge Length: " << "[" + QString::number(mesh.getMinEdgeLength(), 'f') + "," << QString::number(mesh.getMaxEdgeLength(), 'f') + "]" << ""; + edges << "Edge Length: " + << "[" + QString::number(mesh.getMinEdgeLength(), 'f') + "," + << QString::number(mesh.getMaxEdgeLength(), 'f') + "]" + << ""; auto* edge_item = new TreeItem(edges, _rootItem); _rootItem->appendChild(edge_item); diff --git a/Applications/DataExplorer/DataView/ElementTreeView.cpp b/Applications/DataExplorer/DataView/ElementTreeView.cpp index 6125988db6f..2770f4a930b 100644 --- a/Applications/DataExplorer/DataView/ElementTreeView.cpp +++ b/Applications/DataExplorer/DataView/ElementTreeView.cpp @@ -15,20 +15,17 @@ #include "ElementTreeView.h" +#include <QModelIndex> + #include "ElementTreeModel.h" #include "TreeItem.h" -#include <QModelIndex> - -ElementTreeView::ElementTreeView( QWidget* parent) -: QTreeView(parent) -{ -} +ElementTreeView::ElementTreeView(QWidget* parent) : QTreeView(parent) {} void ElementTreeView::updateView() { setAlternatingRowColors(true); - setColumnWidth(0,150); + setColumnWidth(0, 150); std::size_t nColumns = (this->model() != nullptr) ? this->model()->columnCount() : 0; for (std::size_t i = 1; i < nColumns; i++) @@ -38,7 +35,8 @@ void ElementTreeView::updateView() this->expandAll(); } -void ElementTreeView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected ) +void ElementTreeView::selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) { Q_UNUSED(deselected); if (!selected.isEmpty()) @@ -47,12 +45,16 @@ void ElementTreeView::selectionChanged( const QItemSelection &selected, const QI const QModelIndex idx = *(selected.indexes().begin()); if (idx.parent().isValid()) - { // not root node - if (idx.parent().parent().isValid()) // not property node + { // not root node + if (idx.parent().parent().isValid()) // not property node { - const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); - const unsigned node_index = tree_item->data(0).toString().mid(5).toUInt(); - emit nodeSelected(static_cast<ElementTreeModel*>(this->model())->getSource(), node_index, false); + const TreeItem* tree_item = + static_cast<TreeModel*>(this->model())->getItem(idx); + const unsigned node_index = + tree_item->data(0).toString().mid(5).toUInt(); + emit nodeSelected( + static_cast<ElementTreeModel*>(this->model())->getSource(), + node_index, false); } } } diff --git a/Applications/DataExplorer/DataView/FemConditionModel.cpp b/Applications/DataExplorer/DataView/FemConditionModel.cpp index 04ef46567fb..4a6f1ff26af 100644 --- a/Applications/DataExplorer/DataView/FemConditionModel.cpp +++ b/Applications/DataExplorer/DataView/FemConditionModel.cpp @@ -12,7 +12,6 @@ #include "Applications/DataHolderLib/BoundaryCondition.h" #include "Applications/DataHolderLib/SourceTerm.h" - #include "TreeItem.h" /** diff --git a/Applications/DataExplorer/DataView/FemConditionView.cpp b/Applications/DataExplorer/DataView/FemConditionView.cpp index 6a3b6c23a5e..13fdd235113 100644 --- a/Applications/DataExplorer/DataView/FemConditionView.cpp +++ b/Applications/DataExplorer/DataView/FemConditionView.cpp @@ -11,11 +11,11 @@ #include "FemConditionView.h" +#include <QModelIndex> + #include "CondItem.h" #include "FemConditionModel.h" -#include <QModelIndex> - FemConditionView::FemConditionView(QWidget* parent) : QTreeView(parent) {} void FemConditionView::updateView() diff --git a/Applications/DataExplorer/DataView/GEOModels.cpp b/Applications/DataExplorer/DataView/GEOModels.cpp index 74a91f92337..952f6245763 100644 --- a/Applications/DataExplorer/DataView/GEOModels.cpp +++ b/Applications/DataExplorer/DataView/GEOModels.cpp @@ -15,15 +15,12 @@ // ** INCLUDES ** #include "GEOModels.h" -#include "BaseLib/Logging.h" - #include "Applications/FileIO/Legacy/createSurface.h" +#include "BaseLib/Logging.h" +#include "GeoLib/Triangle.h" #include "GeoTreeModel.h" -#include "StationTreeModel.h" - #include "OGSError.h" - -#include "GeoLib/Triangle.h" +#include "StationTreeModel.h" GEOModels::GEOModels(GeoLib::GEOObjects& geo_objects, QObject* parent /*= 0*/) : QObject(parent), _geo_objects(geo_objects) @@ -40,11 +37,11 @@ GEOModels::~GEOModels() delete _geoModel; } -void GEOModels::updateGeometry(const std::string &geo_name) +void GEOModels::updateGeometry(const std::string& geo_name) { - GeoLib::PointVec* points (_geo_objects.getPointVecObj(geo_name)); - GeoLib::PolylineVec* lines (_geo_objects.getPolylineVecObj(geo_name)); - GeoLib::SurfaceVec* surfaces (_geo_objects.getSurfaceVecObj(geo_name)); + GeoLib::PointVec* points(_geo_objects.getPointVecObj(geo_name)); + GeoLib::PolylineVec* lines(_geo_objects.getPolylineVecObj(geo_name)); + GeoLib::SurfaceVec* surfaces(_geo_objects.getSurfaceVecObj(geo_name)); if (points) { @@ -57,7 +54,8 @@ void GEOModels::updateGeometry(const std::string &geo_name) { emit geoDataRemoved(_geoModel, geo_name, GeoLib::GEOTYPE::POLYLINE); this->_geoModel->removeGeoList(geo_name, GeoLib::GEOTYPE::POLYLINE); - _geoModel->addPolylineList(QString::fromStdString(geo_name), *lines); + _geoModel->addPolylineList(QString::fromStdString(geo_name), + *lines); emit geoDataAdded(_geoModel, geo_name, GeoLib::GEOTYPE::POLYLINE); } @@ -65,7 +63,8 @@ void GEOModels::updateGeometry(const std::string &geo_name) { emit geoDataRemoved(_geoModel, geo_name, GeoLib::GEOTYPE::SURFACE); this->_geoModel->removeGeoList(geo_name, GeoLib::GEOTYPE::SURFACE); - _geoModel->addSurfaceList(QString::fromStdString(geo_name), *surfaces); + _geoModel->addSurfaceList(QString::fromStdString(geo_name), + *surfaces); emit geoDataAdded(_geoModel, geo_name, GeoLib::GEOTYPE::SURFACE); } } @@ -187,7 +186,8 @@ void GEOModels::connectPolylineSegments( if (new_line) { - // insert result in a new vector of polylines (because the GEOObjects::appendPolylines()-method requires a vector) + // insert result in a new vector of polylines (because the + // GEOObjects::appendPolylines()-method requires a vector) std::vector<GeoLib::Polyline*> connected_ply; connected_ply.push_back(new_line); @@ -240,29 +240,31 @@ void GEOModels::addNameForElement(std::string const& geometry_name, { if (object_type == GeoLib::GEOTYPE::POINT) { - _geo_objects.getPointVecObj(geometry_name)->setNameForElement(id, new_name); + _geo_objects.getPointVecObj(geometry_name) + ->setNameForElement(id, new_name); } else if (object_type == GeoLib::GEOTYPE::POLYLINE) { - _geo_objects.getPolylineVecObj(geometry_name)->setNameForElement(id, new_name); + _geo_objects.getPolylineVecObj(geometry_name) + ->setNameForElement(id, new_name); } else if (object_type == GeoLib::GEOTYPE::SURFACE) { - _geo_objects.getSurfaceVecObj(geometry_name)->setNameForElement(id, new_name); + _geo_objects.getSurfaceVecObj(geometry_name) + ->setNameForElement(id, new_name); } else ERR("GEOModels::addNameForElement() - Unknown GEOTYPE {:s}.", GeoLib::convertGeoTypeToString(object_type)); } -void GEOModels::addNameForObjectPoints(const std::string &geometry_name, +void GEOModels::addNameForObjectPoints(const std::string& geometry_name, const GeoLib::GEOTYPE object_type, - const std::string &geo_object_name, - const std::string &new_name) + const std::string& geo_object_name, + const std::string& new_name) { - const GeoLib::GeoObject* obj = _geo_objects.getGeoObject(geometry_name, - object_type, - geo_object_name); + const GeoLib::GeoObject* obj = + _geo_objects.getGeoObject(geometry_name, object_type, geo_object_name); GeoLib::PointVec* pnt_vec = _geo_objects.getPointVecObj(geometry_name); if (object_type == GeoLib::GEOTYPE::POLYLINE) { diff --git a/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp b/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp index e1ae987cd00..e8cf72ff6f8 100644 --- a/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp +++ b/Applications/DataExplorer/DataView/GMSHPrefsDialog.cpp @@ -16,18 +16,20 @@ #include "StringTools.h" // Qt/Base -#include "StrictDoubleValidator.h" -#include "StrictIntValidator.h" - -#include "GEOObjects.h" -#include "GMSHPrefsDialog.h" #include <QStringList> #include <QStringListModel> +#include "GEOObjects.h" +#include "GMSHPrefsDialog.h" #include "OGSError.h" +#include "StrictDoubleValidator.h" +#include "StrictIntValidator.h" -GMSHPrefsDialog::GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, QDialog* parent) - : QDialog(parent), _allGeo(new QStringListModel), _selGeo(new QStringListModel) +GMSHPrefsDialog::GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, + QDialog* parent) + : QDialog(parent), + _allGeo(new QStringListModel), + _selGeo(new QStringListModel) { setupUi(this); @@ -40,15 +42,15 @@ GMSHPrefsDialog::GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, QDialog* // object will be deleted by Qt auto* max_number_of_points_in_quadtree_leaf_validator( new StrictIntValidator(1, 1000, this->param1)); - param1->setValidator (max_number_of_points_in_quadtree_leaf_validator); + param1->setValidator(max_number_of_points_in_quadtree_leaf_validator); // object will be deleted by Qt auto* mesh_density_scaling_pnts_validator( new StrictDoubleValidator(0, 1, 5, this->param2)); - param2->setValidator (mesh_density_scaling_pnts_validator); + param2->setValidator(mesh_density_scaling_pnts_validator); // object will be deleted by Qt# auto* mesh_density_scaling_stations_validator( new StrictDoubleValidator(0, 1, 5, this->param3)); - param3->setValidator (mesh_density_scaling_stations_validator); + param3->setValidator(mesh_density_scaling_stations_validator); auto geoNames = geoObjects.getGeometryNames(); @@ -76,7 +78,7 @@ GMSHPrefsDialog::GMSHPrefsDialog(GeoLib::GEOObjects const& geoObjects, QDialog* _allGeo->setStringList(list); this->allGeoView->setModel(_allGeo); this->selectedGeoView->setModel(_selGeo); - this->radioAdaptive->toggle(); // default is adaptive meshing + this->radioAdaptive->toggle(); // default is adaptive meshing this->on_radioAdaptive_toggled(true); } @@ -88,7 +90,8 @@ GMSHPrefsDialog::~GMSHPrefsDialog() void GMSHPrefsDialog::on_selectGeoButton_pressed() { - QModelIndexList selected = this->allGeoView->selectionModel()->selectedIndexes(); + QModelIndexList selected = + this->allGeoView->selectionModel()->selectedIndexes(); QStringList list = _selGeo->stringList(); for (auto& index : selected) @@ -102,7 +105,8 @@ void GMSHPrefsDialog::on_selectGeoButton_pressed() void GMSHPrefsDialog::on_deselectGeoButton_pressed() { - QModelIndexList selected = this->selectedGeoView->selectionModel()->selectedIndexes(); + QModelIndexList selected = + this->selectedGeoView->selectionModel()->selectedIndexes(); QStringList list = _allGeo->stringList(); for (auto& index : selected) @@ -116,14 +120,14 @@ void GMSHPrefsDialog::on_deselectGeoButton_pressed() void GMSHPrefsDialog::on_radioAdaptive_toggled(bool isTrue) { - if (isTrue) // meshing set to adaptive + if (isTrue) // meshing set to adaptive { this->param1->setEnabled(true); this->param2->setEnabled(true); this->param3->setEnabled(true); this->param4->setEnabled(false); } - else // meshing set to homogeneous + else // meshing set to homogeneous { this->param1->setEnabled(false); this->param2->setEnabled(false); @@ -136,26 +140,29 @@ void GMSHPrefsDialog::accept() { if (this->_selGeo->stringList().empty()) { - OGSError::box("No geometry selected. Geometric data\n is necessary for mesh generation."); + OGSError::box( + "No geometry selected. Geometric data\n is necessary for mesh " + "generation."); return; } - std::vector<std::string> selectedObjects = this->getSelectedObjects(_selGeo->stringList()); - unsigned max_number_of_points_in_quadtree_leaf (10); + std::vector<std::string> selectedObjects = + this->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); + double mesh_density_scaling_stations(0.05); double val4(-1); if (this->radioAdaptive->isChecked()) { - double const min_scaling_factor (1e-10); + double const min_scaling_factor(1e-10); max_number_of_points_in_quadtree_leaf = BaseLib::str2number<unsigned>(param1->text().toStdString()); if (max_number_of_points_in_quadtree_leaf == 0) { max_number_of_points_in_quadtree_leaf = 10; } - mesh_density_scaling_pnts = fabs (param2->text().toDouble()); + mesh_density_scaling_pnts = fabs(param2->text().toDouble()); if (mesh_density_scaling_pnts < min_scaling_factor) { mesh_density_scaling_pnts = min_scaling_factor; diff --git a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp index a48e29bb64d..7d08d2af184 100644 --- a/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp +++ b/Applications/DataExplorer/DataView/GeoOnMeshMappingDialog.cpp @@ -13,15 +13,14 @@ */ #include "GeoOnMeshMappingDialog.h" -#include "Mesh.h" - +#include "Mesh.h" #include "OGSError.h" GeoOnMeshMappingDialog::GeoOnMeshMappingDialog( std::vector<std::unique_ptr<MeshLib::Mesh>> const& mesh_vec, QDialog* parent) -: QDialog(parent), _new_geo_name("") + : QDialog(parent), _new_geo_name("") { setupUi(this); @@ -49,7 +48,8 @@ void GeoOnMeshMappingDialog::on_meshNameComboBox_currentIndexChanged(int idx) bool is_enabled(idx != 1); this->normalMappingButton->setEnabled(is_enabled); this->advancedMappingButton->setEnabled(is_enabled); - this->geoNameEdit->setEnabled(is_enabled && this->advancedMappingButton->isChecked()); + this->geoNameEdit->setEnabled(is_enabled && + this->advancedMappingButton->isChecked()); } void GeoOnMeshMappingDialog::accept() @@ -65,5 +65,3 @@ void GeoOnMeshMappingDialog::accept() } this->done(QDialog::Accepted); } - - diff --git a/Applications/DataExplorer/DataView/GeoTabWidget.cpp b/Applications/DataExplorer/DataView/GeoTabWidget.cpp index 9e7a3363953..954abc56408 100644 --- a/Applications/DataExplorer/DataView/GeoTabWidget.cpp +++ b/Applications/DataExplorer/DataView/GeoTabWidget.cpp @@ -15,14 +15,18 @@ // ** INCLUDES ** #include "GeoTabWidget.h" -GeoTabWidget::GeoTabWidget( QWidget* parent /*= 0*/ ) - : QWidget(parent) +GeoTabWidget::GeoTabWidget(QWidget* parent /*= 0*/) : QWidget(parent) { setupUi(this); - connect(this->openGeoPushButton, SIGNAL(clicked()), this->treeView, SLOT(addGeometry())); - connect(this->saveGeoPushButton, SIGNAL(clicked()), this->treeView, SLOT(writeToFile())); - connect(this->removeGeoPushButton, SIGNAL(clicked()), this->treeView, SLOT(removeGeometry())); - connect(this->treeView, SIGNAL(enableSaveButton(bool)), this, SLOT(enableSaveButton(bool))); - connect(this->treeView, SIGNAL(enableRemoveButton(bool)), this, SLOT(enableRemoveButton(bool))); + connect(this->openGeoPushButton, SIGNAL(clicked()), this->treeView, + SLOT(addGeometry())); + connect(this->saveGeoPushButton, SIGNAL(clicked()), this->treeView, + SLOT(writeToFile())); + connect(this->removeGeoPushButton, SIGNAL(clicked()), this->treeView, + SLOT(removeGeometry())); + connect(this->treeView, SIGNAL(enableSaveButton(bool)), this, + SLOT(enableSaveButton(bool))); + connect(this->treeView, SIGNAL(enableRemoveButton(bool)), this, + SLOT(enableRemoveButton(bool))); } diff --git a/Applications/DataExplorer/DataView/GeoTreeModel.cpp b/Applications/DataExplorer/DataView/GeoTreeModel.cpp index 2d8023018fb..5df9e13f42e 100644 --- a/Applications/DataExplorer/DataView/GeoTreeModel.cpp +++ b/Applications/DataExplorer/DataView/GeoTreeModel.cpp @@ -12,43 +12,53 @@ * */ -#include "BaseLib/Logging.h" +#include "GeoTreeModel.h" +#include "BaseLib/Logging.h" +#include "GeoLib/Triangle.h" #include "GeoObjectListItem.h" #include "GeoTreeItem.h" -#include "GeoTreeModel.h" #include "OGSError.h" -#include "GeoLib/Triangle.h" - /** * Constructor. */ -GeoTreeModel::GeoTreeModel( QObject* parent ) - : TreeModel(parent) +GeoTreeModel::GeoTreeModel(QObject* parent) : TreeModel(parent) { QList<QVariant> rootData; delete _rootItem; - rootData << "Id" << "x" << "y" << "z" << "name "; + rootData << "Id" + << "x" + << "y" + << "z" + << "name "; _rootItem = new GeoTreeItem(rootData, nullptr, nullptr); } GeoTreeModel::~GeoTreeModel() = default; -void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVec) +void GeoTreeModel::addPointList(QString geoName, + GeoLib::PointVec const& pointVec) { beginResetModel(); const std::vector<GeoLib::Point*>* points = pointVec.getVector(); QList<QVariant> geoData; - geoData << QVariant(geoName) << "" << "" << "" << ""; + geoData << QVariant(geoName) << "" + << "" + << "" + << ""; auto* geo(new GeoTreeItem(geoData, _rootItem)); _lists.push_back(geo); _rootItem->appendChild(geo); QList<QVariant> pointData; - pointData << "Points" << "" << "" << "" << ""; + pointData << "Points" + << "" + << "" + << "" + << ""; auto* pointList = new GeoObjectListItem(pointData, geo, points, GeoLib::GEOTYPE::POINT); geo->appendChild(pointList); @@ -57,17 +67,14 @@ void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVe for (std::size_t j = 0; j < nPoints; j++) { - const GeoLib::Point &pnt(*(*points)[j]); + const GeoLib::Point& pnt(*(*points)[j]); QList<QVariant> pnt_data; pnt_data.reserve(5); - pnt_data << static_cast<unsigned>(j) - << QString::number(pnt[0], 'f') - << QString::number(pnt[1], 'f') - << QString::number(pnt[2], 'f') + pnt_data << static_cast<unsigned>(j) << QString::number(pnt[0], 'f') + << QString::number(pnt[1], 'f') << QString::number(pnt[2], 'f') << ""; - pointList->appendChild(new GeoTreeItem(pnt_data, - pointList, - static_cast<const GeoLib::Point*>(&pnt))); + pointList->appendChild(new GeoTreeItem( + pnt_data, pointList, static_cast<const GeoLib::Point*>(&pnt))); } for (auto pnt = pointVec.getNameIDMapBegin(); @@ -84,7 +91,8 @@ void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVe endResetModel(); } -void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& polylineVec) +void GeoTreeModel::addPolylineList(QString geoName, + GeoLib::PolylineVec const& polylineVec) { beginResetModel(); @@ -109,7 +117,10 @@ void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& p const std::vector<GeoLib::Polyline*>* lines = polylineVec.getVector(); QList<QVariant> plyData; - plyData << "Polylines" << "" << "" << ""; + plyData << "Polylines" + << "" + << "" + << ""; auto* plyList = new GeoObjectListItem(plyData, geo, lines, GeoLib::GEOTYPE::POLYLINE); geo->appendChild(plyList); @@ -118,7 +129,8 @@ void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& p endResetModel(); } -void GeoTreeModel::appendPolylines(const std::string &name, GeoLib::PolylineVec const& polylineVec) +void GeoTreeModel::appendPolylines(const std::string& name, + GeoLib::PolylineVec const& polylineVec) { for (auto& list : _lists) { @@ -153,9 +165,11 @@ void GeoTreeModel::addChildren(GeoObjectListItem* plyList, { QList<QVariant> line_data; line_data.reserve(4); - line_data << "Line " + QString::number(i) << "" << "" << ""; + line_data << "Line " + QString::number(i) << "" + << "" + << ""; - const GeoLib::Polyline &line(*(lines[i])); + const GeoLib::Polyline& line(*(lines[i])); auto* lineItem(new GeoTreeItem(line_data, plyList, &line)); plyList->appendChild(lineItem); @@ -185,7 +199,8 @@ void GeoTreeModel::addChildren(GeoObjectListItem* plyList, INFO("{:d} polylines added.", end_index - start_index); } -void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& surfaceVec) +void GeoTreeModel::addSurfaceList(QString geoName, + GeoLib::SurfaceVec const& surfaceVec) { beginResetModel(); @@ -210,7 +225,10 @@ void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& sur const std::vector<GeoLib::Surface*>* surfaces = surfaceVec.getVector(); QList<QVariant> sfcData; - sfcData << "Surfaces" << "" << "" << ""; + sfcData << "Surfaces" + << "" + << "" + << ""; auto* sfcList = new GeoObjectListItem(sfcData, geo, surfaces, GeoLib::GEOTYPE::SURFACE); geo->appendChild(sfcList); @@ -219,7 +237,8 @@ void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& sur endResetModel(); } -void GeoTreeModel::appendSurfaces(const std::string &name, GeoLib::SurfaceVec const& surfaceVec) +void GeoTreeModel::appendSurfaces(const std::string& name, + GeoLib::SurfaceVec const& surfaceVec) { for (auto& list : _lists) { @@ -251,15 +270,17 @@ void GeoTreeModel::addChildren(GeoObjectListItem* sfcList, { const std::vector<GeoLib::Surface*>* surfaces = surface_vec.getVector(); - const std::vector<GeoLib::Point*> &nodesVec(*((*surfaces)[start_index]->getPointVec())); + const std::vector<GeoLib::Point*>& nodesVec( + *((*surfaces)[start_index]->getPointVec())); for (std::size_t i = start_index; i < end_index; i++) { QList<QVariant> surface; surface.reserve(4); - surface << "Surface " + QString::number(i) << "" << - "" << ""; + surface << "Surface " + QString::number(i) << "" + << "" + << ""; - const GeoLib::Surface &sfc(*(*surfaces)[i]); + const GeoLib::Surface& sfc(*(*surfaces)[i]); auto* surfaceItem(new GeoTreeItem(surface, sfcList, &sfc)); sfcList->appendChild(surfaceItem); @@ -268,7 +289,7 @@ void GeoTreeModel::addChildren(GeoObjectListItem* sfcList, { QList<QVariant> elem; elem.reserve(4); - const GeoLib::Triangle &triangle(*sfc[j]); + const GeoLib::Triangle& triangle(*sfc[j]); elem << j << static_cast<int>(triangle[0]) << static_cast<int>(triangle[1]) << static_cast<int>(triangle[2]); @@ -279,7 +300,7 @@ void GeoTreeModel::addChildren(GeoObjectListItem* sfcList, { QList<QVariant> node; node.reserve(4); - const GeoLib::Point &pnt(*(nodesVec[triangle[k]])); + const GeoLib::Point& pnt(*(nodesVec[triangle[k]])); node << static_cast<int>(triangle[k]) << QString::number(pnt[0], 'f') << QString::number(pnt[1], 'f') @@ -332,8 +353,8 @@ void GeoTreeModel::removeGeoList(const std::string& name, GeoLib::GEOTYPE type) { for (int j = 0; j < _lists[i]->childCount(); j++) { - if (type == - static_cast<GeoObjectListItem*>(_lists[i]->child(j))->getType()) + if (type == static_cast<GeoObjectListItem*>(_lists[i]->child(j)) + ->getType()) { QModelIndex index = createIndex(j, 0, _lists[i]->child(j)); removeRows(0, _lists[i]->child(j)->childCount(), index); @@ -350,7 +371,8 @@ void GeoTreeModel::removeGeoList(const std::string& name, GeoLib::GEOTYPE type) } } -vtkPolyDataAlgorithm* GeoTreeModel::vtkSource(const std::string &name, GeoLib::GEOTYPE type) const +vtkPolyDataAlgorithm* GeoTreeModel::vtkSource(const std::string& name, + GeoLib::GEOTYPE type) const { std::size_t nLists = _lists.size(); for (std::size_t i = 0; i < nLists; i++) @@ -371,7 +393,7 @@ vtkPolyDataAlgorithm* GeoTreeModel::vtkSource(const std::string &name, GeoLib::G return nullptr; } -void GeoTreeModel::setNameForItem(const std::string &name, +void GeoTreeModel::setNameForItem(const std::string& name, GeoLib::GEOTYPE type, std::size_t id, std::string item_name) @@ -379,20 +401,20 @@ void GeoTreeModel::setNameForItem(const std::string &name, std::string geo_type_str; int col_idx(1); - switch(type) + switch (type) { - case GeoLib::GEOTYPE::POINT: - geo_type_str = "Points"; - col_idx = 4; // for points the name is at a different position - break; - case GeoLib::GEOTYPE::POLYLINE: - geo_type_str = "Polylines"; - break; - case GeoLib::GEOTYPE::SURFACE: - geo_type_str = "Surfaces"; - break; - default: - geo_type_str = ""; + case GeoLib::GEOTYPE::POINT: + geo_type_str = "Points"; + col_idx = 4; // for points the name is at a different position + break; + case GeoLib::GEOTYPE::POLYLINE: + geo_type_str = "Polylines"; + break; + case GeoLib::GEOTYPE::SURFACE: + geo_type_str = "Surfaces"; + break; + default: + geo_type_str = ""; } auto it = find_if(_lists.begin(), _lists.end(), [&name](GeoTreeItem* geo) { diff --git a/Applications/DataExplorer/DataView/GeoTreeView.cpp b/Applications/DataExplorer/DataView/GeoTreeView.cpp index 91beffebd06..dc1416b9084 100644 --- a/Applications/DataExplorer/DataView/GeoTreeView.cpp +++ b/Applications/DataExplorer/DataView/GeoTreeView.cpp @@ -12,6 +12,8 @@ * */ +#include "GeoTreeView.h" + #include <QFileDialog> #include <QMenu> #include <QSettings> @@ -19,42 +21,40 @@ #include "GeoObjectListItem.h" #include "GeoTreeItem.h" #include "GeoTreeModel.h" -#include "GeoTreeView.h" -#include "OGSError.h" #include "ImportFileTypes.h" #include "LastSavedFileDirectory.h" +#include "OGSError.h" - -GeoTreeView::GeoTreeView(QWidget* parent) : QTreeView(parent) -{ -} +GeoTreeView::GeoTreeView(QWidget* parent) : QTreeView(parent) {} void GeoTreeView::updateView() { setAlternatingRowColors(true); - setColumnWidth(0,150); - setColumnWidth(1,75); - setColumnWidth(2,75); - setColumnWidth(3,75); + setColumnWidth(0, 150); + setColumnWidth(1, 75); + setColumnWidth(2, 75); + setColumnWidth(3, 75); } void GeoTreeView::on_Clicked(QModelIndex idx) { - qDebug("%d, %d",idx.parent().row(), idx.row()); + qDebug("%d, %d", idx.parent().row(), idx.row()); } -void GeoTreeView::selectionChanged( const QItemSelection &selected, - const QItemSelection &deselected ) +void GeoTreeView::selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) { Q_UNUSED(deselected); if (!selected.isEmpty()) { const QModelIndex idx = *(selected.indexes().begin()); - const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); + const TreeItem* tree_item = + static_cast<TreeModel*>(this->model())->getItem(idx); emit removeGeoItemSelection(); - const GeoObjectListItem* geo_object = dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()); - if (geo_object) // geometry object + const GeoObjectListItem* geo_object = + dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()); + if (geo_object) // geometry object { emit enableSaveButton(false); emit enableRemoveButton(false); @@ -62,12 +62,12 @@ void GeoTreeView::selectionChanged( const QItemSelection &selected, } else { - if (!idx.parent().isValid()) // geometry item + if (!idx.parent().isValid()) // geometry item { emit enableSaveButton(true); emit enableRemoveButton(true); } - else // line points or surface triangles + else // line points or surface triangles { emit enableSaveButton(false); const auto* geo_type = @@ -94,7 +94,8 @@ void GeoTreeView::selectionChanged( const QItemSelection &selected, } // highlight a point for an expanded surface - list_item = dynamic_cast<GeoObjectListItem*>(tree_item->parentItem()->parentItem()->parentItem()); + list_item = dynamic_cast<GeoObjectListItem*>( + tree_item->parentItem()->parentItem()->parentItem()); if (list_item && list_item->getType() == GeoLib::GEOTYPE::SURFACE) { @@ -110,16 +111,14 @@ void GeoTreeView::selectionChanged( const QItemSelection &selected, emit enableRemoveButton(false); } } - } - } - //emit itemSelectionChanged(selected, deselected); - //return QTreeView::selectionChanged(selected, deselected); + // emit itemSelectionChanged(selected, deselected); + // return QTreeView::selectionChanged(selected, deselected); } -void GeoTreeView::selectionChangedFromOutside( const QItemSelection &selected, - const QItemSelection &deselected ) +void GeoTreeView::selectionChangedFromOutside(const QItemSelection& selected, + const QItemSelection& deselected) { QItemSelectionModel* selModel = this->selectionModel(); @@ -131,7 +130,7 @@ void GeoTreeView::selectionChangedFromOutside( const QItemSelection &selected, QTreeView::selectionChanged(selected, deselected); } -void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) +void GeoTreeView::contextMenuEvent(QContextMenuEvent* event) { QModelIndex index = this->selectionModel()->currentIndex(); auto* item = static_cast<TreeItem*>(index.internalPointer()); @@ -146,8 +145,8 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) { auto const* convertToStationAction = menu.addAction("Convert to Stations"); - connect(convertToStationAction, SIGNAL(triggered()), - this, SLOT(convertPointsToStations())); + connect(convertToStationAction, SIGNAL(triggered()), this, + SLOT(convertPointsToStations())); } if (list->getType() == GeoLib::GEOTYPE::POLYLINE) { @@ -157,8 +156,9 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) SLOT(connectPolylines())); } menu.addSeparator(); - //QAction* removeAction = menu.addAction("Remove " + item->data(0).toString()); - //connect(removeAction, SIGNAL(triggered()), this, SLOT(removeList())); + // QAction* removeAction = menu.addAction("Remove " + + // item->data(0).toString()); connect(removeAction, SIGNAL(triggered()), + // this, SLOT(removeList())); } else { @@ -174,12 +174,15 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) if (parent != nullptr) { QMenu* cond_menu = new QMenu("Set FEM Condition"); - //menu.addMenu(cond_menu); + // menu.addMenu(cond_menu); QAction* addCondAction = cond_menu->addAction("On object..."); - QAction* addCondPointAction = cond_menu->addAction("On all points..."); + QAction* addCondPointAction = + cond_menu->addAction("On all points..."); QAction* addNameAction = menu.addAction("Set name..."); - connect(addCondAction, SIGNAL(triggered()), this, SLOT(setObjectAsCondition())); - connect(addNameAction, SIGNAL(triggered()), this, SLOT(setNameForElement())); + connect(addCondAction, SIGNAL(triggered()), this, + SLOT(setObjectAsCondition())); + connect(addNameAction, SIGNAL(triggered()), this, + SLOT(setNameForElement())); if (parent->getType() == GeoLib::GEOTYPE::POINT) { @@ -194,19 +197,25 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) // The current index refers to the name of a geometry-object else if (item->childCount() > 0) { - if (item->child(0)->data(0).toString().compare("Points") == 0) // clumsy way to find out + if (item->child(0)->data(0).toString().compare("Points") == + 0) // clumsy way to find out { - //QAction* saveAction = menu.addAction("Save geometry..."); + // QAction* saveAction = menu.addAction("Save geometry..."); QAction* mapAction = menu.addAction("Map geometry..."); - //QAction* addCNDAction = menu.addAction("Load FEM Conditions..."); - //QAction* saveCondAction = menu.addAction("Save FEM conditions..."); + // QAction* addCNDAction = menu.addAction("Load FEM + // Conditions..."); QAction* saveCondAction = + // menu.addAction("Save FEM conditions..."); menu.addSeparator(); - //QAction* removeAction = menu.addAction("Remove geometry"); - //connect(saveAction, SIGNAL(triggered()), this, SLOT(writeToFile())); - connect(mapAction, SIGNAL(triggered()), this, SLOT(mapGeometry())); - //connect(addCNDAction, SIGNAL(triggered()), this, SLOT(loadFEMConditions())); - //connect(saveCondAction, SIGNAL(triggered()), this, SLOT(saveFEMConditions())); - //connect(removeAction, SIGNAL(triggered()), this, SLOT(removeList())); + // QAction* removeAction = menu.addAction("Remove geometry"); + // connect(saveAction, SIGNAL(triggered()), this, + // SLOT(writeToFile())); + connect(mapAction, SIGNAL(triggered()), this, + SLOT(mapGeometry())); + // connect(addCNDAction, SIGNAL(triggered()), this, + // SLOT(loadFEMConditions())); connect(saveCondAction, + // SIGNAL(triggered()), this, SLOT(saveFEMConditions())); + // connect(removeAction, SIGNAL(triggered()), this, + // SLOT(removeList())); } } } @@ -216,16 +225,19 @@ void GeoTreeView::contextMenuEvent( QContextMenuEvent* event ) void GeoTreeView::convertPointsToStations() { - TreeItem const*const item = static_cast<GeoTreeModel*>(model()) - ->getItem(this->selectionModel()->currentIndex()) - ->parentItem(); - emit requestPointToStationConversion(item->data(0).toString().toStdString()); + TreeItem const* const item = + static_cast<GeoTreeModel*>(model()) + ->getItem(this->selectionModel()->currentIndex()) + ->parentItem(); + emit requestPointToStationConversion( + item->data(0).toString().toStdString()); } void GeoTreeView::connectPolylines() { - TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem( - this->selectionModel()->currentIndex())->parentItem(); + TreeItem* item = static_cast<GeoTreeModel*>(model()) + ->getItem(this->selectionModel()->currentIndex()) + ->parentItem(); emit requestLineEditDialog(item->data(0).toString().toStdString()); } @@ -236,7 +248,7 @@ void GeoTreeView::addGeometry() void GeoTreeView::removeGeometry() { - QModelIndex index (this->selectionModel()->currentIndex()); + QModelIndex index(this->selectionModel()->currentIndex()); if (!index.isValid()) { OGSError::box("No geometry selected."); @@ -245,16 +257,23 @@ void GeoTreeView::removeGeometry() { TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem(index); auto* list = dynamic_cast<GeoObjectListItem*>(item); - if (list) { - emit listRemoved((item->parentItem()->data( - 0).toString()).toStdString(), list->getType()); - } else { - emit listRemoved((item->data(0).toString()).toStdString(), GeoLib::GEOTYPE::SURFACE); - emit listRemoved((item->data(0).toString()).toStdString(), GeoLib::GEOTYPE::POLYLINE); - emit listRemoved((item->data(0).toString()).toStdString(), GeoLib::GEOTYPE::POINT); + if (list) + { + emit listRemoved( + (item->parentItem()->data(0).toString()).toStdString(), + list->getType()); + } + else + { + emit listRemoved((item->data(0).toString()).toStdString(), + GeoLib::GEOTYPE::SURFACE); + emit listRemoved((item->data(0).toString()).toStdString(), + GeoLib::GEOTYPE::POLYLINE); + emit listRemoved((item->data(0).toString()).toStdString(), + GeoLib::GEOTYPE::POINT); } - if(this->selectionModel()->selectedIndexes().count() == 0) + if (this->selectionModel()->selectedIndexes().count() == 0) { emit enableSaveButton(false); emit enableRemoveButton(false); @@ -265,34 +284,38 @@ void GeoTreeView::removeGeometry() void GeoTreeView::setElementAsCondition(bool set_on_points) { const TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem( - this->selectionModel()->currentIndex()); + this->selectionModel()->currentIndex()); const std::size_t id = item->row(); - const GeoLib::GEOTYPE type = static_cast<GeoObjectListItem*>(item->parentItem())->getType(); - const std::string geometry_name = item->parentItem()->parentItem()->data(0).toString().toStdString(); + const GeoLib::GEOTYPE type = + static_cast<GeoObjectListItem*>(item->parentItem())->getType(); + const std::string geometry_name = + item->parentItem()->parentItem()->data(0).toString().toStdString(); emit requestCondSetupDialog(geometry_name, type, id, set_on_points); } void GeoTreeView::setNameForElement() { const TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem( - this->selectionModel()->currentIndex()); + this->selectionModel()->currentIndex()); const std::size_t id = item->row(); - const GeoLib::GEOTYPE type = static_cast<GeoObjectListItem*>(item->parentItem())->getType(); - const std::string geometry_name = item->parentItem()->parentItem()->data(0).toString().toStdString(); + const GeoLib::GEOTYPE type = + static_cast<GeoObjectListItem*>(item->parentItem())->getType(); + const std::string geometry_name = + item->parentItem()->parentItem()->data(0).toString().toStdString(); emit requestNameChangeDialog(geometry_name, type, id); } void GeoTreeView::mapGeometry() { TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem( - this->selectionModel()->currentIndex()); - std::string geo_name (item->data(0).toString().toStdString()); + this->selectionModel()->currentIndex()); + std::string geo_name(item->data(0).toString().toStdString()); emit geometryMappingRequested(geo_name); } void GeoTreeView::writeToFile() const { - QModelIndex index (this->selectionModel()->currentIndex()); + QModelIndex index(this->selectionModel()->currentIndex()); if (!index.isValid()) { OGSError::box("No geometry selected."); @@ -300,10 +323,10 @@ void GeoTreeView::writeToFile() const else { TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem(index); - QString file_type ("GeoSys geometry file (*.gml)"); + QString file_type("GeoSys geometry file (*.gml)"); #ifndef NDEBUG - file_type.append(";;Legacy geometry file (*.gli)"); -#endif // DEBUG + file_type.append(";;Legacy geometry file (*.gli)"); +#endif // DEBUG QString geoName = item->data(0).toString(); QString fileName = QFileDialog::getSaveFileName( nullptr, "Save geometry as", @@ -319,7 +342,7 @@ void GeoTreeView::writeToFile() const void GeoTreeView::loadFEMConditions() { TreeItem* item = static_cast<GeoTreeModel*>(model())->getItem( - this->selectionModel()->currentIndex()); + this->selectionModel()->currentIndex()); emit loadFEMCondFileRequested(item->data(0).toString().toStdString()); } /* diff --git a/Applications/DataExplorer/DataView/LicenseDialog.cpp b/Applications/DataExplorer/DataView/LicenseDialog.cpp index d6d402097a6..1b3589f4705 100644 --- a/Applications/DataExplorer/DataView/LicenseDialog.cpp +++ b/Applications/DataExplorer/DataView/LicenseDialog.cpp @@ -13,6 +13,7 @@ */ #include "LicenseDialog.h" + #include <QTextStream> LicenseDialog::LicenseDialog(QDialog* parent) : QDialog(parent) @@ -26,37 +27,61 @@ void LicenseDialog::setText() { QString text; QTextStream stream(&text); - stream << "<p>Copyright (c) 2012-2021, OpenGeoSys Community " - << "(<a href='http://www.opengeosys.org'>http://www.opengeosys.org</a>)<br />" - << "All rights reserved.</p>" - << "<p>Redistribution and use in source and binary forms, with or without" - << "modification, are permitted provided that the following conditions are met:" - << "<ol>" - << "<li>Redistributions of source code must retain the above copyright" - << "notice, this list of conditions and the following disclaimer.</li>" - << "<li>Redistributions in binary form must reproduce the above copyright" - << "notice, this list of conditions and the following disclaimer in the" - << "documentation and/or other materials provided with the distribution.</li>" - << "<li>All advertising materials mentioning features or use of this software" - << "must display the following acknowledgement:" << "<br />" - << "'This product includes software developed by the OpenGeoSys Community.'</li>" - << "<li>Neither the name of the OpenGeoSys Community nor the" - << "names of its contributors may be used to endorse or promote products" - << "derived from this software without specific prior written permission.</li>" - << "<li>Attribute the OpenGeoSys Community, preferably citing an appropriate" - << "paper listed on the OpenGeoSys Community homepage:" - << "<a href='http://www.opengeosys.org/papers'>http://www.opengeosys.org/papers</a></li>" - << "</ol></p>" - << "<p>THIS SOFTWARE IS PROVIDED BY THE OpenGeoSys Community ''AS IS'' AND ANY" - << "EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED" - << "WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE" - << "DISCLAIMED. IN NO EVENT SHALL THE OpenGeoSys Community BE LIABLE FOR ANY" - << "DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES" - << "(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;" - << "LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND" - << "ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT" - << "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS" - << "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>"; + stream + << "<p>Copyright (c) 2012-2021, OpenGeoSys Community " + << "(<a " + "href='http://www.opengeosys.org'>http://www.opengeosys.org</a>)<br " + "/>" + << "All rights reserved.</p>" + << "<p>Redistribution and use in source and binary forms, with or " + "without" + << "modification, are permitted provided that the following conditions " + "are met:" + << "<ol>" + << "<li>Redistributions of source code must retain the above copyright" + << "notice, this list of conditions and the following disclaimer.</li>" + << "<li>Redistributions in binary form must reproduce the above " + "copyright" + << "notice, this list of conditions and the following disclaimer in the" + << "documentation and/or other materials provided with the " + "distribution.</li>" + << "<li>All advertising materials mentioning features or use of this " + "software" + << "must display the following acknowledgement:" + << "<br />" + << "'This product includes software developed by the OpenGeoSys " + "Community.'</li>" + << "<li>Neither the name of the OpenGeoSys Community nor the" + << "names of its contributors may be used to endorse or promote " + "products" + << "derived from this software without specific prior written " + "permission.</li>" + << "<li>Attribute the OpenGeoSys Community, preferably citing an " + "appropriate" + << "paper listed on the OpenGeoSys Community homepage:" + << "<a " + "href='http://www.opengeosys.org/papers'>http://www.opengeosys.org/" + "papers</a></li>" + << "</ol></p>" + << "<p>THIS SOFTWARE IS PROVIDED BY THE OpenGeoSys Community ''AS IS'' " + "AND ANY" + << "EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE " + "IMPLIED" + << "WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE " + "ARE" + << "DISCLAIMED. IN NO EVENT SHALL THE OpenGeoSys Community BE LIABLE " + "FOR ANY" + << "DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL " + "DAMAGES" + << "(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR " + "SERVICES;" + << "LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER " + "CAUSED AND" + << "ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, " + "OR TORT" + << "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE " + "USE OF THIS" + << "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>"; this->licenseTextBrowser->setHtml(*(stream.string())); } @@ -65,4 +90,3 @@ void LicenseDialog::on_okPushButton_pressed() { this->done(QDialog::Accepted); } - diff --git a/Applications/DataExplorer/DataView/LineEditDialog.cpp b/Applications/DataExplorer/DataView/LineEditDialog.cpp index eec707fcbf1..c85293d57ca 100644 --- a/Applications/DataExplorer/DataView/LineEditDialog.cpp +++ b/Applications/DataExplorer/DataView/LineEditDialog.cpp @@ -13,12 +13,17 @@ */ #include "LineEditDialog.h" -#include "OGSError.h" + #include <QStringList> #include <QStringListModel> -LineEditDialog::LineEditDialog(const GeoLib::PolylineVec &ply_vec, QDialog* parent) - : QDialog(parent), _allPly(new QStringListModel), _selPly(new QStringListModel), +#include "OGSError.h" + +LineEditDialog::LineEditDialog(const GeoLib::PolylineVec& ply_vec, + QDialog* parent) + : QDialog(parent), + _allPly(new QStringListModel), + _selPly(new QStringListModel), _geoName(ply_vec.getName()) { setupUi(this); @@ -31,7 +36,8 @@ LineEditDialog::LineEditDialog(const GeoLib::PolylineVec &ply_vec, QDialog* pare { std::string ply_name; ply_vec.getNameOfElementByID(i, ply_name); - list.append("Line " + QString::number(i) + " " + QString::fromStdString(ply_name)); + list.append("Line " + QString::number(i) + " " + + QString::fromStdString(ply_name)); } _allPly->setStringList(list); @@ -47,7 +53,8 @@ LineEditDialog::~LineEditDialog() void LineEditDialog::on_selectPlyButton_pressed() { - QModelIndexList selected = this->allPlyView->selectionModel()->selectedIndexes(); + QModelIndexList selected = + this->allPlyView->selectionModel()->selectedIndexes(); QStringList list = _selPly->stringList(); for (auto& index : selected) @@ -61,7 +68,8 @@ void LineEditDialog::on_selectPlyButton_pressed() void LineEditDialog::on_deselectPlyButton_pressed() { - QModelIndexList selected = this->selectedPlyView->selectionModel()->selectedIndexes(); + QModelIndexList selected = + this->selectedPlyView->selectionModel()->selectedIndexes(); QStringList list = _allPly->stringList(); for (auto& index : selected) @@ -75,16 +83,17 @@ void LineEditDialog::on_deselectPlyButton_pressed() void LineEditDialog::accept() { - std::vector<std::size_t> selectedIndeces = this->getSelectedIndeces(_selPly->stringList()); + std::vector<std::size_t> selectedIndeces = + this->getSelectedIndeces(_selPly->stringList()); if (!selectedIndeces.empty()) { std::string prox_string = this->proximityEdit->text().toStdString(); double prox = (prox_string.empty()) ? 0.0 : strtod(prox_string.c_str(), nullptr); - std::string ply_name = - (plyNameEdit->text().toStdString().empty()) ? "" : plyNameEdit->text(). - toStdString(); + std::string ply_name = (plyNameEdit->text().toStdString().empty()) + ? "" + : plyNameEdit->text().toStdString(); emit connectPolylines(_geoName, selectedIndeces, prox, diff --git a/Applications/DataExplorer/DataView/LinearEditDialog.cpp b/Applications/DataExplorer/DataView/LinearEditDialog.cpp index 1227a09576a..c470662332e 100644 --- a/Applications/DataExplorer/DataView/LinearEditDialog.cpp +++ b/Applications/DataExplorer/DataView/LinearEditDialog.cpp @@ -14,9 +14,9 @@ #include "LinearEditDialog.h" -LinearEditDialog::LinearEditDialog(const GeoLib::Polyline &line, - const std::vector<std::size_t> &dis_nodes, - const std::vector<double> &dis_values, +LinearEditDialog::LinearEditDialog(const GeoLib::Polyline& line, + const std::vector<std::size_t>& dis_nodes, + const std::vector<double>& dis_values, QDialog* parent) : QDialog(parent), _line(line) { @@ -24,8 +24,8 @@ LinearEditDialog::LinearEditDialog(const GeoLib::Polyline &line, setupDialog(dis_nodes, dis_values); } -void LinearEditDialog::setupDialog(const std::vector<std::size_t> &dis_nodes, - const std::vector<double> &dis_values) +void LinearEditDialog::setupDialog(const std::vector<std::size_t>& dis_nodes, + const std::vector<double>& dis_values) { std::size_t nPoints(_line.getNumberOfPoints()); this->tableWidget->setRowCount(nPoints); @@ -34,13 +34,13 @@ void LinearEditDialog::setupDialog(const std::vector<std::size_t> &dis_nodes, for (std::size_t i = 0; i < nPoints; i++) { indexlist.push_back(QString::number(i)); - QTableWidgetItem *newItem = new QTableWidgetItem(""); + QTableWidgetItem* newItem = new QTableWidgetItem(""); tableWidget->setItem(i, 0, newItem); } QStringList vHeaders(indexlist); tableWidget->setVerticalHeaderLabels(vHeaders); - std::size_t nValues (dis_values.size()); + std::size_t nValues(dis_values.size()); for (std::size_t i = 0; i < nValues; i++) { tableWidget->item(static_cast<int>(dis_nodes[i]), 0) @@ -52,7 +52,7 @@ LinearEditDialog::~LinearEditDialog() = default; void LinearEditDialog::on_comboBox_currentIndexChanged(int index) { - if (index > 0) //elevation + if (index > 0) // elevation { std::size_t nRows = tableWidget->rowCount(); for (std::size_t i = 0; i < nRows; i++) @@ -65,12 +65,12 @@ void LinearEditDialog::on_comboBox_currentIndexChanged(int index) void LinearEditDialog::accept() { - std::vector< std::pair<std::size_t,double> > linear_values; + std::vector<std::pair<std::size_t, double>> linear_values; std::size_t nRows = tableWidget->rowCount(); for (std::size_t i = 0; i < nRows; i++) { - QString row_text (tableWidget->item(i,0)->text()); + QString row_text(tableWidget->item(i, 0)->text()); if (row_text.length() > 0) { linear_values.emplace_back(i, row_text.toDouble()); diff --git a/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp b/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp index 9c80f74cd5b..b3b678aa3c8 100644 --- a/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp +++ b/Applications/DataExplorer/DataView/MergeGeometriesDialog.cpp @@ -14,14 +14,18 @@ #include "MergeGeometriesDialog.h" -#include "GEOObjects.h" #include <QStringList> #include <QStringListModel> +#include "GEOObjects.h" #include "OGSError.h" -MergeGeometriesDialog::MergeGeometriesDialog(GeoLib::GEOObjects& geoObjects, QDialog* parent) - : QDialog(parent), _geo_objects(geoObjects), _allGeo(new QStringListModel), _selGeo(new QStringListModel) +MergeGeometriesDialog::MergeGeometriesDialog(GeoLib::GEOObjects& geoObjects, + QDialog* parent) + : QDialog(parent), + _geo_objects(geoObjects), + _allGeo(new QStringListModel), + _selGeo(new QStringListModel) { setupUi(this); @@ -31,9 +35,11 @@ MergeGeometriesDialog::MergeGeometriesDialog(GeoLib::GEOObjects& geoObjects, QDi std::vector<std::string> geo_station_names; _geo_objects.getStationVectorNames(geo_station_names); - // merge method does currently not merge stations, converter function needed first - //geoNames.reserve(geo_station_names.size()); - //std::copy(geo_station_names.begin(), geo_station_names.end(), std::back_inserter(geoNames)); + // merge method does currently not merge stations, converter function needed + // first + // geoNames.reserve(geo_station_names.size()); + // std::copy(geo_station_names.begin(), geo_station_names.end(), + // std::back_inserter(geoNames)); std::size_t nGeoObjects(geoNames.size()); @@ -66,7 +72,8 @@ MergeGeometriesDialog::~MergeGeometriesDialog() void MergeGeometriesDialog::on_selectGeoButton_pressed() { - QModelIndexList selected = this->allGeoView->selectionModel()->selectedIndexes(); + QModelIndexList selected = + this->allGeoView->selectionModel()->selectedIndexes(); QStringList list = _selGeo->stringList(); for (auto& index : selected) @@ -80,7 +87,8 @@ void MergeGeometriesDialog::on_selectGeoButton_pressed() void MergeGeometriesDialog::on_deselectGeoButton_pressed() { - QModelIndexList selected = this->selectedGeoView->selectionModel()->selectedIndexes(); + QModelIndexList selected = + this->selectedGeoView->selectionModel()->selectedIndexes(); QStringList list = _allGeo->stringList(); for (auto& index : selected) diff --git a/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp b/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp index dc356a6843d..b3ff0a1b044 100644 --- a/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshAnalysisDialog.cpp @@ -13,18 +13,17 @@ */ #include "MeshAnalysisDialog.h" + #include "Mesh.h" -#include "MeshQuality/MeshValidation.h" #include "MeshEditing/MeshRevision.h" +#include "MeshQuality/MeshValidation.h" #include "MeshSearch/NodeSearch.h" - #include "StrictDoubleValidator.h" - MeshAnalysisDialog::MeshAnalysisDialog( std::vector<std::unique_ptr<MeshLib::Mesh>> const& mesh_vec, QDialog* parent) -: QDialog(parent), _mesh_vec(mesh_vec) + : QDialog(parent), _mesh_vec(mesh_vec) { setupUi(this); @@ -40,34 +39,42 @@ MeshAnalysisDialog::MeshAnalysisDialog( auto* collapse_threshold_validator = new StrictDoubleValidator(0, 1000000, 7, this); - this->collapsibleNodesThreshold->setValidator (collapse_threshold_validator); + this->collapsibleNodesThreshold->setValidator(collapse_threshold_validator); auto* volume_threshold_validator = new StrictDoubleValidator(0, 1e10, 10, this); - this->zeroVolumeThreshold->setValidator (volume_threshold_validator); + this->zeroVolumeThreshold->setValidator(volume_threshold_validator); } MeshAnalysisDialog::~MeshAnalysisDialog() = default; void MeshAnalysisDialog::on_startButton_pressed() { - MeshLib::Mesh const& mesh (*_mesh_vec[this->meshListBox->currentIndex()].get()); + MeshLib::Mesh const& mesh( + *_mesh_vec[this->meshListBox->currentIndex()].get()); MeshLib::NodeSearch ns(mesh); ns.searchUnused(); - const std::vector<std::size_t> unusedNodesIdx (ns.getSearchedNodeIDs()); + const std::vector<std::size_t> unusedNodesIdx(ns.getSearchedNodeIDs()); MeshLib::MeshRevision rev(const_cast<MeshLib::Mesh&>(mesh)); - std::vector<std::size_t> const& collapsibleNodeIds (rev.collapseNodeIndices( - this->collapsibleNodesThreshold->text().toDouble() + std::numeric_limits<double>::epsilon())); - this->nodesGroupBox->setTitle("Nodes (out of " + QString::number(mesh.getNumberOfNodes()) + ")"); + std::vector<std::size_t> const& collapsibleNodeIds(rev.collapseNodeIndices( + this->collapsibleNodesThreshold->text().toDouble() + + std::numeric_limits<double>::epsilon())); + this->nodesGroupBox->setTitle( + "Nodes (out of " + QString::number(mesh.getNumberOfNodes()) + ")"); this->nodesMsgOutput(unusedNodesIdx, collapsibleNodeIds); - const std::vector<ElementErrorCode> element_error_codes (MeshLib::MeshValidation::testElementGeometry( - mesh, this->zeroVolumeThreshold->text().toDouble() + std::numeric_limits<double>::epsilon())); - this->elementsGroupBox->setTitle("Elements (out of " + QString::number(mesh.getNumberOfElements()) + ")"); + const std::vector<ElementErrorCode> element_error_codes( + MeshLib::MeshValidation::testElementGeometry( + mesh, + this->zeroVolumeThreshold->text().toDouble() + + std::numeric_limits<double>::epsilon())); + this->elementsGroupBox->setTitle( + "Elements (out of " + QString::number(mesh.getNumberOfElements()) + + ")"); this->elementsMsgOutput(element_error_codes); - unsigned const n_holes (MeshLib::MeshValidation::detectHoles(mesh)); + unsigned const n_holes(MeshLib::MeshValidation::detectHoles(mesh)); if (n_holes > 0) { this->meshHoleOutputLabel->setText( @@ -76,9 +83,11 @@ void MeshAnalysisDialog::on_startButton_pressed() } } -void MeshAnalysisDialog::nodesMsgOutput(std::vector<std::size_t> const& node_ids, std::vector<std::size_t> const& collapsibleNodeIds) +void MeshAnalysisDialog::nodesMsgOutput( + std::vector<std::size_t> const& node_ids, + std::vector<std::size_t> const& collapsibleNodeIds) { - const std::size_t nNodeIds (node_ids.size()); + const std::size_t nNodeIds(node_ids.size()); QString nodes_output(""); if (node_ids.empty()) { @@ -86,7 +95,8 @@ void MeshAnalysisDialog::nodesMsgOutput(std::vector<std::size_t> const& node_ids } else { - nodes_output += (QString::number(nNodeIds) + " nodes are not part of any element:\n"); + nodes_output += (QString::number(nNodeIds) + + " nodes are not part of any element:\n"); for (std::size_t i = 0; i < nNodeIds; ++i) { nodes_output += (QString::number(node_ids[i]) + ", "); @@ -105,17 +115,22 @@ void MeshAnalysisDialog::nodesMsgOutput(std::vector<std::size_t> const& node_ids count++; } } - nodes_output = (count > 0) ? QString::number(count) + " nodes found:\n" : "No nodes found."; + nodes_output = (count > 0) ? QString::number(count) + " nodes found:\n" + : "No nodes found."; nodes_output.append(node_ids_str); this->collapsibleNodesText->setText(nodes_output); } -void MeshAnalysisDialog::elementsMsgOutput(const std::vector<ElementErrorCode> &element_error_codes) +void MeshAnalysisDialog::elementsMsgOutput( + const std::vector<ElementErrorCode>& element_error_codes) { - std::array<std::string, static_cast<std::size_t>(ElementErrorFlag::MaxValue)> output_str(MeshLib::MeshValidation::ElementErrorCodeOutput(element_error_codes)); + std::array<std::string, + static_cast<std::size_t>(ElementErrorFlag::MaxValue)> + output_str(MeshLib::MeshValidation::ElementErrorCodeOutput( + element_error_codes)); this->zeroVolumeText->setText(QString::fromStdString(output_str[0])); - this-> nonPlanarText->setText(QString::fromStdString(output_str[1])); - this-> nonConvexText->setText(QString::fromStdString(output_str[2])); - this-> nodeOrderText->setText(QString::fromStdString(output_str[3])); + this->nonPlanarText->setText(QString::fromStdString(output_str[1])); + this->nonConvexText->setText(QString::fromStdString(output_str[2])); + this->nodeOrderText->setText(QString::fromStdString(output_str[3])); } diff --git a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp index 22bb71f3be1..f4c84ffa037 100644 --- a/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshElementRemovalDialog.cpp @@ -41,8 +41,8 @@ MeshElementRemovalDialog::MeshElementRemovalDialog( auto const& mesh_vec(_project.getMeshObjects()); - const std::size_t nMeshes (mesh_vec.size()); - for (std::size_t i=0; i<nMeshes; ++i) + const std::size_t nMeshes(mesh_vec.size()); + for (std::size_t i = 0; i < nMeshes; ++i) { std::string name = mesh_vec[i]->getName(); this->meshNameComboBox->addItem(QString::fromStdString(name)); @@ -59,19 +59,21 @@ MeshElementRemovalDialog::~MeshElementRemovalDialog() = default; void MeshElementRemovalDialog::accept() { - if (this->newMeshNameEdit->text().size()==0) + if (this->newMeshNameEdit->text().size() == 0) { OGSError::box("Please enter name for new mesh."); return; } - bool anything_checked (false); + bool anything_checked(false); - const MeshLib::Mesh* msh = _project.getMesh(this->meshNameComboBox->currentText().toStdString()); + const MeshLib::Mesh* msh = + _project.getMesh(this->meshNameComboBox->currentText().toStdString()); MeshLib::ElementSearch ex(*msh); if (this->elementTypeCheckBox->isChecked()) { - QList<QListWidgetItem*> items = this->elementTypeListWidget->selectedItems(); + QList<QListWidgetItem*> items = + this->elementTypeListWidget->selectedItems(); for (auto& item : items) { ex.searchByElementType( @@ -81,7 +83,8 @@ void MeshElementRemovalDialog::accept() } if (this->scalarArrayCheckBox->isChecked()) { - std::string const array_name = this->scalarArrayComboBox->currentText().toStdString(); + std::string const array_name = + this->scalarArrayComboBox->currentText().toStdString(); double min_val; double max_val; bool outside = this->outsideButton->isChecked(); @@ -117,18 +120,28 @@ void MeshElementRemovalDialog::accept() } if (this->boundingBoxCheckBox->isChecked()) { - std::vector<MeshLib::Node*> const& nodes (_project.getMesh(this->meshNameComboBox->currentText().toStdString())->getNodes()); + std::vector<MeshLib::Node*> const& nodes( + _project + .getMesh(this->meshNameComboBox->currentText().toStdString()) + ->getNodes()); GeoLib::AABB const aabb(nodes.begin(), nodes.end()); auto minAABB = aabb.getMinPoint(); auto maxAABB = aabb.getMaxPoint(); - // only extract bounding box parameters that have been edited (otherwise there will be rounding errors!) - minAABB[0] = (aabb_edits[0]) ? this->xMinEdit->text().toDouble() : (minAABB[0]); - maxAABB[0] = (aabb_edits[1]) ? this->xMaxEdit->text().toDouble() : (maxAABB[0]); - minAABB[1] = (aabb_edits[2]) ? this->yMinEdit->text().toDouble() : (minAABB[1]); - maxAABB[1] = (aabb_edits[3]) ? this->yMaxEdit->text().toDouble() : (maxAABB[1]); - minAABB[2] = (aabb_edits[4]) ? this->zMinEdit->text().toDouble() : (minAABB[2]); - maxAABB[2] = (aabb_edits[5]) ? this->zMaxEdit->text().toDouble() : (maxAABB[2]); + // only extract bounding box parameters that have been edited (otherwise + // there will be rounding errors!) + minAABB[0] = + (aabb_edits[0]) ? this->xMinEdit->text().toDouble() : (minAABB[0]); + maxAABB[0] = + (aabb_edits[1]) ? this->xMaxEdit->text().toDouble() : (maxAABB[0]); + minAABB[1] = + (aabb_edits[2]) ? this->yMinEdit->text().toDouble() : (minAABB[1]); + maxAABB[1] = + (aabb_edits[3]) ? this->yMaxEdit->text().toDouble() : (maxAABB[1]); + minAABB[2] = + (aabb_edits[4]) ? this->zMinEdit->text().toDouble() : (minAABB[2]); + maxAABB[2] = + (aabb_edits[5]) ? this->zMaxEdit->text().toDouble() : (maxAABB[2]); std::vector<MathLib::Point3d> extent; extent.push_back(minAABB); extent.push_back(maxAABB); @@ -176,7 +189,8 @@ void MeshElementRemovalDialog::reject() this->done(QDialog::Rejected); } -std::size_t MeshElementRemovalDialog::addScalarArrays(MeshLib::Mesh const& mesh) const +std::size_t MeshElementRemovalDialog::addScalarArrays( + MeshLib::Mesh const& mesh) const { for (auto [name, property] : mesh.getProperties()) { @@ -195,10 +209,14 @@ void MeshElementRemovalDialog::enableScalarArrayWidgets(bool enable) const this->scalarArrayComboBox->setEnabled(enable); this->outsideButton->setEnabled(enable); this->insideButton->setEnabled(enable); - this->outsideScalarMinEdit->setEnabled(enable && this->outsideButton->isChecked()); - this->outsideScalarMaxEdit->setEnabled(enable && this->outsideButton->isChecked()); - this->insideScalarMinEdit->setEnabled(enable && this->insideButton->isChecked()); - this->insideScalarMaxEdit->setEnabled(enable && this->insideButton->isChecked()); + this->outsideScalarMinEdit->setEnabled(enable && + this->outsideButton->isChecked()); + this->outsideScalarMaxEdit->setEnabled(enable && + this->outsideButton->isChecked()); + this->insideScalarMinEdit->setEnabled(enable && + this->insideButton->isChecked()); + this->insideScalarMaxEdit->setEnabled(enable && + this->insideButton->isChecked()); } void MeshElementRemovalDialog::toggleScalarEdits(bool outside) const @@ -216,14 +234,20 @@ void MeshElementRemovalDialog::on_insideButton_toggled(bool /*is_checked*/) void MeshElementRemovalDialog::on_boundingBoxCheckBox_toggled(bool is_checked) { - this->xMinEdit->setEnabled(is_checked); this->xMaxEdit->setEnabled(is_checked); - this->yMinEdit->setEnabled(is_checked); this->yMaxEdit->setEnabled(is_checked); - this->zMinEdit->setEnabled(is_checked); this->zMaxEdit->setEnabled(is_checked); + this->xMinEdit->setEnabled(is_checked); + this->xMaxEdit->setEnabled(is_checked); + this->yMinEdit->setEnabled(is_checked); + this->yMaxEdit->setEnabled(is_checked); + this->zMinEdit->setEnabled(is_checked); + this->zMaxEdit->setEnabled(is_checked); if (is_checked && (_currentIndex != _aabbIndex)) { _aabbIndex = _currentIndex; - std::vector<MeshLib::Node*> const& nodes (_project.getMesh(this->meshNameComboBox->currentText().toStdString())->getNodes()); + std::vector<MeshLib::Node*> const& nodes( + _project + .getMesh(this->meshNameComboBox->currentText().toStdString()) + ->getNodes()); GeoLib::AABB aabb(nodes.begin(), nodes.end()); auto const& minAABB = aabb.getMinPoint(); auto const& maxAABB = aabb.getMaxPoint(); @@ -268,7 +292,8 @@ void MeshElementRemovalDialog::on_meshNameComboBox_currentIndexChanged(int idx) { Q_UNUSED(idx); this->_currentIndex = this->meshNameComboBox->currentIndex(); - this->newMeshNameEdit->setText(this->meshNameComboBox->currentText() + "_new"); + this->newMeshNameEdit->setText(this->meshNameComboBox->currentText() + + "_new"); this->elementTypeListWidget->clearSelection(); this->scalarArrayComboBox->clear(); this->outsideScalarMinEdit->setText(""); @@ -279,10 +304,12 @@ void MeshElementRemovalDialog::on_meshNameComboBox_currentIndexChanged(int idx) on_boundingBoxCheckBox_toggled(this->boundingBoxCheckBox->isChecked()); } -void MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged(int idx) +void MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged( + int idx) { Q_UNUSED(idx); - std::string const vec_name(scalarArrayComboBox->currentText().toStdString()); + std::string const vec_name( + scalarArrayComboBox->currentText().toStdString()); if (vec_name.empty()) { return; @@ -307,7 +334,8 @@ void MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged(int id } template <typename T> -void MeshElementRemovalDialog::setRangeValues(MeshLib::PropertyVector<T> const& vec) +void MeshElementRemovalDialog::setRangeValues( + MeshLib::PropertyVector<T> const& vec) { auto min = std::min_element(vec.cbegin(), vec.cend()); auto max = std::max_element(vec.cbegin(), vec.cend()); diff --git a/Applications/DataExplorer/DataView/MeshItem.cpp b/Applications/DataExplorer/DataView/MeshItem.cpp index 8b690fd3e92..010f8fc70b6 100644 --- a/Applications/DataExplorer/DataView/MeshItem.cpp +++ b/Applications/DataExplorer/DataView/MeshItem.cpp @@ -13,6 +13,7 @@ */ #include "MeshItem.h" + #include "MeshLib/Vtk/VtkMappedMeshSource.h" MeshItem::MeshItem(const QList<QVariant>& data, TreeItem* parent, diff --git a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp index 1d33c8b0c34..9ba27b04474 100644 --- a/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshLayerEditDialog.cpp @@ -12,20 +12,11 @@ * */ -#include "MeshGenerators/LayeredVolume.h" #include "MeshLayerEditDialog.h" -#include "BaseLib/Logging.h" - -#include "OGSError.h" -#include "StringTools.h" -#include "Mesh.h" - -#include "Applications/FileIO/AsciiRasterInterface.h" -#include "TetGenInterface.h" - #include <QCheckBox> #include <QDoubleValidator> +#include <QElapsedTimer> #include <QFileDialog> #include <QFileInfo> #include <QGridLayout> @@ -35,32 +26,43 @@ #include <QPushButton> #include <QRadioButton> #include <QSettings> -#include <QElapsedTimer> #include <QVBoxLayout> -MeshLayerEditDialog::MeshLayerEditDialog(const MeshLib::Mesh* mesh, QDialog* parent) - : QDialog(parent), _msh(mesh), _n_layers(0), - _layerEdit (new QLineEdit("1", this)), +#include "Applications/FileIO/AsciiRasterInterface.h" +#include "BaseLib/Logging.h" +#include "Mesh.h" +#include "MeshGenerators/LayeredVolume.h" +#include "OGSError.h" +#include "StringTools.h" +#include "TetGenInterface.h" + +MeshLayerEditDialog::MeshLayerEditDialog(const MeshLib::Mesh* mesh, + QDialog* parent) + : QDialog(parent), + _msh(mesh), + _n_layers(0), + _layerEdit(new QLineEdit("1", this)), _noDataReplacementEdit(nullptr), _minThicknessEdit(nullptr), - _nextButton (new QPushButton("Next", this)), - _layerBox (nullptr), - _radioButtonBox (nullptr), - _ogsMeshButton (nullptr), - _layerSelectionLayout (new QGridLayout(_layerBox)), + _nextButton(new QPushButton("Next", this)), + _layerBox(nullptr), + _radioButtonBox(nullptr), + _ogsMeshButton(nullptr), + _layerSelectionLayout(new QGridLayout(_layerBox)), _use_rasters(true) { setupUi(this); - this->gridLayoutLayerMapping->addWidget(new QLabel("Please specify the number of layers to add:", this), 0, 0); + this->gridLayoutLayerMapping->addWidget( + new QLabel("Please specify the number of layers to add:", this), 0, 0); this->gridLayoutLayerMapping->addWidget(_layerEdit, 0, 1); this->gridLayoutLayerMapping->addWidget(_nextButton, 0, 2); - _layerEdit->setValidator(new QIntValidator(1,999,_layerEdit)); + _layerEdit->setValidator(new QIntValidator(1, 999, _layerEdit)); connect(_nextButton, SIGNAL(pressed()), this, SLOT(nextButtonPressed())); // configure group box + layout this->_layerSelectionLayout->setMargin(10); - this->_layerSelectionLayout->setColumnMinimumWidth(2,10); + this->_layerSelectionLayout->setColumnMinimumWidth(2, 10); this->_layerSelectionLayout->setColumnStretch(0, 80); this->_layerSelectionLayout->setColumnStretch(1, 200); this->_layerSelectionLayout->setColumnStretch(2, 10); @@ -70,7 +72,7 @@ MeshLayerEditDialog::~MeshLayerEditDialog() = default; void MeshLayerEditDialog::nextButtonPressed() { - _n_layers = static_cast<unsigned>(_layerEdit->text().toInt()); + _n_layers = static_cast<unsigned>(_layerEdit->text().toInt()); if (_n_layers < 1) { @@ -82,8 +84,10 @@ void MeshLayerEditDialog::nextButtonPressed() _nextButton->setEnabled(false); auto* _radiobuttonLayout(new QVBoxLayout(_radioButtonBox)); - QRadioButton* selectButton1 (new QRadioButton("Add layers based on raster files", _radioButtonBox)); - QRadioButton* selectButton2 (new QRadioButton("Add layers with static thickness", _radioButtonBox)); + QRadioButton* selectButton1( + new QRadioButton("Add layers based on raster files", _radioButtonBox)); + QRadioButton* selectButton2( + new QRadioButton("Add layers with static thickness", _radioButtonBox)); _radioButtonBox = new QGroupBox(this); _radiobuttonLayout->addWidget(selectButton1); _radiobuttonLayout->addWidget(selectButton2); @@ -97,9 +101,9 @@ void MeshLayerEditDialog::createWithRasters() { this->_use_rasters = true; this->_radioButtonBox->setEnabled(false); - const QString selectText = (_n_layers>0) ? - "Please specify a raster file for mapping each layer:" : - "Please specify raster file for surface mapping:"; + const QString selectText = + (_n_layers > 0) ? "Please specify a raster file for mapping each layer:" + : "Please specify raster file for surface mapping:"; this->_layerBox = new QGroupBox(this); this->_layerBox->setTitle(selectText); @@ -119,14 +123,15 @@ void MeshLayerEditDialog::createWithRasters() text = "Layer" + QString::number(i + 1) + "-Top"; } auto* edit(new QLineEdit(this)); - QPushButton* button (new QPushButton("...", _layerBox)); + QPushButton* button(new QPushButton("...", _layerBox)); this->_edits.push_back(edit); this->_fileButtonMap.insert(button, edit); connect(button, SIGNAL(clicked()), this, SLOT(getFileName())); - this->_layerSelectionLayout->addWidget(new QLabel(text, _layerBox), i, 0); - this->_layerSelectionLayout->addWidget(_edits[i], i, 1); + this->_layerSelectionLayout->addWidget(new QLabel(text, _layerBox), i, + 0); + this->_layerSelectionLayout->addWidget(_edits[i], i, 1); this->_layerSelectionLayout->addWidget(button, i, 2); } this->_layerBox->setLayout(this->_layerSelectionLayout); @@ -150,8 +155,9 @@ void MeshLayerEditDialog::createStatic() QLineEdit* staticLayerEdit = new QLineEdit("10", this); staticLayerEdit->setValidator(new QDoubleValidator(staticLayerEdit)); _edits.push_back(staticLayerEdit); - this->_layerSelectionLayout->addWidget(new QLabel(text, _layerBox), i, 0); - this->_layerSelectionLayout->addWidget(_edits[i], i, 1); + this->_layerSelectionLayout->addWidget(new QLabel(text, _layerBox), i, + 0); + this->_layerSelectionLayout->addWidget(_edits[i], i, 1); } this->_layerBox->setLayout(this->_layerSelectionLayout); this->gridLayoutLayerMapping->addWidget(_layerBox, 4, 0, 1, 3); @@ -164,7 +170,8 @@ void MeshLayerEditDialog::createMeshToolSelection() meshToolSelectionBox->setTitle("Output element type"); auto* meshToolSelectionLayout(new QGridLayout(meshToolSelectionBox)); _ogsMeshButton = new QRadioButton("Prisms", meshToolSelectionBox); - QRadioButton* tetgenMeshButton = new QRadioButton("Tetrahedra", meshToolSelectionBox); + QRadioButton* tetgenMeshButton = + new QRadioButton("Tetrahedra", meshToolSelectionBox); tetgenMeshButton->setFixedWidth(150); auto* minThicknessLabel = new QLabel(meshToolSelectionBox); minThicknessLabel->setText("Minimum thickness of layers:"); @@ -195,7 +202,7 @@ MeshLib::Mesh* MeshLayerEditDialog::createPrismMesh() myTimer0.start(); if (_use_rasters) { - float minimum_thickness (_minThicknessEdit->text().toFloat()); + float minimum_thickness(_minThicknessEdit->text().toFloat()); if (minimum_thickness <= 0) { minimum_thickness = std::numeric_limits<float>::epsilon(); @@ -227,9 +234,10 @@ MeshLib::Mesh* MeshLayerEditDialog::createPrismMesh() MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() { QSettings settings; - QString filename = QFileDialog::getSaveFileName(this, "Write TetGen input file to", - settings.value("lastOpenedTetgenFileDirectory").toString(), - "TetGen Geometry (*.smesh)"); + QString filename = QFileDialog::getSaveFileName( + this, "Write TetGen input file to", + settings.value("lastOpenedTetgenFileDirectory").toString(), + "TetGen Geometry (*.smesh)"); if (filename.isEmpty()) { return nullptr; @@ -242,7 +250,7 @@ MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() if (_use_rasters) { - float minimum_thickness (_minThicknessEdit->text().toFloat()); + float minimum_thickness(_minThicknessEdit->text().toFloat()); if (minimum_thickness <= 0) { minimum_thickness = std::numeric_limits<float>::epsilon(); @@ -262,9 +270,10 @@ MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() if (tg_mesh) { - std::vector<MeshLib::Node> tg_attr (lv.getAttributePoints()); + std::vector<MeshLib::Node> tg_attr(lv.getAttributePoints()); FileIO::TetGenInterface tetgen_interface; - tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); + tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, + tg_attr); } } else @@ -274,10 +283,12 @@ MeshLib::Mesh* MeshLayerEditDialog::createTetMesh() { layer_thickness.push_back(this->_edits[i]->text().toFloat()); } - tg_mesh = MeshLib::MeshLayerMapper::createStaticLayers(*_msh, layer_thickness); + tg_mesh = MeshLib::MeshLayerMapper::createStaticLayers(*_msh, + layer_thickness); std::vector<MeshLib::Node> tg_attr; FileIO::TetGenInterface tetgen_interface; - tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, tg_attr); + tetgen_interface.writeTetGenSmesh(filename.toStdString(), *tg_mesh, + tg_attr); } INFO("Mesh construction time: {:d} ms.", myTimer0.elapsed()); @@ -293,8 +304,8 @@ void MeshLayerEditDialog::accept() return; } - bool all_paths_set (true); - if (_n_layers==0) + bool all_paths_set(true); + if (_n_layers == 0) { if (_edits[0]->text().isEmpty()) { @@ -303,7 +314,7 @@ void MeshLayerEditDialog::accept() } else { - int start_idx = (_use_rasters) ? 1:0; + int start_idx = (_use_rasters) ? 1 : 0; for (int i = start_idx; i < _edits.size(); ++i) { if (_edits[i]->text().isEmpty()) @@ -319,7 +330,7 @@ void MeshLayerEditDialog::accept() return; } - MeshLib::Mesh* new_mesh (nullptr); + MeshLib::Mesh* new_mesh(nullptr); if (_ogsMeshButton->isChecked()) { new_mesh = createPrismMesh(); diff --git a/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp b/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp index 9e28e5e8078..a588d33d3fa 100644 --- a/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshMapping2DDialog.cpp @@ -8,21 +8,21 @@ */ #include "MeshMapping2DDialog.h" -#include "OGSError.h" -#include "StrictDoubleValidator.h" -#include <QSettings> #include <QFileDialog> +#include <QSettings> -MeshMapping2DDialog::MeshMapping2DDialog(QDialog* parent) -: QDialog(parent) +#include "OGSError.h" +#include "StrictDoubleValidator.h" + +MeshMapping2DDialog::MeshMapping2DDialog(QDialog* parent) : QDialog(parent) { setupUi(this); auto* no_data_validator = new StrictDoubleValidator(this); - this->noDataValueEdit->setValidator (no_data_validator); + this->noDataValueEdit->setValidator(no_data_validator); auto* static_value_validator = new StrictDoubleValidator(this); - this->staticValueEdit->setValidator (static_value_validator); + this->staticValueEdit->setValidator(static_value_validator); } void MeshMapping2DDialog::on_ignoreNoDataCheckbox_toggled(bool isChecked) @@ -54,7 +54,8 @@ void MeshMapping2DDialog::on_rasterSelectButton_pressed() void MeshMapping2DDialog::accept() { - if (this->rasterValueButton->isChecked() && this->rasterPathEdit->text().isEmpty()) + if (this->rasterValueButton->isChecked() && + this->rasterPathEdit->text().isEmpty()) { OGSError::box("Please specify path to raster file."); return; @@ -66,7 +67,8 @@ void MeshMapping2DDialog::accept() OGSError::box("Please specify No Data value."); return; } - if (this->staticValueButton->isChecked() && this->staticValueEdit->text().isEmpty()) + if (this->staticValueButton->isChecked() && + this->staticValueEdit->text().isEmpty()) { OGSError::box("Please specify value for mapping."); return; @@ -83,4 +85,3 @@ void MeshMapping2DDialog::accept() this->done(QDialog::Accepted); } - diff --git a/Applications/DataExplorer/DataView/MeshModel.cpp b/Applications/DataExplorer/DataView/MeshModel.cpp index 264681e34a5..4ad7156620c 100644 --- a/Applications/DataExplorer/DataView/MeshModel.cpp +++ b/Applications/DataExplorer/DataView/MeshModel.cpp @@ -15,32 +15,34 @@ #include "MeshModel.h" #include <vtkUnstructuredGridAlgorithm.h> + #include <QFileInfo> #include <QString> -#include "BaseLib/Logging.h" #include "Applications/DataHolderLib/Project.h" +#include "BaseLib/Logging.h" #include "BaseLib/StringTools.h" #include "Elements/Element.h" -#include "MeshLib/Node.h" - #include "MeshItem.h" +#include "MeshLib/Node.h" #include "TreeItem.h" - const QVariant MeshModel::element_str = "Element"; -const std::map<MeshLib::MeshElemType, QVariant> MeshModel::elem_type_map = MeshModel::createMeshElemTypeMap(); +const std::map<MeshLib::MeshElemType, QVariant> MeshModel::elem_type_map = + MeshModel::createMeshElemTypeMap(); -MeshModel::MeshModel(DataHolderLib::Project &project, QObject* parent /*= 0*/ ) +MeshModel::MeshModel(DataHolderLib::Project& project, QObject* parent /*= 0*/) : TreeModel(parent), _project(project) { delete _rootItem; QList<QVariant> rootData; - rootData << "Mesh Name" << "#" << "Type"; + rootData << "Mesh Name" + << "#" + << "Type"; _rootItem = new TreeItem(rootData, nullptr); } -int MeshModel::columnCount( const QModelIndex &parent /*= QModelIndex()*/ ) const +int MeshModel::columnCount(const QModelIndex& parent /*= QModelIndex()*/) const { Q_UNUSED(parent) @@ -66,9 +68,10 @@ void MeshModel::addMeshObject(const MeshLib::Mesh* mesh) beginResetModel(); INFO("name: {:s}", mesh->getName()); - QVariant const display_name (QString::fromStdString(mesh->getName())); + QVariant const display_name(QString::fromStdString(mesh->getName())); QList<QVariant> meshData; - meshData << display_name << "" << ""; + meshData << display_name << "" + << ""; auto* const newMesh = new MeshItem(meshData, _rootItem, mesh); _rootItem->appendChild(newMesh); @@ -80,15 +83,17 @@ void MeshModel::addMeshObject(const MeshLib::Mesh* mesh) { QList<QVariant> elemData; elemData.reserve(3); - elemData << element_str << i << elem_type_map.at(elems[i]->getGeomType()); + elemData << element_str << i + << elem_type_map.at(elems[i]->getGeomType()); newMesh->appendChild(new TreeItem(elemData, newMesh)); } endResetModel(); - emit meshAdded(this, this->index(_rootItem->childCount() - 1, 0, QModelIndex())); + emit meshAdded(this, + this->index(_rootItem->childCount() - 1, 0, QModelIndex())); } -const MeshLib::Mesh* MeshModel::getMesh(const QModelIndex &idx) const +const MeshLib::Mesh* MeshModel::getMesh(const QModelIndex& idx) const { if (idx.isValid()) { @@ -104,7 +109,7 @@ const MeshLib::Mesh* MeshModel::getMesh(const QModelIndex &idx) const return nullptr; } -const MeshLib::Mesh* MeshModel::getMesh(const std::string &name) const +const MeshLib::Mesh* MeshModel::getMesh(const std::string& name) const { for (int i = 0; i < _rootItem->childCount(); i++) { @@ -119,7 +124,7 @@ const MeshLib::Mesh* MeshModel::getMesh(const std::string &name) const return nullptr; } -bool MeshModel::removeMesh(const QModelIndex &idx) +bool MeshModel::removeMesh(const QModelIndex& idx) { if (idx.isValid()) { @@ -133,7 +138,7 @@ bool MeshModel::removeMesh(const QModelIndex &idx) return false; } -bool MeshModel::removeMesh(const std::string &name) +bool MeshModel::removeMesh(const std::string& name) { for (int i = 0; i < _rootItem->childCount(); i++) { @@ -142,7 +147,7 @@ bool MeshModel::removeMesh(const std::string &name) { beginResetModel(); emit meshRemoved(this, this->index(i, 0, QModelIndex())); - _rootItem->removeChildren(i,1); + _rootItem->removeChildren(i, 1); endResetModel(); return _project.removeMesh(name); } @@ -156,10 +161,11 @@ void MeshModel::updateMesh(MeshLib::Mesh* mesh) { for (int i = 0; i < _rootItem->childCount(); i++) { - if (dynamic_cast<MeshItem*>(this->_rootItem->child(i))->getMesh() == mesh) + if (dynamic_cast<MeshItem*>(this->_rootItem->child(i))->getMesh() == + mesh) { emit meshRemoved(this, this->index(i, 0, QModelIndex())); - _rootItem->removeChildren(i,1); + _rootItem->removeChildren(i, 1); } } this->addMeshObject(mesh); @@ -179,7 +185,8 @@ void MeshModel::updateModel() std::map<MeshLib::MeshElemType, QVariant> MeshModel::createMeshElemTypeMap() { - std::vector<MeshLib::MeshElemType> const& elem_types (MeshLib::getMeshElemTypes()); + std::vector<MeshLib::MeshElemType> const& elem_types( + MeshLib::getMeshElemTypes()); std::map<MeshLib::MeshElemType, QVariant> elem_map; for (MeshLib::MeshElemType t : elem_types) @@ -191,7 +198,7 @@ std::map<MeshLib::MeshElemType, QVariant> MeshModel::createMeshElemTypeMap() return elem_map; } -vtkUnstructuredGridAlgorithm* MeshModel::vtkSource(const QModelIndex &idx) const +vtkUnstructuredGridAlgorithm* MeshModel::vtkSource(const QModelIndex& idx) const { if (idx.isValid()) { @@ -203,7 +210,8 @@ vtkUnstructuredGridAlgorithm* MeshModel::vtkSource(const QModelIndex &idx) const return nullptr; } -vtkUnstructuredGridAlgorithm* MeshModel::vtkSource(const std::string &name) const +vtkUnstructuredGridAlgorithm* MeshModel::vtkSource( + const std::string& name) const { for (int i = 0; i < _rootItem->childCount(); i++) { diff --git a/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp b/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp index 4e4dac9c429..2d085f672a9 100644 --- a/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshQualitySelectionDialog.cpp @@ -13,12 +13,13 @@ */ #include "MeshQualitySelectionDialog.h" -#include "OGSError.h" #include <QFileDialog> #include <QFileInfo> #include <QSettings> +#include "OGSError.h" + /// Constructor MeshQualitySelectionDialog::MeshQualitySelectionDialog(QDialog* parent) : QDialog(parent), _histogram_path("") @@ -29,7 +30,8 @@ MeshQualitySelectionDialog::MeshQualitySelectionDialog(QDialog* parent) MeshQualitySelectionDialog::~MeshQualitySelectionDialog() = default; -void MeshQualitySelectionDialog::on_histogramCheckBox_toggled(bool is_checked) const +void MeshQualitySelectionDialog::on_histogramCheckBox_toggled( + bool is_checked) const { histogramPathEdit->setEnabled(is_checked); histogramPathButton->setEnabled(is_checked); @@ -39,9 +41,9 @@ void MeshQualitySelectionDialog::on_histogramPathButton_pressed() { QSettings settings; QFileInfo fi(settings.value("lastOpenedFileDirectory").toString()); - QString file_name = QFileDialog::getSaveFileName(this, "Save histogram as", - fi.baseName(), - "Text files (*.txt);;All files (* *.*)"); + QString file_name = + QFileDialog::getSaveFileName(this, "Save histogram as", fi.baseName(), + "Text files (*.txt);;All files (* *.*)"); this->histogramPathEdit->setText(file_name); } diff --git a/Applications/DataExplorer/DataView/MeshTabWidget.cpp b/Applications/DataExplorer/DataView/MeshTabWidget.cpp index 0387777a616..b006464f8a0 100644 --- a/Applications/DataExplorer/DataView/MeshTabWidget.cpp +++ b/Applications/DataExplorer/DataView/MeshTabWidget.cpp @@ -15,14 +15,18 @@ // ** INCLUDES ** #include "MeshTabWidget.h" -MeshTabWidget::MeshTabWidget( QWidget* parent /*= 0*/ ) - : QWidget(parent) +MeshTabWidget::MeshTabWidget(QWidget* parent /*= 0*/) : QWidget(parent) { setupUi(this); - connect(this->addMeshPushButton, SIGNAL(clicked()), this->treeView, SLOT(addMesh())); - connect(this->saveMeshPushButton, SIGNAL(clicked()), this->treeView, SLOT(writeToFile())); - connect(this->removeMeshPushButton, SIGNAL(clicked()), this->treeView, SLOT(removeMesh())); - connect(this->treeView, SIGNAL(enableSaveButton(bool)), this, SLOT(enableSaveButton(bool))); - connect(this->treeView, SIGNAL(enableRemoveButton(bool)), this, SLOT(enableRemoveButton(bool))); + connect(this->addMeshPushButton, SIGNAL(clicked()), this->treeView, + SLOT(addMesh())); + connect(this->saveMeshPushButton, SIGNAL(clicked()), this->treeView, + SLOT(writeToFile())); + connect(this->removeMeshPushButton, SIGNAL(clicked()), this->treeView, + SLOT(removeMesh())); + connect(this->treeView, SIGNAL(enableSaveButton(bool)), this, + SLOT(enableSaveButton(bool))); + connect(this->treeView, SIGNAL(enableRemoveButton(bool)), this, + SLOT(enableRemoveButton(bool))); } diff --git a/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp b/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp index 5d024870aa7..7e66bc4e0c1 100644 --- a/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp +++ b/Applications/DataExplorer/DataView/MeshValueEditDialog.cpp @@ -13,10 +13,10 @@ */ #include "MeshValueEditDialog.h" + #include "MeshEditing/ElementValueModification.h" #include "OGSError.h" - MeshValueEditDialog::MeshValueEditDialog(MeshLib::Mesh* mesh, QDialog* parent) : QDialog(parent), _mesh(mesh) { @@ -41,15 +41,19 @@ void MeshValueEditDialog::accept() OGSError::box("Please input which material you want to replace."); return; } - unsigned old_value = static_cast<unsigned>(this->edit_old_value->text().toInt()); + unsigned old_value = + static_cast<unsigned>(this->edit_old_value->text().toInt()); if (this->edit_new_value->text().isEmpty()) { - OGSError::box("Please input the new material to replace group " + this->edit_old_value->text() + "."); + OGSError::box("Please input the new material to replace group " + + this->edit_old_value->text() + "."); return; } - unsigned new_value = static_cast<unsigned>(this->edit_new_value->text().toInt()); + unsigned new_value = + static_cast<unsigned>(this->edit_new_value->text().toInt()); bool do_not_replace = this->replaceCheckBox->isChecked(); - bool result = MeshLib::ElementValueModification::replace(*_mesh, old_value, new_value, !do_not_replace); + bool result = MeshLib::ElementValueModification::replace( + *_mesh, old_value, new_value, !do_not_replace); if (!result && do_not_replace) { OGSError::box("The new material group already exists."); @@ -72,5 +76,3 @@ void MeshValueEditDialog::on_replaceButton_toggled(bool isSelected) this->edit_new_value->setEnabled(isSelected); this->replaceCheckBox->setEnabled(isSelected); } - - diff --git a/Applications/DataExplorer/DataView/MeshView.cpp b/Applications/DataExplorer/DataView/MeshView.cpp index a999c9cae24..d41989066bc 100644 --- a/Applications/DataExplorer/DataView/MeshView.cpp +++ b/Applications/DataExplorer/DataView/MeshView.cpp @@ -14,46 +14,40 @@ #include "MeshView.h" -#include <memory> - -#include <QHeaderView> #include <QContextMenuEvent> #include <QFileDialog> +#include <QHeaderView> #include <QMenu> #include <QObject> #include <QSettings> +#include <memory> -#include "SHPInterface.h" -#include "TetGenInterface.h" +#include "AddLayerToMeshDialog.h" #include "Applications/FileIO/AsciiRasterInterface.h" - +#include "ImportFileTypes.h" +#include "LastSavedFileDirectory.h" +#include "MeshItem.h" +#include "MeshLayerEditDialog.h" #include "MeshLib/Mesh.h" -#include "MeshLib/Node.h" -#include "MeshLib/MeshSurfaceExtraction.h" #include "MeshLib/MeshEditing/AddLayerToMesh.h" #include "MeshLib/MeshEditing/RasterDataToMesh.h" - -#include "OGSError.h" +#include "MeshLib/MeshSurfaceExtraction.h" +#include "MeshLib/Node.h" #include "MeshMapping2DDialog.h" -#include "RasterDataToMeshDialog.h" -#include "MeshLayerEditDialog.h" -#include "MeshValueEditDialog.h" -#include "SurfaceExtractionDialog.h" -#include "AddLayerToMeshDialog.h" -#include "MeshItem.h" #include "MeshModel.h" - -#include "ImportFileTypes.h" -#include "LastSavedFileDirectory.h" +#include "MeshValueEditDialog.h" +#include "OGSError.h" +#include "RasterDataToMeshDialog.h" +#include "SHPInterface.h" #include "SaveMeshDialog.h" +#include "SurfaceExtractionDialog.h" +#include "TetGenInterface.h" - -MeshView::MeshView( QWidget* parent /*= 0*/ ) - : QTreeView(parent) +MeshView::MeshView(QWidget* parent /*= 0*/) : QTreeView(parent) { setUniformRowHeights(true); - //resizeColumnsToContents(); - //resizeRowsToContents(); + // resizeColumnsToContents(); + // resizeRowsToContents(); } MeshView::~MeshView() = default; @@ -61,22 +55,25 @@ MeshView::~MeshView() = default; void MeshView::updateView() { setAlternatingRowColors(true); - setColumnWidth(0,150); - std::size_t nColumns = (this->model() != nullptr) ? this->model()->columnCount() : 0; + setColumnWidth(0, 150); + std::size_t nColumns = + (this->model() != nullptr) ? this->model()->columnCount() : 0; for (std::size_t i = 1; i < nColumns; i++) { resizeColumnToContents(i); } } -void MeshView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected ) +void MeshView::selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) { Q_UNUSED(deselected); if (!selected.isEmpty()) { emit removeSelectedMeshComponent(); const QModelIndex idx = *(selected.indexes().begin()); - const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); + const TreeItem* tree_item = + static_cast<TreeModel*>(this->model())->getItem(idx); const auto* list_item = dynamic_cast<const MeshItem*>(tree_item); if (list_item) @@ -89,7 +86,10 @@ void MeshView::selectionChanged( const QItemSelection &selected, const QItemSele { emit enableSaveButton(false); emit enableRemoveButton(false); - emit elementSelected(dynamic_cast<const MeshItem*>(tree_item->parentItem())->vtkSource(), static_cast<unsigned>(tree_item->row()), true); + emit elementSelected( + dynamic_cast<const MeshItem*>(tree_item->parentItem()) + ->vtkSource(), + static_cast<unsigned>(tree_item->row()), true); } } } @@ -101,7 +101,7 @@ void MeshView::addMesh() void MeshView::removeMesh() { - QModelIndex index (this->selectionModel()->currentIndex()); + QModelIndex index(this->selectionModel()->currentIndex()); if (!index.isValid()) { OGSError::box("No mesh selected."); @@ -114,39 +114,52 @@ void MeshView::removeMesh() } } -void MeshView::contextMenuEvent( QContextMenuEvent* event ) +void MeshView::contextMenuEvent(QContextMenuEvent* event) { QModelIndex const& index = this->selectionModel()->currentIndex(); - MeshItem const*const item = dynamic_cast<MeshItem*>(static_cast<TreeItem*>(index.internalPointer())); + MeshItem const* const item = dynamic_cast<MeshItem*>( + static_cast<TreeItem*>(index.internalPointer())); if (item == nullptr) { return; } - unsigned const mesh_dim (item->getMesh()->getDimension()); + unsigned const mesh_dim(item->getMesh()->getDimension()); std::vector<MeshAction> actions; actions.push_back({new QAction("Map mesh...", this), 1, 2}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(openMap2dMeshDialog())); - actions.push_back({new QAction("Assign raster data to mesh...", this), 1, 2}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(openRasterDataToMeshDialog())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(openMap2dMeshDialog())); + actions.push_back( + {new QAction("Assign raster data to mesh...", this), 1, 2}); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(openRasterDataToMeshDialog())); actions.push_back({new QAction("Edit mesh...", this), 2, 3}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(openMeshEditDialog())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(openMeshEditDialog())); actions.push_back({new QAction("Add layer...", this), 1, 3}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(openAddLayerDialog())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(openAddLayerDialog())); actions.push_back({new QAction("Edit material groups...", this), 1, 3}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(openValuesEditDialog())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(openValuesEditDialog())); actions.push_back({new QAction("Extract surface...", this), 3, 3}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(extractSurfaceMesh())); - actions.push_back({new QAction("Calculate element quality...", this), 2, 3}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(checkMeshQuality())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(extractSurfaceMesh())); + actions.push_back( + {new QAction("Calculate element quality...", this), 2, 3}); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(checkMeshQuality())); actions.push_back({new QAction("Convert to geometry", this), 1, 2}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(convertMeshToGeometry())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(convertMeshToGeometry())); actions.push_back({new QAction("Export to Shapefile...", this), 2, 2}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(exportToShapefile())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(exportToShapefile())); actions.push_back({new QAction("Export to TetGen...", this), 3, 3}); - connect(actions.back().action, SIGNAL(triggered()), this, SLOT(exportToTetGen())); + connect(actions.back().action, SIGNAL(triggered()), this, + SLOT(exportToTetGen())); QMenu menu(this); for (MeshAction a : actions) @@ -161,9 +174,9 @@ void MeshView::contextMenuEvent( QContextMenuEvent* event ) void MeshView::openMap2dMeshDialog() { - MeshModel const*const model = static_cast<MeshModel*>(this->model()); + MeshModel const* const model = static_cast<MeshModel*>(this->model()); QModelIndex const index = this->selectionModel()->currentIndex(); - MeshLib::Mesh const*const mesh = model->getMesh(index); + MeshLib::Mesh const* const mesh = model->getMesh(index); if (mesh == nullptr) { return; @@ -202,7 +215,6 @@ void MeshView::openMap2dMeshDialog() dlg.getStaticValue()); } static_cast<MeshModel*>(this->model())->addMesh(std::move(result)); - } void MeshView::openRasterDataToMeshDialog() @@ -246,25 +258,25 @@ void MeshView::openRasterDataToMeshDialog() void MeshView::openMeshEditDialog() { - MeshModel const*const model = static_cast<MeshModel*>(this->model()); + MeshModel const* const model = static_cast<MeshModel*>(this->model()); QModelIndex const index = this->selectionModel()->currentIndex(); - MeshLib::Mesh const*const mesh = model->getMesh(index); + MeshLib::Mesh const* const mesh = model->getMesh(index); MeshLayerEditDialog meshLayerEdit(mesh); - connect(&meshLayerEdit, SIGNAL(mshEditFinished(MeshLib::Mesh*)), - model, SLOT(addMesh(MeshLib::Mesh*))); + connect(&meshLayerEdit, SIGNAL(mshEditFinished(MeshLib::Mesh*)), model, + SLOT(addMesh(MeshLib::Mesh*))); meshLayerEdit.exec(); } void MeshView::openValuesEditDialog() { - MeshModel const*const model = static_cast<MeshModel*>(this->model()); + MeshModel const* const model = static_cast<MeshModel*>(this->model()); QModelIndex const index = this->selectionModel()->currentIndex(); auto* mesh = const_cast<MeshLib::Mesh*>(model->getMesh(index)); MeshValueEditDialog valueEdit(mesh); - connect(&valueEdit, SIGNAL(valueEditFinished(MeshLib::Mesh*)), - model, SLOT(updateMesh(MeshLib::Mesh*))); + connect(&valueEdit, SIGNAL(valueEditFinished(MeshLib::Mesh*)), model, + SLOT(updateMesh(MeshLib::Mesh*))); valueEdit.exec(); } @@ -276,7 +288,8 @@ void MeshView::openAddLayerDialog() return; } - MeshLib::Mesh const*const mesh = static_cast<MeshModel*>(this->model())->getMesh(index); + MeshLib::Mesh const* const mesh = + static_cast<MeshModel*>(this->model())->getMesh(index); if (mesh == nullptr) { return; @@ -290,9 +303,8 @@ void MeshView::openAddLayerDialog() bool const copy_material_ids = false; double const thickness(dlg.getThickness()); - std::unique_ptr<MeshLib::Mesh> result( - MeshLib::addLayerToMesh(*mesh, thickness, dlg.getName(), - dlg.isTopLayer(), copy_material_ids)); + std::unique_ptr<MeshLib::Mesh> result(MeshLib::addLayerToMesh( + *mesh, thickness, dlg.getName(), dlg.isTopLayer(), copy_material_ids)); if (result) { @@ -312,7 +324,8 @@ void MeshView::extractSurfaceMesh() return; } - MeshLib::Mesh const*const mesh = static_cast<MeshModel*>(this->model())->getMesh(index); + MeshLib::Mesh const* const mesh = + static_cast<MeshModel*>(this->model())->getMesh(index); SurfaceExtractionDialog dlg; if (dlg.exec() != QDialog::Accepted) { @@ -320,7 +333,7 @@ void MeshView::extractSurfaceMesh() } Eigen::Vector3d const& dir(dlg.getNormal()); - int const tolerance (dlg.getTolerance()); + int const tolerance(dlg.getTolerance()); std::unique_ptr<MeshLib::Mesh> sfc_mesh( MeshLib::MeshSurfaceExtraction::getMeshSurface( *mesh, dir, tolerance, "Bulk Mesh Node IDs", @@ -339,7 +352,8 @@ void MeshView::extractSurfaceMesh() void MeshView::convertMeshToGeometry() { QModelIndex const index = this->selectionModel()->currentIndex(); - MeshLib::Mesh const*const mesh = static_cast<MeshModel*>(this->model())->getMesh(index); + MeshLib::Mesh const* const mesh = + static_cast<MeshModel*>(this->model())->getMesh(index); emit requestMeshToGeometryConversion(mesh); } @@ -352,10 +366,14 @@ void MeshView::exportToShapefile() const } QSettings const settings; - QFileInfo const fi (settings.value("lastOpenedMeshFileDirectory").toString()); - MeshLib::Mesh const*const mesh = static_cast<MeshModel*>(this->model())->getMesh(index); - QString const fileName = QFileDialog::getSaveFileName(nullptr, "Convert mesh to shapefile...", - LastSavedFileDirectory::getDir() + QString::fromStdString(mesh->getName()), + QFileInfo const fi( + settings.value("lastOpenedMeshFileDirectory").toString()); + MeshLib::Mesh const* const mesh = + static_cast<MeshModel*>(this->model())->getMesh(index); + QString const fileName = QFileDialog::getSaveFileName( + nullptr, "Convert mesh to shapefile...", + LastSavedFileDirectory::getDir() + + QString::fromStdString(mesh->getName()), "ESRI Shapefile (*.shp)"); if (!fileName.isEmpty()) { @@ -376,9 +394,11 @@ void MeshView::exportToTetGen() return; } - MeshLib::Mesh const*const mesh = static_cast<MeshModel*>(this->model())->getMesh(index); + MeshLib::Mesh const* const mesh = + static_cast<MeshModel*>(this->model())->getMesh(index); QSettings const settings; - QString const filename = QFileDialog::getSaveFileName(this, "Write TetGen input file to", + QString const filename = QFileDialog::getSaveFileName( + this, "Write TetGen input file to", settings.value("lastOpenedTetgenFileDirectory").toString(), "TetGen Geometry (*.smesh)"); if (!filename.isEmpty()) @@ -398,7 +418,8 @@ void MeshView::writeToFile() const return; } - MeshLib::Mesh const*const mesh = static_cast<MeshModel*>(this->model())->getMesh(index); + MeshLib::Mesh const* const mesh = + static_cast<MeshModel*>(this->model())->getMesh(index); if (mesh == nullptr) { OGSError::box("No mesh selected."); @@ -411,8 +432,9 @@ void MeshView::writeToFile() const void MeshView::addDIRECTSourceTerms() { - //QModelIndex const index = this->selectionModel()->currentIndex(); - //MeshLib::Mesh const*const grid = static_cast<MeshModel*>(this->model())->getMesh(index); + // QModelIndex const index = this->selectionModel()->currentIndex(); + // MeshLib::Mesh const*const grid = + // static_cast<MeshModel*>(this->model())->getMesh(index); } void MeshView::loadDIRECTSourceTerms() @@ -421,10 +443,10 @@ void MeshView::loadDIRECTSourceTerms() emit loadFEMCondFileRequested(index.data(0).toString().toStdString()); } -void MeshView::checkMeshQuality () +void MeshView::checkMeshQuality() { QModelIndex const index = this->selectionModel()->currentIndex(); - MeshItem const*const item = static_cast<MeshItem*>(static_cast<MeshModel*>(this->model())->getItem(index)); + MeshItem const* const item = static_cast<MeshItem*>( + static_cast<MeshModel*>(this->model())->getItem(index)); emit qualityCheckRequested(item->vtkSource()); } - diff --git a/Applications/DataExplorer/DataView/ModelTreeItem.cpp b/Applications/DataExplorer/DataView/ModelTreeItem.cpp index f13aa4a3d9f..ae6c52ba7ba 100644 --- a/Applications/DataExplorer/DataView/ModelTreeItem.cpp +++ b/Applications/DataExplorer/DataView/ModelTreeItem.cpp @@ -14,7 +14,8 @@ #include "ModelTreeItem.h" -ModelTreeItem::ModelTreeItem(const QList<QVariant> &data, TreeItem* parent, BaseItem* item) +ModelTreeItem::ModelTreeItem(const QList<QVariant>& data, TreeItem* parent, + BaseItem* item) : TreeItem(data, parent), _item(item), _stn(nullptr) { } @@ -27,4 +28,3 @@ BaseItem* ModelTreeItem::getItem() const } return nullptr; } - diff --git a/Applications/DataExplorer/DataView/ModellingTabWidget.cpp b/Applications/DataExplorer/DataView/ModellingTabWidget.cpp index 0bcde55b2f0..f2625254386 100644 --- a/Applications/DataExplorer/DataView/ModellingTabWidget.cpp +++ b/Applications/DataExplorer/DataView/ModellingTabWidget.cpp @@ -16,10 +16,8 @@ //#include "ProcessModel.h" #include "ModellingTabWidget.h" -ModellingTabWidget::ModellingTabWidget( QWidget* parent /*= 0*/ ) +ModellingTabWidget::ModellingTabWidget(QWidget* parent /*= 0*/) : QWidget(parent) { setupUi(this); } - - diff --git a/Applications/DataExplorer/DataView/ProcessView.cpp b/Applications/DataExplorer/DataView/ProcessView.cpp index 954112a9f26..08e925b9bf6 100644 --- a/Applications/DataExplorer/DataView/ProcessView.cpp +++ b/Applications/DataExplorer/DataView/ProcessView.cpp @@ -8,15 +8,15 @@ * */ +#include "ProcessView.h" + #include <QFileDialog> #include <QMenu> #include "Applications/DataHolderLib/FemCondition.h" - #include "CondItem.h" #include "ProcessModel.h" #include "ProcessVarItem.h" -#include "ProcessView.h" //#include "FEMConditionSetupDialog.h" #include "SelectMeshDialog.h" diff --git a/Applications/DataExplorer/DataView/RasterDataToMeshDialog.cpp b/Applications/DataExplorer/DataView/RasterDataToMeshDialog.cpp index 05ffa235b38..d132b3e7fa1 100644 --- a/Applications/DataExplorer/DataView/RasterDataToMeshDialog.cpp +++ b/Applications/DataExplorer/DataView/RasterDataToMeshDialog.cpp @@ -9,11 +9,12 @@ */ #include "RasterDataToMeshDialog.h" -#include "OGSError.h" -#include "StrictDoubleValidator.h" -#include <QSettings> #include <QFileDialog> +#include <QSettings> + +#include "OGSError.h" +#include "StrictDoubleValidator.h" RasterDataToMeshDialog::RasterDataToMeshDialog(std::string const& mesh_name, QDialog* parent) @@ -23,7 +24,7 @@ RasterDataToMeshDialog::RasterDataToMeshDialog(std::string const& mesh_name, this->meshNameEdit->setText(QString::fromStdString(mesh_name) + "_Raster"); auto* no_data_validator = new StrictDoubleValidator(this); - this->noDataValueEdit->setValidator (no_data_validator); + this->noDataValueEdit->setValidator(no_data_validator); } void RasterDataToMeshDialog::on_rasterSelectButton_pressed() @@ -63,4 +64,3 @@ void RasterDataToMeshDialog::accept() this->done(QDialog::Accepted); } - diff --git a/Applications/DataExplorer/DataView/SHPImportDialog.cpp b/Applications/DataExplorer/DataView/SHPImportDialog.cpp index f7eb9c36cc7..076496baf6e 100644 --- a/Applications/DataExplorer/DataView/SHPImportDialog.cpp +++ b/Applications/DataExplorer/DataView/SHPImportDialog.cpp @@ -12,10 +12,7 @@ * */ -#include "GeoLib/GEOObjects.h" -#include "OGSError.h" #include "SHPImportDialog.h" -#include "SHPInterface.h" #include <QDialogButtonBox> #include <QFileInfo> @@ -24,6 +21,10 @@ #include <QRadioButton> #include <QVBoxLayout> +#include "GeoLib/GEOObjects.h" +#include "OGSError.h" +#include "SHPInterface.h" + SHPImportDialog::SHPImportDialog(std::string filename, GeoLib::GEOObjects& geo_objects, std::string const& gmsh_path, @@ -90,26 +91,28 @@ void SHPImportDialog::setupDialog() } _shpContentLabel = - new QLabel("The selected file contains " + QString::number( - numberOfEntities) + " " + type, this); + new QLabel("The selected file contains " + + QString::number(numberOfEntities) + " " + type, + this); _nameLabel = new QLabel("List Name: ", this); QFileInfo fi(QString::fromStdString(_filename)); _listName->setText(fi.baseName()); - if ((shpType - 1) % 10 == 0 && shpType != 31) // Points + if ((shpType - 1) % 10 == 0 && shpType != 31) // Points { _choice1 = new QRadioButton("Read as Geometry Points"); _choice2 = new QRadioButton("Read as Station Points"); - _choice1->toggle(); // default choice - _layout->addWidget( _shpContentLabel ); - _layout->addWidget( _choice1 ); - _layout->addWidget( _choice2 ); - _layout->addWidget( _nameLabel ); - _layout->addWidget( _listName ); + _choice1->toggle(); // default choice + _layout->addWidget(_shpContentLabel); + _layout->addWidget(_choice1); + _layout->addWidget(_choice2); + _layout->addWidget(_nameLabel); + _layout->addWidget(_listName); _fileType = 1; } - else if ((shpType - 3) % 10 == 0 || (shpType - 5) % 10 == 0) // Polylines + else if ((shpType - 3) % 10 == 0 || + (shpType - 5) % 10 == 0) // Polylines { _choice1 = new QRadioButton("Read Polylines only"); _choice2 = new QRadioButton("Read Polylines/Surfaces"); @@ -118,25 +121,27 @@ void SHPImportDialog::setupDialog() _choice2->setDisabled(true); // disable polygon-choice if file // contains only polylines } - _choice1->toggle(); // default choice - _layout->addWidget( _shpContentLabel ); - _layout->addWidget( _choice1 ); - _layout->addWidget( _choice2 ); - _layout->addWidget( _nameLabel ); - _layout->addWidget( _listName ); + _choice1->toggle(); // default choice + _layout->addWidget(_shpContentLabel); + _layout->addWidget(_choice1); + _layout->addWidget(_choice2); + _layout->addWidget(_nameLabel); + _layout->addWidget(_listName); _fileType = 2; } else { - _nameLabel->setText("This element type is currently not supported."); - _layout->addWidget( _shpContentLabel ); - _layout->addWidget( _nameLabel ); + _nameLabel->setText( + "This element type is currently not supported."); + _layout->addWidget(_shpContentLabel); + _layout->addWidget(_nameLabel); } - _buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + _buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | + QDialogButtonBox::Cancel); connect(_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - _layout->addWidget( _buttonBox ); + _layout->addWidget(_buttonBox); setLayout(_layout); } diff --git a/Applications/DataExplorer/DataView/SaveMeshDialog.cpp b/Applications/DataExplorer/DataView/SaveMeshDialog.cpp index ecb3acc8d4b..ed699c3e74d 100644 --- a/Applications/DataExplorer/DataView/SaveMeshDialog.cpp +++ b/Applications/DataExplorer/DataView/SaveMeshDialog.cpp @@ -17,30 +17,33 @@ #include <QFileDialog> #include <QSettings> - -#include "MeshLib/IO/VtkIO/VtuInterface.h" +#include "LastSavedFileDirectory.h" #include "MeshLib/IO/Legacy/MeshIO.h" +#include "MeshLib/IO/VtkIO/VtuInterface.h" #include "MeshLib/Mesh.h" #include "OGSError.h" -#include "LastSavedFileDirectory.h" SaveMeshDialog::SaveMeshDialog(MeshLib::Mesh const& mesh, QDialog* parent) : QDialog(parent), _mesh(mesh) { setupUi(this); - this->fileNameEdit->setText(LastSavedFileDirectory::getDir() + QString::fromStdString(_mesh.getName()) + ".vtu"); + this->fileNameEdit->setText(LastSavedFileDirectory::getDir() + + QString::fromStdString(_mesh.getName()) + + ".vtu"); } void SaveMeshDialog::on_selectDirButton_clicked() { - QString file_type ("VTK Unstructured Grid (*.vtu)"); + QString file_type("VTK Unstructured Grid (*.vtu)"); #ifndef NDEBUG file_type.append(";;Legacy geometry file (*.msh)"); -#endif // DEBUG +#endif // DEBUG QSettings settings; - QString const file_name = QFileDialog::getSaveFileName(this, + QString const file_name = QFileDialog::getSaveFileName( + this, "Save mesh as...", - LastSavedFileDirectory::getDir() + QString::fromStdString(_mesh.getName()), + LastSavedFileDirectory::getDir() + + QString::fromStdString(_mesh.getName()), file_type); if (!file_name.isEmpty()) @@ -52,7 +55,7 @@ void SaveMeshDialog::on_selectDirButton_clicked() void SaveMeshDialog::on_dataModeBox_currentIndexChanged(int index) { // Disable compression on Ascii - if(index == 0) + if (index == 0) { this->compressionCheckBox->setChecked(false); this->compressionCheckBox->setEnabled(false); @@ -67,7 +70,7 @@ void SaveMeshDialog::on_dataModeBox_currentIndexChanged(int index) void SaveMeshDialog::accept() { - QString const& file_name (this->fileNameEdit->text()); + QString const& file_name(this->fileNameEdit->text()); if (file_name.isEmpty()) { OGSError::box("No file name entered."); @@ -77,9 +80,8 @@ void SaveMeshDialog::accept() QFileInfo fi(file_name); if (fi.suffix().toLower() == "vtu") { - int dataMode = this->dataModeBox->currentIndex(); - bool compress (this->compressionCheckBox->isChecked()); + bool compress(this->compressionCheckBox->isChecked()); MeshLib::IO::VtuInterface vtkIO(&_mesh, dataMode, compress); vtkIO.writeToFile(file_name.toStdString()); } @@ -94,4 +96,3 @@ void SaveMeshDialog::accept() this->done(QDialog::Accepted); } - diff --git a/Applications/DataExplorer/DataView/SelectMeshDialog.cpp b/Applications/DataExplorer/DataView/SelectMeshDialog.cpp index 4844f717077..4f80705dc77 100644 --- a/Applications/DataExplorer/DataView/SelectMeshDialog.cpp +++ b/Applications/DataExplorer/DataView/SelectMeshDialog.cpp @@ -13,15 +13,18 @@ */ #include "SelectMeshDialog.h" -#include "GeoObject.h" +#include <QComboBox> #include <QDialogButtonBox> #include <QLabel> -#include <QComboBox> #include <QVBoxLayout> -SelectMeshDialog::SelectMeshDialog(const GeoLib::GeoObject* geo_object, const std::list<std::string> &msh_names, QDialog* parent) : - QDialog(parent), _geo_object(geo_object) +#include "GeoObject.h" + +SelectMeshDialog::SelectMeshDialog(const GeoLib::GeoObject* geo_object, + const std::list<std::string>& msh_names, + QDialog* parent) + : QDialog(parent), _geo_object(geo_object) { setupDialog(msh_names); show(); @@ -35,14 +38,13 @@ SelectMeshDialog::~SelectMeshDialog() delete _txt_label; } -void SelectMeshDialog::setupDialog(const std::list<std::string> &msh_names) +void SelectMeshDialog::setupDialog(const std::list<std::string>& msh_names) { _layout = new QVBoxLayout(this); QString dialog_text("Select Mesh"); _txt_label = new QLabel(this); _txt_label->setText(dialog_text); - _msh_names = new QComboBox(); for (const auto& msh_name : msh_names) { @@ -50,19 +52,22 @@ void SelectMeshDialog::setupDialog(const std::list<std::string> &msh_names) } setWindowTitle("Select Mesh..."); - _layout->addWidget( _txt_label ); - _layout->addWidget( _msh_names ); - _buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + _layout->addWidget(_txt_label); + _layout->addWidget(_msh_names); + _buttonBox = + new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - _layout->addWidget( _buttonBox ); + _layout->addWidget(_buttonBox); setLayout(_layout); } void SelectMeshDialog::accept() { - //emit requestNameChange(_parent_name, GeoLib::convertGeoType(_object_type_name), _id, _new_name->text().toStdString()); + // emit requestNameChange(_parent_name, + // GeoLib::convertGeoType(_object_type_name), _id, + // _new_name->text().toStdString()); this->done(QDialog::Accepted); } diff --git a/Applications/DataExplorer/DataView/SetNameDialog.cpp b/Applications/DataExplorer/DataView/SetNameDialog.cpp index e6f730d32cf..f6ab85f0e65 100644 --- a/Applications/DataExplorer/DataView/SetNameDialog.cpp +++ b/Applications/DataExplorer/DataView/SetNameDialog.cpp @@ -14,16 +14,17 @@ #include "SetNameDialog.h" -#include <QDialogButtonBox> #include <QDialogButtonBox> #include <QLabel> #include <QLineEdit> #include <QVBoxLayout> -SetNameDialog::SetNameDialog(const std::string &geo_object_type, std::size_t id, const std::string &old_name = "", QDialog* parent) -:QDialog(parent) +SetNameDialog::SetNameDialog(const std::string& geo_object_type, std::size_t id, + const std::string& old_name = "", QDialog* parent) + : QDialog(parent) { - QString const& label = QString::fromStdString(geo_object_type) + "#" + QString::number(id); + QString const& label = + QString::fromStdString(geo_object_type) + "#" + QString::number(id); setupDialog(label, old_name); show(); } @@ -36,7 +37,8 @@ SetNameDialog::~SetNameDialog() delete _txt_label; } -void SetNameDialog::setupDialog(const QString &label, const std::string &old_name) +void SetNameDialog::setupDialog(const QString& label, + const std::string& old_name) { _layout = new QVBoxLayout(this); QString dialog_text("Please enter a name for " + label); @@ -44,12 +46,13 @@ void SetNameDialog::setupDialog(const QString &label, const std::string &old_nam _new_name = new QLineEdit(QString::fromStdString(old_name)); setWindowTitle("Set name..."); - _layout->addWidget( _txt_label ); - _layout->addWidget( _new_name ); - _buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + _layout->addWidget(_txt_label); + _layout->addWidget(_new_name); + _buttonBox = + new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(_buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(_buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - _layout->addWidget( _buttonBox ); + _layout->addWidget(_buttonBox); setLayout(_layout); } diff --git a/Applications/DataExplorer/DataView/StationTabWidget.cpp b/Applications/DataExplorer/DataView/StationTabWidget.cpp index d2d6e373c19..17f425a59fd 100644 --- a/Applications/DataExplorer/DataView/StationTabWidget.cpp +++ b/Applications/DataExplorer/DataView/StationTabWidget.cpp @@ -15,14 +15,18 @@ // ** INCLUDES ** #include "StationTabWidget.h" -StationTabWidget::StationTabWidget( QWidget* parent /*= 0*/ ) - : QWidget(parent) +StationTabWidget::StationTabWidget(QWidget* parent /*= 0*/) : QWidget(parent) { setupUi(this); - connect(this->openStnPushButton, SIGNAL(clicked()), this->treeView, SLOT(addStationList())); - connect(this->saveStnPushButton, SIGNAL(clicked()), this->treeView, SLOT(writeToFile())); - connect(this->removeStnPushButton, SIGNAL(clicked()), this->treeView, SLOT(removeStationList())); - connect(this->treeView, SIGNAL(enableSaveButton(bool)), this, SLOT(enableSaveButton(bool))); - connect(this->treeView, SIGNAL(enableRemoveButton(bool)), this, SLOT(enableRemoveButton(bool))); + connect(this->openStnPushButton, SIGNAL(clicked()), this->treeView, + SLOT(addStationList())); + connect(this->saveStnPushButton, SIGNAL(clicked()), this->treeView, + SLOT(writeToFile())); + connect(this->removeStnPushButton, SIGNAL(clicked()), this->treeView, + SLOT(removeStationList())); + connect(this->treeView, SIGNAL(enableSaveButton(bool)), this, + SLOT(enableSaveButton(bool))); + connect(this->treeView, SIGNAL(enableRemoveButton(bool)), this, + SLOT(enableRemoveButton(bool))); } diff --git a/Applications/DataExplorer/DataView/StationTreeModel.cpp b/Applications/DataExplorer/DataView/StationTreeModel.cpp index 26d89fc96e6..dfc2255dbf7 100644 --- a/Applications/DataExplorer/DataView/StationTreeModel.cpp +++ b/Applications/DataExplorer/DataView/StationTreeModel.cpp @@ -14,22 +14,23 @@ #include "StationTreeModel.h" +#include <QDebug> #include "BaseItem.h" #include "OGSError.h" #include "Station.h" -#include <QDebug> - /** * Constructor. */ -StationTreeModel::StationTreeModel( QObject* parent ) - : TreeModel(parent) +StationTreeModel::StationTreeModel(QObject* parent) : TreeModel(parent) { QList<QVariant> rootData; delete _rootItem; - rootData << "Station Name" << "x" << "y" << "z"; + rootData << "Station Name" + << "x" + << "y" + << "z"; _rootItem = new ModelTreeItem(rootData, nullptr, nullptr); } @@ -42,8 +43,8 @@ StationTreeModel::~StationTreeModel() = default; * \param parent The parent of the item * \return The model index of the item */ -QModelIndex StationTreeModel::index( int row, int column, - const QModelIndex &parent /*= QModelIndex()*/ ) const +QModelIndex StationTreeModel::index( + int row, int column, const QModelIndex& parent /*= QModelIndex()*/) const { if (!hasIndex(row, column, parent)) { @@ -78,13 +79,13 @@ QModelIndex StationTreeModel::index( int row, int column, } /** - * Returns the Station-Object of the ModelTreeItem with the given index and the name of the list this station belongs to. - * \param index Index of the requested item - * \param listName Here, the method will put the name of the list this station belongs to. - * \return The station object associated with the tree item + * Returns the Station-Object of the ModelTreeItem with the given index and the + * name of the list this station belongs to. \param index Index of the requested + * item \param listName Here, the method will put the name of the list this + * station belongs to. \return The station object associated with the tree item */ -GeoLib::Station* StationTreeModel::stationFromIndex( const QModelIndex& index, - QString &listName ) const +GeoLib::Station* StationTreeModel::stationFromIndex(const QModelIndex& index, + QString& listName) const { if (index.isValid()) { @@ -97,7 +98,7 @@ GeoLib::Station* StationTreeModel::stationFromIndex( const QModelIndex& index, return nullptr; } -vtkPolyDataAlgorithm* StationTreeModel::vtkSource(const std::string &name) const +vtkPolyDataAlgorithm* StationTreeModel::vtkSource(const std::string& name) const { std::size_t nLists = _lists.size(); for (std::size_t i = 0; i < nLists; i++) @@ -124,26 +125,31 @@ void StationTreeModel::setNameForItem(const std::string& stn_vec_name, { return; } - TreeItem *const item = (*stn_list)->child(id); + TreeItem* const item = (*stn_list)->child(id); item->setData(0, QString::fromStdString(item_name)); } /** * Inserts a subtree under _rootItem. - * \param listName Name of the new subtree. If no name is given a default name is assigned. - * \param stations The list with stations to be added as children of that subtree + * \param listName Name of the new subtree. If no name is given a default name + * is assigned. \param stations The list with stations to be added as children + * of that subtree */ -void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib::Point*>* stations) +void StationTreeModel::addStationList( + QString listName, const std::vector<GeoLib::Point*>* stations) { beginResetModel(); QList<QVariant> grpName; - if (listName.compare("") == 0) // if no name is given a default name is assigned + if (listName.compare("") == + 0) // if no name is given a default name is assigned { listName = "List"; listName.append(QString::number(rowCount() + 1)); } - grpName << listName << "" << "" << ""; + grpName << listName << "" + << "" + << ""; auto* group = new ModelTreeItem(grpName, _rootItem, new BaseItem(listName, stations)); _lists.push_back(group); @@ -153,17 +159,19 @@ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib for (int i = 0; i < vectorSize; i++) { QList<QVariant> stn; - stn << QString::fromStdString(static_cast<GeoLib::Station*>((*stations)[i])->getName()) - << QString::number((*(*stations)[i])[0],'f') - << QString::number((*(*stations)[i])[1],'f') - << QString::number((*(*stations)[i])[2],'f'); + stn << QString::fromStdString( + static_cast<GeoLib::Station*>((*stations)[i])->getName()) + << QString::number((*(*stations)[i])[0], 'f') + << QString::number((*(*stations)[i])[1], 'f') + << QString::number((*(*stations)[i])[2], 'f'); auto* child = new ModelTreeItem(stn, group); child->setStation(static_cast<GeoLib::Station*>((*stations)[i])); group->appendChild(child); } - qDebug() << "List" << listName << "loaded, " << stations->size() << "items added."; + qDebug() << "List" << listName << "loaded, " << stations->size() + << "items added."; endResetModel(); } @@ -173,7 +181,7 @@ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib */ void StationTreeModel::removeStationList(QModelIndex index) { - if (index.isValid()) // + if (index.isValid()) // { auto* item = static_cast<ModelTreeItem*>(getItem(index)); @@ -194,7 +202,7 @@ void StationTreeModel::removeStationList(QModelIndex index) /** * Removes the TreeItem with the given name including all its children */ -void StationTreeModel::removeStationList(const std::string &name) +void StationTreeModel::removeStationList(const std::string& name) { for (auto& list : _lists) { diff --git a/Applications/DataExplorer/DataView/StationTreeView.cpp b/Applications/DataExplorer/DataView/StationTreeView.cpp index 064ec9eeb63..3949001ffdf 100644 --- a/Applications/DataExplorer/DataView/StationTreeView.cpp +++ b/Applications/DataExplorer/DataView/StationTreeView.cpp @@ -12,44 +12,46 @@ * */ +#include "StationTreeView.h" + #include <QFileDialog> #include <QMenu> -#include "GMSInterface.h" -#include "Station.h" - #include "DiagramPrefsDialog.h" +#include "GMSInterface.h" +#include "ImportFileTypes.h" +#include "LastSavedFileDirectory.h" #include "ModelTreeItem.h" #include "OGSError.h" +#include "Station.h" #include "StationTreeModel.h" -#include "StationTreeView.h" #include "StratWindow.h" -#include "ImportFileTypes.h" -#include "LastSavedFileDirectory.h" StationTreeView::StationTreeView(QWidget* parent) : QTreeView(parent) { -// setContextMenuPolicy(Qt::CustomContextMenu); -// connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &))); + // setContextMenuPolicy(Qt::CustomContextMenu); + // connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), + // this, SLOT(showContextMenu(const QPoint &))); } void StationTreeView::updateView() { setAlternatingRowColors(true); - setColumnWidth(0,150); - setColumnWidth(1,75); - setColumnWidth(2,75); - setColumnWidth(3,75); + setColumnWidth(0, 150); + setColumnWidth(1, 75); + setColumnWidth(2, 75); + setColumnWidth(3, 75); } -void StationTreeView::selectionChanged( const QItemSelection &selected, - const QItemSelection &deselected ) +void StationTreeView::selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) { Q_UNUSED(deselected); if (!selected.isEmpty()) { const QModelIndex idx = *(selected.indexes().begin()); - const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx); + const TreeItem* tree_item = + static_cast<TreeModel*>(this->model())->getItem(idx); const auto* list_item = dynamic_cast<const ModelTreeItem*>(tree_item->parentItem()); @@ -70,12 +72,12 @@ void StationTreeView::selectionChanged( const QItemSelection &selected, emit enableRemoveButton(true); } } - //emit itemSelectionChanged(selected, deselected); - //return QTreeView::selectionChanged(selected, deselected); + // emit itemSelectionChanged(selected, deselected); + // return QTreeView::selectionChanged(selected, deselected); } -void StationTreeView::selectionChangedFromOutside( const QItemSelection &selected, - const QItemSelection &deselected ) +void StationTreeView::selectionChangedFromOutside( + const QItemSelection& selected, const QItemSelection& deselected) { QItemSelectionModel* selModel = this->selectionModel(); @@ -87,7 +89,7 @@ void StationTreeView::selectionChangedFromOutside( const QItemSelection &selecte return QTreeView::selectionChanged(selected, deselected); } -void StationTreeView::contextMenuEvent( QContextMenuEvent* event ) +void StationTreeView::contextMenuEvent(QContextMenuEvent* event) { QModelIndex index = this->selectionModel()->currentIndex(); auto* item = static_cast<ModelTreeItem*>(index.internalPointer()); @@ -102,10 +104,10 @@ void StationTreeView::contextMenuEvent( QContextMenuEvent* event ) if (item->childCount() > 0) { QMenu menu; - QAction* exportAction = menu.addAction("Export to GMS..."); + QAction* exportAction = menu.addAction("Export to GMS..."); menu.addSeparator(); - connect(exportAction, SIGNAL(triggered()), this, SLOT(exportList())); + connect(exportAction, SIGNAL(triggered()), this, SLOT(exportList())); menu.exec(event->globalPos()); } // The current index refers to a station object @@ -115,14 +117,18 @@ void StationTreeView::contextMenuEvent( QContextMenuEvent* event ) QMenu menu; QAction* setNameAction = menu.addAction("Set name..."); - connect(setNameAction, SIGNAL(triggered()), this, SLOT(setNameForElement())); - if (static_cast<StationTreeModel*>(model())->stationFromIndex(index, temp_name)->type() - == GeoLib::Station::StationType::BOREHOLE) + connect(setNameAction, SIGNAL(triggered()), this, + SLOT(setNameForElement())); + if (static_cast<StationTreeModel*>(model()) + ->stationFromIndex(index, temp_name) + ->type() == GeoLib::Station::StationType::BOREHOLE) { QAction* stratAction = menu.addAction("Display Stratigraphy..."); QAction* exportAction = menu.addAction("Export to GMS..."); - connect(stratAction, SIGNAL(triggered()), this, SLOT(displayStratigraphy())); - connect(exportAction, SIGNAL(triggered()), this, SLOT(exportStation())); + connect(stratAction, SIGNAL(triggered()), this, + SLOT(displayStratigraphy())); + connect(exportAction, SIGNAL(triggered()), this, + SLOT(exportStation())); menu.exec(event->globalPos()); } else @@ -137,9 +143,11 @@ void StationTreeView::contextMenuEvent( QContextMenuEvent* event ) void StationTreeView::setNameForElement() { - TreeItem const*const item = static_cast<StationTreeModel*>(model())->getItem( + TreeItem const* const item = + static_cast<StationTreeModel*>(model())->getItem( this->selectionModel()->currentIndex()); - std::string const stn_vec_name = item->parentItem()->data(0).toString().toStdString(); + std::string const stn_vec_name = + item->parentItem()->data(0).toString().toStdString(); emit requestNameChangeDialog(stn_vec_name, item->row()); } @@ -150,17 +158,20 @@ void StationTreeView::displayStratigraphy() QString temp_name; // get list name static_cast<StationTreeModel*>(model())->stationFromIndex( - this->selectionModel()->currentIndex(), temp_name); + this->selectionModel()->currentIndex(), temp_name); // get color table (horrible way to do it but there you go ...) std::map<std::string, DataHolderLib::Color> colorLookupTable = - static_cast<VtkStationSource*>(static_cast<StationTreeModel*> - (model())->vtkSource(temp_name.toStdString()))->getColorLookupTable(); + static_cast<VtkStationSource*>( + static_cast<StationTreeModel*>(model())->vtkSource( + temp_name.toStdString())) + ->getColorLookupTable(); auto* stratView = new StratWindow( static_cast<GeoLib::StationBorehole*>( static_cast<StationTreeModel*>(model())->stationFromIndex( index, temp_name)), &colorLookupTable); - stratView->setAttribute(Qt::WA_DeleteOnClose); // this fixes the memory leak shown by cppcheck + stratView->setAttribute( + Qt::WA_DeleteOnClose); // this fixes the memory leak shown by cppcheck stratView->show(); } @@ -171,16 +182,18 @@ void StationTreeView::addStationList() void StationTreeView::writeToFile() { - QModelIndex index (this->selectionModel()->currentIndex()); + QModelIndex index(this->selectionModel()->currentIndex()); if (!index.isValid()) { OGSError::box("No station list selected."); } else { - TreeItem* item = static_cast<StationTreeModel*>(model())->getItem(index); + TreeItem* item = + static_cast<StationTreeModel*>(model())->getItem(index); QString listName = item->data(0).toString(); - QString fileName = QFileDialog::getSaveFileName(this, "Save station list", + QString fileName = QFileDialog::getSaveFileName( + this, "Save station list", LastSavedFileDirectory::getDir() + listName, "*.stn"); if (!fileName.isEmpty()) { @@ -193,50 +206,57 @@ void StationTreeView::writeToFile() void StationTreeView::exportList() { // only a test for the stratigraphy screenshot tool and writer!! - //QString Name = static_cast<StationTreeModel*>(model())->getItem(this->selectionModel()->currentIndex())->data(0).toString(); - //writeStratigraphiesAsImages(Name); + // QString Name = + // static_cast<StationTreeModel*>(model())->getItem(this->selectionModel()->currentIndex())->data(0).toString(); + // writeStratigraphiesAsImages(Name); TreeItem* item = static_cast<StationTreeModel*>(model())->getItem( - this->selectionModel()->currentIndex()); + this->selectionModel()->currentIndex()); QString listName = item->data(0).toString(); - QString fileName = QFileDialog::getSaveFileName(this, "Export Boreholes to GMS-Format", + QString fileName = QFileDialog::getSaveFileName( + this, "Export Boreholes to GMS-Format", LastSavedFileDirectory::getDir() + listName, "*.txt"); if (!fileName.isEmpty()) { LastSavedFileDirectory::setDir(fileName); - emit stationListExportRequested(listName.toStdString(), fileName.toStdString()); + emit stationListExportRequested(listName.toStdString(), + fileName.toStdString()); } } void StationTreeView::exportStation() { QModelIndex index = this->selectionModel()->currentIndex(); - QString fileName = QFileDialog::getSaveFileName(this, "Export Borehole to GMS-Format", - LastSavedFileDirectory::getDir(), "*.txt"); + QString fileName = + QFileDialog::getSaveFileName(this, "Export Borehole to GMS-Format", + LastSavedFileDirectory::getDir(), "*.txt"); if (!fileName.isEmpty()) { QString temp_name; std::vector<GeoLib::Point*> stations; stations.push_back(static_cast<GeoLib::StationBorehole*>( - static_cast<StationTreeModel*>(model())->stationFromIndex(index,temp_name))); - FileIO::GMSInterface::writeBoreholesToGMS(&stations, fileName.toStdString()); + static_cast<StationTreeModel*>(model())->stationFromIndex( + index, temp_name))); + FileIO::GMSInterface::writeBoreholesToGMS(&stations, + fileName.toStdString()); LastSavedFileDirectory::setDir(fileName); } } void StationTreeView::removeStationList() { - QModelIndex index (this->selectionModel()->currentIndex()); + QModelIndex index(this->selectionModel()->currentIndex()); if (!index.isValid()) { OGSError::box("No station list selected."); } else { - TreeItem* item = static_cast<StationTreeModel*>(model())->getItem(index); + TreeItem* item = + static_cast<StationTreeModel*>(model())->getItem(index); emit stationListRemoved((item->data(0).toString()).toStdString()); - if(this->selectionModel()->selectedIndexes().count() == 0) + if (this->selectionModel()->selectedIndexes().count() == 0) { emit enableSaveButton(false); emit enableRemoveButton(false); @@ -253,9 +273,12 @@ void StationTreeView::showDiagramPrefsDialog() void StationTreeView::writeStratigraphiesAsImages(QString listName) { std::map<std::string, DataHolderLib::Color> colorLookupTable = - static_cast<VtkStationSource*>(static_cast<StationTreeModel*> - (model())->vtkSource(listName.toStdString()))->getColorLookupTable(); - std::vector<ModelTreeItem*> lists = static_cast<StationTreeModel*>(model())->getLists(); + static_cast<VtkStationSource*>( + static_cast<StationTreeModel*>(model())->vtkSource( + listName.toStdString())) + ->getColorLookupTable(); + std::vector<ModelTreeItem*> lists = + static_cast<StationTreeModel*>(model())->getLists(); std::size_t nLists = lists.size(); for (std::size_t i = 0; i < nLists; i++) { diff --git a/Applications/DataExplorer/DataView/StratView/StratBar.cpp b/Applications/DataExplorer/DataView/StratView/StratBar.cpp index 80323c9509e..2ab579e9b71 100644 --- a/Applications/DataExplorer/DataView/StratView/StratBar.cpp +++ b/Applications/DataExplorer/DataView/StratView/StratBar.cpp @@ -13,12 +13,13 @@ */ #include "StratBar.h" + #include <QPainter> StratBar::StratBar(GeoLib::StationBorehole* station, std::map<std::string, DataHolderLib::Color>* stratColors, - QGraphicsItem* parent) : - QGraphicsItem(parent), _station(station) + QGraphicsItem* parent) + : QGraphicsItem(parent), _station(station) { if (stratColors) { @@ -31,10 +32,12 @@ QRectF StratBar::boundingRect() const return QRectF(0, 0, BARWIDTH + 10, totalLogHeight()); } -void StratBar::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +void StratBar::paint(QPainter* painter, + const QStyleOptionGraphicsItem* option, + QWidget* widget) { - Q_UNUSED (option) - Q_UNUSED (widget) + Q_UNUSED(option) + Q_UNUSED(widget) double top = 0; double height = 0; @@ -42,9 +45,9 @@ void StratBar::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QPen pen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin); pen.setCosmetic(true); painter->setPen(pen); - //painter->drawRect(_bar); + // painter->drawRect(_bar); - //pen.setWidth(1); + // pen.setWidth(1); std::vector<GeoLib::Point*> profile = _station->getProfile(); std::vector<std::string> soilNames = _station->getSoilNames(); std::size_t nLayers = profile.size(); @@ -56,7 +59,8 @@ void StratBar::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, top += height; height = logHeight(((*(profile[i - 1]))[2] - (*(profile[i]))[2])); QRectF layer(0, top, BARWIDTH, height); - DataHolderLib::Color const& c (DataHolderLib::getColor(soilNames[i], _stratColors)); + DataHolderLib::Color const& c( + DataHolderLib::getColor(soilNames[i], _stratColors)); QBrush brush(QColor(static_cast<int>(c[0]), static_cast<int>(c[1]), static_cast<int>(c[2]), @@ -69,7 +73,8 @@ void StratBar::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, static_cast<int>(layer.bottom()), BARWIDTH + 5, static_cast<int>(layer.bottom())); - //painter->drawText(BARWIDTH+10, layer.bottom(), QString::number((*(profile[i]))[2])); + // painter->drawText(BARWIDTH+10, layer.bottom(), + // QString::number((*(profile[i]))[2])); } } diff --git a/Applications/DataExplorer/DataView/StratView/StratScene.cpp b/Applications/DataExplorer/DataView/StratView/StratScene.cpp index edb398d9e36..37e14d18c23 100644 --- a/Applications/DataExplorer/DataView/StratView/StratScene.cpp +++ b/Applications/DataExplorer/DataView/StratView/StratScene.cpp @@ -12,43 +12,46 @@ * */ -#include <limits> +#include "StratScene.h" + #include <math.h> #include <QGraphicsTextItem> +#include <limits> #include "DateTools.h" #include "QNonScalableGraphicsTextItem.h" #include "StratBar.h" -#include "StratScene.h" StratScene::StratScene(GeoLib::StationBorehole* station, std::map<std::string, DataHolderLib::Color>* stratColors, - QObject* parent) : QGraphicsScene(parent) + QObject* parent) + : QGraphicsScene(parent) { QRectF textBounds; int stratBarOffset = 250; - QFont font( "Arial", 15, QFont::DemiBold, false); + QFont font("Arial", 15, QFont::DemiBold, false); - QNonScalableGraphicsTextItem* boreholeTag = addNonScalableText("Borehole", font); + QNonScalableGraphicsTextItem* boreholeTag = + addNonScalableText("Borehole", font); QNonScalableGraphicsTextItem* boreholeName = addNonScalableText( - "\"" + QString::fromStdString(station->getName()) + "\"", - font); + "\"" + QString::fromStdString(station->getName()) + "\"", font); textBounds = boreholeTag->boundingRect(); boreholeTag->setPos((textBounds.width() / 2.0), 80); textBounds = boreholeName->boundingRect(); boreholeName->setPos((textBounds.width() / 2.0), 200); - QNonScalableGraphicsTextItem* totalDepth = - addNonScalableText("Depth: " + QString::number(station->getDepth()) + " m"); + QNonScalableGraphicsTextItem* totalDepth = addNonScalableText( + "Depth: " + QString::number(station->getDepth()) + " m"); textBounds = totalDepth->boundingRect(); totalDepth->setPos((textBounds.width() / 2.0), 350); -/* - QNonScalableGraphicsTextItem* dateText = addNonScalableText("Date: " + QString::fromStdString(date2string(station->getDate()))); - textBounds = dateText->boundingRect(); - dateText->setPos(this->MARGIN + (textBounds.width()/2.0), 350); - */ + /* + QNonScalableGraphicsTextItem* dateText = addNonScalableText("Date: " + + QString::fromStdString(date2string(station->getDate()))); textBounds = + dateText->boundingRect(); dateText->setPos(this->MARGIN + + (textBounds.width()/2.0), 350); + */ QNonScalableGraphicsTextItem* dot = addNonScalableText(" "); dot->setPos(0, 0); @@ -56,7 +59,8 @@ StratScene::StratScene(GeoLib::StationBorehole* station, stratBar->setPos(stratBarOffset, MARGIN); QRectF stratBarBounds = stratBar->boundingRect(); - addDepthLabels(station->getProfile(), stratBarOffset + stratBarBounds.width()); + addDepthLabels(station->getProfile(), + stratBarOffset + stratBarBounds.width()); if (!station->getSoilNames().empty()) { @@ -67,25 +71,29 @@ StratScene::StratScene(GeoLib::StationBorehole* station, StratScene::~StratScene() = default; -void StratScene::addDepthLabels(std::vector<GeoLib::Point*> profile, double offset) +void StratScene::addDepthLabels(std::vector<GeoLib::Point*> profile, + double offset) { QRectF textBounds; double vertPos = MARGIN; std::vector<QNonScalableGraphicsTextItem*> depthText; - depthText.push_back(addNonScalableText(QString::number((*(profile[0]))[2]))); + depthText.push_back( + addNonScalableText(QString::number((*(profile[0]))[2]))); textBounds = depthText[0]->boundingRect(); depthText[0]->setPos(offset + textBounds.width() / 2, vertPos); for (std::size_t i = 1; i < profile.size(); i++) { - depthText.push_back(addNonScalableText(QString::number((*(profile[i]))[2]))); + depthText.push_back( + addNonScalableText(QString::number((*(profile[i]))[2]))); vertPos += log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100; textBounds = depthText[i]->boundingRect(); depthText[i]->setPos(offset + textBounds.width() / 2, vertPos); } } -QNonScalableGraphicsTextItem* StratScene::addNonScalableText(const QString &text, const QFont &font) +QNonScalableGraphicsTextItem* StratScene::addNonScalableText( + const QString& text, const QFont& font) { auto* item = new QNonScalableGraphicsTextItem(text); item->setFont(font); @@ -94,29 +102,35 @@ QNonScalableGraphicsTextItem* StratScene::addNonScalableText(const QString &text } void StratScene::addSoilNameLabels(std::vector<std::string> soilNames, - std::vector<GeoLib::Point*> profile, + std::vector<GeoLib::Point*> + profile, double offset) { - //QRectF textBounds; + // QRectF textBounds; double vertPos = MARGIN; double halfHeight = 0; std::vector<QNonScalableGraphicsTextItem*> soilText; - soilText.push_back(addNonScalableText(QString::fromStdString(soilNames[0]))); - //textBounds = soilText[0]->boundingRect(); + soilText.push_back( + addNonScalableText(QString::fromStdString(soilNames[0]))); + // textBounds = soilText[0]->boundingRect(); soilText[0]->setPos(offset /* - textBounds.width() */, vertPos); for (std::size_t i = 1; i < soilNames.size(); i++) { - soilText.push_back(addNonScalableText(QString::fromStdString(soilNames[i]))); - halfHeight = log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100 / 2; - //textBounds = soilText[i]->boundingRect(); - soilText[i]->setPos(offset /* - textBounds.width() */, vertPos + halfHeight); - vertPos += ( 2 * halfHeight ); + soilText.push_back( + addNonScalableText(QString::fromStdString(soilNames[i]))); + halfHeight = + log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100 / 2; + // textBounds = soilText[i]->boundingRect(); + soilText[i]->setPos(offset /* - textBounds.width() */, + vertPos + halfHeight); + vertPos += (2 * halfHeight); } } -StratBar* StratScene::addStratBar(GeoLib::StationBorehole* station, - std::map<std::string, DataHolderLib::Color>* stratColors) +StratBar* StratScene::addStratBar( + GeoLib::StationBorehole* station, + std::map<std::string, DataHolderLib::Color>* stratColors) { auto* b = new StratBar(station, stratColors); addItem(b); diff --git a/Applications/DataExplorer/DataView/StratView/StratView.cpp b/Applications/DataExplorer/DataView/StratView/StratView.cpp index c8e9117df2d..ebbb08d696c 100644 --- a/Applications/DataExplorer/DataView/StratView/StratView.cpp +++ b/Applications/DataExplorer/DataView/StratView/StratView.cpp @@ -12,17 +12,20 @@ * */ -#include "Station.h" #include "StratView.h" + #include <math.h> +#include "Station.h" + StratView::~StratView() { delete _scene; } -void StratView::setStation(GeoLib::StationBorehole* station, - std::map<std::string, DataHolderLib::Color>* stratColors) +void StratView::setStation( + GeoLib::StationBorehole* station, + std::map<std::string, DataHolderLib::Color>* stratColors) { _scene = new StratScene(station, stratColors); setScene(_scene); @@ -39,7 +42,7 @@ void StratView::initialize() void StratView::resizeEvent(QResizeEvent* event) { - Q_UNUSED (event) + Q_UNUSED(event) update(); } diff --git a/Applications/DataExplorer/DataView/StratView/StratWindow.cpp b/Applications/DataExplorer/DataView/StratView/StratWindow.cpp index b9a18921975..2fe2c92187b 100644 --- a/Applications/DataExplorer/DataView/StratView/StratWindow.cpp +++ b/Applications/DataExplorer/DataView/StratView/StratWindow.cpp @@ -12,15 +12,18 @@ * */ -#include "Station.h" #include "StratWindow.h" -StratWindow::StratWindow(GeoLib::StationBorehole* station, - std::map<std::string, DataHolderLib::Color>* stratColors, - QWidget* parent) : QWidget(parent) +#include "Station.h" + +StratWindow::StratWindow( + GeoLib::StationBorehole* station, + std::map<std::string, DataHolderLib::Color>* stratColors, + QWidget* parent) + : QWidget(parent) { setupUi(this); - stationView->setRenderHints( QPainter::Antialiasing ); + stationView->setRenderHints(QPainter::Antialiasing); stationView->setStation(station, stratColors); resizeWindow(); } @@ -33,6 +36,7 @@ void StratWindow::on_closeButton_clicked() void StratWindow::resizeWindow() { int width = (stationView->getWidth() > 800) ? 800 : stationView->getWidth(); - int height = (stationView->getHeight() > 600) ? 600 : stationView->getHeight(); + int height = + (stationView->getHeight() > 600) ? 600 : stationView->getHeight(); resize(width, height); } diff --git a/Applications/DataExplorer/DataView/SurfaceExtractionDialog.cpp b/Applications/DataExplorer/DataView/SurfaceExtractionDialog.cpp index 62c404b6255..0c11bea4615 100644 --- a/Applications/DataExplorer/DataView/SurfaceExtractionDialog.cpp +++ b/Applications/DataExplorer/DataView/SurfaceExtractionDialog.cpp @@ -20,9 +20,12 @@ SurfaceExtractionDialog::SurfaceExtractionDialog(QDialog* parent) : QDialog(parent) { setupUi(this); - this->xNormalEdit->setValidator(new QDoubleValidator(-1, 1, 3, xNormalEdit)); - this->yNormalEdit->setValidator(new QDoubleValidator(-1, 1, 3, yNormalEdit)); - this->zNormalEdit->setValidator(new QDoubleValidator(-1, 1, 3, zNormalEdit)); + this->xNormalEdit->setValidator( + new QDoubleValidator(-1, 1, 3, xNormalEdit)); + this->yNormalEdit->setValidator( + new QDoubleValidator(-1, 1, 3, yNormalEdit)); + this->zNormalEdit->setValidator( + new QDoubleValidator(-1, 1, 3, zNormalEdit)); } void SurfaceExtractionDialog::accept() @@ -34,4 +37,3 @@ void SurfaceExtractionDialog::accept() this->done(QDialog::Accepted); } - diff --git a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp index 1648cf6d9e7..f8550a499e9 100644 --- a/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp +++ b/Applications/DataExplorer/VtkVis/MeshFromRasterDialog.cpp @@ -13,11 +13,12 @@ */ #include "MeshFromRasterDialog.h" -#include "OGSError.h" + #include "MeshGenerators/VtkMeshConverter.h" +#include "OGSError.h" MeshFromRasterDialog::MeshFromRasterDialog(QDialog* parent) -: QDialog(parent), _mesh_name("mesh"), _array_name("MaterialIDs") + : QDialog(parent), _mesh_name("mesh"), _array_name("MaterialIDs") { setupUi(this); @@ -100,4 +101,3 @@ void MeshFromRasterDialog::reject() { this->done(QDialog::Rejected); } - diff --git a/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp b/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp index 2948bba5819..b5e05ca3c68 100644 --- a/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp +++ b/Applications/DataExplorer/VtkVis/NetCdfConfigureDialog.cpp @@ -9,22 +9,23 @@ #include "NetCdfConfigureDialog.h" -#include "MathLib/Point3d.h" -#include "GeoLib/Raster.h" -#include "MeshLib/MeshGenerators/RasterToMesh.h" -#include "MeshLib/MeshEnums.h" -#include "VtkVis/VtkGeoImageSource.h" -#include "VtkVis/VtkRaster.h" +#include <vtkImageImport.h> #include <QMessageBox> #include <QSettings> -#include <vtkImageImport.h> +#include "GeoLib/Raster.h" +#include "MathLib/Point3d.h" +#include "MeshLib/MeshEnums.h" +#include "MeshLib/MeshGenerators/RasterToMesh.h" +#include "VtkVis/VtkGeoImageSource.h" +#include "VtkVis/VtkRaster.h" using namespace netCDF; // Constructor -NetCdfConfigureDialog::NetCdfConfigureDialog(std::string const& fileName, QDialog* parent) +NetCdfConfigureDialog::NetCdfConfigureDialog(std::string const& fileName, + QDialog* parent) : QDialog(parent), _currentFile(fileName.c_str(), NcFile::read), _currentMesh(nullptr), @@ -33,9 +34,13 @@ NetCdfConfigureDialog::NetCdfConfigureDialog(std::string const& fileName, QDialo { setupUi(this); - int const idx = setVariableSelect(); // set up variables of the file in the combobox - comboBoxVariable->setCurrentIndex(idx); //pre-select the variable with the biggest number of dimensions...valueWithMaxDim() - _currentVar = _currentFile.getVar(comboBoxVariable->itemText(idx).toStdString()); + int const idx = + setVariableSelect(); // set up variables of the file in the combobox + comboBoxVariable->setCurrentIndex( + idx); // pre-select the variable with the biggest number of + // dimensions...valueWithMaxDim() + _currentVar = + _currentFile.getVar(comboBoxVariable->itemText(idx).toStdString()); setDimensionSelect(); @@ -50,16 +55,25 @@ NetCdfConfigureDialog::~NetCdfConfigureDialog() = default; void NetCdfConfigureDialog::accept() { QMessageBox valueErrorBox; - if (_currentVar.getDimCount() < 2){ + if (_currentVar.getDimCount() < 2) + { valueErrorBox.setText("Selected Variable has not enough dimensions."); valueErrorBox.exec(); - }else if (doubleSpinBoxDim2Start->value() == doubleSpinBoxDim2Start->maximum()){ + } + else if (doubleSpinBoxDim2Start->value() == + doubleSpinBoxDim2Start->maximum()) + { valueErrorBox.setText("Lon has invalid extend."); valueErrorBox.exec(); - }else if(doubleSpinBoxDim1Start->value() == doubleSpinBoxDim1Start->maximum()){ + } + else if (doubleSpinBoxDim1Start->value() == + doubleSpinBoxDim1Start->maximum()) + { valueErrorBox.setText("Lat has invalid extend."); valueErrorBox.exec(); - }else{ + } + else + { createDataObject(); this->done(QDialog::Accepted); } @@ -78,38 +92,41 @@ void NetCdfConfigureDialog::on_comboBoxVariable_currentIndexChanged(int /*id*/) setDimensionSelect(); } -//set up x-axis/lat +// set up x-axis/lat void NetCdfConfigureDialog::on_comboBoxDim1_currentIndexChanged(int /*id*/) { - double firstValue=0, lastValue=0; + double firstValue = 0, lastValue = 0; unsigned size = 0; - getDimEdges(comboBoxDim1->currentText().toStdString(), size, firstValue, lastValue); + getDimEdges(comboBoxDim1->currentText().toStdString(), size, firstValue, + lastValue); doubleSpinBoxDim1Start->setValue(firstValue); doubleSpinBoxDim1End->setValue(lastValue); doubleSpinBoxResolution->setValue(getResolution()); } -//set up y-axis/lon +// set up y-axis/lon void NetCdfConfigureDialog::on_comboBoxDim2_currentIndexChanged(int /*id*/) { if (_currentVar.getDimCount() > 1) { - double firstValue=0, lastValue=0; + double firstValue = 0, lastValue = 0; unsigned size = 0; - getDimEdges(comboBoxDim2->currentText().toStdString(), size, firstValue, lastValue); + getDimEdges(comboBoxDim2->currentText().toStdString(), size, firstValue, + lastValue); doubleSpinBoxDim2Start->setValue(firstValue); doubleSpinBoxDim2End->setValue(lastValue); } } -//set up time +// set up time void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int /*id*/) { if (_currentVar.getDimCount() > 2) { - double firstValue=0, lastValue=0; + double firstValue = 0, lastValue = 0; unsigned size = 0; - getDimEdges(comboBoxDim3->currentText().toStdString(), size, firstValue, lastValue); + getDimEdges(comboBoxDim3->currentText().toStdString(), size, firstValue, + lastValue); dateTimeEditDim3->setValue(static_cast<int>(firstValue)); dateTimeEditDim3->setMinimum(static_cast<int>(firstValue)); dateTimeEditDim3->setMaximum(static_cast<int>(lastValue)); @@ -117,14 +134,15 @@ void NetCdfConfigureDialog::on_comboBoxDim3_currentIndexChanged(int /*id*/) } } -//set up additional dimension +// set up additional dimension void NetCdfConfigureDialog::on_comboBoxDim4_currentIndexChanged(int /*id*/) { if (_currentVar.getDimCount() > 3) { - double firstValue=0, lastValue=0; + double firstValue = 0, lastValue = 0; unsigned size = 0; - getDimEdges(comboBoxDim4->currentText().toStdString(), size, firstValue, lastValue); + getDimEdges(comboBoxDim4->currentText().toStdString(), size, firstValue, + lastValue); spinBoxDim4->setValue(static_cast<int>(firstValue)); spinBoxDim4->setMinimum(static_cast<int>(firstValue)); spinBoxDim4->setMaximum(static_cast<int>(lastValue)); @@ -135,7 +153,7 @@ int NetCdfConfigureDialog::setVariableSelect() { int max_dim = 0; int max_dim_idx = 0; - auto const& names =_currentFile.getVars(); + auto const& names = _currentFile.getVars(); for (auto [name, var] : names) { int const var_dim_count = var.getDimCount(); @@ -155,7 +173,8 @@ int NetCdfConfigureDialog::setVariableSelect() void NetCdfConfigureDialog::setDimensionSelect() { int const dim_count = _currentVar.getDimCount(); - std::array<QComboBox*,4> dim_box = {{ comboBoxDim1, comboBoxDim2, comboBoxDim3, comboBoxDim4 }}; + std::array<QComboBox*, 4> dim_box = { + {comboBoxDim1, comboBoxDim2, comboBoxDim3, comboBoxDim4}}; for (int i = 0; i < 4; ++i) { @@ -168,7 +187,8 @@ void NetCdfConfigureDialog::setDimensionSelect() { for (int j = 0; j < dim_count; ++j) { - dim_box[j]->addItem(QString::fromStdString(_currentVar.getDim(i).getName())); + dim_box[j]->addItem( + QString::fromStdString(_currentVar.getDim(i).getName())); } } comboBoxDim1->setCurrentIndex(dim_count - 2); @@ -224,11 +244,13 @@ int NetCdfConfigureDialog::getDim4() const { NcVar const& dim3Var = _currentFile.getVar(comboBoxDim4->currentText().toStdString()); - std::vector<std::size_t> start{static_cast<std::size_t>(spinBoxDim4->value())}; + std::vector<std::size_t> start{ + static_cast<std::size_t>(spinBoxDim4->value())}; int value(0); dim3Var.getVar(start, {1}, &value); if (value < 0) - value = 0; //if the value isn't found in the array, set it to 0 as default... + value = 0; // if the value isn't found in the array, set it to 0 as + // default... return value; } @@ -236,7 +258,8 @@ double NetCdfConfigureDialog::getResolution() { if (comboBoxDim1->currentIndex() > -1) { - NcVar const& var = _currentFile.getVar(comboBoxDim1->currentText().toStdString()); + NcVar const& var = + _currentFile.getVar(comboBoxDim1->currentText().toStdString()); double firstValue = 0, lastValue = 0; unsigned size = 0; getDimEdges(var.getName(), size, firstValue, lastValue); @@ -282,8 +305,8 @@ void NetCdfConfigureDialog::createDataObject() } } - data_origin.push_back(0); // x-origin - data_origin.push_back(0); // y-origin + data_origin.push_back(0); // x-origin + data_origin.push_back(0); // y-origin data_length.push_back(sizeLat); data_length.push_back(sizeLon); _currentVar.getVar(data_origin, data_length, data_array.data()); @@ -294,10 +317,12 @@ void NetCdfConfigureDialog::createDataObject() double origin_x = (originLon < lastLon) ? originLon : lastLon; double origin_y = (originLat < lastLat) ? originLat : lastLat; - MathLib::Point3d origin(std::array<double,3>{{origin_x, origin_y, 0}}); + MathLib::Point3d origin(std::array<double, 3>{{origin_x, origin_y, 0}}); double resolution = (doubleSpinBoxResolution->value()); - if (originLat > lastLat) // reverse lines in vertical direction if the original file has its origin in the northwest corner + if (originLat > + lastLat) // reverse lines in vertical direction if the original file + // has its origin in the northwest corner this->reverseNorthSouth(data_array.data(), sizeLon, sizeLat); GeoLib::RasterHeader const header = {sizeLon, sizeLat, 1, @@ -305,27 +330,35 @@ void NetCdfConfigureDialog::createDataObject() if (this->radioMesh->isChecked()) { MeshLib::MeshElemType meshElemType = MeshLib::MeshElemType::QUAD; - MeshLib::UseIntensityAs useIntensity = MeshLib::UseIntensityAs::DATAVECTOR; + MeshLib::UseIntensityAs useIntensity = + MeshLib::UseIntensityAs::DATAVECTOR; if (comboBoxMeshElemType->currentIndex() == 1) { meshElemType = MeshLib::MeshElemType::TRIANGLE; - }else{ + } + else + { meshElemType = MeshLib::MeshElemType::QUAD; } if ((comboBoxUseIntensity->currentIndex()) == 1) { useIntensity = MeshLib::UseIntensityAs::ELEVATION; - }else{ + } + else + { useIntensity = MeshLib::UseIntensityAs::DATAVECTOR; } _currentMesh = MeshLib::RasterToMesh::convert( - data_array.data(), header, meshElemType, useIntensity, _currentVar.getName()); + data_array.data(), header, meshElemType, useIntensity, + _currentVar.getName()); } else { - vtkImageImport* image = VtkRaster::loadImageFromArray(data_array.data(), header); + vtkImageImport* image = + VtkRaster::loadImageFromArray(data_array.data(), header); _currentRaster = VtkGeoImageSource::New(); - _currentRaster->setImage(image, QString::fromStdString(this->getName())); + _currentRaster->setImage(image, + QString::fromStdString(this->getName())); } } @@ -333,7 +366,7 @@ QString NetCdfConfigureDialog::setName() { std::string name; name.append(_currentPath); - name.erase(0,name.find_last_of("/")+1); + name.erase(0, name.find_last_of("/") + 1); name.erase(name.find_last_of(".")); return QString::fromStdString(name); } @@ -346,22 +379,23 @@ std::string NetCdfConfigureDialog::getName() return name; } -void NetCdfConfigureDialog::reverseNorthSouth(double* data, std::size_t width, std::size_t height) +void NetCdfConfigureDialog::reverseNorthSouth(double* data, std::size_t width, + std::size_t height) { auto* cp_array = new double[width * height]; - for (std::size_t i=0; i<height; i++) + for (std::size_t i = 0; i < height; i++) { - for (std::size_t j=0; j<width; j++) + for (std::size_t j = 0; j < width; j++) { - std::size_t old_index((width*height)-(width*(i+1))); - std::size_t new_index(width*i); - cp_array[new_index+j] = data[old_index+j]; + std::size_t old_index((width * height) - (width * (i + 1))); + std::size_t new_index(width * i); + cp_array[new_index + j] = data[old_index + j]; } } - std::size_t length(height*width); - for (std::size_t i=0; i<length; i++) + std::size_t length(height * width); + for (std::size_t i = 0; i < length; i++) data[i] = cp_array[i]; delete[] cp_array; @@ -369,14 +403,14 @@ void NetCdfConfigureDialog::reverseNorthSouth(double* data, std::size_t width, s void NetCdfConfigureDialog::on_radioMesh_toggled(bool isTrue) { - if (isTrue) // output set to "mesh" + if (isTrue) // output set to "mesh" { this->label_2->setEnabled(true); this->label_3->setEnabled(false); this->comboBoxMeshElemType->setEnabled(true); this->comboBoxUseIntensity->setEnabled(false); } - else // output set to "raster" + else // output set to "raster" { this->label_2->setEnabled(false); this->label_3->setEnabled(true); diff --git a/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp b/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp index 2bb261e0c91..99130cb8f94 100644 --- a/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp +++ b/Applications/DataExplorer/VtkVis/QVtkDataSetMapper.cpp @@ -19,9 +19,7 @@ vtkStandardNewMacro(QVtkDataSetMapper); -QVtkDataSetMapper::QVtkDataSetMapper() : QObject(nullptr) -{ -} +QVtkDataSetMapper::QVtkDataSetMapper() : QObject(nullptr) {} QVtkDataSetMapper::~QVtkDataSetMapper() = default; @@ -30,8 +28,7 @@ void QVtkDataSetMapper::PrintSelf(ostream& os, vtkIndent indent) this->Superclass::PrintSelf(os, indent); } -void QVtkDataSetMapper::SetScalarVisibility( bool on ) +void QVtkDataSetMapper::SetScalarVisibility(bool on) { vtkDataSetMapper::SetScalarVisibility(static_cast<int>(on)); } - diff --git a/Applications/DataExplorer/VtkVis/VisPrefsDialog.cpp b/Applications/DataExplorer/VtkVis/VisPrefsDialog.cpp index 57d918b3f20..60e37af110e 100644 --- a/Applications/DataExplorer/VtkVis/VisPrefsDialog.cpp +++ b/Applications/DataExplorer/VtkVis/VisPrefsDialog.cpp @@ -13,6 +13,7 @@ */ #include "VisPrefsDialog.h" + #include <QDoubleValidator> #include <QLineEdit> #include <QSettings> @@ -22,11 +23,14 @@ #include "VtkVisPipeline.h" /// Constructor -VisPrefsDialog::VisPrefsDialog(VtkVisPipeline &pipeline, - VisualizationWidget &widget, - QDialog* parent) : - QDialog(parent), _vtkVisPipeline(pipeline), _visWidget(widget), - _above(0,0,2000000), _below(0,0,-2000000) +VisPrefsDialog::VisPrefsDialog(VtkVisPipeline& pipeline, + VisualizationWidget& widget, + QDialog* parent) + : QDialog(parent), + _vtkVisPipeline(pipeline), + _visWidget(widget), + _above(0, 0, 2000000), + _below(0, 0, -2000000) { setupUi(this); if (_vtkVisPipeline.getLight(_above)) @@ -43,12 +47,15 @@ VisPrefsDialog::VisPrefsDialog(VtkVisPipeline &pipeline, QValidator* validator = new QDoubleValidator(0, 100000, 2, this); superelevationLineEdit->setValidator(validator); QSettings settings; - superelevationLineEdit->setText(settings.value("globalSuperelevation", 1.0).toString()); - cullBackfacesCheckBox->setCheckState(Qt::CheckState(settings.value("globalCullBackfaces", 0).toInt())); - loadShowAllCheckBox->setCheckState(Qt::CheckState(settings.value("resetViewOnLoad", 2).toInt())); + superelevationLineEdit->setText( + settings.value("globalSuperelevation", 1.0).toString()); + cullBackfacesCheckBox->setCheckState( + Qt::CheckState(settings.value("globalCullBackfaces", 0).toInt())); + loadShowAllCheckBox->setCheckState( + Qt::CheckState(settings.value("resetViewOnLoad", 2).toInt())); } -void VisPrefsDialog::on_bgColorButton_colorPicked( QColor color ) +void VisPrefsDialog::on_bgColorButton_colorPicked(QColor color) { QColor bgColor(color.red(), color.green(), color.blue()); _vtkVisPipeline.setBGColor(bgColor); @@ -103,4 +110,3 @@ void VisPrefsDialog::on_cullBackfacesCheckBox_stateChanged(int state) QSettings settings; settings.setValue("globalCullBackfaces", state); } - diff --git a/Applications/DataExplorer/VtkVis/VisualizationWidget.cpp b/Applications/DataExplorer/VtkVis/VisualizationWidget.cpp index 6d8901a9912..30a542e139e 100644 --- a/Applications/DataExplorer/VtkVis/VisualizationWidget.cpp +++ b/Applications/DataExplorer/VtkVis/VisualizationWidget.cpp @@ -13,12 +13,7 @@ */ // ** INCLUDES ** -#include <cmath> - -#include "Point.h" #include "VisualizationWidget.h" -#include "VtkCustomInteractorStyle.h" -#include "VtkPickCallback.h" #include <vtkAxesActor.h> #include <vtkCamera.h> @@ -31,11 +26,9 @@ #include <vtkNew.h> #include <vtkOrientationMarkerWidget.h> #include <vtkPNGWriter.h> -#include <vtkRenderer.h> -#include <vtkRenderWindow.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> -#include <vtkSmartPointer.h> +#include <vtkRenderer.h> #include <vtkSmartPointer.h> #include <vtkWindowToImageFilter.h> @@ -46,6 +39,11 @@ #include <QLineEdit> #include <QSettings> #include <QString> +#include <cmath> + +#include "Point.h" +#include "VtkCustomInteractorStyle.h" +#include "VtkPickCallback.h" VisualizationWidget::VisualizationWidget(QWidget* parent /*= 0*/) : QWidget(parent) @@ -64,16 +62,18 @@ VisualizationWidget::VisualizationWidget(QWidget* parent /*= 0*/) _interactorStyle->SetDefaultRenderer(ren); _vtkPickCallback = VtkPickCallback::New(); - vtkSmartPointer<vtkCellPicker> picker = vtkSmartPointer<vtkCellPicker>::New(); + vtkSmartPointer<vtkCellPicker> picker = + vtkSmartPointer<vtkCellPicker>::New(); picker->AddObserver(vtkCommand::EndPickEvent, _vtkPickCallback); renderWindow->GetInteractor()->SetPicker(picker); QSettings settings; - ren->SetBackground(0.0,0.0,0.0); + ren->SetBackground(0.0, 0.0, 0.0); // Create an orientation marker using vtkAxesActor - vtkSmartPointer<vtkAxesActor> axesActor = vtkSmartPointer<vtkAxesActor>::New(); + vtkSmartPointer<vtkAxesActor> axesActor = + vtkSmartPointer<vtkAxesActor>::New(); _markerWidget = vtkOrientationMarkerWidget::New(); _markerWidget->SetOrientationMarker(axesActor); _markerWidget->SetInteractor(renderWindow->GetInteractor()); @@ -83,11 +83,11 @@ VisualizationWidget::VisualizationWidget(QWidget* parent /*= 0*/) _isShowAllOnLoad = settings.value("resetViewOnLoad", true).toBool(); // Set alternate cursor shapes - connect(_interactorStyle, SIGNAL(cursorChanged(Qt::CursorShape)), - this, SLOT(setCursorShape(Qt::CursorShape))); + connect(_interactorStyle, SIGNAL(cursorChanged(Qt::CursorShape)), this, + SLOT(setCursorShape(Qt::CursorShape))); - connect((QObject*)_interactorStyle, SIGNAL(requestViewUpdate()), - this, SLOT(updateView())); + connect((QObject*)_interactorStyle, SIGNAL(requestViewUpdate()), this, + SLOT(updateView())); } VisualizationWidget::~VisualizationWidget() @@ -122,7 +122,8 @@ void VisualizationWidget::showAll(int x, int y, int z) double* fp = cam->GetFocalPoint(); double* p = cam->GetPosition(); double dist = std::sqrt(vtkMath::Distance2BetweenPoints(p, fp)); - cam->SetPosition(fp[0]+(x*dist), fp[1]+(y*dist), fp[2]+(z*dist)); + cam->SetPosition(fp[0] + (x * dist), fp[1] + (y * dist), + fp[2] + (z * dist)); if (x != 0 || y != 0) { @@ -147,20 +148,22 @@ void VisualizationWidget::updateViewOnLoad() } } -void VisualizationWidget::on_zoomToolButton_toggled( bool checked ) +void VisualizationWidget::on_zoomToolButton_toggled(bool checked) { if (checked) { vtkSmartPointer<vtkInteractorStyleRubberBandZoom> interactorStyle = - vtkSmartPointer<vtkInteractorStyleRubberBandZoom>::New(); - vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(interactorStyle); + vtkSmartPointer<vtkInteractorStyleRubberBandZoom>::New(); + vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle( + interactorStyle); QCursor cursor; cursor.setShape(Qt::CrossCursor); vtkWidget->setCursor(cursor); } else { - vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(_interactorStyle); + vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle( + _interactorStyle); QCursor cursor; cursor.setShape(Qt::ArrowCursor); vtkWidget->setCursor(cursor); @@ -172,7 +175,8 @@ void VisualizationWidget::on_highlightToolButton_toggled(bool checked) _interactorStyle->setHighlightActor(checked); } -void VisualizationWidget::on_orthogonalProjectionToolButton_toggled( bool checked ) +void VisualizationWidget::on_orthogonalProjectionToolButton_toggled( + bool checked) { _vtkRender->GetActiveCamera()->SetParallelProjection(checked); this->updateView(); @@ -181,17 +185,16 @@ void VisualizationWidget::on_orthogonalProjectionToolButton_toggled( bool checke void VisualizationWidget::on_screenshotPushButton_pressed() { QSettings settings; - QString filename = QFileDialog::getSaveFileName(this, tr("Save screenshot"), - settings.value( - "lastScreenshotDir").toString(), - "PNG file (*.png)"); + QString filename = QFileDialog::getSaveFileName( + this, tr("Save screenshot"), + settings.value("lastScreenshotDir").toString(), "PNG file (*.png)"); if (filename.count() > 4) { bool ok; - int magnification = QInputDialog::getInt(this, tr("Screenshot magnification"), - tr( - "Enter a magnification factor for the resulting image."), - 2, 1, 10, 1, &ok); + int magnification = QInputDialog::getInt( + this, tr("Screenshot magnification"), + tr("Enter a magnification factor for the resulting image."), 2, 1, + 10, 1, &ok); if (ok) { QDir dir(filename); diff --git a/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp b/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp index 838e9938f6e..07830e56bf2 100644 --- a/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAddFilterDialog.cpp @@ -15,8 +15,13 @@ // ** INCLUDES ** #include "VtkAddFilterDialog.h" -#include "BaseLib/Logging.h" +#include <vtkContourFilter.h> +#include <vtkOutlineFilter.h> +#include <vtkTransformFilter.h> +#include <QModelIndex> + +#include "BaseLib/Logging.h" #include "VtkCompositeFilter.h" #include "VtkFilterFactory.h" #include "VtkVisImageItem.h" @@ -24,15 +29,9 @@ #include "VtkVisPipelineItem.h" #include "VtkVisPointSetItem.h" -#include <vtkContourFilter.h> -#include <vtkOutlineFilter.h> -#include <vtkTransformFilter.h> - -#include <QModelIndex> - -VtkAddFilterDialog::VtkAddFilterDialog( VtkVisPipeline &pipeline, - QModelIndex parentIndex, - QDialog* parent /*= 0*/ ) +VtkAddFilterDialog::VtkAddFilterDialog(VtkVisPipeline& pipeline, + QModelIndex parentIndex, + QDialog* parent /*= 0*/) : QDialog(parent), _pipeline(pipeline), _parentIndex(parentIndex) { setupUi(this); @@ -40,11 +39,12 @@ VtkAddFilterDialog::VtkAddFilterDialog( VtkVisPipeline &pipeline, auto* parentItem = static_cast<VtkVisPipelineItem*>(_pipeline.getItem(parentIndex)); - vtkDataObject* parentDataObject = parentItem->algorithm()->GetOutputDataObject(0); + vtkDataObject* parentDataObject = + parentItem->algorithm()->GetOutputDataObject(0); int parentDataObjectType = parentDataObject->GetDataObjectType(); QVector<VtkFilterInfo> filterList = VtkFilterFactory::GetFilterList(); - foreach(VtkFilterInfo filter, filterList) + foreach (VtkFilterInfo filter, filterList) { // Check for suitable filters (see vtkDataSet inheritance diagram) int inputType = filter.inputDataObjectType; @@ -60,17 +60,18 @@ VtkAddFilterDialog::VtkAddFilterDialog( VtkVisPipeline &pipeline, } // On double clicking an item the dialog gets accepted - connect(filterListWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)), - this->buttonBox,SIGNAL(accepted())); + connect(filterListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this->buttonBox, SIGNAL(accepted())); } void VtkAddFilterDialog::on_buttonBox_accepted() { QVector<VtkFilterInfo> filterList = VtkFilterFactory::GetFilterList(); QString filterName; - foreach(VtkFilterInfo filter, filterList) + foreach (VtkFilterInfo filter, filterList) { - if (filter.readableName.compare(filterListWidget->currentItem()->text()) == 0) + if (filter.readableName.compare( + filterListWidget->currentItem()->text()) == 0) { filterName = filter.name; break; @@ -84,7 +85,8 @@ void VtkAddFilterDialog::on_buttonBox_accepted() VtkCompositeFilter* filter; if (dynamic_cast<VtkVisImageItem*>(parentItem)) { - filter = VtkFilterFactory::CreateCompositeFilter(filterName, parentItem->algorithm()); + filter = VtkFilterFactory::CreateCompositeFilter( + filterName, parentItem->algorithm()); } else { @@ -106,7 +108,8 @@ void VtkAddFilterDialog::on_buttonBox_accepted() } else { - vtkAlgorithm* algorithm = VtkFilterFactory::CreateSimpleFilter(filterName); + vtkAlgorithm* algorithm = + VtkFilterFactory::CreateSimpleFilter(filterName); if (algorithm) { item = new VtkVisPointSetItem(algorithm, parentItem, itemData); @@ -121,17 +124,17 @@ void VtkAddFilterDialog::on_buttonBox_accepted() _pipeline.addPipelineItem(item, _parentIndex); } -void VtkAddFilterDialog::on_filterListWidget_currentRowChanged( int currentRow ) +void VtkAddFilterDialog::on_filterListWidget_currentRowChanged(int currentRow) { - foreach(VtkFilterInfo filter, VtkFilterFactory::GetFilterList()) + foreach (VtkFilterInfo filter, VtkFilterFactory::GetFilterList()) { - if (filter.readableName.compare(filterListWidget->item(currentRow)->text()) == 0) + if (filter.readableName.compare( + filterListWidget->item(currentRow)->text()) == 0) { QString desc = filter.description; desc = desc + QString("\n\nThis filter outputs ") + filter.OutputDataObjectTypeAsString() + - QString("\n\nFilter class name: ") + - filter.name; + QString("\n\nFilter class name: ") + filter.name; this->filterDescTextEdit->setText(desc); continue; diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp index 0e43c6f187c..913745a747f 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmProperties.cpp @@ -15,12 +15,11 @@ // ** INCLUDES ** #include "VtkAlgorithmProperties.h" -#include "BaseLib/Logging.h" - #include <vtkProperty.h> #include <vtkTexture.h> #include "Applications/DataHolderLib/ColorLookupTable.h" +#include "BaseLib/Logging.h" #include "VtkColorLookupTable.h" #include "XmlIO/Qt/XmlLutReader.h" @@ -28,10 +27,10 @@ VtkAlgorithmProperties::VtkAlgorithmProperties(QObject* parent /*= nullptr*/) : QObject(parent) { _property = vtkProperty::New(); - _texture = nullptr; + _texture = nullptr; _scalarVisibility = true; _algorithmUserProperties = new QMap<QString, QVariant>; - _algorithmUserVectorProperties = new QMap<QString, QList<QVariant> >; + _algorithmUserVectorProperties = new QMap<QString, QList<QVariant>>; _activeAttributeName = ""; _removable = true; } @@ -52,7 +51,8 @@ VtkAlgorithmProperties::~VtkAlgorithmProperties() delete _algorithmUserVectorProperties; } -vtkLookupTable* VtkAlgorithmProperties::GetLookupTable(const QString& array_name) +vtkLookupTable* VtkAlgorithmProperties::GetLookupTable( + const QString& array_name) { auto it = _lut.find(array_name); if (it != _lut.end()) @@ -73,19 +73,21 @@ void VtkAlgorithmProperties::RemoveLookupTable(const QString& array_name) } } -void VtkAlgorithmProperties::SetLookUpTable(const QString &array_name, vtkLookupTable* lut) +void VtkAlgorithmProperties::SetLookUpTable(const QString& array_name, + vtkLookupTable* lut) { lut->Build(); if (array_name.length() > 0) { this->RemoveLookupTable(array_name); - _lut.insert( std::pair<QString, vtkLookupTable*>(array_name, lut) ); + _lut.insert(std::pair<QString, vtkLookupTable*>(array_name, lut)); _activeAttributeName = array_name; } } -void VtkAlgorithmProperties::SetLookUpTable(const QString &array_name, const QString &filename) +void VtkAlgorithmProperties::SetLookUpTable(const QString& array_name, + const QString& filename) { DataHolderLib::ColorLookupTable lut; if (FileIO::XmlLutReader::readFromFile(filename, lut)) @@ -95,7 +97,7 @@ void VtkAlgorithmProperties::SetLookUpTable(const QString &array_name, const QSt SetLookUpTable(array_name, colorLookupTable); } else - ERR ("Error reading color look-up table."); + ERR("Error reading color look-up table."); } void VtkAlgorithmProperties::SetScalarVisibility(bool on) @@ -115,7 +117,8 @@ QVariant VtkAlgorithmProperties::GetUserProperty(QString name) const return QVariant(); } -QList<QVariant> VtkAlgorithmProperties::GetUserVectorProperty(QString name) const +QList<QVariant> VtkAlgorithmProperties::GetUserVectorProperty( + QString name) const { if (this->_algorithmUserVectorProperties->contains(name)) { diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp index e20e6465f37..7dec2be8f11 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyCheckbox.cpp @@ -13,10 +13,10 @@ */ // ** INCLUDES ** -#include <utility> - #include "VtkAlgorithmPropertyCheckbox.h" +#include <utility> + #include "VtkAlgorithmProperties.h" VtkAlgorithmPropertyCheckbox::VtkAlgorithmPropertyCheckbox( @@ -32,7 +32,7 @@ VtkAlgorithmPropertyCheckbox::VtkAlgorithmPropertyCheckbox( VtkAlgorithmPropertyCheckbox::~VtkAlgorithmPropertyCheckbox() = default; -void VtkAlgorithmPropertyCheckbox::setNewValue( int state ) +void VtkAlgorithmPropertyCheckbox::setNewValue(int state) { auto boolState = static_cast<bool>(state); _algProps->SetUserProperty(_name, QVariant(boolState)); diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp index 8d95745bb49..35eb3dbee48 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyLineEdit.cpp @@ -15,12 +15,12 @@ // ** INCLUDES ** #include "VtkAlgorithmPropertyLineEdit.h" -#include "VtkAlgorithmProperties.h" - #include <QDoubleValidator> #include <QIntValidator> #include <utility> +#include "VtkAlgorithmProperties.h" + VtkAlgorithmPropertyLineEdit::VtkAlgorithmPropertyLineEdit( const QString& contents, QString name, @@ -32,18 +32,18 @@ VtkAlgorithmPropertyLineEdit::VtkAlgorithmPropertyLineEdit( _algProps(algProps), _type(type) { - switch(_type) + switch (_type) { - case QVariant::Double: - this->setValidator(new QDoubleValidator(this)); - break; + case QVariant::Double: + this->setValidator(new QDoubleValidator(this)); + break; - case QVariant::Int: - this->setValidator(new QIntValidator(this)); - break; + case QVariant::Int: + this->setValidator(new QIntValidator(this)); + break; - default: - break; + default: + break; } connect(this, SIGNAL(editingFinished()), this, SLOT(setNewValue())); diff --git a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp index 1d58e230607..a14afbe806b 100644 --- a/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAlgorithmPropertyVectorEdit.cpp @@ -15,8 +15,6 @@ // ** INCLUDES ** #include "VtkAlgorithmPropertyVectorEdit.h" -#include "VtkAlgorithmProperties.h" - #include <QDoubleValidator> #include <QHBoxLayout> #include <QIntValidator> @@ -24,6 +22,8 @@ #include <QSize> #include <utility> +#include "VtkAlgorithmProperties.h" + VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit( const QList<QString> contents, QString name, @@ -36,23 +36,23 @@ VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit( layout->setSpacing(3); layout->setContentsMargins(0, 0, 0, 0); - foreach(QString content, contents) + foreach (QString content, contents) { auto* lineEdit = new QLineEdit(content, this); layout->addWidget(lineEdit); - switch(_type) + switch (_type) { - case QVariant::Double: - lineEdit->setValidator(new QDoubleValidator(this)); - break; + case QVariant::Double: + lineEdit->setValidator(new QDoubleValidator(this)); + break; - case QVariant::Int: - lineEdit->setValidator(new QIntValidator(this)); - break; + case QVariant::Int: + lineEdit->setValidator(new QIntValidator(this)); + break; - default: - break; + default: + break; } connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(setNewValue())); diff --git a/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp b/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp index 70d6fad5a61..f223d600066 100644 --- a/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkAppendArrayFilter.cpp @@ -15,8 +15,6 @@ // ** VTK INCLUDES ** #include "VtkAppendArrayFilter.h" -#include "BaseLib/Logging.h" - #include <vtkCellData.h> #include <vtkDoubleArray.h> #include <vtkInformation.h> @@ -27,15 +25,17 @@ #include <vtkStreamingDemandDrivenPipeline.h> #include <vtkUnstructuredGrid.h> +#include "BaseLib/Logging.h" + vtkStandardNewMacro(VtkAppendArrayFilter); VtkAppendArrayFilter::VtkAppendArrayFilter() = default; VtkAppendArrayFilter::~VtkAppendArrayFilter() = default; -void VtkAppendArrayFilter::PrintSelf( ostream& os, vtkIndent indent ) +void VtkAppendArrayFilter::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); os << indent << "== VtkAppendArrayFilter ==" << endl; } @@ -49,10 +49,11 @@ int VtkAppendArrayFilter::RequestData(vtkInformation* /*request*/, return 0; } vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); - vtkUnstructuredGrid* input = - vtkUnstructuredGrid::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkUnstructuredGrid* input = vtkUnstructuredGrid::SafeDownCast( + inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkSmartPointer<vtkDoubleArray> colors = vtkSmartPointer<vtkDoubleArray>::New(); + vtkSmartPointer<vtkDoubleArray> colors = + vtkSmartPointer<vtkDoubleArray>::New(); colors->SetNumberOfComponents(1); std::size_t arrayLength = this->_array.size(); colors->SetNumberOfValues(arrayLength); @@ -60,7 +61,9 @@ int VtkAppendArrayFilter::RequestData(vtkInformation* /*request*/, std::size_t nCells = input->GetNumberOfCells(); if (nCells > arrayLength) - WARN("VtkAppendArrayFilter::RequestData(): Number of cells exceeds selection array length. Surplus cells won't be examined."); + WARN( + "VtkAppendArrayFilter::RequestData(): Number of cells exceeds " + "selection array length. Surplus cells won't be examined."); for (std::size_t i = 0; i < arrayLength; i++) { @@ -68,8 +71,8 @@ int VtkAppendArrayFilter::RequestData(vtkInformation* /*request*/, } vtkInformation* outInfo = outputVector->GetInformationObject(0); - vtkUnstructuredGrid* output = - vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkUnstructuredGrid* output = vtkUnstructuredGrid::SafeDownCast( + outInfo->Get(vtkDataObject::DATA_OBJECT())); output->CopyStructure(input); output->GetPointData()->PassData(input->GetPointData()); output->GetCellData()->PassData(input->GetCellData()); @@ -79,8 +82,8 @@ int VtkAppendArrayFilter::RequestData(vtkInformation* /*request*/, return 1; } -void VtkAppendArrayFilter::SetArray(const std::string &array_name, - const std::vector<double> &new_array) +void VtkAppendArrayFilter::SetArray(const std::string& array_name, + const std::vector<double>& new_array) { this->_array_name = array_name; this->_array = new_array; diff --git a/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp b/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp index 781a45a5545..ec997ed8cbf 100644 --- a/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkBGImageSource.cpp @@ -14,34 +14,37 @@ // ** INCLUDES ** #include "VtkBGImageSource.h" -#include "VtkVisHelper.h" #include <vtkImageAlgorithm.h> -#include <vtkObjectFactory.h> +#include <vtkImageData.h> +#include <vtkImageShiftScale.h> #include <vtkInformation.h> #include <vtkInformationVector.h> +#include <vtkObjectFactory.h> #include <vtkPlaneSource.h> +#include <vtkPointData.h> #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> #include <vtkTexture.h> -#include <vtkImageData.h> -#include <vtkPointData.h> -#include <vtkImageShiftScale.h> + +#include "VtkVisHelper.h" vtkStandardNewMacro(VtkBGImageSource); VtkBGImageSource::VtkBGImageSource() = default; VtkBGImageSource::~VtkBGImageSource() = default; -void VtkBGImageSource::SetRaster(vtkImageAlgorithm *img, double x0, double y0, double scalingFactor) +void VtkBGImageSource::SetRaster(vtkImageAlgorithm* img, double x0, double y0, + double scalingFactor) { double range[2]; img->Update(); img->GetOutput()->GetPointData()->GetScalars()->GetRange(range); - vtkSmartPointer<vtkImageShiftScale> scale = vtkSmartPointer<vtkImageShiftScale>::New(); + vtkSmartPointer<vtkImageShiftScale> scale = + vtkSmartPointer<vtkImageShiftScale>::New(); scale->SetInputConnection(img->GetOutputPort()); scale->SetShift(-range[0]); - scale->SetScale(255.0/(range[1]-range[0])); + scale->SetScale(255.0 / (range[1] - range[0])); scale->SetOutputScalarTypeToUnsignedChar(); scale->Update(); @@ -55,20 +58,21 @@ void VtkBGImageSource::SetRaster(vtkImageAlgorithm *img, double x0, double y0, d texture->SetInputData(imageData); this->SetTexture(texture); - _origin = std::pair<float, float>(static_cast<float>(x0), static_cast<float>(y0)); + _origin = + std::pair<float, float>(static_cast<float>(x0), static_cast<float>(y0)); _cellsize = scalingFactor; - - vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New(); - plane->SetOrigin( _origin.first, _origin.second, -1 ); - plane->SetPoint1( _origin.first + dims[0] * _cellsize, _origin.second, -1 ); - plane->SetPoint2( _origin.first,_origin.second + dims[1] * _cellsize, -1 ); + vtkSmartPointer<vtkPlaneSource> plane = + vtkSmartPointer<vtkPlaneSource>::New(); + plane->SetOrigin(_origin.first, _origin.second, -1); + plane->SetPoint1(_origin.first + dims[0] * _cellsize, _origin.second, -1); + plane->SetPoint2(_origin.first, _origin.second + dims[1] * _cellsize, -1); this->SetInputConnection(0, plane->GetOutputPort(0)); this->SetTexture(texture); } -void VtkBGImageSource::SetUserProperty( QString name, QVariant value ) +void VtkBGImageSource::SetUserProperty(QString name, QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); } diff --git a/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp b/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp index 02f6381abe2..954b4e7518b 100644 --- a/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkColorByHeightFilter.cpp @@ -15,10 +15,6 @@ // ** VTK INCLUDES ** #include "VtkColorByHeightFilter.h" -#include "BaseLib/Logging.h" - -#include "VtkColorLookupTable.h" - #include <vtkCellData.h> #include <vtkDoubleArray.h> #include <vtkInformation.h> @@ -30,6 +26,9 @@ #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> +#include "BaseLib/Logging.h" +#include "VtkColorLookupTable.h" + vtkStandardNewMacro(VtkColorByHeightFilter); VtkColorByHeightFilter::VtkColorByHeightFilter() @@ -39,15 +38,16 @@ VtkColorByHeightFilter::VtkColorByHeightFilter() VtkColorByHeightFilter::~VtkColorByHeightFilter() = default; -void VtkColorByHeightFilter::PrintSelf( ostream& os, vtkIndent indent ) +void VtkColorByHeightFilter::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); double range[2]; ColorLookupTable->GetTableRange(range); os << indent << "== VtkColorByHeightFilter ==" << endl; os << indent << "Range: " << range[0] << "-" << range[1] << endl; - os << indent << "Interpolation Type:" << static_cast<int>(ColorLookupTable->getInterpolationType()) << endl; + os << indent << "Interpolation Type:" + << static_cast<int>(ColorLookupTable->getInterpolationType()) << endl; } vtkMTimeType VtkColorByHeightFilter::GetMTime() @@ -65,9 +65,11 @@ int VtkColorByHeightFilter::RequestData(vtkInformation* /*request*/, vtkInformationVector* outputVector) { vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); - vtkPolyData* input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* input = + vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkSmartPointer<vtkDoubleArray> colors = vtkSmartPointer<vtkDoubleArray>::New(); + vtkSmartPointer<vtkDoubleArray> colors = + vtkSmartPointer<vtkDoubleArray>::New(); colors->SetNumberOfComponents(1); std::size_t nPoints = input->GetNumberOfPoints(); colors->SetNumberOfValues(nPoints); @@ -77,12 +79,13 @@ int VtkColorByHeightFilter::RequestData(vtkInformation* /*request*/, for (std::size_t i = 0; i < nPoints; i++) { double p[3]; - input->GetPoint(i,p); + input->GetPoint(i, p); colors->SetValue(i, p[2]); } vtkInformation* outInfo = outputVector->GetInformationObject(0); - vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* output = + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); output->CopyStructure(input); output->GetPointData()->PassData(input->GetPointData()); output->GetCellData()->PassData(input->GetCellData()); @@ -110,6 +113,6 @@ void VtkColorByHeightFilter::SetTableRange(double min, double max) void VtkColorByHeightFilter::SetTableRangeScaling(double scale) { this->_tableRangeScaling = scale; - this->ColorLookupTable->SetTableRange( - this->_tableRange[0] * scale, this->_tableRange[1] * scale); + this->ColorLookupTable->SetTableRange(this->_tableRange[0] * scale, + this->_tableRange[1] * scale); } diff --git a/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp b/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp index e6d91251af1..c8f325cff93 100644 --- a/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp +++ b/Applications/DataExplorer/VtkVis/VtkColorLookupTable.cpp @@ -14,14 +14,13 @@ #include "VtkColorLookupTable.h" +#include <vtkObjectFactory.h> + #include <cmath> #include <sstream> -#include "BaseLib/Logging.h" - -#include <vtkObjectFactory.h> - #include "Applications/DataHolderLib/Color.h" +#include "BaseLib/Logging.h" vtkStandardNewMacro(VtkColorLookupTable); @@ -35,7 +34,8 @@ VtkColorLookupTable::~VtkColorLookupTable() } } -unsigned char VtkColorLookupTable::linInterpolation(unsigned char a, unsigned char b, +unsigned char VtkColorLookupTable::linInterpolation(unsigned char a, + unsigned char b, double p) const { return static_cast<unsigned char>(a * (1 - p) + b * p); @@ -46,21 +46,22 @@ unsigned char VtkColorLookupTable::expInterpolation(unsigned char a, double gamma, double p) const { - assert (gamma > 0 && gamma < 4); - return static_cast<unsigned char>((b - a) * pow(p,gamma) + a); + assert(gamma > 0 && gamma < 4); + return static_cast<unsigned char>((b - a) * pow(p, gamma) + a); } void VtkColorLookupTable::Build() { double range[2]; this->GetTableRange(range); - const double interval = range[1]-range[0]; - this->SetNumberOfTableValues(static_cast<vtkIdType>(ceil(interval))+1); -// const vtkIdType nColours = this->GetNumberOfTableValues(); + const double interval = range[1] - range[0]; + this->SetNumberOfTableValues(static_cast<vtkIdType>(ceil(interval)) + 1); + // const vtkIdType nColours = this->GetNumberOfTableValues(); if (!_dict.empty()) { - // make sure that color map starts with the first color in the dictionary - unsigned char startcolor[4] = { 0, 0 , 0 , 0 }; + // make sure that color map starts with the first color in the + // dictionary + unsigned char startcolor[4] = {0, 0, 0, 0}; std::pair<std::size_t, unsigned char*> lastValue(0, startcolor); for (auto& it : _dict) @@ -121,31 +122,33 @@ void VtkColorLookupTable::Build() } } -void VtkColorLookupTable::setLookupTable(DataHolderLib::ColorLookupTable const& lut) +void VtkColorLookupTable::setLookupTable( + DataHolderLib::ColorLookupTable const& lut) { - std::size_t const n_colors (lut.size()); + std::size_t const n_colors(lut.size()); for (std::size_t i = 0; i < n_colors; ++i) { setColor(std::get<0>(lut[i]), std::get<1>(lut[i])); } setInterpolationType(lut.getInterpolationType()); - auto const range (lut.getTableRange()); + auto const range(lut.getTableRange()); SetTableRange(range.first, range.second); Build(); } -void VtkColorLookupTable::writeToFile(const std::string &filename) +void VtkColorLookupTable::writeToFile(const std::string& filename) { std::stringstream strout; strout << "Writing color table to " << filename << " ... "; - std::ofstream out( filename.c_str(), std::ios::out ); + std::ofstream out(filename.c_str(), std::ios::out); std::size_t nColors = this->GetNumberOfTableValues(); for (std::size_t i = 0; i < nColors; i++) { unsigned char rgba[4]; this->GetTableValue(i, rgba); - out << i << "\t" << rgba[0] << "\t" << rgba[1] << "\t" << rgba[2] << "\n"; + out << i << "\t" << rgba[0] << "\t" << rgba[1] << "\t" << rgba[2] + << "\n"; } strout << " done." << std::endl; @@ -153,7 +156,8 @@ void VtkColorLookupTable::writeToFile(const std::string &filename) out.close(); } -void VtkColorLookupTable::SetTableValueRGBA(vtkIdType idx, unsigned char rgba[4]) +void VtkColorLookupTable::SetTableValueRGBA(vtkIdType idx, + unsigned char rgba[4]) { double value[4]; @@ -175,25 +179,27 @@ void VtkColorLookupTable::GetTableValue(vtkIdType idx, unsigned char rgba[4]) } } -void VtkColorLookupTable::setColor(double pos, DataHolderLib::Color const& color) +void VtkColorLookupTable::setColor(double pos, + DataHolderLib::Color const& color) { auto* dict_rgba = new unsigned char[4]; for (std::size_t i = 0; i < 4; i++) { dict_rgba[i] = color[i]; } - _dict.insert( std::pair<double, unsigned char*>(pos, dict_rgba) ); + _dict.insert(std::pair<double, unsigned char*>(pos, dict_rgba)); } void VtkColorLookupTable::getColor(vtkIdType indx, unsigned char rgba[4]) const { - indx = - ((indx < this->TableRange[0]) + indx = ((indx < this->TableRange[0]) ? static_cast<vtkIdType>(this->TableRange[0]) - : (indx >=this->TableRange[1] ? static_cast<vtkIdType>(this->TableRange[1]) - 1 : indx)); - indx = - static_cast<std::size_t>( std::floor( (indx - this->TableRange[0]) * - (this->NumberOfColors / (this->TableRange[1] - this->TableRange[0])) ) ); + : (indx >= this->TableRange[1] + ? static_cast<vtkIdType>(this->TableRange[1]) - 1 + : indx)); + indx = static_cast<std::size_t>(std::floor( + (indx - this->TableRange[0]) * + (this->NumberOfColors / (this->TableRange[1] - this->TableRange[0])))); unsigned char* _rgba; _rgba = this->Table->GetPointer(indx * 4); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.cpp index a54409efd0d..c238e906236 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeColorByHeightFilter.cpp @@ -13,15 +13,17 @@ */ // ** INCLUDES ** -#include "VtkColorByHeightFilter.h" -#include "VtkColorLookupTable.h" #include "VtkCompositeColorByHeightFilter.h" #include <vtkDataSetSurfaceFilter.h> #include <vtkSmartPointer.h> #include <vtkUnstructuredGrid.h> -VtkCompositeColorByHeightFilter::VtkCompositeColorByHeightFilter( vtkAlgorithm* inputAlgorithm ) +#include "VtkColorByHeightFilter.h" +#include "VtkColorLookupTable.h" + +VtkCompositeColorByHeightFilter::VtkCompositeColorByHeightFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { this->init(); @@ -35,7 +37,8 @@ void VtkCompositeColorByHeightFilter::init() vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter; VtkColorByHeightFilter* heightFilter = VtkColorByHeightFilter::New(); - if (dynamic_cast<vtkUnstructuredGrid*>(_inputAlgorithm->GetOutputDataObject(0))) + if (dynamic_cast<vtkUnstructuredGrid*>( + _inputAlgorithm->GetOutputDataObject(0))) { surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); surfaceFilter->SetInputConnection(_inputAlgorithm->GetOutputPort()); @@ -46,18 +49,19 @@ void VtkCompositeColorByHeightFilter::init() heightFilter->SetInputConnection(_inputAlgorithm->GetOutputPort()); } - DataHolderLib::Color a{{0, 0, 255, 255}}; // blue - DataHolderLib::Color b{{0, 255, 0, 255}}; // green - DataHolderLib::Color c{{255, 255, 0, 255}}; // yellow - DataHolderLib::Color d{{155, 100, 50, 255}}; // brown - DataHolderLib::Color e{{255, 0, 0, 255}}; // red + DataHolderLib::Color a{{0, 0, 255, 255}}; // blue + DataHolderLib::Color b{{0, 255, 0, 255}}; // green + DataHolderLib::Color c{{255, 255, 0, 255}}; // yellow + DataHolderLib::Color d{{155, 100, 50, 255}}; // brown + DataHolderLib::Color e{{255, 0, 0, 255}}; // red VtkColorLookupTable* ColorLookupTable = heightFilter->GetColorLookupTable(); ColorLookupTable->setInterpolationType(DataHolderLib::LUTType::LINEAR); ColorLookupTable->setColor(-50, a); ColorLookupTable->setColor(0, a); - ColorLookupTable->setColor(1, b); // instant change at 0m a.s.l. - ColorLookupTable->setColor(200, b); // green at about 200m a.s.l. - ColorLookupTable->setColor(500, c); // yellow at about 500m and changing to red from then on + ColorLookupTable->setColor(1, b); // instant change at 0m a.s.l. + ColorLookupTable->setColor(200, b); // green at about 200m a.s.l. + ColorLookupTable->setColor( + 500, c); // yellow at about 500m and changing to red from then on ColorLookupTable->setColor(1000, d); ColorLookupTable->setColor(2000, e); ColorLookupTable->SetTableRange(-35, 2000); @@ -71,7 +75,8 @@ void VtkCompositeColorByHeightFilter::init() _activeAttributeName = heightFilter->GetActiveAttribute(); } -void VtkCompositeColorByHeightFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeColorByHeightFilter::SetUserProperty(QString name, + QVariant value) { Q_UNUSED(name); Q_UNUSED(value); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp index c87ad34279c..1298484a206 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeColormapToImageFilter.cpp @@ -15,19 +15,20 @@ // ** INCLUDES ** #include "VtkCompositeColormapToImageFilter.h" -#include <vtkImageMapToColors.h> #include <vtkImageData.h> +#include <vtkImageMapToColors.h> #include <vtkLookupTable.h> #include <vtkPointData.h> #include <vtkSmartPointer.h> -#include <QSettings> #include <QFileDialog> +#include <QSettings> #include "VtkColorLookupTable.h" #include "XmlIO/Qt/XmlLutReader.h" -VtkCompositeColormapToImageFilter::VtkCompositeColormapToImageFilter( vtkAlgorithm* inputAlgorithm ) +VtkCompositeColormapToImageFilter::VtkCompositeColormapToImageFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { this->init(); @@ -41,15 +42,21 @@ void VtkCompositeColormapToImageFilter::init() this->_inputDataObjectType = VTK_IMAGE_DATA; this->_outputDataObjectType = VTK_IMAGE_DATA; - vtkSmartPointer<VtkColorLookupTable> colormap = vtkSmartPointer<VtkColorLookupTable>::New(); + vtkSmartPointer<VtkColorLookupTable> colormap = + vtkSmartPointer<VtkColorLookupTable>::New(); QWidget* parent = nullptr; QSettings settings; - QString fileName = QFileDialog::getOpenFileName(parent, "Select color lookup table", - settings.value("lastOpenedLookupTableFileDirectory").toString(), - "Lookup table XML files (*.xml);;"); + QString fileName = QFileDialog::getOpenFileName( + parent, "Select color lookup table", + settings.value("lastOpenedLookupTableFileDirectory").toString(), + "Lookup table XML files (*.xml);;"); double range[2]; - dynamic_cast<vtkImageAlgorithm*>(_inputAlgorithm)->GetOutput()->GetPointData()->GetScalars()->GetRange(range); + dynamic_cast<vtkImageAlgorithm*>(_inputAlgorithm) + ->GetOutput() + ->GetPointData() + ->GetScalars() + ->GetRange(range); DataHolderLib::ColorLookupTable lut; if (FileIO::XmlLutReader::readFromFile(fileName, lut)) @@ -85,7 +92,8 @@ void VtkCompositeColormapToImageFilter::init() _outputAlgorithm = map; } -void VtkCompositeColormapToImageFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeColormapToImageFilter::SetUserProperty(QString name, + QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); @@ -101,15 +109,16 @@ void VtkCompositeColormapToImageFilter::SetUserProperty( QString name, QVariant } } -void VtkCompositeColormapToImageFilter::SetUserVectorProperty( QString name, QList<QVariant> values ) +void VtkCompositeColormapToImageFilter::SetUserVectorProperty( + QString name, QList<QVariant> values) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); auto* map = static_cast<vtkImageMapToColors*>(_outputAlgorithm); if (name.compare("TableRange") == 0) { - static_cast<vtkLookupTable*>(map->GetLookupTable())->SetTableRange( - values[0].toInt(), values[1].toInt()); + static_cast<vtkLookupTable*>(map->GetLookupTable()) + ->SetTableRange(values[0].toInt(), values[1].toInt()); } else if (name.compare("HueRange") == 0) { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp index 8d99aa11dd0..bdff7ff68e1 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeContourFilter.cpp @@ -15,14 +15,15 @@ // ** INCLUDES ** #include "VtkCompositeContourFilter.h" -#include <vtkPointData.h> #include <vtkContourFilter.h> +#include <vtkPointData.h> #include <vtkSmartPointer.h> #include <vtkUnstructuredGrid.h> #include <limits> -VtkCompositeContourFilter::VtkCompositeContourFilter( vtkAlgorithm* inputAlgorithm ) +VtkCompositeContourFilter::VtkCompositeContourFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { this->init(); @@ -33,18 +34,19 @@ VtkCompositeContourFilter::~VtkCompositeContourFilter() = default; void VtkCompositeContourFilter::init() { // Set meta information about input and output data types - this->_inputDataObjectType = VTK_UNSTRUCTURED_GRID; //VTK_DATA_SET; + this->_inputDataObjectType = VTK_UNSTRUCTURED_GRID; // VTK_DATA_SET; this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID; // Because this is the only filter here we cannot use vtkSmartPointer vtkContourFilter* contour = vtkContourFilter::New(); contour->SetInputConnection(_inputAlgorithm->GetOutputPort()); - // Getting the scalar range from the active point data scalar of the input algorithm - // This assumes that we do not want to contour on cell data. + // Getting the scalar range from the active point data scalar of the input + // algorithm This assumes that we do not want to contour on cell data. double range[2]; - vtkDataSet* dataSet = vtkDataSet::SafeDownCast(_inputAlgorithm->GetOutputDataObject(0)); - if(dataSet) + vtkDataSet* dataSet = + vtkDataSet::SafeDownCast(_inputAlgorithm->GetOutputDataObject(0)); + if (dataSet) { vtkPointData* pointData = dataSet->GetPointData(); if (pointData) @@ -54,8 +56,8 @@ void VtkCompositeContourFilter::init() } else { - // Setting the range to min / max values, this will result in a "bad table range" - // vtk warning. + // Setting the range to min / max values, this will result in a "bad + // table range" vtk warning. range[0] = std::numeric_limits<double>::lowest(); range[1] = std::numeric_limits<double>::max(); } @@ -78,7 +80,7 @@ void VtkCompositeContourFilter::init() _outputAlgorithm = contour; } -void VtkCompositeContourFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeContourFilter::SetUserProperty(QString name, QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); @@ -90,7 +92,8 @@ void VtkCompositeContourFilter::SetUserProperty( QString name, QVariant value ) } } -void VtkCompositeContourFilter::SetUserVectorProperty( QString name, QList<QVariant> values ) +void VtkCompositeContourFilter::SetUserVectorProperty( + QString name, QList<QVariant> values) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp index bb1ac6d1e2a..179fbe8f737 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeElementSelectionFilter.cpp @@ -14,23 +14,25 @@ // ** INCLUDES ** #include "VtkCompositeElementSelectionFilter.h" -#include "VtkAppendArrayFilter.h" -#include "VtkCompositePointToGlyphFilter.h" -#include "VtkColorLookupTable.h" -#include "VtkPointsSource.h" #include <vtkDataSetSurfaceFilter.h> +#include <vtkIdFilter.h> +#include <vtkPointData.h> #include <vtkSmartPointer.h> #include <vtkThreshold.h> -#include <vtkIdFilter.h> #include <vtkUnstructuredGrid.h> - #include <vtkUnstructuredGridAlgorithm.h> -#include <vtkPointData.h> +#include "VtkAppendArrayFilter.h" +#include "VtkColorLookupTable.h" +#include "VtkCompositePointToGlyphFilter.h" +#include "VtkPointsSource.h" -VtkCompositeElementSelectionFilter::VtkCompositeElementSelectionFilter( vtkAlgorithm* inputAlgorithm ) -: VtkCompositeFilter(inputAlgorithm), _range(0.0, 1.0), _selection_name("Selection") +VtkCompositeElementSelectionFilter::VtkCompositeElementSelectionFilter( + vtkAlgorithm* inputAlgorithm) + : VtkCompositeFilter(inputAlgorithm), + _range(0.0, 1.0), + _selection_name("Selection") { } @@ -41,7 +43,8 @@ void VtkCompositeElementSelectionFilter::init() this->_inputDataObjectType = VTK_UNSTRUCTURED_GRID; this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID; - this->SetLookUpTable(QString::fromStdString(_selection_name), this->GetLookupTable()); + this->SetLookUpTable(QString::fromStdString(_selection_name), + this->GetLookupTable()); vtkSmartPointer<VtkAppendArrayFilter> selFilter(nullptr); if (!_selection.empty()) { @@ -61,17 +64,19 @@ void VtkCompositeElementSelectionFilter::init() { idFilter->SetInputConnection(selFilter->GetOutputPort()); } - idFilter->PointIdsOn(); - idFilter->CellIdsOn(); - idFilter->FieldDataOn(); - idFilter->Update(); + idFilter->PointIdsOn(); + idFilter->CellIdsOn(); + idFilter->FieldDataOn(); + idFilter->Update(); vtkThreshold* threshold = vtkThreshold::New(); - threshold->SetInputConnection(idFilter->GetOutputPort()); - threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS, _selection_name.c_str()); - threshold->SetSelectedComponent(0); - threshold->ThresholdBetween(thresholdLower, thresholdUpper); - threshold->Update(); + threshold->SetInputConnection(idFilter->GetOutputPort()); + threshold->SetInputArrayToProcess(0, 0, 0, + vtkDataObject::FIELD_ASSOCIATION_CELLS, + _selection_name.c_str()); + threshold->SetSelectedComponent(0); + threshold->ThresholdBetween(thresholdLower, thresholdUpper); + threshold->Update(); QList<QVariant> thresholdRangeList; thresholdRangeList.push_back(thresholdLower); @@ -80,14 +85,16 @@ void VtkCompositeElementSelectionFilter::init() _outputAlgorithm = threshold; } -void VtkCompositeElementSelectionFilter::setSelectionArray(const std::string &selection_name, const std::vector<double> &selection) +void VtkCompositeElementSelectionFilter::setSelectionArray( + const std::string& selection_name, const std::vector<double>& selection) { _selection_name = selection_name; _selection = selection; init(); } -void VtkCompositeElementSelectionFilter::SetUserVectorProperty( QString name, QList<QVariant> values) +void VtkCompositeElementSelectionFilter::SetUserVectorProperty( + QString name, QList<QVariant> values) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); @@ -101,9 +108,9 @@ void VtkCompositeElementSelectionFilter::SetUserVectorProperty( QString name, QL VtkColorLookupTable* VtkCompositeElementSelectionFilter::GetLookupTable() { VtkColorLookupTable* lut = VtkColorLookupTable::New(); - lut->SetTableRange(0,1); - DataHolderLib::Color a{{0, 0, 255, 255}}; // blue - DataHolderLib::Color b{{0, 255, 0, 255}}; // green + lut->SetTableRange(0, 1); + DataHolderLib::Color a{{0, 0, 255, 255}}; // blue + DataHolderLib::Color b{{0, 255, 0, 255}}; // green DataHolderLib::Color c{{255, 255, 0, 255}}; // yellow DataHolderLib::Color d{{255, 0, 0, 255}}; // red lut->setColor(1.0, a); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeFilter.cpp index 1413e4596a7..ce45808da5d 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeFilter.cpp @@ -23,8 +23,10 @@ #include <QVector> VtkCompositeFilter::VtkCompositeFilter(vtkAlgorithm* inputAlgorithm) - : _inputDataObjectType(0), _outputDataObjectType(1), - _inputAlgorithm(inputAlgorithm), _outputAlgorithm(nullptr) + : _inputDataObjectType(0), + _outputDataObjectType(1), + _inputAlgorithm(inputAlgorithm), + _outputAlgorithm(nullptr) { } @@ -36,14 +38,15 @@ VtkCompositeFilter::~VtkCompositeFilter() double VtkCompositeFilter::GetInitialRadius() const { double bounding_box[6]; - static_cast<vtkPolyData*>(this->_inputAlgorithm->GetOutputDataObject(0))->GetBounds(bounding_box); - double x_diff = fabs(bounding_box[0]-bounding_box[1]); - double y_diff = fabs(bounding_box[2]-bounding_box[3]); - double z_diff = fabs(bounding_box[4]-bounding_box[5]); + static_cast<vtkPolyData*>(this->_inputAlgorithm->GetOutputDataObject(0)) + ->GetBounds(bounding_box); + double x_diff = fabs(bounding_box[0] - bounding_box[1]); + double y_diff = fabs(bounding_box[2] - bounding_box[3]); + double z_diff = fabs(bounding_box[4] - bounding_box[5]); double max = (x_diff == 0) ? 1 : x_diff; max = (max > y_diff) ? max : y_diff; max = (max > z_diff) ? max : z_diff; - return max/200.0; + return max / 200.0; } diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp index 45daa1176fc..aa33bacd69f 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeGeoObjectFilter.cpp @@ -15,47 +15,51 @@ // ** INCLUDES ** #include "VtkCompositeGeoObjectFilter.h" +#include <vtkAlgorithmOutput.h> #include <vtkDataSetSurfaceFilter.h> +#include <vtkPointData.h> #include <vtkSmartPointer.h> #include <vtkThreshold.h> -#include <vtkAlgorithmOutput.h> +#include "VtkCompositeLineToTubeFilter.h" +#include "VtkCompositePointToGlyphFilter.h" #include "VtkPolylinesSource.h" -#include "VtkSurfacesSource.h" #include "VtkStationSource.h" -#include "VtkCompositePointToGlyphFilter.h" -#include "VtkCompositeLineToTubeFilter.h" - -#include <vtkPointData.h> +#include "VtkSurfacesSource.h" -VtkCompositeGeoObjectFilter::VtkCompositeGeoObjectFilter( vtkAlgorithm* inputAlgorithm ) - : VtkCompositeFilter(inputAlgorithm), _type(GeoLib::GEOTYPE::POINT), _threshold(vtkThreshold::New()) +VtkCompositeGeoObjectFilter::VtkCompositeGeoObjectFilter( + vtkAlgorithm* inputAlgorithm) + : VtkCompositeFilter(inputAlgorithm), + _type(GeoLib::GEOTYPE::POINT), + _threshold(vtkThreshold::New()) { - if (inputAlgorithm->GetNumberOfInputPorts() && inputAlgorithm->GetNumberOfInputConnections(0)) + if (inputAlgorithm->GetNumberOfInputPorts() && + inputAlgorithm->GetNumberOfInputConnections(0)) { - vtkAlgorithmOutput* ao = inputAlgorithm->GetInputConnection(0,0); - - if (ao) - { - vtkAlgorithm* parentAlg = ao->GetProducer(); + vtkAlgorithmOutput* ao = inputAlgorithm->GetInputConnection(0, 0); - if (dynamic_cast<VtkPolylinesSource*>(parentAlg) != nullptr) + if (ao) { - _type = GeoLib::GEOTYPE::POLYLINE; - } - else if (dynamic_cast<VtkSurfacesSource*>(parentAlg) != nullptr) - { - _type = GeoLib::GEOTYPE::SURFACE; - } - else if (dynamic_cast<VtkStationSource*>(parentAlg) != nullptr) - { - /* TODO - if (dynamic_cast<VtkStationSource*>(parentAlg)->getType() == GeoLib::Station::StationType::BOREHOLE) + vtkAlgorithm* parentAlg = ao->GetProducer(); + + if (dynamic_cast<VtkPolylinesSource*>(parentAlg) != nullptr) + { _type = GeoLib::GEOTYPE::POLYLINE; - */ + } + else if (dynamic_cast<VtkSurfacesSource*>(parentAlg) != nullptr) + { + _type = GeoLib::GEOTYPE::SURFACE; + } + else if (dynamic_cast<VtkStationSource*>(parentAlg) != nullptr) + { + /* TODO + if (dynamic_cast<VtkStationSource*>(parentAlg)->getType() == + GeoLib::Station::StationType::BOREHOLE) _type = + GeoLib::GEOTYPE::POLYLINE; + */ + } } - } - this->init(); + this->init(); } } @@ -68,7 +72,7 @@ void VtkCompositeGeoObjectFilter::init() _threshold->SetInputConnection(_inputAlgorithm->GetOutputPort()); _threshold->SetSelectedComponent(0); - _threshold->ThresholdBetween(0,0); + _threshold->ThresholdBetween(0, 0); vtkDataSetSurfaceFilter* surface = vtkDataSetSurfaceFilter::New(); surface->SetInputConnection(_threshold->GetOutputPort()); @@ -97,5 +101,3 @@ void VtkCompositeGeoObjectFilter::SetIndex(std::size_t idx) double const d_idx = static_cast<double>(idx); _threshold->ThresholdBetween(d_idx, d_idx); } - - diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.cpp index 2773d81dc47..750c6c93fd3 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeImageToCylindersFilter.cpp @@ -15,8 +15,6 @@ // ** INCLUDES ** #include "VtkCompositeImageToCylindersFilter.h" -#include "VtkImageDataToLinePolyDataFilter.h" - #include <vtkLookupTable.h> #include <vtkPointData.h> #include <vtkSmartPointer.h> @@ -28,8 +26,10 @@ #include <QVariant> #include <QVector> +#include "VtkImageDataToLinePolyDataFilter.h" + VtkCompositeImageToCylindersFilter::VtkCompositeImageToCylindersFilter( - vtkAlgorithm* inputAlgorithm ) + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm), _lineFilter(nullptr) { this->init(); @@ -48,7 +48,10 @@ void VtkCompositeImageToCylindersFilter::init() double range[2]; // The data is always on points - vtkDataSet::SafeDownCast(_lineFilter->GetOutputDataObject(0))->GetPointData()->GetScalars()->GetRange(range); + vtkDataSet::SafeDownCast(_lineFilter->GetOutputDataObject(0)) + ->GetPointData() + ->GetScalars() + ->GetRange(range); vtkLookupTable* colormap = vtkLookupTable::New(); colormap->SetTableRange(range[0], range[1]); @@ -79,7 +82,8 @@ void VtkCompositeImageToCylindersFilter::init() _outputAlgorithm = tubeFilter; } -void VtkCompositeImageToCylindersFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeImageToCylindersFilter::SetUserProperty(QString name, + QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); @@ -97,11 +101,13 @@ void VtkCompositeImageToCylindersFilter::SetUserProperty( QString name, QVariant } else if (name.compare("NumberOfSides") == 0) { - static_cast<vtkTubeFilter*>(_outputAlgorithm)->SetNumberOfSides(value.toInt()); + static_cast<vtkTubeFilter*>(_outputAlgorithm) + ->SetNumberOfSides(value.toInt()); } else if (name.compare("Capping") == 0) { - static_cast<vtkTubeFilter*>(_outputAlgorithm)->SetCapping(value.toBool()); + static_cast<vtkTubeFilter*>(_outputAlgorithm) + ->SetCapping(value.toBool()); } else if (name.compare("RadiusFactor") == 0) { @@ -110,8 +116,8 @@ void VtkCompositeImageToCylindersFilter::SetUserProperty( QString name, QVariant } } -void VtkCompositeImageToCylindersFilter::SetUserVectorProperty( QString name, - QList<QVariant> values ) +void VtkCompositeImageToCylindersFilter::SetUserVectorProperty( + QString name, QList<QVariant> values) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeImageToPointCloudFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeImageToPointCloudFilter.cpp index 1ced539342d..2b8904f03ac 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeImageToPointCloudFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeImageToPointCloudFilter.cpp @@ -18,7 +18,8 @@ #include "VtkImageDataToPointCloudFilter.h" -VtkCompositeImageToPointCloudFilter::VtkCompositeImageToPointCloudFilter(vtkAlgorithm* inputAlgorithm) +VtkCompositeImageToPointCloudFilter::VtkCompositeImageToPointCloudFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { init(); @@ -35,34 +36,41 @@ void VtkCompositeImageToPointCloudFilter::init() _inputAlgorithm->Update(); QList<QVariant> n_points_range_list; - n_points_range_list.push_back(point_cloud_filter->GetMinNumberOfPointsPerCell()); - n_points_range_list.push_back(point_cloud_filter->GetMaxNumberOfPointsPerCell()); - (*_algorithmUserVectorProperties)["Number of points range"] = n_points_range_list; + n_points_range_list.push_back( + point_cloud_filter->GetMinNumberOfPointsPerCell()); + n_points_range_list.push_back( + point_cloud_filter->GetMaxNumberOfPointsPerCell()); + (*_algorithmUserVectorProperties)["Number of points range"] = + n_points_range_list; QList<QVariant> vertical_extent_list; vertical_extent_list.push_back(point_cloud_filter->GetMinHeight()); vertical_extent_list.push_back(point_cloud_filter->GetMaxHeight()); (*_algorithmUserVectorProperties)["Vertical extent"] = vertical_extent_list; - (*_algorithmUserProperties)["Logarithmic interpolation"] = !point_cloud_filter->GetIsLinear(); + (*_algorithmUserProperties)["Logarithmic interpolation"] = + !point_cloud_filter->GetIsLinear(); (*_algorithmUserProperties)["Gamma value"] = point_cloud_filter->GetGamma(); point_cloud_filter->Update(); _outputAlgorithm = point_cloud_filter; } -void VtkCompositeImageToPointCloudFilter::SetUserProperty(QString name, QVariant value) +void VtkCompositeImageToPointCloudFilter::SetUserProperty(QString name, + QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); if ((name == "Gamma value") && (value.toDouble() > 0)) { - static_cast<VtkImageDataToPointCloudFilter*>(_outputAlgorithm)->SetGamma(value.toDouble()); + static_cast<VtkImageDataToPointCloudFilter*>(_outputAlgorithm) + ->SetGamma(value.toDouble()); } if (name == "Logarithmic interpolation") { if (value.toBool()) { double const gamma = - VtkAlgorithmProperties::GetUserProperty("Gamma value").toDouble(); + VtkAlgorithmProperties::GetUserProperty("Gamma value") + .toDouble(); if (gamma > 0) { static_cast<VtkImageDataToPointCloudFilter*>(_outputAlgorithm) @@ -77,7 +85,8 @@ void VtkCompositeImageToPointCloudFilter::SetUserProperty(QString name, QVariant } } -void VtkCompositeImageToPointCloudFilter::SetUserVectorProperty(QString name, QList<QVariant> values) +void VtkCompositeImageToPointCloudFilter::SetUserVectorProperty( + QString name, QList<QVariant> values) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeImageToSurfacePointsFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeImageToSurfacePointsFilter.cpp index b8f35aa650c..f113c23d120 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeImageToSurfacePointsFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeImageToSurfacePointsFilter.cpp @@ -41,7 +41,8 @@ void VtkCompositeImageToSurfacePointsFilter::init() _outputAlgorithm = point_cloud_filter; } -void VtkCompositeImageToSurfacePointsFilter::SetUserProperty(QString name, QVariant value) +void VtkCompositeImageToSurfacePointsFilter::SetUserProperty(QString name, + QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); if ((name == "Points per pixel") && (value.toInt() > 0)) diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp index 77119f61d20..01c28553718 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeLineToTubeFilter.cpp @@ -19,7 +19,8 @@ #include <vtkSmartPointer.h> #include <vtkTubeFilter.h> -VtkCompositeLineToTubeFilter::VtkCompositeLineToTubeFilter( vtkAlgorithm* inputAlgorithm ) +VtkCompositeLineToTubeFilter::VtkCompositeLineToTubeFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { this->init(); @@ -33,7 +34,8 @@ void VtkCompositeLineToTubeFilter::init() this->_outputDataObjectType = VTK_POLY_DATA; // collapse coincident points - vtkSmartPointer<vtkCleanPolyData> mergePoints = vtkSmartPointer<vtkCleanPolyData>::New(); + vtkSmartPointer<vtkCleanPolyData> mergePoints = + vtkSmartPointer<vtkCleanPolyData>::New(); mergePoints->SetInputConnection(0, _inputAlgorithm->GetOutputPort(0)); mergePoints->SetTolerance(0.0); mergePoints->ConvertLinesToPointsOn(); @@ -43,10 +45,12 @@ void VtkCompositeLineToTubeFilter::init() vtkTubeFilter* tubes = vtkTubeFilter::New(); tubes->SetInputConnection(0, mergePoints->GetOutputPort(0)); - //tubes->SetInputArrayToProcess(1,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS,"StationValue"); - //tubes->SetVaryRadiusToVaryRadiusByScalar(); // KR radius changes with scalar + // tubes->SetInputArrayToProcess(1,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS,"StationValue"); + // tubes->SetVaryRadiusToVaryRadiusByScalar(); // KR radius changes with + // scalar - tubes->SetInputArrayToProcess(1,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS,"Stratigraphies"); + tubes->SetInputArrayToProcess( + 1, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "Stratigraphies"); tubes->SetRadius(default_radius); tubes->SetNumberOfSides(default_number_of_sides); tubes->SetCapping(1); @@ -58,17 +62,19 @@ void VtkCompositeLineToTubeFilter::init() _outputAlgorithm = tubes; } -void VtkCompositeLineToTubeFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeLineToTubeFilter::SetUserProperty(QString name, QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); if (name.compare("Radius") == 0) { - static_cast<vtkTubeFilter*>(_outputAlgorithm)->SetRadius(value.toDouble()); + static_cast<vtkTubeFilter*>(_outputAlgorithm) + ->SetRadius(value.toDouble()); } else if (name.compare("NumberOfSides") == 0) { - static_cast<vtkTubeFilter*>(_outputAlgorithm)->SetNumberOfSides(value.toInt()); + static_cast<vtkTubeFilter*>(_outputAlgorithm) + ->SetNumberOfSides(value.toInt()); } else if (name.compare("Capping") == 0) { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp index 480effba873..6e0cc72c100 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeNodeSelectionFilter.cpp @@ -13,22 +13,22 @@ */ // ** INCLUDES ** -#include <memory> - #include "VtkCompositeNodeSelectionFilter.h" -//#include "VtkCompositePointToGlyphFilter.h" -#include "VtkPointsSource.h" +#include <memory> +//#include "VtkCompositePointToGlyphFilter.h" #include <vtkDataSetAlgorithm.h> +#include <vtkGlyph3D.h> #include <vtkSmartPointer.h> #include <vtkSphereSource.h> -#include <vtkGlyph3D.h> +#include "VtkPointsSource.h" -VtkCompositeNodeSelectionFilter::VtkCompositeNodeSelectionFilter( vtkAlgorithm* inputAlgorithm ) -: VtkCompositeFilter(inputAlgorithm) +VtkCompositeNodeSelectionFilter::VtkCompositeNodeSelectionFilter( + vtkAlgorithm* inputAlgorithm) + : VtkCompositeFilter(inputAlgorithm) { - //this->init(); + // this->init(); } VtkCompositeNodeSelectionFilter::~VtkCompositeNodeSelectionFilter() @@ -46,15 +46,17 @@ void VtkCompositeNodeSelectionFilter::init() if (!_selection.empty()) { - vtkSmartPointer<VtkPointsSource> point_source = vtkSmartPointer<VtkPointsSource>::New(); + vtkSmartPointer<VtkPointsSource> point_source = + vtkSmartPointer<VtkPointsSource>::New(); point_source->setPoints(&_selection); - vtkSmartPointer<vtkSphereSource> _glyphSource = vtkSmartPointer<vtkSphereSource>::New(); - _glyphSource->SetRadius(this->GetInitialRadius()); + vtkSmartPointer<vtkSphereSource> _glyphSource = + vtkSmartPointer<vtkSphereSource>::New(); + _glyphSource->SetRadius(this->GetInitialRadius()); vtkGlyph3D* glyphFilter = vtkGlyph3D::New(); - glyphFilter->SetSourceConnection(_glyphSource->GetOutputPort()); - glyphFilter->SetInputConnection(point_source->GetOutputPort()); + glyphFilter->SetSourceConnection(_glyphSource->GetOutputPort()); + glyphFilter->SetInputConnection(point_source->GetOutputPort()); _outputAlgorithm = glyphFilter; } @@ -64,7 +66,8 @@ void VtkCompositeNodeSelectionFilter::init() } } -void VtkCompositeNodeSelectionFilter::setSelectionArray(const std::vector<unsigned> &point_indeces) +void VtkCompositeNodeSelectionFilter::setSelectionArray( + const std::vector<unsigned>& point_indeces) { for (unsigned int point_index : point_indeces) { @@ -76,4 +79,3 @@ void VtkCompositeNodeSelectionFilter::setSelectionArray(const std::vector<unsign } init(); } - diff --git a/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.cpp index 004ca46fd30..03eb51fab4f 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositePointToGlyphFilter.cpp @@ -20,7 +20,8 @@ #include <vtkPointData.h> #include <vtkSphereSource.h> -VtkCompositePointToGlyphFilter::VtkCompositePointToGlyphFilter( vtkAlgorithm* inputAlgorithm ) +VtkCompositePointToGlyphFilter::VtkCompositePointToGlyphFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm), _glyphSource(nullptr) { this->init(); @@ -37,13 +38,16 @@ void VtkCompositePointToGlyphFilter::init() this->_outputDataObjectType = VTK_POLY_DATA; std::size_t nPoints = static_cast<vtkDataSetAlgorithm*>(_inputAlgorithm) - ->GetOutput()->GetPointData()->GetNumberOfTuples(); - int phi (10 - static_cast<std::size_t>(nPoints / 2000.0)); - int theta (phi); + ->GetOutput() + ->GetPointData() + ->GetNumberOfTuples(); + int phi(10 - static_cast<std::size_t>(nPoints / 2000.0)); + int theta(phi); if (phi < 4) { phi = 4; - theta = 4; // for theta 3 would be possible, too, but 4 looks much better + theta = + 4; // for theta 3 would be possible, too, but 4 looks much better } double default_radius(GetInitialRadius()); @@ -57,9 +61,14 @@ void VtkCompositePointToGlyphFilter::init() (*_algorithmUserProperties)["ThetaResolution"] = theta; vtkGlyph3D* glyphFilter = vtkGlyph3D::New(); - glyphFilter->ScalingOn(); // KR important to scale glyphs with double precision (e.g. 0.1 of their size for small datasets) - //glyphFilter->SetScaleModeToScaleByScalar(); // KR can easily obscure view when scalar values have large differences (this is also the default scaling method) - glyphFilter->SetScaleModeToDataScalingOff(); // KR scaling is possible but scalar values are ignored + glyphFilter + ->ScalingOn(); // KR important to scale glyphs with double precision + // (e.g. 0.1 of their size for small datasets) + // glyphFilter->SetScaleModeToScaleByScalar(); // KR can easily obscure + // view when scalar values have large differences (this is also the default + // scaling method) + glyphFilter->SetScaleModeToDataScalingOff(); // KR scaling is possible but + // scalar values are ignored glyphFilter->SetScaleFactor(1.0); glyphFilter->SetSourceConnection(_glyphSource->GetOutputPort()); glyphFilter->SetInputConnection(_inputAlgorithm->GetOutputPort()); @@ -72,7 +81,8 @@ void VtkCompositePointToGlyphFilter::init() _outputAlgorithm = glyphFilter; } -void VtkCompositePointToGlyphFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositePointToGlyphFilter::SetUserProperty(QString name, + QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); @@ -94,7 +104,8 @@ void VtkCompositePointToGlyphFilter::SetUserProperty( QString name, QVariant val } else if (name.compare("ScaleFactor") == 0) { - static_cast<vtkGlyph3D*>(_outputAlgorithm)->SetScaleFactor(value.toDouble()); + static_cast<vtkGlyph3D*>(_outputAlgorithm) + ->SetScaleFactor(value.toDouble()); } else if (name.compare("ColorMode") == 0) { @@ -102,7 +113,8 @@ void VtkCompositePointToGlyphFilter::SetUserProperty( QString name, QVariant val } else if (name.compare("VectorMode") == 0) { - static_cast<vtkGlyph3D*>(_outputAlgorithm)->SetVectorMode(value.toInt()); + static_cast<vtkGlyph3D*>(_outputAlgorithm) + ->SetVectorMode(value.toInt()); } else if (name.compare("Orient") == 0) { diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp index 41602c4ff6e..c915c449ec6 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeTextureOnSurfaceFilter.cpp @@ -15,14 +15,14 @@ // ** INCLUDES ** #include "VtkCompositeTextureOnSurfaceFilter.h" -#include "BaseLib/Logging.h" - -#include "VtkTextureOnSurfaceFilter.h" #include <vtkDataSetSurfaceFilter.h> #include <vtkSmartPointer.h> #include <vtkUnstructuredGrid.h> + +#include "BaseLib/Logging.h" #include "VtkGeoImageSource.h" #include "VtkRaster.h" +#include "VtkTextureOnSurfaceFilter.h" #ifdef OGS_USE_NETCDF #include "NetCdfConfigureDialog.h" #endif // OGS_USE_NETCDF @@ -33,9 +33,8 @@ //#include "VtkCompositeColormapToImageFilter.h" - VtkCompositeTextureOnSurfaceFilter::VtkCompositeTextureOnSurfaceFilter( - vtkAlgorithm* inputAlgorithm ) + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { this->init(); @@ -52,7 +51,8 @@ void VtkCompositeTextureOnSurfaceFilter::init() vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter; VtkTextureOnSurfaceFilter* surface = VtkTextureOnSurfaceFilter::New(); - if (dynamic_cast<vtkUnstructuredGrid*>(_inputAlgorithm->GetOutputDataObject(0))) + if (dynamic_cast<vtkUnstructuredGrid*>( + _inputAlgorithm->GetOutputDataObject(0))) { surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); surfaceFilter->SetInputConnection(_inputAlgorithm->GetOutputPort()); @@ -101,12 +101,14 @@ void VtkCompositeTextureOnSurfaceFilter::init() } #endif // OGS_USE_NETCDF else - ERR("VtkCompositeTextureOnSurfaceFilter::init(): Error reading texture file."); + ERR("VtkCompositeTextureOnSurfaceFilter::init(): Error reading texture " + "file."); _outputAlgorithm = surface; } -void VtkCompositeTextureOnSurfaceFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeTextureOnSurfaceFilter::SetUserProperty(QString name, + QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); } diff --git a/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp b/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp index 39713fbafc3..1770c2f2ab7 100644 --- a/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCompositeThresholdFilter.cpp @@ -15,13 +15,14 @@ // ** INCLUDES ** #include "VtkCompositeThresholdFilter.h" -#include "BaseLib/Logging.h" - #include <vtkCellData.h> #include <vtkThreshold.h> #include <vtkUnstructuredGrid.h> -VtkCompositeThresholdFilter::VtkCompositeThresholdFilter( vtkAlgorithm* inputAlgorithm ) +#include "BaseLib/Logging.h" + +VtkCompositeThresholdFilter::VtkCompositeThresholdFilter( + vtkAlgorithm* inputAlgorithm) : VtkCompositeFilter(inputAlgorithm) { this->init(); @@ -41,20 +42,22 @@ void VtkCompositeThresholdFilter::init() // Use first array of parent as input array _inputAlgorithm->Update(); - vtkDataSet* dataSet = vtkDataSet::SafeDownCast( - _inputAlgorithm->GetOutputDataObject(0)); + vtkDataSet* dataSet = + vtkDataSet::SafeDownCast(_inputAlgorithm->GetOutputDataObject(0)); vtkDataSetAttributes* pointAttributes = dataSet->GetAttributes(vtkDataObject::AttributeTypes::POINT); vtkDataSetAttributes* cellAttributes = dataSet->GetAttributes(vtkDataObject::AttributeTypes::CELL); if (pointAttributes->GetNumberOfArrays() > 0) { - threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, + threshold->SetInputArrayToProcess( + 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, pointAttributes->GetArray(0)->GetName()); } else if (cellAttributes->GetNumberOfArrays() > 0) { - threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, + threshold->SetInputArrayToProcess( + 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, cellAttributes->GetArray(0)->GetName()); } else @@ -91,7 +94,7 @@ void VtkCompositeThresholdFilter::init() _outputAlgorithm = threshold; } -void VtkCompositeThresholdFilter::SetUserProperty( QString name, QVariant value ) +void VtkCompositeThresholdFilter::SetUserProperty(QString name, QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); @@ -99,7 +102,8 @@ void VtkCompositeThresholdFilter::SetUserProperty( QString name, QVariant value if (name.compare("Selected Component") == 0) { // Set the property on the algorithm - static_cast<vtkThreshold*>(_outputAlgorithm)->SetSelectedComponent(value.toInt()); + static_cast<vtkThreshold*>(_outputAlgorithm) + ->SetSelectedComponent(value.toInt()); } else if (name.compare("Evaluate all points") == 0) { @@ -108,7 +112,8 @@ void VtkCompositeThresholdFilter::SetUserProperty( QString name, QVariant value } } -void VtkCompositeThresholdFilter::SetUserVectorProperty( QString name, QList<QVariant> values ) +void VtkCompositeThresholdFilter::SetUserVectorProperty(QString name, + QList<QVariant> values) { VtkAlgorithmProperties::SetUserVectorProperty(name, values); diff --git a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp index f3ff2b88fc6..9701b1d43fd 100644 --- a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp +++ b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp @@ -9,8 +9,8 @@ */ #include "VtkConsoleOutputWindow.h" -#include <string> #include <ostream> +#include <string> #include "vtkObjectFactory.h" #ifdef WIN32 @@ -56,5 +56,5 @@ void VtkConsoleOutputWindow::DisplayText(const char* someText) //---------------------------------------------------------------------------- void VtkConsoleOutputWindow::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); } diff --git a/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp b/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp index 48b44eca347..2670a928680 100644 --- a/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp +++ b/Applications/DataExplorer/VtkVis/VtkCustomInteractorStyle.cpp @@ -15,8 +15,6 @@ // ** INCLUDES ** #include "VtkCustomInteractorStyle.h" -#include "BaseLib/Logging.h" - #include <vtkActor.h> #include <vtkAlgorithmOutput.h> #include <vtkCamera.h> @@ -39,6 +37,7 @@ #include <string> +#include "BaseLib/Logging.h" #include "VtkCompositeElementSelectionFilter.h" vtkStandardNewMacro(VtkCustomInteractorStyle); @@ -49,7 +48,7 @@ VtkCustomInteractorStyle::VtkCustomInteractorStyle() _selectedActor = vtkActor::New(); _selectedActor->SetMapper(_selectedMapper); _selectedActor->GetProperty()->EdgeVisibilityOn(); - _selectedActor->GetProperty()->SetEdgeColor(1,0,0); + _selectedActor->GetProperty()->SetEdgeColor(1, 0, 0); _selectedActor->GetProperty()->SetLineWidth(3); } @@ -63,13 +62,13 @@ void VtkCustomInteractorStyle::OnChar() { switch (Interactor->GetKeyCode()) { - case '3': - INFO("The 3 key was pressed."); - break; - case 'a': - break; - default: - vtkInteractorStyleTrackballCamera::OnChar(); + case '3': + INFO("The 3 key was pressed."); + break; + case 'a': + break; + default: + vtkInteractorStyleTrackballCamera::OnChar(); } } @@ -77,12 +76,12 @@ void VtkCustomInteractorStyle::OnKeyDown() { switch (Interactor->GetKeyCode()) { - case 32: // Space - _alternateMouseActions = true; - emit cursorChanged(Qt::CrossCursor); - break; - default: - vtkInteractorStyleTrackballCamera::OnKeyDown(); + case 32: // Space + _alternateMouseActions = true; + emit cursorChanged(Qt::CrossCursor); + break; + default: + vtkInteractorStyleTrackballCamera::OnKeyDown(); } } @@ -90,16 +89,16 @@ void VtkCustomInteractorStyle::OnKeyUp() { switch (Interactor->GetKeyCode()) { - case 32: // Space - _alternateMouseActions = false; - emit cursorChanged(Qt::ArrowCursor); - break; - default: - vtkInteractorStyleTrackballCamera::OnKeyUp(); + case 32: // Space + _alternateMouseActions = false; + emit cursorChanged(Qt::ArrowCursor); + break; + default: + vtkInteractorStyleTrackballCamera::OnKeyUp(); } } -void VtkCustomInteractorStyle::highlightActor( vtkProp3D* actor ) +void VtkCustomInteractorStyle::highlightActor(vtkProp3D* actor) { if (_highlightActor) { @@ -109,8 +108,10 @@ void VtkCustomInteractorStyle::highlightActor( vtkProp3D* actor ) void VtkCustomInteractorStyle::removeHighlightActor() { - this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()-> - RemoveActor(_selectedActor); + this->Interactor->GetRenderWindow() + ->GetRenderers() + ->GetFirstRenderer() + ->RemoveActor(_selectedActor); } void VtkCustomInteractorStyle::setHighlightActor(bool on) @@ -127,8 +128,10 @@ void VtkCustomInteractorStyle::pickableDataObject(vtkDataObject* object) _data = object; if (!object) { - this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()-> - RemoveActor(_selectedActor); + this->Interactor->GetRenderWindow() + ->GetRenderers() + ->GetFirstRenderer() + ->RemoveActor(_selectedActor); _selectedMapper->SetInputConnection(nullptr); } } @@ -147,7 +150,7 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() int* pos = this->GetInteractor()->GetEventPosition(); vtkSmartPointer<vtkCellPicker> picker = - vtkSmartPointer<vtkCellPicker>::New(); + vtkSmartPointer<vtkCellPicker>::New(); picker->SetTolerance(0.0005); // Pick from this location. @@ -156,35 +159,35 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() double* worldPosition = picker->GetPickPosition(); INFO("Cell id is: {:d}", picker->GetCellId()); - if(picker->GetCellId() != -1) + if (picker->GetCellId() != -1) { INFO("Pick position is: {:f} {:f} {:f}", worldPosition[0], worldPosition[1], worldPosition[2]); vtkSmartPointer<vtkIdTypeArray> ids = - vtkSmartPointer<vtkIdTypeArray>::New(); + vtkSmartPointer<vtkIdTypeArray>::New(); ids->SetNumberOfValues(1); ids->SetValue(0, picker->GetCellId()); vtkSmartPointer<vtkSelectionNode> selectionNode = - vtkSmartPointer<vtkSelectionNode>::New(); + vtkSmartPointer<vtkSelectionNode>::New(); selectionNode->SetFieldType(vtkSelectionNode::CELL); selectionNode->SetContentType(vtkSelectionNode::INDICES); selectionNode->SetSelectionList(ids); vtkSmartPointer<vtkSelection> selection = - vtkSmartPointer<vtkSelection>::New(); + vtkSmartPointer<vtkSelection>::New(); selection->AddNode(selectionNode); vtkSmartPointer<vtkExtractSelection> extractSelection = - vtkSmartPointer<vtkExtractSelection>::New(); + vtkSmartPointer<vtkExtractSelection>::New(); extractSelection->SetInputData(0, _data); extractSelection->SetInputData(1, selection); extractSelection->Update(); // In selection vtkSmartPointer<vtkUnstructuredGrid> selected = - vtkSmartPointer<vtkUnstructuredGrid>::New(); + vtkSmartPointer<vtkUnstructuredGrid>::New(); selected->ShallowCopy(extractSelection->GetOutput()); INFO("There are {:d} points in the selection.", @@ -192,13 +195,21 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() INFO("There are {:d} cells in the selection.", selected->GetNumberOfCells()); - // check if the underlying object is a mesh and if so, send a signal to the element model for display of information about the picked element. - vtkAlgorithm* data_set = picker->GetActor()->GetMapper()->GetInputConnection(0, 0)->GetProducer()->GetInputConnection(0,0)->GetProducer(); + // check if the underlying object is a mesh and if so, send a signal + // to the element model for display of information about the picked + // element. + vtkAlgorithm* data_set = picker->GetActor() + ->GetMapper() + ->GetInputConnection(0, 0) + ->GetProducer() + ->GetInputConnection(0, 0) + ->GetProducer(); auto* source = dynamic_cast<vtkUnstructuredGridAlgorithm*>(data_set); if (source) { - emit elementPicked(source, static_cast<unsigned>(picker->GetCellId())); + emit elementPicked(source, + static_cast<unsigned>(picker->GetCellId())); } else { @@ -206,8 +217,10 @@ void VtkCustomInteractorStyle::OnLeftButtonDown() } _selectedMapper->SetInputData(selected); - this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()-> - AddActor(_selectedActor); + this->Interactor->GetRenderWindow() + ->GetRenderers() + ->GetFirstRenderer() + ->AddActor(_selectedActor); //_highlightActor = true; } else @@ -239,7 +252,7 @@ void VtkCustomInteractorStyle::OnRightButtonDown() int* pos = this->GetInteractor()->GetEventPosition(); vtkSmartPointer<vtkCellPicker> picker = - vtkSmartPointer<vtkCellPicker>::New(); + vtkSmartPointer<vtkCellPicker>::New(); picker->SetTolerance(0.0005); // Pick from this location. @@ -248,11 +261,11 @@ void VtkCustomInteractorStyle::OnRightButtonDown() double* worldPosition = picker->GetPickPosition(); INFO("Cell id is: {:d}", picker->GetCellId()); - if(picker->GetCellId() != -1) + if (picker->GetCellId() != -1) { - vtkRenderer* renderer = - this->Interactor->GetRenderWindow()->GetRenderers()-> - GetFirstRenderer(); + vtkRenderer* renderer = this->Interactor->GetRenderWindow() + ->GetRenderers() + ->GetFirstRenderer(); vtkCamera* cam = renderer->GetActiveCamera(); cam->SetFocalPoint(worldPosition); emit requestViewUpdate(); diff --git a/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp b/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp index 5fe3f349e12..1e7a8c10686 100644 --- a/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp +++ b/Applications/DataExplorer/VtkVis/VtkFilterFactory.cpp @@ -15,6 +15,8 @@ // ** INCLUDES ** #include "VtkFilterFactory.h" +#include <vtkDataSetSurfaceFilter.h> + #include "VtkCompositeColorByHeightFilter.h" #include "VtkCompositeColormapToImageFilter.h" #include "VtkCompositeContourFilter.h" @@ -30,60 +32,60 @@ #include "VtkCompositeThresholdFilter.h" #include "VtkImageDataToLinePolyDataFilter.h" -#include <vtkDataSetSurfaceFilter.h> - QVector<VtkFilterInfo> VtkFilterFactory::GetFilterList() { QVector<VtkFilterInfo> filterList; // Composite filters - filterList.push_back(VtkFilterInfo( - "VtkCompositeImageToCylindersFilter", - "Image to bar chart", - "This filter converts the red pixel values of the image into a bar graph.", - VTK_IMAGE_DATA, VTK_POLY_DATA)); - - filterList.push_back(VtkFilterInfo( - "VtkCompositePointToGlyphFilter", - "Points to spheres", - "This filter generates spheres on point data that can be scaled and colored by scalar data.", - VTK_POLY_DATA, VTK_POLY_DATA)); - - filterList.push_back(VtkFilterInfo( - "VtkCompositeLineToTubeFilter", - "Lines to tubes", - "This filter will convert lines to tubes that can be colored by scalar data.", - VTK_POLY_DATA, VTK_POLY_DATA)); + filterList.push_back(VtkFilterInfo("VtkCompositeImageToCylindersFilter", + "Image to bar chart", + "This filter converts the red pixel " + "values of the image into a bar graph.", + VTK_IMAGE_DATA, VTK_POLY_DATA)); + + filterList.push_back( + VtkFilterInfo("VtkCompositePointToGlyphFilter", "Points to spheres", + "This filter generates spheres on point data that can be " + "scaled and colored by scalar data.", + VTK_POLY_DATA, VTK_POLY_DATA)); + + filterList.push_back( + VtkFilterInfo("VtkCompositeLineToTubeFilter", "Lines to tubes", + "This filter will convert lines to tubes that can be " + "colored by scalar data.", + VTK_POLY_DATA, VTK_POLY_DATA)); filterList.push_back(VtkFilterInfo( - "VtkCompositeColormapToImageFilter", - "Apply lookup table to image", - "This filter will take an input image of any valid scalar type, and map the first component of the image through a lookup table.", - VTK_IMAGE_DATA, VTK_IMAGE_DATA)); + "VtkCompositeColormapToImageFilter", "Apply lookup table to image", + "This filter will take an input image of any valid scalar type, and " + "map the first component of the image through a lookup table.", + VTK_IMAGE_DATA, VTK_IMAGE_DATA)); filterList.push_back(VtkFilterInfo( - "VtkCompositeTextureOnSurfaceFilter", - "Apply texture to surface", - "This filter assigns an image or raster file as a texture for the given surface.", - VTK_POINT_SET, VTK_POLY_DATA)); + "VtkCompositeTextureOnSurfaceFilter", "Apply texture to surface", + "This filter assigns an image or raster file as a texture for the " + "given surface.", + VTK_POINT_SET, VTK_POLY_DATA)); filterList.push_back(VtkFilterInfo( - "VtkCompositeThresholdFilter", - "Extract cells by threshold", - "This filter extracts cells from any dataset type that satisfy a threshold criterion. A cell satisfies the criterion if the (first) scalar value of (every or any) point satisfies the criterion. For example this can be used to show only certain material groups in a mesh.", - VTK_POINT_SET, VTK_UNSTRUCTURED_GRID)); + "VtkCompositeThresholdFilter", "Extract cells by threshold", + "This filter extracts cells from any dataset type that satisfy a " + "threshold criterion. A cell satisfies the criterion if the (first) " + "scalar value of (every or any) point satisfies the criterion. For " + "example this can be used to show only certain material groups in a " + "mesh.", + VTK_POINT_SET, VTK_UNSTRUCTURED_GRID)); filterList.push_back(VtkFilterInfo( - "VtkCompositeColorByHeightFilter", - "Elevation-based colouring", - "This filter will generate scalar values based on the elevation of each point in the dataset.", - VTK_POINT_SET, VTK_POLY_DATA)); + "VtkCompositeColorByHeightFilter", "Elevation-based colouring", + "This filter will generate scalar values based on the elevation of " + "each point in the dataset.", + VTK_POINT_SET, VTK_POLY_DATA)); filterList.push_back(VtkFilterInfo( - "VtkCompositeContourFilter", - "Generate contours based on scalar fields", - "Visualisation of contour-lines/-planes within dense scalar fields.", - VTK_UNSTRUCTURED_GRID, VTK_UNSTRUCTURED_GRID)); + "VtkCompositeContourFilter", "Generate contours based on scalar fields", + "Visualisation of contour-lines/-planes within dense scalar fields.", + VTK_UNSTRUCTURED_GRID, VTK_UNSTRUCTURED_GRID)); filterList.push_back(VtkFilterInfo( "VtkCompositeImageToPointCloudFilter", "Image to point cloud", @@ -99,29 +101,29 @@ QVector<VtkFilterInfo> VtkFilterFactory::GetFilterList() // Simple filters filterList.push_back(VtkFilterInfo( - "VtkImageDataToLinePolyDataFilter", - "Image to vertical lines", - "This filter converts the red pixel values of the image to lines with length of the value.", - VTK_IMAGE_DATA, VTK_POLY_DATA)); + "VtkImageDataToLinePolyDataFilter", "Image to vertical lines", + "This filter converts the red pixel values of the image to lines with " + "length of the value.", + VTK_IMAGE_DATA, VTK_POLY_DATA)); // Standard VTK filter without properties - filterList.push_back(VtkFilterInfo( - "vtkDataSetSurfaceFilter", - "Surface filter", - "Extracts outer (polygonal) surface.", - VTK_UNSTRUCTURED_GRID, VTK_POLY_DATA)); - -// filterList.push_back(VtkFilterInfo( -// "VtkCompositeSelectionFilter", -// "Mesh Quality Filter", -// "This filter calculates the quality of meshes and highlights deformed elements.", -// VTK_UNSTRUCTURED_GRID, VTK_UNSTRUCTURED_GRID)); + filterList.push_back(VtkFilterInfo("vtkDataSetSurfaceFilter", + "Surface filter", + "Extracts outer (polygonal) surface.", + VTK_UNSTRUCTURED_GRID, VTK_POLY_DATA)); + + // filterList.push_back(VtkFilterInfo( + // "VtkCompositeSelectionFilter", + // "Mesh Quality Filter", + // "This filter calculates the quality of meshes and highlights + // deformed elements.", VTK_UNSTRUCTURED_GRID, + // VTK_UNSTRUCTURED_GRID)); return filterList; } -VtkCompositeFilter* VtkFilterFactory::CreateCompositeFilter( QString type, - vtkAlgorithm* inputAlgorithm ) +VtkCompositeFilter* VtkFilterFactory::CreateCompositeFilter( + QString type, vtkAlgorithm* inputAlgorithm) { if (type.compare(QString("VtkCompositeImageToCylindersFilter")) == 0) { @@ -179,7 +181,7 @@ VtkCompositeFilter* VtkFilterFactory::CreateCompositeFilter( QString type, return nullptr; } -vtkAlgorithm* VtkFilterFactory::CreateSimpleFilter( QString type ) +vtkAlgorithm* VtkFilterFactory::CreateSimpleFilter(QString type) { if (type.compare(QString("VtkImageDataToLinePolyDataFilter")) == 0) { diff --git a/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp b/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp index edae06f821d..b5cc0a19627 100644 --- a/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkGeoImageSource.cpp @@ -16,16 +16,16 @@ #include "VtkGeoImageSource.h" //#include "OGSRaster.h" -#include "VtkRaster.h" - #include <vtkFloatArray.h> #include <vtkImageChangeInformation.h> #include <vtkImageData.h> #include <vtkImageImport.h> #include <vtkImageShiftScale.h> +#include <vtkIntArray.h> #include <vtkObjectFactory.h> #include <vtkPointData.h> -#include <vtkIntArray.h> + +#include "VtkRaster.h" vtkStandardNewMacro(VtkGeoImageSource); @@ -37,19 +37,21 @@ vtkStandardNewMacro(VtkGeoImageSource); // This is not always the case. template <class IT> void vtkSimpleImageFilterExampleExecute(vtkImageData* input, - vtkImageData* output, - IT* inPtr, IT* outPtr) + vtkImageData* output, IT* inPtr, + IT* outPtr) { int dims[3]; input->GetDimensions(dims); if (input->GetScalarType() != output->GetScalarType()) { - vtkGenericWarningMacro(<< "Execute: input ScalarType, " << input->GetScalarType() - << ", must match out ScalarType " << output->GetScalarType()); + vtkGenericWarningMacro( + << "Execute: input ScalarType, " << input->GetScalarType() + << ", must match out ScalarType " << output->GetScalarType()); return; } // HACK LB Multiply by number of scalar components due to RGBA values ????? - int size = dims[0] * dims[1] * dims[2] * input->GetNumberOfScalarComponents(); + int size = + dims[0] * dims[1] * dims[2] * input->GetNumberOfScalarComponents(); for (int i = 0; i < size; i++) { @@ -72,9 +74,9 @@ void VtkGeoImageSource::PrintSelf(ostream& os, vtkIndent indent) this->Superclass::PrintSelf(os, indent); } -bool VtkGeoImageSource::readImage(const QString &filename) +bool VtkGeoImageSource::readImage(const QString& filename) { - vtkImageAlgorithm* img (VtkRaster::loadImage(filename.toStdString())); + vtkImageAlgorithm* img(VtkRaster::loadImage(filename.toStdString())); if (img == nullptr) { return false; @@ -83,7 +85,7 @@ bool VtkGeoImageSource::readImage(const QString &filename) return true; } -void VtkGeoImageSource::setImage(vtkImageAlgorithm* image, const QString &name) +void VtkGeoImageSource::setImage(vtkImageAlgorithm* image, const QString& name) { this->_imageSource = image; this->SetInputConnection(_imageSource->GetOutputPort()); @@ -100,19 +102,19 @@ void VtkGeoImageSource::SimpleExecute(vtkImageData* input, vtkImageData* output) vtkDebugMacro(<< "Executing VtkGeoImageSource"); void* inPtr = input->GetScalarPointer(); void* outPtr = output->GetScalarPointer(); - switch(output->GetScalarType()) + switch (output->GetScalarType()) { // This is simply a #define for a big case list. // It handles all data types that VTK supports. vtkTemplateMacro(vtkSimpleImageFilterExampleExecute( - input, output, (VTK_TT*)(inPtr), (VTK_TT*)(outPtr))); - default: - vtkGenericWarningMacro("Execute: Unknown input ScalarType"); - return; + input, output, (VTK_TT*)(inPtr), (VTK_TT*)(outPtr))); + default: + vtkGenericWarningMacro("Execute: Unknown input ScalarType"); + return; } } -void VtkGeoImageSource::SetUserProperty( QString name, QVariant value ) +void VtkGeoImageSource::SetUserProperty(QString name, QVariant value) { Q_UNUSED(name); Q_UNUSED(value); diff --git a/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp b/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp index ea1c786c9f3..0ee1a536bad 100644 --- a/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkImageDataToLinePolyDataFilter.cpp @@ -56,8 +56,10 @@ int VtkImageDataToLinePolyDataFilter::RequestData( vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); vtkInformation* outInfo = outputVector->GetInformationObject(0); - vtkImageData* input = vtkImageData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkImageData* input = + vtkImageData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* output = + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); void* inScalarPtr = input->GetScalarPointer(); int numScalarComponents = input->GetNumberOfScalarComponents(); @@ -98,7 +100,8 @@ int VtkImageDataToLinePolyDataFilter::RequestData( double dir[3] = {0, 0, 1}; - // Traverse all points creating another point with scalar distance in Z direction + // Traverse all points creating another point with scalar distance in Z + // direction for (vtkIdType ptId = 0; ptId < numPts; ++ptId) { // Skip translucent pixels @@ -153,8 +156,7 @@ int VtkImageDataToLinePolyDataFilter::RequestData( // Avoid keeping extra memory around output->Squeeze(); - vtkDebugMacro(<< "Created: " - << newPts->GetNumberOfPoints() << " points, " + vtkDebugMacro(<< "Created: " << newPts->GetNumberOfPoints() << " points, " << output->GetNumberOfCells() << " lines"); return 1; diff --git a/Applications/DataExplorer/VtkVis/VtkImageDataToPointCloudFilter.cpp b/Applications/DataExplorer/VtkVis/VtkImageDataToPointCloudFilter.cpp index 6df9350a290..bd29889d3c6 100644 --- a/Applications/DataExplorer/VtkVis/VtkImageDataToPointCloudFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkImageDataToPointCloudFilter.cpp @@ -11,9 +11,6 @@ // ** INCLUDES ** #include "VtkImageDataToPointCloudFilter.h" -#include <algorithm> -#include <vector> - #include <vtkDoubleArray.h> #include <vtkIdList.h> #include <vtkImageData.h> @@ -25,6 +22,9 @@ #include <vtkPolyData.h> #include <vtkSmartPointer.h> +#include <algorithm> +#include <vector> + vtkStandardNewMacro(VtkImageDataToPointCloudFilter); VtkImageDataToPointCloudFilter::VtkImageDataToPointCloudFilter() = default; @@ -57,7 +57,8 @@ int VtkImageDataToPointCloudFilter::RequestData( if (input->GetScalarSize() != sizeof(float)) { - vtkDebugMacro("Existing data does not have float-type and cannot be processed. " + vtkDebugMacro( + "Existing data does not have float-type and cannot be processed. " "Aborting filter process..."); return 0; } @@ -120,7 +121,8 @@ int VtkImageDataToPointCloudFilter::RequestData( new_points->SetNumberOfPoints(sum); vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); cells->Allocate(sum); - vtkSmartPointer<vtkDoubleArray> intensity = vtkSmartPointer<vtkDoubleArray>::New(); + vtkSmartPointer<vtkDoubleArray> intensity = + vtkSmartPointer<vtkDoubleArray>::New(); intensity->Allocate(sum); intensity->SetName("Intensity"); double const half_cellsize(spacing[0] / 2.0); @@ -149,10 +151,12 @@ int VtkImageDataToPointCloudFilter::RequestData( output->SetPoints(new_points); output->SetVerts(cells); output->GetPointData()->AddArray(intensity); - output->GetPointData()->SetActiveAttribute("Intensity", vtkDataSetAttributes::SCALARS); + output->GetPointData()->SetActiveAttribute("Intensity", + vtkDataSetAttributes::SCALARS); output->Squeeze(); - vtkDebugMacro(<< "Created " << new_points->GetNumberOfPoints() << " points."); + vtkDebugMacro(<< "Created " << new_points->GetNumberOfPoints() + << " points."); return 1; } @@ -176,7 +180,8 @@ void VtkImageDataToPointCloudFilter::createPoints( } } -double VtkImageDataToPointCloudFilter::getRandomNumber(double const& min, double const& max) const +double VtkImageDataToPointCloudFilter::getRandomNumber(double const& min, + double const& max) const { return (static_cast<double>(std::rand()) / RAND_MAX) * (max - min) + min; } @@ -189,6 +194,7 @@ std::size_t VtkImageDataToPointCloudFilter::interpolate(double low, p = std::clamp(p, low, high); double const r = (p - low) / (high - low); return static_cast<std::size_t>( - (MaxNumberOfPointsPerCell - MinNumberOfPointsPerCell) * std::pow(r, gamma) + - MinNumberOfPointsPerCell); + (MaxNumberOfPointsPerCell - MinNumberOfPointsPerCell) * + std::pow(r, gamma) + + MinNumberOfPointsPerCell); } diff --git a/Applications/DataExplorer/VtkVis/VtkImageDataToSurfacePointsFilter.cpp b/Applications/DataExplorer/VtkVis/VtkImageDataToSurfacePointsFilter.cpp index 5ca4010daf9..8adbdc9ea91 100644 --- a/Applications/DataExplorer/VtkVis/VtkImageDataToSurfacePointsFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkImageDataToSurfacePointsFilter.cpp @@ -11,9 +11,6 @@ // ** INCLUDES ** #include "VtkImageDataToSurfacePointsFilter.h" -#include <algorithm> -#include <vector> - #include <vtkIdList.h> #include <vtkImageData.h> #include <vtkInformation.h> @@ -24,6 +21,9 @@ #include <vtkPolyData.h> #include <vtkSmartPointer.h> +#include <algorithm> +#include <vector> + vtkStandardNewMacro(VtkImageDataToSurfacePointsFilter); VtkImageDataToSurfacePointsFilter::VtkImageDataToSurfacePointsFilter() = @@ -80,7 +80,8 @@ int VtkImageDataToSurfacePointsFilter::RequestData( input->GetDimensions(dimensions); double origin[3]; input->GetOrigin(origin); - MathLib::Point3d const ll(std::array<double, 3>{{origin[0], origin[1], origin[2]}}); + MathLib::Point3d const ll( + std::array<double, 3>{{origin[0], origin[1], origin[2]}}); std::vector<double> pixels; pixels.reserve(n_points); @@ -137,7 +138,8 @@ int VtkImageDataToSurfacePointsFilter::RequestData( output->SetVerts(cells); output->Squeeze(); - vtkDebugMacro(<< "Created " << new_points->GetNumberOfPoints() << " points."); + vtkDebugMacro(<< "Created " << new_points->GetNumberOfPoints() + << " points."); return 1; } @@ -163,7 +165,8 @@ void VtkImageDataToSurfacePointsFilter::createPointSurface( } } -double VtkImageDataToSurfacePointsFilter::getRandomNumber(double const& min, double const& max) const +double VtkImageDataToSurfacePointsFilter::getRandomNumber( + double const& min, double const& max) const { return (static_cast<double>(std::rand()) / RAND_MAX) * (max - min) + min; } diff --git a/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp b/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp index 041c6f1de76..6817df014aa 100644 --- a/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPointsSource.cpp @@ -14,57 +14,57 @@ #include "VtkPointsSource.h" -#include "BaseLib/Logging.h" - #include <vtkCellArray.h> +#include <vtkCellData.h> #include <vtkInformation.h> #include <vtkInformationVector.h> #include <vtkObjectFactory.h> #include <vtkPointData.h> #include <vtkPoints.h> #include <vtkPolyData.h> +#include <vtkProperty.h> #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> -#include <vtkCellData.h> -#include <vtkProperty.h> #include "Applications/DataHolderLib/Color.h" +#include "BaseLib/Logging.h" vtkStandardNewMacro(VtkPointsSource); VtkPointsSource::VtkPointsSource() { - _removable = false; // From VtkAlgorithmProperties + _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); const DataHolderLib::Color c = DataHolderLib::getRandomColor(); - GetProperties()->SetColor(c[0] / 255.0,c[1] / 255.0,c[2] / 255.0); + GetProperties()->SetColor(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0); } -void VtkPointsSource::PrintSelf( ostream& os, vtkIndent indent ) +void VtkPointsSource::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); if (_points->empty()) { return; } - os << indent << "== VtkPointsSource ==" << "\n"; + os << indent << "== VtkPointsSource ==" + << "\n"; int i = 0; for (auto point : *_points) { const double* coords = point->getCoords(); - os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] << ", " << - coords[2] << ")\n"; + os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] + << ", " << coords[2] << ")\n"; i++; } } -int VtkPointsSource::RequestData( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) +int VtkPointsSource::RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { (void)request; (void)inputVector; @@ -80,12 +80,14 @@ int VtkPointsSource::RequestData( vtkInformation* request, return 0; } - vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); + vtkSmartPointer<vtkInformation> outInfo = + outputVector->GetInformationObject(0); vtkSmartPointer<vtkPolyData> output = - vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New(); - vtkSmartPointer<vtkCellArray> newVerts = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkCellArray> newVerts = + vtkSmartPointer<vtkCellArray>::New(); newPoints->SetNumberOfPoints(numPoints); newVerts->Allocate(numPoints); @@ -116,19 +118,20 @@ int VtkPointsSource::RequestData( vtkInformation* request, output->SetPoints(newPoints); output->SetVerts(newVerts); output->GetCellData()->AddArray(pointIDs); - output->GetCellData()->SetActiveAttribute("PointIDs", vtkDataSetAttributes::SCALARS); + output->GetCellData()->SetActiveAttribute("PointIDs", + vtkDataSetAttributes::SCALARS); return 1; } -int VtkPointsSource::RequestInformation( vtkInformation* /*request*/, - vtkInformationVector** /*inputVector*/, - vtkInformationVector* /*outputVector*/ ) +int VtkPointsSource::RequestInformation(vtkInformation* /*request*/, + vtkInformationVector** /*inputVector*/, + vtkInformationVector* /*outputVector*/) { return 1; } -void VtkPointsSource::SetUserProperty( QString name, QVariant value ) +void VtkPointsSource::SetUserProperty(QString name, QVariant value) { Q_UNUSED(name); Q_UNUSED(value); diff --git a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp index c3d5226cbaf..03278132371 100644 --- a/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkPolylinesSource.cpp @@ -15,8 +15,6 @@ // ** INCLUDES ** #include "VtkPolylinesSource.h" -#include "BaseLib/Logging.h" - #include <vtkCellArray.h> #include <vtkCellData.h> #include <vtkInformation.h> @@ -29,16 +27,15 @@ #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> -#include "Polyline.h" - #include "Applications/DataHolderLib/Color.h" - +#include "BaseLib/Logging.h" +#include "Polyline.h" vtkStandardNewMacro(VtkPolylinesSource); VtkPolylinesSource::VtkPolylinesSource() { - _removable = false; // From VtkAlgorithmProperties + _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); const DataHolderLib::Color c = DataHolderLib::getRandomColor(); @@ -47,9 +44,9 @@ VtkPolylinesSource::VtkPolylinesSource() VtkPolylinesSource::~VtkPolylinesSource() = default; -void VtkPolylinesSource::PrintSelf( ostream& os, vtkIndent indent ) +void VtkPolylinesSource::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); if (_polylines->empty()) { @@ -58,21 +55,22 @@ void VtkPolylinesSource::PrintSelf( ostream& os, vtkIndent indent ) for (auto polyline : *_polylines) { - os << indent << "== Polyline ==" << "\n"; + os << indent << "== Polyline ==" + << "\n"; int numPoints = polyline->getNumberOfPoints(); for (int i = 0; i < numPoints; i++) { const GeoLib::Point* point = polyline->getPoint(i); const double* coords = point->getCoords(); - os << indent << "Point " << i << " (" << coords[0] << ", " << coords[1] << - ", " << coords[2] << ")\n"; + os << indent << "Point " << i << " (" << coords[0] << ", " + << coords[1] << ", " << coords[2] << ")\n"; } } } -int VtkPolylinesSource::RequestData( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) +int VtkPolylinesSource::RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { (void)request; (void)inputVector; @@ -87,15 +85,17 @@ int VtkPolylinesSource::RequestData( vtkInformation* request, return 0; } - vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); + vtkSmartPointer<vtkInformation> outInfo = + outputVector->GetInformationObject(0); vtkSmartPointer<vtkPolyData> output = - vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New(); - vtkSmartPointer<vtkCellArray> newLines = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkCellArray> newLines = + vtkSmartPointer<vtkCellArray>::New(); - //newPoints->Allocate(numPoints); - //newLines->Allocate(newLines->EstimateSize(numLines, 2)); + // newPoints->Allocate(numPoints); + // newLines->Allocate(newLines->EstimateSize(numLines, 2)); if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0) @@ -107,15 +107,15 @@ int VtkPolylinesSource::RequestData( vtkInformation* request, plyIDs->SetNumberOfComponents(1); plyIDs->SetName("PolylineIDs"); - unsigned lastMaxIndex (0); - const std::size_t nPolylines (_polylines->size()); + unsigned lastMaxIndex(0); + const std::size_t nPolylines(_polylines->size()); for (std::size_t j = 0; j < nPolylines; j++) { const int numPoints = (*_polylines)[j]->getNumberOfPoints(); const bool isClosed = (*_polylines)[j]->isClosed(); // Generate points - const int numVerts = (isClosed) ? numPoints-1 : numPoints; + const int numVerts = (isClosed) ? numPoints - 1 : numPoints; for (int i = 0; i < numVerts; i++) { const GeoLib::Point* point = (*_polylines)[j]->getPoint(i); @@ -142,20 +142,22 @@ int VtkPolylinesSource::RequestData( vtkInformation* request, output->SetPoints(newPoints); output->SetLines(newLines); output->GetCellData()->AddArray(plyIDs); - output->GetCellData()->SetActiveAttribute("PolylineIDs", vtkDataSetAttributes::SCALARS); + output->GetCellData()->SetActiveAttribute("PolylineIDs", + vtkDataSetAttributes::SCALARS); output->Squeeze(); return 1; } -int VtkPolylinesSource::RequestInformation( vtkInformation* /*request*/, - vtkInformationVector** /*inputVector*/, - vtkInformationVector* /*outputVector*/ ) +int VtkPolylinesSource::RequestInformation( + vtkInformation* /*request*/, + vtkInformationVector** /*inputVector*/, + vtkInformationVector* /*outputVector*/) { return 1; } -void VtkPolylinesSource::SetUserProperty( QString name, QVariant value ) +void VtkPolylinesSource::SetUserProperty(QString name, QVariant value) { Q_UNUSED(name); Q_UNUSED(value); diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index 2df3218025f..e875533d903 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -14,12 +14,6 @@ #include "VtkRaster.h" -#include <algorithm> -#include <cmath> -#include <limits> - -#include <QFileInfo> - #include <vtkBMPReader.h> #include <vtkImageData.h> #include <vtkImageImport.h> @@ -28,6 +22,11 @@ #include <vtkPNGReader.h> #include <vtkTIFFReader.h> +#include <QFileInfo> +#include <algorithm> +#include <cmath> +#include <limits> + #ifdef GEOTIFF_FOUND #include "geo_tiffp.h" #include "xtiffio.h" @@ -41,14 +40,15 @@ #include "BaseLib/StringTools.h" #include "GeoLib/Raster.h" -vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName) +vtkImageAlgorithm* VtkRaster::loadImage(const std::string& fileName) { QFileInfo fileInfo(QString::fromStdString(fileName)); std::unique_ptr<GeoLib::Raster> raster(nullptr); if (fileInfo.suffix().toLower() == "asc") { - raster.reset(FileIO::AsciiRasterInterface::getRasterFromASCFile(fileName)); + raster.reset( + FileIO::AsciiRasterInterface::getRasterFromASCFile(fileName)); } else if (fileInfo.suffix().toLower() == "grd") { @@ -74,18 +74,21 @@ vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName) return loadImageFromFile(fileName); } -vtkImageImport* VtkRaster::loadImageFromArray(double const*const data_array, GeoLib::RasterHeader header) +vtkImageImport* VtkRaster::loadImageFromArray(double const* const data_array, + GeoLib::RasterHeader header) { const unsigned length = header.n_rows * header.n_cols * header.n_depth; auto* data = new float[length * 2]; - float max_val = static_cast<float>(*std::max_element(data_array, data_array+length)); - for (unsigned j=0; j<length; ++j) + float max_val = + static_cast<float>(*std::max_element(data_array, data_array + length)); + for (unsigned j = 0; j < length; ++j) { - data[j*2] = static_cast<float>(data_array[j]); - if (fabs(data[j*2]-header.no_data) < std::numeric_limits<double>::epsilon()) + data[j * 2] = static_cast<float>(data_array[j]); + if (fabs(data[j * 2] - header.no_data) < + std::numeric_limits<double>::epsilon()) { - data[j*2] = max_val; - data[j*2+1] = 0; + data[j * 2] = max_val; + data[j * 2 + 1] = 0; } else { @@ -94,17 +97,19 @@ vtkImageImport* VtkRaster::loadImageFromArray(double const*const data_array, Geo } vtkImageImport* image = vtkImageImport::New(); - image->SetDataSpacing(header.cell_size, header.cell_size, header.cell_size); - image->SetDataOrigin(header.origin[0]+(header.cell_size/2.0), header.origin[1]+(header.cell_size/2.0), 0); // translate whole mesh by half a pixel in x and y - image->SetWholeExtent(0, header.n_cols - 1, 0, header.n_rows - 1, 0, - header.n_depth - 1); - image->SetDataExtent(0, header.n_cols - 1, 0, header.n_rows - 1, 0, - header.n_depth - 1); - image->SetDataExtentToWholeExtent(); - image->SetDataScalarTypeToFloat(); - image->SetNumberOfScalarComponents(2); - image->SetImportVoidPointer(data, 0); - image->Update(); + image->SetDataSpacing(header.cell_size, header.cell_size, header.cell_size); + image->SetDataOrigin(header.origin[0] + (header.cell_size / 2.0), + header.origin[1] + (header.cell_size / 2.0), + 0); // translate whole mesh by half a pixel in x and y + image->SetWholeExtent(0, header.n_cols - 1, 0, header.n_rows - 1, 0, + header.n_depth - 1); + image->SetDataExtent(0, header.n_cols - 1, 0, header.n_rows - 1, 0, + header.n_depth - 1); + image->SetDataExtentToWholeExtent(); + image->SetDataScalarTypeToFloat(); + image->SetNumberOfScalarComponents(2); + image->SetImportVoidPointer(data, 0); + image->Update(); return image; } @@ -119,7 +124,7 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) GTIF* geoTiff = GTIFNew(tiff); int version[3]; - int count (0); + int count(0); GTIFDirectoryInfo(geoTiff, version, &count); if (count == 0) @@ -137,7 +142,8 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) double* pnts = nullptr; // get actual number of images in the tiff file - do { + do + { ++nImages; } while (TIFFReadDirectory(tiff)); if (nImages > 1) @@ -147,15 +153,18 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) nImages); // get image size - TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &imgWidth); + TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &imgWidth); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &imgHeight); // get cellsize - // Note: GeoTiff allows anisotropic pixels. This is not supported here and equilateral pixels are assumed. + // Note: GeoTiff allows anisotropic pixels. This is not supported + // here and equilateral pixels are assumed. if (TIFFGetField(tiff, GTIFF_PIXELSCALE, &pntCount, &pnts)) { if (pnts[0] != pnts[1]) - WARN("VtkRaster::loadImageFromTIFF(): Original raster data has anisotrop pixel size!"); + WARN( + "VtkRaster::loadImageFromTIFF(): Original raster data " + "has anisotrop pixel size!"); cellsize = pnts[0]; } @@ -163,7 +172,9 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) if (TIFFGetField(tiff, GTIFF_TIEPOINTS, &pntCount, &pnts)) { x0 = pnts[3]; - y0 = pnts[4] - (imgHeight * cellsize); // the origin should be the lower left corner of the img + y0 = pnts[4] - + (imgHeight * cellsize); // the origin should be the lower + // left corner of the img } // read pixel values @@ -173,7 +184,8 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) { if (!TIFFReadRGBAImage(tiff, imgWidth, imgHeight, pixVal, 0)) { - ERR("VtkRaster::loadImageFromTIFF(): reading GeoTIFF file."); + ERR("VtkRaster::loadImageFromTIFF(): reading GeoTIFF " + "file."); _TIFFfree(pixVal); GTIFFree(geoTiff); XTIFFClose(tiff); @@ -185,12 +197,10 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) uint16 photometric; TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &photometric); // read colormap - uint16* cmap_red = nullptr, * cmap_green = nullptr, * cmap_blue = nullptr; - int colormap_used = TIFFGetField(tiff, - TIFFTAG_COLORMAP, - &cmap_red, - &cmap_green, - &cmap_blue); + uint16 *cmap_red = nullptr, *cmap_green = nullptr, + *cmap_blue = nullptr; + int colormap_used = TIFFGetField( + tiff, TIFFTAG_COLORMAP, &cmap_red, &cmap_green, &cmap_blue); auto* data = new float[imgWidth * imgHeight * 4]; auto* pxl(new int[4]); @@ -198,33 +208,39 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) { int lineindex = j * imgWidth; for (int i = 0; i < imgWidth; ++i) - { // scale intensities and set nodata values to white (i.e. the background colour) - unsigned pxl_idx(lineindex+i); - unsigned pos = 4 * (pxl_idx); - if (photometric==1 && colormap_used==1) + { // scale intensities and set nodata values to white (i.e. the + // background colour) + unsigned pxl_idx(lineindex + i); + unsigned pos = 4 * (pxl_idx); + if (photometric == 1 && colormap_used == 1) { int idx = TIFFGetR(pixVal[pxl_idx]); - data[pos] = static_cast<float>(cmap_red[idx] >> 8); - data[pos+1] = static_cast<float>(cmap_green[idx] >> 8); - data[pos+2] = static_cast<float>(cmap_blue[idx] >> 8); - data[pos+3] = 1; + data[pos] = static_cast<float>(cmap_red[idx] >> 8); + data[pos + 1] = + static_cast<float>(cmap_green[idx] >> 8); + data[pos + 2] = static_cast<float>(cmap_blue[idx] >> 8); + data[pos + 3] = 1; } else { - data[pos] = static_cast<float>(TIFFGetR(pixVal[pxl_idx])); - data[pos+1] = static_cast<float>(TIFFGetG(pixVal[pxl_idx])); - data[pos+2] = static_cast<float>(TIFFGetB(pixVal[pxl_idx])); - data[pos+3] = static_cast<float>(TIFFGetA(pixVal[pxl_idx])); + data[pos] = + static_cast<float>(TIFFGetR(pixVal[pxl_idx])); + data[pos + 1] = + static_cast<float>(TIFFGetG(pixVal[pxl_idx])); + data[pos + 2] = + static_cast<float>(TIFFGetB(pixVal[pxl_idx])); + data[pos + 3] = + static_cast<float>(TIFFGetA(pixVal[pxl_idx])); } } } - delete [] pxl; + delete[] pxl; // set transparency values according to maximum pixel value - if (photometric==1) + if (photometric == 1) { float max_val(0); - unsigned nPixels = 4*imgWidth*imgHeight; + unsigned nPixels = 4 * imgWidth * imgHeight; for (unsigned j = 0; j < nPixels; ++j) { if (data[j] > max_val) @@ -240,15 +256,15 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) } vtkImageImport* image = vtkImageImport::New(); - image->SetDataOrigin(x0, y0, 0); - image->SetDataSpacing(cellsize, cellsize, cellsize); - image->SetWholeExtent(0, imgWidth-1, 0, imgHeight-1, 0, 0); - image->SetDataExtent(0, imgWidth-1, 0, imgHeight-1, 0, 0); - image->SetDataExtentToWholeExtent(); - image->SetDataScalarTypeToFloat(); - image->SetNumberOfScalarComponents(4); - image->SetImportVoidPointer(data, 0); - image->Update(); + image->SetDataOrigin(x0, y0, 0); + image->SetDataSpacing(cellsize, cellsize, cellsize); + image->SetWholeExtent(0, imgWidth - 1, 0, imgHeight - 1, 0, 0); + image->SetDataExtent(0, imgWidth - 1, 0, imgHeight - 1, 0, 0); + image->SetDataExtentToWholeExtent(); + image->SetDataScalarTypeToFloat(); + image->SetNumberOfScalarComponents(4); + image->SetImportVoidPointer(data, 0); + image->Update(); _TIFFfree(pixVal); GTIFFree(geoTiff); @@ -267,9 +283,9 @@ vtkImageAlgorithm* VtkRaster::loadImageFromTIFF(const std::string& fileName) } #endif -vtkImageReader2* VtkRaster::loadImageFromFile(const std::string &fileName) +vtkImageReader2* VtkRaster::loadImageFromFile(const std::string& fileName) { - QString file_name (QString::fromStdString(fileName)); + QString file_name(QString::fromStdString(fileName)); QFileInfo fi(file_name); vtkImageReader2* image(nullptr); diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp index e3f888b57b1..33857343a2b 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp @@ -15,60 +15,60 @@ // ** VTK INCLUDES ** #include "VtkStationSource.h" -#include "BaseLib/Logging.h" - -#include "StationBorehole.h" - -#include "vtkObjectFactory.h" -#include <vtkDoubleArray.h> #include <vtkCellArray.h> #include <vtkCellData.h> +#include <vtkDoubleArray.h> #include <vtkInformation.h> #include <vtkInformationVector.h> #include <vtkLine.h> #include <vtkPointData.h> #include <vtkPoints.h> #include <vtkPolyData.h> +#include <vtkProperty.h> #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> -#include <vtkProperty.h> + +#include "BaseLib/Logging.h" +#include "StationBorehole.h" +#include "vtkObjectFactory.h" vtkStandardNewMacro(VtkStationSource); VtkStationSource::VtkStationSource() { - _removable = false; // From VtkAlgorithmProperties + _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); const DataHolderLib::Color c = DataHolderLib::getRandomColor(); GetProperties()->SetColor(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0); } -void VtkStationSource::PrintSelf( ostream& os, vtkIndent indent ) +void VtkStationSource::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); if (_stations->empty()) { return; } - os << indent << "== VtkStationSource ==" << "\n"; + os << indent << "== VtkStationSource ==" + << "\n"; int i = 0; for (auto station : *_stations) { const double* coords = station->getCoords(); - os << indent << "Station " << i << " (" << coords[0] << ", " << coords[1] << - ", " << coords[2] << ")\n"; + os << indent << "Station " << i << " (" << coords[0] << ", " + << coords[1] << ", " << coords[2] << ")\n"; i++; } } /// Create 3d Station objects -int VtkStationSource::RequestData( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) +int VtkStationSource::RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { (void)request; (void)inputVector; @@ -84,10 +84,12 @@ int VtkStationSource::RequestData( vtkInformation* request, } bool useStationValues(false); - double sValue=static_cast<GeoLib::Station*>((*_stations)[0])->getStationValue(); + double sValue = + static_cast<GeoLib::Station*>((*_stations)[0])->getStationValue(); for (std::size_t i = 1; i < nStations; i++) { - if (static_cast<GeoLib::Station*>((*_stations)[i])->getStationValue() != sValue) + if (static_cast<GeoLib::Station*>((*_stations)[i])->getStationValue() != + sValue) { useStationValues = true; break; @@ -97,12 +99,14 @@ int VtkStationSource::RequestData( vtkInformation* request, bool isBorehole = static_cast<GeoLib::Station*>((*_stations)[0])->type() == GeoLib::Station::StationType::BOREHOLE; - vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); + vtkSmartPointer<vtkInformation> outInfo = + outputVector->GetInformationObject(0); vtkSmartPointer<vtkPolyData> output = - vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); vtkSmartPointer<vtkPoints> newStations = vtkSmartPointer<vtkPoints>::New(); - vtkSmartPointer<vtkCellArray> newVerts = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkCellArray> newVerts = + vtkSmartPointer<vtkCellArray>::New(); newVerts->Allocate(nStations); vtkSmartPointer<vtkCellArray> newLines; @@ -118,15 +122,18 @@ int VtkStationSource::RequestData( vtkInformation* request, return 1; } - vtkSmartPointer<vtkIntArray> station_ids = vtkSmartPointer<vtkIntArray>::New(); + vtkSmartPointer<vtkIntArray> station_ids = + vtkSmartPointer<vtkIntArray>::New(); station_ids->SetNumberOfComponents(1); station_ids->SetName("SiteIDs"); - vtkSmartPointer<vtkDoubleArray> station_values = vtkSmartPointer<vtkDoubleArray>::New(); + vtkSmartPointer<vtkDoubleArray> station_values = + vtkSmartPointer<vtkDoubleArray>::New(); station_values->SetNumberOfComponents(1); station_values->SetName("StationValue"); - vtkSmartPointer<vtkIntArray> strat_ids = vtkSmartPointer<vtkIntArray>::New(); + vtkSmartPointer<vtkIntArray> strat_ids = + vtkSmartPointer<vtkIntArray>::New(); strat_ids->SetNumberOfComponents(1); strat_ids->SetName("Stratigraphies"); @@ -187,14 +194,16 @@ int VtkStationSource::RequestData( vtkInformation* request, { output->SetVerts(newVerts); output->GetCellData()->AddArray(station_ids); - output->GetCellData()->SetActiveAttribute("SiteIDs", vtkDataSetAttributes::SCALARS); + output->GetCellData()->SetActiveAttribute( + "SiteIDs", vtkDataSetAttributes::SCALARS); } else { output->SetLines(newLines); - //output->GetCellData()->AddArray(station_ids); + // output->GetCellData()->AddArray(station_ids); output->GetCellData()->AddArray(strat_ids); - output->GetCellData()->SetActiveAttribute("Stratigraphies", vtkDataSetAttributes::SCALARS); + output->GetCellData()->SetActiveAttribute( + "Stratigraphies", vtkDataSetAttributes::SCALARS); } if (useStationValues) { @@ -206,20 +215,20 @@ int VtkStationSource::RequestData( vtkInformation* request, return 1; } -int VtkStationSource::RequestInformation( vtkInformation* /*request*/, - vtkInformationVector** /*inputVector*/, - vtkInformationVector* /*outputVector*/ ) +int VtkStationSource::RequestInformation(vtkInformation* /*request*/, + vtkInformationVector** /*inputVector*/, + vtkInformationVector* /*outputVector*/) { return 1; } -void VtkStationSource::SetUserProperty( QString name, QVariant value ) +void VtkStationSource::SetUserProperty(QString name, QVariant value) { Q_UNUSED(name); Q_UNUSED(value); } -std::size_t VtkStationSource::GetIndexByName( std::string const& name ) +std::size_t VtkStationSource::GetIndexByName(std::string const& name) { vtkIdType max_key(0); for (auto& it : _id_map) @@ -234,9 +243,8 @@ std::size_t VtkStationSource::GetIndexByName( std::string const& name ) } } - vtkIdType new_index = (_id_map.empty()) ? 0 : (max_key+1); + vtkIdType new_index = (_id_map.empty()) ? 0 : (max_key + 1); INFO("Key '{:s}' has been assigned index {:d}.", name, new_index); _id_map.insert(std::pair<std::string, vtkIdType>(name, new_index)); return new_index; } - diff --git a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp index 878c0759466..a993903f0b3 100644 --- a/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkSurfacesSource.cpp @@ -14,7 +14,6 @@ // ** INCLUDES ** #include "VtkSurfacesSource.h" -#include <limits> #include <vtkCellArray.h> #include <vtkCellData.h> @@ -22,43 +21,46 @@ #include <vtkInformationVector.h> #include <vtkObjectFactory.h> #include <vtkPolyData.h> -#include <vtkTriangle.h> +#include <vtkProperty.h> #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> -#include <vtkProperty.h> +#include <vtkTriangle.h> + +#include <limits> -#include "GeoLib/Triangle.h" #include "Applications/DataHolderLib/Color.h" +#include "GeoLib/Triangle.h" vtkStandardNewMacro(VtkSurfacesSource); VtkSurfacesSource::VtkSurfacesSource() { - _removable = false; // From VtkAlgorithmProperties + _removable = false; // From VtkAlgorithmProperties this->SetNumberOfInputPorts(0); - //this->SetColorBySurface(true); + // this->SetColorBySurface(true); const DataHolderLib::Color c = DataHolderLib::getRandomColor(); vtkProperty* vtkProps = GetProperties(); - vtkProps->SetColor(c[0] / 255.0,c[1] / 255.0,c[2] / 255.0); + vtkProps->SetColor(c[0] / 255.0, c[1] / 255.0, c[2] / 255.0); vtkProps->SetEdgeVisibility(0); } -void VtkSurfacesSource::PrintSelf( ostream& os, vtkIndent indent ) +void VtkSurfacesSource::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); if (_surfaces->empty()) { return; } - os << indent << "== VtkSurfacesSource ==" << "\n"; + os << indent << "== VtkSurfacesSource ==" + << "\n"; } -int VtkSurfacesSource::RequestData( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) +int VtkSurfacesSource::RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { (void)request; (void)inputVector; @@ -69,12 +71,14 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, return 0; } - const std::vector<GeoLib::Point*>* surfacePoints = (*_surfaces)[0]->getPointVec(); + const std::vector<GeoLib::Point*>* surfacePoints = + (*_surfaces)[0]->getPointVec(); std::size_t nPoints = surfacePoints->size(); - vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); + vtkSmartPointer<vtkInformation> outInfo = + outputVector->GetInformationObject(0); vtkSmartPointer<vtkPolyData> output = - vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0) { @@ -84,8 +88,9 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New(); newPoints->SetNumberOfPoints(nPoints); - vtkSmartPointer<vtkCellArray> newPolygons = vtkSmartPointer<vtkCellArray>::New(); - //newPolygons->Allocate(nSurfaces); + vtkSmartPointer<vtkCellArray> newPolygons = + vtkSmartPointer<vtkCellArray>::New(); + // newPolygons->Allocate(nSurfaces); vtkSmartPointer<vtkIntArray> sfcIDs = vtkSmartPointer<vtkIntArray>::New(); sfcIDs->SetNumberOfComponents(1); @@ -93,7 +98,8 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, for (std::size_t i = 0; i < nPoints; ++i) { - const double* coords = const_cast<double*>((*surfacePoints)[i]->getCoords()); + const double* coords = + const_cast<double*>((*surfacePoints)[i]->getCoords()); newPoints->SetPoint(i, coords); } @@ -122,22 +128,23 @@ int VtkSurfacesSource::RequestData( vtkInformation* request, output->SetPoints(newPoints); output->SetPolys(newPolygons); output->GetCellData()->AddArray(sfcIDs); - output->GetCellData()->SetActiveAttribute("SurfaceIDs", vtkDataSetAttributes::SCALARS); + output->GetCellData()->SetActiveAttribute("SurfaceIDs", + vtkDataSetAttributes::SCALARS); output->Squeeze(); return 1; } -int VtkSurfacesSource::RequestInformation( vtkInformation* /*request*/, - vtkInformationVector** /*inputVector*/, - vtkInformationVector* /*outputVector*/ ) +int VtkSurfacesSource::RequestInformation( + vtkInformation* /*request*/, + vtkInformationVector** /*inputVector*/, + vtkInformationVector* /*outputVector*/) { return 1; } -void VtkSurfacesSource::SetUserProperty( QString name, QVariant value ) +void VtkSurfacesSource::SetUserProperty(QString name, QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); (*_algorithmUserProperties)[name] = value; } - diff --git a/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp b/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp index 2bfeac1ec84..319494010d9 100644 --- a/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp +++ b/Applications/DataExplorer/VtkVis/VtkTextureOnSurfaceFilter.cpp @@ -15,21 +15,20 @@ // ** INCLUDES ** #include "VtkTextureOnSurfaceFilter.h" -#include "BaseLib/Logging.h" - #include <vtkCellData.h> #include <vtkFloatArray.h> +#include <vtkImageAlgorithm.h> +#include <vtkImageShiftScale.h> #include <vtkInformation.h> #include <vtkInformationVector.h> #include <vtkObjectFactory.h> #include <vtkPointData.h> +#include <vtkProperty.h> #include <vtkSmartPointer.h> #include <vtkStreamingDemandDrivenPipeline.h> -#include <vtkImageShiftScale.h> -#include <vtkImageAlgorithm.h> -#include <vtkProperty.h> #include <vtkTexture.h> +#include "BaseLib/Logging.h" #include "MathTools.h" #include "VtkVisHelper.h" @@ -38,14 +37,14 @@ vtkStandardNewMacro(VtkTextureOnSurfaceFilter); VtkTextureOnSurfaceFilter::VtkTextureOnSurfaceFilter() = default; VtkTextureOnSurfaceFilter::~VtkTextureOnSurfaceFilter() = default; -void VtkTextureOnSurfaceFilter::PrintSelf( ostream& os, vtkIndent indent ) +void VtkTextureOnSurfaceFilter::PrintSelf(ostream& os, vtkIndent indent) { - this->Superclass::PrintSelf(os,indent); + this->Superclass::PrintSelf(os, indent); } -int VtkTextureOnSurfaceFilter::RequestData( vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector ) +int VtkTextureOnSurfaceFilter::RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { (void)request; @@ -56,7 +55,8 @@ int VtkTextureOnSurfaceFilter::RequestData( vtkInformation* request, } vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); - vtkPolyData* input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* input = + vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); int dims[3]; this->GetTexture()->GetInput()->GetDimensions(dims); @@ -69,42 +69,43 @@ int VtkTextureOnSurfaceFilter::RequestData( vtkInformation* request, static_cast<int>(_origin.first + (imgWidth * _scalingFactor)), static_cast<int>(_origin.second + (imgHeight * _scalingFactor))); - //calculate texture coordinates + // calculate texture coordinates vtkPoints* points = input->GetPoints(); - vtkSmartPointer<vtkFloatArray> textureCoordinates = vtkSmartPointer<vtkFloatArray>::New(); + vtkSmartPointer<vtkFloatArray> textureCoordinates = + vtkSmartPointer<vtkFloatArray>::New(); textureCoordinates->SetNumberOfComponents(2); std::size_t nPoints = points->GetNumberOfPoints(); textureCoordinates->SetNumberOfTuples(nPoints); textureCoordinates->SetName("textureCoords"); -/* // adaptation for netcdf-curtain for TERENO Demo - double dist(0.0); - for (std::size_t i = 0; i < nPoints; i++) - { - double coords[3]; - if ((i==0) || (i==173)) - { - if (i==0) dist=0; - } - else + /* // adaptation for netcdf-curtain for TERENO Demo + double dist(0.0); + for (std::size_t i = 0; i < nPoints; i++) { - points->GetPoint(i-1, coords); - GeoLib::Point* pnt = new GeoLib::Point(coords); - points->GetPoint(i, coords); - GeoLib::Point* pnt2 = new GeoLib::Point(coords); - if (i<173) - dist += std::sqrt(MathLib::sqrDist(pnt, pnt2)); + double coords[3]; + if ((i==0) || (i==173)) + { + if (i==0) dist=0; + } else - dist -= std::sqrt(MathLib::sqrDist(pnt, pnt2)); + { + points->GetPoint(i-1, coords); + GeoLib::Point* pnt = new GeoLib::Point(coords); + points->GetPoint(i, coords); + GeoLib::Point* pnt2 = new GeoLib::Point(coords); + if (i<173) + dist += std::sqrt(MathLib::sqrDist(pnt, pnt2)); + else + dist -= std::sqrt(MathLib::sqrDist(pnt, pnt2)); + } + points->GetPoint(i, coords); + double x = MathLib::normalize(0, 8404, dist); + double z = MathLib::normalize(-79.5, 1.5, coords[2]); + float newcoords[2] = {x, z}; + textureCoordinates->InsertNextTuple(newcoords); } - points->GetPoint(i, coords); - double x = MathLib::normalize(0, 8404, dist); - double z = MathLib::normalize(-79.5, 1.5, coords[2]); - float newcoords[2] = {x, z}; - textureCoordinates->InsertNextTuple(newcoords); - } -*/ + */ - int const range[2] = { max.first - min.first, max.second - min.second }; + int const range[2] = {max.first - min.first, max.second - min.second}; // Scale values relative to the range. double coords[3]; @@ -113,13 +114,14 @@ int VtkTextureOnSurfaceFilter::RequestData( vtkInformation* request, points->GetPoint(i, coords); textureCoordinates->SetTuple2(i, - (coords[0] - min.first) / range[0], - (coords[1] - min.second) / range[1]); + (coords[0] - min.first) / range[0], + (coords[1] - min.second) / range[1]); } // put it all together vtkInformation* outInfo = outputVector->GetInformationObject(0); - vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData* output = + vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); output->CopyStructure(input); output->GetPointData()->PassData(input->GetPointData()); output->GetCellData()->PassData(input->GetCellData()); @@ -134,11 +136,13 @@ void VtkTextureOnSurfaceFilter::SetRaster(vtkImageAlgorithm* img) double range[2]; img->Update(); img->GetOutput()->GetPointData()->GetScalars()->GetRange(range); - vtkSmartPointer<vtkImageShiftScale> scale = vtkSmartPointer<vtkImageShiftScale>::New(); + vtkSmartPointer<vtkImageShiftScale> scale = + vtkSmartPointer<vtkImageShiftScale>::New(); scale->SetInputConnection(img->GetOutputPort()); scale->SetShift(-range[0]); - scale->SetScale(255.0/(range[1]-range[0])); - scale->SetOutputScalarTypeToUnsignedChar(); // Comment this out to get colored grayscale textures + scale->SetScale(255.0 / (range[1] - range[0])); + scale->SetOutputScalarTypeToUnsignedChar(); // Comment this out to get + // colored grayscale textures scale->Update(); vtkTexture* texture = vtkTexture::New(); @@ -153,7 +157,7 @@ void VtkTextureOnSurfaceFilter::SetRaster(vtkImageAlgorithm* img) _scalingFactor = img->GetOutput()->GetSpacing()[0]; } -void VtkTextureOnSurfaceFilter::SetUserProperty( QString name, QVariant value ) +void VtkTextureOnSurfaceFilter::SetUserProperty(QString name, QVariant value) { VtkAlgorithmProperties::SetUserProperty(name, value); } diff --git a/Applications/DataExplorer/VtkVis/VtkVisHelper.cpp b/Applications/DataExplorer/VtkVis/VtkVisHelper.cpp index 439ce320a53..1b2ad5c43c7 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisHelper.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisHelper.cpp @@ -23,23 +23,23 @@ #include <QImage> -vtkImageData* VtkVisHelper::QImageToVtkImageData(QImage &img) +vtkImageData* VtkVisHelper::QImageToVtkImageData(QImage& img) { std::size_t imgWidth = img.width(); std::size_t imgHeight = img.height(); - vtkSmartPointer<vtkUnsignedCharArray> data = vtkSmartPointer<vtkUnsignedCharArray>::New(); + vtkSmartPointer<vtkUnsignedCharArray> data = + vtkSmartPointer<vtkUnsignedCharArray>::New(); data->SetNumberOfComponents(3); - data->SetNumberOfTuples( imgWidth * imgHeight ); + data->SetNumberOfTuples(imgWidth * imgHeight); for (std::size_t j = 0; j < imgHeight; j++) { for (std::size_t i = 0; i < imgWidth; i++) { - QRgb pix = img.pixel(i,j); - const float color[3] = { static_cast<float>(qRed(pix)), - static_cast<float>(qGreen(pix)), - static_cast<float>(qBlue(pix)) - }; + QRgb pix = img.pixel(i, j); + const float color[3] = {static_cast<float>(qRed(pix)), + static_cast<float>(qGreen(pix)), + static_cast<float>(qBlue(pix))}; data->SetTuple(j * imgWidth + i, color); } } @@ -53,15 +53,15 @@ vtkImageData* VtkVisHelper::QImageToVtkImageData(QImage &img) return imgData; } -vtkTexture* VtkVisHelper::QImageToVtkTexture(QImage &img) +vtkTexture* VtkVisHelper::QImageToVtkTexture(QImage& img) { vtkSmartPointer<vtkImageData> imgData = QImageToVtkImageData(img); vtkTexture* texture = vtkTexture::New(); texture->InterpolateOff(); texture->RepeatOff(); - //texture->EdgeClampOff(); - //texture->SetBlendingMode(0); + // texture->EdgeClampOff(); + // texture->SetBlendingMode(0); texture->SetInputData(imgData); return texture; diff --git a/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp index 7277870213d..ff01e097d69 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisImageItem.cpp @@ -15,23 +15,21 @@ // ** INCLUDES ** #include "VtkVisImageItem.h" -#include "BaseLib/Logging.h" - -#include "BaseLib/FileTools.h" - -#include "VtkAlgorithmProperties.h" -#include "VtkGeoImageSource.h" - #include <vtkActor.h> +#include <vtkDataArray.h> #include <vtkDataSetMapper.h> #include <vtkImageAlgorithm.h> #include <vtkImageChangeInformation.h> #include <vtkImageData.h> +#include <vtkImageShiftScale.h> #include <vtkPointData.h> #include <vtkRenderer.h> #include <vtkSmartPointer.h> -#include <vtkImageShiftScale.h> -#include <vtkDataArray.h> + +#include "BaseLib/FileTools.h" +#include "BaseLib/Logging.h" +#include "VtkAlgorithmProperties.h" +#include "VtkGeoImageSource.h" // export #include <vtkImageActor.h> @@ -151,14 +149,15 @@ void VtkVisImageItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) (void)vtkProps; } -int VtkVisImageItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const +int VtkVisImageItem::callVTKWriter(vtkAlgorithm* algorithm, + const std::string& filename) const { std::string file_name_cpy(filename); auto* algID = dynamic_cast<vtkImageAlgorithm*>(algorithm); if (algID) { vtkSmartPointer<vtkXMLImageDataWriter> iWriter = - vtkSmartPointer<vtkXMLImageDataWriter>::New(); + vtkSmartPointer<vtkXMLImageDataWriter>::New(); iWriter->SetInputData(algID->GetOutputDataObject(0)); if (BaseLib::getFileExtension(filename) != ".vti") { @@ -173,7 +172,7 @@ int VtkVisImageItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string &f void VtkVisImageItem::setTranslation(double x, double y, double z) const { - _transformFilter->SetOriginTranslation(x,y,z); + _transformFilter->SetOriginTranslation(x, y, z); } vtkAlgorithm* VtkVisImageItem::transformFilter() const diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp index afce826c140..adc45ead081 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp @@ -17,10 +17,13 @@ #include <vtkAlgorithm.h> #include <vtkCamera.h> +#include <vtkCellData.h> +#include <vtkFieldData.h> #include <vtkGenericDataObjectReader.h> #include <vtkImageActor.h> #include <vtkImageReader2.h> #include <vtkLight.h> +#include <vtkPointData.h> #include <vtkPointSet.h> #include <vtkProp3D.h> #include <vtkRenderer.h> @@ -32,10 +35,6 @@ #include <vtkXMLStructuredGridReader.h> #include <vtkXMLUnstructuredGridReader.h> -#include <vtkCellData.h> -#include <vtkFieldData.h> -#include <vtkPointData.h> - #include <QColor> #ifndef NDEBUG #include <QElapsedTimer> @@ -45,13 +44,11 @@ #include <QString> #include "BaseLib/Logging.h" - +#include "GeoTreeModel.h" #include "MathLib/InterpolationAlgorithms/LinearIntervalInterpolation.h" +#include "MeshItem.h" #include "MeshLib/Mesh.h" #include "MeshLib/Vtk/VtkMappedMeshSource.h" - -#include "GeoTreeModel.h" -#include "MeshItem.h" #include "MeshModel.h" #include "StationTreeModel.h" #include "TreeModel.h" @@ -68,7 +65,8 @@ VtkVisPipeline::VtkVisPipeline(vtkRenderer* renderer, QObject* parent /*= 0*/) : TreeModel(parent), _renderer(renderer) { QList<QVariant> rootData; - rootData << "Object name" << "Visible"; + rootData << "Object name" + << "Visible"; delete _rootItem; _rootItem = new TreeItem(rootData, nullptr); @@ -79,18 +77,19 @@ VtkVisPipeline::VtkVisPipeline(vtkRenderer* renderer, QObject* parent /*= 0*/) this->setBGColor(backgroundColorVariant.value<QColor>()); } - _resetCameraOnAddOrRemove = settings.value("resetViewOnLoad", true).toBool(); + _resetCameraOnAddOrRemove = + settings.value("resetViewOnLoad", true).toBool(); } -bool VtkVisPipeline::setData( const QModelIndex &index, const QVariant &value, - int role /* = Qt::EditRole */ ) +bool VtkVisPipeline::setData(const QModelIndex& index, const QVariant& value, + int role /* = Qt::EditRole */) { emit vtkVisPipelineChanged(); return TreeModel::setData(index, value, role); } -void VtkVisPipeline::addLight(const GeoLib::Point &pos) +void VtkVisPipeline::addLight(const GeoLib::Point& pos) { double lightPos[3]; for (auto& light : _lights) @@ -108,7 +107,7 @@ void VtkVisPipeline::addLight(const GeoLib::Point &pos) _lights.push_back(l); } -vtkLight* VtkVisPipeline::getLight(const GeoLib::Point &pos) const +vtkLight* VtkVisPipeline::getLight(const GeoLib::Point& pos) const { double lightPos[3]; for (auto light : _lights) @@ -123,13 +122,14 @@ vtkLight* VtkVisPipeline::getLight(const GeoLib::Point &pos) const return nullptr; } -void VtkVisPipeline::removeLight(const GeoLib::Point &pos) +void VtkVisPipeline::removeLight(const GeoLib::Point& pos) { double lightPos[3]; for (auto it = _lights.begin(); it != _lights.end(); ++it) { (*it)->GetPosition(lightPos); - if (pos[0] == lightPos[0] && pos[1] == lightPos[1] && pos[2] == lightPos[2]) + if (pos[0] == lightPos[0] && pos[1] == lightPos[1] && + pos[2] == lightPos[2]) { _renderer->RemoveLight(*it); (*it)->Delete(); @@ -148,19 +148,19 @@ QColor VtkVisPipeline::getBGColor() const return c; } -void VtkVisPipeline::setBGColor(const QColor &color) +void VtkVisPipeline::setBGColor(const QColor& color) { QSettings settings; settings.setValue("VtkBackgroundColor", color); _renderer->SetBackground(color.redF(), color.greenF(), color.blueF()); } -QModelIndex VtkVisPipeline::getIndex( vtkProp3D* actor ) +QModelIndex VtkVisPipeline::getIndex(vtkProp3D* actor) { return _actorMap.value(actor, QModelIndex()); } -Qt::ItemFlags VtkVisPipeline::flags( const QModelIndex &index ) const +Qt::ItemFlags VtkVisPipeline::flags(const QModelIndex& index) const { Qt::ItemFlags defaultFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; @@ -169,7 +169,7 @@ Qt::ItemFlags VtkVisPipeline::flags( const QModelIndex &index ) const return Qt::ItemIsEnabled; } - //if (index.column() == 1) + // if (index.column() == 1) // defaultFlags |= Qt::ItemIsEditable; return defaultFlags; @@ -209,12 +209,13 @@ void VtkVisPipeline::loadFromFile(QString filename) else if (filename.endsWith("vtk")) { vtkGenericDataObjectReader* oldStyleReader = - vtkGenericDataObjectReader::New(); + vtkGenericDataObjectReader::New(); oldStyleReader->SetFileName(filename.toStdString().c_str()); oldStyleReader->ReadAllFieldsOn(); oldStyleReader->ReadAllScalarsOn(); oldStyleReader->Update(); - vtkDataSet* dataSet = vtkDataSet::SafeDownCast(oldStyleReader->GetOutput()); + vtkDataSet* dataSet = + vtkDataSet::SafeDownCast(oldStyleReader->GetOutput()); if (dataSet) { this->listArrays(dataSet); @@ -230,10 +231,12 @@ void VtkVisPipeline::loadFromFile(QString filename) } reader->SetFileName(filename.toStdString().c_str()); - // TODO: insert ReadAllScalarsOn()-equivalent for xml-file-reader here, otherwise arrays are not available in GUI! + // TODO: insert ReadAllScalarsOn()-equivalent for xml-file-reader here, + // otherwise arrays are not available in GUI! reader->Update(); - //std::cout << "#cell scalars: " << reader->GetNumberOfCellArrays() << std::endl; - //std::cout << "#point scalars: " << reader->GetNumberOfPointArrays() << std::endl; + // std::cout << "#cell scalars: " << reader->GetNumberOfCellArrays() << + // std::endl; std::cout << "#point scalars: " << + // reader->GetNumberOfPointArrays() << std::endl; vtkSmartPointer<vtkDataSet> dataSet = reader->GetOutputAsDataSet(); if (dataSet) @@ -281,23 +284,25 @@ void VtkVisPipeline::setGlobalBackfaceCulling(bool enable) const } void VtkVisPipeline::addPipelineItem(GeoTreeModel* model, - const std::string &name, + const std::string& name, GeoLib::GEOTYPE type) { addPipelineItem(model->vtkSource(name, type)); } -void VtkVisPipeline::addPipelineItem(StationTreeModel* model, const std::string &name) +void VtkVisPipeline::addPipelineItem(StationTreeModel* model, + const std::string& name) { addPipelineItem(model->vtkSource(name)); } -void VtkVisPipeline::addPipelineItem(MeshModel* model, const QModelIndex &idx) +void VtkVisPipeline::addPipelineItem(MeshModel* model, const QModelIndex& idx) { addPipelineItem(static_cast<MeshItem*>(model->getItem(idx))->vtkSource()); } -QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, const QModelIndex &parent) +QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, + const QModelIndex& parent) { beginResetModel(); @@ -305,7 +310,7 @@ QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, const QMod TreeItem* parentItem = item->parentItem(); parentItem->appendChild(item); - if (!parent.isValid()) // Set global superelevation on source objects + if (!parent.isValid()) // Set global superelevation on source objects { QSettings settings; if (dynamic_cast<vtkImageAlgorithm*>(item->algorithm()) == nullptr) @@ -338,11 +343,12 @@ QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, const QMod return newIndex; } -QModelIndex VtkVisPipeline::addPipelineItem( vtkAlgorithm* source, QModelIndex parent /* = QModelindex() */) +QModelIndex VtkVisPipeline::addPipelineItem( + vtkAlgorithm* source, QModelIndex parent /* = QModelindex() */) { std::string itemName; - if (!parent.isValid()) // if source object + if (!parent.isValid()) // if source object { auto* old_reader = dynamic_cast<vtkGenericDataObjectReader*>(source); auto* new_reader = dynamic_cast<vtkXMLReader*>(source); @@ -392,12 +398,13 @@ QModelIndex VtkVisPipeline::addPipelineItem( vtkAlgorithm* source, QModelIndex p } void VtkVisPipeline::removeSourceItem(GeoTreeModel* model, - const std::string &name, + const std::string& name, GeoLib::GEOTYPE type) { for (int i = 0; i < _rootItem->childCount(); i++) { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); + VtkVisPipelineItem* item = + static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); if (item->algorithm() == model->vtkSource(name, type)) { removePipelineItem(index(i, 0)); @@ -406,11 +413,13 @@ void VtkVisPipeline::removeSourceItem(GeoTreeModel* model, } } -void VtkVisPipeline::removeSourceItem(StationTreeModel* model, const std::string &name) +void VtkVisPipeline::removeSourceItem(StationTreeModel* model, + const std::string& name) { for (int i = 0; i < _rootItem->childCount(); i++) { - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); + VtkVisPipelineItem* item = + static_cast<VtkVisPipelineItem*>(getItem(index(i, 0))); if (item->algorithm() == model->vtkSource(name)) { removePipelineItem(index(i, 0)); @@ -419,7 +428,7 @@ void VtkVisPipeline::removeSourceItem(StationTreeModel* model, const std::string } } -void VtkVisPipeline::removeSourceItem(MeshModel* model, const QModelIndex &idx) +void VtkVisPipeline::removeSourceItem(MeshModel* model, const QModelIndex& idx) { auto* sItem = static_cast<MeshItem*>(model->getItem(idx)); @@ -435,7 +444,7 @@ void VtkVisPipeline::removeSourceItem(MeshModel* model, const QModelIndex &idx) } } -void VtkVisPipeline::removePipelineItem( QModelIndex index ) +void VtkVisPipeline::removePipelineItem(QModelIndex index) { if (!index.isValid()) { @@ -454,7 +463,7 @@ void VtkVisPipeline::removePipelineItem( QModelIndex index ) ++it; } - //TreeItem* item = getItem(index); + // TreeItem* item = getItem(index); removeRows(index.row(), 1, index.parent()); if (_resetCameraOnAddOrRemove) @@ -483,8 +492,8 @@ void VtkVisPipeline::listArrays(vtkDataSet* dataSet) } void VtkVisPipeline::showMeshElementQuality( - MeshLib::VtkMappedMeshSource* source, - MeshLib::MeshQualityType t, std::vector<double> const& quality) + MeshLib::VtkMappedMeshSource* source, MeshLib::MeshQualityType t, + std::vector<double> const& quality) { if (!source || quality.empty()) { @@ -516,14 +525,17 @@ void VtkVisPipeline::showMeshElementQuality( static_cast<VtkCompositeElementSelectionFilter*>(filter)->setRange( *range.first, *range.second); } - static_cast<VtkCompositeElementSelectionFilter*>(filter)->setSelectionArray("Selection", quality); - VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData); + static_cast<VtkCompositeElementSelectionFilter*>(filter) + ->setSelectionArray("Selection", quality); + VtkVisPointSetItem* item = + new VtkVisPointSetItem(filter, parentItem, itemData); this->addPipelineItem(item, this->createIndex(i, 0, item)); break; } } -void VtkVisPipeline::highlightGeoObject(const vtkPolyDataAlgorithm* source, int index) +void VtkVisPipeline::highlightGeoObject(const vtkPolyDataAlgorithm* source, + int index) { this->removeHighlightedGeoObject(); int nSources = this->_rootItem->childCount(); @@ -560,7 +572,9 @@ void VtkVisPipeline::removeHighlightedGeoObject() } } -void VtkVisPipeline::highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const source, unsigned index, bool is_element) +void VtkVisPipeline::highlightMeshComponent( + vtkUnstructuredGridAlgorithm const* const source, unsigned index, + bool is_element) { int nSources = this->_rootItem->childCount(); for (int i = 0; i < nSources; i++) diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp index ff1754466e1..5989710ba9b 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineItem.cpp @@ -13,27 +13,28 @@ */ // ** INCLUDES ** -#include "FileTools.h" -#include "VtkAlgorithmProperties.h" #include "VtkVisPipelineItem.h" -#include "VtkCompositeFilter.h" -#include "QVtkDataSetMapper.h" #include <vtkActor.h> #include <vtkAlgorithm.h> +#include <vtkCellData.h> #include <vtkDataSetMapper.h> +#include <vtkGenericDataObjectWriter.h> +#include <vtkImageActor.h> +#include <vtkPointData.h> #include <vtkPointSet.h> #include <vtkProperty.h> #include <vtkRenderer.h> #include <vtkSmartPointer.h> #include <vtkTextureMapToPlane.h> -#include <vtkGenericDataObjectWriter.h> -#include <vtkCellData.h> -#include <vtkPointData.h> -#include <vtkImageActor.h> #include <QMessageBox> +#include "FileTools.h" +#include "QVtkDataSetMapper.h" +#include "VtkAlgorithmProperties.h" +#include "VtkCompositeFilter.h" + VtkVisPipelineItem::VtkVisPipelineItem( vtkAlgorithm* algorithm, TreeItem* parentItem, const QList<QVariant> data /*= QList<QVariant>()*/) @@ -71,7 +72,7 @@ VtkVisPipelineItem::~VtkVisPipelineItem() delete _compositeFilter; } -VtkVisPipelineItem* VtkVisPipelineItem::child( int row ) const +VtkVisPipelineItem* VtkVisPipelineItem::child(int row) const { TreeItem* treeItem = TreeItem::child(row); if (treeItem) @@ -82,7 +83,7 @@ VtkVisPipelineItem* VtkVisPipelineItem::child( int row ) const return nullptr; } -QVariant VtkVisPipelineItem::data( int column ) const +QVariant VtkVisPipelineItem::data(int column) const { if (column == 1) { @@ -92,7 +93,7 @@ QVariant VtkVisPipelineItem::data( int column ) const return TreeItem::data(column); } -bool VtkVisPipelineItem::setData( int column, const QVariant &value ) +bool VtkVisPipelineItem::setData(int column, const QVariant& value) { if (column == 1) { @@ -107,14 +108,14 @@ bool VtkVisPipelineItem::isVisible() const return static_cast<bool>(_actor->GetVisibility()); } -void VtkVisPipelineItem::setVisible( bool visible ) +void VtkVisPipelineItem::setVisible(bool visible) { _actor->SetVisibility(static_cast<int>(visible)); _actor->Modified(); _renderer->Render(); } -int VtkVisPipelineItem::writeToFile(const std::string &filename) const +int VtkVisPipelineItem::writeToFile(const std::string& filename) const { if (!filename.empty()) { @@ -123,7 +124,8 @@ int VtkVisPipelineItem::writeToFile(const std::string &filename) const return 0; } -int VtkVisPipelineItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const +int VtkVisPipelineItem::callVTKWriter(vtkAlgorithm* algorithm, + const std::string& filename) const { // needs to be implemented in derived classes! (void)algorithm; @@ -176,24 +178,31 @@ void VtkVisPipelineItem::setBackfaceCullingOnChildren(bool enable) const QStringList VtkVisPipelineItem::getScalarArrayNames() const { this->algorithm()->Update(); - vtkDataSet* dataSet = vtkDataSet::SafeDownCast(this->algorithm()->GetOutputDataObject(0)); + vtkDataSet* dataSet = + vtkDataSet::SafeDownCast(this->algorithm()->GetOutputDataObject(0)); QStringList dataSetAttributesList; if (dataSet) { vtkPointData* pointData = dataSet->GetPointData(); - //std::cout << " #point data arrays: " << pointData->GetNumberOfArrays() << std::endl; + // std::cout << " #point data arrays: " << + // pointData->GetNumberOfArrays() << std::endl; for (int i = 0; i < pointData->GetNumberOfArrays(); i++) { - // std::cout << " Name: " << pointData->GetArrayName(i) << std::endl; - dataSetAttributesList.push_back(QString("P-") + pointData->GetArrayName(i)); + // std::cout << " Name: " << pointData->GetArrayName(i) << + // std::endl; + dataSetAttributesList.push_back(QString("P-") + + pointData->GetArrayName(i)); } vtkCellData* cellData = dataSet->GetCellData(); - //std::cout << " #cell data arrays: " << cellData->GetNumberOfArrays() << std::endl; + // std::cout << " #cell data arrays: " << cellData->GetNumberOfArrays() + // << std::endl; for (int i = 0; i < cellData->GetNumberOfArrays(); i++) { - // std::cout << " Name: " << cellData->GetArrayName(i) << std::endl; - dataSetAttributesList.push_back(QString("C-") + cellData->GetArrayName(i)); + // std::cout << " Name: " << cellData->GetArrayName(i) << + // std::endl; + dataSetAttributesList.push_back(QString("C-") + + cellData->GetArrayName(i)); } } return dataSetAttributesList; diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp index 06ab02ec9fc..ba59fee94b5 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipelineView.cpp @@ -15,17 +15,6 @@ // ** INCLUDES ** #include "VtkVisPipelineView.h" -#include "Mesh.h" -#include "MeshGenerators/RasterToMesh.h" -#include "MeshGenerators/VtkMeshConverter.h" - -#include "OGSError.h" - -#include "CheckboxDelegate.h" -#include "VtkVisPipeline.h" -#include "VtkVisPipelineItem.h" -#include "VtkVisPointSetItem.h" - #include <vtkDataSetMapper.h> #include <vtkProp3D.h> @@ -34,23 +23,32 @@ #include <QFileDialog> #include <QHeaderView> #include <QMenu> -#include <QSettings> #include <QMessageBox> +#include <QSettings> -//image to mesh conversion -#include "VtkGeoImageSource.h" -#include <vtkImageData.h> -#include "MeshFromRasterDialog.h" +#include "CheckboxDelegate.h" +#include "Mesh.h" +#include "MeshGenerators/RasterToMesh.h" +#include "MeshGenerators/VtkMeshConverter.h" +#include "OGSError.h" +#include "VtkVisPipeline.h" +#include "VtkVisPipelineItem.h" +#include "VtkVisPointSetItem.h" + +// image to mesh conversion #include <vtkDataObject.h> -#include <vtkSmartPointer.h> #include <vtkGenericDataObjectReader.h> +#include <vtkImageData.h> +#include <vtkSmartPointer.h> #include <vtkTransformFilter.h> #include <vtkUnstructuredGrid.h> #include <vtkUnstructuredGridAlgorithm.h> #include <vtkXMLUnstructuredGridReader.h> +#include "MeshFromRasterDialog.h" +#include "VtkGeoImageSource.h" -VtkVisPipelineView::VtkVisPipelineView( QWidget* parent /*= 0*/ ) +VtkVisPipelineView::VtkVisPipelineView(QWidget* parent /*= 0*/) : QTreeView(parent) { this->setItemsExpandable(false); @@ -69,15 +67,17 @@ void VtkVisPipelineView::setModel(QAbstractItemModel* model) this->header()->moveSection(1, 0); } -void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) +void VtkVisPipelineView::contextMenuEvent(QContextMenuEvent* event) { QModelIndex index = selectionModel()->currentIndex(); if (index.isValid()) { // check object type - VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>(static_cast<VtkVisPipeline*>( - this->model())->getItem(this->selectionModel()->currentIndex())); - int objectType = item->algorithm()->GetOutputDataObject(0)->GetDataObjectType(); + VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>( + static_cast<VtkVisPipeline*>(this->model()) + ->getItem(this->selectionModel()->currentIndex())); + int objectType = + item->algorithm()->GetOutputDataObject(0)->GetDataObjectType(); VtkAlgorithmProperties* vtkProps = item->getVtkProperties(); bool isSourceItem = !(this->selectionModel()->currentIndex().parent().isValid()); @@ -87,7 +87,8 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) if (objectType == VTK_IMAGE_DATA) { - // this exception is needed as image object are only displayed in the vis-pipeline + // this exception is needed as image object are only displayed in + // the vis-pipeline isSourceItem = false; QAction* addMeshingAction = menu.addAction("Convert Image to Mesh..."); @@ -97,7 +98,8 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) else { QAction* addLUTAction = menu.addAction("Add color table..."); - connect(addLUTAction, SIGNAL(triggered()), this, SLOT(addColorTable())); + connect(addLUTAction, SIGNAL(triggered()), this, + SLOT(addColorTable())); } if (objectType == VTK_UNSTRUCTURED_GRID) @@ -118,7 +120,8 @@ void VtkVisPipelineView::contextMenuEvent( QContextMenuEvent* event ) SLOT(removeSelectedPipelineItem())); } - connect(addFilterAction, SIGNAL(triggered()), this, SLOT(addPipelineFilterItem())); + connect(addFilterAction, SIGNAL(triggered()), this, + SLOT(addPipelineFilterItem())); connect(exportVtkAction, SIGNAL(triggered()), this, SLOT(exportSelectedPipelineItemAsVtk())); @@ -130,13 +133,15 @@ void VtkVisPipelineView::exportSelectedPipelineItemAsVtk() { QSettings settings; QModelIndex idx = this->selectionModel()->currentIndex(); - QString filename = QFileDialog::getSaveFileName(this, "Export object to vtk-file", - settings.value("lastExportedFileDirectory").toString(), - "VTK file (*.*)"); + QString filename = QFileDialog::getSaveFileName( + this, "Export object to vtk-file", + settings.value("lastExportedFileDirectory").toString(), + "VTK file (*.*)"); if (!filename.isEmpty()) { - static_cast<VtkVisPipelineItem*>(static_cast<VtkVisPipeline*>(this->model())-> - getItem(idx))->writeToFile(filename.toStdString()); + static_cast<VtkVisPipelineItem*>( + static_cast<VtkVisPipeline*>(this->model())->getItem(idx)) + ->writeToFile(filename.toStdString()); QDir dir = QDir(filename); settings.setValue("lastExportedFileDirectory", dir.absolutePath()); } @@ -161,10 +166,13 @@ void VtkVisPipelineView::showImageToMeshConversionDialog() } vtkSmartPointer<vtkAlgorithm> algorithm = - static_cast<VtkVisPipelineItem*>(static_cast<VtkVisPipeline*>(this->model())-> - getItem(this->selectionModel()->currentIndex()))->algorithm(); + static_cast<VtkVisPipelineItem*>( + static_cast<VtkVisPipeline*>(this->model()) + ->getItem(this->selectionModel()->currentIndex())) + ->algorithm(); - vtkSmartPointer<VtkGeoImageSource> imageSource = VtkGeoImageSource::SafeDownCast(algorithm); + vtkSmartPointer<VtkGeoImageSource> imageSource = + VtkGeoImageSource::SafeDownCast(algorithm); double origin[3]; imageSource->GetOutput()->GetOrigin(origin); double spacing[3]; @@ -187,11 +195,13 @@ void VtkVisPipelineView::showImageToMeshConversionDialog() void VtkVisPipelineView::convertVTKToOGSMesh() { VtkVisPipelineItem* item = static_cast<VtkVisPipelineItem*>( - static_cast<VtkVisPipeline*>(this->model())->getItem(this->selectionModel()->currentIndex())); + static_cast<VtkVisPipeline*>(this->model()) + ->getItem(this->selectionModel()->currentIndex())); vtkSmartPointer<vtkAlgorithm> algorithm = item->algorithm(); vtkUnstructuredGrid* grid(nullptr); - vtkUnstructuredGridAlgorithm* ugAlg = vtkUnstructuredGridAlgorithm::SafeDownCast(algorithm); + vtkUnstructuredGridAlgorithm* ugAlg = + vtkUnstructuredGridAlgorithm::SafeDownCast(algorithm); if (ugAlg) { grid = ugAlg->GetOutput(); @@ -199,7 +209,8 @@ void VtkVisPipelineView::convertVTKToOGSMesh() else { // for old filetypes - vtkGenericDataObjectReader* dataReader = vtkGenericDataObjectReader::SafeDownCast(algorithm); + vtkGenericDataObjectReader* dataReader = + vtkGenericDataObjectReader::SafeDownCast(algorithm); if (dataReader) { grid = vtkUnstructuredGrid::SafeDownCast(dataReader->GetOutput()); @@ -207,17 +218,19 @@ void VtkVisPipelineView::convertVTKToOGSMesh() else { // for new filetypes - vtkXMLUnstructuredGridReader* xmlReader = vtkXMLUnstructuredGridReader::SafeDownCast(algorithm); + vtkXMLUnstructuredGridReader* xmlReader = + vtkXMLUnstructuredGridReader::SafeDownCast(algorithm); grid = vtkUnstructuredGrid::SafeDownCast(xmlReader->GetOutput()); } } - MeshLib::Mesh* mesh = MeshLib::VtkMeshConverter::convertUnstructuredGrid(grid); + MeshLib::Mesh* mesh = + MeshLib::VtkMeshConverter::convertUnstructuredGrid(grid); mesh->setName(item->data(0).toString().toStdString()); emit meshAdded(mesh); } -void VtkVisPipelineView::selectionChanged( const QItemSelection &selected, - const QItemSelection &deselected ) +void VtkVisPipelineView::selectionChanged(const QItemSelection& selected, + const QItemSelection& deselected) { QTreeView::selectionChanged(selected, deselected); @@ -248,10 +261,11 @@ void VtkVisPipelineView::selectionChanged( const QItemSelection &selected, void VtkVisPipelineView::selectItem(vtkProp3D* actor) { - this->selectItem(static_cast<VtkVisPipeline*>(this->model())->getIndex(actor)); + this->selectItem( + static_cast<VtkVisPipeline*>(this->model())->getIndex(actor)); } -void VtkVisPipelineView::selectItem(const QModelIndex &index) +void VtkVisPipelineView::selectItem(const QModelIndex& index) { if (!index.isValid()) { @@ -265,15 +279,16 @@ void VtkVisPipelineView::selectItem(const QModelIndex &index) void VtkVisPipelineView::addColorTable() { - VtkVisPipelineItem* item ( - static_cast<VtkVisPipelineItem*>(static_cast<VtkVisPipeline*>(this->model())-> - getItem(this->selectionModel()->currentIndex())) ); + VtkVisPipelineItem* item(static_cast<VtkVisPipelineItem*>( + static_cast<VtkVisPipeline*>(this->model()) + ->getItem(this->selectionModel()->currentIndex()))); const QString array_name = item->GetActiveAttribute(); QSettings settings; - QString filename = QFileDialog::getOpenFileName(this, "Select color table", - settings.value("lastOpenedLutFileDirectory"). toString(), - "Color table files (*.xml);;"); + QString filename = QFileDialog::getOpenFileName( + this, "Select color table", + settings.value("lastOpenedLutFileDirectory").toString(), + "Color table files (*.xml);;"); QFileInfo fi(filename); if (fi.suffix().toLower() == "xml") diff --git a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp index 66735792e70..62cd4754ecf 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp @@ -15,37 +15,35 @@ // ** INCLUDES ** #include "VtkVisPointSetItem.h" -#include <limits> +#include <vtkActor.h> +#include <vtkCellData.h> +#include <vtkDataSetMapper.h> +#include <vtkImageAlgorithm.h> +#include <vtkLookupTable.h> +#include <vtkPointData.h> +#include <vtkProperty.h> +#include <vtkRenderer.h> +#include <vtkSmartPointer.h> +#include <vtkTransform.h> +#include <vtkTransformFilter.h> #include <QObject> #include <QRegExp> #include <QSettings> #include <QStringList> - -#include "BaseLib/Logging.h" +#include <limits> #include "BaseLib/FileTools.h" - +#include "BaseLib/Logging.h" +#include "MeshLib/Vtk/VtkMappedMeshSource.h" +#include "QVtkDataSetMapper.h" #include "VtkAlgorithmProperties.h" -#include "VtkCompositeFilter.h" #include "VtkCompositeContourFilter.h" +#include "VtkCompositeFilter.h" #include "VtkCompositeThresholdFilter.h" -#include "MeshLib/Vtk/VtkMappedMeshSource.h" - -#include "QVtkDataSetMapper.h" -#include <vtkActor.h> -#include <vtkCellData.h> -#include <vtkDataSetMapper.h> -#include <vtkImageAlgorithm.h> -#include <vtkPointData.h> -#include <vtkRenderer.h> -#include <vtkSmartPointer.h> -#include <vtkTransform.h> -#include <vtkTransformFilter.h> -#include <vtkProperty.h> -#include <vtkLookupTable.h> // export test +#include <vtkDataSetAttributes.h> #include <vtkPolyDataAlgorithm.h> #include <vtkTriangleFilter.h> #include <vtkTubeFilter.h> @@ -53,13 +51,14 @@ #include <vtkXMLPolyDataWriter.h> #include <vtkXMLUnstructuredGridWriter.h> -#include <vtkDataSetAttributes.h> - VtkVisPointSetItem::VtkVisPointSetItem( - vtkAlgorithm* algorithm, TreeItem* parentItem, - const QList<QVariant> data /*= QList<QVariant>()*/) - : VtkVisPipelineItem(algorithm, parentItem, data), _mapper(nullptr), - _transformFilter(nullptr), _onPointData(true), _activeArrayName("") + vtkAlgorithm* algorithm, TreeItem* parentItem, + const QList<QVariant> data /*= QList<QVariant>()*/) + : VtkVisPipelineItem(algorithm, parentItem, data), + _mapper(nullptr), + _transformFilter(nullptr), + _onPointData(true), + _activeArrayName("") { auto* visParentItem = dynamic_cast<VtkVisPipelineItem*>(parentItem); if (parentItem->parentItem()) @@ -84,10 +83,13 @@ VtkVisPointSetItem::VtkVisPointSetItem( } VtkVisPointSetItem::VtkVisPointSetItem( - VtkCompositeFilter* compositeFilter, TreeItem* parentItem, - const QList<QVariant> data /*= QList<QVariant>()*/) - : VtkVisPipelineItem(compositeFilter, parentItem, data), _mapper(nullptr), - _transformFilter(nullptr), _onPointData(true), _activeArrayName("") + VtkCompositeFilter* compositeFilter, TreeItem* parentItem, + const QList<QVariant> data /*= QList<QVariant>()*/) + : VtkVisPipelineItem(compositeFilter, parentItem, data), + _mapper(nullptr), + _transformFilter(nullptr), + _onPointData(true), + _activeArrayName("") { } @@ -106,7 +108,8 @@ void VtkVisPointSetItem::Initialize(vtkRenderer* renderer) // TODO vtkTransformFilter creates a new copy of the point coordinates which // conflicts with VtkMappedMeshSource. Find a workaround! _transformFilter = vtkTransformFilter::New(); - vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New(); + vtkSmartPointer<vtkTransform> transform = + vtkSmartPointer<vtkTransform>::New(); transform->Identity(); _transformFilter->SetTransform(transform); @@ -124,7 +127,8 @@ void VtkVisPointSetItem::Initialize(vtkRenderer* renderer) _renderer->AddActor(_actor); // Determine the right pre-set properties - // Order is: _algorithm, _compositeFilter, create a new one with props copied from parent + // Order is: _algorithm, _compositeFilter, create a new one with props + // copied from parent auto* vtkProps = dynamic_cast<VtkAlgorithmProperties*>(_algorithm); if (!vtkProps) { @@ -186,14 +190,13 @@ void VtkVisPointSetItem::Initialize(vtkRenderer* renderer) this->setVtkProperties(vtkProps); this->SetActiveAttribute(vtkProps->GetActiveAttribute()); - // Set global backface culling QSettings settings; bool backfaceCulling = settings.value("globalCullBackfaces", 0).toBool(); this->setBackfaceCulling(backfaceCulling); // Set the correct threshold range - if (dynamic_cast<VtkCompositeThresholdFilter*>(this->_compositeFilter) ) + if (dynamic_cast<VtkCompositeThresholdFilter*>(this->_compositeFilter)) { double range[2]; this->GetRangeForActiveAttribute(range); @@ -211,15 +214,15 @@ void VtkVisPointSetItem::Initialize(vtkRenderer* renderer) } } -void VtkVisPointSetItem::SetScalarVisibility( bool on ) +void VtkVisPointSetItem::SetScalarVisibility(bool on) { _mapper->SetScalarVisibility(on); } void VtkVisPointSetItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) { - QObject::connect(vtkProps, SIGNAL(ScalarVisibilityChanged(bool)), - _mapper, SLOT(SetScalarVisibility(bool))); + QObject::connect(vtkProps, SIGNAL(ScalarVisibilityChanged(bool)), _mapper, + SLOT(SetScalarVisibility(bool))); auto* actor = dynamic_cast<vtkActor*>(_actor); if (actor) @@ -227,12 +230,13 @@ void VtkVisPointSetItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) if (vtkProps->GetTexture() != nullptr) { vtkProps->SetScalarVisibility(false); - actor->GetProperty()->SetColor(1,1,1); // don't colorise textures + actor->GetProperty()->SetColor(1, 1, 1); // don't colorise textures actor->SetTexture(vtkProps->GetTexture()); } else { - vtkSmartPointer<vtkProperty> itemProperty = vtkProps->GetProperties(); + vtkSmartPointer<vtkProperty> itemProperty = + vtkProps->GetProperties(); actor->SetProperty(itemProperty); } @@ -243,14 +247,15 @@ void VtkVisPointSetItem::setVtkProperties(VtkAlgorithmProperties* vtkProps) } } -int VtkVisPointSetItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string &filename) const +int VtkVisPointSetItem::callVTKWriter(vtkAlgorithm* algorithm, + const std::string& filename) const { std::string file_name_cpy(filename); auto* algPD = dynamic_cast<vtkPolyDataAlgorithm*>(algorithm); if (algPD) { vtkSmartPointer<vtkXMLPolyDataWriter> pdWriter = - vtkSmartPointer<vtkXMLPolyDataWriter>::New(); + vtkSmartPointer<vtkXMLPolyDataWriter>::New(); pdWriter->SetInputData(algPD->GetOutputDataObject(0)); if (BaseLib::getFileExtension(filename) != ".vtp") { @@ -264,7 +269,7 @@ int VtkVisPointSetItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string if (algUG) { vtkSmartPointer<vtkXMLUnstructuredGridWriter> ugWriter = - vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); + vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); ugWriter->SetInputData(algUG->GetOutputDataObject(0)); if (BaseLib::getFileExtension(filename) != ".vtu") { @@ -278,7 +283,7 @@ int VtkVisPointSetItem::callVTKWriter(vtkAlgorithm* algorithm, const std::string return 0; } -void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) +void VtkVisPointSetItem::SetActiveAttribute(const QString& name) { // Get type by identifier if (name.contains(QRegExp("^P-"))) @@ -303,7 +308,8 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) // Remove type identifier _activeArrayName = QString(name).remove(0, 2).toStdString(); - vtkDataSet* dataSet = vtkDataSet::SafeDownCast(this->_algorithm->GetOutputDataObject(0)); + vtkDataSet* dataSet = + vtkDataSet::SafeDownCast(this->_algorithm->GetOutputDataObject(0)); if (!dataSet) { return; @@ -314,20 +320,22 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) if (_onPointData) { vtkPointData* pointData = dataSet->GetPointData(); - if(pointData) + if (pointData) { - _algorithm->SetInputArrayToProcess(0, 0, 0, - vtkDataObject::FIELD_ASSOCIATION_POINTS, _activeArrayName.c_str()); + _algorithm->SetInputArrayToProcess( + 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, + _activeArrayName.c_str()); _mapper->SetScalarModeToUsePointFieldData(); } } else { vtkCellData* cellData = dataSet->GetCellData(); - if(cellData) + if (cellData) { - _algorithm->SetInputArrayToProcess(0, 0, 0, - vtkDataObject::FIELD_ASSOCIATION_CELLS, _activeArrayName.c_str()); + _algorithm->SetInputArrayToProcess( + 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, + _activeArrayName.c_str()); _mapper->SetScalarModeToUseCellFieldData(); } } @@ -340,21 +348,25 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) auto* mapper = dynamic_cast<QVtkDataSetMapper*>(_mapper); if (mapper) { - // Create a default color table when there is no lookup table for this attribute + // Create a default color table when there is no lookup table for this + // attribute vtkLookupTable* lut = _vtkProps->GetLookupTable(name); if (lut == nullptr) { - //std::cout << "Creating new lookup table for: " << name.toStdString() << std::endl; - lut = vtkLookupTable::New(); // is not a memory leak, gets deleted in VtkAlgorithmProperties + // std::cout << "Creating new lookup table for: " << + // name.toStdString() << std::endl; + lut = vtkLookupTable::New(); // is not a memory leak, gets deleted + // in VtkAlgorithmProperties lut->SetTableRange(range); _vtkProps->SetLookUpTable(name, lut); } _mapper->SetLookupTable(lut); } - _mapper->SelectColorArray( _activeArrayName.c_str()); + _mapper->SelectColorArray(_activeArrayName.c_str()); } -bool VtkVisPointSetItem::activeAttributeExists(vtkDataSetAttributes* data, std::string& name) +bool VtkVisPointSetItem::activeAttributeExists(vtkDataSetAttributes* data, + std::string& name) { bool arrayFound = false; for (int i = 0; i < data->GetNumberOfArrays() && !arrayFound; i++) @@ -417,7 +429,8 @@ void VtkVisPointSetItem::setBackfaceCulling(bool enable) const void VtkVisPointSetItem::GetRangeForActiveAttribute(double range[2]) const { - vtkDataSet* dataSet = vtkDataSet::SafeDownCast(this->_algorithm->GetOutputDataObject(0)); + vtkDataSet* dataSet = + vtkDataSet::SafeDownCast(this->_algorithm->GetOutputDataObject(0)); if (dataSet && _activeArrayName.length() > 0) { if (_onPointData) @@ -431,7 +444,7 @@ void VtkVisPointSetItem::GetRangeForActiveAttribute(double range[2]) const else { vtkCellData* cellData = dataSet->GetCellData(); - cellData->GetArray(_activeArrayName.c_str())->GetRange(range); + cellData->GetArray(_activeArrayName.c_str())->GetRange(range); } } } diff --git a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp index 8560a5bf210..c4b97af2fde 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisTabWidget.cpp @@ -14,6 +14,13 @@ #include "VtkVisTabWidget.h" +#include <vtkActor.h> +#include <vtkImageChangeInformation.h> +#include <vtkProperty.h> +#include <vtkTransform.h> +#include <vtkTransformFilter.h> + +#include "BaseLib/Logging.h" #include "VtkAlgorithmPropertyCheckbox.h" #include "VtkAlgorithmPropertyLineEdit.h" #include "VtkAlgorithmPropertyVectorEdit.h" @@ -22,14 +29,6 @@ #include "VtkVisImageItem.h" #include "VtkVisPipelineItem.h" -#include "BaseLib/Logging.h" - -#include <vtkActor.h> -#include <vtkImageChangeInformation.h> -#include <vtkProperty.h> -#include <vtkTransform.h> -#include <vtkTransformFilter.h> - VtkVisTabWidget::VtkVisTabWidget(QWidget* parent /*= 0*/) : QWidget(parent) { setupUi(this); @@ -40,25 +39,27 @@ VtkVisTabWidget::VtkVisTabWidget(QWidget* parent /*= 0*/) : QWidget(parent) this->transY->setValidator(new QDoubleValidator(this)); this->transZ->setValidator(new QDoubleValidator(this)); - connect(this->vtkVisPipelineView, SIGNAL(requestViewUpdate()), - this, SIGNAL(requestViewUpdate())); + connect(this->vtkVisPipelineView, SIGNAL(requestViewUpdate()), this, + SIGNAL(requestViewUpdate())); connect(this->vtkVisPipelineView, SIGNAL(itemSelected(VtkVisPipelineItem*)), this, SLOT(setActiveItem(VtkVisPipelineItem*))); - connect(this->activeScalarComboBox, SIGNAL(currentIndexChanged(const QString &)), - this, SLOT(SetActiveAttributeOnItem(const QString &))); + connect(this->activeScalarComboBox, + SIGNAL(currentIndexChanged(const QString&)), this, + SLOT(SetActiveAttributeOnItem(const QString&))); } void VtkVisTabWidget::on_arrayResetPushButton_clicked() { VtkAlgorithmProperties* props = _item->getVtkProperties(); - const QString selected_array_name = this->activeScalarComboBox->currentText(); + const QString selected_array_name = + this->activeScalarComboBox->currentText(); props->RemoveLookupTable(selected_array_name); _item->SetActiveAttribute(selected_array_name); } -void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) +void VtkVisTabWidget::setActiveItem(VtkVisPipelineItem* item) { if (item) { @@ -67,10 +68,11 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) auto* transform_filter = dynamic_cast<vtkTransformFilter*>(_item->transformFilter()); - if (transform_filter) // if data set + if (transform_filter) // if data set { actorPropertiesGroupBox->setEnabled(true); - vtkProperty* vtkProps = static_cast<vtkActor*>(_item->actor())->GetProperty(); + vtkProperty* vtkProps = + static_cast<vtkActor*>(_item->actor())->GetProperty(); diffuseColorPickerButton->setColor(vtkProps->GetDiffuseColor()); visibleEdgesCheckBox->setChecked(vtkProps->GetEdgeVisibility()); edgeColorPickerButton->setColor(vtkProps->GetEdgeColor()); @@ -86,7 +88,8 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) double trans[3]; transform->GetPosition(trans); - //switch signals off for just filling in text-boxes after clicking on an item + // switch signals off for just filling in text-boxes after + // clicking on an item this->scaleZ->blockSignals(true); this->transX->blockSignals(true); this->transY->blockSignals(true); @@ -99,7 +102,7 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) this->transX->blockSignals(false); this->transY->blockSignals(false); this->transZ->blockSignals(false); - //switch signals back on + // switch signals back on } this->buildScalarArrayComboBox(_item); @@ -118,7 +121,7 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) } } } - else // if image + else // if image { const VtkVisImageItem* img = static_cast<VtkVisImageItem*>(_item); actorPropertiesGroupBox->setEnabled(false); @@ -149,44 +152,52 @@ void VtkVisTabWidget::setActiveItem( VtkVisPipelineItem* item ) } } -void VtkVisTabWidget::on_diffuseColorPickerButton_colorPicked( QColor color ) +void VtkVisTabWidget::on_diffuseColorPickerButton_colorPicked(QColor color) { - static_cast<vtkActor*>(_item->actor())->GetProperty()->SetDiffuseColor( - color.redF(), color.greenF(), color.blueF()); + static_cast<vtkActor*>(_item->actor()) + ->GetProperty() + ->SetDiffuseColor(color.redF(), color.greenF(), color.blueF()); emit requestViewUpdate(); } -void VtkVisTabWidget::on_visibleEdgesCheckBox_stateChanged( int state ) +void VtkVisTabWidget::on_visibleEdgesCheckBox_stateChanged(int state) { if (state == Qt::Checked) { - static_cast<vtkActor*>(_item->actor())->GetProperty()->SetEdgeVisibility(1); + static_cast<vtkActor*>(_item->actor()) + ->GetProperty() + ->SetEdgeVisibility(1); edgeColorPickerButton->setEnabled(true); } else { - static_cast<vtkActor*>(_item->actor())->GetProperty()->SetEdgeVisibility(0); + static_cast<vtkActor*>(_item->actor()) + ->GetProperty() + ->SetEdgeVisibility(0); edgeColorPickerButton->setEnabled(false); } emit requestViewUpdate(); } -void VtkVisTabWidget::on_edgeColorPickerButton_colorPicked( QColor color ) +void VtkVisTabWidget::on_edgeColorPickerButton_colorPicked(QColor color) { - static_cast<vtkActor*>(_item->actor())->GetProperty()->SetEdgeColor( - color.redF(), color.greenF(), color.blueF()); + static_cast<vtkActor*>(_item->actor()) + ->GetProperty() + ->SetEdgeColor(color.redF(), color.greenF(), color.blueF()); emit requestViewUpdate(); } -void VtkVisTabWidget::on_opacitySlider_sliderMoved( int value ) +void VtkVisTabWidget::on_opacitySlider_sliderMoved(int value) { - static_cast<vtkActor*>(_item->actor())->GetProperty()->SetOpacity(value / 100.0); + static_cast<vtkActor*>(_item->actor()) + ->GetProperty() + ->SetOpacity(value / 100.0); emit requestViewUpdate(); } -void VtkVisTabWidget::on_scaleZ_textChanged(const QString &text) +void VtkVisTabWidget::on_scaleZ_textChanged(const QString& text) { bool ok = true; double scale = text.toDouble(&ok); @@ -281,45 +292,41 @@ void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) VtkAlgorithmPropertyCheckbox* checkbox; switch (value.type()) { - case QVariant::Double: - lineEdit = - new VtkAlgorithmPropertyLineEdit(QString::number( - value.toDouble()), - key, QVariant::Double, - algProps); - connect(lineEdit, SIGNAL(editingFinished()), this, - SIGNAL(requestViewUpdate())); - layout->addRow(key, lineEdit); - break; - - case QVariant::Int: - lineEdit = - new VtkAlgorithmPropertyLineEdit(QString::number( - value.toInt()), - key, QVariant::Int, - algProps); - connect(lineEdit, SIGNAL(editingFinished()), this, - SIGNAL(requestViewUpdate())); - layout->addRow(key, lineEdit); - break; - - case QVariant::Bool: - checkbox = new VtkAlgorithmPropertyCheckbox( - value.toBool(), key, algProps); - connect(checkbox, SIGNAL(stateChanged(int)), this, - SIGNAL(requestViewUpdate())); - layout->addRow(key, checkbox); - break; - - default: - break; + case QVariant::Double: + lineEdit = new VtkAlgorithmPropertyLineEdit( + QString::number(value.toDouble()), key, + QVariant::Double, algProps); + connect(lineEdit, SIGNAL(editingFinished()), this, + SIGNAL(requestViewUpdate())); + layout->addRow(key, lineEdit); + break; + + case QVariant::Int: + lineEdit = new VtkAlgorithmPropertyLineEdit( + QString::number(value.toInt()), key, QVariant::Int, + algProps); + connect(lineEdit, SIGNAL(editingFinished()), this, + SIGNAL(requestViewUpdate())); + layout->addRow(key, lineEdit); + break; + + case QVariant::Bool: + checkbox = new VtkAlgorithmPropertyCheckbox(value.toBool(), + key, algProps); + connect(checkbox, SIGNAL(stateChanged(int)), this, + SIGNAL(requestViewUpdate())); + layout->addRow(key, checkbox); + break; + + default: + break; } } } if (propVecMap) { - QMapIterator<QString, QList<QVariant> > i(*propVecMap); + QMapIterator<QString, QList<QVariant>> i(*propVecMap); while (i.hasNext()) { i.next(); @@ -330,7 +337,7 @@ void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) { QList<QString> valuesAsString; foreach (QVariant variant, values) - valuesAsString.push_back(variant.toString()); + valuesAsString.push_back(variant.toString()); VtkAlgorithmPropertyVectorEdit* vectorEdit = new VtkAlgorithmPropertyVectorEdit( @@ -346,7 +353,7 @@ void VtkVisTabWidget::buildProportiesDialog(VtkVisPipelineItem* item) void VtkVisTabWidget::buildScalarArrayComboBox(VtkVisPipelineItem* item) { QStringList dataSetAttributesList = item->getScalarArrayNames(); - dataSetAttributesList.push_back("Solid Color"); // all scalars switched off + dataSetAttributesList.push_back("Solid Color"); // all scalars switched off this->activeScalarComboBox->blockSignals(true); this->activeScalarComboBox->clear(); this->activeScalarComboBox->insertItems(0, dataSetAttributesList); @@ -364,7 +371,7 @@ void VtkVisTabWidget::buildScalarArrayComboBox(VtkVisPipelineItem* item) it != dataSetAttributesList.end(); ++it) { - if (active_array_name.compare((*it).right((*it).length()-2))==0) + if (active_array_name.compare((*it).right((*it).length() - 2)) == 0) { this->activeScalarComboBox->setCurrentIndex(idx); break; @@ -375,9 +382,8 @@ void VtkVisTabWidget::buildScalarArrayComboBox(VtkVisPipelineItem* item) } } -void VtkVisTabWidget::SetActiveAttributeOnItem( const QString &name ) +void VtkVisTabWidget::SetActiveAttributeOnItem(const QString& name) { _item->SetActiveAttribute(name); emit requestViewUpdate(); } - diff --git a/Applications/DataExplorer/main.cpp b/Applications/DataExplorer/main.cpp index 2c7e28772a3..eb33b1c2368 100644 --- a/Applications/DataExplorer/main.cpp +++ b/Applications/DataExplorer/main.cpp @@ -1,13 +1,13 @@ -#include "mainwindow.h" +#include <QVTKOpenGLWidget.h> +#include <vtkSmartPointer.h> #include <QApplication> #include <QSurfaceFormat> -#include <QVTKOpenGLWidget.h> #include <memory> -#include <vtkSmartPointer.h> #include "InfoLib/GitInfo.h" #include "VtkVis/VtkConsoleOutputWindow.h" +#include "mainwindow.h" int main(int argc, char* argv[]) { @@ -19,16 +19,17 @@ int main(int argc, char* argv[]) QApplication a(argc, argv); QApplication::setApplicationName("OpenGeoSys - Data Explorer"); - QApplication::setApplicationVersion(QString::fromStdString( - GitInfoLib::GitInfo::ogs_version)); + QApplication::setApplicationVersion( + QString::fromStdString(GitInfoLib::GitInfo::ogs_version)); QApplication::setOrganizationName("OpenGeoSys Community"); QApplication::setOrganizationDomain("opengeosys.org"); - setlocale(LC_NUMERIC,"C"); + setlocale(LC_NUMERIC, "C"); QLocale::setDefault(QLocale::German); auto w = std::make_unique<MainWindow>(); - w->setWindowTitle( w->windowTitle() + " - " + - QString::fromStdString(GitInfoLib::GitInfo::ogs_version)); - if (QCoreApplication::arguments().size()>1) { + w->setWindowTitle(w->windowTitle() + " - " + + QString::fromStdString(GitInfoLib::GitInfo::ogs_version)); + if (QCoreApplication::arguments().size() > 1) + { w->loadFileOnStartUp(QCoreApplication::arguments().at(1)); } w->show(); diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index da7f10411de..f5d42b5196f 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -48,13 +48,13 @@ #include "Applications/FileIO/TetGenInterface.h" #include "Applications/FileIO/XmlIO/Qt/XmlPrjInterface.h" #include "Applications/Utils/OGSFileConverter/OGSFileConverter.h" -#include "InfoLib/GitInfo.h" #include "BaseLib/FileTools.h" #include "BaseLib/Histogram.h" #include "GeoLib/DuplicateGeometry.h" #include "GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h" #include "GeoLib/IO/XmlIO/Qt/XmlStnInterface.h" #include "GeoLib/Raster.h" +#include "InfoLib/GitInfo.h" #include "MeshGeoToolsLib/GeoMapper.h" #include "MeshLib/Elements/Element.h" #include "MeshLib/IO/Legacy/MeshIO.h" @@ -81,16 +81,15 @@ #ifdef OGS_USE_NETCDF #include "NetCdfConfigureDialog.h" #endif // OGS_USE_NETCDF -#include "SHPImportDialog.h" -#include "SetNameDialog.h" -#include "VtkAddFilterDialog.h" - #include "GeoTreeModel.h" #include "LastSavedFileDirectory.h" #include "OGSError.h" #include "RecentFiles.h" +#include "SHPImportDialog.h" +#include "SetNameDialog.h" #include "StationTreeModel.h" #include "TreeModelIterator.h" +#include "VtkAddFilterDialog.h" #include "VtkBGImageSource.h" #include "VtkGeoImageSource.h" #include "VtkRaster.h" @@ -121,71 +120,113 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) : QMainWindow(parent) std::make_unique<VtkVisPipeline>(visualizationWidget->renderer()); // station model connects - connect(stationTabWidget->treeView, SIGNAL(openStationListFile(int)), - this, SLOT(open(int))); - connect(stationTabWidget->treeView, SIGNAL(stationListExportRequested(std::string, std::string)), - this, SLOT(exportBoreholesToGMS(std::string, std::string))); // export Stationlist to GMS - connect(stationTabWidget->treeView, SIGNAL(stationListRemoved(std::string)), _geo_model.get(), - SLOT(removeStationVec(std::string))); // update model when stations are removed - connect(stationTabWidget->treeView, SIGNAL(stationListSaved(QString, QString)), this, - SLOT(writeStationListToFile(QString, QString))); // save Stationlist to File - connect(_geo_model.get(), SIGNAL(stationVectorRemoved(StationTreeModel *, std::string)), - this, SLOT(updateDataViews())); // update data view when stations are removed - connect(stationTabWidget->treeView, SIGNAL(requestNameChangeDialog(const std::string&, std::size_t)), + connect(stationTabWidget->treeView, SIGNAL(openStationListFile(int)), this, + SLOT(open(int))); + connect(stationTabWidget->treeView, + SIGNAL(stationListExportRequested(std::string, std::string)), this, + SLOT(exportBoreholesToGMS( + std::string, std::string))); // export Stationlist to GMS + connect(stationTabWidget->treeView, SIGNAL(stationListRemoved(std::string)), + _geo_model.get(), + SLOT(removeStationVec( + std::string))); // update model when stations are removed + connect(stationTabWidget->treeView, + SIGNAL(stationListSaved(QString, QString)), this, + SLOT(writeStationListToFile(QString, + QString))); // save Stationlist to File + connect( + _geo_model.get(), + SIGNAL(stationVectorRemoved(StationTreeModel*, std::string)), this, + SLOT(updateDataViews())); // update data view when stations are removed + connect(stationTabWidget->treeView, + SIGNAL(requestNameChangeDialog(const std::string&, std::size_t)), this, SLOT(showStationNameDialog(const std::string&, std::size_t))); - connect(stationTabWidget->treeView, SIGNAL(diagramRequested(QModelIndex &)), - this, SLOT(showDiagramPrefsDialog(QModelIndex &))); // connect treeview to diagramview + connect(stationTabWidget->treeView, SIGNAL(diagramRequested(QModelIndex&)), + this, + SLOT(showDiagramPrefsDialog( + QModelIndex&))); // connect treeview to diagramview // geo model connects - connect(geoTabWidget->treeView, SIGNAL(openGeometryFile(int)), - this, SLOT(open(int))); - connect(geoTabWidget->treeView, SIGNAL(listRemoved(std::string, GeoLib::GEOTYPE)), - _geo_model.get(), SLOT(removeGeometry(std::string, GeoLib::GEOTYPE))); - connect(geoTabWidget->treeView, SIGNAL(geometryMappingRequested(const std::string&)), - this, SLOT(mapGeometry(const std::string&))); - connect(geoTabWidget->treeView, SIGNAL(saveToFileRequested(QString, QString)), - this, SLOT(writeGeometryToFile(QString, QString))); // save geometry to file - connect(geoTabWidget->treeView, SIGNAL(requestPointToStationConversion(std::string const&)), this, - SLOT(convertPointsToStations( std::string const&))); - connect(geoTabWidget->treeView, SIGNAL(requestLineEditDialog(const std::string &)), - this, SLOT(showLineEditDialog(const std::string &))); // open line edit dialog - connect(geoTabWidget->treeView, SIGNAL(requestNameChangeDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t)), - this, SLOT(showGeoNameDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t))); - connect(_geo_model.get(), SIGNAL(geoDataAdded(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), + connect(geoTabWidget->treeView, SIGNAL(openGeometryFile(int)), this, + SLOT(open(int))); + connect(geoTabWidget->treeView, + SIGNAL(listRemoved(std::string, GeoLib::GEOTYPE)), _geo_model.get(), + SLOT(removeGeometry(std::string, GeoLib::GEOTYPE))); + connect(geoTabWidget->treeView, + SIGNAL(geometryMappingRequested(const std::string&)), this, + SLOT(mapGeometry(const std::string&))); + connect( + geoTabWidget->treeView, SIGNAL(saveToFileRequested(QString, QString)), + this, + SLOT(writeGeometryToFile(QString, QString))); // save geometry to file + connect(geoTabWidget->treeView, + SIGNAL(requestPointToStationConversion(std::string const&)), this, + SLOT(convertPointsToStations(std::string const&))); + connect( + geoTabWidget->treeView, + SIGNAL(requestLineEditDialog(const std::string&)), this, + SLOT(showLineEditDialog(const std::string&))); // open line edit dialog + connect(geoTabWidget->treeView, + SIGNAL(requestNameChangeDialog(const std::string&, + const GeoLib::GEOTYPE, std::size_t)), + this, + SLOT(showGeoNameDialog(const std::string&, const GeoLib::GEOTYPE, + std::size_t))); + connect(_geo_model.get(), + SIGNAL(geoDataAdded(GeoTreeModel*, std::string, GeoLib::GEOTYPE)), this, SLOT(updateDataViews())); - connect(_geo_model.get(), SIGNAL(geoDataRemoved(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), + connect(_geo_model.get(), + SIGNAL(geoDataRemoved(GeoTreeModel*, std::string, GeoLib::GEOTYPE)), this, SLOT(updateDataViews())); - connect(geoTabWidget->treeView, SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)), - _vtkVisPipeline.get(), SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int))); + connect(geoTabWidget->treeView, + SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)), + _vtkVisPipeline.get(), + SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int))); connect(geoTabWidget->treeView, SIGNAL(removeGeoItemSelection()), _vtkVisPipeline.get(), SLOT(removeHighlightedGeoObject())); - connect(stationTabWidget->treeView, SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)), - _vtkVisPipeline.get(), SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int))); + connect(stationTabWidget->treeView, + SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)), + _vtkVisPipeline.get(), + SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int))); connect(stationTabWidget->treeView, SIGNAL(removeGeoItemSelection()), _vtkVisPipeline.get(), SLOT(removeHighlightedGeoObject())); // Setup connections for mesh models to GUI - connect(meshTabWidget->treeView, SIGNAL(openMeshFile(int)), - this, SLOT(open(int))); - connect(meshTabWidget->treeView, SIGNAL(requestMeshRemoval(const QModelIndex &)), - _meshModel.get(), SLOT(removeMesh(const QModelIndex &))); - connect(meshTabWidget->treeView, SIGNAL(requestMeshRemoval(const QModelIndex &)), - _elementModel.get(), SLOT(clearView())); + connect(meshTabWidget->treeView, SIGNAL(openMeshFile(int)), this, + SLOT(open(int))); + connect(meshTabWidget->treeView, + SIGNAL(requestMeshRemoval(const QModelIndex&)), _meshModel.get(), + SLOT(removeMesh(const QModelIndex&))); connect(meshTabWidget->treeView, + SIGNAL(requestMeshRemoval(const QModelIndex&)), _elementModel.get(), + SLOT(clearView())); + connect( + meshTabWidget->treeView, SIGNAL(qualityCheckRequested(MeshLib::VtkMappedMeshSource*)), - this, - SLOT(showMeshQualitySelectionDialog(MeshLib::VtkMappedMeshSource*))); - connect(meshTabWidget->treeView, SIGNAL(requestMeshToGeometryConversion(const MeshLib::Mesh*)), - this, SLOT(convertMeshToGeometry(const MeshLib::Mesh*))); - connect(meshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)), - _vtkVisPipeline.get(), SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, unsigned, bool))); + this, + SLOT(showMeshQualitySelectionDialog(MeshLib::VtkMappedMeshSource*))); + connect(meshTabWidget->treeView, + SIGNAL(requestMeshToGeometryConversion(const MeshLib::Mesh*)), this, + SLOT(convertMeshToGeometry(const MeshLib::Mesh*))); + connect(meshTabWidget->treeView, + SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const* const, + unsigned, bool)), + _vtkVisPipeline.get(), + SLOT(highlightMeshComponent( + vtkUnstructuredGridAlgorithm const* const, unsigned, bool))); connect(meshTabWidget->treeView, SIGNAL(meshSelected(MeshLib::Mesh const&)), this->_elementModel.get(), SLOT(setMesh(MeshLib::Mesh const&))); connect(meshTabWidget->treeView, SIGNAL(meshSelected(MeshLib::Mesh const&)), meshTabWidget->elementView, SLOT(updateView())); - connect(meshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)), - this->_elementModel.get(), SLOT(setElement(vtkUnstructuredGridAlgorithm const*const, unsigned))); - connect(meshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)), + connect( + meshTabWidget->treeView, + SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const* const, + unsigned, bool)), + this->_elementModel.get(), + SLOT(setElement(vtkUnstructuredGridAlgorithm const* const, unsigned))); + connect(meshTabWidget->treeView, + SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const* const, + unsigned, bool)), meshTabWidget->elementView, SLOT(updateView())); connect(meshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const* const, @@ -199,8 +240,12 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) : QMainWindow(parent) unsigned, bool)), reinterpret_cast<QObject*>(visualizationWidget->interactorStyle()), SLOT(removeHighlightActor())); - connect(meshTabWidget->elementView, SIGNAL(nodeSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)), - _vtkVisPipeline.get(), SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, unsigned, bool))); + connect(meshTabWidget->elementView, + SIGNAL(nodeSelected(vtkUnstructuredGridAlgorithm const* const, + unsigned, bool)), + _vtkVisPipeline.get(), + SLOT(highlightMeshComponent( + vtkUnstructuredGridAlgorithm const* const, unsigned, bool))); connect(meshTabWidget->elementView, SIGNAL(removeSelectedMeshComponent()), _vtkVisPipeline.get(), SLOT(removeHighlightedMeshComponent())); @@ -230,31 +275,43 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) : QMainWindow(parent) modellingTabWidget->conditionView, SLOT(updateView())); // VisPipeline Connects - connect(_geo_model.get(), SIGNAL(geoDataAdded(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), - _vtkVisPipeline.get(), SLOT(addPipelineItem(GeoTreeModel *, std::string, GeoLib::GEOTYPE))); - connect(_geo_model.get(), SIGNAL(geoDataRemoved(GeoTreeModel *, std::string, GeoLib::GEOTYPE)), - _vtkVisPipeline.get(), SLOT(removeSourceItem(GeoTreeModel *, std::string, GeoLib::GEOTYPE))); - - connect(_geo_model.get(), SIGNAL(stationVectorAdded(StationTreeModel *, std::string)), - _vtkVisPipeline.get(), SLOT(addPipelineItem(StationTreeModel *, std::string))); - connect(_geo_model.get(), SIGNAL(stationVectorRemoved(StationTreeModel *, std::string)), - _vtkVisPipeline.get(), SLOT(removeSourceItem(StationTreeModel *, std::string))); - - connect(_meshModel.get(), SIGNAL(meshAdded(MeshModel *, QModelIndex)), - _vtkVisPipeline.get(), SLOT(addPipelineItem(MeshModel *,QModelIndex))); - connect(_meshModel.get(), SIGNAL(meshRemoved(MeshModel *, QModelIndex)), - _vtkVisPipeline.get(), SLOT(removeSourceItem(MeshModel *, QModelIndex))); + connect(_geo_model.get(), + SIGNAL(geoDataAdded(GeoTreeModel*, std::string, GeoLib::GEOTYPE)), + _vtkVisPipeline.get(), + SLOT(addPipelineItem(GeoTreeModel*, std::string, GeoLib::GEOTYPE))); + connect( + _geo_model.get(), + SIGNAL(geoDataRemoved(GeoTreeModel*, std::string, GeoLib::GEOTYPE)), + _vtkVisPipeline.get(), + SLOT(removeSourceItem(GeoTreeModel*, std::string, GeoLib::GEOTYPE))); + + connect(_geo_model.get(), + SIGNAL(stationVectorAdded(StationTreeModel*, std::string)), + _vtkVisPipeline.get(), + SLOT(addPipelineItem(StationTreeModel*, std::string))); + connect(_geo_model.get(), + SIGNAL(stationVectorRemoved(StationTreeModel*, std::string)), + _vtkVisPipeline.get(), + SLOT(removeSourceItem(StationTreeModel*, std::string))); + + connect(_meshModel.get(), SIGNAL(meshAdded(MeshModel*, QModelIndex)), + _vtkVisPipeline.get(), + SLOT(addPipelineItem(MeshModel*, QModelIndex))); + connect(_meshModel.get(), SIGNAL(meshRemoved(MeshModel*, QModelIndex)), + _vtkVisPipeline.get(), + SLOT(removeSourceItem(MeshModel*, QModelIndex))); connect(_vtkVisPipeline.get(), SIGNAL(vtkVisPipelineChanged()), visualizationWidget->vtkWidget, SLOT(update())); connect(_vtkVisPipeline.get(), SIGNAL(vtkVisPipelineChanged()), vtkVisTabWidget->vtkVisPipelineView, SLOT(expandAll())); connect(_vtkVisPipeline.get(), SIGNAL(itemSelected(const QModelIndex&)), - vtkVisTabWidget->vtkVisPipelineView, SLOT(selectItem(const QModelIndex&))); - + vtkVisTabWidget->vtkVisPipelineView, + SLOT(selectItem(const QModelIndex&))); vtkVisTabWidget->vtkVisPipelineView->setModel(_vtkVisPipeline.get()); - connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(requestRemovePipelineItem(QModelIndex)), + connect(vtkVisTabWidget->vtkVisPipelineView, + SIGNAL(requestRemovePipelineItem(QModelIndex)), _vtkVisPipeline.get(), SLOT(removePipelineItem(QModelIndex))); connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(requestAddPipelineFilterItem(QModelIndex)), this, @@ -296,8 +353,9 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) : QMainWindow(parent) this->_vtkVisPipeline.get(), SLOT(removeHighlightedMeshComponent())); - connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(meshAdded(MeshLib::Mesh*)), - _meshModel.get(), SLOT(addMesh(MeshLib::Mesh*))); + connect(vtkVisTabWidget->vtkVisPipelineView, + SIGNAL(meshAdded(MeshLib::Mesh*)), _meshModel.get(), + SLOT(addMesh(MeshLib::Mesh*))); // Stack the data dock widgets together tabifyDockWidget(geoDock, mshDock); @@ -315,11 +373,12 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) : QMainWindow(parent) } // Setup import files menu - QMenu* import_files_menu = createImportFilesMenu(); //owned by MainWindow + QMenu* import_files_menu = createImportFilesMenu(); // owned by MainWindow menu_File->insertMenu(action_Exit, import_files_menu); // Setup recent files menu - RecentFiles* recentFiles = new RecentFiles(this, SLOT(openRecentFile()), "recentFileList"); + RecentFiles* recentFiles = + new RecentFiles(this, SLOT(openRecentFile()), "recentFileList"); connect(this, SIGNAL(fileUsed(QString)), recentFiles, SLOT(setCurrentFile(QString))); menu_File->insertMenu(action_Exit, recentFiles->menu()); @@ -436,17 +495,18 @@ void MainWindow::open(int file_type) { QSettings settings; auto t = static_cast<ImportFileType::type>(file_type); - QString type_str = QString::fromStdString((ImportFileType::convertImportFileTypeToString(t))); - QString fileName = QFileDialog::getOpenFileName(this, "Select " + type_str + " file to import", - settings.value("lastOpenedFileDirectory").toString(), - QString::fromStdString(ImportFileType::getFileSuffixString(t))); + QString type_str = QString::fromStdString( + (ImportFileType::convertImportFileTypeToString(t))); + QString fileName = QFileDialog::getOpenFileName( + this, "Select " + type_str + " file to import", + settings.value("lastOpenedFileDirectory").toString(), + QString::fromStdString(ImportFileType::getFileSuffixString(t))); if (!fileName.isEmpty()) { loadFile(t, fileName); QDir dir = QDir(fileName); settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); } - } void MainWindow::openRecentFile() @@ -506,14 +566,15 @@ void MainWindow::save() } } -void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) +void MainWindow::loadFile(ImportFileType::type t, const QString& fileName) { QFile file(fileName); if (!file.exists()) { - QMessageBox::warning(this, tr("Application"), tr( - "Cannot read file %1:\n%2.").arg(fileName).arg( - file.errorString())); + QMessageBox::warning(this, tr("Application"), + tr("Cannot read file %1:\n%2.") + .arg(fileName) + .arg(file.errorString())); return; } @@ -521,9 +582,11 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) QFileInfo fi(fileName); QSettings settings; QDir dir = QDir(fileName); - std::string base = fi.absoluteDir().absoluteFilePath(fi.completeBaseName()).toStdString(); + std::string base = + fi.absoluteDir().absoluteFilePath(fi.completeBaseName()).toStdString(); - if (t == ImportFileType::OGS || t == ImportFileType::OGS_GEO || t == ImportFileType::OGS_STN || t == ImportFileType::OGS_MSH) + if (t == ImportFileType::OGS || t == ImportFileType::OGS_GEO || + t == ImportFileType::OGS_STN || t == ImportFileType::OGS_MSH) { if (fi.suffix().toLower() == "gli") { @@ -617,7 +680,7 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) } else if (t == ImportFileType::FEFLOW) { - if (fi.suffix().toLower() == "fem") // FEFLOW model files + if (fi.suffix().toLower() == "fem") // FEFLOW model files { FileIO::FEFLOWMeshInterface feflowMeshIO; std::unique_ptr<MeshLib::Mesh> mesh( @@ -631,14 +694,14 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) OGSError::box("Failed to load a FEFLOW mesh."); } FileIO::FEFLOWGeoInterface feflowGeoIO; - feflowGeoIO.readFEFLOWFile(fileName.toStdString(), _project.getGEOObjects()); + feflowGeoIO.readFEFLOWFile(fileName.toStdString(), + _project.getGEOObjects()); } settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); - } else if (t == ImportFileType::GMS) { - if (fi.suffix().toLower() == "txt") // GMS borehole files + if (fi.suffix().toLower() == "txt") // GMS borehole files { auto boreholes = std::make_unique<std::vector<GeoLib::Point*>>(); std::string name = fi.baseName().toStdString(); @@ -646,17 +709,19 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) if (GMSInterface::readBoreholesFromGMS(boreholes.get(), fileName.toStdString())) { - _project.getGEOObjects().addStationVec(std::move(boreholes), name); + _project.getGEOObjects().addStationVec(std::move(boreholes), + name); } else { OGSError::box("Error reading GMS file."); } } - else if (fi.suffix().toLower() == "3dm") // GMS mesh files + else if (fi.suffix().toLower() == "3dm") // GMS mesh files { std::string name = fileName.toStdString(); - std::unique_ptr<MeshLib::Mesh> mesh(GMSInterface::readGMS3DMMesh(name)); + std::unique_ptr<MeshLib::Mesh> mesh( + GMSInterface::readGMS3DMMesh(name)); if (mesh) { _meshModel->addMesh(std::move(mesh)); @@ -670,10 +735,11 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) } else if (t == ImportFileType::GMSH) { - std::string msh_name (fileName.toStdString()); - if (FileIO::GMSH::isGMSHMeshFile (msh_name)) + std::string msh_name(fileName.toStdString()); + if (FileIO::GMSH::isGMSHMeshFile(msh_name)) { - std::unique_ptr<MeshLib::Mesh> mesh(FileIO::GMSH::readGMSHMesh(msh_name)); + std::unique_ptr<MeshLib::Mesh> mesh( + FileIO::GMSH::readGMSHMesh(msh_name)); if (mesh) { _meshModel->addMesh(std::move(mesh)); @@ -706,9 +772,8 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); } #ifdef OGS_USE_NETCDF - else if (t == ImportFileType::NETCDF) // CH 01.2012 + else if (t == ImportFileType::NETCDF) // CH 01.2012 { - NetCdfConfigureDialog dlg(fileName.toStdString()); dlg.exec(); if (dlg.getMesh()) @@ -743,7 +808,8 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) vtkImageAlgorithm* img = VtkRaster::loadImage(fileName.toStdString()); VtkBGImageSource* bg = VtkBGImageSource::New(); double* origin = img->GetOutput()->GetOrigin(); - bg->SetRaster(img, origin[0], origin[1], img->GetOutput()->GetSpacing()[0]); + bg->SetRaster(img, origin[0], origin[1], + img->GetOutput()->GetSpacing()[0]); bg->SetName(fileName); _vtkVisPipeline->addPipelineItem(bg); settings.setValue("lastOpenedRasterFileDirectory", dir.absolutePath()); @@ -759,14 +825,19 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName) } else if (t == ImportFileType::TETGEN) { - if (fi.suffix().toLower().compare("poly") == 0 || fi.suffix().toLower().compare("smesh") == 0) + if (fi.suffix().toLower().compare("poly") == 0 || + fi.suffix().toLower().compare("smesh") == 0) { FileIO::TetGenInterface tetgen; - tetgen.readTetGenGeometry(fileName.toStdString(), _project.getGEOObjects()); + tetgen.readTetGenGeometry(fileName.toStdString(), + _project.getGEOObjects()); } - else { - settings.setValue("lastOpenedTetgenFileDirectory", QFileInfo(fileName).absolutePath()); - QString element_fname(fi.path() + "/" + fi.completeBaseName() + ".ele"); + else + { + settings.setValue("lastOpenedTetgenFileDirectory", + QFileInfo(fileName).absolutePath()); + QString element_fname(fi.path() + "/" + fi.completeBaseName() + + ".ele"); if (!fileName.isEmpty()) { @@ -826,13 +897,20 @@ void MainWindow::showLicense() void MainWindow::about() { - QString about("<a href='https://www.opengeosys.org'>www.opengeosys.org</a><br /><br />"); - about.append(QString("Version: %1<br />") - .arg(QString::fromStdString(GitInfoLib::GitInfo::ogs_version))); - - about.append(QString("Git commit: <a href='https://github.com/ufz/ogs/commit/%1'>%1</a><br />") - .arg(QString::fromStdString(GitInfoLib::GitInfo::git_version_sha1_short))); - about.append(QString("Built date: %1<br />").arg(QDate::currentDate().toString(Qt::ISODate))); + QString about( + "<a href='https://www.opengeosys.org'>www.opengeosys.org</a><br /><br " + "/>"); + about.append( + QString("Version: %1<br />") + .arg(QString::fromStdString(GitInfoLib::GitInfo::ogs_version))); + + about.append( + QString("Git commit: <a " + "href='https://github.com/ufz/ogs/commit/%1'>%1</a><br />") + .arg(QString::fromStdString( + GitInfoLib::GitInfo::git_version_sha1_short))); + about.append(QString("Built date: %1<br />") + .arg(QDate::currentDate().toString(Qt::ISODate))); QMessageBox::about(this, "About OpenGeoSys 6", about); } @@ -852,8 +930,7 @@ QMenu* MainWindow::createImportFilesMenu() importFiles->addAction("&NetCDF Files...", [this] { open(ImportFileType::NETCDF); }); #endif // OGS_USE_NETCDF - importFiles->addAction("&Petrel Files...", - [this] { loadPetrelFiles(); }); + importFiles->addAction("&Petrel Files...", [this] { loadPetrelFiles(); }); importFiles->addAction("&Raster Files...", [this] { open(ImportFileType::RASTER); }); importFiles->addAction("&Shape Files...", @@ -869,9 +946,10 @@ void MainWindow::loadPetrelFiles() { QSettings settings; QStringList sfc_file_names = QFileDialog::getOpenFileNames( - this, "Select surface data file(s) to import", "", "Petrel files (*)"); + this, "Select surface data file(s) to import", "", "Petrel files (*)"); QStringList well_path_file_names = QFileDialog::getOpenFileNames( - this, "Select well path data file(s) to import", "", "Petrel files (*)"); + this, "Select well path data file(s) to import", "", + "Petrel files (*)"); if (!sfc_file_names.empty() || !well_path_file_names.empty()) { QStringList::const_iterator it = sfc_file_names.begin(); @@ -892,8 +970,8 @@ void MainWindow::loadPetrelFiles() std::string unique_str(*(sfc_files.begin())); - PetrelInterface(sfc_files, well_path_files, unique_str, &_project.getGEOObjects()); - + PetrelInterface(sfc_files, well_path_files, unique_str, + &_project.getGEOObjects()); QDir dir = QDir(sfc_file_names.at(0)); settings.setValue("lastOpenedFileDirectory", dir.absolutePath()); @@ -929,7 +1007,7 @@ void MainWindow::writeStationListToFile(QString listName, QString fileName) BaseLib::IO::writeStringToFile(xml.writeToString(), fileName.toStdString()); } -void MainWindow::mapGeometry(const std::string &geo_name) +void MainWindow::mapGeometry(const std::string& geo_name) { GeoOnMeshMappingDialog dlg(this->_project.getMeshObjects()); if (dlg.exec() != QDialog::Accepted) @@ -937,17 +1015,19 @@ void MainWindow::mapGeometry(const std::string &geo_name) return; } - int choice (dlg.getDataSetChoice()); + int choice(dlg.getDataSetChoice()); QString file_name(""); - if (choice<2) // load something from a file + if (choice < 2) // load something from a file { - QString file_type[2] = {"OpenGeoSys mesh files (*.vtu *.msh)", "Raster files(*.asc *.grd)" }; + QString file_type[2] = {"OpenGeoSys mesh files (*.vtu *.msh)", + "Raster files(*.asc *.grd)"}; QSettings settings; - file_name = QFileDialog::getOpenFileName( this, - "Select file for mapping", - settings.value("lastOpenedFileDirectory").toString(), - file_type[choice]); + file_name = QFileDialog::getOpenFileName( + this, + "Select file for mapping", + settings.value("lastOpenedFileDirectory").toString(), + file_type[choice]); if (file_name.isEmpty()) { return; @@ -958,12 +1038,13 @@ void MainWindow::mapGeometry(const std::string &geo_name) MeshGeoToolsLib::GeoMapper geo_mapper(_project.getGEOObjects(), geo_name); QFileInfo fi(file_name); - if (choice == 1) // load raster from file + if (choice == 1) // load raster from file { if (fi.suffix().toLower() == "asc" || fi.suffix().toLower() == "grd") { - std::unique_ptr<GeoLib::Raster> raster ( - FileIO::AsciiRasterInterface::getRasterFromASCFile(file_name.toStdString())); + std::unique_ptr<GeoLib::Raster> raster( + FileIO::AsciiRasterInterface::getRasterFromASCFile( + file_name.toStdString())); if (raster) { geo_mapper.mapOnDEM(std::move(raster)); @@ -981,11 +1062,10 @@ void MainWindow::mapGeometry(const std::string &geo_name) return; } - MeshLib::Mesh* mesh (nullptr); - if (choice == 0) // load mesh from file + MeshLib::Mesh* mesh(nullptr); + if (choice == 0) // load mesh from file { - if (fi.suffix().toLower() == "vtu" || - fi.suffix().toLower() == "vtk" || + if (fi.suffix().toLower() == "vtu" || fi.suffix().toLower() == "vtk" || fi.suffix().toLower() == "msh") { mesh = MeshLib::IO::readMeshFromFile(file_name.toStdString()); @@ -1013,7 +1093,8 @@ void MainWindow::mapGeometry(const std::string &geo_name) GeoLib::DuplicateGeometry dup(_project.getGEOObjects(), geo_name, new_geo_name); new_geo_name = dup.getFinalizedOutputName(); - MeshGeoToolsLib::GeoMapper mapper(_project.getGEOObjects(), new_geo_name); + MeshGeoToolsLib::GeoMapper mapper(_project.getGEOObjects(), + new_geo_name); mapper.advancedMapOnMesh(*mesh); _geo_model->updateGeometry(new_geo_name); } @@ -1028,15 +1109,17 @@ void MainWindow::convertMeshToGeometry(const MeshLib::Mesh* mesh) MeshLib::convertMeshToGeo(*mesh, _project.getGEOObjects()); } -void MainWindow::exportBoreholesToGMS(std::string listName, std::string fileName) +void MainWindow::exportBoreholesToGMS(std::string listName, + std::string fileName) { - const std::vector<GeoLib::Point*>* stations(_project.getGEOObjects().getStationVec(listName)); + const std::vector<GeoLib::Point*>* stations( + _project.getGEOObjects().getStationVec(listName)); GMSInterface::writeBoreholesToGMS(stations, fileName); } -void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, - unsigned param1, double param2, double param3, double param4, - bool delete_geo_file) +void MainWindow::callGMSH(std::vector<std::string>& selectedGeometries, + unsigned param1, double param2, double param3, + double param4, bool delete_geo_file) { if (!selectedGeometries.empty()) { @@ -1047,9 +1130,10 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, if (!delete_geo_file) { - fileName = QFileDialog::getSaveFileName(this, "Save GMSH-file as", - LastSavedFileDirectory::getDir() + "tmp_gmsh.geo", - "GMSH geometry files (*.geo)"); + fileName = QFileDialog::getSaveFileName( + this, "Save GMSH-file as", + LastSavedFileDirectory::getDir() + "tmp_gmsh.geo", + "GMSH geometry files (*.geo)"); } else { @@ -1058,14 +1142,17 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, if (!fileName.isEmpty()) { - if (param4 == -1) { // adaptive meshing selected + if (param4 == -1) + { // adaptive meshing selected FileIO::GMSH::GMSHInterface gmsh_io( _project.getGEOObjects(), true, FileIO::GMSH::MeshDensityAlgorithm::AdaptiveMeshDensity, param2, param3, param1, selectedGeometries, false, false); BaseLib::IO::writeStringToFile(gmsh_io.writeToString(), fileName.toStdString()); - } else { // homogeneous meshing selected + } + else + { // homogeneous meshing selected FileIO::GMSH::GMSHInterface gmsh_io( _project.getGEOObjects(), true, FileIO::GMSH::MeshDensityAlgorithm::FixedMeshDensity, @@ -1077,7 +1164,9 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, if (system(nullptr) != 0) // command processor available { QSettings settings; - std::string gmsh_path = settings.value("DataExplorerGmshPath").toString().toStdString(); + std::string gmsh_path = settings.value("DataExplorerGmshPath") + .toString() + .toStdString(); if (!gmsh_path.empty()) { @@ -1144,13 +1233,14 @@ void MainWindow::showFileConverter() dlg->raise(); } -void MainWindow::showDiagramPrefsDialog(QModelIndex &index) +void MainWindow::showDiagramPrefsDialog(QModelIndex& index) { QString listName; GeoLib::Station* stn = _geo_model->getStationModel()->stationFromIndex(index, listName); - if ((stn->type() == GeoLib::Station::StationType::STATION) && stn->getSensorData()) + if ((stn->type() == GeoLib::Station::StationType::STATION) && + stn->getSensorData()) { auto* prefs(new DiagramPrefsDialog(stn)); prefs->setAttribute(Qt::WA_DeleteOnClose); @@ -1165,9 +1255,10 @@ void MainWindow::showDiagramPrefsDialog(QModelIndex &index) void MainWindow::showDiagramPrefsDialog() { QSettings settings; - QString fileName = QFileDialog::getOpenFileName( this, "Select data file to open", - settings.value("lastOpenedFileDirectory").toString(), - "Text files (*.txt);;All files (* *.*)"); + QString fileName = QFileDialog::getOpenFileName( + this, "Select data file to open", + settings.value("lastOpenedFileDirectory").toString(), + "Text files (*.txt);;All files (* *.*)"); if (!fileName.isEmpty()) { QDir dir = QDir(fileName); @@ -1178,23 +1269,32 @@ void MainWindow::showDiagramPrefsDialog() } } -void MainWindow::showGeoNameDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, std::size_t id) +void MainWindow::showGeoNameDialog(const std::string& geometry_name, + const GeoLib::GEOTYPE object_type, + std::size_t id) { - std::string old_name = _project.getGEOObjects().getElementNameByID(geometry_name, object_type, id); - SetNameDialog dlg(GeoLib::convertGeoTypeToString(object_type), id, old_name); + std::string old_name = _project.getGEOObjects().getElementNameByID( + geometry_name, object_type, id); + SetNameDialog dlg(GeoLib::convertGeoTypeToString(object_type), id, + old_name); if (dlg.exec() != QDialog::Accepted) { return; } - _geo_model->addNameForElement(geometry_name, object_type, id, dlg.getNewName()); - static_cast<GeoTreeModel*>(this->geoTabWidget->treeView->model())->setNameForItem(geometry_name, object_type, - id, _project.getGEOObjects().getElementNameByID(geometry_name, object_type, id)); + _geo_model->addNameForElement(geometry_name, object_type, id, + dlg.getNewName()); + static_cast<GeoTreeModel*>(this->geoTabWidget->treeView->model()) + ->setNameForItem(geometry_name, object_type, id, + _project.getGEOObjects().getElementNameByID( + geometry_name, object_type, id)); } -void MainWindow::showStationNameDialog(const std::string& stn_vec_name, std::size_t id) +void MainWindow::showStationNameDialog(const std::string& stn_vec_name, + std::size_t id) { - std::vector<GeoLib::Point*> const* stations = _project.getGEOObjects().getStationVec(stn_vec_name); + std::vector<GeoLib::Point*> const* stations = + _project.getGEOObjects().getStationVec(stn_vec_name); auto* const stn = static_cast<GeoLib::Station*>((*stations)[id]); SetNameDialog dlg("Station", id, stn->getName()); if (dlg.exec() != QDialog::Accepted) @@ -1203,22 +1303,23 @@ void MainWindow::showStationNameDialog(const std::string& stn_vec_name, std::siz } stn->setName(dlg.getNewName()); - static_cast<StationTreeModel*>(this->stationTabWidget->treeView->model())->setNameForItem(stn_vec_name, id, stn->getName()); + static_cast<StationTreeModel*>(this->stationTabWidget->treeView->model()) + ->setNameForItem(stn_vec_name, id, stn->getName()); } void MainWindow::showCreateStructuredGridDialog() { CreateStructuredGridDialog dlg; - connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)), - _meshModel.get(), SLOT(addMesh(MeshLib::Mesh*))); + connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)), _meshModel.get(), + SLOT(addMesh(MeshLib::Mesh*))); dlg.exec(); } void MainWindow::showMeshElementRemovalDialog() { MeshElementRemovalDialog dlg(this->_project); - connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)), - _meshModel.get(), SLOT(addMesh(MeshLib::Mesh*))); + connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)), _meshModel.get(), + SLOT(addMesh(MeshLib::Mesh*))); dlg.exec(); } @@ -1238,24 +1339,30 @@ void MainWindow::convertPointsToStations(std::string const& geo_name) } } -void MainWindow::showLineEditDialog(const std::string &geoName) +void MainWindow::showLineEditDialog(const std::string& geoName) { LineEditDialog lineEdit( *(_project.getGEOObjects().getPolylineVecObj(geoName))); - connect(&lineEdit, SIGNAL(connectPolylines(const std::string&, - std::vector<std::size_t>, double, - std::string, bool, bool)), - _geo_model.get(), SLOT(connectPolylineSegments( - const std::string&, std::vector<std::size_t>, - double, std::string, bool, bool))); + connect( + &lineEdit, + SIGNAL(connectPolylines(const std::string&, std::vector<std::size_t>, + double, std::string, bool, bool)), + _geo_model.get(), + SLOT(connectPolylineSegments(const std::string&, + std::vector<std::size_t>, double, + std::string, bool, bool))); lineEdit.exec(); } void MainWindow::showGMSHPrefsDialog() { GMSHPrefsDialog dlg(_project.getGEOObjects()); - connect(&dlg, SIGNAL(requestMeshing(std::vector<std::string> &, unsigned, double, double, double, bool)), - this, SLOT(callGMSH(std::vector<std::string> &, unsigned, double, double, double, bool))); + connect(&dlg, + SIGNAL(requestMeshing(std::vector<std::string>&, unsigned, double, + double, double, bool)), + this, + SLOT(callGMSH(std::vector<std::string>&, unsigned, double, double, + double, bool))); dlg.exec(); } @@ -1266,7 +1373,7 @@ void MainWindow::showMergeGeometriesDialog() { return; } - std::string name (dlg.getGeometryName()); + std::string name(dlg.getGeometryName()); if (_project.getGEOObjects().mergeGeometries(dlg.getSelectedGeometries(), name) < 0) { @@ -1274,7 +1381,8 @@ void MainWindow::showMergeGeometriesDialog() } } -void MainWindow::showMeshQualitySelectionDialog(MeshLib::VtkMappedMeshSource* mshSource) +void MainWindow::showMeshQualitySelectionDialog( + MeshLib::VtkMappedMeshSource* mshSource) { if (mshSource == nullptr) { @@ -1286,9 +1394,11 @@ void MainWindow::showMeshQualitySelectionDialog(MeshLib::VtkMappedMeshSource* ms { return; } - MeshLib::MeshQualityType const type (dlg.getSelectedMetric()); - MeshLib::ElementQualityInterface quality_interface(*mshSource->GetMesh(), type); - _vtkVisPipeline->showMeshElementQuality(mshSource, type, quality_interface.getQualityVector()); + MeshLib::MeshQualityType const type(dlg.getSelectedMetric()); + MeshLib::ElementQualityInterface quality_interface(*mshSource->GetMesh(), + type); + _vtkVisPipeline->showMeshElementQuality( + mshSource, type, quality_interface.getQualityVector()); if (dlg.getHistogram()) { @@ -1307,9 +1417,7 @@ void MainWindow::showDataExplorerSettingsDialog() dlg.exec(); } -void MainWindow::FEMTestStart() -{ -} +void MainWindow::FEMTestStart() {} void MainWindow::ShowWindow() { @@ -1321,11 +1429,12 @@ void MainWindow::HideWindow() this->hide(); } -void MainWindow::loadFileOnStartUp(const QString &fileName) +void MainWindow::loadFileOnStartUp(const QString& fileName) { QString ext = QFileInfo(fileName).suffix(); - if (ext=="msh" || ext=="vtu" || ext=="gli" || ext=="gml") { - this->loadFile(ImportFileType::OGS,fileName); + if (ext == "msh" || ext == "vtu" || ext == "gli" || ext == "gml") + { + this->loadFile(ImportFileType::OGS, fileName); } } @@ -1344,14 +1453,15 @@ void MainWindow::on_actionExportVTK_triggered(bool checked /*= false*/) QDir const dir = QDir(filename); settings.setValue("lastExportedFileDirectory", dir.absolutePath()); - std::string const basename = QFileInfo(filename).path().toStdString() + "/" + - QFileInfo(filename).baseName().toStdString(); + std::string const basename = + QFileInfo(filename).path().toStdString() + "/" + + QFileInfo(filename).baseName().toStdString(); TreeModelIterator it(_vtkVisPipeline.get()); ++it; while (*it) { std::string const name = basename + std::to_string(++count) + "-" + - (*it)->data(0).toString().toStdString(); + (*it)->data(0).toString().toStdString(); static_cast<VtkVisPipelineItem*>(*it)->writeToFile(name); ++it; } @@ -1362,9 +1472,10 @@ void MainWindow::on_actionExportVRML2_triggered(bool checked /*= false*/) { Q_UNUSED(checked) QSettings settings; - QString fileName = QFileDialog::getSaveFileName(this, "Save scene to VRML file", - settings.value("lastExportedFileDirectory").toString(), - "VRML files (*.wrl);;"); + QString fileName = QFileDialog::getSaveFileName( + this, "Save scene to VRML file", + settings.value("lastExportedFileDirectory").toString(), + "VRML files (*.wrl);;"); if (!fileName.isEmpty()) { QDir dir = QDir(fileName); @@ -1373,7 +1484,7 @@ void MainWindow::on_actionExportVRML2_triggered(bool checked /*= false*/) vtkVRMLExporter* exporter = vtkVRMLExporter::New(); exporter->SetFileName(fileName.toStdString().c_str()); exporter->SetRenderWindow( - visualizationWidget->vtkWidget->GetRenderWindow()); + visualizationWidget->vtkWidget->GetRenderWindow()); exporter->Write(); exporter->Delete(); } @@ -1383,9 +1494,9 @@ void MainWindow::on_actionExportObj_triggered(bool checked /*= false*/) { Q_UNUSED(checked) QSettings settings; - QString fileName = QFileDialog::getSaveFileName(this, "Save scene to Wavefront OBJ files", - settings.value("lastExportedFileDirectory").toString(), - ";;"); + QString fileName = QFileDialog::getSaveFileName( + this, "Save scene to Wavefront OBJ files", + settings.value("lastExportedFileDirectory").toString(), ";;"); if (!fileName.isEmpty()) { QDir dir = QDir(fileName); @@ -1394,7 +1505,7 @@ void MainWindow::on_actionExportObj_triggered(bool checked /*= false*/) vtkOBJExporter* exporter = vtkOBJExporter::New(); exporter->SetFilePrefix(fileName.toStdString().c_str()); exporter->SetRenderWindow( - visualizationWidget->vtkWidget->GetRenderWindow()); + visualizationWidget->vtkWidget->GetRenderWindow()); exporter->Write(); exporter->Delete(); } @@ -1416,13 +1527,13 @@ void MainWindow::createPresentationMenu() else { int count = 0; - const int currentScreen = QApplication::desktop()->screenNumber( - visualizationWidget); + const int currentScreen = + QApplication::desktop()->screenNumber(visualizationWidget); foreach (QRect screenGeo, _screenGeometries) { Q_UNUSED(screenGeo); - QAction* action = new QAction( - QString("On screen %1").arg(count), menu); + QAction* action = + new QAction(QString("On screen %1").arg(count), menu); connect(action, SIGNAL(triggered()), this, SLOT(startPresentationMode())); if (count == currentScreen) @@ -1441,14 +1552,14 @@ void MainWindow::startPresentationMode() _windowState = this->saveState(); // Get the screen number from the QAction which sent the signal - QString actionText = static_cast<QAction*> (QObject::sender())->text(); + QString actionText = static_cast<QAction*>(QObject::sender())->text(); int screen = actionText.split(" ").back().toInt(); // Move the widget to the screen and maximize it // Real fullscreen hides the menu _vtkWidget->setParent(nullptr, Qt::Window); - _vtkWidget->move(QPoint(_screenGeometries[screen].x(), - _screenGeometries[screen].y())); + _vtkWidget->move( + QPoint(_screenGeometries[screen].x(), _screenGeometries[screen].y())); //_vtkWidget->showFullScreen(); _vtkWidget->showMaximized(); -- GitLab