Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
TransparentOverlayPresentation Class Reference

#include <transparentoverlaypresentation.hh>

Inheritance diagram for TransparentOverlayPresentation:
Inheritance graph
Collaboration diagram for TransparentOverlayPresentation:
Collaboration graph

Public Types

using Ptr = std::shared_ptr< TransparentOverlayPresentation >
 
- 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 Aggregate
using Ptr = std::shared_ptr< Aggregate >
 

Public Member Functions

Scroom::Utils::Rectangle< double > getRect () override
 
void redraw (ViewInterface::Ptr const &vi, cairo_t *cr, Scroom::Utils::Rectangle< double > presentationArea, int zoom) override
 
bool getProperty (const std::string &name, std::string &value) override
 
bool isPropertyDefined (const std::string &name) override
 
std::string getTitle () override
 
void viewAdded (ViewInterface::WeakPtr vi) override
 
void viewRemoved (ViewInterface::WeakPtr vi) override
 
Scroom::Utils::WeakKeySet< ViewInterface::WeakPtrgetViews () override
 
void addPresentation (PresentationInterface::Ptr const &p) override
 
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
 

Static Public Member Functions

static Ptr create ()
 

Private Types

using ViewDataMap = Scroom::Utils::WeakKeyMap< ViewInterface::WeakPtr, TransparentOverlayViewInfo::Ptr >
 

Private Member Functions

 TransparentOverlayPresentation ()
 
void setOptimalColor (PresentationInterface::Ptr const &p)
 

Private Attributes

std::list< PresentationInterface::Ptrchildren
 
SizeDeterminer::Ptr sizeDeterminer
 
ViewDataMap viewData
 
Scroom::Utils::RecursiveContext::Ptr context
 

Additional Inherited Members

- 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)
 

Member Typedef Documentation

◆ Ptr

◆ ViewDataMap

Constructor & Destructor Documentation

◆ TransparentOverlayPresentation()

TransparentOverlayPresentation::TransparentOverlayPresentation ( )
private
43{
44}
static Ptr create()
Definition context.cc:16
static Ptr create()
Definition sizedeterminer.cc:66
Scroom::Utils::RecursiveContext::Ptr context
Definition transparentoverlaypresentation.hh:39
SizeDeterminer::Ptr sizeDeterminer
Definition transparentoverlaypresentation.hh:36

Referenced by create().

Here is the caller graph for this function:

Member Function Documentation

◆ addPresentation()

void TransparentOverlayPresentation::addPresentation ( PresentationInterface::Ptr const &  p)
overridevirtual

Implements Aggregate.

47{
48 if(p)
49 {
50 context->add(p->getContext());
51
52 if(p->isPropertyDefined(MONOCHROME_COLORMAPPABLE_PROPERTY_NAME))
53 {
55 }
56
57 children.push_back(p);
58 sizeDeterminer->add(p);
59
60 for(ViewDataMap::value_type const& v: viewData)
61 {
62 v.second->addChild(p);
63 }
64 }
65 else
66 {
67 defect_message("Can't add a nonexistent presentation");
68 }
69}
#define defect_message(m)
Definition assertions.hh:49
void setOptimalColor(PresentationInterface::Ptr const &p)
Definition transparentoverlaypresentation.cc:71
ViewDataMap viewData
Definition transparentoverlaypresentation.hh:38
std::list< PresentationInterface::Ptr > children
Definition transparentoverlaypresentation.hh:35
const std::string MONOCHROME_COLORMAPPABLE_PROPERTY_NAME
Definition colormappable.hh:20
PresentationInterfaceStub::Ptr const p
Definition determine-size-test.cc:172
Here is the call graph for this function:

◆ create()

TransparentOverlayPresentation::Ptr TransparentOverlayPresentation::create ( )
static
38{ return Ptr(new TransparentOverlayPresentation()); }
TransparentOverlayPresentation()
Definition transparentoverlaypresentation.cc:40
std::shared_ptr< TransparentOverlayPresentation > Ptr
Definition transparentoverlaypresentation.hh:29

Referenced by TransparentOverlay::createNew().

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

◆ getContext()

Scroom::Utils::Context::ConstPtr TransparentOverlayPresentation::getContext ( ) const
overridevirtual

Implements PresentationInterface.

168{ return context; }

◆ getProperty()

bool TransparentOverlayPresentation::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.

146{ return false; }

◆ getRect()

Scroom::Utils::Rectangle< double > TransparentOverlayPresentation::getRect ( )
overridevirtual

Return the dimensions of your presentation

Implements PresentationInterface.

102{ return sizeDeterminer->getRect(); }

◆ getTitle()

std::string TransparentOverlayPresentation::getTitle ( )
overridevirtual

Return the title of the presentation

Implements PresentationInterface.

151{
152 std::stringstream s;
153 s << "Overlay(";
154 bool hasPrevious = false;
155 for(PresentationInterface::Ptr const& child: children)
156 {
157 if(hasPrevious)
158 {
159 s << ", ";
160 }
161 s << child->getTitle();
162 hasPrevious = true;
163 }
164 s << ")";
165
166 return s.str();
167}
std::shared_ptr< PresentationInterface > Ptr
Definition presentationinterface.hh:73
BitmapSurface::Ptr const s
Definition transformpresentation_test.cc:70

◆ getViews()

Scroom::Utils::WeakKeySet< ViewInterface::WeakPtr > TransparentOverlayPresentation::getViews ( )
overridevirtual

Implements PresentationBase.

122{
124 for(auto const& p: viewData)
125 {
126 result.insert(p.first);
127 }
128
129 return result;
130}
std::set< K, std::owner_less< K > > WeakKeySet
Definition utilities.hh:121
SampleIterator< const uint8_t > result
Definition sampleiterator-tests.cc:94

◆ isPropertyDefined()

bool TransparentOverlayPresentation::isPropertyDefined ( const std::string &  name)
overridevirtual

Return true if the named property exists

Implements PresentationInterface.

148{ return false; }

◆ redraw()

void TransparentOverlayPresentation::redraw ( ViewInterface::Ptr const &  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.

138{
139 auto e = viewData.find(vi);
140 if(e != viewData.end())
141 {
142 e->second->redraw(cr, presentationArea, zoom);
143 }
144}
ViewInterface::Ptr const vi
Definition pipette-tests.cc:186
cairo_t * cr
Definition transformpresentation_test.cc:72

◆ setOptimalColor()

void TransparentOverlayPresentation::setOptimalColor ( PresentationInterface::Ptr const &  p)
private
72{
73 Colormappable::Ptr const c = std::dynamic_pointer_cast<Colormappable>(p);
74 if(c)
75 {
76 std::map<Color, int, ColorComparer> currentColors;
77 for(PresentationInterface::Ptr const& child: children)
78 {
79 Colormappable::Ptr const cChild = std::dynamic_pointer_cast<Colormappable>(child);
80 if(cChild && child->isPropertyDefined(MONOCHROME_COLORMAPPABLE_PROPERTY_NAME))
81 {
82 currentColors[cChild->getMonochromeColor()]++;
83 }
84 }
85
86 Color minimumColor = c->getMonochromeColor();
87 int minimumColorValue = currentColors[minimumColor];
88
89 for(Color const& color: colors)
90 {
91 if(currentColors[color] < minimumColorValue)
92 {
93 minimumColor = color;
94 minimumColorValue = currentColors[color];
95 }
96 }
97
98 c->setMonochromeColor(minimumColor);
99 }
100}
Definition color.hh:37
std::shared_ptr< Colormappable > Ptr
Definition colormappable.hh:114
const std::list< Color > colors
Definition transparentoverlaypresentation.cc:22
Semaphore c(0)

Referenced by addPresentation().

Here is the caller graph for this function:

◆ viewAdded()

void TransparentOverlayPresentation::viewAdded ( ViewInterface::WeakPtr  vi)
overridevirtual

Implements PresentationBase.

105{
107 tovi->addChildren(children);
108 viewData[vi] = tovi;
109}
std::shared_ptr< TransparentOverlayViewInfo > Ptr
Definition transparentoverlayviewinfo.hh:62
static Ptr create(const ViewInterface::WeakPtr &vi, SizeDeterminer::Ptr const &sizeDeterminer)
Definition transparentoverlayviewinfo.cc:127
Here is the call graph for this function:

◆ viewRemoved()

void TransparentOverlayPresentation::viewRemoved ( ViewInterface::WeakPtr  vi)
overridevirtual

Implements PresentationBase.

112{
113 auto e = viewData.find(vi);
114 if(e != viewData.end())
115 {
116 e->second->close();
117 viewData.erase(e->first);
118 }
119}

Member Data Documentation

◆ children

std::list<PresentationInterface::Ptr> TransparentOverlayPresentation::children
private

◆ context

Scroom::Utils::RecursiveContext::Ptr TransparentOverlayPresentation::context
private

Referenced by addPresentation(), and getContext().

◆ sizeDeterminer

SizeDeterminer::Ptr TransparentOverlayPresentation::sizeDeterminer
private

Referenced by addPresentation(), getRect(), and viewAdded().

◆ viewData

ViewDataMap TransparentOverlayPresentation::viewData
private

The documentation for this class was generated from the following files: