summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bltGrElem.C22
-rw-r--r--src/bltGrElem.h2
-rw-r--r--src/bltGrElemOption.C35
3 files changed, 27 insertions, 32 deletions
diff --git a/src/bltGrElem.C b/src/bltGrElem.C
index 6414c4a..7754b3e 100644
--- a/src/bltGrElem.C
+++ b/src/bltGrElem.C
@@ -27,6 +27,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <math.h>
#include <float.h>
#include <stdlib.h>
@@ -37,6 +38,8 @@
using namespace Blt;
+// Class ElemValues
+
ElemValues::ElemValues()
{
type = SOURCE_VALUES;
@@ -54,6 +57,25 @@ ElemValues::~ElemValues()
delete [] values;
}
+void ElemValues::findRange()
+{
+ if (nValues<1 || !values)
+ return;
+
+ min = DBL_MAX;
+ max = -DBL_MAX;
+ for (int ii=0; ii<nValues; ii++) {
+ if (isfinite(values[ii])) {
+ if (values[ii] < min)
+ min = values[ii];
+ if (values[ii] > max)
+ max = values[ii];
+ }
+ }
+}
+
+// Class Element
+
Element::Element(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr)
{
graphPtr_ = graphPtr;
diff --git a/src/bltGrElem.h b/src/bltGrElem.h
index b863fb8..5b50542 100644
--- a/src/bltGrElem.h
+++ b/src/bltGrElem.h
@@ -84,6 +84,8 @@ namespace Blt {
public:
ElemValues();
virtual ~ElemValues();
+
+ void findRange();
};
typedef struct {
diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C
index 47bccde..379c909 100644
--- a/src/bltGrElemOption.C
+++ b/src/bltGrElemOption.C
@@ -51,7 +51,6 @@ using namespace Blt;
static void FreeDataValues(ElemValues* valuesPtr);
static void FreeVectorSource(ElemValues* valuesPtr);
-static void FindRange(ElemValues* valuesPtr);
static int GetPenStyleFromObj(Tcl_Interp* interp, Graph* graphPtr,
Tcl_Obj *objPtr, ClassId classId,
PenStyle *stylePtr);
@@ -111,7 +110,7 @@ static int ValuesSetProc(ClientData clientData, Tcl_Interp* interp,
return TCL_ERROR;
valuesPtr->values = values;
valuesPtr->nValues = nValues;
- FindRange(valuesPtr);
+ valuesPtr->findRange();
}
*valuesPtrPtr = valuesPtr;
@@ -219,8 +218,8 @@ static int PairsSetProc(ClientData clientData, Tcl_Interp* interp,
}
delete [] values;
- FindRange(coordsPtr->x);
- FindRange(coordsPtr->y);
+ coordsPtr->x->findRange();
+ coordsPtr->y->findRange();
return TCL_OK;
};
@@ -516,32 +515,4 @@ static void FreeDataValues(ElemValues* valuesPtr)
valuesPtr->max =0;
}
-static void FindRange(ElemValues* valuesPtr)
-{
- if (!valuesPtr || (valuesPtr->nValues < 1) || !valuesPtr->values)
- return;
-
- double* x = valuesPtr->values;
- double min = DBL_MAX;
- double max = -DBL_MAX;
- int ii;
- for(ii=0; ii<valuesPtr->nValues; ii++) {
- if (isfinite(x[ii])) {
- min = max = x[ii];
- break;
- }
- }
-
- // Initialize values to track the vector range
- for (/* empty */; ii<valuesPtr->nValues; ii++) {
- if (isfinite(x[ii])) {
- if (x[ii] < min)
- min = x[ii];
- else if (x[ii] > max)
- max = x[ii];
- }
- }
- valuesPtr->min = min;
- valuesPtr->max = max;
-}