//
// 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);
}
void CChartViewer::OnRButtonUp(UINT nFlags, CPoint point) 
{
	
	mouse_state=false;
	updateViewPort(true, true);
	CStatic::OnRButtonUp(nFlags, point);
}
Exemple #3
0
	void cShadowCSM::update(float /*elapsedtime*/)
	{
		updateBiasByCamLength();
		updateInput();
		_getBatchRenderMgr()->extract(*this, cBatchRenderManager::MASK_ALL);//cRenderList::MASK_NOT_SCENE);
		updateViewPort();
	}
void Scene::addPedestrianToAnimationSlot(PPedestrian p_, Animation * animation_,QMutex* mutex_) {
    QMutexLocker locker(mutex_);
    p_->init(this);
    animation_->addPedestrian(p_);
    animation_->updatePedestriansOnScene();
    updateViewPort();
}
void Scene::addVehicleToAnimationSlot(PVehicle v_, Animation* animation_, QMutex * mutex_){
    QMutexLocker locker(mutex_);
    v_->init(this);
    animation_->addVehicle(v_);
    animation_->updateVehiclesOnScene();
    updateViewPort();
}
void GLCamera::updateProj()
{
	updateViewPort();
	m_Proj = glm::perspective(m_FOV, static_cast<float>(m_Viewport.WIDTH) / static_cast<float>(m_Viewport.HEIGHT), m_zNear, m_zFar);
	m_Proj[3][0] = m_x_offset;
	m_Proj[3][1] = m_y_offset;
}
//
// Chart hold timer.
//
void CChartViewer::OnTimer(ONTIMER_TYPE /* nIDEvent */) 
{
	// Reset the timer
	KillTimer(1);
	m_holdTimerActive = false;

	// If has pending chart update request, handles them now.
	if (m_needUpdateChart || m_needUpdateImageMap)
		updateViewPort(m_needUpdateChart, m_needUpdateImageMap);
}
Exemple #8
0
CamTab::CamTab(CamSettings * set, QWidget *parent) :
    QWidget(parent)
{
    settings = set;
    createMainLayout();

    QString suffix(settings->getExt());
    suffix.prepend("*.");
    frameList = QDir(settings->getDir()).entryInfoList(QStringList(suffix), QDir::Files, QDir::Name);
    if (!frameList.isEmpty()) {
        currentFile = frameList.last().absoluteFilePath();
        updateViewPort();
    }

    timer = new QTimer(this);
    connect(&manager, SIGNAL(finished(QNetworkReply*)), SLOT(downloadFinished(QNetworkReply*)));
    connect(timer, SIGNAL(timeout()), this, SLOT(execute()));
    connect(settings, SIGNAL(intChanged()), this, SLOT(updateInterval()));
}
Exemple #9
0
bool CamTab::saveToDisk(const QString &filename, QIODevice *data)
{
    // Compare previous file size with current.
    QFile prevfile(currentFile);
    if ((data->size() == 0) || (prevfile.size() == data->size()))
        return false;

    QFile file(filename);

    if (!file.open(QIODevice::WriteOnly)) {
        fprintf(stderr, "Could not open %s for writing: %s\n",
                qPrintable(filename),
                qPrintable(file.errorString()));
        return false;
    }

    file.write(data->readAll());
    file.close();
    currentFile = filename;
    frameList.append(QFileInfo(currentFile));
    updateViewPort();

    return true;
}
Exemple #10
0
void QGeomWidget::paintEvent ( QPaintEvent* /*event*/ )
{
	if( m_ViewerCore->hasImage() ) {
		m_Painter->begin( this );

		switch( m_InterpolationType ) {
		case nn:
			m_Painter->setRenderHint( QPainter::NonCosmeticDefaultPen, true );
			break;
		case lin:
			m_Painter->setRenderHint( QPainter::SmoothPixmapTransform, true );
			break;
		}

		m_Painter->resetTransform();

		if( m_ViewerCore->getSettings()->getPropertyAs<bool>( "latchSingleImage" ) ) {
			m_LatchOrientation = getWidgetEnsemble()->getImageVector().size() == 1;
		} else {
			m_LatchOrientation = false;
		}

		//bounding box calculation
		m_BoundingBox = _internal::getPhysicalBoundingBox( getWidgetEnsemble()->getImageVector(), m_PlaneOrientation );
		_internal::zoomBoundingBox( m_BoundingBox,
									m_Translation,
									m_ViewerCore->getCurrentImage()->getImageProperties().physicalCoords,
									m_Zoom, m_PlaneOrientation,
									( m_RightMouseButtonPressed && !m_LeftMouseButtonPressed )
									|| m_ZoomEvent
									|| ( !m_RightMouseButtonPressed && !m_LeftMouseButtonPressed  ) );

		if( m_Zoom > 1 ) {
			m_BoundingBox[0] -= m_Translation[0];
			m_BoundingBox[1] -= m_Translation[1];
		}

		m_ZoomEvent = false;

		updateViewPort();
		m_Painter->setWindow( m_BoundingBox[0], m_BoundingBox[1], m_BoundingBox[2], m_BoundingBox[3] );
		m_Painter->setViewport( m_ViewPort[0], m_ViewPort[1], m_ViewPort[2], m_ViewPort[3] );
		BOOST_FOREACH( ImageHolder::Vector::const_reference image, getWidgetEnsemble()->getImageVector() ) {
			if( image->getImageProperties().isVisible && image->getImageProperties().opacity != 0 ) {
				paintImage( image );
			}
		}

		if( m_ViewerCore->hasImage() && m_ShowCrosshair ) {
			paintCrossHair();
		}

		if( m_ShowLabels ) {
			paintLabels();
		}

		if( m_ShowScalingOffset ) {
			m_Painter->resetMatrix();
			m_Painter->setFont( QFont( "Chicago", 10 ) );
			m_Painter->setPen( Qt::red );
			std::stringstream scalingOffset;
			const ImageHolder::Pointer image = getWidgetEnsemble()->getImageVector().back();
			scalingOffset << "Scaling: " << image->getImageProperties().scaling
						  << " Offset: " << image->getImageProperties().offset;
			m_Painter->drawText( 10, 30, scalingOffset.str().c_str() );
		}

		m_ShowScalingOffset = false;
		m_Painter->end();
	}
//
// Process mouse dragging over the plot area
//
void CChartViewer::OnPlotAreaMouseDrag(UINT /* nFlags */, CPoint point)
{
	switch (m_mouseUsage)
	{
		case Chart::MouseUsageZoomIn :
		{
			//
			// Mouse is used for zoom in. Draw the selection rectangle if necessary.
			//

			bool isDragZoom = canZoomIn(m_zoomDirection) && isDrag(m_zoomDirection, point);
			if (isDragZoom)
			{
				int spanX = m_plotAreaMouseDownXPos - point.x;
				int spanY = m_plotAreaMouseDownYPos - point.y;

				switch (m_zoomDirection)
				{
				case Chart::DirectionHorizontal:
					drawRect(point.x, getPlotAreaTop(), spanX, getPlotAreaHeight());
					break;
				case Chart::DirectionVertical:
					drawRect(getPlotAreaLeft(), point.y, getPlotAreaWidth(), spanY);
					break;
				default:
					drawRect(point.x, point.y, spanX, spanY);
					break;
				}
			}
			setRectVisible(isDragZoom);
			break;
		}
		case Chart::MouseUsageScroll :
		{
			//
			// Mouse is used for drag scrolling. Scroll and update the view port.
			//

			if (m_isDragScrolling || isDrag(m_scrollDirection, point))
			{
				m_isDragScrolling = true;
				switch (m_scrollDirection)
				{
				case Chart::DirectionHorizontal:
					::SetCursor(getNoMoveHorizCursor());
					break;
				case Chart::DirectionVertical:
					::SetCursor(getNoMoveVertCursor());
					break;
				default :
					::SetCursor(getNoMove2DCursor());
					break;
				}
								
				if (dragTo(m_scrollDirection, 
					point.x - m_plotAreaMouseDownXPos, point.y - m_plotAreaMouseDownYPos))
					updateViewPort(true, false);
			}
		}
	}
}