From 700f30179ceb323f797dccc0f7d596ddb1eed724 Mon Sep 17 00:00:00 2001 From: joye Date: Mon, 7 Jul 2014 19:34:37 +0000 Subject: *** empty log message *** --- src/bltGrElem.C | 110 +++++++++++++++++++++++-------------------- src/bltGrElem.h | 33 ++++++------- src/bltGrElemBar.C | 120 +++++++++++++++++++++++------------------------ src/bltGrElemLine.C | 126 +++++++++++++++++++++++++------------------------- src/bltGrElemOption.C | 82 +++++++++++++++----------------- src/bltGraphBar.C | 8 ++-- 6 files changed, 242 insertions(+), 237 deletions(-) diff --git a/src/bltGrElem.C b/src/bltGrElem.C index 7823a0a..a386362 100644 --- a/src/bltGrElem.C +++ b/src/bltGrElem.C @@ -42,47 +42,57 @@ using namespace Blt; ElemValues::ElemValues() { - elemPtr =NULL; - values =NULL; - nValues =0; - min =0; - max =0; + values_ =NULL; + nValues_ =0; + min_ =0; + max_ =0; } ElemValues::~ElemValues() { - if (values) - delete [] values; + if (values_) + delete [] values_; } -void ElemValues::findRange() +ElemValuesSource::ElemValuesSource(int nn) : ElemValues() { - if (nValues<1 || !values) - return; - - min = DBL_MAX; - max = -DBL_MAX; - for (int ii=0; ii max) - max = values[ii]; - } - } + nValues_ = nn; + values_ = new double[nn]; } -ElemValuesSource::ElemValuesSource() +ElemValuesSource::ElemValuesSource(int nn, double* vv) : ElemValues() { + nValues_ = nn; + values_ = vv; } ElemValuesSource::~ElemValuesSource() { } -ElemValuesVector::ElemValuesVector() +void ElemValuesSource::findRange() +{ + if (nValues_<1 || !values_) + return; + + min_ = DBL_MAX; + max_ = -DBL_MAX; + for (int ii=0; ii max_) + max_ = values_[ii]; + } + } +} + +ElemValuesVector::ElemValuesVector(Element* ptr, const char* vecName) + : ElemValues() { - vectorSource.vector = NULL; + elemPtr_ = ptr; + Graph* graphPtr = elemPtr_->graphPtr_; + source_.vector = Blt_AllocVectorId(graphPtr->interp_, vecName); } ElemValuesVector::~ElemValuesVector() @@ -90,31 +100,33 @@ ElemValuesVector::~ElemValuesVector() FreeVectorSource(); } -int ElemValuesVector::GetVectorData(Tcl_Interp* interp, const char *vecName) +int ElemValuesVector::GetVectorData() { - vectorSource.vector = Blt_AllocVectorId(interp, vecName); + Graph* graphPtr = elemPtr_->graphPtr_; Blt_Vector *vecPtr; - if (Blt_GetVectorById(interp, vectorSource.vector, &vecPtr) != TCL_OK) + if (Blt_GetVectorById(graphPtr->interp_, source_.vector, &vecPtr) != TCL_OK) return TCL_ERROR; - if (FetchVectorValues(interp, vecPtr) != TCL_OK) { + if (FetchVectorValues(vecPtr) != TCL_OK) { FreeVectorSource(); return TCL_ERROR; } - Blt_SetVectorChangedProc(vectorSource.vector, VectorChangedProc, this); + Blt_SetVectorChangedProc(source_.vector, VectorChangedProc, this); return TCL_OK; } -int ElemValuesVector::FetchVectorValues(Tcl_Interp* interp, Blt_Vector* vector) +int ElemValuesVector::FetchVectorValues(Blt_Vector* vector) { - if (values) - delete [] values; - values = NULL; - nValues = 0; - min =0; - max =0; + Graph* graphPtr = elemPtr_->graphPtr_; + + if (values_) + delete [] values_; + values_ = NULL; + nValues_ = 0; + min_ =0; + max_ =0; int ss = Blt_VecLength(vector); if (!ss) @@ -122,25 +134,25 @@ int ElemValuesVector::FetchVectorValues(Tcl_Interp* interp, Blt_Vector* vector) double* array = new double[ss]; if (!array) { - Tcl_AppendResult(interp, "can't allocate new vector", NULL); + Tcl_AppendResult(graphPtr->interp_, "can't allocate new vector", NULL); return TCL_ERROR; } memcpy(array, Blt_VecData(vector), ss*sizeof(double)); - values = array; - nValues = Blt_VecLength(vector); - min = Blt_VecMin(vector); - max = Blt_VecMax(vector); + values_ = array; + nValues_ = Blt_VecLength(vector); + min_ = Blt_VecMin(vector); + max_ = Blt_VecMax(vector); return TCL_OK; } void ElemValuesVector::FreeVectorSource() { - if (vectorSource.vector) { - Blt_SetVectorChangedProc(vectorSource.vector, NULL, NULL); - Blt_FreeVectorId(vectorSource.vector); - vectorSource.vector = NULL; + if (source_.vector) { + Blt_SetVectorChangedProc(source_.vector, NULL, NULL); + Blt_FreeVectorId(source_.vector); + source_.vector = NULL; } } @@ -192,8 +204,8 @@ double Element::FindElemValuesMinimum(ElemValues* valuesPtr, double minLimit) if (!valuesPtr) return min; - for (int ii=0; iinValues; ii++) { - double x = valuesPtr->values[ii]; + for (int ii=0; iinValues_; ii++) { + double x = valuesPtr->values_[ii]; // What do you do about negative values when using log // scale values seems like a grey area. Mirror. if (x < 0.0) @@ -212,8 +224,8 @@ PenStyle** Element::StyleMap() ElementOptions* ops = (ElementOptions*)ops_; int nPoints = NUMBEROFPOINTS(ops); - int nWeights = MIN(ops->w ? ops->w->nValues : 0, nPoints); - double* w = ops->w ? ops->w->values : NULL; + int nWeights = MIN(ops->w ? ops->w->nValues_ : 0, nPoints); + double* w = ops->w ? ops->w->values_ : NULL; Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); PenStyle* stylePtr = (PenStyle*)Blt_Chain_GetValue(link); diff --git a/src/bltGrElem.h b/src/bltGrElem.h index 665caff..2d8d7cd 100644 --- a/src/bltGrElem.h +++ b/src/bltGrElem.h @@ -47,8 +47,8 @@ extern "C" { #define SHOW_BOTH 3 #define MIN(a,b) (((a)<(b))?(a):(b)) -#define NUMBEROFPOINTS(e) MIN( (e)->coords.x ? (e)->coords.x->nValues : 0, \ - (e)->coords.y ? (e)->coords.y->nValues : 0 ) +#define NUMBEROFPOINTS(e) MIN( (e)->coords.x ? (e)->coords.x->nValues_ : 0, \ + (e)->coords.y ? (e)->coords.y->nValues_ : 0 ) #define NORMALPEN(e) ((((e)->normalPenPtr == NULL) ? \ (e)->builtinPenPtr : (e)->normalPenPtr)) @@ -64,37 +64,38 @@ namespace Blt { class ElemValues { public: - Element* elemPtr; - double *values; - int nValues; - double min; - double max; + double* values_; + int nValues_; + double min_; + double max_; public: ElemValues(); virtual ~ElemValues(); - - void findRange(); }; class ElemValuesSource : public ElemValues { public: - ElemValuesSource(); + ElemValuesSource(int); + ElemValuesSource(int, double*); ~ElemValuesSource(); + + void findRange(); }; class ElemValuesVector : public ElemValues { public: - VectorDataSource vectorSource; + Element* elemPtr_; + VectorDataSource source_; public: - ElemValuesVector(); + ElemValuesVector(Element*, const char*); ~ElemValuesVector(); - int GetVectorData(Tcl_Interp*, const char*); - int FetchVectorValues(Tcl_Interp*, Blt_Vector*); + int GetVectorData(); + int FetchVectorValues(Blt_Vector*); void FreeVectorSource(); }; @@ -105,8 +106,8 @@ namespace Blt { } GraphSegments; typedef struct { - ElemValues* x; - ElemValues* y; + ElemValuesSource* x; + ElemValuesSource* y; } ElemCoords; typedef struct { diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index f1d0d4a..5cf0956 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -255,7 +255,7 @@ void BarElement::map() reset(); if (!ops->coords.x || !ops->coords.y || - !ops->coords.x->nValues || !ops->coords.y->nValues) + !ops->coords.x->nValues_ || !ops->coords.y->nValues_) return; int nPoints = NUMBEROFPOINTS(ops); @@ -269,8 +269,8 @@ void BarElement::map() XRectangle* bars = new XRectangle[nPoints]; int* barToData = new int[nPoints]; - double* x = ops->coords.x->values; - double* y = ops->coords.y->values; + double* x = ops->coords.x->values_; + double* y = ops->coords.y->values_; int count = 0; int ii; @@ -456,12 +456,12 @@ void BarElement::map() } BarStyle** dataToStyle = (BarStyle**)StyleMap(); - if (((ops->yHigh && ops->yHigh->nValues > 0) && - (ops->yLow && ops->yLow->nValues > 0)) || - ((ops->xHigh && ops->xHigh->nValues > 0) && - (ops->xLow && ops->xLow->nValues > 0)) || - (ops->xError && ops->xError->nValues > 0) || - (ops->yError && ops->yError->nValues > 0)) { + if (((ops->yHigh && ops->yHigh->nValues_ > 0) && + (ops->yLow && ops->yLow->nValues_ > 0)) || + ((ops->xHigh && ops->xHigh->nValues_ > 0) && + (ops->xLow && ops->xLow->nValues_ > 0)) || + (ops->xError && ops->xError->nValues_ > 0) || + (ops->yError && ops->yError->nValues_ > 0)) { mapErrorBars(dataToStyle); } @@ -479,7 +479,7 @@ void BarElement::extents(Region2d *regPtr) regPtr->bottom = regPtr->right = -DBL_MAX; if (!ops->coords.x || !ops->coords.y || - !ops->coords.x->nValues || !ops->coords.y->nValues) + !ops->coords.x->nValues_ || !ops->coords.y->nValues_) return; int nPoints = NUMBEROFPOINTS(ops); @@ -488,11 +488,11 @@ void BarElement::extents(Region2d *regPtr) barWidth = ops->barWidth; double middle = 0.5; - regPtr->left = ops->coords.x->min - middle; - regPtr->right = ops->coords.x->max + middle; + regPtr->left = ops->coords.x->min_ - middle; + regPtr->right = ops->coords.x->max_ + middle; - regPtr->top = ops->coords.y->min; - regPtr->bottom = ops->coords.y->max; + regPtr->top = ops->coords.y->min_; + regPtr->bottom = ops->coords.y->max_; if (regPtr->bottom < gops->baseline) regPtr->bottom = gops->baseline; @@ -520,14 +520,14 @@ void BarElement::extents(Region2d *regPtr) } // Correct the extents for error bars if they exist - if (ops->xError && (ops->xError->nValues > 0)) { - nPoints = MIN(ops->xError->nValues, nPoints); + if (ops->xError && (ops->xError->nValues_ > 0)) { + nPoints = MIN(ops->xError->nValues_, nPoints); for (int ii=0; iicoords.x->values[ii] + ops->xError->values[ii]; + double x = ops->coords.x->values_[ii] + ops->xError->values_[ii]; if (x > regPtr->right) regPtr->right = x; - x = ops->coords.x->values[ii] - ops->xError->values[ii]; + x = ops->coords.x->values_[ii] - ops->xError->values_[ii]; if (axisxops->logScale) { // Mirror negative values, instead of ignoring them if (x < 0.0) @@ -543,31 +543,31 @@ void BarElement::extents(Region2d *regPtr) } else { if ((ops->xHigh) && - (ops->xHigh->nValues > 0) && - (ops->xHigh->max > regPtr->right)) - regPtr->right = ops->xHigh->max; + (ops->xHigh->nValues_ > 0) && + (ops->xHigh->max_ > regPtr->right)) + regPtr->right = ops->xHigh->max_; - if (ops->xLow && (ops->xLow->nValues > 0)) { + if (ops->xLow && (ops->xLow->nValues_ > 0)) { double left; - if ((ops->xLow->min <= 0.0) && (axisxops->logScale)) + if ((ops->xLow->min_ <= 0.0) && (axisxops->logScale)) left = FindElemValuesMinimum(ops->xLow, DBL_MIN); else - left = ops->xLow->min; + left = ops->xLow->min_; if (left < regPtr->left) regPtr->left = left; } } - if (ops->yError && (ops->yError->nValues > 0)) { - nPoints = MIN(ops->yError->nValues, nPoints); + if (ops->yError && (ops->yError->nValues_ > 0)) { + nPoints = MIN(ops->yError->nValues_, nPoints); for (int ii=0; iicoords.y->values[ii] + ops->yError->values[ii]; + double y = ops->coords.y->values_[ii] + ops->yError->values_[ii]; if (y > regPtr->bottom) regPtr->bottom = y; - y = ops->coords.y->values[ii] - ops->yError->values[ii]; + y = ops->coords.y->values_[ii] - ops->yError->values_[ii]; if (axisyops->logScale) { // Mirror negative values, instead of ignoring them if (y < 0.0) @@ -583,17 +583,17 @@ void BarElement::extents(Region2d *regPtr) } else { if ((ops->yHigh) && - (ops->yHigh->nValues > 0) && - (ops->yHigh->max > regPtr->bottom)) - regPtr->bottom = ops->yHigh->max; + (ops->yHigh->nValues_ > 0) && + (ops->yHigh->max_ > regPtr->bottom)) + regPtr->bottom = ops->yHigh->max_; - if (ops->yLow && ops->yLow->nValues > 0) { + if (ops->yLow && ops->yLow->nValues_ > 0) { double top; - if ((ops->yLow->min <= 0.0) && + if ((ops->yLow->min_ <= 0.0) && (axisyops->logScale)) top = FindElemValuesMinimum(ops->yLow, DBL_MIN); else - top = ops->yLow->min; + top = ops->yLow->min_; if (top < regPtr->top) regPtr->top = top; @@ -654,9 +654,9 @@ void BarElement::closest() searchPtr->dist = minDist; searchPtr->index = imin; searchPtr->point.x = - ops->coords.x ? (double)ops->coords.x->values[imin] : 0; + ops->coords.x ? (double)ops->coords.x->values_[imin] : 0; searchPtr->point.y = - ops->coords.y ? (double)ops->coords.y->values[imin] : 0; + ops->coords.y ? (double)ops->coords.y->values_[imin] : 0; } } @@ -1050,11 +1050,11 @@ void BarElement::mapErrorBars(BarStyle **dataToStyle) int nPoints = NUMBEROFPOINTS(ops); int nn =0; if (ops->coords.x && ops->coords.y) { - if (ops->xError && (ops->xError->nValues > 0)) - nn = MIN(ops->xError->nValues, nPoints); + if (ops->xError && (ops->xError->nValues_ > 0)) + nn = MIN(ops->xError->nValues_, nPoints); else if (ops->xHigh && ops->xLow) - nn = MIN3(ops->xHigh->nValues, ops->xLow->nValues, nPoints); + nn = MIN3(ops->xHigh->nValues_, ops->xLow->nValues_, nPoints); } if (nn) { @@ -1064,19 +1064,19 @@ void BarElement::mapErrorBars(BarStyle **dataToStyle) int* indexPtr = map; for (int ii=0; iicoords.x->values[ii]; - double y = ops->coords.y->values[ii]; + double x = ops->coords.x->values_[ii]; + double y = ops->coords.y->values_[ii]; BarStyle* stylePtr = dataToStyle[ii]; if ((isfinite(x)) && (isfinite(y))) { double high, low; - if (ops->xError->nValues > 0) { - high = x + ops->xError->values[ii]; - low = x - ops->xError->values[ii]; + if (ops->xError->nValues_ > 0) { + high = x + ops->xError->values_[ii]; + low = x - ops->xError->values_[ii]; } else { - high = ops->xHigh ? ops->xHigh->values[ii] : 0; - low = ops->xLow ? ops->xLow->values[ii] : 0; + high = ops->xHigh ? ops->xHigh->values_[ii] : 0; + low = ops->xLow ? ops->xLow->values_[ii] : 0; } if ((isfinite(high)) && (isfinite(low))) { Point2d p = graphPtr_->map2D(high, y, ops->xAxis, ops->yAxis); @@ -1115,11 +1115,11 @@ void BarElement::mapErrorBars(BarStyle **dataToStyle) nn =0; if (ops->coords.x && ops->coords.y) { - if (ops->yError && (ops->yError->nValues > 0)) - nn = MIN(ops->yError->nValues, nPoints); + if (ops->yError && (ops->yError->nValues_ > 0)) + nn = MIN(ops->yError->nValues_, nPoints); else if (ops->yHigh && ops->yLow) - nn = MIN3(ops->yHigh->nValues, ops->yLow->nValues, nPoints); + nn = MIN3(ops->yHigh->nValues_, ops->yLow->nValues_, nPoints); } if (nn) { @@ -1129,19 +1129,19 @@ void BarElement::mapErrorBars(BarStyle **dataToStyle) int* indexPtr = map; for (int ii=0; iicoords.x->values[ii]; - double y = ops->coords.y->values[ii]; + double x = ops->coords.x->values_[ii]; + double y = ops->coords.y->values_[ii]; BarStyle *stylePtr = dataToStyle[ii]; if ((isfinite(x)) && (isfinite(y))) { double high, low; - if (ops->yError->nValues > 0) { - high = y + ops->yError->values[ii]; - low = y - ops->yError->values[ii]; + if (ops->yError->nValues_ > 0) { + high = y + ops->yError->values_[ii]; + low = y - ops->yError->values_[ii]; } else { - high = ops->yHigh->values[ii]; - low = ops->yLow->values[ii]; + high = ops->yHigh->values_[ii]; + low = ops->yLow->values_[ii]; } if ((isfinite(high)) && (isfinite(low))) { Point2d p = graphPtr_->map2D(x, high, ops->xAxis, ops->yAxis); @@ -1217,8 +1217,8 @@ void BarElement::drawValues(Drawable drawable, BarPen* penPtr, Point2d anchorPos; char string[TCL_DOUBLE_SPACE * 2 + 2]; - double x = ops->coords.x->values[barToData[count]]; - double y = ops->coords.y->values[barToData[count]]; + double x = ops->coords.x->values_[barToData[count]]; + double y = ops->coords.y->values_[barToData[count]]; count++; if (pops->valueShow == SHOW_X) @@ -1284,8 +1284,8 @@ void BarElement::printValues(PSOutput* psPtr, BarPen* penPtr, XRectangle *rp, *rend; for (rp = bars, rend = rp + nBars; rp < rend; rp++) { - double x = ops->coords.x->values[barToData[count]]; - double y = ops->coords.y->values[barToData[count]]; + double x = ops->coords.x->values_[barToData[count]]; + double y = ops->coords.y->values_[barToData[count]]; count++; char string[TCL_DOUBLE_SPACE * 2 + 2]; diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 9e741b8..c028913 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -308,7 +308,7 @@ void LineElement::map() reset(); if (!ops->coords.x || !ops->coords.y || - !ops->coords.x->nValues || !ops->coords.y->nValues) + !ops->coords.x->nValues_ || !ops->coords.y->nValues_) return; int np = NUMBEROFPOINTS(ops); @@ -373,12 +373,12 @@ void LineElement::map() } LineStyle** styleMap = (LineStyle**)StyleMap(); - if (((ops->yHigh && ops->yHigh->nValues > 0) && - (ops->yLow && ops->yLow->nValues > 0)) || - ((ops->xHigh && ops->xHigh->nValues > 0) && - (ops->xLow && ops->xLow->nValues > 0)) || - (ops->xError && ops->xError->nValues > 0) || - (ops->yError && ops->yError->nValues > 0)) { + if (((ops->yHigh && ops->yHigh->nValues_ > 0) && + (ops->yLow && ops->yLow->nValues_ > 0)) || + ((ops->xHigh && ops->xHigh->nValues_ > 0) && + (ops->xLow && ops->xLow->nValues_ > 0)) || + (ops->xError && ops->xError->nValues_ > 0) || + (ops->yError && ops->yError->nValues_ > 0)) { mapErrorBars(styleMap); } @@ -394,33 +394,33 @@ void LineElement::extents(Region2d *extsPtr) extsPtr->bottom = extsPtr->right = -DBL_MAX; if (!ops->coords.x || !ops->coords.y || - !ops->coords.x->nValues || !ops->coords.y->nValues) + !ops->coords.x->nValues_ || !ops->coords.y->nValues_) return; int np = NUMBEROFPOINTS(ops); - extsPtr->right = ops->coords.x->max; + extsPtr->right = ops->coords.x->max_; AxisOptions* axisxops = (AxisOptions*)ops->xAxis->ops(); - if ((ops->coords.x->min <= 0.0) && (axisxops->logScale)) + if ((ops->coords.x->min_ <= 0.0) && (axisxops->logScale)) extsPtr->left = FindElemValuesMinimum(ops->coords.x, DBL_MIN); else - extsPtr->left = ops->coords.x->min; + extsPtr->left = ops->coords.x->min_; - extsPtr->bottom = ops->coords.y->max; + extsPtr->bottom = ops->coords.y->max_; AxisOptions* axisyops = (AxisOptions*)ops->yAxis->ops(); - if ((ops->coords.y->min <= 0.0) && (axisyops->logScale)) + if ((ops->coords.y->min_ <= 0.0) && (axisyops->logScale)) extsPtr->top = FindElemValuesMinimum(ops->coords.y, DBL_MIN); else - extsPtr->top = ops->coords.y->min; + extsPtr->top = ops->coords.y->min_; // Correct the data limits for error bars - if (ops->xError && ops->xError->nValues > 0) { - np = MIN(ops->xError->nValues, np); + if (ops->xError && ops->xError->nValues_ > 0) { + np = MIN(ops->xError->nValues_, np); for (int ii=0; iicoords.x->values[ii] + ops->xError->values[ii]; + double x = ops->coords.x->values_[ii] + ops->xError->values_[ii]; if (x > extsPtr->right) extsPtr->right = x; - x = ops->coords.x->values[ii] - ops->xError->values[ii]; + x = ops->coords.x->values_[ii] - ops->xError->values_[ii]; AxisOptions* axisxops = (AxisOptions*)ops->xAxis->ops(); if (axisxops->logScale) { // Mirror negative values, instead of ignoring them @@ -435,30 +435,30 @@ void LineElement::extents(Region2d *extsPtr) } else { if (ops->xHigh && - (ops->xHigh->nValues > 0) && - (ops->xHigh->max > extsPtr->right)) { - extsPtr->right = ops->xHigh->max; + (ops->xHigh->nValues_ > 0) && + (ops->xHigh->max_ > extsPtr->right)) { + extsPtr->right = ops->xHigh->max_; } - if (ops->xLow && ops->xLow->nValues > 0) { + if (ops->xLow && ops->xLow->nValues_ > 0) { double left; - if ((ops->xLow->min <= 0.0) && (axisxops->logScale)) + if ((ops->xLow->min_ <= 0.0) && (axisxops->logScale)) left = FindElemValuesMinimum(ops->xLow, DBL_MIN); else - left = ops->xLow->min; + left = ops->xLow->min_; if (left < extsPtr->left) extsPtr->left = left; } } - if (ops->yError && ops->yError->nValues > 0) { - np = MIN(ops->yError->nValues, np); + if (ops->yError && ops->yError->nValues_ > 0) { + np = MIN(ops->yError->nValues_, np); for (int ii=0; iicoords.y->values[ii] + ops->yError->values[ii]; + double y = ops->coords.y->values_[ii] + ops->yError->values_[ii]; if (y > extsPtr->bottom) extsPtr->bottom = y; - y = ops->coords.y->values[ii] - ops->yError->values[ii]; + y = ops->coords.y->values_[ii] - ops->yError->values_[ii]; AxisOptions* axisyops = (AxisOptions*)ops->yAxis->ops(); if (axisyops->logScale) { // Mirror negative values, instead of ignoring them @@ -472,16 +472,16 @@ void LineElement::extents(Region2d *extsPtr) } } else { - if (ops->yHigh && (ops->yHigh->nValues > 0) && - (ops->yHigh->max > extsPtr->bottom)) - extsPtr->bottom = ops->yHigh->max; + if (ops->yHigh && (ops->yHigh->nValues_ > 0) && + (ops->yHigh->max_ > extsPtr->bottom)) + extsPtr->bottom = ops->yHigh->max_; - if (ops->yLow && ops->yLow->nValues > 0) { + if (ops->yLow && ops->yLow->nValues_ > 0) { double top; - if ((ops->yLow->min <= 0.0) && (axisyops->logScale)) + if ((ops->yLow->min_ <= 0.0) && (axisyops->logScale)) top = FindElemValuesMinimum(ops->yLow, DBL_MIN); else - top = ops->yLow->min; + top = ops->yLow->min_; if (top < extsPtr->top) extsPtr->top = top; @@ -954,8 +954,8 @@ void LineElement::getScreenPoints(MapInfo* mapPtr) } int np = NUMBEROFPOINTS(ops); - double* x = ops->coords.x->values; - double* y = ops->coords.y->values; + double* x = ops->coords.x->values_; + double* y = ops->coords.y->values_; Point2d* points = new Point2d[np]; int* map = new int[np]; @@ -1332,8 +1332,8 @@ void LineElement::mapActiveSymbols() if (iPoint >= np) continue; - double x = ops->coords.x->values[iPoint]; - double y = ops->coords.y->values[iPoint]; + double x = ops->coords.x->values_[iPoint]; + double y = ops->coords.y->values_[iPoint]; points[count] = graphPtr_->map2D(x, y, ops->xAxis, ops->yAxis); map[count] = iPoint; if (PointInRegion(&exts, points[count].x, points[count].y)) { @@ -1738,11 +1738,11 @@ void LineElement::mapErrorBars(LineStyle **styleMap) int nn =0; int np = NUMBEROFPOINTS(ops); if (ops->coords.x && ops->coords.y) { - if (ops->xError && (ops->xError->nValues > 0)) - nn = MIN(ops->xError->nValues, np); + if (ops->xError && (ops->xError->nValues_ > 0)) + nn = MIN(ops->xError->nValues_, np); else if (ops->xHigh && ops->xLow) - nn = MIN3(ops->xHigh->nValues, ops->xLow->nValues, np); + nn = MIN3(ops->xHigh->nValues_, ops->xLow->nValues_, np); } if (nn) { @@ -1752,20 +1752,20 @@ void LineElement::mapErrorBars(LineStyle **styleMap) int* indexPtr = errorToData; for (int ii=0; iicoords.x->values[ii]; - double y = ops->coords.y->values[ii]; + double x = ops->coords.x->values_[ii]; + double y = ops->coords.y->values_[ii]; LineStyle* stylePtr = styleMap[ii]; if ((isfinite(x)) && (isfinite(y))) { double high; double low; - if (ops->xError->nValues > 0) { - high = x + ops->xError->values[ii]; - low = x - ops->xError->values[ii]; + if (ops->xError->nValues_ > 0) { + high = x + ops->xError->values_[ii]; + low = x - ops->xError->values_[ii]; } else { - high = ops->xHigh ? ops->xHigh->values[ii] : 0; - low = ops->xLow ? ops->xLow->values[ii] : 0; + high = ops->xHigh ? ops->xHigh->values_[ii] : 0; + low = ops->xLow ? ops->xLow->values_[ii] : 0; } if ((isfinite(high)) && (isfinite(low))) { @@ -1805,11 +1805,11 @@ void LineElement::mapErrorBars(LineStyle **styleMap) nn =0; if (ops->coords.x && ops->coords.y) { - if (ops->yError && (ops->yError->nValues > 0)) - nn = MIN(ops->yError->nValues, np); + if (ops->yError && (ops->yError->nValues_ > 0)) + nn = MIN(ops->yError->nValues_, np); else if (ops->yHigh && ops->yLow) - nn = MIN3(ops->yHigh->nValues, ops->yLow->nValues, np); + nn = MIN3(ops->yHigh->nValues_, ops->yLow->nValues_, np); } if (nn) { @@ -1819,20 +1819,20 @@ void LineElement::mapErrorBars(LineStyle **styleMap) int* indexPtr = errorToData; for (int ii=0; iicoords.x->values[ii]; - double y = ops->coords.y->values[ii]; + double x = ops->coords.x->values_[ii]; + double y = ops->coords.y->values_[ii]; LineStyle* stylePtr = styleMap[ii]; if ((isfinite(x)) && (isfinite(y))) { double high; double low; - if (ops->yError->nValues > 0) { - high = y + ops->yError->values[ii]; - low = y - ops->yError->values[ii]; + if (ops->yError->nValues_ > 0) { + high = y + ops->yError->values_[ii]; + low = y - ops->yError->values_[ii]; } else { - high = ops->yHigh->values[ii]; - low = ops->yLow->values[ii]; + high = ops->yHigh->values_[ii]; + low = ops->yLow->values_[ii]; } if ((isfinite(high)) && (isfinite(low))) { @@ -1957,8 +1957,8 @@ void LineElement::closestPoint(ClosestSearch *searchPtr) searchPtr->elemPtr = (Element*)this; searchPtr->dist = dMin; searchPtr->index = iClose; - searchPtr->point.x = ops->coords.x->values[iClose]; - searchPtr->point.y = ops->coords.y->values[iClose]; + searchPtr->point.x = ops->coords.x->values_[iClose]; + searchPtr->point.y = ops->coords.y->values_[iClose]; } } @@ -2375,7 +2375,7 @@ void LineElement::drawValues(Drawable drawable, LinePen* penPtr, TextStyle ts(graphPtr_, &pops->valueStyle); int count = 0; - xval = ops->coords.x->values, yval = ops->coords.y->values; + xval = ops->coords.x->values_, yval = ops->coords.y->values_; for (pp = points, endp = points + length; pp < endp; pp++) { double x = xval[map[count]]; @@ -2521,8 +2521,8 @@ void LineElement::printValues(PSOutput* psPtr, LinePen* penPtr, int count = 0; Point2d *pp, *endp; for (pp = symbolPts, endp = symbolPts + nSymbolPts; pp < endp; pp++) { - double x = ops->coords.x->values[pointToData[count]]; - double y = ops->coords.y->values[pointToData[count]]; + double x = ops->coords.x->values_[pointToData[count]]; + double y = ops->coords.y->values_[pointToData[count]]; count++; char string[TCL_DOUBLE_SPACE * 2 + 2]; diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C index 5eeeea0..2b3744a 100644 --- a/src/bltGrElemOption.C +++ b/src/bltGrElemOption.C @@ -88,23 +88,24 @@ static int ValuesSetProc(ClientData clientData, Tcl_Interp* interp, } const char *string = Tcl_GetString(objv[0]); - if ((objc == 1) && (Blt_VectorExists2(interp, string))) { - ElemValuesVector* valuesPtr = new ElemValuesVector(); - valuesPtr->elemPtr = elemPtr; - if (valuesPtr->GetVectorData(interp, string) != TCL_OK) + if (objc == 1) { + if (Blt_VectorExists2(interp, string)) { + ElemValuesVector* valuesPtr = new ElemValuesVector(elemPtr, string); + if (valuesPtr->GetVectorData() != TCL_OK) { + delete valuesPtr; + return TCL_ERROR; + } + *valuesPtrPtr = valuesPtr; + } + else return TCL_ERROR; - *valuesPtrPtr = valuesPtr; } else { - ElemValuesSource* valuesPtr = new ElemValuesSource(); - valuesPtr->elemPtr = elemPtr; - double* values; int nValues; if (ParseValues(interp, *objPtr, &nValues, &values) != TCL_OK) return TCL_ERROR; - valuesPtr->values = values; - valuesPtr->nValues = nValues; + ElemValuesSource* valuesPtr = new ElemValuesSource(nValues, values); valuesPtr->findRange(); *valuesPtrPtr = valuesPtr; } @@ -120,13 +121,13 @@ static Tcl_Obj* ValuesGetProc(ClientData clientData, Tk_Window tkwin, if (!valuesPtr) return Tcl_NewStringObj("", -1); - int cnt = valuesPtr->nValues; + int cnt = valuesPtr->nValues_; if (!cnt) return Tcl_NewListObj(0, (Tcl_Obj**)NULL); Tcl_Obj** ll = new Tcl_Obj*[cnt]; for (int ii=0; iivalues[ii]); + ll[ii] = Tcl_NewDoubleObj(valuesPtr->values_[ii]); Tcl_Obj* listObjPtr = Tcl_NewListObj(cnt, ll); delete [] ll; @@ -161,6 +162,9 @@ static int PairsSetProc(ClientData clientData, Tcl_Interp* interp, if (ParseValues(interp, *objPtr, &nValues, &values) != TCL_OK) return TCL_ERROR; + if (nValues == 0) + return TCL_OK; + if (nValues & 1) { Tcl_AppendResult(interp, "odd number of data points", NULL); delete [] values; @@ -168,31 +172,18 @@ static int PairsSetProc(ClientData clientData, Tcl_Interp* interp, } nValues /= 2; - size_t newSize = nValues * sizeof(double); - if (coordsPtr->x) { + if (coordsPtr->x) delete coordsPtr->x; - coordsPtr->x = NULL; - } - if (coordsPtr->y) { - delete coordsPtr->y; - coordsPtr->y = NULL; - } - - if (newSize == 0) - return TCL_OK; + coordsPtr->x = new ElemValuesSource(nValues); - coordsPtr->x = new ElemValuesSource(); - coordsPtr->y = new ElemValuesSource(); - - coordsPtr->x->values = new double[newSize]; - coordsPtr->x->nValues = nValues; - coordsPtr->y->values = new double[newSize]; - coordsPtr->y->nValues = nValues; + if (coordsPtr->y) + delete coordsPtr->y; + coordsPtr->y = new ElemValuesSource(nValues); int ii=0; for (double* p = values; iix->values[ii] = *p++; - coordsPtr->y->values[ii] = *p++; + coordsPtr->x->values_[ii] = *p++; + coordsPtr->y->values_[ii] = *p++; } delete [] values; @@ -209,14 +200,14 @@ static Tcl_Obj* PairsGetProc(ClientData clientData, Tk_Window tkwin, if (!coordsPtr || !coordsPtr->x || !coordsPtr->y || - !coordsPtr->x->nValues || !coordsPtr->y->nValues) + !coordsPtr->x->nValues_ || !coordsPtr->y->nValues_) return Tcl_NewListObj(0, (Tcl_Obj**)NULL); - int cnt = MIN(coordsPtr->x->nValues, coordsPtr->y->nValues); + int cnt = MIN(coordsPtr->x->nValues_, coordsPtr->y->nValues_); Tcl_Obj** ll = new Tcl_Obj*[2*cnt]; for (int ii=0, jj=0; iix->values[ii]); - ll[jj++] = Tcl_NewDoubleObj(coordsPtr->y->values[ii]); + ll[jj++] = Tcl_NewDoubleObj(coordsPtr->x->values_[ii]); + ll[jj++] = Tcl_NewDoubleObj(coordsPtr->y->values_[ii]); } Tcl_Obj* listObjPtr = Tcl_NewListObj(2*cnt, ll); delete [] ll; @@ -361,21 +352,21 @@ void VectorChangedProc(Tcl_Interp* interp, ClientData clientData, if (notify == BLT_VECTOR_NOTIFY_DESTROY) { valuesPtr->FreeVectorSource(); - if (valuesPtr->values) - delete [] valuesPtr->values; - valuesPtr->values = NULL; - valuesPtr->nValues = 0; - valuesPtr->min =0; - valuesPtr->max =0; + if (valuesPtr->values_) + delete [] valuesPtr->values_; + valuesPtr->values_ = NULL; + valuesPtr->nValues_ = 0; + valuesPtr->min_ =0; + valuesPtr->max_ =0; } else { Blt_Vector* vector; - Blt_GetVectorById(interp, valuesPtr->vectorSource.vector, &vector); - if (valuesPtr->FetchVectorValues(interp, vector) != TCL_OK) + Blt_GetVectorById(interp, valuesPtr->source_.vector, &vector); + if (valuesPtr->FetchVectorValues(vector) != TCL_OK) return; } - Element* elemPtr = valuesPtr->elemPtr; + Element* elemPtr = valuesPtr->elemPtr_; Graph* graphPtr = elemPtr->graphPtr_; graphPtr->flags |= RESET; @@ -410,5 +401,6 @@ static int ParseValues(Tcl_Interp* interp, Tcl_Obj *objPtr, int *nValuesPtr, *arrayPtr = array; *nValuesPtr = objc; } + return TCL_OK; } diff --git a/src/bltGraphBar.C b/src/bltGraphBar.C index aef6518..ab1121c 100644 --- a/src/bltGraphBar.C +++ b/src/bltGraphBar.C @@ -334,9 +334,9 @@ void BarGraph::initBarSets() nSegs++; if (ops->coords.x) { - int nPoints = ops->coords.x->nValues; + int nPoints = ops->coords.x->nValues_; double *x, *xend; - for (x = ops->coords.x->values, xend = x + nPoints; x < xend; x++) { + for (x = ops->coords.x->values_, xend = x + nPoints; x < xend; x++) { BarSetKey key; key.value =*x; key.xAxis =ops->xAxis; @@ -471,8 +471,8 @@ void BarGraph::computeBarStacks() if (ops->coords.x && ops->coords.y) { double *x, *y, *xend; - for (x = ops->coords.x->values, y = ops->coords.y->values, - xend = x + ops->coords.x->nValues; x < xend; x++, y++) { + for (x = ops->coords.x->values_, y = ops->coords.y->values_, + xend = x + ops->coords.x->nValues_; x < xend; x++, y++) { BarSetKey key; key.value =*x; key.xAxis =ops->xAxis; -- cgit v0.12