Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkStandardViews.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "QmitkStandardViews.h"
14 
15 #include "mitkBaseRenderer.h"
16 
17 #include <QHBoxLayout>
18 #include <QPixmap>
19 #include <QVBoxLayout>
20 #include <qclickablelabel.h>
21 
22 QmitkStandardViews::QmitkStandardViews(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
23 {
24  QVBoxLayout *vlayout = new QVBoxLayout(this);
25  QWidget *labelContainer = new QWidget(this);
26  vlayout->addStretch(1);
27  vlayout->addWidget(labelContainer);
28  vlayout->addStretch(1);
29 
30  QHBoxLayout *hlayout = new QHBoxLayout(labelContainer);
31 
32  // find embedded picture
33  QPixmap pixmap(":QmitkStandardViews.png");
34 
35  // set picture for label
36  m_ClickablePicture = new QClickableLabel(labelContainer);
37 
38  // set hotspots specific for this image
39  m_ClickablePicture->setPixmap(pixmap);
40 
41  m_ClickablePicture->AddHotspot("Left", QRect(QPoint(0, 64), QPoint(21, 83)));
42 
43  m_ClickablePicture->AddHotspot("Right", QRect(QPoint(128, 64), QPoint(149, 83)));
44 
45  m_ClickablePicture->AddHotspot("Top", QRect(QPoint(66, 0), QPoint(83, 75)));
46 
47  m_ClickablePicture->AddHotspot("Bottom", QRect(QPoint(66, 128), QPoint(83, 149)));
48 
49  m_ClickablePicture->AddHotspot("Front", QRect(QPoint(10, 102), QPoint(29, 119)));
50 
51  m_ClickablePicture->AddHotspot("Back", QRect(QPoint(119, 30), QPoint(138, 48)));
52 
53  connect(m_ClickablePicture, SIGNAL(mouseReleased(const QString &)), this, SLOT(hotspotClicked(const QString &)));
54 
55  hlayout->addStretch(1);
56  hlayout->addWidget(m_ClickablePicture);
57  hlayout->addStretch(1);
58 }
59 
61 {
62 }
63 
65 {
66  m_CameraController = controller;
67 }
68 
70 {
71  if (window != nullptr)
72  {
73  if (mitk::BaseRenderer::GetInstance(window) != nullptr)
74  if (mitk::BaseRenderer::GetInstance(window)->GetCameraController() != nullptr)
76  }
77  else
78  {
79  std::cerr << "Warning in " << __FILE__ << ", " << __LINE__ << ": render window is nullptr!" << std::endl;
80  }
81 }
82 
83 void QmitkStandardViews::hotspotClicked(const QString &s)
84 {
86  bool good(true);
87 
88  if (s == "Left")
90  else if (s == "Right")
92  else if (s == "Top")
94  else if (s == "Bottom")
96  else if (s == "Front")
98  else if (s == "Back")
100  else
101  {
102  std::cerr << "Warning in " << __FILE__ << ", " << __LINE__ << ": unknown standard view '" << s.toStdString() << "'"
103  << std::endl;
105  good = false;
106  }
107 
108  if (good)
109  {
110  if (m_CameraController.IsNotNull())
111  {
112  m_CameraController->SetStandardView(view);
113  }
114 
115  emit StandardViewDefined(view);
116  }
117 }
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
mitk::CameraController::Pointer m_CameraController
A QLabel with multiple hotspots, that can be clicked.
void AddHotspot(const QString &name, const QRect position)
void hotspotClicked(const QString &s)
QmitkStandardViews(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
void SetCameraController(mitk::CameraController *controller)
virtual CameraController * GetCameraController()
void StandardViewDefined(mitk::CameraController::StandardView view)
void SetCameraControllerFromRenderWindow(vtkRenderWindow *window)
QClickableLabel * m_ClickablePicture
controls the camera used by the associated BaseRenderer