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