Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Viewport/IViewport.h @ 1852:5ead1852095a StoneWebViewer-2.1
StoneWebViewer-2.1
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Jun 2021 16:26:47 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1577
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1577
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1577
diff
changeset
|
15 * Lesser General Public License for more details. |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1577
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1577
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1577
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #pragma once |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
905
88bf49aebc13
introduced ICompositor and allow SdlViewport to work with a CairoCompositor (to run on machines without OpenGL drivers)
Alain Mazy <alain@mazy.be>
parents:
891
diff
changeset
|
24 #include "../Scene2D/ICompositor.h" |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 namespace OrthancStone |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 { |
1558 | 28 class ViewportController; |
29 | |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 /** |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 * Class that combines a Scene2D with a canvas where to draw the |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 * scene. A call to "Refresh()" will update the content of the |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
33 * canvas. A "IViewport" can possibly be accessed from several |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
34 * threads depending on the rendering back-end (e.g. in SDL or Qt): |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
35 * The "ILock" subclass implements the locking mechanism to modify |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
36 * the content of the scene. |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
37 * |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
38 * NB: The lock must be a "recursive_mutex", as the viewport |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
39 * controller can lock it a second time (TODO - Why so?). |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 **/ |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 class IViewport : public boost::noncopyable |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 public: |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
44 class ILock : public boost::noncopyable |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
45 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
46 public: |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
47 virtual ~ILock() |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
48 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
49 } |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
50 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
51 virtual bool HasCompositor() const = 0; |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
52 |
1306
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
53 /** |
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
54 Do not store the result! Only access the compositor interface through |
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
55 the lock. |
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
56 */ |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
57 virtual ICompositor& GetCompositor() = 0; |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
58 |
1306
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
59 /** |
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
60 Do not store the result! Only access the compositor interface through |
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
61 the lock. |
fef1ec42a7db
Some docs + headers added to CMake for easier VS browsing + tiny predecl
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
62 */ |
1216
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
63 virtual ViewportController& GetController() = 0; |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
64 |
5147277850cf
better abstraction for IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1215
diff
changeset
|
65 virtual void Invalidate() = 0; |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1558
diff
changeset
|
66 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1558
diff
changeset
|
67 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1558
diff
changeset
|
68 /** |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1558
diff
changeset
|
69 * This function must be called when the layout has changed, and |
1577 | 70 * thus the size of the canvas must be re-computed. After a call |
71 * to this method, the canvas size can be accessed through | |
72 * "GetCompositor().GetCanvasWidth()" and | |
73 * "GetCompositor().GetCanvasHeight()". Avoid calling this | |
74 * method too often for performance. | |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1558
diff
changeset
|
75 **/ |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1558
diff
changeset
|
76 virtual void RefreshCanvasSize() = 0; |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
77 }; |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
78 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 virtual ~IViewport() |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 { |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1148
diff
changeset
|
83 virtual ILock* Lock() = 0; |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 }; |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |