diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index 421c58af22dad908deefed1fa32ebdde9e29a24e..43098deafb3f84c2c759a85a98326383099bed1d 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -14,11 +14,12 @@ extern GModel *GMODEL; extern Context_T CTX; -int projection_editor(char *title, double &a, double &b, double &c) +int projection_editor(char *title, projectionFace *p) { + struct _editor{ Fl_Window *window; - Fl_Value_Slider *sa, *sb, *sc; + Fl_Value_Slider *sa, *sb, *sc, *ra, *rb, *rc, *ta, *tb, *tc; Fl_Button *cancel; }; static _editor *editor = 0; @@ -26,28 +27,91 @@ int projection_editor(char *title, double &a, double &b, double &c) const int BH = 2 * CTX.fontsize + 1; const int BB = 7 * CTX.fontsize; const int WB = 7; + + SBoundingBox3d bounds = GMODEL->bounds(); if(!editor){ editor = new _editor; - editor->window = new Dialog_Window(2 * BB + 3 * WB, 4 * BH + 3 * WB); - editor->sa = new Fl_Value_Slider(WB, WB, BB, BH, "blabla"); + editor->window = new Dialog_Window(2 * BB + 3 * WB, 10 * BH + 3 * WB); + + editor->sa = new Fl_Value_Slider(WB, WB, BB, BH, "Scale Factor X"); editor->sa->type(FL_HOR_SLIDER); editor->sa->align(FL_ALIGN_RIGHT); - editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "blibli"); + editor->sa->maximum( bounds.max()[0] + 1 ); + editor->sa->minimum(.1); + editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "Scale Factor Y"); editor->sb->type(FL_HOR_SLIDER); editor->sb->align(FL_ALIGN_RIGHT); - editor->sc = new Fl_Value_Slider(WB, WB + 2 * BH, BB, BH, "blublu"); + editor->sb->maximum( bounds.max()[1] + 1 ); + editor->sb->minimum(.1); + editor->sc = new Fl_Value_Slider(WB, WB + 2 * BH, BB, BH, "Scale Factor Z"); editor->sc->type(FL_HOR_SLIDER); editor->sc->align(FL_ALIGN_RIGHT); - editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 3 * BH, BB, BH, "Cancel"); + editor->sc->maximum( bounds.max()[2] + 1 ); + editor->sc->minimum(.1); + + editor->ra = new Fl_Value_Slider(WB, WB + 3*BH, BB, BH, "Rotation X"); + editor->ra->type(FL_HOR_SLIDER); + editor->ra->align(FL_ALIGN_RIGHT); + editor->ra->maximum(360); + editor->ra->minimum(0); + + editor->rb = new Fl_Value_Slider(WB, WB + 4*BH, BB, BH, "Rotation Y"); + editor->rb->type(FL_HOR_SLIDER); + editor->rb->align(FL_ALIGN_RIGHT); + editor->rb->maximum(360); + editor->rb->minimum(0); + + editor->rc = new Fl_Value_Slider(WB, WB + 5*BH, BB, BH, "Rotation Z"); + editor->rc->type(FL_HOR_SLIDER); + editor->rc->align(FL_ALIGN_RIGHT); + editor->rc->maximum(360); + editor->rc->minimum(0); + + editor->ta = new Fl_Value_Slider(WB, WB + 6*BH, BB, BH, "Translation X"); + editor->ta->type(FL_HOR_SLIDER); + editor->ta->align(FL_ALIGN_RIGHT); + editor->ta->maximum( bounds.max()[0] + 2 ); + editor->ta->minimum( bounds.min()[0] - 2 ); + + editor->tb = new Fl_Value_Slider(WB, WB + 7*BH, BB, BH, "Translation Y"); + editor->tb->type(FL_HOR_SLIDER); + editor->tb->align(FL_ALIGN_RIGHT); + editor->tb->maximum( bounds.max()[1] + 2 ); + editor->tb->minimum( bounds.min()[1] - 2 ); + + editor->tc = new Fl_Value_Slider(WB, WB + 8*BH, BB, BH, "Translation Z"); + editor->tc->type(FL_HOR_SLIDER); + editor->tc->align(FL_ALIGN_RIGHT); + editor->tc->maximum( bounds.max()[2] + 2 ); + editor->tc->minimum( bounds.min()[2] - 2 ); + + editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 9 * BH, BB, BH, "Cancel"); editor->window->end(); editor->window->hotspot(editor->window); } editor->window->label(title); - editor->sa->value(a); - editor->sb->value(b); - editor->sc->value(c); + editor->sa->value( (bounds.max()[0] + bounds.min()[0])/2 ); + editor->sb->value( (bounds.max()[1] + bounds.min()[1])/2 ); + editor->sc->value( (bounds.max()[2] + bounds.min()[2])/2 ); + editor->ra->value(0); + editor->rb->value(0); + editor->rc->value(0); + editor->ta->value( (bounds.max()[0] + bounds.min()[0])/2 ); + editor->tb->value( (bounds.max()[1] + bounds.min()[1])/2 ); + editor->tc->value( (bounds.max()[2] + bounds.min()[2])/2 ); + + SVector3 rescale(editor->sa->value(),editor->sb->value(),editor->sc->value()); + p->setScale(rescale); + SVector3 rerot(editor->ra->value(),editor->rb->value(),editor->rc->value()); + p->setRotation(rerot); + SVector3 retrans(editor->ta->value(),editor->tb->value(),editor->tc->value()); + p->setTranslation(retrans); + + Draw(); + + editor->window->show(); while(editor->window->shown()){ @@ -56,18 +120,35 @@ int projection_editor(char *title, double &a, double &b, double &c) Fl_Widget* o = Fl::readqueue(); if (!o) break; - Draw(); - - if (o == editor->sa) - a = editor->sa->value(); + /* if (o == editor->sa) + SVector3 rescale(editor->sa->value(),0,0); + p->scale(rescale); if (o == editor->sb) - b = editor->sb->value(); + SVector3 rescale(editor->sa->value(),0,0); + p->scale(rescale); if (o == editor->sc) - c = editor->sc->value(); - if (o == editor->window || o == editor->cancel){ - editor->window->hide(); - return 0; + SVector3 rescale(editor->sa->value(),0,0); + p->scale(rescale); + */ + if (o == editor->window || o == editor->cancel) + { + editor->window->hide(); + return 0; + } + else + { + SVector3 rescale(editor->sa->value(),editor->sb->value(),editor->sc->value()); + p->setScale(rescale); + + SVector3 rerot(editor->ra->value(),editor->rb->value(),editor->rc->value()); + p->setRotation(rerot); + + SVector3 retrans(editor->ta->value(),editor->tb->value(),editor->tc->value()); + p->setTranslation(retrans); } + + Draw(); + } } return 0; @@ -82,10 +163,10 @@ void mesh_parameterize_cb(Fl_Widget* w, void* data) CTX.mesh.changed = ENT_SURFACE; CTX.geom.surfaces = 1; - double a=0., b=0., c=0.; - projection_editor("Projection editor", a, b, c); - Draw(); + + projection_editor("Projection editor", p); + //SBoundingBox3d bb = GMODEL->bounds(); diff --git a/Geo/projectionFace.cpp b/Geo/projectionFace.cpp index 5701d1840500cb4271a183d37bc7fcbac7876d6a..e56bc103b19738bf2db3d0e03a2bb29ee711d974 100644 --- a/Geo/projectionFace.cpp +++ b/Geo/projectionFace.cpp @@ -52,6 +52,22 @@ void projectionFace::scale(SVector3 sc) scaleFactor[1] *= sc[1]; scaleFactor[2] *= sc[2]; } +void projectionFace::setScale(SVector3 sc) +{ + scaleFactor[0] = sc[0]; + scaleFactor[1] = sc[1]; + scaleFactor[2] = sc[2]; +} +void projectionFace::setRotation(SVector3 r) +{ + rotation[0] = r[0]; + rotation[1] = r[1]; + rotation[2] = r[2]; +} +void projectionFace::setTranslation(SVector3 t) +{ + translation = t; +} projectionFace::projectionFace(GModel *m,int num) : GFace(m,num) { diff --git a/Geo/projectionFace.h b/Geo/projectionFace.h index f2f6be5a9142a5aa765217d6d611f46cee7127db..4d02efd4c89ab6d957e3880afc22fe296de5291c 100644 --- a/Geo/projectionFace.h +++ b/Geo/projectionFace.h @@ -33,8 +33,9 @@ class projectionFace : public GFace void rotate(SVector3 rot); //rotates the surface by the euler angles rot void translate(SVector3 trans); //translates the surface by trans void scale(SVector3 sc); //scales the surface along the (local?) x,y,z axes by sc - - + void setScale(SVector3 sc); + void setRotation(SVector3 r); + void setTranslation(SVector3 t); Range<double> parBounds(int i) const {throw;} diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index a41a8e6ec9ec64ab5a41a98734f1bf1acafd3689..b99e7de31b3013ce125c5954740cdaeee06bf1a1 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.125 2006-12-05 18:34:58 geuzaine Exp $ +// $Id: Geom.cpp,v 1.126 2006-12-08 16:54:02 jacob Exp $ // // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // @@ -232,21 +232,46 @@ class drawGFace { { Range<double> ubounds = f->parBounds(0); Range<double> vbounds = f->parBounds(1); - const int N = 10; + const int N = 15; - glBegin(GL_POINTS); - for(int i = 0; i < N; i++){ - for(int j = 0; j < N; j++){ - double u = ubounds.low() + (double)i/(double)(N-1) * - (ubounds.high() - ubounds.low()); - double v = vbounds.low() + (double)j/(double)(N-1) * - (vbounds.high() - vbounds.low()); - GPoint p = f->point(u, v); - printf("%g %g %g\n", p.x(), p.y(), p.z()); - glVertex3d(p.x(), p.y(), p.z()); + glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); + glColor3f(1.0f,0.5f,0.0f); + glBegin(GL_QUADS); + for(int i = 1; i < N; i++) + { + for(int j = 1; j < N; j++) + { + double u1 = ubounds.low() + (double)i/(double)(N-1) * + (ubounds.high() - ubounds.low()); + double v1 = vbounds.low() + (double)j/(double)(N-1) * + (vbounds.high() - vbounds.low()); + double u2 = ubounds.low() + (double)(i-1)/(double)(N-1) * + (ubounds.high() - ubounds.low()); + double v2 = vbounds.low() + (double)j/(double)(N-1) * + (vbounds.high() - vbounds.low()); + double u3 = ubounds.low() + (double)(i-1)/(double)(N-1) * + (ubounds.high() - ubounds.low()); + double v3 = vbounds.low() + (double)(j-1)/(double)(N-1) * + (vbounds.high() - vbounds.low()); + double u4 = ubounds.low() + (double)i/(double)(N-1) * + (ubounds.high() - ubounds.low()); + double v4 = vbounds.low() + (double)(j-1)/(double)(N-1) * + (vbounds.high() - vbounds.low()); + GPoint p1 = f->point(u1, v1); + GPoint p2 = f->point(u2,v2); + GPoint p3 = f->point(u3,v3); + GPoint p4 = f->point(u4,v4); + // printf("%g %g %g\n", p.x(), p.y(), p.z()); + glVertex3d(p1.x(), p1.y(), p1.z()); + glVertex3d(p2.x(), p2.y(), p2.z()); + glVertex3d(p3.x(), p3.y(), p3.z()); + glVertex3d(p4.x(), p4.y(), p4.z()); + + } } glEnd(); + glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); } void _drawPlaneGFace(GFace *f)