Ejemplo n.º 1
0
void _warc(
/*********/
/* NOTE: this primitive WILL NOT have an associated region */

    int                 fill_type,
    float               x1,
    float               y1,
    float               x2,
    float               y2,
    float               x3,
    float               y3,
    float               x4,
    float               y4
) {
    HPEN                pen;
    HBRUSH              brush;
    int                 px1, py1;
    int                 px2, py2;
    int                 px3, py3;
    int                 px4, py4;

    get_obj_settings( fill_type, &pen, &brush );

    convert_pt( x1, y1, &px1, &py1 );
    convert_pt( x2, y2, &px2, &py2 );
    convert_pt( x3, y3, &px3, &py3 );
    convert_pt( x4, y4, &px4, &py4 );

    _wpi_arc( Win_dc, px1, py1, px2, py2, px3, py3, px4, py4 );

    del_obj_settings( fill_type, pen, brush );
}
Ejemplo n.º 2
0
void _wpie(
/*********/

    int                 fill_type,
    float               x1,
    float               y1,
    float               x2,
    float               y2,
    float               x3,
    float               y3,
    float               x4,
    float               y4
) {
    HPEN                pen;
    HBRUSH              brush;
    int                 px1, py1;
    int                 px2, py2;
    int                 px3, py3;
    int                 px4, py4;

    get_obj_settings( fill_type, &pen, &brush );

    convert_pt( x1, y1, &px1, &py1 );
    convert_pt( x2, y2, &px2, &py2 );
    convert_pt( x3, y3, &px3, &py3 );
    convert_pt( x4, y4, &px4, &py4 );

    _wpi_pie( Win_dc, px1, py1, px2, py2, px3, py3, px4, py4 );
    rgn_pie( px1, py1, px2, py2, px3, py3, px4, py4 );

    del_obj_settings( fill_type, pen, brush );
}
Ejemplo n.º 3
0
cv::Mat ImageOps::rectlinearProject(cv::Mat ImgToCalibrate, bool INV_FLAG, float F)
{
	cv::Mat Img = ImgToCalibrate;
	int height = Img.rows;
	int width = Img.cols;
	cv::Mat destPic = cv::Mat(cv::Size(width, height), ImgToCalibrate.type());
	//std::cout << "rect linear " << ImgToCalibrate.type() << " " << CV_8UC3 << " " << CV_8UC1 << " " << CV_8UC4 << std::endl;
	for (int y = 0; y < height; y++)
	{
		for (int x = 0; x < width; x++)
		{
			cv::Point2f current_pos(x, y);
			current_pos = convert_pt(current_pos, width, height, INV_FLAG, F);

			cv::Point2i top_left((int)current_pos.x, (int)current_pos.y); //top left because of integer rounding

			//make sure the point is actually inside the original image
			if (top_left.x < 0 ||
				top_left.x > width - 2 ||
				top_left.y < 0 ||
				top_left.y > height - 2)
			{
				continue;
			}
			if (destPic.type() == CV_8UC1) {
				interpolateBilinear(Img, current_pos, top_left, destPic.at<uchar>(y, x));
			}
			else {//JH: added color pixels
				interpolateBilinear(Img, current_pos, top_left, destPic.at<cv::Vec3b>(y, x));
			}

		}
	}
	return destPic;
}
Ejemplo n.º 4
0
void wrgn_rectangle(
/******************/

    float               x1,
    float               y1,
    float               x2,
    float               y2
) {
    int                 px1, py1;
    int                 px2, py2;

    convert_pt( x1, y1, &px1, &py1 );
    convert_pt( x2, y2, &px2, &py2 );

    rgn_rectangle( px1, py1, px2, py2 );
}
Ejemplo n.º 5
0
void _wellipse(
/*************/

    int                 fill_type,
    float               x1,
    float               y1,
    float               x2,
    float               y2
) {
    int                 px1, py1;
    int                 px2, py2;

    convert_pt( x1, y1, &px1, &py1 );
    convert_pt( x2, y2, &px2, &py2 );
    _world_ellipse( fill_type, px1, py1, px2, py2 );
}
Ejemplo n.º 6
0
void _wpolygon_rgn(
/*****************/

    int                 fill_type,
    int                 num_pts,
    wcoord              *pts,
    BOOL                rgn_on
) {
    HPEN                pen;
    HBRUSH              brush;
    WPI_POINT           *p_pts;
    int                 i;

    _new( p_pts, num_pts );

    for( i = 0; i < num_pts; ++i ) {
        /* assumption: sizeof(int)==sizeof(short) */
        convert_pt( pts[i].xcoord, pts[i].ycoord,
                    (int *) &p_pts[i].x, (int *) &p_pts[i].y );
    }

    get_obj_settings( fill_type, &pen, &brush );

    _wpi_polygon( Win_dc, p_pts, num_pts );

    if( rgn_on ) {
        rgn_polygon( p_pts, num_pts );
    }

    del_obj_settings( fill_type, pen, brush );

    _free( p_pts );
}
Ejemplo n.º 7
0
HIDDEN int
convert_grid(int idx)
{
    struct coord_sys *cs;
    point_t tmp_pt;
    VSETALL(tmp_pt, 0.0);


    if (!g_pts[idx].cid)
	return 0;

    for (BU_LIST_FOR(cs, coord_sys, &coord_head.l)) {
	if (cs->cid != g_pts[idx].cid)
	    continue;
	break;
    }

    if (BU_LIST_IS_HEAD(&cs->l, &coord_head.l)) {
	bu_exit(1, "No coordinate system defined for grid point #%d!\n", g_pts[idx].gid);
    }

    if (convert_pt(g_pts[idx].pt, cs, tmp_pt))
	return 1;

    VMOVE(g_pts[idx].pt, tmp_pt);
    g_pts[idx].cid = 0;

    return 0;
}
Ejemplo n.º 8
0
void wrgn_set_add(
/****************/

    wcoord              *pt
) {
    WPI_POINT           win_pt;

    /* assumption: sizeof(int)==sizeof(short) */
    convert_pt( pt->xcoord, pt->ycoord, (int *) &win_pt.x, (int *) &win_pt.y );
    rgn_set_add( &win_pt );
}
Ejemplo n.º 9
0
void _wdot(
/*********/

    float               x,
    float               y
) {
    int                 px, py;

    convert_pt( x, y, &px, &py );
    _wdot_world( px, py );
}
Ejemplo n.º 10
0
HIDDEN int
convert_cs(struct coord_sys *cs)
{
    struct coord_sys *cs2;
    point_t tmp_orig, tmp_pt1, tmp_pt2;
    VSETALL(tmp_orig, 0.0);
    VSETALL(tmp_pt1, 0.0);
    VSETALL(tmp_pt2, 0.0);

    if (!cs->rid)
	return 0;

    for (BU_LIST_FOR(cs2, coord_sys, &coord_head.l)) {
	if (cs2->cid != cs->rid)
	    continue;
	break;
    }

    if (BU_LIST_IS_HEAD(&cs2->l, &coord_head.l)) {
	bu_exit(1, "A coordinate system is defined in terms of a non-existent coordinate system!!!\n");
    }

    if (convert_pt(cs->origin, cs2, tmp_orig))
	return 1;

    if (convert_pt(cs->v1, cs2, tmp_pt1))
	return 1;

    if (convert_pt(cs->v2, cs2, tmp_pt2))
	return 1;

    VMOVE(cs->origin, tmp_orig);
    VSUB2(cs->v3, tmp_pt1, cs->origin);
    VUNITIZE(cs->v3);
    VSUB2(cs->v1, tmp_pt2, cs->origin);
    VCROSS(cs->v2, cs->v3, cs->v1);
    VUNITIZE(cs->v2);
    VCROSS(cs->v1, cs->v3, cs->v2);
    cs->rid = 0;
    return 0;
}
Ejemplo n.º 11
0
void _wlineto(
/************/

    float               x,
    float               y,
    BOOL                fill_last
) {
    int                 px, py;

    convert_pt( x, y, &px, &py );
    _wline( px, py, fill_last, TRUE, FALSE );
}
Ejemplo n.º 12
0
extern bool _wrectvisible(
/************************/
    float               x1,
    float               y1,
    float               x2,
    float               y2
) {
    int                 px1, py1;
    int                 px2, py2;
    WPI_RECT            rect;
    int                 left, right, top, bottom;

    convert_pt( x1, y1, &px1, &py1 );
    convert_pt( x2, y2, &px2, &py2 );

    left = _min( px1, px2 );
    right = _max( px1, px2 );
    top = _min( py1, py2 );
    bottom = _max( py1, py2 );
    _wpi_setintrectvalues( &rect, left, top, right, bottom );

    return( RectVisible( Win_dc, &rect ) );
}
Ejemplo n.º 13
0
void _wrectangle(
/***************/
/* NOTE: this primitive WILL NOT have an associated region */

    int                 fill_type,
    float               x1,
    float               y1,
    float               x2,
    float               y2
) {
    HPEN                pen;
    HBRUSH              brush;
    int                 px1, py1;
    int                 px2, py2;

    get_obj_settings( fill_type, &pen, &brush );

    convert_pt( x1, y1, &px1, &py1 );
    convert_pt( x2, y2, &px2, &py2 );

    _wpi_rectangle( Win_dc, px1, py1, px2, py2 );

    del_obj_settings( fill_type, pen, brush );
}
Ejemplo n.º 14
0
void _wmoveto(
/************/

    float               x,
    float               y
) {
    int                 px;
    int                 py;
    WPI_POINT           pt;

    convert_pt( x, y, &px, &py );

    pt.x = px;
    pt.y = py;
    _wpi_moveto( Win_dc, &pt );
}
Ejemplo n.º 15
0
void wrgn_polygon(
/****************/

    int                 num_pts,
    wcoord              *pts
) {
    WPI_POINT           *p_pts;
    int                 i;

    _new( p_pts, num_pts );

    for( i = 0; i < num_pts; ++i ) {
        /* assumption: sizeof(int)==sizeof(short) */
        convert_pt( pts[i].xcoord, pts[i].ycoord,
                    (int *) &p_pts[i].x, (int *) &p_pts[i].y );
    }

    rgn_polygon( p_pts, num_pts );

    _free( p_pts );
}
Ejemplo n.º 16
0
void _wtextout(
/*************/

    char                *text,
    float               x,
    float               y,
    int                 hor_align,
    int                 ver_align,
    void                *wfont
) {
    WORD                horiz_flags;
    WORD                vert_flags;
    WPI_FONT            old_font;
    int                 dx;
    int                 dy;
    WPI_TEXTMETRIC      font_info;
    int                 len;
    int                 bk_mode;
    int                 px1;
    int                 py1;
    int                 px2;
    int                 py2;
    int                 width;
    int                 height;
    WPI_FONT            font;

    font = (WPI_FONT) wfont;

    bk_mode = _wpi_getbackmode( Win_dc );
    _wpi_setbackmode( Win_dc, TRANSPARENT );

    len = strlen( text );

    convert_pt( x, y, &dx, &dy );

    old_font = _wpi_selectfont( Win_dc, font );

    if( Text_path == TEXT_VERTICAL ) {
        _wpi_gettextmetrics( Win_dc, &font_info );
        width = _wpi_metricmaxcharwidth( font_info );
        height = len * _wpi_metricheight( font_info );
    } else {
        _wpi_gettextextent( Win_dc, text, len, &width, &height );
    }
    px1 = px2 = dx;
    py1 = py2 = dy;

    switch( hor_align ) {

    case TEXT_H_LEFT:
        horiz_flags = TA_LEFT;
        px2 += width;
        break;

    case TEXT_H_CENTER:
        horiz_flags = TA_CENTER;
        px1 -= width / 2;
        px2 += width / 2;
        break;

    case TEXT_H_RIGHT:
        horiz_flags = TA_RIGHT;
        px2 -= width;
        break;
    }

    switch( ver_align ) {

    case TEXT_V_TOP:
        py2 += height * WPI_VERT_MULT;
        break;

    case TEXT_V_CENTER:
        py1 -= height / 2 * WPI_VERT_MULT;
        py2 += height / 2 * WPI_VERT_MULT;
        break;

    case TEXT_V_BOTTOM:
        py2 -= height * WPI_VERT_MULT;
        break;
    }
    rgn_rectangle( px1, py1, px2, py2 );

    if( Text_path == TEXT_HORIZONTAL ) {
        /* normal right path */
        switch( ver_align ) {

        case TEXT_V_TOP:
#ifdef PLAT_OS2
            /* OS/2 has problems with TA_LEFT && TA_TOP aligned text */
            /* This is a messy solution until we actually figure out */
            /* what the problem is.                                  */
            vert_flags = TA_BOTTOM;
            _wpi_gettextmetrics( Win_dc, &font_info );
            dy += _wpi_metricheight( font_info ) * WPI_VERT_MULT;
#else
            vert_flags = TA_TOP;
#endif
            break;

        case TEXT_V_CENTER:
#ifdef PLAT_OS2
            vert_flags = TA_HALF;
#else
            /* OS/2 has a much cleverer way of doing this */
            /* but Windows apparently doesn't             */
            vert_flags = TA_TOP;
            _wpi_gettextmetrics( Win_dc, &font_info );
            dy -= _wpi_metricheight( font_info ) / 2 * WPI_VERT_MULT;
#endif
            break;

        case TEXT_V_BOTTOM:
            vert_flags = TA_BOTTOM;
            break;
        }

        _wpi_settextalign( Win_dc, horiz_flags, vert_flags );
        _wpi_textout( Win_dc, dx, dy, text, len );

    } else {
        /* must display text vertically... do it by hand */

        vert_flags = TA_TOP;
        _wpi_settextalign( Win_dc, horiz_flags, vert_flags );

        switch( ver_align ) {

        case TEXT_V_BOTTOM:
            dy -= _wpi_metricheight( font_info ) * len * WPI_VERT_MULT;
            break;

        case TEXT_V_CENTER:
            dy -= (_wpi_metricheight( font_info ) * len) / 2 * WPI_VERT_MULT;
            break;
        }
        _wpi_settextalign( Win_dc, horiz_flags, vert_flags );

        for( ; len > 0; --len, dy += _wpi_metricheight( font_info )
                                * WPI_VERT_MULT, ++text ) {
            _wpi_textout( Win_dc, dx, dy, text, 1 );
        }
    }
    _wpi_getoldfont( Win_dc, old_font );
    _wpi_setbackmode( Win_dc, bk_mode );
}