diff --git a/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.cpp b/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.cpp index 27303955b4..6f63829d1c 100644 --- a/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.cpp +++ b/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.cpp @@ -1,290 +1,265 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkUSTelemedBModeControls.h" #include "mitkUSTelemedDevice.h" #include #define TELEMED_FREQUENCY_FACTOR 1000000 mitk::USTelemedBModeControls::USTelemedBModeControls(itk::SmartPointer device) : mitk::USControlInterfaceBMode(device.GetPointer()), m_UsgDataView(0), m_PowerControl(0), m_FrequencyControl(0), m_DepthControl(0), m_GainControl(0), m_RejectionControl(0), m_DynamicRangeControl(0), m_Active(false), m_PowerSteps(new double[3]), m_GainSteps(new double[3]), m_RejectionSteps(new double[3]), - m_DynamicRangeSteps(new double[3]), - m_MixerControl(0) + m_DynamicRangeSteps(new double[3]) { - tagRECT *rectDim = new tagRECT(); - //tagRECT* rectDim(*RECT{ 0,0,255,255 }); - rectDim->left = 0; - rectDim->top = 0; - rectDim->right = 255; - rectDim->bottom = 255; - //Rectangle rect; - //Usgfw2Lib::tagRECT rect1; - //rect = ultrasound_panel->ClientRectangle; - //rect1.left = rect.Left; - //rect1.right = rect.Right; - //rect1.top = rect.Top; - //rect1.bottom = rect.Bottom; - //// set ultrasound output rectangle - - - - // Usgfw2Lib::IUsgScanMode* mode; - // get mixer control - //mode->GetMixerControl((unsigned int)Usgfw2Lib::tagScanMode::SCAN_MODE_B, 0, &m_MixerControl); - //m_MixerControl = Usgfw2Lib::IUsgDataStream::GetMixerControl(); - //auto USrect = m_MixerControl->SetOutputRect(rectDim); } mitk::USTelemedBModeControls::~USTelemedBModeControls() { this->ReleaseControls(); delete[] m_PowerSteps; delete[] m_GainSteps; delete[] m_RejectionSteps; delete[] m_DynamicRangeSteps; } void mitk::USTelemedBModeControls::SetUsgDataView( Usgfw2Lib::IUsgDataView* usgDataView) { m_UsgDataView = usgDataView; } void mitk::USTelemedBModeControls::ReinitializeControls( ) { this->ReleaseControls(); this->CreateControls(); } void mitk::USTelemedBModeControls::SetIsActive(bool active) { if (active) { HRESULT hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_STOP); if (FAILED(hr)) { mitkThrow() << "Could not stop scanning (" << hr << ")."; } // make sure that current scan mode is b mode now hr = m_UsgDataView->put_ScanMode(Usgfw2Lib::SCAN_MODE_B); if (FAILED(hr)) { mitkThrow() << "Could not set scan mode b (" << hr << ")."; } hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN); if (FAILED(hr)) { mitkThrow() << "Could not start scanning (" << hr << ")."; } this->CreateControls(); m_Active = true; } else { this->ReleaseControls(); m_Active = false; } } bool mitk::USTelemedBModeControls::GetIsActive( ) { // get scan mode, because scan mode must be B mode // for this interface being active ULONG scanMode; HRESULT hr = m_UsgDataView->get_ScanMode(&scanMode); if (FAILED(hr)) { mitkThrow() << "Could not get scan mode (" << hr << ")."; } return m_Active && scanMode == Usgfw2Lib::SCAN_MODE_B; } double mitk::USTelemedBModeControls::GetScanningFrequencyAPI( ) { RETURN_TelemedValue(m_FrequencyControl); } double mitk::USTelemedBModeControls::GetScanningFrequency( ) { return this->GetScanningFrequencyAPI() / TELEMED_FREQUENCY_FACTOR; } void mitk::USTelemedBModeControls::OnSetScanningFrequency( double value ) { SET_TelemedValue(m_FrequencyControl, value * TELEMED_FREQUENCY_FACTOR); } std::vector mitk::USTelemedBModeControls::GetScanningFrequencyValues( ) { RETURN_TelemedAvailableValuesWithFactor(m_FrequencyControl, TELEMED_FREQUENCY_FACTOR); } double mitk::USTelemedBModeControls::GetScanningPower( ) { RETURN_TelemedValue(m_PowerControl); } void mitk::USTelemedBModeControls::OnSetScanningPower(double value) { SET_TelemedValue(m_PowerControl, value); } double mitk::USTelemedBModeControls::GetScanningPowerMin() { return m_PowerSteps[0]; } double mitk::USTelemedBModeControls::GetScanningPowerMax() { return m_PowerSteps[1]; } double mitk::USTelemedBModeControls::GetScanningPowerTick() { return m_PowerSteps[2]; } double mitk::USTelemedBModeControls::GetScanningDepth() { RETURN_TelemedValue(m_DepthControl); } void mitk::USTelemedBModeControls::OnSetScanningDepth(double value) { SET_TelemedValue(m_DepthControl,value); } std::vector mitk::USTelemedBModeControls::GetScanningDepthValues() { RETURN_TelemedAvailableValues(m_DepthControl); } double mitk::USTelemedBModeControls::GetScanningGain( ) { RETURN_TelemedValue(m_GainControl); } void mitk::USTelemedBModeControls::OnSetScanningGain(double value) { SET_TelemedValue(m_GainControl, value); } double mitk::USTelemedBModeControls::GetScanningGainMin() { return m_GainSteps[0]; } double mitk::USTelemedBModeControls::GetScanningGainMax() { return m_GainSteps[1]; } double mitk::USTelemedBModeControls::GetScanningGainTick() { return m_GainSteps[2]; } double mitk::USTelemedBModeControls::GetScanningRejection() { RETURN_TelemedValue(m_RejectionControl); } void mitk::USTelemedBModeControls::OnSetScanningRejection(double value) { SET_TelemedValue(m_RejectionControl, value); } double mitk::USTelemedBModeControls::GetScanningRejectionMin( ) { return m_RejectionSteps[0]; } double mitk::USTelemedBModeControls::GetScanningRejectionMax( ) { return m_RejectionSteps[1]; } double mitk::USTelemedBModeControls::GetScanningRejectionTick( ) { return m_RejectionSteps[2]; } double mitk::USTelemedBModeControls::GetScanningDynamicRange( ) { RETURN_TelemedValue(m_DynamicRangeControl); } void mitk::USTelemedBModeControls::OnSetScanningDynamicRange( double value ) { SET_TelemedValue(m_DynamicRangeControl, value); } double mitk::USTelemedBModeControls::GetScanningDynamicRangeMin( ) { return m_DynamicRangeSteps[0]; } double mitk::USTelemedBModeControls::GetScanningDynamicRangeMax( ) { return m_DynamicRangeSteps[1]; } double mitk::USTelemedBModeControls::GetScanningDynamicRangeTick( ) { return m_DynamicRangeSteps[2]; } void mitk::USTelemedBModeControls::CreateControls() { // create frequency control CREATE_TelemedControl(m_FrequencyControl, m_UsgDataView, Usgfw2Lib::IID_IUsgProbeFrequency2, Usgfw2Lib::IUsgProbeFrequency2, Usgfw2Lib::SCAN_MODE_B); // create power control CREATE_TelemedControl(m_PowerControl, m_UsgDataView, Usgfw2Lib::IID_IUsgPower, Usgfw2Lib::IUsgPower, Usgfw2Lib::SCAN_MODE_B); GETINOUTPUT_TelemedAvailableValuesBounds(m_PowerControl, m_PowerSteps); // get min, max and tick for gain // create B mode depth control CREATE_TelemedControl(m_DepthControl, m_UsgDataView, Usgfw2Lib::IID_IUsgDepth, Usgfw2Lib::IUsgDepth, Usgfw2Lib::SCAN_MODE_B); // create B mode gain control CREATE_TelemedControl(m_GainControl, m_UsgDataView, Usgfw2Lib::IID_IUsgGain, Usgfw2Lib::IUsgGain, Usgfw2Lib::SCAN_MODE_B); GETINOUTPUT_TelemedAvailableValuesBounds(m_GainControl, m_GainSteps); // get min, max and tick for gain // create B mode rejection control CREATE_TelemedControl(m_RejectionControl, m_UsgDataView, Usgfw2Lib::IID_IUsgRejection2, Usgfw2Lib::IUsgRejection2, Usgfw2Lib::SCAN_MODE_B); GETINOUTPUT_TelemedAvailableValuesBounds(m_RejectionControl, m_RejectionSteps); // get min, max and tick for rejection // create B mode dynamic range control CREATE_TelemedControl(m_DynamicRangeControl, m_UsgDataView, Usgfw2Lib::IID_IUsgDynamicRange, Usgfw2Lib::IUsgDynamicRange, Usgfw2Lib::SCAN_MODE_B); GETINOUTPUT_TelemedAvailableValuesBounds(m_DynamicRangeControl, m_DynamicRangeSteps); // get min, max and tick for dynamic range - // create B mode mixer control - CREATE_TelemedControl(m_MixerControl, m_UsgDataView, Usgfw2Lib::IID_IUsgMixerControl, Usgfw2Lib::IUsgMixerControl, Usgfw2Lib::SCAN_MODE_B); - //GETINOUTPUT_TelemedAvailableValuesBounds(m_MixerControl, m_MixerControlSteps); // get min, max and tick for dynamic range + } void mitk::USTelemedBModeControls::ReleaseControls() { // remove all controls and delete their objects SAFE_RELEASE(m_PowerControl); SAFE_RELEASE(m_FrequencyControl); SAFE_RELEASE(m_DepthControl); SAFE_RELEASE(m_GainControl); SAFE_RELEASE(m_RejectionControl); SAFE_RELEASE(m_DynamicRangeControl); } \ No newline at end of file diff --git a/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.h b/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.h index 663e39f249..2738d7abcb 100644 --- a/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.h +++ b/Modules/US/USHardwareTelemed/mitkUSTelemedBModeControls.h @@ -1,116 +1,119 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKUSTelemedBModeControls_H_HEADER_INCLUDED_ #define MITKUSTelemedBModeControls_H_HEADER_INCLUDED_ #include "mitkUSTelemedSDKHeader.h" #include "mitkUSControlInterfaceBMode.h" #include namespace mitk { class USTelemedDevice; /** * \brief Implementation of mitk::USControlInterfaceBMode for Telemed ultrasound devices. * See documentation of mitk::USControlInterfaceBMode for a description of the interface methods. */ class USTelemedBModeControls : public USControlInterfaceBMode { public: mitkClassMacro(USTelemedBModeControls, USControlInterfaceBMode); mitkNewMacro1Param(Self, itk::SmartPointer); /** * Scan mode is set to b mode when this controls are activated. * All necessary controls are created at the Telemed API. */ virtual void SetIsActive( bool ); /** * \return true if API controls are created and scan mode is set to b mode */ virtual bool GetIsActive( ); virtual double GetScanningFrequency( ); virtual void OnSetScanningFrequency( double frequency ); virtual std::vector GetScanningFrequencyValues( ); virtual double GetScanningPower( ); virtual void OnSetScanningPower( double power ); virtual double GetScanningPowerMin( ); virtual double GetScanningPowerMax( ); virtual double GetScanningPowerTick( ); virtual double GetScanningDepth( ); virtual void OnSetScanningDepth( double ); virtual std::vector GetScanningDepthValues( ); virtual double GetScanningGain( ); virtual void OnSetScanningGain( double ); virtual double GetScanningGainMin( ); virtual double GetScanningGainMax( ); virtual double GetScanningGainTick( ); virtual double GetScanningRejection( ); virtual void OnSetScanningRejection( double ); virtual double GetScanningRejectionMin( ); virtual double GetScanningRejectionMax( ); virtual double GetScanningRejectionTick( ); virtual double GetScanningDynamicRange( ); virtual void OnSetScanningDynamicRange( double ); virtual double GetScanningDynamicRangeMin( ); virtual double GetScanningDynamicRangeMax( ); virtual double GetScanningDynamicRangeTick( ); /** * \brief Setter for the IUsgDataView necesary for communicating with the Telemed API. * This method is just for internal use of the mitk::USTelemedDevice. */ void SetUsgDataView( Usgfw2Lib::IUsgDataView* ); void ReinitializeControls( ); protected: USTelemedBModeControls(itk::SmartPointer device); virtual ~USTelemedBModeControls(); void CreateControls( ); void ReleaseControls( ); double GetScanningFrequencyAPI( ); Usgfw2Lib::IUsgDataView* m_UsgDataView; // main SDK object for comminucating with the Telemed API Usgfw2Lib::IUsgPower* m_PowerControl; // control for scanning power Usgfw2Lib::IUsgProbeFrequency2* m_FrequencyControl; // control for scanning frequency Usgfw2Lib::IUsgDepth* m_DepthControl; // control for B mode scanning depth Usgfw2Lib::IUsgGain* m_GainControl; // control for B mode scanning gain Usgfw2Lib::IUsgRejection2* m_RejectionControl; // control for B mode scanning rejection Usgfw2Lib::IUsgDynamicRange* m_DynamicRangeControl; // control for B mode dynamic range - Usgfw2Lib::IUsgMixerControl* m_MixerControl; // control for B mode mixer control + + bool m_Active; double* m_PowerSteps; // array holding possible power values: [min, max, tick] double* m_GainSteps; // array holding possible gains: [min, max, tick] double* m_RejectionSteps; // array holding possible rejections: [min, max, tick] double* m_DynamicRangeSteps; // array holding possible dynamic range values: [min, max, tick] + + }; } // namespace mitk #endif // MITKUSTelemedBModeControls_H_HEADER_INCLUDED_ \ No newline at end of file diff --git a/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.cpp b/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.cpp index b6af6c3acb..82135bd5ec 100644 --- a/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.cpp +++ b/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.cpp @@ -1,344 +1,367 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkUSTelemedDevice.h" - +#include "vtkWin32OpenGLRenderWindow.h" #include "mitkUSTelemedSDKHeader.h" mitk::USTelemedDevice::USTelemedDevice(std::string manufacturer, std::string model) : mitk::USDevice(manufacturer, model), m_ControlsProbes(mitk::USTelemedProbesControls::New(this)), m_ControlsBMode(mitk::USTelemedBModeControls::New(this)), m_ControlsDoppler(mitk::USTelemedDopplerControls::New(this)), m_ImageSource(mitk::USTelemedImageSource::New()), m_UsgMainInterface(0), -m_Probe(0), m_UsgDataView(0), m_ProbesCollection(0) +m_Probe(0), m_UsgDataView(0), m_ProbesCollection(0), m_usg_wnd(0), m_ImageProps(0) { SetNumberOfOutputs(1); SetNthOutput(0, this->MakeOutput(0)); } mitk::USTelemedDevice::~USTelemedDevice() { } std::string mitk::USTelemedDevice::GetDeviceClass() { return "org.mitk.modules.us.USTelemedDevice"; } mitk::USControlInterfaceBMode::Pointer mitk::USTelemedDevice::GetControlInterfaceBMode() { return m_ControlsBMode.GetPointer(); } mitk::USControlInterfaceProbes::Pointer mitk::USTelemedDevice::GetControlInterfaceProbes() { return m_ControlsProbes.GetPointer(); }; mitk::USControlInterfaceDoppler::Pointer mitk::USTelemedDevice::GetControlInterfaceDoppler() { return m_ControlsDoppler.GetPointer(); }; bool mitk::USTelemedDevice::OnInitialization() { CoInitialize(nullptr); // initialize COM library return true; } bool mitk::USTelemedDevice::OnConnection() { // create main Telemed API COM library object HRESULT hr; hr = CoCreateInstance(Usgfw2Lib::CLSID_Usgfw2, nullptr, CLSCTX_INPROC_SERVER, Usgfw2Lib::IID_IUsgfw2,(LPVOID*) &m_UsgMainInterface); if (FAILED(hr)) { SAFE_RELEASE(m_UsgMainInterface); MITK_ERROR("USDevice")("USTelemedDevice") << "Error at connecting to ultrasound device (" << hr << ")."; return false; } this->ConnectDeviceChangeSink(); return true; } bool mitk::USTelemedDevice::OnDisconnection() { // control objects cannot be active anymore m_ControlsBMode->SetIsActive(false); m_ControlsDoppler->SetIsActive(false); m_ControlsProbes->SetIsActive(false); ReleaseUsgControls(); return true; } bool mitk::USTelemedDevice::OnActivation() { // probe controls are available now m_ControlsProbes->SetIsActive(true); if ( m_ControlsProbes->GetProbesCount() < 1 ) { MITK_WARN("USDevice")("USTelemedDevice") << "No probe found."; return false; } // select first probe as a default m_ControlsProbes->SelectProbe(0); // set scan mode b as default for activation - // control interfaces can override this later HRESULT hr = m_UsgDataView->put_ScanMode(Usgfw2Lib::SCAN_MODE_B); + + Usgfw2Lib::IUsgScanMode* mode; + m_UsgDataView->GetScanModeObj(Usgfw2Lib::SCAN_MODE_B, &mode); + + + // get mixer control + mode->GetMixerControl(Usgfw2Lib::SCAN_MODE_B, 0, &m_MixerControl); + + // set B scanning mode + m_UsgDataView->put_ScanMode(Usgfw2Lib::SCAN_MODE_B); + + tagRECT rect1; + rect1.left = 0; + rect1.top = 0; + rect1.right = rect1.left + 700; + rect1.bottom = rect1.top + 380; + + // set ultrasound output rectangle + m_MixerControl->SetOutputRect(&rect1); + + + m_ImageProps->SetZoom(350, 350, 5); + if (FAILED(hr)) { MITK_ERROR("USDevice")("USTelemedDevice") << "Could not set scan mode b (" << hr << ")."; return false; } // start ultrasound scanning with selected scan mode hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN); if (FAILED(hr)) { MITK_ERROR("USDevice")("USTelemedDevice") << "Start scanning failed (" << hr << ")."; return false; } m_ControlsBMode->ReinitializeControls(); return true; } bool mitk::USTelemedDevice::OnDeactivation() { this->StopScanning(); return true; } void mitk::USTelemedDevice::OnFreeze(bool freeze) { if ( freeze ) { m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_FREEZE); } else { m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_RUN); } } mitk::USImageSource::Pointer mitk::USTelemedDevice::GetUSImageSource() { return m_ImageSource.GetPointer(); } void mitk::USTelemedDevice::ReleaseUsgControls() { if (m_UsgDataView) { this->StopScanning(); }; SAFE_RELEASE(m_UsgMainInterface); SAFE_RELEASE(m_Probe); SAFE_RELEASE(m_UsgDataView); SAFE_RELEASE(m_ProbesCollection); } void mitk::USTelemedDevice::StopScanning() { if ( ! m_UsgDataView ) { MITK_WARN("USDevice")("USTelemedDevice") << "Cannot stop scanning as Telemed Data View is null."; return; } HRESULT hr; hr = m_UsgDataView->put_ScanState(Usgfw2Lib::SCAN_STATE_STOP); if (FAILED(hr)) { MITK_ERROR("USDevice")("USTelemedDevice") << "Stop scanning failed (" << hr << ")."; mitkThrow() << "Stop scanning failed (" << hr << ")."; } } Usgfw2Lib::IUsgfw2* mitk::USTelemedDevice::GetUsgMainInterface() { return m_UsgMainInterface; } void mitk::USTelemedDevice::SetActiveDataView(Usgfw2Lib::IUsgDataView* usgDataView) { // do nothing if the usg data view hasn't changed if ( m_UsgDataView != usgDataView ) { // scan converter plugin is connected to IUsgDataView -> a new plugin // must be created when changing IUsgDataView m_UsgDataView = usgDataView; if ( ! m_ImageSource->CreateAndConnectConverterPlugin(m_UsgDataView, Usgfw2Lib::SCAN_MODE_B)) { return; } // b mode control object must know about active data view m_ControlsBMode->SetUsgDataView(m_UsgDataView); } } void mitk::USTelemedDevice::ConnectDeviceChangeSink( ) { IConnectionPointContainer* cpc = nullptr; HRESULT hr = m_UsgMainInterface->QueryInterface(IID_IConnectionPointContainer, (void**)&cpc); if (hr != S_OK) cpc = nullptr; if (cpc != nullptr) hr = cpc->FindConnectionPoint(Usgfw2Lib::IID_IUsgDeviceChangeSink, &m_UsgDeviceChangeCpnt); if (hr != S_OK) { m_UsgDeviceChangeCpnt = nullptr; m_UsgDeviceChangeCpntCookie = 0; } SAFE_RELEASE(cpc); if (m_UsgDeviceChangeCpnt != nullptr) hr = m_UsgDeviceChangeCpnt->Advise((IUnknown*)((Usgfw2Lib::IUsgDeviceChangeSink*)this), &m_UsgDeviceChangeCpntCookie); } // --- Methods for Telemed API Interfaces HRESULT __stdcall mitk::USTelemedDevice::raw_OnBeamformerArrive(IUnknown *pUsgBeamformer, ULONG *reserved) { this->Connect(); return S_OK; } HRESULT __stdcall mitk::USTelemedDevice::raw_OnBeamformerRemove(IUnknown *pUsgBeamformer, ULONG *reserved) { if ( this->GetIsActive() ) { this->Deactivate(); } this->Disconnect(); return S_OK; } HRESULT __stdcall mitk::USTelemedDevice::raw_OnProbeArrive(IUnknown*, ULONG* probeIndex) { m_ControlsProbes->ProbeAdded(static_cast(*probeIndex)); this->Activate(); return S_OK; }; HRESULT __stdcall mitk::USTelemedDevice::raw_OnProbeRemove(IUnknown*, ULONG* probeIndex) { m_ControlsProbes->ProbeRemoved(static_cast(*probeIndex)); if ( this->GetIsActive() ) { this->Deactivate(); } return S_OK; }; STDMETHODIMP_(ULONG) mitk::USTelemedDevice::AddRef() { ++m_RefCount; return m_RefCount; } STDMETHODIMP_(ULONG) mitk::USTelemedDevice::Release() { --m_RefCount; return m_RefCount; } STDMETHODIMP mitk::USTelemedDevice::QueryInterface(REFIID riid, void** ppv) { if (riid == IID_IUnknown || riid == Usgfw2Lib::IID_IUsgDeviceChangeSink) { *ppv = (IUsgDeviceChangeSink*)this; return S_OK; } if (riid == IID_IDispatch) { *ppv = (IDispatch*)this; return S_OK; } return E_NOINTERFACE; } HRESULT mitk::USTelemedDevice::GetTypeInfoCount(UINT *pctinfo) { if (pctinfo == nullptr) return E_INVALIDARG; *pctinfo = 0; return S_OK; } HRESULT mitk::USTelemedDevice::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) { if (pptinfo == nullptr) return E_INVALIDARG; *pptinfo = nullptr; if(itinfo != 0) return DISP_E_BADINDEX; return S_OK; } HRESULT mitk::USTelemedDevice::GetIDsOfNames(const IID &riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) { // this is not used - must use the same fixed dispid's from Usgfw2 idl file return S_OK; } HRESULT mitk::USTelemedDevice::Invoke(DISPID dispIdMember, const IID &riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { if ( (dispIdMember >= 1) && (dispIdMember <= 6) ) { if (pDispParams->cArgs != 2) // we need 2 arguments return S_OK; IUnknown *unkn = nullptr; ULONG *res = nullptr; VARIANTARG* p1; VARIANTARG* p; p1 = pDispParams->rgvarg; p = p1; if (p->vt == (VT_BYREF|VT_UI4)) res = p->pulVal; p1++; p = p1; if (p->vt == VT_UNKNOWN) unkn = (IUnknown*)(p->punkVal); if (dispIdMember == 1) OnProbeArrive(unkn, res); else if (dispIdMember == 2) OnBeamformerArrive(unkn, res); else if (dispIdMember == 3) OnProbeRemove(unkn, res); else if (dispIdMember == 4) OnBeamformerRemove(unkn, res); else if (dispIdMember == 5) OnProbeStateChanged(unkn, res); else if (dispIdMember == 6) OnBeamformerStateChanged(unkn, res); } return S_OK; } diff --git a/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.h b/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.h index 5c4e079254..de6b3a4aab 100644 --- a/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.h +++ b/Modules/US/USHardwareTelemed/mitkUSTelemedDevice.h @@ -1,185 +1,192 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKUSTelemedDevice_H_HEADER_INCLUDED_ #define MITKUSTelemedDevice_H_HEADER_INCLUDED_ #include "mitkUSDevice.h" #include "mitkUSTelemedImageSource.h" #include "mitkUSTelemedScanConverterPlugin.h" #include "mitkUSTelemedProbesControls.h" #include "mitkUSTelemedBModeControls.h" #include "mitkUSTelemedDopplerControls.h" - +#include #include "mitkUSTelemedSDKHeader.h" namespace mitk { /** * \brief Implementation of mitk::USDevice for Telemed API devices. * Connects to a Telemed API device through its COM library interface. * * This class handles all API communications and creates interfaces for * b mode, doppler and probes controls. * Images given by the device are put into an object of * mitk::USTelemedImageSource. * * It implements IUsgDeviceChangeSink of the Telemed API to be notified * of changes to beamformer device or probes (e.g. probe change). */ class USTelemedDevice : public USDevice, public Usgfw2Lib::IUsgDeviceChangeSink { public: mitkClassMacro(USTelemedDevice, mitk::USDevice); mitkNewMacro2Param(Self, std::string, std::string); /** * \brief Returns the class of the device. */ virtual std::string GetDeviceClass(); virtual USControlInterfaceBMode::Pointer GetControlInterfaceBMode(); virtual USControlInterfaceProbes::Pointer GetControlInterfaceProbes(); virtual USControlInterfaceDoppler::Pointer GetControlInterfaceDoppler(); /** * \brief Is called during the initialization process. * There is nothing done on the initialization of a mik::USTelemedDevive object. * * \return always true */ virtual bool OnInitialization(); /** * \brief Is called during the connection process. * Connect to the Telemed API and try to get available probes from the device. * * \return true if successfull, false if no device is connected to the pc * \throws mitk::Exception if something goes wrong at the API calls */ virtual bool OnConnection(); /** * \brief Is called during the disconnection process. * Deactivate and remove all Telemed API controls. A disconnect from the * Telemed API is not possible for which reason the hardware stays in connected * state even after calling this method. * * \return always true * \throws mitk::Exception if something goes wrong at the API calls */ virtual bool OnDisconnection(); /** * \brief Is called during the activation process. * After this method is finished, the device is generating images in b mode. * Changing scanning mode is possible afterwards by using the appropriate * control interfaces. * * \return always true * \throws mitk::Exception if something goes wrong at the API calls */ virtual bool OnActivation(); /** * \brief Is called during the deactivation process. * After a call to this method the device is connected, but not producing images anymore. * * \return always true * \throws mitk::Exception if something goes wrong at the API calls */ virtual bool OnDeactivation(); /** * \brief Changes scan state of the device if freeze is toggeled in mitk::USDevice. */ virtual void OnFreeze(bool freeze); /** @return Returns the current image source of this device. */ USImageSource::Pointer GetUSImageSource( ); /** * \brief Getter for main Telemed API object. * This method is for being called by Telemed control interfaces. */ Usgfw2Lib::IUsgfw2* GetUsgMainInterface(); /** * \brief Changes active IUsgDataView of the device. * This method is for being called by Telemed control interfaces. */ void SetActiveDataView(Usgfw2Lib::IUsgDataView*); // Methods implemented for IUsgDeviceChangeSink virtual HRESULT __stdcall raw_OnProbeArrive(IUnknown *pUsgProbe, ULONG *reserved); virtual HRESULT __stdcall raw_OnBeamformerArrive(IUnknown *pUsgBeamformer, ULONG *reserved); virtual HRESULT __stdcall raw_OnProbeRemove(IUnknown *pUsgProbe, ULONG *reserved); virtual HRESULT __stdcall raw_OnBeamformerRemove(IUnknown *pUsgBeamformer, ULONG *reserved); virtual HRESULT __stdcall raw_OnProbeStateChanged(IUnknown *pUsgProbe, ULONG *reserved) { return S_OK; }; virtual HRESULT __stdcall raw_OnBeamformerStateChanged(IUnknown *pUsgBeamformer, ULONG *reserved) { return S_OK; }; // Methods implemented for IUnknown (necessary for IUsgDeviceChangeSink) STDMETHODIMP_(ULONG) AddRef(); STDMETHODIMP_(ULONG) Release(); STDMETHODIMP QueryInterface(REFIID riid, void** ppv); // Methods implemented for IDispatch (necessary for IUsgDeviceChangeSink) virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo); virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo); virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(const IID &riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid); virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, const IID &riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); protected: /** * Constructs a mitk::USTelemedDevice object by given manufacturer * and model string. These strings are just for labeling the device * in the micro service. * * Control interfaces and image source are available directly after * construction. Registration at the micro service happens not before * initialization method was called. */ USTelemedDevice(std::string manufacturer, std::string model); virtual ~USTelemedDevice(); void ReleaseUsgControls( ); void ConnectDeviceChangeSink( ); /** * \brief Stop ultrasound scanning by Telemed API call. * * \throw mitk::Exception if API call returned with an error */ void StopScanning( ); USTelemedProbesControls::Pointer m_ControlsProbes; USTelemedBModeControls::Pointer m_ControlsBMode; USTelemedDopplerControls::Pointer m_ControlsDoppler; USTelemedImageSource::Pointer m_ImageSource; Usgfw2Lib::IUsgfw2* m_UsgMainInterface; Usgfw2Lib::IProbe* m_Probe; Usgfw2Lib::IUsgDataView* m_UsgDataView; Usgfw2Lib::IUsgCollection* m_ProbesCollection; + Usgfw2Lib::IUsgMixerControl* m_MixerControl; // control for B mode mixer control + Usgfw2Lib::IUsgImageProperties* m_ImageProps; + + HWND m_usg_wnd; ULONG m_RefCount; IConnectionPoint* m_UsgDeviceChangeCpnt; DWORD m_UsgDeviceChangeCpntCookie; + + mitk::RenderWindow::Pointer m_RenderWindow; +// vtkRenderWindow *GetVtkRenderWindow(); }; } // namespace mitk #endif // MITKUSTelemedDevice_H_HEADER_INCLUDED_ \ No newline at end of file