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
|
/*=========================================================================
Program: ParaView
Module: vtkSMGL2PSExporterProxy.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 "vtkSMGL2PSExporterProxy.h"
#include "vtkObjectFactory.h"
#include "vtkPVGL2PSExporter.h"
#include "vtkPVXMLElement.h"
#include "vtkSMProxy.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkSMContextViewProxy.h"
vtkStandardNewMacro(vtkSMGL2PSExporterProxy)
//----------------------------------------------------------------------------
vtkSMGL2PSExporterProxy::vtkSMGL2PSExporterProxy()
: ViewType(None)
{
}
//----------------------------------------------------------------------------
vtkSMGL2PSExporterProxy::~vtkSMGL2PSExporterProxy()
{
}
//----------------------------------------------------------------------------
bool vtkSMGL2PSExporterProxy::CanExport(vtkSMProxy* proxy)
{
return proxy && ( ( this->ViewType == RenderView &&
proxy->IsA("vtkSMRenderViewProxy") ) ||
( this->ViewType == ContextView &&
proxy->IsA("vtkSMContextViewProxy") ) );
}
//----------------------------------------------------------------------------
void vtkSMGL2PSExporterProxy::Write()
{
this->CreateVTKObjects();
vtkPVGL2PSExporter* exporter =
vtkPVGL2PSExporter::SafeDownCast(this->GetClientSideObject());
vtkSMRenderViewProxy* rv = this->ViewType == RenderView ?
vtkSMRenderViewProxy::SafeDownCast(this->View) : NULL;
vtkSMContextViewProxy *cv = this->ViewType == ContextView ?
vtkSMContextViewProxy::SafeDownCast(this->View) : NULL;
vtkRenderWindow *renWin = NULL;
if (rv)
{
renWin = rv->GetRenderWindow();
}
else if (cv)
{
renWin = cv->GetRenderWindow();
}
if (exporter && renWin)
{
exporter->SetRenderWindow(renWin);
exporter->Write();
exporter->SetRenderWindow(NULL);
}
}
//----------------------------------------------------------------------------
int vtkSMGL2PSExporterProxy::ReadXMLAttributes(vtkSMSessionProxyManager *pm,
vtkPVXMLElement *element)
{
const char *viewType(element->GetAttribute("viewtype"));
this->ViewType = None;
if (viewType)
{
if (strcmp(viewType, "none") == 0)
{
// This proxy definition just defines a base interface.
return 0;
}
if (strcmp(viewType, "renderview") == 0)
{
this->ViewType = RenderView;
}
else if (strcmp(viewType, "contextview") == 0)
{
this->ViewType = ContextView;
}
else
{
vtkErrorMacro(<<"Invalid viewtype specified: " << viewType);
return 0;
}
}
else
{
vtkErrorMacro(<<"No viewtype specified.");
return 0;
}
return this->Superclass::ReadXMLAttributes(pm, element);
}
//----------------------------------------------------------------------------
void vtkSMGL2PSExporterProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "ViewType: ";
switch (ViewType)
{
case RenderView:
os << "RenderView";
break;
case ContextView:
os << "RenderView";
break;
default:
os << "Unknown";
break;
}
os << endl;
}
|