comparison Framework/Scene2DViewport/MeasureCommands.cpp @ 1331:ab81ee8fce1f broker

- Viewport is not passed and stored as a shared_ptr instead of raw reference. - ViewportController can now be injected with an undo stack (not a ctor param anymore, as a preparation for the move of the undo stack to an interactor) - Added (temp) flag to disable emscripten events registration in the WebAssemblyViewport (because legacy client code deals with them directly) - Added emscripten_clear_timeout in ~WebGLViewportsRegistry - Removed GenericToolbox::HoldingRef whose responsibility is better served with proper callback un-registration.
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 30 Mar 2020 14:23:46 +0200
parents a5326ce4f24b
children
comparison
equal deleted inserted replaced
1329:8d3e669f01a2 1331:ab81ee8fce1f
27 27
28 namespace OrthancStone 28 namespace OrthancStone
29 { 29 {
30 void CreateMeasureCommand::Undo() 30 void CreateMeasureCommand::Undo()
31 { 31 {
32 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_.Lock()); 32 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
33 // simply disable the measure tool upon undo 33 // simply disable the measure tool upon undo
34 GetMeasureTool()->Disable(); 34 GetMeasureTool()->Disable();
35 lock->GetController().RemoveMeasureTool(GetMeasureTool()); 35 lock->GetController().RemoveMeasureTool(GetMeasureTool());
36 } 36 }
37 37
38 void CreateMeasureCommand::Redo() 38 void CreateMeasureCommand::Redo()
39 { 39 {
40 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_.Lock()); 40 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
41 GetMeasureTool()->Enable(); 41 GetMeasureTool()->Enable();
42 lock->GetController().AddMeasureTool(GetMeasureTool()); 42 lock->GetController().AddMeasureTool(GetMeasureTool());
43 } 43 }
44 44
45 CreateMeasureCommand::CreateMeasureCommand(IViewport& viewport) 45 CreateMeasureCommand::CreateMeasureCommand(boost::shared_ptr<IViewport> viewport)
46 : MeasureCommand(viewport) 46 : MeasureCommand(viewport)
47 { 47 {
48 48
49 } 49 }
50 50
54 // we thus leave it as is 54 // we thus leave it as is
55 } 55 }
56 56
57 void DeleteMeasureCommand::Redo() 57 void DeleteMeasureCommand::Redo()
58 { 58 {
59 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_.Lock()); 59 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
60 // simply disable the measure tool upon undo 60 // simply disable the measure tool upon undo
61 GetMeasureTool()->Disable(); 61 GetMeasureTool()->Disable();
62 lock->GetController().RemoveMeasureTool(GetMeasureTool()); 62 lock->GetController().RemoveMeasureTool(GetMeasureTool());
63 } 63 }
64 64
65 void DeleteMeasureCommand::Undo() 65 void DeleteMeasureCommand::Undo()
66 { 66 {
67 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_.Lock()); 67 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
68 GetMeasureTool()->Enable(); 68 GetMeasureTool()->Enable();
69 lock->GetController().AddMeasureTool(GetMeasureTool()); 69 lock->GetController().AddMeasureTool(GetMeasureTool());
70 } 70 }
71 71
72 DeleteMeasureCommand::~DeleteMeasureCommand() 72 DeleteMeasureCommand::~DeleteMeasureCommand()
73 { 73 {
74 // deleting the command should not change the model state 74 // deleting the command should not change the model state
75 // we thus leave it as is 75 // we thus leave it as is
76 } 76 }
77 77
78 DeleteMeasureCommand::DeleteMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, IViewport& viewport) 78 DeleteMeasureCommand::DeleteMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, boost::shared_ptr<IViewport> viewport)
79 : MeasureCommand(viewport) 79 : MeasureCommand(viewport)
80 , mementoOriginal_(measureTool->GetMemento()) 80 , mementoOriginal_(measureTool->GetMemento())
81 , measureTool_(measureTool) 81 , measureTool_(measureTool)
82 , mementoModified_(measureTool->GetMemento()) 82 , mementoModified_(measureTool->GetMemento())
83 { 83 {
84 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_.Lock()); 84 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
85 GetMeasureTool()->Disable(); 85 GetMeasureTool()->Disable();
86 lock->GetController().RemoveMeasureTool(GetMeasureTool()); 86 lock->GetController().RemoveMeasureTool(GetMeasureTool());
87 } 87 }
88 88
89 EditMeasureCommand::EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, IViewport& viewport) 89 EditMeasureCommand::EditMeasureCommand(boost::shared_ptr<MeasureTool> measureTool, boost::shared_ptr<IViewport> viewport)
90 : MeasureCommand(viewport) 90 : MeasureCommand(viewport)
91 , mementoOriginal_(measureTool->GetMemento()) 91 , mementoOriginal_(measureTool->GetMemento())
92 , mementoModified_(measureTool->GetMemento()) 92 , mementoModified_(measureTool->GetMemento())
93 { 93 {
94 94