From d0b2a93419897fdb247ab4ba3b2cb98d7fc641ae Mon Sep 17 00:00:00 2001 From: joye Date: Fri, 13 Sep 2013 18:43:55 +0000 Subject: *** empty log message *** --- src/bltGrMarker.C | 644 +----------------------------------------------------- 1 file changed, 1 insertion(+), 643 deletions(-) diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 8c40ab1..89f587b 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -1,4 +1,3 @@ - /* * bltGrMarker.c -- * @@ -33,7 +32,6 @@ #include "bltGraph.h" #include "bltOp.h" #include "bltImage.h" -#include "bltPainter.h" #include "bltGrElem.h" #include "bltBitmap.h" @@ -107,14 +105,6 @@ static Blt_CustomOption colorPairOption = ObjToColorPairProc, ColorPairToObjProc, FreeColorPairProc, (ClientData)0 }; -static Blt_OptionParseProc ObjToPictImageProc; -static Blt_OptionPrintProc PictImageToObjProc; -static Blt_OptionFreeProc FreePictImageProc; -static Blt_CustomOption pictImageOption = -{ - ObjToPictImageProc, PictImageToObjProc, FreePictImageProc, (ClientData)0 -}; - extern Blt_CustomOption bltXAxisOption; extern Blt_CustomOption bltYAxisOption; extern Blt_CustomOption bltFilterOption; @@ -330,125 +320,6 @@ static MarkerClass bitmapMarkerClass = { /* *--------------------------------------------------------------------------- * - * ImageMarker -- - * - *--------------------------------------------------------------------------- - */ -typedef struct { - GraphObj obj; /* Must be first field in marker. */ - - MarkerClass *classPtr; - - Blt_HashEntry *hashPtr; - - Blt_ChainLink link; - - const char *elemName; /* Element associated with marker. Let's - * you link a marker to an element. The - * marker is drawn only if the element - * is also visible. */ - Axis2d axes; - - Point2d *worldPts; /* Coordinate array to position - * marker. */ - - int nWorldPts; /* # of points in above array. */ - - int drawUnder; /* If non-zero, draw the marker - * underneath any elements. This can be - * a performance penalty because the - * graph must be redraw entirely each - * time the marker is redrawn. */ - - int clipped; /* Indicates if the marker is totally - * clipped by the plotting area. */ - - unsigned int flags; - - - int xOffset, yOffset; /* Pixel offset from graph position */ - - int state; - - Tk_Image tkImage; /* Tk image to be displayed. */ - Tk_Anchor anchor; /* Indicates how to translate the given - * marker position. */ - Point2d anchorPt; /* Translated anchor point. */ - int width, height; /* Dimensions of the possibly scaled - * image. */ -#if 0 - Blt_Painter painter; - Blt_Picture picture; - Blt_ResampleFilter filter; - int pictX, pictY; /* */ - Blt_Picture scaled; /* Pixmap containing the scaled image */ -#endif - GC gc; - -} ImageMarker; - -static Blt_ConfigSpec imageConfigSpecs[] = -{ - {BLT_CONFIG_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MARKER_ANCHOR, - Blt_Offset(ImageMarker, anchor), 0}, - {BLT_CONFIG_LIST, "-bindtags", "bindTags", "BindTags", DEF_IMAGE_TAGS, - Blt_Offset(ImageMarker, obj.tags), BLT_CONFIG_NULL_OK}, - {BLT_CONFIG_CUSTOM, "-coords", "coords", "Coords", DEF_MARKER_COORDS, - Blt_Offset(ImageMarker, worldPts), BLT_CONFIG_NULL_OK, &coordsOption}, - {BLT_CONFIG_STRING, "-element", "element", "Element", DEF_MARKER_ELEMENT, - Blt_Offset(ImageMarker, elemName), BLT_CONFIG_NULL_OK}, - {BLT_CONFIG_BITMASK, "-hide", "hide", "Hide", DEF_MARKER_HIDE, - Blt_Offset(ImageMarker, flags), BLT_CONFIG_DONT_SET_DEFAULT, - (Blt_CustomOption *)HIDE}, -#if 0 - {BLT_CONFIG_CUSTOM, "-image", "image", "Image", (char *)NULL, - Blt_Offset(ImageMarker, picture), BLT_CONFIG_NULL_OK, &pictImageOption}, -#endif - {BLT_CONFIG_CUSTOM, "-mapx", "mapX", "MapX", DEF_MARKER_MAP_X, - Blt_Offset(ImageMarker, axes.x), 0, &bltXAxisOption}, - {BLT_CONFIG_CUSTOM, "-mapy", "mapY", "MapY", DEF_MARKER_MAP_Y, - Blt_Offset(ImageMarker, axes.y), 0, &bltYAxisOption}, - {BLT_CONFIG_STRING, "-name", (char *)NULL, (char *)NULL, DEF_MARKER_NAME, - Blt_Offset(ImageMarker, obj.name), BLT_CONFIG_NULL_OK}, -#if 0 - {BLT_CONFIG_CUSTOM, "-resamplefilter", "resampleFilter", "ResampleFilter", - DEF_MARKER_FILTER, Blt_Offset(ImageMarker, filter), - BLT_CONFIG_NULL_OK | BLT_CONFIG_DONT_SET_DEFAULT, &bltFilterOption}, -#endif - {BLT_CONFIG_STATE, "-state", "state", "State", DEF_MARKER_STATE, - Blt_Offset(ImageMarker, state), BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_BOOLEAN, "-under", "under", "Under", DEF_MARKER_UNDER, - Blt_Offset(ImageMarker, drawUnder), BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_PIXELS, "-xoffset", "xOffset", "XOffset", DEF_MARKER_X_OFFSET, - Blt_Offset(ImageMarker, xOffset), BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_PIXELS, "-yoffset", "yOffset", "YOffset", DEF_MARKER_Y_OFFSET, - Blt_Offset(ImageMarker, yOffset), BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} -}; - -static MarkerConfigProc ConfigureImageProc; -static MarkerCreateProc CreateImageProc; -static MarkerDrawProc DrawImageProc; -static MarkerFreeProc FreeImageProc; -static MarkerMapProc MapImageProc; -static MarkerPointProc PointInImageProc; -static MarkerPostscriptProc ImageToPostscriptProc; -static MarkerRegionProc RegionInImageProc; - -static MarkerClass imageMarkerClass = { - imageConfigSpecs, - ConfigureImageProc, - DrawImageProc, - FreeImageProc, - MapImageProc, - PointInImageProc, - RegionInImageProc, - ImageToPostscriptProc, -}; - -/* - *--------------------------------------------------------------------------- - * * LineMarker -- * *--------------------------------------------------------------------------- @@ -972,10 +843,6 @@ static MarkerClass windowMarkerClass = { WindowToPostscriptProc, }; -static Tk_ImageChangedProc ImageChangedProc; - - - /* *--------------------------------------------------------------------------- * @@ -1470,158 +1337,6 @@ ColorPairToObjProc( return listObjPtr; } -/* - *--------------------------------------------------------------------------- - * - * ImageChangedProc - * - * - * Results: - * None. - * - *--------------------------------------------------------------------------- - */ -/* ARGSUSED */ -static void -ImageChangedProc( - ClientData clientData, - int x, int y, int w, int h, /* Not used. */ - int imageWidth, int imageHeight) /* Not used. */ -{ -#if 0 - Graph *graphPtr; - ImageMarker *imPtr = clientData; - int isPhoto; - - graphPtr = imPtr->obj.graphPtr; - if ((imPtr->picture != NULL) && (imPtr->flags & IMAGE_PHOTO)) { - Blt_FreePicture(imPtr->picture); - } - imPtr->picture = NULL; - imPtr->flags &= ~IMAGE_PHOTO; - if (Blt_Image_IsDeleted(imPtr->tkImage)) { - Tk_FreeImage(imPtr->tkImage); - imPtr->tkImage = NULL; - return; - } - imPtr->picture = Blt_GetPictureFromImage(graphPtr->interp, imPtr->tkImage, - &isPhoto); - if (isPhoto) { - imPtr->flags |= IMAGE_PHOTO; - } - graphPtr->flags |= CACHE_DIRTY; - imPtr->flags |= MAP_ITEM; - Blt_EventuallyRedrawGraph(graphPtr); -#endif -} - -/*ARGSUSED*/ -static void -FreePictImageProc( - ClientData clientData, - Display *display, /* Not used. */ - char *widgRec, - int offset) -{ -#if 0 - ImageMarker *imPtr = (ImageMarker *)widgRec; - - if ((imPtr->picture != NULL) && (imPtr->flags & IMAGE_PHOTO)) { - Blt_FreePicture(imPtr->picture); - } - imPtr->picture = NULL; - if (imPtr->tkImage != NULL) { - Tk_FreeImage(imPtr->tkImage); - } - imPtr->tkImage = NULL; - imPtr->flags &= ~IMAGE_PHOTO; -#endif -} - -/* - *--------------------------------------------------------------------------- - * - * ObjToPictImageProc -- - * - * Given an image name, get the Tk image associated with it. - * - * Results: - * The return value is a standard TCL result. - * - *--------------------------------------------------------------------------- - */ -/*ARGSUSED*/ -static int -ObjToPictImageProc( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, /* Interpreter to return results */ - Tk_Window tkwin, /* Not used. */ - Tcl_Obj *objPtr, /* String representation of value. */ - char *widgRec, /* Widget record. */ - int offset, /* Offset to field in structure */ - int flags) -{ -#if 0 - Blt_Picture *picturePtr = (Blt_Picture *)(widgRec + offset); - Graph *graphPtr; - ImageMarker *imPtr = (ImageMarker *)widgRec; - Tk_Image tkImage; - const char *name; - int isPhoto; - - name = Tcl_GetString(objPtr); - tkImage = Tk_GetImage(interp, tkwin, name, ImageChangedProc, imPtr); - if (tkImage == NULL) { - return TCL_ERROR; - } - if (imPtr->tkImage != NULL) { - Tk_FreeImage(imPtr->tkImage); - } - imPtr->flags &= ~IMAGE_PHOTO; - if (*picturePtr != NULL) { - Blt_FreePicture(*picturePtr); - } - *picturePtr = NULL; - imPtr->tkImage = tkImage; - graphPtr = imPtr->obj.graphPtr; - *picturePtr = Blt_GetPictureFromImage(graphPtr->interp, tkImage, &isPhoto); - if (isPhoto) { - imPtr->flags |= IMAGE_PHOTO; - } -#endif - return TCL_OK; -} - -/* - *--------------------------------------------------------------------------- - * - * PictImageToObjProc -- - * - * Convert the image name into a string Tcl_Obj. - * - * Results: - * The string representation of the image is returned. - * - *--------------------------------------------------------------------------- - */ -/*ARGSUSED*/ -static Tcl_Obj * -PictImageToObjProc( - ClientData clientData, /* Not used. */ - Tcl_Interp *interp, - Tk_Window tkwin, /* Not used. */ - char *widgRec, /* Widget record */ - int offset, /* Offset to field in structure */ - int flags) -{ - ImageMarker *imPtr = (ImageMarker *)(widgRec); - - if (imPtr->tkImage == NULL) { - return Tcl_NewStringObj("", -1); - } - return Tcl_NewStringObj(Blt_Image_Name(imPtr->tkImage), -1); -} - static INLINE int IsElementHidden(Marker *markerPtr) { @@ -1767,7 +1482,7 @@ CreateMarker( markerPtr = CreateLineProc(); /* line */ break; case CID_MARKER_IMAGE: - markerPtr = CreateImageProc(); /* image */ + return NULL; /* not supported */ break; case CID_MARKER_TEXT: markerPtr = CreateTextProc(); /* text */ @@ -2335,363 +2050,6 @@ CreateBitmapProc(void) return (Marker *)bmPtr; } - -/* - *--------------------------------------------------------------------------- - * - * ConfigureImageProc -- - * - * This procedure is called to process an objv/objc list, plus the Tk - * option database, in order to configure (or reconfigure) a image - * marker. - * - * Results: - * A standard TCL result. If TCL_ERROR is returned, then interp->result - * contains an error message. - * - * Side effects: - * Configuration information, such as image pixmap, colors, rotation, - * etc. get set for markerPtr; old resources get freed, if there were - * any. The marker is eventually redisplayed. - * - *--------------------------------------------------------------------------- - */ -static int -ConfigureImageProc(Marker *markerPtr) -{ -#if 0 - ImageMarker *imPtr = (ImageMarker *)markerPtr; - Graph *graphPtr = markerPtr->obj.graphPtr; - Blt_Painter painter; - GC newGC; - - newGC = Tk_GetGC(graphPtr->tkwin, 0L, (XGCValues *)NULL); - if (imPtr->gc != NULL) { - Tk_FreeGC(graphPtr->display, imPtr->gc); - } - imPtr->gc = newGC; - - painter = Blt_GetPainter(graphPtr->tkwin, 1.0); - if (imPtr->painter != NULL) { - Blt_FreePainter(painter); - } - imPtr->painter = painter; - markerPtr->flags |= MAP_ITEM; - if (markerPtr->drawUnder) { - graphPtr->flags |= CACHE_DIRTY; - } - Blt_EventuallyRedrawGraph(graphPtr); -#endif - return TCL_OK; -} - -/* - *--------------------------------------------------------------------------- - * - * MapImageProc -- - * - * This procedure gets called each time the layout of the graph changes. - * The x, y window coordinates of the image marker are saved in the - * marker structure. - * - * In addition, if no background color was specified, the - * GCTileStipXOrigin and GCTileStipYOrigin attributes will not set in the - * private GC. - * - * Results: - * None. - * - * Side effects: - * Window coordinates are saved and if no background color was set, the - * GC stipple origins are changed to calculated window coordinates. - * - *--------------------------------------------------------------------------- - */ -static void -MapImageProc(Marker *markerPtr) -{ -#if 0 - Region2d extents; - Graph *graphPtr; - ImageMarker *imPtr; - Point2d anchorPt; - Point2d c1, c2; - int newWidth, newHeight; - int srcWidth, srcHeight; - int x, y, w, h; - int left, right, top, bottom; - - imPtr = (ImageMarker *)markerPtr; - if (imPtr->picture == NULL) { - return; - } - if (imPtr->scaled != NULL) { - Blt_FreePicture(imPtr->scaled); - imPtr->scaled = NULL; - } - graphPtr = markerPtr->obj.graphPtr; - c1 = MapPoint(markerPtr->worldPts, &markerPtr->axes); - - imPtr->width = srcWidth = Blt_PictureWidth(imPtr->picture); - imPtr->height = srcHeight = Blt_PictureHeight(imPtr->picture); - - if ((srcWidth == 0) || (srcHeight == 0)) { - markerPtr->clipped = TRUE; - return; /* Empty image. */ - } - if (markerPtr->nWorldPts > 1) { - double hold; - - c2 = MapPoint(markerPtr->worldPts + 1, &markerPtr->axes); - /* Flip the corners if necessary */ - if (c1.x > c2.x) { - hold = c1.x, c1.x = c2.x, c2.x = hold; - } - if (c1.y > c2.y) { - hold = c1.y, c1.y = c2.y, c2.y = hold; - } - } else { - c2.x = c1.x + srcWidth - 1; - c2.y = c1.y + srcHeight - 1; - } - newWidth = (int)(c2.x - c1.x) + 1; - newHeight = (int)(c2.y - c1.y) + 1; - - if (markerPtr->nWorldPts == 1) { - anchorPt = Blt_AnchorPoint(c1.x, c1.y, (double)newWidth, - (double)newHeight, imPtr->anchor); - } else { - anchorPt = c1; - } - anchorPt.x += markerPtr->xOffset; - anchorPt.y += markerPtr->yOffset; - - /* Check if the image sits at least partially in the plot area. */ - extents.left = anchorPt.x; - extents.top = anchorPt.y; - extents.right = anchorPt.x + newWidth - 1; - extents.bottom = anchorPt.y + newHeight - 1; - - markerPtr->clipped = BoxesDontOverlap(graphPtr, &extents); - if (markerPtr->clipped) { - return; /* Image is offscreen. Don't generate - * rotated or scaled images. */ - } - - /* Determine the extents of the subimage inside of the destination - * image. */ - left = MAX((int)extents.left, graphPtr->left); - top = MAX((int)extents.top, graphPtr->top); - right = MIN((int)extents.right, graphPtr->right); - bottom = MIN((int)extents.bottom, graphPtr->bottom); - - /* Reset image location and coordinates to that of the region */ - anchorPt.x = left; - anchorPt.y = top; - - x = y = 0; - if (graphPtr->left > (int)extents.left) { - x = graphPtr->left - (int)extents.left; - } - if (graphPtr->top > (int)extents.top) { - y = graphPtr->top - (int)extents.top; - } - w = (int)(right - left + 1); - h = (int)(bottom - top + 1); - - if (markerPtr->nWorldPts > 1) { - Blt_Picture scaled; - - scaled = Blt_ScalePictureArea(imPtr->picture, x, y, w, h, - newWidth, newHeight); - imPtr->scaled = scaled; - imPtr->pictX = 0; - imPtr->pictY = 0; - } else { - imPtr->pictX = x; - imPtr->pictY = y; - } - imPtr->width = newWidth; - imPtr->height = newHeight; - imPtr->anchorPt = anchorPt; -#endif -} - -/* - *--------------------------------------------------------------------------- - * - * PointInWindowProc -- - * - * Indicates if the given point is over the window marker. The area of - * the window is the rectangle. - * - * Results: - * Returns 1 is the point is over the window marker, 0 otherwise. - * - *--------------------------------------------------------------------------- - */ -static int -PointInImageProc(Marker *markerPtr, Point2d *samplePtr) -{ - ImageMarker *imPtr = (ImageMarker *)markerPtr; - double left, right, top, bottom; - - left = imPtr->anchorPt.x; - right = imPtr->anchorPt.x + imPtr->width; - top = imPtr->anchorPt.y; - bottom = imPtr->anchorPt.y + imPtr->height; - - return ((samplePtr->x >= left) && (samplePtr->x < right) && - (samplePtr->y >= top) && (samplePtr->y < bottom)); -} - -/* - *--------------------------------------------------------------------------- - * - * RegionInImageProc -- - * - *--------------------------------------------------------------------------- - */ -static int -RegionInImageProc(Marker *markerPtr, Region2d *regPtr, int enclosed) -{ - ImageMarker *imPtr = (ImageMarker *)markerPtr; - - if (markerPtr->nWorldPts > 0) { - double left, right, top, bottom; - - left = imPtr->anchorPt.x; - right = imPtr->anchorPt.x + imPtr->width; - top = imPtr->anchorPt.y; - bottom = imPtr->anchorPt.y + imPtr->height; - if (enclosed) { - return ((left >= regPtr->left) && (top >= regPtr->top) && - (right <= regPtr->right) && (bottom <= regPtr->bottom)); - } - return !((left >= regPtr->right) || (top >= regPtr->bottom) || - (right <= regPtr->left) || (bottom <= regPtr->top)); - } - return FALSE; -} - -/* - *--------------------------------------------------------------------------- - * - * DrawImageProc -- - * - * This procedure is invoked to draw a image marker. - * - * Results: - * None. - * - * Side effects: - * GC stipple origins are changed to current window coordinates. - * Commands are output to X to draw the marker in its current mode. - * - *--------------------------------------------------------------------------- - */ -static void -DrawImageProc(Marker *markerPtr, Drawable drawable) -{ -#if 0 - ImageMarker *imPtr = (ImageMarker *)markerPtr; - Blt_Picture picture; - - picture = (imPtr->scaled != NULL) ? imPtr->scaled : imPtr->picture; - if (picture != NULL) { - Blt_PaintPictureWithBlend(imPtr->painter, drawable, picture, - imPtr->pictX, imPtr->pictY, imPtr->width, imPtr->height, - (int)imPtr->anchorPt.x, (int)imPtr->anchorPt.y, 0, 0.4); - } -#endif -} - -/* - *--------------------------------------------------------------------------- - * - * ImageToPostscriptProc -- - * - * This procedure is invoked to print a image marker. - * - * Results: - * None. - * - *--------------------------------------------------------------------------- - */ -static void -ImageToPostscriptProc(Marker *markerPtr, Blt_Ps ps) -{ -#if 0 - ImageMarker *imPtr = (ImageMarker *)markerPtr; - Blt_Picture picture; - - picture = (imPtr->scaled != NULL) ? imPtr->scaled : imPtr->picture; - if (picture != NULL) { - Blt_Ps_DrawPicture(ps, picture, imPtr->anchorPt.x, imPtr->anchorPt.y); - } -#endif -} - -/* - *--------------------------------------------------------------------------- - * - * FreeImageProc -- - * - * Destroys the structure containing the attributes of the image marker. - * - * Results: - * None. - * - * Side effects: - * Image attributes (GCs, colors, image, etc) get destroyed. Memory is - * released, X resources are freed, and the graph is redrawn. - * - *--------------------------------------------------------------------------- - */ -static void -FreeImageProc(Marker *markerPtr) -{ -#if 0 - ImageMarker *imPtr = (ImageMarker *)markerPtr; - Graph *graphPtr = markerPtr->obj.graphPtr; - - if (imPtr->painter != NULL) { - Blt_FreePainter(imPtr->painter); - } - if (imPtr->scaled != NULL) { - Blt_FreePicture(imPtr->scaled); - } - if (imPtr->gc != NULL) { - Tk_FreeGC(graphPtr->display, imPtr->gc); - } -#endif -} - -/* - *--------------------------------------------------------------------------- - * - * CreateImageProc -- - * - * Allocate memory and initialize methods for the new image marker. - * - * Results: - * The pointer to the newly allocated marker structure is returned. - * - * Side effects: - * Memory is allocated for the image marker structure. - * - *--------------------------------------------------------------------------- - */ -static Marker * -CreateImageProc(void) -{ - ImageMarker *imPtr; - - imPtr = calloc(1, sizeof(ImageMarker)); - imPtr->classPtr = &imageMarkerClass; - return (Marker *)imPtr; -} - /* *--------------------------------------------------------------------------- * -- cgit v0.12