MeVisLab Resolution Independence API
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 SO_NODE_HEADER(SoRenderArea);
49
50 public:
52
54 SoSFColor background;
56 SoSFEnum transparency;
58 SoSFBool antialiasing;
61
65 SoSFInt32 numSamples;
66
68 SoSFBool border;
70 SoSFBool grabKeyFocus;
73
75
77
79 SoSFTrigger doSnapshot;
87 SoSFInt32 snapCount;
90
91
97 SoSFTrigger updateMLOutput;
98
100
102
104 SoSFTrigger startRecording;
106 SoSFTrigger cancelRecording;
108 SoSFTrigger continueRecording;
110 SoSFTrigger stopRecording;
112 SoSFTrigger singleFrame;
114 SoSFTrigger createAvi;
119 SoSFFloat frameRate;
121 SoSFFloat frameRateAvi;
123 SoSFString status;
124
127 SoSFString outputAviFile;
128
130
133
134
140
144 static void initClass();
145
148 void* createViewer(void* hwnd, SoNode* scene) override;
149
151 void deleteViewer(void* viewer) override;
152
154 virtual void setupViewer();
155
157 virtual void setScene (SoNode* scene);
158
160 virtual void fieldChanged(SoSensor* sensor);
161 static void fieldChangedCB(void *userData, SoSensor* s);
162
164 virtual void recordChanged(SoSensor* sensor);
165 static void recordChangedCB(void *userData, SoSensor* s);
166
168 virtual void startRecordingChanged(SoField*);
169
171 virtual void stopRecordingChanged(SoField*);
172
174 virtual void snapshotChanged(SoField*);
175
177 virtual void updateMLOutputChanged(SoField*);
178
180 virtual void createAviChanged(SoField*);
181
182 virtual void enableKeyCommandsChanged(SoField*) {}
183
185 MLuint8* readBuffer(int& w, int& h);
186
188 bool getBufferSize(int &w, int &h);
189
191 static SbBool handleEventCB(void *userData,QEvent* anyevent);
193 virtual SbBool handleEvent(QEvent* anyevent);
194
195 virtual SbBool shouldChangeCursor();
196
198 void syncFromViewerNode(SoViewerNode* node) override;
199
202 virtual void getSyncFieldNames(SbStringList& list);
203
205 void setStatus(const char* str);
206
207 protected:
208
210 void setRecordingFlag(bool flag);
211
212 ~SoRenderArea() override;
213
215 void borderChanged(SoField*);
216 void antialiasingChanged(SoField*);
217 void sampleBufferChanged(SoField*);
218 void backgroundChanged(SoField*);
219 void transparencyChanged(SoField*);
220 void singleFrameChanged(SoField*);
223 void frameRateChanged(SoField*);
225
226 SoNodeSensor* _sensor;
227
230 SoTimerSensor* _recordSensor;
233
235
237
239 QCursor _oldCursor;
240};
241
242
243ML_START_NAMESPACE
244
247
248class SO_VIEWERS_CLASS_SPEC MLSnapshot : public Module {
249
250public:
252 ~MLSnapshot() override;
253
255 void setRenderArea(SoRenderArea* area) { _area = area; }
256
257private:
259 SoRenderArea* _area;
261 int _w,_h;
263 MLuint8* _buffer;
264
266 void calculateOutputImageProperties(int outputIndex, PagedImage* outputImage) override;
267
269 SubImageBox calculateInputSubImageBox(int inIndex, const SubImageBox& outSubImgBox, int outIndex) override;
270
272 void calculateOutputSubImage(SubImage *outSubImg, int outIndex, SubImage *inSubImgs) override;
273
274 // ML runtime system
275 ML_MODULE_CLASS_HEADER(MLSnapshot)
276};
277
278ML_END_NAMESPACE
279
280#endif
#define SO_VIEWERS_CLASS_SPEC
Definition SoViewers.h:43
A class that synchronizes a list of fields of two SoFieldContainer instances.
Definition FieldSync.h:61
FrameGrabber class grabs GL frames for movie generation.
SoRenderArea encapsulates the features of SoQtRenderArea in an Inventor Node.
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
filename (including path) of the avi that will be written.
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
create a viewer in the given window void pointer is used to be compatible to any windows system
void inputDevicesListChanged(SoField *)
void deleteViewer(void *viewer) override
delete the previously created viewer
SoRenderArea()
constructor
virtual void snapshotChanged(SoField *)
doSnapshot changed
SoSFBool autoRedrawWhenRecording
advanced setting if autoredraw of viewer is enabled or if the rendering is done explicitly when savin...
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)
collect the fields that should be synced on cloned viewers if you derive this method,...
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)
SoSFMLConnector field is the interface used by Inventor Nodes to output input/output ML Connector Fie...
Helper for equipping an SoQtSceneHandler with necessary nodes for Managed Interaction and cursor sett...
Base class for all viewer nodes in MeVisLab.
snapshot module that outputs the current viewer snapshot as an ML image used internally in the SoRend...
void setRenderArea(SoRenderArea *area)
set the render area this module is attached to
~MLSnapshot() override