Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkStandardViews.h"
18 
19 #include "mitkBaseRenderer.h"
20 
21 #include <QHBoxLayout>
22 #include <QPixmap>
23 #include <QVBoxLayout>
24 #include <qclickablelabel.h>
25 
26 QmitkStandardViews::QmitkStandardViews(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
27 {
28  QVBoxLayout *vlayout = new QVBoxLayout(this);
29  QWidget *labelContainer = new QWidget(this);
30  vlayout->addStretch(1);
31  vlayout->addWidget(labelContainer);
32  vlayout->addStretch(1);
33 
34  QHBoxLayout *hlayout = new QHBoxLayout(labelContainer);
35 
36  // find embedded picture
37  QPixmap pixmap(":QmitkStandardViews.png");
38 
39  // set picture for label
40  m_ClickablePicture = new QClickableLabel(labelContainer);
41 
42  // set hotspots specific for this image
43  m_ClickablePicture->setPixmap(pixmap);
44 
45  m_ClickablePicture->AddHotspot("Left", QRect(QPoint(0, 64), QPoint(21, 83)));
46 
47  m_ClickablePicture->AddHotspot("Right", QRect(QPoint(128, 64), QPoint(149, 83)));
48 
49  m_ClickablePicture->AddHotspot("Top", QRect(QPoint(66, 0), QPoint(83, 75)));
50 
51  m_ClickablePicture->AddHotspot("Bottom", QRect(QPoint(66, 128), QPoint(83, 149)));
52 
53  m_ClickablePicture->AddHotspot("Front", QRect(QPoint(10, 102), QPoint(29, 119)));
54 
55  m_ClickablePicture->AddHotspot("Back", QRect(QPoint(119, 30), QPoint(138, 48)));
56 
57  connect(m_ClickablePicture, SIGNAL(mouseReleased(const QString &)), this, SLOT(hotspotClicked(const QString &)));
58 
59  hlayout->addStretch(1);
60  hlayout->addWidget(m_ClickablePicture);
61  hlayout->addStretch(1);
62 }
63 
65 {
66 }
67 
69 {
70  m_CameraController = controller;
71 }
72 
74 {
75  if (window != NULL)
76  {
77  if (mitk::BaseRenderer::GetInstance(window) != NULL)
78  if (mitk::BaseRenderer::GetInstance(window)->GetCameraController() != NULL)
80  }
81  else
82  {
83  std::cerr << "Warning in " << __FILE__ << ", " << __LINE__ << ": render window is NULL!" << std::endl;
84  }
85 }
86 
87 void QmitkStandardViews::hotspotClicked(const QString &s)
88 {
90  bool good(true);
91 
92  if (s == "Left")
94  else if (s == "Right")
96  else if (s == "Top")
98  else if (s == "Bottom")
100  else if (s == "Front")
102  else if (s == "Back")
104  else
105  {
106  std::cerr << "Warning in " << __FILE__ << ", " << __LINE__ << ": unknown standard view '" << s.toStdString() << "'"
107  << std::endl;
109  good = false;
110  }
111 
112  if (good)
113  {
114  if (m_CameraController.IsNotNull())
115  {
116  m_CameraController->SetStandardView(view);
117  }
118 
119  emit StandardViewDefined(view);
120  }
121 }
QmitkStandardViews(QWidget *parent=0, Qt::WindowFlags f=0)
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)
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