Scroom  0.14
ExamplePresentation Class Reference

#include <examplepresentation.hh>

Inheritance diagram for ExamplePresentation:
Inheritance graph
Collaboration diagram for ExamplePresentation:
Collaboration graph

Public Member Functions

 ExamplePresentation ()
 
 ~ExamplePresentation () override
 
 ExamplePresentation (const ExamplePresentation &)=delete
 
 ExamplePresentation (ExamplePresentation &&)=delete
 
ExamplePresentation operator= (const ExamplePresentation &)=delete
 
ExamplePresentation operator= (ExamplePresentation &&)=delete
 
Scroom::Utils::Rectangle< double > getRect () override
 
void open (ViewInterface::WeakPtr viewInterface) override
 
void redraw (ViewInterface::Ptr const &vi, cairo_t *cr, Scroom::Utils::Rectangle< double > presentationArea, int zoom) override
 
void close (ViewInterface::WeakPtr vi) override
 
bool getProperty (const std::string &name, std::string &value) override
 
bool isPropertyDefined (const std::string &name) override
 
std::string getTitle () 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)
 

Private Member Functions

void fillPattern ()
 

Private Attributes

cairo_pattern_t * pattern {nullptr}
 

Additional Inherited Members

- 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 > >
 
- Protected Member Functions inherited from Scroom::Utils::Observable< T >
std::list< ObservergetObservers ()
 
virtual void observerAdded (Observer const &observer, Scroom::Bookkeeping::Token const &token)
 

Constructor & Destructor Documentation

◆ ExamplePresentation() [1/3]

ExamplePresentation::ExamplePresentation ( )
17 { fillPattern(); }
Here is the call graph for this function:

◆ ~ExamplePresentation()

ExamplePresentation::~ExamplePresentation ( )
override
19 { cairo_pattern_destroy(pattern); }

◆ ExamplePresentation() [2/3]

ExamplePresentation::ExamplePresentation ( const ExamplePresentation )
delete

◆ ExamplePresentation() [3/3]

ExamplePresentation::ExamplePresentation ( ExamplePresentation &&  )
delete

Member Function Documentation

◆ close()

void ExamplePresentation::close ( ViewInterface::WeakPtr  vi)
overridevirtual

Gets called just before the View is destroyed

Precondition
Should be called from within a Gdk critical section (i.e. between gdk_threads_enter() and gdk_threads_leave() calls)

Implements Viewable.

53 { UNUSED(vi); }

◆ fillPattern()

void ExamplePresentation::fillPattern ( )
private
22 {
23  cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_A1, 1010, 1010);
24  cairo_t* cr = cairo_create(surface);
25 
26  const int xorig = 505;
27  const int yorig = 505;
28 
29  for(int i = -500; i <= 500; i += 50)
30  {
31  cairo_move_to(cr, xorig - 500, yorig + i);
32  cairo_line_to(cr, xorig + 500, yorig + i);
33  cairo_move_to(cr, xorig + i, yorig - 500);
34  cairo_line_to(cr, xorig + i, yorig + 500);
35  }
36  cairo_move_to(cr, xorig - 500, yorig - 500);
37  cairo_line_to(cr, xorig + 500, yorig + 500);
38  cairo_move_to(cr, xorig - 500, yorig + 500);
39  cairo_line_to(cr, xorig + 500, yorig - 500);
40 
41  cairo_stroke(cr);
42 
43  pattern = cairo_pattern_create_for_surface(cairo_get_target(cr));
44 
45  cairo_destroy(cr);
46  cairo_surface_destroy(surface);
47 }

Referenced by ExamplePresentation().

Here is the caller graph for this function:

◆ getProperty()

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

80 {
81  UNUSED(name);
82  UNUSED(value);
83 
84  return false;
85 }

◆ getRect()

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

Return the dimensions of your presentation

Implements PresentationInterface.

49 { return {-500, -500, 1000, 1000}; }

Referenced by redraw().

Here is the caller graph for this function:

◆ getTitle()

std::string ExamplePresentation::getTitle ( )
overridevirtual

Return the title of the presentation

Implements PresentationInterface.

93 { return ""; }

◆ isPropertyDefined()

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

Return true if the named property exists

Implements PresentationInterface.

87 {
88  UNUSED(name);
89 
90  return false;
91 }

◆ open()

void ExamplePresentation::open ( ViewInterface::WeakPtr  vi)
overridevirtual

Gets called just after the View is created

Precondition
Should be called from within a Gdk critical section (i.e. between gdk_threads_enter() and gdk_threads_leave() calls)

Implements Viewable.

51 { UNUSED(viewInterface); }

◆ operator=() [1/2]

ExamplePresentation ExamplePresentation::operator= ( const ExamplePresentation )
delete

◆ operator=() [2/2]

ExamplePresentation ExamplePresentation::operator= ( ExamplePresentation &&  )
delete

◆ redraw()

void ExamplePresentation::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.

56 {
57  cairo_rectangle_int_t const presentationArea = pa.toGdkRectangle();
58  UNUSED(vi);
59  const double pp = pixelSizeFromZoom(zoom);
60  const double scale = pow(2, -zoom);
61 
62  Scroom::Utils::Rectangle<double> const actualPresentationArea = getRect();
63  drawOutOfBoundsWithBackground(cr, pa, actualPresentationArea, pp);
64 
65  const int xorig = static_cast<int>(-presentationArea.x * pp);
66  const int yorig = static_cast<int>(-presentationArea.y * pp);
67 
68  cairo_matrix_t m;
69  cairo_matrix_init_translate(&m, 505, 505);
70  cairo_matrix_scale(&m, scale, scale);
71  cairo_matrix_translate(&m, -xorig, -yorig);
72  cairo_pattern_set_matrix(pattern, &m);
73  cairo_mask(cr, pattern);
74 
75  // cairo_set_source_surface(cr, surface, xorig-505, yorig-505);
76  // cairo_paint(cr);
77 }
Here is the call graph for this function:

Member Data Documentation

◆ pattern

cairo_pattern_t* ExamplePresentation::pattern {nullptr}
private

The documentation for this class was generated from the following files:
UNUSED
#define UNUSED(x)
Definition: unused.hh:10
ExamplePresentation::fillPattern
void fillPattern()
Definition: examplepresentation.cc:21
drawOutOfBoundsWithBackground
void drawOutOfBoundsWithBackground(cairo_t *cr, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
Definition: cairo-helpers.cc:74
ExamplePresentation::pattern
cairo_pattern_t * pattern
Definition: examplepresentation.hh:21
pixelSizeFromZoom
double pixelSizeFromZoom(int zoom)
Definition: cairo-helpers.cc:112
Scroom::Utils::Rectangle::toGdkRectangle
cairo_rectangle_int_t toGdkRectangle() const
Definition: rectangle.hh:62
Scroom::Utils::Rectangle< double >
ExamplePresentation::getRect
Scroom::Utils::Rectangle< double > getRect() override
Definition: examplepresentation.cc:49