Example #1
0
static void plstrip_gen( PLStrip *strip )
{
    int i;
    PLFLT x[]={0.,1.,1.,0.}, y[]={0.,0.,1.,1.};

/* Set up window */

    plvpor(0,1,0,1);
    plwind(0,1,0,1);
    plcol(0);plpsty(0);
    plfill(4, &x[0], &y[0]);
    plvsta();

/* Draw box and same window dimensions */
    strip->wxmin=strip->xmin; strip->wxmax=strip->xmax;
    strip->wymin=strip->ymin; strip->wymax=strip->ymax; /* FIXME - can exist some redundancy here */

    plwind(strip->xmin, strip->xmax, strip->ymin, strip->ymax);

    pllsty(1);
    plcol(strip->colbox);
    plbox(strip->xspec, 0.0, 0, strip->yspec, 0.0, 0);

    plcol(strip->collab);
    pllab(strip->labx, strip->laby, strip->labtop);

    for (i=0; i<PEN; i++) {
        if (strip->npts[i] > 0) {
            plcol(strip->colline[i]);pllsty(strip->styline[i]);
            plline(strip->npts[i], strip->x[i], strip->y[i]);
        }
    }

    plstrip_legend(strip,0);
}
Example #2
0
static void plstrip_legend(PLStrip *mystripc, int first)
{
    int i;
    PLFLT sc, dy;

/* draw legend */

    plgchr(&sc, &dy);
    sc = dy = dy/100;
    plwind(-0.01, 1.01, -0.01, 1.01);
    for (i=0; i<PEN; i++) {
	if (mystripc->npts[i] || first) {
	    plcol(mystripc->colline[i]);
	    pllsty(mystripc->styline[i]);
	    pljoin(mystripc->xlpos, mystripc->ylpos - sc,
		   mystripc->xlpos + 0.1, mystripc->ylpos - sc);
	    plcol(mystripc->collab);
	    plptex(mystripc->xlpos + 0.11, mystripc->ylpos - sc,
		   0., 0., 0, mystripc->legline[i]);
	    sc += dy;
	}
    }
    plwind(mystripc->xmin, mystripc->xmax, mystripc->ymin, mystripc->ymax);
    plflush();
}
Example #3
0
int 
main(int argc, char **argv) 
{
    PLFLT minx, maxx, miny, maxy;
    int c;

/* Parse and process command line arguments */

    (void) plparseopts(&argc, argv, PL_PARSE_FULL);

/* Longitude (x) and latitude (y) */

    miny = -70;
    maxy = 80;

    plinit();

/* Cartesian plots */
/* Most of world */

    minx = 190;
    maxx = 190+360;

    plcol0(1);
    plenv(minx, maxx, miny, maxy, 1, -1);
    plmap(NULL, "usaglobe", minx, maxx, miny, maxy);

/* The Americas */

    minx = 190;
    maxx = 340;

    plcol0(1);
    plenv(minx, maxx, miny, maxy, 1, -1);
    plmap(NULL, "usaglobe", minx, maxx, miny, maxy);

/* Polar, Northern hemisphere */

    minx = 0;
    maxx = 360;

    plenv(-75., 75., -75., 75., 1, -1);
    plmap(mapform19,"globe", minx, maxx, miny, maxy);

    pllsty(2);
    plmeridians(mapform19,10.0, 10.0, 0.0, 360.0, -10.0, 80.0);
    plend();
    exit(0);
}
Example #4
0
static void potential( void )
//shielded potential contour plot example.
{
    int      i, j;
    PLcGrid2 cgrid2;
    PLFLT    rmax, xmin, xmax, x0, ymin, ymax, y0, zmin, zmax;
    PLFLT    peps, xpmin, xpmax, ypmin, ypmax;
    PLFLT    eps, q1, d1, q1i, d1i, q2, d2, q2i, d2i;
    PLFLT    div1, div1i, div2, div2i;
    PLFLT    **z;
    PLINT    nlevelneg, nlevelpos;
    PLFLT    dz, clevel2, clevelneg[PNLEVEL], clevelpos[PNLEVEL];
    PLINT    ncollin, ncolbox, ncollab;
    PLFLT    px[PPERIMETERPTS], py[PPERIMETERPTS];
    PLFLT    t, r, theta;

//create data to be contoured.
    plAlloc2dGrid( &cgrid2.xg, PRPTS, PTHETAPTS );
    plAlloc2dGrid( &cgrid2.yg, PRPTS, PTHETAPTS );
    plAlloc2dGrid( &z, PRPTS, PTHETAPTS );
    cgrid2.nx = PRPTS;
    cgrid2.ny = PTHETAPTS;

    for ( i = 0; i < PRPTS; i++ )
    {
        r = 0.5 + (double) i;
        for ( j = 0; j < PTHETAPTS; j++ )
        {
            theta           = ( 2. * M_PI / (double) ( PTHETAPTS - 1 ) ) * ( 0.5 + (double) j );
            cgrid2.xg[i][j] = r * cos( theta );
            cgrid2.yg[i][j] = r * sin( theta );
        }
    }

    rmax = r;
    f2mnmx( cgrid2.xg, PRPTS, PTHETAPTS, &xmin, &xmax );
    f2mnmx( cgrid2.yg, PRPTS, PTHETAPTS, &ymin, &ymax );
    x0 = ( xmin + xmax ) / 2.;
    y0 = ( ymin + ymax ) / 2.;

    // Expanded limits
    peps  = 0.05;
    xpmin = xmin - fabs( xmin ) * peps;
    xpmax = xmax + fabs( xmax ) * peps;
    ypmin = ymin - fabs( ymin ) * peps;
    ypmax = ymax + fabs( ymax ) * peps;

    // Potential inside a conducting cylinder (or sphere) by method of images.
    // Charge 1 is placed at (d1, d1), with image charge at (d2, d2).
    // Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).
    // Also put in smoothing term at small distances.
    //

    eps = 2.;

    q1 = 1.;
    d1 = rmax / 4.;

    q1i = -q1 * rmax / d1;
    d1i = pow( rmax, 2. ) / d1;

    q2 = -1.;
    d2 = rmax / 4.;

    q2i = -q2 * rmax / d2;
    d2i = pow( rmax, 2. ) / d2;

    for ( i = 0; i < PRPTS; i++ )
    {
        for ( j = 0; j < PTHETAPTS; j++ )
        {
            div1    = sqrt( pow( cgrid2.xg[i][j] - d1, 2. ) + pow( cgrid2.yg[i][j] - d1, 2. ) + pow( eps, 2. ) );
            div1i   = sqrt( pow( cgrid2.xg[i][j] - d1i, 2. ) + pow( cgrid2.yg[i][j] - d1i, 2. ) + pow( eps, 2. ) );
            div2    = sqrt( pow( cgrid2.xg[i][j] - d2, 2. ) + pow( cgrid2.yg[i][j] + d2, 2. ) + pow( eps, 2. ) );
            div2i   = sqrt( pow( cgrid2.xg[i][j] - d2i, 2. ) + pow( cgrid2.yg[i][j] + d2i, 2. ) + pow( eps, 2. ) );
            z[i][j] = q1 / div1 + q1i / div1i + q2 / div2 + q2i / div2i;
        }
    }
    f2mnmx( z, PRPTS, PTHETAPTS, &zmin, &zmax );
//   printf("%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g \n",
//        q1, d1, q1i, d1i, q2, d2, q2i, d2i);
// printf("%.15g %.15g %.15g %.15g %.15g %.15g \n",
//        xmin, xmax, ymin, ymax, zmin, zmax);

    // Positive and negative contour levels.
    dz        = ( zmax - zmin ) / (double) PNLEVEL;
    nlevelneg = 0;
    nlevelpos = 0;
    for ( i = 0; i < PNLEVEL; i++ )
    {
        clevel2 = zmin + ( (double) i + 0.5 ) * dz;
        if ( clevel2 <= 0. )
            clevelneg[nlevelneg++] = clevel2;
        else
            clevelpos[nlevelpos++] = clevel2;
    }
    // Colours!
    ncollin = 11;
    ncolbox = 1;
    ncollab = 2;

    // Finally start plotting this page!
    pladv( 0 );
    plcol0( ncolbox );

    plvpas( 0.1, 0.9, 0.1, 0.9, 1.0 );
    plwind( xpmin, xpmax, ypmin, ypmax );
    plbox( "", 0., 0, "", 0., 0 );

    plcol0( ncollin );
    if ( nlevelneg > 0 )
    {
        // Negative contours
        pllsty( 2 );
        plcont( (const PLFLT * const *) z, PRPTS, PTHETAPTS, 1, PRPTS, 1, PTHETAPTS,
            clevelneg, nlevelneg, pltr2, (void *) &cgrid2 );
    }

    if ( nlevelpos > 0 )
    {
        // Positive contours
        pllsty( 1 );
        plcont( (const PLFLT * const *) z, PRPTS, PTHETAPTS, 1, PRPTS, 1, PTHETAPTS,
            clevelpos, nlevelpos, pltr2, (void *) &cgrid2 );
    }

    // Draw outer boundary
    for ( i = 0; i < PPERIMETERPTS; i++ )
    {
        t     = ( 2. * M_PI / ( PPERIMETERPTS - 1 ) ) * (double) i;
        px[i] = x0 + rmax * cos( t );
        py[i] = y0 + rmax * sin( t );
    }

    plcol0( ncolbox );
    plline( PPERIMETERPTS, px, py );

    plcol0( ncollab );
    pllab( "", "", "Shielded potential of charges in a conducting sphere" );

    plFree2dGrid( z, PRPTS, PTHETAPTS );
    plFree2dGrid( cgrid2.xg, PRPTS, PTHETAPTS );
    plFree2dGrid( cgrid2.yg, PRPTS, PTHETAPTS );
}
Example #5
0
bool plotNoiseStandardDeviation(const hoNDArray< std::complex<T> >& m, const std::vector<std::string>& coilStrings,
                    const std::string& xlabel, const std::string& ylabel, const std::string& title,
                    size_t xsize, size_t ysize, bool trueColor,
                    hoNDArray<float>& plotIm)
{
    try
    {
        size_t CHA = m.get_size(0);
        GADGET_CHECK_RETURN_FALSE(coilStrings.size() == CHA);

        hoNDArray<double> xd, yd, yd2;

        xd.create(CHA);
        yd.create(CHA);

        size_t c;
        for (c = 0; c < CHA; c++)
        {
            xd(c) = c+1;
            yd(c) = std::sqrt( std::abs(m(c, c)) );
        }

        double maxY = Gadgetron::max(&yd);

        yd2 = yd;
        std::sort(yd2.begin(), yd2.end());
        double medY = yd2(CHA / 2);

        // increase dot line to be 1 sigma ~= 33%
        double medRange = 0.33;

        if (maxY < medY*(1 + medRange))
        {
            maxY = medY*(1 + medRange);
        }

        hoNDArray<unsigned char> im;
        im.create(3, xsize, ysize);
        Gadgetron::clear(im);

        plsdev("mem");

        plsmem(im.get_size(1), im.get_size(2), im.begin());

        plinit();
        plfont(2);
        pladv(0);
        plvpor(0.15, 0.75, 0.1, 0.8);

        plwind(0, CHA+1, 0, maxY*1.05);

        plcol0(15);
        plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);

        std::string gly;
        getPlotGlyph(0, gly); // circle
        plstring(CHA, xd.begin(), yd.begin(), gly.c_str());

        // draw the median line
        pllsty(1);

        double px[2], py[2];

        px[0] = 0;
        px[1] = CHA+1;

        py[0] = medY;
        py[1] = medY;

        plline(2, px, py);

        pllsty(2);

        py[0] = medY*(1 - medRange);
        py[1] = medY*(1 - medRange);

        plline(2, px, py);

        py[0] = medY*(1 + medRange);
        py[1] = medY*(1 + medRange);

        plline(2, px, py);

        plmtex("b", 3.2, 0.5, 0.5, xlabel.c_str());
        plmtex("t", 2.0, 0.5, 0.5, title.c_str());
        plmtex("l", 5.0, 0.5, 0.5, ylabel.c_str());

        // draw the legend
        std::vector<PLINT> opt_array(CHA), text_colors(CHA), line_colors(CHA), line_styles(CHA), symbol_numbers(CHA), symbol_colors(CHA);
        std::vector<PLFLT> symbol_scales(CHA), line_widths(CHA), box_scales(CHA, 1);

        std::vector<const char*> symbols(CHA);
        PLFLT legend_width, legend_height;

        std::vector<const char*> legend_text(CHA);

        std::vector<std::string> legends(CHA);

        size_t n;
        for (n = 0; n < CHA; n++)
        {
            opt_array[n] = PL_LEGEND_SYMBOL;
            text_colors[n] = 15;
            line_colors[n] = 15;
            line_styles[n] = (n % 8 + 1);
            line_widths[n] = 0.2;
            symbol_colors[n] = 15;
            symbol_scales[n] = 0.75;
            symbol_numbers[n] = 1;
            symbols[n] = gly.c_str();

            std::ostringstream ostr;
            ostr << n+1 << ":" << coilStrings[n];

            legends[n] = ostr.str();

            legend_text[n] = legends[n].c_str();
        }

        pllegend(&legend_width,
            &legend_height,
            PL_LEGEND_BACKGROUND,
            PL_POSITION_OUTSIDE | PL_POSITION_RIGHT,
            0.02,                                       // x
            0.0,                                        // y
            0.05,                                       // plot_width
            0,                                          // bg_color
            15,                                         // bb_color
            1,                                          // bb_style
            0,                                          // nrow
            0,                                          // ncolumn
            CHA,                                        // nlegend
            &opt_array[0],
            0.05,                                       // text_offset
            0.5,                                        // text_scale
            1.0,                                        // text_spacing
            0.5,                                        // text_justification
            &text_colors[0],
            (const char **)(&legend_text[0]),
            NULL,                                       // box_colors
            NULL,                                       // box_patterns
            &box_scales[0],                             // box_scales
            NULL,                                       // box_line_widths
            &line_colors[0],
            &line_styles[0],
            &line_widths[0],
            &symbol_colors[0],
            &symbol_scales[0],
            &symbol_numbers[0],
            (const char **)(&symbols[0])
            );

        plend();

        outputPlotIm(im, trueColor, plotIm);
    }
    catch (...)
    {
        GERROR_STREAM("Errors happened in plotNoiseStandardDeviation(...) ... ");
        return false;
    }

    return true;
}
Example #6
0
template <typename T> EXPORTGTPLPLOT
bool plotCurves(const std::vector<hoNDArray<T> >& x, const std::vector<hoNDArray<T> >& y, 
                const std::string& xlabel, const std::string& ylabel, 
                const std::string& title, const std::vector<std::string>& legend, 
                const std::vector<std::string>& symbols, 
                size_t xsize, size_t ysize, 
                T xlim[2], T ylim[2], 
                bool trueColor, bool drawLine, 
                hoNDArray<float>& plotIm)
{
    try
    {
        GADGET_CHECK_RETURN_FALSE(x.size()>0);
        GADGET_CHECK_RETURN_FALSE(y.size()>0);
        GADGET_CHECK_RETURN_FALSE(x.size() == y.size());

        T minX = xlim[0];
        T maxX = xlim[1];
        T minY = ylim[0];
        T maxY = ylim[1];

        plsdev("mem");

        hoNDArray<unsigned char> im;
        im.create(3, xsize, ysize);
        Gadgetron::clear(im);

        plsmem(im.get_size(1), im.get_size(2), im.begin());

        plinit();
        plfont(2);

        pladv(0);

        if (legend.size() == x.size())
        {
            plvpor(0.11, 0.75, 0.1, 0.9);
        }
        else
        {
            plvpor(0.15, 0.85, 0.1, 0.9);
        }

        T spaceX = 0.01*(maxX - minX);
        T spaceY = 0.05*(maxY - minY);

        plwind(minX - spaceX, maxX + spaceX, minY - spaceY, maxY + spaceY);

        plcol0(15);
        plbox("bgcnst", 0.0, 0, "bgcnstv", 0.0, 0);

        // int mark[2], space[2];

        //mark[0] = 4000;
        //space[0] = 2500;
        //plstyl(1, mark, space);

        size_t num = x.size();

        size_t n;

        hoNDArray<double> xd, yd;

        // draw lines
        for (n = 0; n < num; n++)
        {
            size_t N = y[n].get_size(0);

            xd.copyFrom(x[n]);
            yd.copyFrom(y[n]);

            if (drawLine)
            {
                int c;
                getPlotColor(n, c);
                plcol0(c);
                pllsty(n % 8 + 1);
                plline(N, xd.begin(), yd.begin());
            }

            std::string gly;
            if(symbols.size()>n)
            {
                gly = symbols[n];
            }
            else
                getPlotGlyph(n, gly);

            plstring(N, xd.begin(), yd.begin(), gly.c_str());
        }

        plcol0(15);
        plmtex("b", 3.2, 0.5, 0.5, xlabel.c_str());
        plmtex("t", 2.0, 0.5, 0.5, title.c_str());
        plmtex("l", 5.0, 0.5, 0.5, ylabel.c_str());

        // draw the legend
        if (legend.size() == x.size())
        {
            std::vector<PLINT> opt_array(num), text_colors(num), line_colors(num), line_styles(num), symbol_numbers(num), symbol_colors(num);
            std::vector<PLFLT> symbol_scales(num), line_widths(num), box_scales(num, 1);

            std::vector<std::string> glyphs(num);
            std::vector<const char*> symbols(num);
            PLFLT legend_width, legend_height;

            std::vector<const char*> legend_text(num);

            for (n = 0; n < num; n++)
            {
                int c;
                getPlotColor(n, c);
                getPlotGlyph(n, glyphs[n]);

                opt_array[n] = PL_LEGEND_SYMBOL | PL_LEGEND_LINE;
                text_colors[n] = 15;
                line_colors[n] = c;
                line_styles[n] = (n%8+1);
                line_widths[n] = 0.2;
                symbol_colors[n] = c;
                symbol_scales[n] = 0.75;
                symbol_numbers[n] = 1;
                symbols[n] = glyphs[n].c_str();
                legend_text[n] = legend[n].c_str();
            }

            pllegend(&legend_width, 
                    &legend_height,
                    PL_LEGEND_BACKGROUND,
                    PL_POSITION_OUTSIDE | PL_POSITION_RIGHT | PL_POSITION_TOP,
                    0.02,                                       // x
                    0.0,                                        // y
                    0.05,                                       // plot_width
                    0,                                          // bg_color
                    15,                                         // bb_color
                    1,                                          // bb_style
                    0,                                          // nrow
                    0,                                          // ncolumn
                    num,                                        // nlegend
                    &opt_array[0], 
                    0.05,                                       // text_offset
                    0.35,                                       // text_scale
                    1.0,                                        // text_spacing
                    0.5,                                        // text_justification
                    &text_colors[0], 
                    (const char **)(&legend_text[0]), 
                    NULL,                                       // box_colors
                    NULL,                                       // box_patterns
                    &box_scales[0],                             // box_scales
                    NULL,                                       // box_line_widths
                    &line_colors[0], 
                    &line_styles[0], 
                    &line_widths[0],
                    &symbol_colors[0], 
                    &symbol_scales[0], 
                    &symbol_numbers[0], 
                    (const char **)(&symbols[0])
                    );
        }

        plend();

        outputPlotIm(im, trueColor, plotIm);
    }
    catch (...)
    {
        GERROR_STREAM("Errors happened in plotCurves(xlim, ylim) ... ");
        return false;
    }

    return true;
}
Example #7
0
int
main( int argc, const char *argv[] )
{
    int   i, j, k;
    int   npts = 0;
    PLFLT xextreme[10][2];
    PLFLT yextreme[10][2];
    PLFLT x0[10];
    PLFLT y0[10];

// Parse and process command line arguments

    (void) plparseopts( &argc, argv, PL_PARSE_FULL );

// Initialize plplot

    plssub( 3, 3 );
    plinit();

    xextreme[0][0] = -120.0; xextreme[0][1] = 120.0; yextreme[0][0] = -120.0; yextreme[0][1] = 120.0;
    xextreme[1][0] = -120.0; xextreme[1][1] = 120.0; yextreme[1][0] = 20.0; yextreme[1][1] = 120.0;
    xextreme[2][0] = -120.0; xextreme[2][1] = 120.0; yextreme[2][0] = -20.0; yextreme[2][1] = 120.0;
    xextreme[3][0] = -80.0; xextreme[3][1] = 80.0; yextreme[3][0] = -20.0; yextreme[3][1] = 120.0;
    xextreme[4][0] = -220.0; xextreme[4][1] = -120.0; yextreme[4][0] = -120.0; yextreme[4][1] = 120.0;
    xextreme[5][0] = -20.0; xextreme[5][1] = 20.0; yextreme[5][0] = -120.0; yextreme[5][1] = 120.0;
    xextreme[6][0] = -20.0; xextreme[6][1] = 20.0; yextreme[6][0] = -20.0; yextreme[6][1] = 20.0;
    xextreme[7][0] = -80.0; xextreme[7][1] = 80.0; yextreme[7][0] = -80.0; yextreme[7][1] = 80.0;
    xextreme[8][0] = 20.0; xextreme[8][1] = 120.0; yextreme[8][0] = -120.0; yextreme[8][1] = 120.0;

    for ( k = 0; k < 2; k++ )
    {
        for ( j = 0; j < 4; j++ )
        {
            if ( j == 0 )
            {
// Polygon 1: a diamond
                x0[0] = 0; y0[0] = -100;
                x0[1] = -100; y0[1] = 0;
                x0[2] = 0; y0[2] = 100;
                x0[3] = 100; y0[3] = 0;
                npts  = 4;
            }
            if ( j == 1 )
            {
// Polygon 1: a diamond - reverse direction
                x0[3] = 0; y0[3] = -100;
                x0[2] = -100; y0[2] = 0;
                x0[1] = 0; y0[1] = 100;
                x0[0] = 100; y0[0] = 0;
                npts  = 4;
            }
            if ( j == 2 )
            {
// Polygon 2: a square with punctures
                x0[0] = -100; y0[0] = -100;
                x0[1] = -100; y0[1] = -80;
                x0[2] = 80; y0[2] = 0;
                x0[3] = -100; y0[3] = 80;
                x0[4] = -100; y0[4] = 100;
                x0[5] = -80; y0[5] = 100;
                x0[6] = 0; y0[6] = 80;
                x0[7] = 80; y0[7] = 100;
                x0[8] = 100; y0[8] = 100;
                x0[9] = 100; y0[9] = -100;
                npts  = 10;
            }
            if ( j == 3 )
            {
// Polygon 2: a square with punctures - reversed direction
                x0[9] = -100; y0[9] = -100;
                x0[8] = -100; y0[8] = -80;
                x0[7] = 80; y0[7] = 0;
                x0[6] = -100; y0[6] = 80;
                x0[5] = -100; y0[5] = 100;
                x0[4] = -80; y0[4] = 100;
                x0[3] = 0; y0[3] = 80;
                x0[2] = 80; y0[2] = 100;
                x0[1] = 100; y0[1] = 100;
                x0[0] = 100; y0[0] = -100;
                npts  = 10;
            }

            for ( i = 0; i < 9; i++ )
            {
                pladv( 0 );
                plvsta();
                plwind( xextreme[i][0], xextreme[i][1], yextreme[i][0], yextreme[i][1] );

                plcol0( 2 );
                plbox( "bc", 1.0, 0, "bcnv", 10.0, 0 );
                plcol0( 1 );
                plpsty( 0 );
                if ( k == 0 )
                    plfill( npts, x0, y0 );
                else
                    plgradient( npts, x0, y0, 45. );
                plcol0( 2 );
                pllsty( 1 );
                plline( npts, x0, y0 );
            }
        }
    }

// Don't forget to call plend() to finish off!

    plend();
    exit( 0 );
}
Example #8
0
void c_plstripa( PLINT id, PLINT p, PLFLT x, PLFLT y )
{
    int j, yasc=0, istart;

    if (p >= PEN) {
    	plabort("Non existent pen");
    	return;
    }

    if ((id < 0) || (id >= MAX_STRIPC) ||
	((stripc = strip[id]) == NULL)) {
    	plabort("Non existent stripchart");
    	return;
    }

/* Add new point, allocating memory if necessary */

    if (++stripc->npts[p] > stripc->nptsmax[p]) {
	stripc->nptsmax[p] += 32;
	stripc->x[p] = (PLFLT *) realloc((void *) stripc->x[p], sizeof(PLFLT)*stripc->nptsmax[p]);
	stripc->y[p] = (PLFLT *) realloc((void *) stripc->y[p], sizeof(PLFLT)*stripc->nptsmax[p]);
	if (stripc->x[p] == NULL || stripc->y[p] == NULL) {
	    plabort("plstripc: Out of memory.");
	    plstripd(id);
	    return;
	}
    }

    stripc->x[p][stripc->npts[p]-1] = x;
    stripc->y[p][stripc->npts[p]-1] = y;

    stripc->xmax = x;

    if (stripc->y_ascl == 1 && (y > stripc->ymax || y < stripc->ymin))
	yasc=1;

    if (y > stripc->ymax)
	stripc->ymax = stripc->ymin + 1.1*(y - stripc->ymin);
	if (y < stripc->ymin)
	  stripc->ymin = stripc->ymax - 1.1*(stripc->ymax - y);

/* Now either plot new point or regenerate plot */

        if (stripc->xmax - stripc->xmin < stripc->xlen) {
            if( yasc == 0) {

            /* If user has changed subwindow, make shure we have the correct one */
                plvsta();
                plwind(stripc->wxmin, stripc->wxmax, stripc->wymin, stripc->wymax); /* FIXME - can exist some redundancy here */
		plcol(stripc->colline[p]); pllsty(stripc->styline[p]);
		if ((stripc->npts[p]-2) < 0)
		  plP_movwor(stripc->x[p][stripc->npts[p]-1], stripc->y[p][stripc->npts[p]-1]);
		else
		  plP_movwor(stripc->x[p][stripc->npts[p]-2], stripc->y[p][stripc->npts[p]-2]);
		plP_drawor(stripc->x[p][stripc->npts[p]-1], stripc->y[p][stripc->npts[p]-1]);
		plflush();
            }
            else {
		stripc->xmax = stripc->xmin + stripc->xlen;
                plstrip_gen(stripc);
	    }
	}
    else {
/* Regenerating plot */
	if (stripc->acc == 0) {
	    for (j=0; j<PEN; j++) {
		if (stripc->npts[j] > 0) {
		    istart = 0;
		    while (stripc->x[j][istart] < stripc->xmin + stripc->xlen*stripc->xjump)
			istart++;

		    stripc->npts[j] = stripc->npts[j] - istart;
		    memcpy( &stripc->x[j][0], &stripc->x[j][istart], (stripc->npts[j])*sizeof(PLFLT));
		    memcpy( &stripc->y[j][0], &stripc->y[j][istart], (stripc->npts[j])*sizeof(PLFLT));
		}
	    }
	} else
	    stripc->xlen = stripc->xlen * (1 + stripc->xjump);

	stripc->xmin = stripc->x[p][0];
	stripc->xmax = stripc->xmax + stripc->xlen*stripc->xjump;

	plstrip_gen(stripc);
    }
}
Example #9
0
int
main( int argc, char **argv )
{
    PLFLT       minx, maxx, miny, maxy;
    PLFLT       x, y;
    //variables for the shapelib example
    const PLINT nbeachareas    = 2;
    const PLINT beachareas[]   = { 23, 24 };
    const PLINT nwoodlandareas = 94;
    PLINT       woodlandareas[94];
    const PLINT nshingleareas  = 22;
    const PLINT shingleareas[] = { 0, 1, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 217, 2424, 2425, 2426, 2427, 2428, 2491, 2577 };
    const PLINT ncragareas     = 2024;
    PLINT       cragareas[2024];
    const PLINT majorroads[] = { 33, 48, 71, 83, 89, 90, 101, 102, 111 };
    int         i;

// Parse and process command line arguments

    (void) plparseopts( &argc, argv, PL_PARSE_FULL );

// Longitude (x) and latitude (y)

    miny = -70;
    maxy = 80;

    plinit();

// Cartesian plots
// Most of world

    minx = -170;
    maxx = minx + 360;

    // Setup a custom latitude and longitude-based scaling function.
    plslabelfunc( geolocation_labeler, NULL );

    plcol0( 1 );
    plenv( minx, maxx, miny, maxy, 1, 70 );
    plmap( NULL, "usaglobe", minx, maxx, miny, maxy );

// The Americas

    minx = 190;
    maxx = 340;

    plcol0( 1 );
    plenv( minx, maxx, miny, maxy, 1, 70 );
    plmap( NULL, "usaglobe", minx, maxx, miny, maxy );

    // Clear the labeling function
    plslabelfunc( NULL, NULL );

// Polar, Northern hemisphere

    minx = 0;
    maxx = 360;

    plenv( -75., 75., -75., 75., 1, -1 );
    plmap( mapform19, "globe", minx, maxx, miny, maxy );

    pllsty( 2 );
    plmeridians( mapform19, 10.0, 10.0, 0.0, 360.0, -10.0, 80.0 );

// Polar, Northern hemisphere, this time with a PLplot-wide transform

    minx = 0;
    maxx = 360;

    plstransform( map_transform, NULL );

    pllsty( 1 );
    plenv( -75., 75., -75., 75., 1, -1 );
    // No need to set the map transform here as the global transform will be
    // used.
    plmap( NULL, "globe", minx, maxx, miny, maxy );

    pllsty( 2 );
    plmeridians( NULL, 10.0, 10.0, 0.0, 360.0, -10.0, 80.0 );

    // Show Baltimore, MD on the map
    plcol0( 2 );
    plssym( 0.0, 2.0 );
    x = -76.6125;
    y = 39.2902778;
    plpoin( 1, &x, &y, 18 );
    plssym( 0.0, 1.0 );
    plptex( -76.6125, 43.0, 0.0, 0.0, 0.0, "Baltimore, MD" );

    // For C, this is how the global transform is cleared
    plstransform( NULL, NULL );

    // An example using shapefiles. The shapefiles used are from Ordnance Survey, UK.
    // These were chosen because they provide shapefiles for small grid boxes which
    // are easilly manageable for this demo.

    pllsty( 1 );


    minx = 240570;
    maxx = 621109;
    miny = 87822;
    maxy = 722770;
    plscol0( 0, 255, 255, 255 );
    plscol0( 1, 0, 0, 0 );
    plscol0( 2, 150, 150, 150 );
    plscol0( 3, 0, 50, 200 );
    plscol0( 4, 50, 50, 50 );
    plscol0( 5, 150, 0, 0 );
    plscol0( 6, 100, 100, 255 );


    minx = 265000;
    maxx = 270000;
    miny = 145000;
    maxy = 150000;
    plscol0( 0, 255, 255, 255 ); //white
    plscol0( 1, 0, 0, 0 );       //black
    plscol0( 2, 255, 200, 0 );   //yelow for sand
    plscol0( 3, 60, 230, 60 );   // green for woodland
    plscol0( 4, 210, 120, 60 );  //brown for contours
    plscol0( 5, 150, 0, 0 );     //red for major roads
    plscol0( 6, 180, 180, 255 ); //pale blue for water
    plscol0( 7, 100, 100, 100 ); //pale grey for shingle or boulders
    plscol0( 8, 100, 100, 100 ); //dark grey for custom polygons - generally crags


    plcol0( 1 );
    plenv( minx, maxx, miny, maxy, 1, -1 );
    pllab( "", "", "Martinhoe CP, Exmoor National Park, UK (shapelib only)" );


    //Beach
    plcol0( 2 );
    plmapfill( NULL, "ss/ss64ne_Landform_Area", minx, maxx, miny, maxy, beachareas, nbeachareas );

    //woodland
    plcol0( 3 );
    for ( i = 0; i < nwoodlandareas; ++i )
        woodlandareas[i] = i + 218;
    plmapfill( NULL, "ss/ss64ne_Landform_Area", minx, maxx, miny, maxy, (PLINT_VECTOR) woodlandareas, nwoodlandareas );

    //shingle or boulders
    plcol0( 7 );
    plmapfill( NULL, "ss/ss64ne_Landform_Area", minx, maxx, miny, maxy, shingleareas, nshingleareas );

    //crags
    plcol0( 8 );
    for ( i = 0; i < ncragareas; ++i )
        cragareas[i] = i + 325;
    plmapfill( NULL, "ss/ss64ne_Landform_Area", minx, maxx, miny, maxy, (PLINT_VECTOR) cragareas, ncragareas );

    //draw contours, we need to separate contours from high/low coastline
    //draw_contours(pls, "ss/SS64_line", 433, 20, 4, 3, minx, maxx, miny, maxy );
    plcol0( 4 );
    plmapline( NULL, "ss/ss64ne_Height_Contours", minx, maxx, miny, maxy, NULL, 0 );

    //draw the sea and surface water
    plwidth( 0.0 );
    plcol0( 6 );
    plmapfill( NULL, "ss/ss64ne_Water_Area", minx, maxx, miny, maxy, NULL, 0 );
    plwidth( 2.0 );
    plmapfill( NULL, "ss/ss64ne_Water_Line", minx, maxx, miny, maxy, NULL, 0 );

    //draw the roads, first with black and then thinner with colour to give an
    //an outlined appearance
    plwidth( 5.0 );
    plcol0( 1 );
    plmapline( NULL, "ss/ss64ne_Road_Centreline", minx, maxx, miny, maxy, NULL, 0 );
    plwidth( 3.0 );
    plcol0( 0 );
    plmapline( NULL, "ss/ss64ne_Road_Centreline", minx, maxx, miny, maxy, NULL, 0 );
    plcol0( 5 );
    plmapline( NULL, "ss/ss64ne_Road_Centreline", minx, maxx, miny, maxy, majorroads, 9 );

    //draw buildings
    plwidth( 1.0 );
    plcol0( 1 );
    plmapfill( NULL, "ss/ss64ne_Building_Area", minx, maxx, miny, maxy, NULL, 0 );

    //labels
    plsfci( 0x80000100 );
    plschr( 0, 0.8 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "MARTINHOE CP", minx, maxx, miny, maxy, 202 );
    plschr( 0, 0.7 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Heale\nDown", minx, maxx, miny, maxy, 13 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "South\nDown", minx, maxx, miny, maxy, 34 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Martinhoe\nCommon", minx, maxx, miny, maxy, 42 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Woody Bay", minx, maxx, miny, maxy, 211 );
    plschr( 0, 0.6 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Mill Wood", minx, maxx, miny, maxy, 16 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Heale Wood", minx, maxx, miny, maxy, 17 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 1.0, "Bodley", minx, maxx, miny, maxy, 31 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.0, "Martinhoe", minx, maxx, miny, maxy, 37 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Woolhanger\nCommon", minx, maxx, miny, maxy, 60 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "West Ilkerton\nCommon", minx, maxx, miny, maxy, 61 );
    plmaptex( NULL, "ss/ss64ne_General_Text", 1.0, 0.0, 0.5, "Caffyns\nHeanton\nDown", minx, maxx, miny, maxy, 62 );

    plend();
    exit( 0 );
}
Example #10
0
static void plplot_setup_linestyle( line_attribute_type line_attr ) {
  pllsty(line_attr.line_style);                                   /* Setting solid/dashed/... */
  plwidth(line_attr.line_width * PLOT_DEFAULT_LINE_WIDTH);          /* Setting line width.*/
  plcol0(line_attr.line_color);                                   /* Setting line color. */
}