| 283 | } |
| 284 | |
| 285 | void QmitkSliderLevelWindowWidget::mouseMoveEvent(QMouseEvent *mouseEvent) |
| 286 | { |
| 287 | if (!mouseEvent) |
| 288 | return; |
| 289 | if (m_LevelWindow.IsFixed()) |
| 290 | return; |
| 291 | if (!m_MouseDown) |
| 292 | { |
| 293 | if (mouseEvent->pos().y() >= 0 && mouseEvent->pos().y() <= (m_Rect.topLeft().y() + 3)) |
| 294 | { |
| 295 | setCursor(Qt::SizeVerCursor); |
| 296 | m_UpperBound.setRect(m_Rect.topLeft().x(), m_Rect.topLeft().y() - 3, 17, 7); |
| 297 | this->setToolTip("Ctrl + left click to change only upper bound"); |
| 298 | m_Resize = true; |
| 299 | } |
| 300 | else if (mouseEvent->pos().y() >= (m_Rect.bottomLeft().y() - 3)) |
| 301 | { |
| 302 | setCursor(Qt::SizeVerCursor); |
| 303 | m_LowerBound.setRect(m_Rect.bottomLeft().x(), m_Rect.bottomLeft().y() - 3, 17, 7); |
| 304 | this->setToolTip("Ctrl + left click to change only lower bound"); |
| 305 | m_Resize = true; |
| 306 | m_Bottom = true; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | setCursor(Qt::ArrowCursor); |
| 311 | this->setToolTip("Left click and move mouse to adjust the slider."); |
| 312 | m_Resize = false; |
| 313 | m_Bottom = false; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | else |
| 318 | { |
| 319 | mitk::ScalarType fact = m_MoveHeight / m_LevelWindow.GetRange(); |
| 320 | |
| 321 | if (m_Leftbutton) |
| 322 | { |
| 323 | if (m_Resize && !m_CtrlPressed) |
| 324 | { |
| 325 | mitk::ScalarType diff = (mouseEvent->pos().y()) / fact; |
| 326 | diff -= (m_StartPos.y()) / fact; |
| 327 | m_StartPos = mouseEvent->pos(); |
| 328 | |
| 329 | if (diff == 0) |
| 330 | return; |
| 331 | mitk::ScalarType value; |
| 332 | if (m_Bottom) |
| 333 | value = m_LevelWindow.GetWindow() + ((2 * diff)); |
| 334 | else |
| 335 | value = m_LevelWindow.GetWindow() - ((2 * diff)); |
| 336 | |
| 337 | if (value < 0) |
| 338 | value = 0; |
| 339 | |
| 340 | m_LevelWindow.SetLevelWindow(m_LevelWindow.GetLevel(), value); |
| 341 | } |
| 342 | else if (m_Resize && m_CtrlPressed) |
no test coverage detected