Beispiel #1
0
void View::wheelEvent( QWheelEvent* e )
{
	if ( e->orientation() == Qt::Vertical )
	{
		if ( e->delta() > 0 )
			zoomAt( e->pos(), ZOOMINFACTOR );
		else if ( e->delta() < 0 )
			zoomAt( e->pos(), ZOOMOUTFACTOR );
	}
}
//
// Mouse left button up event.
//
void CChartViewer::OnLButtonUp(UINT nFlags, CPoint point) 
{
	mouse_state=true;
	if (m_isPlotAreaMouseDown)
	{
		// Release the mouse capture.
		ReleaseCapture();
		m_isPlotAreaMouseDown = false;
		setRectVisible(false);
		bool hasUpdate = false;

		switch (m_mouseUsage)
		{
		case Chart::MouseUsageZoomIn :
			if (canZoomIn(m_zoomDirection))
			{
				if (isDrag(m_zoomDirection, point))
					// Zoom to the drag selection rectangle.
					hasUpdate = zoomTo(m_zoomDirection, 
						m_plotAreaMouseDownXPos, m_plotAreaMouseDownYPos, point.x, point.y);
				else
					// User just click on a point. Zoom-in around the mouse cursor position.
					hasUpdate = zoomAt(m_zoomDirection, point.x, point.y, m_zoomInRatio);
			}
			break;
		case Chart::MouseUsageZoomOut:
			// Zoom out around the mouse cursor position.
			if (canZoomOut(m_zoomDirection))
				hasUpdate = zoomAt(m_zoomDirection, point.x, point.y, m_zoomOutRatio);
			break;
		default :
			if (m_isDragScrolling)
				// Drag to scroll. We can update the image map now as scrolling has finished.
				updateViewPort(false, true);
			else
				// Is not zooming or scrolling, so is just a normal click event.
				GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED), (LPARAM)m_hWnd);
			break;
		}

		m_isDragScrolling = false;
		if (hasUpdate)
			// View port has changed - update it.
			updateViewPort(true, true);
	}
	
	CStatic::OnLButtonUp(nFlags, point);
}
Beispiel #3
0
void View::mouseReleaseEvent( QMouseEvent* e )
{
	if( false == _mouseMoved )
	{
		switch( _mouseButtons )
		{
		case Qt::LeftButton:
			{
				if( e->modifiers() & Qt::CTRL )
				{
					fit();
				}
				else
				{
					if( e->modifiers() & Qt::AltModifier )
					{
						zoomAt( _mousePosAtPressEvent, ZOOMOUTFACTOR );
					}
					else
					{
						zoomAt( _mousePosAtPressEvent, ZOOMINFACTOR );
					}
				}
				break;
			}
		case Qt::RightButton:
			{
				zoomAt( _mousePosAtPressEvent, ZOOMOUTFACTOR );
				break;
			}
		case Qt::MidButton:
			{
				fit();
				break;
			}
		}
	}

	e->accept();
}
Beispiel #4
0
void View::mouseMoveEvent( QMouseEvent* e )
{
	_mouseMoved = true;
	QPoint delta = _mousePos - e->pos();
	_mousePos = e->pos();

	if( e->modifiers() & Qt::AltModifier )
	{
		qreal f = 1.0f;
		if( delta.y() > 0 )
		{
			f = ZOOMOUTFACTORSLOW;
		}
		else
		{
			f = ZOOMINFACTORSLOW;
		}
		zoomAt( _mousePosAtPressEvent, f );
	}
	else
	{
		translate( delta.y(), delta.x() );
	}
}