Mercurial > hg > orthanc-stone
annotate Samples/Qt/Scene2DInteractor.cpp @ 976:3abc47e051c8
Added tag toa2019083101 for changeset e75fd08d6c75
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Sat, 31 Aug 2019 13:50:11 +0200 |
parents | 56e4e9281076 |
children |
rev | line source |
---|---|
879 | 1 #include "Scene2DInteractor.h" |
2 | |
881 | 3 #include "../../Framework/Scene2D/PanSceneTracker.h" |
4 #include "../../Framework/Scene2D/ZoomSceneTracker.h" | |
885
56e4e9281076
sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents:
883
diff
changeset
|
5 #include "../../Framework/Scene2D/RotateSceneTracker.h" |
881 | 6 |
879 | 7 |
8 namespace OrthancStone | |
9 { | |
10 | |
11 } | |
12 | |
13 using namespace OrthancStone; | |
14 | |
15 | |
883 | 16 bool BasicScene2DInteractor::OnMouseEvent(const GuiAdapterMouseEvent& event, const PointerEvent& pointerEvent) |
879 | 17 { |
881 | 18 if (currentTracker_.get() != NULL) |
19 { | |
883 | 20 switch (event.type) |
21 { | |
22 case GUIADAPTER_EVENT_MOUSEUP: | |
23 { | |
24 currentTracker_->PointerUp(pointerEvent); | |
25 if (!currentTracker_->IsAlive()) | |
26 { | |
27 currentTracker_.reset(); | |
28 } | |
29 };break; | |
30 case GUIADAPTER_EVENT_MOUSEMOVE: | |
31 { | |
32 currentTracker_->PointerMove(pointerEvent); | |
33 };break; | |
34 } | |
35 return true; | |
881 | 36 } |
37 else | |
38 { | |
39 if (event.button == GUIADAPTER_MOUSEBUTTON_LEFT) | |
40 { | |
885
56e4e9281076
sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents:
883
diff
changeset
|
41 currentTracker_.reset(new RotateSceneTracker(viewportController_, pointerEvent)); |
881 | 42 } |
43 else if (event.button == GUIADAPTER_MOUSEBUTTON_MIDDLE) | |
44 { | |
45 currentTracker_.reset(new PanSceneTracker(viewportController_, pointerEvent)); | |
46 } | |
883 | 47 else if (event.button == GUIADAPTER_MOUSEBUTTON_RIGHT && compositor_.get() != NULL) |
881 | 48 { |
883 | 49 currentTracker_.reset(new ZoomSceneTracker(viewportController_, pointerEvent, compositor_->GetHeight())); |
881 | 50 } |
883 | 51 return true; |
881 | 52 } |
883 | 53 return false; |
879 | 54 } |
55 | |
883 | 56 bool BasicScene2DInteractor::OnKeyboardEvent(const GuiAdapterKeyboardEvent& guiEvent) |
57 { | |
58 switch (guiEvent.sym[0]) | |
59 { | |
60 case 's': | |
61 { | |
62 viewportController_->FitContent(compositor_->GetWidth(), compositor_->GetHeight()); | |
63 return true; | |
64 }; | |
65 } | |
66 return false; | |
67 } | |
879 | 68 |
883 | 69 bool BasicScene2DInteractor::OnWheelEvent(const GuiAdapterWheelEvent& guiEvent) |
70 { | |
71 return false; | |
72 } |