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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
1 #include "Scene2DInteractor.h"
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
2
881
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
3 #include "../../Framework/Scene2D/PanSceneTracker.h"
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
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
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
6
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
7
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
8 namespace OrthancStone
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
9 {
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
10
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
11 }
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
12
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
13 using namespace OrthancStone;
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
14
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
15
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
16 bool BasicScene2DInteractor::OnMouseEvent(const GuiAdapterMouseEvent& event, const PointerEvent& pointerEvent)
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
17 {
881
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
18 if (currentTracker_.get() != NULL)
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
19 {
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
20 switch (event.type)
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
21 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
22 case GUIADAPTER_EVENT_MOUSEUP:
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
23 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
24 currentTracker_->PointerUp(pointerEvent);
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
25 if (!currentTracker_->IsAlive())
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
26 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
27 currentTracker_.reset();
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
28 }
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
29 };break;
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
30 case GUIADAPTER_EVENT_MOUSEMOVE:
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
31 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
32 currentTracker_->PointerMove(pointerEvent);
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
33 };break;
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
34 }
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
35 return true;
881
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
36 }
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
37 else
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
38 {
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
39 if (event.button == GUIADAPTER_MOUSEBUTTON_LEFT)
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
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
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
42 }
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
43 else if (event.button == GUIADAPTER_MOUSEBUTTON_MIDDLE)
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
44 {
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
45 currentTracker_.reset(new PanSceneTracker(viewportController_, pointerEvent));
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
46 }
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
47 else if (event.button == GUIADAPTER_MOUSEBUTTON_RIGHT && compositor_.get() != NULL)
881
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
48 {
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
49 currentTracker_.reset(new ZoomSceneTracker(viewportController_, pointerEvent, compositor_->GetHeight()));
881
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
50 }
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
51 return true;
881
Alain Mazy <alain@mazy.be>
parents: 879
diff changeset
52 }
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
53 return false;
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
54 }
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
55
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
56 bool BasicScene2DInteractor::OnKeyboardEvent(const GuiAdapterKeyboardEvent& guiEvent)
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
57 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
58 switch (guiEvent.sym[0])
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
59 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
60 case 's':
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
61 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
62 viewportController_->FitContent(compositor_->GetWidth(), compositor_->GetHeight());
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
63 return true;
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
64 };
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
65 }
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
66 return false;
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
67 }
879
12b591d5d63c some Qt integration (wip)
Alain Mazy <alain@mazy.be>
parents:
diff changeset
68
883
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
69 bool BasicScene2DInteractor::OnWheelEvent(const GuiAdapterWheelEvent& guiEvent)
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
70 {
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
71 return false;
30268a0cafca basic scene Qt sample working
Alain Mazy <alain@mazy.be>
parents: 881
diff changeset
72 }