Medical Imaging Interaction Toolkit  2016.11.0
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,
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 #include "mitkStatusBar.h"
18 #include <itkObjectFactory.h>
19 #include <itkOutputWindow.h>
20 
21 namespace mitk
22 {
23  StatusBarImplementation *StatusBar::m_Implementation = nullptr;
24  StatusBar *StatusBar::m_Instance = nullptr;
25 
29  void StatusBar::DisplayText(const char *t)
30  {
31  if (m_Implementation != nullptr)
33  }
34 
38  void StatusBar::DisplayText(const char *t, int ms)
39  {
40  if (m_Implementation != nullptr)
42  }
43 
44  void StatusBar::DisplayErrorText(const char *t)
45  {
46  if (m_Implementation != nullptr)
48  }
49  void StatusBar::DisplayWarningText(const char *t)
50  {
51  if (m_Implementation != nullptr)
53  }
54  void StatusBar::DisplayWarningText(const char *t, int ms)
55  {
56  if (m_Implementation != nullptr)
58  }
60  {
61  if (m_Implementation != nullptr)
63  }
64  void StatusBar::DisplayDebugText(const char *t)
65  {
66  if (m_Implementation != nullptr)
68  }
69  void StatusBar::DisplayGreyValueText(const char *t)
70  {
71  if (m_Implementation != nullptr)
73  }
74 
75  static void WriteCommonImageInfo(
76  std::ostringstream &stream, Point3D point, itk::Index<3> index, ScalarType time)
77  {
78  stream << "Position: <" << std::fixed << point[0] << ", "
79  << std::fixed << point[1] << ", "
80  << std::fixed << point[2] << "> mm; ";
81 
82  stream << "Index: <" << index[0] << ", "
83  << index[1] << ", "
84  << index[2] << "> ; ";
85 
86  stream << "Time: " << time << " ms";
87  }
88 
90  {
91  if (m_Implementation == nullptr)
92  return;
93 
94  std::ostringstream stream;
95  stream.imbue(std::locale::classic());
96  stream.precision(2);
97 
98  WriteCommonImageInfo(stream, point, index, time);
99  stream << "; Pixel value: ";
100 
101  if (fabs(pixelValue) > 1000000 || fabs(pixelValue) < 0.01)
102  stream << std::scientific;
103 
104  stream << pixelValue;
105 
106  m_Implementation->DisplayGreyValueText(stream.str().c_str());
107  }
108 
109  void StatusBar::DisplayImageInfo(Point3D point, itk::Index<3> index, ScalarType time, const char *pixelValue)
110  {
111  if (m_Implementation == nullptr)
112  return;
113 
114  std::ostringstream stream;
115  stream.imbue(std::locale::classic());
116  stream.precision(2);
117 
118  WriteCommonImageInfo(stream, point, index, time);
119  stream << "; " << pixelValue;
120 
121  m_Implementation->DisplayGreyValueText(stream.str().c_str());
122  }
123 
125  {
126  if (m_Implementation != nullptr)
127  m_Implementation->DisplayGreyValueText("No image information at this position!");
128  }
130  {
131  if (m_Implementation != nullptr)
133  }
135  {
136  if (m_Implementation != nullptr)
137  {
139  }
140  }
145  {
146  if (m_Instance == nullptr) // if not set, then send a errormessage on OutputWindow
147  {
148  m_Instance = new StatusBar();
149  }
150 
151  return m_Instance;
152  }
153 
158  {
159  if (m_Implementation == implementation)
160  {
161  return;
162  }
163  m_Implementation = implementation;
164  }
165 
168 } // 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)
static StatusBarImplementation * m_Implementation
Definition: mitkStatusBar.h:90
void DisplayText(const char *t)
Send a string to the applications StatusBar.
virtual void DisplayGenericOutputText(const char *t)=0
virtual ~StatusBar()
virtual void DisplayErrorText(const char *t)=0
static StatusBar * m_Instance
Definition: mitkStatusBar.h:91
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:36
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