diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index c680c50d88d043ff165a739886cb75dc4c2bf4c7..ebe0848d713dcb3ecfa79f0ebb7df8922de6bea1 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -9,6 +9,8 @@ extern Context_T CTX; #if defined(HAVE_FOURIER_MODEL) +static double currentParams[9]; + void uvPlot::draw() { // draw background @@ -37,28 +39,42 @@ projection::projection(FProjectionFace *f, int x, int y, int w, int h, int BB, i ProjectionSurface *ps = f->GetProjectionSurface(); for(int i = 0; i < ps->GetNumParameters() + 9; i++){ Fl_Value_Input *v = new Fl_Value_Input(x, y + i * BH, BB, BH); + + ps->GetScale(currentParams[0],currentParams[1],currentParams[2]); + ps->GetOrigin(currentParams[6],currentParams[7],currentParams[8]); + if(i < 3){ // scaling v->maximum(CTX.lc * 10.); v->minimum(CTX.lc / 100.); v->step(CTX.lc / 100.); v->label((i == 0) ? "X scale" : (i == 1) ? "Y scale" : "Z scale"); - v->value(1.); + v->value(currentParams[i]); } else if(i < 6){ //rotation + currentParams[i] = 0.; v->maximum(-180.); v->minimum(180.); v->step(0.1); - v->label((i == 3) ? "X rotation" : (i == 4) ? "Y rotation" : "Z rotation"); + v->label((i == 3) ? "X rotation" : (i == 4) ? "Y rotation" : + "Z rotation"); + v->value(currentParams[i]); } else if(i < 9){ // translation - v->maximum(bounds.max()[i] + CTX.lc); - v->minimum(bounds.min()[i] - CTX.lc); + v->maximum(bounds.max()[i] + 10. * CTX.lc); + v->minimum(bounds.min()[i] - 10. * CTX.lc); v->step(CTX.lc / 100.); - v->label((i == 6) ? "X translation" : (i == 7) ? "Y translation" : "Z translation"); + v->label((i == 6) ? "X translation" : (i == 7) ? "Y translation" : + "Z translation"); + //v->value(currentParams[i]); + v->value(bounds.center()[i]); } else{ // other parameters + v->maximum(10. * CTX.lc); + v->minimum(-10. * CTX.lc); + v->step(CTX.lc / 100.); v->label("My nice label"); v->value(ps->GetParameter(i - 9)); + v->value(currentParams[i]); } v->align(FL_ALIGN_RIGHT); v->callback(update_cb, e); @@ -78,24 +94,27 @@ projectionEditor::projectionEditor(std::vector<FProjectionFace*> &faces) _window = new Dialog_Window(width, height, "Reparameterize"); new Fl_Box(WB, WB + BH, BB / 2, BH, "Select:"); - + Fl_Group *o = new Fl_Group(WB, WB, 2 * BB, 3 * BH); - _select[0] = new Fl_Round_Button(2 * WB + BB / 2, WB, BB, BH, "Points"); + _select[0] = + new Fl_Round_Button(2 * WB + BB / 2, WB, BB, BH, "Points"); _select[0]->value(1); - _select[1] = new Fl_Round_Button(2 * WB + BB / 2, WB + BH, BB, BH, "Elements"); - _select[2] = new Fl_Round_Button(2 * WB + BB / 2, WB + 2 * BH, BB, BH, "Surfaces"); + _select[1] = + new Fl_Round_Button(2 * WB + BB / 2, WB + BH, BB, BH, "Elements"); + _select[2] = + new Fl_Round_Button(2 * WB + BB / 2, WB + 2 * BH, BB, BH, "Surfaces"); for(int i = 0; i < 3; i++){ _select[i]->callback(select_cb, this); _select[i]->type(FL_RADIO_BUTTON); } o->end(); - Fl_Toggle_Button *b1 = new Fl_Toggle_Button(width - WB - (int)(1.5 * BB), WB, - (int)(1.5 * BB), BH, "Hide unselected"); + Fl_Toggle_Button *b1 = new Fl_Toggle_Button + (width - WB - 3 * BB / 2, WB, 3 * BB / 2, BH, "Hide unselected"); b1->callback(hide_cb); - - Fl_Button *b2 = new Fl_Button(width - WB - (int)(1.5 * BB), WB + BH, - (int)(1.5 * BB), BH, "Save selection"); + + Fl_Button *b2 = new Fl_Button + (width - WB - 3 * BB / 2, WB + BH, 3 * BB / 2, BH, "Save selection"); b2->callback(save_cb, this); const int brw = (int)(1.25 * BB); @@ -105,11 +124,13 @@ projectionEditor::projectionEditor(std::vector<FProjectionFace*> &faces) for(unsigned int i = 0; i < faces.size(); i++){ ProjectionSurface *ps = faces[i]->GetProjectionSurface(); _browser->add(ps->GetName().c_str()); - _projections.push_back(new projection(faces[i], 2 * WB + brw, 2 * WB + 3 * BH, - width - 3 * WB - brw, 5 * BH, BB, BH, this)); + _projections.push_back + (new projection(faces[i], 2 * WB + brw, 2 * WB + 3 * BH, + width - 3 * WB - brw, 5 * BH, BB, BH, this)); } - _uvPlot = new uvPlot(WB, 3 * WB + 8 * BH, width - 2 * WB, height - 5 * WB - 9 * BH); + _uvPlot = + new uvPlot(WB, 3 * WB + 8 * BH, width - 2 * WB, height - 5 * WB - 9 * BH); _uvPlot->end(); Fl_Button *b3 = new Fl_Button(width - 2 * WB - 2 * BB, height - WB - BH, @@ -119,7 +140,7 @@ projectionEditor::projectionEditor(std::vector<FProjectionFace*> &faces) Fl_Button *b4 = new Fl_Button(width - WB - BB, height - WB - BH, BB, BH, "Cancel"); b4->callback(close_cb, _window); - + _window->end(); _window->hotspot(_window); _window->resizable(_uvPlot); @@ -151,11 +172,68 @@ void browse_cb(Fl_Widget *w, void *data) projections[i]->face->setVisibility(false); projections[i]->group->hide(); } + + /* +<<<<<<< GUI_Projection.cpp + for(int i = 0; i < MAX_PROJECTION_PARAMETERS; i++) + e->getValueInput(i)->hide(); + + FProjectionFace *f = e->getCurrentProjectionFace(); + if(f){ + f->setVisibility(true); + ProjectionSurface *ps = f->GetProjectionSurface(); + for(int i = 0; i < 9; i++){ + e->getValueInput(i)->show(); + ps->GetScale(currentParams[0],currentParams[1],currentParams[2]); + ps->GetOrigin(currentParams[6],currentParams[7],currentParams[8]); + if(i < 3){ // scaling + e->getValueInput(i)->maximum(CTX.lc * 10.); + e->getValueInput(i)->minimum(CTX.lc / 100.); + e->getValueInput(i)->step(CTX.lc / 100.); + e->getValueInput(i)-> + label((i == 0) ? "X scale" : (i == 1) ? "Y scale" : "Z scale"); + e->getValueInput(i)->value(currentParams[i]); + } + else if(i < 6){ //rotation + currentParams[i] = 0.; + e->getValueInput(i)->maximum(180.); + e->getValueInput(i)->minimum(-180.); + e->getValueInput(i)->step(0.1); + e->getValueInput(i)-> + label((i == 3) ? "X Rotation" : (i == 4) ? "Y Rotation" : + "Z Rotation"); + e->getValueInput(i)->value(currentParams[i]); + } + else{ // translation + e->getValueInput(i)->maximum(bounds.max()[i] + CTX.lc); + e->getValueInput(i)->minimum(bounds.min()[i] - CTX.lc); + e->getValueInput(i)->step(( CTX.lc) / 100.); + e->getValueInput(i)-> + label((i == 6) ? "X Translation" : (i == 7) ? "Y Translation" : + "Z Translation"); + e->getValueInput(i)->value(currentParams[i]); + } + } + for(int i = 9; i < 9 + ps->GetNumParameters(); i++){ + currentParams[i] = ps->GetParameter(i - 9); + e->getValueInput(i)->show(); + e->getValueInput(i)->maximum(10. * CTX.lc); + e->getValueInput(i)->minimum(-10. * CTX.lc); + e->getValueInput(i)->step(CTX.lc / 100.); + e->getValueInput(i)->label("My nice label"); + e->getValueInput(i)->value(currentParams[i]); + } +======= + */ projection *p = e->getCurrentProjection(); if(p){ p->face->setVisibility(true); p->group->show(); + + + // >>>>>>> 1.12 + } Draw(); } @@ -165,22 +243,26 @@ void update_cb(Fl_Widget *w, void *data) projectionEditor *e = (projectionEditor*)data; // get all parameters from GUI and modify projection surface accordingly + projection *p = e->getCurrentProjection(); if(p){ ProjectionSurface *ps = p->face->GetProjectionSurface(); - ps->Rescale(p->parameters[0]->value(), - p->parameters[1]->value(), - p->parameters[2]->value()); - ps->Rotate(p->parameters[3]->value(), - p->parameters[4]->value(), - p->parameters[5]->value()); - ps->Translate(p->parameters[6]->value(), - p->parameters[7]->value(), - p->parameters[8]->value()); - for(int i = 9; i < 9 + ps->GetNumParameters(); i++) - ps->SetParameter(i - 9, p->parameters[i]->value()); + ps->Rescale(p->parameters[0]->value() / currentParams[0], + p->parameters[1]->value() / currentParams[1], + p->parameters[2]->value() / currentParams[2]); + ps->Rotate(p->parameters[3]->value() - currentParams[3], + p->parameters[4]->value() - currentParams[4], + p->parameters[5]->value() - currentParams[5]); + ps->Translate(p->parameters[6]->value() - currentParams[6], + p->parameters[7]->value() - currentParams[7], + p->parameters[8]->value() - currentParams[8]); + for (int i = 9; i < 9 + ps->GetNumParameters(); i++) + ps->SetParameter(i - 9, p->parameters[i]->value() - currentParams[i]); + Draw(); - } + for (int i = 0; i < 9; i++) + currentParams[i] = p->parameters[i]->value(); +} // project all selected points and update u,v display std::vector<double> u, v; @@ -332,10 +414,10 @@ void mesh_parameterize_cb(Fl_Widget* w, void* data) // create one instance of each available projection surface std::vector<FProjectionFace*> faces; if(faces.empty()){ - faces.push_back(new FProjectionFace(GMODEL, 10000, - new CylindricalProjectionSurface(0))); - faces.push_back(new FProjectionFace(GMODEL, 10001, - new RevolvedParabolaProjectionSurface(0))); + faces.push_back(new FProjectionFace + (GMODEL, 10000, new CylindricalProjectionSurface(0))); + faces.push_back(new FProjectionFace + (GMODEL, 10001, new RevolvedParabolaProjectionSurface(1))); } // make each projection surface invisible and diff --git a/contrib/FourierModel/CylindricalProjectionSurface.cpp b/contrib/FourierModel/CylindricalProjectionSurface.cpp index ba7b49d33bcd2e7af67f5e4facb6054b9eb54b78..8307d7162430cadce70f9ab9e64f2c06da6dcb56 100755 --- a/contrib/FourierModel/CylindricalProjectionSurface.cpp +++ b/contrib/FourierModel/CylindricalProjectionSurface.cpp @@ -4,15 +4,20 @@ CylindricalProjectionSurface::CylindricalProjectionSurface (int tag) : ProjectionSurface(1.) { SetTag(tag); - SetName(std::string("cylinder")); + SetName(std::string("Cylinder")); twoPi_ = 2 * M_PI; + R_ = 1.; + Z_ = 1.; + + numParameters_ = 2; + O_[0] = O_[1] = O_[2] = 0.; - E0_[0] = 0.; E0_[1] = 0.; E0_[2] = 1.; - E1_[0] = 1.; E1_[1] = 0.; E1_[2] = 0.; - E2_[0] = 0.; E2_[1] = 1.; E2_[2] = 0.; + E0_[0] = 1.; E0_[1] = 0.; E0_[2] = 0.; + E1_[0] = 0.; E1_[1] = 1.; E1_[2] = 0.; + E2_[0] = 0.; E2_[1] = 0.; E2_[2] = 1.; scale_[0] = scale_[1] = scale_[2] = 1.; } @@ -22,7 +27,7 @@ CylindricalProjectionSurface::CylindricalProjectionSurface : ProjectionSurface(1.) { SetTag(tag); - SetName(std::string("cylinder")); + SetName(std::string("Cylinder")); twoPi_ = 2 * M_PI; @@ -41,16 +46,16 @@ CylindricalProjectionSurface::CylindricalProjectionSurface void CylindricalProjectionSurface:: F(double u, double v, double &x, double &y, double &z) { - x = O_[0] + E0_[0] * scale_[0] * v; - y = O_[1] + E0_[1] * scale_[0] * v; - z = O_[2] + E0_[2] * scale_[0] * v; + x = O_[0] + E0_[0] * Z_ * v; + y = O_[1] + E0_[1] * Z_ * v; + z = O_[2] + E0_[2] * Z_ * v; - x += E1_[0] * cos(twoPi_ * (u - 0.5)) + - E2_[0] * sin(twoPi_ * (u - 0.5)); - y += E1_[1] * cos(twoPi_ * (u - 0.5)) + - E2_[1] * sin(twoPi_ * (u - 0.5)); - z += E1_[2] * cos(twoPi_ * (u - 0.5)) + - E2_[2] * sin(twoPi_ * (u - 0.5)); + x += R_ * (E1_[0] * cos(twoPi_ * (u - 0.5)) + + E2_[0] * sin(twoPi_ * (u - 0.5))); + y += R_ * (E1_[1] * cos(twoPi_ * (u - 0.5)) + + E2_[1] * sin(twoPi_ * (u - 0.5))); + z += R_ * (E1_[2] * cos(twoPi_ * (u - 0.5)) + + E2_[2] * sin(twoPi_ * (u - 0.5))); } bool CylindricalProjectionSurface:: @@ -61,7 +66,7 @@ Inverse(double x, double y, double z, double &u,double &v) double t = (x - O_[0]) * E0_[0] + (y - O_[1]) * E0_[1] + (z - O_[2]) * E0_[2]; - v = t / scale_[0]; + v = t / Z_; double n[3]; n[0] = x - (O_[0] + t * E0_[0]); n[1] = y - (O_[1] + t * E0_[1]); @@ -84,13 +89,13 @@ Inverse(double x, double y, double z, double &u,double &v) void CylindricalProjectionSurface:: Dfdu(double u, double v, double &x, double &y, double &z) { - x = twoPi_ * + x = twoPi_ * R_ * (- E1_[0] * sin(twoPi_ * (u - 0.5)) + E2_[0] * cos(twoPi_ * (u - 0.5))); - y = twoPi_ * + y = twoPi_ * R_ * (- E1_[1] * sin(twoPi_ * (u - 0.5)) + E2_[1] * cos(twoPi_ * (u - 0.5))); - z = twoPi_ * + z = twoPi_ * R_ * (- E1_[2] * sin(twoPi_ * (u - 0.5)) + E2_[2] * cos(twoPi_ * (u - 0.5))); } @@ -98,21 +103,21 @@ Dfdu(double u, double v, double &x, double &y, double &z) void CylindricalProjectionSurface:: Dfdv(double u, double v, double &x, double &y, double &z) { - x = E0_[0] * scale_[0]; - y = E0_[1] * scale_[0]; - z = E0_[2] * scale_[0]; + x = E0_[0] * Z_; + y = E0_[1] * Z_; + z = E0_[2] * Z_; } void CylindricalProjectionSurface:: Dfdfdudu(double u,double v, double &x, double &y, double &z) { - x = - twoPi_ * twoPi_ * + x = - twoPi_ * twoPi_ * R_ * (E1_[0] * cos(twoPi_ * (u - 0.5)) + E2_[0] * sin(twoPi_ * (u - 0.5))); - y = - twoPi_ * twoPi_ * + y = - twoPi_ * twoPi_ * R_ * (E1_[1] * cos(twoPi_ * (u - 0.5)) + E2_[1] * sin(twoPi_ * (u - 0.5))); - z = - twoPi_ * twoPi_ * + z = - twoPi_ * twoPi_ * R_ * (E1_[2] * cos(twoPi_ * (u - 0.5)) + E2_[2] * sin(twoPi_ * (u - 0.5))); } @@ -132,13 +137,13 @@ Dfdfdvdv(double u, double v, double &x, double &y, double &z) void CylindricalProjectionSurface:: Dfdfdfdududu(double u,double v,double &x,double &y,double &z) { - x = twoPi_ * twoPi_ * twoPi_ * + x = twoPi_ * twoPi_ * twoPi_ * R_ * (E1_[0] * sin(twoPi_ * (u - 0.5)) - E2_[0] * cos(twoPi_ * (u - 0.5))); - y = twoPi_ * twoPi_ * twoPi_ * + y = twoPi_ * twoPi_ * twoPi_ * R_ * (E1_[1] * sin(twoPi_ * (u - 0.5)) - E2_[1] * cos(twoPi_ * (u - 0.5))); - z = twoPi_ * twoPi_ * twoPi_ * + z = twoPi_ * twoPi_ * twoPi_ * R_ * (E1_[2] * sin(twoPi_ * (u - 0.5)) + E2_[2] * cos(twoPi_ * (u - 0.5))); } @@ -211,10 +216,21 @@ OrthoProjectionOnSurface(double x, double y, double z, double &u,double &v) void CylindricalProjectionSurface:: SetParameter(int i, double x) { + switch (i) { + case 0: + R_ = x; + case 1: + Z_ = x; + } } double CylindricalProjectionSurface:: GetParameter(int i) { - return 0.; + switch (i) { + case 0: + return R_; + case 1: + return Z_; + } } diff --git a/contrib/FourierModel/CylindricalProjectionSurface.h b/contrib/FourierModel/CylindricalProjectionSurface.h index 34fc45b58197c823418389726854bf25d50a40ef..01ac33a553d7ccc8d96d65c3386a2c4a5973ebed 100755 --- a/contrib/FourierModel/CylindricalProjectionSurface.h +++ b/contrib/FourierModel/CylindricalProjectionSurface.h @@ -7,6 +7,7 @@ class CylindricalProjectionSurface : public ProjectionSurface { private: double twoPi_; + double R_, Z_; public: CylindricalProjectionSurface (int tag);