From cb5e5f92f59ab2e71aa5c532c41b93e6c228d4ba Mon Sep 17 00:00:00 2001
From: Karsten Rink <karsten.rink@ufz.de>
Date: Wed, 10 Apr 2013 12:02:32 +0200
Subject: [PATCH] added mesh-element-view class and started implementing
 hightlighting of selected mesh nodes

---
 Gui/DataView/CMakeLists.txt                |  2 +
 Gui/DataView/ElementTreeModel.cpp          | 84 ++++++++++++----------
 Gui/DataView/ElementTreeModel.h            |  9 +--
 Gui/DataView/ElementTreeView.cpp           | 54 ++++++++++++++
 Gui/DataView/ElementTreeView.h             | 46 ++++++++++++
 Gui/DataView/MshTabWidgetBase.ui           |  7 +-
 Gui/DataView/MshView.cpp                   |  1 +
 Gui/DataView/MshView.h                     |  2 +-
 Gui/VtkAct/VtkCustomInteractorStyle.cpp    |  8 ++-
 Gui/VtkAct/VtkCustomInteractorStyle.h      | 11 +--
 Gui/VtkVis/VtkCompositeSelectionFilter.cpp | 39 ++++++----
 Gui/VtkVis/VtkCompositeSelectionFilter.h   |  3 +
 Gui/VtkVis/VtkMeshSource.h                 |  2 +-
 Gui/VtkVis/VtkVisPipeline.cpp              |  4 +-
 Gui/VtkVis/VtkVisPipeline.h                |  2 +-
 Gui/mainwindow.cpp                         | 16 +++--
 16 files changed, 216 insertions(+), 74 deletions(-)
 create mode 100644 Gui/DataView/ElementTreeView.cpp
 create mode 100644 Gui/DataView/ElementTreeView.h

diff --git a/Gui/DataView/CMakeLists.txt b/Gui/DataView/CMakeLists.txt
index 0e2f4e04e9c..7d4f36cd852 100644
--- a/Gui/DataView/CMakeLists.txt
+++ b/Gui/DataView/CMakeLists.txt
@@ -6,6 +6,7 @@ set( SOURCES
 	ConditionWriterDialog.cpp
 	DirectConditionGenerator.cpp
 	ElementTreeModel.cpp
+	ElementTreeView.cpp
 	FEMConditionSetupDialog.cpp
 	GeoMapper.cpp
 	GEOModels.cpp
@@ -45,6 +46,7 @@ set( MOC_HEADERS
 	CondFromRasterDialog.h
 	ConditionWriterDialog.h
 	ElementTreeModel.h
+	ElementTreeView.h
 	FEMConditionSetupDialog.h
 	GEOModels.h
 	GeoTabWidget.h
diff --git a/Gui/DataView/ElementTreeModel.cpp b/Gui/DataView/ElementTreeModel.cpp
index d0f3e9cc2e1..d167794a126 100644
--- a/Gui/DataView/ElementTreeModel.cpp
+++ b/Gui/DataView/ElementTreeModel.cpp
@@ -19,66 +19,76 @@
 #include "Node.h"
 #include "Elements/Element.h"
 
+#include "VtkMeshSource.h"
+
 /**
  * Constructor.
  */
 ElementTreeModel::ElementTreeModel( QObject* parent )
-	: TreeModel(parent)
+	: TreeModel(parent), _mesh_source(nullptr)
 {
 	QList<QVariant> rootData;
 	delete _rootItem;
 	rootData << "Name" << "Type" << "" << "";
-	_rootItem = new TreeItem(rootData, NULL);
+	_rootItem = new TreeItem(rootData, nullptr);
 }
 
 ElementTreeModel::~ElementTreeModel()
 {
 }
 
-void ElementTreeModel::setElement(const MeshLib::Mesh* grid, const size_t elem_index)
+void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, const size_t elem_index)
 {
+	this->_mesh_source = grid;
 	this->clearView();
-	const MeshLib::Element* elem = grid->getElement(elem_index);
 
-	QList<QVariant> elemData;
-	elemData << "Element " + QString::number(elem_index) << "" << "" << "";
-	TreeItem* elemItem = new TreeItem(elemData, _rootItem);
-	_rootItem->appendChild(elemItem);
+	VtkMeshSource const*const source = dynamic_cast<VtkMeshSource const*const>(grid);
 
-	QList<QVariant> typeData;
-	typeData << "Element Type: " << QString::fromStdString(MshElemType2String(elem->getGeomType()));
-	TreeItem* typeItem = new TreeItem(typeData, elemItem);
-	elemItem->appendChild(typeItem);
+	if (source)
+	{
+		const MeshLib::Mesh* mesh = source->GetMesh();
+		const MeshLib::Element* elem = mesh->getElement(elem_index);
 
-	QList<QVariant> materialData;
-	materialData << "MaterialID: " << QString::number(elem->getValue());
-	TreeItem* matItem = new TreeItem(materialData, elemItem);
-	elemItem->appendChild(matItem);
+		QList<QVariant> elemData;
+		elemData << "Element " + QString::number(elem_index) << "" << "" << "";
+		TreeItem* elemItem = new TreeItem(elemData, _rootItem);
+		_rootItem->appendChild(elemItem);
 
-	QList<QVariant> volData;
-	volData << "Area/Volume: " <<
-	QString::number(grid->getElement(elem_index)->getContent());
-	TreeItem* volItem = new TreeItem(volData, elemItem);
-	elemItem->appendChild(volItem);
+		QList<QVariant> typeData;
+		typeData << "Element Type: " << QString::fromStdString(MshElemType2String(elem->getGeomType()));
+		TreeItem* typeItem = new TreeItem(typeData, elemItem);
+		elemItem->appendChild(typeItem);
 
-	QList<QVariant> nodeListData;
-	nodeListData << "Nodes" << "" << "" << "";
-	TreeItem* nodeListItem = new TreeItem(nodeListData, elemItem);
-	elemItem->appendChild(nodeListItem);
+		QList<QVariant> materialData;
+		materialData << "MaterialID: " << QString::number(elem->getValue());
+		TreeItem* matItem = new TreeItem(materialData, elemItem);
+		elemItem->appendChild(matItem);
 
-	//const std::vector<MeshLib::Node*> nodes_vec = grid->getNodes();
-	size_t nElemNodes = elem->getNNodes();
-	for (size_t i = 0; i < nElemNodes; i++)
-	{
-		const MeshLib::Node* node = elem->getNode(i);
-		QList<QVariant> nodeData;
-		nodeData << "Node " + QString::number(node->getID()) <<
-		QString::number((*node)[0]) << QString::number((*node)[1]) <<
-		QString::number((*node)[2]);
-		TreeItem* nodeItem = new TreeItem(nodeData, nodeListItem);
-		nodeListItem->appendChild(nodeItem);
+		QList<QVariant> volData;
+		volData << "Area/Volume: " <<
+		QString::number(mesh->getElement(elem_index)->getContent());
+		TreeItem* volItem = new TreeItem(volData, elemItem);
+		elemItem->appendChild(volItem);
+
+		QList<QVariant> nodeListData;
+		nodeListData << "Nodes" << "" << "" << "";
+		TreeItem* nodeListItem = new TreeItem(nodeListData, elemItem);
+		elemItem->appendChild(nodeListItem);
+
+		//const std::vector<MeshLib::Node*> nodes_vec = grid->getNodes();
+		size_t nElemNodes = elem->getNNodes();
+		for (size_t i = 0; i < nElemNodes; i++)
+		{
+			const MeshLib::Node* node = elem->getNode(i);
+			QList<QVariant> nodeData;
+			nodeData << "Node " + QString::number(node->getID()) <<
+			QString::number((*node)[0]) << QString::number((*node)[1]) <<
+			QString::number((*node)[2]);
+			TreeItem* nodeItem = new TreeItem(nodeData, nodeListItem);
+			nodeListItem->appendChild(nodeItem);
+		}
+		reset();
 	}
-	reset();
 }
 
 void ElementTreeModel::clearView()
diff --git a/Gui/DataView/ElementTreeModel.h b/Gui/DataView/ElementTreeModel.h
index cf85a7a5961..1645fbf1c2c 100644
--- a/Gui/DataView/ElementTreeModel.h
+++ b/Gui/DataView/ElementTreeModel.h
@@ -17,9 +17,7 @@
 
 #include "TreeModel.h"
 
-namespace MeshLib {
-	class Mesh;
-}
+class vtkUnstructuredGridAlgorithm;
 
 /**
  * \brief A model for the display of information concerning element information implemented as a TreeModel.
@@ -33,14 +31,17 @@ public:
 	ElementTreeModel( QObject* parent = 0 );
 	~ElementTreeModel();
 
+	vtkUnstructuredGridAlgorithm const*const getSource() const { return _mesh_source; };
+
 public slots:
 	/// Clears the tree.
 	void clearView();
 
 	/// Extracts information of the element with the given index from the given grid.
-	void setElement(const MeshLib::Mesh* grid, const std::size_t elem_index);
+	void setElement(vtkUnstructuredGridAlgorithm const*const grid, const std::size_t elem_index);
 
 private:
+	vtkUnstructuredGridAlgorithm const* _mesh_source;
 };
 
 #endif //ELEMENTTREEMODEL_H
diff --git a/Gui/DataView/ElementTreeView.cpp b/Gui/DataView/ElementTreeView.cpp
new file mode 100644
index 00000000000..253752f1f42
--- /dev/null
+++ b/Gui/DataView/ElementTreeView.cpp
@@ -0,0 +1,54 @@
+/**
+ * \file
+ * \author Karsten Rink
+ * \date   2013-04-09
+ * \brief  Implementation of the ElementTreeView class.
+ *
+ * \copyright
+ * Copyright (c) 2013, 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 "ElementTreeView.h"
+
+#include "ElementTreeModel.h"
+#include "TreeItem.h"
+
+#include <QModelIndex>
+
+ElementTreeView::ElementTreeView( QWidget* parent) 
+: QTreeView(parent)
+{
+}
+
+void ElementTreeView::updateView()
+{
+	setAlternatingRowColors(true);
+	setColumnWidth(0,125);
+	size_t nColumns = (this->model() != NULL) ? this->model()->columnCount() : 0;
+	for (size_t i = 1; i < nColumns; i++)
+		resizeColumnToContents(i);
+}
+
+void ElementTreeView::selectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
+{
+	Q_UNUSED(deselected);
+	if (!selected.isEmpty())
+	{
+		emit removeSelectedMeshComponent();
+		const QModelIndex idx = *(selected.indexes().begin());
+		
+
+		if (idx.parent().isValid()) // not root node
+			if (idx.parent().parent().isValid()) // not property node
+			{
+				const TreeItem* tree_item = static_cast<TreeModel*>(this->model())->getItem(idx);
+				int node_index = tree_item->data(0).toString().mid(5).toInt();
+				emit nodeSelected(static_cast<ElementTreeModel*>(this->model())->getSource(), false, node_index);
+			}
+	}
+}
\ No newline at end of file
diff --git a/Gui/DataView/ElementTreeView.h b/Gui/DataView/ElementTreeView.h
new file mode 100644
index 00000000000..6d1aa520a22
--- /dev/null
+++ b/Gui/DataView/ElementTreeView.h
@@ -0,0 +1,46 @@
+/**
+ * \file
+ * \author Karsten Rink
+ * \date   2013-04-09
+ * \brief  Definition of the ElementTreeView class.
+ *
+ * \copyright
+ * Copyright (c) 2013, 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 ELEMENTTREEVIEW_H
+#define ELEMENTTREEVIEW_H
+
+#include <QTreeView>
+
+class vtkUnstructuredGridAlgorithm;
+
+/**
+ *	A TreeView to display mesh element properties.
+ */
+class ElementTreeView : public QTreeView
+{
+	Q_OBJECT
+
+public:
+	/// Constructor
+	ElementTreeView(QWidget* parent = 0);
+
+public slots:
+	void updateView();
+
+protected slots:
+	/// Is called when the selection of this view changes.
+	void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
+
+signals:
+	void nodeSelected(vtkUnstructuredGridAlgorithm const*const, bool, int);
+	void removeSelectedMeshComponent();
+};
+
+
+#endif // ELEMENTTREEVIEW_H
+
diff --git a/Gui/DataView/MshTabWidgetBase.ui b/Gui/DataView/MshTabWidgetBase.ui
index 17885a96595..e51da631fba 100644
--- a/Gui/DataView/MshTabWidgetBase.ui
+++ b/Gui/DataView/MshTabWidgetBase.ui
@@ -170,7 +170,7 @@
     </layout>
    </item>
    <item>
-    <widget class="MshView" name="elementView"/>
+    <widget class="ElementTreeView" name="elementView"/>
    </item>
   </layout>
  </widget>
@@ -180,6 +180,11 @@
    <extends>QTreeView</extends>
    <header>MshView.h</header>
   </customwidget>
+  <customwidget>
+   <class>ElementTreeView</class>
+   <extends>QTreeView</extends>
+   <header>ElementTreeView.h</header>
+  </customwidget>
  </customwidgets>
  <resources>
   <include location="../Img/icons.qrc"/>
diff --git a/Gui/DataView/MshView.cpp b/Gui/DataView/MshView.cpp
index 6b712ca3988..3625d5b7b15 100644
--- a/Gui/DataView/MshView.cpp
+++ b/Gui/DataView/MshView.cpp
@@ -82,6 +82,7 @@ void MshView::selectionChanged( const QItemSelection &selected, const QItemSelec
 	//emit itemSelectionChanged(selected, deselected);
 	//return QTreeView::selectionChanged(selected, deselected);
 }
+
 void MshView::addMesh()
 {
 	emit openMeshFile(ImportFileType::OGS_MSH);
diff --git a/Gui/DataView/MshView.h b/Gui/DataView/MshView.h
index 1b4a7a64ecf..1a9adbc7cb4 100644
--- a/Gui/DataView/MshView.h
+++ b/Gui/DataView/MshView.h
@@ -87,7 +87,7 @@ private slots:
 	void checkMeshQuality();
 
 signals:
-	void elementSelected(const vtkUnstructuredGridAlgorithm*, bool, int);
+	void elementSelected(vtkUnstructuredGridAlgorithm const*const, bool, int);
 	void enableSaveButton(bool);
 	void enableRemoveButton(bool);
 	void openMeshFile(int);
diff --git a/Gui/VtkAct/VtkCustomInteractorStyle.cpp b/Gui/VtkAct/VtkCustomInteractorStyle.cpp
index ebf8559be25..90781663176 100644
--- a/Gui/VtkAct/VtkCustomInteractorStyle.cpp
+++ b/Gui/VtkAct/VtkCustomInteractorStyle.cpp
@@ -33,10 +33,10 @@
 #include <vtkSelectionNode.h>
 #include <vtkSmartPointer.h>
 #include <vtkUnstructuredGrid.h>
+#include <vtkUnstructuredGridAlgorithm.h>
 
 #include <string>
 
-#include "VtkMeshSource.h"
 #include "VtkCompositeSelectionFilter.h"
 
 vtkStandardNewMacro(VtkCustomInteractorStyle);
@@ -183,9 +183,11 @@ void VtkCustomInteractorStyle::OnLeftButtonDown()
 
 			// 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();
-			VtkMeshSource* source = dynamic_cast<VtkMeshSource*>(data_set);
+			vtkUnstructuredGridAlgorithm* source = dynamic_cast<vtkUnstructuredGridAlgorithm*>(data_set);
 			if (source)
-				emit elementPicked(source->GetMesh(), picker->GetCellId());
+				emit elementPicked(source, picker->GetCellId());
+			else
+				emit clearElementView();
 			selectedMapper->SetInputConnection(selected->GetProducerPort());
 
 			this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->
diff --git a/Gui/VtkAct/VtkCustomInteractorStyle.h b/Gui/VtkAct/VtkCustomInteractorStyle.h
index 6e5a059f772..36b6dcdaf39 100644
--- a/Gui/VtkAct/VtkCustomInteractorStyle.h
+++ b/Gui/VtkAct/VtkCustomInteractorStyle.h
@@ -24,9 +24,7 @@ class vtkDataObject;
 class vtkDataSetMapper;
 class vtkActor;
 
-namespace MeshLib {
-	class Mesh;
-}
+class vtkUnstructuredGridAlgorithm;
 
 /**
  * VtkCustomInteractorStyle implements highlighting of an active actor and
@@ -91,7 +89,12 @@ signals:
 	void cursorChanged(Qt::CursorShape);
 
 	/// @brief Emitted when a mesh element has been picked
-	void elementPicked(const MeshLib::Mesh*, const std::size_t);
+	void elementPicked(vtkUnstructuredGridAlgorithm const*const, const std::size_t);
+
+	/// @brief Emitted when the current object type cannot be handled by the element model
+	void clearElementView();
+
 };
 
+
 #endif // VTKINTERACTORSTYLE_H
diff --git a/Gui/VtkVis/VtkCompositeSelectionFilter.cpp b/Gui/VtkVis/VtkCompositeSelectionFilter.cpp
index 3f1981e5731..88b5af2d93d 100644
--- a/Gui/VtkVis/VtkCompositeSelectionFilter.cpp
+++ b/Gui/VtkVis/VtkCompositeSelectionFilter.cpp
@@ -24,6 +24,10 @@
 #include <vtkIdFilter.h>
 #include <vtkUnstructuredGrid.h>
 
+#include <vtkUnstructuredGridAlgorithm.h>
+#include <vtkPointData.h>
+
+
 VtkCompositeSelectionFilter::VtkCompositeSelectionFilter( vtkAlgorithm* inputAlgorithm )
 	: VtkCompositeFilter(inputAlgorithm), _selection_name("Selection"), _is_element_array(true)
 {
@@ -32,7 +36,7 @@ VtkCompositeSelectionFilter::VtkCompositeSelectionFilter( vtkAlgorithm* inputAlg
 
 void VtkCompositeSelectionFilter::init()
 {
-	double thresholdLower(0.0), thresholdUpper(1.0);
+	double thresholdLower(0.0), thresholdUpper(100000.0);
 	this->_inputDataObjectType = VTK_UNSTRUCTURED_GRID;
 	this->_outputDataObjectType = VTK_UNSTRUCTURED_GRID;
 
@@ -57,29 +61,32 @@ void VtkCompositeSelectionFilter::init()
 		idFilter->FieldDataOn();
 		idFilter->Update();
 		
-	vtkThreshold* threshold = vtkThreshold::New();
-		threshold->SetInputConnection(idFilter->GetOutputPort());
+	size_t nPoints = idFilter->GetOutput()->GetPointData()->GetNumberOfTuples();
+
+	_threshold = vtkThreshold::New();
+		_threshold->SetInputConnection(idFilter->GetOutputPort());
 		if (_is_element_array)
-			threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS, _selection_name.c_str());
+			_threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_CELLS, _selection_name.c_str());
 		else
-			threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, _selection_name.c_str());
-		threshold->SetSelectedComponent(0);
-		threshold->ThresholdBetween(thresholdLower, thresholdUpper);
-		threshold->Update();
-
+			_threshold->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, _selection_name.c_str());
+		_threshold->SetSelectedComponent(0);
+		_threshold->ThresholdBetween(thresholdLower, thresholdUpper);
+		_threshold->Update();
+		
 	QList<QVariant> thresholdRangeList;
-	thresholdRangeList.push_back(0.0);
-	thresholdRangeList.push_back(1.0);
+	thresholdRangeList.push_back(thresholdLower);
+	thresholdRangeList.push_back(thresholdUpper);
 	(*_algorithmUserVectorProperties)["Threshold Between"] = thresholdRangeList;
-
+	
 	if (!_is_element_array)
 	{
-		VtkCompositeFilter* composite = new VtkCompositePointToGlyphFilter(threshold);
+			size_t nPoints = _threshold->GetOutput()->GetPointData()->GetNumberOfTuples();
+		VtkCompositeFilter* composite = new VtkCompositePointToGlyphFilter(_threshold);
 		composite->SetUserProperty("Radius", this->GetInitialRadius());
 		_outputAlgorithm = composite->GetOutputAlgorithm();
 	}
 	else
-		_outputAlgorithm = threshold;
+		_outputAlgorithm = _threshold;
 }
 
 void VtkCompositeSelectionFilter::setSelectionArray(const std::string &selection_name, bool is_element_array, const std::vector<double> &selection)
@@ -93,9 +100,11 @@ void VtkCompositeSelectionFilter::setSelectionArray(const std::string &selection
 void VtkCompositeSelectionFilter::SetUserVectorProperty( QString name, QList<QVariant> values)
 {
 	VtkAlgorithmProperties::SetUserVectorProperty(name, values);
+	double a = values[0].toDouble();
+	double b = values[1].toDouble();
 
 	if (name.compare("Threshold Between") == 0)
-		static_cast<vtkThreshold*>(_outputAlgorithm)->ThresholdBetween(
+		static_cast<vtkThreshold*>(_threshold)->ThresholdBetween(
 		        values[0].toDouble(), values[1].toDouble());
 }
 
diff --git a/Gui/VtkVis/VtkCompositeSelectionFilter.h b/Gui/VtkVis/VtkCompositeSelectionFilter.h
index d0a868ebf25..dd0e5b5fe8c 100644
--- a/Gui/VtkVis/VtkCompositeSelectionFilter.h
+++ b/Gui/VtkVis/VtkCompositeSelectionFilter.h
@@ -19,6 +19,8 @@
 
 #include <vector>
 
+class vtkThreshold;
+
 class VtkColorLookupTable;
 
 /// @brief This filter colors the input by the points z-value.
@@ -38,6 +40,7 @@ private:
 	/// Returns a colour lookup table optimised for quality measures
 	VtkColorLookupTable* GetLookupTable();
 
+	vtkThreshold* _threshold;
 	std::string _selection_name;
 	std::vector<double> _selection;
 	bool _is_element_array;
diff --git a/Gui/VtkVis/VtkMeshSource.h b/Gui/VtkVis/VtkMeshSource.h
index 689a77f54c1..224d2e25749 100644
--- a/Gui/VtkVis/VtkMeshSource.h
+++ b/Gui/VtkVis/VtkMeshSource.h
@@ -41,7 +41,7 @@ public:
 	const char* GetMaterialArrayName() const { return _matName; }
 
 	/// Returns the base object of this grid
-	const MeshLib::Mesh* GetMesh() { return this->_grid; }
+	const MeshLib::Mesh* GetMesh() const { return this->_grid; }
 
 	/// Sets the grid object that should be visualized
 	void SetMesh(const MeshLib::Mesh* grid) { _grid = grid; }
diff --git a/Gui/VtkVis/VtkVisPipeline.cpp b/Gui/VtkVis/VtkVisPipeline.cpp
index cd9092c6285..6c853f803c9 100644
--- a/Gui/VtkVis/VtkVisPipeline.cpp
+++ b/Gui/VtkVis/VtkVisPipeline.cpp
@@ -592,7 +592,7 @@ void VtkVisPipeline::removeHighlightedGeoObject()
 	}
 }
 
-void VtkVisPipeline::highlightMeshComponent(const vtkUnstructuredGridAlgorithm* source, bool is_element, int index)
+void VtkVisPipeline::highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const source, bool is_element, int index)
 {
 	int nSources = this->_rootItem->childCount();
 	for (int i = 0; i < nSources; i++)
@@ -609,7 +609,7 @@ void VtkVisPipeline::highlightMeshComponent(const vtkUnstructuredGridAlgorithm*
 															"VtkCompositeSelectionFilter",
 															parentItem->transformFilter());
 			static_cast<VtkCompositeSelectionFilter*>(filter)->setSelectionArray("vtkIdFilter_Ids", is_element);
-			static_cast<VtkCompositeSelectionFilter*>(filter)->SetUserVectorProperty("Threshold Between", selected_index);
+			//static_cast<VtkCompositeSelectionFilter*>(filter)->SetUserVectorProperty("Threshold Between", selected_index);
 
 			VtkVisPointSetItem* item = new VtkVisPointSetItem(filter, parentItem, itemData);
 			QModelIndex parent_index = static_cast<TreeModel*>(this)->index(i, 0, QModelIndex());
diff --git a/Gui/VtkVis/VtkVisPipeline.h b/Gui/VtkVis/VtkVisPipeline.h
index 2d6debb5c4d..c73b88a0a05 100644
--- a/Gui/VtkVis/VtkVisPipeline.h
+++ b/Gui/VtkVis/VtkVisPipeline.h
@@ -126,7 +126,7 @@ public slots:
 	void removeHighlightedGeoObject();
 
 	/// Applies a VtkCompositeSelectionFilter to add a specific component of the given mesh-source to the pipeline for highlighted display in the render window.
-	void highlightMeshComponent(const vtkUnstructuredGridAlgorithm* source, bool is_element, int index);
+	void highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const source, bool is_element, int index);
 
 	/// Removes the currently highlighted mesh component
 	void removeHighlightedMeshComponent();
diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp
index d29de28553c..4905616882d 100644
--- a/Gui/mainwindow.cpp
+++ b/Gui/mainwindow.cpp
@@ -201,10 +201,14 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/)
 	        this, SLOT(showMshQualitySelectionDialog(VtkMeshSource*)));
 	connect(mshTabWidget->treeView, SIGNAL(requestCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool)),
 			this, SLOT(showCondSetupDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t, bool)));
-	connect(mshTabWidget->treeView, SIGNAL(elementSelected(const vtkUnstructuredGridAlgorithm*, bool, int)),
-		    _vtkVisPipeline, SLOT(highlightMeshComponent(const vtkUnstructuredGridAlgorithm*, bool, int)));
+	connect(mshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, bool, int)),
+		    _vtkVisPipeline, SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, bool, int)));
 	connect(mshTabWidget->treeView, SIGNAL(removeSelectedMeshComponent()),
 		    _vtkVisPipeline, SLOT(removeHighlightedMeshComponent()));
+	connect(mshTabWidget->elementView, SIGNAL(nodeSelected(vtkUnstructuredGridAlgorithm const*const, bool, int)),
+		    _vtkVisPipeline, SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, bool, int)));
+	connect(mshTabWidget->elementView, SIGNAL(removeSelectedMeshComponent()),
+		    _vtkVisPipeline, SLOT(removeHighlightedMeshComponent()));
 
 	// Setup connections for process model to GUI
 	connect(modellingTabWidget->treeView, SIGNAL(conditionsRemoved(const FiniteElement::ProcessType, const std::string&, const FEMCondition::CondType)),
@@ -269,11 +273,13 @@ MainWindow::MainWindow(QWidget* parent /* = 0*/)
 	        SIGNAL(actorPicked(vtkProp3D*)),
 	        vtkVisTabWidget->vtkVisPipelineView, SLOT(selectItem(vtkProp3D*)));
 	connect((QObject*) (visualizationWidget->interactorStyle()),
-	        SIGNAL(elementPicked(const MeshLib::Mesh *, const std::size_t)),
-	        this->_elementModel, SLOT(setElement(const MeshLib::Mesh *, const std::size_t)));
+	        SIGNAL(elementPicked(vtkUnstructuredGridAlgorithm const*const, const std::size_t)),
+	        this->_elementModel, SLOT(setElement(vtkUnstructuredGridAlgorithm const*const, const std::size_t)));
 	connect((QObject*) (visualizationWidget->interactorStyle()),
-	        SIGNAL(elementPicked(const MeshLib::Mesh *, const std::size_t)),
+	        SIGNAL(elementPicked(vtkUnstructuredGridAlgorithm const*const, const std::size_t)),
 	        mshTabWidget->elementView, SLOT(updateView()));
+	connect((QObject*) (visualizationWidget->interactorStyle()), SIGNAL(clearElementView()),
+	        this->_elementModel, SLOT(clearView()));
 
 	connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(meshAdded(MeshLib::Mesh*)),
 	        _meshModels, SLOT(addMesh(MeshLib::Mesh*)));
-- 
GitLab