• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pltick.c

Go to the documentation of this file.
00001 // $Id: pltick.c 11680 2011-03-27 17:57:51Z airwin $
00002 //
00003 //      Routines for drawing error bars and tick marks.
00004 //
00005 // Copyright (C) 2004  Alan W. Irwin
00006 //
00007 // This file is part of PLplot.
00008 //
00009 // PLplot is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU Library General Public License as published
00011 // by the Free Software Foundation; either version 2 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // PLplot is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU Library General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Library General Public License
00020 // along with PLplot; if not, write to the Free Software
00021 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00022 //
00023 
00024 #include "plplotP.h"
00025 
00026 //--------------------------------------------------------------------------
00027 // void plwxtik()
00028 //
00029 // Draws a tick parallel to x, using world coordinates
00030 //--------------------------------------------------------------------------
00031 void
00032 plwxtik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert )
00033 {
00034     PLINT length, below, above;
00035     PLFLT height;
00036     if ( minor )
00037     {
00038         // Minor tick
00039         height = plsc->minht;
00040     }
00041     else
00042     {
00043         // Major tick
00044         height = plsc->majht;
00045     }
00046     length = MAX( ROUND( height * plsc->ypmm ), 1 );
00047 
00048     if ( invert )
00049     {
00050         below = 0;
00051         above = length;
00052     }
00053     else
00054     {
00055         below = length;
00056         above = 0;
00057     }
00058     // Actually draw the tick
00059     plxtik( plP_wcpcx( x ), plP_wcpcy( y ), below, above );
00060 }
00061 
00062 //--------------------------------------------------------------------------
00063 // void plwytik()
00064 //
00065 // Draws a tick parallel to y, using world coordinates
00066 //--------------------------------------------------------------------------
00067 void
00068 plwytik( PLFLT x, PLFLT y, PLBOOL minor, PLBOOL invert )
00069 {
00070     PLINT length, below, above;
00071     PLFLT height;
00072     if ( minor )
00073     {
00074         // Minor tick
00075         height = plsc->minht;
00076     }
00077     else
00078     {
00079         // Major tick
00080         height = plsc->majht;
00081     }
00082     length = MAX( ROUND( height * plsc->xpmm ), 1 );
00083 
00084     if ( invert )
00085     {
00086         below = 0;
00087         above = length;
00088     }
00089     else
00090     {
00091         below = length;
00092         above = 0;
00093     }
00094     // Actually draw the tick
00095     plytik( plP_wcpcx( x ), plP_wcpcy( y ), below, above );
00096 }
00097 
00098 //--------------------------------------------------------------------------
00099 // void plxtik()
00100 //
00101 // Draws a tick parallel to x.
00102 //--------------------------------------------------------------------------
00103 
00104 void
00105 plxtik( PLINT x, PLINT y, PLINT below, PLINT above )
00106 {
00107     plP_movphy( x, y - below );
00108     plP_draphy( x, y + above );
00109 }
00110 
00111 //--------------------------------------------------------------------------
00112 // void plytik()
00113 //
00114 // Draws a tick parallel to y.
00115 //--------------------------------------------------------------------------
00116 
00117 void
00118 plytik( PLINT x, PLINT y, PLINT left, PLINT right )
00119 {
00120     plP_movphy( x - left, y );
00121     plP_draphy( x + right, y );
00122 }
00123 
00124 //--------------------------------------------------------------------------
00125 // void plstik()
00126 //
00127 // Draws a slanting tick at position (mx,my) (measured in mm) of
00128 // vector length (dx,dy).
00129 //--------------------------------------------------------------------------
00130 
00131 void
00132 plstik( PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy )
00133 {
00134     plP_movphy( plP_mmpcx( mx ), plP_mmpcy( my ) );
00135     plP_draphy( plP_mmpcx( (PLFLT) ( mx + dx ) ), plP_mmpcy( (PLFLT) ( my + dy ) ) );
00136 }
00137 
00138 //--------------------------------------------------------------------------
00139 // void plerx1()
00140 //
00141 // Plot single horizontal error bar.
00142 //--------------------------------------------------------------------------
00143 
00144 static void
00145 plerx1( PLFLT xmin, PLFLT xmax, PLFLT y )
00146 {
00147     PLINT yminor;
00148 
00149     yminor = (PLINT) ( MAX( 1.0, plsc->minht * plsc->ypmm ) );
00150     plxtik( plP_wcpcx( xmin ), plP_wcpcy( y ), yminor, yminor );
00151     plP_movwor( xmin, y );
00152     plP_drawor( xmax, y );
00153     plxtik( plP_wcpcx( xmax ), plP_wcpcy( y ), yminor, yminor );
00154 }
00155 
00156 //--------------------------------------------------------------------------
00157 // void plery1()
00158 //
00159 // Plot single vertical error bar.
00160 //--------------------------------------------------------------------------
00161 
00162 static void
00163 plery1( PLFLT x, PLFLT ymin, PLFLT ymax )
00164 {
00165     PLINT xminor;
00166 
00167     xminor = (PLINT) ( MAX( 1.0, plsc->minht * plsc->xpmm ) );
00168     plytik( plP_wcpcx( x ), plP_wcpcy( ymin ), xminor, xminor );
00169     plP_movwor( x, ymin );
00170     plP_drawor( x, ymax );
00171     plytik( plP_wcpcx( x ), plP_wcpcy( ymax ), xminor, xminor );
00172 }
00173 
00174 //--------------------------------------------------------------------------
00175 // void plerrx()
00176 //
00177 // Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)).
00178 //--------------------------------------------------------------------------
00179 
00180 void
00181 c_plerrx( PLINT n, const PLFLT *xmin, const PLFLT *xmax, const PLFLT *y )
00182 {
00183     PLINT i;
00184 
00185     if ( plsc->level < 3 )
00186     {
00187         plabort( "plerrx: Please set up window first" );
00188         return;
00189     }
00190 
00191     for ( i = 0; i < n; i++ )
00192         plerx1( xmin[i], xmax[i], y[i] );
00193 }
00194 
00195 //--------------------------------------------------------------------------
00196 // void plerry()
00197 //
00198 // Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)).
00199 //--------------------------------------------------------------------------
00200 
00201 void
00202 c_plerry( PLINT n, const PLFLT *x, const PLFLT *ymin, const PLFLT *ymax )
00203 {
00204     PLINT i;
00205 
00206     if ( plsc->level < 3 )
00207     {
00208         plabort( "plerry: Please set up window first" );
00209         return;
00210     }
00211 
00212     for ( i = 0; i < n; i++ )
00213         plery1( x[i], ymin[i], ymax[i] );
00214 }

Generated on Wed Oct 12 2011 20:42:23 for PLplot by  doxygen 1.7.1