Free Electron
SurfaceViewerOp.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __opview_SurfaceViewerOp_h__
8 #define __opview_SurfaceViewerOp_h__
9 
10 #include "operator/RulerOp.h"
11 
12 namespace fe
13 {
14 namespace ext
15 {
16 
17 /**************************************************************************//**
18  @brief Operator to look at surfaces in an independent window
19 
20  @ingroup opview
21 *//***************************************************************************/
22 class FE_DL_EXPORT SurfaceViewerOp:
23  public OperatorSurfaceCommon,
24  public Initialize<SurfaceViewerOp>
25 {
26  public:
27  typedef enum
28  {
29  e_reframeObject= 0x00,
30  e_centerObject= 0x01,
31  e_centerOrigin= 0x02
32  } Targeting;
33 
34  SurfaceViewerOp(void);
35 virtual ~SurfaceViewerOp(void);
36 
37  void initialize(void);
38 
39  //* As HandlerI
40 virtual void handle(Record& a_rSignal);
41 
42  sp<QuickViewerI> quickViewer(void) { return m_spQuickViewerI; }
43 
44  sp<DrawableI> drawable(I32 a_surfaceIndex);
45  I32 drawableCount(void);
46 
47  Array< sp<DrawableI> >& subDrawableArray(I32 a_surfaceIndex);
48 
49  sp<CameraI> camera(I32 a_cameraIndex);
50  I32 cameraCount(void);
51 
52  BWORD getRebuild(void);
53 
54  void target(Targeting a_targeting);
55  Targeting targeting(void) const;
56 
57  DrawMode::DrawStyle drawStyle(void) const;
58  String orthoAxis(void) const;
59  BWORD uvSpace(void) const;
60  BWORD cameraView(void) const;
61  I32 cameraIndex(void) const;
62  BWORD help(void) const;
63  BWORD spiral(void) const;
64  BWORD tracking(void) const;
65  BWORD edging(void) const;
66  BWORD grid(void) const;
67  BWORD outline(void) const;
68  BWORD backfacing(void) const;
69  BWORD lighting(void) const;
70  BWORD shadows(void) const;
71  Real pointSize(void) const;
72  Real lineWidth(void) const;
73  I32 refinement(void) const;
74 
75  I32 glowFrame(void) const { return m_glowFrame; }
76 
77  Real updateSlack(void);
78  void setSlack(Real a_slack,Real a_slackInc,
79  Real a_slackMin)
80  { m_slack=a_slack;
81  m_slackInc=a_slackInc;
82  m_slackMin=a_slackMin; }
83 
84  String menuString(void) const { return m_menuString; }
85  void setMenuString(String a_string)
86  { m_menuString=a_string; }
87  sp<Catalog>& menu(void) { return m_spMenu; }
88 
89  String findPartitionAttribute(sp<SurfaceAccessibleI>
90  a_spSurfaceAccessible,String a_nodeName);
91 
92  sp<CameraEditable> orthoCam(void) { return m_spOrthoCam; }
93  private:
94 
95  void post(Real a_frame);
96  void react(WindowEvent& a_rEvent);
97  void partitionSurface(I32 a_surfaceIndex);
98  String inputNameByIndex(I32 a_inputIndex);
99 
100  class DrawHandler:
101  virtual public HandlerI,
102  public CastableAs<DrawHandler>
103  {
104  public:
105  DrawHandler(void);
106 
107  virtual void handle(Record& a_render);
108 
109  void bind(sp<DrawI> a_spDrawI)
110  { m_spDrawI=a_spDrawI; }
111  void bindDrawable(I32 a_inputIndex,I32 a_surfaceIndex,
112  sp<DrawableI> a_spDrawable,String a_nodeName);
113 
114  void incrementSerial(void) { m_serial++; }
115  void setFrame(Real a_frame);
116  void updateFrame(void);
117  Real minFrame(void) const { return m_minFrame; }
118  Real maxFrame(void) const { return m_maxFrame; }
119  void setStartFrame(Real a_frame) { m_startFrame=a_frame; }
120  Real startFrame(void) const { return m_startFrame; }
121  void setEndFrame(Real a_frame) { m_endFrame=a_frame; }
122  Real endFrame(void) const { return m_endFrame; }
123 
124  void setMicroseconds(I32 a_us) { m_us=a_us; }
125  I32 microseconds(void) { return m_us; }
126 
127  sp<SurfaceI> impactSurface(void) const
128  { return m_spImpactSurface; }
129  sp<SurfaceI> surface(I32 a_surfaceIndex) const;
130  String nodeName(I32 a_surfaceIndex) const;
131 
132  I32 isolatedIndex(void)
133  { return m_isolateSurfaceIndex; }
134 
135  BWORD hideAll(I32 a_surfaceIndex);
136  BWORD ghostAll(I32 a_surfaceIndex);
137 
138  void setSurfaceViewerOp(
139  sp<SurfaceViewerOp> a_spSurfaceViewerOp);
140  void setImpactAccessible(
141  sp<SurfaceAccessibleI> a_spSurfaceAccessible);
142  void setImpactSurface(sp<SurfaceI> a_spSurface)
143  { m_spImpactSurface=a_spSurface; }
144  void setSurfaceImpact(
145  sp<SurfaceI::ImpactI> a_spSurfaceImpact)
146  { if(!m_paperMode)
147  m_spSurfaceImpact=a_spSurfaceImpact; }
148  void setImpactNodeName(String a_nodeName)
149  { m_impactNodeName=a_nodeName; }
150  void setImpactInputName(String a_inputName)
151  { m_impactInputName=a_inputName; }
152 
153  I32 impactSurfaceIndex(void)
154  { return m_impactSurfaceIndex; }
155  void setImpactSurfaceIndex(I32 a_surfaceIndex)
156  { m_impactSurfaceIndex=a_surfaceIndex; }
157 
158  void pickIncrement(I32 a_increment);
159  void pick(I32 a_surfaceIndex);
160  void unpick(void);
161  void hideSelected(void);
162  void ghostSelected(void);
163  void isolateToggle(void);
164  void paperToggle(void);
165 
166  BWORD getImpactRegion(SpatialVector& a_rCenter,
167  Real& a_rRadius) const ;
168  BWORD getSelectRegion(SpatialVector& a_rCenter,
169  Real& a_rRadius) const ;
170 
171  void setPickingSurfaceIndex(I32 a_surfaceIndex)
172  { m_pickingSurfaceIndex=a_surfaceIndex; }
173  void setPickingAccessible(
174  sp<SurfaceAccessibleI> a_spPickingAccessible);
175  void setPickingNodeName(String a_nodeName)
176  { m_pickingNodeName=a_nodeName; }
177  void setPickingImpact(
178  sp<SurfaceI::ImpactI> a_spPickingImpact)
179  { m_spPickingImpact=a_spPickingImpact; }
180  void setPickPoint(SpatialVector a_point,Real a_radius)
181  { m_pickPoint=a_point;
182  m_pickRadius=a_radius; }
183 
184  void clearEmphasis(void);
185  void setEmphasis(I32 a_surfaceIndex,Real a_emphasis);
186 
187  void clearGeodesics(void);
188 
189  void drawNormals(I32 a_surfaceIndex);
190  void drawInstances(I32 a_surfaceIndex,
191  const Color* a_pColor);
192  void drawHorizon(void);
193  void drawDesignator(I32 a_surfaceIndex);
194  void runMenu(void);
195  void findPart(String a_partname);
196  void clearBuffer(I32 a_surfaceIndex);
197  void clearBuffers(void);
198  void applyHidden(I32 a_surfaceIndex);
199  void applyGhosted(I32 a_surfaceIndex);
200  void reapply(void);
201 
202  Color background(void);
203  Real gaugeAlpha(sp<SurfaceI::GaugeI> a_spGauge,
204  const SpatialVector& a_point);
205 
206  private:
207 
208  class SurfaceNode
209  {
210  public:
211  SurfaceNode(void):
212  m_hideAll(FALSE),
213  m_ghostAll(FALSE),
214  m_inputIndex(-1),
215  m_emphasis(0) {}
216 
217  sp<DrawableI> m_spDrawable;
218  sp<DrawBufferI> m_spSolidBuffer;
219  sp<DrawBufferI> m_spWireBuffer;
220  sp<SurfaceTrianglesAccessible> m_spSurfaceGeodesic;
221  sp<PartitionI> m_spGhostPartition;
222  Array<String> m_hideList;
223  Array<String> m_ghostList;
224  BWORD m_hideAll;
225  BWORD m_ghostAll;
226  I32 m_inputIndex;
227  Real m_emphasis;
228  String m_nodeName;
229 
230  };
231  Array<SurfaceNode> m_nodeArray;
232 
233  AsViewer m_asViewer;
234  sp<DrawI> m_spDrawI;
235  U32 m_serial;
236  U32 m_lastSerial;
237  Real m_frame;
238  Real m_newFrame;
239  Real m_minFrame;
240  Real m_maxFrame;
241  Real m_startFrame;
242  Real m_endFrame;
243  I32 m_us;
244  I32 m_reopenCountdown;
245 
246  I32 m_pickingSurfaceIndex;
247  String m_pickingNodeName;
248  sp<SurfaceI::ImpactI> m_spPickingImpact;
249  sp<SurfaceAccessibleI> m_spPickingAccessible;
250  sp<SurfaceTrianglesAccessible> m_spPickingGeodesic;
251  SpatialVector m_pickPoint;
252  Real m_pickRadius;
253  BWORD m_selectRegion;
254  SpatialVector m_selectCenter;
255  Real m_selectRadius;
256  String m_selectName;
257  I32 m_isolateSurfaceIndex;
258  String m_isolatePart;
259  I32 m_outlineAt;
260  Array<String> m_outline;
261 
262  Real m_multiplication;
263  I32 m_characterWidth;
264  I32 m_textHeight;
265 
266  BWORD m_paperMode;
267  BWORD m_keepEdges;
268  std::map<U64,Edge> m_edgeMap;
269 
270  hp<SurfaceViewerOp> m_hpSurfaceViewerOp;
271  sp<RulerOp> m_spRulerOp;
272  sp<SurfaceAccessibleI> m_spImpactAccessible;
273  sp<SurfaceI> m_spImpactSurface;
274  sp<SurfaceI::ImpactI> m_spSurfaceImpact;
275  String m_impactNodeName;
276  String m_impactInputName;
277  I32 m_impactSurfaceIndex;
278  String m_partAttr;
279 
280  sp<DrawMode> m_spDrawGhost;
281  sp<DrawMode> m_spDrawPoints;
282  sp<DrawMode> m_spDrawWire;
283  sp<DrawMode> m_spDrawImpact;
284  sp<DrawMode> m_spDrawEdging;
285  sp<DrawMode> m_spDrawSketch;
286  sp<DrawMode> m_spDrawPicking;
287  sp<DrawMode> m_spDrawText;
288 
289  sp<ImageI> m_spTextureImage;
290  };
291 
292  class EventHandler:
293  virtual public HandlerI,
294  public CastableAs<EventHandler>
295  {
296  public:
297  EventHandler(void) {}
298 
299  virtual void handle(Record& a_render);
300 
301  void setSurfaceViewerOp(sp<SurfaceViewerOp> a_spSurfaceViewerOp)
302  { m_hpSurfaceViewerOp=a_spSurfaceViewerOp; }
303 
304  private:
305  WindowEvent m_event;
306  hp<SurfaceViewerOp> m_hpSurfaceViewerOp;
307  };
308 
309  class Worker: public Thread::Functor
310  {
311  public:
312  Worker(sp< JobQueue<Real> > a_spJobQueue,
313  U32 a_id,String a_stage):
314  m_hpJobQueue(a_spJobQueue),
315  m_id(a_id),
316  m_us(0),
317  m_spiralAngle(0.0),
318  m_spiralStep(0.1) {}
319 
320  virtual ~Worker(void) {}
321 
322  virtual void operate(void);
323 
324  void setObject(sp<Counted> a_spObject)
325  { m_pSurfaceViewerOp=
326  sp<SurfaceViewerOp>(a_spObject).raw(); }
327 
328  private:
329  hp< JobQueue<Real> > m_hpJobQueue;
330  U32 m_id;
331  U32 m_us;
332  Real m_spiralAngle;
333  Real m_spiralStep;
334 
335  //* may use during ~SurfaceViewerOp
336  SurfaceViewerOp* m_pSurfaceViewerOp;
337  };
338 
339  U32 m_jobs;
340  U32 m_us;
341  I32 m_milliDelay;
342  sp< JobQueue<Real> > m_spJobQueue;
343  sp< Gang<Worker,Real> > m_spGang;
344  sp<QuickViewerI> m_spQuickViewerI;
345  sp<EventHandler> m_spEventHandler;
346  sp<DrawHandler> m_spDrawHandler;
347  sp<RecorderI> m_spVideoRecorder;
348  sp<CameraEditable> m_spOrthoCam;
349 
350  Array< sp<SurfaceAccessibleI> > m_accessibleArray;
351  Array< sp<DrawableI> > m_drawableArray;
352  Array< sp<CameraI> > m_cameraArray;
353 
354  Array< Array< sp<DrawableI> > > m_drawableTable;
355 
356  sp<Catalog> m_spMenu;
357  String m_menuString;
358 
359  BWORD m_rebuild;
360  BWORD m_freezeFrame;
361  Real m_lastFrame;
362  I32 m_glowFrame;
363  Real m_slack;
364  Real m_slackInc;
365  Real m_slackMin;
366  Targeting m_targeting;
367  String m_orthoAxis;
368  BWORD m_uvSpace;
369  BWORD m_cameraView;
370  I32 m_cameraIndex;
371  BWORD m_help;
372  BWORD m_spiral;
373  BWORD m_tracking;
374  Box2i m_scrubBox;
375 
376  public:
377 
378  sp<DrawHandler> drawHandler(void) { return m_spDrawHandler; }
379 };
380 
381 } /* namespace ext */
382 } /* namespace fe */
383 
384 #endif /* __opview_SurfaceViewerOp_h__ */
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Special vector for color (RGBA)
Definition: Color.h:21
Interface to handle signals from an SignalerI.
Definition: HandlerI.h:22
Generalized windowing event.
Definition: WindowEvent.h:43
Safe handle for shared pointer.
Definition: Handled.h:61
Automatically reference-counted string container.
Definition: String.h:128
Partial Generic SurfaceI Implemention.
Definition: OperatorSurfaceCommon.h:20
Wrapper for std::vector.
Definition: Array.h:21
Reference to an instance of a Layout.
Definition: RecordSB.h:35
DrawStyle
Rendering schemes that an an implementation may recognize.
Definition: DrawMode.h:42
Operator to look at surfaces in an independent window.
Definition: SurfaceViewerOp.h:22
SignalerViewerI attributes.
Definition: SignalerViewerI.h:37
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192