Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
QmitkUSAbstractCustomWidget Class Referenceabstract

Abstract superclass for all custom control widgets of mitk::USDevice classes. More...

#include <QmitkUSAbstractCustomWidget.h>

Inheritance diagram for QmitkUSAbstractCustomWidget:
Collaboration diagram for QmitkUSAbstractCustomWidget:

Public Member Functions

 QmitkUSAbstractCustomWidget (QWidget *parent=nullptr)
 
 ~QmitkUSAbstractCustomWidget () override
 
void SetDevice (mitk::USDevice::Pointer device)
 
mitk::USDevice::Pointer GetDevice () const
 
virtual void OnDeviceSet ()=0
 Called every time a mitk::USDevice was set with QmitkUSAbstractCustomWidget::SetDevice(). A sublcass can implement this function to handle initialiation actions necessary when a device was set. More...
 
virtual std::string GetDeviceClass () const =0
 Subclass must implement this method to return device class of corresponding mitk::USDevice. More...
 
virtual QmitkUSAbstractCustomWidgetClone (QWidget *parent=nullptr) const =0
 Subclass must implement this method to return a pointer to a copy of the object. More...
 
virtual void Initialize ()=0
 Method for initializing the Qt stuff of the widget (setupUI, connect). This method will be called in CloneForQt() and has to be implemented by concrete subclasses. More...
 
QmitkUSAbstractCustomWidgetCloneForQt (QWidget *parent=nullptr) const
 Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with additionaly setting an internal flag that the object was really cloned. More...
 
us::ServiceProperties GetServiceProperties () const
 Returns the properties of the micro service. Properties consist of just the device class of the corresponding mitk::USDevice. More...
 
void showEvent (QShowEvent *event) override
 Overwritten Qt even method. It is checked if the object was cloned with QmitkUSAbstractCustomWidget::CloneForQt() before. An exception is thrown if not. This is done, because using the object from micro service directly in Qt without cloning it first can cause problems after Qt deleted the object. More...
 

Static Public Member Functions

static std::string US_DEVICE_PROPKEY_CLASS ()
 Property key for the class name of corresponding us device object. More...
 

Detailed Description

Abstract superclass for all custom control widgets of mitk::USDevice classes.

The custom control widgets are made available using a us::PrototypeServiceFactory. This means that each concrete subclass should be registered in the microservice by calling QmitkUSAbstractCustomWidget::RegisterService() on an object. The best place for doing this would be in the corresponding module or plugin activator.

Afterwards a copy of the registered object can be obtained from the microservice as shown in the example below. Do not forget to call QmitkUSAbstractCustomWidget::CloneForQt() on the object received from the microservice. This is necessary to allow deleting the object as it is necessary in Qt for removing it from a layout.

Subclasses must implement three methods:

The code to use a custom control widget in a plugin can look like this:

ctkPluginContext* pluginContext = // get the plugig context
mitk::USDevice device = // get the ultrasound device
// get service references for ultrasound device
std::string filter = "(org.mitk.services.UltrasoundCustomWidget.deviceClass=" + device->GetDeviceClass() + ")";
QString interfaceName ( us_service_interface_iid<QmitkUSAbstractCustomWidget>() );
QList<ctkServiceReference> serviceRefs = pluginContext->getServiceReferences(interfaceName, QString::fromStdString(filter));
if (serviceRefs.size() > 0)
{
// get widget from the service and make sure that it is cloned, so that
// it can be deleted if it should be removed from the GUI later
QmitkUSAbstractCustomWidget* widget = pluginContext->getService<QmitkUSAbstractCustomWidget>
(serviceRefs.at(0))->CloneForQt(parentWidget);
// now the widget can be used like any other QWidget
}

Definition at line 65 of file QmitkUSAbstractCustomWidget.h.

Constructor & Destructor Documentation

◆ QmitkUSAbstractCustomWidget()

QmitkUSAbstractCustomWidget::QmitkUSAbstractCustomWidget ( QWidget *  parent = nullptr)

◆ ~QmitkUSAbstractCustomWidget()

QmitkUSAbstractCustomWidget::~QmitkUSAbstractCustomWidget ( )
override

Member Function Documentation

◆ Clone()

virtual QmitkUSAbstractCustomWidget* QmitkUSAbstractCustomWidget::Clone ( QWidget *  parent = nullptr) const
pure virtual

Subclass must implement this method to return a pointer to a copy of the object.

Implemented in QmitkUSControlsCustomVideoDeviceWidget.

◆ CloneForQt()

QmitkUSAbstractCustomWidget* QmitkUSAbstractCustomWidget::CloneForQt ( QWidget *  parent = nullptr) const

Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with additionaly setting an internal flag that the object was really cloned.

◆ GetDevice()

mitk::USDevice::Pointer QmitkUSAbstractCustomWidget::GetDevice ( ) const

◆ GetDeviceClass()

virtual std::string QmitkUSAbstractCustomWidget::GetDeviceClass ( ) const
pure virtual

Subclass must implement this method to return device class of corresponding mitk::USDevice.

Returns
same value as mitk::USDevice::GetDeviceClass() of the corresponding mitk::USDevice

Implemented in QmitkUSControlsCustomVideoDeviceWidget.

◆ GetServiceProperties()

us::ServiceProperties QmitkUSAbstractCustomWidget::GetServiceProperties ( ) const

Returns the properties of the micro service. Properties consist of just the device class of the corresponding mitk::USDevice.

◆ Initialize()

virtual void QmitkUSAbstractCustomWidget::Initialize ( )
pure virtual

Method for initializing the Qt stuff of the widget (setupUI, connect). This method will be called in CloneForQt() and has to be implemented by concrete subclasses.

Warning
All Qt initialization stuff belongs into this method rather than in the constructor.

Implemented in QmitkUSControlsCustomVideoDeviceWidget.

◆ OnDeviceSet()

virtual void QmitkUSAbstractCustomWidget::OnDeviceSet ( )
pure virtual

Called every time a mitk::USDevice was set with QmitkUSAbstractCustomWidget::SetDevice(). A sublcass can implement this function to handle initialiation actions necessary when a device was set.

Implemented in QmitkUSControlsCustomVideoDeviceWidget.

◆ SetDevice()

void QmitkUSAbstractCustomWidget::SetDevice ( mitk::USDevice::Pointer  device)

◆ showEvent()

void QmitkUSAbstractCustomWidget::showEvent ( QShowEvent *  event)
override

Overwritten Qt even method. It is checked if the object was cloned with QmitkUSAbstractCustomWidget::CloneForQt() before. An exception is thrown if not. This is done, because using the object from micro service directly in Qt without cloning it first can cause problems after Qt deleted the object.

Exceptions
mitk::Exception

◆ US_DEVICE_PROPKEY_CLASS()

static std::string QmitkUSAbstractCustomWidget::US_DEVICE_PROPKEY_CLASS ( )
static

Property key for the class name of corresponding us device object.


The documentation for this class was generated from the following file:
QmitkUSAbstractCustomWidget::CloneForQt
QmitkUSAbstractCustomWidget * CloneForQt(QWidget *parent=nullptr) const
Return pointer to copy of the object. Internally use of QmitkUSAbstractCustomWidget::Clone() with add...
mitk::USDevice::GetDeviceClass
virtual std::string GetDeviceClass()=0
Returns the Class of the Device. This Method must be reimplemented by every Inheriting Class.
mitk::USDevice
A device holds information about it's model, make and the connected probes. It is the common super cl...
Definition: mitkUSDevice.h:75
QmitkUSAbstractCustomWidget
Abstract superclass for all custom control widgets of mitk::USDevice classes.
Definition: QmitkUSAbstractCustomWidget.h:65