From 7a4ed01e0b456b1d8574f0205b867d3b726fb0a6 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 20 Dec 2000 15:28:49 +0000
Subject: [PATCH] Added resize "on the fly"

---
 Common/Context.cpp  |  5 +----
 Common/Options.h    |  6 +++++-
 Graphics/Draw.cpp   | 20 ++++++++++++++------
 Parser/Gmsh.tab.cpp |  2 +-
 Parser/Gmsh.yy.cpp  |  2 +-
 Unix/Geometry.cpp   |  3 +--
 Unix/Main.cpp       |  5 +++--
 Unix/Widgets.cpp    | 14 +++++++++-----
 Unix/Widgets.h      |  5 ++---
 Unix/XRessources.h  |  5 +++--
 tutorial/t8.geo     | 28 ++++++++++++++++++----------
 11 files changed, 58 insertions(+), 37 deletions(-)

diff --git a/Common/Context.cpp b/Common/Context.cpp
index b0a5dc0c47..b86349c0da 100644
--- a/Common/Context.cpp
+++ b/Common/Context.cpp
@@ -1,4 +1,4 @@
-/* $Id: Context.cpp,v 1.22 2000-12-11 22:09:42 geuzaine Exp $ */
+/* $Id: Context.cpp,v 1.23 2000-12-20 15:28:42 geuzaine Exp $ */
 
 #include "Gmsh.h"
 #include "Const.h"
@@ -206,9 +206,6 @@ void Init_Context(void){
   CTX.max[0]   = CTX.max[1]   = CTX.max[2]   = 1.0 ;
   CTX.range[0] = CTX.range[1] = CTX.range[2] = 1.0 ;
 
-  CTX.viewport[0] = CTX.viewport[1] = 0 ;
-  CTX.viewport[2] = CTX.viewport[3] = 1 ;
-
   CTX.vxmin = CTX.vymin = CTX.vxmax = CTX.vymax = 0. ;
 
   CTX.render_mode    = GMSH_RENDER ;
diff --git a/Common/Options.h b/Common/Options.h
index 82a066af97..12be4804b3 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -1,4 +1,4 @@
-/* $Id: Options.h,v 1.7 2000-12-20 10:40:49 geuzaine Exp $ */
+/* $Id: Options.h,v 1.8 2000-12-20 15:28:42 geuzaine Exp $ */
 #ifndef _OPTIONS_H_
 #define _OPTIONS_H_
 
@@ -37,6 +37,10 @@ StringXString PrintOptions_String[] = {
 // NUMBERS
 
 StringXNumber GeneralOptions_Number[] = {
+  { "Viewport0"    , GMSH_INT,    (void*)&CTX.viewport[0]    , 0. }, 
+  { "Viewport1"    , GMSH_INT,    (void*)&CTX.viewport[1]    , 0. }, 
+  { "Viewport2"    , GMSH_INT,    (void*)&CTX.viewport[2]    , 1. }, 
+  { "Viewport3"    , GMSH_INT,    (void*)&CTX.viewport[3]    , 1. }, 
   { "Rotation0"    , GMSH_DOUBLE, (void*)&CTX.r[0]          , 0.0 }, 
   { "Rotation1"    , GMSH_DOUBLE, (void*)&CTX.r[1]          , 0.0 }, 
   { "Rotation2"    , GMSH_DOUBLE, (void*)&CTX.r[2]          , 0.0 }, 
diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp
index 8432108b81..fdc633f552 100644
--- a/Graphics/Draw.cpp
+++ b/Graphics/Draw.cpp
@@ -1,4 +1,4 @@
-/* $Id: Draw.cpp,v 1.11 2000-12-10 23:31:45 geuzaine Exp $ */
+/* $Id: Draw.cpp,v 1.12 2000-12-20 15:28:44 geuzaine Exp $ */
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -171,13 +171,21 @@ void Orthogonalize(int x, int y){
 /*  i n i t                                                                 */
 /* ------------------------------------------------------------------------ */
 
+#ifdef _UNIX
+#include <X11/IntrinsicP.h>
+#endif
+
 void Init(void){
-  /* 
-     Attention:
-     X11 interdit de changer le contexte (GLX) en mode GL_FEEDBACK ou GL_SELECT,
-     ce qui serait le cas pour les sorties postscript...
-  */
 #ifdef _UNIX
+  /* Resize Graphical Window if told to do it */
+  XWindowAttributes  xattrib;
+  XGetWindowAttributes(XtDisplay(WID.G.bottomForm),XtWindow(WID.G.bottomForm),&xattrib);
+  XtResizeWidget(WID.G.shell,
+		 CTX.viewport[2]-CTX.viewport[0],
+		 xattrib.height+CTX.viewport[3]-CTX.viewport[1],
+		 0);
+  /* X11 forbids to change the context (GLX) in GL_FEEDBACK or GL_SELECT mode,
+     which would happen for postcript output */
   if(CTX.stream == TO_SCREEN)
     glXMakeCurrent(XtDisplay(WID.G.glw), XtWindow(WID.G.glw), XCTX.glw.context);
 #endif
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index be3b0b1085..dc8f995024 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -168,7 +168,7 @@
 #define	UNARYPREC	418
 
 #line 1 "Gmsh.y"
- /* $Id: Gmsh.tab.cpp,v 1.53 2000-12-20 12:17:10 geuzaine Exp $ */
+ /* $Id: Gmsh.tab.cpp,v 1.54 2000-12-20 15:28:45 geuzaine Exp $ */
 
 #include <stdarg.h>
 
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index cdf278bd39..f227a095f9 100644
--- a/Parser/Gmsh.yy.cpp
+++ b/Parser/Gmsh.yy.cpp
@@ -2,7 +2,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.53 2000-12-20 12:17:10 geuzaine Exp $
+ * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.54 2000-12-20 15:28:46 geuzaine Exp $
  */
 
 #define FLEX_SCANNER
diff --git a/Unix/Geometry.cpp b/Unix/Geometry.cpp
index a044380d2b..7427cea6a7 100644
--- a/Unix/Geometry.cpp
+++ b/Unix/Geometry.cpp
@@ -1,4 +1,4 @@
-/* $Id: Geometry.cpp,v 1.7 2000-12-20 12:17:13 geuzaine Exp $ */
+/* $Id: Geometry.cpp,v 1.8 2000-12-20 15:28:48 geuzaine Exp $ */
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -215,7 +215,6 @@ void ForceGeometry_G (Widgets_T *w){
                 XmNmarginHeight, 0,
                 NULL);
 
-
 }
 
 /* ------------------------------------------------------------------------ 
diff --git a/Unix/Main.cpp b/Unix/Main.cpp
index 81556c7aab..c4eeeb1f86 100644
--- a/Unix/Main.cpp
+++ b/Unix/Main.cpp
@@ -1,4 +1,4 @@
-/* $Id: Main.cpp,v 1.30 2000-12-19 08:56:56 geuzaine Exp $ */
+/* $Id: Main.cpp,v 1.31 2000-12-20 15:28:48 geuzaine Exp $ */
 
 #include <signal.h>
 
@@ -157,11 +157,12 @@ void OpenProblem(char *name){
 
   strncpy(THEM->name, TheBaseFileName,NAME_STR_L);
 
-  if(!CTX.interactive)
+  if(!CTX.interactive){
     XtVaSetValues(WID.G.shell,
                   XmNtitle, TheFileName,
                   XmNiconName, TheBaseFileName,
                   NULL);
+  }
 
   Msg(INFOS, "Opening '%s'", TheFileName); 
 
diff --git a/Unix/Widgets.cpp b/Unix/Widgets.cpp
index bef0ce1fc3..be853e1576 100644
--- a/Unix/Widgets.cpp
+++ b/Unix/Widgets.cpp
@@ -1,4 +1,4 @@
-/* $Id: Widgets.cpp,v 1.20 2000-12-20 12:17:13 geuzaine Exp $ */
+/* $Id: Widgets.cpp,v 1.21 2000-12-20 15:28:48 geuzaine Exp $ */
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -417,8 +417,11 @@ void CreateWidgets_G(Widgets_T *w){
   
   /* container form */
   i=0;
-  XtSetArg(arg[i], XmNresizable, False); i++;  
-  XtSetArg(arg[i], XmNresizePolicy, XmRESIZE_NONE); i++;
+  // We want glw to be able to force the size of the container win
+  //XtSetArg(arg[i], XmNresizable, False); i++;  
+  //XtSetArg(arg[i], XmNresizePolicy, XmRESIZE_NONE); i++;
+  XtSetArg(arg[i], XmNwidth, 700); i++;  
+  XtSetArg(arg[i], XmNheight, 525); i++;
   w->G.containerForm = XmCreateForm(w->G.shell, "GcontainerForm", arg, i);
   XtManageChild(w->G.containerForm);
 
@@ -427,6 +430,7 @@ void CreateWidgets_G(Widgets_T *w){
   XtSetArg(arg[i], XmNcolormap, XCTX.glw.colormap); i++;
   XtSetArg(arg[i], GLwNvisualInfo, XCTX.glw.visinfo); i++;
   XtSetArg(arg[i], GLwNinstallColormap, True); i++;
+
   w->G.glw = GLwCreateMDrawingArea(w->G.containerForm, "glw", arg, i);
   XtManageChild(w->G.glw);
 
@@ -496,8 +500,8 @@ void CreateWidgets_G(Widgets_T *w){
   /* 3 textes au milieu */
 
   i=0;
-  XtSetArg(arg[i], XmNresizable, False); i++;  
-  XtSetArg(arg[i], XmNresizePolicy, XmRESIZE_NONE); i++;
+  //XtSetArg(arg[i], XmNresizable, False); i++;  
+  //XtSetArg(arg[i], XmNresizePolicy, XmRESIZE_NONE); i++;
   w->G.textForm = XmCreateForm(w->G.bottomForm, "GtextForm", arg, i);
   XtManageChild(w->G.textForm);
 
diff --git a/Unix/Widgets.h b/Unix/Widgets.h
index e70dbac4d1..d51fded87a 100644
--- a/Unix/Widgets.h
+++ b/Unix/Widgets.h
@@ -1,4 +1,4 @@
-/* $Id: Widgets.h,v 1.10 2000-12-20 12:17:13 geuzaine Exp $ */
+/* $Id: Widgets.h,v 1.11 2000-12-20 15:28:48 geuzaine Exp $ */
 #ifndef _WIDGETS_H_
 #define _WIDGETS_H_
 
@@ -49,8 +49,7 @@ typedef struct {
 
   struct {
     Widget   shell, containerForm ;
-    Widget   drawForm ;
-    Widget     glw, glo ; 
+    Widget   glw, glo ; 
     Widget   bottomForm ;
     Widget     Butt[7] ;
     Widget     textForm, infoLabel, selectLabel, statusLabel ;
diff --git a/Unix/XRessources.h b/Unix/XRessources.h
index a1c957237e..5e0e0de606 100644
--- a/Unix/XRessources.h
+++ b/Unix/XRessources.h
@@ -1,4 +1,4 @@
-/* $Id: XRessources.h,v 1.3 2000-11-25 15:26:12 geuzaine Exp $ */
+/* $Id: XRessources.h,v 1.4 2000-12-20 15:28:48 geuzaine Exp $ */
 
 /* 
    Les resources ci-dessous sont prises en compte par defaut. Toutre 
@@ -55,7 +55,8 @@ String FallbackResources[] = {
   "gmshMW*HDaboutDialog*fontList: fixed",
 
   /* geometrie */
-  "gmshGW*geometry: 700x525+20+30",
+  //"gmshGW*geometry: 700x525+20+30", Dont't force the dimension this way !!!
+  "gmshGW*geometry: +20+30",
   "gmshMW*geometry: x420+800+80",
   "gmshCW*geometry: 440x130+30+570",
 
diff --git a/tutorial/t8.geo b/tutorial/t8.geo
index 4aed4c7652..c6696bce96 100644
--- a/tutorial/t8.geo
+++ b/tutorial/t8.geo
@@ -56,9 +56,16 @@ For num In {1:255}
   
   PostProcessing.View[0].Raise2 += 0.001*t ;
 
+  If (num == 3)
+// We want to use mpeg_encode when num==3, so we set the width and
+// height of the graphic window have to be multiple of 16!
+    General.Viewport2 = 320 ; 
+    General.Viewport3 = 240 ;
+  EndIf
+
 // It is possible to nest loops:
 
-  For num2 In {1:10}
+  For num2 In {1:50}
 
     General.Rotation0 += 10 ;
     General.Rotation1 = General.Rotation0 / 3 ;
@@ -67,19 +74,20 @@ For num In {1:255}
     Sleep 0.01; // sleep for 0.01 second
     Draw; // draw the scene
 
-  EndFor
+    If ((num == 3) && (num2 < 10))
+      Print Sprintf("t8-0%g.jpg", num2); // print the scene in a jpeg file
+    EndIf
 
-// It is also possible make tests
+    If ((num == 3) && (num2 >= 10))
+      Print Sprintf("t8-%g.jpg", num2); // print the scene in a jpeg file
+    EndIf
 
-  If (num < 10)
+  EndFor
 
-// The Sprintf function permits to create complex strings using
-// variables (since all Gmsh variables are treated internally as
-// double precision numbers, the format should only contain valid
-// double precision number format specifiers):
-   
-    Print Sprintf("t8-0%g.jpg", num); // print the scene in a jpeg file
 
+  If(num == 3)
+    // We make a system call to generate the mpeg
+    System "mpeg_encode t8.par" ;    
   EndIf
 
 EndFor
-- 
GitLab