OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
spectrum.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_SPECTRUM_HPP__
10 #define CMZN_SPECTRUM_HPP__
11 
12 #include "zinc/spectrum.h"
13 #include "zinc/context.hpp"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
29 {
30 protected:
31  cmzn_spectrumcomponent_id id;
32 
33 public:
34 
36  id(0)
37  {
38  }
39 
40  // takes ownership of C handle, responsibility for destroying it
41  explicit Spectrumcomponent(
42  cmzn_spectrumcomponent_id in_spectrumcomponent_id) :
43  id(in_spectrumcomponent_id)
44  {
45  }
46 
47  Spectrumcomponent(const Spectrumcomponent& spectrumComponent) :
48  id(cmzn_spectrumcomponent_access(spectrumComponent.id))
49  {
50  }
51 
52  Spectrumcomponent& operator=(const Spectrumcomponent& spectrumComponent)
53  {
54  cmzn_spectrumcomponent_id temp_id = cmzn_spectrumcomponent_access(
55  spectrumComponent.id);
56  if (0 != id)
57  {
58  cmzn_spectrumcomponent_destroy(&id);
59  }
60  id = temp_id;
61  return *this;
62  }
63 
65  {
66  if (0 != id)
67  {
68  cmzn_spectrumcomponent_destroy(&id);
69  }
70  }
71 
77  bool isValid() const
78  {
79  return (0 != id);
80  }
81 
85  enum ScaleType
86  {
87  SCALE_TYPE_INVALID = CMZN_SPECTRUMCOMPONENT_SCALE_TYPE_INVALID,
89  SCALE_TYPE_LINEAR = CMZN_SPECTRUMCOMPONENT_SCALE_TYPE_LINEAR,
95  SCALE_TYPE_LOG = CMZN_SPECTRUMCOMPONENT_SCALE_TYPE_LOG
100  };
101 
108  {
109  COLOUR_MAPPING_TYPE_INVALID = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_INVALID,
111  COLOUR_MAPPING_TYPE_ALPHA = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_ALPHA,
118  COLOUR_MAPPING_TYPE_BANDED = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_BANDED,
127  COLOUR_MAPPING_TYPE_BLUE = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_BLUE,
130  COLOUR_MAPPING_TYPE_GREEN = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_GREEN,
133  COLOUR_MAPPING_TYPE_MONOCHROME = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_MONOCHROME,
136  COLOUR_MAPPING_TYPE_RAINBOW = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_RAINBOW,
142  COLOUR_MAPPING_TYPE_RED = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_RED,
145  COLOUR_MAPPING_TYPE_STEP = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_STEP,
150  COLOUR_MAPPING_TYPE_WHITE_TO_BLUE = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_WHITE_TO_BLUE,
153  COLOUR_MAPPING_TYPE_WHITE_TO_RED = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_WHITE_TO_RED,
156  COLOUR_MAPPING_TYPE_WHITE_TO_GREEN = CMZN_SPECTRUMCOMPONENT_COLOUR_MAPPING_TYPE_WHITE_TO_GREEN
159  };
160 
166  cmzn_spectrumcomponent_id getId() const
167  {
168  return id;
169  }
170 
179  {
180  return cmzn_spectrumcomponent_get_range_minimum(id);
181  }
182 
192  int setRangeMinimum(double value)
193  {
194  return cmzn_spectrumcomponent_set_range_minimum(id, value);
195  }
196 
205  {
206  return cmzn_spectrumcomponent_get_range_maximum(id);
207  }
208 
218  int setRangeMaximum(double value)
219  {
220  return cmzn_spectrumcomponent_set_range_maximum(id, value);
221  }
222 
231  {
232  return cmzn_spectrumcomponent_get_colour_minimum(id);
233  }
234 
246  int setColourMinimum(double value)
247  {
248  return cmzn_spectrumcomponent_set_colour_minimum(id,value);
249  }
250 
259  {
260  return cmzn_spectrumcomponent_get_colour_maximum(id);
261  }
262 
274  int setColourMaximum(double value)
275  {
276  return cmzn_spectrumcomponent_set_colour_maximum(id, value);
277  }
278 
287  double getStepValue()
288  {
289  return cmzn_spectrumcomponent_get_step_value(id);
290  }
291 
301  int setStepValue(double value)
302  {
303  return cmzn_spectrumcomponent_set_step_value(id, value);
304  }
305 
314  {
315  return cmzn_spectrumcomponent_get_exaggeration(id);
316  }
317 
326  int setExaggeration(double value)
327  {
328  return cmzn_spectrumcomponent_set_exaggeration(id, value);
329  }
330 
339  double getBandedRatio()
340  {
341  return cmzn_spectrumcomponent_get_banded_ratio(id);
342  }
343 
353  int setBandedRatio(double value)
354  {
355  return cmzn_spectrumcomponent_set_banded_ratio(id, value);
356  }
357 
365  bool isActive()
366  {
367  return cmzn_spectrumcomponent_is_active(id);
368  }
369 
378  int setActive(bool active)
379  {
380  return cmzn_spectrumcomponent_set_active(id, active);
381  }
382 
391  {
392  return cmzn_spectrumcomponent_is_colour_reverse(id);
393  }
394 
403  int setColourReverse(bool reverse)
404  {
405  return cmzn_spectrumcomponent_set_colour_reverse(id, reverse);
406  }
407 
417  {
418  return cmzn_spectrumcomponent_is_extend_above(id);
419  }
420 
432  int setExtendAbove(bool extend_above)
433  {
434  return cmzn_spectrumcomponent_set_extend_above(id, extend_above);
435  }
436 
446  {
447  return cmzn_spectrumcomponent_is_extend_below(id);
448  }
449 
461  int setExtendBelow(bool extend_below)
462  {
463  return cmzn_spectrumcomponent_set_extend_below(id, extend_below);
464  }
465 
476  {
477  return cmzn_spectrumcomponent_get_field_component(id);
478  }
479 
490  int setFieldComponent(int componentNumber)
491  {
492  return cmzn_spectrumcomponent_set_field_component(id,
493  componentNumber);
494  }
495 
505  {
506  return cmzn_spectrumcomponent_get_number_of_bands(id);
507  }
508 
518  int setNumberOfBands(int numberOfBands)
519  {
520  return cmzn_spectrumcomponent_set_number_of_bands(id, numberOfBands);
521  }
522 
523  ScaleType getScaleType()
524  {
525  return static_cast<ScaleType>(cmzn_spectrumcomponent_get_scale_type(
526  id));
527  }
528 
537  int setScaleType(ScaleType scaleType)
538  {
539  return cmzn_spectrumcomponent_set_scale_type(id,
540  static_cast<cmzn_spectrumcomponent_scale_type>(scaleType));
541  }
542 
552  {
553  return static_cast<ColourMappingType>(cmzn_spectrumcomponent_get_colour_mapping_type(
554  id));
555  }
556 
566  {
567  return cmzn_spectrumcomponent_set_colour_mapping_type(id,
568  static_cast<cmzn_spectrumcomponent_colour_mapping_type>(colourMapping));
569  }
570 
571 };
572 
581 class Spectrum
582 {
583 protected:
584  cmzn_spectrum_id id;
585 
586 public:
587 
588  Spectrum() :
589  id(0)
590  {
591  }
592 
593  // takes ownership of C handle, responsibility for destroying it
594  explicit Spectrum(cmzn_spectrum_id in_spectrum_id) :
595  id(in_spectrum_id)
596  {
597  }
598 
599  Spectrum(const Spectrum& spectrum) :
600  id(cmzn_spectrum_access(spectrum.id))
601  {
602  }
603 
604  Spectrum& operator=(const Spectrum& spectrum)
605  {
606  cmzn_spectrum_id temp_id = cmzn_spectrum_access(spectrum.id);
607  if (0 != id)
608  {
609  cmzn_spectrum_destroy(&id);
610  }
611  id = temp_id;
612  return *this;
613  }
614 
615  ~Spectrum()
616  {
617  if (0 != id)
618  {
619  cmzn_spectrum_destroy(&id);
620  }
621  }
622 
628  bool isValid() const
629  {
630  return (0 != id);
631  }
632 
638  cmzn_spectrum_id getId() const
639  {
640  return id;
641  }
642 
649  bool isManaged()
650  {
651  return cmzn_spectrum_is_managed(id);
652  }
653 
663  int setManaged(bool value)
664  {
665  return cmzn_spectrum_set_managed(id, value);
666  }
667 
678  {
679  return cmzn_spectrum_begin_change(id);
680  }
681 
690  int endChange()
691  {
692  return cmzn_spectrum_end_change(id);
693  }
694 
701  char *getName()
702  {
703  return cmzn_spectrum_get_name(id);
704  }
705 
713  int setName(const char *name)
714  {
715  return cmzn_spectrum_set_name(id, name);
716  }
717 
724  {
725  return cmzn_spectrum_get_number_of_spectrumcomponents(id);
726  }
727 
734  {
735  return Spectrumcomponent(cmzn_spectrum_create_spectrumcomponent(id));
736  }
737 
744  {
745  return Spectrumcomponent(cmzn_spectrum_get_first_spectrumcomponent(id));
746  }
747 
755  {
756  return Spectrumcomponent(
757  cmzn_spectrum_get_next_spectrumcomponent(id, refComponent.getId()));
758  }
759 
767  {
768  return Spectrumcomponent(
769  cmzn_spectrum_get_previous_spectrumcomponent(id, refComponent.getId()));
770  }
771 
782  const Spectrumcomponent& refComponent)
783  {
784  return cmzn_spectrum_move_spectrumcomponent_before(id, component.getId(),
785  refComponent.getId());
786  }
787 
799  {
800  return cmzn_spectrum_remove_spectrumcomponent(id, component.getId());
801  }
802 
811  {
812  return cmzn_spectrum_remove_all_spectrumcomponents(id);
813  }
814 
825  {
826  return cmzn_spectrum_is_material_overwrite(id);
827  }
828 
835  int setMaterialOverwrite(bool overwrite)
836  {
837  return cmzn_spectrum_set_material_overwrite(id, overwrite);
838  }
839 
840 };
841 
842 inline bool operator==(const Spectrum& a, const Spectrum& b)
843 {
844  return a.getId() == b.getId();
845 }
846 
855 {
856 private:
857 
858  cmzn_spectrumiterator_id id;
859 
860 public:
861 
862  Spectrumiterator() : id(0)
863  { }
864 
865  // takes ownership of C handle, responsibility for destroying it
866  explicit Spectrumiterator(cmzn_spectrumiterator_id iterator_id) :
867  id(iterator_id)
868  { }
869 
870  Spectrumiterator(const Spectrumiterator& spectrumiterator) :
871  id(cmzn_spectrumiterator_access(spectrumiterator.id))
872  { }
873 
874  Spectrumiterator& operator=(const Spectrumiterator& spectrumiterator)
875  {
876  cmzn_spectrumiterator_id temp_id = cmzn_spectrumiterator_access(spectrumiterator.id);
877  if (0 != id)
878  {
879  cmzn_spectrumiterator_destroy(&id);
880  }
881  id = temp_id;
882  return *this;
883  }
884 
886  {
887  if (0 != id)
888  {
889  cmzn_spectrumiterator_destroy(&id);
890  }
891  }
892 
898  bool isValid() const
899  {
900  return (0 != id);
901  }
902 
912  {
913  return Spectrum(cmzn_spectrumiterator_next(id));
914  }
915 };
916 
923 {
924 protected:
925  cmzn_spectrummodule_id id;
926 
927 public:
928 
929  Spectrummodule() :
930  id(0)
931  {
932  }
933 
934  // takes ownership of C handle, responsibility for destroying it
935  explicit Spectrummodule(cmzn_spectrummodule_id in_spectrummodule_id) :
936  id(in_spectrummodule_id)
937  {
938  }
939 
940  Spectrummodule(const Spectrummodule& spectrummodule) :
941  id(cmzn_spectrummodule_access(spectrummodule.id))
942  {
943  }
944 
945  Spectrummodule& operator=(const Spectrummodule& spectrummodule)
946  {
947  cmzn_spectrummodule_id temp_id = cmzn_spectrummodule_access(
948  spectrummodule.id);
949  if (0 != id)
950  {
951  cmzn_spectrummodule_destroy(&id);
952  }
953  id = temp_id;
954  return *this;
955  }
956 
957  ~Spectrummodule()
958  {
959  if (0 != id)
960  {
961  cmzn_spectrummodule_destroy(&id);
962  }
963  }
964 
970  bool isValid() const
971  {
972  return (0 != id);
973  }
974 
980  cmzn_spectrummodule_id getId() const
981  {
982  return id;
983  }
984 
992  {
993  return Spectrum(cmzn_spectrummodule_create_spectrum(id));
994  }
995 
1009  {
1010  return Spectrumiterator(cmzn_spectrummodule_create_spectrumiterator(id));
1011  }
1012 
1019  Spectrum findSpectrumByName(const char *name)
1020  {
1021  return Spectrum(cmzn_spectrummodule_find_spectrum_by_name(id, name));
1022  }
1023 
1034  {
1035  return cmzn_spectrummodule_begin_change(id);
1036  }
1037 
1048  {
1049  return cmzn_spectrummodule_end_change(id);
1050  }
1051 
1061  {
1062  return Spectrum(cmzn_spectrummodule_get_default_spectrum(id));
1063  }
1064 
1071  int setDefaultSpectrum(const Spectrum& spectrum)
1072  {
1073  return cmzn_spectrummodule_set_default_spectrum(id, spectrum.getId());
1074  }
1075 };
1076 
1078 {
1079  return Spectrummodule(cmzn_context_get_spectrummodule(id));
1080 }
1081 
1082 } // namespace Zinc
1083 }
1084 
1085 #endif
Maps a single component of a data field to colour in a spectrum.
Definition: spectrum.hpp:28
int setFieldComponent(int componentNumber)
Definition: spectrum.hpp:490
Spectrumiterator createSpectrumiterator()
Definition: spectrum.hpp:1008
bool isExtendBelow()
Definition: spectrum.hpp:445
Spectrumcomponent getNextSpectrumcomponent(const Spectrumcomponent &refComponent)
Definition: spectrum.hpp:754
int setColourReverse(bool reverse)
Definition: spectrum.hpp:403
int setRangeMinimum(double value)
Definition: spectrum.hpp:192
Spectrum findSpectrumByName(const char *name)
Definition: spectrum.hpp:1019
int setColourMinimum(double value)
Definition: spectrum.hpp:246
double getRangeMinimum()
Definition: spectrum.hpp:178
int getNumberOfBands()
Definition: spectrum.hpp:504
ColourMappingType
Definition: spectrum.hpp:107
int getNumberOfSpectrumcomponents()
Definition: spectrum.hpp:723
int setScaleType(ScaleType scaleType)
Definition: spectrum.hpp:537
Spectrumcomponent createSpectrumcomponent()
Definition: spectrum.hpp:733
int beginChange()
Definition: spectrum.hpp:1033
Spectrumcomponent getFirstSpectrumcomponent()
Definition: spectrum.hpp:743
ScaleType
Definition: spectrum.hpp:85
Spectrumcomponent getPreviousSpectrumcomponent(const Spectrumcomponent &refComponent)
Definition: spectrum.hpp:766
int endChange()
Definition: spectrum.hpp:1047
double getColourMinimum()
Definition: spectrum.hpp:230
int setExtendAbove(bool extend_above)
Definition: spectrum.hpp:432
int setColourMaximum(double value)
Definition: spectrum.hpp:274
cmzn_spectrum_id getId() const
Definition: spectrum.hpp:638
Spectrum getDefaultSpectrum()
Definition: spectrum.hpp:1060
int setExtendBelow(bool extend_below)
Definition: spectrum.hpp:461
int removeAllSpectrumcomponents()
Definition: spectrum.hpp:810
Spectrum createSpectrum()
Definition: spectrum.hpp:991
int beginChange()
Definition: spectrum.hpp:677
bool isMaterialOverwrite()
Definition: spectrum.hpp:824
Spectrum next()
Definition: spectrum.hpp:911
ColourMappingType getColourMappingType()
Definition: spectrum.hpp:551
double getRangeMaximum()
Definition: spectrum.hpp:204
int setMaterialOverwrite(bool overwrite)
Definition: spectrum.hpp:835
cmzn_spectrumcomponent_id getId() const
Definition: spectrum.hpp:166
double getColourMaximum()
Definition: spectrum.hpp:258
int setExaggeration(double value)
Definition: spectrum.hpp:326
int setNumberOfBands(int numberOfBands)
Definition: spectrum.hpp:518
int setManaged(bool value)
Definition: spectrum.hpp:663
bool isValid() const
Definition: spectrum.hpp:898
int endChange()
Definition: spectrum.hpp:690
Module managing all spectrums.
Definition: spectrum.hpp:922
int setActive(bool active)
Definition: spectrum.hpp:378
Zinc Spectrum maps values of graphics data fields to colours.
Definition: spectrum.hpp:581
char * getName()
Definition: spectrum.hpp:701
An iterator for looping through all the spectrums in a spectrum module.
Definition: spectrum.hpp:854
int getFieldComponent()
Definition: spectrum.hpp:475
bool isValid() const
Definition: spectrum.hpp:970
int setName(const char *name)
Definition: spectrum.hpp:713
int removeSpectrumcomponent(const Spectrumcomponent &component)
Definition: spectrum.hpp:798
bool isExtendAbove()
Definition: spectrum.hpp:416
double getStepValue()
Definition: spectrum.hpp:287
int moveSpectrumcomponentBefore(const Spectrumcomponent &component, const Spectrumcomponent &refComponent)
Definition: spectrum.hpp:781
int setColourMappingType(ColourMappingType colourMapping)
Definition: spectrum.hpp:565
int setStepValue(double value)
Definition: spectrum.hpp:301
bool isValid() const
Definition: spectrum.hpp:77
bool isValid() const
Definition: spectrum.hpp:628
bool isColourReverse()
Definition: spectrum.hpp:390
double getExaggeration()
Definition: spectrum.hpp:313
Spectrummodule getSpectrummodule()
Definition: spectrum.hpp:1077
int setDefaultSpectrum(const Spectrum &spectrum)
Definition: spectrum.hpp:1071
double getBandedRatio()
Definition: spectrum.hpp:339
int setBandedRatio(double value)
Definition: spectrum.hpp:353
cmzn_spectrummodule_id getId() const
Definition: spectrum.hpp:980
int setRangeMaximum(double value)
Definition: spectrum.hpp:218
bool isManaged()
Definition: spectrum.hpp:649
bool isActive()
Definition: spectrum.hpp:365