void cubo::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);
    QPen pointPen(Qt::black);
    pointPen.setWidth(2);
    painter.setPen(pointPen);

    if (dibuja)
    {
        for(int i=0; i<transforms.size(); ++i)
        {
            painter.setTransform(transforms[i],true);
            drawCubo(painter);

        }
    }


}
void drawcandeeirodetecto(float x, float z){
	//base dos suportes
	float color[] = {1.0,1.0,1.0,1.0};
	glPushMatrix();
    glTranslatef(0.0f+x,0.8f,0.0f+z);
    drawCubo(candeeirodetectoG[0],candeeirodetectoGn[0] ,candeeirodetectoGt[0],madeiraID,color);
    
	glPopMatrix();
    
	//suportes
	glPushMatrix();
    glTranslatef(0.15f+x,0.45f,0.0f+z);
    drawCilindro(candeeirodetectoG[1],candeeirodetectoGn[1] ,candeeirodetectoGt[1],resolucao,metalID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.15f+x,0.45f,0.0f+z);
    drawCilindro(candeeirodetectoG[1],candeeirodetectoGn[1] ,candeeirodetectoGt[1],resolucao,metalID,color);
    
	glPopMatrix();
    
	//base dos suportes das lampadas e das lampadas
	glPushMatrix();
    glTranslatef(0.0f+x,0.175f,0.0f+z);
    drawCubo(candeeirodetectoG[2],candeeirodetectoGn[2] ,candeeirodetectoGt[2],metalID,color);
	glPopMatrix();
    
	//suportes (cilindricos) das lampadas
	glPushMatrix();
    glTranslatef(0.15f+x,0.175f,0.0f+z);
    drawCilindro(candeeirodetectoG[3],candeeirodetectoGn[3] ,candeeirodetectoGt[3],resolucao,metalID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.15f+x,0.175f,0.0f+z);
    drawCilindro(candeeirodetectoG[3],candeeirodetectoGn[3] ,candeeirodetectoGt[3],resolucao,metalID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.45f+x,0.175f,0.0f+z);
    drawCilindro(candeeirodetectoG[3],candeeirodetectoGn[3] ,candeeirodetectoGt[3],resolucao,metalID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(0.45f+x,0.175f,0.0f+z);
    drawCilindro(candeeirodetectoG[3],candeeirodetectoGn[3] ,candeeirodetectoGt[3],resolucao,metalID,color);
    
	glPopMatrix();
    
	//lampadas
	glPushMatrix();
    glTranslatef(0.15f+x,0.075f,0.0f+z);
    drawCilindro(candeeirodetectoG[4],candeeirodetectoGn[4] ,candeeirodetectoGt[4],resolucao,vidroID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.15f+x,0.075f,0.0f+z);
    drawCilindro(candeeirodetectoG[4],candeeirodetectoGn[4] ,candeeirodetectoGt[4],resolucao,vidroID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.45f+x,0.075f,0.0f+z);
    drawCilindro(candeeirodetectoG[4],candeeirodetectoGn[4] ,candeeirodetectoGt[4],resolucao,vidroID,color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(0.45f+x,0.075f,0.0f+z);
    drawCilindro(candeeirodetectoG[4],candeeirodetectoGn[4] ,candeeirodetectoGt[4],resolucao,vidroID,color);
    
	glPopMatrix();
}
void drawmesalta(float x, float z){
	
	//descanso dos pés
    //horizontais
	float color[] = {1.0,1.0,1.0,1.0};
	glPushMatrix();
    glTranslatef(0.0f+x,0.32f,0.25f+z);
    drawCubo(mesaltaG[0],mesaltaGn[0] ,mesaltaGt[0],metalID, color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(0.0f+x,0.32f,-0.25f+z);
    drawCubo(mesaltaG[0],mesaltaGn[0] ,mesaltaGt[0],metalID, color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(0.25f+x,0.32f,0.0f+z);
    glRotatef(90,0.0f,1.0f,0.0f);
    drawCubo(mesaltaG[0],mesaltaGn[0] ,mesaltaGt[0],metalID, color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.25f+x,0.32f,0.0f+z);
    glRotatef(90,0.0f,1.0f,0.0f);
    drawCubo(mesaltaG[0],mesaltaGn[0] ,mesaltaGt[0],metalID, color);
	glPopMatrix();
    //suportes diagonais
	glPushMatrix();
    glTranslatef(0.12f+x,0.32f,0.12f+z);
    glRotatef(135,0.0f,1.0f,0.0f);
    drawCubo(mesaltaG[1],mesaltaGn[1] ,mesaltaGt[1],metalID, color);
    
	glPopMatrix();
    
    
	glPushMatrix();
    glTranslatef(-0.12f+x,0.32f,-0.12f+z);
    glRotatef(135,0.0f,1.0f,0.0f);
    drawCubo(mesaltaG[1],mesaltaGn[1] ,mesaltaGt[1],metalID, color);
    
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(0.12f+x,0.32f,-0.12f+z);
    glRotatef(45,0.0f,1.0f,0.0f);
    drawCubo(mesaltaG[1],mesaltaGn[1] ,mesaltaGt[1],metalID, color);
	
	glPopMatrix();
    
	glPushMatrix();
    glTranslatef(-0.12f+x,0.32f,0.12f+z);
    glRotatef(45,0.0f,1.0f,0.0f);
    drawCubo(mesaltaG[1],mesaltaGn[1] ,mesaltaGt[1],metalID, color);
    
	glPopMatrix();
    
	//base
	glPushMatrix();
    glTranslatef(0.0f+x,0.0f,0.0f+z);
    drawCubo(mesaltaG[2],mesaltaGn[2] ,mesaltaGt[2],mesatextID, color);
    
	glPopMatrix();
    
	//perna
	glPushMatrix();
    glTranslatef(0.0f+x,0.625f,0.0f+z);
    drawCilindro(mesaltaG[3],mesaltaGn[3] ,mesaltaGt[3],resolucao,metalID, color);
    
	glPopMatrix();
    
	//base do tampo
	glPushMatrix();
    glTranslatef(0.0f+x,1.25f,0.0f+z);
    drawCubo(mesaltaG[4],mesaltaGn[4] ,mesaltaGt[4],mesatextID, color);
    
	glPopMatrix();
    
	//tampo
	glPushMatrix();
    glTranslatef(0.0f+x,1.45f,0.0f+z);
    drawCilindro(mesaltaG[5],mesaltaGn[5] ,mesaltaGt[5],resolucao,mesatextID, color);
    
	glPopMatrix();
}