MeVisLab Resolution Independence API
Loading...
Searching...
No Matches
SoRenderArea.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef SO_RENDER_AREA_H
14#define SO_RENDER_AREA_H
15
17
18#include "SoViewers.h"
19#include "SoViewerNode.h"
20#include "FrameGrabber.h"
21
22#include "SoMeVisRenderArea.h"
23#include <QCursor>
24#include <QBitmap>
25
26class FieldSync;
27class SbVec2s; // Inventor class
29
30ML_START_NAMESPACE
31class MLSnapshot;
32ML_END_NAMESPACE
33
34//=============================================================
37
45//=============================================================
47{
48
49 SO_NODE_HEADER(SoRenderArea);
50
51public:
53
55 SoSFColor background;
57 SoSFEnum transparency;
59 SoSFBool antialiasing;
62
66 SoSFInt32 numSamples;
67
69 SoSFBool border;
71 SoSFBool grabKeyFocus;
74
76
78
80 SoSFTrigger doSnapshot;
88 SoSFInt32 snapCount;
91
92
98 SoSFTrigger updateMLOutput;
99
101
103
105 SoSFTrigger startRecording;
107 SoSFTrigger cancelRecording;
109 SoSFTrigger continueRecording;
111 SoSFTrigger stopRecording;
113 SoSFTrigger singleFrame;
115 SoSFTrigger createAvi;
120 SoSFFloat frameRate;
122 SoSFFloat frameRateAvi;
124 SoSFString status;
125
128 SoSFString outputAviFile;
129
131
134
135
141
145 static void initClass();
146
149 void* createViewer(void* hwnd, SoNode* scene) override;
150
152 void deleteViewer(void* viewer) override;
153
155 virtual void setupViewer();
156
158 virtual void setScene(SoNode* scene);
159
161 virtual void fieldChanged(SoSensor* sensor);
162 static void fieldChangedCB(void* userData, SoSensor* s);
163
165 virtual void recordChanged(SoSensor* sensor);
166 static void recordChangedCB(void* userData, SoSensor* s);
167
169 virtual void startRecordingChanged(SoField*);
170
172 virtual void stopRecordingChanged(SoField*);
173
175 virtual void snapshotChanged(SoField*);
176
178 virtual void updateMLOutputChanged(SoField*);
179
181 virtual void createAviChanged(SoField*);
182
183 virtual void enableKeyCommandsChanged(SoField*)
184 {}
185
187 MLuint8* readBuffer(int& w, int& h);
188
190 bool getBufferSize(int& w, int& h);
191
193 static SbBool handleEventCB(void* userData, QEvent* anyevent);
195 virtual SbBool handleEvent(QEvent* anyevent);
196
197 virtual SbBool shouldChangeCursor();
198
200 void syncFromViewerNode(SoViewerNode* node) override;
201
204 virtual void getSyncFieldNames(SbStringList& list);
205
207 void setStatus(const char* str);
208
209protected:
211 void setRecordingFlag(bool flag);
212
213 ~SoRenderArea() override;
214
216 void borderChanged(SoField*);
217 void antialiasingChanged(SoField*);
218 void sampleBufferChanged(SoField*);
219 void backgroundChanged(SoField*);
220 void transparencyChanged(SoField*);
221 void singleFrameChanged(SoField*);
224 void frameRateChanged(SoField*);
226
227 SoNodeSensor* _sensor;
228
231 SoTimerSensor* _recordSensor;
234
236
238
240 QCursor _oldCursor;
241};
242
243
244ML_START_NAMESPACE
245
248
250{
251
252public:
254 ~MLSnapshot() override;
255
258 {
259 _area = area;
260 }
261
262private:
264 SoRenderArea* _area;
266 int _w, _h;
268 MLuint8* _buffer;
269
271 void calculateOutputImageProperties(int outputIndex, PagedImage* outputImage) override;
272
274 SubImageBox calculateInputSubImageBox(int inIndex, const SubImageBox& outSubImgBox, int outIndex) override;
275
277 void calculateOutputSubImage(SubImage* outSubImg, int outIndex, SubImage* inSubImgs) override;
278
279 // ML runtime system
280 ML_MODULE_CLASS_HEADER(MLSnapshot)
281};
282
283ML_END_NAMESPACE
284
285#endif
#define SO_VIEWERS_CLASS_SPEC
Definition SoViewers.h:44
A class that synchronizes a list of fields of two SoFieldContainer instances.
Definition FieldSync.h:61
FrameGrabber class grabs GL frames for movie generation.
virtual void stopRecordingChanged(SoField *)
stop recording:
SoSFBool border
show a 3D border
~SoRenderArea() override
SoSFEnum transparency
transparency type
SoSFString outputSnapshotFile
filename of the screenshot (without file extension)
SoSFBool autoIncreaseFile
set if filename should be autoincreased
SoSFTrigger singleFrame
record a single frame, recording is started if it was not running
virtual SbBool handleEvent(QEvent *anyevent)
called by handleEventCB for each event in viewer
SoSFBool antialiasing
turn antialiasing on/off
SoSFFloat frameRate
frame rate which the recorder uses to grab the screen
void setStatus(const char *str)
set the status in status field and also with progress CB
SoSFString outputAviFile
FrameGrabber _writer
SoSFColor background
Appearance Fields.
void borderChanged(SoField *)
further field change callbacks:
void continueRecordingChanged(SoField *)
SoSFTrigger doSnapshot
Screenshot feature Fields.
SoSFEnum snapshotFormat
format of the output, may be RGB or GREY
virtual void recordChanged(SoSensor *sensor)
timer sensor call:
SoSFTrigger updateMLOutput
trigger the update of the ML output
virtual void enableKeyCommandsChanged(SoField *)
SoSFBool enableKeyCommands
enable the keyboard commands for snapshots and movie generation
SoSFString miSelectedPointingActionProvider
SoSceneSetupHelper * _sceneSetupHelper
SoSFBool miSelectedPointingActionActive
SoSFString miSelectedPointingAction
Managed Interaction support.
SoSFTrigger continueRecording
continue recording
SoSFMLConnector outputImage
ML Output of Viewer screenshot.
static void recordChangedCB(void *userData, SoSensor *s)
virtual void setScene(SoNode *scene)
This method gets called by createViewer.
static void fieldChangedCB(void *userData, SoSensor *s)
void sampleBufferChanged(SoField *)
virtual SbBool shouldChangeCursor()
SoSFString status
current status of the recorder
FieldSync * _fieldSync
SoSFTrigger startRecording
Recorder feature Fields.
static SbBool handleEventCB(void *userData, QEvent *anyevent)
needed for key focus grabbing
SoSFBool grabKeyFocus
grab the key focus when the mouse moves onto the viewer window
SoSFTrigger cancelRecording
cancel recording
QCursor _oldCursor
remember old cursor shape:
SoSFString inputDevicesList
space separated list of input device type names
SoSFInt32 numSamples
number of samples (0 = maximum number of samplers)
void * createViewer(void *hwnd, SoNode *scene) override
void inputDevicesListChanged(SoField *)
void deleteViewer(void *viewer) override
delete the previously created viewer
SoRenderArea()
constructor
virtual void snapshotChanged(SoField *)
doSnapshot changed
SoSFBool autoRedrawWhenRecording
void syncFromViewerNode(SoViewerNode *node) override
sync from given src viewer node
virtual void setupViewer()
sets all values from fields
SoSFFloat frameRateAvi
frame rate that is used in the generated AVI
virtual void getSyncFieldNames(SbStringList &list)
void transparencyChanged(SoField *)
SoTimerSensor * _recordSensor
virtual void fieldChanged(SoSensor *sensor)
priority 0 sensor call for all fields:
virtual void createAviChanged(SoField *)
createAvi:
virtual void updateMLOutputChanged(SoField *)
updateMLOutput changed
void antialiasingChanged(SoField *)
SoSFBool useSampleBuffers
turn sample buffers on/off
SoNodeSensor * _sensor
ml::MLSnapshot * _snapshot
SoSFBool showSnapshotWithShell
start external program when screenshot was saved (Windows only)
void setRecordingFlag(bool flag)
sets the recording flag and starts/stops the recording timer
void cancelRecordingChanged(SoField *)
MLuint8 * readBuffer(int &w, int &h)
read the gl back buffer (ownership is passed to caller, memory needs to be cleared by delete)
bool getBufferSize(int &w, int &h)
returns current size of image (returns FALSE if there is no viewer)
void backgroundChanged(SoField *)
virtual void startRecordingChanged(SoField *)
start recording:
static void initClass()
inventor runtime type system
void frameRateChanged(SoField *)
SoSFString outputSnapshotFileWritten
filename that was written on doScreenshot
SoSFInt32 snapCount
count of screenshots taken used for autoIncreaseFile
SoSFInt32 antialiasingNumPasses
number of antialiasing passes
SoSFTrigger stopRecording
stop recording
void singleFrameChanged(SoField *)
SoSFTrigger createAvi
create an AVI of the movie (by running a createMovie callback)
void setRenderArea(SoRenderArea *area)
set the render area this module is attached to
~MLSnapshot() override