コード例 #1
0
ファイル: trackscenenode.cpp プロジェクト: julian9/LODRender
//================================================================
void update_track_dimensions(TrackSceneNode* t)
{
    if(!t) return;
    float max_x = 0.0, max_y = 0.0;
    float min_x = 0.0, min_y = 0.0;

    for( int i = 0; i < t->zorder.size(); ++i)
    {
        CoreSection* c = t->modelvec[ t->zorder[i] ];
        if( !c ) continue;
        
        if( c->px < min_x ) min_x = c->px;
        if( c->py < min_y ) min_y = c->py;
        
        float cw, ch;
        float gw, gh;

        cw = get_texset_src_width( c->src );
        ch = get_texset_src_height( c->src );
        
        if(c->orientation == PORTRAIT)
        {
            float t;
            t  = cw;
            cw = ch;
            ch = t;
        }

//        printf("Checking image of dims %f x %f, with dpis of %f, %f\n",
//               cw,ch,c->dpi_x,c->dpi_y);

        if( cw > 0)
        {
            // scale to describe number of inches actually covered
            cw /= c->dpi_x;
            if( c->px + cw > max_x) max_x = (c->px + cw);
        }

        if( ch > 0)
        {
            // scale to describe number of inches actually covered
            ch /= c->dpi_y;
            if( c->py + cw > max_y) max_y = (c->py + ch);
        }

        for( int i = 0; i < c->graphvec.size(); i++)
        {
            Box* b = get_graph_box( c, c->graphvec[i] );
            if(!b) continue;
            delete b;
        }
    }

    t->w = max_x - min_x;
    t->h = max_y - min_y;

//    printf("Updated track dimensions %f x %f\n", t->w, t->h);
}
コード例 #2
0
ファイル: params.cpp プロジェクト: nixz/covise
void put_annotation(int, FILE *pp, int imbed)
{
    int i;
    boxtype b;
    linetype l;
    plotstr s;
    char imbedstr[2];

    if (imbed)
    {
        strcpy(imbedstr, "@");
    }
    else
    {
        imbedstr[0] = 0;
    }
    for (i = 0; i < MAXBOXES; i++)
    {
        get_graph_box(i, &b);
        if (b.active == ON)
        {
            fprintf(pp, "%swith box\n", imbedstr);
            fprintf(pp, "%s    box on\n", imbedstr);
            fprintf(pp, "%s    box loctype %s\n", imbedstr, w_or_v(b.loctype));
            if (b.loctype == WORLD)
            {
                fprintf(pp, "%s    box g%1d\n", imbedstr, b.gno);
            }
            fprintf(pp, "%s    box %.12lg, %.12lg, %.12lg, %.12lg\n", imbedstr, b.x1, b.y1, b.x2, b.y2);
            fprintf(pp, "%s    box linestyle %d\n", imbedstr, b.lines);
            fprintf(pp, "%s    box linewidth %d\n", imbedstr, b.linew);
            fprintf(pp, "%s    box color %d\n", imbedstr, b.color);
            switch (b.fill)
            {
            case PLOT_NONE:
                fprintf(pp, "%s    box fill none\n", imbedstr);
                break;
            case COLOR:
                fprintf(pp, "%s    box fill color\n", imbedstr);
                break;
            case PATTERN:
                fprintf(pp, "%s    box fill pattern\n", imbedstr);
                break;
            }
            fprintf(pp, "%s    box fill color %d\n", imbedstr, b.fillcolor);
            fprintf(pp, "%s    box fill pattern %d\n", imbedstr, b.fillpattern);
            fprintf(pp, "%sbox def\n", imbedstr);
        }
    }

    for (i = 0; i < MAXLINES; i++)
    {
        get_graph_line(i, &l);
        if (l.active == ON)
        {
            fprintf(pp, "%swith line\n", imbedstr);
            fprintf(pp, "%s    line on\n", imbedstr);
            fprintf(pp, "%s    line loctype %s\n", imbedstr, w_or_v(l.loctype));
            if (l.loctype == WORLD)
            {
                fprintf(pp, "%s    line g%1d\n", imbedstr, l.gno);
            }
            fprintf(pp, "%s    line %.12lg, %.12lg, %.12lg, %.12lg\n", imbedstr, l.x1, l.y1, l.x2, l.y2);
            fprintf(pp, "%s    line linewidth %d\n", imbedstr, l.linew);
            fprintf(pp, "%s    line linestyle %d\n", imbedstr, l.lines);
            fprintf(pp, "%s    line color %d\n", imbedstr, l.color);
            fprintf(pp, "%s    line arrow %d\n", imbedstr, l.arrow);
            fprintf(pp, "%s    line arrow size %lf\n", imbedstr, l.asize);
            fprintf(pp, "%s    line arrow type %d\n", imbedstr, l.atype);
            fprintf(pp, "%sline def\n", imbedstr);
        }
    }

    for (i = 0; i < MAXSTR; i++)
    {
        get_graph_string(i, &s);
        if (s.active == ON && s.s[0])
        {
            fprintf(pp, "%swith string\n", imbedstr);
            fprintf(pp, "%s    string on\n", imbedstr);
            fprintf(pp, "%s    string loctype %s\n", imbedstr, w_or_v(s.loctype));
            if (s.loctype == WORLD)
            {
                fprintf(pp, "%s    string g%1d\n", imbedstr, s.gno);
            }
            fprintf(pp, "%s    string %.12lg, %.12lg\n", imbedstr, s.x, s.y);
            fprintf(pp, "%s    string linewidth %d\n", imbedstr, s.linew);
            fprintf(pp, "%s    string color %d\n", imbedstr, s.color);
            fprintf(pp, "%s    string rot %d\n", imbedstr, s.rot);
            fprintf(pp, "%s    string font %d\n", imbedstr, s.font);
            fprintf(pp, "%s    string just %d\n", imbedstr, s.just);
            fprintf(pp, "%s    string char size %lf\n", imbedstr, s.charsize);
            fprintf(pp, "%sstring def \"%s\"\n", imbedstr, s.s);
        }
    }
}