Пример #1
0
void GLWidget3D::mouseMoveEvent(QMouseEvent *event) {
	QVector2D pos;
	mouseTo2D(event->x(), event->y(), pos);

	float dx = (float)(event->x() - lastPos.x());
	float dy = (float)(event->y() - lastPos.y());
	float camElevation = camera->getCamElevation();

	vboRenderManager.mousePos3D=pos.toVector3D();

	switch (mainWin->mode) {
	case MainWindow::MODE_AREA_SELECT:
		/*if(altPressed==false&&G::global()["3d_render_mode"]==1){
			camera3D.motion(dx,dy);
			lastPos = event->pos();
			break;
		}*/
		if (altPressed) {	// editing
			if (event->buttons() & Qt::RightButton||event->buttons() & Qt::LeftButton||event->buttons() & Qt::MiddleButton) {//make sure something is clicking
					// normal Gaussian edition
					float change=mainWin->controlWidget->ui.terrainPaint_changeSlider->value()*0.003f;
					float radi=mainWin->controlWidget->ui.terrainPaint_sizeSlider->value()*0.01f;
					change*=0.2f;//while moving, it is not necessary to change much
					if (event->buttons() & Qt::RightButton) {
						change = -change;
					}
					if (event->buttons() & Qt::MiddleButton) {
						change=FLT_MAX;//hack: flat terrain
					}
					//mainWin->urbanGeometry->vboRenderManager->addValue(pos.x(), pos.y(), change);
					float xM=1.0f-(vboRenderManager.side/2.0f-pos.x())/vboRenderManager.side;
					float yM=1.0f-(vboRenderManager.side/2.0f-pos.y())/vboRenderManager.side;
					vboRenderManager.vboTerrain.updateTerrain(xM,yM,change,radi);//rad,change);

					mainWin->urbanGeometry->adaptToTerrain();
					shadow.makeShadowMap(this);
			}
		} else if (event->buttons() & Qt::LeftButton) {	// Rotate
			camera->changeXRotation(rotationSensitivity * dy);
			camera->changeZRotation(-rotationSensitivity * dx);    
			updateCamera();
			lastPos = event->pos();
		} else if (event->buttons() & Qt::MidButton) {
			camera->changeXYZTranslation(-dx, dy, 0);
			updateCamera();
			lastPos = event->pos();
		} else if (event->buttons() & Qt::RightButton) {	// Zoom
			camera->changeXYZTranslation(0, 0, -zoomSensitivity * dy);
			updateCamera();
			lastPos = event->pos();
		}
		break;
	}

	updateGL();
}
Пример #2
0
void MouseMoveSceneStrategy::wheelEvent(std::shared_ptr<Model> const &model, QWheelEvent *mouseEvent,
                                        QVector2D pos)
{
    pos = (model->view->aspectMatrix.inverted() * pos.toVector3D()).toVector2D();
    float delta = mouseEvent->delta();
    float delta2 = powf(2, delta / 120);

    std::shared_ptr<ResizeScene> op = std::make_shared<ResizeScene>(delta2, pos);
    operationRunner.lock()->RunOperation(op);
}
Пример #3
0
void MouseMoveSceneStrategy::mouseMoveEvent(std::shared_ptr<Model> const &model, QMouseEvent *mouseEvent,
                                            QVector2D pos)
{
    pos = (model->view->aspectMatrix.inverted() * pos.toVector3D()).toVector2D();
    QVector2D offset = pos - this->mousePos;
    this->mousePos = pos;

    auto buttons = mouseEvent->buttons();
    if (buttons & Qt::LeftButton)
    {
        std::shared_ptr<TranslateScene> op = std::make_shared<TranslateScene>(offset);
        MouseStrategy::operationRunner.lock()->RunOperation(op);
    }
}
Пример #4
0
void MouseMoveSceneStrategy::mousePressEvent(std::shared_ptr<Model> const &model, QMouseEvent *event,
                                             QVector2D pos)
{
    pos = (model->view->aspectMatrix.inverted() * pos.toVector3D()).toVector2D();
    this->mousePos = pos;
}
Пример #5
0
bool Util::segmentSegmentIntersectXY3D(const QVector3D& a, const QVector3D& b, const QVector3D& c, const QVector3D& d, float *tab, float *tcd, bool segmentOnly, QVector3D& intPoint) {
	QVector2D interPoint;
	bool res=segmentSegmentIntersectXY(QVector2D(a.x(),a.y()),QVector2D(b.x(),b.y()),QVector2D(c.x(),c.y()),QVector2D(d.x(),d.y()),tab,tcd,segmentOnly,interPoint);
	intPoint=interPoint.toVector3D();
	return res;
}//