OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
glyph.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef CMZN_GLYPH_HPP__
10 #define CMZN_GLYPH_HPP__
11 
12 #include "zinc/glyph.h"
13 #include "zinc/context.hpp"
14 #include "zinc/material.hpp"
15 #include "zinc/spectrum.hpp"
16 
17 namespace OpenCMISS
18 {
19 namespace Zinc
20 {
21 
22 class GlyphAxes;
23 class GlyphColourBar;
24 
35 class Glyph
36 {
37 protected:
38  cmzn_glyph_id id;
39 
40 public:
41 
42  Glyph() : id(0)
43  { }
44 
45  // takes ownership of C handle, responsibility for destroying it
46  explicit Glyph(cmzn_glyph_id in_glyph_id) :
47  id(in_glyph_id)
48  { }
49 
50  Glyph(const Glyph& glyph) :
51  id(cmzn_glyph_access(glyph.id))
52  { }
53 
54  Glyph& operator=(const Glyph& glyph)
55  {
56  cmzn_glyph_id temp_id = cmzn_glyph_access(glyph.id);
57  if (0 != id)
58  {
59  cmzn_glyph_destroy(&id);
60  }
61  id = temp_id;
62  return *this;
63  }
64 
65  ~Glyph()
66  {
67  if (0 != id)
68  {
69  cmzn_glyph_destroy(&id);
70  }
71  }
72 
78  bool isValid() const
79  {
80  return (0 != id);
81  }
82 
88  cmzn_glyph_id getId() const
89  {
90  return id;
91  }
92 
98  {
99  REPEAT_MODE_INVALID = CMZN_GLYPH_REPEAT_MODE_INVALID,
101  REPEAT_MODE_NONE = CMZN_GLYPH_REPEAT_MODE_NONE,
105  REPEAT_MODE_AXES_2D = CMZN_GLYPH_REPEAT_MODE_AXES_2D,
109  REPEAT_MODE_AXES_3D = CMZN_GLYPH_REPEAT_MODE_AXES_3D,
113  REPEAT_MODE_MIRROR = CMZN_GLYPH_REPEAT_MODE_MIRROR
123  };
124 
125 
131  {
132  SHAPE_TYPE_INVALID = CMZN_GLYPH_SHAPE_TYPE_INVALID,
134  SHAPE_TYPE_NONE = CMZN_GLYPH_SHAPE_TYPE_NONE,
136  SHAPE_TYPE_ARROW = CMZN_GLYPH_SHAPE_TYPE_ARROW,
138  SHAPE_TYPE_ARROW_SOLID = CMZN_GLYPH_SHAPE_TYPE_ARROW_SOLID,
140  SHAPE_TYPE_AXIS = CMZN_GLYPH_SHAPE_TYPE_AXIS,
142  SHAPE_TYPE_AXIS_SOLID = CMZN_GLYPH_SHAPE_TYPE_AXIS_SOLID,
144  SHAPE_TYPE_CONE = CMZN_GLYPH_SHAPE_TYPE_CONE,
146  SHAPE_TYPE_CONE_SOLID = CMZN_GLYPH_SHAPE_TYPE_CONE_SOLID,
148  SHAPE_TYPE_CROSS = CMZN_GLYPH_SHAPE_TYPE_CROSS,
150  SHAPE_TYPE_CUBE_SOLID = CMZN_GLYPH_SHAPE_TYPE_CUBE_SOLID,
152  SHAPE_TYPE_CUBE_WIREFRAME = CMZN_GLYPH_SHAPE_TYPE_CUBE_WIREFRAME,
154  SHAPE_TYPE_CYLINDER = CMZN_GLYPH_SHAPE_TYPE_CYLINDER,
156  SHAPE_TYPE_CYLINDER_SOLID = CMZN_GLYPH_SHAPE_TYPE_CYLINDER_SOLID,
158  SHAPE_TYPE_DIAMOND = CMZN_GLYPH_SHAPE_TYPE_DIAMOND,
160  SHAPE_TYPE_LINE = CMZN_GLYPH_SHAPE_TYPE_LINE,
162  SHAPE_TYPE_POINT = CMZN_GLYPH_SHAPE_TYPE_POINT,
164  SHAPE_TYPE_SHEET = CMZN_GLYPH_SHAPE_TYPE_SHEET,
166  SHAPE_TYPE_SPHERE = CMZN_GLYPH_SHAPE_TYPE_SPHERE,
168  SHAPE_TYPE_AXES = CMZN_GLYPH_SHAPE_TYPE_AXES,
170  SHAPE_TYPE_AXES_123 = CMZN_GLYPH_SHAPE_TYPE_AXES_123,
172  SHAPE_TYPE_AXES_XYZ = CMZN_GLYPH_SHAPE_TYPE_AXES_XYZ,
174  SHAPE_TYPE_AXES_COLOUR = CMZN_GLYPH_SHAPE_TYPE_AXES_COLOUR,
176  SHAPE_TYPE_AXES_SOLID = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID,
178  SHAPE_TYPE_AXES_SOLID_123 = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID_123,
180  SHAPE_TYPE_AXES_SOLID_XYZ = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID_XYZ,
182  SHAPE_TYPE_AXES_SOLID_COLOUR = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID_COLOUR
184  };
185 
192  char *getName()
193  {
194  return cmzn_glyph_get_name(id);
195  }
196 
203  int setName(const char *name)
204  {
205  return cmzn_glyph_set_name(id, name);
206  }
207 
214  bool isManaged()
215  {
216  return (0 != cmzn_glyph_is_managed(id));
217  }
218 
231  int setManaged(bool value)
232  {
233  return cmzn_glyph_set_managed(id, static_cast<int>(value));
234  }
235 
242  inline GlyphAxes castAxes();
249  inline GlyphColourBar castColourBar();
250 };
251 
258 class GlyphAxes : public Glyph
259 {
260 private:
266  inline cmzn_glyph_axes_id getDerivedId()
267  {
268  return reinterpret_cast<cmzn_glyph_axes_id>(id);
269  }
270 
271 public:
272  GlyphAxes() : Glyph(0) {}
273 
274  explicit GlyphAxes(cmzn_glyph_axes_id axes_id)
275  : Glyph(reinterpret_cast<cmzn_glyph_id>(axes_id))
276  {}
277 
283  double getAxisWidth()
284  {
285  return cmzn_glyph_axes_get_axis_width(getDerivedId());
286  }
287 
296  int setAxisWidth(double axisWidth)
297  {
298  return cmzn_glyph_axes_set_axis_width(getDerivedId(), axisWidth);
299  }
300 
308  char *getAxisLabel(int axisNumber)
309  {
310  return cmzn_glyph_axes_get_axis_label(getDerivedId(), axisNumber);
311  }
312 
320  int setAxisLabel(int axisNumber, const char *label)
321  {
322  return cmzn_glyph_axes_set_axis_label(getDerivedId(), axisNumber, label);
323  }
324 
331  Material getAxisMaterial(int axisNumber)
332  {
333  return Material(cmzn_glyph_axes_get_axis_material(getDerivedId(), axisNumber));
334  }
335 
345  int setAxisMaterial(int axisNumber, const Material& material)
346  {
347  return cmzn_glyph_axes_set_axis_material(getDerivedId(), axisNumber, material.getId());
348  }
349 
350 };
351 
353 {
354  return GlyphAxes(cmzn_glyph_cast_axes(id));
355 }
356 
364 class GlyphColourBar : public Glyph
365 {
366 private:
372  inline cmzn_glyph_colour_bar_id getDerivedId()
373  {
374  return reinterpret_cast<cmzn_glyph_colour_bar_id>(id);
375  }
376 
377 public:
378  GlyphColourBar() : Glyph(0) {}
379 
380  explicit GlyphColourBar(cmzn_glyph_colour_bar_id colour_bar_id)
381  : Glyph(reinterpret_cast<cmzn_glyph_id>(colour_bar_id))
382  {}
383 
391  int getAxis(int valuesCount, double *valuesOut)
392  {
393  return cmzn_glyph_colour_bar_get_axis(getDerivedId(), valuesCount, valuesOut);
394  }
395 
406  int setAxis(int valuesCount, const double *valuesIn)
407  {
408  return cmzn_glyph_colour_bar_set_axis(getDerivedId(), valuesCount, valuesIn);
409  }
410 
418  int getCentre(int valuesCount, double *valuesOut)
419  {
420  return cmzn_glyph_colour_bar_get_centre(getDerivedId(), valuesCount, valuesOut);
421  }
422 
434  int setCentre(int valuesCount, const double *valuesIn)
435  {
436  return cmzn_glyph_colour_bar_set_centre(getDerivedId(), valuesCount, valuesIn);
437  }
438 
445  double getExtendLength()
446  {
447  return cmzn_glyph_colour_bar_get_extend_length(getDerivedId());
448  }
449 
458  int setExtendLength(double extendLength)
459  {
460  return cmzn_glyph_colour_bar_set_extend_length(getDerivedId(), extendLength);
461  }
462 
469  {
470  return cmzn_glyph_colour_bar_get_label_divisions(getDerivedId());
471  }
472 
481  int setLabelDivisions(int labelDivisions)
482  {
483  return cmzn_glyph_colour_bar_set_label_divisions(getDerivedId(), labelDivisions);
484  }
485 
492  {
493  return Material(cmzn_glyph_colour_bar_get_label_material(getDerivedId()));
494  }
495 
504  int setLabelMaterial(const Material& material)
505  {
506  return cmzn_glyph_colour_bar_set_label_material(getDerivedId(), material.getId());
507  }
508 
516  {
517  return cmzn_glyph_colour_bar_get_number_format(getDerivedId());
518  }
519 
531  int setNumberFormat(const char *numberFormat)
532  {
533  return cmzn_glyph_colour_bar_set_number_format(getDerivedId(), numberFormat);
534  }
535 
543  int getSideAxis(int valuesCount, double *valuesOut)
544  {
545  return cmzn_glyph_colour_bar_get_side_axis(getDerivedId(), valuesCount, valuesOut);
546  }
547 
559  int setSideAxis(int valuesCount, const double *valuesIn)
560  {
561  return cmzn_glyph_colour_bar_set_side_axis(getDerivedId(), valuesCount, valuesIn);
562  }
563 
569  double getTickLength()
570  {
571  return cmzn_glyph_colour_bar_get_tick_length(getDerivedId());
572  }
573 
582  int setTickLength(double tickLength)
583  {
584  return cmzn_glyph_colour_bar_set_tick_length(getDerivedId(), tickLength);
585  }
586 
587 };
588 
590 {
591  return GlyphColourBar(cmzn_glyph_cast_colour_bar(id));
592 }
593 
603 {
604 protected:
605  cmzn_glyphmodule_id id;
606 
607 public:
608 
609  Glyphmodule() : id(0)
610  { }
611 
612  // takes ownership of C handle, responsibility for destroying it
613  explicit Glyphmodule(cmzn_glyphmodule_id in_glyphmodule_id) :
614  id(in_glyphmodule_id)
615  { }
616 
617  Glyphmodule(const Glyphmodule& glyphModule) :
618  id(cmzn_glyphmodule_access(glyphModule.id))
619  { }
620 
621  Glyphmodule& operator=(const Glyphmodule& glyphModule)
622  {
623  cmzn_glyphmodule_id temp_id = cmzn_glyphmodule_access(glyphModule.id);
624  if (0 != id)
625  {
626  cmzn_glyphmodule_destroy(&id);
627  }
628  id = temp_id;
629  return *this;
630  }
631 
632  ~Glyphmodule()
633  {
634  if (0 != id)
635  {
636  cmzn_glyphmodule_destroy(&id);
637  }
638  }
639 
645  bool isValid() const
646  {
647  return (0 != id);
648  }
649 
655  cmzn_glyphmodule_id getId() const
656  {
657  return id;
658  }
659 
670  {
671  return cmzn_glyphmodule_begin_change(id);
672  }
673 
683  int endChange()
684  {
685  return cmzn_glyphmodule_end_change(id);
686  }
687 
698  GlyphAxes createGlyphAxes(const Glyph& axisGlyph, double axisWidth)
699  {
700  return GlyphAxes(reinterpret_cast<cmzn_glyph_axes_id>(
701  cmzn_glyphmodule_create_glyph_axes(id, axisGlyph.getId(), axisWidth)));
702  }
703 
713  {
714  return GlyphColourBar(reinterpret_cast<cmzn_glyph_colour_bar_id>(
715  cmzn_glyphmodule_create_glyph_colour_bar(id, spectrum.getId())));
716  }
717 
763  {
764  return cmzn_glyphmodule_define_standard_glyphs(id);
765  }
766 
773  Glyph findGlyphByName(const char *name)
774  {
775  return Glyph(cmzn_glyphmodule_find_glyph_by_name(id, name));
776  }
777 
778  Glyph findGlyphByGlyphShapeType(Glyph::ShapeType glyphShapeType)
779  {
780  return Glyph(cmzn_glyphmodule_find_glyph_by_glyph_shape_type(id, static_cast<cmzn_glyph_shape_type>(glyphShapeType)));
781  }
782 
789  {
790  return Glyph(cmzn_glyphmodule_get_default_point_glyph(id));
791  }
792 
799  int setDefaultPointGlyph(const Glyph& glyph)
800  {
801  return cmzn_glyphmodule_set_default_point_glyph(id, glyph.getId());
802  }
803 
804 };
805 
807 {
808  return Glyphmodule(cmzn_context_get_glyphmodule(id));
809 }
810 
811 } // namespace Zinc
812 }
813 
814 #endif
Material getAxisMaterial(int axisNumber)
Definition: glyph.hpp:331
char * getAxisLabel(int axisNumber)
Definition: glyph.hpp:308
A specialised glyph type which renders 3-D axes.
Definition: glyph.hpp:258
int endChange()
Definition: glyph.hpp:683
bool isManaged()
Definition: glyph.hpp:214
int defineStandardGlyphs()
Definition: glyph.hpp:762
GlyphColourBar castColourBar()
Definition: glyph.hpp:589
double getTickLength()
Definition: glyph.hpp:569
cmzn_material_id getId() const
Definition: material.hpp:83
RepeatMode
Definition: glyph.hpp:97
Glyphmodule getGlyphmodule()
Definition: glyph.hpp:806
GlyphAxes createGlyphAxes(const Glyph &axisGlyph, double axisWidth)
Definition: glyph.hpp:698
int getAxis(int valuesCount, double *valuesOut)
Definition: glyph.hpp:391
cmzn_spectrum_id getId() const
Definition: spectrum.hpp:638
int setManaged(bool value)
Definition: glyph.hpp:231
A glyph is a static graphics object used to visualise a point in space.
Definition: glyph.hpp:35
Glyph findGlyphByName(const char *name)
Definition: glyph.hpp:773
int setAxisMaterial(int axisNumber, const Material &material)
Definition: glyph.hpp:345
Zinc materials specify colouring of graphics.
Definition: material.hpp:29
int getSideAxis(int valuesCount, double *valuesOut)
Definition: glyph.hpp:543
cmzn_glyphmodule_id getId() const
Definition: glyph.hpp:655
int setAxisWidth(double axisWidth)
Definition: glyph.hpp:296
int setDefaultPointGlyph(const Glyph &glyph)
Definition: glyph.hpp:799
int setNumberFormat(const char *numberFormat)
Definition: glyph.hpp:531
int setLabelDivisions(int labelDivisions)
Definition: glyph.hpp:481
bool isValid() const
Definition: glyph.hpp:645
char * getNumberFormat()
Definition: glyph.hpp:515
char * getName()
Definition: glyph.hpp:192
Zinc Spectrum maps values of graphics data fields to colours.
Definition: spectrum.hpp:581
int beginChange()
Definition: glyph.hpp:669
ShapeType
Definition: glyph.hpp:130
double getExtendLength()
Definition: glyph.hpp:445
Module managing all glyphs.
Definition: glyph.hpp:602
A specialised glyph type which draws a cylindrical colour bar.
Definition: glyph.hpp:364
double getAxisWidth()
Definition: glyph.hpp:283
int setAxisLabel(int axisNumber, const char *label)
Definition: glyph.hpp:320
Material getLabelMaterial()
Definition: glyph.hpp:491
int getCentre(int valuesCount, double *valuesOut)
Definition: glyph.hpp:418
int setCentre(int valuesCount, const double *valuesIn)
Definition: glyph.hpp:434
GlyphColourBar createGlyphColourBar(const Spectrum &spectrum)
Definition: glyph.hpp:712
int setSideAxis(int valuesCount, const double *valuesIn)
Definition: glyph.hpp:559
int setExtendLength(double extendLength)
Definition: glyph.hpp:458
GlyphAxes castAxes()
Definition: glyph.hpp:352
int setTickLength(double tickLength)
Definition: glyph.hpp:582
Glyph getDefaultPointGlyph()
Definition: glyph.hpp:788
cmzn_glyph_id getId() const
Definition: glyph.hpp:88
int getLabelDivisions()
Definition: glyph.hpp:468
int setLabelMaterial(const Material &material)
Definition: glyph.hpp:504
bool isValid() const
Definition: glyph.hpp:78
int setName(const char *name)
Definition: glyph.hpp:203
int setAxis(int valuesCount, const double *valuesIn)
Definition: glyph.hpp:406