Example #1
0
void TimeScene::setupScene() {
    this->clear();

    calcZoom();
    int projects = _model->rowCount(QModelIndex());
    for (int x = 0; x < projects; x++) {
        QModelIndex index = _model->index(x, 0);
        drawIndex(index);
    }
    this->_viewSizeHeight = _currentY; // + headerSizeHint().height()
    createBackground();
    setSceneRect(0, 0, _viewSizeWidth, _viewSizeHeight);
}
Example #2
0
// Slots
void CamWidget::setImage(const cv::Mat &updatedImage)
{
	// Perform conversion from cv::Mat to QImage
	cv::Mat tmpImage;
	// Assume the image has 3 channels and is in BGR format
	cv::cvtColor(updatedImage, tmpImage, CV_BGR2RGB);
	QImage qImage(tmpImage.data, tmpImage.cols, tmpImage.rows, QImage::Format_RGB888);
	pixmap.convertFromImage(qImage);

	QSize newSize = calcZoom(pixmap.size()) * pixmap.size();
	pixmap = pixmap.scaled(newSize);

	resize(newSize);

	update();
}
Example #3
0
/********************************************************************************
Update the camera for third person view
Vector3 newPosition is the new position which the camera is to be based on
********************************************************************************/
void TPCamera::UpdatePosition(Vector3 newPos, Vector3 newDir)
{
	//Controls zoom with MMB
	if (myKeys[VK_MBUTTON])
		calcZoom();

	//Rotate and adjust pitch with RMB
	//if (myKeys[VK_RBUTTON])
	{
		//calcPitch();
		calcRotation();
	}
	//else
	{
		//pitchChange = 0.f;
		//angleChange = 0.f;
	}

	float theta = m_fTPVCameraAngle;
	float offSet_X = calcHDist() * sin(Math::DegreeToRadian(theta));
	float offSet_Z = calcHDist() * cos(Math::DegreeToRadian(theta));

	//Target is at player
	target.x = newPos.x + offSet_X * 2;
	target.y = newPos.y + 5.f;
	target.z = newPos.z + offSet_Z * 2;

	//Focus mode
	//if (myKeys[VK_RBUTTON])
	//{
	//	position.x = newPos.x - offSet_X * 0.5f;
	//	position.y = newPos.y + calcVDist() * 0.5f;
	//	position.z = newPos.z - offSet_Z * 0.5f;
	//}
	//else
	{
		position.x = newPos.x - offSet_X;
		position.y = newPos.y + calcVDist();
		position.z = newPos.z - offSet_Z;
	}
}
Example #4
0
void ImageView::resizeImage()
{
	static bool busy = false;
	if (busy || (!imageLabel->pixmap() && !anim))
		return;
	busy = true;

	imageLabel->setVisible(false);
	QSize imgSize = isAnimation? anim->currentPixmap().size() : imageLabel->pixmap()->size();

	if (tempDisableResize) {
		imgSize.scale(calcZoom(imgSize.width()), calcZoom(imgSize.height()), Qt::KeepAspectRatio);
	} else {
		switch(GData::zoomInFlags) {
			case Disable:
				if (imgSize.width() < size().width() && imgSize.height() < size().height())
					imgSize.scale(calcZoom(imgSize.width()), calcZoom(imgSize.height()),
																					Qt::KeepAspectRatio);
				break;
				
			case WidthNHeight:
				if (imgSize.width() < size().width() && imgSize.height() < size().height())
					imgSize.scale(calcZoom(size().width()), calcZoom(size().height()),
																					Qt::KeepAspectRatio);
				break;

			case Width:
				if (imgSize.width() < size().width())
					imgSize.scale(calcZoom(size().width()), 
						calcZoom(getHeightByWidth(imgSize.width(), imgSize.height(), size().width())),
						Qt::KeepAspectRatio);
				break;
				
			case Height:
				if (imgSize.height() < size().height())
					imgSize.scale(calcZoom(getWidthByHeight(imgSize.height(), imgSize.width(),
									size().height())), calcZoom(size().height()), Qt::KeepAspectRatio);
				break;

			case Disprop:
				int newWidth = imgSize.width(), newHeight = imgSize.height();
				if (newWidth < size().width())
					newWidth = size().width();
				if (newHeight < size().height())
					newHeight = size().height();
				imgSize.scale(calcZoom(newWidth), calcZoom(newHeight), Qt::IgnoreAspectRatio);
				break;
		}

		switch(GData::zoomOutFlags) {
			case Disable:
				if (imgSize.width() >= size().width() || imgSize.height() >= size().height())
					imgSize.scale(calcZoom(imgSize.width()), calcZoom(imgSize.height()),
																					Qt::KeepAspectRatio);
				break;
		
			case WidthNHeight:
				if (imgSize.width() >= size().width() || imgSize.height() >= size().height())
					imgSize.scale(calcZoom(size().width()), calcZoom(size().height()),
																					Qt::KeepAspectRatio);
				break;

			case Width:
				if (imgSize.width() > size().width())
					imgSize.scale(calcZoom(size().width()), 
						calcZoom(getHeightByWidth(imgSize.width(), imgSize.height(), size().width())),
																					Qt::KeepAspectRatio);
				break;
				
			case Height:
				if (imgSize.height() > size().height())
					imgSize.scale(calcZoom(getWidthByHeight(imgSize.height(), imgSize.width(), 
																					size().height())),
						calcZoom(size().height()), Qt::KeepAspectRatio);
			
				break;

			case Disprop:
				int newWidth = imgSize.width(), newHeight = imgSize.height();
				if (newWidth > size().width())
					newWidth = size().width();
				if (newHeight > size().height())
					newHeight = size().height();
				imgSize.scale(calcZoom(newWidth), calcZoom(newHeight), Qt::IgnoreAspectRatio);
				break;
		}
	}

	imageLabel->setFixedSize(imgSize);
	imageLabel->setVisible(true);
	centerImage(imgSize);
	busy = false;
}