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

simplify drawTransform

parent 0afe9686
Branches
Tags
No related merge requests found
...@@ -128,11 +128,12 @@ GUI::GUI(int argc, char **argv) ...@@ -128,11 +128,12 @@ GUI::GUI(int argc, char **argv)
// e.g. directly loop through time steps with the keyboard) // e.g. directly loop through time steps with the keyboard)
graph[0]->gl->take_focus(); graph[0]->gl->take_focus();
// test: create another graphic window // test: create another graphic window, with a coordinate
double mat[3][3]={{3,0,0}, {0,1,0}, {0,0,1}}; // transformation
drawContext *ctx = new drawContext(new drawTransformScaled(mat)); //graph.push_back(new graphicWindow(_fontsize));
graph.push_back(new graphicWindow(_fontsize, ctx)); //drawTransform *tr = new drawTransformScaled(2,1,0, 0,1,0, 0,0,1);
graph.back()->win->show(); //graph.back()->gl->getDrawContext()->setTransform(tr);
//graph.back()->win->show();
options = new optionWindow(_fontsize); options = new optionWindow(_fontsize);
fields = new fieldWindow(_fontsize); fields = new fieldWindow(_fontsize);
......
...@@ -278,7 +278,7 @@ static void status_stepforward_cb(Fl_Widget *w, void *data) ...@@ -278,7 +278,7 @@ static void status_stepforward_cb(Fl_Widget *w, void *data)
status_play_manual(!CTX.post.anim_cycle, 1); status_play_manual(!CTX.post.anim_cycle, 1);
} }
graphicWindow::graphicWindow(int fontsize, drawContext *ctx) graphicWindow::graphicWindow(int fontsize)
{ {
static bool first = true; static bool first = true;
if(first){ if(first){
...@@ -397,7 +397,7 @@ graphicWindow::graphicWindow(int fontsize, drawContext *ctx) ...@@ -397,7 +397,7 @@ graphicWindow::graphicWindow(int fontsize, drawContext *ctx)
win->resizable(resbox); win->resizable(resbox);
// opengl window // opengl window
gl = new openglWindow(0, 0, width, glheight, 0, ctx); gl = new openglWindow(0, 0, width, glheight);
int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE); int mode = FL_RGB | FL_DEPTH | (CTX.db ? FL_DOUBLE : FL_SINGLE);
if(CTX.antialiasing) mode |= FL_MULTISAMPLE; if(CTX.antialiasing) mode |= FL_MULTISAMPLE;
gl->mode(mode); gl->mode(mode);
......
...@@ -18,7 +18,7 @@ class graphicWindow{ ...@@ -18,7 +18,7 @@ class graphicWindow{
Fl_Button *butt[12]; Fl_Button *butt[12];
Fl_Box *label[2]; Fl_Box *label[2];
public: public:
graphicWindow(int fontsize, drawContext *ctx=0); graphicWindow(int fontsize);
void setAnimButtons(int mode); void setAnimButtons(int mode);
void checkAnimButtons(); void checkAnimButtons();
}; };
......
...@@ -68,9 +68,8 @@ static void lassoZoom(drawContext *ctx, mousePosition &click1, mousePosition &cl ...@@ -68,9 +68,8 @@ static void lassoZoom(drawContext *ctx, mousePosition &click1, mousePosition &cl
GUI::instance()->manip->update(); GUI::instance()->manip->update();
} }
openglWindow::openglWindow(int x, int y, int w, int h, const char *l, openglWindow::openglWindow(int x, int y, int w, int h, const char *l)
drawContext *ctx) : Fl_Gl_Window(x, y, w, h, l)
: _ctx(ctx), Fl_Gl_Window(x, y, w, h, l)
{ {
addPointMode = lassoMode = selectionMode = false; addPointMode = lassoMode = selectionMode = false;
selection = ENT_NONE; selection = ENT_NONE;
...@@ -78,8 +77,7 @@ openglWindow::openglWindow(int x, int y, int w, int h, const char *l, ...@@ -78,8 +77,7 @@ openglWindow::openglWindow(int x, int y, int w, int h, const char *l,
undoSelection = invertSelection = 0; undoSelection = invertSelection = 0;
for(int i = 0; i < 4; i++) trySelectionXYWH[i] = 0; for(int i = 0; i < 4; i++) trySelectionXYWH[i] = 0;
_point[0] = _point[1] = _point[2] = 0.; _point[0] = _point[1] = _point[2] = 0.;
// create default draw context if none given _ctx = new drawContext();
if(!_ctx) _ctx = new drawContext();
} }
openglWindow::~openglWindow() openglWindow::~openglWindow()
......
...@@ -60,8 +60,7 @@ class openglWindow : public Fl_Gl_Window { ...@@ -60,8 +60,7 @@ class openglWindow : public Fl_Gl_Window {
public: public:
bool addPointMode, lassoMode, selectionMode; bool addPointMode, lassoMode, selectionMode;
int endSelection, undoSelection, invertSelection, quitSelection; int endSelection, undoSelection, invertSelection, quitSelection;
openglWindow(int x, int y, int w, int h, const char *l=0, openglWindow(int x, int y, int w, int h, const char *l=0);
drawContext *ctx=0);
~openglWindow(); ~openglWindow();
drawContext *getDrawContext(){ return _ctx; } drawContext *getDrawContext(){ return _ctx; }
char selectEntity(int type, char selectEntity(int type,
......
...@@ -17,24 +17,19 @@ class drawTransform { ...@@ -17,24 +17,19 @@ class drawTransform {
class drawTransformScaled : public drawTransform { class drawTransformScaled : public drawTransform {
private: private:
bool _identityTransform;
double _mat[3][3]; double _mat[3][3];
public: public:
drawTransformScaled(double mat[3][3]) : drawTransform() drawTransformScaled(double a11, double a12, double a13,
double a21, double a22, double a23,
double a31, double a32, double a33)
: drawTransform()
{ {
if(mat[0][0] != 1. || mat[0][1] != 0. || mat[0][2] != 0. || _mat[0][0] = a11; _mat[0][1] = a12; _mat[0][2] = a13;
mat[1][0] != 0. || mat[1][1] != 1. || mat[1][2] != 0. || _mat[1][0] = a21; _mat[1][1] = a22; _mat[1][2] = a23;
mat[2][0] != 0. || mat[2][1] != 0. || mat[2][2] != 1.) _mat[2][0] = a31; _mat[2][1] = a32; _mat[2][2] = a33;
_identityTransform = false;
else
_identityTransform = true;
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
_mat[i][j] = mat[i][j];
} }
virtual void transform(double &x, double &y, double &z) virtual void transform(double &x, double &y, double &z)
{ {
if(_identityTransform) return;
double xyz[3] = {x, y, z}; double xyz[3] = {x, y, z};
x = y = z = 0.; x = y = z = 0.;
for(int k = 0; k < 3; k++){ for(int k = 0; k < 3; k++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment