Select Git revision
-
Christophe Geuzaine authored
tutorial/ -> tutorials/
Christophe Geuzaine authoredtutorial/ -> tutorials/
Colorbar_Window.cpp 17.91 KiB
// $Id: Colorbar_Window.cpp,v 1.46 2004-12-31 04:04:50 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to <gmsh@geuz.org>.
// This class was inspired by the colorbar widget provided in Vis5d, a
// program for visualizing five dimensional gridded data sets
// Copyright (C) 1990 - 1995 Bill Hibbard, Brian Paul, Dave Santek,
// and Andre Battaiola.
#include "Gmsh.h"
#include "GmshUI.h"
#include "GUI.h"
#include "ColorTable.h"
#include "Colorbar_Window.h"
#include "Context.h"
extern Context_T CTX;
#define EPS 1.e-10
// This file defines the Colorbar_Window class (subclass of Fl_Window)
// The constructor
Colorbar_Window::Colorbar_Window(int x, int y, int w, int h, const char *l)
: Fl_Window(x, y, w, h, l)
{
ct = NULL;
label = NULL;
help_flag = 1;
font_height = CTX.fontsize;
marker_height = font_height;
wedge_height = marker_height;
marker_pos = 0;
minval = maxval = 0.0;
}
// Convert window X coordinate to color table index
int Colorbar_Window::x_to_index(int x)
{
int index;
index = (int)(x * (double)ct->size / (double)w());
if(index < 0)
index = 0;
else if(index >= ct->size)
index = ct->size - 1;
return index;
}
// Convert color table index to window X coordinate
int Colorbar_Window::index_to_x(int index)