Changeset 1474 for trunk/packages/vizservers/nanovis
- Timestamp:
- May 29, 2009 6:09:42 AM (15 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r1434 r1474 953 953 NanoVis::SetVolumeRanges(); 954 954 } 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); 957 956 return TCL_OK; 958 957 } … … 1412 1411 return TCL_ERROR; 1413 1412 } 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); 1424 1416 } 1425 1417 return TCL_OK; … … 1477 1469 return TCL_ERROR; 1478 1470 } 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); 1489 1474 } 1490 1475 return TCL_OK; … … 1528 1513 vector<Volume *>::iterator iter; 1529 1514 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1530 (*iter)-> set_diffuse(diffuse);1515 (*iter)->diffuse(diffuse); 1531 1516 } 1532 1517 return TCL_OK; … … 1568 1553 vector<Volume *>::iterator iter; 1569 1554 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1570 (*iter)-> set_opacity_scale(opacity);1555 (*iter)->opacity_scale(opacity); 1571 1556 } 1572 1557 return TCL_OK; … … 1587 1572 vector<Volume *>::iterator iter; 1588 1573 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1589 (*iter)->s et_specular(specular);1574 (*iter)->specular(specular); 1590 1575 } 1591 1576 return TCL_OK; … … 1687 1672 return TCL_ERROR; 1688 1673 } 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); 1699 1677 } 1700 1678 return TCL_OK; … … 1705 1683 Tcl_Obj *const *objv) 1706 1684 { 1707 NanoVis::volume[1]->d isable_data();1708 NanoVis::volume[1]-> disable();1685 NanoVis::volume[1]->data(false); 1686 NanoVis::volume[1]->visible(false); 1709 1687 return TCL_OK; 1710 1688 } -
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r1473 r1474 67 67 {Rappture::SWITCH_BOOLEAN, "-outline", "boolean", 68 68 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}, 69 75 {Rappture::SWITCH_END} 70 76 }; … … 269 275 * been allocated for this vector. */ 270 276 _sv.sliceVisible = 1; 277 _sv.tfPtr = NanoVis::get_transfunc("default"); 271 278 _volPtr = NULL; 272 279 _cmdToken = Tcl_CreateObjCommand(interp, (char *)_name, … … 649 656 volPtr->disable_cutplane(2); 650 657 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 667 665 float dx0 = -0.5; 668 666 float dy0 = -0.5*volPtr->height/volPtr->width; 669 667 float dz0 = -0.5*volPtr->depth/volPtr->width; 670 668 volPtr->move(Vector3(dx0, dy0, dz0)); 669 Volume::update_pending = true; 671 670 return volPtr; 672 671 } … … 1596 1595 1597 1596 /* 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 */ 1607 static int 1608 FlowLegendOp(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 /* 1598 1636 *--------------------------------------------------------------------------- 1599 1637 * … … 1615 1653 {"configure", 1, FlowConfigureOp, 2, 0, "?switches?"}, 1616 1654 {"data", 1, FlowDataOp, 2, 0, "oper ?args?"}, 1655 {"legend", 1, FlowLegendOp, 4, 4, "w h"}, 1617 1656 {"particles", 1, FlowParticlesOp, 2, 0, "oper ?args?"} 1618 1657 }; … … 1934 1973 return TCL_OK; 1935 1974 } 1975 1936 1976 1937 1977 /* -
trunk/packages/vizservers/nanovis/FlowCmd.h
r1469 r1474 140 140 int showOutline; 141 141 int isHidden; 142 /* The following are settings for the volume.*/ 143 float diffuse; 144 float specular; 145 float opacity; 142 146 }; 143 147 … … 255 259 return (SliceAxis)_sv.slicePos.axis; 256 260 } 261 TransferFunction *GetTransferFunction(void) { 262 return _sv.tfPtr; 263 } 257 264 float GetRelativePosition(void); 258 265 void SetAxis(void) { -
trunk/packages/vizservers/nanovis/Lic.cpp
r1431 r1474 117 117 void Lic::make_patterns() 118 118 { 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; 123 123 124 for (i = 0; i < 256; i++) lut[i] = i < 127 ? 0 : 255;125 for (i = 0; i < NPN; i++)126 127 128 for (k = 0; k < Npat; k++) {129 130 131 132 133 134 135 136 137 138 139 140 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, 141 141 GL_RGBA, GL_UNSIGNED_BYTE, pat); 142 143 }142 glEndList(); 143 } 144 144 } 145 145 -
trunk/packages/vizservers/nanovis/NvRegularVolumeShader.h
r870 r1474 39 39 cgGLSetParameter4f(m_render_param_one_volume_param, 40 40 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()); 44 44 else 45 45 cgGLSetParameter4f(m_render_param_one_volume_param, 46 46 0., 47 volume-> get_opacity_scale(),48 volume-> get_diffuse(),49 volume-> get_specular());47 volume->opacity_scale(), 48 volume->diffuse(), 49 volume->specular()); 50 50 51 51 cgGLSetParameter4f(m_option_one_volume_param, -
trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h
r870 r1474 35 35 cgGLSetParameter4f(_renderParam, 36 36 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()); 40 40 else 41 41 cgGLSetParameter4f(_renderParam, 42 42 0., 43 vol-> get_opacity_scale(),44 vol-> get_diffuse(),45 vol-> get_specular());43 vol->opacity_scale(), 44 vol->diffuse(), 45 vol->specular()); 46 46 47 47 cgGLSetParameter4f(_option_one_volume_param, -
trunk/packages/vizservers/nanovis/Renderable.cpp
r848 r1474 19 19 Renderable::Renderable(){} 20 20 Renderable::Renderable(Vector3 loc): 21 location(loc), 22 enabled(true){ } 21 location(loc), 22 enabled(true) 23 { 24 } 23 25 24 26 Renderable::~Renderable(){} -
trunk/packages/vizservers/nanovis/Volume.cpp
r1429 r1474 37 37 //n_slice(256), // default value 38 38 n_slice(512), // default value 39 specular(6.), // default value40 diffuse(3.), // default value41 opacity_scale(10.),// default value39 _specular(6.), // default value 40 _diffuse(3.), // default value 41 _opacity_scale(10.), // default value 42 42 data_enabled(true), // default value 43 43 outline_enabled(true), // default value -
trunk/packages/vizservers/nanovis/Volume.h
r1370 r1474 80 80 // the better quality, lower speed. 81 81 82 float specular; // specular lighting parameter83 float diffuse; // diffuse lighting parameter84 float opacity_scale; // The scale multiplied to the opacity assigned82 float _specular; // specular lighting parameter 83 float _diffuse; // diffuse lighting parameter 84 float _opacity_scale; // The scale multiplied to the opacity assigned 85 85 // by the transfer function. Rule of thumb: 86 86 // higher opacity_scale the object is to appear … … 110 110 ~Volume(); 111 111 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 117 122 Vector3* get_location(); 118 123 … … 138 143 139 144 //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 } 154 175 void set_outline_color(float* rgb); 155 176 void get_outline_color(float* rgb); … … 164 185 }; 165 186 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 }178 187 inline Vector3* Volume::get_location() { 179 188 return &location; … … 246 255 } 247 256 248 inline float249 Volume::get_specular()250 {251 return specular;252 }253 254 inline float255 Volume::get_diffuse()256 {257 return diffuse;258 }259 260 inline float261 Volume::get_opacity_scale()262 {263 return opacity_scale;264 }265 266 inline void267 Volume::set_specular(float s)268 {269 specular = s;270 }271 272 inline void273 Volume::set_diffuse(float d)274 {275 diffuse = d;276 }277 278 inline void279 Volume::set_opacity_scale(float s)280 {281 opacity_scale = s;282 }283 284 inline void285 Volume::enable_data()286 {287 data_enabled = true;288 }289 290 inline void291 Volume::disable_data()292 {293 data_enabled = false;294 }295 296 inline bool297 Volume::data_is_enabled()298 {299 return data_enabled;300 }301 302 inline void303 Volume::enable_outline()304 {305 outline_enabled = true;306 }307 308 inline void309 Volume::disable_outline()310 {311 outline_enabled = false;312 }313 314 inline bool315 Volume::outline_is_enabled()316 {317 return outline_enabled;318 }319 320 257 inline void 321 258 Volume::set_outline_color(float *rgb) -
trunk/packages/vizservers/nanovis/VolumeInterpolator.cpp
r1111 r1474 154 154 _volume->disable_cutplane(1); 155 155 _volume->disable_cutplane(2); 156 _volume-> enable();157 _volume-> enable_data();158 _volume->s et_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()); 161 161 _volume->set_isosurface(0); 162 162 -
trunk/packages/vizservers/nanovis/VolumeRenderer.cpp
r1431 r1474 164 164 for(int i=0; i<n_volumes; i++){ 165 165 int volume_index = i; 166 if(!volume[i]-> is_enabled())166 if(!volume[i]->visible()) 167 167 continue; //skip this volume 168 168 … … 173 173 glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z); 174 174 175 if (volume[volume_index]->outline _is_enabled()) {175 if (volume[volume_index]->outline()) { 176 176 float olcolor[3]; 177 177 volume[volume_index]->get_outline_color(olcolor); … … 225 225 actual_slices[vol_index] = 0; 226 226 227 if(!cur_vol-> is_enabled()) {227 if(!cur_vol->visible()) { 228 228 continue; //skip this volume 229 229 } … … 287 287 //draw volume bounding box with translation (the correct location in 288 288 //space) 289 if (cur_vol->outline _is_enabled()) {289 if (cur_vol->outline()) { 290 290 float olcolor[3]; 291 291 cur_vol->get_outline_color(olcolor); … … 299 299 glPushMatrix(); 300 300 glTranslatef(shift_4d.x, shift_4d.y, shift_4d.z); 301 if(cur_vol->outline _is_enabled()) {301 if(cur_vol->outline()) { 302 302 //draw_label(i); 303 303 } … … 314 314 int n_actual_slices; 315 315 316 if (cur_vol->data _is_enabled()) {316 if (cur_vol->data()) { 317 317 n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1); 318 318 polys[vol_index] = new ConvexPolygon*[n_actual_slices]; … … 572 572 573 573 //draw volume bounding box 574 if (volume[volume_index]->outline _is_enabled()) {574 if (volume[volume_index]->outline()) { 575 575 draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1, 0.8, 0.1, 0.1, 1.5); 576 576 } … … 920 920 921 921 void VolumeRenderer::enable_volume(int index){ 922 volume[index]-> enable();922 volume[index]->visible(true); 923 923 } 924 924 925 925 void VolumeRenderer::disable_volume(int index){ 926 volume[index]-> disable();926 volume[index]->visible(false); 927 927 } 928 928 -
trunk/packages/vizservers/nanovis/VolumeRenderer.h
r1429 r1474 116 116 void render_all(); //render all enabled volumes; 117 117 void render_all_points(void); //render all enabled volumes; 118 void s et_specular(float val);119 void set_diffuse(float val);118 void specular(float val); 119 void diffuse(float val); 120 120 void set_slice_mode(bool val); //control independently. 121 121 void set_volume_mode(bool val); -
trunk/packages/vizservers/nanovis/dxReader.cpp
r1434 r1474 59 59 dx = dy = dz = 0.0; // Suppress compiler warning. 60 60 x0 = y0 = z0 = 0.0; // May not have an origin line. 61 nx = ny = nz = npts = nxy = 0; 61 62 do { 62 63 fin.getline(line,sizeof(line)-1); … … 423 424 dx = dy = dz = 0.0; // Suppress compiler warning. 424 425 x0 = y0 = z0 = 0.0; // May not have an origin line. 426 nx = ny = nz = npts = nxy = 0; 425 427 while (!fin.eof()) { 426 428 fin.getline(line, sizeof(line) - 1); … … 852 854 dx = dy = dz = 0.0; // Suppress compiler warning. 853 855 x0 = y0 = z0 = 0.0; // May not have an origin line. 856 nx = ny = nz = npts = nxy = 0; 854 857 while (!fin.eof()) { 855 858 fin.getline(line, sizeof(line) - 1); -
trunk/packages/vizservers/nanovis/nanovis.cpp
r1472 r1474 625 625 fprintf(stderr, "leaving render_legend\n"); 626 626 } 627 delete plane[0]; 627 628 return TCL_OK; 628 629 } … … 1544 1545 continue; 1545 1546 } 1546 if (!volPtr-> enabled) {1547 if (!volPtr->visible()) { 1547 1548 continue; 1548 1549 } … … 1870 1871 1871 1872 NanoVis::vol_renderer->add_volume(volPtr, 1872 1873 NanoVis::get_transfunc("default")); 1873 1874 float dx0 = -0.5; 1874 1875 float dy0 = -0.5*volPtr->height/volPtr->width; 1875 1876 float dz0 = -0.5*volPtr->depth/volPtr->width; 1876 1877 volPtr->move(Vector3(dx0, dy0, dz0)); 1877 //volPtr-> enable_data();1878 volPtr->d isable_data();1878 //volPtr->data(true); 1879 volPtr->data(false); 1879 1880 NanoVis::flowVisRenderer->addVectorField(vf_name, volPtr, 1880 1881 *(volPtr->get_location()),
Note: See TracChangeset
for help on using the changeset viewer.