Scroom  0.14
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation Class Reference
Inheritance diagram for anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation:
Inheritance graph
Collaboration diagram for anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation:
Collaboration graph

Public Types

using Ptr = boost::shared_ptr< TiledBitmapPresentation >
 
- Public Types inherited from PresentationInterface
using Ptr = boost::shared_ptr< PresentationInterface >
 
using WeakPtr = boost::weak_ptr< PresentationInterface >
 
- Public Types inherited from Viewable
using Ptr = boost::shared_ptr< Viewable >
 
using WeakPtr = boost::weak_ptr< Viewable >
 
- Public Types inherited from Scroom::Utils::Observable< T >
using Observer = boost::shared_ptr< T >
 
using Ptr = boost::shared_ptr< Observable< T > >
 
- Public Types inherited from Colormappable
using Ptr = boost::shared_ptr< Colormappable >
 
using WeakPtr = boost::weak_ptr< Colormappable >
 
- Public Types inherited from PipetteViewInterface
using Ptr = boost::shared_ptr< PipetteViewInterface >
 
- Public Types inherited from ShowMetadataInterface
using Ptr = boost::shared_ptr< ShowMetadataInterface >
 

Public Member Functions

Scroom::Utils::Rectangle< double > getRect () override
 
void redraw (const ViewInterface::Ptr &vi, cairo_t *cr, Scroom::Utils::Rectangle< double > presentationArea, int zoom) override
 
bool getProperty (const std::string &propertyName, std::string &value) override
 
bool isPropertyDefined (const std::string &propertyName) override
 
std::string getTitle () override
 
PipetteLayerOperations::PipetteColor getPixelAverages (Scroom::Utils::Rectangle< double > area) override
 
void showMetadata (GtkWindow *parent) override
 
void setColormap (Colormap::Ptr colormap) override
 
Colormap::Ptr getOriginalColormap () override
 
int getNumberOfColors () override
 
Color getMonochromeColor () override
 
void setMonochromeColor (const Color &c) override
 
void setTransparentBackground () override
 
void disableTransparentBackground () override
 
bool getTransparentBackground () override
 
void add (Scroom::Utils::Stuff s)
 
- Public Member Functions inherited from PresentationBase
void open (ViewInterface::WeakPtr vi) override
 
void close (ViewInterface::WeakPtr vi) override
 
- Public Member Functions inherited from PresentationInterface
virtual Scroom::Utils::Point< double > getAspectRatio () const
 
- Public Member Functions inherited from Scroom::Utils::Observable< T >
 Observable ()
 
 ~Observable () override
 
 Observable (const Observable &)=delete
 
 Observable (Observable &&)=delete
 
Observable operator= (const Observable &)=delete
 
Observable operator= (Observable &&)=delete
 
Scroom::Bookkeeping::Token registerStrongObserver (Observer const &observer)
 
Scroom::Bookkeeping::Token registerObserver (ObserverWeak const &observer)
 
For monochrome presentations: Set/Get the current color
Manipulate the "Transparent Background" setting of the presentation
- Public Member Functions inherited from Scroom::Utils::Base
 Base ()=default
 
 Base (const Base &)=delete
 
 Base (Base &&)=delete
 
Baseoperator= (const Base &)=delete
 
Baseoperator= (Base &&)=delete
 
virtual ~Base ()=default
 
template<typename R >
boost::shared_ptr< R > shared_from_this ()
 
template<typename R >
boost::shared_ptr< R const > shared_from_this () const
 

Static Public Member Functions

static TiledBitmapPresentation::Ptr create (std::string name_, BitmapMetaData bmd_, TiledBitmapInterface::Ptr tbi_, std::map< std::string, std::string > properties_, ColormapHelperBase::Ptr colormapHelper_, PipetteLayerOperations::Ptr pipetteLayerOperation_)
 

Protected Member Functions

void viewAdded (ViewInterface::WeakPtr vi) override
 
void viewRemoved (ViewInterface::WeakPtr vi) override
 
std::set< ViewInterface::WeakPtrgetViews () override
 
- Protected Member Functions inherited from PresentationBase
void observerAdded (Viewable::Ptr const &viewable, Scroom::Bookkeeping::Token const &t) override
 
- Protected Member Functions inherited from Scroom::Utils::Observable< T >
std::list< ObservergetObservers ()
 
virtual void observerAdded (Observer const &observer, Scroom::Bookkeeping::Token const &token)
 

Private Types

using Views = std::set< ViewInterface::WeakPtr >
 

Private Member Functions

void clearCaches ()
 
 TiledBitmapPresentation (std::string &&name_, BitmapMetaData &&bmd_, TiledBitmapInterface::Ptr &&tbi_, std::map< std::string, std::string > &&properties_, ColormapHelperBase::Ptr &&colormapHelper_, PipetteLayerOperations::Ptr &&pipetteLayerOperation_)
 

Private Attributes

std::string name
 
Scroom::TiledBitmap::BitmapMetaData bmd
 
TiledBitmapInterface::Ptr tbi
 
std::map< std::string, std::string > properties
 
Views views
 
ColormapHelperBase::Ptr colormapHelper
 
PipetteLayerOperations::Ptr pipetteLayerOperation
 
Scroom::Utils::StuffList stuff
 

Member Typedef Documentation

◆ Ptr

using anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::Ptr = boost::shared_ptr<TiledBitmapPresentation>

◆ Views

using anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::Views = std::set<ViewInterface::WeakPtr>
private

Constructor & Destructor Documentation

◆ TiledBitmapPresentation()

anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::TiledBitmapPresentation ( std::string &&  name_,
BitmapMetaData &&  bmd_,
TiledBitmapInterface::Ptr &&  tbi_,
std::map< std::string, std::string > &&  properties_,
ColormapHelperBase::Ptr &&  colormapHelper_,
PipetteLayerOperations::Ptr &&  pipetteLayerOperation_ 
)
inlineprivate
150  : name(name_)
151  , bmd(bmd_)
152  , tbi(tbi_)
153  , properties(properties_)
154  , colormapHelper(colormapHelper_)
155  , pipetteLayerOperation(pipetteLayerOperation_)
156  {
157  }

Member Function Documentation

◆ add()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::add ( Scroom::Utils::Stuff  s)
inline
132 { stuff.push_back(std::move(s)); }

◆ clearCaches()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::clearCaches ( )
private
161  {
162  for(const Views::value_type& p: views)
163  {
164  ViewInterface::Ptr const v = p.lock();
165  if(v)
166  {
167  if(tbi)
168  {
169  tbi->clearCaches(v);
170  }
171  v->invalidate();
172  }
173  }
174  }

◆ create()

static TiledBitmapPresentation::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::create ( std::string  name_,
BitmapMetaData  bmd_,
TiledBitmapInterface::Ptr  tbi_,
std::map< std::string, std::string >  properties_,
ColormapHelperBase::Ptr  colormapHelper_,
PipetteLayerOperations::Ptr  pipetteLayerOperation_ 
)
inlinestatic
84  {
85  return Ptr(new TiledBitmapPresentation(std::move(name_),
86  std::move(bmd_),
87  std::move(tbi_),
88  std::move(properties_),
89  std::move(colormapHelper_),
90  std::move(pipetteLayerOperation_)));
91  }

◆ disableTransparentBackground()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::disableTransparentBackground ( )
overridevirtual

Implements Colormappable.

343  {
344  colormapHelper->disableTransparentBackground();
345  clearCaches();
346  }

◆ getMonochromeColor()

Color anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getMonochromeColor ( )
overridevirtual

Implements Colormappable.

328 { return colormapHelper->getMonochromeColor(); }

◆ getNumberOfColors()

int anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getNumberOfColors ( )
overridevirtual

Retrieve the number of colors in use by the presentation

Implements Colormappable.

327 { return colormapHelper->getNumberOfColors(); }

◆ getOriginalColormap()

Colormap::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getOriginalColormap ( )
overridevirtual

Retrieve the images colormap (if any)

Implements Colormappable.

326 { return colormapHelper->getOriginalColormap(); }

◆ getPixelAverages()

PipetteLayerOperations::PipetteColor anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getPixelAverages ( Scroom::Utils::Rectangle< double >  area)
overridevirtual

Returns the average pixel values for each component, contained in the area.

Parameters
areaselected area to get the pixel values from.

Implements PipetteViewInterface.

225  {
227 
228  auto intArea = roundOutward(area.intersection(getRect())).to<int>();
229 
230  Layer::Ptr const bottomLayer = tbi->getBottomLayer();
232 
233  const int totalPixels = intArea.getWidth() * intArea.getHeight();
234 
235  if(totalPixels == 0)
236  {
237  return {};
238  }
239 
240  // Get start tile (tile_pos_x_start, tile_pos_y_start)
241  const int tile_pos_x_start = intArea.getLeft() / TILESIZE;
242  const int tile_pos_y_start = intArea.getTop() / TILESIZE;
243 
244  // Get end tile (tile_pos_x_end, tile_pos_y_end)
245  const int tile_pos_x_end = (intArea.getRight() - 1) / TILESIZE;
246  const int tile_pos_y_end = (intArea.getBottom() - 1) / TILESIZE;
247 
248  for(int x = tile_pos_x_start; x <= tile_pos_x_end; x++)
249  {
250  for(int y = tile_pos_y_start; y <= tile_pos_y_end; y++)
251  {
252  ConstTile::Ptr const tile = bottomLayer->getTile(x, y)->getConstTileSync();
253  Scroom::Utils::Rectangle<int> const tile_rectangle(x * TILESIZE, y * TILESIZE, tile->width, tile->height);
254 
255  Scroom::Utils::Rectangle<int> inter_rect = tile_rectangle.intersection(intArea);
256  Scroom::Utils::Point<int> const base(x * TILESIZE, y * TILESIZE);
257 
258  inter_rect -= base; // rectangle coordinates relative to constTile with topleft corner (0,0)
259 
260  pipetteColors = sumPipetteColors(pipetteColors, pipetteLayerOperation->sumPixelValues(inter_rect, tile));
261  }
262  }
263  return dividePipetteColors(pipetteColors, totalPixels);
264  }
Here is the call graph for this function:

◆ getProperty()

bool anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getProperty ( const std::string &  name,
std::string &  value 
)
overridevirtual

Return the value of the requested property

Parameters
[in]nameThe name of the requested property
[out]valueThe value of the requested property
Return values
trueif the property existed
falseif the property didn't exist

Implements PresentationInterface.

196  {
197  auto p = properties.find(propertyName);
198  bool found = false;
199  if(p == properties.end())
200  {
201  found = false;
202  value = "";
203  }
204  else
205  {
206  found = true;
207  value = p->second;
208  }
209 
210  return found;
211  }

◆ getRect()

Scroom::Utils::Rectangle< double > anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getRect ( )
overridevirtual

Return the dimensions of your presentation

Implements PresentationInterface.

◆ getTitle()

std::string anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getTitle ( )
overridevirtual

Return the title of the presentation

Implements PresentationInterface.

218 { return name; }

◆ getTransparentBackground()

bool anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getTransparentBackground ( )
overridevirtual

Implements Colormappable.

348 { return colormapHelper->getTransparentBackground(); }

◆ getViews()

std::set< ViewInterface::WeakPtr > anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getViews ( )
overrideprotectedvirtual

Implements PresentationBase.

314 { return views; }

◆ isPropertyDefined()

bool anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::isPropertyDefined ( const std::string &  name)
overridevirtual

Return true if the named property exists

Implements PresentationInterface.

214  {
215  return properties.end() != properties.find(propertyName);
216  }

◆ redraw()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::redraw ( const ViewInterface::Ptr vi,
cairo_t *  cr,
Scroom::Utils::Rectangle< double >  presentationArea,
int  zoom 
)
overridevirtual

Draw the requested ara at the requested zoom level

Parameters
viThe ViewInterface on whose behalf the request is made
crThe context to draw the area on
presentationAreathe area that is to be drawn. The given x and y coordinates should map on 0,0 of the given context cr.
zoomThe requested zoom level. One pixel of your presentation should have size 2**zoom when drawn. zoom may be negative.

Implements PresentationInterface.

186  {
187  drawOutOfBoundsWithoutBackground(cr, presentationArea, getRect(), pixelSizeFromZoom(zoom));
188 
189  if(tbi)
190  {
191  tbi->redraw(vi, cr, presentationArea, zoom);
192  }
193  }
Here is the call graph for this function:

◆ setColormap()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::setColormap ( Colormap::Ptr  colormap)
overridevirtual

Request that the presentation use the given colormap

Implements Colormappable.

321  {
322  colormapHelper->setColormap(colormap);
323  clearCaches();
324  }

◆ setMonochromeColor()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::setMonochromeColor ( const Color c)
overridevirtual

Implements Colormappable.

331  {
332  colormapHelper->setMonochromeColor(c);
333  clearCaches();
334  }

◆ setTransparentBackground()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::setTransparentBackground ( )
overridevirtual

Implements Colormappable.

337  {
338  colormapHelper->setTransparentBackground();
339  clearCaches();
340  }

◆ showMetadata()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::showMetadata ( GtkWindow *  parent)
overridevirtual

Request to show a window containing the presentation metadata

Parameters
parentthe parent window, if found. Nullptr otherwise

Implements ShowMetadataInterface.

◆ viewAdded()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::viewAdded ( ViewInterface::WeakPtr  vi)
overrideprotectedvirtual

Implements PresentationBase.

287  {
288  views.insert(viewInterface);
289 
290  if(tbi)
291  {
292  tbi->open(viewInterface);
293  }
294  else
295  {
296  spdlog::error("TiffPresentation::open(): No TiledBitmapInterface available!");
297  }
298  }

◆ viewRemoved()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::viewRemoved ( ViewInterface::WeakPtr  vi)
overrideprotectedvirtual

Implements PresentationBase.

301  {
302  views.erase(vi);
303 
304  if(tbi)
305  {
306  tbi->close(vi);
307  }
308  else
309  {
310  spdlog::error("TiffPresentation::close(): No TiledBitmapInterface available!");
311  }
312  }

Member Data Documentation

◆ bmd

Scroom::TiledBitmap::BitmapMetaData anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::bmd
private

◆ colormapHelper

ColormapHelperBase::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::colormapHelper
private

◆ name

std::string anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::name
private

◆ pipetteLayerOperation

PipetteLayerOperations::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::pipetteLayerOperation
private

◆ properties

std::map<std::string, std::string> anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::properties
private

◆ stuff

Scroom::Utils::StuffList anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::stuff
private

◆ tbi

TiledBitmapInterface::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::tbi
private

◆ views

Views anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::views
private

The documentation for this class was generated from the following file:
PipetteLayerOperations::PipetteColor
std::vector< std::pair< std::string, double > > PipetteColor
Definition: pipettelayeroperations.hh:22
Layer::Ptr
boost::shared_ptr< Layer > Ptr
Definition: tiledbitmaplayer.hh:247
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::clearCaches
void clearCaches()
Definition: tiledbitmappresentation.cc:160
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::tbi
TiledBitmapInterface::Ptr tbi
Definition: tiledbitmappresentation.cc:70
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::colormapHelper
ColormapHelperBase::Ptr colormapHelper
Definition: tiledbitmappresentation.cc:73
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::pipetteLayerOperation
PipetteLayerOperations::Ptr pipetteLayerOperation
Definition: tiledbitmappresentation.cc:74
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::TiledBitmapPresentation
TiledBitmapPresentation(std::string &&name_, BitmapMetaData &&bmd_, TiledBitmapInterface::Ptr &&tbi_, std::map< std::string, std::string > &&properties_, ColormapHelperBase::Ptr &&colormapHelper_, PipetteLayerOperations::Ptr &&pipetteLayerOperation_)
Definition: tiledbitmappresentation.cc:144
anonymous_namespace{tiledbitmappresentation.cc}::dividePipetteColors
PipetteLayerOperations::PipetteColor dividePipetteColors(PipetteLayerOperations::PipetteColor elements, const int divisor)
Definition: tiledbitmappresentation.cc:47
ConstTile::Ptr
boost::shared_ptr< ConstTile > Ptr
Definition: tile.hh:47
Scroom::Utils::Rectangle::intersection
Rectangle intersection(const Rectangle &other) const
Definition: rectangle.hh:95
ViewInterface::Ptr
boost::shared_ptr< ViewInterface > Ptr
Definition: viewinterface.hh:193
require
#define require(expr)
Definition: assertions.hh:28
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::Ptr
boost::shared_ptr< TiledBitmapPresentation > Ptr
Definition: tiledbitmappresentation.cc:63
Scroom::TiledBitmap::BitmapMetaData::rect
Scroom::Utils::Rectangle< int > rect
Definition: opentiledbitmapinterface.hh:46
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::properties
std::map< std::string, std::string > properties
Definition: tiledbitmappresentation.cc:71
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getRect
Scroom::Utils::Rectangle< double > getRect() override
Definition: tiledbitmappresentation.cc:180
colormap
const Colormap::Ptr colormap
Definition: colormaphelpers_test.cc:54
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::name
std::string name
Definition: tiledbitmappresentation.cc:68
drawOutOfBoundsWithoutBackground
void drawOutOfBoundsWithoutBackground(cairo_t *cr, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
Definition: cairo-helpers.cc:93
pixelSizeFromZoom
double pixelSizeFromZoom(int zoom)
Definition: cairo-helpers.cc:112
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::views
Views views
Definition: tiledbitmappresentation.cc:72
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::bmd
Scroom::TiledBitmap::BitmapMetaData bmd
Definition: tiledbitmappresentation.cc:69
TILESIZE
#define TILESIZE
Definition: tiledbitmaplayer.hh:28
Scroom::Utils::Rectangle< int >
Scroom::Utils::roundOutward
Segment< double > roundOutward(Segment< double > s)
Definition: linearsegment.hh:240
anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::stuff
Scroom::Utils::StuffList stuff
Definition: tiledbitmappresentation.cc:75
anonymous_namespace{tiledbitmappresentation.cc}::sumPipetteColors
PipetteLayerOperations::PipetteColor sumPipetteColors(const PipetteLayerOperations::PipetteColor &lhs, const PipetteLayerOperations::PipetteColor &rhs)
Definition: tiledbitmappresentation.cc:29
Scroom::Utils::Point< int >