annotate Framework/Scene2D/Internals/OpenGLInfoPanelRenderer.cpp @ 700:059e1fd05fd6 refactor-viewport-controller

Introduced the ViewportController that sits between the application and the Scene2D to handle the trackers and measuring tools. This is a work in progress. The Scene2D is no longer an observable. Message sending is managed by the ViewportController. Move some refs to shared and weak to prevent lifetime issues.
author Benjamin Golinvaux <bgo@osimis.io>
date Sun, 19 May 2019 16:26:17 +0200
parents 9807ed3d3e03
children 6e888cf6a48b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
594
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "OpenGLInfoPanelRenderer.h"
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 namespace OrthancStone
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 {
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 namespace Internals
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 {
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 void OpenGLInfoPanelRenderer::LoadTexture(const InfoPanelSceneLayer& layer)
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 context_.MakeCurrent();
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 texture_.reset(new OpenGL::OpenGLTexture);
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 texture_->Load(layer.GetTexture(), layer.IsLinearInterpolation());
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 anchor_ = layer.GetAnchor();
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 }
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 OpenGLInfoPanelRenderer::OpenGLInfoPanelRenderer(OpenGL::IOpenGLContext& context,
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 OpenGLColorTextureProgram& program,
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 const InfoPanelSceneLayer& layer) :
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 context_(context),
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 program_(program)
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 LoadTexture(layer);
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 }
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 void OpenGLInfoPanelRenderer::Render(const AffineTransform2D& transform)
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (texture_.get() != NULL)
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 int dx, dy;
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 InfoPanelSceneLayer::ComputeAnchorLocation(
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 dx, dy, anchor_, texture_->GetWidth(), texture_->GetHeight(),
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 context_.GetCanvasWidth(), context_.GetCanvasHeight());
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 // The position of this type of layer is layer: Ignore the
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 // "transform" coming from the scene
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 program_.Apply(*texture_, AffineTransform2D::CreateOffset(dx, dy), true);
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
9807ed3d3e03 OpenGLCompositor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }