annotate Framework/Wrappers/CairoContext.h @ 1313:f30905f5d246 broker

Added support for OnGenericSdlEvent to GuiAdapter. This makes it possible to piggyback app-specific logic to special events (here, to support the Viewport refresh events)
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 16 Mar 2020 11:12:39 +0100
parents 2d8ab34c8c91
children 30deba7bc8e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * Affero General Public License for more details.
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
16 *
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "CairoSurface.h"
366
a7de01c8fd29 new enum BitmapAnchor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 365
diff changeset
25 #include "../StoneEnumerations.h"
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
365
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
27 #include <Core/Images/Font.h>
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
28
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 // This is a RAII wrapper around the Cairo drawing context
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class CairoContext : public boost::noncopyable
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 private:
365
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
35 class AlphaSurface;
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
36
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
37 cairo_t* context_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
38 unsigned int width_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
39 unsigned int height_;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 public:
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 CairoContext(CairoSurface& surface);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 ~CairoContext();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 cairo_t* GetObject()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 return context_;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
51 unsigned int GetWidth() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
52 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
53 return width_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
54 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
55
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
56 unsigned int GetHeight() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
57 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
58 return height_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
59 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 134
diff changeset
60
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 void SetSourceColor(uint8_t red,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 uint8_t green,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 uint8_t blue);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 void SetSourceColor(const uint8_t color[3])
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 SetSourceColor(color[0], color[1], color[2]);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
365
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
69
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
70 void DrawText(const Orthanc::Font& font,
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
71 const std::string& text,
ef31240a73f6 no automatic call to moc and uic, CircleMeasureTracker using Orthanc fonts
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
72 double x,
366
a7de01c8fd29 new enum BitmapAnchor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 365
diff changeset
73 double y,
a7de01c8fd29 new enum BitmapAnchor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 365
diff changeset
74 BitmapAnchor anchor);
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 };
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }