Back to index

plt-scheme  4.2.1
plsdef.c
Go to the documentation of this file.
00001 /* $Id: plsdef.c,v 1.1 2004/03/01 20:54:52 cozmic Exp $
00002 
00003        Routines to set various plplot parameters, such as char height,
00004        symbol size, tick length, line and fill patterns, etc.
00005 */
00006 
00007 #include "plplotP.h"
00008 
00009 /* Line pattern defaults */
00010 
00011 static struct line {
00012     PLINT nels;
00013     PLINT mark[4];
00014     PLINT space[4];
00015 } line[] = {
00016 
00017     {
00018        0,                   /* Continuous line */
00019        {
00020            0, 0, 0, 0
00021        },
00022        {
00023            0, 0, 0, 0
00024        }
00025     },
00026     {
00027        1,
00028        {
00029            1000, 0, 0, 0
00030        },
00031        {
00032            1000, 0, 0, 0
00033        }
00034     },
00035     {
00036        1,
00037        {
00038            2000, 0, 0, 0
00039        },
00040        {
00041            2000, 0, 0, 0
00042        }
00043     },
00044     {
00045        1,
00046        {
00047            2000, 0, 0, 0
00048        },
00049        {
00050            1000, 0, 0, 0
00051        }
00052     },
00053     {
00054        2,
00055        {
00056            2500, 1000, 0, 0
00057        },
00058        {
00059            1000, 1000, 0, 0
00060        }
00061     },
00062     {
00063        2,
00064        {
00065            2000, 1000, 0, 0
00066        },
00067        {
00068            2000, 1000, 0, 0
00069        }
00070     },
00071     {
00072        3,
00073        {
00074            1000, 1500, 2000, 0
00075        },
00076        {
00077            1000, 1500, 2000, 0
00078        }
00079     },
00080     {
00081        3,
00082        {
00083            1000, 1500, 2000, 0
00084        },
00085        {
00086            1000, 1000, 1000, 0
00087        }
00088     }
00089 };
00090 
00091 /* Fill pattern defaults */
00092 
00093 static struct pattern {
00094     PLINT nlines;           /* Number of lines in pattern (1 or 2) */
00095     PLINT inc[2];           /* Inclination 10 ths of degrees */
00096     PLINT del[2];           /* Spacing for each line */
00097 } pattern[] = {
00098 
00099     {
00100        1,
00101        {
00102            0, 0
00103        },
00104        {
00105            2000, 0
00106        }
00107     },
00108     {
00109        1,
00110        {
00111            900, 0
00112        },
00113        {
00114            2000, 0
00115        }
00116     },
00117     {
00118        1,
00119        {
00120            450, 0
00121        },
00122        {
00123            2000, 0
00124        }
00125     },
00126     {
00127        1,
00128        {
00129            -450, 0
00130        },
00131        {
00132            2000, 0
00133        }
00134     },
00135     {
00136        1,
00137        {
00138            300, 0
00139        },
00140        {
00141            2000, 0
00142        }
00143     },
00144     {
00145        1,
00146        {
00147            -300, 0
00148        },
00149        {
00150            2000, 0
00151        }
00152     },
00153     {
00154        2,
00155        {
00156            0, 900
00157        },
00158        {
00159            2000, 2000
00160        }
00161     },
00162     {
00163        2,
00164        {
00165            450, -450
00166        },
00167        {
00168            2000, 2000
00169        }
00170     }
00171 };
00172 
00173 /* Set defining parameters for pattern fill */
00174 
00175 static void
00176 spat(PLINT inc[], PLINT del[], PLINT nlin);
00177 
00178 /*----------------------------------------------------------------------*\
00179  * void plschr()
00180  *
00181  * Set character height.
00182 \*----------------------------------------------------------------------*/
00183 
00184 void
00185 c_plschr(PLFLT def, PLFLT scale)
00186 {
00187     if (def != 0.0) 
00188        plsc->chrdef = def;
00189 
00190     plsc->chrht = scale * plsc->chrdef;
00191 }
00192 
00193 /*----------------------------------------------------------------------*\
00194  * void plsmin()
00195  *
00196  * Set up lengths of minor tick marks.
00197 \*----------------------------------------------------------------------*/
00198 
00199 void
00200 c_plsmin(PLFLT def, PLFLT scale)
00201 {
00202     if (def != 0.0) 
00203        plsc->mindef = def;
00204 
00205     plsc->minht = scale * plsc->mindef;
00206 }
00207 
00208 /*----------------------------------------------------------------------*\
00209  * void plsmaj()
00210  *
00211  * Set up lengths of major tick marks.
00212 \*----------------------------------------------------------------------*/
00213 
00214 void
00215 c_plsmaj(PLFLT def, PLFLT scale)
00216 {
00217     if (def != 0.0) 
00218        plsc->majdef = def;
00219 
00220     plsc->majht = scale * plsc->majdef;
00221 }
00222 
00223 /*----------------------------------------------------------------------*\
00224  * void plssym()
00225  *
00226  * Set symbol height.
00227 \*----------------------------------------------------------------------*/
00228 
00229 void
00230 c_plssym(PLFLT def, PLFLT scale)
00231 {
00232     if (def != 0.0) 
00233        plsc->symdef = def;
00234 
00235     plsc->symht = scale * plsc->symdef;
00236 }
00237 
00238 /*----------------------------------------------------------------------*\
00239  * void pllsty()
00240  *
00241  * Set line style.
00242 \*----------------------------------------------------------------------*/
00243 
00244 void
00245 c_pllsty(PLINT lin)
00246 {
00247     if (plsc->level < 1) {
00248        plabort("pllsty: Please call plinit first");
00249        return;
00250     }
00251     if (lin < 1 || lin > 8) {
00252        plabort("pllsty: Invalid line style");
00253        return;
00254     }
00255 
00256     plstyl(line[lin - 1].nels,
00257           &line[lin - 1].mark[0], &line[lin - 1].space[0]);
00258 }
00259 
00260 /*----------------------------------------------------------------------*\
00261  * void plpat()
00262  *
00263  * Set fill pattern directly.
00264 \*----------------------------------------------------------------------*/
00265 
00266 void
00267 c_plpat(PLINT nlin, PLINT *inc, PLINT *del)
00268 {
00269     PLINT i;
00270 
00271     if (plsc->level < 1) {
00272        plabort("plpat: Please call plinit first");
00273        return;
00274     }
00275     if (nlin < 1 || nlin > 2) {
00276        plabort("plpat: Only 1 or 2 line styles allowed");
00277        return;
00278     }
00279     for (i = 0; i < nlin; i++) {
00280        if (del[i] < 0) {
00281            plabort("plpat: Line spacing must be greater than 0");
00282            return;
00283        }
00284     }
00285     spat(inc, del, nlin);
00286 }
00287 
00288 /*----------------------------------------------------------------------*\
00289  * void plpsty()
00290  *
00291  * Set fill pattern, using one of the predefined patterns.
00292  * A fill pattern <= 0 indicates hardware fill.
00293 \*----------------------------------------------------------------------*/
00294 
00295 void
00296 c_plpsty(PLINT patt)
00297 {
00298     if (plsc->level < 1) {
00299        plabort("plpsty: Please call plinit first");
00300        return;
00301     }
00302     if (patt > 8) {
00303        plabort("plpsty: Invalid pattern");
00304        return;
00305     }
00306     if (patt != plsc->patt) {
00307        plsc->patt = patt;
00308 
00309        if (plsc->level > 0) {
00310            plP_state(PLSTATE_FILL);
00311        }
00312     }
00313     if (patt > 0) {
00314        spat(&pattern[patt - 1].inc[0], &pattern[patt - 1].del[0],
00315             pattern[patt - 1].nlines);
00316     }
00317 }
00318 
00319 /*----------------------------------------------------------------------*\
00320  * void spat()
00321  *
00322  * Set defining parameters for pattern fill 
00323 \*----------------------------------------------------------------------*/
00324 
00325 static void
00326 spat(PLINT inc[], PLINT del[], PLINT nlin)
00327 {
00328     PLINT i;
00329 
00330     plsc->nps = nlin;
00331     for (i = 0; i < nlin; i++) {
00332        plsc->inclin[i] = inc[i];
00333        plsc->delta[i] = del[i];
00334     }
00335 }