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
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkRenderState.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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 "vtkRenderState.h"
#include <cassert>
#include "vtkRenderer.h"
#include "vtkFrameBufferObject.h"
// ----------------------------------------------------------------------------
// Description:
// Constructor. All values are initialized to 0 or NULL.
// \pre renderer_exists: renderer!=0
// \post renderer_is_set: GetRenderer()==renderer.
// \post valid_state: IsValid()
vtkRenderState::vtkRenderState(vtkRenderer *renderer)
{
assert("pre: renderer_exists" && renderer!=0);
this->Renderer = renderer;
this->FrameBuffer = 0;
this->PropArray = 0;
this->PropArrayCount = 0;
this->RequiredKeys = 0;
assert("post: renderer_is_set" && this->GetRenderer() == renderer);
assert("post: is_valid" && this->IsValid());
}
// ----------------------------------------------------------------------------
// Description:
// Destructor. As a vtkRenderState does not own any of its variables,
// the destructor does nothing.
vtkRenderState::~vtkRenderState()
{
}
// ----------------------------------------------------------------------------
// Description:
// Tells if the RenderState is a valid one (Renderer is not null).
bool vtkRenderState::IsValid() const
{
return this->Renderer != 0;
}
// ----------------------------------------------------------------------------
// Description:
// Return the Renderer.
// \post result_exists: result!=0
vtkRenderer *vtkRenderState::GetRenderer() const
{
assert("post: valid_result" && this->Renderer != 0);
return this->Renderer;
}
// ----------------------------------------------------------------------------
// Description:
// Return the FrameBuffer.
vtkFrameBufferObject *vtkRenderState::GetFrameBuffer() const
{
return this->FrameBuffer;
}
// ----------------------------------------------------------------------------
// Description:
// Set the FrameBuffer.
// \post is_set: GetFrameBuffer()==fbo
void vtkRenderState::SetFrameBuffer(vtkFrameBufferObject *fbo)
{
this->FrameBuffer = fbo;
assert("post: is_set" && this->GetFrameBuffer() == fbo);
}
// ----------------------------------------------------------------------------
// Description:
// Get the window size of the state.
void vtkRenderState::GetWindowSize(int size[2]) const
{
if (this->FrameBuffer==0)
{
this->Renderer->GetTiledSize(&size[0], &size[1]);
}
else
{
this->FrameBuffer->GetLastSize(size);
}
}
// ----------------------------------------------------------------------------
// Description:
// Return the array of filtered props
vtkProp **vtkRenderState::GetPropArray() const
{
return this->PropArray;
}
// ----------------------------------------------------------------------------
// Description:
// Return the size of the array of filtered props.
// \post positive_result: result>=0
int vtkRenderState::GetPropArrayCount() const
{
assert("post: positive_result" && this->PropArrayCount >= 0);
return this->PropArrayCount;
}
// ----------------------------------------------------------------------------
// Description:
// Set the array of of filtered props and its size.
// \pre positive_size: propArrayCount>=0
// \pre valid_null_array: propArray!=0 || propArrayCount==0
// \post is_set: GetPropArray()==propArray && GetPropArrayCount()==propArrayCount
void vtkRenderState::SetPropArrayAndCount(vtkProp **propArray,
int propArrayCount)
{
assert("pre: positive_size" && propArrayCount >= 0);
assert("pre: valid_null_array" && (propArray != 0 || propArrayCount == 0));
this->PropArray = propArray;
this->PropArrayCount = propArrayCount;
assert("post: is_set" && this->GetPropArray() == propArray
&& this->GetPropArrayCount() == propArrayCount);
}
// ----------------------------------------------------------------------------
// Description:
// Return the required property keys for the props.
vtkInformation *vtkRenderState::GetRequiredKeys() const
{
return this->RequiredKeys;
}
// ----------------------------------------------------------------------------
// Description:
// Set the required property keys for the props.
// \post is_set: GetRequiredKeys()==keys
void vtkRenderState::SetRequiredKeys(vtkInformation *keys)
{
this->RequiredKeys = keys;
assert("post: is_set" && this->GetRequiredKeys() == keys);
}
|