annotate Framework/Radiography/RadiographyLayerMaskTracker.cpp @ 999:2d69b8bee484

Added tests for Dicom structure set classes (loaders and utils)
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 20 Sep 2019 11:58:33 +0200
parents 4f2416d519b4
children 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
1 /**
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
6 *
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
11 *
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
16 *
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
19 **/
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
20
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
21
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
22 #include "RadiographyLayerMaskTracker.h"
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
23 #include "RadiographyMaskLayer.h"
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
24
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
25 #include "RadiographySceneCommand.h"
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
26
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
27 #include <Core/OrthancException.h>
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
28
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
29 namespace OrthancStone
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
30 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
31 class RadiographyLayerMaskTracker::UndoRedoCommand : public RadiographySceneCommand
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
32 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
33 private:
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
34 ControlPoint sourceSceneCp_;
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
35 ControlPoint targetSceneCp_;
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
36
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
37 protected:
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
38 virtual void UndoInternal(RadiographyLayer& layer) const
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
39 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
40 RadiographyMaskLayer* maskLayer = dynamic_cast<RadiographyMaskLayer*>(&layer);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
41 if (maskLayer == NULL)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
42 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
43 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
44 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
45 unsigned int ix, iy; // image coordinates
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
46 if (maskLayer->GetPixel(ix, iy, sourceSceneCp_.x, sourceSceneCp_.y))
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
47 {
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 480
diff changeset
48 maskLayer->SetCorner(Orthanc::ImageProcessing::ImagePoint((int32_t)ix, (int32_t)iy), sourceSceneCp_.index);
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
49 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
50 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
51
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
52 virtual void RedoInternal(RadiographyLayer& layer) const
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
53 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
54 RadiographyMaskLayer* maskLayer = dynamic_cast<RadiographyMaskLayer*>(&layer);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
55 if (maskLayer == NULL)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
56 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
57 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
58 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
59 unsigned int ix, iy; // image coordinates
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
60 if (maskLayer->GetPixel(ix, iy, targetSceneCp_.x, targetSceneCp_.y))
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
61 {
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 480
diff changeset
62 maskLayer->SetCorner(Orthanc::ImageProcessing::ImagePoint((int32_t)ix, (int32_t)iy), targetSceneCp_.index);
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
63 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
64 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
65
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
66 public:
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
67 UndoRedoCommand(const RadiographyLayerMaskTracker& tracker) :
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
68 RadiographySceneCommand(tracker.accessor_),
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
69 sourceSceneCp_(tracker.startSceneCp_),
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
70 targetSceneCp_(tracker.endSceneCp_)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
71 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
72 RadiographyMaskLayer* maskLayer = dynamic_cast<RadiographyMaskLayer*>(&(tracker.accessor_.GetLayer()));
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
73 if (maskLayer == NULL)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
74 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
76 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
77 unsigned int ix, iy; // image coordinates
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
78 if (maskLayer->GetPixel(ix, iy, targetSceneCp_.x, targetSceneCp_.y))
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
79 {
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 480
diff changeset
80 maskLayer->SetCorner(Orthanc::ImageProcessing::ImagePoint((int32_t)ix, (int32_t)iy), targetSceneCp_.index);
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
81 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
82 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
83 };
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
84
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
85
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
86 RadiographyLayerMaskTracker::RadiographyLayerMaskTracker(UndoRedoStack& undoRedoStack,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
87 RadiographyScene& scene,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 488
diff changeset
88 const Deprecated::ViewportGeometry& view,
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
89 size_t layer,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
90 const ControlPoint& startSceneControlPoint) :
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
91 undoRedoStack_(undoRedoStack),
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
92 accessor_(scene, layer),
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
93 startSceneCp_(startSceneControlPoint),
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
94 endSceneCp_(startSceneControlPoint)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
95 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
96 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
97
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
98
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
99 void RadiographyLayerMaskTracker::Render(CairoContext& context,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
100 double zoom)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
101 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
102 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
103 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
104
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
105
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
106 void RadiographyLayerMaskTracker::MouseUp()
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
107 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
108 if (accessor_.IsValid() && startSceneCp_.x != endSceneCp_.x && startSceneCp_.y != endSceneCp_.y)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
109 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
110 undoRedoStack_.Add(new UndoRedoCommand(*this));
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
111 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
112 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
113
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
114
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
115 void RadiographyLayerMaskTracker::MouseMove(int displayX,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
116 int displayY,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
117 double sceneX,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
118 double sceneY,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 488
diff changeset
119 const std::vector<Deprecated::Touch>& displayTouches,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 488
diff changeset
120 const std::vector<Deprecated::Touch>& sceneTouches)
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
121 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
122 if (accessor_.IsValid())
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
123 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
124 unsigned int ix, iy; // image coordinates
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
125
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
126 RadiographyLayer& layer = accessor_.GetLayer();
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
127 if (layer.GetPixel(ix, iy, sceneX, sceneY))
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
128 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
129 endSceneCp_ = ControlPoint(sceneX, sceneY, startSceneCp_.index);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
130
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
131 RadiographyMaskLayer* maskLayer = dynamic_cast<RadiographyMaskLayer*>(&layer);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
132 if (maskLayer == NULL)
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
133 {
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
135 }
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 480
diff changeset
136 maskLayer->SetCorner(Orthanc::ImageProcessing::ImagePoint((int32_t)ix, (int32_t)iy), startSceneCp_.index);
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
137 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
138 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
139 }
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents:
diff changeset
140 }