UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VisualTS.h
1 /* $Id: VisualTS.h,v 1.23 2007/09/05 14:32:39 vlad Exp $ */
2 
3 #ifndef __VisualTS_h
4 
5 #define __VisualTS_h
6 
7 #include <mix/Types.h>
8 #include <mix/Types.h>
9 
10 #include <ymprog.h>
11 
12 #include <tv/TraceSet.h>
13 #include <tv/TVscaler.h>
14 #include <tv/GraphicEnv.h>
15 #include <tv/VisualParams.h>
16 #include <tv/Cursors.h>
17 #include <tv/Selector.h>
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23 
24 /* class VisualTraceSet:
25 
26  methods:
27 
28  int CreateVTS (VisualTraceSet* pvts, TraceSet ts);
29  -- creates empty visual trace set;
30  void DestroyVTS (VisualTraceSet* vts);
31  -- destroys visual trace set;
32  int LinkGEtoVTS (VisualTraceSet vts, GraphicEnv* ge);
33  -- opens visual trace set for opened trace set;
34  void UnlinkGEtoVTS (VisualTraceSet vts);
35  -- clean visual trace set from all data;
36  int TuneGCforVTS (VisualTraceSet vts);
37  -- tunes gc for the vts drawing;
38 
39  void ReplotVTS (VisualTraceSet vts);
40  -- forces all changed parameters to action;
41 
42  methods parameter:
43 
44  int ChangedOrResizedVTS (VisualTraceSet vts);
45  -- returns 1 if vts needed to replot due to parameters or geometry changes;
46 
47  void SetTracesRect (VisualTraceSet vts, unsigned int x, unsigned int y,
48  unsigned int w, unsigned int h);
49  -- set parameters of the rectangular area for trace drawing;
50  void GetTracesRect (VisualTraceSet vts, unsigned int* x, unsigned int* y,
51  unsigned int* w, unsigned int* h)
52  -- get parameters of the rectangular area for trace drawing;
53 
54  void SetTimeBoundsVTS (VisualTraceSet vts, float tl, float tr);
55  -- set left and right times {ms};
56  void GetTimeBoundsVTS (VisualTraceSet vts, float* tl, float* tr);
57  -- get values of left and right times {ms};
58 
59  void SetTraceRangeVTS (VisualTraceSet vts, TraceRange* ptrange);
60  -- set range of traces to display;
61  void GetTraceRangeVTS (VisualTraceSet vts, TraceRange* ptrange);
62  -- get range of traces to display;
63 
64  void SetSineKindVTS (VisualTraceSet vts, SineKind sk);
65  -- set a kind of sine visualization type;
66  SineKind GetSineKindVTS (VisualTraceSet vts);
67  -- get a kind of sine visualization type;
68 
69  void SetAGCGapVTS (VisualTraceSet vts, float gap);
70  -- set automatic amplitude level adjustment gap width {ms};
71  float GetAGCGapVTS (VisualTraceSet vts);
72  -- get automatic amplitude level adjustment gap width {ms};
73 
74  void SetOverlappingVTS (VisualTraceSet vts, float overlapping);
75  float GetOverlappingVTS (VisualTraceSet vts);
76 
77  void SetAvgLevelVTS (VisualTraceSet vts, float avg_level);
78  float GetAvgLevelVTS (VisualTraceSet vts);
79 
80  int SaveViewVTS (VisualTraceSet vts);
81  -- trace view saving;
82  int RestoreViewVTS (VisualTraceSet vts);
83  -- trace view restoring;
84 
85  int TheFirstPlotVTS (VisualTraceSet vts);
86  -- returns boolean value of the first plotting predicate or -1.
87 
88  void GrabTraceRangeVTS (VisualTraceSet vts, TraceRange* tr,
89  short y1, short y2);
90  -- returns in *tr indexes (in iterator order) of the first and the last
91  -- trace on the view placed between y1 and y2;
92  float GrabTraceTimeVTS (VisualTraceSet vts, short x);
93  -- returns time {ms} in view at the point with x coordinate;
94  void GrabTraceTimesVTS (VisualTraceSet vts, float times[2],
95  short x1, short x2);
96 
97  void SetVPtoVTS (VisualTraceSet vts, VisualParams* vp);
98  -- saves at *vp the current visual state;
99  void GetVPfromVTS (VisualTraceSet vts, VisualParams* vp);
100  -- set *vp at the current visual state;
101 
102  int TimeToSampleIndexVTS (VisualTraceSet vts, float time);
103  -- return index of the sample, closest to the pointed time.
104 
105  float YToTraceAmplVTS (VisualTraceSet vts, int y, float time,
106  int curTraceIndex, float* curTraceBody);
107  -- returns amplitude (real value) pointed for curTraceIndex by
108  y-coord at given time.
109  */
110 
111 
112 
113 #define TVcolorsDepth 4
114 /* TVcolor */
115 typedef enum
116 {
117  BackgroundColor, /* white default */
118  TraceBackgroundColor, /* white default */
119  TraceColor, /* black default */
120  SelectedTraceColor, /* black default */
121  TimeAxisColor, /* black default */
122  TimeGridColor, /* black default */
123  DepthAxisColor, /* black default */
124  TitleColor, /* black default */
125  TimeLabelsColor, /* black default */
126  DepthLabelsColor, /* black default */
127  ActMarksColor, /* black default */
128  InfoHintFGColor,
129  InfoHintBGColor,
130  AppStampFGColor,
131  __TVcolorsCnt
132 
133 } TVcolor;
134 
135 /* TVfont */
136 typedef enum
137 {
138  DepthAxisTitleFont,
139  DepthAxisLabelsFont,
140  TimeAxisTitleFont,
141  TimeAxisLabelsFont,
142  InfoHintFont,
143  LegendFont,
144  AppStampFont,
145  __TVfontsCnt
146 
147 } TVfont;
148 
149 
150 typedef enum
151 {
152  reNoPixmap,
153  reActualPixmap
154 
155 } RedrawFlag;
156 
157 typedef struct
158 {
159  TraceSet ts; /* current trace set */
160 
161  /**** View storing fields ****/
162  int changed; /* !0 - parameters have been changed or resize event */
163  GraphicEnv ge; /* display, screen, window and gc in one structure */
164  RedrawFlag redrawFlag;
165  Pixmap area; /* pixmap to store trace view */
166  unsigned long tracePlaneMask;
167  unsigned long rubberBandPlaneMask;
168  int colors[__TVcolorsCnt];
169  Font fonts[__TVfontsCnt];
170 
171  /**** Trace parameters ****/
172  float Tl, Tr; /* left and right bound times {ms} */
173  float dt; /* step time {ms} */
174  unsigned long StartIndex, TrCnt; /* the first trace index and
175  count of displayed traces in backward order */
176 
177  /**** Visual parameters ****/
178  float gridStep; /* {ms}, step of the time grid; 0.0 - no grid */
179  Logic colorMode; /* TRUE switches on amplitude colorification */
180  SineKind sk; /* sinus visualization type */
181  TraceScale* scTab; /* scaling table */
182  float averaging; /* persent; 'average' level of amplitude adjusting */
183  float overlapping; /* persent; how many area used by neibour traces */
184  float gapWidth; /* automatic Amplitude Level Adjustment gap width {ms} */
185  float agcDynamicAmplify; /* AGC dynamic amplify koefficient (0..1) */
186  float zeroAmplLevel;/* 0..100: zero is drawn if |Acur|<Amax*ZAL */
187  AmplNormKind amplNormKind; /* AGC or global normalization */
188  float cutAmplLevel; /* 0..100: % of |A|max to draw amplitude */
189  float globalAmax; /* defined |A|max for all traces */
190  float fixedAmax; /* custom value of |A|max */
191  VisTraceData *vtd; /* Parameters for each visualized trace */
192 
193  /**** Window parameters ****/
194  short tax, tay; /* trace available left x and top y */
195  short taw, tah; /* trace available width and height */
196  unsigned wid_w, wid_h; /* the whole window width and height */
197 
198  /**** Trace color listing ****/
199  int n_color_list;
200  TypeCompColor *color_list;
201 
202  /**** Header field displaying along coordinate axis ****/
203  int taid;
205  /**** List of tags for rectangular area-based event processing ****/
206  int n_tags;
207  struct vtssTag {
208  char *tag_name;
209  XRectangle area;
210  } *tags;
211 
213 
215 
216 /*=== Argument types ===*/
217 
218 typedef enum
219 {
220  Indexes,
221  IndexAndCount,
222  Depths
223 
224 } TraceRangeType;
225 
226 typedef struct
227 {
228  TraceRangeType tr_type;
229 
230  unsigned long startIndex, endIndex; /* backward order */
231  float startDepth, endDepth;
232  unsigned long traceCnt;
233 
234 } TraceRange;
235 
236 
237 /* To find out zero samples */
238 #define ALMOST_ZERO 1e-34
239 
240 
241 /*=== Methods ===*/
242 /*--- Life time ---*/
243 int CreateVTS (VisualTraceSet* pvts, TraceSet ts);
244 void DestroyVTS (VisualTraceSet* vts);
245 int LinkGEtoVTS (VisualTraceSet vts, GraphicEnv* ge);
246 /*--- Drawing ---*/
247 int ExposeVTS (VisualTraceSet vts);
248 int TuneGCforVTS (VisualTraceSet vts);
249 int TuneSpecGCforVTS (VisualTraceSet vts, int line_width, int color_index);
250 int PlotOneTrace (VisualTraceSet vts, SineKind sk, int colorIndex,
251  int lineWidth, int trace_i, float* trace_body);
252 int ReplotVTS (VisualTraceSet vts);
253 void PlotAxesVTS(VisualTraceSet vts);
254 void PlotGridVTS(VisualTraceSet vts);
255 void DrawTextAtTimeAxisVTS (VisualTraceSet vts);
256 void DrawTextAtDepthAxisVTS (VisualTraceSet vts);
257 int SaveViewVTS (VisualTraceSet vts);
258 int RestoreViewVTS (VisualTraceSet vts);
259 int ChangedOrResizedVTS (VisualTraceSet vts);
260 /*--- Parameters ---*/
261 void SetTracesRect (VisualTraceSet vts, unsigned int x, unsigned int y,
262  unsigned int w, unsigned int h);
263 void GetTracesRect (VisualTraceSet vts, unsigned int* x, unsigned int* y,
264  unsigned int* w, unsigned int* h);
265 void SetTimeBoundsVTS (VisualTraceSet vts, float tl, float tr);
266 void GetTimeBoundsVTS (VisualTraceSet vts, float* tl, float* tr);
267 void SetTraceRangeVTS (VisualTraceSet vts, TraceRange* ptrange);
268 void GetTraceRangeVTS (VisualTraceSet vts, TraceRange* ptrange);
269 void SetOverlappingVTS (VisualTraceSet vts, float overlapping);
270 float GetOverlappingVTS (VisualTraceSet vts);
271 void SetAvgLevelVTS (VisualTraceSet vts, float avg_level);
272 float GetAvgLevelVTS (VisualTraceSet vts);
273 void SetSineKindVTS (VisualTraceSet vts, SineKind sk);
274 SineKind GetSineKindVTS (VisualTraceSet vts);
275 void SetAmplNormKindVTS (VisualTraceSet vts, AmplNormKind ank);
276 AmplNormKind GetAmplNormKindVTS (VisualTraceSet vts);
277 void SetCutAmplLevelVTS (VisualTraceSet vts, float cal);
278 float GetCutAmplLevelVTS (VisualTraceSet vts);
279 void SetGridStepVTS(VisualTraceSet vts, float gridStep);
280 float GetGridStepVTS(VisualTraceSet vts);
281 /*--- Automatic Level Adjustment ---*/
282 void SetAGCGapVTS (VisualTraceSet vts, float gap);
283 float GetAGCGapVTS (VisualTraceSet vts);
284 /*--- View information ---*/
285 int TheFirstPlotVTS (VisualTraceSet vts);
286 
287 void GrabTraceVTS (VisualTraceSet vts, TraceRange* tr, int x, int y);
288 void GrabTraceRangeVTS (VisualTraceSet vts, TraceRange* tr, int y1, int y2);
289 float GrabTraceTimeVTS (VisualTraceSet vts, int x);
290 void GrabTraceTimesVTS (VisualTraceSet vts, float times[2], int x1, int x2);
291 
292 int TimeToXVTS (VisualTraceSet vts, float time);
293 float XToTimeVTS (VisualTraceSet vts, int x);
294 int TraceIndexToYVTS (VisualTraceSet vts, int index);
295 int YToTraceIndexVTS (VisualTraceSet vts, int y);
296 int TimeToSampleIndexVTS (VisualTraceSet vts, float time);
297 float SampleIndexToTimeVTS (VisualTraceSet vts, int sample_i);
298 float YToTraceAmplVTS (VisualTraceSet vts, int y, float time,
299  int curTraceIndex, float* curTraceBody);
300 /*--- Visual parameters ---*/
301 void SetVPtoVTS (VisualTraceSet vts, VisualParams* vp);
302 void GetVPfromVTS (VisualTraceSet vts, VisualParams* vp);
303 
304 /*--- Force the point of event origin to be inside visual box ---*/
305 void ForceEventOriginVTS (XEvent* xe);
306 
307 /*--- Draw rubber rectangle between two diagonal points ---*/
308 void DrawRubberBandVTS (VisualTraceSet vts, XPoint* p1, XPoint* p2);
309 
310 /*--- General event handlers ---*/
311 void InfoHandlerVTS (VisualTraceSet vts, XEvent* xe);
312 int ZoomInHandlerVTS (VisualTraceSet vts, XEvent* xe);
313 int ZoomOutHandlerVTS (VisualTraceSet vts, XEvent* xe);
314 
315 /*--- Smart trace field redrawing ---*/
316 void ExposeTraceFieldVTS (VisualTraceSet vts,
317  YScrollBar* yHorSB, YScrollBar* yVerSB);
318 
319 
320 /* Dummy. Just for backward compatibility */
321 void SetAGCKindVTS (VisualTraceSet vts, AGCKind agcKind);
322 AGCKind GetAGCKind (VisualTraceSet vts);
323 
324 
325 /*--- Type&Comp color fetch ---*/
326 TypeCompColor* FindTypeCompColorVTS (VisualTraceSet vts,
327  char type, char comp);
328 TypeCompColor* AddTypeCompColorVTS (VisualTraceSet vts,
329  char type, char comp,
330  const char* colorname);
331 
337 void PutLegendComp (VisualTraceSet vts,
338  TypeCompPair* pairs, int n_pairs,
339  Display* dpy, Window wid, GC gc,
340  int ch_w, int ch_h, int* x, int* y,
341  int enabled);
342 
343 /* Display the whole legend box. */
344 void ExposeLegendBoxVTS (VisualTraceSet vts);
345 
346 /*--- Normalization routines ---*/
347 
348 /* Prepare normalization data. */
349 void PrepareNormData (VisualTraceSet vts);
350 
351 /* Normalize the i-trace. */
352 void NormalizeTrace (VisualTraceSet vts, int i,
353  float* src, float* dst, float* dAmax);
354 
355 
356 /*--- Selector ---*/
357 
358 /* Prepare list of selectable traces. Return error code which means:
359  OK - selector can function correctly;
360  ERROR__* - selector can't be done correctly. */
361 ErrCode PrepareSelectorVTS (VisualTraceSet vts);
362 
363 /* Make selection over input modification. Selector is prepared in
364  rSelSet variable.
365  Returns: OK -> ready to redisplay traces;
366  ERROR__EMPTY -> empty selection - no traces are in resulting set. */
367 ErrCode ApplySelectionTSforVTS (VisualTraceSet vts);
368 
369 /* Select traces. Return error code which means:
370  OK - new trace set was selected; need to redisplay traces;
371  ERROR__FIRST - cancel pressed; do nothing;
372  ERROR__* - some error take place. */
373 ErrCode SelectTSforVTS (Widget wMainWin, VisualTraceSet vts,
374  void (*OnSelect)(void));
375 
378 ErrCode SelectTypeAndCompVTS (VisualTraceSet vts, char type, char comp);
379 
380 
381 /*--- Visual parameter's save&load ---*/
382 
383 /* Save trace visualization parameters to the configuration file in
384  given subdirectory. Return OK in success or error code otherwise. */
385 ErrCode SaveTVpar (VisualTraceSet vts, const char* szDir);
386 
387 /* Load trace visualization parameters from the configuration file in
388  given subdirectory. Return OK in success or return silently error
389  code in case of failure. */
390 ErrCode LoadTVpar (VisualTraceSet vts, const char* szDir);
391 
392 
393 /*--- Working with tags ---*/
394 
396 ErrCode AddTagVTS (VisualTraceSet vts, const char* szTag,
397  int x, int y, int width, int height);
398 
400 ErrCode ResetTagsVTS (VisualTraceSet vts);
401 
404 const char* FindTagVTS (VisualTraceSet vts, int x, int y);
405 
406 
407 #ifdef __cplusplus
408 };
409 #endif /* __cplusplus */
410 
411 #endif /* VisualTS.h */
Definition: VisualTS.h:157
int taid
Definition: VisualTS.h:203
char * tag_name
Definition: VisualTS.h:208
Definition: ymprog.h:615
Definition: VisualParams.h:77
Definition: VisualTS.h:226
Definition: GraphicEnv.h:15
Definition: TVscaler.h:11
Definition: Selector.h:43
Definition: VisualTS.h:207
Definition: VisualParams.h:59
Definition: trset.h:96
Definition: VisualParams.h:39
XRectangle area
Definition: VisualTS.h:209