From b763acbb124202aa34c4a155de6b20ebbccc5408 Mon Sep 17 00:00:00 2001 From: joye Date: Wed, 16 Apr 2014 18:24:15 +0000 Subject: *** empty log message *** --- src/bltGrAxisOp.C | 34 +++++++++++++++------------------- src/bltGrElemBar.C | 51 +++++++++++++++++++++++++-------------------------- src/bltGraph.C | 8 ++++---- src/bltGraph.h | 8 ++++---- 4 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C index 1cbf0ad..bb581d9 100644 --- a/src/bltGrAxisOp.C +++ b/src/bltGrAxisOp.C @@ -675,25 +675,23 @@ void FreeAxis(char* data) void Blt_ResetAxes(Graph* graphPtr) { GraphOptions* gops = (GraphOptions*)graphPtr->ops_; - Blt_ChainLink link; - Tcl_HashEntry *hPtr; - Tcl_HashSearch cursor; - + /* FIXME: This should be called whenever the display list of * elements change. Maybe yet another flag INIT_STACKS to * indicate that the element display list has changed. * Needs to be done before the axis limits are set. */ Blt_InitBarSetTable(graphPtr); - if ((gops->barMode == BARS_STACKED) && (graphPtr->nBarGroups > 0)) + if ((gops->barMode == BARS_STACKED) && (graphPtr->nBarGroups_ > 0)) Blt_ComputeBarStacks(graphPtr); /* * Step 1: Reset all axes. Initialize the data limits of the axis to * impossible values. */ - for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { + Tcl_HashSearch cursor; + for (Tcl_HashEntry* hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); + hPtr; hPtr = Tcl_NextHashEntry(&cursor)) { Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr); axisPtr->min_ = axisPtr->valueRange_.min = DBL_MAX; axisPtr->max_ = axisPtr->valueRange_.max = -DBL_MAX; @@ -705,8 +703,8 @@ void Blt_ResetAxes(Graph* graphPtr) * will be the axis limits if the user doesn't override them * with -min and -max options. */ - for (link = Blt_Chain_FirstLink(graphPtr->elements.displayList); - link != NULL; link = Blt_Chain_NextLink(link)) { + for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->elements.displayList); + link; link = Blt_Chain_NextLink(link)) { Region2d exts; Element* elemPtr = (Element*)Blt_Chain_GetValue(link); @@ -719,23 +717,21 @@ void Blt_ResetAxes(Graph* graphPtr) * Step 3: Now that we know the range of data values for each axis, * set axis limits and compute a sweep to generate tick values. */ - for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { - double min, max; - + for (Tcl_HashEntry* hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); + hPtr; hPtr = Tcl_NextHashEntry(&cursor)) { Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr); AxisOptions* ops = (AxisOptions*)axisPtr->ops(); axisPtr->fixRange(); /* Calculate min/max tick (major/minor) layouts */ - min = axisPtr->min_; - max = axisPtr->max_; - if ((!isnan(axisPtr->scrollMin_)) && (min < axisPtr->scrollMin_)) { + double min = axisPtr->min_; + double max = axisPtr->max_; + if ((!isnan(axisPtr->scrollMin_)) && (min < axisPtr->scrollMin_)) min = axisPtr->scrollMin_; - } - if ((!isnan(axisPtr->scrollMax_)) && (max > axisPtr->scrollMax_)) { + + if ((!isnan(axisPtr->scrollMax_)) && (max > axisPtr->scrollMax_)) max = axisPtr->scrollMax_; - } + if (ops->logScale) axisPtr->logScale(min, max); else diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 07455ec..baa948b 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -303,7 +303,7 @@ void BarElement::map() * coordinates of the two corners. */ - if ((graphPtr_->nBarGroups > 0) && (gops->barMode != BARS_INFRONT) && + if ((graphPtr_->nBarGroups_ > 0) && (gops->barMode != BARS_INFRONT) && (!gops->stackAxes)) { Tcl_HashEntry *hPtr; BarSetKey key; @@ -311,7 +311,7 @@ void BarElement::map() key.value = (float)x[i]; key.axes = ops->axes; key.axes.y = NULL; - hPtr = Tcl_FindHashEntry(&graphPtr_->setTable, (char *)&key); + hPtr = Tcl_FindHashEntry(&graphPtr_->setTable_, (char *)&key); if (hPtr) { Tcl_HashTable *tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr); @@ -322,9 +322,9 @@ void BarElement::map() double slice, width, offset; BarGroup *groupPtr = (BarGroup*)Tcl_GetHashValue(hPtr); - slice = barWidth / (double)graphPtr_->maxBarSetSize; + slice = barWidth / (double)graphPtr_->maxBarSetSize_; offset = (slice * groupPtr->index); - if (graphPtr_->maxBarSetSize > 1) { + if (graphPtr_->maxBarSetSize_ > 1) { offset += slice * 0.05; slice *= 0.90; } @@ -506,7 +506,7 @@ void BarElement::extents(Region2d *regPtr) // Handle stacked bar elements specially. // If element is stacked, the sum of its ordinates may be outside the // minimum/maximum limits of the element's data points. - if ((gops->barMode == BARS_STACKED) && (graphPtr_->nBarGroups > 0)) + if ((gops->barMode == BARS_STACKED) && (graphPtr_->nBarGroups_ > 0)) CheckBarStacks(&ops->axes, ®Ptr->top, ®Ptr->bottom); // Warning: You get what you deserve if the x-axis is logScale @@ -868,11 +868,11 @@ void BarElement::ResetStylePalette(Blt_Chain stylePalette) void BarElement::CheckBarStacks(Axis2d *pairPtr, double *minPtr, double *maxPtr) { GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; - if ((gops->barMode != BARS_STACKED) || (graphPtr_->nBarGroups == 0)) + if ((gops->barMode != BARS_STACKED) || (graphPtr_->nBarGroups_ == 0)) return; BarGroup *gp, *gend; - for (gp = graphPtr_->barGroups, gend = gp + graphPtr_->nBarGroups; gp < gend; + for (gp = graphPtr_->barGroups_, gend = gp + graphPtr_->nBarGroups_; gp < gend; gp++) { if ((gp->axes.x == pairPtr->x) && (gp->axes.y == pairPtr->y)) { @@ -1434,7 +1434,7 @@ void Blt_InitBarSetTable(Graph* graphPtr) Blt_DestroyBarSets(graphPtr); if (gops->barMode == BARS_INFRONT) return; - Tcl_InitHashTable(&graphPtr->setTable, sizeof(BarSetKey) / sizeof(int)); + Tcl_InitHashTable(&graphPtr->setTable_, sizeof(BarSetKey) / sizeof(int)); /* * Initialize a hash table and fill it with unique abscissas. Keep track @@ -1501,7 +1501,7 @@ void Blt_InitBarSetTable(Graph* graphPtr) int isNew; keyPtr = (BarSetKey *)Tcl_GetHashKey(&setTable, hPtr); - hPtr2 = Tcl_CreateHashEntry(&graphPtr->setTable, (char *)keyPtr,&isNew); + hPtr2 = Tcl_CreateHashEntry(&graphPtr->setTable_, (char *)keyPtr,&isNew); Tcl_HashTable *tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr); Tcl_SetHashValue(hPtr2, tablePtr); if (max < tablePtr->numEntries) { @@ -1514,9 +1514,9 @@ void Blt_InitBarSetTable(Graph* graphPtr) Tcl_HashEntry *hPtr; Tcl_HashSearch iter; - graphPtr->barGroups = (BarGroup*)calloc(sum, sizeof(BarGroup)); - BarGroup *groupPtr = graphPtr->barGroups; - for (hPtr = Tcl_FirstHashEntry(&graphPtr->setTable, &iter); + graphPtr->barGroups_ = (BarGroup*)calloc(sum, sizeof(BarGroup)); + BarGroup* groupPtr = graphPtr->barGroups_; + for (hPtr = Tcl_FirstHashEntry(&graphPtr->setTable_, &iter); hPtr; hPtr = Tcl_NextHashEntry(&iter)) { BarSetKey *keyPtr; Tcl_HashEntry *hPtr2; @@ -1539,8 +1539,8 @@ void Blt_InitBarSetTable(Graph* graphPtr) } } } - graphPtr->maxBarSetSize = max; - graphPtr->nBarGroups = sum; + graphPtr->maxBarSetSize_ = max; + graphPtr->nBarGroups_ = sum; } void Blt_ComputeBarStacks(Graph* graphPtr) @@ -1548,14 +1548,13 @@ void Blt_ComputeBarStacks(Graph* graphPtr) GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Blt_ChainLink link; - if ((gops->barMode != BARS_STACKED) || (graphPtr->nBarGroups == 0)) + if ((gops->barMode != BARS_STACKED) || (graphPtr->nBarGroups_ == 0)) return; /* Initialize the stack sums to zero. */ { BarGroup *gp, *gend; - - for (gp = graphPtr->barGroups, gend = gp + graphPtr->nBarGroups; + for (gp = graphPtr->barGroups_, gend = gp + graphPtr->nBarGroups_; gp < gend; gp++) { gp->sum = 0.0; } @@ -1583,7 +1582,7 @@ void Blt_ComputeBarStacks(Graph* graphPtr) key.value = *x; key.axes = ops->axes; key.axes.y = NULL; - hPtr = Tcl_FindHashEntry(&graphPtr->setTable, (char *)&key); + hPtr = Tcl_FindHashEntry(&graphPtr->setTable_, (char *)&key); if (!hPtr) continue; @@ -1604,7 +1603,7 @@ void Blt_ResetBarGroups(Graph* graphPtr) { BarGroup* gp; BarGroup* gend; - for (gp = graphPtr->barGroups, gend = gp + graphPtr->nBarGroups; gp < gend; + for (gp = graphPtr->barGroups_, gend = gp + graphPtr->nBarGroups_; gp < gend; gp++) { gp->lastY = 0.0; gp->count = 0; @@ -1613,19 +1612,19 @@ void Blt_ResetBarGroups(Graph* graphPtr) void Blt_DestroyBarSets(Graph* graphPtr) { - if (graphPtr->barGroups) { - free(graphPtr->barGroups); - graphPtr->barGroups = NULL; + if (graphPtr->barGroups_) { + free(graphPtr->barGroups_); + graphPtr->barGroups_ = NULL; } - graphPtr->nBarGroups = 0; + graphPtr->nBarGroups_ = 0; Tcl_HashSearch iter; - for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->setTable, &iter); + for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->setTable_, &iter); hPtr; hPtr = Tcl_NextHashEntry(&iter)) { Tcl_HashTable* tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr); Tcl_DeleteHashTable(tablePtr); free(tablePtr); } - Tcl_DeleteHashTable(&graphPtr->setTable); - Tcl_InitHashTable(&graphPtr->setTable, sizeof(BarSetKey) / sizeof(int)); + Tcl_DeleteHashTable(&graphPtr->setTable_); + Tcl_InitHashTable(&graphPtr->setTable_, sizeof(BarSetKey) / sizeof(int)); } diff --git a/src/bltGraph.C b/src/bltGraph.C index c7c5c33..fcd9656 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -261,9 +261,9 @@ Graph::Graph(ClientData clientData, Tcl_Interp* interp, cacheWidth_ =0; cacheHeight_ =0; - barGroups =NULL; - nBarGroups =0; - maxBarSetSize =0; + barGroups_ =NULL; + nBarGroups_ =0; + maxBarSetSize_ =0; ops->bottomMargin.site = MARGIN_BOTTOM; ops->leftMargin.site = MARGIN_LEFT; @@ -281,7 +281,7 @@ Graph::Graph(ClientData clientData, Tcl_Interp* interp, Tcl_InitHashTable(&markers.tagTable, TCL_STRING_KEYS); Tcl_InitHashTable(&dataTables, TCL_STRING_KEYS); Tcl_InitHashTable(&penTable, TCL_STRING_KEYS); - Tcl_InitHashTable(&setTable, sizeof(BarSetKey) / sizeof(int)); + Tcl_InitHashTable(&setTable_, sizeof(BarSetKey) / sizeof(int)); elements.displayList = Blt_Chain_Create(); markers.displayList = Blt_Chain_Create(); axes.displayList = Blt_Chain_Create(); diff --git a/src/bltGraph.h b/src/bltGraph.h index ba9485a..c943355 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -189,10 +189,10 @@ class Graph { short int cacheHeight_; // barchart specific information - BarGroup *barGroups; - int nBarGroups; - Tcl_HashTable setTable; - int maxBarSetSize; + BarGroup *barGroups_; + int nBarGroups_; + Tcl_HashTable setTable_; + int maxBarSetSize_; public: Graph(ClientData clientData, Tcl_Interp*interp, -- cgit v0.12