Changeset 4612 for nanovis/branches/1.1/FlowCmd.cpp
- Timestamp:
- Aug 2, 2014 11:06:20 AM (10 years ago)
- Location:
- nanovis/branches/1.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.1
- Property svn:mergeinfo changed
/trunk/packages/vizservers/nanovis merged: 3597
- Property svn:mergeinfo changed
-
nanovis/branches/1.1/FlowCmd.cpp
r3584 r4612 16 16 #include <unistd.h> 17 17 #include <poll.h> 18 18 19 #include <tcl.h> 19 20 20 #include <RpField1D.h>21 #include <RpFieldRect3D.h>22 #include <RpFieldPrism3D.h>23 21 #include <RpOutcome.h> 24 22 … … 29 27 #include "nanovis.h" 30 28 #include "CmdProc.h" 29 #include "Command.h" 31 30 #include "FlowCmd.h" 32 31 #include "FlowTypes.h" 32 #include "Flow.h" 33 33 #include "FlowBox.h" 34 34 #include "FlowParticles.h" … … 36 36 #include "TransferFunction.h" 37 37 #include "NvLIC.h" 38 #include "Trace.h"39 38 #include "Unirect.h" 40 39 #include "VelocityArrowsSlice.h" 41 40 #include "Volume.h" 41 #include "Trace.h" 42 42 43 43 using namespace vrmath; … … 68 68 }; 69 69 70 Rappture::SwitchSpec Flow Cmd::_switches[] = {70 Rappture::SwitchSpec Flow::_switches[] = { 71 71 {Rappture::SWITCH_FLOAT, "-ambient", "value", 72 72 offsetof(FlowValues, ambient), 0}, … … 128 128 }; 129 129 130 static Tcl_ObjCmdProc FlowInstObjCmd;131 static Tcl_CmdDeleteProc FlowInstDeleteProc;132 133 FlowCmd::FlowCmd(Tcl_Interp *interp, const char *name) :134 _interp(interp),135 _name(name),136 _data(NULL),137 _volume(NULL),138 _field(NULL)139 {140 memset(&_sv, 0, sizeof(FlowValues));141 _sv.sliceVisible = 1;142 _sv.transferFunction = NanoVis::getTransferFunction("default");143 144 _cmdToken = Tcl_CreateObjCommand(_interp, (char *)name,145 (Tcl_ObjCmdProc *)FlowInstObjCmd,146 this, FlowInstDeleteProc);147 }148 149 FlowCmd::~FlowCmd()150 {151 TRACE("Enter");152 153 Rappture::FreeSwitches(_switches, &_sv, 0);154 if (_field != NULL) {155 delete _field;156 }157 if (_data != NULL) {158 delete _data;159 }160 if (_volume != NULL) {161 NanoVis::removeVolume(_volume);162 _volume = NULL;163 }164 for (BoxHashmap::iterator itr = _boxTable.begin();165 itr != _boxTable.end(); ++itr) {166 delete itr->second;167 }168 _boxTable.clear();169 for (ParticlesHashmap::iterator itr = _particlesTable.begin();170 itr != _particlesTable.end(); ++itr) {171 delete itr->second;172 }173 _particlesTable.clear();174 }175 176 void177 FlowCmd::getBounds(Vector3f& min,178 Vector3f& max,179 bool onlyVisible)180 {181 TRACE("Enter");182 183 if (onlyVisible && !visible())184 return;185 186 #if 0 // Using volume bounds instead of these187 if (isDataLoaded()) {188 Vector3f umin, umax;189 Rappture::Unirect3d *unirect = data();190 unirect->getWorldSpaceBounds(umin, umax);191 if (min.x > umin.x) {192 min.x = umin.x;193 }194 if (max.x < umax.x) {195 max.x = umax.x;196 }197 if (min.y > umin.y) {198 min.y = umin.y;199 }200 if (max.y < umax.y) {201 max.y = umax.y;202 }203 if (min.z > umin.z) {204 min.z = umin.z;205 }206 if (max.z < umax.z) {207 max.z = umax.z;208 }209 }210 #endif211 for (BoxHashmap::iterator itr = _boxTable.begin();212 itr != _boxTable.end(); ++itr) {213 FlowBox *box = itr->second;214 if (!onlyVisible || box->visible()) {215 Vector3f fbmin, fbmax;216 box->getWorldSpaceBounds(fbmin, fbmax,217 getVolume());218 if (min.x > fbmin.x) {219 min.x = fbmin.x;220 }221 if (max.x < fbmax.x) {222 max.x = fbmax.x;223 }224 if (min.y > fbmin.y) {225 min.y = fbmin.y;226 }227 if (max.y < fbmax.y) {228 max.y = fbmax.y;229 }230 if (min.z > fbmin.z) {231 min.z = fbmin.z;232 }233 if (max.z < fbmax.z) {234 max.z = fbmax.z;235 }236 }237 }238 }239 240 void241 FlowCmd::resetParticles()242 {243 for (ParticlesHashmap::iterator itr = _particlesTable.begin();244 itr != _particlesTable.end(); ++itr) {245 itr->second->reset();246 }247 }248 249 void250 FlowCmd::advect()251 {252 NvVectorField *fieldPtr = getVectorField();253 fieldPtr->active(true);254 for (ParticlesHashmap::iterator itr = _particlesTable.begin();255 itr != _particlesTable.end(); ++itr) {256 if (itr->second->visible()) {257 itr->second->advect();258 }259 }260 }261 262 void263 FlowCmd::render()264 {265 _field->active(true);266 _field->render();267 for (ParticlesHashmap::iterator itr = _particlesTable.begin();268 itr != _particlesTable.end(); ++itr) {269 if (itr->second->visible()) {270 itr->second->render();271 }272 }273 renderBoxes();274 }275 276 FlowParticles *277 FlowCmd::createParticles(const char *particlesName)278 {279 ParticlesHashmap::iterator itr = _particlesTable.find(particlesName);280 if (itr != _particlesTable.end()) {281 TRACE("Deleting existing particle injection plane '%s'", particlesName);282 delete itr->second;283 _particlesTable.erase(itr);284 }285 FlowParticles *particles = new FlowParticles(particlesName);286 _particlesTable[particlesName] = particles;287 return particles;288 }289 290 FlowParticles *291 FlowCmd::getParticles(const char *particlesName)292 {293 ParticlesHashmap::iterator itr;294 itr = _particlesTable.find(particlesName);295 if (itr == _particlesTable.end()) {296 TRACE("Can't find particle injection plane '%s' in '%s'", particlesName, name());297 return NULL;298 }299 return itr->second;300 }301 302 void303 FlowCmd::deleteParticles(const char *particlesName)304 {305 ParticlesHashmap::iterator itr = _particlesTable.find(particlesName);306 if (itr == _particlesTable.end()) {307 TRACE("Can't find particle injection plane '%s' in '%s'", particlesName, name());308 return;309 }310 delete itr->second;311 _particlesTable.erase(itr);312 }313 314 void315 FlowCmd::getParticlesNames(std::vector<std::string>& names)316 {317 for (ParticlesHashmap::iterator itr = _particlesTable.begin();318 itr != _particlesTable.end(); ++itr) {319 names.push_back(std::string(itr->second->name()));320 }321 }322 323 FlowBox *324 FlowCmd::createBox(const char *boxName)325 {326 BoxHashmap::iterator itr = _boxTable.find(boxName);327 if (itr != _boxTable.end()) {328 TRACE("Deleting existing box '%s'", boxName);329 delete itr->second;330 _boxTable.erase(itr);331 }332 FlowBox *box = new FlowBox(boxName);333 _boxTable[boxName] = box;334 return box;335 }336 337 FlowBox *338 FlowCmd::getBox(const char *boxName)339 {340 BoxHashmap::iterator itr = _boxTable.find(boxName);341 if (itr == _boxTable.end()) {342 TRACE("Can't find box '%s' in '%s'", boxName, name());343 return NULL;344 }345 return itr->second;346 }347 348 void349 FlowCmd::deleteBox(const char *boxName)350 {351 BoxHashmap::iterator itr = _boxTable.find(boxName);352 if (itr == _boxTable.end()) {353 TRACE("Can't find box '%s' in '%s'", boxName, name());354 return;355 }356 delete itr->second;357 _boxTable.erase(itr);358 }359 360 void FlowCmd::getBoxNames(std::vector<std::string>& names)361 {362 for (BoxHashmap::iterator itr = _boxTable.begin();363 itr != _boxTable.end(); ++itr) {364 names.push_back(std::string(itr->second->name()));365 }366 }367 368 void369 FlowCmd::initializeParticles()370 {371 for (ParticlesHashmap::iterator itr = _particlesTable.begin();372 itr != _particlesTable.end(); ++itr) {373 itr->second->initialize();374 }375 }376 377 bool378 FlowCmd::scaleVectorField()379 {380 if (_volume != NULL) {381 TRACE("Removing existing volume: %s", _volume->name());382 NanoVis::removeVolume(_volume);383 _volume = NULL;384 }385 float *vdata = getScaledVector();386 if (vdata == NULL) {387 return false;388 }389 Volume *volume = makeVolume(vdata);390 delete [] vdata;391 if (volume == NULL) {392 return false;393 }394 _volume = volume;395 396 // Remove the associated vector field.397 if (_field != NULL) {398 delete _field;399 }400 _field = new NvVectorField();401 if (_field == NULL) {402 return false;403 }404 405 Vector3f scale = volume->getPhysicalScaling();406 Vector3f location = _volume->location();407 408 _field->setVectorField(_volume,409 location,410 scale.x,411 scale.y,412 scale.z,413 NanoVis::magMax);414 415 if (NanoVis::licRenderer != NULL) {416 NanoVis::licRenderer->417 setVectorField(_volume->textureID(),418 location,419 scale.x,420 scale.y,421 scale.z,422 _volume->wAxis.max());423 setCurrentPosition();424 setAxis();425 setActive();426 }427 428 if (NanoVis::velocityArrowsSlice != NULL) {429 NanoVis::velocityArrowsSlice->430 setVectorField(_volume->textureID(),431 location,432 scale.x,433 scale.y,434 scale.z,435 _volume->wAxis.max());436 NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis);437 NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value);438 NanoVis::velocityArrowsSlice->enabled(_sv.showArrows);439 }440 441 for (ParticlesHashmap::iterator itr = _particlesTable.begin();442 itr != _particlesTable.end(); ++itr) {443 itr->second->setVectorField(_volume,444 location,445 scale.x,446 scale.y,447 scale.z,448 _volume->wAxis.max());449 }450 return true;451 }452 453 void454 FlowCmd::renderBoxes()455 {456 for (BoxHashmap::iterator itr = _boxTable.begin();457 itr != _boxTable.end(); ++itr) {458 if (itr->second->visible()) {459 itr->second->render(_volume);460 }461 }462 }463 464 float *465 FlowCmd::getScaledVector()466 {467 assert(_data->nComponents() == 3);468 size_t n = _data->nValues() / _data->nComponents() * 4;469 float *data = new float[n];470 if (data == NULL) {471 return NULL;472 }473 memset(data, 0, sizeof(float) * n);474 float *destPtr = data;475 const float *values = _data->values();476 for (size_t iz = 0; iz < _data->zNum(); iz++) {477 for (size_t iy = 0; iy < _data->yNum(); iy++) {478 for (size_t ix = 0; ix < _data->xNum(); ix++) {479 double vx, vy, vz, vm;480 vx = values[0];481 vy = values[1];482 vz = values[2];483 vm = sqrt(vx*vx + vy*vy + vz*vz);484 destPtr[0] = vm / NanoVis::magMax;485 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5;486 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5;487 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5;488 values += 3;489 destPtr += 4;490 }491 }492 }493 return data;494 }495 496 Volume *497 FlowCmd::makeVolume(float *data)498 {499 Volume *volume =500 NanoVis::loadVolume(_name.c_str(),501 _data->xNum(),502 _data->yNum(),503 _data->zNum(),504 4, data,505 NanoVis::magMin, NanoVis::magMax, 0);506 volume->xAxis.setRange(_data->xMin(), _data->xMax());507 volume->yAxis.setRange(_data->yMin(), _data->yMax());508 volume->zAxis.setRange(_data->zMin(), _data->zMax());509 510 TRACE("min=%g %g %g max=%g %g %g mag=%g %g",511 NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,512 NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,513 NanoVis::magMin, NanoVis::magMax);514 515 volume->disableCutplane(0);516 volume->disableCutplane(1);517 volume->disableCutplane(2);518 519 /* Initialize the volume with the previously configured values. */520 volume->transferFunction(_sv.transferFunction);521 volume->dataEnabled(_sv.showVolume);522 volume->twoSidedLighting(_sv.twoSidedLighting);523 volume->outline(_sv.showOutline);524 volume->opacityScale(_sv.opacity);525 volume->ambient(_sv.ambient);526 volume->diffuse(_sv.diffuse);527 volume->specularLevel(_sv.specular);528 volume->specularExponent(_sv.specularExp);529 volume->visible(_sv.showVolume);530 531 Vector3f volScaling = volume->getPhysicalScaling();532 Vector3f loc(volScaling);533 loc *= -0.5;534 volume->location(loc);535 536 Volume::updatePending = true;537 return volume;538 }539 540 130 static int 541 131 FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 566 156 Rappture::Unirect3d *dataPtr; 567 157 dataPtr = new Rappture::Unirect3d(nComponents); 568 Flow Cmd *flowPtr = (FlowCmd*)clientData;158 Flow *flow = (Flow *)clientData; 569 159 size_t length = buf.size(); 570 160 char *bytes = (char *)buf.bytes(); … … 603 193 return TCL_ERROR; 604 194 } 605 flow Ptr->data(dataPtr);195 flow->data(dataPtr); 606 196 NanoVis::eventuallyRedraw(NanoVis::MAP_FLOWS); 607 197 return TCL_OK; … … 649 239 dataPtr = new Rappture::Unirect3d(nComponents); 650 240 651 Flow Cmd *flowPtr = (FlowCmd*)clientData;241 Flow *flow = (Flow *)clientData; 652 242 size_t length = buf.size(); 653 243 char *bytes = (char *)buf.bytes(); … … 699 289 TRACE("magMin = %lg magMax = %lg", 700 290 dataPtr->magMin(), dataPtr->magMax()); 701 flow Ptr->data(dataPtr);291 flow->data(dataPtr); 702 292 { 703 293 char info[1024]; … … 706 296 707 297 length = sprintf(info, "nv>data tag %s min %g max %g\n", 708 flow Ptr->name(), dataPtr->magMin(), dataPtr->magMax());298 flow->name(), dataPtr->magMin(), dataPtr->magMax()); 709 299 nWritten = write(1, info, length); 710 300 assert(nWritten == (ssize_t)strlen(info)); … … 732 322 } 733 323 return (*proc) (clientData, interp, objc, objv); 734 }735 736 float737 FlowCmd::getRelativePosition(FlowPosition *posPtr)738 {739 if (posPtr->flags == RELPOS) {740 return posPtr->value;741 }742 switch (posPtr->axis) {743 case AXIS_X:744 return (posPtr->value - NanoVis::xMin) /745 (NanoVis::xMax - NanoVis::xMin);746 case AXIS_Y:747 return (posPtr->value - NanoVis::yMin) /748 (NanoVis::yMax - NanoVis::yMin);749 case AXIS_Z:750 return (posPtr->value - NanoVis::zMin) /751 (NanoVis::zMax - NanoVis::zMin);752 }753 return 0.0;754 }755 756 float757 FlowCmd::getRelativePosition()758 {759 return FlowCmd::getRelativePosition(&_sv.slicePos);760 }761 762 /* Static NanoVis class commands. */763 764 FlowCmd *765 NanoVis::getFlow(const char *name)766 {767 FlowHashmap::iterator itr = flowTable.find(name);768 if (itr == flowTable.end()) {769 TRACE("Can't find flow '%s'", name);770 return NULL;771 }772 return itr->second;773 }774 775 FlowCmd *776 NanoVis::createFlow(Tcl_Interp *interp, const char *name)777 {778 FlowHashmap::iterator itr = flowTable.find(name);779 if (itr != flowTable.end()) {780 ERROR("Flow '%s' already exists", name);781 return NULL;782 }783 FlowCmd *flow = new FlowCmd(interp, name);784 flowTable[name] = flow;785 return flow;786 }787 788 /**789 * \brief Delete flow object and hash table entry790 *791 * This is called by the flow command instance delete callback792 */793 void794 NanoVis::deleteFlow(const char *name)795 {796 FlowHashmap::iterator itr = flowTable.find(name);797 if (itr != flowTable.end()) {798 delete itr->second;799 flowTable.erase(itr);800 }801 }802 803 /**804 * \brief Delete all flow object commands805 *806 * This will also delete the flow objects and hash table entries807 */808 void809 NanoVis::deleteFlows(Tcl_Interp *interp)810 {811 FlowHashmap::iterator itr;812 for (itr = flowTable.begin();813 itr != flowTable.end(); ++itr) {814 Tcl_DeleteCommandFromToken(interp, itr->second->getCommandToken());815 }816 flowTable.clear();817 }818 819 bool820 NanoVis::mapFlows()821 {822 TRACE("Enter");823 824 flags &= ~MAP_FLOWS;825 826 /*827 * Step 1. Get the overall min and max magnitudes of all the828 * flow vectors.829 */830 magMin = DBL_MAX, magMax = -DBL_MAX;831 832 for (FlowHashmap::iterator itr = flowTable.begin();833 itr != flowTable.end(); ++itr) {834 FlowCmd *flow = itr->second;835 double min, max;836 if (!flow->isDataLoaded()) {837 continue;838 }839 Rappture::Unirect3d *data = flow->data();840 min = data->magMin();841 max = data->magMax();842 if (min < magMin) {843 magMin = min;844 }845 if (max > magMax) {846 magMax = max;847 }848 if (data->xMin() < xMin) {849 xMin = data->xMin();850 }851 if (data->yMin() < yMin) {852 yMin = data->yMin();853 }854 if (data->zMin() < zMin) {855 zMin = data->zMin();856 }857 if (data->xMax() > xMax) {858 xMax = data->xMax();859 }860 if (data->yMax() > yMax) {861 yMax = data->yMax();862 }863 if (data->zMax() > zMax) {864 zMax = data->zMax();865 }866 }867 868 TRACE("magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax);869 870 /*871 * Step 2. Generate the vector field from each data set.872 */873 for (FlowHashmap::iterator itr = flowTable.begin();874 itr != flowTable.end(); ++itr) {875 FlowCmd *flow = itr->second;876 if (!flow->isDataLoaded()) {877 continue; // Flow exists, but no data has been loaded yet.878 }879 if (flow->visible()) {880 flow->initializeParticles();881 }882 if (!flow->scaleVectorField()) {883 return false;884 }885 // FIXME: This doesn't work when there is more than one flow.886 licRenderer->setOffset(flow->getRelativePosition());887 velocityArrowsSlice->slicePos(flow->getRelativePosition());888 }889 advectFlows();890 return true;891 }892 893 void894 NanoVis::getFlowBounds(Vector3f& min,895 Vector3f& max,896 bool onlyVisible)897 {898 TRACE("Enter");899 900 min.set(FLT_MAX, FLT_MAX, FLT_MAX);901 max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);902 903 for (FlowHashmap::iterator itr = flowTable.begin();904 itr != flowTable.end(); ++itr) {905 itr->second->getBounds(min, max, onlyVisible);906 }907 }908 909 void910 NanoVis::renderFlows()911 {912 for (FlowHashmap::iterator itr = flowTable.begin();913 itr != flowTable.end(); ++itr) {914 FlowCmd *flow = itr->second;915 if (flow->isDataLoaded() && flow->visible()) {916 flow->render();917 }918 }919 flags &= ~REDRAW_PENDING;920 }921 922 void923 NanoVis::resetFlows()924 {925 if (licRenderer->active()) {926 NanoVis::licRenderer->reset();927 }928 for (FlowHashmap::iterator itr = flowTable.begin();929 itr != flowTable.end(); ++itr) {930 FlowCmd *flow = itr->second;931 if (flow->isDataLoaded() && flow->visible()) {932 flow->resetParticles();933 }934 }935 }936 937 void938 NanoVis::advectFlows()939 {940 for (FlowHashmap::iterator itr = flowTable.begin();941 itr != flowTable.end(); ++itr) {942 FlowCmd *flow = itr->second;943 if (flow->isDataLoaded() && flow->visible()) {944 flow->advect();945 }946 }947 324 } 948 325 … … 969 346 const char *string = Tcl_GetString(objPtr); 970 347 if (string[1] == '\0') { 971 Flow Cmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);348 Flow::SliceAxis *axisPtr = (Flow::SliceAxis *)(record + offset); 972 349 char c; 973 350 c = tolower((unsigned char)string[0]); 974 351 if (c == 'x') { 975 *axisPtr = Flow Cmd::AXIS_X;352 *axisPtr = Flow::AXIS_X; 976 353 return TCL_OK; 977 354 } else if (c == 'y') { 978 *axisPtr = Flow Cmd::AXIS_Y;355 *axisPtr = Flow::AXIS_Y; 979 356 return TCL_OK; 980 357 } else if (c == 'z') { 981 *axisPtr = Flow Cmd::AXIS_Z;358 *axisPtr = Flow::AXIS_Z; 982 359 return TCL_OK; 983 360 } … … 1175 552 Tcl_Obj *const *objv) 1176 553 { 1177 Flow Cmd *flowPtr = (FlowCmd*)clientData;1178 1179 if (flow Ptr->parseSwitches(interp, objc - 2, objv + 2) != TCL_OK) {554 Flow *flow = (Flow *)clientData; 555 556 if (flow->parseSwitches(interp, objc - 2, objv + 2) != TCL_OK) { 1180 557 return TCL_ERROR; 1181 558 } … … 1188 565 Tcl_Obj *const *objv) 1189 566 { 1190 Flow Cmd *flow = (FlowCmd*)clientData;567 Flow *flow = (Flow *)clientData; 1191 568 const char *particlesName = Tcl_GetString(objv[3]); 1192 569 FlowParticles *particles = flow->createParticles(particlesName); … … 1212 589 Tcl_Obj *const *objv) 1213 590 { 1214 Flow Cmd *flow = (FlowCmd*)clientData;591 Flow *flow = (Flow *)clientData; 1215 592 const char *particlesName = Tcl_GetString(objv[3]); 1216 593 FlowParticles *particles = flow->getParticles(particlesName); … … 1233 610 Tcl_Obj *const *objv) 1234 611 { 1235 Flow Cmd *flow = (FlowCmd*)clientData;612 Flow *flow = (Flow *)clientData; 1236 613 for (int i = 3; i < objc; i++) { 1237 614 flow->deleteParticles(Tcl_GetString(objv[i])); … … 1245 622 Tcl_Obj *const *objv) 1246 623 { 1247 Flow Cmd *flow = (FlowCmd*)clientData;624 Flow *flow = (Flow *)clientData; 1248 625 Tcl_Obj *listObjPtr; 1249 626 listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); … … 1288 665 return TCL_ERROR; 1289 666 } 1290 Flow Cmd *flowPtr = (FlowCmd*)clientData;1291 Tcl_Preserve(flow Ptr);667 Flow *flow = (Flow *)clientData; 668 Tcl_Preserve(flow); 1292 669 int result; 1293 670 result = (*proc) (clientData, interp, objc, objv); 1294 Tcl_Release(flow Ptr);671 Tcl_Release(flow); 1295 672 return result; 1296 673 } … … 1300 677 Tcl_Obj *const *objv) 1301 678 { 1302 Flow Cmd *flow = (FlowCmd*)clientData;679 Flow *flow = (Flow *)clientData; 1303 680 const char *boxName = Tcl_GetString(objv[3]); 1304 681 FlowBox *box = flow->createBox(boxName); … … 1322 699 Tcl_Obj *const *objv) 1323 700 { 1324 Flow Cmd *flow = (FlowCmd*)clientData;701 Flow *flow = (Flow *)clientData; 1325 702 const char *boxName = Tcl_GetString(objv[3]); 1326 703 FlowBox *box = flow->getBox(boxName); … … 1341 718 Tcl_Obj *const *objv) 1342 719 { 1343 Flow Cmd *flow = (FlowCmd*)clientData;720 Flow *flow = (Flow *)clientData; 1344 721 for (int i = 3; i < objc; i++) { 1345 722 flow->deleteBox(Tcl_GetString(objv[i])); … … 1353 730 Tcl_Obj *const *objv) 1354 731 { 1355 Flow Cmd *flow = (FlowCmd*)clientData;732 Flow *flow = (Flow *)clientData; 1356 733 Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); 1357 734 std::vector<std::string> names; … … 1393 770 return TCL_ERROR; 1394 771 } 1395 Flow Cmd *flowPtr = (FlowCmd*)clientData;1396 Tcl_Preserve(flow Ptr);772 Flow *flow = (Flow *)clientData; 773 Tcl_Preserve(flow); 1397 774 int result; 1398 775 result = (*proc) (clientData, interp, objc, objv); 1399 Tcl_Release(flow Ptr);776 Tcl_Release(flow); 1400 777 return result; 1401 778 } … … 1414 791 Tcl_Obj *const *objv) 1415 792 { 1416 Flow Cmd *flowPtr = (FlowCmd*)clientData;793 Flow *flow = (Flow *)clientData; 1417 794 1418 795 const char *string = Tcl_GetString(objv[1]); 1419 796 TransferFunction *tf; 1420 tf = flow Ptr->getTransferFunction();797 tf = flow->getTransferFunction(); 1421 798 if (tf == NULL) { 1422 799 Tcl_AppendResult(interp, "unknown transfer function \"", string, "\"", … … 1455 832 * \return A standard Tcl result. 1456 833 */ 1457 staticint834 int 1458 835 FlowInstObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1459 836 Tcl_Obj *const *objv) … … 1466 843 } 1467 844 assert(CheckGL(AT)); 1468 Flow Cmd *flow = (FlowCmd*)clientData;845 Flow *flow = (Flow *)clientData; 1469 846 Tcl_Preserve(flow); 1470 847 int result = (*proc) (clientData, interp, objc, objv); … … 1478 855 * This is called only when the command associated with the flow is destroyed. 1479 856 */ 1480 staticvoid857 void 1481 858 FlowInstDeleteProc(ClientData clientData) 1482 859 { 1483 Flow Cmd *flow = (FlowCmd*)clientData;860 Flow *flow = (Flow *)clientData; 1484 861 NanoVis::deleteFlow(flow->name()); 1485 862 } … … 1496 873 return TCL_ERROR; 1497 874 } 1498 Flow Cmd*flow = NanoVis::createFlow(interp, name);875 Flow *flow = NanoVis::createFlow(interp, name); 1499 876 if (flow == NULL) { 1500 877 Tcl_AppendResult(interp, "Flow \"", name, "\" already exists", … … 1516 893 { 1517 894 for (int i = 2; i < objc; i++) { 1518 Flow Cmd*flow = NanoVis::getFlow(Tcl_GetString(objv[i]));895 Flow *flow = NanoVis::getFlow(Tcl_GetString(objv[i])); 1519 896 if (flow != NULL) { 1520 897 Tcl_DeleteCommandFromToken(interp, flow->getCommandToken()); … … 1530 907 { 1531 908 bool value = false; 1532 Flow Cmd*flow = NanoVis::getFlow(Tcl_GetString(objv[2]));909 Flow *flow = NanoVis::getFlow(Tcl_GetString(objv[2])); 1533 910 if (flow != NULL) { 1534 911 value = true; … … 1577 954 for (NanoVis::FlowHashmap::iterator itr = NanoVis::flowTable.begin(); 1578 955 itr != NanoVis::flowTable.end(); ++itr) { 1579 Flow Cmd*flow = itr->second;956 Flow *flow = itr->second; 1580 957 Tcl_Obj *objPtr = Tcl_NewStringObj(flow->name(), -1); 1581 958 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); … … 1668 1045 }; 1669 1046 1670 Rappture::SwitchSpec FlowCmd::videoSwitches[] = {1047 static Rappture::SwitchSpec flowVideoSwitches[] = { 1671 1048 {Rappture::SWITCH_INT, "-bitrate", "value", 1672 1049 offsetof(FlowVideoSwitches, bitRate), 0}, … … 1872 1249 switches.formatObjPtr = Tcl_NewStringObj("mpeg1video", 10); 1873 1250 Tcl_IncrRefCount(switches.formatObjPtr); 1874 if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,1251 if (Rappture::ParseSwitches(interp, flowVideoSwitches, 1875 1252 objc - 3, objv + 3, &switches, SWITCH_DEFAULTS) < 0) { 1876 1253 return TCL_ERROR; … … 1918 1295 tmpFileName[length] = '\0'; 1919 1296 rmdir(tmpFileName); 1920 Rappture::FreeSwitches( FlowCmd::videoSwitches, &switches, 0);1297 Rappture::FreeSwitches(flowVideoSwitches, &switches, 0); 1921 1298 return result; 1922 1299 }
Note: See TracChangeset
for help on using the changeset viewer.