void PainelVisualizacaoBarragemOpenGL::keyPressEvent(QKeyEvent* kev){

    GLdouble cos5 = 0.996;
    GLdouble sen5 = 0.087;


    double rotaX,rotaY,rotaZ;

    //rotacoes em torno de y

    //roda esquerda para direita
    if(kev->key() == Qt::Key_D){

        rotaX = cos5 * posicaoCamera[0] - (-1) * sen5 * posicaoCamera[2];
        rotaZ = cos5 * posicaoCamera[2] + (-1) * sen5 * posicaoCamera[0];

        posicaoCamera[0] = rotaX;
        posicaoCamera[2] = rotaZ;



        //posição do vetor de view up
        rotaX = cos5 * normalCamera[0] - (-1) * sen5 * normalCamera[2];
        rotaZ = cos5 * normalCamera[2] + (-1) * sen5 * normalCamera[0];

        //                     normalCamera[0] = rotaX;
        //                     normalCamera[2] = rotaZ;


    }


    //roda esquerda para direita
    if(kev->key() == Qt::Key_A){


        rotaX = cos5 * posicaoCamera[0] - sen5 * posicaoCamera[2];
        rotaZ = cos5 * posicaoCamera[2] + sen5 * posicaoCamera[0];

        posicaoCamera[0] = rotaX;
        posicaoCamera[2] = rotaZ;

        //posição do vetor de view up
        rotaX = cos5 * normalCamera[0] - sen5 * normalCamera[2];
        rotaZ = cos5 * normalCamera[2] + sen5 * normalCamera[0];

        //                          normalCamera[0] = rotaX;
        //                          normalCamera[2] = rotaZ;




    }

    //rotacoes em torno de x
    //roda baixo para cima
    if(kev->key() == Qt::Key_W){


        rotaY = (cos5 * posicaoCamera[1] +  sen5 *posicaoCamera[2]);
        rotaZ = cos5 * posicaoCamera[2] -  sen5 * posicaoCamera[1];


        posicaoCamera[1] = rotaY;
        posicaoCamera[2] = rotaZ;


        //posição do vetor de view up
        rotaY = cos5 * normalCamera[1] - (-1) * sen5 * normalCamera[2];
        rotaZ = cos5 * normalCamera[2] + (-1) * sen5 * normalCamera[1];

        //                              normalCamera[1] = rotaY;
        //                              normalCamera[2] = rotaZ;


    }

    //roda cima para baixo
    if(kev->key() == Qt::Key_S){

        rotaY = cos5 * posicaoCamera[1] - sen5 * posicaoCamera[2];
        rotaZ = cos5 * posicaoCamera[2] + sen5 * posicaoCamera[1];

        posicaoCamera[1] = rotaY;
        posicaoCamera[2] = rotaZ;

        //posição do vetor de view up
        rotaY = cos5 * normalCamera[1] - sen5 * normalCamera[2];
        rotaZ = cos5 * normalCamera[2] + sen5 * normalCamera[1];

        //                            normalCamera[1] = rotaY;
        //                            normalCamera[2] = rotaZ;

    }
    double zMaisCamera = 1.5;
    double zMenosCamera = 0.5;
    if(kev->key() == Qt::Key_N){
        posicaoCamera[0] =  posicaoCamera[1] = posicaoCamera[2] *= zMaisCamera;

    }

    if(kev->key() == Qt::Key_F){
        posicaoCamera[0] =  posicaoCamera[1] = posicaoCamera[2] *= zMenosCamera;

    }

    updateGL();





}
Ejemplo n.º 2
0
void GLWidget::keyPressEvent(QKeyEvent *e)
{
    switch( e->key() )
    {
    case Qt::Key_Left:
        if( e->modifiers() & Qt::ControlModifier )
            xSpeed = -10;
        else
            zRot -= 18;
        break;
    case Qt::Key_Right:
        if( e->modifiers() & Qt::ControlModifier )
            xSpeed = +10;
        else
            zRot += 18;
        break;
    case Qt::Key_Up:
        if( e->modifiers() & Qt::ControlModifier )
            ySpeed = -10;
        else
            yRot -= 18;
        break;
    case Qt::Key_Down:
        if( e->modifiers() & Qt::ControlModifier )
            ySpeed = +10;
        else
            yRot += 18;
        break;
    case Qt::Key_PageUp:
        zoom -= zoom * 0.1;
        break;
    case Qt::Key_PageDown:
        zoom += zoom * 0.1;
        break;
    case Qt::Key_Plus:
        scale += 0.1;
        break;
    case Qt::Key_Minus:
        scale -= 0.1;
        break;
    case Qt::Key_S:
        killTimer(t);
        break;
    case Qt::Key_R:
        t = startTimer(50);
        break;
    case Qt::Key_Home: //回到初始状态
        if( e->modifiers() & Qt::ControlModifier )
            Go_init();
        break;
    case Qt::Key_X: //观察X面
        if( e->modifiers() & Qt::ControlModifier )
            Go_init();
        break;
    case Qt::Key_Y:
        if( e->modifiers() & Qt::ControlModifier )
        {
            Go_init();
            zRot = -90;
        }
        break;
    case Qt::Key_Z:
        if( e->modifiers() & Qt::ControlModifier )
        {
            Go_init();
            yRot = 90;
        }
        break;
    case Qt::Key_Escape:
        close();
        break;
    }
    updateGL();
}
void GLWidget::UpdateOpacityCorretion(float para)
{
    opacityCorrection = para;
    //initializeGL();
    updateGL();
}
Ejemplo n.º 4
0
void glFinalWidget::performEmbed()
{
    m_qVertices = MainWindow::globalInstance->glMeshWidget->GetVertices();
    m_qEdges = MainWindow::globalInstance->glMeshWidget->GetEdges();
    m_qTriangles = MainWindow::globalInstance->glMeshWidget->GetTriangles();
    m_validTriangulations = MainWindow::globalInstance->progressWidget->GetValidTriangulations();

    // Find fixed points that should not be repositioned while embeddings
    for (int i = 0; i < m_validTriangulations.size(); ++i)
    {
        glProgressWidget::validateTriangulation currentTriangle = m_validTriangulations[i];

        glMeshSelectWidget::vertex* vertexA;
        glMeshSelectWidget::vertex* vertexB;
        glMeshSelectWidget::vertex* vertexC;

        vertexA = currentTriangle.edgeA->startVertex;
        if (vertexA == currentTriangle.edgeB->startVertex)
        {
            vertexB = currentTriangle.edgeB->targetVertex;
        }
        else
        {
            vertexB = currentTriangle.edgeB->startVertex;
        }

        if (currentTriangle.edgeC->startVertex == vertexA || currentTriangle.edgeC->startVertex == vertexB)
        {
            vertexC = currentTriangle.edgeC->targetVertex;
        }
        else
        {
            vertexC = currentTriangle.edgeC->startVertex;
        }

        if (!HasThePoint(vertexA))
        {
            m_fixedPoints.push_back(vertexA);
        }
        if (!HasThePoint(vertexB))
        {
            m_fixedPoints.push_back(vertexB);
        }
        if (!HasThePoint(vertexC))
        {
            m_fixedPoints.push_back(vertexC);
        }
    }

    EmbedForPatches();

    for (int i = 0; i < 10; ++i)
    {
        RepositionInteriorPoints();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-75, 75, 0, 150, -90, 160);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    updateGL();
}
Ejemplo n.º 5
0
void GLWidget::mouseDoubleClickEvent(QMouseEvent *)
{
    Go_init();
    updateGL();
}
Ejemplo n.º 6
0
void Viewer::slot_drawTopo(bool b)
{
	m_drawTopo = b ;
	updateGL() ;
}
Ejemplo n.º 7
0
void Viewer::slot_normalsSize(int i)
{
	normalScaleFactor = i / 50.0f ;
	updateGL() ;
}
Ejemplo n.º 8
0
void LitSphereWidget::brightnessChanged( float v )
{
    brightness = v;
    updateGL();
}
Ejemplo n.º 9
0
void LitSphereWidget::gammaChanged( float v )
{
    gamma = v;
    updateGL();
}
Ejemplo n.º 10
0
//////////////////////////////////////////////////////////////////////
// Private slots Functions
//////////////////////////////////////////////////////////////////////
// Rotate the view
void GLWidget::rotateView()
{
    m_GlView.cameraHandle()->rotateAroundTarget(glc::Z_AXIS, 2.0 * glc::PI / static_cast<double>(200));
    updateGL();
}
void GLWidget::redraw() {
  if (refresh_required) {
    updateGL();
  }
}
Ejemplo n.º 12
0
/*******************************************************
* timerEvent()
*
* Description: Repaints the OpenGL widget whenever the
* timer triggers.
*
* Inputs: The event itself (unused).
*
* Outputs: none.
*
* Return: none.
*******************************************************/
void GLWidget::timerEvent(QTimerEvent *event)
{
    // Redraw the graphics window.
    updateGL();
}
Ejemplo n.º 13
0
void CGView::wheelEvent(QWheelEvent* event) {
	if (event->delta() < 0) zoom *= 1.2; else zoom *= 1/1.2;
	updateGL();
}
Ejemplo n.º 14
0
void GLDebugBufferWidget::drawBuffer(QImage buffer)
{
	this->buffer = buffer;
	paintGL();
	updateGL();
}
Ejemplo n.º 15
0
void Viewer::slot_drawEdges(bool b)
{
	m_drawEdges = b ;
	updateGL() ;
}
Ejemplo n.º 16
0
void LitSphereWidget::exposureChanged( float v )
{
    exposure = v;
    updateGL();
}
Ejemplo n.º 17
0
void Viewer::slot_faceLighting(int i)
{
	m_renderStyle = i ;
	updateGL() ;
}
Ejemplo n.º 18
0
void LitSphereWidget::doubleThetaChanged( int dp )
{
    doubleTheta = bool(dp);
    updateGL();
}
Ejemplo n.º 19
0
void Viewer::slot_drawNormals(bool b)
{
	m_drawNormals = b ;
	updateGL() ;
}
Ejemplo n.º 20
0
void LitSphereWidget::useNDotLChanged( int val )
{
    useNDotL = bool(val);
    updateGL();
}
Ejemplo n.º 21
0
void glFinalWidget::mousePressEvent(QMouseEvent* mouseEvent)
{
    //redraw glWidget
    updateGL();
}
Ejemplo n.º 22
0
void LitSphereWidget::brdfListChanged( std::vector<brdfPackage> brdfList )
{
    brdfs = brdfList;
    updateGL();
}
Ejemplo n.º 23
0
/*****The all timer,mouse and keyboard events******/
void GLWidget::timerEvent(QTimerEvent *)
{
    zRot += xSpeed;
    yRot += ySpeed;
    updateGL();
}
Ejemplo n.º 24
0
void Viewer::cb_keyPress(int keycode)
{
	switch(keycode)
	{
		case 'c' :
			myMap.check();
			break;

		case 'a':
		{
			Utils::Chrono ch;
			ch.start();
			VertexAttribute<VEC3, MAP> pos2 = myMap.getAttribute<VEC3, VERTEX, MAP>("pos2") ;
			if(!pos2.isValid())
				pos2 = myMap.addAttribute<VEC3, VERTEX, MAP>("pos2") ;

			for (int i=0; i< 10; ++i)
			{
				TraversorV<MAP> trav(myMap);
				for (Dart d=trav.begin(), d_end = trav.end(); d!=d_end ; d = trav.next())
				{
					pos2[d] = VEC3(0,0,0);
					int nb=0;
					Traversor2VVaF<MAP> trf(myMap,d);
					for (Dart e = trf.begin(),e_end =trf.end() ; e != e_end; e = trf.next())
					{
						pos2[d] += position[e];
						nb++;
					}
					pos2[d]/=nb;
				}
				myMap.swapAttributes(position, pos2);
			}
			std::cout << "Traversor "<< ch.elapsed()<< " ms "<< std::endl;
			Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
			m_positionVBO->updateData(position) ;
			m_normalVBO->updateData(normal) ;
			updateGL();
		}
			break;

		case 'b':
		{
			Utils::Chrono ch;
			ch.start();

			VertexAttribute<VEC3,MAP> pos2 = myMap.getAttribute<VEC3, VERTEX, MAP>("pos2") ;
			if(!pos2.isValid())
				pos2 = myMap.addAttribute<VEC3, VERTEX, MAP>("pos2") ;

			for (int i=0; i< 6; ++i)
			{
				foreach_cell<VERTEX>(myMap, [&] (Vertex d)
				{
					pos2[d] = VEC3(0,0,0);
					int nb=0;
					foreach_adjacent2<FACE>(myMap,d,[&](Vertex e)
					{
						pos2[d] += position[e];
						nb++;
					});
					pos2[d]/=nb;
				});
				myMap.swapAttributes(position,pos2);
			}
			std::cout << "Lambda "<< ch.elapsed()<< " ms "<< std::endl;
			Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
			m_positionVBO->updateData(position) ;
			m_normalVBO->updateData(normal) ;
			updateGL();
		}
			break;
		case 'B':
		{
			Utils::Chrono ch;
			ch.start();

			VertexAttribute<VEC3,MAP> pos2 = myMap.getAttribute<VEC3, VERTEX, MAP>("pos2") ;
			if(!pos2.isValid())
				pos2 = myMap.addAttribute<VEC3, VERTEX, MAP>("pos2") ;

			//		foreach_cell_EvenOddd<VERTEX>(myMap, [&] (Vertex d)
			//		{
			//			pos2[d] = VEC3(0,0,0);
			//			int nb=0;
			//			foreach_adjacent2<FACE>(myMap,d,[&](Vertex e)
			//			{
			//				pos2[d] += position[e];
			//				nb++;
			//			});
			//			pos2[d]/=nb;
			//		},
			//		[&] (Vertex d)
			//		{
			//			position[d] = VEC3(0,0,0);
			//			int nb=0;
			//			foreach_adjacent2<FACE>(myMap,d,[&](Vertex e)
			//			{
			//				position[d] += pos2[e];
			//				nb++;
			//			});
			//			position[d]/=nb;
			//		},
			//		3);

			//		std::cout << "Even/Odd "<< ch.elapsed()<< " ms "<< std::endl;
			Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
			m_positionVBO->updateData(position) ;
			m_normalVBO->updateData(normal) ;
			updateGL();
		}
			break;

		case 'e':
		{
			Utils::Chrono ch;
			ch.start();
			VertexAttribute<VEC3,MAP> pos2 = myMap.getAttribute<VEC3, VERTEX, MAP>("pos2") ;
			if(!pos2.isValid())
				pos2 = myMap.addAttribute<VEC3, VERTEX, MAP>("pos2") ;

			for (int i=0; i< 10; ++i)
			{
				TraversorV<MAP> trav(myMap);
				for (Dart d=trav.begin(), d_end = trav.end(); d!=d_end ; d = trav.next())
				{
					pos2[d] = VEC3(0,0,0);
					int nb=0;
					Traversor2VE<MAP> trf(myMap,d);
					for (Dart e = trf.begin(),e_end =trf.end() ; e != e_end; e = trf.next())
					{
						pos2[d] += position[myMap.phi1(e)];
						nb++;
					}
					pos2[d]/=nb;
				}
				myMap.swapAttributes(position,pos2);
			}
			std::cout << "Traversor "<< ch.elapsed()<< " ms "<< std::endl;
			Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
			m_positionVBO->updateData(position) ;
			m_normalVBO->updateData(normal) ;
			updateGL();
		}
			break;

		case 'f':
		{
			Utils::Chrono ch;
			ch.start();

			VertexAttribute<VEC3,MAP> pos2 = myMap.getAttribute<VEC3, VERTEX, MAP>("pos2") ;
			if(!pos2.isValid())
				pos2 = myMap.addAttribute<VEC3, VERTEX, MAP>("pos2") ;

			for (int i=0; i< 10; ++i)
			{
				foreach_cell<VERTEX>(myMap, [&] (Vertex d)
				{
					pos2[d] = VEC3(0,0,0);
					int nb=0;
					foreach_incident2<EDGE>(myMap,d,[&](Edge e)
					{
						pos2[d] += position[myMap.phi1(e)];
						nb++;
					});
					pos2[d]/=nb;
				});
				myMap.swapAttributes(position,pos2);
			}
			std::cout << "Lambda "<< ch.elapsed()<< " ms "<< std::endl;
			Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
			m_positionVBO->updateData(position) ;
			m_normalVBO->updateData(normal) ;
			updateGL();
		}
			break;

		case'A':
		{
			myMap.disableQuickTraversal<VERTEX>() ;
#define NBLOOP 5
			Utils::Chrono ch;
			ch.start();
			{
				TraversorCell<MAP, VERTEX, FORCE_CELL_MARKING> trav(myMap,true);
				for(unsigned int i=0; i<NBLOOP; ++i)
				{
					for (Cell<VERTEX> v = trav.begin(), e = trav.end(); v.dart != e.dart; v = trav.next())
					{
						normal[v][0] = 0.0f;
					}
				}
				std::cout << "FORCE_CELL_MARKING "<< ch.elapsed()<< " ms "<< std::endl;
			}

			ch.start();
			{
				TraversorCell<MAP, VERTEX> trav(myMap);
				for(unsigned int i=0; i<NBLOOP; ++i)
				{
					for (Cell<VERTEX> v = trav.begin(), e = trav.end(); v.dart != e.dart; v = trav.next())
					{
						normal[v][0] = 0.0f;
					}
				}
				std::cout << "auto "<< ch.elapsed()<< " ms "<< std::endl;
			}

			ch.start();
			{
				TraversorCell<MAP, VERTEX> trav(myMap,true);
				for(unsigned int i=0; i<NBLOOP; ++i)
				{
					for (Cell<VERTEX> v = trav.begin(), e = trav.end(); v.dart != e.dart; v = trav.next())
					{
						normal[v][0] = 0.0f;
					}
				}
				std::cout << "auto forcedart "<< ch.elapsed()<< " ms "<< std::endl;
			}

			ch.start();
			{
				TraversorCell<MAP, VERTEX, FORCE_DART_MARKING> trav(myMap,true);
				for(unsigned int i=0; i<NBLOOP; ++i)
				{
					for (Cell<VERTEX> v = trav.begin(), e = trav.end(); v.dart != e.dart; v = trav.next())
					{
						normal[v][0] = 0.0f;
					}
				}
				std::cout << "FORCE_DART_MARKING "<< ch.elapsed()<< " ms "<< std::endl;
			}
			myMap.enableQuickTraversal<MAP, VERTEX>() ;
			ch.start();
			{
				TraversorCell<MAP, VERTEX> trav(myMap);
				for(unsigned int i=0; i<NBLOOP; ++i)
				{
					for (Cell<VERTEX> v = trav.begin(), e = trav.end(); v.dart != e.dart; v = trav.next())
					{
						normal[v][0] = 0.0f;
					}
				}
				std::cout << "auto (quick) "<< ch.elapsed()<< " ms "<< std::endl;
			}

			ch.start();
			{
				TraversorCell<MAP, VERTEX, FORCE_QUICK_TRAVERSAL> trav(myMap);
				for(unsigned int i=0; i<NBLOOP; ++i)
				{
					for (Cell<VERTEX> v = trav.begin(), e = trav.end(); v.dart != e.dart; v = trav.next())
					{
						normal[v][0] = 0.0f;
					}
				}
				std::cout << "FORCE_QUICK_TRAVERSAL "<< ch.elapsed()<< " ms "<< std::endl;
			}

		}
			break;

		case'Z':
		{

			Utils::Chrono ch;
			ch.start();
			CGoGN::Parallel::NumberOfThreads = 1;
			for (unsigned int i=0; i<4; ++i)
				Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
			std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl;

			ch.start();
			CGoGN::Parallel::NumberOfThreads = 2;
			for (unsigned int i=0; i<4; ++i)
				Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
			std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices2 "<< ch.elapsed()<< " ms "<< std::endl;

			ch.start();
			CGoGN::Parallel::NumberOfThreads = 3;
			for (unsigned int i=0; i<4; ++i)
				Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
			std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices3 "<< ch.elapsed()<< " ms "<< std::endl;

			ch.start();
			CGoGN::Parallel::NumberOfThreads = 4;
			for (unsigned int i=0; i<4; ++i)
				Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
			std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices4 "<< ch.elapsed()<< " ms "<< std::endl;

			ch.start();
			CGoGN::Parallel::NumberOfThreads = 8;
			for (unsigned int i=0; i<4; ++i)
				Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
			std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices8 "<< ch.elapsed()<< " ms "<< std::endl;


			//		ch.start();
			//		Parallel::foreach_cell_EO<VERTEX>(myMap,[&](Vertex v, unsigned int thr)
			//		{
			//			normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
			//		},
			//		[&](Vertex v, unsigned int th)
			//		{
			//			normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
			//		},2,4,false,FORCE_CELL_MARKING);

			//		std::cout << "Parallel::foreach_cell_EO "<< ch.elapsed()<< " ms "<< std::endl;


		}
			break;


		default:
			break;
	}
}
Ejemplo n.º 25
0
void GLWidget::wheelEvent(QWheelEvent *e)
{
    e->delta()>0 ? scale += scale*0.1 : scale -= scale*0.1;
    updateGL();
}
Ejemplo n.º 26
0
void Viewer::slot_drawVertices(bool b)
{
	m_drawVertices = b ;
	updateGL() ;
}
Ejemplo n.º 27
0
void GLWidget::timeOutSlot()
{
    updateGL();
}
Ejemplo n.º 28
0
void Viewer::slot_verticesSize(int i)
{
	vertexScaleFactor = i / 500.0f ;
	updateGL() ;
}
Ejemplo n.º 29
0
void GLWidget::UpdateLight(int type)
{
    lighttype = type;
    updateGL();
}
    void SplineDisplayerWidget::setAE(aaAaa::aaSpline *sdata){
		m_spline_data = sdata;
        ctrlSelected = -1;
        updateGL();
        emit selectValuesChanged(0, 0);
	}