1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
/*
* $Id: axisBox.cxx,v 4.3 2007/06/07 13:30:14 hut66au Exp $
*
* Imview, the portable image analysis application
* http://www.cmis.csiro.au/Hugues.Talbot/imview
* ----------------------------------------------------------
*
* Imview is an attempt to provide an image display application
* suitable for professional image analysis. It was started in
* 1997 and is mostly the result of the efforts of Hugues Talbot,
* Image Analysis Project, CSIRO Mathematical and Information
* Sciences, with help from others (see the CREDITS files for
* more information)
*
* Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was
* supported in parts by the Australian Commonwealth Science and
* Industry Research Organisation. Please see the COPYRIGHT file
* for full details. Imview also includes the contributions of
* many others. Please see the CREDITS file for full details.
*
* 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, USA.
* */
/*------------------------------------------------------------------------
*
* Code for axis drawing box.
*
* Hugues Talbot 6 Aug 1998
*
*-----------------------------------------------------------------------*/
#include <stdio.h>
#include "axisBox.hxx"
void axisBox::draw(void)
{
draw_box();
draw_label();
fl_color(FL_BLACK);
if (w() > h()) {
// single horizontal line
fl_line(x(), y()+1, x()+w()-1, y()+1);
if (minval != maxval) {
char p[20];
int stringw, stringh;
fl_font(FL_HELVETICA, 10);
fl_color(FL_GRAY); // default colour
fl_push_clip(x(),y(),w(),h());
// draw a quick erasing box
// nb. fl_width() returns a double and assumed to be +ve here!! k_
fl_rectf(x()+w()-(int)(fl_width("-0.1234")+0.5)-1, y()+2, (int)(fl_width("-0.1234")+0.5), h()-2);
fl_color(FL_BLACK);
sprintf(p, "%.4g", minval);
fl_draw(p, x(), y()+h()-1);
sprintf(p, "%.4g", maxval);
fl_measure(p, stringw, stringh);
if (stringw <= w()/2)
fl_draw(p, x()+w()-stringw, y()+h()-1);
else
fl_draw(p, x()+w()/2, y()+h()-1); // uses at most max half of the box.
fl_pop_clip();
}
} else {
// single vertical line
fl_line(x()+w()-1, y(), x()+w()-1, y()+h());
if (minval != maxval) {
char p[20];
int stringw, stringh;
fl_font(FL_HELVETICA, 10);
fl_color(FL_GRAY); // default colour
fl_push_clip(x(),y(),w(),h());
// draw a quick erasing box
fl_rectf(x(), y()+h()-fl_height(), w()-1, fl_height());
fl_color(FL_BLACK);
sprintf(p, "%.4g", minval);
fl_measure(p, stringw, stringh);
if (w()-stringw-5 >= 0)
fl_draw(p, x()+w()-stringw-5, y()+h());
else
fl_draw(p, x(), y()+h());
fl_color(FL_GRAY); // default colour
fl_rectf(x(), y(), w()-1, fl_height()+1);
fl_color(FL_BLACK);
sprintf(p, "%.4g", maxval);
fl_measure(p, stringw, stringh);
if (w()-stringw-5 >= 0)
fl_draw(p, x()+w()-stringw-5, y()+fl_height());
else
fl_draw(p, x(), y()+fl_height());
fl_pop_clip();
}
}
return;
}
|