diff --git a/NURBSCircleSphere.pdf b/NURBSCircleSphere.pdf new file mode 100644 index 0000000..c1489f8 Binary files /dev/null and b/NURBSCircleSphere.pdf differ diff --git a/Prototipo-1/DOT_CPP/BSplines.cpp b/Prototipo-1/DOT_CPP/BSplines.cpp index df83157..ea3a548 100644 --- a/Prototipo-1/DOT_CPP/BSplines.cpp +++ b/Prototipo-1/DOT_CPP/BSplines.cpp @@ -4,6 +4,56 @@ /* Public */ // Construtores + +BSplines::BSplines(BSplines * bspline):Object() +{ + + this->translation = bspline->translation; + this->rotation = bspline->rotation; + this->scale = bspline->scale; + + // Quantidade de Pontos da Curva + this->quant = bspline->getQuant(); + + // Ordem da Curva B-Spline + this->ordCurva = bspline->getOrdCurva(); + + // Lista de Nos usados para geração da curva B-Spline + this->nos = bspline->getNo(); + + // Lista de Pontos da Curva B-Spline + // A Cada 3 elementos da lista tem-se um ponto representando + // px,py,pz + this->ptsCurv = bspline->getPtsCurva(); + + // Lista Bidimensional Representando os Pontos de Controle + this->ptControle = bspline->getPtControle(); + + this->updatePtsCurv(); + + this->setTipo("BSplines"); +} + +BSplines::BSplines(vector < vector > ptControle, vector nos):Object() +{ + vector p1,p2,p3,p4; + + quant = 80; + ordCurva = 4; + ptcSelec = -1; + noSelec = -1; + this->ptControle = ptControle; + this->nos = nos; + + // Tipo Curva BSpline + setTipo("BSplines"); + //iniNo(); + + this->updatePtsCurv(); +} + + + BSplines::BSplines(float x, float y, float z):Object() { vector p1,p2,p3,p4; @@ -248,16 +298,17 @@ int BSplines::incNo(double inc) if(j + 1 > ordCurva){ nos = noscopia; - + normaNos(); return 0; } else { + normaNos(); return 1; } } else { - + normaNos(); return 0; } } @@ -333,9 +384,30 @@ void BSplines::setPtControle(float x, float y, float z) { if(ptcSelec >= 0){ - ptControle[ptcSelec][0] = x-translation[0]; - ptControle[ptcSelec][1] = y-translation[1]; - ptControle[ptcSelec][2] = z-translation[2]; + //int count = 0; + vector r = getRotation(); + //GLfloat matrix[16]; + glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); + glm::quat quaternion = quat ; + glm::mat4 mat = glm::toMat4(quaternion); + /*for (int k = 0; k < 4; ++k){ + for (int j = 0; j < 4; ++j){ + matrix[count] = mat[k][j]; + count++; + } + }*/ + + glm::mat4 INVERSE_ROTATE = glm::inverse(mat); + glm::vec4 reverse_point = INVERSE_ROTATE * glm::vec4( + (x-translation[0])/scale[0], + (y-translation[1])/scale[1], + (z-translation[2])/scale[2], + 1.0f + ); + + ptControle[ptcSelec][0] = reverse_point[0]; + ptControle[ptcSelec][1] = reverse_point[1]; + ptControle[ptcSelec][2] = reverse_point[2]; } } @@ -351,6 +423,9 @@ void BSplines::setQuant(int valor) quant = valor; } + + + // Atualiza/Processa os Pontos da Curva B-Spline void BSplines::updatePtsCurv() { @@ -368,7 +443,7 @@ void BSplines::updatePtsCurv() inc = ( fim - inic ) / quant; } - for(t = inic; t <= fim; t+=inc){ + for(t = 0; t < fim; t+=inc){ x = y = z = 0; @@ -392,6 +467,9 @@ void BSplines::updatePtsCurv() ptsCurv = pts; } + + + /* Private */ // Gerencia os Nos @@ -558,7 +636,7 @@ void BSplines::rmvNode(int tipo) // Normaliza a lista de nós void BSplines::normaNos(){ -/* + int i = 0; int n = nos.size(); double dif = 0 - nos[0]; @@ -567,7 +645,7 @@ void BSplines::normaNos(){ for(i = 0; i < n; i++){ nos[i] = (nos[i]+dif) * coef; - }*/ + } } // Inicializa os Nos @@ -617,7 +695,8 @@ double BSplines::bspline(int i, int k, double u) } } -void BSplines::draw(int index_load, bool is_selecting) + +void BSplines::draw(int index_load, bool is_selecting, int size_world) { int i,k,j; int sizePtc = (int) ptControle.size(); @@ -645,9 +724,9 @@ void BSplines::draw(int index_load, bool is_selecting) glPushMatrix(); // Aplicar Transformações Geométricas glColor3f(c[0],c[1],c[2]); - glScalef(s[0], s[1], s[2]); glTranslatef(t[0],t[1],t[2]); - glMultMatrixf(m); + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); if( !render_mode && this->is_selected){ @@ -666,8 +745,10 @@ void BSplines::draw(int index_load, bool is_selecting) } glPushMatrix(); - glTranslatef(ptControle[i][0],ptControle[i][1],ptControle[i][2]); - glutSolidCube(2); + glPointSize(5); + glBegin(GL_POINTS); + glVertex3f(ptControle[i][0],ptControle[i][1],ptControle[i][2]); + glEnd(); glPopMatrix(); } @@ -755,4 +836,66 @@ void BSplines::draw(int index_load, bool is_selecting) } glPopMatrix(); -} \ No newline at end of file + + + //modificador + if(render_mode && is_selected){ + + glPushMatrix(); + glTranslatef(translation[0], translation[1]-20, translation[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw( size_world-1, true); + glPopMatrix(); + + } else if (!render_mode && is_selected && hit_index_internal >= 1){ + + + //index_internal++; + glPushMatrix(); + glTranslatef(t[0],t[1],t[2]); + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); + glTranslatef(ptControle[ptcSelec][0], ptControle[ptcSelec][1], ptControle[ptcSelec][2]); + glScalef(0.8, 0.8, 0.8); + glScalef(1/s[0], 1/s[1], 1/s[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw(index_internal, true); + glPopMatrix(); + } + +} + +int BSplines::getSizeControlPoints() +{ + return (int) ptControle.size(); +} + + +vector BSplines::getControlPointSelected() +{ + + if( ptcSelec >= 0 ){ + + return ptControle[ptcSelec]; + + } else { + return ptControle[0]; + } +} + +void BSplines::setPtControleModifier(float x, float y, float z) +{ + if( ptcSelec >= 0 ){ + + ptControle[ptcSelec][0] = x; + ptControle[ptcSelec][1] = y; + ptControle[ptcSelec][2] = z; + + updatePtsCurv(); + } +} + +void BSplines::setModifier(int tp) +{ + modifier.setModifierType(tp); +} diff --git a/Prototipo-1/DOT_CPP/BezierCubic.cpp b/Prototipo-1/DOT_CPP/BezierCubic.cpp index 177a453..58162ab 100644 --- a/Prototipo-1/DOT_CPP/BezierCubic.cpp +++ b/Prototipo-1/DOT_CPP/BezierCubic.cpp @@ -1,17 +1,17 @@ #include "BezierCubic.h" -// Construtor +// Construtor BezierCubic::BezierCubic(void) { } -// Destrutor +// Destrutor BezierCubic::~BezierCubic(void) { } -// Função que calcula e retorna os pontos da curva de Beizer -// Recebe o paramêtro t, que representa a a quantidade de pontos +// Função que calcula e retorna os pontos da curva de Beizer +// Recebe o paramêtro t, que representa a a quantidade de pontos vector BezierCubic::processaPontoControle(int quant) { double t = 0; @@ -42,8 +42,8 @@ vector BezierCubic::processaPontoControle(int quant) return pontosCurva; } -// Define os 4 pontos de controle da curva de Bezier Cubica -// Recebe como paramêtro os 4 pontos de controle +// Define os 4 pontos de controle da curva de Bezier Cubica +// Recebe como paramêtro os 4 pontos de controle void BezierCubic::setPtControles(float p1[], float p2[], float p3[], float p4[]) { ptC1[0] = p1[0]; diff --git a/Prototipo-1/DOT_CPP/BezierCurve.cpp b/Prototipo-1/DOT_CPP/BezierCurve.cpp index b28937b..682cd92 100644 --- a/Prototipo-1/DOT_CPP/BezierCurve.cpp +++ b/Prototipo-1/DOT_CPP/BezierCurve.cpp @@ -1,38 +1,64 @@ #include "BezierCurve.h" #include + + + // Construtor + +BezierCurve::BezierCurve(BezierCurve *BezierCurve):Object() +{ + this->translation = BezierCurve->translation; + this->rotation = BezierCurve->rotation; + this->scale = BezierCurve->scale; + // Todos os Pontos da Curva de Bezier + // Pontos da Curva de Bezier Cubica + // A Cada 3 elementos tem-se um ponto representando + // px,py,pz + this->ptsCurv = BezierCurve->getPtsCurva();; + + // Lista de Segmentos de Controle da Curva + this->segments = BezierCurve->getSegments();; + + // Quantidade de Vertices que compem a curva + this->quant = BezierCurve->getQuant();; + + this->updatePtsCurv(); + + this->setTipo("BezierCurve"); +} + BezierCurve::BezierCurve(float x, float y,float z):Object() { - // Inicialização da Curva - Segment s1,s2; + // Inicialização da Curva + Segment s1,s2; - s1.setC(x,y,z); - s1.setCStatus(1); + s1.setC(x,y,z); + s1.setCStatus(1); - s1.setP1(x,y-20,z); - s1.setP1Status(0); + s1.setP1(x,y-20,z); + s1.setP1Status(0); - s1.setP2(x,y+20,z); - s1.setP2Status(1); + s1.setP2(x,y+20,z); + s1.setP2Status(1); - s2.setC(x+40,y,z); - s2.setCStatus(1); + s2.setC(x+40,y,z); + s2.setCStatus(1); - s2.setP1(x+40,y-20,z); - s2.setP1Status(1); + s2.setP1(x+40,y-20,z); + s2.setP1Status(1); - s2.setP2(x+40,y+20,z); - s2.setP2Status(0); + s2.setP2(x+40,y+20,z); + s2.setP2Status(0); - segments.push_back(s1); - segments.push_back(s2); + segments.push_back(s1); + segments.push_back(s2); - selectSegments = -1; - quant = 80; + selectSegments = -1; + quant = 80; - setTipo("BezierCurve"); - this->updatePtsCurv(); + setTipo("BezierCurve"); + this->updatePtsCurv(); } // Destrutor @@ -43,156 +69,191 @@ BezierCurve::~BezierCurve(void) // Atualiza os pontos da Curva void BezierCurve::updatePtsCurv() { - int i = 0; - float p1[3]; - float p2[3]; - float p3[3]; - float p4[3]; + int i = 0; + float p1[3]; + float p2[3]; + float p3[3]; + float p4[3]; - vector< vector > ptsControle; - vector aux; + vector< vector > ptsControle; + vector aux; - ptsCurv.clear(); + ptsCurv.clear(); - ptsControle = usedControlPts(); + ptsControle = usedControlPts(); - while(i < (int) ptsControle.size()){ + while(i < (int) ptsControle.size()){ - // Carrega os 4 pontos de Controles usados - // para gerar a curva de bezier cubica - p1[0] = ptsControle[i][0]; - p1[1] = ptsControle[i][1]; - p1[2] = ptsControle[i][2]; - i++; + // Carrega os 4 pontos de Controles usados + // para gerar a curva de bezier cubica + p1[0] = ptsControle[i][0]; + p1[1] = ptsControle[i][1]; + p1[2] = ptsControle[i][2]; + i++; - p2[0] = ptsControle[i][0]; - p2[1] = ptsControle[i][1]; - p2[2] = ptsControle[i][2]; - i++; + p2[0] = ptsControle[i][0]; + p2[1] = ptsControle[i][1]; + p2[2] = ptsControle[i][2]; + i++; - p3[0] = ptsControle[i][0]; - p3[1] = ptsControle[i][1]; - p3[2] = ptsControle[i][2]; - i++; + p3[0] = ptsControle[i][0]; + p3[1] = ptsControle[i][1]; + p3[2] = ptsControle[i][2]; + i++; - p4[0] = ptsControle[i][0]; - p4[1] = ptsControle[i][1]; - p4[2] = ptsControle[i][2]; + p4[0] = ptsControle[i][0]; + p4[1] = ptsControle[i][1]; + p4[2] = ptsControle[i][2]; - if(i+1 == (int) ptsControle.size()){ - i++; - } + if(i+1 == (int) ptsControle.size()){ + i++; + } - // Define os 4 pontos de controle usados para gerar a curva - bzcubic.setPtControles(p1,p2,p3,p4); + // Define os 4 pontos de controle usados para gerar a curva + bzcubic.setPtControles(p1,p2,p3,p4); - // Processa a curva de bezier cubica - aux = bzcubic.processaPontoControle(quant); + // Processa a curva de bezier cubica + aux = bzcubic.processaPontoControle(quant); - // Acrescenta a curva gerada com a lista geral das curvas - ptsCurv.reserve(ptsCurv.size()+aux.size()); - ptsCurv.insert(ptsCurv.end(), aux.begin(), aux.end()); + // Acrescenta a curva gerada com a lista geral das curvas + ptsCurv.reserve(ptsCurv.size()+aux.size()); + ptsCurv.insert(ptsCurv.end(), aux.begin(), aux.end()); - // Limpa a lista auxiliar - aux.clear(); - } + // Limpa a lista auxiliar + aux.clear(); + } } // Retorna os pontos da Curva vector BezierCurve::getPtsCurva() { - return ptsCurv; + return ptsCurv; } // Retorna a Lista de Segmentos vector BezierCurve::getSegments() { - return segments; + return segments; } // Retorna o indice do segmento selecionado int BezierCurve::getSelectSegments() { - return selectSegments; + return selectSegments; } // Define o Segmento e o Ponto do Segmento, selecionado void BezierCurve::setSelectSegments(int seg, int point) { - if(selectSegments != -1){ + if(selectSegments != -1){ - segments[selectSegments].setPtSelect(-1); - } + segments[selectSegments].setPtSelect(-1); + } - selectSegments = seg; + selectSegments = seg; - if(seg != -1){ + if(seg != -1){ - segments[selectSegments].setPtSelect(point); - } + segments[selectSegments].setPtSelect(point); + } } // Retorna a quantidade de Vertices que compem a curva int BezierCurve::getQuant() { - return quant; + return quant; } // Define a quantidade de Vertices que compem a curva void BezierCurve::setQuant(int valor) { - quant = valor; + quant = valor; } // Altera a posição do ponto de um segmento que está // selecionado void BezierCurve::setPtControle(float x, float y,float z) { - if(selectSegments != -1 ){ - if(segments[selectSegments].getPtSelect() == 0){ - segments[selectSegments].setC(x-translation[0],y-translation[1],z-translation[2]); - } - - if(segments[selectSegments].getPtSelect() == 1){ - segments[selectSegments].setP1(x-translation[0],y-translation[1],z-translation[2]); - } - if(segments[selectSegments].getPtSelect() == 2){ - segments[selectSegments].setP2(x-translation[0],y-translation[1],z-translation[2]); - } - } + if(selectSegments != -1 ){ + + //int count = 0; + vector r = getRotation(); + //GLfloat matrix[16]; + glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); + glm::quat quaternion = quat ; + glm::mat4 mat = glm::toMat4(quaternion); + /* for (int k = 0; k < 4; ++k){ + for (int j = 0; j < 4; ++j){ + matrix[count] = mat[k][j]; + count++; + } + }*/ + + glm::mat4 INVERSE_ROTATE = glm::inverse(mat); + glm::vec4 reverse_point = INVERSE_ROTATE * glm::vec4( + (x-translation[0])/scale[0], + (y-translation[1])/scale[1], + (z-translation[2])/scale[2], + 1.0f + ); + + if(segments[selectSegments].getPtSelect() == 0){ + segments[selectSegments].setC( + reverse_point[0], + reverse_point[1], + reverse_point[2] + ); + } + + if(segments[selectSegments].getPtSelect() == 1){ + segments[selectSegments].setP1( + reverse_point[0], + reverse_point[1], + reverse_point[2] + ); + } + + if(segments[selectSegments].getPtSelect() == 2){ + segments[selectSegments].setP2( + reverse_point[0], + reverse_point[1], + reverse_point[2] + ); + } + } } // Retorna os Pontos de Controle do Segmento que serão usados // para gerar a curva de Bezier vector< vector > BezierCurve::usedControlPts() { - vector< vector > usedCPts; + vector< vector > usedCPts; - vector pts; - int i; + vector pts; + int i; - for(i = 0; i < (int) segments.size() ; i++) - { + for(i = 0; i < (int) segments.size() ; i++) + { - pts = segments[i].getP1(); - if(pts[3] == 1){ - usedCPts.push_back(pts); - } + pts = segments[i].getP1(); + if(pts[3] == 1){ + usedCPts.push_back(pts); + } - pts = segments[i].getC(); - if(pts[3] == 1){ - usedCPts.push_back(pts); - } + pts = segments[i].getC(); + if(pts[3] == 1){ + usedCPts.push_back(pts); + } - pts = segments[i].getP2(); - if(pts[3] == 1){ - usedCPts.push_back(pts); - } - } + pts = segments[i].getP2(); + if(pts[3] == 1){ + usedCPts.push_back(pts); + } + } - return usedCPts; + return usedCPts; } // Adciona um Segmento extremo da curva, @@ -200,28 +261,28 @@ vector< vector > BezierCurve::usedControlPts() // tem de estar selecionados int BezierCurve::addSegment() { - if(selectSegments == 0){ + if(selectSegments == 0){ - Segment newSegment = segments[selectSegments]; + Segment newSegment = segments[selectSegments]; - segments[selectSegments].setP1Status(1); + segments[selectSegments].setP1Status(1); - segments.insert(segments.begin(),newSegment); + segments.insert(segments.begin(),newSegment); - } else if(selectSegments == (int) segments.size()-1){ + } else if(selectSegments == (int) segments.size()-1){ - Segment newSegment = segments[selectSegments]; + Segment newSegment = segments[selectSegments]; - segments[selectSegments].setP2Status(1); + segments[selectSegments].setP2Status(1); - segments.push_back(newSegment); + segments.push_back(newSegment); - } else { + } else { - return 0; - } + return 0; + } - return 1; + return 1; } // Remove um Segmento extremo da curva, @@ -229,52 +290,52 @@ int BezierCurve::addSegment() // tem de estar selecionados int BezierCurve::removeSegment() { - if(selectSegments != -1 && (int) segments.size() > 2){ + if(selectSegments != -1 && (int) segments.size() > 2){ - if(selectSegments == 0) { + if(selectSegments == 0) { - segments[1].setP1Status(0); - segments.erase(segments.begin()+selectSegments); + segments[1].setP1Status(0); + segments.erase(segments.begin()+selectSegments); - } else if(selectSegments == (int) segments.size()-1){ + } else if(selectSegments == (int) segments.size()-1){ - segments[segments.size()-2].setP2Status(0); - segments.erase(segments.begin()+selectSegments); - selectSegments--; + segments[segments.size()-2].setP2Status(0); + segments.erase(segments.begin()+selectSegments); + selectSegments--; - } else { + } else { - segments.erase(segments.begin()+selectSegments); - } + segments.erase(segments.begin()+selectSegments); + } - } else { + } else { - return 0; - } + return 0; + } - return 1; + return 1; } - void BezierCurve::ponteiro(float x,float y,float z, int size) { - glBegin(GL_POLYGON); - glVertex3f(x+size,y+size,z); - glVertex3f(x+size,y-size,z); - glVertex3f(x-size,y-size,z); - glVertex3f(x-size,y+size,z); - glEnd(); + glBegin(GL_POLYGON); + glVertex3f(x+size,y+size,z); + glVertex3f(x+size,y-size,z); + glVertex3f(x-size,y-size,z); + glVertex3f(x-size,y+size,z); + glEnd(); } -void BezierCurve::draw(int index_load, bool is_selecting) +void BezierCurve::draw(int index_load, bool is_selecting, int size_world) { - int i,k,j; - int sizeSeg = (int) segments.size(); - int sizeCur = (int) ptsCurv.size(); - vector pt; - - GLfloat m[16]; - vector c = getColor(); + int idselec; + int i,k,j; + int sizeSeg = (int) segments.size(); + int sizeCur = (int) ptsCurv.size(); + vector pt; + + GLfloat m[16]; + vector c = getColor(); vector r = getRotation(); vector t = getTranslation(); vector s = getScale(); @@ -291,135 +352,229 @@ void BezierCurve::draw(int index_load, bool is_selecting) } } - glPushMatrix(); // Aplicar Transformações Geométricas glColor3f(c[0],c[1],c[2]); - glScalef(s[0], s[1], s[2]); glTranslatef(t[0],t[1],t[2]); + glScalef(s[0], s[1], s[2]); glMultMatrixf(m); if( !render_mode && this->is_selected){ - // Modo Edição - index_internal = 0; - - if(!is_selecting){ + // Modo Edição + index_internal = 0; + + if(!is_selecting){ + + this->updatePtsCurv(); + + if(this->is_selected){ + glColor4f(GREEN); + } else { + glColor4f(RED); + } + + glPushMatrix(); + glBegin(GL_LINE_STRIP); + for(j = 0; j < sizeCur; j+=3){ + glVertex3f(ptsCurv[j],ptsCurv[j+1],ptsCurv[j+2]); + } + glEnd(); + glPopMatrix(); + } + + for(i = 0; i < sizeSeg; i++){ + + cout << " modo edição " << endl; + // Point 1 + index_internal++; + glLoadName(index_internal); + glColor4f(BLACK); + if(index_internal == hit_index_internal){ + cout << "que merda ta acontecendo aqui" << endl; + glColor4f(ORANGE); + this->setSelectSegments(i,1); + } + pt = segments[i].getP1(); + glPushMatrix(); + glPointSize(5); + glBegin(GL_POINTS); + glVertex3f(pt[0],pt[1],pt[2]); + glEnd(); + glPopMatrix(); + + // Point C + index_internal++; + glLoadName(index_internal); + glColor4f(BLACK); + if(index_internal == hit_index_internal){ + glColor4f(ORANGE); + this->setSelectSegments(i,0); + } + pt = segments[i].getC(); + glPushMatrix(); + glPointSize(5); + glBegin(GL_POINTS); + glVertex3f(pt[0],pt[1],pt[2]); + glEnd(); + glPopMatrix(); + + // Pointe 2 + index_internal++; + glLoadName(index_internal); + glColor4f(BLACK); + if(index_internal == hit_index_internal){ + glColor4f(ORANGE); + this->setSelectSegments(i,2); + } + pt = segments[i].getP2(); + glPushMatrix(); + glPointSize(5); + glBegin(GL_POINTS); + glVertex3f(pt[0],pt[1],pt[2]); + glEnd(); + glPopMatrix(); + + + if(!is_selecting){ + //Line + glColor4f(BLACK); + glPushMatrix(); + glBegin(GL_LINES); + pt = segments[i].getP1(); + glVertex3f(pt[0],pt[1],pt[2]); + pt = segments[i].getP2(); + glVertex3f(pt[0],pt[1],pt[2]); + glEnd(); + glPopMatrix(); + } + } - this->updatePtsCurv(); + } else { - if(this->is_selected){ - glColor4f(GREEN); - } else { - glColor4f(RED); - } + // Modo Objeto + if(render_mode){ + + glLoadName(index_load); + + if(this->is_selected){ + glColor4f(GREEN); + } else { + glColor4f(RED); + } + + glPushMatrix(); + glBegin(GL_LINE_STRIP); + for(i = 0; i < sizeCur; i+=3){ + glVertex3f(ptsCurv[i],ptsCurv[i+1],ptsCurv[i+2]); + } + glEnd(); + glPopMatrix(); + + } else if(!is_selecting){ + + if(this->is_selected){ + glColor4f(GREEN); + } else { + glColor4f(RED); + } + + glPushMatrix(); + glBegin(GL_LINE_STRIP); + for(i = 0; i < sizeCur; i+=3){ + glVertex3f(ptsCurv[i],ptsCurv[i+1],ptsCurv[i+2]); + } + glEnd(); + glPopMatrix(); + } + } + glPopMatrix(); - glPushMatrix(); - glBegin(GL_LINE_STRIP); - for(j = 0; j < sizeCur; j+=3){ - glVertex3f(ptsCurv[j],ptsCurv[j+1],ptsCurv[j+2]); - } - glEnd(); - glPopMatrix(); + //modificador + if(render_mode && is_selected){ + + glPushMatrix(); + glTranslatef(translation[0], translation[1]-20, translation[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw( size_world-1, true); + glPopMatrix(); + + } else if (!render_mode && is_selected && hit_index_internal >= 1){ + + idselec = getSelectSegments(); + if( idselec >= 0 ){ + if(segments[idselec].getPtSelect() == 0){ + pt = segments[idselec].getC(); + } + if(segments[idselec].getPtSelect() == 1){ + pt = segments[idselec].getP1(); + } + if(segments[idselec].getPtSelect() == 2){ + pt = segments[idselec].getP2(); + } } + //index_internal++; + glPushMatrix(); + glTranslatef(t[0],t[1],t[2]); + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); + glTranslatef(pt[0], pt[1], pt[2]); + glScalef(0.8, 0.8, 0.8); + glScalef(1/s[0], 1/s[1], 1/s[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw(index_internal, true); + glPopMatrix(); + } - for(i = 0; i < sizeSeg; i++){ - - cout << " modo edição " << endl; - // Point 1 - index_internal++; - glLoadName(index_internal); - glColor4f(BLACK); - if(index_internal == hit_index_internal){ - glColor4f(ORANGE); - this->setSelectSegments(i,1); - } - pt = segments[i].getP1(); - glPushMatrix(); - glTranslatef(pt[0],pt[1],pt[2]); - glutSolidCube(2); - glPopMatrix(); - - // Point C - index_internal++; - glLoadName(index_internal); - glColor4f(BLACK); - if(index_internal == hit_index_internal){ - glColor4f(ORANGE); - this->setSelectSegments(i,0); - } - pt = segments[i].getC(); - glPushMatrix(); - glTranslatef(pt[0],pt[1],pt[2]); - glutSolidCube(2); - glPopMatrix(); - - // Pointe 2 - index_internal++; - glLoadName(index_internal); - glColor4f(BLACK); - if(index_internal == hit_index_internal){ - glColor4f(ORANGE); - this->setSelectSegments(i,2); - } - pt = segments[i].getP2(); - glPushMatrix(); - glTranslatef(pt[0],pt[1],pt[2]); - glutSolidCube(2); - glPopMatrix(); - - - if(!is_selecting){ - //Line - glColor4f(BLACK); - glPushMatrix(); - glBegin(GL_LINES); - pt = segments[i].getP1(); - glVertex3f(pt[0],pt[1],pt[2]); - pt = segments[i].getP2(); - glVertex3f(pt[0],pt[1],pt[2]); - glEnd(); - glPopMatrix(); - } - } +} - } else { +int BezierCurve::getSizeControlPoints() +{ + return ((int) segments.size())*3; +} - // Modo Objeto - if(render_mode){ - - glLoadName(index_load); - - if(this->is_selected){ - glColor4f(GREEN); - } else { - glColor4f(RED); - } - - glPushMatrix(); - glBegin(GL_LINE_STRIP); - for(i = 0; i < sizeCur; i+=3){ - glVertex3f(ptsCurv[i],ptsCurv[i+1],ptsCurv[i+2]); - } - glEnd(); - glPopMatrix(); - - } else if(!is_selecting){ - - if(this->is_selected){ - glColor4f(GREEN); - } else { - glColor4f(RED); - } - - glPushMatrix(); - glBegin(GL_LINE_STRIP); - for(i = 0; i < sizeCur; i+=3){ - glVertex3f(ptsCurv[i],ptsCurv[i+1],ptsCurv[i+2]); - } - glEnd(); - glPopMatrix(); - } +vector BezierCurve::getControlPointSelected() +{ + + vector pt; + int idselec = getSelectSegments(); + + if( idselec >= 0 ){ + if(segments[idselec].getPtSelect() == 0){ + pt = segments[idselec].getC(); + } + if(segments[idselec].getPtSelect() == 1){ + pt = segments[idselec].getP1(); + } + if(segments[idselec].getPtSelect() == 2){ + pt = segments[idselec].getP2(); + } } - glPopMatrix(); -} \ No newline at end of file + + return pt; +} + +void BezierCurve::setPtControleModifier(float x, float y, float z) +{ + vector pt; + int idselec = getSelectSegments(); + + if( idselec >= 0 ){ + if(segments[idselec].getPtSelect() == 0){ + segments[idselec].setC(x,y,z); + } + if(segments[idselec].getPtSelect() == 1){ + segments[idselec].setP1(x,y,z); + } + if(segments[idselec].getPtSelect() == 2){ + segments[idselec].setP2(x,y,z); + } + } + + updatePtsCurv(); +} + +void BezierCurve::setModifier(int tp) +{ + modifier.setModifierType(tp); +} diff --git a/Prototipo-1/DOT_CPP/Nurbs.cpp b/Prototipo-1/DOT_CPP/Nurbs.cpp index 1193bfc..84649e7 100644 --- a/Prototipo-1/DOT_CPP/Nurbs.cpp +++ b/Prototipo-1/DOT_CPP/Nurbs.cpp @@ -1,6 +1,54 @@ #include "Nurbs.h" #include + +Nurbs::Nurbs(Nurbs * nurb):BSplines() +{ + + this->translation = nurb->translation; + this->rotation = nurb->rotation; + this->scale = nurb->scale; + + // Quantidade de Pontos da Curva + this->quant = nurb->getQuant(); + + // Ordem da Curva B-Spline + this->ordCurva = nurb->getOrdCurva(); + + // Lista de Nos usados para geração da curva B-Spline + this->nos = nurb->getNo(); + + // Lista de Pontos da Curva B-Spline + // A Cada 3 elementos da lista tem-se um ponto representando + // px,py,pz + this->ptsCurv = nurb->getPtsCurva(); + + // Lista Bidimensional Representando os Pontos de Controle + this->ptControle = nurb->getPtControle(); + + // Lista de Pesos + this->pesos = nurb->getPesos(); + + this->updatePtsCurv(); + + this->setTipo("Nurbs"); +} + +// Construtor +Nurbs::Nurbs(vector < vector > ptControle, vector nos, vector pesos):BSplines() +{ + + this->ptControle = ptControle; + this->pesos = pesos; + this->nos = nos; + ordCurva = 3; + //iniNo(); + + // Tipo Curva Nurbs + setTipo("Nurbs"); + + this->updatePtsCurv(); +} // Construtor Nurbs::Nurbs(float x, float y, float z):BSplines() { @@ -57,6 +105,17 @@ vector Nurbs::getPesos() return pesos; } +float Nurbs::getPesoSelec() +{ + float val = -1; + + if(ptcSelec >= 0){ + val = pesos[ptcSelec]; + } + + return val; +} + // Altera o peso de um ponto de Controle selecionado void Nurbs::setPeso(float valor) { @@ -85,7 +144,7 @@ void Nurbs::updatePtsCurv() inc = ( fim - inic ) / quant; } - for(t = inic; t <= fim; t+=inc){ + for(t = 0; t <= 1; t+=inc){ x = y = z = 0; x2 = y2 = z2 = 0; diff --git a/Prototipo-1/DOT_CPP/bezierSurface.cpp b/Prototipo-1/DOT_CPP/bezierSurface.cpp index 6101ec0..c7e994b 100644 --- a/Prototipo-1/DOT_CPP/bezierSurface.cpp +++ b/Prototipo-1/DOT_CPP/bezierSurface.cpp @@ -1,17 +1,41 @@ #include "bezierSurface.h" -#include #include #include #include #include #include #include + using namespace std; +SurfaceBezier::SurfaceBezier( SurfaceBezier *surface):Object() +{ + setTipo("BezierSurface"); + + this->translation = surface->translation; + this->rotation = surface->rotation; + this->scale = surface->scale; + modifier = Modifier(translation[0], translation[1], translation[2]); + + this->NI = surface->NI; //dimensao na direcao de u + this->NJ = surface->NJ; // dimensao na direcao de v + + this->RESOLUTIONI = surface->RESOLUTIONI; //resolucao na direcao I + this->RESOLUTIONJ = surface->RESOLUTIONJ; // resolucao na direcao J + + this->weight = surface->weight; + this->controlPoints = surface->controlPoints; + surface3dBezierRenderNUBRS(); + + +} SurfaceBezier::SurfaceBezier():Object() { - cout << "NA superifice de bezier ...."<< endl; + + setTipo("BezierSurface"); + + modifier = Modifier(translation[0], translation[1], translation[2]); this->NI = 3; //dimensao na direcao de u this->NJ = 3; // dimensao na direcao de v @@ -19,29 +43,29 @@ SurfaceBezier::SurfaceBezier():Object() this->RESOLUTIONI = 4; //resolucao na direcao I this->RESOLUTIONJ = 4; // resolucao na direcao J - vector > w(NI+1,vector (NJ+1, 0)); - weight = w; + weight = vector > (NI+1,vector (NJ+1, 0)); - vector > > cP(NI+1,vector >(NJ+1,vector (3,0))); - controlPoints = cP; + controlPoints = vector > > (NI+1,vector >(NJ+1,vector (3,0))); createControlPoints(); preencheMatrizPesos(); surface3dBezierRenderNUBRS(); + + } SurfaceBezier::SurfaceBezier(int ni, int nj, int resolutioni, int resolutionj):Object() { - cout << "NA superifice de bezier ...."<< endl; + setTipo("BezierSurface"); this->NI = ni-1; //dimensao na direcao de u this->NJ = nj-1; // dimensao na direcao de v - - this->RESOLUTIONI = resolutioni; //resolucao na direcao I - this->RESOLUTIONJ = resolutionj; // resolucao na direcao J + + this->RESOLUTIONI = resolutioni-1; //resolucao na direcao I + this->RESOLUTIONJ = resolutionj-1; // resolucao na direcao J vector > w(NI+1,vector (NJ+1, 0)); @@ -55,7 +79,7 @@ SurfaceBezier::SurfaceBezier(int ni, int nj, int resolutioni, int resolutionj):O preencheMatrizPesos(); surface3dBezierRenderNUBRS(); - + } SurfaceBezier::~SurfaceBezier() @@ -115,7 +139,7 @@ void SurfaceBezier::surface3dBezierRenderNUBRS() /*calcula os pontos da superficie*/ for (int k = 0; k <= NI ; k++) { for (int l = 0; l <= NJ ; l++){ - bi =(combination(NI, k) * pow( (1.00-INTER_I), (double) (NI-k)) * pow(INTER_I, double(k))) ; + bi =(combination(NI, k) * pow( (1.00-INTER_I), (double) (NI-k)) * pow(INTER_I, double(k))) ; bj =(combination(NJ, l) * pow( (1.00-INTER_J), (double) (NJ-l)) * pow(INTER_J, double(l))) ; output[0] += bi * bj * controlPoints[k][l][0] * weight[k][l]; output[1] += bi * bj * controlPoints[k][l][1] * weight[k][l]; @@ -134,7 +158,73 @@ void SurfaceBezier::surface3dBezierRenderNUBRS() } surfaceBezier = surface; } +void SurfaceBezier::translateObject( vector newTranslation) + +{ + this->translation = newTranslation; +} + +void SurfaceBezier::rotateObject(vector newRotation) +{ + this->rotation = newRotation; + +} + + +void SurfaceBezier::setGlobalScale( float x, float y, float z) +{ + + this->globalScale[0] = x; + this->globalScale[1] = y; + this->globalScale[2] = z; +} +void SurfaceBezier::setPtControleModifier(float x, float y, float z) +{ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + controlPoints[i][j][0] = x; + controlPoints[i][j][1] = y; + controlPoints[i][j][2] = z; + surface3dBezierRenderNUBRS(); +} +void SurfaceBezier::setPtControle(float x, float y, float z) +{ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + + vector r = getRotation(); + glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); + glm::quat quaternion = quat ; + glm::mat4 mat = glm::toMat4(quaternion); + + controlPoints[i][j][0] = (x-translation[0])/scale[0]; + controlPoints[i][j][1] = (y-translation[1])/scale[1]; + controlPoints[i][j][2] = (z-translation[2])/scale[2]; + + glm::mat4 INVERSE_ROTATE = glm::inverse(mat); + glm::vec4 reverse_point = INVERSE_ROTATE * glm::vec4(controlPoints[i][j][0], + controlPoints[i][j][1], + controlPoints[i][j][2], + 1.0f + ); + controlPoints[i][j][0] = reverse_point[0]; + controlPoints[i][j][1] = reverse_point[1]; + controlPoints[i][j][2] = reverse_point[2]; + + surface3dBezierRenderNUBRS(); +} + +vector SurfaceBezier::getControlPointSelected() +{ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + vector selectedPoint(3, 0); + selectedPoint[0] = controlPoints[i][j][0]; + selectedPoint[1] = controlPoints[i][j][1]; + selectedPoint[2] = controlPoints[i][j][2]; + return selectedPoint; +} vector SurfaceBezier::getControlPoints() @@ -168,9 +258,13 @@ void SurfaceBezier::createControlPoints(void) for (int i = 0; i <= NI; i++){ for (int j = 0; j <= NJ; j++){ controlPoints[i][j][0] = X1; - controlPoints[i][j][1] = 0.0; + //controlPoints[i][j][1] = 0.0; controlPoints[i][j][2] = Z1;; //+ (double) ( rand() % 100 ); X1 += variation; + if (i > 0 && j < NJ && i == j){ + controlPoints[i][j][1] = 10.0; + controlPoints[i][NJ-j][1] = 10.0; + } } Z1-=variation; @@ -179,6 +273,10 @@ void SurfaceBezier::createControlPoints(void) } +int SurfaceBezier::getSizeControlPoints() +{ + return (NI+1) * (NJ+1); +} void SurfaceBezier::movePointControlSurfaceBspline(double *p, int index) { @@ -208,145 +306,12 @@ void SurfaceBezier::preencheMatrizPesos(){ //weight[i][j] = (double) ( rand() % 100 ); weight[i][j] = 1.0; - cout << weight[i][j] << ", "; + //cout << weight[i][j] << ", "; } - cout << endl; + //cout << endl; } } -/*void Bezier::draw(int index_load, bool is_selecting) -{ - int i,k,j; - int sizeSeg = (int) segments.size(); - int sizeCur = (int) ptsCurv.size(); - vector pt; - - GLfloat m[16]; - vector c = getColor(); - vector r = getRotation(); - vector t = getTranslation(); - vector s = getScale(); - - glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); - glm::quat quaternion = quat ; - glm::mat4 mat = glm::toMat4(quaternion); - - int count = 0; - for ( k = 0; k < 4; ++k){ - for ( j = 0; j < 4; ++j){ - m[count] = mat[k][j]; - count++; - } - } - - if( !render_mode && this->is_selected){ - - // Modo Edição - index_internal = 0; - - if(!is_selecting){ - - this->updatePtsCurv(); - - if(this->is_selected){ - glColor4f(GREEN); - } else { - glColor4f(RED); - } - - glPushMatrix(); - glBegin(GL_LINE_STRIP); - for(j = 0; j < sizeCur; j+=3){ - glVertex3f(ptsCurv[j],ptsCurv[j+1],ptsCurv[j+2]); - } - glEnd(); - glPopMatrix(); - } - - - for(i = 0; i < sizeSeg; i++){ - - cout << " modo edição " << endl; - // Point 1 - index_internal++; - glLoadName(index_internal); - glColor4f(BLACK); - if(index_internal == hit_index_internal){ - glColor4f(ORANGE); - this->setSelectSegments(i,1); - } - pt = segments[i].getP1(); - glPushMatrix(); - glTranslatef(pt[0],pt[1],0); - glutSolidCube(2); - glPopMatrix(); - - // Point C - index_internal++; - glLoadName(index_internal); - glColor4f(BLACK); - if(index_internal == hit_index_internal){ - glColor4f(ORANGE); - this->setSelectSegments(i,0); - } - pt = segments[i].getC(); - glPushMatrix(); - glTranslatef(pt[0],pt[1],pt[2]); - glutSolidCube(2); - glPopMatrix(); - - // Pointe 2 - index_internal++; - glLoadName(index_internal); - glColor4f(BLACK); - if(index_internal == hit_index_internal){ - glColor4f(ORANGE); - this->setSelectSegments(i,2); - } - pt = segments[i].getP2(); - glPushMatrix(); - glTranslatef(pt[0],pt[1],pt[2]); - glutSolidCube(2); - glPopMatrix(); - - - if(!is_selecting){ - //Line - glColor4f(BLACK); - glPushMatrix(); - glBegin(GL_LINES); - pt = segments[i].getP1(); - glVertex3f(pt[0],pt[1],pt[2]); - pt = segments[i].getP2(); - glVertex3f(pt[0],pt[1],pt[2]); - glEnd(); - glPopMatrix(); - } - } - - } else { - - // Modo Objeto - cout << " modo objeto " << endl; - glLoadName(index_load); - - this->updatePtsCurv(); - - if(this->is_selected){ - glColor4f(GREEN); - } else { - glColor4f(RED); - } - - glPushMatrix(); - glBegin(GL_LINE_STRIP); - for(i = 0; i < sizeCur; i+=3){ - glVertex3f(ptsCurv[i],ptsCurv[i+1],ptsCurv[i+2]); - } - glEnd(); - glPopMatrix(); - } -}*/ void SurfaceBezier::drawGlQuadStripVector(vector array , int n, int m, int type) @@ -365,15 +330,15 @@ void SurfaceBezier::drawGlQuadStripVector(vector array , int n, int m for (int j = 0; j < m ; j++) { - + glVertex3f(array[i*m+j][0], array[i*m+j][1], array[i*m+j][2] ); - glVertex3f(array[(1+i)*m+j][0], array[(1+i)*m+j][1], array[(1+i)*m+j][2] ); - + glVertex3f(array[(1+i)*m+j][0], array[(1+i)*m+j][1], array[(1+i)*m+j][2] ); + } glEnd(); glPopMatrix(); } - + } void SurfaceBezier::drawControlPoint(int hit) @@ -381,31 +346,55 @@ void SurfaceBezier::drawControlPoint(int hit) int count_object = 0; glEnable( GL_POINT_SMOOTH ); glPointSize(6.0f); - + for (int i = 0; i <= NI; i++) { for (int j = 0; j <= NJ; ++j){ - count_object++; + count_object++; glLoadName(count_object); glPushMatrix(); - if ( ( (hit-1) /(NI + 1) ) == i && ( (hit-1) % (NJ + 1) ) == j ){ + if ( ( (hit-1) /(NJ + 1) ) == i && ( (hit-1) % (NJ + 1) ) == j ){ glColor4f(ORANGE); } else { glColor4f(BLACK); } glBegin(GL_POINTS); - glVertex3f(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2] ); - glEnd(); + glVertex3f(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2] ); + glEnd(); glPopMatrix(); } } - } -void SurfaceBezier::draw(int index_load, bool is_selecting) +void SurfaceBezier::drawControlPolygon() + +{ + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glColor4f(BLACK); + + + //desenahdo o poligono de controle + for (int i = 0; i < NI; i++) { + + glPushMatrix(); + glBegin(GL_QUAD_STRIP); + + for (int j = 0; j < NJ+1 ; j++) { + + + glVertex3f(controlPoints [i][j][0],controlPoints [i][j][1],controlPoints [i][j][2]); + glVertex3f(controlPoints [i+1][j][0],controlPoints [i+1][j][1],controlPoints [i+1][j][2]); + + } + glEnd(); + glPopMatrix(); + } +} + +void SurfaceBezier::draw(int index_load, bool is_selecting, int size_world) { GLfloat m[16]; @@ -415,7 +404,7 @@ void SurfaceBezier::draw(int index_load, bool is_selecting) vector s = getScale(); glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); - glm::quat quaternion = quat ; + glm::quat quaternion = quat ; glm::mat4 mat = glm::toMat4(quaternion); int count = 0; @@ -423,40 +412,73 @@ void SurfaceBezier::draw(int index_load, bool is_selecting) for (int j = 0; j < 4; ++j){ m[count] = mat[k][j]; count++; - } - } + } + } + + //modificador + if(render_mode && is_selected){ + glPushMatrix(); + glTranslatef(translation[0], translation[1]-20, translation[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw( size_world-1, true); + glPopMatrix(); + } + + else if (!render_mode && is_selected && hit_index_internal >= 1){ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + glPushMatrix(); + glTranslatef(t[0],t[1],t[2]); + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); + glTranslatef(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2]); + glScalef(0.8, 0.8, 0.8); + glScalef(1/s[0], 1/s[1], 1/s[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw( (NI+1)*(NJ+1), true); + glPopMatrix(); + } + glPushMatrix(); glTranslatef(t[0],t[1],t[2]); - glScalef(2, 2, 2); - //drawControlPoint(getControlPoints()); - //glColor3f(0, 0, 0); - + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); + //modo objeto if(render_mode){ - glLoadName(index_load); - + if (is_selected){ + //modifier.draw( ( ( index_load-1 ) * 4 ) + 1, true); glColor4f(GREEN); } else { - glColor4f(RED); + glColor4f(GRAY1); } - + + glLoadName(index_load); + //glLoadName( index_load ); drawGlQuadStripVector(surfaceBezier, RESOLUTIONI+1, RESOLUTIONJ+1, 1); - + //modo Edicao } else if (!render_mode && is_selected){ glColor4f(GREEN); if (!is_selecting){ drawGlQuadStripVector(surfaceBezier, RESOLUTIONI+1, RESOLUTIONJ+1, 1); + drawControlPolygon(); } drawControlPoint(hit_index_internal); - + } else if (!render_mode && !is_selected) { if (!is_selecting){ - glColor4f(RED); - drawGlQuadStripVector(surfaceBezier, RESOLUTIONI+1, RESOLUTIONJ+1, 1); + glColor4f(GRAY1); + drawGlQuadStripVector(surfaceBezier, RESOLUTIONI+1, RESOLUTIONJ+1, 1); } } glPopMatrix(); +} + + +void SurfaceBezier::setModifier(int tp) +{ + modifier.setModifierType(tp); } \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/customDialog.cpp b/Prototipo-1/DOT_CPP/customDialog.cpp new file mode 100644 index 0000000..c4580ed --- /dev/null +++ b/Prototipo-1/DOT_CPP/customDialog.cpp @@ -0,0 +1,128 @@ +#include "customDialog.h" +CustomDialog::CustomDialog(wxWindow* parent, + wxWindowID id, + const wxString& title) + : wxDialog(parent, id, title, + wxDefaultPosition, wxSize(300, 280)) { + + // Setup the Panel and Widgets. + wxPanel* panel = new wxPanel(this, wxID_ANY); + panel->SetBackgroundColour(wxColour(150, 150, 150)); + + cancelButton = new wxButton(panel, wxID_ANY, "Cancel"); + okButton = new wxButton(panel, wxID_ANY, "Ok"); + + controlPointTextCtrlU = new wxTextCtrl(panel, wxID_ANY); + controlPointTextCtrlV = new wxTextCtrl(panel, wxID_ANY); + resolutionTextCtrlU = new wxTextCtrl(panel, wxID_ANY); + resolutionTextCtrlV = new wxTextCtrl(panel, wxID_ANY); + degree = new wxTextCtrl(panel, wxID_ANY); + + wxFont font(11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, + wxFONTWEIGHT_BOLD, false); + + // Put the widgets in a sizer. + wxBoxSizer *sizer1 = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *sizer2 = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *sizer3 = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *sizer4 = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *sizer5 = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *sizer6 = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *sizer7 = new wxBoxSizer(wxHORIZONTAL); + + wxStaticText *st1 = new wxStaticText(panel, wxID_ANY, "Control Point U: " ); + wxStaticText *st2 = new wxStaticText(panel, wxID_ANY, "Control Point V: " ); + wxStaticText *st3 = new wxStaticText(panel, wxID_ANY, "Resolution U: " ); + wxStaticText *st4 = new wxStaticText(panel, wxID_ANY, "Resolution V: " ); + wxStaticText *st5 = new wxStaticText(panel, wxID_ANY, "degree: " ); + + st1->SetFont(font); + st2->SetFont(font); + st3->SetFont(font); + st4->SetFont(font); + st5->SetFont(font); + + sizer2->Add(st1, 0, wxALL, 5); + sizer2->Add(controlPointTextCtrlU, 0,wxALL, 5); + + sizer3->Add(st2, 0, wxALL, 5); + sizer3->Add(controlPointTextCtrlV, 0,wxALL, 5); + + + sizer4->Add(st3, 0, wxALL, 5); + sizer4->Add(resolutionTextCtrlU, 0,wxALL, 5); + + sizer5->Add(st4, 0, wxALL, 5); + sizer5->Add(resolutionTextCtrlV, 0,wxALL, 5); + + sizer6->Add(st5, 0, wxALL, 5); + sizer6->Add(degree, 0,wxALL, 5); + + sizer7->Add(okButton, 0, wxALL , 0); + sizer7->Add(cancelButton, 0, wxALL | 0); + + sizer1->Add(sizer2, 0, wxALL, 5); + sizer1->Add(sizer3, 0, wxALL, 5); + sizer1->Add(sizer4, 0, wxALL, 5); + sizer1->Add(sizer5, 0, wxALL, 5); + sizer1->Add(sizer6, 0, wxALL, 5); + sizer1->Add(sizer7, 0, wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 0); + panel->SetSizer(sizer1); + + okButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CustomDialog::OnButtonClickOk ), NULL, this ); + cancelButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CustomDialog::OnButtonClickCancel ), NULL, this ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CustomDialog::OnClose ), NULL, this ); + Center(); +} + +CustomDialog::~CustomDialog() { + okButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CustomDialog::OnButtonClickOk ), NULL, this ); + cancelButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CustomDialog::OnButtonClickCancel ), NULL, this ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CustomDialog::OnClose ), NULL, this ); + +} + +void CustomDialog::OnButtonClickOk( wxCommandEvent& event) +{ + EndModal(wxID_OK); + Destroy(); +} +void CustomDialog::OnButtonClickCancel( wxCommandEvent& event) +{ + EndModal(wxID_CANCEL); + Destroy(); +} + + +void CustomDialog::OnClose( wxCloseEvent& event ) +{ + Destroy(); +} + +std::string CustomDialog::getControlPointU() +{ + + return controlPointTextCtrlU->GetValue().ToStdString(); +} + +std::string CustomDialog::getControlPointV() +{ + + return controlPointTextCtrlV->GetValue().ToStdString(); +} + +std::string CustomDialog::getResolutionU() +{ + + return resolutionTextCtrlU->GetValue().ToStdString(); +} + +std::string CustomDialog::getResolutionV() +{ + return resolutionTextCtrlV->GetValue().ToStdString(); +} + +std::string CustomDialog::getDegree() +{ + return degree->GetValue().ToStdString(); +} \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/customPanel.cpp b/Prototipo-1/DOT_CPP/customPanel.cpp new file mode 100644 index 0000000..2e0fa2e --- /dev/null +++ b/Prototipo-1/DOT_CPP/customPanel.cpp @@ -0,0 +1,290 @@ +#include "customPanel.h" + +Transform::Transform(wxWindow* parent): wxScrolledWindow(parent, wxID_ANY) +{ + + //Criando todos os componentes + toggleButtonTransform = new wxToggleButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(13, 13), wxBU_NOTEXT); + panelTransform = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + this->SetBackgroundColour(wxColour(150, 150, 150)); + panelTransform->SetBackgroundColour(wxColour(150, 150, 150)); + //Cria os botoes de translacao... + buttonTranslateX = new wxButton( panelTransform, wxID_ANY, wxT("ButtonTransX"), wxDefaultPosition, wxSize(150, 20), 0 ); + buttonTranslateY = new wxButton( panelTransform, wxID_ANY, wxT("ButtonTransY"), wxDefaultPosition, wxSize(150, 20), 0 ); + buttonTranslateZ = new wxButton( panelTransform, wxID_ANY, wxT("ButtonTransZ"), wxDefaultPosition, wxSize(150, 20), 0 ); + transformStaticText = new wxStaticText( this, wxID_ANY, wxT("Transform "), wxDefaultPosition, wxDefaultSize, 0 ); + controlPointStaticText = new wxStaticText( panelTransform, wxID_ANY, wxT("Control Point:"), wxDefaultPosition, wxDefaultSize, 0 ); + toggleButtonTransform->Connect( wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonClickTransform ), NULL, this ); + Connect(wxEVT_PAINT, wxPaintEventHandler(Transform::paintEventEditMode)); + +} + +Transform::Transform(wxWindow* parent, wxWindowID id): wxScrolledWindow(parent, id) + +{ + //Criando todos os componentes + toggleButtonTransform = new wxToggleButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(13, 13), wxBU_NOTEXT); + toggleButton3dCursor = new wxToggleButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(13, 13), wxBU_NOTEXT); + toggleButtonItem = new wxToggleButton( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(13, 13), wxBU_NOTEXT); + panelTransform = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + panel3dCursor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + panelItem = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + + this->SetBackgroundColour(wxColour(150, 150, 150)); + panelTransform->SetBackgroundColour(wxColour(150, 150, 150)); + panel3dCursor->SetBackgroundColour(wxColour(150, 150, 150)); + panelItem->SetBackgroundColour(wxColour(150, 150, 150)); + + //Cria os botoes de translacao... + buttonTranslateX = new wxButton( panelTransform, wxID_ANY, wxT("ButtonTransX"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonTranslateY = new wxButton( panelTransform, wxID_ANY, wxT("ButtonTransY"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonTranslateZ = new wxButton( panelTransform, wxID_ANY, wxT("ButtonTransZ"), wxDefaultPosition, wxSize(150, 25), 0 ); + + buttonTranslateX->SetBackgroundColour(wxColour(150, 150, 150)); + //panelTransform->SetBorder(45); + + buttonRotateX = new wxButton( panelTransform, wxID_ANY, wxT("ButtonRatateX"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonRotateY = new wxButton( panelTransform, wxID_ANY, wxT("ButtonRotateY"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonRotateZ = new wxButton( panelTransform, wxID_ANY, wxT("ButtonRotateZ"), wxDefaultPosition, wxSize(150, 25), 0 ); + + buttonScaleX = new wxButton( panelTransform, wxID_ANY, wxT("ButtonScaleX"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonScaleY = new wxButton( panelTransform, wxID_ANY, wxT("ButtonScaleY"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonScaleZ = new wxButton( panelTransform, wxID_ANY, wxT("ButtonScaleZ"), wxDefaultPosition, wxSize(150, 25), 0 ); + + buttonCursorX = new wxButton( panel3dCursor, wxID_ANY, wxT("CursorX"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonCursorY = new wxButton( panel3dCursor, wxID_ANY, wxT("CursorY"), wxDefaultPosition, wxSize(150, 25), 0 ); + buttonCursorZ = new wxButton( panel3dCursor, wxID_ANY, wxT("CursorZ"), wxDefaultPosition, wxSize(150, 25), 0 ); + + transformStaticText = new wxStaticText( this, wxID_ANY, wxT("Transform "), wxDefaultPosition, wxDefaultSize, 0 ); + cursor3dStaticText = new wxStaticText( this, wxID_ANY, wxT("3D Cursor"), wxDefaultPosition, wxDefaultSize, 0 ); + itemStaticText = new wxStaticText( this, wxID_ANY, wxT("Item"), wxDefaultPosition, wxDefaultSize, 0 ); + translateStaticText = new wxStaticText( panelTransform, wxID_ANY, wxT("Translation:"), wxDefaultPosition, wxDefaultSize, 0 ); + rotateStaticText = new wxStaticText( panelTransform, wxID_ANY, wxT("Rotation:"), wxDefaultPosition, wxDefaultSize, 0 ); + scaletaticText = new wxStaticText( panelTransform, wxID_ANY, wxT("Scale:"), wxDefaultPosition, wxDefaultSize, 0 ); + pointCursor3dStaticText = new wxStaticText( panel3dCursor, wxID_ANY, wxT("Point:"), wxDefaultPosition, wxDefaultSize, 0 ); + itemTextCtrl = new wxTextCtrl( panelItem, wxID_ANY, wxString("Surface Nurbs"), wxDefaultPosition, wxSize(150, 25), 0 ); + + staticLineTansform = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxSize(200, 10), wxLI_HORIZONTAL ); + staticLineCursor = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxSize(200, 10), wxLI_HORIZONTAL ); + staticLineItem = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxSize(200, 10), wxLI_HORIZONTAL ); + + toggleButtonTransform->Connect( wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonClickTransform ), NULL, this ); + toggleButton3dCursor->Connect( wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonClick3dCursor ), NULL, this ); + toggleButtonItem->Connect(wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonItem), NULL, this); + doLayoutObjectMode(); + +} +Transform::~Transform() +{ + toggleButtonItem->Disconnect(wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonItem), NULL, this); + toggleButtonTransform->Disconnect( wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonClickTransform ), NULL, this ); + toggleButton3dCursor->Disconnect( wxEVT_TOGGLEBUTTON, wxCommandEventHandler( Transform::OnButtonClick3dCursor ), NULL, this ); + +} +void Transform::doLayoutObjectMode() +{ + //Criacao dos sizers + principal = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *transformSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *cursorSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *itemSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *buttonTransformSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *button3dCursorSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *textItemSizer = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *lineTransformSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *lineCursor = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *lineItem = new wxBoxSizer(wxHORIZONTAL); + + //faz o layout + transformSizer->Add( toggleButtonTransform, 0, wxALL, 5 ); + transformSizer->Add( transformStaticText, 0, wxALL, 5 ); + + cursorSizer->Add(toggleButton3dCursor, 0, wxALL, 5); + cursorSizer->Add( cursor3dStaticText, 0, wxALL, 5 ); + + itemSizer->Add(toggleButtonItem, 0, wxALL, 5); + itemSizer->Add(itemStaticText, 0, wxALL, 5); + + lineTransformSizer->Add(staticLineTansform, 0, wxALL, 0 ); + lineCursor->Add(staticLineCursor, 0, wxALL, 0 ); + lineItem->Add(staticLineItem, 0, wxALL, 0 ); + + //---Tudo do transform------------------------------------------------------ + buttonTransformSizer->Add(translateStaticText, 0, wxALL, 5); + buttonTransformSizer->Add(buttonTranslateX, 0, wxALL, -2); + buttonTransformSizer->Add(buttonTranslateY, 0, wxALL, -2); + buttonTransformSizer->Add(buttonTranslateZ, 0, wxALL, -2); + + buttonTransformSizer->AddSpacer (10); + + buttonTransformSizer->Add(rotateStaticText, 0, wxALL, 5); + buttonTransformSizer->Add(buttonRotateX, 0, wxALL, -2); + buttonTransformSizer->Add(buttonRotateY, 0, wxALL, -2); + buttonTransformSizer->Add(buttonRotateZ, 0, wxALL, -2); + + buttonTransformSizer->AddSpacer (10); + + buttonTransformSizer->Add(scaletaticText, 0, wxALL, 5); + buttonTransformSizer->Add(buttonScaleX, 0, wxALL, -2); + buttonTransformSizer->Add(buttonScaleY, 0, wxALL, -2); + buttonTransformSizer->Add(buttonScaleZ, 0, wxALL, -2); + + panelTransform->SetSizer(buttonTransformSizer); + panelTransform->Layout(); + buttonTransformSizer->Fit(panelTransform); + + //------------Cursor-------------------------------------------------------// + + button3dCursorSizer->Add(pointCursor3dStaticText, 0, wxALL, 5); + button3dCursorSizer->Add(buttonCursorX, 0, wxALL, -2); + button3dCursorSizer->Add(buttonCursorY, 0, wxALL, -2); + button3dCursorSizer->Add(buttonCursorZ, 0, wxALL, -2); + + panel3dCursor->SetSizer(button3dCursorSizer); + panel3dCursor->Layout(); + button3dCursorSizer->Fit(panel3dCursor); + + //----------Item------------------------------------------------------// + + textItemSizer->Add( itemTextCtrl, 0, wxALL, -2 ); + panelItem->SetSizer(textItemSizer); + panelItem->Layout(); + textItemSizer->Fit(panelItem); + + principal->Add(transformSizer, 0, wxALL, 5); + principal->Add(panelTransform, 0, wxALL, 5); + principal->Add(lineTransformSizer, 0, wxALL, 5); + principal->Add(cursorSizer, 0, wxALL, 5); + principal->Add(panel3dCursor, 0, wxALL, 5); + principal->Add(lineCursor, 0, wxALL, 5); + principal->Add(itemSizer, 0, wxALL, 5); + principal->Add(panelItem, 0, wxALL, 5); + principal->Add(lineItem, 0, wxALL, 5); + + this->SetSizer(principal); + this->Layout(); + principal->Fit(this); + this->FitInside(); // ask the sizer about the needed size + this->SetScrollRate(5, 5); +} + +void Transform::doLayoutEditMode() +{ + wxBoxSizer *principal = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *transformSizer = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *buttonTransformSizer = new wxBoxSizer(wxVERTICAL); + + //faz o layout + transformSizer->Add( toggleButtonTransform, 0, wxALL, 5 ); + transformSizer->Add( transformStaticText, 0, wxALL, 5 ); + + transformSizer->AddSpacer (2); + + buttonTransformSizer->Add( controlPointStaticText , 0, wxALL, 5); + buttonTransformSizer->Add(buttonTranslateX, 0, wxALL, -2); + buttonTransformSizer->Add(buttonTranslateY, 0, wxALL, -2); + buttonTransformSizer->Add(buttonTranslateZ, 0, wxALL, -2); + + panelTransform->SetSizer(buttonTransformSizer); + panelTransform->Layout(); + buttonTransformSizer->Fit(panelTransform); + + principal->Add(transformSizer, 0, wxALL, 5); + principal->Add(panelTransform, 0, wxALL, 5); + + this->SetSizer(principal); + this->Layout(); + principal->Fit(this); +} + +void Transform::doLayoutHideItems() +{ + wxBoxSizer *principal = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *transformSizer = new wxBoxSizer(wxHORIZONTAL); + transformSizer->Add( toggleButtonTransform, 0, wxALL, 5 ); + transformSizer->Add( transformStaticText, 0, wxALL, 5 ); + principal->Add(transformSizer, 0, wxALL, 5); + this->SetSizer(principal); + this->Layout(); + principal->Fit(this); +} + +void Transform::OnButtonClickTransform( wxCommandEvent& event ) +{ + toggleButtonTransform->GetValue() == true ? panelTransform->Hide() : panelTransform->Show(); + + /*setTranslationLabel(12, 3, 4); + setRotationLabel(45, 39, 23); + setScaleLabel(33, 2, 4); + setCursorLabel(3, 4, 5); + setItemLabel(std::string("Curve BSplines")); + */ + principal->Layout(); + //this->Update(); +} + +void Transform::OnButtonClick3dCursor( wxCommandEvent& event ) +{ + toggleButton3dCursor->GetValue() == true ? panel3dCursor->Hide() : panel3dCursor->Show(); + principal->Layout(); +} +void Transform::OnButtonItem( wxCommandEvent& event ) +{ + toggleButtonItem->GetValue() == true ? panelItem->Hide() : panelItem->Show(); + principal->Layout(); +} + +void Transform::paintEventObjectMode(wxPaintEvent & evt) +{ + wxPaintDC dc(this); + //renderObjectMode(dc); +} +void Transform::renderObjectMode(wxDC& dc) +{ + // +} + +void Transform::paintEventEditMode(wxPaintEvent & evt) +{ + wxPaintDC dc(this); + //renderEditMode(dc); +} + +void Transform::renderEditMode(wxDC& dc) +{ + // +} + +void Transform::setTranslationLabel(float x, float y, float z) +{ + buttonTranslateX->SetLabel(wxString::Format(wxT("X: %5f"), x)); + buttonTranslateY->SetLabel(wxString::Format(wxT("Y: %5f"), y)); + buttonTranslateZ->SetLabel(wxString::Format(wxT("Z: %5f"), z)); +} + +void Transform::setRotationLabel(float x, float y, float z) +{ + buttonRotateX->SetLabel(wxString::Format(wxT("X: %5f"), x)); + buttonRotateY->SetLabel(wxString::Format(wxT("Y: %5f"), y)); + buttonRotateZ->SetLabel(wxString::Format(wxT("Z: %5f"), z)); + +} + +void Transform::setScaleLabel(float x, float y, float z) +{ + buttonScaleX->SetLabel(wxString::Format(wxT("X: %5f"), x)); + buttonScaleY->SetLabel(wxString::Format(wxT("Y: %5f"), y)); + buttonScaleZ->SetLabel(wxString::Format(wxT("Z: %5f"), z)); +} + +void Transform::setCursorLabel(float x, float y, float z) +{ + buttonCursorX->SetLabel(wxString::Format(wxT("X: %5f"), x)); + buttonCursorY->SetLabel(wxString::Format(wxT("Y: %5f"), y)); + buttonCursorZ->SetLabel(wxString::Format(wxT("Z: %5f"), z)); +} +void Transform::setItemLabel(std::string str) +{ + wxString s(str); + itemTextCtrl->ChangeValue(str); +} diff --git a/Prototipo-1/DOT_CPP/customTreeCtrl.cpp b/Prototipo-1/DOT_CPP/customTreeCtrl.cpp new file mode 100644 index 0000000..c25e57a --- /dev/null +++ b/Prototipo-1/DOT_CPP/customTreeCtrl.cpp @@ -0,0 +1,16 @@ +#include "customTreeCtrl.h" + +CustomTreeCtrl::CustomTreeCtrl(wxWindow* parent):wxTreeCtrl(parent, wxID_ANY, wxDefaultPosition, + wxSize(200, 200), wxTR_DEFAULT_STYLE|wxTR_ROW_LINES|wxTR_MULTIPLE) +{ + this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CustomTreeCtrl::OnLeftButtonClick ) ); +} +CustomTreeCtrl::~CustomTreeCtrl() +{ + this->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CustomTreeCtrl::OnLeftButtonClick ) ); +} + +void CustomTreeCtrl::OnLeftButtonClick( wxMouseEvent& event ) +{ + GetParent()->GetEventHandler()->ProcessEvent(event); +} \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/froms.cpp b/Prototipo-1/DOT_CPP/froms.cpp new file mode 100644 index 0000000..963b1df --- /dev/null +++ b/Prototipo-1/DOT_CPP/froms.cpp @@ -0,0 +1,148 @@ +/* +Julho de 2015 +*/ +#include "forms.h" +#include + +Forms::Forms(){} +Forms::~Forms(){} + +vector< vector > Forms::getCircle(float cx, float cy, float r, int num_segments) +{ + vector< vector > circle; + vector p0(3, 0), p1(3, 0), p2(3, 0), p3(3, 0), p4(3, 0), p5(3, 0), p6(3, 0), p7(3, 0), p8(3, 0); + p0[0] = 0; p0[1] = -10; p0[2] = 0.0f; + p1[0] = -10; p1[1] = -10; p1[2] = 0.0f; + p2[0] = -10; p2[1] = 0; p2[2] = 0.0f; + p3[0] = -10; p3[1] = 10; p3[2] = 0.0f; + p4[0] = 0; p4[1] = 10; p4[2] = 0.f; + p5[0] = 10; p5[1] = 10; p5[2] = 0.f; + p6[0] = 10; p6[1] = 0; p6[2] = 0.f; + p7[0] = 10; p7[1] = -10; p7[2] = 0.f; + p8[0] = 0; p8[1] = -10; p8[2] = 0.f; + + circle.push_back(p0); + + circle.push_back(p1); + + circle.push_back(p2); + + circle.push_back(p3); + + circle.push_back(p4); + + circle.push_back(p5); + + circle.push_back(p6); + + circle.push_back(p7); + + circle.push_back(p8); + + + /*for(int ii = 0; ii <= num_segments; ii++) + { + vector point(3, 0); + + float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle + point[0] = r * cosf(theta);//calculate the x component + point[1] = r * sinf(theta);//calculate the y component + circle.push_back(point); + } + */ + return circle; +} + + +vector< vector > Forms::getElipse() +{ + vector< vector > elipse; + vector p0(3, 0), p1(3, 0), p2(3, 0), p3(3, 0), p4(3, 0), p5(3, 0), p6(3, 0), p7(3, 0), p8(3, 0); + p0[0] = -7.5; p0[1] = 7.5; p0[2] = 0.0f; + p1[0] = 0; p1[1] = 15; p1[2] = 0.0f; + p2[0] = 7.5; p2[1] = 7.5; p2[2] = 0.0f; + p3[0] = 15; p3[1] = 0; p3[2] = 0.0f; + p4[0] = 7.5; p4[1] = -7.5; p4[2] = 0.f; + p5[0] = 0; p5[1] = -15; p5[2] = 0.f; + p6[0] = -7.5; p6[1] = -7.5; p6[2] = 0.f; + p7[0] = -15; p7[1] = 0; p7[2] = 0.f; + p8[0] = -7.5; p8[1] = 7.5; p8[2] = 0.f; + + elipse.push_back(p0); + + elipse.push_back(p1); + + elipse.push_back(p2); + + elipse.push_back(p3); + + elipse.push_back(p4); + + elipse.push_back(p5); + + elipse.push_back(p6); + + elipse.push_back(p7); + + elipse.push_back(p8); + + + /*for(int ii = 0; ii <= num_segments; ii++) + { + vector point(3, 0); + + float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle + point[0] = r * cosf(theta);//calculate the x component + point[1] = r * sinf(theta);//calculate the y component + circle.push_back(point); + } + */ + return elipse; +} + + +vector< vector > Forms::getRecatangle() +{ + vector< vector > rectangle; + vector p0(3, 0), p1(3, 0), p2(3, 0), p3(3, 0), p4(3, 0), p5(3, 0), p6(3, 0), p7(3, 0), p8(3, 0); + p0[0] = 0; p0[1] = -10; p0[2] = 0.0f; + p1[0] = -10; p1[1] = -10; p1[2] = 0.0f; + p2[0] = -10; p2[1] = 0; p2[2] = 0.0f; + p3[0] = -10; p3[1] = 10; p3[2] = 0.0f; + p4[0] = 0; p4[1] = 10; p4[2] = 0.f; + p5[0] = 10; p5[1] = 10; p5[2] = 0.f; + p6[0] = 10; p6[1] = 0; p6[2] = 0.f; + p7[0] = 10; p7[1] = -10; p7[2] = 0.f; + p8[0] = 0; p8[1] = -10; p8[2] = 0.f; + + rectangle.push_back(p0); + + rectangle.push_back(p1); + + rectangle.push_back(p2); + + rectangle.push_back(p3); + + rectangle.push_back(p4); + + rectangle.push_back(p5); + + rectangle.push_back(p6); + + rectangle.push_back(p7); + + rectangle.push_back(p8); + + + /*for(int ii = 0; ii <= num_segments; ii++) + { + vector point(3, 0); + + float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle + point[0] = r * cosf(theta);//calculate the x component + point[1] = r * sinf(theta);//calculate the y component + circle.push_back(point); + } + */ + return rectangle; +} diff --git a/Prototipo-1/DOT_CPP/grid.cpp b/Prototipo-1/DOT_CPP/grid.cpp index f74f749..7b8fba1 100644 --- a/Prototipo-1/DOT_CPP/grid.cpp +++ b/Prototipo-1/DOT_CPP/grid.cpp @@ -8,11 +8,11 @@ Grid::Grid(vector obj):Object(obj) Grid::Grid():Object() { - + setTipo("Grid"); vector vertex; for (int i = 0; i < 170 ; i+=10){ - + vertex.push_back(Object::point3f(-80+i, 0, 100)); vertex.push_back(Object::point3f(-80+i, 0, -100)); } @@ -21,7 +21,7 @@ Grid::Grid():Object() vertex.push_back(Object::point3f( -80, 0, 100-i )); vertex.push_back(Object::point3f( 80, 0, 100-i )); } - + this->vertex = vertex; } @@ -29,7 +29,7 @@ Grid::Grid():Object() Grid::~Grid(){} -void Grid::draw(int index_load, bool is_selecting) +void Grid::draw(int index_load, bool is_selecting, int size_world) { @@ -41,7 +41,7 @@ void Grid::draw(int index_load, bool is_selecting) vector s = getScale(); glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); - glm::quat quaternion = quat ; + glm::quat quaternion = quat ; glm::mat4 mat = glm::toMat4(quaternion); int count = 0; @@ -49,12 +49,12 @@ void Grid::draw(int index_load, bool is_selecting) for (int j = 0; j < 4; ++j){ m[count] = mat[k][j]; count++; - } + } } glLoadName(index_load); // register object. glPushMatrix(); - glColor3f(c[0],c[1],c[2]); + //glColor3f(c[0],c[1],c[2]); glScalef(s[0], s[1], s[2]); glTranslatef(t[0],t[1],t[2]); glMultMatrixf(m); @@ -62,11 +62,18 @@ void Grid::draw(int index_load, bool is_selecting) vector < float * > vertex = getVertex(); for (int j = 0; j < (int) vertex.size(); ++j){ - + if(j == 16 || j == 17){ + glColor3f(1, 0, 0); + } + else if (j == 44 || j == 45){ + glColor3f(0, 1, 0); + } else { + glColor3f(c[0],c[1],c[2]); + } glVertex3fv(vertex[j]); } glEnd(); - + glPopMatrix(); } //glPopName(); diff --git a/Prototipo-1/DOT_CPP/main.cpp b/Prototipo-1/DOT_CPP/main.cpp index 8f30090..4888f7a 100644 --- a/Prototipo-1/DOT_CPP/main.cpp +++ b/Prototipo-1/DOT_CPP/main.cpp @@ -3,32 +3,33 @@ IMPLEMENT_APP(MyApp) - - + + bool MyApp::OnInit() { - wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); WidgetFrame *frame = new WidgetFrame(wxT("3D-STUDIO-FORMS")); - + /*wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0}; - + BasicGLPane *glPane = new BasicGLPane( (wxFrame*) frame, args); - /*sem isso os eventos de teclado nao funcionam*/ + //sem isso os eventos de teclado nao funcionam glPane->SetFocus (); - - /* passa o glPane para a frame, a frame pode trasmitir os eventos para BasicGLPane*/ + + // passa o glPane para a frame, a frame pode trasmitir os eventos para BasicGLPane frame->setBasicPlane(glPane); sizer->Add(glPane, 1, wxEXPAND); - + frame->SetSizer(sizer); frame->SetAutoLayout(true); - - frame->Show(); + */ + + frame->Show(true); return true; -} - +} + diff --git a/Prototipo-1/DOT_CPP/manager.cpp b/Prototipo-1/DOT_CPP/manager.cpp index 26196ac..ba64d77 100644 --- a/Prototipo-1/DOT_CPP/manager.cpp +++ b/Prototipo-1/DOT_CPP/manager.cpp @@ -1,4 +1,3 @@ -#include #include "BezierCurve.h" #include "bezierSurface.h" #include "nurbsSurface.h" @@ -7,7 +6,12 @@ #include "object.h" #include "grid.h" #include "cube.h" -#include +#include "modifier.h" +#include "forms.h" +#include // std::find + + +#include /*table of the events*/ /* tabela de eventos referente a canvas*/ @@ -32,27 +36,24 @@ EVT_PAINT(BasicGLPane::render) END_EVENT_TABLE() -//To Opengl -static float obsP[] = { -50, 100, 250, 0, 0, 0, 0, 1, 0 }; - -//To objects -vector world; -//vector obj_selected; -int last_object_selected = 0; -bool render_mode = true; -vector ROTATION(3, 0); -float SCALE = 1.0; - -/*Variaveis de rotacao do cenario*/ -int start_x, start_y, start_angle_x, start_angle_y, angle_x = 0, angle_y = 0; - -BasicGLPane::BasicGLPane(wxFrame* parent, int* args) : +BasicGLPane::BasicGLPane(wxWindow* parent, int* args) : wxGLCanvas(parent, wxID_ANY, args, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) { - //Render::viewport3D(0,0, getWidth(), getHeight(), obsP); + + LAST_EVENT = 0; + POINTER_BACKUP = 0; + RENDER_MODE = true; + MODIFIER_TYPE = 1; + SCALE = 1.0; + ROTATION = vector (3, 0); + CURSOR_POSITION = vector (3, 0); + LAST_MOUSE_POSITION_DRAGG = vector (3, 0); + LAST_OBJECT_SELECTED = 0; + LAST_CLICK_OBJECT = 0; + ANGLE_X = 45; + ANGLE_Y = 45; + LIST_INDEX_OBJECT.push_back(0); m_context = new wxGLContext(this); - //No construtor na funcionou - //Render::viewport3D(0,0, getWidth(), getHeight(), obsP); // To avoid flashing on MSW @@ -60,56 +61,13 @@ BasicGLPane::BasicGLPane(wxFrame* parent, int* args) : char* argv[1] = { wxString((wxTheApp->argv)[0]).char_str() }; glutInit(&argc, argv); - vector vertex; - vector vertex2; - - float c[] = {0, 0, 1} ; - float r[] = {0, 45, 0}; - float s[] = {20.5, 20.5, 20.5}; - float t[] = {-80.0, 4.0, 0.0}; - float t2[] = {80.0, 4.0, 0.0}; - vector rotate (r, r + sizeof(r) / sizeof(float)); - vector color (c, c + sizeof(c) / sizeof(float) ); - vector scale (s, s + sizeof(s) / sizeof(float) ); - vector trans (t, t + sizeof(t) / sizeof(float) ); - vector trans2 (t2, t2 + sizeof(t2) / sizeof(float) ); - Object *grid = new Grid[1]; - Object *cube = new Cube[1]; - Object *cube2 = new Cube[1]; - Object *cube3 = new Cube[1]; - - cube2->translateObject(trans); - cube2->scaleObject(scale); - cube2->setColor(color); - cube->scaleObject(scale); - cube3->scaleObject(scale); - cube3->translateObject(trans2); - //grid->setColor(color); - - Object *bezier = new BezierCurve(0,0,0); - Object *bezier2 = new BezierCurve(-50,0,0); - Object *bspline = new BSplines(0,50,0); - Object *surfaceBezier = new SurfaceBezier() ; - Object *surfaceNurbs = new SurfaceNurbs() ; - surfaceNurbs->translateObject(trans); - surfaceBezier->translateObject(trans2); - - - - - world.push_back(grid); - world.push_back(bezier); - //world.push_back(bezier2); - //world.push_back(bspline); - world.push_back(surfaceBezier); - world.push_back(surfaceNurbs); - - //world.push_back(cube); - //world.push_back(cube2); - //world.push_back(cube3); - + WORLD.push_back(grid); + ROTATION[0] = 45; + ROTATION[1] = 45; + BACKUP.push_back(WORLD); + LIST_INDEX_OBJECT_STATES.push_back(LIST_INDEX_OBJECT); SetBackgroundStyle(wxBG_STYLE_CUSTOM); } @@ -133,12 +91,14 @@ void BasicGLPane::mouseMiddleDown(wxMouseEvent& event) cout << "Botao do meio para baixo" << endl; //quando o botao do mouse abaixa seta as variaveis para a logica da rotacao// - start_angle_x = angle_x; - start_angle_y = angle_y; + START_ANGLE_X = ANGLE_X; + START_ANGLE_Y = ANGLE_Y; - start_x = event.GetX(); - start_y = event.GetY(); + START_X = event.GetX(); + START_Y = event.GetY(); //------------------------------------------------------------------------// + + } @@ -155,112 +115,229 @@ void BasicGLPane::mouseMoved(wxMouseEvent& event ) int x = 0, y = 0; // Cordenadas do Mouse no Mundo - vector worldC; + vector worldC(3, 0); + vector worldC2(3, 0); // Nome do Objeto Selecionado string name; if(event.Dragging() && event.LeftIsDown()){ - // Convertendo Coordenadas do mouse em coordenadas no Mundo x = event.GetX(); y = event.GetY(); worldC = Render::worldPoint(x,y); - - if(render_mode){ - - name = world[last_object_selected]->getTipo(); - - if(name == "BSplines" || name == "Nurbs" || name == "BezierCurve"){ - - world[last_object_selected]->translateObject(worldC); - } - + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + cout << "LAST_CLICK_OBJECT: " << LAST_CLICK_OBJECT << "---" << "LAST_OBJECT_SELECTED: " << LAST_OBJECT_SELECTED << endl; + + /*Modo objeto */ + if(RENDER_MODE){ + + //if(name == "BSplines" || name == "Nurbs" || name == "BezierCurve" || "bezierSurface" || "nurbsSurface"){ + if (LAST_OBJECT_SELECTED && LAST_OBJECT_SELECTED == (int)LAST_CLICK_OBJECT){ + + vector object_position = WORLD[LAST_OBJECT_SELECTED]->getTranslation(); + worldC2[0] = object_position[0] + worldC[0] - LAST_MOUSE_POSITION_DRAGG[0]; + worldC2[1] = object_position[1] + worldC[1] - LAST_MOUSE_POSITION_DRAGG[1]; + worldC2[2] = object_position[2] + worldC[2] - LAST_MOUSE_POSITION_DRAGG[2]; + LAST_MOUSE_POSITION_DRAGG = worldC; + WORLD[LAST_OBJECT_SELECTED]->translateObject(worldC2); + LAST_EVENT = 1; + } + + /* Se o Modificador de translacao estiver setado para a transalacao. */ + else if (LAST_CLICK_OBJECT >= WORLD.size() && MODIFIER_TYPE == 1){ + vector object_position = WORLD[LAST_OBJECT_SELECTED]->getTranslation(); + worldC2 = object_position; + switch(1 + LAST_CLICK_OBJECT - WORLD.size()){ + case 1: + worldC2[0] = (object_position[0] + worldC[0] - LAST_MOUSE_POSITION_DRAGG[0]); + break; + + case 2: + worldC2[1] = object_position[1] + worldC[1] - LAST_MOUSE_POSITION_DRAGG[1]; + break; + + case 3: + worldC2[2] = object_position[2] + worldC[2] - LAST_MOUSE_POSITION_DRAGG[2]; + break; + + } + LAST_MOUSE_POSITION_DRAGG = worldC; + WORLD[LAST_OBJECT_SELECTED]->translateObject(worldC2); + LAST_EVENT = 1; + } + else if (LAST_CLICK_OBJECT >= WORLD.size() && MODIFIER_TYPE == 2){ + vector rotation = WORLD[LAST_OBJECT_SELECTED]->getRotation(); + worldC2 = rotation; + switch(1 + LAST_CLICK_OBJECT - WORLD.size()){ + case 1: + worldC2[1] = rotation[1] + (worldC[0] - LAST_MOUSE_POSITION_DRAGG[0])*10; + break; + + case 2: + worldC2[0] = rotation[0] + (worldC[1] - LAST_MOUSE_POSITION_DRAGG[1])*10; + break; + + case 3: + worldC2[2] = rotation[2] + (worldC[2] - LAST_MOUSE_POSITION_DRAGG[2])*10; + break; + + } + LAST_MOUSE_POSITION_DRAGG = worldC; + WORLD[LAST_OBJECT_SELECTED]->rotateObject(worldC2); + LAST_EVENT = 1; + } + + /* Se o Modificador de Escala estiver setado deve proceder da seguinte forma abaixo... */ + if (LAST_CLICK_OBJECT >= WORLD.size() && MODIFIER_TYPE == 3){ + vector object_scale = WORLD[LAST_OBJECT_SELECTED]->getScale(); + worldC2 = object_scale; + switch(1 + LAST_CLICK_OBJECT - WORLD.size()){ + + case 1: + worldC2[0] = object_scale[0] + (worldC[0] - LAST_MOUSE_POSITION_DRAGG[0])/5; + break; + + case 2: + worldC2[1] = object_scale[1] + (worldC[1] - LAST_MOUSE_POSITION_DRAGG[1])/5; + break; + + case 3: + worldC2[2] = object_scale[2] + (worldC[2] - LAST_MOUSE_POSITION_DRAGG[2])/5; + break; + + } + LAST_MOUSE_POSITION_DRAGG = worldC; + WORLD[LAST_OBJECT_SELECTED]->scaleObject(worldC2[0], worldC2[1], worldC2[2]); + LAST_EVENT = 1; + } + //} + + /*Modo edicao...*/ } else { - name = world[last_object_selected]->getTipo(); - if(name == "BSplines" || name == "Nurbs" || name == "BezierCurve"){ - - world[last_object_selected]->setPtControle(worldC[0],worldC[1],worldC[2]); + if (LAST_OBJECT_SELECTED && (int)LAST_CLICK_OBJECT == WORLD[LAST_OBJECT_SELECTED]->getHitIndexInternal()){ + WORLD[LAST_OBJECT_SELECTED]->setPtControle(worldC[0],worldC[1],worldC[2]); + LAST_EVENT = 1; + } + else if ((int)LAST_CLICK_OBJECT > WORLD[LAST_OBJECT_SELECTED]->getSizeControlPoints()){ + vector selectedPoint = WORLD[LAST_OBJECT_SELECTED]->getControlPointSelected(); + worldC2 = selectedPoint; + cout << "selectedPoint: " <<"X: " <getSizeControlPoints()){ + + case 1: + worldC2[0] = (selectedPoint[0] + worldC[0] - LAST_MOUSE_POSITION_DRAGG[0]); + break; + + case 2: + worldC2[1] = (selectedPoint[1] + worldC[1] - LAST_MOUSE_POSITION_DRAGG[1]); + + break; + + case 3: + worldC2[2] = (selectedPoint[2] + worldC[2] - LAST_MOUSE_POSITION_DRAGG[2]); + break; + } + LAST_MOUSE_POSITION_DRAGG = worldC; + WORLD[LAST_OBJECT_SELECTED]->setPtControleModifier(worldC2[0], worldC2[1], worldC2[2]); + LAST_EVENT = 1; } } displayScene(); + GetParent()->GetEventHandler()->ProcessEvent(event); } - - //displayScene(); if(event.Dragging() && event.MiddleIsDown()){ + //Rotaca geral do cenario + ANGLE_X = START_ANGLE_X + (event.GetX() - START_X); + ANGLE_Y = START_ANGLE_Y + (event.GetY() - START_Y); + ROTATION[0] = ANGLE_Y; + ROTATION[1] = ANGLE_X; - //cout << "R_X: " << rotation_x << ", " << "R_Y: " << rotation_y << endl; - angle_x = start_angle_x + (event.GetX() - start_x); - angle_y = start_angle_y + (event.GetY() - start_y); - ROTATION[0] = angle_y; - ROTATION[1] = angle_x; displayScene(); - + GetParent()->GetEventHandler()->ProcessEvent(event); } } void BasicGLPane::mouseDown(wxMouseEvent& event) { - //criar aqui o evento do cursor + cout << "X: " << event.GetX() << endl; + vector proj; + proj.push_back(45.0); proj.push_back((float)getWidth()/(float)getHeight()); + proj.push_back(0.1); proj.push_back(400); + + //pegando o objeto que atingido pelo ultimo clique do botao esquerdo... + cout << "Mouse down event..." << endl; + LAST_CLICK_OBJECT = Render::selectNearObject(WORLD, proj, event.GetX(), event.GetY(), RENDER_MODE, ROTATION, SCALE); + + //PEGA A ULTIMA POSICAO CLICADA COM O BOTAO ESQUERDO PARA USA NO DRAGG---// + LAST_MOUSE_POSITION_DRAGG = Render::worldPoint(event.GetX(),event.GetY()); + CURSOR_POSITION = LAST_MOUSE_POSITION_DRAGG; + GetParent()->GetEventHandler()->ProcessEvent(event); } void BasicGLPane::mouseWheelMoved(wxMouseEvent& event) { - + //Escala geral do cenario event.GetWheelRotation() > 0 ? SCALE+=0.0625 : SCALE-=0.0625; if(SCALE == 0){ SCALE = 0.0625; } - if (SCALE >= 1.0){ - SCALE = 1.0; - } - cout << "SCALE---" << SCALE << endl; displayScene(); } void BasicGLPane::mouseReleased(wxMouseEvent& event) { + cout << "mouseReleased" << endl; + switch(LAST_EVENT){ + + case 1: + cout << "Adicionando novo estado....." << endl; + addNewState(); + break; + } + + LAST_EVENT = 0; } void BasicGLPane::rightClick(wxMouseEvent& event) { - //simulando a criacao de objetos - //vector pointWorld = Render::worldPoint(event.GetX(), event.GetY()); - //cout << "X: " << pointWorld[0] << "Y: " << pointWorld[1] << "Z: " << pointWorld[2] << endl; - //world[1].translateObject(pointWorld); vector proj; proj.push_back(45.0); proj.push_back((float)getWidth()/(float)getHeight()); proj.push_back(0.1); proj.push_back(400); - unsigned int obj_selected = Render::render(world, proj, event.GetX(), event.GetY(), render_mode, ROTATION, SCALE); - //int obj_sel = getMinDepth(obj_selected, world) ; - cout << "Objeto selecionado: " << obj_selected << endl; - //modificando o estado do objeto selecionado - if(!render_mode && obj_selected){ - cout << "Modo edicao selecionando um ponto....." << endl; - world[last_object_selected]->setHitIndexInternal((int)obj_selected); + unsigned int obj_selected = Render::selectNearObject(WORLD, proj, event.GetX(), event.GetY(), RENDER_MODE, ROTATION, SCALE); + cout << "Ponto retornando pela selecao: " << obj_selected << endl; + //Modo ediciao + if(!RENDER_MODE && obj_selected){ + cout << "Dentro da condicao testada..." << endl; + if ( (int)obj_selected <= WORLD[LAST_OBJECT_SELECTED]->getSizeControlPoints() ){ + cout << "Modo edicao selecionando um ponto....." << ", " << WORLD[LAST_OBJECT_SELECTED]->getSizeControlPoints()<setHitIndexInternal((int)obj_selected); + LAST_CLICK_OBJECT = (int)obj_selected; + } + //Modo objeto } else { - if(obj_selected){ - cout << "Modo objeto selecionando um objeto...." << endl; - world[last_object_selected]->setSelected(false); - last_object_selected = (int)obj_selected; - world[(int)obj_selected]->setSelected(true); - + if(obj_selected && obj_selected < WORLD.size()){ + WORLD[LAST_OBJECT_SELECTED]->setSelected(false); + LAST_OBJECT_SELECTED = (int)obj_selected; + WORLD[(int)obj_selected]->setSelected(true); + //cout << "Antes de morrer...." << endl; } } - cout << "Ultimo objeto selecionado: " << last_object_selected << endl; + cout << "Ultimo objeto selecionado: " << LAST_OBJECT_SELECTED << endl; displayScene(); + GetParent()->GetEventHandler()->ProcessEvent(event); } void BasicGLPane::mouseLeftWindow(wxMouseEvent& event) @@ -281,10 +358,10 @@ void BasicGLPane::keyPressed(wxKeyEvent& event) if ( uc == WXK_TAB){ //modo edicao e objeto.... cout << "Evento de tab..." << endl; - if(world.size() > 1 && last_object_selected){ + if(WORLD.size() > 1 && LAST_OBJECT_SELECTED){ cout << "Mudando o modo de renderezicao..." << endl; - render_mode = !render_mode; - //world[last_object_selected]->setRenderMode(render_mode); + RENDER_MODE = !RENDER_MODE; + //world[LAST_OBJECT_SELECTED]->setRenderMode(RENDER_MODE); } } @@ -296,6 +373,7 @@ void BasicGLPane::keyPressed(wxKeyEvent& event) cout << "Evento de A..." << endl; } } + GetParent()->GetEventHandler()->ProcessEvent(event); displayScene(); } void BasicGLPane::keyReleased(wxKeyEvent& event) @@ -345,7 +423,6 @@ void BasicGLPane::render( wxPaintEvent& evt ) } - void BasicGLPane::displayScene() { @@ -356,12 +433,471 @@ void BasicGLPane::displayScene() wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint outside the paint event //toda as vezes tem que definir a projecao...... - Render::viewport3D(0,0, getWidth(), getHeight(), obsP); + Render::viewport3D(0,0, getWidth(), getHeight()); //glScalef(100, 100, 100); - Render::renderObjects(world, render_mode, false, ROTATION, SCALE); + Render::renderObjects(WORLD, RENDER_MODE, false, ROTATION, SCALE); glFlush(); SwapBuffers(); +} + + +//////////////////Metdos para conversar com objetos externos//////////////////// +std::string BasicGLPane::createBezierSurface (int symbolicIndex, int u, int v, int ru, int rv) +{ + vector cursor = getCursorPosition(); + Object *surfaceBezier = new SurfaceBezier(u, v, ru, rv) ; + surfaceBezier->translateObject(cursor); + LIST_INDEX_OBJECT.push_back(symbolicIndex); + WORLD.push_back(surfaceBezier); + displayScene(); + addNewState(); + return surfaceBezier->getTipo(); +} + +std::string BasicGLPane::createSplineSurface (int symbolicIndex, int u, int v, int ru, int rv, int degree) +{ + vector cursor = getCursorPosition(); + Object *surfaceNurbs = new SurfaceNurbs(u, v, ru, rv, degree, 1) ; + surfaceNurbs->translateObject(cursor); + LIST_INDEX_OBJECT.push_back(symbolicIndex); + WORLD.push_back(surfaceNurbs); + displayScene(); + addNewState(); + return surfaceNurbs->getTipo(); +} + +std::string BasicGLPane::createNurbsSurface (int symbolicIndex, int u, int v, int ru, int rv, int degree) +{ + vector cursor = getCursorPosition(); + Object *surfaceNurbs = new SurfaceNurbs(u, v, ru, rv, degree, 2) ; + surfaceNurbs->translateObject(cursor); + LIST_INDEX_OBJECT.push_back(symbolicIndex); + WORLD.push_back(surfaceNurbs); + displayScene(); + addNewState(); + return surfaceNurbs->getTipo(); + +} + + +vector BasicGLPane::getCursorPosition() +{ + return CURSOR_POSITION; +} + +void BasicGLPane::setCursorPosition(int x, int y, int z) +{ + CURSOR_POSITION[0] = x; + CURSOR_POSITION[1] = y; + CURSOR_POSITION[2] = z; +} +void BasicGLPane::selectObject(int symbolicIndex) +{ + std::vector::iterator it = find (LIST_INDEX_OBJECT.begin(), LIST_INDEX_OBJECT.end(), symbolicIndex); + size_t offset = it - LIST_INDEX_OBJECT.begin(); + + if (offset < WORLD.size()) { + WORLD[LAST_OBJECT_SELECTED]->setSelected(false); + WORLD[offset]->setSelected(true); + LAST_OBJECT_SELECTED = offset; + } + //cout << "Tipossss: " << WORLD[idexObject]->getTipo() <<"Idex: " << idexObject <::iterator it = find (LIST_INDEX_OBJECT.begin(), LIST_INDEX_OBJECT.end(), symbolicIndex); + size_t offset = it - LIST_INDEX_OBJECT.begin(); + + WORLD.erase(WORLD.begin() + offset); + LIST_INDEX_OBJECT.erase(it); + LAST_OBJECT_SELECTED = 0; + if (WORLD.size() == 1){ + RENDER_MODE = true; + } + addNewState(); + displayScene(); + +} + +//Isso na e legal.... +vector BasicGLPane::getPositionLastObjectSelected() +{ + return WORLD[LAST_OBJECT_SELECTED]->getTranslation(); +} + +vector BasicGLPane::getRotationLastObjectSelected() +{ + return WORLD[LAST_OBJECT_SELECTED]->getRotation(); +} + +vector BasicGLPane::getScaleLastObjectSelected() +{ + return WORLD[LAST_OBJECT_SELECTED]->getScale(); +} + +std::string BasicGLPane::getTipoLastObjectSelected() +{ + return WORLD[LAST_OBJECT_SELECTED]->getTipo(); +} + +void BasicGLPane::newScene() +{ + WORLD.erase(WORLD.begin()+1, WORLD.begin() + WORLD.size()); + LIST_INDEX_OBJECT.erase(LIST_INDEX_OBJECT.begin()+1, LIST_INDEX_OBJECT.begin()+ + LIST_INDEX_OBJECT.size()); + BACKUP.clear(); + BACKUP.push_back(WORLD); + POINTER_BACKUP = 0; + setCursorPosition(0, 0, 0); + RENDER_MODE = true; + ROTATION[0] = 45; + ROTATION[1] = 45; + ANGLE_X = 45; + ANGLE_Y = 45; + displayScene(); +} + +std::string BasicGLPane::duplicateObject(int oldIndex, int newIndex) +{ + std::string strResult = ""; + std::vector::iterator it = find (LIST_INDEX_OBJECT.begin(), LIST_INDEX_OBJECT.end(), oldIndex); + size_t offset = it - LIST_INDEX_OBJECT.begin(); + + if (offset < WORLD.size()) { + strResult = WORLD[offset]->getTipo(); + LIST_INDEX_OBJECT.push_back(newIndex); + Object* object; + if (strResult.compare("BezierSurface") == 0){ + object = new SurfaceBezier( (SurfaceBezier * ) WORLD[offset] ); + }else if (strResult.compare("BSplineSurface") == 0){ + object = new SurfaceNurbs( (SurfaceNurbs * ) WORLD[offset] ); + }else if (strResult.compare("NurbsSurface") == 0){ + object = new SurfaceNurbs( (SurfaceNurbs * ) WORLD[offset] ); + }else if (strResult.compare("BezierCurve") == 0){ + object = new BezierCurve( (BezierCurve * ) WORLD[offset] ); + }else if (strResult.compare("BSplines") == 0){ + object = new BSplines( (BSplines * ) WORLD[offset] ); + }else if (strResult.compare("Nurbs") == 0){ + object = new Nurbs( (Nurbs * ) WORLD[offset] ); + } + WORLD.push_back(object); + WORLD[WORLD.size()-1]->translateObject(getCursorPosition()); + } + displayScene(); + return strResult; +} + +std::string BasicGLPane::InterpolateNurbs( int indexCurve1, int indexCurve2, int symbolicIndex) +{ + std::vector::iterator it = find (LIST_INDEX_OBJECT.begin(), LIST_INDEX_OBJECT.end(), indexCurve1); + size_t offset = it - LIST_INDEX_OBJECT.begin(); + + std::vector::iterator it1 = find (LIST_INDEX_OBJECT.begin(), LIST_INDEX_OBJECT.end(), indexCurve2); + size_t offset1 = it1 - LIST_INDEX_OBJECT.begin(); + + Nurbs *nurb= (Nurbs * ) WORLD[offset]; + Nurbs *nurb1= (Nurbs * ) WORLD[offset1]; + + vector< vector< float> > ptControle = nurb->getPtControle(); + vector< vector > ptControle1 = nurb1->getPtControle(); + vector t = nurb->getTranslation(); + vector t1 = nurb1->getTranslation(); + vector s = nurb->getScale(); + vector s1 = nurb1->getScale(); + vector pontos = nurb->getPtsCurva(); + vector pontos1 = nurb1->getPtsCurva(); + + vector > > cP(2,vector >((int)pontos.size()/3,vector (3,0))); + int c = 0; + for (int i = 0; i < 1; ++i){ + + for (int j = 0; j < (int)pontos.size()/3; j++){ + cP[i][j][0] = (pontos[c] * s[0]) + t[0]; + cP[i][j][1] = (pontos[c + 1] * s[1]) + t[1]; + cP[i][j][2] = (pontos[c + 2] * s[2]) + t[2]; + + cP[i+1][j][0] = (pontos1[c] * s1[0]) + t1[0]; + cP[i+1][j][1] = (pontos1[c + 1] * s1[1]) + t1[1]; + cP[i+1][j][2] = (pontos1[c + 2] * s1[2]) + t1[2]; + + c+=3; + } + } + vector cursor = getCursorPosition(); + Object *surfaceNurbs = new SurfaceNurbs(1, ((int)pontos.size()/3)-1, 20, 20, 3, 1, cP) ; + surfaceNurbs->translateObject(cursor); + LIST_INDEX_OBJECT.push_back(symbolicIndex); + WORLD.push_back(surfaceNurbs); + displayScene(); + return std::string(surfaceNurbs->getTipo()); +} + +void BasicGLPane::setGlobalRotation( float x, float y, float z) +{ + ROTATION[0] = x; + ROTATION[1] = y; + ROTATION[2] = z; + + ANGLE_X = y; + ANGLE_Y = x; + displayScene(); +} +vector < Object *> BasicGLPane::createTempPointer(vector < Object *> WORLD) +{ + vector WORLD_TEMP (WORLD.size()); + //vector WORLD; + for (int i = 0; i < (int)WORLD.size(); ++i){ + std::string strResult = WORLD[i]->getTipo(); + Object* object; + if (strResult.compare("BezierSurface") == 0){ + object = new SurfaceBezier( (SurfaceBezier * ) WORLD[i] ); + }else if (strResult.compare("BSplineSurface") == 0){ + object = new SurfaceNurbs( (SurfaceNurbs * ) WORLD[i] ); + }else if (strResult.compare("NurbsSurface") == 0){ + object = new SurfaceNurbs( (SurfaceNurbs * ) WORLD[i] ); + }else if (strResult.compare("BezierCurve") == 0){ + object = new BezierCurve( (BezierCurve * ) WORLD[i] ); + }else if (strResult.compare("BSplines") == 0){ + object = new BSplines( (BSplines * ) WORLD[i] ); + }else if (strResult.compare("Nurbs") == 0){ + object = new Nurbs( (Nurbs * ) WORLD[i] ); + }else if (strResult.compare("Grid") == 0){ + object = new Grid[1]; + } + WORLD_TEMP[i] = object; + } + cout << "Tam dentro do create: " << WORLD_TEMP.size() << endl; + return WORLD_TEMP; +} + +vector < int > BasicGLPane::createTempVector( vector oldVector) +{ + vector NEW_TEMP; + for (int i = 0; i < (int)oldVector.size(); ++i){ + NEW_TEMP.push_back(oldVector[i]); + } + return NEW_TEMP; +} + + +vector BasicGLPane::ctrZ() +{ + vector listObjectsName; + if (POINTER_BACKUP ){ + + cout << "Aqui no BACKUP: " << POINTER_BACKUP <<" SIZE: " << BACKUP.size() <<"size_world: "<< WORLD.size()<getTipo() + std::string(" ") + ss.str() ); + } + cout << "POINTER_BACKUP: " << POINTER_BACKUP << endl; + displayScene(); + return listObjectsName; +} + +vector BasicGLPane::ctrY() +{ + //POINTER_BACKUP += 1; + vector listObjectsName; + if (POINTER_BACKUP < (int) (BACKUP.size() - 1) ){ + POINTER_BACKUP += 1; + WORLD = createTempPointer(BACKUP[POINTER_BACKUP]); + LIST_INDEX_OBJECT = createTempVector(LIST_INDEX_OBJECT_STATES[POINTER_BACKUP]); + + } + + for (int i = 1; i < (int)WORLD.size(); ++i){ + std::ostringstream ss; + ss << LIST_INDEX_OBJECT[i]; + listObjectsName.push_back( WORLD[i]->getTipo() + std::string(" ") + ss.str()); + } + cout << "POINTER_BACKUP ctrY: " << POINTER_BACKUP << endl; + displayScene(); + return listObjectsName; +} + +void BasicGLPane::addNewState() +{ + vector WORLD_TEMP = createTempPointer(WORLD); + vector NEW_TEMP = createTempVector(LIST_INDEX_OBJECT); + //cout << "Topos: "<getTipo() << ", " << WORLD_TEMP[0]->getTipo() << endl; + BACKUP.push_back(WORLD_TEMP); + LIST_INDEX_OBJECT_STATES.push_back(NEW_TEMP); + + POINTER_BACKUP = BACKUP.size()-1; +} + +// Cria uma Curva +std::string BasicGLPane::createCurve(int tp, long symbolicIndex) +{ + vector cursor = getCursorPosition(); + Object *curve; + + if(tp == 0){ + curve = new BezierCurve(0,0,0); + } + if(tp == 1){ + curve = new BSplines(0,0,0); + } + if(tp == 2){ + curve = new Nurbs(0,0,0); + //curve = new Nurbs(Forms::getCircle(0, 0 , 10, 8)); + } + if(tp == 3){ + + vector nos(12, 0); + vector pesos(9, 1); + nos[3] = 0.25; nos[4] = 0.25; + nos[5] = 0.5; nos[6] = 0.5; + nos[7] = 0.75; nos[8] = 0.75; + nos[9] = 1.0; nos[10] = 1.0; nos[11] = 1.0; + + pesos[1] = 0.707106781; pesos[3] = 0.707106781; + pesos[5] = 0.707106781; pesos[7] = 0.707106781; + curve = new Nurbs(Forms::getCircle(0, 0 , 10, 8), nos, pesos); + //curve = new Nurbs(Forms::getCircle(0, 0 , 10, 10)); + } + if (tp == 4){ + + vector nos(13, 0); + vector pesos(9, 1); + + nos[3] = 0.25; nos[4] = 0.25; + nos[5] = 0.5; nos[6] = 0.5; + nos[7] = 0.75; nos[8] = 0.75; + nos[9] = 1.0; nos[10] = 1.0; nos[11] = 1.0; + + + pesos[1] = 100; pesos[3] = 100; + pesos[5] = 100; pesos[7] = 100; + + curve = new Nurbs(Forms::getRecatangle(), nos, pesos); + } + curve->translateObject(cursor); + WORLD.push_back(curve); + LIST_INDEX_OBJECT.push_back(symbolicIndex); + displayScene(); + addNewState(); + return curve->getTipo(); +} + +void BasicGLPane::setNodeCurve(int idNode,double inc) +{ + string name; + if(!RENDER_MODE){ + + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + + if(name == "BSplines" || name == "Nurbs"){ + WORLD[LAST_OBJECT_SELECTED]->setNoSelec(idNode); + WORLD[LAST_OBJECT_SELECTED]->incNo(inc); + } + } +} + +void BasicGLPane::setOrdCurve(int ord) +{ + string name; + if(!RENDER_MODE){ + + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + + if(name == "BSplines" || name == "Nurbs"){ + WORLD[LAST_OBJECT_SELECTED]->setOrdCurva(ord); + } + } +} + +void BasicGLPane::setQuantCurv(int quant) +{ + string name; + if(!RENDER_MODE){ + + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + + if(name == "BSplines" || name == "Nurbs"){ + WORLD[LAST_OBJECT_SELECTED]->setQuant(quant); + } + } +} + +void BasicGLPane::setPesoCurv(float val) +{ + string name; + if(!RENDER_MODE){ + + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + + if(name == "Nurbs"){ + WORLD[LAST_OBJECT_SELECTED]->setPeso(val); + } + } +} + +// EVENTOS PARA EDIÇÃO DE UMA CURVA +void BasicGLPane::addPtC() +{ + string name; + + if(!RENDER_MODE){ + + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + + if(name == "BSplines" || name == "Nurbs"){ + WORLD[LAST_OBJECT_SELECTED]->addPtControle(); + } + + if(name == "BezierCurve"){ + WORLD[LAST_OBJECT_SELECTED]->addSegment(); + } + } +} + +void BasicGLPane::rmvPtC() +{ + string name; + + if(!RENDER_MODE){ + + name = WORLD[LAST_OBJECT_SELECTED]->getTipo(); + + if(name == "BSplines" || name == "Nurbs"){ + WORLD[LAST_OBJECT_SELECTED]->rmvPtControle(); + } + + if(name == "BezierCurve"){ + WORLD[LAST_OBJECT_SELECTED]->removeSegment(); + } + } +} + +Object * BasicGLPane::getObject() +{ + return WORLD[LAST_OBJECT_SELECTED]; +} + +void BasicGLPane::setMod(int tp) +{ + int i; + + MODIFIER_TYPE = tp; + + for(i = 0; i < (int) WORLD.size(); i++){ + WORLD[i]->setModifier(tp); + } +} + +void BasicGLPane::update() +{ + displayScene(); } \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/modifier.cpp b/Prototipo-1/DOT_CPP/modifier.cpp new file mode 100644 index 0000000..65e15e4 --- /dev/null +++ b/Prototipo-1/DOT_CPP/modifier.cpp @@ -0,0 +1,248 @@ +#include "modifier.h" +#include +#include +#include +#include +#include +#include +using namespace std; + + +Modifier::Modifier(){} +Modifier::Modifier(float x, float y, float z) +{ + //vector v(3, 0); + globalScale = vector (3, 1); + globaRotation = vector (3, 0); + setPosition(x,y,z); + setModifierType(1); +} +Modifier::~Modifier(){} + +void Modifier::setModifierType(int modifierType) +{ + this->modifierType = modifierType; +} + +int Modifier::getModifierType() +{ + return this->modifierType; +} + +void Modifier::setGlobalScale( float x, float y, float z) +{ + + this->globalScale[0] = x; + this->globalScale[1] = y; + this->globalScale[2] = z; +} + +void Modifier::setGlobalRotation( float x, float y, float z) +{ + this->globaRotation[0] = x; + this->globaRotation[1] = y; + this->globaRotation[2] = z; +} + + +void drawCircle(float cx, float cy, float r, int num_segments) { + glBegin(GL_LINE_LOOP); + for (int ii = 0; ii < num_segments; ii++) { + float theta = 2.0f * PI * float(ii) / float(num_segments);//get the current angle + float x = r * cosf(theta);//calculate the x component + float y = r * sinf(theta);//calculate the y component + glVertex2f(x + cx, y + cy);//output vertex + } + glEnd(); +} + +void Modifier::drawModifierTranslation(int index_load) +{ + float size_axi = 10; + float cone_base = 0.8; + float cone_height = 3; + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glLineWidth(1.5); + + glPushMatrix(); + + //Eixo 1 + glLoadName(index_load+1); + glColor4f(GREEN); + glBegin(GL_LINES); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(size_axi, 0, 0); + glEnd(); + + glPushMatrix(); + glTranslatef(size_axi, 0, 0); + glRotatef(90, 0, 1, 0); + glutSolidCone(cone_base, cone_height,16,16); + glPopMatrix(); + + /*----------------------------------------------------------------------- */ + + //Eixo 2 + glLoadName(index_load+2); + glColor4f(BLUE); + glBegin(GL_LINES); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0, size_axi, 0); + glEnd(); + + glPushMatrix(); + glTranslatef(0, size_axi, 0); + glRotatef(-90, 1, 0, 0); + glutSolidCone(cone_base, cone_height, 16,16); + glPopMatrix(); + + /*----------------------------------------------------------------------- */ + + //Eixo 3 + glLoadName(index_load+3); + glColor4f(RED); + glBegin(GL_LINES); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0, 0.0, size_axi); + glEnd(); + + glPushMatrix(); + glTranslatef(0, 0, size_axi); + glRotatef(90, 0, 0, 1); + glutSolidCone(cone_base, cone_height ,16,16); + glPopMatrix(); + + /*------------------------------------------------------------------------*/ + glPopMatrix(); + glLineWidth(1.0); + +} + +void Modifier::drawModifierRotation(int index_load) +{ + float ray = 8; + float cx = 0.0; + float cy = 0.0; + int num_segments = 36; + + //Circulo 1 + glPushMatrix(); + glLoadName(index_load+1); + glColor4f(BLUE); + glRotatef(90, 1, 0, 0); + drawCircle(cx, cy, ray, num_segments); + glPopMatrix(); + + //Circulo 2 + glPushMatrix(); + glLoadName(index_load+2); + glColor4f(GREEN); + glRotatef(90, 0, 1, 0); + drawCircle(cx, cy, ray, num_segments); + glPopMatrix(); + + //Circulo 3 + glPushMatrix(); + glLoadName(index_load+3); + glColor4f(RED); + glRotatef(90, 0, 0, 1); + drawCircle(cx, cy, ray, num_segments); + glPopMatrix(); + /*------------------------------------------------------------------------*/ + glPopMatrix(); + +} +void Modifier::drawModifierScale(int index_load) +{ + float size_axi = 10; + float size_cube = 1.3; + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glLineWidth(1.5); + glPushMatrix(); + + //Eixo 1 + glLoadName(index_load+1); + glColor4f(GREEN); + glBegin(GL_LINES); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(size_axi, 0, 0); + glEnd(); + + glPushMatrix(); + glTranslatef(size_axi, 0, 0); + glRotatef(90, 0, 1, 0); + glutSolidCube(size_cube); + glPopMatrix(); + + /*----------------------------------------------------------------------- */ + + //Eixo 2 + glLoadName(index_load+2); + glColor4f(BLUE); + glBegin(GL_LINES); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0, size_axi, 0); + glEnd(); + + glPushMatrix(); + glTranslatef(0, size_axi, 0); + glRotatef(-90, 1, 0, 0); + glutSolidCube(size_cube); + glPopMatrix(); + + /*----------------------------------------------------------------------- */ + + //Eixo 3 + glLoadName(index_load+3); + glColor4f(RED); + glBegin(GL_LINES); + glVertex3f(0.0, 0.0, 0.0); + glVertex3f(0, 0.0, size_axi); + glEnd(); + + glPushMatrix(); + glTranslatef(0, 0, size_axi); + glRotatef(90, 0, 0, 1); + glutSolidCube(size_cube); + glPopMatrix(); + + /*------------------------------------------------------------------------*/ + + glPopMatrix(); + glLineWidth(1.0); +} +void Modifier::setPosition(float x, float y, float z) +{ + vector position(3, 0); + position[0] = x; position[1] = y; position[2] = z; + this->position = position; +} +vector Modifier::getPosition() +{ + return this->position; +} + +void Modifier::draw(int index_load, bool is_selecting) +{ + //switch(this->modifierType) + switch(this->modifierType) + { + //desenha o cursor de Translacao + case 1: + //cout << "Desenhando o modificador de translacao..." << endl; + drawModifierTranslation(index_load); + break; + + //desenha o cursor de Rotacao + case 2: + drawModifierRotation(index_load); + break; + + //desenha o cursor de Escala + case 3: + drawModifierScale(index_load); + break; + } +} \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/nurbsSurface.cpp b/Prototipo-1/DOT_CPP/nurbsSurface.cpp index e60cc03..391a13b 100644 --- a/Prototipo-1/DOT_CPP/nurbsSurface.cpp +++ b/Prototipo-1/DOT_CPP/nurbsSurface.cpp @@ -1,5 +1,4 @@ #include "nurbsSurface.h" -#include #include #include #include @@ -7,24 +6,152 @@ #include #include +using namespace std; +SurfaceNurbs::SurfaceNurbs(SurfaceNurbs *surface):Object() +{ + + this->translation = surface->translation; + this->rotation = surface->rotation; + this->scale = surface->scale; + modifier = Modifier(translation[0], translation[1], translation[2]); + + this->NI = surface->NI; //dimensao na direcao de u + this->NJ = surface->NJ; // dimensao na direcao de v + + this->TI = surface->TI; //Ordem 4 e grau 3 na direcao de U + this->TJ = surface->TJ; //Ordem 4 e grau 3 na direcao de V + + + this->RESOLUTIONI = surface->RESOLUTIONI; //resolucao na direcao I + this->RESOLUTIONJ = surface->RESOLUTIONJ; // resolucao na direcao J + + this->weight = surface->weight; + this->controlPoints = surface->controlPoints; + + this->uknots = surface->uknots; + this->vknots = surface->vknots; + setTipo(surface->getTipo().c_str()); + surface3dBsplineRenderNURBS(); +} + +SurfaceNurbs::SurfaceNurbs(int ni, int nj, int resolutioni, int resolutionj, int degree, int type, + vector > > cP):Object() +{ + modifier = Modifier(translation[0], translation[1], translation[2]); + + this->RESOLUTIONI = resolutioni; //resolucao na direcao I + this->RESOLUTIONJ = resolutionj; // resolucao na direcao J + + this->NI = ni; //dimensao na direcao de u + this->NJ = nj; // dimensao na direcao de v + + this->TI = degree; //Ordem 4 e grau 3 na direcao de U + this->TJ = degree; //Ordem 4 e grau 3 na direcao de V + + if (ni+1 == 2 || nj+1 == 2){ + this->TI = this->TJ = 2; + } + + else if (ni+1 == 3 || nj+1 == 3){ + this->TI = this->TJ = 3; + } + + //this->TI = 2; //Ordem 4 e grau 3 na direcao de U + //this->TJ = 2; //Ordem 4 e grau 3 na direcao de V + + vector > w(NI+1,vector (NJ+1, 0)); + weight = w; + + controlPoints = cP; + + uknots = new double[NI + TI + 1]; + vknots = new double[NJ + TJ + 1]; + + splineKnotsDouble(uknots, NI, TI); + splineKnotsDouble(vknots, NJ, TJ); + + if (type == 1){ + setTipo("BSplineSurface"); + preencheMatrizPesos(); + } else { + setTipo("NurbsSurface"); + preencheMatrizPesosRandom(); + } + surface3dBsplineRenderNURBS(); + +} + + + + +SurfaceNurbs::SurfaceNurbs(int ni, int nj, int resolutioni, int resolutionj, int degree, int type):Object() + +{ + + //setTipo("NurbsSurface"); + modifier = Modifier(translation[0], translation[1], translation[2]); + + this->RESOLUTIONI = resolutioni-1; //resolucao na direcao I + this->RESOLUTIONJ = resolutionj-1; // resolucao na direcao J + + this->NI = ni-1; //dimensao na direcao de u + this->NJ = nj-1; // dimensao na direcao de v + + this->TI = degree; //Ordem 4 e grau 3 na direcao de U + this->TJ = degree; //Ordem 4 e grau 3 na direcao de V + + if (ni+1 == 2 || nj+1 == 2){ + this->TI = this->TJ = 2; + } + + else if (ni+1 == 3 || nj+1 == 3){ + this->TI = this->TJ = 3; + } + + //this->TI = 2; //Ordem 4 e grau 3 na direcao de U + //this->TJ = 2; //Ordem 4 e grau 3 na direcao de V + + vector > w(NI+1,vector (NJ+1, 0)); + weight = w; + + vector > > cP(NI+1,vector >(NJ+1,vector (3,0))); + controlPoints = cP; + + uknots = new double[NI + TI + 1]; + vknots = new double[NJ + TJ + 1]; + + splineKnotsDouble(uknots, NI, TI); + splineKnotsDouble(vknots, NJ, TJ); + + createControlPoints(); + //createControlPointsSpehere(); + if (type == 1){ + setTipo("BSplineSurface"); + preencheMatrizPesos(); + } else { + setTipo("NurbsSurface"); + preencheMatrizPesosRandom(); + } + surface3dBsplineRenderNURBS(); +} -using namespace std; - SurfaceNurbs::SurfaceNurbs():Object() { + setTipo("NurbsSurface"); + modifier = Modifier(translation[0], translation[1], translation[2]); - this->RESOLUTIONI = 16; //resolucao na direcao I - this->RESOLUTIONJ = 16; // resolucao na direcao J + this->RESOLUTIONI = 6; //resolucao na direcao I + this->RESOLUTIONJ = 6; // resolucao na direcao J this->NI = 5; //dimensao na direcao de u this->NJ = 5; // dimensao na direcao de v - + this->TI = 4; //Ordem 4 e grau 3 na direcao de U this->TJ = 4; //Ordem 4 e grau 3 na direcao de V @@ -49,14 +176,11 @@ SurfaceNurbs::SurfaceNurbs():Object() SurfaceNurbs::~SurfaceNurbs() { - cout << "Limpando a memoria...\n"; delete uknots; delete vknots; } - - // Recursive computation of B-spline functions. By Sumanta double SurfaceNurbs::Bspline(int i, int m, double *knots, double u) { @@ -69,7 +193,7 @@ double SurfaceNurbs::Bspline(int i, int m, double *knots, double u) } else { - if ( knots[i+m-1] == knots[i] ) + if ( knots[i+m-1] == knots[i] ) { if ( u == knots[i] ) coef1 = 1; else coef1 = 0; @@ -108,7 +232,7 @@ vector SurfaceNurbs::getControlPoints() for (int i = 0; i <= NI; i++){ for (int j = 0; j <= NJ; j++) - { + { double *vec = new double[3]; vec[0] = controlPoints[i][j][0]; vec[1] = controlPoints[i][j][1]; @@ -173,10 +297,13 @@ void SurfaceNurbs::createControlPoints(void) for (int i = 0; i <= NI; i++){ for (int j = 0; j <= NJ; j++){ controlPoints[i][j][0] = X1; - controlPoints[i][j][1] = 0.0; + //controlPoints[i][j][1] = 0.0; controlPoints[i][j][2] = Z1; //+ (double) ( rand() % 100 ); X1 += variation; - + if (i > 0 && j < NJ && i == j){ + controlPoints[i][j][1] = 10.0; + controlPoints[i][NJ-j][1] = 10.0; + } } Z1-=variation; X1 = xInitial; @@ -202,6 +329,7 @@ void SurfaceNurbs::movePointControlSurfaceBspline(double *p, int index) } } +//para as bsplines void SurfaceNurbs::preencheMatrizPesos(){ @@ -212,11 +340,86 @@ void SurfaceNurbs::preencheMatrizPesos(){ //weight[i][j] = (double) ( rand() % 100 ); weight[i][j] = 1.0; - cout << weight[i][j] << ", "; + //cout << weight[i][j] << ", "; } cout << endl; } } +//para as nurbs +void SurfaceNurbs::preencheMatrizPesosRandom(){ + + + srand(10); + for (int i = 0; i <= NI; i++){ + + for (int j = 0; j <= NJ; j++) { + + weight[i][j] = (double) ( rand() % 100 ); + //weight[i][j] = 1.0; + //cout << weight[i][j] << ", "; + } + cout << endl; + } +} + +void SurfaceNurbs::setGlobalScale( float x, float y, float z) +{ + + this->globalScale[0] = x; + this->globalScale[1] = y; + this->globalScale[2] = z; +} + +vector SurfaceNurbs::getControlPointSelected() +{ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + vector selectedPoint(3, 0); + selectedPoint[0] = controlPoints[i][j][0]; + selectedPoint[1] = controlPoints[i][j][1]; + selectedPoint[2] = controlPoints[i][j][2]; + return selectedPoint; +} +int SurfaceNurbs::getSizeControlPoints() + +{ + return (NI+1) * (NJ+1); +} + +void SurfaceNurbs::setPtControleModifier(float x, float y, float z) +{ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + controlPoints[i][j][0] = x; + controlPoints[i][j][1] = y; + controlPoints[i][j][2] = z; + surface3dBsplineRenderNURBS(); +} +void SurfaceNurbs::setPtControle(float x, float y, float z) +{ + + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + vector r = getRotation(); + glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); + glm::quat quaternion = quat ; + glm::mat4 mat = glm::toMat4(quaternion); + + controlPoints[i][j][0] = (x-translation[0])/scale[0]; + controlPoints[i][j][1] = (y-translation[1])/scale[1]; + controlPoints[i][j][2] = (z-translation[2])/scale[2]; + + glm::mat4 INVERSE_ROTATE = glm::inverse(mat); + glm::vec4 reverse_point = INVERSE_ROTATE * glm::vec4(controlPoints[i][j][0], + controlPoints[i][j][1], + controlPoints[i][j][2], + 1.0f + ); + controlPoints[i][j][0] = reverse_point[0]; + controlPoints[i][j][1] = reverse_point[1]; + controlPoints[i][j][2] = reverse_point[2]; + surface3dBsplineRenderNURBS(); +} @@ -237,37 +440,14 @@ void SurfaceNurbs::drawGlQuadStripVector(vector array , int n, int m, for (int j = 0; j < m ; j++) { - - glVertex3f(array[i*m+j][0], array[i*m+j][1], array[i*m+j][2] ); - glVertex3f(array[(1+i)*m+j][0], array[(1+i)*m+j][1], array[(1+i)*m+j][2] ); - - } - glEnd(); - glPopMatrix(); - } - - //glColor4f(BLACK); - - - //desenahdo o poligono de controle - /*for (int i = 0; i < NI; i++) { - glPushMatrix(); - glBegin(GL_QUAD_STRIP); - - for (int j = 0; j < NJ+1 ; j++) { - - - glVertex3f(controlPoints [i][j][0],controlPoints [i][j][1],controlPoints [i][j][2]); - glVertex3f(controlPoints [i+1][j][0],controlPoints [i+1][j][1],controlPoints [i+1][j][2]); + glVertex3f(array[i*m+j][0], array[i*m+j][1], array[i*m+j][2] ); + glVertex3f(array[(1+i)*m+j][0], array[(1+i)*m+j][1], array[(1+i)*m+j][2] ); } glEnd(); glPopMatrix(); - }*/ - - - + } } @@ -276,31 +456,56 @@ void SurfaceNurbs::drawControlPoint(int hit) int count_object = 0; glEnable( GL_POINT_SMOOTH ); glPointSize(6.0f); - + for (int i = 0; i <= NI; i++) { for (int j = 0; j <= NJ; ++j){ - count_object++; + count_object++; glLoadName(count_object); glPushMatrix(); - if ( ( (hit-1) /(NI + 1) ) == i && ( (hit-1) % (NJ + 1) ) == j ){ + if ( ( (hit-1) /(NJ + 1) ) == i && ( (hit-1) % (NJ + 1) ) == j ){ glColor4f(ORANGE); } else { glColor4f(BLACK); } glBegin(GL_POINTS); - glVertex3f(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2] ); - glEnd(); + glVertex3f(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2] ); + glEnd(); glPopMatrix(); } } - + } +void SurfaceNurbs::drawControlPolygon() + +{ + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glColor4f(BLACK); + + + //desenahdo o poligono de controle + for (int i = 0; i < NI; i++) { + + glPushMatrix(); + glBegin(GL_QUAD_STRIP); + + for (int j = 0; j < NJ+1 ; j++) { -void SurfaceNurbs::draw(int index_load, bool is_selecting) + + glVertex3f(controlPoints [i][j][0],controlPoints [i][j][1],controlPoints [i][j][2]); + glVertex3f(controlPoints [i+1][j][0],controlPoints [i+1][j][1],controlPoints [i+1][j][2]); + + } + glEnd(); + glPopMatrix(); + } +} + + +void SurfaceNurbs::draw(int index_load, bool is_selecting, int size_world) { GLfloat m[16]; @@ -310,7 +515,7 @@ void SurfaceNurbs::draw(int index_load, bool is_selecting) vector s = getScale(); glm::quat quat (glm::vec3(r[0]*PI/BASE, r[1]*PI/BASE, r[2]*PI/BASE)); - glm::quat quaternion = quat ; + glm::quat quaternion = quat ; glm::mat4 mat = glm::toMat4(quaternion); int count = 0; @@ -318,40 +523,73 @@ void SurfaceNurbs::draw(int index_load, bool is_selecting) for (int j = 0; j < 4; ++j){ m[count] = mat[k][j]; count++; - } - } + } + } + + //modificador para o objeto inteiro + if(render_mode && is_selected){ + glPushMatrix(); + glTranslatef(translation[0], translation[1]-20, translation[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw( size_world-1 , true); + glPopMatrix(); + } + + //modificador para o ponto de controle + else if (!render_mode && is_selected && hit_index_internal >= 1){ + int i = ( (hit_index_internal-1) / (NJ + 1) ); + int j = ( (hit_index_internal-1) % (NJ + 1) ); + glPushMatrix(); + glTranslatef(t[0],t[1],t[2]); + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); + glTranslatef(controlPoints[i][j][0], controlPoints[i][j][1], controlPoints[i][j][2]); + glScalef(0.8, 0.8, 0.8); + glScalef(1/s[0], 1/s[1], 1/s[2]); + glScalef(1/globalScale[0], 1/globalScale[1], 1/globalScale[2]); + modifier.draw( (NI+1)*(NJ+1), true); + glPopMatrix(); + } + glPushMatrix(); glTranslatef(t[0],t[1],t[2]); - glScalef(2, 2, 2); + glScalef(s[0], s[1], s[2]); + glMultMatrixf(m); //drawControlPoint(getControlPoints()); //glColor3f(0, 0, 0); - + //modo objeto if(render_mode){ - glLoadName(index_load); - + if (is_selected){ glColor4f(GREEN); } else { - glColor4f(RED); + glColor4f(GRAY1); } - + + glLoadName(index_load); drawGlQuadStripVector( surfaceNurbs, RESOLUTIONI+1, RESOLUTIONJ+1, 1); - + //modo Edicao } else if (!render_mode && is_selected){ glColor4f(GREEN); if (!is_selecting){ drawGlQuadStripVector( surfaceNurbs, RESOLUTIONI+1, RESOLUTIONJ+1, 1); + drawControlPolygon(); } drawControlPoint(hit_index_internal); - + } else if (!render_mode && !is_selected) { if (!is_selecting){ - glColor4f(RED); - drawGlQuadStripVector( surfaceNurbs, RESOLUTIONI+1, RESOLUTIONJ+1, 1); + glColor4f(GRAY1); + drawGlQuadStripVector( surfaceNurbs, RESOLUTIONI+1, RESOLUTIONJ+1, 1); } } - glPopMatrix(); + glPopMatrix(); +} + +void SurfaceNurbs::setModifier(int tp) +{ + modifier.setModifierType(tp); } \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/object.cpp b/Prototipo-1/DOT_CPP/object.cpp index 72e1da0..5ff6082 100644 --- a/Prototipo-1/DOT_CPP/object.cpp +++ b/Prototipo-1/DOT_CPP/object.cpp @@ -1,6 +1,7 @@ #include "object.h" #include using namespace std; + float *Object::point3f(float x, float y, float z) { float *p = new float[3]; @@ -16,6 +17,11 @@ float *Object::point4f(float x, float y, float z, float w) } +/*Object::Object( Object *newObject) +{ + this = newObject; +}*/ + Object::Object() { @@ -24,13 +30,14 @@ Object::Object() float t[]={0, 0, 0}; float c[]={1, 1, 1}; + this->hit_index_internal = 0; this->index_internal = 0; this->is_selected = false; this->rotation.insert(this->rotation.end(), r, r+3); this->translation.insert(this->translation.end(), t, t+3); this->scale.insert(this->scale.end(), s, s+3 ); this->color.insert(this->color.end(), c, c+3); - + this->globalScale = vector (3, 1); } Object::Object(vector < float *> vertex) { @@ -83,9 +90,11 @@ void Object::setPrimitive(int GL_PRIMITIVE) } -void Object::scaleObject(vector newScale) +void Object::scaleObject(float x, float y, float z) { - this->scale = newScale; + this->scale[0] = x; + this->scale[1] = y; + this->scale[2] = z; } vector Object::getScale() @@ -113,6 +122,30 @@ vector Object::getRotation() return this->rotation; } +void Object::setGlobalScale( float x, float y, float z) +{ + this->globalScale[0] = x; + this->globalScale[1] = y; + this->globalScale[2] = z; +} +void Object::setGlobalRotation( float x, float y, float z) +{ + this->globaRotation[0] = x; + this->globaRotation[1] = y; + this->globaRotation[2] = z; +} + +void Object::setGlobalTranslation(vector newTranslation) +{ + this->global_translation = newTranslation; +} + +vector Object::getGlobalTranslation() +{ + return this->global_translation; +} + + float Object::getDepth() { return this->translation[2]; @@ -138,8 +171,12 @@ void Object::setHitIndexInternal(int val) { hit_index_internal = val; } +int Object::getHitIndexInternal() +{ + return hit_index_internal; +} -void Object::draw(int index_load, bool is_selecting) +void Object::draw(int index_load, bool is_selecting, int size_world) { cout << "Funcao virtual chamada...." << endl; } @@ -155,5 +192,136 @@ string Object::getTipo() return tipo; } +int Object::getSizeControlPoints() +{ + return 0; +} + +vector Object::getControlPointSelected() +{ + return vector (3, 0); +} + +void Object::setPtControleModifier(float x, float y, float z){} + + + // Metodos da Curva -void Object::setPtControle(float x, float y, float z) {} \ No newline at end of file +void Object::setPtControle(float x, float y, float z){} + +void Object::updatePtsCurv(){} + + +// Duplica um Ponto de Controle Extremo +// Um dos Pontos de Controles Extremos +// tem de estarem selecionados +int Object::addPtControle() +{ + return -1; +} + +// Adiciona um Ponto de Controle Extremo +// Um dos Pontos de Controles Extremos +// tem de estarem selecionados +int Object::addPtControle(float x, float y, float z) +{ + return -1; +} + +// Retorna as Imagens dos Nós na Curva +// As imagens dos nós são os pontos iniciais +// de cada segmento da curva B-Spline +vector Object::getImgNo() +{ + vector nulo; + return nulo; +} + +float Object::getPesoSelec() +{ + return -1; +} + +// Retorna o identificador do Nó selecionado +int Object::getNoSelec() +{ + return -1; +} + +// Retorna a ordem da Curva B-Spline +int Object::getOrdCurva() +{ + return -1; +} + +// Retorna o identificador do Ponto de Controle selecionado +int Object::getPtcSelec() +{ + return -1; +} + +// Retorna a quantidade de pontos gerados para a curva +// B-Spline +int Object::getQuant() +{ + return -1; +} + +// Incrementa/Decrementa o valor de um nó selecionado +int Object::incNo(double inc) +{ + return -1; +} + +// Remove o Ponto de Controle Selecionado +int Object::rmvPtControle() +{ + return -1; +} + +// Define o valor da ordem da curva B-Spline +void Object::setOrdCurva(int ord){} + +// Define a quantide de Pontos que terá a curva B-Spline +void Object::setQuant(int valor){} + +// Nurbs +// Retorna a lista de Pesos +vector Object::getPesos() +{ + vector nulo; + return nulo; +} + +// Nurbs +// Altera o peso de um ponto de Controle selecionado +void Object::setPeso(float valor){} + +// Adciona um Segmento extremo da curva, +// os Segmentos extremos da Curva +// tem de estar selecionados +int Object::addSegment() +{ + return -1; +} + +// Remove um Segmento extremo da curva, +// os Segmentos extremos da Curva +// tem de estar selecionados +int Object::removeSegment() +{ + return -1; +} + +vector Object::getNo() +{ + vector nulo; + return nulo; +} + +void Object::setNoSelec(int id){} + +void Object::setModifier(int tp) +{ +} + diff --git a/Prototipo-1/DOT_CPP/render.cpp b/Prototipo-1/DOT_CPP/render.cpp index 1427d41..5503df2 100644 --- a/Prototipo-1/DOT_CPP/render.cpp +++ b/Prototipo-1/DOT_CPP/render.cpp @@ -2,11 +2,9 @@ #include using namespace std; -#define N 40.0 // Number of vertices on the boundary of the disc. - static int hits; // Number of entries in hit buffer. static unsigned int buffer[1024]; // Hit buffer. - +static float obsP[] = { 0, 0, 200, 0, 0, 0, 0, 1, 0 }; unsigned int findClosestHit(int hits, unsigned int buffer[]) { @@ -28,11 +26,10 @@ unsigned int findClosestHit(int hits, unsigned int buffer[]) ptr += 3; } } - return closestName; } -unsigned int Render::render(vector objects, vector proj, int x, int y, bool render_mode, vector r, float s) +unsigned int Render::selectNearObject(vector objects, vector proj, int x, int y, bool render_mode, vector r, float s) { @@ -77,36 +74,38 @@ void Render::renderObjects(vector objects, bool render_mode, bool is_ //cout << "Tamanho dos vertices do cubo: " << objects[0]->getVertex().size() << " Size world: " << objects.size() << endl; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - gluLookAt(-50, 100, 200, 0, 0, 0, 0, 1, 0); + gluLookAt(obsP[0], obsP[1], obsP[2], obsP[3], obsP[4], obsP[5], obsP[6], obsP[7], obsP[8]); //Rotacao de todo o cenario GLfloat matrix[16]; - glm::quat quat (glm::vec3((r[0]*PI/BASE)/2, 0*PI/BASE, 0*PI/BASE)); - glm::quat quat2 (glm::vec3(0*PI/BASE, (r[1]*PI/BASE)/2, 0*PI/BASE)); + glm::quat quat (glm::vec3((r[0]*PI/BASE)/4, 0*PI/BASE, 0*PI/BASE)); + glm::quat quat2 (glm::vec3(0*PI/BASE, (r[1]*PI/BASE)/4, 0*PI/BASE)); glm::quat quaternion = quat * quat2; glm::mat4 mat = glm::toMat4(quaternion); int count = 0; for (int k = 0; k < 4; ++k){ for (int j = 0; j < 4; ++j){ matrix[count] = mat[k][j]; + //cout << matrix[count] << ", "; count++; } + cout << endl; } - //glPushMatrix(); + + //Rotacao no cenario glMultMatrixf(matrix); - glPushMatrix(); + + //Escala para dar um Zoom no cenario. glScalef(s, s, s); - //if (!is_selecting){ - //glRotatef(r[0]/2, 1.0, .0, 0.0); - //glRotatef(r[1]/2, 0.0, 1.0, 0.0); - //} for (int i = 0; i < (int) objects.size() ; ++i) { - - //glLoadName(i+1); // register object. + //if(!objects[i]->getTipo().compare("bezierSurface")){ + objects[i]->setGlobalScale(s, s, s); + //} objects[i]->setRenderMode(render_mode); - objects[i]->draw(i, is_selecting); - cout << "Modo de renderizacao: " << objects[i]->getRenderMode() << endl; + objects[i]->draw(i, is_selecting, objects.size()); + //cout << "Antes de morrer..." << " size: " << objects.size() << " index: " <getTipo() << endl; + //cout << "Modo de renderizacao: " << objects[i]->getRenderMode() << endl; } glPopName(); glPopMatrix(); @@ -114,7 +113,7 @@ void Render::renderObjects(vector objects, bool render_mode, bool is_ /** Inits the OpenGL viewport for drawing in 3D. */ -void Render::viewport3D(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y, const float *obsP) +void Render::viewport3D(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y) { @@ -157,18 +156,16 @@ vector Render::worldPoint(int x, int y) glGetIntegerv( GL_VIEWPORT, viewport ); //Read the window z value from the z-buffer - //glReadPixels( x, viewport[3]-y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z ); - //if (z == 1) - z = 1 - 0.0002; + glReadPixels( x, viewport[3]-y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z ); + z = 1 - 0.0002; //Use the gluUnProject to get the world co-ordinates of //the point the user clicked and save in objx, objy, objz. gluUnProject( x, viewport[3]-y, z, modelview, projection, viewport, &objx, &objy, &objz ); - float v[] = {(float)objx, (float)objy, (float)objz}; vector p; //p.insert(p.end(), v, v+3); p.push_back(objx); p.push_back(objy); p.push_back(objz); - + //cout << "\n\n\nPonto Mouse world " << "X: " << objx << "Y: " << objy << "Z: " << objz << endl; return p; } \ No newline at end of file diff --git a/Prototipo-1/DOT_CPP/widget.cpp b/Prototipo-1/DOT_CPP/widget.cpp index 780e337..31727bc 100644 --- a/Prototipo-1/DOT_CPP/widget.cpp +++ b/Prototipo-1/DOT_CPP/widget.cpp @@ -1,112 +1,1024 @@ #include "widget.h" +#include +#include +#include #include #include +#include +#include +#include + +//struct timeval tv1, tv2; + +#define ID_DELETE_OBJECT 2001 +#define ID_DUPLICATE_OBJECT 2002 +#define ID_NEW 2003 +#define ID_INTERPOLATE_NURBS 2004 + +BEGIN_EVENT_TABLE(WidgetFrame, wxFrame) + +EVT_MOTION(WidgetFrame::mouseMoved) +EVT_LEFT_DOWN(WidgetFrame::mouseDown) +EVT_RIGHT_DOWN(WidgetFrame::rightClick) +EVT_KEY_DOWN(WidgetFrame::keyPressed) +EVT_MENU(ID_NEW, WidgetFrame::OnNew) +EVT_MENU(wxID_EXIT, WidgetFrame::OnExit) +/*EVT_LEFT_UP(BasicGLPane::mouseReleased) +EVT_LEAVE_WINDOW(BasicGLPane::mouseLeftWindow) +EVT_SIZE(BasicGLPane::resized) +EVT_KEY_UP(BasicGLPane::keyReleased) +EVT_MOUSEWHEEL(BasicGLPane::mouseWheelMoved) +EVT_MIDDLE_DCLICK(BasicGLPane::mouseMiddleDclick) +EVT_MIDDLE_DOWN(BasicGLPane::mouseMiddleDown) +EVT_MIDDLE_UP(BasicGLPane::mouseMiddleUp) +EVT_PAINT(WidgetFrame::render) +*/ +END_EVENT_TABLE() using namespace std; /* variavel para controlar o id dos componentes do menu*/ -static int idEvent = 1; WidgetFrame::WidgetFrame(const wxString &title) - :wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600)) + :wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600)) { - - wxMenuBar *menubar = createMenuBar(); - createToolBar(); - + //gettimeofday(&tv1, NULL); + countItemTree = 1; + m_mgr.SetManagedWindow(this); + int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0}; + opengl = new BasicGLPane( this, args); + opengl->SetFocus (); + + + //sem isso os eventos de teclado nao funcionam + + customPanel = new Transform(this, wxID_ANY); + //wxTextCtrl* text2 = new wxTextCtrl(this, -1, _("Pane 2 - sample text"), + //wxDefaultPosition, wxSize(200,150),wxNO_BORDER | wxTE_MULTILINE); + + //wxTextCtrl* text3 = new wxTextCtrl(this, -1, _("Main content window"), + //wxDefaultPosition, wxSize(200,150), wxNO_BORDER | wxTE_MULTILINE); + wxTextCtrl* text4 = new wxTextCtrl(this, -1, _("Pane 4 - sample text"), + wxDefaultPosition, wxSize(200,150),wxNO_BORDER | wxTE_MULTILINE); - Connect(wxID_ANY , wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(WidgetFrame::acessBasicPlaneEvents));//command for class BasicGLPane + m_treeCtrl = new CustomTreeCtrl(this); + root = m_treeCtrl->AddRoot(wxString("Objects"), -1, -1,NULL); + //m_treeCtrl->AppendItem (root, wxString ("Filho-1"), -1, -1, NULL); + //m_treeCtrl->AppendItem (root, wxString ("Filho-2"), -1, -1, NULL); + //m_treeCtrl->AppendItem (root, wxString ("Filho-3"), -1, -1, NULL); + //isso serve para passar as info para o panel + wxAuiPaneInfo info = wxAuiPaneInfo (); + info.CloseButton (false); + info.Left(); + m_mgr.AddPane(m_treeCtrl, info); + info.Right(); - SetMenuBar(menubar); + // Edição das Curvas está em m_panel4 + m_panel4 = this->createEditBarCurve(); + m_mgr.AddPane( m_panel4, info); - Centre(); + m_mgr.AddPane(customPanel, info); + //m_mgr.AddPane(text2, info); + info.Bottom(); + m_mgr.AddPane(text4, info); + + info.Center(); + m_mgr.AddPane(opengl, info); + + m_mgr.GetPane(customPanel).Hide(); + //m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_BORDER_COLOUR, *wxBLACK); + //m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_BACKGROUND_COLOUR, *wxGREEN); + //m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE, 15); + m_mgr.Update(); + + + //SetMenuBar(createMenuBar()); + createMenuBar(); + this->SetMenuBar( menubar ); + createToolBar(); + + this->Centre(); + //Connect(wxID_ANY , wxEVT_COMMAND_MENU_SELECTED, + //wxCommandEventHandler(WidgetFrame::acessBasicPlaneEvents));//command for class BasicGLPane + //this->Connect(-1, wxEVT_LEFT_DOWN , wxCommandEventHandler(WidgetFrame::OnClick)); + m_treeCtrl->Connect( wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, wxTreeEventHandler( WidgetFrame::OnTreeItemRightClick ), NULL, this ); } -void WidgetFrame::setBasicPlane(BasicGLPane *glPane) +WidgetFrame::~WidgetFrame() +{ + cout << "Desrufasdfas dfaosidjf" << endl; + //eventos d arvore de objetos + m_treeCtrl->Disconnect( wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, wxTreeEventHandler( WidgetFrame::OnTreeItemRightClick ), NULL, this ); + + + /*Eventos dos submenus */ + this->Disconnect( itemCurveBezier->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveBezierMenuSelection ) ); -{ /*set pointer glPane*/ - this->glPane = glPane; + this->Disconnect( itemCurveSpline->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveSplineMenuSelection ) ); + + this->Disconnect( itemCurveNurbs->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveNurbsMenuSelection ) ); + + this->Disconnect( itemSurfaceBezier->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemSurfaceBezierMenuSelection ) ); + + this->Disconnect( itemSurfaceSpline->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemSurfaceSplineMenuSelection ) ); + + this->Disconnect( itemSurfaceNurbs->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemSurfaceNurbsMenuSelection ) ); + + + m_button74->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::addPtControle ), NULL, this ); + m_button75->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::rmvPtControle ), NULL, this ); + m_button17->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::decNo ), NULL, this ); + m_button16->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::incNo ), NULL, this ); + m_button9->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::modOrdem ), NULL, this ); + m_button91->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::modPtCurva ), NULL, this ); + m_button92->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::modPeso ), NULL, this ); + + m_mgr.UnInit(); } +/*void WidgetFrame::setBasicPlane(BasicGLPane *glPane) + +{ //set pointer glPane + this->glPane = glPane; +} +*/ void WidgetFrame::acessBasicPlaneEvents(wxCommandEvent& event) { - int id = event. GetId (); - glPane->optionsActions(id); + int id = event. GetId (); + opengl->optionsActions(id); +} + +void WidgetFrame::createMenuBar() + +{ + menubar = new wxMenuBar( 0 ); + menuFile = new wxMenu(); + menuAdd = new wxMenu(); + subMenuCurve = new wxMenu(); + subMenuSurface = new wxMenu(); + + //Constoi o Submenu das curvas + + + + + menuItemCurve = new wxMenuItem( menuAdd, wxID_ANY, wxT("Curve"), wxEmptyString, wxITEM_NORMAL, subMenuCurve ); + menuAdd->Append( menuItemCurve ); + + + itemCurveCircle = new wxMenuItem( subMenuCurve, wxID_ANY, wxString( wxT("Circle") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuCurve->Append(itemCurveCircle); + + itemCurveRectangle = new wxMenuItem( subMenuCurve, wxID_ANY, wxString( wxT("Rectangle") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuCurve->Append(itemCurveRectangle); + + + itemCurveBezier = new wxMenuItem( subMenuCurve, wxID_ANY, wxString( wxT("Bezier") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuCurve->Append(itemCurveBezier); + + itemCurveSpline = new wxMenuItem( subMenuCurve, wxID_ANY, wxString( wxT("Spline") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuCurve->Append(itemCurveSpline); + + itemCurveNurbs = new wxMenuItem( subMenuCurve, wxID_ANY, wxString( wxT("Nurbs") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuCurve->Append(itemCurveNurbs); + + + /*Constroi o Submenu das Superficies*/ + menuItemSurface = new wxMenuItem( menuAdd, wxID_ANY, wxT("Surface"), wxEmptyString, wxITEM_NORMAL, subMenuSurface ); + menuAdd->Append( menuItemSurface ); + + itemSurfaceBezier = new wxMenuItem( subMenuSurface, wxID_ANY, wxString( wxT("Bezier") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuSurface->Append(itemSurfaceBezier); + + itemSurfaceSpline = new wxMenuItem( subMenuSurface, wxID_ANY, wxString( wxT("Spline") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuSurface->Append(itemSurfaceSpline); + + itemSurfaceNurbs = new wxMenuItem( subMenuSurface, wxID_ANY, wxString( wxT("Nurbs") ) , wxEmptyString, wxITEM_NORMAL ); + subMenuSurface->Append(itemSurfaceNurbs); + + menuFile->Append(ID_NEW, "&New\tCtrl-N", + "Restart the application"); + + menuFile->Append(wxID_EXIT); + + menubar->Append( menuFile, wxT("&File") ); + + menubar->Append( menuAdd, wxT("&Add") ); + + + + /*Eventos dos submenus */ + + + this->Connect( itemCurveRectangle->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveRectangleMenuSelection ) ); + + + this->Connect( itemCurveCircle->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveCircleMenuSelection ) ); + + + this->Connect( itemCurveBezier->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveBezierMenuSelection ) ); + + + this->Connect( itemCurveSpline->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveSplineMenuSelection ) ); + + + + this->Connect( itemCurveNurbs->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemCurveNurbsMenuSelection ) ); + + + this->Connect( itemSurfaceBezier->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemSurfaceBezierMenuSelection ) ); + + + this->Connect( itemSurfaceSpline->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemSurfaceSplineMenuSelection ) ); + + + this->Connect( itemSurfaceNurbs->GetId(), wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler( WidgetFrame::itemSurfaceNurbsMenuSelection ) ); + + //m_menu3 = new wxMenu(); + //menubar->Append( m_menu3, wxT("Help") ); + +} + +/*void WidgetFrame::OnClick(wxCommandEvent& event) +{ + std::cout << "Evento do bota esquerdo chegando na frame, veio la da canvas..." << std::endl; + event.Skip(); +}*/ + +void WidgetFrame::OnNew(wxCommandEvent& event) +{ + m_treeCtrl->DeleteChildren(root); + countItemTree = 1; + opengl->newScene(); } -wxMenuBar * WidgetFrame::createMenuBar() - +void WidgetFrame::OnExit(wxCommandEvent& event) { - /*variaveis auxliares*/ - int k = 0; - int sizeMenuBar = 2; + Close( true ); +} - /* menubar e menu*/ - string vecMenu[] = {"Save", "Save as", "Projetcion 2D", "Projetcion 3D "}; - string vecMenuBar[] = {"File", "Projetcion"}; - - /*vector para adicionar os menus no menubar*/ - vector arrayMenu; - wxMenuBar *menubar = new wxMenuBar; +void WidgetFrame::itemCurveBezierMenuSelection( wxCommandEvent& event ) +{ + std::string s(opengl->createCurve(0,countItemTree)); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Criando uma curva de Bezier..." << endl; +} - //create a complete menu - for (int i = 0; i < 2; i++) { +void WidgetFrame::itemCurveSplineMenuSelection( wxCommandEvent& event ) +{ + std::string s(opengl->createCurve(1,countItemTree)); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Criando uma curva de BSpline..." << endl; +} - wxMenu *m = new wxMenu; +void WidgetFrame::itemCurveNurbsMenuSelection( wxCommandEvent& event ) +{ + + std::string s(opengl->createCurve(2,countItemTree)); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Criando uma curva de BSpline..." << endl; +} + +void WidgetFrame::itemCurveCircleMenuSelection( wxCommandEvent& event ) +{ + + std::string s(opengl->createCurve(3,countItemTree)); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Criando um Circlo..." << endl; +} + +void WidgetFrame::itemCurveRectangleMenuSelection( wxCommandEvent& event ) +{ - for (int j = 0; j < 2; j++) { + std::string s(opengl->createCurve(4,countItemTree)); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Criando um retangulo..." << endl; +} - /*conversao de string para o formato da wxWidget*/ - wxString mystring(vecMenu[k++].c_str(), wxConvUTF8); - m->Append(idEvent++, mystring); - } - arrayMenu.push_back(m); - } - /*adiciona os menus no menubar*/ - for (int i = 0; i < sizeMenuBar; i++ ){ +void WidgetFrame::itemSurfaceBezierMenuSelection( wxCommandEvent& event ) +{ + dialog = new CustomDialog(this, wxID_ANY, wxString("Bezier Config")); + if ( dialog->ShowModal() == wxID_OK ){ + std::string s = opengl->createBezierSurface(countItemTree, + atoi(dialog->getControlPointU().c_str()), + atoi(dialog->getControlPointV().c_str()), + atoi(dialog->getResolutionU().c_str()), + atoi(dialog->getResolutionV().c_str()) + ); + //std::string s(opengl->createBezierSurface(countItemTree)); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Clicando na superficie Bezier..." << endl; + } +} +void WidgetFrame::itemSurfaceSplineMenuSelection( wxCommandEvent& event ) +{ + dialog = new CustomDialog(this, wxID_ANY, wxString("BSpline Config")); + if ( dialog->ShowModal() == wxID_OK ){ + std::string s = opengl->createSplineSurface(countItemTree, + atoi(dialog->getControlPointU().c_str()), + atoi(dialog->getControlPointV().c_str()), + atoi(dialog->getResolutionU().c_str()), + atoi(dialog->getResolutionV().c_str()), + atoi(dialog->getDegree().c_str()) + ); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Clicando na superficie Spline..." << endl; + } +} - /*conversao de string para o formato da wxWidget*/ - wxString mystring(vecMenuBar[i].c_str(), wxConvUTF8); - menubar->Append(arrayMenu[i], mystring); - } +void WidgetFrame::itemSurfaceNurbsMenuSelection( wxCommandEvent& event ) +{ + dialog = new CustomDialog(this, wxID_ANY, wxString("Nurbs Config")); + if ( dialog->ShowModal() == wxID_OK ){ + std::string s = opengl->createNurbsSurface(countItemTree, + atoi(dialog->getControlPointU().c_str()), + atoi(dialog->getControlPointV().c_str()), + atoi(dialog->getResolutionU().c_str()), + atoi(dialog->getResolutionV().c_str()), + atoi(dialog->getDegree().c_str()) + ); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + cout << "Clicando na superficie Nurbs..." << endl; + } +} - return menubar; +void WidgetFrame::fillCustomPanel(std::vector t, std::vector r, std::vector s, + std::string tipo ) +{ + customPanel->setTranslationLabel(t[0], t[1], t[2]); + customPanel->setRotationLabel(r[0], r[1], r[2]); + customPanel->setScaleLabel(s[0], s[1], s[2]); + customPanel->setItemLabel(tipo); } + wxToolBar * WidgetFrame::createToolBar() - { - vector arrayStringNames; - //string s1 = ("ICONS/pencil.png"); - //string s2 = ("ICONS/exit.png"); + vector arrayStringNames; + //string s1 = ("ICONS/pencil.png"); + //string s2 = ("ICONS/exit.png"); + + + wxImage::AddHandler( new wxPNGHandler ); + + wxBitmap trans(wxT("ICONS/translacao.png"), wxBITMAP_TYPE_PNG); + wxBitmap rotac(wxT("ICONS/rotacao.png"), wxBITMAP_TYPE_PNG); + wxBitmap escal(wxT("ICONS/escala.png"), wxBITMAP_TYPE_PNG); + wxBitmap disab(wxT("ICONS/disable.png"), wxBITMAP_TYPE_PNG); + wxBitmap undo(wxT("ICONS/undo.png"), wxBITMAP_TYPE_PNG); + wxBitmap redo(wxT("ICONS/redo.png"), wxBITMAP_TYPE_PNG); + + wxToolBar *toolbar = CreateToolBar(); + toolbar->AddTool(1001, wxT("Copy"), trans, wxString("Translacao")); + toolbar->AddTool(1002,wxT("Copy"), rotac, wxString("Rotacao")); + toolbar->AddTool(1003,wxT("Copy"), escal, wxString("Escala")); + toolbar->AddTool(1004,wxT("Copy"), disab, wxString("Desabilitar Modificador")); + toolbar->AddTool(1005,wxT("&Undo\tCtrl-Z"), undo, wxString("Undo")); + toolbar->AddTool(1006,wxT("&Redo\tCtrl-Y"), redo, wxString("Redo")); + toolbar->Realize(); + + Connect(1001, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WidgetFrame::clickTranslat )); + Connect(1002, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WidgetFrame::clickRotat )); + Connect(1003, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WidgetFrame::clickEscal )); + Connect(1004, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WidgetFrame::clickDesab )); + Connect(1005, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WidgetFrame::clickUndo )); + Connect(1006, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WidgetFrame::clickRedo )); + + + return toolbar; +} + +void WidgetFrame::mouseDown(wxMouseEvent& event) +{ + //Verficando se o click acertou algum objeto da lista... + //GetChildren().GetEventHandler(); + //wxWindowList* wlist = &this->GetChildren(); + //wxWindow *child; + /*for( wxWindowList::iterator iter = wlist->begin(); + iter != wlist->end(); + ++iter ) + { + child = *iter; + cout <<"Name:" <GetName() << endl; + } + */ + + + int num=wxTREE_HITTEST_ONITEMLABEL; + wxTreeItemId item = m_treeCtrl->HitTest(event.GetPosition(), num); + if (item.IsOk()){ + int idObject = getNumberBottomString( m_treeCtrl->GetItemText(item).ToStdString()); + //m_treeCtrl->UnselectAll(); + if (!wxGetKeyState(WXK_CONTROL)){ + m_treeCtrl->UnselectAll(); + } + m_treeCtrl->SelectItem(item, true); + opengl->selectObject(idObject); + fillCustomPanel(opengl->getPositionLastObjectSelected(), + opengl->getRotationLastObjectSelected(), + opengl->getScaleLastObjectSelected(), + opengl->getTipoLastObjectSelected() + ); + cout << "item clicked: " << m_treeCtrl->GetItemText(item).ToStdString() << endl; + + } + + vector cursor = opengl->getCursorPosition(); + customPanel->setCursorLabel(cursor[0], cursor[1], cursor[2]); + + cout << "Fui chamado de fora...Mouse left down... fazer algoo..." << endl; + + //fazer aqui uma condica para verificar ao qual janela o ponto pertence..... + + +} + +void WidgetFrame::mouseMoved(wxMouseEvent& event) +{ + fillCustomPanel(opengl->getPositionLastObjectSelected(), + opengl->getRotationLastObjectSelected(), + opengl->getScaleLastObjectSelected(), + opengl->getTipoLastObjectSelected() + ); + cout << "Fui chamado de fora..., Mouse em movimento, fui chamada de fora...." << endl; +} + +void WidgetFrame::rightClick(wxMouseEvent& event) +{ + fillCustomPanel(opengl->getPositionLastObjectSelected(), + opengl->getRotationLastObjectSelected(), + opengl->getScaleLastObjectSelected(), + opengl->getTipoLastObjectSelected() + ); + + + cout << "Evento de botao direito na frame......chamar aqui as funcoes da opengl...." << endl; + loadInfo(); +} + + +void WidgetFrame::keyPressed(wxKeyEvent& event) +{ + + char n = 78; + static bool panelOption = true; + wxChar uc = event.GetUnicodeKey(); + //cout << uc << endl; + if (uc != WXK_NONE){ + //cout << "Aqui dentro..." << endl; + if (uc == n){ + if (panelOption){ + //cout << "Evento de n..." << endl; + m_mgr.GetPane(customPanel).Show(); + } else { + m_mgr.GetPane(customPanel).Hide(); + } + panelOption = !panelOption; + m_mgr.Update(); + this->Update(); + } + }else if (uc == WXK_CONTROL_Z){ + + cout << "CTR-Z"<< endl; + } else { + switch ( event.GetKeyCode() ){ + + case WXK_NUMPAD1: + cout << "TECLADO ... END" << endl; + opengl->setGlobalRotation(0, -360, 0); + //TO DO AIXS X/Y + break; + + case WXK_NUMPAD3: + cout << "TECLADO ... END" << endl; + opengl->setGlobalRotation(0, 0, 90); + //TO DO AIXS Y/Z + break; + + case WXK_NUMPAD7: + cout << "TECLADO ... WXK_NUMPAD7" << endl; + opengl->setGlobalRotation(360, 0, 0); + //TO DO AIXS X/Z + break; + + case WXK_CONTROL_Z: + cout << "CTR-Z"<< endl; + break; + + + case WXK_CONTROL_Y: + cout << "CTR-Z"<< endl; + break; + + } + } + cout <<"Testando eventos de teclado: " << event.GetKeyCode() << endl; + cout << "evendo de teclado...." << endl; + + loadInfo(); +} + +int WidgetFrame::getNumberBottomString(std::string str) +{ + typedef boost::tokenizer > tokenizer; + boost::char_separator sep(" "); + tokenizer tokens(str, sep); + string numberItem; + for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter){ + numberItem = *tok_iter; + } + return atoi(numberItem.c_str()); +} +std::string WidgetFrame::getFirstNameItem(std::string str) +{ + typedef boost::tokenizer > tokenizer; + boost::char_separator sep(" "); + tokenizer tokens(str, sep); + string strResult; + for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter){ + strResult = *tok_iter; + break; + } + return strResult; +} +std::vector WidgetFrame::getListNameObjectSelected(std::string name) +{ + std::vector ids; + wxArrayTreeItemIds items; + m_treeCtrl->GetSelections(items); + + for ( unsigned i = 0; i < items.size(); i++ ) + { + wxTreeItemId treeid = items[i]; + if (treeid.IsOk()){ + string stringItemFirstName = getFirstNameItem(m_treeCtrl->GetItemText(treeid).ToStdString()); + string stringItem = m_treeCtrl->GetItemText(treeid).ToStdString(); + if (name.compare(stringItemFirstName) == 0){ + ids.push_back(getNumberBottomString(stringItem)); + } + } + } + return ids; +} +int WidgetFrame::lengthObjecteSelected() +{ + int lenght = 0; + wxArrayTreeItemIds items; + m_treeCtrl->GetSelections(items); + + for ( unsigned i = 0; i < items.size(); i++ ) + { + wxTreeItemId treeid = items[i]; + if (treeid.IsOk()){ + lenght++; + } + } + return lenght; +} +void WidgetFrame::OnTreeItemRightClick(wxTreeEvent& event) +{ + + // Show popupmenu at position + bool conditionMenu = false; + std::vector nurbsCurveSelection; + wxTreeItemId item = event.GetItem(); + lastItemSelected = item; + int idObject = getNumberBottomString( m_treeCtrl->GetItemText(item).ToStdString()); + nurbsCurveSelection = getListNameObjectSelected(std::string("Nurbs")); + opengl->selectObject(idObject); + wxMenu mnu; + if (lengthObjecteSelected() == 1 && m_treeCtrl->GetItemText(item).ToStdString().compare("Objects") != 0){ + mnu.Append(ID_DELETE_OBJECT, "Delete"); + mnu.Append(ID_DUPLICATE_OBJECT, "Duplicate"); + mnu.Connect(ID_DELETE_OBJECT, wxEVT_MENU, wxCommandEventHandler(WidgetFrame::OnPopupClickDeleteObject), NULL, this); + mnu.Connect(ID_DUPLICATE_OBJECT,wxEVT_MENU, wxCommandEventHandler(WidgetFrame::OnPopupClickDuplicateObject), NULL, this); + conditionMenu = true; + } + if (nurbsCurveSelection.size() == 2){ + mnu.Append(ID_INTERPOLATE_NURBS, "Interpolate Nurbs"); + mnu.Connect(ID_INTERPOLATE_NURBS,wxEVT_MENU, wxCommandEventHandler(WidgetFrame::OnPopupClickInterpolateNurbsObject), NULL, this); + conditionMenu = true; + } + if (conditionMenu){ + PopupMenu(&mnu); + } + //PopupMenu(&mnu); +} + +void WidgetFrame::OnPopupClickInterpolateNurbsObject(wxCommandEvent &event) +{ + //TO DO + std::vector indexsSelection = getListNameObjectSelected(std::string("Nurbs")); + std::string objectName = opengl->InterpolateNurbs( indexsSelection[0], indexsSelection[1], countItemTree); + std::ostringstream ss; + ss << countItemTree; + wxString str(objectName + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; +} + +void WidgetFrame::OnPopupClickDeleteObject(wxCommandEvent &event) +{ + std::string stringItem = m_treeCtrl->GetItemText(lastItemSelected).ToStdString(); + if (stringItem.compare(std::string("Objects")) != 0){ + int idObject = getNumberBottomString( stringItem); + opengl->deleteObject(idObject); + m_treeCtrl->Delete(lastItemSelected); + } + cout << "DELETE-1" << endl; + +} + +void WidgetFrame::OnPopupClickDuplicateObject(wxCommandEvent &event) +{ + std::string stringItem = m_treeCtrl->GetItemText(lastItemSelected).ToStdString(); + if (stringItem.compare(std::string("Objects")) != 0){ + int idObject = getNumberBottomString(stringItem); + std::string s = opengl->duplicateObject(idObject, countItemTree); + std::ostringstream ss; + ss << countItemTree; + wxString str(s + std::string(" ") + ss.str()); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + countItemTree++; + } + cout << "Duplicate-1" << endl; +} + + +wxPanel * WidgetFrame::createEditBarCurve() +{ + //wxGridBagSizer* gbSizer1; + //gbSizer1 = new wxGridBagSizer( 0, 0 ); + //gbSizer1->SetFlexibleDirection( wxBOTH ); + //gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + //wxBoxSizer* bSizer2; + //bSizer2 = new wxBoxSizer( wxVERTICAL ); + + m_panel4 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer8; + bSizer8 = new wxBoxSizer( wxVERTICAL ); + + m_button74 = new wxButton( m_panel4, wxID_ANY, wxT("Adicionar Ponto de Controle"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer8->Add( m_button74, 0, wxALL, 5 ); + + m_button75 = new wxButton( m_panel4, wxID_ANY, wxT("Remover Ponto de Controle"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer8->Add( m_button75, 0, wxALL, 5 ); + + //m_button76 = new wxButton( m_panel4, wxID_ANY, wxT("Mover"), wxDefaultPosition, wxDefaultSize, 0 ); + //bSizer8->Add( m_button76, 0, wxALL, 5 ); + + m_staticText6 = new wxStaticText( m_panel4, wxID_ANY, wxT("Lista de Nós"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText6->Wrap( -1 ); + + wxBoxSizer* bSizer10; + bSizer10 = new wxBoxSizer( wxHORIZONTAL ); + + wxArrayString m_checkList2Choices; + m_checkList2 = new wxListBox( m_panel4, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_checkList2Choices, 0 ); + m_checkList2 ->SetMinSize( wxSize( 100,180 ) ); + + bSizer10->Add( m_checkList2, 0, wxALL, 5 ); + + wxBoxSizer* bSizer14; + bSizer14 = new wxBoxSizer( wxVERTICAL ); + + m_button16 = new wxButton( m_panel4, wxID_ANY, wxT("Incrementar"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer14->Add( m_button16, 0, wxALL, 5 ); + + m_button17 = new wxButton( m_panel4, wxID_ANY, wxT("Decrementar"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer14->Add( m_button17, 0, wxALL, 5 ); + + //opengl->m_staticText52 = new wxStaticText( opengl->m_panel4, wxID_ANY, wxT("Valor do Incremento"), wxDefaultPosition, wxDefaultSize, 0 ); + //opengl->m_staticText52->Wrap( -1 ); + //bSizer14->Add( opengl->m_staticText52, 0, wxALL, 5 ); + + //opengl->m_textCtrl4 = new wxTextCtrl( opengl->m_panel4, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + //bSizer14->Add( opengl->m_textCtrl4, 0, wxALL, 5 ); + + bSizer10->Add( bSizer14, 1, wxEXPAND, 5 ); + + + m_staticText8 = new wxStaticText( m_panel4, wxID_ANY, wxT("Ordem da Curva"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText8->Wrap( -1 ); + bSizer8->Add( m_staticText8, 0, wxALL, 5 ); + + wxBoxSizer* bSizer61; + bSizer61 = new wxBoxSizer( wxHORIZONTAL ); + + m_textCtrl3 = new wxTextCtrl( m_panel4, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer61->Add( m_textCtrl3, 0, wxALL, 5 ); + + m_button9 = new wxButton( m_panel4, wxID_ANY, wxT("Modificar"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer61->Add( m_button9, 0, wxALL, 5 ); + + bSizer8->Add( bSizer61, 0, wxEXPAND, 5 ); + + m_staticText51 = new wxStaticText( m_panel4, wxID_ANY, wxT("Quantidade de Pontos da Curva"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText51->Wrap( -1 ); + bSizer8->Add( m_staticText51, 0, wxALL, 5 ); + + wxBoxSizer* bSizer611; + bSizer611 = new wxBoxSizer( wxHORIZONTAL ); + + m_textCtrl31 = new wxTextCtrl( m_panel4, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer611->Add( m_textCtrl31, 0, wxALL, 5 ); + + m_button91 = new wxButton( m_panel4, wxID_ANY, wxT("Modificar"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer611->Add( m_button91, 0, wxALL, 5 ); + + bSizer8->Add( bSizer611, 0, wxEXPAND, 5 ); + + m_staticText5 = new wxStaticText(m_panel4, wxID_ANY, wxT("Peso do Ponto de Controle"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText5->Wrap( -1 ); + bSizer8->Add( m_staticText5, 0, wxALL, 5 ); + + wxBoxSizer* bSizer612; + bSizer612 = new wxBoxSizer( wxHORIZONTAL ); + + m_textCtrl32 = new wxTextCtrl( m_panel4, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer612->Add( m_textCtrl32, 0, wxALL, 5 ); + + m_button92 = new wxButton(m_panel4, wxID_ANY, wxT("Modificar"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer612->Add( m_button92, 0, wxALL, 5 ); + + bSizer8->Add( bSizer612, 0, wxEXPAND, 5 ); + + // Lista de Nos por Ultimo + bSizer8->Add( m_staticText6, 0, wxALL, 5 ); + bSizer8->Add( bSizer10, 1, wxEXPAND, 5 ); + + m_panel4->SetSizer( bSizer8 ); + m_panel4->Layout(); + bSizer8->Fit( m_panel4 ); + + m_button74->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::addPtControle ), NULL, this ); + m_button75->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::rmvPtControle ), NULL, this ); + //m_button76->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( BasicGLPane::move ), NULL, this ); + //m_checkList2->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::getNoSelect ), NULL, this ); + m_button17->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::decNo ), NULL, this ); + m_button16->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::incNo ), NULL, this ); + m_button9->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::modOrdem ), NULL, this ); + m_button91->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::modPtCurva ), NULL, this ); + m_button92->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( WidgetFrame::modPeso ), NULL, this ); + //m_textCtrl3->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( BasicGLPane::key ), NULL, this ); + //m_textCtrl31->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( BasicGLPane::key ), NULL, this ); + //m_textCtrl32->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( BasicGLPane::key ), NULL, this ); + + return m_panel4; +} + + +void WidgetFrame::decNo( wxMouseEvent& event ) +{ + int id = m_checkList2->GetSelection(); + opengl->setNodeCurve(id,-0.80); + event.Skip(); + opengl->update(); +} + +void WidgetFrame::incNo( wxMouseEvent& event ) +{ + + int id = m_checkList2->GetSelection(); + opengl->setNodeCurve(id,0.80); + event.Skip(); + opengl->update(); +} + +void WidgetFrame::modOrdem( wxMouseEvent& event ) +{ + wxString str = m_textCtrl3->GetValue(); + int num = wxAtoi(str); + opengl->setOrdCurve(num); + event.Skip(); + opengl->update(); +} + +void WidgetFrame::modPtCurva( wxMouseEvent& event ) +{ + wxString str = m_textCtrl31->GetValue(); + int num = wxAtoi(str); + opengl->setQuantCurv(num); + event.Skip(); + opengl->update(); +} + +void WidgetFrame::modPeso( wxMouseEvent& event ) +{ + wxString str = m_textCtrl32->GetValue(); + double num; + if(!str.ToDouble(&num)){ /* error! */ } + opengl->setPesoCurv( (float) num); + event.Skip(); + opengl->update(); +} + +void WidgetFrame::loadInfo() +{ + string name; + int ordem; + float peso; + vector nos; + wxString val; + int i; + Object * world = opengl->getObject(); + // Limpa os Campos + m_textCtrl3->Clear(); + m_textCtrl31->Clear(); + m_textCtrl32->Clear(); + m_checkList2->Clear(); + + name = world->getTipo(); + + // if(!render_mode){ + // Preenche os Campos + if(name == "BSplines" || name == "Nurbs"){ + + ordem = world->getOrdCurva(); + nos = world->getNo(); + + val = wxString::Format(wxT("%d"), (int) ordem); + + m_textCtrl3->AppendText(val); + + for(i = 0; i < (int) nos.size(); i++){ + + val = wxString::Format(wxT("%f"), (double) nos[i]); + m_checkList2->Append(val); + } + } + + // Preenche os Campos + if(name == "BSplines" || name == "Nurbs" || name == "BezierCurve"){ + + ordem = world->getQuant(); + + val = wxString::Format(wxT("%d"), (int) ordem); + + m_textCtrl31->AppendText(val); + } + + // Preenche os Campos + if(name == "Nurbs"){ + + peso = world->getPesoSelec(); + peso = world->getPesoSelec(); + + val = wxString::Format(wxT("%f"), (float) peso); + + if(peso != -1){ + m_textCtrl32->AppendText(val); + } + } + opengl->update(); + //} +} + +// EVENTOS PARA EDIÇÃO DE UMA CURVA +void WidgetFrame::addPtControle( wxMouseEvent& event ) +{ + + opengl->addPtC(); + event.Skip(); + opengl->update(); +} +void WidgetFrame::rmvPtControle( wxMouseEvent& event ) +{ - wxImage::AddHandler( new wxPNGHandler ); + opengl->rmvPtC(); + event.Skip(); + opengl->update(); +} - wxBitmap curve(wxT("ICONS/pencil.png"), wxBITMAP_TYPE_PNG); - wxBitmap exit(wxT("ICONS/exit.png"), wxBITMAP_TYPE_PNG); - wxBitmap surface(wxT("ICONS/surface.png"), wxBITMAP_TYPE_PNG); +void WidgetFrame::clickTranslat(wxCommandEvent& event) +{ - wxToolBar *toolbar = CreateToolBar(); - toolbar->AddTool(idEvent++, curve, wxT("Curve Bezier")); - toolbar->AddTool(idEvent++, surface, wxT("Surface Bezier")); - toolbar->AddTool(idEvent++, exit, wxT("I will....")); - toolbar->Realize(); + opengl->setMod(1); + opengl->update(); +} - return toolbar; +void WidgetFrame::clickRotat(wxCommandEvent& event) +{ + opengl->setMod(2); + opengl->update(); } +void WidgetFrame::clickEscal(wxCommandEvent& event) +{ + + opengl->setMod(3); + opengl->update(); +} + +void WidgetFrame::clickDesab(wxCommandEvent& event) +{ + + opengl->setMod(0); + opengl->update(); +} + + +void WidgetFrame::clickUndo(wxCommandEvent& event) +{ + cout << "CTR-Z" << endl; + m_treeCtrl->DeleteChildren(root); + vector objetcsName = opengl->ctrZ(); + if (objetcsName.size()){ + countItemTree = getNumberBottomString(objetcsName[objetcsName.size()-1]); + } + for (int i = 0; i < (int)objetcsName.size(); ++i){ + wxString str(objetcsName[i]); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + } + countItemTree++; +} + + +void WidgetFrame::clickRedo(wxCommandEvent& event) +{ + cout << "CTR-Y" << endl; + m_treeCtrl->DeleteChildren(root); + vector objetcsName = opengl->ctrY(); + + if (objetcsName.size()){ + countItemTree = getNumberBottomString(objetcsName[objetcsName.size()-1]); + } + + for (int i = 0; i < (int)objetcsName.size(); ++i){ + wxString str(objetcsName[i]); + m_treeCtrl->AppendItem (root, str, -1, -1, NULL); + m_treeCtrl->ExpandAll (); + } + countItemTree++; +} \ No newline at end of file diff --git a/Prototipo-1/DOT_H/BSplines.h b/Prototipo-1/DOT_H/BSplines.h index 6be490e..0bc291a 100644 --- a/Prototipo-1/DOT_H/BSplines.h +++ b/Prototipo-1/DOT_H/BSplines.h @@ -1,6 +1,7 @@ #include #include #include "object.h" +#include "modifier.h" using namespace std; @@ -11,10 +12,13 @@ class BSplines: public Object public: // Construtores + BSplines(vector < vector > ptControle, vector nos); + BSplines(BSplines * bspline); BSplines(float x, float y, float z); BSplines(void); ~BSplines(void); + // Duplica um Ponto de Controle Extremo // Um dos Pontos de Controles Extremos // tem de estarem selecionados @@ -79,10 +83,20 @@ class BSplines: public Object virtual void updatePtsCurv(); // draw - void draw(int index_load, bool is_selecting); + void draw(int index_load, bool is_selecting, int size_world); + + int getSizeControlPoints(); + + void setModifier(int tp); + + vector getControlPointSelected(); + + void setPtControleModifier(float x, float y, float z); protected: + Modifier modifier; + // Quantidade de Pontos da Curva int quant; @@ -126,4 +140,4 @@ class BSplines: public Object // k é a ordem de continuidade da curva // u é o parametro double bspline(int i, int k, double u); -}; \ No newline at end of file +}; diff --git a/Prototipo-1/DOT_H/BezierCubic.h b/Prototipo-1/DOT_H/BezierCubic.h index a7eb082..6989d1d 100644 --- a/Prototipo-1/DOT_H/BezierCubic.h +++ b/Prototipo-1/DOT_H/BezierCubic.h @@ -8,26 +8,26 @@ class BezierCubic public: - // Construtores + // Construtores BezierCubic(void); ~BezierCubic(void); - // Função que calcula e retorna os pontos da curva de Beizer - // Recebe o paramêtro quant, que representa a a quantidade de pontos + // Função que calcula e retorna os pontos da curva de Beizer + // Recebe o paramêtro quant, que representa a a quantidade de pontos vector processaPontoControle(int quant); - // Define os 4 pontos de controle da curva de Bezier Cubica - // Recebe como paramêtro os 4 pontos de controle + // Define os 4 pontos de controle da curva de Bezier Cubica + // Recebe como paramêtro os 4 pontos de controle void setPtControles(float p1[], float p2[], float p3[], float p4[]); private: // Pontos da Curva de Bezier Cubica - // A Cada 3 elementos tem-se um ponto representando - // px,py,pz + // A Cada 3 elementos tem-se um ponto representando + // px,py,pz vector pontosCurva; - - // Pontos de Controle da Curva de Bezier Cubica + + // Pontos de Controle da Curva de Bezier Cubica float ptC1[3]; float ptC2[3]; float ptC3[3]; diff --git a/Prototipo-1/DOT_H/BezierCurve.h b/Prototipo-1/DOT_H/BezierCurve.h index aca6c5e..5f097be 100644 --- a/Prototipo-1/DOT_H/BezierCurve.h +++ b/Prototipo-1/DOT_H/BezierCurve.h @@ -1,5 +1,6 @@ #include "Segment.h" #include "BezierCubic.h" +#include "modifier.h" #include "Nurbs.h" // Inclusão do Objeto em Nurbs->BSpliens->Objeto //Object *bezier = new BezierCurve(0,0,0); @@ -13,10 +14,11 @@ class BezierCurve: public Object public: // Construtores + BezierCurve(BezierCurve *BezierCurve); BezierCurve(float x, float y,float z); ~BezierCurve(void); - // Atualiza os pontos da Curva + // Atualiza os pontos da Curva void updatePtsCurv(); // Retorna os pontos da Curva @@ -41,28 +43,40 @@ class BezierCurve: public Object // selecionado void setPtControle(float x, float y,float z); - // Adciona um Segmento extremo da curva, + // Adciona um Segmento extremo da curva, // os Segmentos extremos da Curva // tem de estar selecionados int addSegment(); - // Remove um Segmento extremo da curva, + // Remove um Segmento extremo da curva, // os Segmentos extremos da Curva // tem de estar selecionados - int removeSegment(); + int removeSegment(); // draw - void draw(int index_load, bool is_selecting); + void draw(int index_load, bool is_selecting, int size_world); + int getSizeControlPoints(); + + vector getControlPointSelected(); + + void setPtControleModifier(float x, float y, float z); + + void setModifier(int tp); + + + private: // Bezier Cubica BezierCubic bzcubic; - // Todos os Pontos da Curva de Bezier + Modifier modifier; + + // Todos os Pontos da Curva de Bezier // Pontos da Curva de Bezier Cubica - // A Cada 3 elementos tem-se um ponto representando - // px,py,pz + // A Cada 3 elementos tem-se um ponto representando + // px,py,pz vector ptsCurv; // Lista de Segmentos de Controle da Curva diff --git a/Prototipo-1/DOT_H/Nurbs.h b/Prototipo-1/DOT_H/Nurbs.h index ea58771..94b73e6 100644 --- a/Prototipo-1/DOT_H/Nurbs.h +++ b/Prototipo-1/DOT_H/Nurbs.h @@ -8,12 +8,16 @@ class Nurbs: public BSplines public: // Construtores + Nurbs(vector < vector > ptControle, vector nos, vector pesos); + Nurbs(Nurbs * nurb); Nurbs(float x, float y, float z); ~Nurbs(void); // Retorna a lista de Pesos vector getPesos(); + float getPesoSelec(); + // Altera o peso de um ponto de Controle selecionado void setPeso(float valor); @@ -36,6 +40,8 @@ class Nurbs: public BSplines // draw //void draw(int index_load, bool is_selecting); + //void draw(int index_load, bool is_selecting); + private: // Lista de Pesos diff --git a/Prototipo-1/DOT_H/bezierSurface.h b/Prototipo-1/DOT_H/bezierSurface.h index ea08979..14fe38b 100644 --- a/Prototipo-1/DOT_H/bezierSurface.h +++ b/Prototipo-1/DOT_H/bezierSurface.h @@ -1,4 +1,4 @@ -/* + /* * File: lista.h * Author: leandro * @@ -8,6 +8,7 @@ #ifndef BEZIER_SURFACE_H #define BEZIER_SURFACE_H +#include "modifier.h" #include "object.h" #include @@ -19,6 +20,7 @@ class SurfaceBezier: public Object public: + SurfaceBezier( SurfaceBezier *surface); SurfaceBezier(int ni, int nj, int resolutioni, int resolutionj ); SurfaceBezier(); ~SurfaceBezier(); @@ -31,18 +33,30 @@ class SurfaceBezier: public Object void movePointControlSurface(double *point, int position); void surface3dBezierRenderNUBRS(); vector getControlPoints(); - void draw(int index_load, bool is_selecting); + void draw(int index_load, bool is_selecting, int size_world); void drawControlPoint(int hit); + void drawControlPolygon(); void drawGlQuadStripVector(vector array , int n, int m, int type); + void setPtControle(float x, float y, float z); + void translateObject( vector newTranslation); + void rotateObject(vector newRotation); + void setGlobalScale( float x, float y, float z); + int getSizeControlPoints(); + vector getControlPointSelected(); + void setPtControleModifier(float x, float y, float z); + void setModifier(int tp); + private: + Modifier modifier; + vector surfaceBezier; vector > weight; vector > > controlPoints; - + int NI; //dimensao na direcao de u int NJ; // dimensao na direcao de v diff --git a/Prototipo-1/DOT_H/customDialog.h b/Prototipo-1/DOT_H/customDialog.h new file mode 100644 index 0000000..b10eca9 --- /dev/null +++ b/Prototipo-1/DOT_H/customDialog.h @@ -0,0 +1,43 @@ +#ifndef CUSTOMDIALOG_H +#define CUSTOMDIALOG_H + +#include + +class CustomDialog: public wxDialog { +public: + CustomDialog(wxWindow* parent, wxWindowID id, + const wxString& title); + ~CustomDialog(); + void OnButtonClickOk( wxCommandEvent& event ); + void OnButtonClickCancel( wxCommandEvent& event ); + void OnClose( wxCloseEvent& event ); + + + wxButton *okButton; + wxButton *cancelButton; + //void onCancel(wxCommandEvent& pEvent); + //void onOk(wxCommandEvent& pEvent); + + //std::string getName() { + // return nameTextCtrl_->GetValue().ToStdString(); } + + std::string getControlPointU(); + + std::string getControlPointV(); + + std::string getResolutionU(); + + std::string getResolutionV(); + + std::string getDegree(); + +private: + wxTextCtrl* controlPointTextCtrlU; + wxTextCtrl* controlPointTextCtrlV; + wxTextCtrl* resolutionTextCtrlU; + wxTextCtrl* resolutionTextCtrlV; + wxTextCtrl* degree; + +}; + +#endif /* CUSTOMDIALOG_ */ diff --git a/Prototipo-1/DOT_H/customPanel.h b/Prototipo-1/DOT_H/customPanel.h new file mode 100644 index 0000000..def7404 --- /dev/null +++ b/Prototipo-1/DOT_H/customPanel.h @@ -0,0 +1,99 @@ +/* + +*/ +#ifndef CUSTOM_PANEL_H +#define CUSTOM_PANEL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Transform : public wxScrolledWindow +{ + +public: + + Transform(wxWindow* parent); + Transform(wxWindow* parent, wxWindowID id); + ~Transform(); + + void setTranslationLabel(float x, float y, float z); + void setRotationLabel(float x, float y, float z); + void setScaleLabel(float x, float y, float z); + void setCursorLabel(float x, float y, float z); + void setItemLabel(std::string str); + +protected: + + wxBoxSizer *principal; + + //Linhas estaticas + wxStaticLine *staticLineTansform; + wxStaticLine *staticLineCursor; + wxStaticLine *staticLineItem; + + //Botao para esconder o painel + wxToggleButton *toggleButtonTransform; + wxToggleButton *toggleButton3dCursor; + wxToggleButton *toggleButtonItem; + + //Botoes para a Translacao + wxButton *buttonTranslateX; + wxButton *buttonTranslateY; + wxButton *buttonTranslateZ; + + //Botoes para a Rotacao + wxButton *buttonRotateX; + wxButton *buttonRotateY; + wxButton *buttonRotateZ; + + //Botoes para a escala + wxButton *buttonScaleX; + wxButton *buttonScaleY; + wxButton *buttonScaleZ; + + //Botoes para o cursor + wxButton *buttonCursorX; + wxButton *buttonCursorY; + wxButton *buttonCursorZ; + + // textos para os grupos de tranformacoes + wxStaticText* transformStaticText; + wxStaticText* translateStaticText; + wxStaticText* rotateStaticText; + wxStaticText* scaletaticText; + wxStaticText* controlPointStaticText; + wxStaticText* cursor3dStaticText; + wxStaticText* pointCursor3dStaticText; + wxStaticText* itemStaticText; + wxTextCtrl * itemTextCtrl; + + // painel pai dos botoes + wxPanel * panelTransform; + wxPanel * panel3dCursor; + wxPanel * panelItem; + + virtual void OnButtonClickTransform( wxCommandEvent& event ); + virtual void OnButtonClick3dCursor( wxCommandEvent& event ); + virtual void OnButtonItem( wxCommandEvent& event ); + + void paintEventObjectMode(wxPaintEvent & evt); + void paintEventEditMode(wxPaintEvent & evt); + void renderObjectMode(wxDC& dc); + void renderEditMode(wxDC& dc); + void doLayoutObjectMode(); + void doLayoutHideItems(); + void doLayoutEditMode(); + +}; + +#endif /* CUSTOM_PANEL_H */ diff --git a/Prototipo-1/DOT_H/customTreeCtrl.h b/Prototipo-1/DOT_H/customTreeCtrl.h new file mode 100644 index 0000000..0b25fb0 --- /dev/null +++ b/Prototipo-1/DOT_H/customTreeCtrl.h @@ -0,0 +1,25 @@ +/* +Julho de 2015 +*/ + + +#ifndef CUSTOM_TREE_CTRL_H +#define CUSTOM_TREE_CTRL_H +#include +#include + +class CustomTreeCtrl: public wxTreeCtrl + +{ + +public: + + CustomTreeCtrl(wxWindow* parent); + ~CustomTreeCtrl(); + +protected: + + void OnLeftButtonClick( wxMouseEvent& event ); +}; + +#endif /* CUSTOM_TREE_CTRL_H */ diff --git a/Prototipo-1/DOT_H/forms.h b/Prototipo-1/DOT_H/forms.h new file mode 100644 index 0000000..1974d36 --- /dev/null +++ b/Prototipo-1/DOT_H/forms.h @@ -0,0 +1,23 @@ + +#ifndef FORMS_H +#define FORMS_H +#include "object.h" +#include + +using namespace std; + +class Forms: public Object + +{ + +public: + + Forms(); + ~Forms(); + static vector< vector > getCircle(float cx, float cy, float r, int num_segments); + static vector< vector > getElipse(); + static vector< vector > getRecatangle(); + +}; + +#endif /* FORMS_H */ diff --git a/Prototipo-1/DOT_H/grid.h b/Prototipo-1/DOT_H/grid.h index 6084804..106f148 100644 --- a/Prototipo-1/DOT_H/grid.h +++ b/Prototipo-1/DOT_H/grid.h @@ -23,7 +23,7 @@ class Grid: public Object Grid(); Grid(vector < float * > vertex); ~Grid(); - void draw(int index_load, bool is_selecting); + void draw(int index_load, bool is_selecting, int size_world); }; diff --git a/Prototipo-1/DOT_H/manager.h b/Prototipo-1/DOT_H/manager.h index 9c1da67..c0cb88b 100644 --- a/Prototipo-1/DOT_H/manager.h +++ b/Prototipo-1/DOT_H/manager.h @@ -1,54 +1,116 @@ - #include #include #include "render.h" - - +#include using namespace std; class BasicGLPane : public wxGLCanvas { - wxGLContext* m_context; + wxGLContext* m_context; public: - //construtor e destrutors - BasicGLPane(wxFrame* parent, int* args); - virtual ~BasicGLPane(); - - //metodos do opengl - void resized(wxSizeEvent& evt); - int getWidth(); - int getHeight(); - - //metodos auxiliares - void getCoordenateWorldMouse(int mouseX, int mouseY, double *point); - void optionsActions(int id); - void quadrado(float base, float altura); - void render(wxPaintEvent& evt); - - // events mouse - void mouseMoved(wxMouseEvent& event); - void mouseDown(wxMouseEvent& event); - void mouseWheelMoved(wxMouseEvent& event); - void mouseReleased(wxMouseEvent& event); - void rightClick(wxMouseEvent& event); - void mouseLeftWindow(wxMouseEvent& event); - void mouseMiddleDclick(wxMouseEvent &event); - void keyPressed(wxKeyEvent& event); - void keyReleased(wxKeyEvent& event); - void mouseMiddleDown(wxMouseEvent& event); - void mouseMiddleUp(wxMouseEvent& event); - - //events menubar - void OnQuit(wxCommandEvent& event); - - //events display - void displayScene(); - - - //macro for table of the events - DECLARE_EVENT_TABLE() + //construtor e destrutors + BasicGLPane(wxWindow* parent, int* args); + virtual ~BasicGLPane(); + + //metodos do opengl + void resized(wxSizeEvent& evt); + int getWidth(); + int getHeight(); + + //metodos auxiliares + void getCoordenateWorldMouse(int mouseX, int mouseY, double *point); + void optionsActions(int id); + void quadrado(float base, float altura); + void render(wxPaintEvent& evt); + void setGlobalRotation( float x, float y, float z); + + //events display + void displayScene(); + + //metodos para conversar com objetos externos.. + vector getCursorPosition(); + void setCursorPosition(int x, int y, int z); + + std::string createBezierSurface(int symbolicIndex, int u, int v, int ru, int rv); + std::string createSplineSurface (int symbolicIndex, int u, int v, int ru, int rv, int degree); + std::string createNurbsSurface(int symbolicIndex, int u, int v, int ru, int rv, int degree); + void selectObject(int idexObject); + void deleteObject(int idexObject); + int getIndexLastObjectSelected(); + + + //Isso na e legal.... + vector getPositionLastObjectSelected(); + vector getRotationLastObjectSelected(); + vector getScaleLastObjectSelected(); + std::string getTipoLastObjectSelected(); + void newScene(); + + + // Para Edição das Curvas + std::string createCurve(int tp, long symbolicIndex); + void setNodeCurve(int idNode,double inc); + void setOrdCurve(int ord); + void setQuantCurv(int quant); + void setPesoCurv(float val); + void addPtC(); + void rmvPtC(); + void setMod(int tp); + vector ctrZ(); + vector ctrY(); + void addNewState(); + vector < Object *> createTempPointer(vector < Object *> WORLD); + vector < int > createTempVector( vector oldVector); + + + Object * getObject(); + std::string duplicateObject(int oldIndex, int newIndex); + void update(); + std::string InterpolateNurbs( int indexCurve1, int indexCurve2, int symbolicIndex); + +protected: + + int POINTER_BACKUP; + vector < vector < Object * > > BACKUP; + vector WORLD; + vector ROTATION; + vector CURSOR_POSITION; + vector LAST_MOUSE_POSITION_DRAGG; + bool RENDER_MODE; + int MODIFIER_TYPE ; + float SCALE ; + int LAST_OBJECT_SELECTED; + unsigned int LAST_CLICK_OBJECT; + int START_X; + int START_Y; + int START_ANGLE_X; + int START_ANGLE_Y; + int ANGLE_X; + int ANGLE_Y; + int LAST_EVENT; + std::vector LIST_INDEX_OBJECT; + std::vector< vector > LIST_INDEX_OBJECT_STATES; + + // events mouse e teclado + void mouseMoved(wxMouseEvent& event); + void mouseDown(wxMouseEvent& event); + void mouseWheelMoved(wxMouseEvent& event); + void mouseReleased(wxMouseEvent& event); + void rightClick(wxMouseEvent& event); + void mouseLeftWindow(wxMouseEvent& event); + void mouseMiddleDclick(wxMouseEvent &event); + void keyPressed(wxKeyEvent& event); + void keyReleased(wxKeyEvent& event); + void mouseMiddleDown(wxMouseEvent& event); + void mouseMiddleUp(wxMouseEvent& event); + + //events menubar + void OnQuit(wxCommandEvent& event); + + //macro for table of the events + DECLARE_EVENT_TABLE() }; diff --git a/Prototipo-1/DOT_H/modifier.h b/Prototipo-1/DOT_H/modifier.h new file mode 100644 index 0000000..a62099c --- /dev/null +++ b/Prototipo-1/DOT_H/modifier.h @@ -0,0 +1,41 @@ +/* +Julho de 2015 +*/ + + +#ifndef MODIFIER_H +#define MODIFIER_H +#include "object.h" +#include + +using namespace std; + +class Modifier: public Object + +{ + +public: + + Modifier(float x, float y, float z); + Modifier(); + ~Modifier(); + void setModifierType(int modifierType); + int getModifierType(); + void setGlobalScale( float x, float y, float z); + void setGlobalRotation( float x, float y, float z); + void drawModifierTranslation(int index_load); + void drawModifierRotation(int index_load); + void drawModifierScale(int index_load); + void draw(int index_load, bool is_selecting); + void setPosition(float x, float y, float z); + vector getPosition(); + vector getInverseMatrixRotation(); + +private: + + int modifierType; + vector position; + +}; + +#endif /* MODIFIER_H */ diff --git a/Prototipo-1/DOT_H/nurbsSurface.h b/Prototipo-1/DOT_H/nurbsSurface.h index a0a6204..a97a153 100644 --- a/Prototipo-1/DOT_H/nurbsSurface.h +++ b/Prototipo-1/DOT_H/nurbsSurface.h @@ -1,4 +1,4 @@ -/* +/* * File: lista.h * Author: leandro * @@ -9,6 +9,7 @@ #ifndef NURBS_SURFACE_H #define NURBS_SURFACE_H #include "object.h" +#include "modifier.h" #include using namespace std; @@ -19,12 +20,17 @@ class SurfaceNurbs: public Object public: + SurfaceNurbs(int ni, int nj, int resolutioni, int resolutionj, int degree, int type, + vector > > cP); + SurfaceNurbs(SurfaceNurbs *surface); + SurfaceNurbs(int ni, int nj, int resolutioni, int resolutionj, int degree, int type); SurfaceNurbs(); ~SurfaceNurbs(); int verify_two_vectors_oriented(double *v, double *v2); double Bspline(int i, int m, double *knots, double u); double combination(int n, int d); void preencheMatrizPesos(); + void preencheMatrizPesosRandom(); void movePointControlSurfaceBspline(double *p, int index); void splineKnotsDouble(double *u,int n,int t); void createControlPoints(void); @@ -32,16 +38,26 @@ class SurfaceNurbs: public Object double fatorial(int number); void movePointControlSurface(double *point, int position); void drawGlQuadStripVector(vector array , int n, int m, int type); - void draw(int index_load, bool is_selecting); + void draw(int index_load, bool is_selecting, int size_world); void drawControlPoint(int hit); + void drawControlPolygon(); void surface3dBsplineRenderNURBS(); vector createControlPointsSpehere(); vector getControlPoints(); + void setPtControle(float x, float y, float z); + void setGlobalScale( float x, float y, float z); + void setPtControleModifier(float x, float y, float z); + int getSizeControlPoints(); + vector getControlPointSelected(); + void setModifier(int tp); + private: + Modifier modifier; + vector surfaceNurbs; - + vector > weight; vector > > controlPoints; @@ -58,8 +74,9 @@ class SurfaceNurbs: public Object //vector vknots; double *uknots; double *vknots; - + + }; -#endif /* BEZIER_H */ +#endif /* NURBS_H */ diff --git a/Prototipo-1/DOT_H/object.h b/Prototipo-1/DOT_H/object.h index 44e548e..671a8c5 100644 --- a/Prototipo-1/DOT_H/object.h +++ b/Prototipo-1/DOT_H/object.h @@ -31,7 +31,10 @@ #include #include +#include +#include +#include #include #include #include @@ -58,21 +61,33 @@ class Object int getPrimitive(); void setColor( vector color); vector getColor(); - void scaleObject(vector newScale); + void scaleObject(float x, float y, float z); vector getScale(); - void translateObject( vector newTranslation); vector getTranslation(); - void rotateObject(vector newRotation); vector getRotation(); - virtual void draw(int index_load, bool is_selecting); + virtual void rotateObject(vector newRotation); + virtual void setGlobalScale( float x, float y, float z); + virtual void setGlobalRotation( float x, float y, float z); + virtual void draw(int index_load, bool is_selecting, int size_world); void setTipo(const char * val); string getTipo(); void setSelected(bool is_selected); void setRenderMode(bool mode); bool getRenderMode(); float getDepth(); + void setGlobalTranslation(vector newTranslation); + vector getGlobalTranslation(); void setHitIndexInternal(int val); + int getHitIndexInternal(); + + virtual int getSizeControlPoints(); + + virtual vector getControlPointSelected(); + + virtual void setPtControleModifier(float x, float y, float z); + + virtual void translateObject( vector newTranslation); /*****************************************************/ // Metodos das Curvas @@ -80,6 +95,75 @@ class Object // selecionado virtual void setPtControle(float x, float y, float z); + // Atualiza os pontos da Curva + virtual void updatePtsCurv(); + + // Duplica um Ponto de Controle Extremo + // Um dos Pontos de Controles Extremos + // tem de estarem selecionados + virtual int addPtControle(); + + // Adiciona um Ponto de Controle Extremo + // Um dos Pontos de Controles Extremos + // tem de estarem selecionados + virtual int addPtControle(float x, float y, float z); + + // Retorna as Imagens dos Nós na Curva + // As imagens dos nós são os pontos iniciais + // de cada segmento da curva B-Spline + virtual vector getImgNo(); + + // Retorna o identificador do Nó selecionado + virtual int getNoSelec(); + + // Retorna a ordem da Curva B-Spline + virtual int getOrdCurva(); + + // Retorna o identificador do Ponto de Controle selecionado + virtual int getPtcSelec(); + + // Retorna a quantidade de pontos gerados para a curva + // B-Spline + virtual int getQuant(); + + // Incrementa/Decrementa o valor de um nó selecionado + virtual int incNo(double inc); + + // Remove o Ponto de Controle Selecionado + virtual int rmvPtControle(); + + // Define o valor da ordem da curva B-Spline + virtual void setOrdCurva(int ord); + + // Define a quantide de Pontos que terá a curva B-Spline + virtual void setQuant(int valor); + + // Nurbs + // Retorna a lista de Pesos + virtual vector getPesos(); + virtual float getPesoSelec(); + + // Retorna os Nós + virtual vector getNo(); + + // Define o identificador do Nó Selecionado + virtual void setNoSelec(int id); + + // Nurbs + // Altera o peso de um ponto de Controle selecionado + virtual void setPeso(float valor); + + // Adciona um Segmento extremo da curva, + // os Segmentos extremos da Curva + // tem de estar selecionados + virtual int addSegment(); + + // Remove um Segmento extremo da curva, + // os Segmentos extremos da Curva + // tem de estar selecionados + virtual int removeSegment(); + + virtual void setModifier(int tp); protected: @@ -90,6 +174,8 @@ class Object vector < float > translation; vector < float > scale; vector < float > color; + vector < float > global_translation; + bool is_selected; // Indice dos Objetos Interno no Modo Edição @@ -102,9 +188,12 @@ class Object bool visible; int GL_PRIMITIVE; string tipo; + + vector globalScale; + vector globaRotation; }; -#endif \ No newline at end of file +#endif diff --git a/Prototipo-1/DOT_H/render.h b/Prototipo-1/DOT_H/render.h index cfbc114..7d08710 100644 --- a/Prototipo-1/DOT_H/render.h +++ b/Prototipo-1/DOT_H/render.h @@ -22,10 +22,10 @@ class Render /*metodos que auxiliam no set do ambiente opengl e desenhos de primitvas basicas*/ static bool status_projection; - static void viewport3D(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y, const float *obsP); + static void viewport3D(int topleft_x, int topleft_y, int bottomrigth_x, int bottomrigth_y); void drawGlQuadStripVector(vector array , int n, int m); static void renderObjects(vector objects, bool render_mode, bool is_selecting, vector r, float s); - static unsigned int render(vector objects, vector proj, int x, int y, bool render_mode, vector r, float s); + static unsigned int selectNearObject(vector objects, vector proj, int x, int y, bool render_mode, vector r, float s); static vector worldPoint(int x, int y); diff --git a/Prototipo-1/DOT_H/widget.h b/Prototipo-1/DOT_H/widget.h index 6886ee7..199d743 100644 --- a/Prototipo-1/DOT_H/widget.h +++ b/Prototipo-1/DOT_H/widget.h @@ -1,27 +1,154 @@ #include +#include +#include +#include +#include #include #include #include #include "manager.h" +#include "customPanel.h" +#include "customTreeCtrl.h" +#include "customDialog.h" -class WidgetFrame : public wxFrame +class WidgetFrame : public wxFrame { public: - WidgetFrame (const wxString &title); - - wxToolBar * createToolBar(); - wxMenuBar * createMenuBar(); - void setBasicPlane(BasicGLPane *glPane); + WidgetFrame (const wxString &title); + ~WidgetFrame(); + + +protected: + + CustomDialog *dialog; + CustomTreeCtrl* m_treeCtrl; + wxTreeItemId root; + wxTreeItemId lastItemSelected; + wxMenuBar* menubar; + wxMenu* menuFile; + wxMenu* menuAdd; + wxMenu* subMenuCurve; + wxMenu* subMenuSurface; + wxMenu* m_menu3; + Transform *customPanel; + + //Objetos do menu + wxMenuItem* menuItemCurve; + wxMenuItem* itemCurveRectangle; + wxMenuItem* itemCurveCircle; + wxMenuItem* itemCurveBezier; + wxMenuItem* itemCurveSpline ; + wxMenuItem* itemCurveNurbs; + wxMenuItem* menuItemSurface; + wxMenuItem* itemSurfaceBezier; + wxMenuItem* itemSurfaceSpline; + wxMenuItem* itemSurfaceNurbs; + + + // eventos na frame que pode vir dos filhos... + void mouseMoved(wxMouseEvent& event); + void mouseDown(wxMouseEvent& event); + void mouseWheelMoved(wxMouseEvent& event); + void mouseReleased(wxMouseEvent& event); + void rightClick(wxMouseEvent& event); + void mouseLeftWindow(wxMouseEvent& event); + void mouseMiddleDclick(wxMouseEvent &event); + void keyPressed(wxKeyEvent& event); + void keyReleased(wxKeyEvent& event); + void mouseMiddleDown(wxMouseEvent& event); + void mouseMiddleUp(wxMouseEvent& event); + void OnExit(wxCommandEvent& event); + void OnNew(wxCommandEvent& event); + void OnPopupClickDeleteObject(wxCommandEvent &event); + void OnPopupClickDuplicateObject(wxCommandEvent &event); + void OnPopupClickInterpolateNurbsObject(wxCommandEvent &event); + + + //Eventos do subMenu + void itemCurveRectangleMenuSelection( wxCommandEvent& event ); + virtual void itemCurveCircleMenuSelection( wxCommandEvent& event ); + virtual void itemCurveBezierMenuSelection( wxCommandEvent& event ); + virtual void itemCurveSplineMenuSelection( wxCommandEvent& event ); + virtual void itemCurveNurbsMenuSelection( wxCommandEvent& event ); + virtual void itemSurfaceBezierMenuSelection( wxCommandEvent& event ); + virtual void itemSurfaceSplineMenuSelection( wxCommandEvent& event ); + virtual void itemSurfaceNurbsMenuSelection( wxCommandEvent& event ); + virtual void OnTreeItemRightClick(wxTreeEvent& event); + //virtual void OnPopupClick(wxCommandEvent &evt); + + + DECLARE_EVENT_TABLE(); + + //--------------------------------------------// + // Componentes para edição da Curva + wxPanel* m_panel4; + wxButton* m_button74; + wxButton* m_button75; + wxButton* m_button76; + wxStaticText* m_staticText6; + wxListBox* m_checkList2; + wxButton* m_button16; + wxButton* m_button17; + wxStaticText* m_staticText8; + wxTextCtrl* m_textCtrl3; + wxButton* m_button9; + wxStaticText* m_staticText51; + wxTextCtrl* m_textCtrl31; + wxButton* m_button91; + wxStaticText* m_staticText5; + wxTextCtrl* m_textCtrl32; + wxButton* m_button92; + wxStaticText* m_staticText52; + wxTextCtrl* m_textCtrl4; + + // Funções para Edição da Curva + wxPanel * createEditBarCurve(); + + // Eventos da Curva + void decNo( wxMouseEvent& event ); + void incNo( wxMouseEvent& event ); + void modOrdem( wxMouseEvent& event ); + void modPtCurva( wxMouseEvent& event ); + void modPeso( wxMouseEvent& event ); + void loadInfo(); + + void addPtControle( wxMouseEvent& event ); + void rmvPtControle( wxMouseEvent& event ); + + void clickTranslat(wxCommandEvent& event); + void clickRotat(wxCommandEvent& event); + void clickEscal(wxCommandEvent& event); + void clickDesab(wxCommandEvent& event); + + void clickUndo(wxCommandEvent& event); + void clickRedo(wxCommandEvent& event); + + wxToolBar * createToolBar(); + void createMenuBar(); + //void setBasicPlane(BasicGLPane *glPane); + + /*funcao para receber um evento de menu acessar metodos publicos de BasciPlane*/ + void acessBasicPlaneEvents(wxCommandEvent& event); + int getNumberBottomString(std::string str); + void fillCustomPanel(std::vector t, std::vector r, std::vector, + std::string tipo ); + std::string getFirstNameItem(std::string str); + std::vector getListNameObjectSelected(std::string name); + int lengthObjecteSelected(); + - /*funcao para receber um evento de menu acessar metodos publicos de BasciPlane*/ - void acessBasicPlaneEvents(wxCommandEvent& event); private: - - /*objeto para acessar as funcoes publicas de BasicPlane */ - BasicGLPane *glPane; + + /*objeto para acessar as funcoes publicas de BasicPlane */ + BasicGLPane *opengl; + wxAuiManager m_mgr; + long countItemTree; + + + }; diff --git a/Prototipo-1/DOT_O/BSplines.o b/Prototipo-1/DOT_O/BSplines.o index 95ffd53..92d513b 100644 Binary files a/Prototipo-1/DOT_O/BSplines.o and b/Prototipo-1/DOT_O/BSplines.o differ diff --git a/Prototipo-1/DOT_O/BezierCurve.o b/Prototipo-1/DOT_O/BezierCurve.o index 8793131..da19650 100644 Binary files a/Prototipo-1/DOT_O/BezierCurve.o and b/Prototipo-1/DOT_O/BezierCurve.o differ diff --git a/Prototipo-1/DOT_O/Nurbs.o b/Prototipo-1/DOT_O/Nurbs.o index ef7129e..cc1c271 100644 Binary files a/Prototipo-1/DOT_O/Nurbs.o and b/Prototipo-1/DOT_O/Nurbs.o differ diff --git a/Prototipo-1/DOT_O/bezierSurface.o b/Prototipo-1/DOT_O/bezierSurface.o index 355acbc..a8905a1 100644 Binary files a/Prototipo-1/DOT_O/bezierSurface.o and b/Prototipo-1/DOT_O/bezierSurface.o differ diff --git a/Prototipo-1/DOT_O/cube.o b/Prototipo-1/DOT_O/cube.o index 7cf5f87..ccde285 100644 Binary files a/Prototipo-1/DOT_O/cube.o and b/Prototipo-1/DOT_O/cube.o differ diff --git a/Prototipo-1/DOT_O/customDialog.o b/Prototipo-1/DOT_O/customDialog.o new file mode 100644 index 0000000..694e127 Binary files /dev/null and b/Prototipo-1/DOT_O/customDialog.o differ diff --git a/Prototipo-1/DOT_O/customPanel.o b/Prototipo-1/DOT_O/customPanel.o new file mode 100644 index 0000000..1a0002c Binary files /dev/null and b/Prototipo-1/DOT_O/customPanel.o differ diff --git a/Prototipo-1/DOT_O/customTreeCtrl.o b/Prototipo-1/DOT_O/customTreeCtrl.o new file mode 100644 index 0000000..53f94c7 Binary files /dev/null and b/Prototipo-1/DOT_O/customTreeCtrl.o differ diff --git a/Prototipo-1/DOT_O/froms.o b/Prototipo-1/DOT_O/froms.o new file mode 100644 index 0000000..57893b8 Binary files /dev/null and b/Prototipo-1/DOT_O/froms.o differ diff --git a/Prototipo-1/DOT_O/grid.o b/Prototipo-1/DOT_O/grid.o index f24417d..c0fd4b2 100644 Binary files a/Prototipo-1/DOT_O/grid.o and b/Prototipo-1/DOT_O/grid.o differ diff --git a/Prototipo-1/DOT_O/main.o b/Prototipo-1/DOT_O/main.o index 121b158..6d67a31 100644 Binary files a/Prototipo-1/DOT_O/main.o and b/Prototipo-1/DOT_O/main.o differ diff --git a/Prototipo-1/DOT_O/manager.o b/Prototipo-1/DOT_O/manager.o index e6124db..828bd1a 100644 Binary files a/Prototipo-1/DOT_O/manager.o and b/Prototipo-1/DOT_O/manager.o differ diff --git a/Prototipo-1/DOT_O/modifier.o b/Prototipo-1/DOT_O/modifier.o new file mode 100644 index 0000000..04890e6 Binary files /dev/null and b/Prototipo-1/DOT_O/modifier.o differ diff --git a/Prototipo-1/DOT_O/nurbsSurface.o b/Prototipo-1/DOT_O/nurbsSurface.o index f590645..9723e82 100644 Binary files a/Prototipo-1/DOT_O/nurbsSurface.o and b/Prototipo-1/DOT_O/nurbsSurface.o differ diff --git a/Prototipo-1/DOT_O/object.o b/Prototipo-1/DOT_O/object.o index 90a3167..da86992 100644 Binary files a/Prototipo-1/DOT_O/object.o and b/Prototipo-1/DOT_O/object.o differ diff --git a/Prototipo-1/DOT_O/render.o b/Prototipo-1/DOT_O/render.o index 5a048cf..7b76f5b 100644 Binary files a/Prototipo-1/DOT_O/render.o and b/Prototipo-1/DOT_O/render.o differ diff --git a/Prototipo-1/DOT_O/widget.o b/Prototipo-1/DOT_O/widget.o index 5f5f0ce..ba7b02f 100644 Binary files a/Prototipo-1/DOT_O/widget.o and b/Prototipo-1/DOT_O/widget.o differ diff --git a/Prototipo-1/ICONS/disable.png b/Prototipo-1/ICONS/disable.png new file mode 100644 index 0000000..c37233c Binary files /dev/null and b/Prototipo-1/ICONS/disable.png differ diff --git a/Prototipo-1/ICONS/escala.png b/Prototipo-1/ICONS/escala.png new file mode 100644 index 0000000..117fbd2 Binary files /dev/null and b/Prototipo-1/ICONS/escala.png differ diff --git a/Prototipo-1/ICONS/redo.png b/Prototipo-1/ICONS/redo.png new file mode 100644 index 0000000..9f82542 Binary files /dev/null and b/Prototipo-1/ICONS/redo.png differ diff --git a/Prototipo-1/ICONS/rotacao.png b/Prototipo-1/ICONS/rotacao.png new file mode 100644 index 0000000..9caa507 Binary files /dev/null and b/Prototipo-1/ICONS/rotacao.png differ diff --git a/Prototipo-1/ICONS/translacao.png b/Prototipo-1/ICONS/translacao.png new file mode 100644 index 0000000..a302460 Binary files /dev/null and b/Prototipo-1/ICONS/translacao.png differ diff --git a/Prototipo-1/ICONS/undo.png b/Prototipo-1/ICONS/undo.png new file mode 100644 index 0000000..ab34fe9 Binary files /dev/null and b/Prototipo-1/ICONS/undo.png differ diff --git a/Prototipo-1/makefile b/Prototipo-1/makefile index cef8626..6bcdde9 100644 --- a/Prototipo-1/makefile +++ b/Prototipo-1/makefile @@ -1,7 +1,8 @@ CC = g++ -CFLAGS = -c -Wall -COPENGL = -lglut -lGLU -lm -lGL -CFLAGSEXTRA = `wx-config --libs --cxxflags --gl-libs` +CFLAGS = -c -Wall +COPENGL = -lglut -lGLU -lm -lGL +CFLAGSEXTRA = `wx-config --libs core, base, aui --cxxflags --gl-libs` +COPTIMIZATION = -Ofast -O2 -std=c++11 CPPSOURCES = $(wildcard DOT_CPP/* .cpp) HSOURCES = -I DOT_H/ @@ -11,10 +12,10 @@ all: programa programa: $(CPPSOURCES:cpp=o) - g++ -Ofast -O2 -o $@ $^ $(CFLAGSEXTRA) $(COPENGL) + g++ $(COPTIMIZATION) -o $@ $^ $(CFLAGSEXTRA) $(COPENGL) mv $^ DOT_O -%.o: %.cpp +%.o: %.cpp g++ -c $< $(HSOURCES) -o $@ $(COPENGL) $(CFLAGSEXTRA) $(CFLAGS) - + diff --git a/Prototipo-1/programa b/Prototipo-1/programa index c1557d2..c0363c9 100755 Binary files a/Prototipo-1/programa and b/Prototipo-1/programa differ diff --git a/circle.pdf b/circle.pdf new file mode 100644 index 0000000..f97540c Binary files /dev/null and b/circle.pdf differ diff --git a/compilaca-aui.txt b/compilaca-aui.txt new file mode 100644 index 0000000..d40ac5c --- /dev/null +++ b/compilaca-aui.txt @@ -0,0 +1 @@ +g++ teste_aui.cpp -o teste_aui `wx-config --libs core, base, aui --cxxflags --gl-libs` -lglut -lGL -lGLU