From ded3cb13d7967280ed701e636d4e6f6aded71bc4 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Fri, 18 Jan 2013 12:04:45 +0100 Subject: [PATCH] removed highlighting of boreholes again due to severe colour-lookup-table issues; tidied up lots of other very small things --- FileIO/RapidXmlIO/BoostVtuInterface.cpp | 2 +- GeoLib/Station.h | 7 ++++--- Gui/DataView/GeoTreeView.cpp | 6 ++++-- Gui/DataView/LineEditDialog.h | 1 + Gui/DataView/MshView.cpp | 4 ++++ Gui/DataView/StationTreeView.cpp | 2 ++ Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp | 16 +++++++++------- Gui/VtkVis/VtkStationSource.cpp | 14 +++++--------- Gui/VtkVis/VtkStationSource.h | 14 +++++++++----- Gui/VtkVis/VtkVisPointSetItem.cpp | 2 -- Gui/mainwindow.cpp | 11 ++++++----- 11 files changed, 45 insertions(+), 34 deletions(-) diff --git a/FileIO/RapidXmlIO/BoostVtuInterface.cpp b/FileIO/RapidXmlIO/BoostVtuInterface.cpp index 9524add4d9a..e007502ef49 100644 --- a/FileIO/RapidXmlIO/BoostVtuInterface.cpp +++ b/FileIO/RapidXmlIO/BoostVtuInterface.cpp @@ -368,7 +368,7 @@ unsigned char* BoostVtuInterface::uncompressData(property_tree::ptree const& com { const unsigned char* compressed_data = reinterpret_cast<const unsigned char*>(compressed_data_node.data().c_str()); unsigned long compressed_size = strlen(compressed_data_node.data().c_str()); - unsigned char* uncompressed_data; + unsigned char* uncompressed_data = NULL; unsigned long uncompressed_size = 0; unsigned long result = zLibDataCompressor::UncompressBuffer(compressed_data, compressed_size, uncompressed_data, uncompressed_size); return uncompressed_data; diff --git a/GeoLib/Station.h b/GeoLib/Station.h index 1d424fccd86..e85c6180e84 100644 --- a/GeoLib/Station.h +++ b/GeoLib/Station.h @@ -74,8 +74,9 @@ public: /// Signals if the object is a "simple" Station or a Borehole (i.e. containing borehole-specific information). enum StationType { - STATION = 1, - BOREHOLE = 2 + INVALID = 0, + STATION, + BOREHOLE }; /** @@ -136,7 +137,7 @@ public: std::string const& getName() const { return _name; } /// Returns the GeoSys-station-type for the station. - int type() const { return _type; } + 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); diff --git a/Gui/DataView/GeoTreeView.cpp b/Gui/DataView/GeoTreeView.cpp index b52996dc2c3..7741aa1669c 100644 --- a/Gui/DataView/GeoTreeView.cpp +++ b/Gui/DataView/GeoTreeView.cpp @@ -104,8 +104,8 @@ 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 { @@ -180,6 +180,8 @@ void GeoTreeView::removeGeometry() 0).toString()).toStdString(), list->getType()); else emit listRemoved((item->data(0).toString()).toStdString(), GeoLib::INVALID); + emit enableSaveButton(false); + emit enableRemoveButton(false); } } diff --git a/Gui/DataView/LineEditDialog.h b/Gui/DataView/LineEditDialog.h index 7c8729bb232..e9f94dd6519 100644 --- a/Gui/DataView/LineEditDialog.h +++ b/Gui/DataView/LineEditDialog.h @@ -66,3 +66,4 @@ signals: }; #endif //LINEEDITDIALOG_H + \ No newline at end of file diff --git a/Gui/DataView/MshView.cpp b/Gui/DataView/MshView.cpp index 1f8b86b73c8..5f3c981faf9 100644 --- a/Gui/DataView/MshView.cpp +++ b/Gui/DataView/MshView.cpp @@ -90,7 +90,11 @@ void MshView::removeMesh() if (!index.isValid()) OGSError::box("No mesh selected."); else + { emit requestMeshRemoval(index); + emit enableSaveButton(false); + emit enableRemoveButton(false); + } } void MshView::contextMenuEvent( QContextMenuEvent* event ) diff --git a/Gui/DataView/StationTreeView.cpp b/Gui/DataView/StationTreeView.cpp index 5d1038d69ef..738173b8507 100644 --- a/Gui/DataView/StationTreeView.cpp +++ b/Gui/DataView/StationTreeView.cpp @@ -222,6 +222,8 @@ void StationTreeView::removeStationList() { TreeItem* item = static_cast<StationTreeModel*>(model())->getItem(index); emit stationListRemoved((item->data(0).toString()).toStdString()); + emit enableSaveButton(false); + emit enableRemoveButton(false); } } diff --git a/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp b/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp index 97fad2d66ac..31822e30590 100644 --- a/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp +++ b/Gui/VtkVis/VtkCompositeGeoObjectFilter.cpp @@ -22,6 +22,7 @@ #include "VtkPolylinesSource.h" #include "VtkSurfacesSource.h" +#include "VtkStationSource.h" #include "VtkCompositePointToGlyphFilter.h" #include "VtkCompositeLineToTubeFilter.h" @@ -42,6 +43,13 @@ VtkCompositeGeoObjectFilter::VtkCompositeGeoObjectFilter( vtkAlgorithm* inputAlg _type = GeoLib::POLYLINE; else if (dynamic_cast<VtkSurfacesSource*>(parentAlg) != NULL) _type = GeoLib::SURFACE; + else if (dynamic_cast<VtkStationSource*>(parentAlg) != NULL) + { + /* TODO + if (dynamic_cast<VtkStationSource*>(parentAlg)->getType() == GeoLib::Station::BOREHOLE) + _type = GeoLib::POLYLINE; + */ + } } } @@ -71,21 +79,15 @@ void VtkCompositeGeoObjectFilter::init() composite = new VtkCompositePointToGlyphFilter(surface); composite->SetUserProperty("Radius", this->GetInitialRadius()); _outputAlgorithm = composite->GetOutputAlgorithm(); - _outputAlgorithm->Update(); - vtkPolyData* pd = static_cast<vtkPolyData*>(_outputAlgorithm->GetOutputDataObject(0)); - //int a = pd->GetPoints()->GetNumberOfPoints(); - //std::cout << a << std::endl; } else if (_type == GeoLib::POLYLINE) { composite = new VtkCompositeLineToTubeFilter(surface); composite->SetUserProperty("Radius", this->GetInitialRadius()); _outputAlgorithm = composite->GetOutputAlgorithm(); - } else _outputAlgorithm = surface; - } void VtkCompositeGeoObjectFilter::SetIndex(size_t idx) @@ -104,5 +106,5 @@ float VtkCompositeGeoObjectFilter::GetInitialRadius() const double max = (x_diff > y_diff) ? x_diff : y_diff; max = (max > z_diff) ? max : z_diff; - return max/200.0; + return max/100.0; } diff --git a/Gui/VtkVis/VtkStationSource.cpp b/Gui/VtkVis/VtkStationSource.cpp index 995def7fe24..715008aa673 100644 --- a/Gui/VtkVis/VtkStationSource.cpp +++ b/Gui/VtkVis/VtkStationSource.cpp @@ -12,9 +12,6 @@ * */ -#include "Color.h" -#include "Station.h" - // ** VTK INCLUDES ** #include "VtkStationSource.h" @@ -157,11 +154,9 @@ int VtkStationSource::RequestData( vtkInformation* request, double loc[3] = { pCoords[0], pCoords[1], pCoords[2] }; newStations->InsertNextPoint(loc); station_ids->InsertNextValue(site_count); - newLines->InsertNextCell(2); newLines->InsertCellPoint(lastMaxIndex); // start of borehole-layer - newLines->InsertCellPoint(lastMaxIndex + 1); //end of boreholelayer - lastMaxIndex++; + newLines->InsertCellPoint(++lastMaxIndex); //end of boreholelayer strat_ids->InsertNextValue(this->GetIndexByName(soilNames[i])); if (useStationValues) station_values->InsertNextValue(static_cast<GeoLib::Station*>(*it)->getStationValue()); @@ -182,9 +177,9 @@ int VtkStationSource::RequestData( vtkInformation* request, else { output->SetLines(newLines); + //output->GetCellData()->AddArray(station_ids); output->GetCellData()->AddArray(strat_ids); - output->GetCellData()->SetActiveAttribute("Stratigraphies", - vtkDataSetAttributes::SCALARS); + output->GetCellData()->SetActiveAttribute("Stratigraphies", vtkDataSetAttributes::SCALARS); } if (useStationValues) output->GetPointData()->AddArray(station_values); @@ -224,7 +219,8 @@ size_t VtkStationSource::GetIndexByName( std::string name ) } vtkIdType new_index = (_id_map.empty()) ? 0 : (max_key+1); - std::cout << "Key \"" << name << "\" (Index " << new_index << ") not found in color lookup table..." << std::endl; + std::cout << "Key \"" << name << "\" has been assigned index " << new_index << std::endl; _id_map.insert(std::pair<std::string, vtkIdType>(name, new_index)); return new_index; } + diff --git a/Gui/VtkVis/VtkStationSource.h b/Gui/VtkVis/VtkStationSource.h index e5dd07f9470..bbe7031c451 100644 --- a/Gui/VtkVis/VtkStationSource.h +++ b/Gui/VtkVis/VtkStationSource.h @@ -21,6 +21,7 @@ // GeoLib #include "Color.h" +#include "Station.h" /** * \brief VTK source object for the visualisation of station data (including boreholes) @@ -35,13 +36,16 @@ public: /// Returns the colour lookup table generated for boreholes. /// This method should only be called after the colour lookup table has actually been build (via RequestData() or setColorLookupTable()). - const std::map<std::string, - GeoLib::Color*>& getColorLookupTable() const { return _colorLookupTable; } + const std::map<std::string, GeoLib::Color*>& getColorLookupTable() const + { return _colorLookupTable; } + /// Returns the type of observation site represented in this source object + GeoLib::Station::StationType getType() const + { return static_cast<GeoLib::Station*>((*_stations)[0])->type(); }; + /// Sets a predefined color lookup table for the colouring of borehole stratigraphies - int setColorLookupTable(const std::string &filename) { return readColorLookupTable( - _colorLookupTable, - filename); } + int setColorLookupTable(const std::string &filename) + { return readColorLookupTable(_colorLookupTable, filename); } /// Sets the stations as a vector void setStations(const std::vector<GeoLib::Point*>* stations) { _stations = stations; } diff --git a/Gui/VtkVis/VtkVisPointSetItem.cpp b/Gui/VtkVis/VtkVisPointSetItem.cpp index c6122f0c75e..7c5c7c4abb5 100644 --- a/Gui/VtkVis/VtkVisPointSetItem.cpp +++ b/Gui/VtkVis/VtkVisPointSetItem.cpp @@ -272,7 +272,6 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) { _algorithm->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, charName); _mapper->SetScalarModeToUsePointData(); - pointData->GetArray(_activeArrayName.c_str())->GetRange(range); pointData->GetArray(charName)->GetRange(range); } else @@ -293,7 +292,6 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) { _algorithm->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, charName); _mapper->SetScalarModeToUseCellData(); - cellData->GetArray(_activeArrayName.c_str())->GetRange(range); cellData->GetArray(charName)->GetRange(range); } else diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index dd7105b8fcd..b43a5dfb827 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -185,8 +185,8 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/) _vtkVisPipeline, SLOT(removeHighlightedGeoObject())); connect(stationTabWidget->treeView, SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)), _vtkVisPipeline, SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int))); - connect(stationTabWidget->treeView, SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)), - _vtkVisPipeline, SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int))); + connect(stationTabWidget->treeView, SIGNAL(removeGeoItemSelection()), + _vtkVisPipeline, SLOT(removeHighlightedGeoObject())); @@ -447,7 +447,8 @@ void MainWindow::save() this, "Save data as", dir_str, - "GeoSys project (*.gsp);;GeoSys4 geometry files (*.gli);;GMSH geometry files (*.geo)"); + //"GeoSys project (*.gsp);;GeoSys4 geometry files (*.gli);;GMSH geometry files (*.geo)"); + "GeoSys project (*.gsp);;GMSH geometry files (*.geo)"); //Saving gli files is no longer possible if (!fileName.isEmpty()) { @@ -1120,8 +1121,8 @@ void MainWindow::showNewProcessDialog() void MainWindow::showLineEditDialog(const std::string &geoName) { LineEditDialog lineEdit(*(_geoModels->getPolylineVecObj(geoName))); - connect(&lineEdit, SIGNAL(connectPolylines(const std::string &, std::vector<size_t>, double, std::string, bool, bool)), - _geoModels, SLOT(connectPolylineSegments(const std::string &, std::vector<size_t>, double, std::string, bool, bool))); + connect(&lineEdit, SIGNAL(connectPolylines(const std::string&, std::vector<std::size_t>, double, std::string, bool, bool)), + _geoModels, SLOT(connectPolylineSegments(const std::string &, std::vector<std::size_t>, double, std::string, bool, bool))); lineEdit.exec(); } -- GitLab