summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-03-28 14:49:12 (GMT)
committerjoye <joye>2014-03-28 14:49:12 (GMT)
commit5d03724931dffbb33a42660444c5b040c72d044d (patch)
treee5511fc14119ef9e42a88a2a5bcce8421d32784f
parente8752647d6547dfbbe39ec22f1643e4782c6358b (diff)
downloadblt-5d03724931dffbb33a42660444c5b040c72d044d.zip
blt-5d03724931dffbb33a42660444c5b040c72d044d.tar.gz
blt-5d03724931dffbb33a42660444c5b040c72d044d.tar.bz2
*** empty log message ***
-rw-r--r--bltGrMarkerBitmap.C4
-rw-r--r--src/bltGrMarker.C138
-rw-r--r--src/bltGrMarker.h10
-rw-r--r--src/bltGrMarkerLine.C10
-rw-r--r--src/bltGrMarkerPolygon.C2
-rw-r--r--src/bltGrMarkerText.C5
6 files changed, 87 insertions, 82 deletions
diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C
index 6dc46c2..210b8a0 100644
--- a/bltGrMarkerBitmap.C
+++ b/bltGrMarkerBitmap.C
@@ -195,7 +195,7 @@ void BitmapMarker::map()
int lheight;
Tk_SizeOfBitmap(graphPtr->display, opp->bitmap, &lwidth, &lheight);
- Point2d lanchorPt = Blt_MapPoint(opp->worldPts->points, &opp->axes);
+ Point2d lanchorPt = mapPoint(opp->worldPts->points, &opp->axes);
lanchorPt =
Blt_AnchorPoint(lanchorPt.x, lanchorPt.y, lwidth, lheight, opp->anchor);
lanchorPt.x += opp->xOffset;
@@ -206,7 +206,7 @@ void BitmapMarker::map()
extents.top = lanchorPt.y;
extents.right = lanchorPt.x + lwidth - 1;
extents.bottom = lanchorPt.y + lheight - 1;
- clipped = Blt_BoxesDontOverlap(graphPtr, &extents);
+ clipped = boxesDontOverlap(graphPtr, &extents);
if (clipped)
return;
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C
index b527f48..f00ac6d 100644
--- a/src/bltGrMarker.C
+++ b/src/bltGrMarker.C
@@ -92,6 +92,75 @@ Marker::~Marker()
free(ops);
}
+double Marker::HMap(Axis *axisPtr, double x)
+{
+ if (x == DBL_MAX)
+ x = 1.0;
+ else if (x == -DBL_MAX)
+ x = 0.0;
+ else {
+ if (axisPtr->logScale) {
+ if (x > 0.0)
+ x = log10(x);
+ else if (x < 0.0)
+ x = 0.0;
+ }
+ x = NORMALIZE(axisPtr, x);
+ }
+ if (axisPtr->descending)
+ x = 1.0 - x;
+
+ // Horizontal transformation
+ return (x * axisPtr->screenRange + axisPtr->screenMin);
+}
+
+double Marker::VMap(Axis *axisPtr, double y)
+{
+ if (y == DBL_MAX)
+ y = 1.0;
+ else if (y == -DBL_MAX)
+ y = 0.0;
+ else {
+ if (axisPtr->logScale) {
+ if (y > 0.0)
+ y = log10(y);
+ else if (y < 0.0)
+ y = 0.0;
+ }
+ y = NORMALIZE(axisPtr, y);
+ }
+ if (axisPtr->descending)
+ y = 1.0 - y;
+
+ // Vertical transformation
+ return (((1.0 - y) * axisPtr->screenRange) + axisPtr->screenMin);
+}
+
+Point2d Marker::mapPoint(Point2d* pointPtr, Axis2d* axesPtr)
+{
+ Graph* graphPtr = axesPtr->y->obj.graphPtr;
+
+ Point2d result;
+ if (graphPtr->inverted) {
+ result.x = HMap(axesPtr->y, pointPtr->y);
+ result.y = VMap(axesPtr->x, pointPtr->x);
+ }
+ else {
+ result.x = HMap(axesPtr->x, pointPtr->x);
+ result.y = VMap(axesPtr->y, pointPtr->y);
+ }
+
+ return result;
+}
+
+int Marker::boxesDontOverlap(Graph* graphPtr, Region2d *extsPtr)
+{
+ return (((double)graphPtr->right < extsPtr->left) ||
+ ((double)graphPtr->bottom < extsPtr->top) ||
+ (extsPtr->right < (double)graphPtr->left) ||
+ (extsPtr->bottom < (double)graphPtr->top));
+}
+
// Defs
static int GetCoordinate(Tcl_Interp* interp, Tcl_Obj *objPtr, double *valuePtr);
@@ -695,67 +764,6 @@ static int IsElementHidden(Marker* markerPtr)
return FALSE;
}
-static double HMap(Axis *axisPtr, double x)
-{
- if (x == DBL_MAX)
- x = 1.0;
- else if (x == -DBL_MAX)
- x = 0.0;
- else {
- if (axisPtr->logScale) {
- if (x > 0.0)
- x = log10(x);
- else if (x < 0.0)
- x = 0.0;
- }
- x = NORMALIZE(axisPtr, x);
- }
- if (axisPtr->descending)
- x = 1.0 - x;
-
- // Horizontal transformation
- return (x * axisPtr->screenRange + axisPtr->screenMin);
-}
-
-static double VMap(Axis *axisPtr, double y)
-{
- if (y == DBL_MAX)
- y = 1.0;
- else if (y == -DBL_MAX)
- y = 0.0;
- else {
- if (axisPtr->logScale) {
- if (y > 0.0)
- y = log10(y);
- else if (y < 0.0)
- y = 0.0;
- }
- y = NORMALIZE(axisPtr, y);
- }
- if (axisPtr->descending)
- y = 1.0 - y;
-
- // Vertical transformation
- return (((1.0 - y) * axisPtr->screenRange) + axisPtr->screenMin);
-}
-
-Point2d Blt_MapPoint(Point2d *pointPtr, Axis2d *axesPtr)
-{
- Graph* graphPtr = axesPtr->y->obj.graphPtr;
-
- Point2d result;
- if (graphPtr->inverted) {
- result.x = HMap(axesPtr->y, pointPtr->y);
- result.y = VMap(axesPtr->x, pointPtr->x);
- }
- else {
- result.x = HMap(axesPtr->x, pointPtr->x);
- result.y = VMap(axesPtr->y, pointPtr->y);
- }
-
- return result;
-}
-
static int GetMarkerFromObj(Tcl_Interp* interp, Graph* graphPtr,
Tcl_Obj *objPtr, Marker** markerPtrPtr)
{
@@ -895,14 +903,6 @@ void Blt_FreeMarker(char* dataPtr)
delete markerPtr;
}
-int Blt_BoxesDontOverlap(Graph* graphPtr, Region2d *extsPtr)
-{
- return (((double)graphPtr->right < extsPtr->left) ||
- ((double)graphPtr->bottom < extsPtr->top) ||
- (extsPtr->right < (double)graphPtr->left) ||
- (extsPtr->bottom < (double)graphPtr->top));
-}
-
static Tcl_Obj* PrintCoordinate(double x)
{
if (x == DBL_MAX)
diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h
index 159418c..97e0b4e 100644
--- a/src/bltGrMarker.h
+++ b/src/bltGrMarker.h
@@ -78,6 +78,14 @@ typedef struct {
void* ops;
+ private:
+ double HMap(Axis*, double);
+ double VMap(Axis*, double);
+
+ protected:
+ Point2d mapPoint(Point2d*, Axis2d*);
+ int boxesDontOverlap(Graph*, Region2d*);
+
public:
Marker(Graph*, const char*);
virtual ~Marker();
@@ -92,9 +100,7 @@ typedef struct {
};
-Point2d Blt_MapPoint(Point2d *pointPtr, Axis2d *axesPtr);
void Blt_FreeMarker(char*);
-int Blt_BoxesDontOverlap(Graph* graphPtr, Region2d *extsPtr);
extern Tk_ObjCustomOption coordsObjOption;
extern Tk_ObjCustomOption capStyleObjOption;
diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C
index 5544b92..68adb8f 100644
--- a/src/bltGrMarkerLine.C
+++ b/src/bltGrMarkerLine.C
@@ -207,7 +207,7 @@ void LineMarker::map()
// disconnected segments.
Segment2d* lsegments = (Segment2d*)malloc(opp->worldPts->num * sizeof(Segment2d));
Point2d* srcPtr = opp->worldPts->points;
- Point2d p = Blt_MapPoint(srcPtr, &opp->axes);
+ Point2d p = mapPoint(srcPtr, &opp->axes);
p.x += opp->xOffset;
p.y += opp->yOffset;
@@ -215,7 +215,7 @@ void LineMarker::map()
Point2d* pend;
for (srcPtr++, pend = opp->worldPts->points + opp->worldPts->num;
srcPtr < pend; srcPtr++) {
- Point2d next = Blt_MapPoint(srcPtr, &opp->axes);
+ Point2d next = mapPoint(srcPtr, &opp->axes);
next.x += opp->xOffset;
next.y += opp->yOffset;
Point2d q = next;
@@ -250,7 +250,7 @@ int LineMarker::regionIn(Region2d *extsPtr, int enclosed)
for (pp = opp->worldPts->points, pend = pp + opp->worldPts->num;
pp < pend; pp++) {
- Point2d p = Blt_MapPoint(pp, &opp->axes);
+ Point2d p = mapPoint(pp, &opp->axes);
if ((p.x < extsPtr->left) && (p.x > extsPtr->right) &&
(p.y < extsPtr->top) && (p.y > extsPtr->bottom)) {
return FALSE;
@@ -263,8 +263,8 @@ int LineMarker::regionIn(Region2d *extsPtr, int enclosed)
int count = 0;
for (pp = opp->worldPts->points, pend = pp + (opp->worldPts->num - 1);
pp < pend; pp++) {
- Point2d p = Blt_MapPoint(pp, &opp->axes);
- Point2d q = Blt_MapPoint(pp + 1, &opp->axes);
+ Point2d p = mapPoint(pp, &opp->axes);
+ Point2d q = mapPoint(pp + 1, &opp->axes);
if (Blt_LineRectClip(extsPtr, &p, &q))
count++;
}
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index ea81cdc..026457f 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -287,7 +287,7 @@ void PolygonMarker::map()
dp = lscreenPts;
for (sp = opp->worldPts->points, send = sp + opp->worldPts->num;
sp < send; sp++) {
- *dp = Blt_MapPoint(sp, &opp->axes);
+ *dp = mapPoint(sp, &opp->axes);
dp->x += opp->xOffset;
dp->y += opp->yOffset;
dp++;
diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C
index 0a93b1a..03d541a 100644
--- a/src/bltGrMarkerText.C
+++ b/src/bltGrMarkerText.C
@@ -193,8 +193,7 @@ void TextMarker::map()
outline[4].x = outline[0].x;
outline[4].y = outline[0].y;
- Point2d lanchorPtr =
- Blt_MapPoint(opp->worldPts->points, &opp->axes);
+ Point2d lanchorPtr = mapPoint(opp->worldPts->points, &opp->axes);
lanchorPtr = Blt_AnchorPoint(lanchorPtr.x, lanchorPtr.y, width,
height, opp->anchor);
lanchorPtr.x += opp->xOffset;
@@ -205,7 +204,7 @@ void TextMarker::map()
extents.top = lanchorPtr.y;
extents.right = lanchorPtr.x + width - 1;
extents.bottom = lanchorPtr.y + height - 1;
- clipped = Blt_BoxesDontOverlap(graphPtr, &extents);
+ clipped = boxesDontOverlap(graphPtr, &extents);
anchorPt = lanchorPtr;
}