From db2d7b674d885f59f9928d57e49c16025cbaffb7 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 27 Aug 2006 23:10:36 +0000
Subject: [PATCH] draw the rotation center

---
 Common/Context.h       |  4 ++--
 Common/Options.cpp     |  3 ++-
 Fltk/Callbacks.cpp     |  8 ++++++--
 Fltk/GUI.cpp           |  8 ++++----
 Fltk/Opengl_Window.cpp |  4 +++-
 Graphics/Geom.cpp      | 26 +++++++++++++++++---------
 doc/TODO               |  7 ++++++-
 7 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index a79fb84706..5d0c21d729 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -91,8 +91,8 @@ public :
 
   int db;                     // double buffer? 
   int ortho;                  // orthogonal projection? 
-  int draw_bbox;              // always draw the bounding boxes?
-  int fast_redraw;            // only draw the bbox when rotating/panning the model?
+  int draw_bbox, draw_rotation_center; // draw the bounding boxes and the rot center?
+  int fast_redraw;            // draw simplified model during user interaction
   int small_axes, small_axes_size, small_axes_pos[2]; // small axes
   int axes, axes_auto_position, axes_tics[3]; // large axes
   double axes_position[6];  
diff --git a/Common/Options.cpp b/Common/Options.cpp
index f0d0082164..2c1fcd26a4 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.307 2006-08-27 16:14:46 geuzaine Exp $
+// $Id: Options.cpp,v 1.308 2006-08-27 23:10:35 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -133,6 +133,7 @@ void Init_Options(int num)
   CTX.polygon_offset = 0;
   CTX.printing = 0;
   CTX.mesh_timer[0] = CTX.mesh_timer[1] = CTX.mesh_timer[2] = 0.;
+  CTX.draw_rotation_center = 0;
   CTX.mesh.draw = 1;
   CTX.post.draw = 1;
   CTX.post.list = NULL;
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 4197ec044b..cdc4db20fc 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.454 2006-08-27 16:14:46 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.455 2006-08-27 23:10:35 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -958,7 +958,10 @@ void general_options_ok_cb(CALLBACK_ARGS)
   }
   if(data){
     char *name = (char*)data;
-    if(!strcmp(name, "light_value")){
+    if(!strcmp(name, "rotation_center_coord")){
+      CTX.draw_rotation_center = 1;
+    }
+    else if(!strcmp(name, "light_value")){
       double x, y, z;
       x = WID->gen_value[2]->value();
       y = WID->gen_value[3]->value();
@@ -1049,6 +1052,7 @@ void general_options_ok_cb(CALLBACK_ARGS)
     CTX.post.draw = CTX.mesh.draw = 0;
   Draw();
   CTX.post.draw = CTX.mesh.draw = 1;
+  CTX.draw_rotation_center = 0;
 }
 
 void general_arrow_param_cb(CALLBACK_ARGS)
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 27eeb22910..bb1a920622 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.544 2006-08-27 16:14:46 geuzaine Exp $
+// $Id: GUI.cpp,v 1.545 2006-08-27 23:10:35 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -1757,12 +1757,12 @@ void GUI::create_option_window()
       gen_push_butt[0]->callback(general_options_rotation_center_select_cb);
 
       gen_value[8] = new Fl_Value_Input(L + 2 * WB, 2 * WB + 8 * BH, IW / 3, BH);
-      gen_value[8]->callback(general_options_ok_cb);
+      gen_value[8]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
       gen_value[9] = new Fl_Value_Input(L + 2 * WB + IW / 3, 2 * WB + 8 * BH, IW / 3, BH);
-      gen_value[9]->callback(general_options_ok_cb);
+      gen_value[9]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
       gen_value[10] = new Fl_Value_Input(L + 2 * WB + 2 * IW / 3, 2 * WB + 8 * BH, IW / 3, BH, "Rotation center");
       gen_value[10]->align(FL_ALIGN_RIGHT);
-      gen_value[10]->callback(general_options_ok_cb);
+      gen_value[10]->callback(general_options_ok_cb, (void*)"rotation_center_coord");
 
       o->end();
     }
diff --git a/Fltk/Opengl_Window.cpp b/Fltk/Opengl_Window.cpp
index 5d0380b5e1..f605764577 100644
--- a/Fltk/Opengl_Window.cpp
+++ b/Fltk/Opengl_Window.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl_Window.cpp,v 1.69 2006-08-25 23:52:56 geuzaine Exp $
+// $Id: Opengl_Window.cpp,v 1.70 2006-08-27 23:10:36 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -273,6 +273,7 @@ int Opengl_Window::handle(int event)
 
   case FL_RELEASE:
     curr.set();
+    CTX.draw_rotation_center = 0;
     if(!LassoMode) {
       CTX.mesh.draw = 1;
       CTX.post.draw = 1;
@@ -318,6 +319,7 @@ int Opengl_Window::handle(int event)
 	CTX.t[1] += (curr.wnr[1] - click.wnr[1]);
         CTX.t[2] = 0.;
       }
+      CTX.draw_rotation_center = 1;
       if(CTX.fast_redraw) {
         CTX.mesh.draw = 0;
         CTX.post.draw = 0;
diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp
index 8ecd1c2fe8..132bc03122 100644
--- a/Graphics/Geom.cpp
+++ b/Graphics/Geom.cpp
@@ -1,4 +1,4 @@
-// $Id: Geom.cpp,v 1.117 2006-08-20 14:12:40 geuzaine Exp $
+// $Id: Geom.cpp,v 1.118 2006-08-27 23:10:36 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -445,16 +445,24 @@ void Draw_Geom()
     glColor4ubv((GLubyte *) & CTX.color.axes);
     glLineWidth(CTX.line_width);
     gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
-    if(!CTX.axes_auto_position){
+    if(CTX.axes_auto_position){
+      double bb[6] = {CTX.min[0], CTX.max[0], CTX.min[1], 
+		      CTX.max[1], CTX.min[2], CTX.max[2]};
+      Draw_Axes(CTX.axes, CTX.axes_tics, CTX.axes_format, CTX.axes_label, bb);
+    }
+    else{
       Draw_Axes(CTX.axes, CTX.axes_tics, CTX.axes_format, CTX.axes_label, 
 		CTX.axes_position);
     }
-    else if(geometryExists){
-      double bb[6] = {CTX.min[0], CTX.max[0],
-		      CTX.min[1], CTX.max[1],
-		      CTX.min[2], CTX.max[2]};
-      Draw_Axes(CTX.axes, CTX.axes_tics, CTX.axes_format, CTX.axes_label, bb);
-    }
   }
-}
 
+  if(CTX.draw_rotation_center){
+    glColor4ubv((GLubyte *) & CTX.color.fg);
+    if(CTX.rotation_center_cg)
+      Draw_Sphere(5, CTX.cg[0], CTX.cg[1], CTX.cg[2], CTX.geom.light);
+    else
+      Draw_Sphere(5, CTX.rotation_center[0], CTX.rotation_center[1], 
+		  CTX.rotation_center[2], CTX.geom.light);
+  }
+
+}
diff --git a/doc/TODO b/doc/TODO
index bd5eba5ef2..4107a08864 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -1,4 +1,9 @@
-$Id: TODO,v 1.17 2006-08-26 22:30:06 geuzaine Exp $
+$Id: TODO,v 1.18 2006-08-27 23:10:36 geuzaine Exp $
+
+********************************************************************
+
+should implement a better algo to determine which axes to draw 
+(cf. mathematica or qwt3dplot)
 
 ********************************************************************
 
-- 
GitLab