Scroom 0.14-48-ga0fee447
Loading...
Searching...
No Matches
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 = std::shared_ptr< TiledBitmapPresentation >
 
- Public Types inherited from PresentationInterface
using Ptr = std::shared_ptr< PresentationInterface >
 
using WeakPtr = std::weak_ptr< PresentationInterface >
 
- Public Types inherited from Viewable
using Ptr = std::shared_ptr< Viewable >
 
using WeakPtr = std::weak_ptr< Viewable >
 
- Public Types inherited from Scroom::Utils::Observable< T >
using Observer = std::shared_ptr< T >
 
using Ptr = std::shared_ptr< Observable< T > >
 
- Public Types inherited from Colormappable
using Ptr = std::shared_ptr< Colormappable >
 
using WeakPtr = std::weak_ptr< Colormappable >
 
- Public Types inherited from PipetteViewInterface
using Ptr = std::shared_ptr< PipetteViewInterface >
 
- Public Types inherited from ShowMetadataInterface
using Ptr = std::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)
 
Scroom::Utils::Context::ConstPtr getContext () const override
 
- Public Member Functions inherited from PresentationBase
void open (ViewInterface::WeakPtr vi) override
 
void close (ViewInterface::WeakPtr vi) override
 
- 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)
 
- 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 >
std::shared_ptr< R > shared_from_this ()
 
template<typename R >
std::shared_ptr< R const > shared_from_this () const
 
For monochrome presentations: Set/Get the current color
Manipulate the "Transparent Background" setting of the presentation

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
 
Scroom::Utils::WeakKeySet< 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 = Scroom::Utils::WeakKeySet< 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::Context::Ptr context
 
Scroom::Utils::StuffList stuff
 
Scroom::Logger logger
 

Member Typedef Documentation

◆ Ptr

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

◆ Views

using anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::Views = Scroom::Utils::WeakKeySet<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
164 : name(name_)
165 , bmd(bmd_)
166 , tbi(tbi_)
167 , properties(properties_)
168 , colormapHelper(colormapHelper_)
169 , pipetteLayerOperation(pipetteLayerOperation_)
171 {
172 }
static Ptr create()
Definition context.cc:15
Scroom::Utils::Context::Ptr context
Definition tiledbitmappresentation.cc:76
Scroom::TiledBitmap::BitmapMetaData bmd
Definition tiledbitmappresentation.cc:70
std::string name
Definition tiledbitmappresentation.cc:69
ColormapHelperBase::Ptr colormapHelper
Definition tiledbitmappresentation.cc:74
TiledBitmapInterface::Ptr tbi
Definition tiledbitmappresentation.cc:71
std::map< std::string, std::string > properties
Definition tiledbitmappresentation.cc:72
PipetteLayerOperations::Ptr pipetteLayerOperation
Definition tiledbitmappresentation.cc:75

Member Function Documentation

◆ add()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::add ( Scroom::Utils::Stuff  s)
inline
139{ stuff.push_back(std::move(s)); }
Scroom::Utils::StuffList stuff
Definition tiledbitmappresentation.cc:77
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70

◆ clearCaches()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::clearCaches ( )
private
176 {
177 for(const Views::value_type& p: views)
178 {
179 ViewInterface::Ptr const v = p.lock();
180 if(v)
181 {
182 if(tbi)
183 {
184 tbi->clearCaches(v);
185 }
186 v->invalidate();
187 }
188 }
189 }
std::shared_ptr< ViewInterface > Ptr
Definition viewinterface.hh:193
PresentationInterfaceStub::Ptr const p
Definition determine-size-test.cc:172

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

Here is the caller graph for this function:

◆ 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
89 {
91 std::move(name_),
92 std::move(bmd_),
93 std::move(tbi_),
94 std::move(properties_),
95 std::move(colormapHelper_),
96 std::move(pipetteLayerOperation_)
97 ));
98 }
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:156
std::shared_ptr< TiledBitmapPresentation > Ptr
Definition tiledbitmappresentation.cc:64

Referenced by anonymous_namespace{tiledbitmappresentation.cc}::OpenTiledBitmapAsPresentation::open().

Here is the caller graph for this function:

◆ disableTransparentBackground()

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

Implements Colormappable.

360 {
361 colormapHelper->disableTransparentBackground();
362 clearCaches();
363 }
void clearCaches()
Definition tiledbitmappresentation.cc:175
Here is the call graph for this function:

◆ getContext()

Scroom::Utils::Context::ConstPtr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getContext ( ) const
overridevirtual

Implements PresentationInterface.

366{ return context; }

◆ getMonochromeColor()

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

Implements Colormappable.

345{ return colormapHelper->getMonochromeColor(); }

◆ getNumberOfColors()

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

Retrieve the number of colors in use by the presentation

Implements Colormappable.

344{ return colormapHelper->getNumberOfColors(); }

◆ getOriginalColormap()

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

Retrieve the images colormap (if any)

Implements Colormappable.

343{ 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.

242 {
244
245 auto intArea = roundOutward(area.intersection(getRect())).to<int>();
246
247 Layer::Ptr const bottomLayer = tbi->getBottomLayer();
249
250 const int totalPixels = intArea.getWidth() * intArea.getHeight();
251
252 if(totalPixels == 0)
253 {
254 return {};
255 }
256
257 // Get start tile (tile_pos_x_start, tile_pos_y_start)
258 const int tile_pos_x_start = intArea.getLeft() / TILESIZE;
259 const int tile_pos_y_start = intArea.getTop() / TILESIZE;
260
261 // Get end tile (tile_pos_x_end, tile_pos_y_end)
262 const int tile_pos_x_end = (intArea.getRight() - 1) / TILESIZE;
263 const int tile_pos_y_end = (intArea.getBottom() - 1) / TILESIZE;
264
265 for(int x = tile_pos_x_start; x <= tile_pos_x_end; x++)
266 {
267 for(int y = tile_pos_y_start; y <= tile_pos_y_end; y++)
268 {
269 ConstTile::Ptr const tile = bottomLayer->getTile(x, y)->getConstTileSync();
270 Scroom::Utils::Rectangle<int> const tile_rectangle(x * TILESIZE, y * TILESIZE, tile->width, tile->height);
271
272 Scroom::Utils::Rectangle<int> inter_rect = tile_rectangle.intersection(intArea);
273 Scroom::Utils::Point<int> const base(x * TILESIZE, y * TILESIZE);
274
275 inter_rect -= base; // rectangle coordinates relative to constTile with topleft corner (0,0)
276
277 pipetteColors = sumPipetteColors(pipetteColors, pipetteLayerOperation->sumPixelValues(inter_rect, tile));
278 }
279 }
280 return dividePipetteColors(pipetteColors, totalPixels);
281 }
#define require(expr)
Definition assertions.hh:30
std::shared_ptr< ConstTile > Ptr
Definition tile.hh:45
std::shared_ptr< Layer > Ptr
Definition tiledbitmaplayer.hh:250
std::vector< std::pair< std::string, double > > PipetteColor
Definition pipettelayeroperations.hh:25
Definition point.hh:28
Definition rectangle.hh:29
Rectangle intersection(const Rectangle &other) const
Definition rectangle.hh:95
Scroom::Utils::Rectangle< double > getRect() override
Definition tiledbitmappresentation.cc:195
Segment< double > roundOutward(Segment< double > s)
Definition linearsegment.hh:240
PipetteLayerOperations::PipetteColor dividePipetteColors(PipetteLayerOperations::PipetteColor elements, const int divisor)
Definition tiledbitmappresentation.cc:48
PipetteLayerOperations::PipetteColor sumPipetteColors(const PipetteLayerOperations::PipetteColor &lhs, const PipetteLayerOperations::PipetteColor &rhs)
Definition tiledbitmappresentation.cc:31
#define TILESIZE
Definition tiledbitmaplayer.hh:27
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.

213 {
214 auto p = properties.find(propertyName);
215 bool found = false;
216 if(p == properties.end())
217 {
218 found = false;
219 value = "";
220 }
221 else
222 {
223 found = true;
224 value = p->second;
225 }
226
227 return found;
228 }
const uint8_t value
Definition blob-tests.cc:114

◆ getRect()

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

Return the dimensions of your presentation

Implements PresentationInterface.

Scroom::Utils::Rectangle< int > rect
Definition opentiledbitmapinterface.hh:47

Referenced by getPixelAverages(), and redraw().

Here is the caller graph for this function:

◆ getTitle()

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

Return the title of the presentation

Implements PresentationInterface.

235{ return name; }

Referenced by showMetadata().

Here is the caller graph for this function:

◆ getTransparentBackground()

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

Implements Colormappable.

365{ return colormapHelper->getTransparentBackground(); }

◆ getViews()

Scroom::Utils::WeakKeySet< ViewInterface::WeakPtr > anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::getViews ( )
overrideprotectedvirtual

Implements PresentationBase.

331{ return views; }

◆ isPropertyDefined()

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

Return true if the named property exists

Implements PresentationInterface.

231 {
232 return properties.end() != properties.find(propertyName);
233 }

◆ 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.

203 {
205
206 if(tbi)
207 {
208 tbi->redraw(vi, cr, presentationArea, zoom);
209 }
210 }
double pixelSizeFromZoom(int zoom)
Definition cairo-helpers.cc:123
void drawOutOfBoundsWithoutBackground(cairo_t *cr, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
Definition cairo-helpers.cc:97
ViewInterface::Ptr const vi
Definition pipette-tests.cc:186
cairo_t * cr
Definition transformpresentation_test.cc:72
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.

338 {
339 colormapHelper->setColormap(colormap);
340 clearCaches();
341 }
Colormap::Ptr const colormap
Definition colormaphelpers_test.cc:55
Here is the call graph for this function:

◆ setMonochromeColor()

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

Implements Colormappable.

348 {
349 colormapHelper->setMonochromeColor(c);
350 clearCaches();
351 }
Semaphore c(0)
Here is the call graph for this function:

◆ setTransparentBackground()

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

Implements Colormappable.

354 {
355 colormapHelper->setTransparentBackground();
356 clearCaches();
357 }
Here is the call graph for this function:

◆ showMetadata()

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

Show all metadata in the image properties window for a tiledbitmappresentation @override the base showMetadata() function in PresentationBase

Implements ShowMetadataInterface.

292 {
293 const std::string filepath = getTitle();
294 const std::string title = "Properties: " + filepath.substr(filepath.find_last_of("/\\") + 1);
295
297 }
std::string getTitle() override
Definition tiledbitmappresentation.cc:235
void showMetaData(GtkWindow *parent, std::string title, Metadata data)
Definition showmetadata.cc:68
Metadata::Metadata to_metadata(const BitmapMetaData &bmd)
Definition layerspecforbitmap.cc:35
Here is the call graph for this function:

◆ viewAdded()

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

Implements PresentationBase.

304 {
305 views.insert(viewInterface);
306
307 if(tbi)
308 {
309 tbi->open(viewInterface);
310 }
311 else
312 {
313 logger->error("TiffPresentation::open(): No TiledBitmapInterface available!");
314 }
315 }
Scroom::Logger logger
Definition tiledbitmappresentation.cc:78

◆ viewRemoved()

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

Implements PresentationBase.

318 {
319 views.erase(vi);
320
321 if(tbi)
322 {
323 tbi->close(vi);
324 }
325 else
326 {
327 logger->error("TiffPresentation::close(): No TiledBitmapInterface available!");
328 }
329 }

Member Data Documentation

◆ bmd

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

◆ colormapHelper

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

◆ context

Scroom::Utils::Context::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::context
private

◆ logger

Scroom::Logger anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::logger
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: