MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
QmitkUSAbstractCustomWidget.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
16{
17 static std::string s = "org.mitk.services.UltrasoundCustomWidget.deviceClass";
18 return s;
19}
20
22 : QWidget(parent), m_IsClonedForQt(false)
23{
24}
25
29
30void QmitkUSAbstractCustomWidget::SetDevice(mitk::USDevice::Pointer device)
31{
32 m_Device = device;
33
34 if ( device ) { this->OnDeviceSet(); }
35}
36
37mitk::USDevice::Pointer QmitkUSAbstractCustomWidget::GetDevice() const
38{
39 return m_Device;
40}
41
43{
44 QmitkUSAbstractCustomWidget* clonedWidget = this->Clone(parent);
45 clonedWidget->Initialize(); // initialize the Qt stuff of the widget
46 clonedWidget->m_IsClonedForQt = true; // set flag that this object was really cloned
47 return clonedWidget;
48}
49
51{
52 us::ServiceProperties result;
53
55
56 return result;
57}
58
59void QmitkUSAbstractCustomWidget::showEvent ( QShowEvent * event )
60{
61 // using object from micro service directly in Qt without cloning it first
62 // can cause problems when Qt deletes this object -> throw an exception to
63 // show that object should be cloned before
64 if ( ! m_IsClonedForQt )
65 {
66 MITK_ERROR << "Object wasn't cloned with CloneForQt() before using as QWidget.";
67 mitkThrow() << "Object wasn't cloned with CloneForQt() before using as QWidget.";
68 }
69
70 QWidget::showEvent(event);
71}
Abstract superclass for all custom control widgets of mitk::USDevice classes.
virtual QmitkUSAbstractCustomWidget * Clone(QWidget *parent=nullptr) const =0
Subclass must implement this method to return a pointer to a copy of the object.
virtual void Initialize()=0
Method for initializing the Qt stuff of the widget (setupUI, connect). This method will be called in ...
virtual void OnDeviceSet()=0
Called every time a mitk::USDevice was set with QmitkUSAbstractCustomWidget::SetDevice()....
us::ServiceProperties GetServiceProperties() const
Returns the properties of the micro service. Properties consist of just the device class of the corre...
static std::string US_DEVICE_PROPKEY_CLASS()
Property key for the class name of corresponding us device object.
void SetDevice(mitk::USDevice::Pointer device)
virtual std::string GetDeviceClass() const =0
Subclass must implement this method to return device class of corresponding mitk::USDevice.
QmitkUSAbstractCustomWidget(QWidget *parent=nullptr)
QmitkUSAbstractCustomWidget * CloneForQt(QWidget *parent=nullptr) const
Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with add...
mitk::USDevice::Pointer GetDevice() const
void showEvent(QShowEvent *event) override
Overwritten Qt even method. It is checked if the object was cloned with QmitkUSAbstractCustomWidget::...