Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
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 = std::shared_ptr< ColormapHelperBase >
 
- Public Types inherited from ColormapProvider
using Ptr = std::shared_ptr< ColormapProvider >
 
- Public Types inherited from Colormappable
using Ptr = std::shared_ptr< Colormappable >
 
using WeakPtr = std::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
79 : ColormapHelperBase(generateInitialColormap(numberOfColors_, inverted_))
80 , numberOfColors(numberOfColors_)
81 , inverted(inverted_)
82 , blackish(Color(inverted_ ? 1 : 0))
83 , whitish(Color(inverted_ ? 0 : 1))
84
85{
86}
Definition color.hh:37
Definition colormappable.hh:156
int numberOfColors
Definition colormappable.hh:231
Color blackish
Definition colormappable.hh:233
static Colormap::Ptr generateInitialColormap(int numberOfColors, bool inverted)
Definition colormap-helpers.cc:126
Color whitish
Definition colormappable.hh:234
bool inverted
Definition colormappable.hh:232

Member Function Documentation

◆ create()

MonochromeColormapHelper::Ptr MonochromeColormapHelper::create ( int  numberOfColors)
static
69{
71}
std::shared_ptr< ColormapHelperBase > Ptr
Definition colormappable.hh:158
Definition colormappable.hh:208

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

Here is the caller graph for this function:

◆ createInverted()

MonochromeColormapHelper::Ptr MonochromeColormapHelper::createInverted ( int  numberOfColors)
static
74{
76}

Referenced by Scroom::Tiff::open().

Here is the caller graph for this function:

◆ disableTransparentBackground()

void MonochromeColormapHelper::disableTransparentBackground ( )
overridevirtual

Reimplemented from ColormapHelperBase.

138{
139 transparentBackground = false;
141}
void regenerateColormap()
Definition colormap-helpers.cc:104
bool transparentBackground
Definition colormappable.hh:235
Here is the call graph for this function:

◆ generateInitialColormap()

Colormap::Ptr MonochromeColormapHelper::generateInitialColormap ( int  numberOfColors,
bool  inverted 
)
staticprivate
127{
129}
Definition colormappable.hh:27
static Colormap::Ptr createDefaultInverted(int n)
Definition colormappable.hh:65
Here is the call graph for this function:

◆ getMonochromeColor()

Color MonochromeColormapHelper::getMonochromeColor ( )
overridevirtual

Reimplemented from ColormapHelperBase.

102{ return inverted ? whitish : blackish; }

◆ getProperties()

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

Implements ColormapHelperBase.

146{
148}
const std::string MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
Definition colormappable.hh:20

◆ getTransparentBackground()

bool MonochromeColormapHelper::getTransparentBackground ( )
overridevirtual

Reimplemented from ColormapHelperBase.

143{ return transparentBackground; }

◆ regenerateColormap()

void MonochromeColormapHelper::regenerateColormap ( )
private
105{
106 Color w = whitish;
107 Color b = blackish;
109 {
110 if(inverted)
111 {
112 b.setAlpha(0);
113 }
114 else
115 {
116 w.setAlpha(0);
117 }
118 }
119
120 for(int i = 0; i < numberOfColors; i++)
121 {
122 colormap->colors[i] = mix(w, b, 1.0 * i / (numberOfColors - 1));
123 }
124}
Blob::Ptr const b
Definition blob-tests.cc:118
Color & setAlpha(double alpha_)
Definition color.hh:128
Colormap::Ptr colormap
Definition colormappable.hh:161
Color mix(const Color &a, const Color &b, double alpha)
Definition color.hh:133
std::pair< GSourceFunc, gpointer > const w
Definition gtkhelper-tests.cc:42

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.

89{
90 if(inverted)
91 {
92 whitish = c;
93 }
94 else
95 {
96 blackish = c;
97 }
98
100}
Semaphore c(0)
Here is the call graph for this function:

◆ setTransparentBackground()

void MonochromeColormapHelper::setTransparentBackground ( )
overridevirtual

Reimplemented from ColormapHelperBase.

132{
135}
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: