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 class Graphics;
25 
36 class Glyph
37 {
38 protected:
39  cmzn_glyph_id id;
40 
41 public:
42 
43  Glyph() : id(0)
44  { }
45 
46  // takes ownership of C handle, responsibility for destroying it
47  explicit Glyph(cmzn_glyph_id in_glyph_id) :
48  id(in_glyph_id)
49  { }
50 
51  Glyph(const Glyph& glyph) :
52  id(cmzn_glyph_access(glyph.id))
53  { }
54 
55  Glyph& operator=(const Glyph& glyph)
56  {
57  cmzn_glyph_id temp_id = cmzn_glyph_access(glyph.id);
58  if (0 != id)
59  {
60  cmzn_glyph_destroy(&id);
61  }
62  id = temp_id;
63  return *this;
64  }
65 
66  ~Glyph()
67  {
68  if (0 != id)
69  {
70  cmzn_glyph_destroy(&id);
71  }
72  }
73 
79  bool isValid() const
80  {
81  return (0 != id);
82  }
83 
89  cmzn_glyph_id getId() const
90  {
91  return id;
92  }
93 
99  {
100  REPEAT_MODE_INVALID = CMZN_GLYPH_REPEAT_MODE_INVALID,
102  REPEAT_MODE_NONE = CMZN_GLYPH_REPEAT_MODE_NONE,
106  REPEAT_MODE_AXES_2D = CMZN_GLYPH_REPEAT_MODE_AXES_2D,
110  REPEAT_MODE_AXES_3D = CMZN_GLYPH_REPEAT_MODE_AXES_3D,
114  REPEAT_MODE_MIRROR = CMZN_GLYPH_REPEAT_MODE_MIRROR
124  };
125 
126 
132  {
133  SHAPE_TYPE_INVALID = CMZN_GLYPH_SHAPE_TYPE_INVALID,
135  SHAPE_TYPE_NONE = CMZN_GLYPH_SHAPE_TYPE_NONE,
137  SHAPE_TYPE_ARROW = CMZN_GLYPH_SHAPE_TYPE_ARROW,
139  SHAPE_TYPE_ARROW_SOLID = CMZN_GLYPH_SHAPE_TYPE_ARROW_SOLID,
141  SHAPE_TYPE_AXIS = CMZN_GLYPH_SHAPE_TYPE_AXIS,
143  SHAPE_TYPE_AXIS_SOLID = CMZN_GLYPH_SHAPE_TYPE_AXIS_SOLID,
145  SHAPE_TYPE_CONE = CMZN_GLYPH_SHAPE_TYPE_CONE,
147  SHAPE_TYPE_CONE_SOLID = CMZN_GLYPH_SHAPE_TYPE_CONE_SOLID,
149  SHAPE_TYPE_CROSS = CMZN_GLYPH_SHAPE_TYPE_CROSS,
151  SHAPE_TYPE_CUBE_SOLID = CMZN_GLYPH_SHAPE_TYPE_CUBE_SOLID,
153  SHAPE_TYPE_CUBE_WIREFRAME = CMZN_GLYPH_SHAPE_TYPE_CUBE_WIREFRAME,
155  SHAPE_TYPE_CYLINDER = CMZN_GLYPH_SHAPE_TYPE_CYLINDER,
157  SHAPE_TYPE_CYLINDER_SOLID = CMZN_GLYPH_SHAPE_TYPE_CYLINDER_SOLID,
159  SHAPE_TYPE_DIAMOND = CMZN_GLYPH_SHAPE_TYPE_DIAMOND,
161  SHAPE_TYPE_LINE = CMZN_GLYPH_SHAPE_TYPE_LINE,
163  SHAPE_TYPE_POINT = CMZN_GLYPH_SHAPE_TYPE_POINT,
165  SHAPE_TYPE_SHEET = CMZN_GLYPH_SHAPE_TYPE_SHEET,
167  SHAPE_TYPE_SPHERE = CMZN_GLYPH_SHAPE_TYPE_SPHERE,
169  SHAPE_TYPE_AXES = CMZN_GLYPH_SHAPE_TYPE_AXES,
171  SHAPE_TYPE_AXES_123 = CMZN_GLYPH_SHAPE_TYPE_AXES_123,
173  SHAPE_TYPE_AXES_XYZ = CMZN_GLYPH_SHAPE_TYPE_AXES_XYZ,
175  SHAPE_TYPE_AXES_COLOUR = CMZN_GLYPH_SHAPE_TYPE_AXES_COLOUR,
177  SHAPE_TYPE_AXES_SOLID = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID,
179  SHAPE_TYPE_AXES_SOLID_123 = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID_123,
181  SHAPE_TYPE_AXES_SOLID_XYZ = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID_XYZ,
183  SHAPE_TYPE_AXES_SOLID_COLOUR = CMZN_GLYPH_SHAPE_TYPE_AXES_SOLID_COLOUR
185  };
186 
193  char *getName()
194  {
195  return cmzn_glyph_get_name(id);
196  }
197 
204  int setName(const char *name)
205  {
206  return cmzn_glyph_set_name(id, name);
207  }
208 
215  bool isManaged()
216  {
217  return (0 != cmzn_glyph_is_managed(id));
218  }
219 
232  int setManaged(bool value)
233  {
234  return cmzn_glyph_set_managed(id, static_cast<int>(value));
235  }
236 
243  inline GlyphAxes castAxes();
250  inline GlyphColourBar castColourBar();
251 };
252 
253 inline bool operator==(const Glyph& a, const Glyph& b)
254 {
255  return a.getId() == b.getId();
256 }
257 
264 class GlyphAxes : public Glyph
265 {
266 private:
272  inline cmzn_glyph_axes_id getDerivedId()
273  {
274  return reinterpret_cast<cmzn_glyph_axes_id>(id);
275  }
276 
277 public:
278  GlyphAxes() : Glyph(0) {}
279 
280  explicit GlyphAxes(cmzn_glyph_axes_id axes_id)
281  : Glyph(reinterpret_cast<cmzn_glyph_id>(axes_id))
282  {}
283 
289  double getAxisWidth()
290  {
291  return cmzn_glyph_axes_get_axis_width(getDerivedId());
292  }
293 
302  int setAxisWidth(double axisWidth)
303  {
304  return cmzn_glyph_axes_set_axis_width(getDerivedId(), axisWidth);
305  }
306 
314  char *getAxisLabel(int axisNumber)
315  {
316  return cmzn_glyph_axes_get_axis_label(getDerivedId(), axisNumber);
317  }
318 
326  int setAxisLabel(int axisNumber, const char *label)
327  {
328  return cmzn_glyph_axes_set_axis_label(getDerivedId(), axisNumber, label);
329  }
330 
337  Material getAxisMaterial(int axisNumber)
338  {
339  return Material(cmzn_glyph_axes_get_axis_material(getDerivedId(), axisNumber));
340  }
341 
351  int setAxisMaterial(int axisNumber, const Material& material)
352  {
353  return cmzn_glyph_axes_set_axis_material(getDerivedId(), axisNumber, material.getId());
354  }
355 
356 };
357 
359 {
360  return GlyphAxes(cmzn_glyph_cast_axes(id));
361 }
362 
370 class GlyphColourBar : public Glyph
371 {
372 private:
378  inline cmzn_glyph_colour_bar_id getDerivedId()
379  {
380  return reinterpret_cast<cmzn_glyph_colour_bar_id>(id);
381  }
382 
383 public:
384  GlyphColourBar() : Glyph(0) {}
385 
386  explicit GlyphColourBar(cmzn_glyph_colour_bar_id colour_bar_id)
387  : Glyph(reinterpret_cast<cmzn_glyph_id>(colour_bar_id))
388  {}
389 
397  int getAxis(int valuesCount, double *valuesOut)
398  {
399  return cmzn_glyph_colour_bar_get_axis(getDerivedId(), valuesCount, valuesOut);
400  }
401 
412  int setAxis(int valuesCount, const double *valuesIn)
413  {
414  return cmzn_glyph_colour_bar_set_axis(getDerivedId(), valuesCount, valuesIn);
415  }
416 
424  int getCentre(int valuesCount, double *valuesOut)
425  {
426  return cmzn_glyph_colour_bar_get_centre(getDerivedId(), valuesCount, valuesOut);
427  }
428 
440  int setCentre(int valuesCount, const double *valuesIn)
441  {
442  return cmzn_glyph_colour_bar_set_centre(getDerivedId(), valuesCount, valuesIn);
443  }
444 
451  double getExtendLength()
452  {
453  return cmzn_glyph_colour_bar_get_extend_length(getDerivedId());
454  }
455 
464  int setExtendLength(double extendLength)
465  {
466  return cmzn_glyph_colour_bar_set_extend_length(getDerivedId(), extendLength);
467  }
468 
475  {
476  return cmzn_glyph_colour_bar_get_label_divisions(getDerivedId());
477  }
478 
487  int setLabelDivisions(int labelDivisions)
488  {
489  return cmzn_glyph_colour_bar_set_label_divisions(getDerivedId(), labelDivisions);
490  }
491 
498  {
499  return Material(cmzn_glyph_colour_bar_get_label_material(getDerivedId()));
500  }
501 
510  int setLabelMaterial(const Material& material)
511  {
512  return cmzn_glyph_colour_bar_set_label_material(getDerivedId(), material.getId());
513  }
514 
522  {
523  return cmzn_glyph_colour_bar_get_number_format(getDerivedId());
524  }
525 
537  int setNumberFormat(const char *numberFormat)
538  {
539  return cmzn_glyph_colour_bar_set_number_format(getDerivedId(), numberFormat);
540  }
541 
549  int getSideAxis(int valuesCount, double *valuesOut)
550  {
551  return cmzn_glyph_colour_bar_get_side_axis(getDerivedId(), valuesCount, valuesOut);
552  }
553 
565  int setSideAxis(int valuesCount, const double *valuesIn)
566  {
567  return cmzn_glyph_colour_bar_set_side_axis(getDerivedId(), valuesCount, valuesIn);
568  }
569 
575  double getTickLength()
576  {
577  return cmzn_glyph_colour_bar_get_tick_length(getDerivedId());
578  }
579 
588  int setTickLength(double tickLength)
589  {
590  return cmzn_glyph_colour_bar_set_tick_length(getDerivedId(), tickLength);
591  }
592 
593 };
594 
596 {
597  return GlyphColourBar(cmzn_glyph_cast_colour_bar(id));
598 }
599 
606 {
607 private:
608 
609  cmzn_glyphiterator_id id;
610 
611 public:
612 
613  Glyphiterator() : id(0)
614  { }
615 
616  // takes ownership of C handle, responsibility for destroying it
617  explicit Glyphiterator(cmzn_glyphiterator_id iterator_id) :
618  id(iterator_id)
619  { }
620 
621  Glyphiterator(const Glyphiterator& glyphiterator) :
622  id(cmzn_glyphiterator_access(glyphiterator.id))
623  { }
624 
625  Glyphiterator& operator=(const Glyphiterator& glyphiterator)
626  {
627  cmzn_glyphiterator_id temp_id = cmzn_glyphiterator_access(glyphiterator.id);
628  if (0 != id)
629  {
630  cmzn_glyphiterator_destroy(&id);
631  }
632  id = temp_id;
633  return *this;
634  }
635 
636  ~Glyphiterator()
637  {
638  if (0 != id)
639  {
640  cmzn_glyphiterator_destroy(&id);
641  }
642  }
643 
649  bool isValid() const
650  {
651  return (0 != id);
652  }
653 
662  {
663  return Glyph(cmzn_glyphiterator_next(id));
664  }
665 };
666 
676 {
677 protected:
678  cmzn_glyphmodule_id id;
679 
680 public:
681 
682  Glyphmodule() : id(0)
683  { }
684 
685  // takes ownership of C handle, responsibility for destroying it
686  explicit Glyphmodule(cmzn_glyphmodule_id in_glyphmodule_id) :
687  id(in_glyphmodule_id)
688  { }
689 
690  Glyphmodule(const Glyphmodule& glyphModule) :
691  id(cmzn_glyphmodule_access(glyphModule.id))
692  { }
693 
694  Glyphmodule& operator=(const Glyphmodule& glyphModule)
695  {
696  cmzn_glyphmodule_id temp_id = cmzn_glyphmodule_access(glyphModule.id);
697  if (0 != id)
698  {
699  cmzn_glyphmodule_destroy(&id);
700  }
701  id = temp_id;
702  return *this;
703  }
704 
705  ~Glyphmodule()
706  {
707  if (0 != id)
708  {
709  cmzn_glyphmodule_destroy(&id);
710  }
711  }
712 
718  bool isValid() const
719  {
720  return (0 != id);
721  }
722 
728  cmzn_glyphmodule_id getId() const
729  {
730  return id;
731  }
732 
743  {
744  return cmzn_glyphmodule_begin_change(id);
745  }
746 
756  int endChange()
757  {
758  return cmzn_glyphmodule_end_change(id);
759  }
760 
771  GlyphAxes createGlyphAxes(const Glyph& axisGlyph, double axisWidth)
772  {
773  return GlyphAxes(reinterpret_cast<cmzn_glyph_axes_id>(
774  cmzn_glyphmodule_create_glyph_axes(id, axisGlyph.getId(), axisWidth)));
775  }
776 
786  {
787  return GlyphColourBar(reinterpret_cast<cmzn_glyph_colour_bar_id>(
788  cmzn_glyphmodule_create_glyph_colour_bar(id, spectrum.getId())));
789  }
790 
804  {
805  return Glyphiterator(cmzn_glyphmodule_create_glyphiterator(id));
806  }
807 
852  {
853  return cmzn_glyphmodule_define_standard_glyphs(id);
854  }
855 
862  Glyph findGlyphByName(const char *name)
863  {
864  return Glyph(cmzn_glyphmodule_find_glyph_by_name(id, name));
865  }
866 
874  {
875  return Glyph(cmzn_glyphmodule_find_glyph_by_glyph_shape_type(id, static_cast<cmzn_glyph_shape_type>(glyphShapeType)));
876  }
877 
884  {
885  return Glyph(cmzn_glyphmodule_get_default_point_glyph(id));
886  }
887 
894  int setDefaultPointGlyph(const Glyph& glyph)
895  {
896  return cmzn_glyphmodule_set_default_point_glyph(id, glyph.getId());
897  }
898 
907  inline Glyph createStaticGlyphFromGraphics(const Graphics& graphics);
908 
909 };
910 
912 {
913  return Glyphmodule(cmzn_context_get_glyphmodule(id));
914 }
915 
916 } // namespace Zinc
917 }
918 
919 #endif
Material getAxisMaterial(int axisNumber)
Definition: glyph.hpp:337
char * getAxisLabel(int axisNumber)
Definition: glyph.hpp:314
A specialised glyph type which renders 3-D axes.
Definition: glyph.hpp:264
int endChange()
Definition: glyph.hpp:756
bool isManaged()
Definition: glyph.hpp:215
int defineStandardGlyphs()
Definition: glyph.hpp:851
GlyphColourBar castColourBar()
Definition: glyph.hpp:595
Glyph createStaticGlyphFromGraphics(const Graphics &graphics)
Definition: graphics.hpp:1853
Glyph findGlyphByGlyphShapeType(Glyph::ShapeType glyphShapeType)
Definition: glyph.hpp:873
double getTickLength()
Definition: glyph.hpp:575
cmzn_material_id getId() const
Definition: material.hpp:83
RepeatMode
Definition: glyph.hpp:98
Glyphmodule getGlyphmodule()
Definition: glyph.hpp:911
GlyphAxes createGlyphAxes(const Glyph &axisGlyph, double axisWidth)
Definition: glyph.hpp:771
int getAxis(int valuesCount, double *valuesOut)
Definition: glyph.hpp:397
Base graphics type: produces 3-D graphics visualising domains and fields.
Definition: graphics.hpp:45
cmzn_spectrum_id getId() const
Definition: spectrum.hpp:638
int setManaged(bool value)
Definition: glyph.hpp:232
A glyph is a static graphics object used to visualise a point in space.
Definition: glyph.hpp:36
Glyph findGlyphByName(const char *name)
Definition: glyph.hpp:862
int setAxisMaterial(int axisNumber, const Material &material)
Definition: glyph.hpp:351
Zinc materials specify colouring of graphics.
Definition: material.hpp:29
int getSideAxis(int valuesCount, double *valuesOut)
Definition: glyph.hpp:549
cmzn_glyphmodule_id getId() const
Definition: glyph.hpp:728
int setAxisWidth(double axisWidth)
Definition: glyph.hpp:302
int setDefaultPointGlyph(const Glyph &glyph)
Definition: glyph.hpp:894
int setNumberFormat(const char *numberFormat)
Definition: glyph.hpp:537
int setLabelDivisions(int labelDivisions)
Definition: glyph.hpp:487
bool isValid() const
Definition: glyph.hpp:718
char * getNumberFormat()
Definition: glyph.hpp:521
char * getName()
Definition: glyph.hpp:193
Zinc Spectrum maps values of graphics data fields to colours.
Definition: spectrum.hpp:581
int beginChange()
Definition: glyph.hpp:742
ShapeType
Definition: glyph.hpp:131
bool isValid() const
Definition: glyph.hpp:649
double getExtendLength()
Definition: glyph.hpp:451
Module managing all glyphs.
Definition: glyph.hpp:675
A specialised glyph type which draws a cylindrical colour bar.
Definition: glyph.hpp:370
double getAxisWidth()
Definition: glyph.hpp:289
int setAxisLabel(int axisNumber, const char *label)
Definition: glyph.hpp:326
An iterator for looping through all the glyphs in a glyphmodule.
Definition: glyph.hpp:605
Material getLabelMaterial()
Definition: glyph.hpp:497
int getCentre(int valuesCount, double *valuesOut)
Definition: glyph.hpp:424
int setCentre(int valuesCount, const double *valuesIn)
Definition: glyph.hpp:440
Glyphiterator createGlyphiterator()
Definition: glyph.hpp:803
Glyph next()
Definition: glyph.hpp:661
GlyphColourBar createGlyphColourBar(const Spectrum &spectrum)
Definition: glyph.hpp:785
int setSideAxis(int valuesCount, const double *valuesIn)
Definition: glyph.hpp:565
int setExtendLength(double extendLength)
Definition: glyph.hpp:464
GlyphAxes castAxes()
Definition: glyph.hpp:358
int setTickLength(double tickLength)
Definition: glyph.hpp:588
Glyph getDefaultPointGlyph()
Definition: glyph.hpp:883
cmzn_glyph_id getId() const
Definition: glyph.hpp:89
int getLabelDivisions()
Definition: glyph.hpp:474
int setLabelMaterial(const Material &material)
Definition: glyph.hpp:510
bool isValid() const
Definition: glyph.hpp:79
int setName(const char *name)
Definition: glyph.hpp:204
int setAxis(int valuesCount, const double *valuesIn)
Definition: glyph.hpp:412