scene.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::camera
26 
27 Description
28 
29 SourceFiles
30  scene.C
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef scene_H
35 #define scene_H
36 
37 // OpenFOAM includes
38 #include "dictionary.H"
39 #include "DataEntry.H"
40 #include "vector.H"
41 #include "point.H"
42 #include "boundBox.H"
43 #include "NamedEnum.H"
44 #include "HashPtrTable.H"
45 #include "vector.H"
46 
47 // VTK includes
48 #include "vtkSmartPointer.h"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 class vtkRenderer;
53 class vtkRenderWindow;
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class scene Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class scene
63 {
64 public:
65 
67 
69 
70 
71 private:
72 
73  // Private data
74 
75  //- Reference to the object registry
76  const objectRegistry& obr_;
77 
78  //- Object name
79  const word name_;
80 
81 
82  // Private Member Functions
83 
84  //- Read camera properties
85  void readCamera(const dictionary& dict);
86 
87  //- Read solour properties
88  void readColours(const dictionary& dict);
89 
90  //- Disallow default bitwise copy construct
91  scene(const scene&);
92 
93  //- Disallow default bitwise assignment
94  void operator=(const scene&);
95 
96 
97 protected:
98 
99  // Protected data
100 
101  //- Colours
103 
104 
105  // Camera settings
106 
107  //- Mode
108  modeType mode_;
109 
110  //- Position
112 
113  //- Focal point
115 
116  //- Up direction
118 
119  //- Zoom level
121 
122  //- View angle
124 
125 
126  // Scene management
127 
128  //- Clipping box
130 
131  //- Parallel projection flag
132  bool parallelProjection_;
133 
134  //- Number of frames
136 
137  //- Position [0-1]
138  scalar position_;
139 
140  //- Change in position per frame
141  scalar dPosition_;
142 
143  //- Index of current frame
145 
146  //- Name prefix of output
148 
149 
150  // Protected Member Functions
151 
152  void setCamera(vtkRenderer* renderer, const bool override) const;
153 
154  string frameIndexStr() const;
155 
156 
157 public:
158 
159  // Constructors
160 
161  //- Construct from components
162  scene(const objectRegistry& obr, const word& name);
163 
164 
165  //- Destructor
166  virtual ~scene();
167 
168 
169  // Member Functions
170 
171  // Access
172 
173  //- Return the colours
175 
176  //- Return the current frame index
177  label frameIndex() const;
178 
179  //- Return the current position (in range 0-1)
180  scalar position() const;
181 
182  void read(const dictionary& dict);
183 
184  void initialise(vtkRenderer* renderer, const word& outputName);
185 
186  //- Main control loop
187  bool loop(vtkRenderer* renderer);
188 
189  //- Save image to file
190  void saveImage(vtkRenderWindow* renderWindow) const;
191 };
192 
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace Foam
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 #endif
201 
202 // ************************************************************************* //
Foam::scene::frameIndexStr
string frameIndexStr() const
Definition: scene.C:268
Foam::scene::modeTypeNames_
NamedEnum< modeType, 2 > modeTypeNames_
Definition: scene.H:67
Foam::scene::scene
scene(const scene &)
Disallow default bitwise copy construct.
Foam::scene::cameraViewAngle_
autoPtr< DataEntry< scalar > > cameraViewAngle_
View angle.
Definition: scene.H:122
Foam::scene::~scene
virtual ~scene()
Destructor.
Definition: scene.C:302
Foam::scene::cameraFocalPoint_
autoPtr< DataEntry< point > > cameraFocalPoint_
Focal point.
Definition: scene.H:113
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::scene::nFrameTotal_
label nFrameTotal_
Number of frames.
Definition: scene.H:134
Foam::scene::position_
scalar position_
Position [0-1].
Definition: scene.H:137
Foam::scene::parallelProjection_
bool parallelProjection_
Parallel projection flag.
Definition: scene.H:131
Foam::scene::readCamera
void readCamera(const dictionary &dict)
Read camera properties.
Definition: scene.C:58
point.H
NamedEnum.H
Foam::scene::mode_
modeType mode_
Mode.
Definition: scene.H:107
Foam::scene::name_
const word name_
Object name.
Definition: scene.H:78
Foam::scene::position
scalar position() const
Return the current position (in range 0-1)
Definition: scene.C:321
Foam::scene::currentFrameI_
label currentFrameI_
Index of current frame.
Definition: scene.H:143
Foam::scene::initialise
void initialise(vtkRenderer *renderer, const word &outputName)
Definition: scene.C:168
Foam::scene::colours
const HashPtrTable< DataEntry< vector >, word > & colours() const
Return the colours.
Definition: scene.C:309
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::scene::readColours
void readColours(const dictionary &dict)
Read solour properties.
Definition: scene.C:157
Foam::scene::cameraPosition_
autoPtr< DataEntry< point > > cameraPosition_
Position.
Definition: scene.H:110
Foam::scene::setCamera
void setCamera(vtkRenderer *renderer, const bool override) const
Definition: scene.C:241
DataEntry.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::scene::mtStatic
@ mtStatic
Definition: scene.H:65
Foam::scene::read
void read(const dictionary &dict)
Definition: scene.C:327
Foam::scene::loop
bool loop(vtkRenderer *renderer)
Main control loop.
Definition: scene.C:334
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::scene::modeType
modeType
Definition: scene.H:65
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::scene::frameIndex
label frameIndex() const
Return the current frame index.
Definition: scene.C:315
Foam::scene::operator=
void operator=(const scene &)
Disallow default bitwise assignment.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::scene::cameraUp_
autoPtr< DataEntry< vector > > cameraUp_
Up direction.
Definition: scene.H:116
Foam::scene::outputName_
word outputName_
Name prefix of output.
Definition: scene.H:146
Foam::scene::dPosition_
scalar dPosition_
Change in position per frame.
Definition: scene.H:140
boundBox.H
Foam::scene::obr_
const objectRegistry & obr_
Reference to the object registry.
Definition: scene.H:75
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::scene::mtFlightPath
@ mtFlightPath
Definition: scene.H:65
Foam::scene::saveImage
void saveImage(vtkRenderWindow *renderWindow) const
Save image to file.
Definition: scene.C:364
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
Foam::scene::clipBox_
boundBox clipBox_
Clipping box.
Definition: scene.H:128
HashPtrTable.H
dictionary.H
Foam::scene::cameraZoom_
autoPtr< DataEntry< scalar > > cameraZoom_
Zoom level.
Definition: scene.H:119
vector.H
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::scene
Definition: scene.H:61
Foam::scene::colours_
HashPtrTable< DataEntry< vector >, word > colours_
Colours.
Definition: scene.H:101
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::NamedEnum< modeType, 2 >