Antiprism 0.23

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions

# color_map_map Class Reference

A colour map with the mappings held in a map. More...

`#include <col_map.h>`

Inheritance diagram for color_map_map:
[legend]
Collaboration diagram for color_map_map:
[legend]

List of all members.

## Public Member Functions
virtual bool | init (const char *map_name, char *errmsg=0)
| Initialise from a file.
bool | init_from_line (const char *map_line, char *errmsg=0)
| Initialise from a formatted line.
color_map * | clone () const
| Get a copy of the map.
virtual color_map * | get_condensed () const
| Get a copy of the map with any with the values indexed by order.
void | read_named_colors ()
| Read the named colours into a colour map.
void | set_map (const map< int, col_val > col_map)
| Set the colour map.
bool | generate_map_hsv (int map_sz, const vector< double > &hue, const vector< double > &sat, const vector< double > &val, const vector< double > &alpha=vector< double >())
| Generate a colour map with HSV values.
bool | generate_map_rgb (int map_sz, const vector< double > &red, const vector< double > &green, const vector< double > &blue, const vector< double > &alpha=vector< double >())
| Generate a colour map with RGB values.
bool | generate_map (const char *map_name)
| Generate a colour map.
const map< int, col_val > & | get_map () const
| Get the colour map.
color_map & | operator= (const color_map &col_map)
| Assign operator.
void | clear ()
| Clear the colour map.
unsigned int | size () const
| The size of the map.
virtual int | effective_size () const
| The effective size of the map.
virtual col_val | get_col (int idx) const
| Get the colour value for an index number.
void | set_col (int idx, col_val col)
| Set a colour value for an index number.
void | get_sequential_index (color_map &col_map)
| Get a colour map containing the colours in this map indexed sequentially.

## Detailed Description

A colour map with the mappings held in a map.

## Member Function Documentation

color_map* color_map_map::clone | ( |  | ) | const`[inline, virtual]`

Get a copy of the map.

Returns:
  a pointer to the dynamically allocated copy, which must be freed by the caller with `delete`, 0 indicates that the clone failed.

Reimplemented from color_map.

int color_map_map::effective_size | ( |  | ) | const`[virtual]`

The effective size of the map.

The effective size of a map is one greater than the highest index number in the map. It is the size of the smallest map (sequential, starting at 0) that will include all the entries of the map.

Returns:
  The effective size

Reimplemented from color_map.

bool color_map_map::generate_map | ( | const char * | map_name | ) |

Generate a colour map.

The map name is of the form cmNUMBEROFCOLORS_HUELIST_SATLIST_VALLIST with the lists containing floating point values 0.0 - 1.0 separated by commas e.g. cm256_0,1_0.9_0.9 gives a 256 colour spectrum map. The map is generated by inserting the H, S and V values evenly in map and interpolating the values for the other entries.

Parameters:

  map_name | the name of the map

Returns:
  `true` if a map was set, otherwise `false`.

bool color_map_map::generate_map_hsv | ( | int | map_sz,
|  | const vector< double > & | hue,
|  | const vector< double > & | sat,
|  | const vector< double > & | val,
|  | const vector< double > & | alpha = `vector< double >()`
| ) |  |

Generate a colour map with HSV values.

The map is generated by inserting the H, S, V and A values evenly in map and interpolating the values for the other entries.

Parameters:

  map_sz | the number of entries in the map
  hue | the list of Hue values
  sat | the list of Saturation values
  val | the list of Value values
  alpha | the list of Alpha values

Returns:
  `true` if a map was set, otherwise `false`.

bool color_map_map::generate_map_rgb | ( | int | map_sz,
|  | const vector< double > & | red,
|  | const vector< double > & | green,
|  | const vector< double > & | blue,
|  | const vector< double > & | alpha = `vector< double >()`
| ) |  |

Generate a colour map with RGB values.

The map is generated by inserting the R, G, V and A values evenly in map and interpolating the values for the other entries.

Parameters:

  map_sz | the number of entries in the map
  red | the list of Red values
  green | the list of Blue values
  blue | the list of Green values
  alpha | the list of Alpha values

Returns:
  `true` if a map was set, otherwise `false`.

col_val color_map_map::get_col | ( | int | idx | ) | const`[virtual]`

Get the colour value for an index number.

Parameters:

  idx | the index.

Returns:
  The colour.

Reimplemented from color_map.

color_map * color_map_map::get_condensed | ( |  | ) | const`[virtual]`

Get a copy of the map with any with the values indexed by order.

Returns:
  a pointer to the dynamically allocated condensed copy, which must be freed by the caller with `delete`, 0 indicates that the copy failed.

Reimplemented from color_map.

const map<int, col_val>& color_map_map::get_map | ( |  | ) | const`[inline]`

Get the colour map.

Returns:
  the colour map

void color_map_map::get_sequential_index | ( | color_map & | col_map | ) |

Get a colour map containing the colours in this map indexed sequentially.

Parameters:

  col_map | to return the sequential indexing.

bool color_map_map::init | ( | const char * | map_name,
|  | char * | errmsg = `0`
| ) |  | `[virtual]`

Initialise from a file.

The colour map can be in the Antiprism, GIMP or Fractint format. If the filename isn't found then the name will be looked for in the Antiprism data directory colour map resources.

Parameters:

  map_name | the map name.
  errmsg | an array at least `MSG_SZ` chars long to return any error message.

Returns:
  true if the file could be read, otherwise false and the error is detailed in errmsg.

cmap_ok &&

Reimplemented from color_map.

bool color_map_map::init_from_line | ( | const char * | map_line,
|  | char * | errmsg = `0`
| ) |  |

Initialise from a formatted line.

The colour map line is converted to Antiprism format in the following way: ':' is converted to a newline, and '_' to a space. If the lines are bare colours then "idx=" is added.

Parameters:

  map_line | the map line text.
  errmsg | an array at least `MSG_SZ` chars long to return any error message.

Returns:
  true if the mal line was valid, otherwise false and the error is detailed in errmsg.

color_map& color_map_map::operator= | ( | const color_map & | col_map | ) |

Assign operator.

Parameters:

  col_map | the colour map to set equal to.

void color_map_map::read_named_colors | ( |  | ) |

Read the named colours into a colour map.

This is equivalent to reading in the x11 colour map from the resources.

void color_map_map::set_col | ( | int | idx,
|  | col_val | col
| ) |  |

Set a colour value for an index number.

Parameters:

  idx | the index.
  col | the colour to set.

Returns:
  The colour.

void color_map_map::set_map | ( | const map< int, col_val > | col_map | ) | `[inline]`

Set the colour map.

Parameters:

  col_map | the colour map to use.

unsigned int color_map_map::size | ( |  | ) | const`[inline]`

The size of the map.

Returns:
  The size

The documentation for this class was generated from the following files:

- base/col_map.h
- base/col_map.cc