Commit d23b7985 authored by Jeff Baumes's avatar Jeff Baumes

Option to disable edge selection from vtkGraphLayoutView

Submitted by Nicolas Rannou <nicolas_rannou@hms.harvard.edu>

vtkGraphLayoutView
-> new method: void SetEdgeSelection(bool) - modify the representation
   variable EdgeSelection.
-> new method: bool GetEdgeSelection() - get the representation variable
   EdgeSelection.

vtkRenderedGraphRepresentation
-> new variable: bool EdgeSelection - default true=edges will be
selected
-> new method: void SetEdgeSelection(bool) - modify EdgeSelection value.
-> new method: bool GetEdgeSelection() - get EdgeSelection value.

Change-Id: I7f438386fd119fa9a819dffeea864f64de29ebaa
parent 83217be5
......@@ -278,7 +278,17 @@ bool vtkGraphLayoutView::GetColorEdges()
{
return this->GetGraphRepresentation()->GetColorEdgesByArray();
}
//----------------------------------------------------------------------------
void vtkGraphLayoutView::SetEdgeSelection(bool vis)
{
this->GetGraphRepresentation()->SetEdgeSelection(vis);
}
//----------------------------------------------------------------------------
bool vtkGraphLayoutView::GetEdgeSelection()
{
return this->GetGraphRepresentation()->GetEdgeSelection();
}
//----------------------------------------------------------------------------
void vtkGraphLayoutView::SetEdgeScalarBarVisibility(bool vis)
{
......@@ -514,4 +524,3 @@ void vtkGraphLayoutView::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
......@@ -116,6 +116,12 @@ public:
bool GetColorEdges();
vtkBooleanMacro(ColorEdges, bool);
// Description:
// Whether edges are selectable. Default is on.
void SetEdgeSelection(bool vis);
bool GetEdgeSelection();
vtkBooleanMacro(EdgeSelection, bool);
// Description:
// The array to use for coloring edges.
void SetEnabledEdgesArrayName(const char* name);
......
......@@ -139,6 +139,8 @@ vtkRenderedGraphRepresentation::vtkRenderedGraphRepresentation()
this->HideVertexLabelsOnInteraction = false;
this->HideEdgeLabelsOnInteraction = false;
this->EdgeSelection = true;
/*
<graphviz>
digraph {
......@@ -339,6 +341,16 @@ bool vtkRenderedGraphRepresentation::GetEdgeVisibility()
return this->EdgeActor->GetVisibility() ? true : false;
}
void vtkRenderedGraphRepresentation::SetEdgeSelection(bool b)
{
this->EdgeSelection = b;
}
bool vtkRenderedGraphRepresentation::GetEdgeSelection()
{
return this->EdgeSelection;
}
void vtkRenderedGraphRepresentation::SetVertexLabelTextProperty(vtkTextProperty* p)
{
this->VertexLabelHierarchy->SetTextProperty(p);
......@@ -1144,31 +1156,34 @@ vtkSelection* vtkRenderedGraphRepresentation::ConvertSelection(
vtkConvertSelection::GetSelectedVertices(
vertexConverted, input, selectedVerts);
// Get the list of induced edges on these vertices.
vtkSmartPointer<vtkIdTypeArray> selectedEdges =
vtkSmartPointer<vtkIdTypeArray>::New();
input->GetInducedEdges(selectedVerts, selectedEdges);
// Create an edge index selection containing the induced edges.
vtkSmartPointer<vtkSelection> edgeSelection =
vtkSmartPointer<vtkSelection>::New();
vtkSmartPointer<vtkSelectionNode> edgeSelectionNode =
vtkSmartPointer<vtkSelectionNode>::New();
edgeSelectionNode->SetSelectionList(selectedEdges);
edgeSelectionNode->SetContentType(vtkSelectionNode::INDICES);
edgeSelectionNode->SetFieldType(vtkSelectionNode::EDGE);
edgeSelection->AddNode(edgeSelectionNode);
// Convert the edge selection to the appropriate type for this representation.
vtkSelection* edgeConverted = vtkConvertSelection::ToSelectionType(
edgeSelection, input, this->SelectionType, this->SelectionArrayNames);
// Add the converted induced edge selection to the output selection.
if (edgeConverted->GetNumberOfNodes() > 0)
if( this->EdgeSelection )
{
converted->AddNode(edgeConverted->GetNode(0));
// Get the list of induced edges on these vertices.
vtkSmartPointer<vtkIdTypeArray> selectedEdges =
vtkSmartPointer<vtkIdTypeArray>::New();
input->GetInducedEdges(selectedVerts, selectedEdges);
// Create an edge index selection containing the induced edges.
vtkSmartPointer<vtkSelection> edgeSelection =
vtkSmartPointer<vtkSelection>::New();
vtkSmartPointer<vtkSelectionNode> edgeSelectionNode =
vtkSmartPointer<vtkSelectionNode>::New();
edgeSelectionNode->SetSelectionList(selectedEdges);
edgeSelectionNode->SetContentType(vtkSelectionNode::INDICES);
edgeSelectionNode->SetFieldType(vtkSelectionNode::EDGE);
edgeSelection->AddNode(edgeSelectionNode);
// Convert the edge selection to the appropriate type for this representation.
vtkSelection* edgeConverted = vtkConvertSelection::ToSelectionType(
edgeSelection, input, this->SelectionType, this->SelectionArrayNames);
// Add the converted induced edge selection to the output selection.
if (edgeConverted->GetNumberOfNodes() > 0)
{
converted->AddNode(edgeConverted->GetNode(0));
}
edgeConverted->Delete();
}
edgeConverted->Delete();
}
// Add the vertex selection node to the output selection.
......@@ -1177,7 +1192,7 @@ vtkSelection* vtkRenderedGraphRepresentation::ConvertSelection(
polyConverted->Delete();
vertexConverted->Delete();
}
if (foundEdgeNode && !selectedVerticesFound)
if (foundEdgeNode && !selectedVerticesFound && this->EdgeSelection)
{
// If no vertices were found (hence no induced edges), look for
// edges that were within the selection box.
......
......@@ -205,6 +205,9 @@ public:
virtual bool GetEdgeVisibility();
vtkBooleanMacro(EdgeVisibility, bool);
void SetEdgeSelection(bool b);
bool GetEdgeSelection();
// ------------------------------------------------------------------------
// Vertex layout strategy
......@@ -422,6 +425,8 @@ protected:
bool HideVertexLabelsOnInteraction;
bool HideEdgeLabelsOnInteraction;
bool EdgeSelection;
private:
vtkRenderedGraphRepresentation(const vtkRenderedGraphRepresentation&); // Not implemented
void operator=(const vtkRenderedGraphRepresentation&); // Not implemented
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment