1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/*=========================================================================
Program: ParaView
Module: vtkSMPlotMatrixViewProxy.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkSMPlotMatrixViewProxy.h"
#include "vtkScatterPlotMatrix.h"
#include "vtkClientServerStream.h"
#include "vtkDoubleArray.h"
#include "vtkIdTypeArray.h"
#include "vtkObjectFactory.h"
#include "vtkPVPlotMatrixView.h"
#include "vtkPVXMLElement.h"
#include "vtkCommand.h"
#include "vtkVector.h"
#include "vtkSMSession.h"
vtkStandardNewMacro(vtkSMPlotMatrixViewProxy);
//---------------------------------------------------------------------------
vtkSMPlotMatrixViewProxy::vtkSMPlotMatrixViewProxy()
{
this->ActiveChanged = false;
}
//---------------------------------------------------------------------------
vtkSMPlotMatrixViewProxy::~vtkSMPlotMatrixViewProxy()
{
this->SetVTKClassName(0);
}
//----------------------------------------------------------------------------
void vtkSMPlotMatrixViewProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
void vtkSMPlotMatrixViewProxy::CreateVTKObjects()
{
if (this->ObjectsCreated)
return;
this->Superclass::CreateVTKObjects();
#if 0 // Server-side animation has been deactivated for now, support
// for animation is broken in tiling mode, and this
// prevent the plot matrix view usage in cs.
// This class may be removed alltogether if we decide not to support
// it again.
// see bug 16118
vtkPVPlotMatrixView *matrix =
vtkPVPlotMatrixView::SafeDownCast(this->GetClientSideObject());
if (matrix)
{
// matrix->AddObserver(vtkCommand::AnnotationChangedEvent, this,
// &vtkSMPlotMatrixViewProxy::ActivePlotChanged);
matrix->AddObserver(vtkCommand::CreateTimerEvent, this,
&vtkSMPlotMatrixViewProxy::SendAnimationPath);
matrix->AddObserver(vtkCommand::AnimationCueTickEvent, this,
&vtkSMPlotMatrixViewProxy::AnimationTickEvent);
}
#endif
}
//----------------------------------------------------------------------------
void vtkSMPlotMatrixViewProxy::ActivePlotChanged()
{
this->ActiveChanged = true;
}
//----------------------------------------------------------------------------
void vtkSMPlotMatrixViewProxy::PostRender(bool interactive)
{
this->Superclass::PostRender(interactive);
if (this->ActiveChanged)
{
vtkPVPlotMatrixView *matrix =
vtkPVPlotMatrixView::SafeDownCast(this->GetClientSideObject());
if (matrix)
{
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(this) << "SetActivePlot"
<< matrix->GetActiveRow() << matrix->GetActiveColumn()
<< vtkClientServerStream::End;
this->ExecuteStream(stream);
this->ActiveChanged = false;
}
}
}
//----------------------------------------------------------------------------
void vtkSMPlotMatrixViewProxy::AnimationTickEvent()
{
if (this->Session->GetProcessRoles() != vtkPVSession::CLIENT_AND_SERVERS)
{
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(this) << "AdvanceAnimationPath"
<< vtkClientServerStream::End;
this->ExecuteStream(stream, false, vtkPVSession::RENDER_SERVER);
}
}
//----------------------------------------------------------------------------
void vtkSMPlotMatrixViewProxy::SendAnimationPath()
{
// Only send this to the render server(s) if we are not in builtin mode.
if (this->Session->GetProcessRoles() != vtkPVSession::CLIENT_AND_SERVERS)
{
vtkPVPlotMatrixView *matrix =
vtkPVPlotMatrixView::SafeDownCast(this->GetClientSideObject());
if (!matrix)
{
return;
}
vtkScatterPlotMatrix *plotMatrix =
vtkScatterPlotMatrix::SafeDownCast(matrix->GetContextItem());
if (!plotMatrix || plotMatrix->GetNumberOfAnimationPathElements() == 0)
{
return;
}
vtkIdType n = plotMatrix->GetNumberOfAnimationPathElements();
vtkClientServerStream stream;
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(this) << "ClearAnimationPath"
<< vtkClientServerStream::End;
for (vtkIdType i = 0; i < n; ++i)
{
vtkVector2i element = plotMatrix->GetAnimationPathElement(i);
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(this) << "AddAnimationPath"
<< element[0] << element[1]
<< vtkClientServerStream::End;
}
stream << vtkClientServerStream::Invoke
<< VTKOBJECT(this) << "StartAnimationPath"
<< vtkClientServerStream::End;
this->ExecuteStream(stream, false, vtkPVSession::RENDER_SERVER);
this->MarkModified(this);
}
}
//----------------------------------------------------------------------------
vtkAbstractContextItem* vtkSMPlotMatrixViewProxy::GetContextItem()
{
vtkPVPlotMatrixView* pvview = vtkPVPlotMatrixView::SafeDownCast(
this->GetClientSideObject());
return pvview? pvview->GetContextItem() : NULL;
}
|