MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUSNavigationFreezeButton.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
14#include <QShortcut>
15
17 QPushButton(parent),
18 m_OutputIndex(-1),
19 m_FreezeButtonToggle(true)
20{
21 this->setText("Freeze Imaging");
22 this->setIcon(QIcon(":/USNavigation/system-lock-screen.png"));
23 this->setCheckable(true);
24
25 //set shortcuts
26 QShortcut *shortcut = new QShortcut(QKeySequence("F12"), parent);
27 connect(shortcut, SIGNAL(activated()), this, SLOT(OnFreezeButtonToggle()));
28
29 connect(this, SIGNAL(clicked(bool)), this, SLOT(OnButtonClicked(bool)));
30}
31
35
36void QmitkUSNavigationFreezeButton::SetCombinedModality(mitk::AbstractUltrasoundTrackerDevice::Pointer combinedModality, int outputIndex)
37{
38 m_CombinedModality = combinedModality;
39 m_OutputIndex = outputIndex;
40}
41
43{
44 if ( ! this->isChecked() )
45 {
46 this->setChecked(true);
47 this->OnButtonClicked(true);
48 }
49}
50
52{
53 if ( this->isChecked() )
54 {
55 this->setChecked(false);
56 this->OnButtonClicked(false);
57 }
58}
60{
61if(this->isVisible())
62 {
63 this->setChecked(m_FreezeButtonToggle);
64 OnButtonClicked(m_FreezeButtonToggle);
65 }
66}
67
69{
70 // cannot do anything without a combined modality
71 if ( m_CombinedModality.IsNull() )
72 {
73 MITK_WARN("QmitkUSNavigationFreezeButton")
74 << "Cannot freeze the device as the device is null.";
75 this->setChecked(false);
76 m_FreezeButtonToggle = true;
77 return;
78 }
79 m_FreezeButtonToggle = !checked;
80
81 // cannot do anything without a navigation data source
82 mitk::NavigationDataSource::Pointer navigationDataSource = m_CombinedModality->GetNavigationDataSource();
83 if ( navigationDataSource.IsNull() )
84 {
85 MITK_WARN("QmitkUSNavigationFreezeButton")
86 << "Cannot freeze the device as the NavigationDataSource is null.";
87 this->setChecked(false);
88 return;
89 }
90
91 if (checked) //freezing
92 {
93 MITK_INFO << "Freezing";
94 // freeze the imaging and the tracking
95 m_CombinedModality->SetIsFreezed(true);
96
97 if ( m_OutputIndex >= 0 )
98 {
99 // make sure that the navigation data is up to date
100 navigationDataSource->Update();
101
102 // unfreeze if the navigation data got invalid during the time between
103 // the button click and the actual freeze
104 if ( checked &&
105 ! navigationDataSource->GetOutput(m_OutputIndex)->IsDataValid() )
106 {
107 MITK_WARN("QmitkUSNavigationStepZoneMarking")("QmitkUSNavigationStepTumourSelection")
108 << "Unfreezing device as the last tracking data of the reference sensor wasn't valid.";
109
110 m_CombinedModality->SetIsFreezed(false);
111 this->setChecked(false);
112 return;
113 }
114 }
115 emit SignalFreezed(true);
116 }
117
118 else //unfreezing
119 {
120 MITK_INFO << "Unfreezing";
121 emit SignalFreezed(false);
122 //m_CombinedModality->SetIsFreezed(false);//commented out to workaround bug: may only be unfreezed after critical structure was added
123 }
124
125
126
127
128
129
130
131
132}
void Unfreeze()
Unfreeze the combined modality. This does the same as clicking the button while the combined modality...
void Freeze()
Try to freeze the combined modality. This does the same as clicking the button while the combined mod...
QmitkUSNavigationFreezeButton(QWidget *parent=nullptr)
void SignalFreezed(bool)
Emitted every time the freeze state of the combined modality changed. True if the combined modality i...
void SetCombinedModality(mitk::AbstractUltrasoundTrackerDevice::Pointer combinedModality, int outputIndex=-1)
Setter for the combined modality to be freezed by this button. An index may be specified for a tracki...