MHEG5  18.9.0
MHEG5 Documentation
mh5lineart.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
32 /*---includes for this file--------------------------------------------------*/
33 #include "mh5lineart.h"
34 #include "mh5object.h" /* for actions */
35 #include "mh5variable.h" /* for actions */
36 #include "mh5display.h" /* for actions */
37 #include "mh5memory.h" /* for constructor/destructor */
38 #include "mh5debug.h"
39 #include "tmcolor.h"
40 
41 #ifdef MH5PRINTOUT
42 #include <string.h>
43 #endif /* #ifdef MH5PRINTOUT */
44 
45 /*---constant definitions for this file--------------------------------------*/
46 
47 
48 /*---local typedef structs for this file-------------------------------------*/
49 
50 /*---local (static) variable declarations for this file----------------------*/
51 
52 /*---local function definitions----------------------------------------------*/
53 
54 /*---global function definitions---------------------------------------------*/
55 
61 /*
62  Debug
63  */
64 #ifdef MH5PRINTOUT
65 
72 void MHEG5lineartPrint(MHEG5Lineart *lineart, char *out)
73 {
74  MHEG5visiblePrint(&lineart->visible, out);
75  if (((MHEG5Root *)lineart)->clazz != MHEG5RECTANGLE)
76  {
77  if (!lineart->borderedBoundingBox)
78  {
79  MHEG5indent(out);
80  MHEG_PRINT(out, ":BBBox false");
81  MHEG5newLine(out);
82  }
83  }
84  if (lineart->originalLineWidth != 1)
85  {
86  MHEG5indent(out);
87  MHEG_PRINT(out, ":OrigLineWidth ");
88  MHEG5intPrint(lineart->originalLineWidth, out);
89  MHEG5newLine(out);
90  }
91  if (lineart->originalLineStyle != 1)
92  {
93  MHEG5indent(out);
94  MHEG_PRINT(out, ":OrigLineStyle ");
95  MHEG5intPrint(lineart->originalLineStyle, out);
96  MHEG5newLine(out);
97  }
99  {
100  MHEG5indent(out);
101  MHEG_PRINT(out, ":OrigRefLineColour ");
102  MHEG5colourPrint(lineart->originalRefLineColour, out);
103  MHEG5newLine(out);
104  }
106  {
107  MHEG5indent(out);
108  MHEG_PRINT(out, ":OrigRefFillColour ");
109  MHEG5colourPrint(lineart->originalRefFillColour, out);
110  MHEG5newLine(out);
111  }
112  /* Internal Attributes
113  if (lineart->lineWidth) {
114  MHEG5indent(out);
115  MHEG_PRINT(out,"//:LineWidth ");
116  MHEG5intPrint(lineart->lineWidth,out);
117  MHEG5newLine(out);
118  }
119  if (lineart->lineStyle) {
120  MHEG5indent(out);
121  MHEG_PRINT(out,"//:LineStyle ");
122  MHEG5intPrint(lineart->lineStyle,out);
123  MHEG5newLine(out);
124  }
125  if (!lineart->refLineColour.indirect) {
126  MHEG5indent(out);
127  MHEG_PRINT(out,"//:RefLineColour ");
128  MHEG5colourPrint(lineart->refLineColour,out);
129  MHEG5newLine(out);
130  }
131  if (!lineart->refFillColour.indirect) {
132  MHEG5indent(out);
133  MHEG_PRINT(out,"//:RefFillColour ");
134  MHEG5colourPrint(lineart->refFillColour,out);
135  MHEG5newLine(out);
136  }
137  */
138 }
139 
140 #endif
141 
142 
143 static MHEG5Bool MHEG5lineartIs(MHEG5Root *target)
144 {
145  if ((target->clazz == MHEG5LINEART) ||
146  (target->clazz == MHEG5RECTANGLE) ||
147  (target->clazz == MHEG5DYNAMICLINEART))
148  return MHEG5TRUE;
149  return MHEG5FALSE;
150 }
151 
152 /*
153  Lineart Clone
154  */
155 void MHEG5lineartClone(MHEG5Lineart *destination, MHEG5Lineart *source)
156 {
157  assert(source);
158  assert(destination);
159 
160  MHEG5visibleClone(&destination->visible, &source->visible);
161 
162  destination->borderedBoundingBox = source->borderedBoundingBox;
163  destination->originalLineWidth = source->originalLineWidth;
164  destination->originalLineStyle = source->originalLineStyle;
167 }
168 
169 /*
170  Constructor
171  */
172 
179 {
180  assert(lineart);
181 
182  MHEG5visibleInit(&lineart->visible);
183 
184  lineart->borderedBoundingBox = MHEG5TRUE;
185  lineart->originalLineWidth = 1;
186  lineart->originalLineStyle = 1;
189 }
190 
199 {
200  assert(lineart);
201 
202  MHEG5visibleFree(&lineart->visible);
203 
206 }
207 
208 /*
209  Internal behaviours
210  */
211 /*
212  33.3 Internal behaviours
213  this class has the same behaviours as its base class, with identical semantics.
214  */
216 {
217  assert(lineart);
218 
219  lineart->lineWidth = lineart->originalLineWidth;
220  lineart->lineStyle = lineart->originalLineStyle;
223 
224  MHEG5visiblePrepare(&lineart->visible);
225 }
226 
228 {
229  assert(lineart);
230 
232  {
233  MHEG5lineartPrepare( lineart );
234  }
235  MHEG5visibleActivate(&lineart->visible);
236 }
237 
239 {
240  assert(lineart);
241 
242  MHEG5visibleDeactivate(&lineart->visible);
243 }
244 
246 {
247  assert(lineart);
248 
249  MHEG5visibleDestruct(&lineart->visible);
250 
253 }
254 
255 /*
256  Actions
257  */
258 /*
259  SetLineWidth (NewLineWidth)
260  Change the width of lines of a LineArt object.
261  Execute the following sequence of actions:
262  1. Set the value of the LineWidth attribute to NewLineWidth.
263  2. If the target LineArt object is active, redraw immediately the target object by
264  taking into account the new value of the LineWidth attribute and according to its
265  position in the DisplayStack of the active Application object.
266 
267  Provisions of use:
268  The Target object shall be an available LineArt object.
269  NewLineWidth shall be set or refer to a positive integer value.
270  */
272 {
273  MHEG5Int i = -1;
274 
275  assert(target);
276 
277  if (!MHEG5lineartIs(target))
278  {
279  return MHEG5ERR_WRONGTARGET;
280  }
281 
282  if (!params)
283  {
285  }
286  MHEG5resolveGenericInteger(params, &i);
287 
288  if ((i >= 0))
289  {
290  ((MHEG5Lineart *) target)->lineWidth = i;
291  MHEG5displayRedraw((MHEG5Visible *) target);
292  }
293 
294  return MHEG5ERR_NOERROR;
295 }
296 
297 /*
298  SetLineStyle (NewLineStyle)
299  Change the line style of a LineArt object.
300  Execute the following sequence of actions:
301  1. Set the value of the LineStyle attribute to NewLineStyle.
302  2. If the target LineArt object is active, redraw immediately the target object by
303  taking into account the new value of the LineStyle attribute and according to its
304  position in the DisplayStack of the active Application object.
305 
306  Provisions of use:
307  The Target object shall be an available LineArt object.
308  NewLineStyle shall be set or refer to a positive integer value: 1, 2 or 3.
309  */
311 {
312  MHEG5Int i = 0;
313 
314  assert(target);
315 
316  if (!MHEG5lineartIs(target))
317  {
318  return MHEG5ERR_WRONGTARGET;
319  }
320 
321  if (!params)
322  {
324  }
325  MHEG5resolveGenericInteger(params, &i);
326 
327  if ((i > 0) && (i < 4))
328  {
329  ((MHEG5Lineart *) target)->lineStyle = i;
330 
331  MHEG5displayRedraw((MHEG5Visible *) target);
332  }
333  return MHEG5ERR_NOERROR;
334 }
335 
336 /*
337  SetLineColour (NewColour)
338  Change the colour of lines of a LineArt object.
339  Execute the following sequence of actions:
340  1. Set the value of the RefLineColour attribute to NewColour.
341  2. If the target object is active, redraw immediately the target object by taking into
342  account the new value of the LineWidth attribute and according to its position in
343  the DisplayStack of the active Application object.
344  NewColour may be either an absolute colour value or the zero-based index of a
345  colour in the look-up table referenced by the PaletteRef attribute.
346 
347  Provisions of use:
348  The Target object shall be an available LineArt object.
349  If RefLineColour is currently set to an absolute colour value, NewColour shall be
350  set or refer to an absolute colour value.
351  If RefLineColour is currently set to an index of a colour look-up table, NewColour
352  shall be set or refer to an index of a colour look-up table.
353  */
355 {
356  MHEG5Generic g;
357 
358  assert(target);
359 
360  if (!MHEG5lineartIs(target))
361  {
362  return MHEG5ERR_WRONGTARGET;
363  }
364 
365  if (!params)
366  {
368  }
369  MHEG5resolveGenericGeneric(params, &g);
370 
371  if (!((g.type == MHEG5INT) || (g.type == MHEG5OCTETSTRING)))
372  {
373  return MHEG5ERR_WRONGPARAM;
374  }
375 
376  MHEG5genericDestruct(&((MHEG5Lineart *) target)->refLineColour);
377  MHEG5genericCopy(&((MHEG5Lineart *) target)->refLineColour, &g);
378 
379  MHEG5displayRedraw((MHEG5Visible *) target);
380 
381  return MHEG5ERR_NOERROR;
382 }
383 
384 /*
385  SetFillColour (NewColour)
386  Change the fill-in colour of a LineArt object.
387  Execute the following sequence of actions:
388  1. Set the value of the RefFillColour attribute to NewColour.
389  2. If the target object is active, redraw immediately the target object by taking into
390  account the new value of the RefFillColour attribute and according to its position
391  in the DisplayStack of the active Application object.
392  NewColour may be either an absolute colour value or the zero-based index of a
393  colour in the look-up table referenced by the PaletteRef attribute.
394  If NewColour is not encoded, the RefFillColour attribute shall be set to
395  «transparent».
396 
397  Provisions of use:
398  The Target object shall be an available LineArt object.
399  If RefFillColour is not currently set, NewColour shall be set or refer to an absolute
400  colour value.
401  If RefFillColour is currently set to an absolute colour value, NewColour shall be
402  set or refer to an absolute colour value.
403  If RefFillColour is currently set to an index of a colour look-up table, NewColour
404  shall be set or refer to an index of a colour look-up table.
405  */
407 {
408  MHEG5Generic g;
409 
410  assert(target);
411 
412  if (!MHEG5lineartIs(target))
413  {
414  return MHEG5ERR_WRONGTARGET;
415  }
416 
417  if (params)
418  {
419  MHEG5resolveGenericGeneric(params, &g);
420  }
421  else
422  {
423  MHEG5genericSet(&g, RGBT(0, 0, 0, 0xff));
424  }
425 
426  if (!((g.type == MHEG5INT) || (g.type == MHEG5OCTETSTRING)))
427  {
428  return MHEG5ERR_WRONGPARAM;
429  }
430 
431  MHEG5genericDestruct(&((MHEG5Lineart *) target)->refFillColour);
432  MHEG5genericCopy(&((MHEG5Lineart *) target)->refFillColour, &g);
433 
434  MHEG5displayRedraw((MHEG5Visible *) target);
435 
436  return MHEG5ERR_NOERROR;
437 }
438 
void MHEG5lineartPrepare(MHEG5Lineart *lineart)
Definition: mh5lineart.c:215
MHEG5Bool availabilityStatus
Definition: mh5root.h:52
void MHEG5visibleActivate(MHEG5Visible *visible)
Apply the activation behaviour of the visible class. Apply the activation behaviour off the visible c...
Definition: mh5visible.c:306
#define TRANSPARENTCOLOR
Definition: tmcolor.h:37
#define RGBT(r, g, b, t)
Definition: tmcolor.h:48
#define MHEG5colourInit
Definition: mh5base.h:61
void MHEG5lineartInit(MHEG5Lineart *lineart)
Initialise a lineart object with default values.
Definition: mh5lineart.c:178
MHEG5Int i
Definition: mh5base.h:154
MHEG5Int originalLineStyle
Definition: mh5lineart.h:56
MHEG5Int originalLineWidth
Definition: mh5lineart.h:55
U16BIT type
Definition: mh5base.h:151
void MHEG5genericSet(MHEG5Generic *item, MHEG5Int initialValue)
Set a MHEG5Generic to the MHEG5Int value.
Definition: mh5base.c:978
void MHEG5lineartActivate(MHEG5Lineart *lineart)
Definition: mh5lineart.c:227
MHEG5GList * MHEG5resolveGenericInteger(MHEG5GList *params, MHEG5Int *value)
Definition: mh5object.c:510
MHEG5Final clazz
Definition: mh5root.h:55
void MHEG5visibleFree(MHEG5Visible *visible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5visible.c:186
MHEG5ErrorCode MHEG5setLineWidth(MHEG5Root *target, MHEG5GList *params)
Definition: mh5lineart.c:271
Implement the MHEG5 LineArt Class. Defines functionality associated with vectorial representation of ...
void MHEG5genericCopy(MHEG5Generic *dest, MHEG5Generic *src)
Copy a MHEG5Generic.
Definition: mh5base.c:861
union MHEG5Generic::@6 value
MHEG5ErrorCode MHEG5setFillColour(MHEG5Root *target, MHEG5GList *params)
Definition: mh5lineart.c:406
void MHEG5visiblePrepare(MHEG5Visible *visible)
Apply the preparation behaviour off the visible class Apply the preparation behaviour of the visible ...
Definition: mh5visible.c:239
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5visibleDestruct(MHEG5Visible *visible)
Destruct a visible object.
Definition: mh5visible.c:282
long MHEG5Int
Definition: mh5base.h:73
OSDColor OSDgetColour(const char *colour, int len)
Converts an MHEG5 colour value to an OSDColor type.
Definition: tmcolor.c:53
void MHEG5lineartClone(MHEG5Lineart *destination, MHEG5Lineart *source)
<Function description>="">
Definition: mh5lineart.c:155
#define BLACKCOLOR
Definition: tmcolor.h:38
#define MHEG5displayRedraw(v)
Definition: mh5display.h:47
MHEG5Int lineWidth
Definition: mh5lineart.h:61
MHEG5Bool borderedBoundingBox
Definition: mh5lineart.h:54
MHEG5Colour originalRefLineColour
Definition: mh5lineart.h:57
void MHEG5lineartFree(MHEG5Lineart *lineart)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5lineart.c:198
short MHEG5Bool
Definition: mh5base.h:71
MHEG5ErrorCode
Definition: mh5base.h:222
#define MHEG5colourDestruct
Definition: mh5base.h:62
void MHEG5lineartDestruct(MHEG5Lineart *lineart)
Definition: mh5lineart.c:245
#define MHEG5TRUE
Definition: mh5base.h:49
void MHEG5genericDestruct(MHEG5Generic *item)
Destruct a MHEG5Generic.
Definition: mh5base.c:834
Implement functions to retrieve MHEG5objects by GroupID and ID.
Mheg5 logging and debug printing.
MHEG5Colour refFillColour
Definition: mh5lineart.h:64
MHEG5Colour refLineColour
Definition: mh5lineart.h:63
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
MHEG5ErrorCode MHEG5setLineStyle(MHEG5Root *target, MHEG5GList *params)
Definition: mh5lineart.c:310
MHEG5ErrorCode MHEG5setLineColour(MHEG5Root *target, MHEG5GList *params)
Definition: mh5lineart.c:354
redirection include
void MHEG5visibleClone(MHEG5Visible *destination, MHEG5Visible *source)
Copy a visible object with original values.
Definition: mh5visible.c:206
void MHEG5lineartDeactivate(MHEG5Lineart *lineart)
Definition: mh5lineart.c:238
MHEG5Colour originalRefFillColour
Definition: mh5lineart.h:58
MHEG5Visible visible
Definition: mh5lineart.h:51
Definition of colour type for MHEG5 - settings and conversions.
MHEG5GList * MHEG5resolveGenericGeneric(MHEG5GList *params, MHEG5Generic *value)
Definition: mh5object.c:364
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
void MHEG5visibleDeactivate(MHEG5Visible *visible)
Apply the deactivation behaviour of the visible class. As this class has no own deactivation behaviou...
Definition: mh5visible.c:338
#define MHEG5FALSE
Definition: mh5base.h:48
MHEG5Int lineStyle
Definition: mh5lineart.h:62
void MHEG5visibleInit(MHEG5Visible *visible)
Initialise a visible object with default values.
Definition: mh5visible.c:172