diff options
author | joye <joye> | 2014-03-18 18:57:52 (GMT) |
---|---|---|
committer | joye <joye> | 2014-03-18 18:57:52 (GMT) |
commit | f03aeeae4cfa1671d83df080d6d079e43cce27c7 (patch) | |
tree | 696f39c1a1a4c4312fbd19b0374d7d3e24cb07ef | |
parent | 64d0636aa8defdba6b48d1406c6bdb52fac8f1bc (diff) | |
download | blt-f03aeeae4cfa1671d83df080d6d079e43cce27c7.zip blt-f03aeeae4cfa1671d83df080d6d079e43cce27c7.tar.gz blt-f03aeeae4cfa1671d83df080d6d079e43cce27c7.tar.bz2 |
*** empty log message ***
-rw-r--r-- | src/bltConfig.C | 2 | ||||
-rw-r--r-- | src/bltGrAxis.C | 13 | ||||
-rw-r--r-- | src/bltGrMarker.C | 32 | ||||
-rw-r--r-- | src/bltGrMarkerLine.C | 55 | ||||
-rw-r--r-- | tests/linemarker.tcl | 26 | ||||
-rw-r--r-- | tests/polygonmarker.tcl | 49 |
6 files changed, 109 insertions, 68 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C index b05094d..dbe357f 100644 --- a/src/bltConfig.C +++ b/src/bltConfig.C @@ -241,7 +241,7 @@ static Tcl_Obj* ListGetProc(ClientData clientData, Tk_Window tkwin, Tcl_Obj** ll = (Tcl_Obj**)calloc(cnt, sizeof(Tcl_Obj*)); for (int ii=0; ii<cnt; ii++) - ll[ii] = Tcl_NewStringObj(*listPtr[ii], -1); + ll[ii] = Tcl_NewStringObj((*listPtr)[ii], -1); Tcl_Obj* listObjPtr = Tcl_NewListObj(cnt, ll); free(ll); diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 65ded79..7cafce7 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -3309,10 +3309,10 @@ static int GetAxisFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, return TCL_OK; } } - if (interp) { + if (interp) Tcl_AppendResult(interp, "can't find axis \"", name, "\" in \"", Tk_PathName(graphPtr->tkwin), "\"", NULL); - } + return TCL_ERROR; } @@ -3330,11 +3330,10 @@ static int GetAxisByClass(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, Blt_GraphSetObjectClass(&axisPtr->obj, classId); else if (axisPtr->obj.classId != classId) { - if (!interp) - Tcl_AppendResult(interp, "axis \"", Tcl_GetString(objPtr), - "\" is already in use on an opposite ", - axisPtr->obj.className, "-axis", - NULL); + Tcl_AppendResult(interp, "axis \"", Tcl_GetString(objPtr), + "\" is already in use on an opposite ", + axisPtr->obj.className, "-axis", + NULL); return TCL_ERROR; } axisPtr->refCount++; diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 18da1c6..d6f17c7 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -433,22 +433,19 @@ static int DeleteOp(Graph* graphPtr, Tcl_Interp* interp, static int GetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - Marker *markerPtr; - const char* string; + const char* string = Tcl_GetString(objv[3]); + if (!strcmp(string, "current")) { + Marker* markerPtr = (Marker*)Blt_GetCurrentItem(graphPtr->bindTable); - string = Tcl_GetString(objv[3]); - if ((string[0] == 'c') && (strcmp(string, "current") == 0)) { - markerPtr = (Marker *)Blt_GetCurrentItem(graphPtr->bindTable); - if (markerPtr == NULL) { - return TCL_OK; /* Report only on markers. */ + if (markerPtr == NULL) + return TCL_OK; - } + // Report only on markers if ((markerPtr->obj.classId >= CID_MARKER_BITMAP) && - (markerPtr->obj.classId <= CID_MARKER_WINDOW)) { - Tcl_SetStringObj(Tcl_GetObjResult(interp), - markerPtr->obj.name, -1); - } + (markerPtr->obj.classId <= CID_MARKER_WINDOW)) + Tcl_SetStringObj(Tcl_GetObjResult(interp), markerPtr->obj.name, -1); } + return TCL_OK; } @@ -458,6 +455,7 @@ static int ExistsOp(Graph* graphPtr, Tcl_Interp* interp, Tcl_HashEntry* hPtr = Tcl_FindHashEntry(&graphPtr->markers.table, Tcl_GetString(objv[3])); Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (hPtr)); + return TCL_OK; } @@ -491,14 +489,16 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp, if (left < right) { extents.left = (double)left; extents.right = (double)right; - } else { + } + else { extents.left = (double)right; extents.right = (double)left; } if (top < bottom) { extents.top = (double)top; extents.bottom = (double)bottom; - } else { + } + else { extents.top = (double)bottom; extents.bottom = (double)top; } @@ -514,9 +514,7 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp, continue; if ((*markerPtr->classPtr->regionProc)(markerPtr, &extents, enclosed)) { - Tcl_Obj *objPtr; - - objPtr = Tcl_GetObjResult(interp); + Tcl_Obj* objPtr = Tcl_GetObjResult(interp); Tcl_SetStringObj(objPtr, markerPtr->obj.name, -1); return TCL_OK; } diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index 87818a4..4314196 100644 --- a/src/bltGrMarkerLine.C +++ b/src/bltGrMarkerLine.C @@ -117,37 +117,31 @@ static int PointInLineProc(Marker *markerPtr, Point2d *samplePtr) static int RegionInLineProc(Marker *markerPtr, Region2d *extsPtr, int enclosed) { - if (markerPtr->nWorldPts < 2) { + if (markerPtr->nWorldPts < 2) return FALSE; - } + if (enclosed) { Point2d *pp, *pend; for (pp = markerPtr->worldPts, pend = pp + markerPtr->nWorldPts; pp < pend; pp++) { - Point2d p; - - p = Blt_MapPoint(pp, &markerPtr->axes); + Point2d p = Blt_MapPoint(pp, &markerPtr->axes); if ((p.x < extsPtr->left) && (p.x > extsPtr->right) && (p.y < extsPtr->top) && (p.y > extsPtr->bottom)) { return FALSE; } } return TRUE; /* All points inside bounding box. */ - } else { - int count; + } + else { Point2d *pp, *pend; - - count = 0; + int count = 0; for (pp = markerPtr->worldPts, pend = pp + (markerPtr->nWorldPts - 1); pp < pend; pp++) { - Point2d p, q; - - p = Blt_MapPoint(pp, &markerPtr->axes); - q = Blt_MapPoint(pp + 1, &markerPtr->axes); - if (Blt_LineRectClip(extsPtr, &p, &q)) { + Point2d p = Blt_MapPoint(pp, &markerPtr->axes); + Point2d q = Blt_MapPoint(pp + 1, &markerPtr->axes); + if (Blt_LineRectClip(extsPtr, &p, &q)) count++; - } } return (count > 0); /* At least 1 segment passes through * region. */ @@ -172,13 +166,10 @@ static int ConfigureLineProc(Marker *markerPtr) { Graph* graphPtr = markerPtr->obj.graphPtr; LineMarker *lmPtr = (LineMarker *)markerPtr; - GC newGC; - XGCValues gcValues; - unsigned long gcMask; - Drawable drawable; - drawable = Tk_WindowId(graphPtr->tkwin); - gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle); + Drawable drawable = Tk_WindowId(graphPtr->tkwin); + unsigned long gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle); + XGCValues gcValues; if (lmPtr->outlineColor) { gcMask |= GCForeground; gcValues.foreground = lmPtr->outlineColor->pixel; @@ -201,21 +192,21 @@ static int ConfigureLineProc(Marker *markerPtr) gcMask |= GCFunction; pixel = Tk_3DBorderColor(graphPtr->plotBg)->pixel; - if (gcMask & GCBackground) { + if (gcMask & GCBackground) gcValues.background ^= pixel; - } + gcValues.foreground ^= pixel; - if (drawable != None) { + if (drawable != None) DrawLineProc(markerPtr, drawable); - } } - newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); - if (lmPtr->gc) { + + GC newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); + if (lmPtr->gc) Blt_FreePrivateGC(graphPtr->display, lmPtr->gc); - } - if (LineIsDashed(lmPtr->dashes)) { + + if (LineIsDashed(lmPtr->dashes)) Blt_SetDashes(graphPtr->display, newGC, &lmPtr->dashes); - } + lmPtr->gc = newGC; if (lmPtr->xorr) { if (drawable != None) { @@ -225,9 +216,9 @@ static int ConfigureLineProc(Marker *markerPtr) return TCL_OK; } markerPtr->flags |= MAP_ITEM; - if (markerPtr->drawUnder) { + if (markerPtr->drawUnder) graphPtr->flags |= CACHE_DIRTY; - } + Blt_EventuallyRedrawGraph(graphPtr); return TCL_OK; } diff --git a/tests/linemarker.tcl b/tests/linemarker.tcl index 70c69d4..a5240b8 100644 --- a/tests/linemarker.tcl +++ b/tests/linemarker.tcl @@ -4,42 +4,46 @@ set w .line set graph [bltLineGraph $w] set mm [$graph marker create line tt -element data1 \ - -coords "1 50 1.5 100 1 150" -linewidth 10] -return + -coords {1 50 1.5 100 1 150} -linewidth 5] +set nn [$graph marker create line ss -element data1 \ + -coords {1 150 .5 100 1 50} -linewidth 1 \ + -outline green -dashes 4] + #bltTest3 $graph marker $mm -bindtags bltTest3 $graph marker $mm -cap round -#bltTest3 $graph marker $mm -coords +bltTest3 $graph marker $mm -coords {1 50 1.5 100 2 150} bltTest3 $graph marker $mm -dashes dashdot bltTest3 $graph marker $mm -dashoffset 10 bltTest3 $graph marker $mm -element data2 -#bltTest3 $graph marker $mm -fill +bltTest3 $graph marker $nn -fill yellow bltTest3 $graph marker $mm -join round bltTest3 $graph marker $mm -linewidth 1 bltTest3 $graph marker $mm -hide yes bltTest3 $graph marker $mm -mapx x -bltTest3 $graph marker $mm -mapy y +bltTest3 $graph marker $mm -mapy y bltTest3 $graph marker $mm -outline green -#bltTest3 $graph marker $mm -state +bltTest3 $graph marker $mm -state disabled bltTest3 $graph marker $mm -under yes bltTest3 $graph marker $mm -xoffset 20 bltTest3 $graph marker $mm -xor yes bltTest3 $graph marker $mm -yoffset 20 #bltCmd $graph marker bind marker ?sequence command? -#bltCmd $graph marker cget -#bltCmd $graph marker configure +bltCmd $graph marker cget $mm -cap +bltCmd $graph marker configure $mm +bltCmd $graph marker configure $mm -cap set foo [$graph marker create line] bltCmd $graph marker delete $foo set foo [$graph marker create line foo] bltCmd $graph marker delete $foo bltCmd $graph marker exists $mm -#bltCmd $graph marker find "enclosed|overlapping x1 y1 x2 y2" -#bltCmd $graph marker get name +bltCmd $graph marker find enclosed 0 0 2 200 +bltCmd $graph marker get name current bltCmd $graph marker lower $mm bltCmd $graph marker names bltCmd $graph marker raise $mm bltCmd $graph marker type $mm echo "done" -#bltPlotDestroy $w +bltPlotDestroy $w diff --git a/tests/polygonmarker.tcl b/tests/polygonmarker.tcl new file mode 100644 index 0000000..a5240b8 --- /dev/null +++ b/tests/polygonmarker.tcl @@ -0,0 +1,49 @@ +source base.tcl + +set w .line +set graph [bltLineGraph $w] + +set mm [$graph marker create line tt -element data1 \ + -coords {1 50 1.5 100 1 150} -linewidth 5] +set nn [$graph marker create line ss -element data1 \ + -coords {1 150 .5 100 1 50} -linewidth 1 \ + -outline green -dashes 4] + +#bltTest3 $graph marker $mm -bindtags +bltTest3 $graph marker $mm -cap round +bltTest3 $graph marker $mm -coords {1 50 1.5 100 2 150} +bltTest3 $graph marker $mm -dashes dashdot +bltTest3 $graph marker $mm -dashoffset 10 +bltTest3 $graph marker $mm -element data2 +bltTest3 $graph marker $nn -fill yellow +bltTest3 $graph marker $mm -join round +bltTest3 $graph marker $mm -linewidth 1 +bltTest3 $graph marker $mm -hide yes +bltTest3 $graph marker $mm -mapx x +bltTest3 $graph marker $mm -mapy y +bltTest3 $graph marker $mm -outline green +bltTest3 $graph marker $mm -state disabled +bltTest3 $graph marker $mm -under yes +bltTest3 $graph marker $mm -xoffset 20 +bltTest3 $graph marker $mm -xor yes +bltTest3 $graph marker $mm -yoffset 20 + +#bltCmd $graph marker bind marker ?sequence command? +bltCmd $graph marker cget $mm -cap +bltCmd $graph marker configure $mm +bltCmd $graph marker configure $mm -cap +set foo [$graph marker create line] +bltCmd $graph marker delete $foo +set foo [$graph marker create line foo] +bltCmd $graph marker delete $foo +bltCmd $graph marker exists $mm +bltCmd $graph marker find enclosed 0 0 2 200 +bltCmd $graph marker get name current +bltCmd $graph marker lower $mm +bltCmd $graph marker names +bltCmd $graph marker raise $mm +bltCmd $graph marker type $mm + +echo "done" +bltPlotDestroy $w + |