Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
507e5ad8
Commit
507e5ad8
authored
5 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add name and doc
parent
fe8243ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SimoxUtility/color/ColorMap.cpp
+12
-2
12 additions, 2 deletions
SimoxUtility/color/ColorMap.cpp
SimoxUtility/color/ColorMap.h
+37
-0
37 additions, 0 deletions
SimoxUtility/color/ColorMap.h
with
49 additions
and
2 deletions
SimoxUtility/color/ColorMap.cpp
+
12
−
2
View file @
507e5ad8
...
...
@@ -8,7 +8,16 @@ namespace simox::color
{
}
ColorMap
::
ColorMap
(
std
::
initializer_list
<
Color
>
init
)
ColorMap
::
ColorMap
(
std
::
initializer_list
<
Color
>
init
)
:
ColorMap
(
""
,
init
)
{
}
ColorMap
::
ColorMap
(
std
::
initializer_list
<
std
::
pair
<
float
,
Color
>
>
init
)
:
ColorMap
(
""
,
init
)
{
}
ColorMap
::
ColorMap
(
const
std
::
string
&
name
,
std
::
initializer_list
<
Color
>
init
)
:
_name
(
name
)
{
if
(
init
.
size
()
==
1
)
{
...
...
@@ -25,7 +34,8 @@ namespace simox::color
}
}
ColorMap
::
ColorMap
(
std
::
initializer_list
<
std
::
pair
<
float
,
Color
>
>
init
)
ColorMap
::
ColorMap
(
const
std
::
string
&
name
,
std
::
initializer_list
<
std
::
pair
<
float
,
Color
>
>
init
)
:
_name
(
name
)
{
for
(
const
auto
&
[
v
,
c
]
:
init
)
{
...
...
This diff is collapsed.
Click to expand it.
SimoxUtility/color/ColorMap.h
+
37
−
0
View file @
507e5ad8
...
...
@@ -9,30 +9,67 @@
namespace
simox
::
color
{
/**
* @brief A color map, mapping scalar values to colors.
*/
class
ColorMap
{
public:
/// Construct an empty color map. Will always return black.
ColorMap
();
/// Construct an unnamed color map with equidistant values from 0 to 1 (inclusive).
ColorMap
(
std
::
initializer_list
<
Color
>
init
);
/// Construct an unnamed color map with given values.
ColorMap
(
std
::
initializer_list
<
std
::
pair
<
float
,
Color
>>
init
);
/// Construct a named color map with equidistant values from 0 to 1 (inclusive).
ColorMap
(
const
std
::
string
&
name
,
std
::
initializer_list
<
Color
>
init
);
/// Construct a named color map with given values.
ColorMap
(
const
std
::
string
&
name
,
std
::
initializer_list
<
std
::
pair
<
float
,
Color
>>
init
);
bool
empty
()
const
;
/// Get the number of keys.
size_t
size
()
const
;
void
clear
();
/// Add a key color at the given value.
void
addKey
(
float
value
,
const
Color
&
color
);
/**
* @brief Get the color for the given scalar value.
*
* Empty color maps always return black.
*
* @param value The scalar value.
* @return
*/
Color
at
(
float
value
)
const
;
/// @see `ColorMap::at()`
inline
Color
operator
()(
float
value
)
const
{
return
this
->
at
(
value
);
}
std
::
string
name
()
const
{
return
_name
;
}
void
setName
(
const
std
::
string
&
name
)
{
this
->
_name
=
name
;
}
private
:
/// Map of value to color at that value.
std
::
map
<
float
,
Color
>
keys
;
/// The name.
std
::
string
_name
=
""
;
};
}
namespace
simox
{
using
ColorMap
=
color
::
ColorMap
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment