Ignore:
Timestamp:
May 29, 2009 6:09:42 AM (15 years ago)
Author:
gah
Message:
 
Location:
trunk/packages/vizservers/nanovis
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Command.cpp

    r1434 r1474  
    953953        NanoVis::SetVolumeRanges();
    954954    }
    955     NanoVis::render_legend(tf, NanoVis::grid->yAxis.min(),
    956                            NanoVis::grid->yAxis.max(), w, h, label);
     955    NanoVis::render_legend(tf, Volume::valueMin, Volume::valueMax, w, h, label);
    957956    return TCL_OK;
    958957}
     
    14121411        return TCL_ERROR;
    14131412    }
    1414     if (state) {
    1415         vector<Volume *>::iterator iter;
    1416         for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1417             (*iter)->enable_data();
    1418         }
    1419     } else {
    1420         vector<Volume *>::iterator iter;
    1421         for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1422             (*iter)->disable_data();
    1423         }
     1413    vector<Volume *>::iterator iter;
     1414    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
     1415        (*iter)->data(state);
    14241416    }
    14251417    return TCL_OK;
     
    14771469        return TCL_ERROR;
    14781470    }
    1479     if (state) {
    1480         vector<Volume *>::iterator iter;
    1481         for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1482             (*iter)->enable_outline();
    1483         }
    1484     } else {
    1485         vector<Volume *>::iterator iter;
    1486         for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1487             (*iter)->disable_outline();
    1488         }
     1471    vector<Volume *>::iterator iter;
     1472    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
     1473        (*iter)->outline(state);
    14891474    }
    14901475    return TCL_OK;
     
    15281513    vector<Volume *>::iterator iter;
    15291514    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1530         (*iter)->set_diffuse(diffuse);
     1515        (*iter)->diffuse(diffuse);
    15311516    }
    15321517    return TCL_OK;
     
    15681553    vector<Volume *>::iterator iter;
    15691554    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1570         (*iter)->set_opacity_scale(opacity);
     1555        (*iter)->opacity_scale(opacity);
    15711556    }
    15721557    return TCL_OK;
     
    15871572    vector<Volume *>::iterator iter;
    15881573    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1589         (*iter)->set_specular(specular);
     1574        (*iter)->specular(specular);
    15901575    }
    15911576    return TCL_OK;
     
    16871672        return TCL_ERROR;
    16881673    }
    1689     if (state) {
    1690         vector<Volume *>::iterator iter;
    1691         for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1692             (*iter)->enable();
    1693         }
    1694     } else {
    1695         vector<Volume *>::iterator iter;
    1696         for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1697             (*iter)->disable();
    1698         }
     1674    vector<Volume *>::iterator iter;
     1675    for (iter = ivol.begin(); iter != ivol.end(); iter++) {
     1676        (*iter)->visible(state);
    16991677    }
    17001678    return TCL_OK;
     
    17051683             Tcl_Obj *const *objv)
    17061684{
    1707     NanoVis::volume[1]->disable_data();
    1708     NanoVis::volume[1]->disable();
     1685    NanoVis::volume[1]->data(false);
     1686    NanoVis::volume[1]->visible(false);
    17091687    return TCL_OK;
    17101688}
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r1473 r1474  
    6767    {Rappture::SWITCH_BOOLEAN, "-outline", "boolean",
    6868        offsetof(FlowValues, showOutline), 0},
     69    {Rappture::SWITCH_FLOAT, "-diffuse", "value",
     70        offsetof(FlowValues, diffuse), 0},
     71    {Rappture::SWITCH_FLOAT, "-opacity", "value",
     72        offsetof(FlowValues, opacity), 0},
     73    {Rappture::SWITCH_FLOAT, "-specular", "value",
     74        offsetof(FlowValues, specular), 0},
    6975    {Rappture::SWITCH_END}
    7076};
     
    269275                                         * been allocated for this vector. */
    270276    _sv.sliceVisible = 1;
     277    _sv.tfPtr = NanoVis::get_transfunc("default");
    271278    _volPtr = NULL;
    272279    _cmdToken = Tcl_CreateObjCommand(interp, (char *)_name,
     
    649656    volPtr->disable_cutplane(2);
    650657
    651     TransferFunction *tfPtr;
    652     tfPtr = _sv.tfPtr;
    653     if (tfPtr == NULL) {
    654         tfPtr = NanoVis::get_transfunc("default");
    655     }
    656     NanoVis::vol_renderer->add_volume(volPtr, tfPtr);
    657     if (_sv.showVolume) {
    658         volPtr->enable_data();
    659     } else {
    660         volPtr->disable_data();
    661     }
    662     if (_sv.showOutline) {
    663         volPtr->enable_outline();
    664     } else {
    665         volPtr->disable_outline();
    666     }
     658    NanoVis::vol_renderer->add_volume(volPtr, _sv.tfPtr);
     659    volPtr->data(_sv.showVolume);
     660    volPtr->outline(_sv.showOutline);
     661    volPtr->opacity_scale(_sv.opacity);
     662    volPtr->specular(_sv.specular);
     663    volPtr->diffuse(_sv.diffuse);
     664
    667665    float dx0 = -0.5;
    668666    float dy0 = -0.5*volPtr->height/volPtr->width;
    669667    float dz0 = -0.5*volPtr->depth/volPtr->width;
    670668    volPtr->move(Vector3(dx0, dy0, dz0));
     669    Volume::update_pending = true;
    671670    return volPtr;
    672671}
     
    15961595
    15971596/*
     1597 * ----------------------------------------------------------------------
     1598 * CLIENT COMMAND:
     1599 *   $flow legend <width> <height>
     1600 *
     1601 * Clients use this to generate a legend image for the specified
     1602 * transfer function.  The legend image is a color gradient from 0
     1603 * to one, drawn in the given transfer function.  The resulting image
     1604 * is returned in the size <width> x <height>.
     1605 * ----------------------------------------------------------------------
     1606 */
     1607static int
     1608FlowLegendOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1609          Tcl_Obj *const *objv)
     1610{
     1611    FlowCmd *flowPtr = (FlowCmd *)clientData;
     1612   
     1613    const char *string = Tcl_GetString(objv[1]);
     1614    TransferFunction *tf;
     1615    tf = flowPtr->GetTransferFunction();
     1616    if (tf == NULL) {
     1617        Tcl_AppendResult(interp, "unknown transfer function \"", string, "\"",
     1618                             (char*)NULL);
     1619        return TCL_ERROR;
     1620    }
     1621    const char *label;
     1622    label = Tcl_GetString(objv[0]);
     1623    int w, h;
     1624    if ((Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) ||
     1625        (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK)) {
     1626        return TCL_ERROR;
     1627    }
     1628    if (NanoVis::MAP_FLOWS) {
     1629        NanoVis::MapFlows();
     1630    }
     1631    NanoVis::render_legend(tf, NanoVis::magMin, NanoVis::magMax, w, h, label);
     1632    return TCL_OK;
     1633}
     1634
     1635/*
    15981636 *---------------------------------------------------------------------------
    15991637 *
     
    16151653    {"configure",   1, FlowConfigureOp,  2, 0, "?switches?"},
    16161654    {"data",        1, FlowDataOp,       2, 0, "oper ?args?"},
     1655    {"legend",      1, FlowLegendOp,     4, 4, "w h"},
    16171656    {"particles",   1, FlowParticlesOp,  2, 0, "oper ?args?"}
    16181657};
     
    19341973    return TCL_OK;
    19351974}
     1975
    19361976
    19371977/*
  • trunk/packages/vizservers/nanovis/FlowCmd.h

    r1469 r1474  
    140140    int showOutline;
    141141    int isHidden;
     142    /* The following are settings for the volume.*/
     143    float diffuse;
     144    float specular;
     145    float opacity;
    142146};
    143147
     
    255259        return (SliceAxis)_sv.slicePos.axis;
    256260    }
     261    TransferFunction *GetTransferFunction(void) {
     262        return _sv.tfPtr;
     263    }
    257264    float GetRelativePosition(void);
    258265    void SetAxis(void) {
  • trunk/packages/vizservers/nanovis/Lic.cpp

    r1431 r1474  
    117117void Lic::make_patterns()
    118118{
    119    int lut[256];
    120    int phase[NPN][NPN];
    121    GLubyte pat[NPN][NPN][4];
    122    int i, j, k, t;
     119    int lut[256];
     120    int phase[NPN][NPN];
     121    GLubyte pat[NPN][NPN][4];
     122    int i, j, k, t;
    123123   
    124    for (i = 0; i < 256; i++) lut[i] = i < 127 ? 0 : 255;
    125    for (i = 0; i < NPN; i++)
    126    for (j = 0; j < NPN; j++) phase[i][j] = rand() % 256;
    127 
    128    for (k = 0; k < Npat; k++) {
    129      t = k*256/Npat;
    130      for (i = 0; i < NPN; i++)
    131      for (j = 0; j < NPN; j++) {
    132        pat[i][j][0] =
    133        pat[i][j][1] =
    134        pat[i][j][2] = lut[(t + phase[i][j]) % 255];
    135        pat[i][j][3] = alpha;
    136      }
    137 
    138      glNewList(k + 1, GL_COMPILE);
    139      glBindTexture(GL_TEXTURE_2D, pattern_tex);
    140      glTexImage2D(GL_TEXTURE_2D, 0, 4, NPN, NPN, 0,
     124    for (i = 0; i < 256; i++) lut[i] = i < 127 ? 0 : 255;
     125    for (i = 0; i < NPN; i++)
     126        for (j = 0; j < NPN; j++) phase[i][j] = rand() % 256;
     127   
     128    for (k = 0; k < Npat; k++) {
     129        t = k*256/Npat;
     130        for (i = 0; i < NPN; i++)
     131            for (j = 0; j < NPN; j++) {
     132                pat[i][j][0] =
     133                    pat[i][j][1] =
     134                    pat[i][j][2] = lut[(t + phase[i][j]) % 255];
     135                pat[i][j][3] = alpha;
     136            }
     137       
     138        glNewList(k + 1, GL_COMPILE);
     139        glBindTexture(GL_TEXTURE_2D, pattern_tex);
     140        glTexImage2D(GL_TEXTURE_2D, 0, 4, NPN, NPN, 0,
    141141                     GL_RGBA, GL_UNSIGNED_BYTE, pat);
    142      glEndList();
    143    }
     142        glEndList();
     143    }
    144144}
    145145
  • trunk/packages/vizservers/nanovis/NvRegularVolumeShader.h

    r870 r1474  
    3939        cgGLSetParameter4f(m_render_param_one_volume_param,
    4040            volume->get_n_slice(),
    41             volume->get_opacity_scale(),
    42             volume->get_diffuse(),
    43             volume->get_specular());
     41            volume->opacity_scale(),
     42            volume->diffuse(),
     43            volume->specular());
    4444    else
    4545        cgGLSetParameter4f(m_render_param_one_volume_param,
    4646            0.,
    47             volume->get_opacity_scale(),
    48             volume->get_diffuse(),
    49             volume->get_specular());
     47            volume->opacity_scale(),
     48            volume->diffuse(),
     49            volume->specular());
    5050
    5151    cgGLSetParameter4f(m_option_one_volume_param,
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h

    r870 r1474  
    3535        cgGLSetParameter4f(_renderParam,
    3636            vol->get_n_slice(),
    37             vol->get_opacity_scale(),
    38             vol->get_diffuse(),
    39             vol->get_specular());
     37            vol->opacity_scale(),
     38            vol->diffuse(),
     39            vol->specular());
    4040    else
    4141        cgGLSetParameter4f(_renderParam,
    4242            0.,
    43             vol->get_opacity_scale(),
    44             vol->get_diffuse(),
    45             vol->get_specular());
     43            vol->opacity_scale(),
     44            vol->diffuse(),
     45            vol->specular());
    4646
    4747    cgGLSetParameter4f(_option_one_volume_param,
  • trunk/packages/vizservers/nanovis/Renderable.cpp

    r848 r1474  
    1919Renderable::Renderable(){}
    2020Renderable::Renderable(Vector3 loc):
    21   location(loc),
    22   enabled(true){ }
     21    location(loc),
     22    enabled(true)
     23{
     24}
    2325
    2426Renderable::~Renderable(){}
  • trunk/packages/vizservers/nanovis/Volume.cpp

    r1429 r1474  
    3737    //n_slice(256),             // default value
    3838    n_slice(512),               // default value
    39     specular(6.),               // default value
    40     diffuse(3.),                // default value
    41     opacity_scale(10.),         // default value
     39    _specular(6.),              // default value
     40    _diffuse(3.),               // default value
     41    _opacity_scale(10.),        // default value
    4242    data_enabled(true),         // default value
    4343    outline_enabled(true),      // default value
  • trunk/packages/vizservers/nanovis/Volume.h

    r1370 r1474  
    8080                                // the better quality, lower speed.
    8181
    82     float specular;             // specular lighting parameter
    83     float diffuse;              // diffuse lighting parameter
    84     float opacity_scale;        // The scale multiplied to the opacity assigned
     82    float _specular;            // specular lighting parameter
     83    float _diffuse;             // diffuse lighting parameter
     84    float _opacity_scale;       // The scale multiplied to the opacity assigned
    8585                                // by the transfer function.  Rule of thumb:
    8686                                // higher opacity_scale the object is to appear
     
    110110    ~Volume();
    111111       
    112     void enable();              // VolumeRenderer will render an enabled
    113                                 // volume and its cutplanes
    114     void disable();
    115     void move(Vector3 _loc);
    116     bool is_enabled();
     112    void visible(bool value) {
     113        enabled = value;
     114    }
     115    bool visible(void) {
     116        return enabled;
     117    }
     118    void move(Vector3 _loc) {
     119        location = _loc;
     120    }
     121
    117122    Vector3* get_location();
    118123   
     
    138143
    139144    //methods related to shading. These parameters are per volume
    140     float get_specular();
    141     float get_diffuse();
    142     float get_opacity_scale();
    143     void set_specular(float s);
    144     void set_diffuse(float d);
    145     void set_opacity_scale(float s);
    146    
    147     void enable_data();
    148     void disable_data();
    149     bool data_is_enabled();
    150    
    151     void enable_outline();
    152     void disable_outline();
    153     bool outline_is_enabled();
     145    float specular(void) {
     146        return _specular;
     147    }
     148    void specular(float value) {
     149        _specular = value;
     150    }
     151    float diffuse(void) {
     152        return _diffuse;
     153    }
     154    void diffuse(float value) {
     155        _diffuse = value;
     156    }
     157    float opacity_scale(void) {
     158        return _opacity_scale;
     159    }
     160    void opacity_scale(float value) {
     161        _opacity_scale = value;
     162    }
     163    void data(bool value) {
     164        data_enabled = value;
     165    }
     166    bool data(void) {
     167        return data_enabled;
     168    }
     169    void outline(bool value) {
     170        outline_enabled = value;
     171    }
     172    bool outline(void) {
     173        return outline_enabled;
     174    }
    154175    void set_outline_color(float* rgb);
    155176    void get_outline_color(float* rgb);
     
    164185};
    165186
    166 inline void Volume::enable() {
    167     enabled = true;
    168 }
    169 inline void Volume::disable() {
    170     enabled = false;
    171 }
    172 inline void Volume::move(Vector3 _loc) {
    173     location = _loc;
    174 }
    175 inline bool Volume::is_enabled() {
    176     return enabled;
    177 }
    178187inline Vector3* Volume::get_location() {
    179188    return &location;
     
    246255}
    247256
    248 inline float
    249 Volume::get_specular()
    250 {
    251     return specular;
    252 }
    253 
    254 inline float
    255 Volume::get_diffuse()
    256 {
    257     return diffuse;
    258 }
    259 
    260 inline float
    261 Volume::get_opacity_scale()
    262 {
    263     return opacity_scale;
    264 }
    265 
    266 inline void
    267 Volume::set_specular(float s)
    268 {
    269     specular = s;
    270 }
    271 
    272 inline void
    273 Volume::set_diffuse(float d)
    274 {
    275     diffuse = d;
    276 }
    277 
    278 inline void
    279 Volume::set_opacity_scale(float s)
    280 {
    281     opacity_scale = s;
    282 }
    283 
    284 inline void
    285 Volume::enable_data()
    286 {
    287     data_enabled = true;
    288 }
    289 
    290 inline void
    291 Volume::disable_data()
    292 {
    293     data_enabled = false;
    294 }
    295 
    296 inline bool
    297 Volume::data_is_enabled()
    298 {
    299     return data_enabled;
    300 }
    301 
    302 inline void
    303 Volume::enable_outline()
    304 {
    305     outline_enabled = true;
    306 }
    307 
    308 inline void
    309 Volume::disable_outline()
    310 {
    311     outline_enabled = false;
    312 }
    313 
    314 inline bool
    315 Volume::outline_is_enabled()
    316 {
    317     return outline_enabled;
    318 }
    319 
    320257inline void
    321258Volume::set_outline_color(float *rgb)
  • trunk/packages/vizservers/nanovis/VolumeInterpolator.cpp

    r1111 r1474  
    154154        _volume->disable_cutplane(1);
    155155        _volume->disable_cutplane(2);
    156         _volume->enable();
    157         _volume->enable_data();
    158         _volume->set_specular(volume->get_specular());
    159         _volume->set_diffuse(volume->get_diffuse());
    160         _volume->set_opacity_scale(volume->get_opacity_scale());
     156        _volume->visible(true);
     157        _volume->data(true);
     158        _volume->specular(volume->specular());
     159        _volume->diffuse(volume->diffuse());
     160        _volume->opacity_scale(volume->opacity_scale());
    161161        _volume->set_isosurface(0);
    162162       
  • trunk/packages/vizservers/nanovis/VolumeRenderer.cpp

    r1431 r1474  
    164164    for(int i=0; i<n_volumes; i++){
    165165        int volume_index = i;
    166         if(!volume[i]->is_enabled())
     166        if(!volume[i]->visible())
    167167            continue; //skip this volume
    168168       
     
    173173        glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z);
    174174       
    175         if (volume[volume_index]->outline_is_enabled()) {
     175        if (volume[volume_index]->outline()) {
    176176            float olcolor[3];
    177177            volume[volume_index]->get_outline_color(olcolor);
     
    225225        actual_slices[vol_index] = 0;
    226226
    227         if(!cur_vol->is_enabled()) {
     227        if(!cur_vol->visible()) {
    228228            continue; //skip this volume
    229229        }
     
    287287        //draw volume bounding box with translation (the correct location in
    288288        //space)
    289         if (cur_vol->outline_is_enabled()) {
     289        if (cur_vol->outline()) {
    290290            float olcolor[3];
    291291            cur_vol->get_outline_color(olcolor);
     
    299299        glPushMatrix();
    300300        glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z);
    301         if(cur_vol->outline_is_enabled()) {
     301        if(cur_vol->outline()) {
    302302            //draw_label(i);
    303303        }
     
    314314        int n_actual_slices;
    315315       
    316         if (cur_vol->data_is_enabled()) {
     316        if (cur_vol->data()) {
    317317            n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1);
    318318            polys[vol_index] = new ConvexPolygon*[n_actual_slices];
     
    572572
    573573  //draw volume bounding box
    574   if (volume[volume_index]->outline_is_enabled()) {
     574  if (volume[volume_index]->outline()) {
    575575      draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1, 0.8, 0.1, 0.1, 1.5);
    576576  }
     
    920920
    921921void VolumeRenderer::enable_volume(int index){
    922   volume[index]->enable();
     922  volume[index]->visible(true);
    923923}
    924924
    925925void VolumeRenderer::disable_volume(int index){
    926   volume[index]->disable();
     926  volume[index]->visible(false);
    927927}
    928928
  • trunk/packages/vizservers/nanovis/VolumeRenderer.h

    r1429 r1474  
    116116    void render_all();  //render all enabled volumes;
    117117    void render_all_points(void); //render all enabled volumes;
    118     void set_specular(float val);
    119     void set_diffuse(float val);
     118    void specular(float val);
     119    void diffuse(float val);
    120120    void set_slice_mode(bool val); //control independently.
    121121    void set_volume_mode(bool val);
  • trunk/packages/vizservers/nanovis/dxReader.cpp

    r1434 r1474  
    5959    dx = dy = dz = 0.0;         // Suppress compiler warning.
    6060    x0 = y0 = z0 = 0.0;         // May not have an origin line.
     61    nx = ny = nz = npts = nxy = 0;
    6162    do {
    6263        fin.getline(line,sizeof(line)-1);
     
    423424    dx = dy = dz = 0.0;         // Suppress compiler warning.
    424425    x0 = y0 = z0 = 0.0;         // May not have an origin line.
     426    nx = ny = nz = npts = nxy = 0;
    425427    while (!fin.eof()) {
    426428        fin.getline(line, sizeof(line) - 1);
     
    852854    dx = dy = dz = 0.0;         // Suppress compiler warning.
    853855    x0 = y0 = z0 = 0.0;         // May not have an origin line.
     856    nx = ny = nz = npts = nxy = 0;
    854857    while (!fin.eof()) {
    855858        fin.getline(line, sizeof(line) - 1);
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1472 r1474  
    625625        fprintf(stderr, "leaving render_legend\n");
    626626    }
     627    delete plane[0];
    627628    return TCL_OK;
    628629}
     
    15441545            continue;
    15451546        }
    1546         if (!volPtr->enabled) {
     1547        if (!volPtr->visible()) {
    15471548            continue;
    15481549        }
     
    18701871           
    18711872            NanoVis::vol_renderer->add_volume(volPtr,
    1872                                               NanoVis::get_transfunc("default"));
     1873                NanoVis::get_transfunc("default"));
    18731874            float dx0 = -0.5;
    18741875            float dy0 = -0.5*volPtr->height/volPtr->width;
    18751876            float dz0 = -0.5*volPtr->depth/volPtr->width;
    18761877            volPtr->move(Vector3(dx0, dy0, dz0));
    1877             //volPtr->enable_data();
    1878             volPtr->disable_data();
     1878            //volPtr->data(true);
     1879            volPtr->data(false);
    18791880            NanoVis::flowVisRenderer->addVectorField(vf_name, volPtr,
    18801881                *(volPtr->get_location()),
Note: See TracChangeset for help on using the changeset viewer.