MCPcopy Create free account
hub / github.com/MITK/MITK / paintEvent

Method paintEvent

Modules/QtWidgets/src/QmitkSliderLevelWindowWidget.cpp:101–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void QmitkSliderLevelWindowWidget::paintEvent(QPaintEvent *itkNotUsed(e))
102{
103 QPixmap pm(width(), height());
104 pm.fill(this->palette().color(this->backgroundRole()));
105 QPainter painter(&pm);
106
107 painter.setFont(m_Font);
108 painter.setPen(this->palette().color(this->foregroundRole()));
109
110 QColor c(51, 153, 204);
111 QColor cl = c.lighter();
112 QColor cd = c.darker();
113
114 painter.setBrush(c);
115 painter.drawRect(m_Rect);
116
117 mitk::ScalarType mr = m_LevelWindow.GetRange();
118 float smallestLevelableValue = 1e-9;
119
120 //This check is needed as safe guard. LevelWindow is refactored to only deduce finite ranges
121 //from images, but old scene serialization may contain infinite ranges that overwrite the new
122 //business logic. This roots in two many "jobs" LevelWindow" is used for; see also T24962.
123 //Until LevelWindow and this widget is refactored the check was the minimal invasive fix.
124 if (!std::isfinite(mr))
125 {
126 mr = m_LevelWindow.GetWindow();
127 }
128
129
130 // avoiding a division by 0 while still enabling small level windows
131 if (mr < smallestLevelableValue)
132 mr = smallestLevelableValue;
133
134 mitk::ScalarType fact = m_MoveHeight / mr;
135
136 // begin draw scale
137 if (m_ScaleVisible)
138 {
139 mitk::ScalarType minRange = m_LevelWindow.GetRangeMin();
140 mitk::ScalarType maxRange = m_LevelWindow.GetRangeMax();
141
142 //This check is needed as safe guard. LevelWindow is refactored to only deduce finite ranges
143 //from images, but old scene serialization may contain infinite ranges that overwrite the new
144 //business logic. This roots in two many "jobs" LevelWindow" is used for; see also T24962.
145 //Until LevelWindow and this widget is refactored the check was the minimal invasive fix.
146 if (!std::isfinite(minRange))
147 {
148 minRange = m_LevelWindow.GetLowerWindowBound();
149 }
150 //This check is needed as safe guard. LevelWindow is refactored to only deduce finite ranges
151 //from images, but old scene serialization may contain infinite ranges that overwrite the new
152 //business logic. This roots in two many "jobs" LevelWindow" is used for; see also T24962.
153 //Until LevelWindow and this widget is refactored the check was the minimal invasive fix.
154 if (!std::isfinite(maxRange))
155 {
156 maxRange = m_LevelWindow.GetUpperWindowBound();
157 }
158

Callers

nothing calls this directly

Calls 8

colorMethod · 0.80
GetLowerWindowBoundMethod · 0.80
GetUpperWindowBoundMethod · 0.80
GetRangeMethod · 0.45
GetWindowMethod · 0.45
GetRangeMinMethod · 0.45
GetRangeMaxMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected