diff options
author | joye <joye> | 2014-04-18 17:56:52 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-18 17:56:52 (GMT) |
commit | e99f62660663d130a8358ec69c3fda614512fd74 (patch) | |
tree | 010ca11e365b7d5effb0e745ded66ca02b7c6d33 /src | |
parent | a42c9243c09c908e0fdbe8eef5784b2fc5e22b39 (diff) | |
download | blt-e99f62660663d130a8358ec69c3fda614512fd74.zip blt-e99f62660663d130a8358ec69c3fda614512fd74.tar.gz blt-e99f62660663d130a8358ec69c3fda614512fd74.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxisOp.C | 32 | ||||
-rw-r--r-- | src/bltGrAxisOp.h | 6 | ||||
-rw-r--r-- | src/bltGrElemBar.C | 15 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 12 | ||||
-rw-r--r-- | src/bltGraph.C | 32 | ||||
-rw-r--r-- | src/bltGraph.h | 2 | ||||
-rw-r--r-- | src/bltGraphOp.C | 4 |
7 files changed, 49 insertions, 54 deletions
diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C index 237fca1..e43b925 100644 --- a/src/bltGrAxisOp.C +++ b/src/bltGrAxisOp.C @@ -594,38 +594,6 @@ void FreeAxis(char* data) delete axisPtr; } -Point2d Blt_Map2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr) -{ - GraphOptions* gops = (GraphOptions*)graphPtr->ops_; - Point2d point; - - if (gops->inverted) { - point.x = axesPtr->y->hMap(y); - point.y = axesPtr->x->vMap(x); - } - else { - point.x = axesPtr->x->hMap(x); - point.y = axesPtr->y->vMap(y); - } - return point; -} - -Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr) -{ - GraphOptions* gops = (GraphOptions*)graphPtr->ops_; - Point2d point; - - if (gops->inverted) { - point.x = axesPtr->x->invVMap(y); - point.y = axesPtr->y->invHMap(x); - } - else { - point.x = axesPtr->x->invHMap(x); - point.y = axesPtr->y->invVMap(y); - } - return point; -} - Axis *Blt_GetFirstAxis(Blt_Chain chain) { Blt_ChainLink link = Blt_Chain_FirstLink(chain); diff --git a/src/bltGrAxisOp.h b/src/bltGrAxisOp.h index dd15a17..f822b67 100644 --- a/src/bltGrAxisOp.h +++ b/src/bltGrAxisOp.h @@ -36,12 +36,6 @@ extern int Blt_AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); extern Tcl_FreeProc FreeAxis; -extern Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, - Axis2d *pairPtr); -extern Point2d Blt_Map2D(Graph* graphPtr, double x, double y, - Axis2d *pairPtr); - -extern void Blt_UpdateAxisBackgrounds(Graph* graphPtr); extern Axis *Blt_GetFirstAxis(Blt_Chain chain); #endif diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 23932ca..d4cc617 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -375,11 +375,10 @@ void BarElement::map() * Get the two corners of the bar segment and compute the rectangle */ double ybot = c2.y; - c1 = Blt_Map2D(graphPtr_, c1.x, c1.y, &ops->axes); - c2 = Blt_Map2D(graphPtr_, c2.x, c2.y, &ops->axes); - if ((ybot == 0.0) && (axisyops->logScale)) { + c1 = graphPtr_->map2D(c1.x, c1.y, &ops->axes); + c2 = graphPtr_->map2D(c2.x, c2.y, &ops->axes); + if ((ybot == 0.0) && (axisyops->logScale)) c2.y = graphPtr_->bottom_; - } if (c2.y < c1.y) { double t; @@ -1120,8 +1119,8 @@ void BarElement::MapErrorBars(BarStyle **dataToStyle) low = ops->xLow ? ops->xLow->values[ii] : 0; } if ((isfinite(high)) && (isfinite(low))) { - Point2d p = Blt_Map2D(graphPtr_, high, y, &ops->axes); - Point2d q = Blt_Map2D(graphPtr_, low, y, &ops->axes); + Point2d p = graphPtr_->map2D(high, y, &ops->axes); + Point2d q = graphPtr_->map2D(low, y, &ops->axes); segPtr->p = p; segPtr->q = q; if (Blt_LineRectClip(®, &segPtr->p, &segPtr->q)) { @@ -1182,8 +1181,8 @@ void BarElement::MapErrorBars(BarStyle **dataToStyle) low = ops->yLow->values[ii]; } if ((isfinite(high)) && (isfinite(low))) { - Point2d p = Blt_Map2D(graphPtr_, x, high, &ops->axes); - Point2d q = Blt_Map2D(graphPtr_, x, low, &ops->axes); + Point2d p = graphPtr_->map2D(x, high, &ops->axes); + Point2d q = graphPtr_->map2D(x, low, &ops->axes); segPtr->p = p; segPtr->q = q; if (Blt_LineRectClip(®, &segPtr->p, &segPtr->q)) { diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 43476d4..649cae4 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -1463,7 +1463,7 @@ void LineElement::MapActiveSymbols() double x = ops->coords.x->values[iPoint]; double y = ops->coords.y->values[iPoint]; - points[count] = Blt_Map2D(graphPtr_, x, y, &ops->axes); + points[count] = graphPtr_->map2D(x, y, &ops->axes); map[count] = iPoint; if (PointInRegion(&exts, points[count].x, points[count].y)) { count++; @@ -1954,8 +1954,8 @@ void LineElement::MapErrorBars(LineStyle **styleMap) if ((isfinite(high)) && (isfinite(low))) { Point2d p, q; - p = Blt_Map2D(graphPtr_, high, y, &ops->axes); - q = Blt_Map2D(graphPtr_, low, y, &ops->axes); + p = graphPtr_->map2D(high, y, &ops->axes); + q = graphPtr_->map2D(low, y, &ops->axes); segPtr->p = p; segPtr->q = q; if (Blt_LineRectClip(&exts, &segPtr->p, &segPtr->q)) { @@ -2023,8 +2023,8 @@ void LineElement::MapErrorBars(LineStyle **styleMap) if ((isfinite(high)) && (isfinite(low))) { Point2d p, q; - p = Blt_Map2D(graphPtr_, x, high, &ops->axes); - q = Blt_Map2D(graphPtr_, x, low, &ops->axes); + p = graphPtr_->map2D(x, high, &ops->axes); + q = graphPtr_->map2D(x, low, &ops->axes); segPtr->p = p; segPtr->q = q; if (Blt_LineRectClip(&exts, &segPtr->p, &segPtr->q)) { @@ -2098,7 +2098,7 @@ int LineElement::ClosestTrace() searchPtr->dist = dMin; searchPtr->elemPtr = (Element*)this; searchPtr->index = iClose; - searchPtr->point = Blt_InvMap2D(graphPtr_, closest.x, closest.y, &ops->axes); + searchPtr->point = graphPtr_->invMap2D(closest.x, closest.y, &ops->axes); return 1; } diff --git a/src/bltGraph.C b/src/bltGraph.C index 840884a..366e1e6 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -1433,6 +1433,38 @@ void Graph::adjustAxes() } } +Point2d Graph::map2D(double x, double y, Axis2d* axesPtr) +{ + GraphOptions* ops = (GraphOptions*)ops_; + + Point2d point; + if (ops->inverted) { + point.x = axesPtr->y->hMap(y); + point.y = axesPtr->x->vMap(x); + } + else { + point.x = axesPtr->x->hMap(x); + point.y = axesPtr->y->vMap(y); + } + return point; +} + +Point2d Graph::invMap2D(double x, double y, Axis2d* axesPtr) +{ + GraphOptions* ops = (GraphOptions*)ops_; + + Point2d point; + if (ops->inverted) { + point.x = axesPtr->x->invVMap(y); + point.y = axesPtr->y->invHMap(x); + } + else { + point.x = axesPtr->x->invHMap(x); + point.y = axesPtr->y->invVMap(y); + } + return point; +} + void Graph::resetAxes() { GraphOptions* gops = (GraphOptions*)ops_; diff --git a/src/bltGraph.h b/src/bltGraph.h index 0edce6b..e00d522 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -252,6 +252,8 @@ class Graph { void printAxesLimits(Blt_Ps); int getAxis(Tcl_Obj*, Axis**); ClientData axisTag(const char*); + Point2d map2D(double, double, Axis2d*); + Point2d invMap2D(double, double, Axis2d*); void resetAxes(); Axis* nearestAxis(int, int); diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index 5fca07c..2798fed 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -344,7 +344,7 @@ static int InvtransformOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Axis2d axes; axes.x = Blt_GetFirstAxis(graphPtr->axisChain_[0]); axes.y = Blt_GetFirstAxis(graphPtr->axisChain_[1]); - Point2d point = Blt_InvMap2D(graphPtr, x, y, &axes); + Point2d point = graphPtr->invMap2D(x, y, &axes); Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(point.x)); @@ -374,7 +374,7 @@ static int TransformOp(Graph* graphPtr, Tcl_Interp* interp, int objc, axes.x = Blt_GetFirstAxis(graphPtr->axisChain_[0]); axes.y = Blt_GetFirstAxis(graphPtr->axisChain_[1]); - Point2d point = Blt_Map2D(graphPtr, x, y, &axes); + Point2d point = graphPtr->map2D(x, y, &axes); Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(ROUND(point.x))); |