Mercurial > hg > orthanc-stone
annotate Applications/Qt/QCairoWidget.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 | 8a0a62189f46 |
children |
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 |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
4 4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
860
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
280
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 |
291 | 23 #include "../../Applications/Generic/NativeStoneApplicationContext.h" |
860 | 24 #include "../../Framework/Wrappers/CairoSurface.h" |
25 #include "../../Framework/Deprecated/Widgets/IWidget.h" | |
276
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 <memory> |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
29 #include <cassert> |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
30 |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
31 class QCairoWidget : public QWidget |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
32 { |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
33 Q_OBJECT |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
34 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
35 private: |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
36 class StoneObserver : public OrthancStone::IObserver |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
37 { |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
38 private: |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
39 QCairoWidget& that_; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
40 |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
41 public: |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
42 StoneObserver(QCairoWidget& that, |
730
fe938bddb932
fix after namespace rename to Deprecated
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
43 Deprecated::IViewport& viewport, |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
44 OrthancStone::MessageBroker& broker); |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
45 |
730
fe938bddb932
fix after namespace rename to Deprecated
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
46 void OnViewportChanged(const Deprecated::IViewport::ViewportChangedMessage& message) |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
47 { |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
48 that_.OnViewportChanged(); |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
49 } |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
50 }; |
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
51 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
52 std::unique_ptr<QImage> image_; |
277 | 53 OrthancStone::CairoSurface surface_; |
291 | 54 OrthancStone::NativeStoneApplicationContext* context_; |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
55 std::unique_ptr<StoneObserver> observer_; |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
56 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
57 protected: |
277 | 58 virtual void paintEvent(QPaintEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
59 |
277 | 60 virtual void resizeEvent(QResizeEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
61 |
277 | 62 virtual void mouseMoveEvent(QMouseEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
63 |
277 | 64 virtual void mousePressEvent(QMouseEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
65 |
277 | 66 virtual void mouseReleaseEvent(QMouseEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
67 |
277 | 68 virtual void wheelEvent(QWheelEvent *event); |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
69 |
284 | 70 virtual void keyPressEvent(QKeyEvent *event); |
71 | |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
72 public: |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
73 explicit QCairoWidget(QWidget *parent); |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
74 |
291 | 75 void SetContext(OrthancStone::NativeStoneApplicationContext& context); |
277 | 76 |
385
6cc3ce74dc05
using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
77 void OnViewportChanged() |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
78 { |
277 | 79 update(); // schedule a repaint (handled by Qt) |
80 emit ContentChanged(); | |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
81 } |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
82 |
277 | 83 signals: |
84 void ContentChanged(); | |
276
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
85 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
86 public slots: |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
87 |
5de5699ad570
first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff
changeset
|
88 }; |