annotate Applications/Qt/QCairoWidget.h @ 483:29fc066b6f65 am-touch-events

Export now accepts Json::Value
author am@osimis.io
date Fri, 15 Feb 2019 10:39:23 +0100
parents b70e9be013e4
children fe938bddb932
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 385
diff changeset
5 * Copyright (C) 2017-2019 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
87376a645ee1 renaming
am@osimis.io
parents: 284
diff changeset
23 #include "../../Applications/Generic/NativeStoneApplicationContext.h"
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
24 #include "../../Framework/Viewport/CairoSurface.h"
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
25 #include "../../Framework/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,
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
43 OrthancStone::IViewport& viewport,
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
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
46 void OnViewportChanged(const OrthancStone::IViewport::ViewportChangedMessage& message)
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
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
52 std::auto_ptr<QImage> image_;
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
53 OrthancStone::CairoSurface surface_;
291
87376a645ee1 renaming
am@osimis.io
parents: 284
diff changeset
54 OrthancStone::NativeStoneApplicationContext* context_;
385
6cc3ce74dc05 using message broker in widgets
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 291
diff changeset
55 std::auto_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
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
58 virtual void paintEvent(QPaintEvent *event);
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
59
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
60 virtual void resizeEvent(QResizeEvent *event);
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
61
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
62 virtual void mouseMoveEvent(QMouseEvent *event);
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
63
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
64 virtual void mousePressEvent(QMouseEvent *event);
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
65
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
66 virtual void mouseReleaseEvent(QMouseEvent *event);
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
67
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
68 virtual void wheelEvent(QWheelEvent *event);
276
5de5699ad570 first display in QCairoWidget; no mouse interaction yet
am@osimis.io
parents:
diff changeset
69
284
38b0ac8055b9 Qt: catch and forward keyboard events
am@osimis.io
parents: 280
diff changeset
70 virtual void keyPressEvent(QKeyEvent *event);
38b0ac8055b9 Qt: catch and forward keyboard events
am@osimis.io
parents: 280
diff changeset
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
87376a645ee1 renaming
am@osimis.io
parents: 284
diff changeset
75 void SetContext(OrthancStone::NativeStoneApplicationContext& context);
277
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
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
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
79 update(); // schedule a repaint (handled by Qt)
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
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
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
83 signals:
a38465cc909f Qt: refresh ok + mouse interaction ok
am@osimis.io
parents: 276
diff changeset
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 };