PLplot  5.10.0
plsdef.c
Go to the documentation of this file.
00001 //      Routines to set various plplot parameters, such as char height,
00002 //      symbol size, tick length, line and fill patterns, etc.
00003 //
00004 // Copyright (C) 2004-2014 Alan W. Irwin
00005 //
00006 // This file is part of PLplot.
00007 //
00008 // PLplot is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU Library General Public License as published
00010 // by the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // PLplot is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public License
00019 // along with PLplot; if not, write to the Free Software
00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021 //
00022 
00023 #include "plplotP.h"
00024 
00025 // Line pattern defaults
00026 
00027 static struct line
00028 {
00029     PLINT nels;
00030     PLINT mark[4];
00031     PLINT space[4];
00032 } line[] = {
00033     {
00034         0,                      // Continuous line
00035         {
00036             0, 0, 0, 0
00037         },
00038         {
00039             0, 0, 0, 0
00040         }
00041     },
00042     {
00043         1,
00044         {
00045             1000, 0, 0, 0
00046         },
00047         {
00048             1000, 0, 0, 0
00049         }
00050     },
00051     {
00052         1,
00053         {
00054             2000, 0, 0, 0
00055         },
00056         {
00057             2000, 0, 0, 0
00058         }
00059     },
00060     {
00061         1,
00062         {
00063             2000, 0, 0, 0
00064         },
00065         {
00066             1000, 0, 0, 0
00067         }
00068     },
00069     {
00070         2,
00071         {
00072             2500, 1000, 0, 0
00073         },
00074         {
00075             1000, 1000, 0, 0
00076         }
00077     },
00078     {
00079         2,
00080         {
00081             2000, 1000, 0, 0
00082         },
00083         {
00084             2000, 1000, 0, 0
00085         }
00086     },
00087     {
00088         3,
00089         {
00090             1000, 1500, 2000, 0
00091         },
00092         {
00093             1000, 1500, 2000, 0
00094         }
00095     },
00096     {
00097         3,
00098         {
00099             1000, 1500, 2000, 0
00100         },
00101         {
00102             1000, 1000, 1000, 0
00103         }
00104     }
00105 };
00106 
00107 // Fill pattern defaults
00108 
00109 static struct pattern
00110 {
00111     PLINT nlines;               // Number of lines in pattern (1 or 2)
00112     PLINT inc[2];               // Inclination 10 ths of degrees
00113     PLINT del[2];               // Spacing for each line
00114 } pattern[] = {
00115     {
00116         1,
00117         {
00118             0, 0
00119         },
00120         {
00121             2000, 0
00122         }
00123     },
00124     {
00125         1,
00126         {
00127             900, 0
00128         },
00129         {
00130             2000, 0
00131         }
00132     },
00133     {
00134         1,
00135         {
00136             450, 0
00137         },
00138         {
00139             2000, 0
00140         }
00141     },
00142     {
00143         1,
00144         {
00145             -450, 0
00146         },
00147         {
00148             2000, 0
00149         }
00150     },
00151     {
00152         1,
00153         {
00154             300, 0
00155         },
00156         {
00157             2000, 0
00158         }
00159     },
00160     {
00161         1,
00162         {
00163             -300, 0
00164         },
00165         {
00166             2000, 0
00167         }
00168     },
00169     {
00170         2,
00171         {
00172             0, 900
00173         },
00174         {
00175             2000, 2000
00176         }
00177     },
00178     {
00179         2,
00180         {
00181             450, -450
00182         },
00183         {
00184             2000, 2000
00185         }
00186     }
00187 };
00188 
00189 // Set defining parameters for pattern fill
00190 
00191 static void
00192 spat( const PLINT inc[], const PLINT del[], PLINT nlin );
00193 
00194 //--------------------------------------------------------------------------
00195 // void plschr()
00196 //
00197 // Set character height.
00198 //--------------------------------------------------------------------------
00199 
00200 void
00201 c_plschr( PLFLT def, PLFLT scale )
00202 {
00203     if ( def != 0.0 )
00204         plsc->chrdef = def;
00205 
00206     plsc->chrht = scale * plsc->chrdef;
00207 }
00208 
00209 //--------------------------------------------------------------------------
00210 // void plsmin()
00211 //
00212 // Set up lengths of minor tick marks.
00213 //--------------------------------------------------------------------------
00214 
00215 void
00216 c_plsmin( PLFLT def, PLFLT scale )
00217 {
00218     if ( def != 0.0 )
00219         plsc->mindef = def;
00220 
00221     plsc->minht = scale * plsc->mindef;
00222 }
00223 
00224 //--------------------------------------------------------------------------
00225 // void plsmaj()
00226 //
00227 // Set up lengths of major tick marks.
00228 //--------------------------------------------------------------------------
00229 
00230 void
00231 c_plsmaj( PLFLT def, PLFLT scale )
00232 {
00233     if ( def != 0.0 )
00234         plsc->majdef = def;
00235 
00236     plsc->majht = scale * plsc->majdef;
00237 }
00238 
00239 //--------------------------------------------------------------------------
00240 // void plssym()
00241 //
00242 // Set symbol height.
00243 //--------------------------------------------------------------------------
00244 
00245 void
00246 c_plssym( PLFLT def, PLFLT scale )
00247 {
00248     if ( def != 0.0 )
00249         plsc->symdef = def;
00250 
00251     plsc->symht = scale * plsc->symdef;
00252 }
00253 
00254 //--------------------------------------------------------------------------
00255 // void pllsty()
00256 //
00257 // Set line style.
00258 //--------------------------------------------------------------------------
00259 
00260 void
00261 c_pllsty( PLINT lin )
00262 {
00263     if ( plsc->level < 1 )
00264     {
00265         plabort( "pllsty: Please call plinit first" );
00266         return;
00267     }
00268     if ( lin < 1 || lin > 8 )
00269     {
00270         plabort( "pllsty: Invalid line style" );
00271         return;
00272     }
00273 
00274     plsc->line_style = lin;
00275     plstyl( line[lin - 1].nels,
00276         &line[lin - 1].mark[0], &line[lin - 1].space[0] );
00277 }
00278 
00279 //--------------------------------------------------------------------------
00280 // void plpat()
00281 //
00282 // Set fill pattern directly.
00283 //--------------------------------------------------------------------------
00284 
00285 void
00286 c_plpat( PLINT nlin, const PLINT *inc, const PLINT *del )
00287 {
00288     PLINT i;
00289 
00290     if ( plsc->level < 1 )
00291     {
00292         plabort( "plpat: Please call plinit first" );
00293         return;
00294     }
00295     if ( nlin < 1 || nlin > 2 )
00296     {
00297         plabort( "plpat: Only 1 or 2 line styles allowed" );
00298         return;
00299     }
00300     for ( i = 0; i < nlin; i++ )
00301     {
00302         if ( del[i] < 0 )
00303         {
00304             plabort( "plpat: Line spacing must be greater than 0" );
00305             return;
00306         }
00307     }
00308     spat( inc, del, nlin );
00309 }
00310 
00311 //--------------------------------------------------------------------------
00312 // void plpsty()
00313 //
00314 // Set fill pattern, using one of the predefined patterns.
00315 // A fill pattern <= 0 indicates hardware fill.
00316 //--------------------------------------------------------------------------
00317 
00318 void
00319 c_plpsty( PLINT patt )
00320 {
00321     if ( plsc->level < 1 )
00322     {
00323         plabort( "plpsty: Please call plinit first" );
00324         return;
00325     }
00326     if ( patt > 8 )
00327     {
00328         plabort( "plpsty: Invalid pattern" );
00329         return;
00330     }
00331     if ( patt != plsc->patt )
00332     {
00333         plsc->patt = patt;
00334 
00335         if ( plsc->level > 0 )
00336         {
00337             plP_state( PLSTATE_FILL );
00338         }
00339     }
00340     if ( patt > 0 )
00341     {
00342         spat( &pattern[patt - 1].inc[0], &pattern[patt - 1].del[0],
00343             pattern[patt - 1].nlines );
00344     }
00345 }
00346 
00347 //--------------------------------------------------------------------------
00348 // void spat()
00349 //
00350 // Set defining parameters for pattern fill
00351 //--------------------------------------------------------------------------
00352 
00353 static void
00354 spat( const PLINT inc[], const PLINT del[], PLINT nlin )
00355 {
00356     PLINT i;
00357 
00358     plsc->nps = nlin;
00359     for ( i = 0; i < nlin; i++ )
00360     {
00361         plsc->inclin[i] = inc[i];
00362         plsc->delta[i]  = del[i];
00363     }
00364 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines