Skip to content
Snippets Groups Projects
Select Git revision
  • d1f97610ddf771fb9f87cece3c057be66b1882fd
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

GModel.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    drawGlyph.cpp 18.62 KiB
    // Gmsh - Copyright (C) 1997-2010 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // bugs and problems to <gmsh@geuz.org>.
    
    #include <string.h>
    #include "drawContext.h"
    #include "GmshDefines.h"
    #include "Numeric.h"
    #include "StringUtils.h"
    #include "Context.h"
    #include "gl2ps.h"
    #include "SVector3.h"
    
    void drawContext::drawString(const std::string &s, const std::string &font_name,
                                 int font_enum, int font_size, int align)
    {
      if(CTX::instance()->printing && !CTX::instance()->print.text) return;
    
      // change the raster position only if not creating TeX files
      if(align > 0 && (!CTX::instance()->printing || 
                       CTX::instance()->print.format != FORMAT_TEX)){
        GLboolean valid;
        glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
        if(valid == GL_TRUE){
          GLdouble pos[4];
          glGetDoublev(GL_CURRENT_RASTER_POSITION, pos);
          double x[3], w[3] = {pos[0], pos[1], pos[2]};
          drawContext::global()->setFont(font_enum, font_size);
          double width = drawContext::global()->getStringWidth(s.c_str());
          double height = drawContext::global()->getStringHeight();
          switch(align){
          case 1: w[0] -= width/2.;                     break; // bottom center
          case 2: w[0] -= width;                        break; // bottom right
          case 3:                    w[1] -= height;    break; // top left
          case 4: w[0] -= width/2.;  w[1] -= height;    break; // top center
          case 5: w[0] -= width;     w[1] -= height;    break; // top right
          case 6:                    w[1] -= height/2.; break; // center left
          case 7: w[0] -= width/2.;  w[1] -= height/2.; break; // center center
          case 8: w[0] -= width;     w[1] -= height/2.; break; // center right
          default: break;
          }
          viewport2World(w, x);
          glRasterPos3d(x[0], x[1], x[2]);
        }
      }
      
      if(!CTX::instance()->printing){
        drawContext::global()->setFont(font_enum, font_size);
        drawContext::global()->drawString(s.c_str());
      }
      else{
        if(CTX::instance()->print.format == FORMAT_TEX){
          std::string tmp = SanitizeTeXString
            (s.c_str(), CTX::instance()->print.texAsEquation);
          int opt;
          switch(align){
          case 1: opt = GL2PS_TEXT_B;   break; // bottom center
          case 2: opt = GL2PS_TEXT_BR;  break; // bottom right
          case 3: opt = GL2PS_TEXT_TL;  break; // top left
          case 4: opt = GL2PS_TEXT_T;   break; // top center
          case 5: opt = GL2PS_TEXT_TR;  break; // top right
          case 6: opt = GL2PS_TEXT_CL;  break; // center left
          case 7: opt = GL2PS_TEXT_C;   break; // center center
          case 8: opt = GL2PS_TEXT_CR;  break; // center right
          default: opt = GL2PS_TEXT_BL; break; // bottom left
          }
          gl2psTextOpt(tmp.c_str(), font_name.c_str(), font_size, opt, 0.);
        }
        else if(CTX::instance()->print.epsQuality &&