Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
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
 
ExamplePresentationoperator= (const ExamplePresentation &)=delete
 
ExamplePresentation operator= (ExamplePresentation &&)=delete
 
Scroom::Utils::Context::ConstPtr getContext () const override
 
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 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
 

Private Member Functions

void fillPattern ()
 

Private Attributes

Scroom::Utils::Context::Ptr context
 
cairo_pattern_t * pattern {nullptr}
 

Additional Inherited Members

- 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 > >
 
- 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 ( )
19{
21}
Scroom::Utils::Context::Ptr context
Definition examplepresentation.hh:21
void fillPattern()
Definition examplepresentation.cc:25
static Ptr create()
Definition context.cc:15
Here is the call graph for this function:

◆ ~ExamplePresentation()

ExamplePresentation::~ExamplePresentation ( )
override
23{ cairo_pattern_destroy(pattern); }
cairo_pattern_t * pattern
Definition examplepresentation.hh:24

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

57{}

◆ fillPattern()

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

Referenced by ExamplePresentation().

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

◆ getContext()

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

Implements PresentationInterface.

87{ return context; }

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

82{ return false; }

◆ getRect()

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

Return the dimensions of your presentation

Implements PresentationInterface.

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

86{ return ""; }

◆ isPropertyDefined()

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

Return true if the named property exists

Implements PresentationInterface.

84{ return false; }

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

55{}

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

60{
61 cairo_rectangle_int_t const presentationArea = pa.toGdkRectangle();
62 const double pp = pixelSizeFromZoom(zoom);
63 const double scale = pow(2, -zoom);
64
65 Scroom::Utils::Rectangle<double> const actualPresentationArea = getRect();
66 drawOutOfBoundsWithBackground(cr, pa, actualPresentationArea, pp);
67
68 const int xorig = static_cast<int>(-presentationArea.x * pp);
69 const int yorig = static_cast<int>(-presentationArea.y * pp);
70
71 cairo_matrix_t m;
72 cairo_matrix_init_translate(&m, 505, 505);
73 cairo_matrix_scale(&m, scale, scale);
74 cairo_matrix_translate(&m, -xorig, -yorig);
75 cairo_pattern_set_matrix(pattern, &m);
76 cairo_mask(cr, pattern);
77
78 // cairo_set_source_surface(cr, surface, xorig-505, yorig-505);
79 // cairo_paint(cr);
80}
void drawOutOfBoundsWithBackground(cairo_t *cr, Scroom::Utils::Rectangle< double > const &requestedPresentationArea, Scroom::Utils::Rectangle< double > const &actualPresentationArea, double pixelSize)
Definition cairo-helpers.cc:74
double pixelSizeFromZoom(int zoom)
Definition cairo-helpers.cc:123
Scroom::Utils::Rectangle< double > getRect() override
Definition examplepresentation.cc:53
Definition rectangle.hh:29
cairo_rectangle_int_t toGdkRectangle() const
Definition rectangle.hh:62
Here is the call graph for this function:

Member Data Documentation

◆ context

Scroom::Utils::Context::Ptr ExamplePresentation::context
private

Referenced by getContext().

◆ pattern

cairo_pattern_t* ExamplePresentation::pattern {nullptr}
private
24{nullptr};

Referenced by fillPattern(), redraw(), and ~ExamplePresentation().


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