1
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
3
// See the LICENSE.txt file for license information. Please report all
4
// bugs and problems to <gmsh@geuz.org>.
7
#include <FL/Fl_Return_Button.H>
10
#include "manipWindow.h"
11
#include "paletteWindow.h"
12
#include "graphicWindow.h"
18
void manip_cb(Fl_Widget *w, void *data)
20
GUI::instance()->manip->show();
23
static void manip_update_cb(Fl_Widget *w, void *data)
25
drawContext *ctx = GUI::instance()->getCurrentOpenglWindow()->getDrawContext();
26
ctx->r[0] = GUI::instance()->manip->value[0]->value();
27
ctx->r[1] = GUI::instance()->manip->value[1]->value();
28
ctx->r[2] = GUI::instance()->manip->value[2]->value();
29
ctx->t[0] = GUI::instance()->manip->value[3]->value();
30
ctx->t[1] = GUI::instance()->manip->value[4]->value();
31
ctx->t[2] = GUI::instance()->manip->value[5]->value();
32
ctx->s[0] = GUI::instance()->manip->value[6]->value();
33
ctx->s[1] = GUI::instance()->manip->value[7]->value();
34
ctx->s[2] = GUI::instance()->manip->value[8]->value();
35
ctx->setQuaternionFromEulerAngles();
39
manipWindow::manipWindow(int deltaFontSize)
41
FL_NORMAL_SIZE -= deltaFontSize;
43
int width = 4 * BB + 2 * WB;
44
int height = 5 * BH + 3 * WB;
46
win = new paletteWindow
47
(width, height, CTX.non_modal_windows ? true : false, "Manipulator");
48
win->box(GMSH_WINDOW_BOX);
50
Fl_Box *top[3], *left[3];
51
top[0] = new Fl_Box(WB + 1 * BB, 1 * WB + 0 * BH, BB, BH, "X");
52
top[1] = new Fl_Box(WB + 2 * BB, 1 * WB + 0 * BH, BB, BH, "Y");
53
top[2] = new Fl_Box(WB + 3 * BB, 1 * WB + 0 * BH, BB, BH, "Z");
54
left[0] = new Fl_Box(WB + 0 * BB, 1 * WB + 1 * BH, BB, BH, "Rotation");
55
left[1] = new Fl_Box(WB + 0 * BB, 1 * WB + 2 * BH, BB, BH, "Translation");
56
left[2] = new Fl_Box(WB + 0 * BB, 1 * WB + 3 * BH, BB, BH, "Scale");
57
for(int i = 0; i < 3; i++){
58
top[i]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
59
left[i]->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
62
value[0] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 1 * BH, BB, BH);
63
value[1] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 1 * BH, BB, BH);
64
value[2] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 1 * BH, BB, BH);
65
value[3] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 2 * BH, BB, BH);
66
value[4] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 2 * BH, BB, BH);
67
value[5] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 2 * BH, BB, BH);
68
value[6] = new Fl_Value_Input(WB + 1 * BB, 1 * WB + 3 * BH, BB, BH);
69
value[7] = new Fl_Value_Input(WB + 2 * BB, 1 * WB + 3 * BH, BB, BH);
70
value[8] = new Fl_Value_Input(WB + 3 * BB, 1 * WB + 3 * BH, BB, BH);
72
for(int i = 0; i < 9; i++){
74
value[i]->minimum(0.);
75
value[i]->maximum(360.);
79
value[i]->minimum(0.1);
80
value[i]->maximum(100.);
83
value[i]->align(FL_ALIGN_RIGHT);
84
value[i]->callback(manip_update_cb);
88
Fl_Return_Button *o = new Fl_Return_Button
89
(width - BB - WB, height - BH - WB, BB, BH, "Reset");
90
o->callback(status_xyz1p_cb, (void *)"reset");
93
win->position(CTX.manip_position[0], CTX.manip_position[1]);
96
FL_NORMAL_SIZE += deltaFontSize;
99
void manipWindow::update(bool force)
101
if(force || win->shown()){
102
double val1 = CTX.lc;
104
double r0 = opt_general_rotation0(0, GMSH_GET, 0);
105
double r1 = opt_general_rotation1(0, GMSH_GET, 0);
106
double r2 = opt_general_rotation2(0, GMSH_GET, 0);
107
double t0 = opt_general_translation0(0, GMSH_GET, 0);
108
double t1 = opt_general_translation1(0, GMSH_GET, 0);
109
double t2 = opt_general_translation2(0, GMSH_GET, 0);
110
double s0 = opt_general_scale0(0, GMSH_GET, 0);
111
double s1 = opt_general_scale1(0, GMSH_GET, 0);
112
double s2 = opt_general_scale2(0, GMSH_GET, 0);
123
for(int i = 0; i < 3; i++){
124
value[i]->minimum(-360.);
125
value[i]->maximum(360.);
127
value[i+3]->minimum(-val1);
128
value[i+3]->maximum(val1);
129
value[i+3]->step(val1/200.);
130
value[i+6]->minimum(0.01);
131
value[i+6]->maximum(100.);
132
value[i+6]->step(0.01);
137
void manipWindow::show()