⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkrectoval.c

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 C
📖 第 1 页 / 共 3 页
字号:
    }    oval[0] = ovalPtr->bbox[0] - halfWidth;    oval[1] = ovalPtr->bbox[1] - halfWidth;    oval[2] = ovalPtr->bbox[2] + halfWidth;    oval[3] = ovalPtr->bbox[3] + halfWidth;    result = TkOvalToArea(oval, areaPtr);    /*     * If the rectangle appears to overlap the oval and the oval     * isn't filled, do one more check to see if perhaps all four     * of the rectangle's corners are totally inside the oval's     * unfilled center, in which case we should return "outside".     */    if ((result == 0) && (ovalPtr->outlineGC != None)	    && (ovalPtr->fillGC == None)) {	double centerX, centerY, width, height;	double xDelta1, yDelta1, xDelta2, yDelta2;	centerX = (ovalPtr->bbox[0] + ovalPtr->bbox[2])/2.0;	centerY = (ovalPtr->bbox[1] + ovalPtr->bbox[3])/2.0;	width = (ovalPtr->bbox[2] - ovalPtr->bbox[0])/2.0 - halfWidth;	height = (ovalPtr->bbox[3] - ovalPtr->bbox[1])/2.0 - halfWidth;	xDelta1 = (areaPtr[0] - centerX)/width;	xDelta1 *= xDelta1;	yDelta1 = (areaPtr[1] - centerY)/height;	yDelta1 *= yDelta1;	xDelta2 = (areaPtr[2] - centerX)/width;	xDelta2 *= xDelta2;	yDelta2 = (areaPtr[3] - centerY)/height;	yDelta2 *= yDelta2;	if (((xDelta1 + yDelta1) < 1.0)		&& ((xDelta1 + yDelta2) < 1.0)		&& ((xDelta2 + yDelta1) < 1.0)		&& ((xDelta2 + yDelta2) < 1.0)) {	    return -1;	}    }    return result;}/* *-------------------------------------------------------------- * * ScaleRectOval -- * *	This procedure is invoked to rescale a rectangle or oval *	item. * * Results: *	None. * * Side effects: *	The rectangle or oval referred to by itemPtr is rescaled *	so that the following transformation is applied to all *	point coordinates: *		x' = originX + scaleX*(x-originX) *		y' = originY + scaleY*(y-originY) * *-------------------------------------------------------------- */static voidScaleRectOval(canvasPtr, itemPtr, originX, originY, scaleX, scaleY)    Tk_Canvas *canvasPtr;		/* Canvas containing rectangle. */    Tk_Item *itemPtr;			/* Rectangle to be scaled. */    double originX, originY;		/* Origin about which to scale rect. */    double scaleX;			/* Amount to scale in X direction. */    double scaleY;			/* Amount to scale in Y direction. */{    register RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;    rectOvalPtr->bbox[0] = originX + scaleX*(rectOvalPtr->bbox[0] - originX);    rectOvalPtr->bbox[1] = originY + scaleY*(rectOvalPtr->bbox[1] - originY);    rectOvalPtr->bbox[2] = originX + scaleX*(rectOvalPtr->bbox[2] - originX);    rectOvalPtr->bbox[3] = originY + scaleY*(rectOvalPtr->bbox[3] - originY);    ComputeRectOvalBbox(canvasPtr, rectOvalPtr);}/* *-------------------------------------------------------------- * * TranslateRectOval -- * *	This procedure is called to move a rectangle or oval by a *	given amount. * * Results: *	None. * * Side effects: *	The position of the rectangle or oval is offset by *	(xDelta, yDelta), and the bounding box is updated in the *	generic part of the item structure. * *-------------------------------------------------------------- */static voidTranslateRectOval(canvasPtr, itemPtr, deltaX, deltaY)    Tk_Canvas *canvasPtr;		/* Canvas containing item. */    Tk_Item *itemPtr;			/* Item that is being moved. */    double deltaX, deltaY;		/* Amount by which item is to be					 * moved. */{    register RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;    rectOvalPtr->bbox[0] += deltaX;    rectOvalPtr->bbox[1] += deltaY;    rectOvalPtr->bbox[2] += deltaX;    rectOvalPtr->bbox[3] += deltaY;    ComputeRectOvalBbox(canvasPtr, rectOvalPtr);}/* *-------------------------------------------------------------- * * RectOvalToPostscript -- * *	This procedure is called to generate Postscript for *	rectangle and oval items. * * Results: *	The return value is a standard Tcl result.  If an error *	occurs in generating Postscript then an error message is *	left in canvasPtr->interp->result, replacing whatever used *	to be there.  If no error occurs, then Postscript for the *	rectangle is appended to the result. * * Side effects: *	None. * *-------------------------------------------------------------- */static intRectOvalToPostscript(canvasPtr, itemPtr, psInfoPtr)    Tk_Canvas *canvasPtr;		/* Information about overall canvas. */    Tk_Item *itemPtr;			/* Item for which Postscript is					 * wanted. */    Tk_PostscriptInfo *psInfoPtr;	/* Information about the Postscript;					 * must be passed back to Postscript					 * utility procedures. */{    char pathCmd[500], string[100];    register RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;    double y1, y2;    y1 = TkCanvPsY(psInfoPtr, rectOvalPtr->bbox[1]);    y2 = TkCanvPsY(psInfoPtr, rectOvalPtr->bbox[3]);    /*     * Generate a string that creates a path for the rectangle or oval.     * This is the only part of the procedure's code that is type-     * specific.     */    if (rectOvalPtr->header.typePtr == &TkRectangleType) {	sprintf(pathCmd, "%.15g %.15g moveto %.15g 0 rlineto 0 %.15g rlineto %.15g 0 rlineto closepath\n",		rectOvalPtr->bbox[0], y1,		rectOvalPtr->bbox[2]-rectOvalPtr->bbox[0], y2-y1,		rectOvalPtr->bbox[0]-rectOvalPtr->bbox[2]);    } else {	sprintf(pathCmd, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n",		(rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2])/2, (y1 + y2)/2,		(rectOvalPtr->bbox[2] - rectOvalPtr->bbox[0])/2, (y1 - y2)/2);    }    /*     * First draw the filled area of the rectangle.     */    if (rectOvalPtr->fillColor != NULL) {	Tcl_AppendResult(canvasPtr->interp, pathCmd, (char *) NULL);	if (TkCanvPsColor(canvasPtr, psInfoPtr, rectOvalPtr->fillColor)		!= TCL_OK) {	    return TCL_ERROR;	}	if (rectOvalPtr->fillStipple != None) {	    if (TkCanvPsStipple(canvasPtr, psInfoPtr,		    rectOvalPtr->fillStipple, 1) != TCL_OK) {		return TCL_ERROR;	    }	} else {	    Tcl_AppendResult(canvasPtr->interp, "fill\n", (char *) NULL);	}    }    /*     * Now draw the outline, if there is one.     */    if (rectOvalPtr->outlineColor != NULL) {	Tcl_AppendResult(canvasPtr->interp, pathCmd, (char *) NULL);	sprintf(string, "%d setlinewidth", rectOvalPtr->width);	Tcl_AppendResult(canvasPtr->interp, string,		" 0 setlinejoin 2 setlinecap\n", (char *) NULL);	if (TkCanvPsColor(canvasPtr, psInfoPtr, rectOvalPtr->outlineColor)		!= TCL_OK) {	    return TCL_ERROR;	}	Tcl_AppendResult(canvasPtr->interp, "stroke\n", (char *) NULL);    }    return TCL_OK;}#include "feather.h"static int FeatherConfigureRectOval ARGS(( Tk_Canvas *canvasPtr,                                           Tk_Item *itemPtr,                                           Feather_RectInfo *rectInfo,                                           unsigned long rectMask ));void FeatherConfigTags ARGS(( Tk_Item *itemPtr,			      int ntags,			      Tk_Uid *tagList ));/* *-------------------------------------------------------------- * * FeatherCreateRect -- * *	This procedure is invoked to create a new rectangle *	or oval item in a canvas. * * Results: *	A standard Tcl return value.  If an error occurred in *	creating the item, then an error message is left in *	canvasPtr->interp->result;  in this case itemPtr is *	left uninitialized, so it can be safely freed by the *	caller. * * Side effects: *	A new rectangle or oval item is created. * *-------------------------------------------------------------- */int FeatherCreateRect( canvasPtr, itemPtr, x1, y1, x2, y2,		       rectInfo, rectMask )Tk_Canvas *canvasPtr;Tk_Item *itemPtr;double x1, y1, x2, y2;Feather_RectInfo *rectInfo;unsigned long rectMask;{    register RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;    /*     * Carry out initialization that is needed in order to clean     * up after errors during the the remainder of this procedure.     */    rectOvalPtr->width = 1;    rectOvalPtr->outlineColor = NULL;    rectOvalPtr->fillColor = NULL;    rectOvalPtr->fillStipple = None;    rectOvalPtr->outlineGC = None;    rectOvalPtr->fillGC = None;    /*     * Process the arguments to fill in the item record.     */    rectOvalPtr->bbox[0] = x1;    rectOvalPtr->bbox[1] = y1;    rectOvalPtr->bbox[2] = x2;    rectOvalPtr->bbox[3] = y2;    /*     * printf( "coords %f %f %f %f\n", x1, y1, x2, y2 );     */    if (FeatherConfigureRectOval(canvasPtr, itemPtr, rectInfo,				 rectMask) != TCL_OK) {	   DeleteRectOval(canvasPtr, itemPtr);	   return TCL_ERROR;    }    return TCL_OK;}/* *-------------------------------------------------------------- * * FeatherConfigureRectOval -- * *	This procedure is invoked to configure various aspects *	of a rectangle or oval item, such as its border and *	background colors. * * Results: *	A standard Tcl result code.  If an error occurs, then *	an error message is left in canvasPtr->interp->result. * * Side effects: *	Configuration information, such as colors and stipple *	patterns, may be set for itemPtr. * *-------------------------------------------------------------- */static int FeatherConfigureRectOval( canvasPtr, itemPtr, rectInfo, rectMask )Tk_Canvas *canvasPtr;Tk_Item *itemPtr;Feather_RectInfo *rectInfo;unsigned long rectMask;{  register RectOvalItem *rectOvalPtr;  XGCValues gcValues;  unsigned long mask;  static Feather_Color black_color = 0;    rectOvalPtr = (RectOvalItem *) itemPtr;  if (!black_color) {    black_color = Feather_GetColor( canvasPtr->interp, canvasPtr->tkwin,				    None, Tk_GetUid( "black" ) );  }    /* stipple is needed by fillGC */  if (rectMask & FEATHER_FILLSTIPPLE) {    rectOvalPtr->fillStipple = Feather_UseBitmap( rectInfo->fillStipple );  } else {    rectOvalPtr->fillStipple = None;  }  if (rectMask & FEATHER_FILLCOLOR) {    rectOvalPtr->fillColor = Feather_UseColor( rectInfo->fillColor );  }  if (rectOvalPtr->fillColor) {    gcValues.foreground = rectOvalPtr->fillColor->pixel;    if (rectOvalPtr->fillStipple != None) {      gcValues.stipple = rectOvalPtr->fillStipple;      gcValues.fill_style = FillStippled;      mask = GCForeground|GCStipple|GCFillStyle;    } else {      mask = GCForeground;    }    rectOvalPtr->fillGC = Tk_GetGC(canvasPtr->tkwin, mask, &gcValues);      } else {    rectOvalPtr->fillGC = None;  }      /* width is needed by outlineGC */  if (rectMask & FEATHER_WIDTH) {    rectOvalPtr->width = rectInfo->width;  } else {    rectOvalPtr->width = 1;  }    if (rectMask & FEATHER_OUTLINECOLOR) {    rectOvalPtr->outlineColor = Feather_UseColor( rectInfo->outlineColor );  } else {    rectOvalPtr->outlineColor = Feather_UseColor( black_color );  }  if (rectOvalPtr->outlineColor) {    gcValues.foreground = rectOvalPtr->outlineColor->pixel;    gcValues.cap_style = CapProjecting;    if (rectOvalPtr->width < 0) {      rectOvalPtr->width = 1;    }    gcValues.line_width = rectOvalPtr->width;    mask = GCForeground|GCCapStyle|GCLineWidth;    rectOvalPtr->outlineGC = Tk_GetGC(canvasPtr->tkwin, mask, &gcValues);  } else {    rectOvalPtr->outlineGC = None;  }    if (rectMask & FEATHER_TAGLIST) {    FeatherConfigTags( itemPtr, rectInfo->ntags, rectInfo->tagList );  }    ComputeRectOvalBbox(canvasPtr, rectOvalPtr);  /*   * printf( "%p %p %p %p %d %f %d %d\n", rectInfo->fillColor,   * rectInfo->outlineColor, rectInfo->fillStipple, rectInfo->tagList,   * rectInfo->ntags, rectInfo->width, rectInfo->above, rectInfo->below );   */  return TCL_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -