Skip to content
Snippets Groups Projects
Commit 99614ee8 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

simple coord freeze

parent cb5de5b8
No related branches found
No related tags found
No related merge requests found
...@@ -90,6 +90,10 @@ elementaryContextWindow::elementaryContextWindow(int deltaFontSize) ...@@ -90,6 +90,10 @@ elementaryContextWindow::elementaryContextWindow(int deltaFontSize)
input[3]->value("0"); input[3]->value("0");
input[4] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate"); input[4] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate");
input[4]->value("0"); input[4]->value("0");
for(int i = 0; i < 3; i++)
_butt[i] = new Fl_Check_Button
(width - 2 * WB - IW, 2 * WB + (i+1) * BH, IW, BH, "Freeze");
input[5] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, input[5] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH,
"Prescribed mesh element size at point"); "Prescribed mesh element size at point");
input[5]->value("1.0"); input[5]->value("1.0");
...@@ -203,6 +207,23 @@ elementaryContextWindow::elementaryContextWindow(int deltaFontSize) ...@@ -203,6 +207,23 @@ elementaryContextWindow::elementaryContextWindow(int deltaFontSize)
FL_NORMAL_SIZE += deltaFontSize; FL_NORMAL_SIZE += deltaFontSize;
} }
bool elementaryContextWindow::frozenPointCoord(int coord)
{
if(coord < 0 || coord > 2) return false;
return _butt[coord]->value() ? true : false;
}
void elementaryContextWindow::updatePoint(double pt[3])
{
for(int i = 0; i < 3; i++){
if(!frozenPointCoord(i)){
char str[32];
sprintf(str, "%g", pt[i]);
input[2 + i]->value(str);
}
}
}
void elementaryContextWindow::show(int pane) void elementaryContextWindow::show(int pane)
{ {
for(int i = 0; i < 6; i++) for(int i = 0; i < 6; i++)
......
...@@ -20,9 +20,12 @@ class elementaryContextWindow{ ...@@ -20,9 +20,12 @@ class elementaryContextWindow{
Fl_Input *input[30]; Fl_Input *input[30];
Fl_Value_Input *value[10]; Fl_Value_Input *value[10];
Fl_Group *group[10]; Fl_Group *group[10];
Fl_Check_Button *_butt[3];
public: public:
elementaryContextWindow(int deltaFontSize=0); elementaryContextWindow(int deltaFontSize=0);
void show(int pane); void show(int pane);
void updatePoint(double pt[3]);
bool frozenPointCoord(int coord);
}; };
class physicalContextWindow{ class physicalContextWindow{
......
...@@ -625,22 +625,18 @@ int openglWindow::handle(int event) ...@@ -625,22 +625,18 @@ int openglWindow::handle(int event)
CTX::instance()->cg[2] - p[2]}, t; CTX::instance()->cg[2] - p[2]}, t;
prosca(r, d, &t); prosca(r, d, &t);
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
_point[i] = p[i] + t * d[i]; if(!FlGui::instance()->elementaryContext->frozenPointCoord(i)){
if(CTX::instance()->geom.snap[i]){ _point[i] = p[i] + t * d[i];
double d = _point[i] / CTX::instance()->geom.snap[i]; if(CTX::instance()->geom.snap[i]){
double f = floor(d); double d = _point[i] / CTX::instance()->geom.snap[i];
double c = ceil(d); double f = floor(d);
double n = (d - f < c - d) ? f : c; double c = ceil(d);
_point[i] = n * CTX::instance()->geom.snap[i]; double n = (d - f < c - d) ? f : c;
_point[i] = n * CTX::instance()->geom.snap[i];
}
} }
} }
char str[32]; FlGui::instance()->elementaryContext->updatePoint(_point);
sprintf(str, "%g", _point[0]);
FlGui::instance()->elementaryContext->input[2]->value(str);
sprintf(str, "%g", _point[1]);
FlGui::instance()->elementaryContext->input[3]->value(str);
sprintf(str, "%g", _point[2]);
FlGui::instance()->elementaryContext->input[4]->value(str);
redraw(); redraw();
} }
else{ // hover mode else{ // hover mode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment