annotate Framework/Viewport/ViewportBase.cpp @ 1107:1533cccb5c43 broker

fix warnings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Oct 2019 10:21:51 +0100
parents 6dd90b8d1589
children f3bb9a6dd949 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
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
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
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
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
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 #include "ViewportBase.h"
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include <Core/OrthancException.h>
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <boost/make_shared.hpp>
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace OrthancStone
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
1055
af456106576c moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1053
diff changeset
29 ViewportBase::ViewportBase() :
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 scene_(boost::make_shared<Scene2D>())
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 }
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
1055
af456106576c moving GetCanvasIdentifier from IViewport to WebAssemblyViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1053
diff changeset
35 ViewportBase::ViewportBase(boost::shared_ptr<Scene2D>& scene) :
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 scene_(scene)
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 if (scene.get() == NULL)
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 }
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
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
1071
6dd90b8d1589 Fixes related to refactorings in viewports.
Benjamin Golinvaux <bgo@osimis.io>
parents: 1055
diff changeset
45 ScenePoint2D ViewportBase::GetPixelCenterCoordinates(int x, int y) const
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
1053
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
47 if (HasCompositor())
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
48 {
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
49 const ICompositor& compositor = GetCompositor();
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
50 return ScenePoint2D(
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
51 static_cast<double>(x) + 0.5 - static_cast<double>(compositor.GetCanvasWidth()) / 2.0,
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
52 static_cast<double>(y) + 0.5 - static_cast<double>(compositor.GetCanvasHeight()) / 2.0);
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
53 }
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
54 else
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
55 {
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
56 return ScenePoint2D(0, 0);
32b403a47b19 simplifying IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 891
diff changeset
57 }
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 }
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }