Scroom  0.14
MonochromeColormapHelper Class Reference

#include <colormappable.hh>

Inheritance diagram for MonochromeColormapHelper:
Inheritance graph
Collaboration diagram for MonochromeColormapHelper:
Collaboration graph

Public Member Functions

std::map< std::string, std::string > getProperties () override
 
Color getMonochromeColor () override
 
void setMonochromeColor (const Color &c) override
 
void setTransparentBackground () override
 
void disableTransparentBackground () override
 
bool getTransparentBackground () override
 
- Public Member Functions inherited from ColormapHelperBase
 ColormapHelperBase (Colormap::Ptr const &colormap)
 
void setColormap (Colormap::Ptr colormap) override
 
Colormap::Ptr getOriginalColormap () override
 
int getNumberOfColors () override
 
Colormap::Ptr getColormap () override
 
virtual void setOriginalColormap (Colormap::Ptr colormap)
 
For monochrome presentations: Set/Get the current color
Manipulate the "Transparent Background" setting of the presentation

Static Public Member Functions

static Ptr create (int numberOfColors)
 
static Ptr createInverted (int numberOfColors)
 

Private Member Functions

 MonochromeColormapHelper (int numberOfColors, bool inverted)
 
void regenerateColormap ()
 

Static Private Member Functions

static Colormap::Ptr generateInitialColormap (int numberOfColors, bool inverted)
 

Private Attributes

int numberOfColors
 
bool inverted
 
Color blackish
 
Color whitish
 
bool transparentBackground {false}
 

Additional Inherited Members

- Public Types inherited from ColormapHelperBase
using Ptr = boost::shared_ptr< ColormapHelperBase >
 
- Public Types inherited from ColormapProvider
using Ptr = boost::shared_ptr< ColormapProvider >
 
- Public Types inherited from Colormappable
using Ptr = boost::shared_ptr< Colormappable >
 
using WeakPtr = boost::weak_ptr< Colormappable >
 
- Public Attributes inherited from ColormapHelperBase
Colormap::Ptr colormap
 
Colormap::Ptr originalColormap
 

Constructor & Destructor Documentation

◆ MonochromeColormapHelper()

MonochromeColormapHelper::MonochromeColormapHelper ( int  numberOfColors,
bool  inverted 
)
private
83  : ColormapHelperBase(generateInitialColormap(numberOfColors_, inverted_))
84  , numberOfColors(numberOfColors_)
85  , inverted(inverted_)
86  , blackish(Color(inverted_ ? 1 : 0))
87  , whitish(Color(inverted_ ? 0 : 1))
88 
89 {
90 }

Referenced by create(), and createInverted().

Here is the caller graph for this function:

Member Function Documentation

◆ create()

MonochromeColormapHelper::Ptr MonochromeColormapHelper::create ( int  numberOfColors)
static
73 {
74  return Ptr(new MonochromeColormapHelper(numberOfColors, false));
75 }

Referenced by BOOST_AUTO_TEST_CASE(), Scroom::TiledBitmap::GreyscaleBitmap(), and Scroom::Tiff::open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createInverted()

MonochromeColormapHelper::Ptr MonochromeColormapHelper::createInverted ( int  numberOfColors)
static
78 {
79  return Ptr(new MonochromeColormapHelper(numberOfColors, true));
80 }

Referenced by BOOST_AUTO_TEST_CASE(), and Scroom::Tiff::open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableTransparentBackground()

void MonochromeColormapHelper::disableTransparentBackground ( )
overridevirtual

Reimplemented from ColormapHelperBase.

142 {
143  transparentBackground = false;
145 }
Here is the call graph for this function:

◆ generateInitialColormap()

Colormap::Ptr MonochromeColormapHelper::generateInitialColormap ( int  numberOfColors,
bool  inverted 
)
staticprivate
131 {
133 }
Here is the call graph for this function:

◆ getMonochromeColor()

Color MonochromeColormapHelper::getMonochromeColor ( )
overridevirtual

Reimplemented from ColormapHelperBase.

106 { return inverted ? whitish : blackish; }

◆ getProperties()

std::map< std::string, std::string > MonochromeColormapHelper::getProperties ( )
overridevirtual

Implements ColormapHelperBase.

150 {
152 }

◆ getTransparentBackground()

bool MonochromeColormapHelper::getTransparentBackground ( )
overridevirtual

Reimplemented from ColormapHelperBase.

147 { return transparentBackground; }

◆ regenerateColormap()

void MonochromeColormapHelper::regenerateColormap ( )
private
109 {
110  Color w = whitish;
111  Color b = blackish;
113  {
114  if(inverted)
115  {
116  b.setAlpha(0);
117  }
118  else
119  {
120  w.setAlpha(0);
121  }
122  }
123 
124  for(int i = 0; i < numberOfColors; i++)
125  {
126  colormap->colors[i] = mix(w, b, 1.0 * i / (numberOfColors - 1));
127  }
128 }

Referenced by disableTransparentBackground(), setMonochromeColor(), and setTransparentBackground().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMonochromeColor()

void MonochromeColormapHelper::setMonochromeColor ( const Color c)
overridevirtual

Reimplemented from ColormapHelperBase.

93 {
94  if(inverted)
95  {
96  whitish = c;
97  }
98  else
99  {
100  blackish = c;
101  }
102 
104 }
Here is the call graph for this function:

◆ setTransparentBackground()

void MonochromeColormapHelper::setTransparentBackground ( )
overridevirtual

Reimplemented from ColormapHelperBase.

136 {
137  transparentBackground = true;
139 }
Here is the call graph for this function:

Member Data Documentation

◆ blackish

Color MonochromeColormapHelper::blackish
private

◆ inverted

bool MonochromeColormapHelper::inverted
private

◆ numberOfColors

int MonochromeColormapHelper::numberOfColors
private

◆ transparentBackground

bool MonochromeColormapHelper::transparentBackground {false}
private

◆ whitish

Color MonochromeColormapHelper::whitish
private

The documentation for this class was generated from the following files:
ColormapHelperBase::ColormapHelperBase
ColormapHelperBase(Colormap::Ptr const &colormap)
Definition: colormap-helpers.cc:18
MonochromeColormapHelper::blackish
Color blackish
Definition: colormappable.hh:235
MonochromeColormapHelper::whitish
Color whitish
Definition: colormappable.hh:236
MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
const std::string MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
Definition: colormappable.hh:22
MonochromeColormapHelper::generateInitialColormap
static Colormap::Ptr generateInitialColormap(int numberOfColors, bool inverted)
Definition: colormap-helpers.cc:130
mix
Color mix(const Color &a, const Color &b, double alpha)
Definition: color.hh:133
MonochromeColormapHelper::inverted
bool inverted
Definition: colormappable.hh:234
MonochromeColormapHelper::transparentBackground
bool transparentBackground
Definition: colormappable.hh:237
ColormapHelperBase::colormap
Colormap::Ptr colormap
Definition: colormappable.hh:163
Colormap::createDefaultInverted
static Colormap::Ptr createDefaultInverted(int n)
Definition: colormappable.hh:67
ColormapHelperBase::Ptr
boost::shared_ptr< ColormapHelperBase > Ptr
Definition: colormappable.hh:160
MonochromeColormapHelper::numberOfColors
int numberOfColors
Definition: colormappable.hh:233
b
static void b(const B::Ptr &)
Definition: gtkhelper-tests.cc:32
MonochromeColormapHelper::regenerateColormap
void regenerateColormap()
Definition: colormap-helpers.cc:108
Color::setAlpha
Color & setAlpha(double alpha_)
Definition: color.hh:128
MonochromeColormapHelper::MonochromeColormapHelper
MonochromeColormapHelper(int numberOfColors, bool inverted)
Definition: colormap-helpers.cc:82
Color
Definition: color.hh:34
Colormap
Definition: colormappable.hh:28