SMIL  1.0.4
DQtImageViewer.hpp
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _D_QT_IMAGE_VIEWER_HPP
31 #define _D_QT_IMAGE_VIEWER_HPP
32 
33 #include <QApplication>
34 #include <QGraphicsSceneEvent>
35 
36 #include "Gui/include/private/DImageViewer.hpp"
37 #include "Core/include/DTypes.h"
38 
39 #include "PureQt/ImageViewerWidget.h"
40 
41 class PlotWidget;
42 
43 namespace smil
44 {
45 #define BASE_QT_VIEWER ImageViewerWidget
46 
47  template <class T>
48  class Image;
49 
54 
69  template <class T>
71 #ifndef SWIG
72  : public ImageViewer<T>,
73  public BASE_QT_VIEWER
74 #endif // SWIG
75  {
76  public:
77  typedef ImageViewer<T> parentClass;
78  QtImageViewer();
80  ~QtImageViewer();
81 
82  virtual void setImage(Image<T> &im);
83  virtual void hide();
84  virtual void show();
85  virtual void showLabel();
86  virtual bool isVisible();
87  virtual void setName(const char *_name);
88  virtual void update();
89  virtual void saveSnapshot(const char *fileName);
90  virtual void redrawImage() // ImageViewerWidget
91  {
92  update();
93  }
94  void updateIcon()
95  {
96  if (!this->image)
97  return;
98 
99  BASE_QT_VIEWER::updateIcon();
100  }
101  virtual void drawOverlay(const Image<T> &im);
102  virtual void clearOverlay()
103  {
104  BASE_QT_VIEWER::clearOverlay();
105  }
106  virtual RES_T getOverlay(Image<T> &img);
107 
109  virtual void setLookup(const map<UINT8, RGB> &lut);
110  virtual void resetLookup();
111 
112  virtual void setCurSlice(int)
113  {
114  this->update();
115  }
116 
117  virtual void setLabelImage(bool val);
118 
119 #ifdef USE_QWT
120  virtual void displayHistogram(bool update = false);
121  virtual void displayProfile(bool update = false);
122 #endif // USE_QWT
123 
124  protected:
125  virtual void displayPixelValue(size_t x, size_t y, size_t z);
126  virtual void displayMagnifyView(size_t x, size_t y, size_t z);
127  virtual void drawImage();
128  virtual void overlayDataChanged(bool triggerEvents = true);
129  // ImageViewerWidget *qtViewer;
130  // ImageViewer *qtViewer;
131  virtual void dropEvent(QDropEvent *de);
132 
133 #ifdef USE_QWT
134  PlotWidget *histoPlot;
135  PlotWidget *profilePlot;
136 #endif // USE_QWT
137  };
138 
141 } // namespace smil
142 
143 #endif // _D_QT_IMAGE_VIEWER_HPP
Definition: PlotWidget.h:43
Main Image class.
Definition: DImage.hpp:57
Base image viewer.
Definition: DImageViewer.hpp:52
Qt image viewer.
Definition: DQtImageViewer.hpp:75
virtual void setLookup(const map< UINT8, RGB > &lut)
Set the color table as a 8bits RGB map (keys between 0 and 255)
Definition: DQtImageViewer.hxx:308