Mercurial > hg > orthanc-stone
annotate Samples/Qt/QStoneOpenGlWidget.h @ 1327:4f8db2d202c8 broker
OrthancSeriesProgressiveLoader now has two modes that
can be selected at object creation :
- progressive (will first load jpeg50, then jpeg90 then PAM)
- non-progressive (will directly load PAM (uncompressed))
Please note that the slice loading order remains dynamic
and depending upon the slice that the client code wishes
to extract from the volume.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 25 Mar 2020 14:34:27 +0100 |
parents | a911f5bb48da |
children |
rev | line source |
---|---|
849 | 1 #pragma once |
2 #include "../../Framework/OpenGL/OpenGLIncludes.h" | |
3 #include <QOpenGLWidget> | |
4 #include <QOpenGLFunctions> | |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
5 #include <QOpenGLContext> |
849 | 6 |
7 #include <boost/shared_ptr.hpp> | |
8 #include "../../Framework/OpenGL/IOpenGLContext.h" | |
9 #include "../../Framework/Scene2D/OpenGLCompositor.h" | |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
10 #include "../../Framework/Viewport/ViewportBase.h" |
885
56e4e9281076
sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents:
883
diff
changeset
|
11 #include "../../Applications/Generic/Scene2DInteractor.h" |
849 | 12 |
879 | 13 namespace OrthancStone |
849 | 14 { |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
15 class QStoneOpenGlWidget : |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
16 public QOpenGLWidget, |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
17 public OpenGL::IOpenGLContext, |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
18 public ViewportBase |
879 | 19 { |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
20 std::unique_ptr<OrthancStone::OpenGLCompositor> compositor_; |
879 | 21 boost::shared_ptr<Scene2DInteractor> sceneInteractor_; |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
22 QOpenGLContext openGlContext_; |
849 | 23 |
879 | 24 public: |
25 QStoneOpenGlWidget(QWidget *parent) : | |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
26 QOpenGLWidget(parent), |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
27 ViewportBase("QtStoneOpenGlWidget") // TODO: we shall be able to define a name but construction time is too early ! |
879 | 28 { |
885
56e4e9281076
sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents:
883
diff
changeset
|
29 setFocusPolicy(Qt::StrongFocus); // to enable keyPressEvent |
56e4e9281076
sharing code between Qt/SDL BasiceScene sample
Alain Mazy <alain@mazy.be>
parents:
883
diff
changeset
|
30 setMouseTracking(true); // to enable mouseMoveEvent event when no button is pressed |
879 | 31 } |
32 | |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
33 void Init() |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
34 { |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
35 QSurfaceFormat requestedFormat; |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
36 requestedFormat.setVersion( 2, 0 ); |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
37 openGlContext_.setFormat( requestedFormat ); |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
38 openGlContext_.create(); |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
39 openGlContext_.makeCurrent(context()->surface()); |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
40 |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
41 compositor_.reset(new OpenGLCompositor(*this, GetScene())); |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
42 } |
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
43 |
879 | 44 protected: |
849 | 45 |
879 | 46 //**** QWidget overrides |
47 void initializeGL() override; | |
48 void resizeGL(int w, int h) override; | |
49 void paintGL() override; | |
849 | 50 |
879 | 51 void mousePressEvent(QMouseEvent* event) override; |
881 | 52 void mouseMoveEvent(QMouseEvent* event) override; |
53 void mouseReleaseEvent(QMouseEvent* event) override; | |
883 | 54 void keyPressEvent(QKeyEvent* event) override; |
55 void keyReleaseEvent(QKeyEvent *event) override; | |
56 void wheelEvent(QWheelEvent* event) override; | |
849 | 57 |
879 | 58 //**** IOpenGLContext overrides |
849 | 59 |
879 | 60 virtual void MakeCurrent() override; |
61 virtual void SwapBuffer() override {} | |
849 | 62 |
879 | 63 virtual unsigned int GetCanvasWidth() const override |
64 { | |
65 return this->width(); | |
66 } | |
67 | |
68 virtual unsigned int GetCanvasHeight() const override | |
69 { | |
70 return this->height(); | |
71 } | |
849 | 72 |
879 | 73 public: |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
74 |
879 | 75 void SetInteractor(boost::shared_ptr<Scene2DInteractor> sceneInteractor) |
76 { | |
77 sceneInteractor_ = sceneInteractor; | |
78 } | |
849 | 79 |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
80 virtual ICompositor& GetCompositor() |
879 | 81 { |
916
a911f5bb48da
MultiPlatform Basic Scene sample (so far: SDL + Qt)
Alain Mazy <alain@mazy.be>
parents:
897
diff
changeset
|
82 return *compositor_; |
879 | 83 } |
849 | 84 |
881 | 85 protected: |
86 void mouseEvent(QMouseEvent* qtEvent, OrthancStone::GuiAdapterHidEventType guiEventType); | |
883 | 87 bool keyEvent(QKeyEvent* qtEvent, OrthancStone::GuiAdapterHidEventType guiEventType); |
881 | 88 |
879 | 89 }; |
90 } |