ITK  5.3.0
Insight Toolkit
QuickView.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef QuickView_h
19 #define QuickView_h
20 
21 #include <vector>
22 #include <algorithm>
23 #include <string>
24 
25 #include <itkImage.h>
26 #include <itkRGBPixel.h>
27 #include <itkIntTypes.h>
28 
29 #include "ITKVtkGlueExport.h"
30 
36 class ITKVtkGlue_EXPORT ImageInfo
37 {
38 public:
40 
41  ImageInfo(ImageType * image, std::string description = "")
42  {
43  m_Image = image;
44  m_Description = description;
45  }
46 
48  std::string m_Description;
49 };
50 
56 class ITKVtkGlue_EXPORT RGBImageInfo
57 {
58 public:
60  RGBImageInfo(ImageType * image, std::string description = "")
61  {
62  m_Image = image;
63  m_Description = description;
64  }
65 
67  std::string m_Description;
68 };
69 
103 
111 class ITKVtkGlue_EXPORT QuickView
112 {
113 public:
115  {
116  m_ShareCamera = true;
117  m_Interpolate = true;
118  m_Counter = 0;
119  m_Snapshot = false;
120  m_SnapshotPath = "";
121  m_SnapshotPrefix = "snapshot_";
122  m_SnapshotExtension = "png";
123  m_NumberOfColumns = 4;
124  m_ViewPortSize = 300;
125  }
127  template <typename TImage>
128  void
129  AddImage(TImage *, bool FlipVertical = true, std::string Description = "");
130 
132  template <typename TImage>
133  void
134  AddRGBImage(TImage *, bool FlipVertical = true, std::string Description = "");
135 
139  void
140  Visualize(bool interact = true);
141 
142 
144  void
146  {
147  m_ShareCamera = false;
148  }
149 
151  void
153  {
154  m_ShareCamera = true;
155  }
156 
158  void
160  {
161  m_Interpolate = false;
162  }
163 
165  void
167  {
168  m_Interpolate = true;
169  }
170 
172  void
174  {
175  m_Snapshot = true;
176  }
177 
179  void
181  {
182  m_Snapshot = false;
183  }
184 
185  void
186  SetSnapshotPath(const std::string & iPath)
187  {
188  m_SnapshotPath = iPath;
189  }
190 
191  void
192  SetSnapshotPrefix(const std::string & iPrefix)
193  {
194  m_SnapshotPrefix = iPrefix;
195  }
196 
198  void
199  SetSnapshotExtension(const std::string & iExtension)
200  {
201  m_SnapshotExtension = iExtension;
202  std::transform(m_SnapshotExtension.begin(), m_SnapshotExtension.end(), m_SnapshotExtension.begin(), ::tolower);
203  }
205 
207  void
208  SetNumberOfColumns(const unsigned int columns)
209  {
210  m_NumberOfColumns = columns;
211  }
212 
214  void
215  SetViewPortSize(const unsigned int size)
216  {
217  m_ViewPortSize = size;
218  }
219 
220 private:
221  std::vector<ImageInfo> Images; // Container for images
222  std::vector<RGBImageInfo> RGBImages; // Container for rgb images
224  std::string m_SnapshotPath;
225  std::string m_SnapshotPrefix;
226  std::string m_SnapshotExtension;
230  unsigned int m_NumberOfColumns;
231  unsigned int m_ViewPortSize;
232 };
233 
234 #endif
QuickView::SetSnapshotExtension
void SetSnapshotExtension(const std::string &iExtension)
Definition: QuickView.h:199
itkRGBPixel.h
QuickView::m_Snapshot
bool m_Snapshot
Definition: QuickView.h:228
QuickView::SnapshotOn
void SnapshotOn()
Definition: QuickView.h:173
ImageInfo::m_Image
ImageType::Pointer m_Image
Definition: QuickView.h:47
ImageInfo::ImageInfo
ImageInfo(ImageType *image, std::string description="")
Definition: QuickView.h:41
QuickView::Images
std::vector< ImageInfo > Images
Definition: QuickView.h:221
QuickView::m_SnapshotPath
std::string m_SnapshotPath
Definition: QuickView.h:224
QuickView::InterpolateOff
void InterpolateOff()
Definition: QuickView.h:159
QuickView::SnapshotOff
void SnapshotOff()
Definition: QuickView.h:180
itkImage.h
RGBImageInfo
A container for an rgb image and its description.
Definition: QuickView.h:56
itk::SmartPointer< Self >
RGBImageInfo::m_Description
std::string m_Description
Definition: QuickView.h:67
QuickView::m_Interpolate
bool m_Interpolate
Definition: QuickView.h:229
QuickView::QuickView
QuickView()
Definition: QuickView.h:114
QuickView::RGBImages
std::vector< RGBImageInfo > RGBImages
Definition: QuickView.h:222
ImageInfo::m_Description
std::string m_Description
Definition: QuickView.h:48
QuickView::SetNumberOfColumns
void SetNumberOfColumns(const unsigned int columns)
Definition: QuickView.h:208
QuickView::m_NumberOfColumns
unsigned int m_NumberOfColumns
Definition: QuickView.h:230
QuickView::ShareCameraOff
void ShareCameraOff()
Definition: QuickView.h:145
QuickView::m_Counter
itk::IdentifierType m_Counter
Definition: QuickView.h:223
QuickView::m_ViewPortSize
unsigned int m_ViewPortSize
Definition: QuickView.h:231
itkIntTypes.h
QuickView::InterpolateOn
void InterpolateOn()
Definition: QuickView.h:166
QuickView::m_ShareCamera
bool m_ShareCamera
Definition: QuickView.h:227
QuickView::m_SnapshotPrefix
std::string m_SnapshotPrefix
Definition: QuickView.h:225
QuickView
A convenient class to render itk images with vtk.
Definition: QuickView.h:111
RGBImageInfo::m_Image
ImageType::Pointer m_Image
Definition: QuickView.h:66
QuickView::ShareCameraOn
void ShareCameraOn()
Definition: QuickView.h:152
QuickView::m_SnapshotExtension
std::string m_SnapshotExtension
Definition: QuickView.h:226
QuickView::SetSnapshotPath
void SetSnapshotPath(const std::string &iPath)
Definition: QuickView.h:186
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
RGBImageInfo::RGBImageInfo
RGBImageInfo(ImageType *image, std::string description="")
Definition: QuickView.h:60
QuickView::SetSnapshotPrefix
void SetSnapshotPrefix(const std::string &iPrefix)
Definition: QuickView.h:192
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
ImageInfo
A container for an image and its description.
Definition: QuickView.h:36
QuickView::SetViewPortSize
void SetViewPortSize(const unsigned int size)
Definition: QuickView.h:215