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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
/*=========================================================================
Program: ParaView
Module: vtkSMComparativeViewProxy.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 "vtkSMComparativeViewProxy.h"
#include "vtkCollection.h"
#include "vtkCommand.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPVComparativeView.h"
#include "vtkPVSession.h"
#include "vtkSMProxyManager.h"
#include "vtkSMUndoStackBuilder.h"
#include <assert.h>
#define GET_PV_COMPARATIVE_VIEW()\
vtkPVComparativeView::SafeDownCast(this->GetClientSideObject())
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkSMComparativeViewProxy);
//----------------------------------------------------------------------------
vtkSMComparativeViewProxy::vtkSMComparativeViewProxy()
{
this->SetLocation(vtkPVSession::CLIENT);
}
//----------------------------------------------------------------------------
vtkSMComparativeViewProxy::~vtkSMComparativeViewProxy()
{
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::Update()
{
// Make sure we don't track in Undo/Redo the proxy update that we have set in
// the comparative view
vtkSMUndoStackBuilder* usb =
vtkSMProxyManager::GetProxyManager()->GetUndoStackBuilder();
if (usb)
{
bool prev = usb->GetIgnoreAllChanges();
usb->SetIgnoreAllChanges(true);
this->Superclass::Update();
usb->SetIgnoreAllChanges(prev);
}
else
{
// Simply update
this->Superclass::Update();
}
// I can't remember where is this flag coming from. Keeping it as it was for
// now.
this->NeedsUpdate =false;
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::CreateVTKObjects()
{
if (this->ObjectsCreated)
{
return;
}
// If prototype do not setup subproxy location and do not send anything
// to the server
if(this->Location == 0)
{
this->Superclass::CreateVTKObjects();
return;
}
this->GetSubProxy("RootView")->SetLocation(
vtkPVSession::CLIENT_AND_SERVERS);
this->Superclass::CreateVTKObjects();
if (!this->ObjectsCreated)
{
return;
}
vtkSMViewProxy* rootView = vtkSMViewProxy::SafeDownCast(
this->GetSubProxy("RootView"));
if (!rootView)
{
vtkErrorMacro("Subproxy \"Root\" must be defined in the xml configuration.");
return;
}
GET_PV_COMPARATIVE_VIEW()->AddObserver(
vtkCommand::ConfigureEvent,
this, &vtkSMComparativeViewProxy::InvokeConfigureEvent);
GET_PV_COMPARATIVE_VIEW()->Initialize(rootView);
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::InvokeConfigureEvent()
{
this->InvokeEvent(vtkCommand::ConfigureEvent);
}
//----------------------------------------------------------------------------
vtkSMViewProxy* vtkSMComparativeViewProxy::GetRootView()
{
return GET_PV_COMPARATIVE_VIEW()->GetRootView();
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::MarkDirty(vtkSMProxy* modifiedProxy)
{
if (vtkSMViewProxy::SafeDownCast(modifiedProxy) == NULL)
{
//cout << "vtkSMComparativeViewProxy::MarkDirty == " << modifiedProxy << endl;
// The representation that gets added to this view is a consumer of it's
// input. While this view is a consumer of the representation. So, when the
// input source is modified, that call eventually leads to
// vtkSMComparativeViewProxy::MarkDirty(). When that happens, we need to
// ensure that we regenerate the comparison, so we call this->MarkOutdated().
// TODO: We can be even smarter. We may want to try to consider only those
// representations that are actually involved in the parameter comparison to
// mark this view outdated. This will save on the regeneration of cache when
// not needed.
// TODO: Another optimization: we can enable caching only for those
// representations that are invovled in parameter comparison, others we don't
// even need to cache.
// TODO: Need to update data ranges by collecting ranges from all views.
GET_PV_COMPARATIVE_VIEW()->MarkOutdated();
}
this->Superclass::MarkDirty(modifiedProxy);
}
//----------------------------------------------------------------------------
const char* vtkSMComparativeViewProxy::GetRepresentationType(
vtkSMSourceProxy* src, int outputport)
{
return this->GetRootView()->GetRepresentationType(src, outputport);
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::GetViews(vtkCollection* collection)
{
if (!collection)
{
return;
}
GET_PV_COMPARATIVE_VIEW()->GetViews(collection);
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::GetRepresentationsForView(
vtkSMViewProxy* view, vtkCollection *collection)
{
if (!collection)
{
return;
}
GET_PV_COMPARATIVE_VIEW()->GetRepresentationsForView(view, collection);
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::GetRepresentations(int x, int y,
vtkCollection* collection)
{
if (!collection)
{
return;
}
GET_PV_COMPARATIVE_VIEW()->GetRepresentations(x, y, collection);
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::SetupInteractor(vtkRenderWindowInteractor*)
{
vtkErrorMacro("vtkSMComparativeViewProxy doesn't support SetupInteractor. "
"Please setup interactors on each of the internal views explicitly.");
}
//----------------------------------------------------------------------------
bool vtkSMComparativeViewProxy::MakeRenderWindowInteractor(bool quiet)
{
bool flag = true;
vtkNew<vtkCollection> views;
this->GetViews(views.GetPointer());
views->InitTraversal();
for (vtkSMViewProxy* view = vtkSMViewProxy::SafeDownCast(views->GetNextItemAsObject());
view != NULL; view = vtkSMViewProxy::SafeDownCast(views->GetNextItemAsObject()))
{
flag = view->MakeRenderWindowInteractor(quiet) && flag;
}
return flag;
}
//----------------------------------------------------------------------------
vtkImageData* vtkSMComparativeViewProxy::CaptureWindowInternal(int magnification)
{
// This is needed to ensure that the views are laid out properly before trying
// to capture images from each of them.
this->Update();
return GET_PV_COMPARATIVE_VIEW()->CaptureWindow(magnification);
}
//----------------------------------------------------------------------------
void vtkSMComparativeViewProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
|