Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/ViewportController.cpp @ 1203:f3bb9a6dd949 broker
locking abstraction in IViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 29 Nov 2019 21:22:21 +0100 |
parents | e713f1a99861 |
children | 00e6bff9ea39 |
comparison
equal
deleted
inserted
replaced
1200:54cbffabdc45 | 1203:f3bb9a6dd949 |
---|---|
134 { | 134 { |
135 measureTools_[i]->ResetHighlightState(); | 135 measureTools_[i]->ResetHighlightState(); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 const OrthancStone::AffineTransform2D& ViewportController::GetCanvasToSceneTransform() const | 139 OrthancStone::AffineTransform2D ViewportController::GetCanvasToSceneTransform() const |
140 { | 140 { |
141 return GetScene().GetCanvasToSceneTransform(); | 141 std::auto_ptr<IViewport::ILock> lock(viewport_.Lock()); |
142 } | 142 return lock->GetScene().GetCanvasToSceneTransform(); |
143 | 143 } |
144 const OrthancStone::AffineTransform2D& ViewportController::GetSceneToCanvasTransform() const | 144 |
145 { | 145 OrthancStone::AffineTransform2D ViewportController::GetSceneToCanvasTransform() const |
146 return GetScene().GetSceneToCanvasTransform(); | 146 { |
147 std::auto_ptr<IViewport::ILock> lock(viewport_.Lock()); | |
148 return lock->GetScene().GetSceneToCanvasTransform(); | |
147 } | 149 } |
148 | 150 |
149 void ViewportController::SetSceneToCanvasTransform( | 151 void ViewportController::SetSceneToCanvasTransform( |
150 const AffineTransform2D& transform) | 152 const AffineTransform2D& transform) |
151 { | 153 { |
152 viewport_.GetScene().SetSceneToCanvasTransform(transform); | 154 { |
155 std::auto_ptr<IViewport::ILock> lock(viewport_.Lock()); | |
156 lock->GetScene().SetSceneToCanvasTransform(transform); | |
157 } | |
158 | |
153 BroadcastMessage(SceneTransformChanged(*this)); | 159 BroadcastMessage(SceneTransformChanged(*this)); |
154 | 160 |
155 // update the canvas to scene factor | 161 // update the canvas to scene factor |
156 canvasToSceneFactor_ = 0.0; | 162 canvasToSceneFactor_ = 0.0; |
157 canvasToSceneFactor_ = GetCanvasToSceneFactor(); | 163 canvasToSceneFactor_ = GetCanvasToSceneFactor(); |
158 } | 164 } |
159 | 165 |
160 void ViewportController::FitContent( | 166 void ViewportController::FitContent( |
161 unsigned int canvasWidth, unsigned int canvasHeight) | 167 unsigned int canvasWidth, unsigned int canvasHeight) |
162 { | 168 { |
163 viewport_.GetScene().FitContent(canvasWidth, canvasHeight); | 169 { |
170 std::auto_ptr<IViewport::ILock> lock(viewport_.Lock()); | |
171 lock->GetScene().FitContent(canvasWidth, canvasHeight); | |
172 } | |
173 | |
164 BroadcastMessage(SceneTransformChanged(*this)); | 174 BroadcastMessage(SceneTransformChanged(*this)); |
165 } | 175 } |
166 | 176 |
167 void ViewportController::FitContent() | 177 void ViewportController::FitContent() |
168 { | 178 { |
169 if (viewport_.HasCompositor()) | 179 std::auto_ptr<IViewport::ILock> lock(viewport_.Lock()); |
170 { | 180 |
171 const ICompositor& compositor = viewport_.GetCompositor(); | 181 if (lock->HasCompositor()) |
172 viewport_.GetScene().FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight()); | 182 { |
183 const ICompositor& compositor = lock->GetCompositor(); | |
184 lock->GetScene().FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight()); | |
173 BroadcastMessage(SceneTransformChanged(*this)); | 185 BroadcastMessage(SceneTransformChanged(*this)); |
174 } | 186 } |
175 } | 187 } |
176 | 188 |
177 void ViewportController::AddMeasureTool(boost::shared_ptr<MeasureTool> measureTool) | 189 void ViewportController::AddMeasureTool(boost::shared_ptr<MeasureTool> measureTool) |
193 | 205 |
194 double ViewportController::GetCanvasToSceneFactor() const | 206 double ViewportController::GetCanvasToSceneFactor() const |
195 { | 207 { |
196 if (canvasToSceneFactor_ == 0) | 208 if (canvasToSceneFactor_ == 0) |
197 { | 209 { |
198 canvasToSceneFactor_ = | 210 std::auto_ptr<IViewport::ILock> lock(viewport_.Lock()); |
199 GetScene().GetCanvasToSceneTransform().ComputeZoom(); | 211 canvasToSceneFactor_ = lock->GetScene().GetCanvasToSceneTransform().ComputeZoom(); |
200 } | 212 } |
201 return canvasToSceneFactor_; | 213 return canvasToSceneFactor_; |
202 } | 214 } |
203 | 215 |
204 double ViewportController::GetHandleSideLengthS() const | 216 double ViewportController::GetHandleSideLengthS() const |