Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKUSTelemedSDKHeader_H
18 #define MITKUSTelemedSDKHeader_H
19 
20 /*#include <strmif.h>
21 #include <usgfw2.h>
22 #include <usgfw.h>
23 #include <usgscanb.h>*/
24 
25 #include <Usgfw2.tlh>
26 
27 #include <mitkCommon.h>
28 
32 #define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; }
33 
37 #define RETURN_TelemedValue(control) { \
38  LONG value; \
39  HRESULT hr = control->get_Current(&value); \
40  if (FAILED(hr)) { mitkThrow() << "Could not get telemed value " << control << "(" << hr << ")."; }; \
41  return static_cast<double>(value); \
42 }
43 
47 #define SET_TelemedValue(control,value) { \
48  HRESULT hr = control->put_Current(static_cast<LONG>(value)); \
49  if (FAILED(hr)) { mitkThrow() << "Could not set telemed value " << value << " to " << control << "(" << hr << ")."; }; \
50 }
51 
56 #define RETURN_TelemedAvailableValues(control) { \
57  RETURN_TelemedAvailableValuesWithFactor(control, 1); \
58 }
59 
60 #define RETURN_TelemedAvailableValuesWithFactor(control, factor) { \
61  Usgfw2Lib::IUsgValues *usgValues; \
62  HRESULT hr = control->get_Values(&usgValues); \
63  \
64  LONG usgValuesNum; \
65  hr = usgValues->get_Count(&usgValuesNum); \
66  \
67  std::vector<double> values(usgValuesNum, 0); \
68  \
69  VARIANT item; \
70  for (int n = 0; n < usgValuesNum; n++) \
71  { \
72  item = usgValues->Item(n); \
73  values.at(n) = static_cast<double>(item.lVal) / factor; \
74  VariantClear(&item); \
75  } \
76  \
77  SAFE_RELEASE(usgValues); \
78  return values; \
79 }
80 
87 #define GETINOUTPUT_TelemedAvailableValuesBounds(control, output) { \
88  Usgfw2Lib::IUsgValues *usgValues; \
89  HRESULT hr = control->get_Values(&usgValues); \
90  if (FAILED(hr)) { mitkThrow() << "Values couldn't be read from Teleme API (" << hr << ")."; } \
91  \
92  LONG usgValuesNum; \
93  hr = usgValues->get_Count(&usgValuesNum); \
94  if (usgValuesNum < 1 || FAILED(hr)) { mitkThrow() << "No values could be read from Telemed API."; } \
95  \
96  VARIANT item; \
97  \
98  item = usgValues->Item(0); \
99  output[0] = static_cast<double>(item.lVal); \
100  VariantClear(&item); \
101  \
102  item = usgValues->Item(usgValuesNum-1); \
103  output[1] = static_cast<double>(item.lVal); \
104  VariantClear(&item); \
105  \
106  output[2] = (output[1] - output[0]) / usgValuesNum; \
107 }
108 
113 #define CREATE_TelemedControl(control, dataView, iidType, type, scanMode) { \
114  IUnknown* tmp_obj = NULL; \
115  mitk::telemed::CreateUsgControl( dataView, iidType, scanMode, 0, (void**)&tmp_obj ); \
116  if ( ! tmp_obj ) { mitkThrow() << "Could not create telemed control " << control << ")."; } \
117  \
118  SAFE_RELEASE(control); \
119  control = (type*)tmp_obj; \
120 }
121 
122 namespace mitk {
123  namespace telemed {
125 
131  bool CreateUsgControl( Usgfw2Lib::IUsgDataView* dataView, const IID& typeId, ULONG scanMode, ULONG streamId, void** ctrl );
132 
136  std::string ConvertWcharToString( const BSTR input );
137  } // namespace telemed
138 } // namespace mitk
139 
140 #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)