Mercurial > hg > orthanc-stone
annotate Applications/Qt/QCairoWidget.h @ 367:face7b7008de am-2
line and circle measure tools are now compatible with WebAssembly
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 01 Nov 2018 12:09:11 +0100 |
parents | 87376a645ee1 |
children | 6cc3ce74dc05 |
rev | line source |
---|---|
280
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
1 /** |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
2 * Stone of Orthanc |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
6 * |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
10 * the License, or (at your option) any later version. |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
11 * |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
15 * Affero General Public License for more details. |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
16 * |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
19 **/ |
829163c6efc1
split MainWindow into a generic one and one specific to these samples
am@osimis.io
parents:
277
diff
changeset
|
20 |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
21 #pragma once |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
22 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
23 #include "../../Framework/Widgets/CairoWidget.h" |
291 | 24 #include "../../Applications/Generic/NativeStoneApplicationContext.h" |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
25 #include "../../Framework/Viewport/CairoSurface.h" |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
26 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
27 #include <QWidget> |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
28 #include <QGestureEvent> |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
29 #include <memory> |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
30 #include <cassert> |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
31 |
277 | 32 class QCairoWidget : public QWidget, public OrthancStone::IViewport::IObserver |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
33 { |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
34 Q_OBJECT |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
35 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
36 private: |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
37 std::auto_ptr<QImage> image_; |
277 | 38 OrthancStone::CairoSurface surface_; |
291 | 39 OrthancStone::NativeStoneApplicationContext* context_; |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
40 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
41 protected: |
277 | 42 virtual void paintEvent(QPaintEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
43 |
277 | 44 virtual void resizeEvent(QResizeEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
45 |
277 | 46 virtual void mouseMoveEvent(QMouseEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
47 |
277 | 48 virtual void mousePressEvent(QMouseEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
49 |
277 | 50 virtual void mouseReleaseEvent(QMouseEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
51 |
277 | 52 virtual void wheelEvent(QWheelEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
53 |
284 | 54 virtual void keyPressEvent(QKeyEvent *event); |
55 | |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
56 public: |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
57 explicit QCairoWidget(QWidget *parent); |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
58 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
59 virtual ~QCairoWidget(); |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
60 |
291 | 61 void SetContext(OrthancStone::NativeStoneApplicationContext& context); |
277 | 62 |
63 virtual void OnViewportContentChanged(const OrthancStone::IViewport& /*sceneNotUsed*/) | |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
64 { |
277 | 65 update(); // schedule a repaint (handled by Qt) |
66 emit ContentChanged(); | |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
67 } |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
68 |
277 | 69 signals: |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
70 |
277 | 71 void ContentChanged(); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
72 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
73 public slots: |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
74 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
75 }; |