Changeset 932


Ignore:
Timestamp:
Mar 10, 2008 3:40:26 PM (16 years ago)
Author:
gah
Message:

Initial implementation of axis autoscaling

Location:
trunk/vizservers/nanovis
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/vizservers/nanovis/AxisRange.h

    r929 r932  
    33
    44class AxisRange {
     5    double _min, _max;
    56public:
    6     enum Axes { X, Y, Z, VALUES };
    7     double min, max;
     7    AxisRange(void) {
     8        SetRange(0.0, 1.0);
     9    }
     10    void SetRange(double min, double max) {
     11        _min = min, _max = max;
     12    }
     13    double Min(void) {
     14        return _min;
     15    }
     16    double Max(void) {
     17        return _max;
     18    }
    819};
     20
    921#endif /*_AXIS_RANGE_H*/
  • trunk/vizservers/nanovis/Command.cpp

    r931 r932  
    228228}
    229229
    230 
    231 static int
    232 GetVolumeLimits(Tcl_Interp *interp, AxisRange *range)
    233 {
    234 
    235     /* Find the first volume. */
    236     int start;
    237     for (start = 0; start < NanoVis::n_volumes; start++) {
    238         if (NanoVis::volume[start] != NULL) {
    239             break;
    240         }
    241     }
    242     if (start == NanoVis::n_volumes) {
    243         Tcl_AppendResult(interp, "no volumes found", (char *)NULL);
    244         return TCL_ERROR;
    245     }
    246     int axis;
    247     for (axis = AxisRange::X; axis <= AxisRange::VALUES; axis++) {
    248         Volume *volPtr;
    249         int i;
    250 
    251         i = start;
    252         volPtr = NanoVis::volume[i];
    253         range[axis] = *volPtr->GetRange(axis);
    254         for (i++; i < NanoVis::n_volumes; i++) {
    255             const AxisRange *rangePtr;
    256 
    257             volPtr = NanoVis::volume[i];
    258             rangePtr = volPtr->GetRange(axis);
    259             if (range[axis].max < rangePtr->max) {
    260                 range[axis].max = rangePtr->max;
    261             }
    262             if (range[axis].min > rangePtr->min) {
    263                 range[axis].min = rangePtr->min;
    264             }
    265         }
    266     }
    267     return TCL_OK;
    268 }
    269 
    270 
    271230/*
    272231 * -----------------------------------------------------------------------
     
    334293        }
    335294    }
    336     HeightMap* hMap;
    337     hMap = new HeightMap();
    338     hMap->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights);
    339     hMap->setColorMap(NanoVis::get_transfunc("default"));
    340     hMap->setVisible(true);
    341     hMap->setLineContourVisible(true);
     295    HeightMap* hmPtr;
     296    hmPtr = new HeightMap();
     297    hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights);
     298    hmPtr->setColorMap(NanoVis::get_transfunc("default"));
     299    hmPtr->setVisible(true);
     300    hmPtr->setLineContourVisible(true);
    342301    delete [] heights;
    343     return hMap;
     302    return hmPtr;
    344303}
    345304
    346305/*
    347306 * ----------------------------------------------------------------------
    348  * FUNCTION: GetHeightMap
    349  *
    350  * Used internally to decode a series of volume index values and
    351  * store then in the specified vector.  If there are no volume index
    352  * arguments, this means "all volumes" to most commands, so all
    353  * active volume indices are stored in the vector.
    354  *
    355  * Updates pushes index values into the vector.  Returns TCL_OK or
    356  * TCL_ERROR to indicate an error.
     307 *
     308 * GetHeightMapIndex --
     309 *
    357310 * ----------------------------------------------------------------------
    358311 */
    359312static int
    360 GetHeightMap(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr)
    361 {
    362     int mapIndex;
    363     if (Tcl_GetIntFromObj(interp, objPtr, &mapIndex) != TCL_OK) {
    364         return TCL_ERROR;
    365     }
    366     if ((mapIndex < 0) || (mapIndex >= (int)NanoVis::heightMap.size()) ||
    367         (NanoVis::heightMap[mapIndex] == NULL)) {
    368         Tcl_AppendResult(interp, "invalid heightmap index \"",
    369                          Tcl_GetString(objPtr), "\"", (char *)NULL);
    370         return TCL_ERROR;
    371     }
    372     *hmPtrPtr = NanoVis::heightMap[mapIndex];
     313GetHeightMapIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, unsigned int *indexPtr)
     314{
     315    int index;
     316    if (Tcl_GetIntFromObj(interp, objPtr, &index) != TCL_OK) {
     317        return TCL_ERROR;
     318    }
     319    if (index < 0) {
     320        Tcl_AppendResult(interp, "can't have negative index \"",
     321                         Tcl_GetString(objPtr), "\"", (char*)NULL);
     322        return TCL_ERROR;
     323    }
     324    if (index >= (int)NanoVis::heightMap.size()) {
     325        Tcl_AppendResult(interp, "index \"", Tcl_GetString(objPtr),
     326                         "\" is out of range", (char*)NULL);
     327        return TCL_ERROR;
     328    }
     329    *indexPtr = (unsigned int)index;
     330    return TCL_OK;
     331}
     332
     333/*
     334 * ----------------------------------------------------------------------
     335 *
     336 * GetHeightMapFromObj --
     337 *
     338 * ----------------------------------------------------------------------
     339 */
     340static int
     341GetHeightMapFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr)
     342{
     343    unsigned int index;
     344    if (GetHeightMapIndex(interp, objPtr, &index) != TCL_OK) {
     345        return TCL_ERROR;
     346    }
     347    HeightMap *hmPtr;
     348    hmPtr = NanoVis::heightMap[index];
     349    if (hmPtr == NULL) {
     350        Tcl_AppendResult(interp, "no heightmap defined for index \"",
     351                         Tcl_GetString(objPtr), "\"", (char*)NULL);
     352        return TCL_ERROR;
     353    }
     354    *hmPtrPtr = hmPtr;
    373355    return TCL_OK;
    374356}
     
    477459}
    478460
    479 static int
    480 GetIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    481            vector<unsigned int>* vectorPtr)
    482 {
    483     for (int n = 0; n < objc; n++) {
    484         int index;
    485 
    486         if (Tcl_GetIntFromObj(interp, objv[n], &index) != TCL_OK) {
    487             return TCL_ERROR;
    488         }
    489         if (index < 0) {
    490             Tcl_AppendResult(interp, "can't have negative index \"",
    491                              Tcl_GetString(objv[n]), "\"", (char *)NULL);
    492             return TCL_ERROR;
    493         }
    494         vectorPtr->push_back((unsigned int)index);
    495     }
    496     return TCL_OK;
    497 }
    498 
    499 
    500461/*
    501462 * ----------------------------------------------------------------------
     
    528489                return TCL_ERROR;
    529490            }
    530             if (volPtr != NULL) {
    531                 vectorPtr->push_back(volPtr);
    532             }
     491            vectorPtr->push_back(volPtr);
     492        }
     493    }
     494    return TCL_OK;
     495}
     496
     497/*
     498 * ----------------------------------------------------------------------
     499 * FUNCTION: GetHeightMaps()
     500 *
     501 * Used internally to decode a series of volume index values and
     502 * store then in the specified vector.  If there are no volume index
     503 * arguments, this means "all volumes" to most commands, so all
     504 * active volume indices are stored in the vector.
     505 *
     506 * Updates pushes index values into the vector.  Returns TCL_OK or
     507 * TCL_ERROR to indicate an error.
     508 * ----------------------------------------------------------------------
     509 */
     510static int
     511GetHeightMaps(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
     512           vector<HeightMap *>* vectorPtr)
     513{
     514    if (objc == 0) {
     515        for (unsigned int n = 0; n < NanoVis::heightMap.size(); n++) {
     516            if (NanoVis::heightMap[n] != NULL) {
     517                vectorPtr->push_back(NanoVis::heightMap[n]);
     518            }
     519        }
     520    } else {
     521        for (int n = 0; n < objc; n++) {
     522            HeightMap *hmPtr;
     523
     524            if (GetHeightMapFromObj(interp, objv[n], &hmPtr) != TCL_OK) {
     525                return TCL_ERROR;
     526            }
     527            vectorPtr->push_back(hmPtr);
    533528        }
    534529    }
     
    555550        c = tolower((unsigned char)string[0]);
    556551        if (c == 'x') {
    557             *indexPtr = AxisRange::X;
     552            *indexPtr = 0;
    558553            return TCL_OK;
    559554        } else if (c == 'y') {
    560             *indexPtr = AxisRange::Y;
     555            *indexPtr = 1;
    561556            return TCL_OK;
    562557        } else if (c == 'z') {
    563             *indexPtr = AxisRange::Z;
     558            *indexPtr = 2;
    564559            return TCL_OK;
    565560        }
     
    787782      }
    788783      Texture2D* plane = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
    789       AxisRange *rangePtr;
    790       rangePtr = vol->GetRange(AxisRange::VALUES);
    791       NanoVis::color_table_renderer->render(1024, 1024, plane, tf, rangePtr->min,
    792                 rangePtr->max);
     784      NanoVis::color_table_renderer->render(1024, 1024, plane, tf, vol->wAxis.Min(),
     785                vol->wAxis.Max());
    793786      delete plane;
    794787   
     
    937930        return TCL_ERROR;
    938931    }
    939     AxisRange range[4];
    940     if (GetVolumeLimits(interp, range) != TCL_OK) {
    941         return TCL_ERROR;
    942     }
    943     NanoVis::render_legend(tf,
    944                            range[AxisRange::VALUES].min,
    945                            range[AxisRange::VALUES].max,
    946                            w, h, label);
     932    if (volPtr->update_pending) {
     933        NanoVis::SetVolumeRanges();
     934    }
     935    NanoVis::render_legend(tf, Volume::valueMin, Volume::valueMin, w, h, label);
    947936    return TCL_OK;
    948937}
     
    13501339        Volume *volPtr;
    13511340        char info[1024];
    1352         AxisRange overall[4];
    13531341       
    1354         if (GetVolumeLimits(interp, overall) != TCL_OK) {
    1355             return TCL_ERROR;
     1342        if (Volume::update_pending) {
     1343            NanoVis::SetVolumeRanges();
    13561344        }
    13571345        volPtr = NanoVis::volume[n];
    1358         const AxisRange *rangePtr;
    1359         rangePtr = volPtr->GetRange(AxisRange::VALUES);
    13601346        sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n",
    1361                 n, rangePtr->min, rangePtr->max,
    1362                 overall[AxisRange::VALUES].min,
    1363                 overall[AxisRange::VALUES].max);
     1347                n, volPtr->wAxis.Min(), volPtr->wAxis.Max(),
     1348                Volume::valueMin, Volume::valueMax);
    13641349        write(0, info, strlen(info));
    13651350    }
     
    16021587
    16031588    proc = Rappture::GetOpFromObj(interp, nVolumeShadingOps, volumeShadingOps,
    1604                                   Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1589        Rappture::CMDSPEC_ARG2, objc, objv, 0);
    16051590    if (proc == NULL) {
    16061591        return TCL_ERROR;
     
    17071692
    17081693    proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps,
    1709                                   Rappture::CMDSPEC_ARG1, objc, objv, 0);
     1694        Rappture::CMDSPEC_ARG1, objc, objv, 0);
    17101695    if (proc == NULL) {
    17111696        return TCL_ERROR;
     
    17211706    if (objc < 2) {
    17221707        Tcl_AppendResult(interp, "wrong # args: should be \"",
    1723                          Tcl_GetString(objv[0]), " option ?arg arg?", (char *)NULL);
     1708                Tcl_GetString(objv[0]), " option ?arg arg?", (char *)NULL);
    17241709        return TCL_ERROR;
    17251710    }
     
    17291714        if (objc != 3) {
    17301715            Tcl_AppendResult(interp, "wrong # args: should be \"",
    1731                              Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL);
     1716                Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL);
    17321717            return TCL_ERROR;
    17331718        }
    17341719        Volume *volPtr;
    1735         const AxisRange *rangePtr;
    1736 
    17371720        if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) {
    17381721            return TCL_ERROR;
    17391722        }
    1740         rangePtr = volPtr->GetRange(AxisRange::VALUES);
    17411723        if (NanoVis::particleRenderer != NULL) {
    17421724            NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f,
    17431725                volPtr->height / (float)volPtr->width,
    17441726                volPtr->depth  / (float)volPtr->width,
    1745                 rangePtr->max);
     1727                volPtr->wAxis.Max());
    17461728            NanoVis::initParticle();
    17471729        }
     
    17511733                1.0f / volPtr->aspect_ratio_height,
    17521734                1.0f / volPtr->aspect_ratio_depth,
    1753                 rangePtr->max);
     1735                volPtr->wAxis.Max());
    17541736            NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z);
    17551737        }
     
    17681750        if (objc < 3) {
    17691751            Tcl_AppendResult(interp, "wrong # args: should be \"",
    1770                              Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"",
    1771                              (char*)NULL);
     1752                Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"",
     1753                (char*)NULL);
    17721754            return TCL_ERROR;
    17731755        }
     
    19311913
    19321914                NanoVis::vol_renderer->add_volume(volPtr,
    1933                                                   NanoVis::get_transfunc("default"));
     1915                        NanoVis::get_transfunc("default"));
    19341916            }
    19351917        }
     
    19731955        return TCL_ERROR;
    19741956    }
    1975     vector<unsigned int> indices;
    1976     if (GetIndices(interp, objc - 4, objv + 4, &indices) != TCL_OK) {
    1977         return TCL_ERROR;
    1978     }
    1979     for (unsigned int i = 0; i < indices.size(); ++i) {
    1980         if ((indices[i] < NanoVis::heightMap.size()) &&
    1981             (NanoVis::heightMap[indices[i]] != NULL)) {
    1982             NanoVis::heightMap[indices[i]]->setVisible(visible);
    1983         }
     1957    vector<HeightMap *> imap;
     1958    if (GetHeightMaps(interp, objc - 4, objv + 4, &imap) != TCL_OK) {
     1959        return TCL_ERROR;
     1960    }
     1961    vector<HeightMap *>::iterator iter;
     1962    for (iter = imap.begin(); iter != imap.end(); iter++) {
     1963        (*iter)->setVisible(visible);
    19841964    }
    19851965    return TCL_OK;
     
    20151995        return TCL_ERROR;
    20161996    }           
    2017     vector<unsigned int> indices;
    2018     if (GetIndices(interp, objc-6, objv + 6, &indices) != TCL_OK) {
    2019         return TCL_ERROR;
    2020     }
    2021     for (unsigned int i = 0; i < indices.size(); ++i) {
    2022         if ((indices[i] < NanoVis::heightMap.size()) &&
    2023             (NanoVis::heightMap[indices[i]] != NULL)) {
    2024             NanoVis::heightMap[indices[i]]->setLineContourColor(rgb);
    2025         }
     1997    vector<HeightMap *> imap;
     1998    if (GetHeightMaps(interp, objc - 6, objv + 6, &imap) != TCL_OK) {
     1999        return TCL_ERROR;
     2000    }
     2001    vector<HeightMap *>::iterator iter;
     2002    for (iter = imap.begin(); iter != imap.end(); iter++) {
     2003        (*iter)->setLineContourColor(rgb);
    20262004    }
    20272005    return TCL_OK;
     
    20362014        return TCL_ERROR;
    20372015    }
    2038     vector<unsigned int> indices;
    2039     if (GetIndices(interp, objc-4, objv+4, &indices) != TCL_OK) {
    2040         return TCL_ERROR;
    2041     }
    2042     for (unsigned int i = 0; i < indices.size(); ++i) {
    2043         if ((indices[i] < NanoVis::heightMap.size()) &&
    2044             (NanoVis::heightMap[indices[i]] != NULL)) {
    2045             NanoVis::heightMap[indices[i]]->setLineContourVisible(visible);
    2046         }
     2016    vector<HeightMap *> imap;
     2017    if (GetHeightMaps(interp, objc - 4, objv + 4, &imap) != TCL_OK) {
     2018        return TCL_ERROR;
     2019    }
     2020    vector<HeightMap *>::iterator iter;
     2021    for (iter = imap.begin(); iter != imap.end(); iter++) {
     2022        (*iter)->setLineContourVisible(visible);
    20472023    }
    20482024    return TCL_OK;
     
    20622038
    20632039    proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps,
    2064                                   heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0);
     2040        heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0);
    20652041    if (proc == NULL) {
    20662042        return TCL_ERROR;
     
    20852061                  Tcl_Obj *CONST *objv)
    20862062{
    2087     HeightMap *hMap;
     2063    HeightMap *hmPtr;
    20882064   
    20892065    /* heightmap create xmin ymin xmax ymax xnum ynum values */
    2090     hMap = CreateHeightMap(cdata, interp, objc - 2, objv + 2);
    2091     if (hMap == NULL) {
    2092         return TCL_ERROR;
    2093     }
    2094     NanoVis::heightMap.push_back(hMap);
     2066    hmPtr = CreateHeightMap(cdata, interp, objc - 2, objv + 2);
     2067    if (hmPtr == NULL) {
     2068        return TCL_ERROR;
     2069    }
     2070    NanoVis::heightMap.push_back(hmPtr);
    20952071    Tcl_SetIntObj(Tcl_GetObjResult(interp), NanoVis::heightMap.size() - 1);;
    20962072    return TCL_OK;
     
    21012077                  Tcl_Obj *CONST *objv)
    21022078{
    2103     HeightMap *hMap;
    2104     if (GetHeightMap(interp, objv[2], &hMap) != TCL_OK) {
     2079    HeightMap *hmPtr;
     2080    if (GetHeightMapFromObj(interp, objv[2], &hmPtr) != TCL_OK) {
    21052081        return TCL_ERROR;
    21062082    }
    21072083    TransferFunction *tf;
    2108     tf = hMap->getColorMap();
     2084    tf = hmPtr->getColorMap();
    21092085    if (tf == NULL) {
    21102086        Tcl_AppendResult(interp, "no transfer function defined for heightmap \"",
     
    21172093        return TCL_ERROR;
    21182094    }
    2119     const AxisRange *rangePtr;
    2120     rangePtr = hMap->GetRange(AxisRange::VALUES);
    2121     NanoVis::render_legend(tf, rangePtr->min, rangePtr->max, w, h, "label");
     2095    if (HeightMap::update_pending) {
     2096        NanoVis::SetHeightmapRanges();
     2097    }
     2098    NanoVis::render_legend(tf, HeightMap::valueMin, HeightMap::valueMax, w, h,
     2099        "label");
    21222100    return TCL_OK;
    21232101}
     
    21362114
    21372115static int
    2138 HeightMapShadeOp(ClientData cdata, Tcl_Interp *interp, int objc,
     2116HeightMapShadingOp(ClientData cdata, Tcl_Interp *interp, int objc,
    21392117                 Tcl_Obj *CONST *objv)
    21402118{
     
    21652143    }
    21662144   
    2167     HeightMap* heightMap = new HeightMap();
     2145    HeightMap* hmPtr = new HeightMap();
    21682146    float minx = 0.0f;
    21692147    float maxx = 1.0f;
    21702148    float miny = 0.5f;
    21712149    float maxy = 3.5f;
    2172     heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data);
    2173     heightMap->setColorMap(NanoVis::get_transfunc("default"));
    2174     heightMap->setVisible(true);
    2175     heightMap->setLineContourVisible(true);
    2176     NanoVis::heightMap.push_back(heightMap);
    2177 
    2178 
    2179     const AxisRange *rangePtr;
    2180     rangePtr = heightMap->GetRange(AxisRange::VALUES);
    2181     Vector3 min(minx, (float)rangePtr->min, miny);
    2182     Vector3 max(maxx, (float)rangePtr->max, maxy);
    2183    
    2184     NanoVis::grid->setMinMax(min, max);
     2150    hmPtr->setHeight(minx, miny, maxx, maxy, 20, 200, data);
     2151    hmPtr->setColorMap(NanoVis::get_transfunc("default"));
     2152    hmPtr->setVisible(true);
     2153    hmPtr->setLineContourVisible(true);
    21852154    NanoVis::grid->setVisible(true);
    2186    
     2155    NanoVis::heightMap.push_back(hmPtr);
    21872156    return TCL_OK;
    21882157}
     
    22012170        return TCL_ERROR;
    22022171    }
    2203     vector<unsigned int> indices;
    2204     if (GetIndices(interp, objc - 3, objv + 3, &indices) != TCL_OK) {
    2205         return TCL_ERROR;
    2206     }
    2207     for (unsigned int i = 0; i < indices.size(); ++i) {
    2208         if ((indices[i] < NanoVis::heightMap.size()) &&
    2209             (NanoVis::heightMap[indices[i]] != NULL)) {
    2210             NanoVis::heightMap[indices[i]]->setColorMap(tf);
    2211         }
     2172    vector<HeightMap *> imap;
     2173    if (GetHeightMaps(interp, objc - 3, objv + 3, &imap) != TCL_OK) {
     2174        return TCL_ERROR;
     2175    }
     2176    vector<HeightMap *>::iterator iter;
     2177    for (iter = imap.begin(); iter != imap.end(); iter++) {
     2178        (*iter)->setColorMap(tf);
    22122179    }
    22132180    return TCL_OK;
     
    22222189    {"linecontour",  2, HeightMapLineContourOp, 2, 0, "oper ?args?",},
    22232190    {"polygon",      1, HeightMapPolygonOp,     3, 3, "mode",},
    2224     {"shade",        1, HeightMapShadeOp,       3, 3, "model",},
     2191    {"shading",      1, HeightMapShadingOp,     3, 3, "model",},
    22252192    {"test",         2, HeightMapTestOp,        2, 2, "",},
    22262193    {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?indices?",},
     
    22702237    }
    22712238    if (NanoVis::grid) {
     2239#ifdef notdef
    22722240        NanoVis::grid->setAxisName(axisId, Tcl_GetString(objv[3]));
     2241#endif
    22732242    }
    22742243    return TCL_OK;
     
    22902259    }           
    22912260    if (NanoVis::grid) {
    2292         NanoVis::grid->setGridLineColor(r, g, b, a);
    2293     }
    2294     return TCL_OK;
    2295 }
    2296 
    2297 static int
    2298 GridLineCountOp(ClientData cdata, Tcl_Interp *interp, int objc,
    2299                 Tcl_Obj *CONST *objv)
    2300 {
    2301     int x, y, z;
    2302    
    2303     if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) ||
    2304         (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) ||
    2305         (Tcl_GetIntFromObj(interp, objv[4], &z) != TCL_OK)) {
    2306         return TCL_ERROR;
    2307     }
    2308     if (NanoVis::grid) {
    2309         NanoVis::grid->setGridLineCount(x, y, z);
    2310     }
    2311     return TCL_OK;
    2312 }
    2313 
    2314 static int
    2315 GridMinMaxOp(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
    2316 {
    2317     double x1, y1, z1, x2, y2, z2;
    2318     if ((Tcl_GetDoubleFromObj(interp, objv[2], &x1) != TCL_OK) ||
    2319         (Tcl_GetDoubleFromObj(interp, objv[3], &y1) != TCL_OK) ||
    2320         (Tcl_GetDoubleFromObj(interp, objv[4], &z1) != TCL_OK) ||
    2321         (Tcl_GetDoubleFromObj(interp, objv[5], &x2) != TCL_OK) ||
    2322         (Tcl_GetDoubleFromObj(interp, objv[6], &y2) != TCL_OK) ||
    2323         (Tcl_GetDoubleFromObj(interp, objv[7], &z2) != TCL_OK)) {
    2324         return TCL_ERROR;
    2325     }
    2326     if (NanoVis::grid) {
    2327         NanoVis::grid->setMinMax(Vector3(x1, y1, z1), Vector3(x2, y2, z2));
     2261        NanoVis::grid->setLineColor(r, g, b, a);
    23282262    }
    23292263    return TCL_OK;
     
    23452279    {"axisname",   5, GridAxisNameOp,   5, 5, "index width height",},
    23462280    {"linecolor",  7, GridLineColorOp,  5, 6, "r g b ?a?",},
    2347     {"linecount",  7, GridLineCountOp,  5, 5, "xCount yCount zCount",},
    2348     {"minmax",     1, GridMinMaxOp,     8, 8, "xMin yMin zMin xMax yMax zMax",},
    23492281    {"visible",    1, GridVisibleOp,    3, 3, "bool",},
    23502282};
     
    25962528        return TCL_ERROR;
    25972529    }
    2598     HeightMap* hMap;
    2599     hMap = new HeightMap();
    2600     hMap->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, zValues);
    2601     hMap->setColorMap(NanoVis::get_transfunc("default"));
    2602     hMap->setVisible(true);
    2603     hMap->setLineContourVisible(true);
    2604     NanoVis::heightMap.push_back(hMap);
     2530    HeightMap* hmPtr;
     2531    hmPtr = new HeightMap();
     2532    hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, zValues);
     2533    hmPtr->setColorMap(NanoVis::get_transfunc("default"));
     2534    hmPtr->setVisible(true);
     2535    hmPtr->setLineContourVisible(true);
     2536    NanoVis::heightMap.push_back(hmPtr);
    26052537    delete [] zValues;
    26062538    return TCL_OK;
  • trunk/vizservers/nanovis/Grid.cpp

    r929 r932  
    33#include "Grid.h"
    44
     5#define NUMDIGITS       6
     6
    57Grid::Grid() :
    6     _axisColor(1.0f, 1.0f, 1.0f, 1.0f),
    7     _gridLineColor(1.0f, 1.0f, 1.0f, 1.0f),
    8     _axisMin(0.0f, 0.0f, 0.0f),
    9     _axisMax(1.0f, 1.0f, 1.0f),
    10     _axisGridLineCount(5.0f, 5.0f, 5.0f),
     8    _axisColor(1.0f, 1.0f, 1.0f, 1.0f),
     9    _majorColor(1.0f, 1.0f, 1.0f, 1.0f),
     10    _minorColor(0.7f, 0.7f, 0.7f, 1.0f),
    1111    _font(0),
    12     _visible(false)
     12    _visible(false),
     13    xAxis("X"),
     14    yAxis("Y"),
     15    zAxis("Z")
    1316{
    14     __axisScale = _axisMax - _axisMin;
    15     _axisName[0] = "X";
    16     _axisName[1] = "Y";
    17     _axisName[2] = "Z";
     17    /*empty*/
    1818}
    1919
     
    2222    glPushMatrix();
    2323    glEnable(GL_DEPTH_TEST);
    24     glEnable(GL_BLEND);
    25 
    26     glScalef(1.0 / __axisScale.x, __axisScale.y / __axisScale.x, __axisScale.z / __axisScale.x);
     24#ifdef notdef
     25    glEnable(GL_LINE_SMOOTH);
     26#endif
     27#ifdef notdef
     28    glScalef(xAxis.Scale(),
     29             yAxis.Range() / xAxis.Range(),
     30             zAxis.Range() / xAxis.Range());
     31#endif
     32    glScalef(1.0, 1.0, 1.0);
    2733
    2834    glTranslatef(-0.5f, -0.5f, -0.5f);
    29     glDisable(GL_TEXTURE_2D);
    3035    glLineWidth(2.0f);
    31     glColor4f(_axisColor.x, _axisColor.y, _axisColor.z, _axisColor.w);
    32     //glColor3f(_axisColor.x, _axisColor.y, _axisColor.z);
     36    glColor4f(_axisColor.red, _axisColor.green, _axisColor.blue,
     37              _axisColor.alpha);
    3338
    3439    glBegin(GL_LINES);
    3540    {
    36         glVertex3f(0.0f,0.0f,0.0f);
    37         glVertex3f(1.2f,0.0f,0.0f);
    38         glVertex3f(0.0f,0.0f,0.0f);
    39         glVertex3f(0.0f,1.2f,0.0f);
    4041        glVertex3f(0.0f, 0.0f, 0.0f);
    41         glVertex3f(0.0f, 0.0f, 1.2f);
     42        glVertex3f(1.15f, 0.0f, 0.0f);
     43        glVertex3f(0.0f, 0.0f, 0.0f);
     44        glVertex3f(0.0f, 1.15f, 0.0f);
     45        glVertex3f(0.0f, 0.0f, 0.0f);
     46        glVertex3f(0.0f, 0.0f, 1.15f);
    4247    }
    4348    glEnd();
    4449
     50    glDisable(GL_TEXTURE_2D);
    4551    glLineWidth(1.0f);
    46     glColor4f(_gridLineColor.x, _gridLineColor.y, _gridLineColor.z, _gridLineColor.w);
     52    glEnable(GL_BLEND);
     53    glColor4f(_majorColor.red, _majorColor.green, _majorColor.blue,
     54              _majorColor.alpha);
     55
    4756    glBegin(GL_LINES);
    48 
    49     // +y
    50     for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) {
    51         glVertex3f(0.0f, i / _axisGridLineCount.y, 0.0f);
    52         glVertex3f(1.1f, i / _axisGridLineCount.y, 0.0f);
    53     }
    54    
    55     for (int i = 1; i <= (int) _axisGridLineCount.x; ++i) {
    56         glVertex3f(i / _axisGridLineCount.x, 0.0f, 0.0f);
    57         glVertex3f(i / _axisGridLineCount.x, 1.0f, 0.0f);
    58     }
    59    
    60     for (int i = 1; i <= (int) _axisGridLineCount.z; ++i) {
    61         glVertex3f(0.0f, 0.0f, i / _axisGridLineCount.z);
    62         glVertex3f(0.0f, 1.0f, i / _axisGridLineCount.z);
    63     }
    64    
    65     for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) {
    66         glVertex3f(0.0f, i / _axisGridLineCount.y, 0.0f);
    67         glVertex3f(0.0f, i / _axisGridLineCount.y, 1.0f);
    68     }
    69    
    70     for (int i = 1; i <= (int) _axisGridLineCount.x; ++i) {
    71         glVertex3f(i / _axisGridLineCount.x,0.0f, 0.0f);
    72         glVertex3f(i / _axisGridLineCount.x,0.0f, 1.1f);
    73     }
    74    
    75     for (int i = 1; i <= (int) _axisGridLineCount.z; ++i) {
    76         glVertex3f(0.0f, 0.0f, i / _axisGridLineCount.z);
    77         glVertex3f(1.1f, 0.0f, i / _axisGridLineCount.z);
     57    {
     58        bool result;
     59        TickIter iter;
     60
     61        for (result = xAxis.FirstMajor(iter); result; result = iter.Next()) {
     62            float x;
     63            x = xAxis.Map(iter.GetValue());
     64            glVertex3f(x, 0.0f, 0.0f);
     65            glVertex3f(x, 1.0f, 0.0f);
     66            glVertex3f(x, 0.0f, 0.0f);
     67            glVertex3f(x, 0.0f, 1.1f);
     68        }
     69        for (result = yAxis.FirstMajor(iter); result; result = iter.Next()) {
     70            float y;
     71            y = yAxis.Map(iter.GetValue());
     72            glVertex3f(0.0f, y, 0.0f);
     73            glVertex3f(1.1f, y, 0.0f);
     74            glVertex3f(0.0f, y, 0.0f);
     75            glVertex3f(0.0f, y, 1.0f);
     76        }
     77        for (result = zAxis.FirstMajor(iter); result; result = iter.Next()) {
     78            float z;
     79            z = zAxis.Map(iter.GetValue());
     80            glVertex3f(0.0f, 0.0f, z);
     81            glVertex3f(0.0f, 1.0f, z);
     82            glVertex3f(0.0f, 0.0f, z);
     83            glVertex3f(1.1f, 0.0f, z);
     84        }
    7885    }
    7986    glEnd();
    8087
    81     if (_font) {
     88    // Set minor line color
     89    glColor4f(_minorColor.red, _minorColor.green, _minorColor.blue,
     90              _minorColor.alpha);
     91
     92    glBegin(GL_LINES);
     93    {
     94        bool result;
     95        TickIter iter;
     96
     97        for (result = xAxis.FirstMinor(iter); result; result = iter.Next()) {
     98            float x;
     99            x = xAxis.Map(iter.GetValue());
     100            glVertex3f(x, 0.0f, 0.0f);
     101            glVertex3f(x, 1.0f, 0.0f);
     102            glVertex3f(x, 0.0f, 0.0f);
     103            glVertex3f(x, 0.0f, 1.0f);
     104        }
     105        for (result = yAxis.FirstMinor(iter); result; result = iter.Next()) {
     106            float y;
     107            y = yAxis.Map(iter.GetValue());
     108            glVertex3f(0.0f, y, 0.0f);
     109            glVertex3f(1.0f, y, 0.0f);
     110            glVertex3f(0.0f, y, 0.0f);
     111            glVertex3f(0.0f, y, 1.0f);
     112        }
     113        for (result = zAxis.FirstMinor(iter); result; result = iter.Next()) {
     114            float z;
     115            z = zAxis.Map(iter.GetValue());
     116            glVertex3f(0.0f, 0.0f, z);
     117            glVertex3f(0.0f, 1.0f, z);
     118            glVertex3f(0.0f, 0.0f, z);
     119            glVertex3f(1.0f, 0.0f, z);
     120        }
     121    }
     122    glEnd();
     123
     124    if (_font != NULL) {
    82125        double mv[16], prjm[16];
    83126        int viewport[4];
    84         double winx, winy, winz;
     127        double wx, wy, wz;
     128        bool result;
     129        TickIter iter;
     130
    85131        glGetDoublev(GL_MODELVIEW_MATRIX, mv);
    86132        glGetDoublev(GL_PROJECTION_MATRIX, prjm);
    87133        glGetIntegerv(GL_VIEWPORT, viewport);
    88134       
    89        
    90135        _font->begin();
    91         if (gluProject(1.2, 0.0, 0.0, mv, prjm, viewport, &winx, &winy,
    92                        &winz)) {
     136        if (gluProject(1.2, 0.0, 0.0, mv, prjm, viewport, &wx, &wy, &wz)) {
    93137            glLoadIdentity();
    94             glTranslatef((int) winx, viewport[3] - (int) winy, 0);
    95             _font->draw((const char*) _axisName[0]);
    96         }
    97        
    98         if (gluProject(0.0, 1.2, 0.0, mv, prjm, viewport, &winx, &winy,
    99                        &winz)) {
     138            glTranslatef((int) wx, viewport[3] - (int) wy, 0);
     139            _font->draw(xAxis.GetName());
     140        }
     141       
     142        if (gluProject(0.0, 1.2, 0.0, mv, prjm, viewport, &wx, &wy, &wz)) {
    100143            glLoadIdentity();
    101             glTranslatef((int) winx, viewport[3] - (int)winy, 0);
    102             _font->draw((const char*) _axisName[1]);
    103         }
    104        
    105         if (gluProject(0.0, 0.0, 1.2, mv, prjm, viewport, &winx, &winy,
    106                        &winz)) {
     144            glTranslatef((int) wx, viewport[3] - (int)wy, 0);
     145            _font->draw(yAxis.GetName());
     146        }
     147       
     148        if (gluProject(0.0, 0.0, 1.2, mv, prjm, viewport, &wx, &wy, &wz)) {
    107149            glLoadIdentity();
    108             glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
    109             _font->draw((const char*) _axisName[2]);
    110         }
    111        
    112         glColor4f(1.0f, 1.0f, 0.0f, 0.5f);
    113         char buff[20];
    114         // Y
    115         for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) {
    116             if (gluProject(1.2, i / _axisGridLineCount.y, 0.0f, mv, prjm, viewport, &winx, &winy, &winz)) {
     150            glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
     151            _font->draw(zAxis.GetName());
     152        }
     153       
     154        glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
     155
     156        for (result = xAxis.FirstMajor(iter); result; result = iter.Next()) {
     157            float x;
     158            x = xAxis.Map(iter.GetValue());
     159            if (gluProject(x, 0.0f, 1.11f, mv, prjm, viewport, &wx, &wy, &wz)) {
     160                char buff[20];
    117161                glLoadIdentity();
    118                 glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
    119                 sprintf(buff, "%0.2f", __axisScale.y / _axisGridLineCount.y * i + _axisMin.y);
     162                glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
     163                sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue());
    120164                _font->draw(buff);
    121165            }
    122166        }
    123        
    124         for (int i = 1; i <= (int) _axisGridLineCount.z; ++i) {
    125             if (gluProject(1.2, 0.0, i / _axisGridLineCount.z , mv, prjm, viewport, &winx, &winy, &winz)) {
     167        for (result = yAxis.FirstMajor(iter); result; result = iter.Next()) {
     168            float y;
     169            y = yAxis.Map(iter.GetValue());
     170            if (gluProject(1.11f, y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz)) {
     171                char buff[20];
    126172                glLoadIdentity();
    127                 glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
    128                 sprintf(buff, "%0.2f", __axisScale.z / _axisGridLineCount.z * i + _axisMin.z);
     173                glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
     174                sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue());
    129175                _font->draw(buff);
    130176            }
    131177        }
    132        
    133         for (int i = 1; i <= (int) _axisGridLineCount.x; ++i) {
    134             if (gluProject( i / _axisGridLineCount.x, 0.0f, 1.2, mv, prjm, viewport, &winx, &winy, &winz)) {
     178        for (result = zAxis.FirstMajor(iter); result; result = iter.Next()) {
     179            float z;
     180            z = zAxis.Map(iter.GetValue());
     181            if (gluProject(1.11f, 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz)) {
     182                char buff[20];
    135183                glLoadIdentity();
    136                 glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f);
    137                 sprintf(buff, "%0.2f", __axisScale.x / _axisGridLineCount.x * i + _axisMin.x);
     184                glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f);
     185                sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue());
    138186                _font->draw(buff);
    139187            }
    140188        }
    141        
    142189        _font->end();
    143190    };
    144    
    145191    glPopMatrix();
    146192    glDisable(GL_DEPTH_TEST);
    147193    glDisable(GL_BLEND);
     194#ifdef notdef
     195    glDisable(GL_LINE_SMOOTH);
     196#endif
    148197}
    149198 
     
    156205    _font = font;
    157206}
     207
  • trunk/vizservers/nanovis/Grid.h

    r929 r932  
    33
    44#include <R2/R2Fonts.h>
    5 #include "Vector3.h"
    6 #include "Vector4.h"
     5#include "Axis.h"
     6#include "AxisRange.h"
     7
     8class RGBA {
     9public:
     10    float red, green, blue, alpha;
     11    RGBA(float r, float g, float b, float a) :
     12        red(r), green(g), blue(b), alpha(a)
     13    { /*empty*/ }
     14    void SetColor(float r, float g, float b, float a) {
     15        red   = r;
     16        green = g;
     17        blue  = b;
     18        alpha = a;
     19    }
     20};
    721
    822class Grid {
    9     Vector3 __axisScale;
    10    
    11     Vector4 _axisColor;
    12     Vector4 _gridLineColor;
    13     Vector3 _axisMin;
    14     Vector3 _axisMax;
    15     Vector3 _axisGridLineCount;
     23    RGBA _axisColor, _majorColor, _minorColor;
    1624    R2Fonts* _font;
    1725    bool _visible;
    18    
    19     R2string _axisName[3];
    2026
    2127public :
     28    Axis xAxis;
     29    Axis yAxis;
     30    Axis zAxis;
     31
    2232    Grid();
    23 public :
    24     bool isVisible() const;
     33    bool isVisible() const {
     34        return _visible;
     35    }
    2536    void render();
    26    
    27     void setMin(const Vector3& min);
    28     void setMax(const Vector3& max);
    2937   
    3038    void setFont(R2Fonts* font);
    3139    void setVisible(bool visible);
    32    
    33     void setGridLineCount(int x, int y, int z);
    3440    void setAxisColor(float r, float g, float b, float a);
    35     void setGridLineColor(float r, float g, float b, float a);
    36     void setMinMax(const Vector3& min, const Vector3& max);
    37     void setAxisName(int axisID, const char* name);
     41    void setLineColor(float r, float g, float b, float a);
    3842};
    39 
    40 inline bool Grid::isVisible() const
    41 {
    42     return _visible;
    43 }
    44 
    45 inline void Grid::setMin(const Vector3& min)
    46 {
    47     _axisMin = min;
    48     __axisScale = _axisMax - _axisMin;
    49 }
    50 
    51 inline void Grid::setMax(const Vector3& max)
    52 {
    53     _axisMax = max;
    54     __axisScale = _axisMax - _axisMin;
    55 }
    5643
    5744inline void Grid::setVisible(bool visible)
     
    6047}
    6148
    62 inline void Grid::setGridLineCount(int x, int y, int z)
     49inline void Grid::setAxisColor(float r, float g, float b, float a)
    6350{
    64     _axisGridLineCount.x = x;
    65     _axisGridLineCount.y = y;
    66     _axisGridLineCount.z = z;
     51    _axisColor.SetColor(r, g, b, a);
    6752}
    6853
    69 inline void Grid::setAxisColor(float r, float g, float b, float a)
     54inline void Grid::setLineColor(float r, float g, float b, float a)
    7055{
    71     _axisColor.x = r;
    72     _axisColor.y = g;
    73     _axisColor.z = b;
    74     _axisColor.w = a;
     56    _majorColor.SetColor(r, g, b, a);
     57    _minorColor = _majorColor;
    7558}
    7659
    77 inline void Grid::setGridLineColor(float r, float g, float b, float a)
    78 {
    79     _gridLineColor.x = r;
    80     _gridLineColor.y = g;
    81     _gridLineColor.z = b;
    82     _gridLineColor.w = a;
    83 }
    84 
    85 inline void Grid::setMinMax(const Vector3& min, const Vector3& max)
    86 {
    87     _axisMin = min;
    88     _axisMax = max;
    89     __axisScale.x = _axisMax.x - _axisMin.x;
    90     __axisScale.y = _axisMax.y - _axisMin.y;
    91     __axisScale.z = _axisMax.z - _axisMin.z;
    92 }
    93 
    94 inline void Grid::setAxisName(int axisID, const char* name)
    95 {
    96     if (axisID >= 0 && axisID < 3) {
    97         _axisName[axisID] = name;
    98     }
    99 }
    100 
    101 
    10260#endif
  • trunk/vizservers/nanovis/HeightMap.cpp

    r929 r932  
    1616#include <RenderContext.h>
    1717
     18bool HeightMap::update_pending = false;
     19double HeightMap::valueMin = 0.0;
     20double HeightMap::valueMax = 1.0;
     21
    1822HeightMap::HeightMap() :
    1923    _vertexBufferObjectID(0),
     
    6670    glPushMatrix();
    6771
    68     if (_scale.x != 0) {
     72    if (_scale.x != 0.0) {
    6973        glScalef(1 / _scale.x, 1 / _scale.x , 1 / _scale.x);
    7074    }
     
    133137}
    134138
    135 void HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights)
     139void
     140HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer,
     141                             int& indexCount, float* heights)
    136142{
    137143    indexCount = (xCount - 1) * (zCount - 1) * 6;
     
    188194}
    189195
    190 void HeightMap::reset()
     196void
     197HeightMap::reset()
    191198{
    192199    if (_vertexBufferObjectID) {
     
    207214}
    208215
    209 void HeightMap::setHeight(int xCount, int yCount, Vector3* heights)
     216void
     217HeightMap::setHeight(int xCount, int yCount, Vector3* heights)
    210218{
    211219    _vertexCount = xCount * yCount;
     
    229237    _scale.y = 1.0f;
    230238
    231     SetRange(AxisRange::VALUES, min, max);
    232     SetRange(AxisRange::X, 0.0, 1.0);
    233     SetRange(AxisRange::Y, 0.0, 1.0);
    234     SetRange(AxisRange::Z, min, max);
    235 
     239    xAxis.SetRange(0.0, 1.0);
     240    yAxis.SetRange(0.0, 1.0);
     241    zAxis.SetRange(0.0, 1.0);
     242    wAxis.SetRange(min, max);
     243    update_pending = true;
     244   
    236245    _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5);
    237246
     
    294303    _scale.z = endY - startY;
    295304
    296     SetRange(AxisRange::VALUES, min, max);
    297     SetRange(AxisRange::X, startX, endX);
    298     SetRange(AxisRange::Y, min, max);
    299     SetRange(AxisRange::Z, startY, endY);
     305    wAxis.SetRange(min, max);
     306    xAxis.SetRange(startX, endX);
     307    yAxis.SetRange(min, max);
     308    zAxis.SetRange(startY, endY);
     309    update_pending = true;
    300310
    301311    _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + min,
  • trunk/vizservers/nanovis/HeightMap.h

    r929 r932  
    3838    Vector3 _centerPoint;
    3939
    40     AxisRange _ranges[4];
    4140public :
     41    AxisRange xAxis, yAxis, zAxis, wAxis;
     42    static bool update_pending;
     43    static double valueMin, valueMax;
     44
    4245    /**
    4346     *@brief Constructor
     
    113116        _contourColor.z = rgb[2];
    114117    }
    115 
    116     void SetRange(int axis, double min, double max) {
    117         _ranges[axis].min = min;
    118         _ranges[axis].max = max;
    119     }
    120     const AxisRange *GetRange(int axis) {
    121         return _ranges + axis;
    122     }
    123118};
    124119
  • trunk/vizservers/nanovis/RpDX.cpp

    r931 r932  
    1616#include "RpDX.h"
    1717#include <math.h>
    18 
    19 #ifdef __cplusplus
    20     extern "C" {
    21 #endif // ifdex __cplusplus
     18#include <stdio.h>
     19#include <stdlib.h>
    2220
    2321using namespace Rappture;
    2422
    25 DX::DX(const char* filename)
    26     : _dataMin(0),
    27       _dataMax(0),
    28       _nzero_min(0),
    29       _numAxis(0),
    30       _axisLen(NULL),
    31       _data(NULL),
    32       _n(0),
    33       _rank(0),
    34       _shape(0),
    35       _positions(NULL),
    36       _delta(NULL),
    37       _max(NULL),
    38       _origin(NULL)
     23DX::DX(const char* filename) :
     24    _dataMin(0),
     25    _dataMax(0),
     26    _nzero_min(0),
     27    _numAxis(0),
     28    _axisLen(NULL),
     29    _data(NULL),
     30    _n(0),
     31    _rank(0),
     32    _shape(0),
     33    _positions(NULL),
     34    _delta(NULL),
     35    _max(NULL),
     36    _origin(NULL)
    3937{
    4038    Array dxarr;
     
    4442    Category category;
    4543    Type type;
    46 
     44   
    4745    if (filename == NULL) {
    4846        // error
    4947    }
    50 
     48   
    5149    // open the file with libdx
    5250    fprintf(stdout, "Calling DXImportDX(%s)\n", filename);
     
    271269}
    272270
    273 #ifdef __cplusplus
    274     }
    275 #endif // ifdef __cplusplus
     271
     272
  • trunk/vizservers/nanovis/Volume.cpp

    r929 r932  
    1818#include "Trace.h"
    1919
     20bool Volume::update_pending = false;
     21double Volume::valueMin = 0.0;
     22double Volume::valueMax = 1.0;
    2023
    2124Volume::Volume(float x, float y, float z,
     
    4548    int fcount = width * height * depth * n_components;
    4649    _data = new float[fcount];
    47     if (data)
    48     {
     50    if (data) {
    4951        Trace("data is copied\n");
    5052        memcpy(_data, data, fcount * sizeof(float));
    5153        tex->initialize(_data);
    52     }
    53     else
    54     {
     54    } else {
    5555        Trace("data is null\n");
    56         memset(_data, 0x00, sizeof(width *height* depth * n_components *sizeof(float)));
     56        memset(_data, 0, sizeof(width * height * depth * n_components *
     57                                sizeof(float)));
    5758        tex->initialize(_data);
    58 
    5959    }
    6060
    6161    id = tex->id;
    6262   
    63     SetRange(AxisRange::VALUES, v0, v1);
     63    wAxis.SetRange(v0, v1);
    6464
    6565    aspect_ratio_width = s*tex->aspect_ratio_width;
  • trunk/vizservers/nanovis/Volume.h

    r929 r932  
    5555                                // render engine.
    5656
     57    AxisRange xAxis, yAxis, zAxis, wAxis;
     58    static bool update_pending;
     59    static double valueMin, valueMax;
    5760
    5861    int n_components;
    59 
    60     AxisRange _ranges[4];       // min/max for each axis
    6162
    6263    double nonzero_min;
     
    152153    void get_outline_color(float* rgb);
    153154   
    154     void SetRange(int axis, double min, double max);
    155     const AxisRange *GetRange(int axis);
    156155    void set_label(int axis, const char* txt); // change the label displayed
    157156                                               // on an axis
     
    331330}
    332331
    333 inline void
    334 Volume::SetRange(int axis, double min, double max)
    335 {
    336     _ranges[axis].min = min;
    337     _ranges[axis].max = max;
    338 }
    339 
    340 inline const AxisRange *
    341 Volume::GetRange(int axis)
    342 {
    343     return _ranges + axis;
    344 }
    345 
    346332inline int
    347333Volume::get_isosurface() const
  • trunk/vizservers/nanovis/VolumeInterpolator.cpp

    r929 r932  
    146146                             volume->n_components,
    147147                             volume->_data,
    148                              volume->_ranges[AxisRange::VALUES].min,
    149                              volume->_ranges[AxisRange::VALUES].max,
     148                             volume->wAxis.Min(),
     149                             volume->wAxis.Max(),
    150150                             volume->nonzero_min);
    151151        _referenceOfVolume = volumeId;
  • trunk/vizservers/nanovis/dxReader.cpp

    r931 r932  
    194194        volPtr = NanoVis::load_volume(index, nx, ny, nz, 3, data, vmin, vmax,
    195195                    nzero_min);
    196         volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx));
    197         volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy));
    198         volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz));
     196
     197        volPtr->xAxis.SetRange(x0, x0 + (nx * ddx));
     198        volPtr->yAxis.SetRange(y0, y0 + (ny * ddy));
     199        volPtr->zAxis.SetRange(z0, z0 + (nz * ddz));
     200        volPtr->wAxis.SetRange(y0, y0 + (ny * ddy));
     201        volPtr->update_pending = true;
    199202        delete [] data;
    200203    } else {
     
    443446            Volume *volPtr;
    444447            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    445                                           vmin, vmax, nzero_min);
    446             volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx));
    447             volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy));
    448             volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz));
     448                                          vmin, vmax, nzero_min);
     449            fprintf(stderr, "x nx=%d ddx=%g min=%g max=%g\n", nx, ddx,
     450                    x0, x0 + (nx * ddx));
     451            fflush(stderr);
     452#ifdef notdef
     453            volPtr->xAxis.SetRange(x0, x0 + (nx * ddx));
     454            volPtr->yAxis.SetRange(y0, y0 + (ny * ddy));
     455            volPtr->zAxis.SetRange(z0, z0 + (nz * ddz));
     456#endif
     457            volPtr->xAxis.SetRange(-20.0, 108.0);
     458            volPtr->yAxis.SetRange(0.001, 102.2);
     459            volPtr->zAxis.SetRange(-21, 19);
     460            volPtr->update_pending = true;
    449461            delete [] data;
    450462
     
    576588            Volume *volPtr;
    577589            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    578             field.valueMin(), field.valueMax(), nzero_min);
    579             volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis),
    580                    field.rangeMax(Rappture::xaxis));
    581             volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis),
    582                    field.rangeMax(Rappture::yaxis));
    583             volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis),
    584                    field.rangeMax(Rappture::zaxis));
     590                field.valueMin(), field.valueMax(), nzero_min);
     591            fprintf(stderr, "x min=%g max=%g\n",
     592                    field.rangeMin(Rappture::xaxis),
     593                    field.rangeMax(Rappture::xaxis));
     594            fflush(stderr);
     595            volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis),
     596                               field.rangeMax(Rappture::xaxis));
     597            volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis),
     598                               field.rangeMax(Rappture::yaxis));
     599            volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis),
     600                               field.rangeMax(Rappture::zaxis));
     601            volPtr->update_pending = true;
    585602            delete [] data;
    586603        }
     
    733750                    int nindex = iz*nx*ny + iy*nx + ix;
    734751                    field.define(nindex, dval[p]);
    735                     fprintf(stdout,"nindex = %i\tdval[%i] = %lg\n",nindex,p,dval[p]);
    736                     fflush(stdout);
     752                    fprintf(stderr,"nindex = %i\tdval[%i] = %lg\n", nindex, p,
     753                            dval[p]);
     754                    fflush(stderr);
    737755                    nread++;
    738756                    if (++iz >= nz) {
     
    800818
    801819            for (int i=0; i<nx*ny*nz; i++) {
    802                 fprintf(stdout,"enddata[%i] = %lg\n",i,data[i]);
    803                 fflush(stdout);
     820                fprintf(stderr,"enddata[%i] = %lg\n",i,data[i]);
     821                fflush(stderr);
    804822            }
    805823            // Compute the gradient of this data.  BE CAREFUL: center
     
    879897            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    880898            field.valueMin(), field.valueMax(), nzero_min);
    881             volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis),
    882                        field.rangeMax(Rappture::xaxis));
    883             volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis),
    884                        field.rangeMax(Rappture::yaxis));
    885             volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis),
    886                        field.rangeMax(Rappture::zaxis));
     899            volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis),
     900                               field.rangeMax(Rappture::xaxis));
     901            volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis),
     902                               field.rangeMax(Rappture::yaxis));
     903            volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis),
     904                               field.rangeMax(Rappture::zaxis));
     905            volPtr->update_pending = true;
    887906            // TBD..
    888907            // POINTSET
     
    10251044            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    10261045            field.valueMin(), field.valueMax(), nzero_min);
    1027             volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis),
    1028                        field.rangeMax(Rappture::xaxis));
    1029             volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis),
    1030                        field.rangeMax(Rappture::yaxis));
    1031             volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis),
    1032                        field.rangeMax(Rappture::zaxis));
    1033 
     1046            volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis),
     1047                               field.rangeMax(Rappture::xaxis));
     1048            volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis),
     1049                               field.rangeMax(Rappture::yaxis));
     1050            volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis),
     1051                               field.rangeMax(Rappture::zaxis));
     1052            volPtr->update_pending = true;
    10341053            // TBD..
    10351054            // POINTSET
  • trunk/vizservers/nanovis/dxReader2.cpp

    r931 r932  
    11
     2#include "RpDX.h"
    23#include "dxReaderCommon.h"
    34
  • trunk/vizservers/nanovis/dxReaderCommon.h

    r931 r932  
    1 #include "RpDX.h"
     1#ifndef _DX_READER_COMMON_H
     2#define _DX_READER_COMMON_H
     3
    24
    35float* merge(float* scalar, float* gradient, int size);
    46void normalizeScalar(float* fdata, int count, float min, float max);
    5 float* computeGradient(float* fdata, int width, int height, int depth, float min, float max);
     7float* computeGradient(float* fdata, int width, int height, int depth,
     8        float min, float max);
     9
     10#endif /*_DX_READER_COMMON_H*/
  • trunk/vizservers/nanovis/nanovis.cpp

    r927 r932  
    100100bool NanoVis::particle_on = false;
    101101bool NanoVis::vector_on = false;
     102bool NanoVis::config_pending = false;
    102103
    103104// pointers to volumes, currently handle up to 10 volumes
     
    625626    NvShader::setErrorCallback(CgErrorCallback);
    626627
    627 /*
    628628    fonts = new R2Fonts();
    629629    fonts->addFont("verdana", "verdana.fnt");
    630630    fonts->setFont("verdana");
    631 */
    632631
    633632    color_table_renderer = new NvColorTableRenderer();
     
    988987      nanosleep(&ts, 0);
    989988#endif
    990    
    991989#ifdef XINETD
    992990    xinetd_listen();
     
    10121010    glColor3f(1.,1.,1.);                //MUST HAVE THIS LINE!!!
    10131011    glBegin(GL_QUADS);
    1014     glTexCoord2f(0, 0); glVertex2f(0, 0);
    1015     glTexCoord2f(1, 0); glVertex2f(win_width, 0);
    1016     glTexCoord2f(1, 1); glVertex2f(win_width, win_height);
    1017     glTexCoord2f(0, 1); glVertex2f(0, win_height);
     1012    {
     1013        glTexCoord2f(0, 0); glVertex2f(0, 0);
     1014        glTexCoord2f(1, 0); glVertex2f(win_width, 0);
     1015        glTexCoord2f(1, 1); glVertex2f(win_width, win_height);
     1016        glTexCoord2f(0, 1); glVertex2f(0, win_height);
     1017    }
    10181018    glEnd();
    10191019}
     
    10351035{
    10361036    glDisable(GL_TEXTURE_2D);
    1037    
    10381037    glColor4d(r, g, b, 1.0);
    10391038    glLineWidth(line_width);
    1040    
    10411039    glBegin(GL_LINE_LOOP);
    1042    
    1043     glVertex3d(x0, y0, z0);
    1044     glVertex3d(x1, y0, z0);
    1045     glVertex3d(x1, y1, z0);
    1046     glVertex3d(x0, y1, z0);
    1047    
     1040    {
     1041        glVertex3d(x0, y0, z0);
     1042        glVertex3d(x1, y0, z0);
     1043        glVertex3d(x1, y1, z0);
     1044        glVertex3d(x0, y1, z0);
     1045    }
    10481046    glEnd();
    1049    
    10501047    glBegin(GL_LINE_LOOP);
    1051    
    1052     glVertex3d(x0, y0, z1);
    1053     glVertex3d(x1, y0, z1);
    1054     glVertex3d(x1, y1, z1);
    1055     glVertex3d(x0, y1, z1);
    1056    
     1048    {
     1049        glVertex3d(x0, y0, z1);
     1050        glVertex3d(x1, y0, z1);
     1051        glVertex3d(x1, y1, z1);
     1052        glVertex3d(x0, y1, z1);
     1053    }
    10571054    glEnd();
    1058    
    1059    
    10601055    glBegin(GL_LINE_LOOP);
    1061    
    1062     glVertex3d(x0, y0, z0);
    1063     glVertex3d(x0, y0, z1);
    1064     glVertex3d(x0, y1, z1);
    1065     glVertex3d(x0, y1, z0);
    1066    
     1056    {
     1057        glVertex3d(x0, y0, z0);
     1058        glVertex3d(x0, y0, z1);
     1059        glVertex3d(x0, y1, z1);
     1060        glVertex3d(x0, y1, z0);
     1061    }
    10671062    glEnd();
    1068    
    10691063    glBegin(GL_LINE_LOOP);
    1070    
    1071     glVertex3d(x1, y0, z0);
    1072     glVertex3d(x1, y0, z1);
    1073     glVertex3d(x1, y1, z1);
    1074     glVertex3d(x1, y1, z0);
    1075    
     1064    {
     1065        glVertex3d(x1, y0, z0);
     1066        glVertex3d(x1, y0, z1);
     1067        glVertex3d(x1, y1, z1);
     1068        glVertex3d(x1, y1, z0);
     1069    }
    10761070    glEnd();
    1077    
    10781071    glEnable(GL_TEXTURE_2D);
    10791072}
     
    11691162    glColor4f(0,0.8,0.8,0.6);
    11701163    glBegin(GL_POINTS);
    1171     for(int i=0; i<psys->psys_width * psys->psys_height; i++){
    1172         glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]);
     1164    {
     1165        for(int i=0; i < psys->psys_width * psys->psys_height; i++){
     1166            glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]);
     1167        }
    11731168    }
    11741169    glEnd();
     
    12101205    glUniform3fARB(oddevenMergeSort.getUniformLocation("Param1"), float(pstage+pstage),
    12111206                   float(ppass%pstage), float((pstage+pstage)-(ppass%pstage)-1));
    1212     glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"), float(psys_width), float(psys_height), float(ppass));
     1207    glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"),
     1208                   float(psys_width), float(psys_height), float(ppass));
    12131209    glUniform1iARB(oddevenMergeSort.getUniformLocation("Data"), 0);
    12141210    staticdebugmsg("sort","stage "<<pstage<<" pass "<<ppass);
     
    12261222    // Initiate the sorting step on the GPU a full-screen quad
    12271223    glBegin(GL_QUADS);
     1224    {
    12281225#ifdef notdef
    1229     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f); glVertex2f(-1.0f,-1.0f);
    1230     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f); glVertex2f(1.0f,-1.0f);
    1231     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f); glVertex2f(1.0f,1.0f);       
    1232     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f); glVertex2f(-1.0f,1.0f);   
    1233 #endif
    1234     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f); glVertex2f(0.,0.);       
    1235     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f); glVertex2f(float(psys_width), 0.);
    1236     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f); glVertex2f(float(psys_width), float(psys_height));   
    1237     glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f); glVertex2f(0., float(psys_height));       
     1226        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f);
     1227        glVertex2f(-1.0f,-1.0f);
     1228        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f);
     1229        glVertex2f(1.0f,-1.0f);
     1230        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f);
     1231        glVertex2f(1.0f,1.0f);       
     1232        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f);
     1233        glVertex2f(-1.0f,1.0f);   
     1234#endif
     1235        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f);
     1236        glVertex2f(0.,0.);       
     1237        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f);
     1238        glVertex2f(float(psys_width), 0.);
     1239        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f);
     1240        glVertex2f(float(psys_width), float(psys_height));   
     1241        glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f);
     1242        glVertex2f(0., float(psys_height));       
     1243    }
    12381244    glEnd();
    1239 
    12401245
    12411246    // switch off sorting shader
     
    13831388        struct timeval clock;
    13841389        gettimeofday(&clock, NULL);
    1385         double elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 - vol_renderer->_volumeInterpolator->getStartTime();
     1390        double elapsed_time;
     1391
     1392        elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 -
     1393            vol_renderer->_volumeInterpolator->getStartTime();
    13861394       
    13871395        Trace("%lf %lf\n", elapsed_time, vol_renderer->_volumeInterpolator->getInterval());
     
    13891397        float f;
    13901398
    1391         f = fmod((float) elapsed_time, (float) vol_renderer->_volumeInterpolator->getInterval());
     1399        f = fmod((float) elapsed_time, (float)vol_renderer->_volumeInterpolator->getInterval());
    13921400        if (f == 0.0) {
    13931401            fraction = 0.0f;
     
    13951403            fraction = f / vol_renderer->_volumeInterpolator->getInterval();
    13961404        }
    1397 
    13981405        Trace("fraction : %f\n", fraction);
    13991406        vol_renderer->_volumeInterpolator->update(fraction);
     
    14011408}
    14021409
     1410void
     1411NanoVis::SetVolumeRanges()
     1412{
     1413    double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
     1414   
     1415    xMin = yMin = zMin = wMin = DBL_MAX;
     1416    xMax = yMax = zMax = wMax = -DBL_MAX;
     1417    for (unsigned int i = 0; i < volume.size(); i++) {
     1418        Volume *volPtr;
     1419       
     1420        volPtr = volume[i];
     1421        if (volPtr == NULL) {
     1422            continue;
     1423        }
     1424        if (!volPtr->enabled) {
     1425            continue;
     1426        }
     1427        if (xMin > volPtr->xAxis.Min()) {
     1428            xMin = volPtr->xAxis.Min();
     1429        }
     1430        if (xMax < volPtr->xAxis.Max()) {
     1431            xMax = volPtr->xAxis.Max();
     1432        }
     1433        if (yMin > volPtr->yAxis.Min()) {
     1434            yMin = volPtr->yAxis.Min();
     1435        }
     1436        if (yMax < volPtr->yAxis.Max()) {
     1437            yMax = volPtr->yAxis.Max();
     1438        }
     1439        if (zMin > volPtr->zAxis.Min()) {
     1440            zMin = volPtr->zAxis.Min();
     1441        }
     1442        if (zMax < volPtr->zAxis.Max()) {
     1443            zMax = volPtr->zAxis.Max();
     1444        }
     1445        if (wMin > volPtr->wAxis.Min()) {
     1446            wMin = volPtr->wAxis.Min();
     1447        }
     1448        if (wMax < volPtr->wAxis.Max()) {
     1449            wMax = volPtr->wAxis.Max();
     1450        }
     1451    }
     1452    if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) {
     1453        grid->xAxis.SetScale(xMin, xMax);
     1454    }
     1455    if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) {
     1456        grid->yAxis.SetScale(yMin, yMax);
     1457    }
     1458    if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) {
     1459        grid->zAxis.SetScale(zMin, zMax);
     1460    }
     1461    if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) {
     1462        Volume::valueMin = wMin;
     1463        Volume::valueMax = wMax;
     1464    }
     1465    Volume::update_pending = false;
     1466}
     1467
     1468void
     1469NanoVis::SetHeightmapRanges()
     1470{
     1471    double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
     1472   
     1473    xMin = yMin = zMin = wMin = DBL_MAX;
     1474    xMax = yMax = zMax = wMax = -DBL_MAX;
     1475    for (unsigned int i = 0; i < heightMap.size(); i++) {
     1476        HeightMap *hmPtr;
     1477       
     1478        hmPtr = heightMap[i];
     1479        if (hmPtr == NULL) {
     1480            continue;
     1481        }
     1482        if (xMin > hmPtr->xAxis.Min()) {
     1483            xMin = hmPtr->xAxis.Min();
     1484        }
     1485        if (xMax < hmPtr->xAxis.Max()) {
     1486            xMax = hmPtr->xAxis.Max();
     1487        }
     1488        if (yMin > hmPtr->yAxis.Min()) {
     1489            yMin = hmPtr->yAxis.Min();
     1490        }
     1491        if (yMax < hmPtr->yAxis.Max()) {
     1492            yMax = hmPtr->yAxis.Max();
     1493        }
     1494        if (zMin > hmPtr->zAxis.Min()) {
     1495            zMin = hmPtr->zAxis.Min();
     1496        }
     1497        if (zMax < hmPtr->zAxis.Max()) {
     1498            zMax = hmPtr->zAxis.Max();
     1499        }
     1500        if (wMin > hmPtr->wAxis.Min()) {
     1501            wMin = hmPtr->wAxis.Min();
     1502        }
     1503        if (wMax < hmPtr->wAxis.Max()) {
     1504            wMax = hmPtr->wAxis.Max();
     1505        }
     1506    }
     1507    if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) {
     1508        grid->xAxis.SetScale(xMin, xMax);
     1509    }
     1510    if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) {
     1511        grid->yAxis.SetScale(yMin, yMax);
     1512    }
     1513    if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) {
     1514        grid->zAxis.SetScale(zMin, zMax);
     1515    }
     1516    if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) {
     1517        HeightMap::valueMin = wMin;
     1518        HeightMap::valueMax = wMax;
     1519    }
     1520    HeightMap::update_pending = false;
     1521}
     1522
    14031523/*----------------------------------------------------*/
    14041524void
     
    14061526{
    14071527    //assert(glGetError()==0);
    1408    
     1528    if (HeightMap::update_pending) {
     1529        SetHeightmapRanges();
     1530    }
     1531    if (Volume::update_pending) {
     1532        SetVolumeRanges();
     1533    }
    14091534    //start final rendering
    14101535    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
  • trunk/vizservers/nanovis/nanovis.h

    r929 r932  
    127127    static float lic_slice_y;
    128128    static float lic_slice_z;
    129     static int lic_axis; /* 0:x, 1:y, 2:z */
     129    static int lic_axis;        /* 0:x, 1:y, 2:z */
    130130
    131131    static bool axis_on;
    132 
    133     static int win_width;                       //size of the render window
    134     static int win_height;                      //size of the render window
     132    static bool config_pending; // Indicates if the limits need to be recomputed.
     133    static int win_width;       //size of the render window
     134    static int win_height;      //size of the render window
    135135 
    136136
     
    142142    static TransferFunction* set_transfunc(const char *name, int nSlots,
    143143                                           float *data);
     144    static void SetVolumeRanges(void);
     145    static void SetHeightmapRanges(void);
    144146    static void init(const char* path);
    145147    static void initGL(void);
Note: See TracChangeset for help on using the changeset viewer.