Scroom 0.14-49-gb7ae7a6d
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::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
163 : name(name_)
164 , bmd(bmd_)
165 , tbi(tbi_)
166 , properties(properties_)
167 , colormapHelper(colormapHelper_)
168 , pipetteLayerOperation(pipetteLayerOperation_)
169 {
170 }
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
138{ stuff.push_back(std::move(s)); }
Scroom::Utils::StuffList stuff
Definition tiledbitmappresentation.cc:76
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70

◆ clearCaches()

void anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::clearCaches ( )
private
174 {
175 for(const Views::value_type& p: views)
176 {
177 ViewInterface::Ptr const v = p.lock();
178 if(v)
179 {
180 if(tbi)
181 {
182 tbi->clearCaches(v);
183 }
184 v->invalidate();
185 }
186 }
187 }
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
88 {
90 std::move(name_),
91 std::move(bmd_),
92 std::move(tbi_),
93 std::move(properties_),
94 std::move(colormapHelper_),
95 std::move(pipetteLayerOperation_)
96 ));
97 }
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:155
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.

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

◆ getContext()

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

Implements PresentationInterface.

364{ return tbi->getContext(); }

◆ getMonochromeColor()

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

Implements Colormappable.

343{ return colormapHelper->getMonochromeColor(); }

◆ getNumberOfColors()

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

Retrieve the number of colors in use by the presentation

Implements Colormappable.

342{ return colormapHelper->getNumberOfColors(); }

◆ getOriginalColormap()

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

Retrieve the images colormap (if any)

Implements Colormappable.

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

240 {
242
243 auto intArea = roundOutward(area.intersection(getRect())).to<int>();
244
245 Layer::Ptr const bottomLayer = tbi->getBottomLayer();
247
248 const int totalPixels = intArea.getWidth() * intArea.getHeight();
249
250 if(totalPixels == 0)
251 {
252 return {};
253 }
254
255 // Get start tile (tile_pos_x_start, tile_pos_y_start)
256 const int tile_pos_x_start = intArea.getLeft() / TILESIZE;
257 const int tile_pos_y_start = intArea.getTop() / TILESIZE;
258
259 // Get end tile (tile_pos_x_end, tile_pos_y_end)
260 const int tile_pos_x_end = (intArea.getRight() - 1) / TILESIZE;
261 const int tile_pos_y_end = (intArea.getBottom() - 1) / TILESIZE;
262
263 for(int x = tile_pos_x_start; x <= tile_pos_x_end; x++)
264 {
265 for(int y = tile_pos_y_start; y <= tile_pos_y_end; y++)
266 {
267 ConstTile::Ptr const tile = bottomLayer->getTile(x, y)->getConstTileSync();
268 Scroom::Utils::Rectangle<int> const tile_rectangle(x * TILESIZE, y * TILESIZE, tile->width, tile->height);
269
270 Scroom::Utils::Rectangle<int> inter_rect = tile_rectangle.intersection(intArea);
271 Scroom::Utils::Point<int> const base(x * TILESIZE, y * TILESIZE);
272
273 inter_rect -= base; // rectangle coordinates relative to constTile with topleft corner (0,0)
274
275 pipetteColors = sumPipetteColors(pipetteColors, pipetteLayerOperation->sumPixelValues(inter_rect, tile));
276 }
277 }
278 return dividePipetteColors(pipetteColors, totalPixels);
279 }
#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:193
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.

211 {
212 auto p = properties.find(propertyName);
213 bool found = false;
214 if(p == properties.end())
215 {
216 found = false;
217 value = "";
218 }
219 else
220 {
221 found = true;
222 value = p->second;
223 }
224
225 return found;
226 }
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.

233{ return name; }

Referenced by showMetadata().

Here is the caller graph for this function:

◆ getTransparentBackground()

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

Implements Colormappable.

363{ return colormapHelper->getTransparentBackground(); }

◆ getViews()

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

Implements PresentationBase.

329{ return views; }

◆ isPropertyDefined()

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

Return true if the named property exists

Implements PresentationInterface.

229 {
230 return properties.end() != properties.find(propertyName);
231 }

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

201 {
203
204 if(tbi)
205 {
206 tbi->redraw(vi, cr, presentationArea, zoom);
207 }
208 }
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.

336 {
337 colormapHelper->setColormap(colormap);
338 clearCaches();
339 }
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.

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

◆ setTransparentBackground()

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

Implements Colormappable.

352 {
353 colormapHelper->setTransparentBackground();
354 clearCaches();
355 }
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.

290 {
291 const std::string filepath = getTitle();
292 const std::string title = "Properties: " + filepath.substr(filepath.find_last_of("/\\") + 1);
293
295 }
std::string getTitle() override
Definition tiledbitmappresentation.cc:233
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.

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

◆ viewRemoved()

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

Implements PresentationBase.

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

Member Data Documentation

◆ bmd

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

◆ colormapHelper

ColormapHelperBase::Ptr anonymous_namespace{tiledbitmappresentation.cc}::TiledBitmapPresentation::colormapHelper
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: