summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-04-17 18:16:13 (GMT)
committerjoye <joye>2014-04-17 18:16:13 (GMT)
commit675412c7b062450b79a5614b9d3b47e916af60b1 (patch)
tree091cc6aa44e3041bed41df3914f42b72de0ef284 /src
parentcff1b47d05e28e69193701b1d8dd5326a3657138 (diff)
downloadblt-675412c7b062450b79a5614b9d3b47e916af60b1.zip
blt-675412c7b062450b79a5614b9d3b47e916af60b1.tar.gz
blt-675412c7b062450b79a5614b9d3b47e916af60b1.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrAxisOp.C69
-rw-r--r--src/bltGrAxisOp.h1
-rw-r--r--src/bltGraph.C65
-rw-r--r--src/bltGraph.h1
4 files changed, 65 insertions, 71 deletions
diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C
index 789aa59..55f18c6 100644
--- a/src/bltGrAxisOp.C
+++ b/src/bltGrAxisOp.C
@@ -696,75 +696,6 @@ Axis *Blt_GetFirstAxis(Blt_Chain chain)
return (Axis*)Blt_Chain_GetValue(link);
}
-Axis *Blt_NearestAxis(Graph* graphPtr, int x, int y)
-{
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch cursor;
-
- for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes_.table, &cursor);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) {
- Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
- AxisOptions* ops = (AxisOptions*)axisPtr->ops();
- if (ops->hide || !axisPtr->use_ || (axisPtr->flags & DELETE_PENDING))
- continue;
-
- if (ops->showTicks) {
-
-
- for (Blt_ChainLink link=Blt_Chain_FirstLink(axisPtr->tickLabels_);
- link; link = Blt_Chain_NextLink(link)) {
- Point2d t;
- double rw, rh;
- Point2d bbox[5];
-
- TickLabel *labelPtr = (TickLabel*)Blt_Chain_GetValue(link);
- Blt_GetBoundingBox(labelPtr->width, labelPtr->height,
- ops->tickAngle, &rw, &rh, bbox);
- t = Blt_AnchorPoint(labelPtr->anchorPos.x,
- labelPtr->anchorPos.y, rw, rh,
- axisPtr->tickAnchor_);
- t.x = x - t.x - (rw * 0.5);
- t.y = y - t.y - (rh * 0.5);
-
- bbox[4] = bbox[0];
- if (Blt_PointInPolygon(&t, bbox, 5)) {
- axisPtr->detail_ = "label";
- return axisPtr;
- }
- }
- }
- if (ops->title) { /* and then the title string. */
- Point2d bbox[5];
- Point2d t;
- double rw, rh;
- unsigned int w, h;
-
- Blt_GetTextExtents(ops->titleFont, 0, ops->title,-1,&w,&h);
- Blt_GetBoundingBox(w, h, axisPtr->titleAngle_, &rw, &rh, bbox);
- t = Blt_AnchorPoint(axisPtr->titlePos_.x, axisPtr->titlePos_.y,
- rw, rh, axisPtr->titleAnchor_);
- /* Translate the point so that the 0,0 is the upper left
- * corner of the bounding box. */
- t.x = x - t.x - (rw * 0.5);
- t.y = y - t.y - (rh * 0.5);
-
- bbox[4] = bbox[0];
- if (Blt_PointInPolygon(&t, bbox, 5)) {
- axisPtr->detail_ = "title";
- return axisPtr;
- }
- }
- if (ops->lineWidth > 0) { /* Check for the axis region */
- if ((x <= axisPtr->right_) && (x >= axisPtr->left_) &&
- (y <= axisPtr->bottom_) && (y >= axisPtr->top_)) {
- axisPtr->detail_ = "line";
- return axisPtr;
- }
- }
- }
- return NULL;
-}
-
ClientData Blt_MakeAxisTag(Graph* graphPtr, const char *tagName)
{
int isNew;
diff --git a/src/bltGrAxisOp.h b/src/bltGrAxisOp.h
index 6d33664..a4990ed 100644
--- a/src/bltGrAxisOp.h
+++ b/src/bltGrAxisOp.h
@@ -45,6 +45,5 @@ extern void Blt_AdjustAxisPointers(Graph* graphPtr);
extern void Blt_UpdateAxisBackgrounds(Graph* graphPtr);
extern void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps);
extern Axis *Blt_GetFirstAxis(Blt_Chain chain);
-extern Axis *Blt_NearestAxis(Graph* graphPtr, int x, int y);
#endif
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 815feab..a0190c5 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -1228,7 +1228,70 @@ void Graph::resetAxes()
flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | MAP_ALL | REDRAW_WORLD);
}
+Axis* Graph::nearestAxis(int x, int y)
+{
+ Tcl_HashSearch cursor;
+ for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
+ hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
+ Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
+ AxisOptions* ops = (AxisOptions*)axisPtr->ops();
+ if (ops->hide || !axisPtr->use_ || (axisPtr->flags & DELETE_PENDING))
+ continue;
+
+ if (ops->showTicks) {
+ for (Blt_ChainLink link=Blt_Chain_FirstLink(axisPtr->tickLabels_);
+ link; link = Blt_Chain_NextLink(link)) {
+ TickLabel *labelPtr = (TickLabel*)Blt_Chain_GetValue(link);
+ double rw, rh;
+ Point2d bbox[5];
+ Blt_GetBoundingBox(labelPtr->width, labelPtr->height,
+ ops->tickAngle, &rw, &rh, bbox);
+ Point2d t;
+ t = Blt_AnchorPoint(labelPtr->anchorPos.x, labelPtr->anchorPos.y,
+ rw, rh, axisPtr->tickAnchor_);
+ t.x = x - t.x - (rw * 0.5);
+ t.y = y - t.y - (rh * 0.5);
+
+ bbox[4] = bbox[0];
+ if (Blt_PointInPolygon(&t, bbox, 5)) {
+ axisPtr->detail_ = "label";
+ return axisPtr;
+ }
+ }
+ }
+ if (ops->title) {
+ unsigned int w, h;
+ double rw, rh;
+ Point2d bbox[5];
+ Blt_GetTextExtents(ops->titleFont, 0, ops->title,-1,&w,&h);
+ Blt_GetBoundingBox(w, h, axisPtr->titleAngle_, &rw, &rh, bbox);
+ Point2d t;
+ t = Blt_AnchorPoint(axisPtr->titlePos_.x, axisPtr->titlePos_.y,
+ rw, rh, axisPtr->titleAnchor_);
+ // Translate the point so that the 0,0 is the upper left
+ // corner of the bounding box
+ t.x = x - t.x - (rw * 0.5);
+ t.y = y - t.y - (rh * 0.5);
+
+ bbox[4] = bbox[0];
+ if (Blt_PointInPolygon(&t, bbox, 5)) {
+ axisPtr->detail_ = "title";
+ return axisPtr;
+ }
+ }
+ if (ops->lineWidth > 0) {
+ if ((x <= axisPtr->right_) && (x >= axisPtr->left_) &&
+ (y <= axisPtr->bottom_) && (y >= axisPtr->top_)) {
+ axisPtr->detail_ = "line";
+ return axisPtr;
+ }
+ }
+ }
+
+ return NULL;
+}
+
void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
Blt_List list)
{
@@ -1305,7 +1368,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
// Sample coordinate is in one of the graph margins. Can only pick an axis.
if ((x >= exts.right) || (x < exts.left) ||
(y >= exts.bottom) || (y < exts.top)) {
- Axis* axisPtr = Blt_NearestAxis(graphPtr, x, y);
+ Axis* axisPtr = graphPtr->nearestAxis(x, y);
if (axisPtr) {
*contextPtr = (ClientData)axisPtr->classId();
return axisPtr;
diff --git a/src/bltGraph.h b/src/bltGraph.h
index 6ab071c..4dd5cf5 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -248,6 +248,7 @@ class Graph {
int isElementHidden(Blt::Marker*);
Blt::Marker* nearestMarker(int, int, int);
+ Axis* nearestAxis(int, int);
};
typedef ClientData (MakeTagProc)(Graph* graphPtr, const char *tagName);