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

*** empty log message ***

parent a08f4c91
No related branches found
No related tags found
No related merge requests found
#include "Gmsh.h"
#include "GmshUI.h"
#include "Geo.h"
#include "Mesh.h"
#include "Draw.h"
#include "Views.h"
#include "OpenFile.h"
#include "Context.h"
#include "GUI.h"
#include <FL/fl_file_chooser.H>
extern GUI *WID;
extern Mesh M;
extern Context_T CTX;
// File Menu
void file_open_cb(void) {
char *newfile;
newfile = fl_file_chooser("Open File", "*.geo", NULL);
if (newfile != NULL) {
OpenProblem(newfile);
Init();
Draw();
}
}
void file_merge_cb(void) {
char *newfile;
newfile = fl_file_chooser("Merge File", "*.{geo,pos,msh}", NULL);
if (newfile != NULL) {
MergeProblem(newfile);
Init();
Draw();
}
}
void file_save_cb(void) {
}
void file_save_as_cb(void) {
}
void file_reload_all_views_cb(void) {
}
void file_remove_all_views_cb(void) {
}
void file_quit_cb(void) {
exit(0);
}
// Option Menu
void opt_general_cb(void) {
WID->opt_general();
}
void opt_geometry_cb(void) {
}
void opt_mesh_cb(void) {
}
void opt_post_cb(void) {
}
void opt_stat_cb(void) {
}
// Help Menu
void help_short_cb(void){
}
void help_about_cb(void){
}
// Module Menu
void mod_geometry_cb(void){
}
void mod_mesh_cb(void){
}
void mod_post_cb(void){
}
// View Menus
void view_reload_cb(Fl_Widget* w, void* data){
printf("Reload view %d \n", (int)data);
}
void view_remove_cb(Fl_Widget* w, void* data){
printf("Remove view %d \n", (int)data);
}
void view_duplicate_cb(Fl_Widget* w, void* data){
printf("Duplicate view %d \n", (int)data);
}
void view_lighting_cb(Fl_Widget* w, void* data){
printf("Light view %d \n", (int)data);
}
void view_elements_cb(Fl_Widget* w, void* data){
printf("Show Elements view %d \n", (int)data);
}
void view_applybgmesh_cb(Fl_Widget* w, void* data){
printf("Apply bgmesh view %d \n", (int)data);
}
void view_timestep_cb(Fl_Widget* w, void* data){
printf("Timestep view %d \n", (int)data);
}
void view_options_cb(Fl_Widget* w, void* data){
printf("Options view %d \n", (int)data);
}
#ifndef _CALLBACKS_H_
#define _CALLBACKS_H_
void file_open_cb(void) ;
void file_merge_cb(void) ;
void file_save_cb(void) ;
void file_save_as_cb(void) ;
void file_reload_all_views_cb(void) ;
void file_remove_all_views_cb(void) ;
void file_quit_cb(void) ;
void opt_general_cb(void) ;
void opt_geometry_cb(void) ;
void opt_mesh_cb(void) ;
void opt_post_cb(void) ;
void opt_stat_cb(void) ;
void help_short_cb(void) ;
void help_about_cb(void) ;
void mod_geometry_cb(void) ;
void mod_mesh_cb(void) ;
void mod_post_cb(void) ;
void view_reload_cb(Fl_Widget* w, void*) ;
void view_remove_cb(Fl_Widget* w, void*) ;
void view_duplicate_cb(Fl_Widget* w, void*) ;
void view_lighting_cb(Fl_Widget* w, void*) ;
void view_elements_cb(Fl_Widget* w, void*) ;
void view_timestep_cb(Fl_Widget* w, void*) ;
void view_options_cb(Fl_Widget* w, void*) ;
void view_applybgmesh_cb(Fl_Widget* w, void*) ;
#endif
// To make the interface as visually consistent as possible, please:
// - use the BH and WB values for button heights and window borders
// - use CTX.fontsize for font sizes
// - examine what's already done before adding something new...
#include "Gmsh.h"
#include "GmshUI.h"
#include "Context.h"
#include "Const.h"
#include "Geo.h"
#include "Mesh.h"
#include "Draw.h"
#include "Version.h"
#include "GUI.h"
#include "Callbacks.h"
extern Context_T CTX;
// Definition of the static menus
Fl_Menu_Item m_menubar_table[] = {
{"File", 0, 0, 0, FL_SUBMENU},
{"Open...", FL_CTRL+'o', (Fl_Callback *)file_open_cb, 0},
{"Merge...", FL_CTRL+'m', (Fl_Callback *)file_merge_cb, 0, FL_MENU_DIVIDER},
{"Save", FL_CTRL+'s', (Fl_Callback *)file_save_cb, 0},
{"Save As...", FL_CTRL+'p', (Fl_Callback *)file_save_as_cb, 0, FL_MENU_DIVIDER},
{"Reload All Views", FL_CTRL+'l', (Fl_Callback *)file_reload_all_views_cb, 0},
{"Remove All Views", FL_CTRL+'r', (Fl_Callback *)file_remove_all_views_cb, 0, FL_MENU_DIVIDER},
{"Quit", FL_CTRL+'q', (Fl_Callback *)file_quit_cb, 0},
{0},
{"Options",0,0,0,FL_SUBMENU},
{"Geometry...", FL_SHIFT+'g', (Fl_Callback *)opt_geometry_cb, 0},
{"Mesh...", FL_SHIFT+'m', (Fl_Callback *)opt_mesh_cb, 0},
{"Post-Processing...", FL_SHIFT+'p', (Fl_Callback *)opt_post_cb, 0, FL_MENU_DIVIDER},
{"General...", FL_SHIFT+'o', (Fl_Callback *)opt_general_cb, 0},
{"Statistics...", FL_SHIFT+'i', (Fl_Callback *)opt_stat_cb, 0},
{0},
{"Help",0,0,0,FL_SUBMENU},
{"Short Help...", 0, (Fl_Callback *)help_short_cb, 0, FL_MENU_DIVIDER},
{"About...", 0, (Fl_Callback *)help_about_cb, 0},
{0},
{0}
};
Fl_Menu_Item m_module_table[] = {
{" Geometry", 'g', (Fl_Callback *)mod_geometry_cb, 0},
{" Mesh", 'm', (Fl_Callback *)mod_mesh_cb, 0},
{" Post-Processing", 'p', (Fl_Callback *)mod_post_cb, 0},
{0}
};
// The GUI constructor creates ONLY the widgets that always exist (we
// want the lowest memory footprint for the interface and the fastest
// startup time). All optional dialogs are also created only once, but
// on demand.
GUI::GUI() {
int i, x, y;
BH = 2*CTX.fontsize+2;
WB = CTX.fontsize-6;
if(strlen(CTX.display)) Fl::display(CTX.display);
// Menu Window
{
int width = 152 ;
int height = 450 ;
m_window = new Fl_Window(width,height);
m_window->box(FL_THIN_UP_BOX);
{
Fl_Menu_Bar *o = new Fl_Menu_Bar(0,0,width,BH);
o->menu(m_menubar_table);
o->textsize(CTX.fontsize);
o->box(FL_UP_BOX);
}
Fl_Box *o = new Fl_Box(0,BH,width,BH+6);
o->box(FL_UP_BOX);
y = BH+3;
m_navig_butt[0] = new Fl_Button(2,y,20,BH/2,"@<");
m_navig_butt[0]->labeltype(FL_SYMBOL_LABEL);
m_navig_butt[0]->box(FL_FLAT_BOX);
m_navig_butt[0]->selection_color(FL_WHITE);
m_navig_butt[1] = new Fl_Button(2,y+BH/2,20,BH/2,"@>");
m_navig_butt[1]->labeltype(FL_SYMBOL_LABEL);
m_navig_butt[1]->box(FL_FLAT_BOX);
m_navig_butt[1]->selection_color(FL_WHITE);
m_module_butt = new Fl_Choice(22,y,width-26,BH);
m_module_butt->menu(m_module_table);
m_module_butt->textsize(CTX.fontsize);
m_module_butt->box(FL_THIN_DOWN_BOX);
y = BH+ BH +6;
for(i=0; i<NB_BUTT_MAX; i++){
m_push_butt[i] = new Fl_Button(0,y+i*BH,width,BH);
m_push_butt[i]->labelsize(CTX.fontsize);
m_push_butt[i]->hide();
m_toggle_butt[i] = new Fl_Light_Button(0,y+i*BH,width,BH,"test");
m_toggle_butt[i]->labelsize(CTX.fontsize);
if(i>5)m_toggle_butt[i]->hide();
m_popup_butt[i] = new Fl_Menu_Button(0,y+i*BH,width,BH);
m_popup_butt[i]->type(Fl_Menu_Button::POPUP3);
m_popup_butt[i]->add("Reload", 0,
(Fl_Callback *)view_reload_cb, (void*)i, 0);
m_popup_butt[i]->add("Remove", 0,
(Fl_Callback *)view_remove_cb, (void*)i, 0);
m_popup_butt[i]->add("Duplicate", 0,
(Fl_Callback *)view_duplicate_cb, (void*)i, 0);
m_popup_butt[i]->add("Lightning", 0,
(Fl_Callback *)view_lighting_cb, (void*)i, 0);
m_popup_butt[i]->add("Show Elements", 0,
(Fl_Callback *)view_elements_cb, (void*)i, 0);
m_popup_butt[i]->add("Apply as Background Mesh", 0,
(Fl_Callback *)view_applybgmesh_cb, (void*)i, FL_MENU_DIVIDER);
m_popup_butt[i]->add("Time Step...", 0,
(Fl_Callback *)view_timestep_cb, (void*)i, 0);
m_popup_butt[i]->add("Options...", 0,
(Fl_Callback *)view_options_cb, (void*)i, 0);
m_popup_butt[i]->textsize(CTX.fontsize);
if(i>5)m_popup_butt[i]->hide();
}
m_window->resizable(m_window);
m_window->position(800,50);
m_window->end();
m_window->show();
}
// Graphic Window
{
g_window = new Fl_Window(700,520);
g_opengl_window = new Opengl_Window(0,0,700,500);
{
Fl_Group *o = new Fl_Group(0,500,700,20);
o->box(FL_THIN_UP_BOX);
x = 2;
g_status_butt[0] = new Fl_Button(x,502,15,16,"X"); x+=15;
//g_status_butt[0]->tooltip("Set X view");
g_status_butt[1] = new Fl_Button(x,502,15,16,"Y"); x+=15;
g_status_butt[2] = new Fl_Button(x,502,15,16,"Z"); x+=15;
g_status_butt[3] = new Fl_Button(x,502,16,16,"1:1"); x+=16;
g_status_butt[4] = new Fl_Button(x,502,15,16,"?"); x+=15;
g_status_butt[5] = new Fl_Button(x,502,15,16,">>"); x+=15;
g_status_butt[6] = new Fl_Button(x,502,15,16,"0"); x+=15;
for(i = 0 ; i<7 ; i++){
g_status_butt[i]->box(FL_FLAT_BOX);
g_status_butt[i]->selection_color(FL_WHITE);
g_status_butt[i]->labelsize(CTX.fontsize);
g_status_butt[i]->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
}
g_status_box[0] = new Fl_Box(x,502,(700-x)/3,16);
g_status_box[1] = new Fl_Box(x+(700-x)/3,5022,(700-x)/3,16);
g_status_box[2] = new Fl_Box(x+2*(700-x)/3,5022,(700-x)/3-2,16);
for(i = 0 ; i<3 ; i++){
g_status_box[i]->box(FL_FLAT_BOX);
g_status_box[i]->labelsize(CTX.fontsize);
g_status_box[i]->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
}
o->end();
}
g_window->resizable(g_opengl_window);
g_window->position(20,30);
g_window->end();
g_window->show();
}
// Draw the actual scene
g_opengl_window->redraw();
}
// Definition of general purpose public GUI functions. This is mainly
// for compatibility with the old Motif programming structure.
void GUI::draw_gl(){
g_opengl_window->redraw();
}
void GUI::draw_gl_overlay(){
g_opengl_window->redraw_overlay();
}
void GUI::run(){
Fl::run();
}
void GUI::check(){
Fl::check();
}
static int initw, inith, init=1;
void GUI::set_size(int w, int h){
if(init){
init = 0;
initw = w;
inith = h;
}
if(w == initw && h == inith) return;
initw = w;
inith = h;
int hh = g_window->h()-g_opengl_window->h();
g_window->size(w,h+hh);
}
// The window for general options
static int init_opt_general = 0;
void GUI::opt_general(){
if(!init_opt_general){
init_opt_general = 1 ;
int width = 280;
int height = 5*WB+8*BH ;
gen_window = new Fl_Window(width,height);
gen_window->box(FL_THIN_UP_BOX);
{
Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH);
{
Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Miscellaneous");
o->labelsize(CTX.fontsize);
gen_butt[0] = new Fl_Check_Button(2*WB, 2*WB+BH, 150, BH, "Show moving axes");
gen_butt[1] = new Fl_Check_Button(2*WB, 2*WB+2*BH, 150, BH, "Show small axes");
gen_butt[2] = new Fl_Check_Button(2*WB, 2*WB+3*BH, 150, BH, "Enable fast redraw");
gen_butt[3] = new Fl_Check_Button(2*WB, 2*WB+4*BH, 150, BH, "Use Display lists");
gen_butt[4] = new Fl_Check_Button(2*WB, 2*WB+5*BH, 150, BH, "Enable alpha blending");
gen_butt[5] = new Fl_Check_Button(2*WB, 2*WB+6*BH, 150, BH, "Trackball rotation mode");
for(int i=0 ; i<6 ; i++){
gen_butt[i]->type(FL_TOGGLE_BUTTON);
gen_butt[i]->down_box(FL_DOWN_BOX);
gen_butt[i]->labelsize(CTX.fontsize);
gen_butt[i]->selection_color(FL_YELLOW);
}
o->end();
}
{
Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Projection");
o->labelsize(CTX.fontsize);
o->hide();
gen_butt[6] = new Fl_Check_Button(2*WB, 2*WB+BH, 150, BH, "Orthographic");
gen_butt[7] = new Fl_Check_Button(2*WB, 2*WB+2*BH, 150, BH, "Perspective");
for(int i=6 ; i<8 ; i++){
gen_butt[i]->type(FL_RADIO_BUTTON);
gen_butt[i]->labelsize(CTX.fontsize);
gen_butt[i]->selection_color(FL_YELLOW);
}
o->end();
}
{
Fl_Group* o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Light and color");
o->labelsize(CTX.fontsize);
o->hide();
gen_value[0] = new Fl_Value_Input(2*WB, 2*WB+BH, 100, BH, "Color Scheme");
gen_value[0]->minimum(1); gen_value[0]->maximum(3); gen_value[0]->step(1);
gen_value[1] = new Fl_Value_Input(2*WB, 2*WB+2*BH, 100, BH, "Shininess");
gen_value[1]->minimum(0); gen_value[1]->maximum(100); gen_value[1]->step(1);
gen_value[2] = new Fl_Value_Input(2*WB, 2*WB+3*BH, 100, BH, "Light Position X");
gen_value[2]->minimum(0); gen_value[2]->maximum(100); gen_value[2]->step(1);
gen_value[3] = new Fl_Value_Input(2*WB, 2*WB+4*BH, 100, BH, "Light Position Y");
gen_value[3]->minimum(0); gen_value[3]->maximum(100); gen_value[3]->step(1);
gen_value[4] = new Fl_Value_Input(2*WB, 2*WB+5*BH, 100, BH, "Light Position Z");
gen_value[4]->minimum(0); gen_value[4]->maximum(100); gen_value[4]->step(1);
for(int i=0 ; i<5 ; i++){
gen_value[i]->labelsize(CTX.fontsize);
gen_value[i]->type(FL_HORIZONTAL);
gen_value[i]->align(FL_ALIGN_RIGHT);
}
o->end();
}
o->end();
}
{
Fl_Button* o = new Fl_Button(width-2*60-2*WB, height-BH-WB, 60, BH, "cancel");
o->labelsize(CTX.fontsize);
}
{
Fl_Return_Button* o = new Fl_Return_Button(width-60-WB, height-BH-WB, 60, BH, "OK");
o->labelsize(CTX.fontsize);
}
gen_window->end();
gen_window->show();
}
else{
if(gen_window->shown())
gen_window->hide();
else
gen_window->show();
}
}
#ifndef _GUI_H_
#define _GUI_H_
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/fl_draw.H>
#include <FL/gl.h>
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Fl_Light_Button.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Value_Input.H>
#define NB_BUTT_MAX 100
// New composite widgets
class Opengl_Window : public Fl_Gl_Window {
void draw();
void draw_overlay();
int handle(int);
// new
void draw_highlight();
void clear_overlay();
void draw_overlay_zoom();
void draw_overlay_highlight();
public:
Opengl_Window(int x,int y,int w,int h,const char *l=0)
: Fl_Gl_Window(x, y, w, h, l) {}
};
// The GUI class contains only the important widgets
class GUI{
int BH; // button height
int WB; // window border
// Windows
Fl_Window *m_window, *g_window, *gen_window, *geo_window ;
Fl_Window *mesh_window, *post_window, *stat_window ;
Fl_Window *view_window ;
Opengl_Window *g_opengl_window ;
// We keep the following widgets for easy further reference
// menu window
Fl_Choice *m_module_butt ;
Fl_Button *m_navig_butt [2] ;
Fl_Button *m_push_butt [NB_BUTT_MAX] ;
Fl_Light_Button *m_toggle_butt [NB_BUTT_MAX] ;
Fl_Menu_Button *m_popup_butt [NB_BUTT_MAX] ;
// graphic window
Fl_Button *g_status_butt[7] ;
Fl_Box *g_status_box[3] ;
// general options window
Fl_Check_Button *gen_butt[10] ;
Fl_Value_Input *gen_value[10] ;
// geometry options window
// mesh options window
// post-processing options window
// statistics window
// view options window
public:
GUI();
void run();
void check();
void draw_gl();
void draw_gl_overlay();
void set_size(int w, int h);
void opt_general();
void opt_geometry();
void opt_mesh();
void opt_post();
void opt_stat();
};
#endif
// $Id: Main.cpp,v 1.2 2001-01-08 08:02:57 geuzaine Exp $
#include <signal.h>
#include "Gmsh.h"
#include "GmshUI.h"
#include "Geo.h"
#include "Verif.h"
#include "Mesh.h"
#include "Draw.h"
#include "Context.h"
#include "ColorTable.h"
#include "Parser.h"
#include "Static.h"
#include "Version.h"
#include "GUI.h"
#include "OpenFile.h"
#include "GetOptions.h"
extern List_T *Post_ViewList;
int SHOW_ALL_ENTITIES ;
void AddViewInUI(int, char *, int){}
GUI *WID ;
int main(int argc, char *argv[]){
int i, nbf;
extern char TextAbout[1024];
// Gmsh default context options
Init_Context();
// Command line options
Get_Options(argc, argv, &nbf);
if(CTX.verbosity)
fprintf(stderr, "%s, Version %.2f\n", gmsh_progname, GMSH_VERSION);
// Initialize the static Mesh
M.Vertices = NULL ;
M.VertexEdges = NULL ;
M.Simplexes = NULL ;
M.Points = NULL ;
M.Curves = NULL ;
M.SurfaceLoops = NULL ;
M.EdgeLoops = NULL ;
M.Surfaces = NULL ;
M.Volumes = NULL ;
M.PhysicalGroups = NULL ;
M.Metric = NULL ;
// Signal handling
signal(SIGINT, Signal);
signal(SIGSEGV, Signal);
signal(SIGFPE, Signal);
// Non-interactive Gmsh
if(CTX.interactive){
OpenProblem(CTX.filename);
if(yyerrorstate)
exit(1);
else {
if(nbf > 1){
for(i=1;i<nbf;i++) MergeProblem(TheFileNameTab[i]);
}
if(TheBgmFileName){
MergeProblem(TheBgmFileName);
if(List_Nbr(Post_ViewList))
BGMWithView((Post_View*)List_Pointer(Post_ViewList, List_Nbr(Post_ViewList)-1));
else
Msg(ERROR, "Invalid Background Mesh (no View)");
}
if(CTX.interactive > 0){
mai3d(THEM, CTX.interactive);
Print_Mesh(THEM,NULL,CTX.mesh.format);
}
else
Print_Geo(THEM, NULL);
exit(1);
}
}
// Interactive Gmsh
CTX.interactive = -1 ; // The GUI is not ready yet for interactivity
// Text for about window
sprintf(TextAbout, "%s\n \n%s%.2f\n%s\n%s\n%s\n%s\n%s\n%s\n \n%s\n \n"
"Type 'gmsh -help' for command line options",
gmsh_progname, gmsh_version, GMSH_VERSION,
gmsh_os, gmsh_date, gmsh_host, gmsh_packager,
gmsh_url, gmsh_email, gmsh_copyright);
// Create the GUI
WID = new GUI();
// The GUI is ready
CTX.interactive = 0 ;
CTX.expose = 1 ;
// Say welcome!
Msg(STATUS, "Ready");
Msg(SELECT, "Gmsh %.2f", GMSH_VERSION);
// Display the GUI to have a quick "a la Windows" launch time
WID->check();
// Open input file
OpenProblem(CTX.filename);
// Merge all Input Files, then init first context (geometry or post)
if(nbf > 1){
for(i=1;i<nbf;i++) MergeProblem(TheFileNameTab[i]);
//ActualizeContextCb (NULL,(XtPointer)CONTEXT_POST,NULL);
}
else {
//ActualizeContextCb(NULL,(XtPointer)CONTEXT_GEOM,NULL);
}
// Read background mesh on disk
if(TheBgmFileName){
MergeProblem(TheBgmFileName);
if(List_Nbr(Post_ViewList))
BGMWithView((Post_View*)List_Pointer(Post_ViewList, List_Nbr(Post_ViewList)-1));
else
Msg(ERROR, "Invalid Background Mesh (no View)");
}
// Draw the actual scene
Init();
Draw();
// loop
WID->run();
}
# $Id: Makefile,v 1.1 2001-01-08 08:03:16 geuzaine Exp $
#
# Makefile for "libFltk.a"
#
.IGNORE:
CC = c++
RM = rm
RANLIB = ranlib
LIB = ../lib/libFltk.a
INCLUDE = -I../Common -I../DataStr -I../Graphics -I../Geo\
-I../Mesh -I../Parser -I../Fltk
C_FLAGS = -g -Wall
OS_FLAGS = -D_LITTLE_ENDIAN
VERSION_FLAGS = -D_NOTHREADS -D_FLTK
GL_INCLUDE = -I$(HOME)/SOURCES/Mesa-3.1/include\
-I$(HOME)/SOURCES/Mesa-3.1/include/GL
GUI_INCLUDE = -I$(HOME)/SOURCES/fltk
RMFLAGS = -f
CFLAGS = $(C_FLAGS) $(OS_FLAGS) $(VERSION_FLAGS) $(INCLUDE)\
$(GUI_INCLUDE) $(GL_INCLUDE)
SRC = Main.cpp \
Message.cpp \
GUI.cpp\
Opengl.cpp\
Callbacks.cpp
OBJ = $(SRC:.cpp=.o)
.SUFFIXES: .o .cpp
$(LIB): $(OBJ)
ar ruvs $(LIB) $(OBJ)
$(RANLIB) $(LIB)
.cpp.o:
$(CC) $(CFLAGS) -c $<
clean:
$(RM) $(RMFLAGS) *.o
lint:
$(LINT) $(CFLAGS) $(SRC)
depend:
(sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
$(CC) -MM $(CFLAGS) ${SRC} \
) >Makefile.new
cp Makefile Makefile.bak
cp Makefile.new Makefile
$(RM) $(RMFLAGS) Makefile.new
# DO NOT DELETE THIS LINE
Main.o: Main.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
../Common/GmshUI.h ../Geo/Geo.h ../Geo/Verif.h ../Mesh/Mesh.h \
../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \
../Common/Views.h ../Common/Const.h ../Common/ColorTable.h \
../Common/Context.h ../Parser/Parser.h ../Common/Static.h \
../Common/Version.h GUI.h ../Parser/OpenFile.h ../Common/GetOptions.h
Message.o: Message.cpp ../Common/Gmsh.h ../Common/Message.h \
../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \
../Common/Version.h ../Common/Context.h ../Common/Const.h
GUI.o: GUI.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
../Common/GmshUI.h ../Common/Context.h ../Common/Const.h ../Geo/Geo.h \
../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \
../Common/Views.h ../Common/ColorTable.h ../Common/Version.h GUI.h
Opengl.o: Opengl.cpp ../Common/Gmsh.h ../Common/Message.h \
../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \
../Common/Context.h ../Common/Const.h ../Geo/Geo.h ../Mesh/Mesh.h \
../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \
../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \
../Common/Views.h ../Common/ColorTable.h GUI.h
// $Id: Message.cpp,v 1.1 2001-01-08 08:03:16 geuzaine Exp $
#include <signal.h>
#include <sys/resource.h>
#include "Gmsh.h"
#include "GmshUI.h"
#include "Version.h"
#include "Context.h"
extern Context_T CTX;
/* ------------------------------------------------------------------------ */
/* S i g n a l */
/* ------------------------------------------------------------------------ */
void Signal (int sig_num){
switch (sig_num){
case SIGSEGV :
Msg(FATAL, "Segmentation Violation (Invalid Memory Reference)\n"
"------------------------------------------------------\n"
"You have discovered a bug in Gmsh. You may e-mail the\n"
"context in which it occurred to one of the authors:\n"
"type 'gmsh -info' to get feedback information");
break;
case SIGFPE :
Msg(FATAL, "Floating Point Exception (Division by Zero?)");
break;
case SIGINT :
Msg(FATAL, "Interrupt (Generated from Terminal Special Character)");
break;
default :
Msg(FATAL, "Unknown Signal");
break;
}
}
/* ------------------------------------------------------------------------ */
/* M s g */
/* ------------------------------------------------------------------------ */
char *TextBuffer, TextAbout[1024];
#define PUT_IN_COMMAND_WIN \
vfprintf(stderr, fmt, args); \
fprintf(stderr, "\n");
void Msg(int level, char *fmt, ...){
va_list args;
int abort=0;
if(level != FATAL && level != ERROR && level != PARSER_ERROR &&
CTX.interactive && !CTX.verbosity)
return ;
va_start (args, fmt);
switch(level){
case FATAL :
fprintf(stderr, FATAL_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
abort = 1;
break;
case ERROR :
if(CTX.interactive || !CTX.command_win){
fprintf(stderr, ERROR_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
else{
PUT_IN_COMMAND_WIN ;
}
break;
case WARNING :
if(CTX.interactive || !CTX.command_win){
if(CTX.verbosity > 0){
fprintf(stderr, WARNING_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
}
break;
case INFOS :
if(CTX.interactive || !CTX.command_win){
if(CTX.verbosity > 1){
fprintf(stderr, INFOS_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
}
break;
case INFO :
if(CTX.interactive){
if(CTX.verbosity > 1){
fprintf(stderr, INFO_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
/*
vsprintf(TextBuffer, fmt, args);
XtVaSetValues(WID.G.infoLabel, XmNlabelString,
XmStringCreateSimple(TextBuffer), NULL);
XmUpdateDisplay(WID.G.infoLabel);
*/
}
break;
case SELECT :
if(CTX.interactive){
if(CTX.verbosity > 1){
fprintf(stderr, SELECT_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
/*
vsprintf(TextBuffer, fmt, args);
XtVaSetValues(WID.G.selectLabel, XmNlabelString,
XmStringCreateSimple(TextBuffer), NULL);
XmUpdateDisplay(WID.G.selectLabel);
*/
}
break;
case STATUS :
if(CTX.interactive){
if(CTX.verbosity > 1){
fprintf(stderr, STATUS_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
/*
vsprintf(TextBuffer, fmt, args);
XtVaSetValues(WID.G.statusLabel, XmNlabelString,
XmStringCreateSimple(TextBuffer), NULL);
XmUpdateDisplay(WID.G.statusLabel);
*/
}
break;
case PARSER_ERROR :
if(CTX.interactive || !CTX.command_win){
if(CTX.verbosity > 0){
fprintf(stderr, PARSER_ERROR_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
}
break;
case PARSER_INFO :
if(CTX.interactive || !CTX.command_win){
if(CTX.verbosity > 1){
fprintf(stderr, PARSER_INFO_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
}
break;
case DEBUG :
if(CTX.interactive || !CTX.command_win){
if(CTX.verbosity > 2){
fprintf(stderr, DEBUG_STR);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
}
else{
PUT_IN_COMMAND_WIN ;
}
break;
}
va_end (args);
if(abort) exit(1);
}
/* ------------------------------------------------------------------------ */
/* C p u */
/* ------------------------------------------------------------------------ */
void GetResources(long *s, long *us, long *mem){
static struct rusage r;
getrusage(RUSAGE_SELF,&r);
*s = (long)r.ru_utime.tv_sec ;
*us = (long)r.ru_utime.tv_usec ;
*mem = (long)r.ru_maxrss ;
}
void PrintResources(FILE *stream, char *fmt, long s, long us, long mem){
fprintf(stream, "Resources = %scpu %ld.%ld s / mem %ld kb\n", fmt, s, us, mem);
}
double Cpu(void){
long s, us, mem;
GetResources(&s, &us, &mem);
return (double)s + (double)us/1.e6 ;
}
/* ------------------------------------------------------------------------ */
/* P r o g r e s s */
/* ------------------------------------------------------------------------ */
void Progress(int i){
}
/* ------------------------------------------------------------------------ */
/* E d i t G e o m e t r y */
/* ------------------------------------------------------------------------ */
void AddALineInTheEditGeometryForm (char* line){
}
// $Id: Opengl.cpp,v 1.1 2001-01-08 08:03:16 geuzaine Exp $
#include "Gmsh.h"
#include "GmshUI.h"
#include "Context.h"
#include "Const.h"
#include "Geo.h"
#include "Mesh.h"
#include "Draw.h"
#include "GUI.h"
extern GUI *WID;
extern Mesh M;
extern Context_T CTX;
void Process_SelectionBuffer(int x, int y, int *n, GLuint *ii, GLuint *jj);
void Filter_SelectionBuffer(int n, GLuint *typ, GLuint *ient, Vertex **thev,
Curve **thec, Surface **thes, Mesh *m);
void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
GLdouble Xc1, GLdouble Xc2, GLdouble Yc1, GLdouble Yc2);
/* ------------------------------------------------------------------------ */
/* Init/Draw */
/* ------------------------------------------------------------------------ */
void Init(void){
}
void InitOverlay(void){
}
void Draw(void){
WID->set_size(CTX.viewport[2]-CTX.viewport[0],
CTX.viewport[3]-CTX.viewport[1]);
WID->draw_gl();
}
void DrawOverlay(void){
WID->draw_gl_overlay();
}
void DrawUI(void){
WID->check();
}
/* ------------------------------------------------------------------------
set_XXX
------------------------------------------------------------------------ */
void set_r(int i, double val){
if(!CTX.useTrackball){
if(!CTX.rlock[i]){
CTX.r[i] = val;
}
}
}
void set_t(int i, double val){
if(!CTX.tlock[i]){
CTX.t[i] = val;
}
}
void set_s(int i, double val){
if(!CTX.slock[i]){
CTX.s[i] = val;
}
}
/* ------------------------------------------------------------------------ */
/* SelectEntity */
/* ------------------------------------------------------------------------ */
int check_type(int type, Vertex *v, Curve *c, Surface *s){
return ( (type==ENT_POINT && v) ||
(type==ENT_LINE && c) ||
(type==ENT_SURFACE && s) ) ;
}
int SelectEntity(int type, Vertex **v, Curve **c, Surface **s){
int hits;
GLuint ii[SELECTION_BUFFER_SIZE],jj[SELECTION_BUFFER_SIZE];
int event;
*v = NULL; *c = NULL; *s = NULL;
printf("select entity...\n");
while(1){
Fl::check();
if((event = Fl::event_key())){
if(event == 'q') return(0);
if(event == 'e') return(-1);
}
if(Fl::event_is_click()){
Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &hits, ii, jj);
Filter_SelectionBuffer(hits,ii,jj,v,c,s,&M);
if(check_type(type,*v,*c,*s)){
BeginHighlight();
HighlightEntity(*v,*c,*s,1);
EndHighlight(1);
return(Fl::event_button());
}
}
}
}
/* ------------------------------------------------------------------------ */
/* The OpenGL Widget */
/* ------------------------------------------------------------------------ */
void Opengl_Window::draw() {
if (!valid()) {
valid(1);
CTX.viewport[0] = 0 ;
CTX.viewport[1] = 0 ;
CTX.viewport[2] = w() ;
CTX.viewport[3] = h() ;
glViewport(CTX.viewport[0],
CTX.viewport[1],
CTX.viewport[2],
CTX.viewport[3]);
}
Orthogonalize(0,0);
glClearColor(UNPACK_RED(CTX.color.bg)/255.,
UNPACK_GREEN(CTX.color.bg)/255.,
UNPACK_BLUE(CTX.color.bg)/255.,
0.);
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
Draw3d();
Draw2d();
}
void Opengl_Window::clear_overlay() {
if(CTX.overlay) {}
}
void Opengl_Window::draw_overlay_zoom() {
/*
if (!valid()) {
valid(1);
CTX.viewport[0] = 0 ;
CTX.viewport[1] = 0 ;
CTX.viewport[2] = w() ;
CTX.viewport[3] = h() ;
glViewport(CTX.viewport[0],
CTX.viewport[1],
CTX.viewport[2],
CTX.viewport[3]);
}
Orthogonalize(0,0);
glClearIndex(0);
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(1.);
glClearIndex(0);
glClear(GL_COLOR_BUFFER_BIT);
glIndexi((CTX.color.bg<CTX.color.fg)?FL_WHITE:FL_BLACK);
glBegin(GL_LINE_STRIP);
glVertex2d(xb,yb);
glVertex2d(xb+movzx,yb);
glVertex2d(xb+movzx,yb+movzy);
glVertex2d(xb,yb+movzy);
glVertex2d(xb,yb);
glEnd();
*/
}
void Opengl_Window::draw_overlay_highlight(){
/*
if(CTX.overlay){
glXMakeCurrent(XtDisplay(WID.G.glo), XtWindow(WID.G.glo), XCTX.glo.context);
if(ov != v || oc != c || os != s) {
glClearIndex(0);
glClear(GL_COLOR_BUFFER_BIT);
glIndexi((CTX.color.bg<CTX.color.fg)?XCTX.xcolor.ovwhite:XCTX.xcolor.ovblack);
BeginHighlight();
HighlightEntity(v,c,s,0);
EndHighlight(0);
}
glXMakeCurrent(XtDisplay(WID.G.glw), XtWindow(WID.G.glw), XCTX.glw.context);
}
else{
if(ov != v || oc != c || os != s) {
if(CTX.geom.highlight){
Init();
Draw();
}
BeginHighlight();
HighlightEntity(v,c,s,0);
EndHighlight(0);
}
}
*/
}
void Opengl_Window::draw_overlay() {
}
static int Modifier=0;
int Opengl_Window::handle(int event) {
GLuint ii[SELECTION_BUFFER_SIZE], jj[SELECTION_BUFFER_SIZE];
int previous_mesh_draw, previous_post_draw ;
int width, height ;
static int ibut, hits;
static int ButtonPressed=0, ZoomClick=0, FirstClick=0;
static int x, y, movx, movy;
static GLdouble xc1, yc1, xc2, yc2, xt1, yt1, xscale1, yscale1;
static GLdouble xb, yb, xc, yc, xe, ye, xz, yz;
static GLdouble movzx, movzy;
static Vertex *v=NULL, *ov;
static Curve *c=NULL, *oc;
static Surface *s=NULL, *os;
width = w() ;
height = h() ;
switch (event) {
/* -------------------------------------------------------------
K e y s
------------------------------------------------------------- */
case FL_SHORTCUT:
/*
m = menu->test_shortcut();
if (m) {m->do_callback(this, (void*)m); return 1;}
*/
return 0;
case FL_ENTER :
case FL_LEAVE :
ButtonPressed = 0;
Modifier = 0;
return Fl_Gl_Window::handle(event);
case FL_FOCUS:
return 1;
case FL_UNFOCUS:
return 1;
case FL_KEYBOARD:
switch(Fl::event_key()){
case FL_Control_L : case FL_Control_R :
printf("got a ctrl\n");
Modifier = 1;
return 1;
case FL_Alt_L : case FL_Alt_R :
case FL_Meta_L : case FL_Meta_R :
Modifier = 2;
return 1;
default:
return Fl_Gl_Window::handle(event);
}
break;
/* -------------------------------------------------------------
B u t t o n P r e s s
------------------------------------------------------------- */
case FL_PUSH:
ButtonPressed++;
FirstClick=1;
ibut = Fl::event_button();
x = Fl::event_x();
y = Fl::event_y();
switch(ibut){
case 1:
if(!ZoomClick && Modifier){
xb = CTX.vxmin + ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin);
yb = CTX.vymax - ((GLdouble) y / height) * (CTX.vymax - CTX.vymin);
xc1 = xb/CTX.s[0] - CTX.t[0];
yc1 = yb/CTX.s[1] - CTX.t[1];
ZoomClick=1;
Modifier = 0;
}
else if(ZoomClick){
xe = CTX.vxmin + ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin);
ye = CTX.vymax - ((GLdouble) y / height) * (CTX.vymax - CTX.vymin);
xc2 = xe/CTX.s[0] - CTX.t[0];
yc2 = ye/CTX.s[1] - CTX.t[1];
ZoomClick=0;
clear_overlay();
if(xb!=xe && yb!=ye) myZoom(xb,xe,yb,ye,xc1,xc2,yc1,yc2);
}
break;
case 2:
if(Modifier && !ZoomClick){
Modifier = 0;
set_s(1, CTX.s[0]);
set_s(2, CTX.s[0]);
Init();
Draw();
}
else{
ZoomClick=0;
clear_overlay();
}
break;
case 3:
if(Modifier && !ZoomClick){
Modifier = 0;
if(CTX.useTrackball){
CTX.setQuaternion(0.,0.,0.,1.);
}
else{
set_r(0,0.); set_r(1,0.); set_r(2,0.);
}
set_t(0,0.); set_t(1,0.); set_t(2,0.);
set_s(0,1.); set_s(1,1.); set_s(2,1.);
Init();
Draw();
}
else{
ZoomClick=0;
clear_overlay();
}
break;
}
return 1;
/* -------------------------------------------------------------
B u t t o n R e l e a s e
------------------------------------------------------------- */
case FL_RELEASE:
if(ButtonPressed>0){
ButtonPressed--;
ibut = Fl::event_button();
x = Fl::event_x();
y = Fl::event_y();
}
if(!ZoomClick){
Init();
previous_mesh_draw = CTX.mesh.draw ;
previous_post_draw = CTX.post.draw ;
if(ButtonPressed>0){
if(CTX.fast) CTX.mesh.draw = CTX.post.draw = 0;
}
Draw();
CTX.mesh.draw = previous_mesh_draw ;
CTX.post.draw = previous_post_draw ;
}
return 1;
/* -------------------------------------------------------------
M o t i o n N o t i f y
------------------------------------------------------------- */
case FL_DRAG:
movx = Fl::event_x()-x;
movy = Fl::event_y()-y;
if(ZoomClick) {
printf("should draw the zoom... %d %d %d %d\n", x, y, movx, movy);
xz = CTX.vxmin + ((GLdouble) Fl::event_x() / width) *
(CTX.vxmax - CTX.vxmin);
yz = CTX.vymax - ((GLdouble) Fl::event_y() / height) *
(CTX.vymax - CTX.vymin) ;
movzx = xz - xb; movzy = yz - yb;
draw_overlay();
}
else {
if(ButtonPressed){
clear_overlay();
if(FirstClick){
xc1 = ( ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin)
+ CTX.vxmin )/CTX.s[0] - CTX.t[0];
yc1 = ( CTX.vymax - ((GLdouble) y / height) *
(CTX.vymax - CTX.vymin))/CTX.s[1] - CTX.t[1];
xt1 = CTX.t[0];
yt1 = CTX.t[1];
xscale1 = CTX.s[0];
yscale1 = CTX.s[1];
FirstClick=0;
}
switch(ibut){
case 1:
if(CTX.useTrackball){
CTX.addQuaternion ((2.0*x - width) / width,
(height - 2.0*y) / height,
(2.0*Fl::event_x() - width) / width,
(height - 2.0*Fl::event_y()) / height);
}
else{
set_r(1, CTX.r[1] + ((abs(movx) > abs(movy))?180*(float)movx/(float)width:0));
set_r(0, CTX.r[0] + ((abs(movx) > abs(movy))?0:180*(float)movy/(float)height));
}
break;
case 2:
if(!CTX.useTrackball)
set_r(2, CTX.r[2] + ((abs(movy) > abs(movx))?0:-180*(float)movx/(float)width));
set_s(0, CTX.s[0] * ( (abs(movy) > abs(movx)) ?
( (movy>0) ? (float)(1.04*(abs(movy)+height))/(float)height
: (float)(height)/(float)(1.04*(abs(movy)+height)) )
: 1.) );
set_s(1, CTX.s[0]);
set_s(2, CTX.s[0]);
if(abs(movy) > abs(movx)){
set_t(0, xt1*(xscale1/CTX.s[0])-xc1*(1.-(xscale1/CTX.s[0])));
set_t(1, yt1*(yscale1/CTX.s[1])-yc1*(1.-(yscale1/CTX.s[1])));
}
break;
case 3:
xc = ( ((GLdouble) x / width) * (CTX.vxmax - CTX.vxmin) +
CTX.vxmin ) / CTX.s[0];
yc = ( CTX.vymax - ((GLdouble) y / height) *
(CTX.vymax - CTX.vymin)) / CTX.s[1];
set_t(0, xc-xc1);
set_t(1, yc-yc1);
set_t(2, 0.);
break;
}
Init();
previous_mesh_draw = CTX.mesh.draw ;
previous_post_draw = CTX.post.draw ;
if(CTX.fast) CTX.mesh.draw = CTX.post.draw = 0;
Draw();
CTX.mesh.draw = previous_mesh_draw ;
CTX.post.draw = previous_post_draw ;
}
else{
Process_SelectionBuffer(Fl::event_x(), Fl::event_y(), &hits, ii, jj);
ov = v; oc = c; os = s;
v = NULL; c = NULL; s = NULL;
Filter_SelectionBuffer(hits,ii,jj,&v,&c,&s,&M);
draw_overlay_highlight();
}
x += movx;
y += movy;
}
return 1;
/* -------------------------------------------------------------
O t h er
------------------------------------------------------------- */
default:
// pass other events to the base class...
return Fl_Gl_Window::handle(event);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment