CiftiLib
A C++ library for CIFTI-2 and CIFTI-1 files
Label.h
1 #ifndef __LABEL_H__
2 #define __LABEL_H__
3 
4 /*LICENSE_START*/
5 /*
6  * Copyright (c) 2014, Washington University School of Medicine
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "Common/AString.h"
32 
33 #include <stdint.h>
34 
35 namespace cifti {
36 
37  class GroupAndNameHierarchyItem;
38 
39  class Label {
40 
41  public:
42  Label(
43  const int32_t key,
44  const AString& name);
45 
46  explicit Label(
47  const int32_t key,
48  const AString& name,
49  const float red,
50  const float green,
51  const float blue,
52  const float alpha);
53 
54  explicit Label(
55  const int32_t key,
56  const AString& name,
57  const double red,
58  const double green,
59  const double blue,
60  const double alpha);
61 
62  Label(
63  const int32_t key,
64  const AString& name,
65  const float rgba[]);
66 
67  explicit Label(
68  const int32_t key,
69  const AString& name,
70  const int32_t red,
71  const int32_t green,
72  const int32_t blue,
73  const int32_t alpha);
74 
75  Label(
76  const int32_t key,
77  const AString& name,
78  const int32_t rgba[]);
79 
80  Label(const int32_t key);
81 
82  Label(const Label& gl);
83 
84  public:
85  Label& operator=(const Label& gl);
86 
87  virtual ~Label();
88 
89  private:
90  void copyHelper(const Label& o);
91 
92  void initializeMembersLabel();
93 
94  public:
95  int32_t hashCode();
96 
97  bool equals(const Label&);
98 
99  int32_t operator<(const Label& gl);
100 
101  int32_t getKey() const;
102 
103  void setKey(const int32_t key);
104 
105  AString getName() const;
106 
107  void setName(const AString& name);
108 
109  bool isSelected() const;
110 
111  void setSelected(const bool selected);
112 
113  float* getColor() const;
114 
115  void getColor(float rgbaOut[]) const;
116 
117  void setColor(const float rgba[]);
118 
119  int32_t* getColorInt() const;
120 
121  void setColorInt(const int32_t rgba[]);
122 
123  static void getDefaultColor(float rgbaOut[4]);
124 
125  float getRed() const;
126 
127  float getGreen() const;
128 
129  float getBlue() const;
130 
131  float getAlpha() const;
132 
133  bool matches(const Label& rhs, const bool checkColor = false) const;
134 
138  static inline int32_t getInvalidLabelKey() { return s_invalidLabelKey; }
139 
140  private:
141  AString name;
142 
143  int32_t key;
144 
145  bool selected;
146 
147  float red;
148 
149  float green;
150 
151  float blue;
152 
153  float alpha;
154 
156  const static int32_t s_invalidLabelKey;
157  };
158 
159 } // namespace
160 
161 #endif // __LABEL_H__
cifti::Label::getInvalidLabelKey
static int32_t getInvalidLabelKey()
Definition: Label.h:138
cifti::Label::operator<
int32_t operator<(const Label &gl)
Definition: Label.cxx:274
cifti::Label::getKey
int32_t getKey() const
Definition: Label.cxx:285
cifti::Label::equals
bool equals(const Label &)
Definition: Label.cxx:261
cifti::Label::getAlpha
float getAlpha() const
Definition: Label.cxx:485
cifti::Label
Definition: Label.h:39
cifti::Label::setColorInt
void setColorInt(const int32_t rgba[])
Definition: Label.cxx:422
cifti::Label::getRed
float getRed() const
Definition: Label.cxx:452
cifti::Label::setSelected
void setSelected(const bool selected)
Definition: Label.cxx:344
cifti::Label::isSelected
bool isSelected() const
Definition: Label.cxx:332
cifti::Label::getColorInt
int32_t * getColorInt() const
Definition: Label.cxx:406
cifti::Label::getBlue
float getBlue() const
Definition: Label.cxx:474
cifti::Label::setKey
void setKey(const int32_t key)
Definition: Label.cxx:298
cifti::Label::getName
AString getName() const
Definition: Label.cxx:309
cifti::Label::getGreen
float getGreen() const
Definition: Label.cxx:463
cifti::Label::getDefaultColor
static void getDefaultColor(float rgbaOut[4])
Definition: Label.cxx:438
cifti::Label::setName
void setName(const AString &name)
Definition: Label.cxx:320
cifti::Label::getColor
float * getColor() const
Definition: Label.cxx:358
cifti::Label::setColor
void setColor(const float rgba[])
Definition: Label.cxx:391
cifti
namespace for all CiftiLib functionality
Definition: CiftiBrainModelsMap.h:42
cifti::Label::Label
Label(const int32_t key, const AString &name)
Definition: Label.cxx:45