diff --git a/Applications/DataExplorer/DataView/StationTreeView.cpp b/Applications/DataExplorer/DataView/StationTreeView.cpp index 7b61fc1ad4b16b5d711b197c7f96c7d9680d2605..84a7b4630f8cb812923257aafdad2e6efeb156d1 100644 --- a/Applications/DataExplorer/DataView/StationTreeView.cpp +++ b/Applications/DataExplorer/DataView/StationTreeView.cpp @@ -121,9 +121,9 @@ void StationTreeView::contextMenuEvent(QContextMenuEvent* event) 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) + if (dynamic_cast<GeoLib::StationBorehole*>( + static_cast<StationTreeModel*>(model())->stationFromIndex( + index, temp_name))) { QAction* stratAction = menu.addAction("Display Stratigraphy..."); QAction* exportAction = menu.addAction("Export to GMS..."); diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp index 0e44ba4933a41a77e067e4a9fce25a0d9b90ae00..560afd8e69543741606c681e8da05ffdb94120e4 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.cpp +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.cpp @@ -95,8 +95,7 @@ int VtkStationSource::RequestData(vtkInformation* request, } } - bool isBorehole = static_cast<GeoLib::Station*>((*_stations)[0])->type() == - GeoLib::Station::StationType::BOREHOLE; + bool isBorehole = dynamic_cast<GeoLib::StationBorehole*>((*_stations)[0]); vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); diff --git a/Applications/DataExplorer/VtkVis/VtkStationSource.h b/Applications/DataExplorer/VtkVis/VtkStationSource.h index a422022d7e1115bfc2b6df0f092b1d68d86f9505..226873c2f8c13765cab2facf273861753166c05d 100644 --- a/Applications/DataExplorer/VtkVis/VtkStationSource.h +++ b/Applications/DataExplorer/VtkVis/VtkStationSource.h @@ -17,6 +17,7 @@ #include <vtkPolyDataAlgorithm.h> #include "Applications/DataHolderLib/Color.h" +#include "GeoLib/StationBorehole.h" #include "GeoLib/Station.h" #include "VtkAlgorithmProperties.h" @@ -38,7 +39,16 @@ public: /// Returns the type of observation site represented in this source object GeoLib::Station::StationType getType() const - { return static_cast<GeoLib::Station*>((*_stations)[0])->type(); }; + { + if (dynamic_cast<GeoLib::StationBorehole*>((*_stations)[0])) + { + return GeoLib::Station::StationType::STATION; + } + else + { + return GeoLib::Station::StationType::BOREHOLE; + } + }; /// Sets a predefined color lookup table for the colouring of borehole stratigraphies // int setColorLookupTable(const std::string &filename) diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index 591fbc0657f4843d6a8515375c87f6b3e973fd3e..548c9c38f279679328bd29a14bc67860cee5e23b 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -1242,17 +1242,16 @@ void MainWindow::showDiagramPrefsDialog(QModelIndex& index) GeoLib::Station* stn = _geo_model->getStationModel()->stationFromIndex(index, listName); - if ((stn->type() == GeoLib::Station::StationType::STATION) && - stn->getSensorData()) + if (dynamic_cast<GeoLib::StationBorehole*>(stn)) + { + OGSError::box("No time series data available for borehole."); + } + else if (dynamic_cast<GeoLib::Station*>(stn) && stn->getSensorData()) { auto* prefs(new DiagramPrefsDialog(stn)); prefs->setAttribute(Qt::WA_DeleteOnClose); prefs->show(); } - if (stn->type() == GeoLib::Station::StationType::BOREHOLE) - { - OGSError::box("No time series data available for borehole."); - } } void MainWindow::showDiagramPrefsDialog() diff --git a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp index 5321bb8351cc9cb0cc60c3c9d85ae54467eaced2..0b7fe8bf5d2f25009c68c1cae799cc4bfee22348 100644 --- a/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Qt/XmlStnInterface.cpp @@ -264,8 +264,7 @@ bool XmlStnInterface::write() const std::vector<GeoLib::Point*>* stations( _geo_objs.getStationVec(export_name)); bool const is_borehole = - static_cast<GeoLib::Station*>((*stations)[0])->type() == - GeoLib::Station::StationType::BOREHOLE; + dynamic_cast<GeoLib::StationBorehole*>((*stations)[0]); doc.appendChild(root); QDomElement stationListTag = doc.createElement("stationlist"); diff --git a/GeoLib/Station.h b/GeoLib/Station.h index 875998dcd6c9c8f5fbea7a8c3e33f7307302fb57..afe1b5b0a660a0b1d47c47471c76efc07bc0e8cd 100644 --- a/GeoLib/Station.h +++ b/GeoLib/Station.h @@ -74,9 +74,6 @@ public: void setName(std::string const& name) { _name = name; } - /// Returns the GeoSys-station-type for the station. - StationType type() const { return _type; } - /// Creates a Station-object from information contained in a string (assuming the string has the right format) static Station* createStation(const std::string &line);