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 
244  int setColourMinimum(double value)
245  {
246  return cmzn_spectrumcomponent_set_colour_minimum(id,value);
247  }
248 
257  {
258  return cmzn_spectrumcomponent_get_colour_maximum(id);
259  }
260 
270  int setColourMaximum(double value)
271  {
272  return cmzn_spectrumcomponent_set_colour_maximum(id, value);
273  }
274 
283  double getStepValue()
284  {
285  return cmzn_spectrumcomponent_get_step_value(id);
286  }
287 
297  int setStepValue(double value)
298  {
299  return cmzn_spectrumcomponent_set_step_value(id, value);
300  }
301 
310  {
311  return cmzn_spectrumcomponent_get_exaggeration(id);
312  }
313 
322  int setExaggeration(double value)
323  {
324  return cmzn_spectrumcomponent_set_exaggeration(id, value);
325  }
326 
335  double getBandedRatio()
336  {
337  return cmzn_spectrumcomponent_get_banded_ratio(id);
338  }
339 
349  int setBandedRatio(double value)
350  {
351  return cmzn_spectrumcomponent_set_banded_ratio(id, value);
352  }
353 
361  bool isActive()
362  {
363  return cmzn_spectrumcomponent_is_active(id);
364  }
365 
374  int setActive(bool active)
375  {
376  return cmzn_spectrumcomponent_set_active(id, active);
377  }
378 
387  {
388  return cmzn_spectrumcomponent_is_colour_reverse(id);
389  }
390 
399  int setColourReverse(bool reverse)
400  {
401  return cmzn_spectrumcomponent_set_colour_reverse(id, reverse);
402  }
403 
413  {
414  return cmzn_spectrumcomponent_is_extend_above(id);
415  }
416 
426  int setExtendAbove(bool extend_above)
427  {
428  return cmzn_spectrumcomponent_set_extend_above(id, extend_above);
429  }
430 
440  {
441  return cmzn_spectrumcomponent_is_extend_below(id);
442  }
443 
453  int setExtendBelow(bool extend_below)
454  {
455  return cmzn_spectrumcomponent_set_extend_below(id, extend_below);
456  }
457 
468  {
469  return cmzn_spectrumcomponent_get_field_component(id);
470  }
471 
482  int setFieldComponent(int componentNumber)
483  {
484  return cmzn_spectrumcomponent_set_field_component(id,
485  componentNumber);
486  }
487 
497  {
498  return cmzn_spectrumcomponent_get_number_of_bands(id);
499  }
500 
510  int setNumberOfBands(int numberOfBands)
511  {
512  return cmzn_spectrumcomponent_set_number_of_bands(id, numberOfBands);
513  }
514 
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 
848 {
849 protected:
850  cmzn_spectrummodule_id id;
851 
852 public:
853 
854  Spectrummodule() :
855  id(0)
856  {
857  }
858 
859  // takes ownership of C handle, responsibility for destroying it
860  explicit Spectrummodule(cmzn_spectrummodule_id in_spectrummodule_id) :
861  id(in_spectrummodule_id)
862  {
863  }
864 
865  Spectrummodule(const Spectrummodule& spectrummodule) :
866  id(cmzn_spectrummodule_access(spectrummodule.id))
867  {
868  }
869 
870  Spectrummodule& operator=(const Spectrummodule& spectrummodule)
871  {
872  cmzn_spectrummodule_id temp_id = cmzn_spectrummodule_access(
873  spectrummodule.id);
874  if (0 != id)
875  {
876  cmzn_spectrummodule_destroy(&id);
877  }
878  id = temp_id;
879  return *this;
880  }
881 
882  ~Spectrummodule()
883  {
884  if (0 != id)
885  {
886  cmzn_spectrummodule_destroy(&id);
887  }
888  }
889 
895  bool isValid() const
896  {
897  return (0 != id);
898  }
899 
905  cmzn_spectrummodule_id getId() const
906  {
907  return id;
908  }
909 
917  {
918  return Spectrum(cmzn_spectrummodule_create_spectrum(id));
919  }
920 
927  Spectrum findSpectrumByName(const char *name)
928  {
929  return Spectrum(cmzn_spectrummodule_find_spectrum_by_name(id, name));
930  }
931 
942  {
943  return cmzn_spectrummodule_begin_change(id);
944  }
945 
955  int endChange()
956  {
957  return cmzn_spectrummodule_end_change(id);
958  }
959 
970  {
971  return Spectrum(cmzn_spectrummodule_get_default_spectrum(id));
972  }
973 
980  int setDefaultSpectrum(const Spectrum& spectrum)
981  {
982  return cmzn_spectrummodule_set_default_spectrum(id, spectrum.getId());
983  }
984 };
985 
987 {
988  return Spectrummodule(cmzn_context_get_spectrummodule(id));
989 }
990 
991 } // namespace Zinc
992 }
993 
994 #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:482
bool isExtendBelow()
Definition: spectrum.hpp:439
Spectrumcomponent getNextSpectrumcomponent(const Spectrumcomponent &refComponent)
Definition: spectrum.hpp:754
int setColourReverse(bool reverse)
Definition: spectrum.hpp:399
int setRangeMinimum(double value)
Definition: spectrum.hpp:192
Spectrum findSpectrumByName(const char *name)
Definition: spectrum.hpp:927
int setColourMinimum(double value)
Definition: spectrum.hpp:244
double getRangeMinimum()
Definition: spectrum.hpp:178
int getNumberOfBands()
Definition: spectrum.hpp:496
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:941
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:955
double getColourMinimum()
Definition: spectrum.hpp:230
int setExtendAbove(bool extend_above)
Definition: spectrum.hpp:426
int setColourMaximum(double value)
Definition: spectrum.hpp:270
cmzn_spectrum_id getId() const
Definition: spectrum.hpp:638
Spectrum getDefaultSpectrum()
Definition: spectrum.hpp:969
int setExtendBelow(bool extend_below)
Definition: spectrum.hpp:453
int removeAllSpectrumcomponents()
Definition: spectrum.hpp:810
Spectrum createSpectrum()
Definition: spectrum.hpp:916
int beginChange()
Definition: spectrum.hpp:677
bool isMaterialOverwrite()
Definition: spectrum.hpp:824
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:256
int setExaggeration(double value)
Definition: spectrum.hpp:322
int setNumberOfBands(int numberOfBands)
Definition: spectrum.hpp:510
int setManaged(bool value)
Definition: spectrum.hpp:663
int endChange()
Definition: spectrum.hpp:690
Module managing all spectrums.
Definition: spectrum.hpp:847
int setActive(bool active)
Definition: spectrum.hpp:374
Zinc Spectrum maps values of graphics data fields to colours.
Definition: spectrum.hpp:581
char * getName()
Definition: spectrum.hpp:701
int getFieldComponent()
Definition: spectrum.hpp:467
ScaleType getScaleType()
Definition: spectrum.hpp:523
bool isValid() const
Definition: spectrum.hpp:895
int setName(const char *name)
Definition: spectrum.hpp:713
int removeSpectrumcomponent(const Spectrumcomponent &component)
Definition: spectrum.hpp:798
bool isExtendAbove()
Definition: spectrum.hpp:412
double getStepValue()
Definition: spectrum.hpp:283
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:297
bool isValid() const
Definition: spectrum.hpp:77
bool isValid() const
Definition: spectrum.hpp:628
bool isColourReverse()
Definition: spectrum.hpp:386
double getExaggeration()
Definition: spectrum.hpp:309
Spectrummodule getSpectrummodule()
Definition: spectrum.hpp:986
int setDefaultSpectrum(const Spectrum &spectrum)
Definition: spectrum.hpp:980
double getBandedRatio()
Definition: spectrum.hpp:335
int setBandedRatio(double value)
Definition: spectrum.hpp:349
cmzn_spectrummodule_id getId() const
Definition: spectrum.hpp:905
int setRangeMaximum(double value)
Definition: spectrum.hpp:218
bool isManaged()
Definition: spectrum.hpp:649
bool isActive()
Definition: spectrum.hpp:361