DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
DGtal::RandomColorMap Class Reference

#include <RandomColorMap.h>

Collaboration diagram for DGtal::RandomColorMap:
Collaboration graph
[legend]

Public Types

typedef unsigned int Value

Public Member Functions

 RandomColorMap (const RandomColorMap &other)
RandomColorMapoperator= (const RandomColorMap &anOther)
 RandomColorMap (const unsigned int &aFirstIndex, const unsigned int &aLastIndex, const Color &aFirstColor=Color::White, const Color &aLastColor=Color::Red)
void addColor (const Color &aColor)
Color operator() (const unsigned int &aValue) const
const unsigned int & min () const
const unsigned int & max () const
 ~RandomColorMap ()
void selfDisplay (std::ostream &out) const
bool isValid () const

Protected Member Functions

 RandomColorMap ()

Protected Attributes

unsigned int myMin
unsigned int myMax

Private Member Functions

void associateRandomIndexColor ()

Private Attributes

GradientColorMap< unsigned int > * myGradientMap
std::vector< unsigned int > myColorIndex
std::vector< unsigned int > myFreeColorIndex

Detailed Description

Aim: access to random color from a gradientColorMap.

Description of class 'RandomColorMap'

Definition at line 59 of file RandomColorMap.h.


Member Typedef Documentation

typedef unsigned int DGtal::RandomColorMap::Value

Definition at line 65 of file RandomColorMap.h.


Constructor & Destructor Documentation

DGtal::RandomColorMap::RandomColorMap ( const RandomColorMap other)

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.
DGtal::RandomColorMap::RandomColorMap ( const unsigned int &  aFirstIndex,
const unsigned int &  aLastIndex,
const Color aFirstColor = Color::White,
const Color aLastColor = Color::Red 
)
inline

Constructor from two unsigned intergers and two Colors.

Definition at line 47 of file RandomColorMap.ih.

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), associateRandomIndexColor(), myGradientMap, myMax, and myMin.

{
myMin = aFirstIndex;
myMax = aLastIndex;
myGradientMap = new GradientColorMap<unsigned int> (aFirstIndex, aLastIndex);
myGradientMap->addColor(aFirstColor);
myGradientMap->addColor(aLastColor);
}
DGtal::RandomColorMap::~RandomColorMap ( )
inline

Destructor.

Definition at line 78 of file RandomColorMap.ih.

{
delete myGradientMap;
}
DGtal::RandomColorMap::RandomColorMap ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).


Member Function Documentation

void DGtal::RandomColorMap::addColor ( const Color aColor)
inline

Adds a color to the list of color steps.

Parameters:
colorA color.

Definition at line 87 of file RandomColorMap.ih.

void DGtal::RandomColorMap::associateRandomIndexColor ( )
inlineprivate

Definition at line 62 of file RandomColorMap.ih.

Referenced by RandomColorMap().

{
for(unsigned int i=myMin; i<=myMax; i++){
myColorIndex.push_back(myMax+1);
myFreeColorIndex.push_back(i);
}
unsigned int i=0;
while(myFreeColorIndex.size()!=0){
unsigned int pos = rand()%myFreeColorIndex.size();
myFreeColorIndex.erase(myFreeColorIndex.begin()+pos);
i++;
}
}
bool DGtal::RandomColorMap::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Definition at line 103 of file RandomColorMap.ih.

{
return true;
}
const unsigned int & DGtal::RandomColorMap::max ( ) const
inline

Returns the upper bound of the value range.

Returns:
The upper bound of the value range.

Definition at line 140 of file RandomColorMap.ih.

{
return myMax;
}
const unsigned int & DGtal::RandomColorMap::min ( ) const
inline

Returns the lower bound of the value range.

Returns:
The lower bound of the value range.

Definition at line 133 of file RandomColorMap.ih.

{
return myMin;
}
Color DGtal::RandomColorMap::operator() ( const unsigned int &  aValue) const
inline

Computes the color associated with a value in a given range.

Parameters:
valueA value within the value range.
Returns:
A random color identified by an unique [aValue] within the current range.

Definition at line 125 of file RandomColorMap.ih.

{
return (*myGradientMap)(myColorIndex.at(aValue));
}
DGtal::RandomColorMap & DGtal::RandomColorMap::operator= ( const RandomColorMap anOther)
inline

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.

Definition at line 111 of file RandomColorMap.ih.

References myColorIndex, myFreeColorIndex, myMax, and myMin.

{
if ( &anOther != this ) {
myMin = anOther.myMin;
myMax = anOther.myMax;
myColorIndex = anOther.myColorIndex;
myFreeColorIndex= anOther.myFreeColorIndex;
myGradientMap = new GradientColorMap<unsigned int> (myMin, myMax);
}
return *this;
}
void DGtal::RandomColorMap::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 95 of file RandomColorMap.ih.

{
out << "[RandomColorMap]";
}

Field Documentation

std::vector<unsigned int> DGtal::RandomColorMap::myColorIndex
private

Definition at line 161 of file RandomColorMap.h.

Referenced by operator=().

std::vector<unsigned int> DGtal::RandomColorMap::myFreeColorIndex
private

Definition at line 162 of file RandomColorMap.h.

Referenced by operator=().

GradientColorMap<unsigned int>* DGtal::RandomColorMap::myGradientMap
private

Definition at line 160 of file RandomColorMap.h.

Referenced by RandomColorMap().

unsigned int DGtal::RandomColorMap::myMax
protected

The lower bound of the value range.

Definition at line 153 of file RandomColorMap.h.

Referenced by operator=(), and RandomColorMap().

unsigned int DGtal::RandomColorMap::myMin
protected

The lower bound of the value range.

Definition at line 152 of file RandomColorMap.h.

Referenced by operator=(), and RandomColorMap().


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