Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkStatusBar.cpp
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 #include "mitkStatusBar.h"
14 #include <itkObjectFactory.h>
15 #include <itkOutputWindow.h>
16 
17 namespace mitk
18 {
19  StatusBarImplementation *StatusBar::m_Implementation = nullptr;
20  StatusBar *StatusBar::m_Instance = nullptr;
21 
25  void StatusBar::DisplayText(const char *t)
26  {
27  if (m_Implementation != nullptr)
29  }
30 
34  void StatusBar::DisplayText(const char *t, int ms)
35  {
36  if (m_Implementation != nullptr)
38  }
39 
40  void StatusBar::DisplayErrorText(const char *t)
41  {
42  if (m_Implementation != nullptr)
44  }
45  void StatusBar::DisplayWarningText(const char *t)
46  {
47  if (m_Implementation != nullptr)
49  }
50  void StatusBar::DisplayWarningText(const char *t, int ms)
51  {
52  if (m_Implementation != nullptr)
54  }
56  {
57  if (m_Implementation != nullptr)
59  }
60  void StatusBar::DisplayDebugText(const char *t)
61  {
62  if (m_Implementation != nullptr)
64  }
65  void StatusBar::DisplayGreyValueText(const char *t)
66  {
67  if (m_Implementation != nullptr)
69  }
70 
71  static void WriteCommonImageInfo(
72  std::ostringstream &stream, Point3D point, itk::Index<3> index, ScalarType time)
73  {
74  stream << "Position: <" << std::fixed << point[0] << ", "
75  << std::fixed << point[1] << ", "
76  << std::fixed << point[2] << "> mm; ";
77 
78  stream << "Index: <" << index[0] << ", "
79  << index[1] << ", "
80  << index[2] << "> ; ";
81 
82  stream << "Time: " << time << " ms";
83  }
84 
86  {
87  if (m_Implementation == nullptr)
88  return;
89 
90  std::ostringstream stream;
91  stream.imbue(std::locale::classic());
92  stream.precision(2);
93 
94  WriteCommonImageInfo(stream, point, index, time);
95  stream << "; Pixel value: ";
96 
97  if (fabs(pixelValue) > 1000000 || fabs(pixelValue) < 0.01)
98  stream << std::scientific;
99 
100  stream << pixelValue;
101 
102  m_Implementation->DisplayGreyValueText(stream.str().c_str());
103  }
104 
105  void StatusBar::DisplayImageInfo(Point3D point, itk::Index<3> index, ScalarType time, const char *pixelValue)
106  {
107  if (m_Implementation == nullptr)
108  return;
109 
110  std::ostringstream stream;
111  stream.imbue(std::locale::classic());
112  stream.precision(2);
113 
114  WriteCommonImageInfo(stream, point, index, time);
115  stream << "; " << pixelValue;
116 
117  m_Implementation->DisplayGreyValueText(stream.str().c_str());
118  }
119 
121  {
122  if (m_Implementation != nullptr)
123  m_Implementation->DisplayGreyValueText("No image information at this position!");
124  }
126  {
127  if (m_Implementation != nullptr)
129  }
131  {
132  if (m_Implementation != nullptr)
133  {
135  }
136  }
141  {
142  if (m_Instance == nullptr) // if not set, then send a errormessage on OutputWindow
143  {
144  m_Instance = new StatusBar();
145  }
146 
147  return m_Instance;
148  }
149 
154  {
155  if (m_Implementation == implementation)
156  {
157  return;
158  }
159  m_Implementation = implementation;
160  }
161 
164 } // end namespace mitk
void DisplayImageInfoInvalid()
Display placeholder text for invalid information.
virtual void SetSizeGripEnabled(bool enable)=0
Set the SizeGrip of the window (the triangle in the lower right Windowcorner for changing the size) t...
double ScalarType
void SetSizeGripEnabled(bool enable)
Set the SizeGrip of the window (the triangle in the lower right Windowcorner for changing the size) t...
void DisplayImageInfo(mitk::Point3D point, itk::Index< 3 > index, mitk::ScalarType time, mitk::ScalarType pixelValue)
Display position, index, time and pixel value.
void DisplayDebugText(const char *t)
DataCollection - Class to facilitate loading/accessing structured data.
void DisplayGenericOutputText(const char *t)
static void WriteCommonImageInfo(std::ostringstream &stream, Point3D point, itk::Index< 3 > index, ScalarType time)
GUI indepentent Interface for all Gui depentent implementations of a StatusBar.
void DisplayErrorText(const char *t)
~StatusBar() override
static StatusBarImplementation * m_Implementation
Definition: mitkStatusBar.h:86
void DisplayText(const char *t)
Send a string to the applications StatusBar.
virtual void DisplayGenericOutputText(const char *t)=0
virtual void DisplayErrorText(const char *t)=0
static StatusBar * m_Instance
Definition: mitkStatusBar.h:87
virtual void DisplayWarningText(const char *t)=0
static StatusBar * GetInstance()
static method to get the GUI dependent StatusBar-instance so the methods DisplayText, etc. can be called No reference counting, cause of decentral static use!
void Clear()
removes any temporary message being shown.
void DisplayGreyValueText(const char *t)
virtual void DisplayText(const char *t)=0
Send a string to the applications StatusBar.
virtual void Clear()=0
removes any temporary message being shown.
Sending a message to the applications StatusBar.
Definition: mitkStatusBar.h:32
static void SetImplementation(StatusBarImplementation *instance)
Supply a GUI- dependent StatusBar. Has to be set by the application to connect the application depend...
void DisplayWarningText(const char *t)
virtual void DisplayDebugText(const char *t)=0
virtual void DisplayGreyValueText(const char *t)=0