Commit de460148 authored by Jeff Baumes's avatar Jeff Baumes
Browse files

BUG: Fixing several bugs related to new views

Updating a view used to cause the view to render. Now, rendering the
view causes the view to update. This simplifies making sure views are
up-to-date, but required some changes.

 - ClientGeoView/2D plugins now execute Render on the view instead of
   Update.

 - ClientGeoView/2D Initialize() warning is now fixed.

 - vtkCommand has a new event (ComputeVisiblePropBoundsEvent). This is
   called when vtkRenderer::ComputeVisiblePropBoundsEvent is called.
   vtkRenderView now listens for this event, along with vtkRenderer's
   StartEvent, so it can catch (almost?) all indications that the
   pipeline is about to be updated. vtkRenderView (and all its
   representations) now correctly update before pipeline updates.

 - Some geovis tests needed to be updated to make sure the view is
   rendered correctly with these changes.

 - vtkGeoView/2D need to call superclass's PrepareForRendering.

 - vtkConvertSelection had some memory bugs, and was not handling all
   cases correctly.

 - vtkRenderView subclasses needed to be more careful about making sure
   pipeline is valid at every stage, including when the selection
   connection is temporarily NULL.

 - vtkView no longer has the hack that calls Update on representations
   before they are added to the view.
parent 314f50c9
......@@ -96,6 +96,7 @@ static const char *vtkCommandEventStrings[] = {
"ViewProgressEvent",
"UpdateDataEvent",
"CurrentChangedEvent",
"ComputeVisiblePropBoundsEvent",
NULL
};
......
......@@ -166,6 +166,8 @@
// - GUISupport/Qt/QVTKWidget returns a QEvent*
// - vtkCommand::RenderWindowMessageEvent
// - Rendering/vtkWin32OpenGLRenderWindow return a pointer to a UINT message
// - vtkCommand::ComputeVisiblePropBoundsEvent
// - Rendering/vtkRenderer returns a pointer to itself
// - QVTKWidget::ContextMenuEvent
// - GUISupport/Qt/QVTKWidget returns a QContextMenuEvent*
// - QVTKWidget::DragEnterEvent
......@@ -336,6 +338,7 @@ public:
ViewProgressEvent,
UpdateDataEvent,
CurrentChangedEvent,
ComputeVisiblePropBoundsEvent,
UserEvent = 1000
};
//ETX
......
......@@ -269,23 +269,9 @@ int TestCoincidentGeoGraphRepresentation2D(int argc, char* argv[])
// Set up the viewport
win->SetSize(900, 600);
vtkSmartPointer<vtkGeoTerrainNode> root =
vtkSmartPointer<vtkGeoTerrainNode>::New();
terrainSource->FetchRoot(root);
double bounds[6];
root->GetModel()->GetBounds(bounds);
bounds[0] = bounds[0] - (bounds[1] - bounds[0])*0.01;
bounds[1] = bounds[1] + (bounds[1] - bounds[0])*0.01;
bounds[2] = bounds[2] - (bounds[3] - bounds[2])*0.01;
bounds[3] = bounds[3] + (bounds[3] - bounds[2])*0.01;
double scalex = (bounds[1] - bounds[0])/2.0;
double scaley = (bounds[3] - bounds[2])/2.0;
double scale = (scalex > scaley) ? scalex : scaley;
view->GetRenderer()->GetActiveCamera()->SetParallelScale(scale);
view->Update();
view->GetRenderer()->ResetCamera();
view->GetRenderer()->GetActiveCamera()->Zoom(2.1);
view->GetRenderer()->GetActiveCamera()->SetParallelScale(95.8);
view->GetRenderer()->Render();
int retVal = vtkRegressionTestImage(win);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
......
......@@ -195,7 +195,7 @@ int TestGeoView(int argc, char* argv[])
}
imageRep->SetSource(imageSource);
view->Update();
view->GetRenderer()->ResetCameraClippingRange();
//int retVal = vtkRegressionTestImage(win);
int retVal = vtkRegressionTestImageThreshold(win, 11);
......
......@@ -41,7 +41,7 @@
#include "vtkSmartPointer.h"
#include "vtkViewTheme.h"
vtkCxxRevisionMacro(vtkGeoView, "1.11");
vtkCxxRevisionMacro(vtkGeoView, "1.12");
vtkStandardNewMacro(vtkGeoView);
vtkCxxSetObjectMacro(vtkGeoView, Terrain, vtkGeoTerrain);
//----------------------------------------------------------------------------
......@@ -164,6 +164,7 @@ bool vtkGeoView::GetLockHeading()
// Prepares the view for rendering.
void vtkGeoView::PrepareForRendering()
{
this->Superclass::PrepareForRendering();
vtkSmartPointer<vtkCollection> imageReps =
vtkSmartPointer<vtkCollection>::New();
for (int i = 0; i < this->GetNumberOfRepresentations(); i++)
......
......@@ -31,7 +31,7 @@
#include "vtkSmartPointer.h"
#include "vtkViewTheme.h"
vtkCxxRevisionMacro(vtkGeoView2D, "1.3");
vtkCxxRevisionMacro(vtkGeoView2D, "1.4");
vtkStandardNewMacro(vtkGeoView2D);
vtkCxxSetObjectMacro(vtkGeoView2D, Surface, vtkGeoTerrain2D);
......@@ -72,6 +72,7 @@ void vtkGeoView2D::ApplyViewTheme(vtkViewTheme* theme)
void vtkGeoView2D::PrepareForRendering()
{
this->Superclass::PrepareForRendering();
if (!this->Surface)
{
return;
......
......@@ -55,7 +55,7 @@
vtkCxxSetObjectMacro(vtkConvertSelection, ArrayNames, vtkStringArray);
vtkCxxRevisionMacro(vtkConvertSelection, "1.24");
vtkCxxRevisionMacro(vtkConvertSelection, "1.25");
vtkStandardNewMacro(vtkConvertSelection);
//----------------------------------------------------------------------------
vtkConvertSelection::vtkConvertSelection()
......@@ -678,7 +678,11 @@ int vtkConvertSelection::Convert(
}
}
}
else
// If no domain array, the name of the selection and data arrays
// must match (if they exist).
else if (inputNode->GetContentType() != vtkSelectionNode::PEDIGREEIDS ||
!selArr->GetName() || !dataArr->GetName() ||
!strcmp(selArr->GetName(), dataArr->GetName()))
{
// Perform the lookup
vtkIdType numTuples = selArr->GetNumberOfTuples();
......@@ -924,6 +928,7 @@ void vtkConvertSelection::GetSelectedItems(
}
}
}
indexSel->Delete();
}
//----------------------------------------------------------------------------
......@@ -1025,17 +1030,16 @@ vtkSelection* vtkConvertSelection::ToSelectionType(
VTK_CREATE(vtkConvertSelection, convert);
vtkDataObject* dataCopy = data->NewInstance();
dataCopy->ShallowCopy(data);
vtkSelection* inputCopy = vtkSelection::New();
VTK_CREATE(vtkSelection, inputCopy);
inputCopy->ShallowCopy(input);
convert->SetInput(0, input);
convert->SetInput(1, data);
convert->SetInput(0, inputCopy);
convert->SetInput(1, dataCopy);
convert->SetOutputType(type);
convert->SetArrayNames(arrayNames);
convert->Update();
vtkSelection* output = convert->GetOutput();
output->Register(0);
dataCopy->Delete();
inputCopy->Delete();
return output;
}
......
......@@ -40,7 +40,7 @@
#include "vtkRenderPass.h"
#include "vtkRenderState.h"
vtkCxxRevisionMacro(vtkRenderer, "1.246");
vtkCxxRevisionMacro(vtkRenderer, "1.247");
vtkCxxSetObjectMacro(vtkRenderer, Delegate, vtkRendererDelegate);
vtkCxxSetObjectMacro(vtkRenderer, Pass, vtkRenderPass);
......@@ -879,6 +879,8 @@ void vtkRenderer::ComputeVisiblePropBounds( double allBounds[6] )
double *bounds;
int nothingVisible=1;
this->InvokeEvent(vtkCommand::ComputeVisiblePropBoundsEvent, this);
allBounds[0] = allBounds[2] = allBounds[4] = VTK_DOUBLE_MAX;
allBounds[1] = allBounds[3] = allBounds[5] = -VTK_DOUBLE_MAX;
......
......@@ -73,7 +73,7 @@
#include <ctype.h> // for tolower()
vtkCxxRevisionMacro(vtkGraphLayoutView, "1.52");
vtkCxxRevisionMacro(vtkGraphLayoutView, "1.53");
vtkStandardNewMacro(vtkGraphLayoutView);
//----------------------------------------------------------------------------
vtkGraphLayoutView::vtkGraphLayoutView()
......@@ -772,7 +772,23 @@ void vtkGraphLayoutView::AddInputConnection( int port, int item,
else if (this->GraphLayout->GetNumberOfInputConnections(0) == 0)
{
this->GraphLayout->SetInputConnection(conn);
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
if (selectionConn)
{
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
}
else
{
vtkSmartPointer<vtkSelection> empty =
vtkSmartPointer<vtkSelection>::New();
vtkSmartPointer<vtkSelectionNode> emptyNode =
vtkSmartPointer<vtkSelectionNode>::New();
emptyNode->SetContentType(vtkSelectionNode::INDICES);
vtkSmartPointer<vtkIdTypeArray> arr =
vtkSmartPointer<vtkIdTypeArray>::New();
emptyNode->SetSelectionList(arr);
empty->AddNode(emptyNode);
this->ExtractSelectedGraph->SetInput(1, empty);
}
this->Renderer->AddActor(this->GraphActor);
this->Renderer->AddActor(this->SelectedGraphActor);
......@@ -905,7 +921,11 @@ void vtkGraphLayoutView::ProcessEvents(
if (sel)
{
vtkSelectionNode* node = sel->GetNode(0);
ids = node ? vtkIdTypeArray::SafeDownCast(node->GetSelectionList()) : 0;
if (node && node->GetProperties()->Get(vtkSelectionNode::PROP()) ==
this->EdgeSelectionActor)
{
ids = vtkIdTypeArray::SafeDownCast(node->GetSelectionList());
}
}
// Turn off the special edge actor
......@@ -969,12 +989,14 @@ void vtkGraphLayoutView::PrepareForRendering()
// Make sure the input connection is up to date.
vtkAlgorithmOutput* conn = rep->GetInputConnection();
if (this->GraphLayout->GetInputConnection(0, 0) != conn)
vtkAlgorithmOutput* selectionConn = rep->GetSelectionConnection();
if (this->GraphLayout->GetInputConnection(0, 0) != conn ||
this->ExtractSelectedGraph->GetInputConnection(1, 0) != selectionConn)
{
this->RemoveInputConnection( 0, 0,
this->RemoveInputConnection( 0, 0,
this->GraphLayout->GetInputConnection(0, 0),
this->ExtractSelectedGraph->GetInputConnection(1, 0));
this->AddInputConnection(0, 0, conn, rep->GetSelectionConnection());
this->AddInputConnection(0, 0, conn, selectionConn);
}
this->Superclass::PrepareForRendering();
......
......@@ -74,7 +74,7 @@
#define VTK_CREATE(type, name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
vtkCxxRevisionMacro(vtkHierarchicalGraphView, "1.10");
vtkCxxRevisionMacro(vtkHierarchicalGraphView, "1.11");
vtkStandardNewMacro(vtkHierarchicalGraphView);
//----------------------------------------------------------------------------
vtkHierarchicalGraphView::vtkHierarchicalGraphView()
......@@ -244,6 +244,7 @@ vtkHierarchicalGraphView::vtkHierarchicalGraphView()
this->GraphEdgeMapper->SetInputConnection(this->Spline->GetOutputPort());
this->GraphEdgeActor->SetMapper(this->GraphEdgeMapper);
this->KdTreeSelector->SetInputConnection(this->VertexDegree->GetOutputPort());
this->ExtractSelectedGraph->SetInput(1, this->EmptySelection);
this->SelectedGraphHBundle->SetInputConnection(0, this->ExtractSelectedGraph->GetOutputPort());
this->SelectedGraphHBundle->SetInputConnection(1, this->VertexDegree->GetOutputPort());
this->SelectedGraphSpline->SetInputConnection(this->SelectedGraphHBundle->GetOutputPort());
......@@ -689,14 +690,28 @@ void vtkHierarchicalGraphView::AddInputConnection( int port, int vtkNotUsed(inde
if( port == 0 )
{
this->TreeAggregation->SetInputConnection(0, conn);
this->ExtractSelectedTree->SetInputConnection(1, selectionConn);
if (selectionConn)
{
this->ExtractSelectedTree->SetInputConnection(1, selectionConn);
}
else
{
this->ExtractSelectedTree->SetInput(1, this->EmptySelection);
}
haveTree = true;
}
else
{
this->HBundle->SetInputConnection(0, conn);
this->ExtractSelectedGraph->SetInputConnection(0, conn);
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
if (selectionConn)
{
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
}
else
{
this->ExtractSelectedGraph->SetInput(1, this->EmptySelection);
}
haveGraph = true;
}
......@@ -861,7 +876,11 @@ void vtkHierarchicalGraphView::ProcessEvents(
if (sel)
{
vtkSelectionNode* node = sel->GetNode(0);
ids = node ? vtkIdTypeArray::SafeDownCast(node->GetSelectionList()) : 0;
if (node && node->GetProperties()->Get(vtkSelectionNode::PROP()) ==
this->GraphEdgeMapper)
{
ids = vtkIdTypeArray::SafeDownCast(node->GetSelectionList());
}
}
// Set the speciale dge actor back to normal.
......@@ -938,24 +957,28 @@ void vtkHierarchicalGraphView::PrepareForRendering()
vtkDataRepresentation* treeRep = this->GetRepresentation();
vtkAlgorithmOutput* treeConn = treeRep->GetInputConnection();
if (this->TreeAggregation->GetInputConnection(0, 0) != treeConn)
vtkAlgorithmOutput* selectionConn = treeRep->GetSelectionConnection();
if (this->TreeAggregation->GetInputConnection(0, 0) != treeConn ||
this->ExtractSelectedTree->GetInputConnection(1, 0) != selectionConn)
{
this->RemoveInputConnection(0, 0,
this->RemoveInputConnection(0, 0,
this->TreeAggregation->GetInputConnection(0, 0),
this->ExtractSelectedTree->GetInputConnection(1, 0));
this->AddInputConnection(0, 0, treeConn, treeRep->GetSelectionConnection());
this->AddInputConnection(0, 0, treeConn, selectionConn);
}
// Make sure the graph input connection is up to date.
vtkDataRepresentation* graphRep = this->GetRepresentation(1, 0);
vtkAlgorithmOutput* graphConn = graphRep->GetInputConnection();
if (this->HBundle->GetInputConnection(0, 0) != graphConn)
selectionConn = graphRep->GetSelectionConnection();
if (this->HBundle->GetInputConnection(0, 0) != graphConn ||
this->ExtractSelectedGraph->GetInputConnection(1, 0) != selectionConn)
{
this->RemoveInputConnection(1, 0,
this->RemoveInputConnection(1, 0,
this->HBundle->GetInputConnection(0, 0),
this->ExtractSelectedGraph->GetInputConnection(1, 0));
this->AddInputConnection(1, 0, graphConn, graphRep->GetSelectionConnection());
this->AddInputConnection(1, 0, graphConn, selectionConn);
}
this->Superclass::PrepareForRendering();
......
......@@ -39,13 +39,15 @@
#include <vtksys/stl/map>
using vtksys_stl::map;
vtkCxxRevisionMacro(vtkRenderView, "1.11");
vtkCxxRevisionMacro(vtkRenderView, "1.12");
vtkStandardNewMacro(vtkRenderView);
//----------------------------------------------------------------------------
vtkRenderView::vtkRenderView()
{
this->Renderer = vtkRenderer::New();
this->Renderer->AddObserver(vtkCommand::StartEvent, this->GetObserver());
this->Renderer->AddObserver(vtkCommand::ComputeVisiblePropBoundsEvent,
this->GetObserver());
this->InteractorStyle = vtkInteractorStyleRubberBand3D::New();
this->InteractorStyle->AddObserver(vtkCommand::SelectionChangedEvent, this->GetObserver());
this->SelectionMode = SURFACE;
......@@ -115,6 +117,11 @@ void vtkRenderView::ProcessEvents(vtkObject* caller, unsigned long eventId,
{
this->PrepareForRendering();
}
else if (caller == this->Renderer &&
eventId == vtkCommand::ComputeVisiblePropBoundsEvent)
{
this->Update();
}
else if (caller == this->InteractorStyle && eventId == vtkCommand::SelectionChangedEvent)
{
unsigned int* rect = reinterpret_cast<unsigned int*>(callData);
......@@ -223,7 +230,11 @@ void vtkRenderView::ProcessEvents(vtkObject* caller, unsigned long eventId,
}
else if(eventId == vtkCommand::SelectionChangedEvent)
{
this->Update();
if (this->Renderer->GetRenderWindow())
{
this->Renderer->ResetCameraClippingRange();
this->Renderer->GetRenderWindow()->Render();
}
Superclass::ProcessEvents(caller, eventId, callData);
}
else
......@@ -232,31 +243,12 @@ void vtkRenderView::ProcessEvents(vtkObject* caller, unsigned long eventId,
}
}
//----------------------------------------------------------------------------
void vtkRenderView::Update()
{
this->Superclass::Update();
if (this->Renderer->GetRenderWindow())
{
this->Renderer->ResetCameraClippingRange();
this->Renderer->GetRenderWindow()->Render();
}
}
//----------------------------------------------------------------------------
void vtkRenderView::ApplyViewTheme(vtkViewTheme* theme)
{
this->Renderer->SetBackground(theme->GetBackgroundColor());
}
//----------------------------------------------------------------------------
void vtkRenderView::RepresentationSelectionChanged(
vtkDataRepresentation* vtkNotUsed(rep),
vtkSelection* vtkNotUsed(selection))
{
this->Update();
}
//----------------------------------------------------------------------------
void vtkRenderView::PrepareForRendering()
{
......
......@@ -63,10 +63,6 @@ public:
// Apply a theme to the view.
virtual void ApplyViewTheme(vtkViewTheme* theme);
// Description:
// Update the view.
virtual void Update();
//BTX
enum {
SURFACE = 0,
......@@ -93,12 +89,6 @@ protected:
// Called by the view when the renderer is about to render.
virtual void PrepareForRendering();
// Description:
// Called when a representation's selection changed.
virtual void RepresentationSelectionChanged(
vtkDataRepresentation* rep,
vtkSelection* selection);
// Description:
// Allow subclasses to change the interactor style.
vtkGetObjectMacro(InteractorStyle, vtkInteractorStyle);
......
......@@ -70,7 +70,7 @@
#define VTK_CREATE(type, name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
vtkCxxRevisionMacro(vtkTreeAreaView, "1.2");
vtkCxxRevisionMacro(vtkTreeAreaView, "1.3");
vtkStandardNewMacro(vtkTreeAreaView);
//----------------------------------------------------------------------------
vtkTreeAreaView::vtkTreeAreaView()
......@@ -252,6 +252,7 @@ vtkTreeAreaView::vtkTreeAreaView()
this->GraphEdgeMapper->SetInputConnection(this->Spline->GetOutputPort());
this->GraphEdgeActor->SetMapper(this->GraphEdgeMapper);
this->KdTreeSelector->SetInputConnection(this->AreaLayout->GetOutputPort());
this->ExtractSelectedGraph->SetInput(1, this->EmptySelection);
this->SelectedGraphHBundle->SetInputConnection(0, this->ExtractSelectedGraph->GetOutputPort());
this->SelectedGraphHBundle->SetInputConnection(1, this->AreaLayout->GetOutputPort(1));
this->SelectedGraphSpline->SetInputConnection(this->SelectedGraphHBundle->GetOutputPort());
......@@ -263,6 +264,7 @@ vtkTreeAreaView::vtkTreeAreaView()
this->AreaLabelMapper->SetInputConnection(this->AreaLayout->GetOutputPort());
this->AreaLabelActor->SetMapper(this->AreaLabelMapper);
this->ConvertSelection->SetInput(0, this->EmptySelection);
this->ConvertSelection->SetInputConnection(1, this->AreaToPolyData->GetOutputPort());
this->ExtractSelectedAreas->SetInputConnection(0, this->AreaToPolyData->GetOutputPort());
this->ExtractSelectedAreas->SetInputConnection(1, this->ConvertSelection->GetOutputPort());
......@@ -524,7 +526,14 @@ void vtkTreeAreaView::AddInputConnection(
if( port == 0 )
{
this->TreeLevels->SetInputConnection(0, conn);
this->ConvertSelection->SetInputConnection(0, selectionConn);
if (selectionConn)
{
this->ConvertSelection->SetInputConnection(0, selectionConn);
}
else
{
this->ConvertSelection->SetInput(0, this->EmptySelection);
}
haveTree = true;
}
else
......@@ -532,7 +541,14 @@ void vtkTreeAreaView::AddInputConnection(
this->HBundle->SetInputConnection(0, conn);
this->GraphVertexDegree->SetInputConnection(0, conn);
this->ExtractSelectedGraph->SetInputConnection(0, conn);
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
if (selectionConn)
{
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
}
else
{
this->ExtractSelectedGraph->SetInput(1, this->EmptySelection);
}
this->TreeAggregation->SetInputConnection(this->TransferAttributes->GetOutputPort());
haveGraph = true;
}
......@@ -809,13 +825,11 @@ void vtkTreeAreaView::PrepareForRendering()
{
// Make sure the tree input connection is up to date.
vtkAlgorithmOutput* treeConn = treeRep->GetInputConnection();
if (this->TreeLevels->GetInputConnection(0, 0) != treeConn)
vtkAlgorithmOutput* selectionConn = treeRep->GetSelectionConnection();
if (this->TreeLevels->GetInputConnection(0, 0) != treeConn ||
this->ConvertSelection->GetInputConnection(0, 0) != selectionConn)
{
this->RemoveInputConnection(0, 0,
this->TreeLevels->GetInputConnection(0, 0), NULL );
//FIXME - jfsheph - what does setting this to NULL do?
// this->ExtractSelectedTree->GetInputConnection(1, 0));
this->AddInputConnection(0, 0, treeConn, treeRep->GetSelectionConnection());
this->AddInputConnection(0, 0, treeConn, selectionConn);
}
// Make sure vertex color range is up-to-date.
......@@ -839,12 +853,11 @@ void vtkTreeAreaView::PrepareForRendering()
{
// Make sure the graph input connection is up to date.
vtkAlgorithmOutput* graphConn = graphRep->GetInputConnection();
if (this->HBundle->GetInputConnection(0, 0) != graphConn)
vtkAlgorithmOutput* selectionConn = graphRep->GetSelectionConnection();
if (this->HBundle->GetInputConnection(0, 0) != graphConn ||
this->ExtractSelectedGraph->GetInputConnection(1, 0) != selectionConn)
{
this->RemoveInputConnection(1, 0,
this->HBundle->GetInputConnection(0, 0),
this->ExtractSelectedGraph->GetInputConnection(1, 0));
this->AddInputConnection(1, 0, graphConn, graphRep->GetSelectionConnection());
this->AddInputConnection(1, 0, graphConn, selectionConn);
}
// Make sure edge color range is up-to-date.
......
......@@ -58,7 +58,7 @@
using vtksys_stl::set;
vtkCxxRevisionMacro(vtkTreeLayoutView, "1.14");
vtkCxxRevisionMacro(vtkTreeLayoutView, "1.15");
vtkStandardNewMacro(vtkTreeLayoutView);
//----------------------------------------------------------------------------
vtkTreeLayoutView::vtkTreeLayoutView()
......@@ -408,7 +408,23 @@ void vtkTreeLayoutView::AddInputConnection( int port, int item,
else if (this->GraphLayout->GetNumberOfInputConnections(0) == 0)
{
this->GraphLayout->SetInputConnection(conn);
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
if (selectionConn)
{
this->ExtractSelectedGraph->SetInputConnection(1, selectionConn);
}
else
{
vtkSmartPointer<vtkSelection> empty =
vtkSmartPointer<vtkSelection>::New();
vtkSmartPointer<vtkSelectionNode> node =
vtkSmartPointer<vtkSelectionNode>::New();
node->SetContentType(vtkSelectionNode::INDICES);
vtkSmartPointer<vtkIdTypeArray> arr =
vtkSmartPointer<vtkIdTypeArray>::New();
node->SetSelectionList(arr);
empty->AddNode(node);
this->ExtractSelectedGraph->SetInput(1, empty);
}
this->Renderer->AddActor(this->VertexActor);
this->Renderer->AddActor(this->OutlineActor);
......@@ -619,12 +635,14 @@ void vtkTreeLayoutView::PrepareForRendering()
// Make sure the input connection is up to date.
vtkAlgorithmOutput* conn = rep->GetInputConnection();
if (this->GraphLayout->GetInputConnection(0, 0) != conn)
vtkAlgorithmOutput* selectionConn = rep->GetSelectionConnection();
if (this->GraphLayout->GetInputConnection(0, 0) != conn ||
this->ExtractSelectedGraph->GetInputConnection(1, 0) != selectionConn)
{
this->RemoveInputConnection( 0, 0,
this->RemoveInputConnection( 0, 0,
this->GraphLayout->GetInputConnection(0, 0),
this->ExtractSelectedGraph->GetInputConnection(1, 0));
this->AddInputConnection(0, 0, conn, rep->GetSelectionConnection());
this->AddInputConnection(0, 0, conn, selectionConn);
}
// Update the pipeline up until the graph to polydata
......
......@@ -76,7 +76,7 @@ public:
};
vtkCxxRevisionMacro(vtkView, "1.17");
vtkCxxRevisionMacro(vtkView, "1.18");
vtkStandardNewMacro(vtkView);
vtkCxxSetObjectMacro(vtkView, SelectionArrayNames, vtkStringArray);
//----------------------------------------------------------------------------
......@@ -311,7 +311,6 @@ void vtkView::AddRepresentation(int port, vtkDataRepresentation* rep)
{
if( !this->CheckPort( port, 0 ) )
{
rep->Update();
this->SetRepresentation(port, 0, rep);
}
else
......@@ -321,7 +320,6 @@ void vtkView::AddRepresentation(int port, vtkDataRepresentation* rep)
if( rep->AddToView( this ) )
{
rep->AddObserver(vtkCommand::SelectionChangedEvent, this->GetObserver());
rep->Update();
if (rep->GetNumberOfInputPorts() > 0)
{
this->AddInputConnection(port, 0, rep->GetInputConnection(),
......@@ -379,7 +377,6 @@ void vtkView::SetRepresentation(int port, int index, vtkDataRepresentation* rep)
}
rep->AddObserver(vtkCommand::SelectionChangedEvent, this->GetObserver());
rep->Update();
if (rep->GetNumberOfInputPorts() > 0)
{
this->AddInputConnection(port, index, rep->GetInputConnection(),
......
Supports Markdown
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