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

font options could not be set in .gmshrc/.gmsh-options since the global fltk...

font options could not be set in .gmshrc/.gmsh-options since the global fltk draw context was not created; fixed
parent 7d0e44b9
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#if defined(HAVE_FLTK) #if defined(HAVE_FLTK)
#include <FL/Fl_Tooltip.H> #include <FL/Fl_Tooltip.H>
#include "FlGui.h" #include "FlGui.h"
#include "drawContextFltk.h"
#include "graphicWindow.h" #include "graphicWindow.h"
#include "optionWindow.h" #include "optionWindow.h"
#include "manipWindow.h" #include "manipWindow.h"
...@@ -1121,10 +1122,11 @@ std::string opt_general_graphics_font(OPT_ARGS_STR) ...@@ -1121,10 +1122,11 @@ std::string opt_general_graphics_font(OPT_ARGS_STR)
if(action & GMSH_SET) if(action & GMSH_SET)
CTX::instance()->glFont = val; CTX::instance()->glFont = val;
#if defined(HAVE_FLTK) #if defined(HAVE_FLTK)
int index = drawContext::global()->getFontIndex(CTX::instance()->glFont.c_str()); drawContextFltk dc;
int index = dc.getFontIndex(CTX::instance()->glFont.c_str());
if(action & GMSH_SET){ if(action & GMSH_SET){
CTX::instance()->glFont = drawContext::global()->getFontName(index); CTX::instance()->glFont = dc.getFontName(index);
CTX::instance()->glFontEnum = drawContext::global()->getFontEnum(index); CTX::instance()->glFontEnum = dc.getFontEnum(index);
} }
if(FlGui::available() && (action & GMSH_GUI)){ if(FlGui::available() && (action & GMSH_GUI)){
FlGui::instance()->options->general.choice[1]->value(index); FlGui::instance()->options->general.choice[1]->value(index);
...@@ -1138,10 +1140,11 @@ std::string opt_general_graphics_font_title(OPT_ARGS_STR) ...@@ -1138,10 +1140,11 @@ std::string opt_general_graphics_font_title(OPT_ARGS_STR)
if(action & GMSH_SET) if(action & GMSH_SET)
CTX::instance()->glFontTitle = val; CTX::instance()->glFontTitle = val;
#if defined(HAVE_FLTK) #if defined(HAVE_FLTK)
int index = drawContext::global()->getFontIndex(CTX::instance()->glFontTitle.c_str()); drawContextFltk dc;
int index = dc.getFontIndex(CTX::instance()->glFontTitle.c_str());
if(action & GMSH_SET){ if(action & GMSH_SET){
CTX::instance()->glFontTitle = drawContext::global()->getFontName(index); CTX::instance()->glFontTitle = dc.getFontName(index);
CTX::instance()->glFontEnumTitle = drawContext::global()->getFontEnum(index); CTX::instance()->glFontEnumTitle = dc.getFontEnum(index);
} }
if(FlGui::available() && (action & GMSH_GUI)){ if(FlGui::available() && (action & GMSH_GUI)){
FlGui::instance()->options->general.choice[6]->value(index); FlGui::instance()->options->general.choice[6]->value(index);
......
...@@ -15,9 +15,8 @@ typedef unsigned long intptr_t; ...@@ -15,9 +15,8 @@ typedef unsigned long intptr_t;
#include <FL/Fl_Tooltip.H> #include <FL/Fl_Tooltip.H>
#include <FL/Fl_Shared_Image.H> #include <FL/Fl_Shared_Image.H>
#include <FL/Fl_File_Icon.H> #include <FL/Fl_File_Icon.H>
#include <FL/x.H>
#include <FL/gl.h>
#include "FlGui.h" #include "FlGui.h"
#include "drawContextFltk.h"
#include "graphicWindow.h" #include "graphicWindow.h"
#include "optionWindow.h" #include "optionWindow.h"
#include "fieldWindow.h" #include "fieldWindow.h"
...@@ -62,136 +61,6 @@ void FlGui::wait(){ Fl::wait(); } ...@@ -62,136 +61,6 @@ void FlGui::wait(){ Fl::wait(); }
// wait (at most time seconds) for any events, then process them // wait (at most time seconds) for any events, then process them
void FlGui::wait(double time){ Fl::wait(time); } void FlGui::wait(double time){ Fl::wait(time); }
class drawContextFltk : public drawContextGlobal{
public:
void draw()
{
if(!FlGui::available()) return;
for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++){
for(unsigned int j = 0; j < FlGui::instance()->graph[i]->gl.size(); j++){
FlGui::instance()->graph[i]->gl[j]->make_current();
FlGui::instance()->graph[i]->gl[j]->redraw();
// to initialize the camera distance from model
drawContext * ctx = FlGui::instance()->graph[i]->gl[j]->getDrawContext();
ctx->camera.update();
}
}
FlGui::instance()->check();
}
void drawCurrentOpenglWindow(bool make_current)
{
if(!FlGui::available()) return;
openglWindow *gl = FlGui::instance()->getCurrentOpenglWindow();
if(make_current) gl->make_current();
gl->redraw();
glFlush();
FlGui::instance()->check();
}
int getFontIndex(const char *fontname)
{
if(fontname){
for(int i = 0; i < NUM_FONTS; i++)
if(!strcmp(menu_font_names[i].label(), fontname))
return i;
}
Msg::Error("Unknown font \"%s\" (using \"Helvetica\" instead)", fontname);
Msg::Info("Available fonts:");
for(int i = 0; i < NUM_FONTS; i++)
Msg::Info(" \"%s\"", menu_font_names[i].label());
return 4;
}
int getFontEnum(int index)
{
if(index >= 0 && index < NUM_FONTS)
return (intptr_t)menu_font_names[index].user_data();
return FL_HELVETICA;
}
const char *getFontName(int index)
{
if(index >= 0 && index < NUM_FONTS)
return menu_font_names[index].label();
return "Helvetica";
}
int getFontAlign(const char *alignstr)
{
if(alignstr){
if(!strcmp(alignstr, "BottomLeft") || !strcmp(alignstr, "Left") ||
!strcmp(alignstr, "left"))
return 0;
else if(!strcmp(alignstr, "BottomCenter") || !strcmp(alignstr, "Center") ||
!strcmp(alignstr, "center"))
return 1;
else if(!strcmp(alignstr, "BottomRight") || !strcmp(alignstr, "Right") ||
!strcmp(alignstr, "right"))
return 2;
else if(!strcmp(alignstr, "TopLeft"))
return 3;
else if(!strcmp(alignstr, "TopCenter"))
return 4;
else if(!strcmp(alignstr, "TopRight"))
return 5;
else if(!strcmp(alignstr, "CenterLeft"))
return 6;
else if(!strcmp(alignstr, "CenterCenter"))
return 7;
else if(!strcmp(alignstr, "CenterRight"))
return 8;
}
Msg::Error("Unknown font alignment \"%s\" (using \"Left\" instead)", alignstr);
Msg::Info("Available font alignments:");
Msg::Info(" \"Left\" (or \"BottomLeft\")");
Msg::Info(" \"Center\" (or \"BottomCenter\")");
Msg::Info(" \"Right\" (or \"BottomRight\")");
Msg::Info(" \"TopLeft\"");
Msg::Info(" \"TopCenter\"");
Msg::Info(" \"TopRight\"");
Msg::Info(" \"CenterLeft\"");
Msg::Info(" \"CenterCenter\"");
Msg::Info(" \"CenterRight\"");
return 0;
}
int getFontSize()
{
if(CTX::instance()->fontSize > 0){
return CTX::instance()->fontSize;
}
else{
int w = Fl::w();
if(w <= 1024) return 11;
else if(w <= 1280) return 12;
else if(w <= 1680) return 13;
else if(w <= 1920) return 14;
else return 15;
}
}
void setFont(int fontid, int fontsize)
{
gl_font(fontid, fontsize);
}
double getStringWidth(const char *str)
{
return gl_width(str);
}
int getStringHeight()
{
return gl_height();
}
int getStringDescent()
{
return gl_descent();
}
void drawString(const char *str)
{
gl_draw(str);
}
void resetFontTextures()
{
#if defined(__APPLE__)
gl_texture_pile_height(1); // force font texture recomputation
#endif
}
};
static int globalShortcut(int event) static int globalShortcut(int event)
{ {
if(!FlGui::available()) return 0; if(!FlGui::available()) return 0;
......
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#ifndef _DRAW_CONTEXT_FLTK_H_
#define _DRAW_CONTEXT_FLTK_H_
#include <FL/x.H>
#include <FL/gl.h>
#include "FlGui.h"
#include "drawContext.h"
#include "graphicWindow.h"
#include "optionWindow.h"
#include "Context.h"
class drawContextFltk : public drawContextGlobal{
public:
void draw()
{
if(!FlGui::available()) return;
for(unsigned int i = 0; i < FlGui::instance()->graph.size(); i++){
for(unsigned int j = 0; j < FlGui::instance()->graph[i]->gl.size(); j++){
FlGui::instance()->graph[i]->gl[j]->make_current();
FlGui::instance()->graph[i]->gl[j]->redraw();
// to initialize the camera distance from model
drawContext * ctx = FlGui::instance()->graph[i]->gl[j]->getDrawContext();
ctx->camera.update();
}
}
FlGui::instance()->check();
}
void drawCurrentOpenglWindow(bool make_current)
{
if(!FlGui::available()) return;
openglWindow *gl = FlGui::instance()->getCurrentOpenglWindow();
if(make_current) gl->make_current();
gl->redraw();
glFlush();
FlGui::instance()->check();
}
int getFontIndex(const char *fontname)
{
if(fontname){
for(int i = 0; i < NUM_FONTS; i++)
if(!strcmp(menu_font_names[i].label(), fontname))
return i;
}
Msg::Error("Unknown font \"%s\" (using \"Helvetica\" instead)", fontname);
Msg::Info("Available fonts:");
for(int i = 0; i < NUM_FONTS; i++)
Msg::Info(" \"%s\"", menu_font_names[i].label());
return 4;
}
int getFontEnum(int index)
{
if(index >= 0 && index < NUM_FONTS)
return (intptr_t)menu_font_names[index].user_data();
return FL_HELVETICA;
}
const char *getFontName(int index)
{
if(index >= 0 && index < NUM_FONTS)
return menu_font_names[index].label();
return "Helvetica";
}
int getFontAlign(const char *alignstr)
{
if(alignstr){
if(!strcmp(alignstr, "BottomLeft") || !strcmp(alignstr, "Left") ||
!strcmp(alignstr, "left"))
return 0;
else if(!strcmp(alignstr, "BottomCenter") || !strcmp(alignstr, "Center") ||
!strcmp(alignstr, "center"))
return 1;
else if(!strcmp(alignstr, "BottomRight") || !strcmp(alignstr, "Right") ||
!strcmp(alignstr, "right"))
return 2;
else if(!strcmp(alignstr, "TopLeft"))
return 3;
else if(!strcmp(alignstr, "TopCenter"))
return 4;
else if(!strcmp(alignstr, "TopRight"))
return 5;
else if(!strcmp(alignstr, "CenterLeft"))
return 6;
else if(!strcmp(alignstr, "CenterCenter"))
return 7;
else if(!strcmp(alignstr, "CenterRight"))
return 8;
}
Msg::Error("Unknown font alignment \"%s\" (using \"Left\" instead)", alignstr);
Msg::Info("Available font alignments:");
Msg::Info(" \"Left\" (or \"BottomLeft\")");
Msg::Info(" \"Center\" (or \"BottomCenter\")");
Msg::Info(" \"Right\" (or \"BottomRight\")");
Msg::Info(" \"TopLeft\"");
Msg::Info(" \"TopCenter\"");
Msg::Info(" \"TopRight\"");
Msg::Info(" \"CenterLeft\"");
Msg::Info(" \"CenterCenter\"");
Msg::Info(" \"CenterRight\"");
return 0;
}
int getFontSize()
{
if(CTX::instance()->fontSize > 0){
return CTX::instance()->fontSize;
}
else{
int w = Fl::w();
if(w <= 1024) return 11;
else if(w <= 1280) return 12;
else if(w <= 1680) return 13;
else if(w <= 1920) return 14;
else return 15;
}
}
void setFont(int fontid, int fontsize)
{
gl_font(fontid, fontsize);
}
double getStringWidth(const char *str)
{
return gl_width(str);
}
int getStringHeight()
{
return gl_height();
}
int getStringDescent()
{
return gl_descent();
}
void drawString(const char *str)
{
gl_draw(str);
}
void resetFontTextures()
{
#if defined(__APPLE__)
gl_texture_pile_height(1); // force font texture recomputation
#endif
}
};
#endif
...@@ -193,7 +193,8 @@ class drawContext { ...@@ -193,7 +193,8 @@ class drawContext {
void drawAxes(int mode, double tics[3], std::string format[3], void drawAxes(int mode, double tics[3], std::string format[3],
std::string label[3], double bb[6], int mikado, double value_bb[6]); std::string label[3], double bb[6], int mikado, double value_bb[6]);
void drawAxes(int mode, double tics[3], std::string format[3], void drawAxes(int mode, double tics[3], std::string format[3],
std::string label[3], SBoundingBox3d &bb, int mikado, SBoundingBox3d &value_bb); std::string label[3], SBoundingBox3d &bb, int mikado,
SBoundingBox3d &value_bb);
void drawAxes(); void drawAxes();
void drawSmallAxes(); void drawSmallAxes();
void drawTrackball(); void drawTrackball();
...@@ -205,7 +206,8 @@ class drawContext { ...@@ -205,7 +206,8 @@ class drawContext {
void drawStringRight(const std::string &s); void drawStringRight(const std::string &s);
void drawString(const std::string &s, double style); void drawString(const std::string &s, double style);
void drawSphere(double R, double x, double y, double z, int n1, int n2, int light); void drawSphere(double R, double x, double y, double z, int n1, int n2, int light);
void drawEllipsoid(double x, double y, double z, float v0[3], float v1[3], float v2[3], int light); void drawEllipsoid(double x, double y, double z, float v0[3], float v1[3],
float v2[3], int light);
void drawEllipse(double x, double y, double z, float v0[3], float v1[3], int light); void drawEllipse(double x, double y, double z, float v0[3], float v1[3], int light);
void drawSphere(double size, double x, double y, double z, int light); void drawSphere(double size, double x, double y, double z, int light);
void drawCylinder(double width, double *x, double *y, double *z, int light); void drawCylinder(double width, double *x, double *y, double *z, int light);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment