00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2009-05-12 19:14:45 +0200 (Tue, 12 May 2009) $ 00006 Version: $Revision: 17169 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "QmitkCrossWidget.h" 00019 00020 #include <QMouseEvent> 00021 #include <QCursor> 00022 00023 QmitkCrossWidget::QmitkCrossWidget(QWidget * parent, Qt::WindowFlags f) : 00024 QLabel(parent, f) 00025 { 00026 setEnabled(true); 00027 setVisible(true); 00028 setFocusPolicy(Qt::ClickFocus); 00029 } 00030 00031 void QmitkCrossWidget::mousePressEvent(QMouseEvent * ) 00032 { 00033 QPoint p = QCursor::pos(); 00034 00035 lastX = p.x(); 00036 lastY = p.y(); 00037 00038 emit SignalDeltaMove( 0 , 0 ); 00039 } 00040 00041 void QmitkCrossWidget::mouseMoveEvent(QMouseEvent * ) 00042 { 00043 QPoint p = QCursor::pos(); 00044 00045 int newX = p.x(); 00046 int newY = p.y(); 00047 00048 int deltaX = newX-lastX; 00049 int deltaY = newY-lastY; 00050 00051 this->ResetMousePosition( lastX,lastY); 00052 00053 emit SignalDeltaMove( deltaX , deltaY ); 00054 } 00055 00056 void QmitkCrossWidget::mouseReleaseEvent(QMouseEvent*) 00057 { 00058 }