22 #include <itkObject.h>
23 #include <itksys/SystemTools.hxx>
27 #include <vtkCamera.h>
28 #include <vtkConfigure.h>
29 #include <vtkImageActor.h>
30 #include <vtkImageData.h>
31 #include <vtkImageFlip.h>
32 #include <vtkImageImport.h>
33 #include <vtkImageMapper.h>
34 #include <vtkMapper.h>
35 #include <vtkObjectFactory.h>
36 #include <vtkPNGReader.h>
37 #include <vtkPolyData.h>
38 #include <vtkRenderWindow.h>
39 #include <vtkRenderer.h>
40 #include <vtkRendererCollection.h>
69 if (m_RenderWindow !=
nullptr)
70 if (this->IsEnabled())
73 if (m_Mapper !=
nullptr)
76 if (m_Actor !=
nullptr)
79 if (m_Renderer !=
nullptr)
82 if (m_PngReader !=
nullptr)
83 m_PngReader->Delete();
85 if (m_VtkImageImport !=
nullptr)
86 m_VtkImageImport->Delete();
88 if (m_ImageData !=
nullptr)
99 m_RenderWindow = renderWindow;
108 return m_RenderWindow;
141 if (file.length() != 0)
144 m_PngReader->SetFileName(m_FileName.c_str());
157 if (m_RenderWindow !=
nullptr)
159 if (itksys::SystemTools::FileExists(m_FileName.c_str()) && !m_ForceShowMBIDepartmentLogo)
161 m_PngReader->Update();
162 m_Actor->SetInputData(m_PngReader->GetOutput());
166 m_VtkImageImport->SetDataScalarTypeToUnsignedChar();
169 m_VtkImageImport->SetDataExtentToWholeExtent();
174 unsigned int column, row;
175 char *dest = m_ImageData;
193 m_VtkImageImport->SetImportVoidPointer(m_ImageData);
194 m_VtkImageImport->Modified();
195 m_VtkImageImport->Update();
197 m_Actor->SetInputData(m_VtkImageImport->GetOutput());
200 m_Actor->SetOpacity(m_Opacity);
202 m_Renderer->AddActor(m_Actor);
203 m_Renderer->InteractiveOff();
218 vtkImageData *image = m_Actor->GetInput();
219 m_Camera = m_Renderer->GetActiveCamera();
220 m_Camera->SetClippingRange(1, 100000);
229 image->GetSpacing(spacing);
230 image->GetOrigin(origin);
231 image->GetDimensions(dimensions);
233 double focalPoint[3];
236 for (
unsigned int cc = 0; cc < 3; cc++)
238 focalPoint[cc] = origin[cc] + (spacing[cc] * dimensions[cc]) / 2.0;
239 position[cc] = focalPoint[cc];
242 m_Camera->SetViewUp(0, 1, 0);
244 const double distanceToFocalPoint = 1000;
245 position[idx] = distanceToFocalPoint;
247 m_Camera->ParallelProjectionOn();
248 m_Camera->SetPosition(position);
249 m_Camera->SetFocalPoint(focalPoint);
251 int d1 = (idx + 1) % 3;
252 int d2 = (idx + 2) % 3;
254 double max =
std::max(dimensions[d1], dimensions[d2]);
256 m_Camera->SetParallelScale(max / 2);
264 vtkImageData *image = m_Actor->GetInput();
265 image->GetDimensions(dimensions);
267 double max =
std::max(dimensions[0], dimensions[1]);
268 double normX = dimensions[0] /
max;
269 double normY = dimensions[1] /
max;
273 switch (m_LogoPosition)
277 newPos[0] = (0 + buffer);
278 newPos[1] = (0 + buffer);
279 newPos[2] = 0.2 * normX * m_ZoomFactor;
280 newPos[3] = 0.2 * normY * m_ZoomFactor;
285 newPos[0] = (1 - buffer) - 0.2 * normX * m_ZoomFactor;
287 newPos[2] = (1 - buffer);
288 newPos[3] = 0.2 * normY * m_ZoomFactor;
293 newPos[0] = (0 + buffer);
294 newPos[1] = (1 - buffer) - 0.2 * normY * m_ZoomFactor;
295 newPos[2] = 0.2 * normX * m_ZoomFactor;
296 newPos[3] = (1 - buffer);
301 newPos[0] = (1 - buffer) - 0.2 * normX * m_ZoomFactor;
302 newPos[1] = (1 - buffer) - 0.2 * normY * m_ZoomFactor;
303 newPos[2] = (1 - buffer);
304 newPos[3] = (1 - buffer);
310 newPos[0] = 0.5 - 0.1 * normX * m_ZoomFactor;
311 newPos[1] = 0.5 - 0.1 * normY * m_ZoomFactor;
312 newPos[2] = 0.5 + 0.1 * normX * m_ZoomFactor;
313 newPos[3] = 0.5 + 0.1 * normY * m_ZoomFactor;
318 m_Renderer->SetViewport(newPos);
323 m_ForceShowMBIDepartmentLogo = visible;
328 m_ZoomFactor = factor;
341 if (this->IsEnabled() && !m_ForceShowMBIDepartmentLogo)
bool m_ForceShowMBIDepartmentLogo
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override
virtual vtkImageActor * GetActor()
vtkImageMapper * m_Mapper
LogoPosition m_LogoPosition
void InsertForegroundRenderer(vtkSmartPointer< vtkRenderer > renderer, bool forceAbsoluteForeground)
static const unsigned int mbiLogo_Data[]
virtual vtkRenderWindow * GetRenderWindow()
virtual void SetZoomFactor(double factor)
virtual vtkImageMapper * GetMapper()
virtual void SetRequestedRegion(const itk::DataObject *) override
virtual void SetRequestedRegionToLargestPossibleRegion() override
virtual void ForceMBILogoVisible(bool visible)
static const unsigned int mbiLogo_Height
virtual void SetLogoSource(const char *filename)
static VtkLayerController * GetInstance(vtkSmartPointer< vtkRenderWindow > renWin)
static const unsigned int mbiLogo_Width
virtual void SetRenderWindow(vtkRenderWindow *renderWindow)
static const std::string filename
vtkImageImport * m_VtkImageImport
void RemoveRenderer(vtkSmartPointer< vtkRenderer > renderer)
virtual void SetOpacity(double opacity)
vtkRenderWindow * m_RenderWindow
virtual bool VerifyRequestedRegion() override
virtual vtkRenderer * GetVtkRenderer()
static const unsigned int mbiLogo_NumberOfScalars
vtkPNGReader * m_PngReader
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.