diff options
author | joye <joye> | 2014-06-27 16:49:47 (GMT) |
---|---|---|
committer | joye <joye> | 2014-06-27 16:49:47 (GMT) |
commit | 981bf095749dc8346392dea756dc7306381da7b6 (patch) | |
tree | c994c25517c53a076251c5a17615210d78beb872 | |
parent | b576b84f7721f0d301189d4269dc559af985a803 (diff) | |
download | blt-981bf095749dc8346392dea756dc7306381da7b6.zip blt-981bf095749dc8346392dea756dc7306381da7b6.tar.gz blt-981bf095749dc8346392dea756dc7306381da7b6.tar.bz2 |
*** empty log message ***
-rw-r--r-- | bltGrMarkerBitmap.C | 281 | ||||
-rw-r--r-- | bltGrMarkerBitmap.h | 84 | ||||
-rwxr-xr-x | configure | 1 | ||||
-rwxr-xr-x | configure.in | 1 | ||||
-rw-r--r-- | src/bltGrMarkerOp.C | 5 | ||||
-rw-r--r-- | tests/bitmapmarker.tcl | 39 | ||||
-rw-r--r-- | tests/markers.tcl | 1 |
7 files changed, 1 insertions, 411 deletions
diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C deleted file mode 100644 index a2e2888..0000000 --- a/bltGrMarkerBitmap.C +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Smithsonian Astrophysical Observatory, Cambridge, MA, USA - * This code has been modified under the terms listed below and is made - * available under the same terms. - */ - -/* - * Copyright 1993-2004 George A Howlett. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include <stdlib.h> -#include <string.h> - -#include "bltGraph.h" -#include "bltGrMarkerBitmap.h" -#include "bltGrMarkerOption.h" -#include "bltGrMisc.h" -#include "bltGrDef.h" -#include "bltConfig.h" -#include "bltGrPSOutput.h" - -using namespace Blt; - -static Tk_OptionSpec optionSpecs[] = { - {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", - "center", -1, Tk_Offset(BitmapMarkerOptions, anchor), 0, NULL, 0}, - {TK_OPTION_COLOR, "-background", "background", "Background", - NULL, -1, Tk_Offset(BitmapMarkerOptions, fillColor), - TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, - {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags", - "Bitmap all", -1, Tk_Offset(BitmapMarkerOptions, tags), - TK_OPTION_NULL_OK, &listObjOption, 0}, - {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", - NULL, -1, Tk_Offset(BitmapMarkerOptions, bitmap), - TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_CUSTOM, "-coords", "coords", "Coords", - NULL, -1, Tk_Offset(BitmapMarkerOptions, worldPts), - TK_OPTION_NULL_OK, &coordsObjOption, 0}, - {TK_OPTION_STRING, "-element", "element", "Element", - NULL, -1, Tk_Offset(BitmapMarkerOptions, elemName), - TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, - {TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, - {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BitmapMarkerOptions, outlineColor), - TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", - "no", -1, Tk_Offset(BitmapMarkerOptions, hide), 0, NULL, 0}, - {TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX", - "x", -1, Tk_Offset(BitmapMarkerOptions, xAxis), 0, &xAxisObjOption, 0}, - {TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY", - "y", -1, Tk_Offset(BitmapMarkerOptions, yAxis), 0, &yAxisObjOption, 0}, - {TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, - {TK_OPTION_BOOLEAN, "-under", "under", "Under", - "no", -1, Tk_Offset(BitmapMarkerOptions, drawUnder), 0, NULL, CACHE}, - {TK_OPTION_PIXELS, "-xoffset", "xOffset", "XOffset", - "0", -1, Tk_Offset(BitmapMarkerOptions, xOffset), 0, NULL, 0}, - {TK_OPTION_PIXELS, "-yoffset", "yOffset", "YOffset", - "0", -1, Tk_Offset(BitmapMarkerOptions, yOffset), 0, NULL, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} -}; - -BitmapMarker::BitmapMarker(Graph* graphPtr, const char* name, - Tcl_HashEntry* hPtr) - : Marker(graphPtr, name, hPtr) -{ - ops_ = (BitmapMarkerOptions*)calloc(1, sizeof(BitmapMarkerOptions)); - optionTable_ = Tk_CreateOptionTable(graphPtr->interp_, optionSpecs); - - anchorPt_.x =0; - anchorPt_.y =0; - gc_ =NULL; - fillGC_ =NULL; - nOutlinePts_ =0; - width_ =0; - height_ =0; -} - -BitmapMarker::~BitmapMarker() -{ - if (gc_) - Tk_FreeGC(graphPtr_->display_, gc_); - if (fillGC_) - Tk_FreeGC(graphPtr_->display_, fillGC_); -} - -int BitmapMarker::configure() -{ - BitmapMarkerOptions* ops = (BitmapMarkerOptions*)ops_; - - if (ops->bitmap == None) - return TCL_OK; - - XGCValues gcValues; - unsigned long gcMask = 0; - if (ops->outlineColor) { - gcMask |= GCForeground; - gcValues.foreground = ops->outlineColor->pixel; - } - - if (ops->fillColor) { - // Opaque bitmap: both foreground and background (fill) colors are used - gcValues.background = ops->fillColor->pixel; - gcMask |= GCBackground; - } - else { - // Transparent bitmap: set the clip mask to the current bitmap - gcValues.clip_mask = ops->bitmap; - gcMask |= GCClipMask; - } - - // This is technically a shared GC, but we're going to set/change the clip - // origin anyways before we draw the bitmap. This relies on the fact that - // no other client will be allocated this GC with the GCClipMask set to - // this particular bitmap. - GC newGC = Tk_GetGC(graphPtr_->tkwin_, gcMask, &gcValues); - if (gc_) - Tk_FreeGC(graphPtr_->display_, gc_); - gc_ = newGC; - - // Create the background GC containing the fill color - if (ops->fillColor) { - gcValues.foreground = ops->fillColor->pixel; - newGC = Tk_GetGC(graphPtr_->tkwin_, gcMask, &gcValues); - if (fillGC_) - Tk_FreeGC(graphPtr_->display_, fillGC_); - fillGC_ = newGC; - } - - return TCL_OK; -} - -void BitmapMarker::draw(Drawable drawable) -{ - BitmapMarkerOptions* ops = (BitmapMarkerOptions*)ops_; - - if ((ops->bitmap == None) || (width_ < 1) || (height_ < 1)) - return; - - if (ops->fillColor == NULL) { - XSetClipMask(graphPtr_->display_, gc_, ops->bitmap); - XSetClipOrigin(graphPtr_->display_, gc_, anchorPt_.x, anchorPt_.y); - } - else { - XSetClipMask(graphPtr_->display_, gc_, None); - XSetClipOrigin(graphPtr_->display_, gc_, 0, 0); - } - XCopyPlane(graphPtr_->display_, ops->bitmap, drawable, gc_, 0, 0, - width_, height_, anchorPt_.x, anchorPt_.y, 1); -} - -void BitmapMarker::map() -{ - BitmapMarkerOptions* ops = (BitmapMarkerOptions*)ops_; - - if (ops->bitmap == None) - return; - - if (!ops->worldPts || (ops->worldPts->num < 1)) - return; - - int lwidth; - int lheight; - Tk_SizeOfBitmap(graphPtr_->display_, ops->bitmap, &lwidth, &lheight); - - Point2d lanchorPt = mapPoint(ops->worldPts->points, ops->xAxis, ops->yAxis); - lanchorPt = graphPtr_->anchorPoint(lanchorPt.x, lanchorPt.y, - lwidth, lheight, ops->anchor); - lanchorPt.x += ops->xOffset; - lanchorPt.y += ops->yOffset; - - Region2d extents; - extents.left = lanchorPt.x; - extents.top = lanchorPt.y; - extents.right = lanchorPt.x + lwidth - 1; - extents.bottom = lanchorPt.y + lheight - 1; - clipped_ = boxesDontOverlap(graphPtr_, &extents); - - if (clipped_) - return; - - width_ = lwidth; - height_ = lheight; - anchorPt_ = lanchorPt; - - // Compute a polygon to represent the background area of the bitmap. - // This is needed for print a background in PostScript. - double rotWidth, rotHeight; - Point2d polygon[5]; - graphPtr_->getBoundingBox(width_, height_, 0, &rotWidth, &rotHeight, polygon); - - // Adjust each point of the polygon. Both scale it to the new size and - // translate it to the actual screen position of the bitmap. - double tx = extents.left + width_ * 0.5; - double ty = extents.top + height_ * 0.5; - for (int ii=0; ii<4; ii++) { - polygon[ii].x = (polygon[ii].x) + tx; - polygon[ii].y = (polygon[ii].y) + ty; - } - - graphPtr_->extents(&extents); - - int nn = Blt_PolyRectClip(&extents, polygon, 4, outline_); - if (nn < 3) { - memcpy(&outline_, polygon, sizeof(Point2d) * 4); - nOutlinePts_ = 4; - } - else - nOutlinePts_ = nn; -} - -int BitmapMarker::pointIn(Point2d *samplePtr) -{ - BitmapMarkerOptions* ops = (BitmapMarkerOptions*)ops_; - - if (ops->bitmap == None) - return 0; - - return ((samplePtr->x >= anchorPt_.x) && - (samplePtr->x < (anchorPt_.x + width_)) && - (samplePtr->y >= anchorPt_.y) && - (samplePtr->y < (anchorPt_.y + height_))); -} - -int BitmapMarker::regionIn(Region2d *extsPtr, int enclosed) -{ - if (enclosed) { - return ((anchorPt_.x >= extsPtr->left) && - (anchorPt_.y >= extsPtr->top) && - ((anchorPt_.x + width_) <= extsPtr->right) && - ((anchorPt_.y + height_) <= extsPtr->bottom)); - } - - return !((anchorPt_.x >= extsPtr->right) || - (anchorPt_.y >= extsPtr->bottom) || - ((anchorPt_.x + width_) <= extsPtr->left) || - ((anchorPt_.y + height_) <= extsPtr->top)); -} - -void BitmapMarker::print(PSOutput* psPtr) -{ - BitmapMarkerOptions* ops = (BitmapMarkerOptions*)ops_; - - if ((ops->bitmap == None) || (width_ < 1) || (height_ < 1)) - return; - - if (ops->fillColor) { - psPtr->setBackground(ops->fillColor); - psPtr->fillPolygon(outline_, 4); - } - psPtr->setForeground(ops->outlineColor); - - psPtr->append("gsave\n"); - psPtr->format("%g %g translate\n", anchorPt_.x, anchorPt_.y + height_); - psPtr->format("%d %d scale\n", width_, -height_); - psPtr->format("%d %d true [%d 0 0 %d 0 %d]\n{", - width_, height_, width_, -height_, height_); - psPtr->setBitmap(graphPtr_->display_, ops->bitmap, width_, height_); - psPtr->append("}\nimagemask\n"); - psPtr->append("grestore\n"); -} diff --git a/bltGrMarkerBitmap.h b/bltGrMarkerBitmap.h deleted file mode 100644 index 38752e2..0000000 --- a/bltGrMarkerBitmap.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Smithsonian Astrophysical Observatory, Cambridge, MA, USA - * This code has been modified under the terms listed below and is made - * available under the same terms. - */ - -/* - * Copyright 1993-2004 George A Howlett. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __BltGrMarkerBitmap_h__ -#define __BltGrMarkerBitmap_h__ - -#include <tk.h> - -#include "bltGrMarker.h" - -namespace Blt { - - typedef struct { - const char** tags; - Coords* worldPts; - const char* elemName; - Axis* xAxis; - Axis* yAxis; - int hide; - int drawUnder; - int xOffset; - int yOffset; - - Tk_Anchor anchor; - Pixmap bitmap; - XColor* fillColor; - XColor* outlineColor; - } BitmapMarkerOptions; - - class BitmapMarker : public Marker { - public: - Point2d anchorPt_; - GC gc_; - GC fillGC_; - Point2d outline_[12]; - int nOutlinePts_; - int width_; - int height_; - - protected: - int configure(); - void draw(Drawable); - void map(); - int pointIn(Point2d*); - int regionIn(Region2d*, int); - void print(PSOutput*); - - public: - BitmapMarker(Graph*, const char*, Tcl_HashEntry*); - virtual ~BitmapMarker(); - - ClassId classId() {return CID_MARKER_BITMAP;} - const char* className() {return "BitmapMarker";} - const char* typeName() {return "bitmap";} - }; -}; - -#endif @@ -5544,7 +5544,6 @@ done bltGrMarkerOp.C bltGrMarkerOption.C bltGrMarker.C - bltGrMarkerBitmap.C bltGrMarkerLine.C bltGrMarkerPolygon.C bltGrMarkerText.C diff --git a/configure.in b/configure.in index 1017ebf..3adeaf4 100755 --- a/configure.in +++ b/configure.in @@ -89,7 +89,6 @@ TEA_ADD_SOURCES([ bltGrMarkerOp.C bltGrMarkerOption.C bltGrMarker.C - bltGrMarkerBitmap.C bltGrMarkerLine.C bltGrMarkerPolygon.C bltGrMarkerText.C diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C index 76d9a2e..43bf61c 100644 --- a/src/bltGrMarkerOp.C +++ b/src/bltGrMarkerOp.C @@ -34,7 +34,6 @@ #include "bltGrElem.h" #include "bltGrMarkerOp.h" #include "bltGrMarker.h" -#include "bltGrMarkerBitmap.h" #include "bltGrMarkerLine.h" #include "bltGrMarkerPolygon.h" #include "bltGrMarkerText.h" @@ -127,9 +126,7 @@ static int CreateMarker(Graph* graphPtr, Tcl_Interp* interp, const char* type = Tcl_GetString(objv[3]); Marker* markerPtr; - if (!strcmp(type, "bitmap")) - markerPtr = new BitmapMarker(graphPtr, name, hPtr); - else if (!strcmp(type, "line")) + if (!strcmp(type, "line")) markerPtr = new LineMarker(graphPtr, name, hPtr); else if (!strcmp(type, "polygon")) markerPtr = new PolygonMarker(graphPtr, name, hPtr); diff --git a/tests/bitmapmarker.tcl b/tests/bitmapmarker.tcl deleted file mode 100644 index a3ed1d4..0000000 --- a/tests/bitmapmarker.tcl +++ /dev/null @@ -1,39 +0,0 @@ -source base.tcl - -set w .line -set graph [bltLineGraph $w] - -set mm [$graph marker create bitmap tt -element data2 \ - -coords {1.5 100} -bitmap error] -$graph element configure data1 -hide yes - -echo "Testing Bitmap Marker..." - -bltTest3 $graph marker $mm -anchor nw $dops -bltTest3 $graph marker $mm -anchor n $dops -bltTest3 $graph marker $mm -anchor ne $dops -bltTest3 $graph marker $mm -anchor e $dops -bltTest3 $graph marker $mm -anchor se $dops -bltTest3 $graph marker $mm -anchor s $dops -bltTest3 $graph marker $mm -anchor sw $dops -bltTest3 $graph marker $mm -anchor w $dops -bltTest3 $graph marker $mm -background yellow $dops -bltTest3 $graph marker $mm -bg red $dops -bltTest3 $graph marker $mm -bindtags {aa} 0 -bltTest3 $graph marker $mm -bitmap hourglass $dops -bltTest3 $graph marker $mm -coords {1 50} $dops -bltTest3 $graph marker $mm -element data1 $dops -bltTest3 $graph marker $mm -fg cyan $dops -bltTest3 $graph marker $mm -fill yellow $dops -bltTest3 $graph marker $mm -foreground blue $dops -bltTest3 $graph marker $mm -hide yes $dops -bltTest3 $graph marker $mm -mapx x2 $dops -bltTest3 $graph marker $mm -mapy y2 $dops -bltTest3 $graph marker $mm -outline green $dops -bltTest3 $graph marker $mm -under yes $dops -bltTest3 $graph marker $mm -xoffset 20 $dops -bltTest3 $graph marker $mm -yoffset 20 $dops - -echo "done" -bltPlotDestroy $w - diff --git a/tests/markers.tcl b/tests/markers.tcl index 7d39a63..2f43c8b 100644 --- a/tests/markers.tcl +++ b/tests/markers.tcl @@ -1,5 +1,4 @@ source marker.tcl -source bitmapmarker.tcl source linemarker.tcl source polygonmarker.tcl source textmarker.tcl |