Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • lurpi/ogsPW
  • steffenbeese/ogs
  • HBShaoUFZ/ogs
  • vehling/ogs
  • kuateric/ogs
  • heinzej/ogs
  • MostafaMollaali/dynamic
  • GuanglinDu/ogs
  • katakurgyis/ogs
  • felikskiszkurno/ogs
  • aachaudhry/ogs
  • friederl/ogs
  • fparisio/ogs
  • Scinopode/ogs
  • MaxDoe/ogs
  • nagelt/ogs
  • zhangning737/ogs
  • ogs/ogs
  • bilke/ogs
  • montoyav/ogs
  • TomFischer/ogs
  • wenqing/ogs
  • renchao-lu/ogs
  • ChaofanChen/ogs
  • rinkk/ogs
  • WanlongCai/ogs
  • dominik-kern/ogs
  • Yonghui56/ogs
  • endJunction/ogs
  • VinayGK/ogs
  • AlirezaBGE/ogs
  • SebasTouristTrophyF/ogs
  • tengfeideng/ogs
  • joergbuchwald/ogs
  • KeitaYoshioka/ogs
  • hhutyou/debug-petsc-large
  • ThieJan/ogs
  • ArashPartow/ogs
  • skai95/ogs
  • yezhigangzju/ogs
  • PhilippSelzer/ogs
  • MartinBinder/ogs
  • MehranGhasabeh/ogs-mg
  • MManicaM/ogs
  • TobiasMeisel/ogs
  • norihiro-w/ogs
  • garibay-j/ogs
  • Christopher-McDermott/ogs
  • loewenzahm/ogs
  • aheinri5/ogs
  • RichardScottOZ/ogs
  • lagraviereScience/ogs
  • tcajuhi/ogs
  • jrandow/ogs
  • cbsilver/ogs
  • reza-taherdangkoo/ogs
  • joboog/ogs
  • basakz/ogs
  • ropaoleon/ogs
  • ShuangChen88/ogs
  • cguevaramorel/ogs
  • boyanmeng/ogs
  • XRuiWang/ogs
  • grubbymoon/ogs
  • yUHaOLiu-tj/ogs
  • FZill/ogs
  • michaelpitz/ogs
  • hhutyou/ogs
  • Lifan97/ogs
  • mattschy/ogs
  • Mojtaba-abdolkhani/ogs
  • kristofkessler/ogs
  • ozgurozansen/ogs
  • eike-radeisen/ogs-gitlab
  • DStafford/ogs
  • Max_Jaeschke/ogs
  • fwitte/ogs
  • LionAhrendt/ogs
  • emadnrz/ogs
  • laubry/ogs
  • HailongS/ogs
  • noorhasan/ogs
  • WenjieXuZJU/ogs
  • suresh199824/ogs
84 results
Show changes
Showing
with 1422 additions and 688 deletions
/**
* \file
* \author Karsten Rink
* \date 2016-01-18
* \brief Definition of the AddLayerToMeshDialog class.
*
* \copyright
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include "ui_AddLayerToMesh.h"
#include <QDialog>
#include <QLineEdit>
/**
* \brief A dialog window for adding a layer to the top or bottom of a mesh
*/
class AddLayerToMeshDialog : public QDialog, private Ui_AddLayerToMesh
{
Q_OBJECT
public:
explicit AddLayerToMeshDialog(QDialog* parent = nullptr);
/// Returns if the top layer button is selected (if false, bottom is selected).
bool isTopLayer() const { return this->topButton->isChecked(); };
/// Returns the thickness of the new layer.
double getThickness() const { return this->thicknessEdit->text().toDouble(); };
/// Returns the name of the new mesh.
std::string getName() const { return this->nameEdit->text().toStdString(); };
private slots:
/// Instructions if the OK-Button has been pressed.
void accept() override;
/// Instructions if the Cancel-Button has been pressed.
void reject() override;
};
......@@ -5,21 +5,23 @@
* \brief Definition of the BaseItem class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef BASEITEM_H
#define BASEITEM_H
#pragma once
#include "Point.h"
#include "VtkStationSource.h"
#include "VtkVis/VtkStationSource.h"
#include <QModelIndex>
#include <vtkPolyDataAlgorithm.h>
namespace GeoLib
{
class Point;
}
/**
* \brief A BaseItem contains additional Information about a subtree in the StationTreeModel.
*
......@@ -29,37 +31,36 @@
class BaseItem
{
public:
BaseItem(const QString &listName, const std::vector<GeoLib::Point*>* stations = NULL )
: _stations(stations), _vtkSource(VtkStationSource::New())
{
// create the vtk-object for 3d-visualisation of this list
static_cast<VtkStationSource*>(_vtkSource)->setStations(stations);
static_cast<VtkStationSource*>(_vtkSource)->SetName(listName);
}
explicit BaseItem(const QString& listName,
const std::vector<GeoLib::Point*>* stations = nullptr)
: _stations(stations), _vtkSource(VtkStationSource::New())
{
// create the vtk-object for 3d-visualisation of this list
static_cast<VtkStationSource*>(_vtkSource)->setStations(stations);
static_cast<VtkStationSource*>(_vtkSource)->SetName(listName);
}
~BaseItem()
{
_vtkSource->Delete();
}
~BaseItem()
{
_vtkSource->Delete();
}
/// Returns the associated QModelIndex which belongs to a Qt model
QModelIndex modelIndex() const { return _modelIndex; }
/// Returns the associated QModelIndex which belongs to a Qt model
QModelIndex modelIndex() const { return _modelIndex; }
/// Sets the model index
void setModelIndex( QModelIndex index ) { _modelIndex = index; }
/// Sets the model index
void setModelIndex( QModelIndex index ) { _modelIndex = index; }
const std::vector<GeoLib::Point*>* getStations() { return _stations; }
const std::vector<GeoLib::Point*>* getStations() { return _stations; }
/// Returns the Vtk polydata source object
vtkPolyDataAlgorithm* vtkSource() const { return _vtkSource; }
/// Returns the Vtk polydata source object
vtkPolyDataAlgorithm* vtkSource() const { return _vtkSource; }
private:
QModelIndex _modelIndex;
const std::vector<GeoLib::Point*>* _stations;
QModelIndex _modelIndex;
const std::vector<GeoLib::Point*>* _stations;
/// The Vtk data source object. This is the starting point for a Vtk data
/// visualization pipeline.
vtkPolyDataAlgorithm* _vtkSource;
/// The Vtk data source object. This is the starting point for a Vtk data
/// visualization pipeline.
vtkPolyDataAlgorithm* _vtkSource;
};
#endif //BASEITEM_H
# Source files
set(SOURCES
ColorTableModel.cpp
ColorTableView.cpp
CondFromRasterDialog.cpp
DataExplorerSettingsDialog.cpp
DirectConditionGenerator.cpp
ElementTreeModel.cpp
ElementTreeView.cpp
GEOModels.cpp
GeoOnMeshMappingDialog.cpp
GeoTabWidget.cpp
GeoTreeModel.cpp
GeoTreeView.cpp
GMSHPrefsDialog.cpp
LicenseDialog.cpp
LinearEditDialog.cpp
LineEditDialog.cpp
MergeGeometriesDialog.cpp
MeshAnalysisDialog.cpp
MeshElementRemovalDialog.cpp
MeshQualitySelectionDialog.cpp
MeshValueEditDialog.cpp
ModellingTabWidget.cpp
ModelTreeItem.cpp
MeshLayerEditDialog.cpp
MshItem.cpp
MshModel.cpp
MshTabWidget.cpp
MshView.cpp
NetCdfConfigureDialog.cpp
SaveMeshDialog.cpp
SelectMeshDialog.cpp
SetNameDialog.cpp
SHPImportDialog.cpp
StationTabWidget.cpp
StationTreeModel.cpp
StationTreeView.cpp
SurfaceExtractionDialog.cpp
AddFaultsToVoxelGridDialog.cpp
AddLayerToMeshDialog.cpp
ColorTableModel.cpp
ColorTableView.cpp
CondFromRasterDialog.cpp
CreateStructuredGridDialog.cpp
DataExplorerSettingsDialog.cpp
DirectConditionGenerator.cpp
ElementTreeModel.cpp
ElementTreeView.cpp
FemConditionModel.cpp
FemConditionView.cpp
GEOModels.cpp
GeoOnMeshMappingDialog.cpp
GeoTabWidget.cpp
GeoTreeModel.cpp
GeoTreeView.cpp
GMSHPrefsDialog.cpp
Layers2GridDialog.cpp
LicenseDialog.cpp
LinearEditDialog.cpp
LineEditDialog.cpp
MergeGeometriesDialog.cpp
MeshAnalysisDialog.cpp
MeshElementRemovalDialog.cpp
MeshItem.cpp
MeshLayerEditDialog.cpp
MeshMapping2DDialog.cpp
MeshModel.cpp
MeshQualitySelectionDialog.cpp
MeshTabWidget.cpp
MeshValueEditDialog.cpp
MeshView.cpp
ModellingTabWidget.cpp
ModelTreeItem.cpp
ProcessModel.cpp
ProcessView.cpp
RasterDataToMeshDialog.cpp
SaveMeshDialog.cpp
SelectMeshDialog.cpp
SetNameDialog.cpp
SHPImportDialog.cpp
StationTabWidget.cpp
StationTreeModel.cpp
StationTreeView.cpp
SurfaceExtractionDialog.cpp
TranslateDataDialog.cpp
Vtu2GridDialog.cpp
)
# Header files
set(HEADERS
BaseItem.h
CondItem.h
DirectConditionGenerator.h
CondObjectListItem.h
GeoObjectListItem.h
GeoTreeItem.h
ModelTreeItem.h
MshItem.h
ColorTableModel.h
ColorTableView.h
CondFromRasterDialog.h
DataExplorerSettingsDialog.h
ElementTreeModel.h
ElementTreeView.h
GEOModels.h
GeoOnMeshMappingDialog.h
GeoTabWidget.h
GeoTreeModel.h
GeoTreeView.h
GMSHPrefsDialog.h
LicenseDialog.h
LinearEditDialog.h
LineEditDialog.h
MergeGeometriesDialog.h
MeshAnalysisDialog.h
MeshElementRemovalDialog.h
MeshQualitySelectionDialog.h
MeshValueEditDialog.h
ModellingTabWidget.h
MeshLayerEditDialog.h
MshModel.h
MshTabWidget.h
MshView.h
NetCdfConfigureDialog.h
SaveMeshDialog.h
SelectMeshDialog.h
SetNameDialog.h
SHPImportDialog.h
StationTabWidget.h
StationTreeModel.h
StationTreeView.h
SurfaceExtractionDialog.h
AddFaultsToVoxelGridDialog.h
AddLayerToMeshDialog.h
BaseItem.h
ColorTableModel.h
ColorTableView.h
CondFromRasterDialog.h
CondItem.h
CreateStructuredGridDialog.h
DataExplorerSettingsDialog.h
DirectConditionGenerator.h
ElementTreeModel.h
ElementTreeView.h
FemConditionModel.h
FemConditionView.h
GEOModels.h
GeoObjectListItem.h
GeoOnMeshMappingDialog.h
GeoTabWidget.h
GeoTreeItem.h
GeoTreeModel.h
GeoTreeView.h
GMSHPrefsDialog.h
Layers2GridDialog.h
LicenseDialog.h
LinearEditDialog.h
LineEditDialog.h
MergeGeometriesDialog.h
MeshAnalysisDialog.h
MeshElementRemovalDialog.h
MeshItem.h
MeshLayerEditDialog.h
MeshMapping2DDialog.h
MeshModel.h
MeshQualitySelectionDialog.h
MeshTabWidget.h
MeshValueEditDialog.h
MeshView.h
ModellingTabWidget.h
ModelTreeItem.h
ProcessModel.h
ProcessVarItem.h
ProcessView.h
RasterDataToMeshDialog.h
SaveMeshDialog.h
SelectMeshDialog.h
SetNameDialog.h
SHPImportDialog.h
StationTabWidget.h
StationTreeModel.h
StationTreeView.h
SurfaceExtractionDialog.h
Vtu2GridDialog.h
)
# Put filter in a folder
# Visual Studio folder
source_group("Dialog Header Files" REGULAR_EXPRESSION "[.]*Dialog.h")
source_group("Dialog Source Files" REGULAR_EXPRESSION "[.]*Dialog.cpp")
source_group("Data Model Header Files" REGULAR_EXPRESSION "[.]*Item.h|[.]*Model.h|[.]*View.h")
source_group("Data Model Source Files" REGULAR_EXPRESSION "[.]*Item.cpp|[.]*Model.cpp|[.]*View.cpp")
source_group(
"Data Model Header Files"
REGULAR_EXPRESSION "[.]*Item.h|[.]*Model.h|[.]*View.h"
)
source_group(
"Data Model Source Files"
REGULAR_EXPRESSION "[.]*Item.cpp|[.]*Model.cpp|[.]*View.cpp"
)
file(GLOB UIS CONFIGURE_DEPENDS *.ui)
source_group("UI Files" FILES ${UIS})
# Include the headers which are generated by uic and moc
# and include additional header
set(SOURCE_DIR_REL ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
set(GUI_SOURCE_DIR_REL ${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../Base
${CMAKE_CURRENT_BINARY_DIR}/DiagramView
${CMAKE_CURRENT_BINARY_DIR}/StratView
${SOURCE_DIR_REL}/BaseLib
${SOURCE_DIR_REL}/MathLib
${SOURCE_DIR_REL}/GeoLib
${SOURCE_DIR_REL}/MeshGeoToolsLib
${SOURCE_DIR_REL}/MeshLib
${SOURCE_DIR_REL}/FileIO
${CMAKE_CURRENT_SOURCE_DIR}/DiagramView
${CMAKE_CURRENT_SOURCE_DIR}/StratView
${GUI_SOURCE_DIR_REL}/Base
${GUI_SOURCE_DIR_REL}/VtkVis
)
if(VTKOSGCONVERTER_FOUND)
include_directories(${VTKOSGCONVERTER_INCLUDE_DIRS})
endif()
if(GEOTIFF_FOUND)
include_directories(${GEOTIFF_INCLUDE_DIRS})
include_directories(${GEOTIFF_INCLUDE_DIRS})
endif() # GEOTIFF_FOUND
# Put moc files in a project folder
source_group("UI Files" REGULAR_EXPRESSION "\\w*\\.ui")
source_group("Moc Files" REGULAR_EXPRESSION "moc_.*")
# TODO: Workaround for #3172.
set(CMAKE_AUTOUIC NO)
qt5_wrap_ui(genUiHeaders ${UIS})
# Create the library
add_library(QtDataView STATIC
${SOURCES}
${HEADERS}
ogs_add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS} ${genUiHeaders})
target_include_directories(
QtDataView PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
)
# Link Qt library
target_link_libraries(QtDataView PUBLIC Qt4::QtCore Qt4::QtGui)
target_link_libraries(QtDataView INTERFACE
FileIO
QtBase
target_link_libraries(
QtDataView
PUBLIC GeoLib MeshGeoToolsLib MeshLib QtBase VtkVis
PRIVATE BaseLib
MathLib
ApplicationsFileIO
QtDiagramView
QtStratView
DataHolderLib
Qt5::Core
Qt5::Gui
)
add_dependencies(QtDataView QtDiagramView QtStratView)
include(AddCatalystDependency)
ADD_CATALYST_DEPENDENCY(QtDataView)
if(GEOTIFF_FOUND)
target_link_libraries( QtDataView INTERFACE ${GEOTIFF_LIBRARIES} )
endif () # GEOTIFF_FOUND
target_compile_definitions(QtDataView PRIVATE GEOTIFF_FOUND)
target_link_libraries(QtDataView PRIVATE ${GEOTIFF_LIBRARIES})
endif() # GEOTIFF_FOUND
add_autogen_include(QtDataView)
set_property(TARGET QtDataView PROPERTY FOLDER "DataExplorer")
......@@ -5,7 +5,7 @@
* \brief Implementation of the ColorTableModel class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
......@@ -14,95 +14,105 @@
#include "ColorTableModel.h"
ColorTableModel::ColorTableModel( const std::map<std::string, GeoLib::Color*> &colorLookupTable,
QObject* parent /*= 0*/ )
ColorTableModel::ColorTableModel(
const std::map<std::string, DataHolderLib::Color*>& colorLookupTable,
QObject* parent /*= 0*/)
{
Q_UNUSED(parent)
Q_UNUSED(parent)
this->buildTable(colorLookupTable);
this->buildTable(colorLookupTable);
}
ColorTableModel::~ColorTableModel()
{
}
ColorTableModel::~ColorTableModel() = default;
int ColorTableModel::columnCount( const QModelIndex& parent /*= QModelIndex()*/ ) const
int ColorTableModel::columnCount(
const QModelIndex& parent /*= QModelIndex()*/) const
{
Q_UNUSED(parent)
Q_UNUSED(parent)
return 2;
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)
return QVariant();
if (orientation == Qt::Horizontal)
{
switch (section)
{
case 0: return "Name";
case 1: return "Colour";
default: return QVariant();
}
}
else
return QString("Row %1").arg(section);
if (role != Qt::DisplayRole)
{
return QVariant();
}
if (orientation == Qt::Horizontal)
{
switch (section)
{
case 0:
return "Name";
case 1:
return "Colour";
default:
return QVariant();
}
}
else
{
return QString("Row %1").arg(section);
}
}
QVariant ColorTableModel::data( const QModelIndex& index, int role ) const
QVariant ColorTableModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= _listOfPairs.size() || index.row() < 0)
return QVariant();
if (role == Qt::DisplayRole)
{
QPair<QString, QColor> pair = _listOfPairs.at(index.row());
switch (index.column())
{
case 0:
return pair.first;
case 1:
return pair.second;
default:
return QVariant();
}
}
return QVariant();
if (!index.isValid())
{
return QVariant();
}
if (index.row() >= _listOfPairs.size() || index.row() < 0)
{
return QVariant();
}
if (role == Qt::DisplayRole)
{
QPair<QString, QColor> pair = _listOfPairs.at(index.row());
switch (index.column())
{
case 0:
return pair.first;
case 1:
return pair.second;
default:
return QVariant();
}
}
return QVariant();
}
bool ColorTableModel::buildTable(const std::map<std::string, GeoLib::Color*> &colorLookupTable)
bool ColorTableModel::buildTable(
const std::map<std::string, DataHolderLib::Color*>& colorLookupTable)
{
int count = 0;
beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1);
for (std::map<std::string, GeoLib::Color*>::const_iterator it = colorLookupTable.begin();
it != colorLookupTable.end(); ++it)
{
QColor color((*(it->second))[0], (*(it->second))[1], (*(it->second))[2]);
QString name(QString::fromStdString(it->first));
/* Saudi Arabia strat names *
if (it->first.compare("1")==0) name="Buweib";
if (it->first.compare("2")==0) name="Wasia";
if (it->first.compare("3")==0) name="Aruma";
if (it->first.compare("4")==0) name="Umm Er Radhuma";
if (it->first.compare("5")==0) name="Rus";
if (it->first.compare("6")==0) name="Dammam";
if (it->first.compare("7")==0) name="Neogene";
*/
QPair<QString, QColor> pair(name, color);
_listOfPairs.insert(count++, pair);
}
endInsertRows();
return true;
int count = 0;
beginInsertRows(QModelIndex(), 0, colorLookupTable.size() - 1);
for (const auto& row : colorLookupTable)
{
QColor color((*row.second)[0], (*row.second)[1], (*row.second)[2]);
QString name(QString::fromStdString(row.first));
/* Saudi Arabia strat names *
if (it->first.compare("1")==0) name="Buweib";
if (it->first.compare("2")==0) name="Wasia";
if (it->first.compare("3")==0) name="Aruma";
if (it->first.compare("4")==0) name="Umm Er Radhuma";
if (it->first.compare("5")==0) name="Rus";
if (it->first.compare("6")==0) name="Dammam";
if (it->first.compare("7")==0) name="Neogene";
*/
QPair<QString, QColor> pair(name, color);
_listOfPairs.insert(count++, pair);
}
endInsertRows();
return true;
}
......@@ -5,48 +5,48 @@
* \brief Definition of the ColorTableModel class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef COLORTABLEMODEL_H
#define COLORTABLEMODEL_H
#pragma once
#include "Color.h"
#include <QAbstractTableModel>
#include <QColor>
#include "Applications/DataHolderLib/Color.h"
/**
* The PolylinesModel is a Qt model which represents Polylines.
*/
class ColorTableModel : public QAbstractTableModel
{
Q_OBJECT
Q_OBJECT
public:
ColorTableModel( const std::map<std::string, GeoLib::Color*> &colorLookupTable,
QObject* parent = 0 );
~ColorTableModel();
explicit ColorTableModel(
const std::map<std::string, DataHolderLib::Color*>& colorLookupTable,
QObject* parent = nullptr);
~ColorTableModel() override;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data( const QModelIndex& index, int role ) const;
QVariant data(const QModelIndex& index, int role) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const
{
Q_UNUSED (parent);
return _listOfPairs.size();
}
int rowCount(const QModelIndex& parent = QModelIndex()) const override
{
Q_UNUSED (parent);
return _listOfPairs.size();
}
QVariant headerData( int section, Qt::Orientation orientation,
int role /*= Qt::DisplayRole*/ ) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role /*= Qt::DisplayRole*/) const override;
private:
bool buildTable( const std::map<std::string, GeoLib::Color*> &colorLookupTable );
bool buildTable( const std::map<std::string, DataHolderLib::Color*> &colorLookupTable );
QList< QPair<QString, QColor> > _listOfPairs;
QList< QPair<QString, QColor> > _listOfPairs;
};
#endif // COLORTABLEMODEL_H
......@@ -5,7 +5,7 @@
* \brief Implementation of the ColorTableView class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
......@@ -14,41 +14,45 @@
*/
#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);
this->resizeColumnsToContents();
this->resizeRowsToContents();
this->verticalHeader()->hide();
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->resizeColumnsToContents();
this->resizeRowsToContents();
}
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)
{
if (qVariantCanConvert<QColor>(index.data()))
{
val = qVariantValue<QColor>(index.data());
QBrush brush(val);
painter->fillRect(option.rect, brush);
}
}
else
QItemDelegate::paint(painter, option, index);
QColor val;
if (index.column() == 1)
{
if (index.data().canConvert(QMetaType::QColor))
{
val = index.data().value<QColor>();
QBrush brush(val);
painter->fillRect(option.rect, brush);
}
}
else
{
QItemDelegate::paint(painter, option, index);
}
}
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() )
s.setHeight((int)(0.5 * s.height()));
return s;
QSize s = QItemDelegate::sizeHint(option, index);
if (s.isValid())
{
s.setHeight(static_cast<int>(0.5 * s.height()));
}
return s;
}
......@@ -5,47 +5,46 @@
* \brief Definition of the ColorTableView class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef COLORTABLEVIEW_H
#define COLORTABLEVIEW_H
#pragma once
#include <QItemDelegate>
#include <QTableView>
/**
* A QTableView to display colour lookup tables.
* A QTableView to display colour lookup tables.
*/
class ColorTableView : public QTableView
{
Q_OBJECT
Q_OBJECT
public:
/// Constructor
ColorTableView(QWidget* parent = 0);
/// Constructor
explicit ColorTableView(QWidget* parent = nullptr);
};
/**
* A delegate class to manage properties of ColorTableView.
* A delegate class to manage properties of ColorTableView.
*/
class ColorTableViewDelegate : public QItemDelegate
{
Q_OBJECT
Q_OBJECT
public:
/// Constructor
ColorTableViewDelegate(QWidget* parent = 0) : QItemDelegate(parent) {}
/// Overwrites the paint-method to set user-defined properties instead of the default properties.
void paint(QPainter* painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const;
/// Constructor
explicit ColorTableViewDelegate(QWidget* parent = nullptr)
: QItemDelegate(parent)
{
}
/// Overwrites the paint-method to set user-defined properties instead of the default properties.
void paint(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const override;
QSize sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const override;
};
#endif // COLORTABLEVIEW_H
......@@ -35,7 +35,7 @@
</size>
</property>
<property name="text">
<string>Mesh</string>
<string>Mesh:</string>
</property>
</widget>
</item>
......@@ -70,7 +70,7 @@
</size>
</property>
<property name="text">
<string>Raster</string>
<string>Raster:</string>
</property>
</widget>
</item>
......
......@@ -5,7 +5,7 @@
* \brief Implementation of the CondFromRasterDialog class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
......@@ -13,115 +13,121 @@
*/
#include "CondFromRasterDialog.h"
#include "Mesh.h"
#include <QFileDialog>
#include <QSettings>
#include <utility>
#include "Base/OGSError.h"
#include "Base/StrictDoubleValidator.h"
#include "DirectConditionGenerator.h"
#include "OGSError.h"
#include "StrictDoubleValidator.h"
#include "MeshLib/Mesh.h"
CondFromRasterDialog::CondFromRasterDialog(const std::vector<MeshLib::Mesh*> &msh_vec, QDialog* parent)
: QDialog(parent), _msh_vec(msh_vec)
CondFromRasterDialog::CondFromRasterDialog(std::vector<MeshLib::Mesh*> msh_vec,
QDialog* parent)
: QDialog(parent), _msh_vec(std::move(msh_vec))
{
setupUi(this);
setupUi(this);
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->setEnabled(false);
_scale_validator = new StrictDoubleValidator(-1e+10, 1e+20, 5);
this->scalingEdit->setText("1.0");
this->scalingEdit->setValidator(_scale_validator);
for (std::vector<MeshLib::Mesh*>::const_iterator it = _msh_vec.begin(); it != _msh_vec.end(); ++it)
this->meshBox->addItem(QString::fromStdString((*it)->getName()));
for (auto mesh : _msh_vec)
{
this->meshBox->addItem(QString::fromStdString(mesh->getName()));
}
this->directButton->setChecked(true);
this->directButton->setChecked(true);
}
CondFromRasterDialog::~CondFromRasterDialog()
{
delete _scale_validator;
delete _scale_validator;
}
void CondFromRasterDialog::on_selectButton_pressed()
{
QSettings settings;
QSettings settings;
#ifdef GEOTIFF_FOUND
QString geotiffExtension(" *.tif");
QString geotiffExtension(" *.tif");
#else
QString geotiffExtension("");
QString geotiffExtension("");
#endif
QString fileName = QFileDialog::getOpenFileName(this, "Select raster file",
settings.value("lastOpenedRasterFileDirectory").toString(),
QString("Raster files (*.asc *.grd);;").arg(geotiffExtension));
if (!fileName.isEmpty())
{
this->rasterEdit->setText(fileName);
QFileInfo fi(fileName);
settings.setValue("lastOpenedRasterFileDirectory", fi.absolutePath());
}
QString fileName = QFileDialog::getOpenFileName(
this, "Select raster file",
settings.value("lastOpenedRasterFileDirectory").toString(),
QString("Raster files (*.asc *.grd);;").arg(geotiffExtension));
if (!fileName.isEmpty())
{
this->rasterEdit->setText(fileName);
QFileInfo fi(fileName);
settings.setValue("lastOpenedRasterFileDirectory", fi.absolutePath());
}
}
void CondFromRasterDialog::accept()
{
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<size_t,double> > direct_values;
if (mesh_name.empty())
{
OGSError::box("No mesh selected.");
return;
}
if (raster_name.empty())
{
OGSError::box("No raster selected.");
return;
}
MeshLib::Mesh* mesh (NULL);
for (size_t i=0; i<_msh_vec.size(); i++)
if (_msh_vec[i]->getName().compare(mesh_name) == 0)
{
mesh = _msh_vec[i];
break;
}
if (this->directButton->isChecked())
{
DirectConditionGenerator dcg;
direct_values = dcg.directToSurfaceNodes(*mesh, raster_name);
//dcg.writeToFile(direct_node_name);
}
else
{
if (scaling_factor <= 0)
{
OGSError::box("No valid scaling factor given.");
return;
}
MeshLib::Mesh* new_mesh = const_cast<MeshLib::Mesh*>(mesh);
DirectConditionGenerator dcg;
direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name, scaling_factor);
//dcg.writeToFile(direct_node_name);
}
//emit directNodesWritten(direct_node_name);
emit transmitDisValues(direct_values);
this->done(QDialog::Accepted);
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;
if (mesh_name.empty())
{
OGSError::box("No mesh selected.");
return;
}
if (raster_name.empty())
{
OGSError::box("No raster selected.");
return;
}
MeshLib::Mesh* mesh(nullptr);
for (auto mesh_ : _msh_vec)
{
if (mesh_->getName() == mesh_name)
{
mesh = mesh_;
break;
}
}
if (this->directButton->isChecked())
{
DirectConditionGenerator dcg;
direct_values = dcg.directToSurfaceNodes(*mesh, raster_name);
// dcg.writeToFile(direct_node_name);
}
else
{
if (scaling_factor <= 0)
{
OGSError::box("No valid scaling factor given.");
return;
}
auto* new_mesh = const_cast<MeshLib::Mesh*>(mesh);
DirectConditionGenerator dcg;
direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name,
scaling_factor);
// dcg.writeToFile(direct_node_name);
}
// emit directNodesWritten(direct_node_name);
emit transmitDisValues(direct_values);
this->done(QDialog::Accepted);
}
void CondFromRasterDialog::reject()
{
this->done(QDialog::Rejected);
this->done(QDialog::Rejected);
}
void CondFromRasterDialog::on_integrateButton_toggled(bool isSelected)
{
this->scalingEdit->setEnabled(isSelected);
this->scalingEdit->setEnabled(isSelected);
}
......@@ -5,21 +5,20 @@
* \brief Definition of the CondFromRasterDialog class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef CONDFROMRASTERDIALOG_H
#define CONDFROMRASTERDIALOG_H
#pragma once
#include "ui_CondFromRaster.h"
#include <QDialog>
namespace MeshLib {
class Mesh;
class Mesh;
}
class StrictDoubleValidator;
......@@ -29,29 +28,28 @@ class StrictDoubleValidator;
*/
class CondFromRasterDialog : public QDialog, private Ui_CondFromRaster
{
Q_OBJECT
Q_OBJECT
public:
CondFromRasterDialog(const std::vector<MeshLib::Mesh*> &msh_vec, QDialog* parent = 0);
~CondFromRasterDialog(void);
explicit CondFromRasterDialog(std::vector<MeshLib::Mesh*> msh_vec,
QDialog* parent = nullptr);
~CondFromRasterDialog() override;
private:
const std::vector<MeshLib::Mesh*> _msh_vec;
StrictDoubleValidator* _scale_validator;
const std::vector<MeshLib::Mesh*> _msh_vec;
StrictDoubleValidator* _scale_validator;
private slots:
void on_integrateButton_toggled(bool isSelected);
void on_selectButton_pressed();
void on_integrateButton_toggled(bool isSelected);
void on_selectButton_pressed();
/// Instructions if the OK-Button has been pressed.
void accept();
/// Instructions if the OK-Button has been pressed.
void accept() override;
/// Instructions if the Cancel-Button has been pressed.
void reject();
/// Instructions if the Cancel-Button has been pressed.
void reject() override;
signals:
void directNodesWritten(std::string);
void transmitDisValues(std::vector< std::pair<std::size_t,double> >);
void directNodesWritten(std::string);
void transmitDisValues(std::vector< std::pair<std::size_t,double> >);
};
#endif //CONDFROMRASTERDIALOG_H
/**
* \file
* \author Karsten Rink
* \date 2010-10-20
* \brief Definition of the CondItem class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef CONDITEM_H
#define CONDITEM_H
#pragma once
#include <memory>
#include "Applications/DataHolderLib/FemCondition.h"
#include "Base/TreeItem.h"
#include "FEMCondition.h"
#include "TreeItem.h"
#include "VtkPointsSource.h"
#include <QList>
#include <QVariant>
/**
* \brief A TreeItem containing a condition of a FEM (BC, IC or ST).
* \brief A TreeItem containing a boundary condition or source term
* \sa TreeItem
*/
class CondItem : public TreeItem
{
public:
/// Constructor
CondItem(const QList<QVariant> &data, TreeItem* parent, const FEMCondition* cond)
: TreeItem(data, parent), _item(cond)
{
}
/// Constructor
CondItem(const QList<QVariant>& data, TreeItem* parent,
DataHolderLib::FemCondition* cond)
: TreeItem(data, parent), _cond(cond)
{
}
~CondItem() {}
/// Returns the FEM Condition associated with the item.
DataHolderLib::FemCondition* getCondition() const { return _cond; }
/// Returns the FEM Condition associated with the item.
const FEMCondition* getItem() { return _item; }
/// Returns the geo-object on which the condition is placed.
const GeoLib::GeoObject* getGeoObject() { return this->getGeoObject(); }
QString const getName() const { return data(0).toString(); }
private:
const FEMCondition* _item;
DataHolderLib::FemCondition* _cond;
};
#endif //CONDITEM_H
/**
* \file
* \author Karsten Rink
* \date 2011-04-05
* \brief Definition of the CondObjectListItem class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*
*/
#ifndef CONDOBJECTLISTITEM_H
#define CONDOBJECTLISTITEM_H
#include "FEMCondition.h"
#include "TreeItem.h"
#include "VtkConditionSource.h"
#include <QModelIndex>
#include <vtkPolyDataAlgorithm.h>
#include <vtkThresholdPoints.h>
/**
* \brief The CondObjectListItem is the TreeItem that contains the subtree for either initial conditions,
* boundary conditions source terms. This item also contains the vtk source-item for visualisation of this
* information and the indices of the associated geometry-objects.
* Upon creation the type of condition needs to be defined and the vector of points of the associated geometry
* is needed for created of the vtk-object.
* The actual FEM Condtions are added using the addCondition()-method.
* \sa TreeItem
*/
class CondObjectListItem : public TreeItem
{
public:
/// Constructor for the TreeItem specifying FEM Conditions.
CondObjectListItem(const QList<QVariant> &data,
TreeItem* parent,
FEMCondition* cond,
const std::vector<GeoLib::Point*>* points)
: TreeItem(data, parent), _vtkSource(VtkConditionSource::New()), _type(cond->getCondType()),
_cond_vec(new std::vector<FEMCondition*>)
{
_cond_vec->push_back(cond);
QString display_name = parent->data(0).toString().append(" - ").append(
QString::fromStdString(FEMCondition::condTypeToString(_type)));
static_cast<VtkConditionSource*>(_vtkSource)->setData( points, _cond_vec);
static_cast<VtkConditionSource*>(_vtkSource)->SetName( display_name );
}
~CondObjectListItem()
{
_vtkSource->Delete();
delete _cond_vec;
}
/// Adds FEMCondtion for construction of VTK object.
void addCondition(FEMCondition* cond)
{
_cond_vec->push_back(cond);
_vtkSource->Modified();
}
/// Returns the type of geo-objects contained in the subtree of this item.
FEMCondition::CondType getType() const { return _type; };
/// Returns the Vtk polydata source object
vtkPolyDataAlgorithm* vtkSource() const { return _vtkSource; };
private:
/// The Vtk data source object. This is the starting point for a Vtk data visualization pipeline.
vtkPolyDataAlgorithm* _vtkSource;
FEMCondition::CondType _type;
std::vector<FEMCondition*>* _cond_vec;
};
#endif //CONDOBJECTLISTITEM_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateStructuredGrid</class>
<widget class="QDialog" name="CreateStructuredGrid">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>490</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>490</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>490</height>
</size>
</property>
<property name="windowTitle">
<string>Create Structured Mesh</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="elementTypeBox">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Element type</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>20</number>
</property>
<item row="3" column="0">
<widget class="QRadioButton" name="prismButton">
<property name="text">
<string>Prism</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="quadButton">
<property name="text">
<string>Quad</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="hexButton">
<property name="text">
<string>Hex</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="lineButton">
<property name="text">
<string>Line</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="triButton">
<property name="text">
<string>Triangle</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="paramBox">
<property name="title">
<string>Mesh size</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="verticalSpacing">
<number>20</number>
</property>
<item row="6" column="1">
<widget class="QLineEdit" name="zElemEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="yElemLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Elements in y</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="xLengthEdit">
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="elemExtentButton">
<property name="text">
<string>Element extent</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="xElemLabel">
<property name="text">
<string>Elements in x</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="zElemLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Elements in z</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="meshExtentButton">
<property name="text">
<string>Mesh extent</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="yLengthLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Length in y</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="yElemEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="xElemEdit">
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="zLengthEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="xLengthLabel">
<property name="text">
<string>Length in x</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="zLengthLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Length in z</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="yLengthEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="originBox">
<property name="title">
<string>Origin</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="xOriginLabel">
<property name="text">
<string>x:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="zOriginLabel">
<property name="text">
<string> z:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="yOriginEdit">
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="yOriginLabel">
<property name="text">
<string> y:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="xOriginEdit">
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLineEdit" name="zOriginEdit">
<property name="text">
<string>0.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="meshNameLabel">
<property name="text">
<string>Mesh name:</string>
</property>
<property name="margin">
<number>11</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="meshNameEdit">
<property name="text">
<string>StructuredMesh</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>meshNameEdit</tabstop>
<tabstop>lineButton</tabstop>
<tabstop>triButton</tabstop>
<tabstop>quadButton</tabstop>
<tabstop>prismButton</tabstop>
<tabstop>hexButton</tabstop>
<tabstop>meshExtentButton</tabstop>
<tabstop>elemExtentButton</tabstop>
<tabstop>xLengthEdit</tabstop>
<tabstop>yLengthEdit</tabstop>
<tabstop>zLengthEdit</tabstop>
<tabstop>xElemEdit</tabstop>
<tabstop>yElemEdit</tabstop>
<tabstop>zElemEdit</tabstop>
<tabstop>xOriginEdit</tabstop>
<tabstop>yOriginEdit</tabstop>
<tabstop>zOriginEdit</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CreateStructuredGrid</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>229</x>
<y>364</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CreateStructuredGrid</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>297</x>
<y>361</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/**
* \file
* \author Karsten Rink
* \date 2016-02-04
* \brief Implementation of the CreateStructuredGridDialog class.
*
* \copyright
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "CreateStructuredGridDialog.h"
#include <QIntValidator>
#include "Base/OGSError.h"
#include "Base/StrictDoubleValidator.h"
#include "GeoLib/Point.h"
#include "MeshToolsLib/MeshGenerators/MeshGenerator.h"
CreateStructuredGridDialog::CreateStructuredGridDialog(QDialog* parent)
: QDialog(parent)
{
setupUi(this);
setValidators();
}
void CreateStructuredGridDialog::setValidators()
{
auto* origin_x_validator = new StrictDoubleValidator(this);
this->xOriginEdit->setValidator(origin_x_validator);
auto* origin_y_validator = new StrictDoubleValidator(this);
this->yOriginEdit->setValidator(origin_y_validator);
auto* origin_z_validator = new StrictDoubleValidator(this);
this->zOriginEdit->setValidator(origin_z_validator);
auto* x_length_validator = new StrictDoubleValidator(0, 10000000, 10, this);
this->xLengthEdit->setValidator(x_length_validator);
auto* y_length_validator = new StrictDoubleValidator(0, 10000000, 10, this);
this->yLengthEdit->setValidator(y_length_validator);
auto* z_length_validator = new StrictDoubleValidator(0, 10000000, 10, this);
this->zLengthEdit->setValidator(z_length_validator);
auto* x_n_elem_validator = new QIntValidator(1, 10000000, this);
this->xElemEdit->setValidator(x_n_elem_validator);
auto* y_n_elem_validator = new QIntValidator(1, 10000000, this);
this->yElemEdit->setValidator(y_n_elem_validator);
auto* z_n_elem_validator = new QIntValidator(1, 10000000, this);
this->zElemEdit->setValidator(z_n_elem_validator);
}
void CreateStructuredGridDialog::on_lineButton_toggled() const
{
this->yLengthLabel->setEnabled(false);
this->yLengthEdit->setEnabled(false);
this->zLengthLabel->setEnabled(false);
this->zLengthEdit->setEnabled(false);
this->yElemLabel->setEnabled(false);
this->yElemEdit->setEnabled(false);
this->zElemLabel->setEnabled(false);
this->zElemEdit->setEnabled(false);
}
void CreateStructuredGridDialog::enable2dWidgets() const
{
this->yLengthLabel->setEnabled(true);
this->yLengthEdit->setEnabled(true);
this->zLengthLabel->setEnabled(false);
this->zLengthEdit->setEnabled(false);
this->yElemLabel->setEnabled(true);
this->yElemEdit->setEnabled(true);
this->zElemLabel->setEnabled(false);
this->zElemEdit->setEnabled(false);
}
void CreateStructuredGridDialog::enable3dWidgets() const
{
this->yLengthLabel->setEnabled(true);
this->yLengthEdit->setEnabled(true);
this->zLengthLabel->setEnabled(true);
this->zLengthEdit->setEnabled(true);
this->yElemLabel->setEnabled(true);
this->yElemEdit->setEnabled(true);
this->zElemLabel->setEnabled(true);
this->zElemEdit->setEnabled(true);
}
void CreateStructuredGridDialog::on_meshExtentButton_toggled()
{
this->xLengthLabel->setText("Mesh size in x");
this->yLengthLabel->setText("Mesh size in y");
this->zLengthLabel->setText("Mesh size in z");
}
void CreateStructuredGridDialog::on_elemExtentButton_toggled()
{
this->xLengthLabel->setText("Element size in x");
this->yLengthLabel->setText("Element size in y");
this->zLengthLabel->setText("Element size in z");
}
bool CreateStructuredGridDialog::inputIsEmpty() const
{
QString const type_str =
(this->meshExtentButton->isChecked()) ? "mesh" : "element";
if (this->xLengthEdit->text().isEmpty())
{
OGSError::box("Please specify " + type_str +
"\nextent in x-direction.");
return true;
}
if (this->xElemEdit->text().isEmpty())
{
OGSError::box("Please specify number of\nelements in x-direction.");
return true;
}
if (this->xOriginEdit->text().isEmpty() ||
this->yOriginEdit->text().isEmpty() ||
this->zOriginEdit->text().isEmpty())
{
OGSError::box("Please specify coordinates\nof mesh origin.");
return true;
}
if (this->meshNameEdit->text().isEmpty())
{
OGSError::box("Please specify mesh name.");
return true;
}
if (!this->lineButton->isChecked())
{
if (this->yLengthEdit->text().isEmpty())
{
OGSError::box("Please specify " + type_str +
"\nextent in y-direction.");
return true;
}
if (this->yElemEdit->text().isEmpty())
{
OGSError::box("Please specify number of\nelements in y-direction.");
return true;
}
}
if (this->prismButton->isChecked() || this->hexButton->isChecked())
{
if (this->zLengthEdit->text().isEmpty())
{
OGSError::box("Please specify " + type_str +
"\nextent in z-direction.");
return true;
}
if (this->zElemEdit->text().isEmpty())
{
OGSError::box("Please specify number of\nelements in z-direction.");
return true;
}
}
return false;
}
void CreateStructuredGridDialog::accept()
{
if (inputIsEmpty())
{
return;
}
if ((this->xLengthEdit->text().toDouble() <= 0) ||
(this->yLengthEdit->text().toDouble() <= 0) ||
(this->zLengthEdit->text().toDouble() <= 0))
{
OGSError::box("Length needs to be larger than 0.");
return;
}
if ((this->xElemEdit->text().toDouble() <= 0) ||
(this->yElemEdit->text().toDouble() <= 0) ||
(this->zElemEdit->text().toDouble() <= 0))
{
OGSError::box("Number of elements needs to be larger than 0.");
return;
}
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);
if (this->lineButton->isChecked())
{
if (this->meshExtentButton->isChecked())
{
mesh = MeshToolsLib::MeshGenerator::generateLineMesh(
this->xLengthEdit->text().toDouble(),
this->xElemEdit->text().toInt(), origin, name);
}
else
{
mesh = MeshToolsLib::MeshGenerator::generateLineMesh(
this->xElemEdit->text().toInt(),
this->xLengthEdit->text().toDouble(), origin, name);
}
}
else if (this->triButton->isChecked())
{
if (this->meshExtentButton->isChecked())
{
mesh = MeshToolsLib::MeshGenerator::generateRegularTriMesh(
this->xLengthEdit->text().toDouble(),
this->yLengthEdit->text().toDouble(),
this->xElemEdit->text().toInt(),
this->yElemEdit->text().toInt(), origin, name);
}
else
{
mesh = MeshToolsLib::MeshGenerator::generateRegularTriMesh(
this->xElemEdit->text().toInt(),
this->yElemEdit->text().toInt(),
this->xLengthEdit->text().toDouble(),
this->yLengthEdit->text().toDouble(), origin, name);
}
}
else if (this->quadButton->isChecked())
{
if (this->meshExtentButton->isChecked())
{
mesh = MeshToolsLib::MeshGenerator::generateRegularQuadMesh(
this->xLengthEdit->text().toDouble(),
this->yLengthEdit->text().toDouble(),
this->xElemEdit->text().toInt(),
this->yElemEdit->text().toInt(), origin, name);
}
else
{
mesh = MeshToolsLib::MeshGenerator::generateRegularQuadMesh(
this->xElemEdit->text().toInt(),
this->yElemEdit->text().toInt(),
this->xLengthEdit->text().toDouble(),
this->yLengthEdit->text().toDouble(), origin, name);
}
}
else if (this->prismButton->isChecked())
{
if (this->meshExtentButton->isChecked())
{
mesh = MeshToolsLib::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);
}
else
{
mesh = MeshToolsLib::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);
}
}
else if (this->hexButton->isChecked())
{
if (this->meshExtentButton->isChecked())
{
mesh = MeshToolsLib::MeshGenerator::generateRegularHexMesh(
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
{
mesh = MeshToolsLib::MeshGenerator::generateRegularHexMesh(
this->xElemEdit->text().toInt(),
this->yElemEdit->text().toInt(),
this->zElemEdit->text().toInt(),
this->xLengthEdit->text().toDouble(),
this->yLengthEdit->text().toDouble(),
this->zLengthEdit->text().toDouble(), origin, name);
}
}
if (mesh == nullptr)
{
OGSError::box("Error creating mesh.");
return;
}
auto* const mat_ids = mesh->getProperties().createNewPropertyVector<int>(
"MaterialIDs", MeshLib::MeshItemType::Cell);
assert(mat_ids != nullptr);
mat_ids->resize(mesh->getNumberOfElements());
emit meshAdded(mesh);
this->done(QDialog::Accepted);
}
/**
* \file
* \author Karsten Rink
* \date 2016-02-04
* \brief Definition of the CreateStructuredGridDialog class.
*
* \copyright
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include "ui_CreateStructuredGrid.h"
#include <QDialog>
#include "MeshLib/Mesh.h"
/**
* \brief A dialog window for managing general Data Explorer settings
*/
class CreateStructuredGridDialog : public QDialog, private Ui_CreateStructuredGrid
{
Q_OBJECT
public:
explicit CreateStructuredGridDialog(QDialog* parent = nullptr);
private slots:
void on_lineButton_toggled() const;
void on_triButton_toggled() const { enable2dWidgets(); }
void on_quadButton_toggled() const { enable2dWidgets(); }
void on_prismButton_toggled() const { enable3dWidgets(); }
void on_hexButton_toggled() const { enable3dWidgets(); }
void on_meshExtentButton_toggled();
void on_elemExtentButton_toggled();
/// Instructions if the OK-Button has been pressed.
void accept() override;
/// Instructions if the Cancel-Button has been pressed.
void reject() override { this->done(QDialog::Rejected); };
private:
void enable2dWidgets() const;
void enable3dWidgets() const;
void setValidators();
/// Checks if all necessary inputs have been specified.
bool inputIsEmpty() const;
signals:
void meshAdded(MeshLib::Mesh* mesh);
};
......@@ -7,9 +7,21 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>115</height>
<height>120</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>120</height>
</size>
</property>
<property name="windowTitle">
<string>OGS Data Explorer Settings</string>
</property>
......@@ -87,12 +99,12 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>349</x>
<y>108</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
<y>119</y>
</hint>
</hints>
</connection>
......@@ -103,12 +115,12 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>388</x>
<y>108</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
<y>119</y>
</hint>
</hints>
</connection>
......
/**
* \file DataExplorerSettingsDialog.cpp
* \file
* \author Karsten Rink
* \date 2014-02-05
* \brief Implementation of the DataExplorerSettingsDialog class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
......@@ -17,39 +17,35 @@
#include <QFileDialog>
#include <QSettings>
// ThirdParty/logog
#include "logog/include/logog.hpp"
#include "Base/OGSError.h"
#include "OGSError.h"
DataExplorerSettingsDialog::DataExplorerSettingsDialog(QDialog* parent) : QDialog(parent)
DataExplorerSettingsDialog::DataExplorerSettingsDialog(QDialog* parent)
: QDialog(parent)
{
setupUi(this);
setupUi(this);
QSettings settings;
this->gmshPathEdit->setText(settings.value("DataExplorerGmshPath").toString());
QSettings settings;
this->gmshPathEdit->setText(
settings.value("DataExplorerGmshPath").toString());
}
DataExplorerSettingsDialog::~DataExplorerSettingsDialog()
{
}
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*");
if (!file_name.isEmpty())
this->gmshPathEdit->setText(file_name);
QSettings settings;
QString file_name = QFileDialog::getOpenFileName(
this, "Select path for GMSH...",
settings.value("DataExplorerGmshPath").toString(), "*gmsh*");
if (!file_name.isEmpty())
{
this->gmshPathEdit->setText(file_name);
}
}
void DataExplorerSettingsDialog::accept()
{
QSettings settings;
settings.setValue("DataExplorerGmshPath", this->gmshPathEdit->text());
this->done(QDialog::Accepted);
QSettings settings;
settings.setValue("DataExplorerGmshPath", this->gmshPathEdit->text());
this->done(QDialog::Accepted);
}
/**
* \file DataExplorerSettingsDialog.h
* \file
* \author Karsten Rink
* \date 2014-02-05
* \brief Definition of the DataExplorerSettingsDialog class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef DATAEXPLORERSETTINGSDIALOG_H
#define DATAEXPLORERSETTINGSDIALOG_H
#pragma once
#include "ui_DataExplorerSettings.h"
#include <QDialog>
......@@ -23,22 +22,18 @@
*/
class DataExplorerSettingsDialog : public QDialog, private Ui_DataExplorerSettings
{
Q_OBJECT
Q_OBJECT
public:
DataExplorerSettingsDialog(QDialog* parent = 0);
~DataExplorerSettingsDialog(void);
explicit DataExplorerSettingsDialog(QDialog* parent = nullptr);
~DataExplorerSettingsDialog() override;
private slots:
void on_gmshPathButton_clicked();
/// Instructions if the OK-Button has been pressed.
void accept();
void on_gmshPathButton_clicked();
/// Instructions if the Cancel-Button has been pressed.
void reject() { this->done(QDialog::Rejected); };
/// Instructions if the OK-Button has been pressed.
void accept() override;
/// Instructions if the Cancel-Button has been pressed.
void reject() override { this->done(QDialog::Rejected); };
};
#endif //DATAEXPLORERSETTINGSDIALOG_H
# Source files
set(SOURCES
DetailWindow.cpp
DiagramList.cpp
DiagramPrefsDialog.cpp
DiagramScene.cpp
DiagramView.cpp
QArrow.cpp
QGraphicsGrid.cpp
DetailWindow.cpp
DiagramList.cpp
DiagramPrefsDialog.cpp
DiagramScene.cpp
DiagramView.cpp
QArrow.cpp
QGraphicsGrid.cpp
)
# Header files
set(HEADERS
DiagramList.h
QArrow.h
QGraphicsGrid.h
DiagramScene.h
DetailWindow.h
DiagramPrefsDialog.h
DiagramView.h
DiagramList.h
GetDateTime.h
QArrow.h
QGraphicsGrid.h
DiagramScene.h
DetailWindow.h
DiagramPrefsDialog.h
DiagramView.h
)
# Include the headers which are generated by uic and moc
# and include additional header
set(SOURCE_DIR_REL ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
set(GUI_SOURCE_DIR_REL ${CMAKE_CURRENT_SOURCE_DIR}/../..)
include_directories(
${SOURCE_DIR_REL}/BaseLib
${SOURCE_DIR_REL}/GeoLib
${SOURCE_DIR_REL}/MathLib
${GUI_SOURCE_DIR_REL}/Base
${GUI_SOURCE_DIR_REL}/DataView
${CMAKE_CURRENT_BINARY_DIR}/../../DataView
${CMAKE_CURRENT_BINARY_DIR}
)
file(GLOB UIS CONFIGURE_DEPENDS *.ui)
source_group("UI Files" FILES ${UIS})
# Put moc files in a project folder
source_group("Moc Files" REGULAR_EXPRESSION moc_*)
# TODO: Workaround for #3172.
set(CMAKE_AUTOUIC NO)
qt5_wrap_ui(genUiHeaders ${UIS})
# Create the library
add_library(QtDiagramView STATIC
${SOURCES}
${HEADERS}
ogs_add_library(QtDiagramView ${SOURCES} ${HEADERS} ${UIS} ${genUiHeaders})
target_include_directories(
QtDiagramView PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(
QtDiagramView PRIVATE BaseLib GeoLib QtBase DataHolderLib Qt5::Gui
)
# Link Qt library
target_link_libraries(QtDiagramView PUBLIC Qt4::QtGui)
add_autogen_include(QtDiagramView)
set_property(TARGET QtDiagramView PROPERTY FOLDER "DataExplorer")
......@@ -5,151 +5,156 @@
* \brief Implementation of the DetailWindow class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "Color.h"
#include "DetailWindow.h"
#include "DiagramPrefsDialog.h"
#include <QFileDialog>
#include <QSettings>
#include "Applications/DataHolderLib/Color.h"
#include "DiagramPrefsDialog.h"
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->addGraph(list);
stationView->addGraph(list2);
resizeWindow();
*/
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->addGraph(list);
stationView->addGraph(list2);
resizeWindow();
*/
}
DetailWindow::DetailWindow(QString filename, QWidget* parent) : QWidget(parent)
{
setupUi(this);
stationView->setRenderHints( QPainter::Antialiasing );
setupUi(this);
stationView->setRenderHints(QPainter::Antialiasing);
std::vector<DiagramList*> lists;
DiagramList::readList(filename, lists);
std::vector<DiagramList*> lists;
DiagramList::readList(filename, lists);
for (size_t i = 0; i < lists.size(); i++)
stationView->addGraph(lists[i]);
for (auto& list : lists)
{
stationView->addGraph(list);
}
resizeWindow();
resizeWindow();
}
DetailWindow::DetailWindow(DiagramList* list, QWidget* parent) : QWidget(parent)
{
setupUi(this);
stationView->setRenderHints( QPainter::Antialiasing );
stationView->addGraph(list);
resizeWindow();
setupUi(this);
stationView->setRenderHints(QPainter::Antialiasing);
stationView->addGraph(list);
resizeWindow();
}
DetailWindow::DetailWindow(std::vector<size_t> data, QWidget* parent) : QWidget(parent)
DetailWindow::DetailWindow(std::vector<std::size_t> data, QWidget* parent)
: QWidget(parent)
{
setupUi(this);
size_t nEntries = data.size();
std::vector< std::pair<float, float> > list_data(nEntries);
for (size_t i=0; i<nEntries; i++)
list_data.push_back(std::pair<float, float>(static_cast<float>(i), static_cast<float>(data[i])));
DiagramList* list = new DiagramList();
list->setList(list_data);
list->setXUnit("Value");
list->setYUnit("Amount");
list->setName("Histogram");
stationView->setRenderHints( QPainter::Antialiasing );
stationView->addGraph(list);
resizeWindow();
setupUi(this);
std::size_t nEntries = data.size();
std::vector<std::pair<float, float>> list_data(nEntries);
for (std::size_t i = 0; i < nEntries; i++)
{
list_data.emplace_back(static_cast<float>(i),
static_cast<float>(data[i]));
}
auto* list = new DiagramList();
list->setList(list_data);
list->setXUnit("Value");
list->setYUnit("Amount");
list->setName("Histogram");
stationView->setRenderHints(QPainter::Antialiasing);
stationView->addGraph(list);
resizeWindow();
}
DetailWindow::~DetailWindow()
{
}
DetailWindow::~DetailWindow() = default;
void DetailWindow::on_closeButton_clicked()
{
this->close();
this->close();
}
void DetailWindow::resizeWindow()
{
int width = (stationView->getWidth() > 800) ? 800 : stationView->getWidth();
int height = (stationView->getHeight() > 600) ? 600 : stationView->getHeight();
resize(width, height);
int width = (stationView->getWidth() > 800) ? 800 : stationView->getWidth();
int height =
(stationView->getHeight() > 600) ? 600 : stationView->getHeight();
resize(width, height);
}
void DetailWindow::addList(DiagramList* list)
{
GeoLib::Color* c = GeoLib::getRandomColor();
QColor colour((*c)[0], (*c)[1], (*c)[2]);
delete c;
this->addList(list, colour);
resizeWindow();
DataHolderLib::Color const c = DataHolderLib::getRandomColor();
QColor colour(c[0], c[1], c[2]);
this->addList(list, colour);
resizeWindow();
}
void DetailWindow::addList(DiagramList* list, QColor c)
{
list->setColor(c);
this->stationView->addGraph(list);
list->setColor(c);
this->stationView->addGraph(list);
}
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 (* *.*)");
if (!fileName.isEmpty())
{
QDir dir = QDir(fileName);
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
DiagramPrefsDialog* prefs = new DiagramPrefsDialog(fileName, this);
prefs->setAttribute(Qt::WA_DeleteOnClose);
prefs->show();
}
QSettings settings;
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);
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
auto* prefs = new DiagramPrefsDialog(fileName, this);
prefs->setAttribute(Qt::WA_DeleteOnClose);
prefs->show();
}
}