Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkInteractionSchemeToolBar.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 
14 
15 #include <QActionGroup>
16 
18  : QToolBar(parent)
19  , m_ActionGroup(new QActionGroup(this))
20  , m_InteractionSchemeSwitcher(nullptr)
21  , m_InteractionEventHandler(nullptr)
22 {
23  QToolBar::setOrientation(Qt::Vertical);
24  QToolBar::setIconSize(QSize(17, 17));
25  m_ActionGroup->setExclusive(true); // only one selectable action
26 
27  AddButton(InteractionScheme::PACSStandard, tr("Pointer"), QIcon(":/Qmitk/mm_pointer.png"), true);
28  AddButton(InteractionScheme::PACSLevelWindow, tr("Level/Window"), QIcon(":/Qmitk/mm_contrast.png"));
29  AddButton(InteractionScheme::PACSPan, tr("Pan"), QIcon(":/Qmitk/mm_pan.png"));
30  AddButton(InteractionScheme::PACSScroll, tr("Scroll"), QIcon(":/Qmitk/mm_scroll.png"));
31  AddButton(InteractionScheme::PACSZoom, tr("Zoom"), QIcon(":/Qmitk/mm_zoom.png"));
32 
33  m_InteractionSchemeSwitcher = mitk::InteractionSchemeSwitcher::New();
34 }
35 
37 {
38  if (interactionEventHandler == m_InteractionEventHandler)
39  {
40  return;
41  }
42 
43  m_InteractionEventHandler = interactionEventHandler;
44  try
45  {
46  m_InteractionSchemeSwitcher->SetInteractionScheme(m_InteractionEventHandler, InteractionScheme::PACSStandard);
47  }
48  catch (const mitk::Exception&)
49  {
50  return;
51  }
52 }
53 
54 void QmitkInteractionSchemeToolBar::AddButton(InteractionScheme interactionScheme, const QString& toolName, const QIcon& icon, bool on)
55 {
56  QAction* action = new QAction(icon, toolName, this);
57  action->setCheckable(true);
58  action->setActionGroup(m_ActionGroup);
59  action->setChecked(on);
60  action->setData(interactionScheme);
61  connect(action, SIGNAL(triggered()), this, SLOT(OnInteractionSchemeChanged()));
62  QToolBar::addAction(action);
63 }
64 
66 {
67  // nothing here
68 }
69 
71 {
72  QAction* action = dynamic_cast<QAction*>(sender());
73  if (action)
74  {
75  InteractionScheme interactionScheme = static_cast<InteractionScheme>(action->data().toInt());
76 
77  try
78  {
79  m_InteractionSchemeSwitcher->SetInteractionScheme(m_InteractionEventHandler, interactionScheme);
80  }
81  catch (const mitk::Exception&)
82  {
83  return;
84  }
85  }
86 }
void AddButton(InteractionScheme id, const QString &toolName, const QIcon &icon, bool on=false)
void SetInteractionEventHandler(mitk::InteractionEventHandler::Pointer interactionEventHandler)
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
QmitkInteractionSchemeToolBar(QWidget *parent=nullptr)