Scroom  0.14
presentationinterface.hh
Go to the documentation of this file.
1 /*
2  * Scroom - Generic viewer for 2D data
3  * Copyright (C) 2009-2022 Kees-Jan Dijkzeul
4  *
5  * SPDX-License-Identifier: LGPL-2.1
6  */
7 
8 #pragma once
9 
10 #include <set>
11 
12 #include <boost/shared_ptr.hpp>
13 #include <boost/weak_ptr.hpp>
14 
15 #include <gdk/gdk.h>
16 
17 #include <cairo.h>
18 
19 #include <scroom/interface.hh>
20 #include <scroom/observable.hh>
21 #include <scroom/rectangle.hh>
22 #include <scroom/viewinterface.hh>
23 
32 class Viewable : private Interface
33 {
34 public:
35  using Ptr = boost::shared_ptr<Viewable>;
36  using WeakPtr = boost::weak_ptr<Viewable>;
37 
38 public:
46  virtual void open(ViewInterface::WeakPtr vi) = 0;
47 
55  virtual void close(ViewInterface::WeakPtr vi) = 0;
56 };
57 
59 
70  : public Viewable
71  , public ViewObservable
72 {
73 public:
74  using Ptr = boost::shared_ptr<PresentationInterface>;
75  using WeakPtr = boost::weak_ptr<PresentationInterface>;
76 
79 
92  virtual void redraw(ViewInterface::Ptr const& vi, cairo_t* cr, Scroom::Utils::Rectangle<double> presentationArea, int zoom) = 0;
93 
102  virtual bool getProperty(const std::string& name, std::string& value) = 0;
103 
105  virtual bool isPropertyDefined(const std::string& name) = 0;
106 
108  virtual std::string getTitle() = 0;
109 
111 };
112 
114 {
115 public:
116  // Viewable
117  void open(ViewInterface::WeakPtr vi) override;
118  void close(ViewInterface::WeakPtr vi) override;
119 
120 protected:
121  // ViewObservable
122  void observerAdded(Viewable::Ptr const& viewable, Scroom::Bookkeeping::Token const& t) override;
123 
124 protected:
125  virtual void viewAdded(ViewInterface::WeakPtr vi) = 0;
126  virtual void viewRemoved(ViewInterface::WeakPtr vi) = 0;
127  virtual std::set<ViewInterface::WeakPtr> getViews() = 0;
128 };
129 
131 {
132 private:
133  std::set<ViewInterface::WeakPtr> views;
134 
135 private:
136  void viewAdded(ViewInterface::WeakPtr vi) final { views.insert(vi); }
137  void viewRemoved(ViewInterface::WeakPtr vi) final { views.erase(vi); }
138  std::set<ViewInterface::WeakPtr> getViews() final { return views; }
139 };
140 
144 class Aggregate : private Interface
145 {
146 public:
147  using Ptr = boost::shared_ptr<Aggregate>;
148 
149 public:
150  virtual void addPresentation(PresentationInterface::Ptr const& presentation) = 0;
151 };
PresentationBase::getViews
virtual std::set< ViewInterface::WeakPtr > getViews()=0
Viewable::open
virtual void open(ViewInterface::WeakPtr vi)=0
PresentationInterface
Definition: presentationinterface.hh:69
Viewable::close
virtual void close(ViewInterface::WeakPtr vi)=0
Viewable::WeakPtr
boost::weak_ptr< Viewable > WeakPtr
Definition: presentationinterface.hh:36
PresentationBaseSimple::views
std::set< ViewInterface::WeakPtr > views
Definition: presentationinterface.hh:133
PresentationInterface::getAspectRatio
virtual Scroom::Utils::Point< double > getAspectRatio() const
Definition: presentationinterface.hh:110
PresentationInterface::redraw
virtual void redraw(ViewInterface::Ptr const &vi, cairo_t *cr, Scroom::Utils::Rectangle< double > presentationArea, int zoom)=0
ViewInterface::Ptr
boost::shared_ptr< ViewInterface > Ptr
Definition: viewinterface.hh:193
Aggregate::addPresentation
virtual void addPresentation(PresentationInterface::Ptr const &presentation)=0
Aggregate
Definition: presentationinterface.hh:144
observable.hh
PresentationBase::viewRemoved
virtual void viewRemoved(ViewInterface::WeakPtr vi)=0
Scroom::Utils::make_point
Point< T > make_point(T x, T y)
Definition: point.hh:116
PresentationInterface::isPropertyDefined
virtual bool isPropertyDefined(const std::string &name)=0
PresentationBase::observerAdded
void observerAdded(Viewable::Ptr const &viewable, Scroom::Bookkeeping::Token const &t) override
Definition: presentationinterface.cc:35
PresentationInterface::getTitle
virtual std::string getTitle()=0
PresentationInterface::Ptr
boost::shared_ptr< PresentationInterface > Ptr
Definition: presentationinterface.hh:74
ViewInterface::WeakPtr
boost::weak_ptr< ViewInterface > WeakPtr
Definition: viewinterface.hh:194
Scroom::Utils::Observable::Ptr
boost::shared_ptr< Observable< T > > Ptr
Definition: observable.hh:75
PresentationInterface::getProperty
virtual bool getProperty(const std::string &name, std::string &value)=0
PresentationBaseSimple::viewRemoved
void viewRemoved(ViewInterface::WeakPtr vi) final
Definition: presentationinterface.hh:137
PresentationBase::open
void open(ViewInterface::WeakPtr vi) override
Definition: presentationinterface.cc:11
PresentationBase::viewAdded
virtual void viewAdded(ViewInterface::WeakPtr vi)=0
PresentationInterface::getRect
virtual Scroom::Utils::Rectangle< double > getRect()=0
PresentationBase
Definition: presentationinterface.hh:113
Scroom::Utils::Observable
Definition: observable.hh:24
viewinterface.hh
PresentationBase::close
void close(ViewInterface::WeakPtr vi) override
Definition: presentationinterface.cc:23
Interface
Definition: interface.hh:10
PresentationBaseSimple
Definition: presentationinterface.hh:130
Viewable
Definition: presentationinterface.hh:32
PresentationBaseSimple::getViews
std::set< ViewInterface::WeakPtr > getViews() final
Definition: presentationinterface.hh:138
Scroom::Bookkeeping::Token
Definition: bookkeeping.hh:37
Scroom::Utils::Rectangle< double >
Viewable::Ptr
boost::shared_ptr< Viewable > Ptr
Definition: presentationinterface.hh:35
interface.hh
rectangle.hh
Aggregate::Ptr
boost::shared_ptr< Aggregate > Ptr
Definition: presentationinterface.hh:147
PresentationBaseSimple::viewAdded
void viewAdded(ViewInterface::WeakPtr vi) final
Definition: presentationinterface.hh:136
Scroom::Utils::Point< double >