annotate OrthancStone/Sources/Scene2D/ArrowSceneLayer.cpp @ 2037:d81a7157a846 deep-learning

added OpenGLTexture::ConvertToOpenGLFormats()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 28 Jan 2023 12:55:34 +0100
parents 7053b8a0aaec
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1614
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1614
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "ArrowSceneLayer.h"
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include <boost/math/constants/constants.hpp>
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace OrthancStone
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 ArrowSceneLayer::ArrowSceneLayer(const ScenePoint2D& a,
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 const ScenePoint2D& b) :
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 a_(a),
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 b_(b),
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 thickness_(1.0),
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 revision_(0),
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 arrowLength_(10), // 10 pixels
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 arrowAngle_(boost::math::constants::pi<double>() / 12.0) // 15 degrees
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 ISceneLayer* ArrowSceneLayer::Clone() const
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 std::unique_ptr<ArrowSceneLayer> copy(new ArrowSceneLayer(a_, b_));
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 copy->color_ = color_;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 copy->thickness_ = thickness_;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 copy->arrowLength_ = arrowLength_;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 copy->arrowAngle_ = arrowAngle_;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 return copy.release();
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 void ArrowSceneLayer::SetThickness(double thickness)
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 thickness_ = thickness;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 revision_ += 1;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 void ArrowSceneLayer::SetColor(const Color& color)
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 color_ = color;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 revision_ += 1;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 void ArrowSceneLayer::SetArrowLength(double length)
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 arrowLength_ = length;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 revision_ += 1;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 void ArrowSceneLayer::SetArrowAngle(double angle)
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 arrowAngle_ = angle;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 revision_ += 1;
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 void ArrowSceneLayer::GetBoundingBox(Extent2D& target) const
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 target.Clear();
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 target.AddPoint(a_.GetX(), a_.GetY());
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 target.AddPoint(b_.GetX(), b_.GetY());
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
ad9b425f27ae new class: ArrowSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }