Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/Internals/OpenGLBasicPolylineRenderer.cpp @ 1597:f9e3a9c21c0f
removed annoying whitespace
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 26 Oct 2020 18:11:20 +0100 |
parents | 85e117739eca |
children | 8563ea5d8ae4 |
rev | line source |
---|---|
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
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:
947
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
655
1e26bb5f2a02
Fixed truncating conversion warnings + fixed deletion of incomplete type
Benjamin Golinvaux <bgo@osimis.io>
parents:
593
diff
changeset
|
16 * |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "OpenGLBasicPolylineRenderer.h" |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "../../OpenGL/OpenGLIncludes.h" |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 namespace OrthancStone |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 namespace Internals |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 OpenGLBasicPolylineRenderer::OpenGLBasicPolylineRenderer(OpenGL::IOpenGLContext& context, |
804
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
655
diff
changeset
|
31 const PolylineSceneLayer& layer) : |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 context_(context) |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 layer_.Copy(layer); |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
1571 | 37 void OpenGLBasicPolylineRenderer::Render(const AffineTransform2D& transform, |
38 unsigned int canvasWidth, | |
39 unsigned int canvasHeight) | |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
41 if (!context_.IsContextLost()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
42 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
43 AffineTransform2D t = AffineTransform2D::Combine( |
1571 | 44 AffineTransform2D::CreateOpenGLClipspace(canvasWidth, canvasHeight), |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
45 transform); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
47 glUseProgram(0); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
49 glBegin(GL_LINES); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
51 for (size_t i = 0; i < layer_.GetChainsCount(); i++) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
52 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
53 const Color& color = layer_.GetColor(i); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
54 glColor3ub(color.GetRed(), color.GetGreen(), color.GetBlue()); |
804
61ba4b504e9a
PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
655
diff
changeset
|
55 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
56 const PolylineSceneLayer::Chain& chain = layer_.GetChain(i); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
58 if (chain.size() > 1) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
59 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
60 ScenePoint2D previous = chain[0].Apply(t); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
62 for (size_t j = 1; j < chain.size(); j++) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
63 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
64 ScenePoint2D p = chain[j].Apply(t); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
66 glVertex2f(static_cast<GLfloat>(previous.GetX()), |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
67 static_cast<GLfloat>(previous.GetY())); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
68 glVertex2f(static_cast<GLfloat>(p.GetX()), |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
69 static_cast<GLfloat>(p.GetY())); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
71 previous = p; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
72 } |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
74 if (layer_.IsClosedChain(i)) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
75 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
76 ScenePoint2D p = chain[0].Apply(t); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
78 glVertex2f(static_cast<GLfloat>(previous.GetX()), |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
79 static_cast<GLfloat>(previous.GetY())); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
80 glVertex2f(static_cast<GLfloat>(p.GetX()), |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
81 static_cast<GLfloat>(p.GetY())); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
82 } |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 } |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
85 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
86 glEnd(); |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
655
1e26bb5f2a02
Fixed truncating conversion warnings + fixed deletion of incomplete type
Benjamin Golinvaux <bgo@osimis.io>
parents:
593
diff
changeset
|
90 |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 void OpenGLBasicPolylineRenderer::Update(const ISceneLayer& layer) |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 layer_.Copy(dynamic_cast<const PolylineSceneLayer&>(layer)); |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 } |