Medical Imaging Interaction Toolkit  2018.4.99-b585543d
Medical Imaging Interaction Toolkit
mitkUSTelemedSDKHeader.h
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 
13 #ifndef MITKUSTelemedSDKHeader_H
14 #define MITKUSTelemedSDKHeader_H
15 
16 /*#include <strmif.h>
17 #include <usgfw2.h>
18 #include <usgfw.h>
19 #include <usgscanb.h>*/
20 
21 #include <Usgfw2.tlh>
22 
23 #include <mitkCommon.h>
24 
28 #define SAFE_RELEASE(x) { if (x) x->Release(); x = nullptr; }
29 
33 #define RETURN_TelemedValue(control) { \
34  LONG value; \
35  HRESULT hr = control->get_Current(&value); \
36  if (FAILED(hr)) { mitkThrow() << "Could not get telemed value " << control << "(" << hr << ")."; }; \
37  return static_cast<double>(value); \
38 }
39 
43 #define SET_TelemedValue(control,value) { \
44  HRESULT hr = control->put_Current(static_cast<LONG>(value)); \
45  if (FAILED(hr)) { mitkThrow() << "Could not set telemed value " << value << " to " << control << "(" << hr << ")."; }; \
46 }
47 
52 #define RETURN_TelemedAvailableValues(control) { \
53  RETURN_TelemedAvailableValuesWithFactor(control, 1); \
54 }
55 
56 #define RETURN_TelemedAvailableValuesWithFactor(control, factor) { \
57  Usgfw2Lib::IUsgValues *usgValues; \
58  HRESULT hr = control->get_Values(&usgValues); \
59  \
60  LONG usgValuesNum; \
61  hr = usgValues->get_Count(&usgValuesNum); \
62  \
63  std::vector<double> values(usgValuesNum, 0); \
64  \
65  VARIANT item; \
66  for (int n = 0; n < usgValuesNum; n++) \
67  { \
68  item = usgValues->Item(n); \
69  values.at(n) = static_cast<double>(item.lVal) / factor; \
70  VariantClear(&item); \
71  } \
72  \
73  SAFE_RELEASE(usgValues); \
74  return values; \
75 }
76 
83 #define GETINOUTPUT_TelemedAvailableValuesBounds(control, output) { \
84  Usgfw2Lib::IUsgValues *usgValues; \
85  HRESULT hr = control->get_Values(&usgValues); \
86  if (FAILED(hr)) { mitkThrow() << "Values couldn't be read from Teleme API (" << hr << ")."; } \
87  \
88  LONG usgValuesNum; \
89  hr = usgValues->get_Count(&usgValuesNum); \
90  if (usgValuesNum < 1 || FAILED(hr)) { mitkThrow() << "No values could be read from Telemed API."; } \
91  \
92  VARIANT item; \
93  \
94  item = usgValues->Item(0); \
95  output[0] = static_cast<double>(item.lVal); \
96  VariantClear(&item); \
97  \
98  item = usgValues->Item(usgValuesNum-1); \
99  output[1] = static_cast<double>(item.lVal); \
100  VariantClear(&item); \
101  \
102  output[2] = (output[1] - output[0]) / usgValuesNum; \
103 }
104 
109 #define CREATE_TelemedControl(control, dataView, iidType, type, scanMode) { \
110  IUnknown* tmp_obj = nullptr; \
111  mitk::telemed::CreateUsgControl( dataView, iidType, scanMode, 0, (void**)&tmp_obj ); \
112  if ( ! tmp_obj ) { mitkThrow() << "Could not create telemed control " << control << ")."; } \
113  \
114  SAFE_RELEASE(control); \
115  control = (type*)tmp_obj; \
116 }
117 
118 namespace mitk {
119  namespace telemed {
121 
127  bool CreateUsgControl( Usgfw2Lib::IUsgDataView* dataView, const IID& typeId, ULONG scanMode, ULONG streamId, void** ctrl );
128 
132  std::string ConvertWcharToString( const BSTR input );
133  } // namespace telemed
134 } // namespace mitk
135 
136 #endif // MITKUSTelemedSDKHeader_H
DataCollection - Class to facilitate loading/accessing structured data.
std::string ConvertWcharToString(const BSTR input)
bool CreateUsgControl(Usgfw2Lib::IUsgDataView *dataView, const IID &typeId, ULONG scanMode, ULONG streamId, void **ctrl)