Changeset 3844 for branches/1.3/packages
- Timestamp:
- Jul 26, 2013, 6:00:09 PM (11 years ago)
- Location:
- branches/1.3
- Files:
-
- 25 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/packages/vizservers/vtkvis/Contour3D.cpp
r3680 r3844 151 151 #endif 152 152 _contourFilter->SetInputConnection(mesher->GetOutputPort()); 153 } else if (vtkPolyData::SafeDownCast(ds) != NULL) {154 // DataSet is a vtkPolyData with lines and/or polygons155 ERROR("Not a 3D DataSet");156 return;157 153 } else { 158 // DataSet is NOT a vtkPolyData 154 // DataSet is 3D with cells. If DataSet is a surface 155 // (e.g. polydata or ugrid with 2D cells), we will 156 // generate lines instead of surfaces 159 157 #ifdef USE_VTK6 160 158 _contourFilter->SetInputData(ds); -
branches/1.3/packages/vizservers/vtkvis/DataSet.cpp
r3710 r3844 24 24 #include <vtkCell.h> 25 25 #include <vtkLookupTable.h> 26 #include <vtkExtractUnstructuredGrid.h> 26 27 27 28 #include "DataSet.h" … … 145 146 } 146 147 147 void DataSet::print() const148 {149 print(_dataSet);150 }151 152 void DataSet::print(vtkDataSet *ds)153 {154 if (ds == NULL)155 return;156 157 TRACE("DataSet class: %s", ds->GetClassName());158 159 TRACE("DataSet memory: %g MiB", ds->GetActualMemorySize()/1024.);160 161 double bounds[6];162 ds->GetBounds(bounds);163 164 // Topology165 TRACE("DataSet bounds: %g %g %g %g %g %g",166 bounds[0], bounds[1],167 bounds[2], bounds[3],168 bounds[4], bounds[5]);169 TRACE("Points: %d Cells: %d", ds->GetNumberOfPoints(), ds->GetNumberOfCells());170 171 double dataRange[2];172 if (ds->GetPointData() != NULL) {173 TRACE("PointData arrays: %d", ds->GetPointData()->GetNumberOfArrays());174 for (int i = 0; i < ds->GetPointData()->GetNumberOfArrays(); i++) {175 if (ds->GetPointData()->GetArray(i) != NULL) {176 ds->GetPointData()->GetArray(i)->GetRange(dataRange, -1);177 TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i,178 ds->GetPointData()->GetArrayName(i),179 ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents(),180 dataRange[0], dataRange[1]);181 } else {182 TRACE("PointData[%d]: '%s' comp:%d", i,183 ds->GetPointData()->GetArrayName(i),184 ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents());185 }186 }187 if (ds->GetPointData()->GetScalars() != NULL) {188 TRACE("Active point scalars: %s", ds->GetPointData()->GetScalars()->GetName());189 }190 if (ds->GetPointData()->GetVectors() != NULL) {191 TRACE("Active point vectors: %s", ds->GetPointData()->GetVectors()->GetName());192 }193 }194 if (ds->GetCellData() != NULL) {195 TRACE("CellData arrays: %d", ds->GetCellData()->GetNumberOfArrays());196 for (int i = 0; i < ds->GetCellData()->GetNumberOfArrays(); i++) {197 if (ds->GetCellData()->GetArray(i) != NULL) {198 ds->GetCellData()->GetArray(i)->GetRange(dataRange, -1);199 TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i,200 ds->GetCellData()->GetArrayName(i),201 ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents(),202 dataRange[0], dataRange[1]);203 } else {204 TRACE("CellData[%d]: '%s' comp:%d", i,205 ds->GetCellData()->GetArrayName(i),206 ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents());207 }208 }209 if (ds->GetCellData()->GetScalars() != NULL) {210 TRACE("Active cell scalars: %s", ds->GetCellData()->GetScalars()->GetName());211 }212 if (ds->GetCellData()->GetVectors() != NULL) {213 TRACE("Active cell vectors: %s", ds->GetCellData()->GetVectors()->GetName());214 }215 }216 if (ds->GetFieldData() != NULL) {217 TRACE("FieldData arrays: %d", ds->GetFieldData()->GetNumberOfArrays());218 for (int i = 0; i < ds->GetFieldData()->GetNumberOfArrays(); i++) {219 if (ds->GetFieldData()->GetArray(i) != NULL) {220 ds->GetFieldData()->GetArray(i)->GetRange(dataRange, -1);221 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i,222 ds->GetFieldData()->GetArrayName(i),223 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(),224 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples(),225 dataRange[0], dataRange[1]);226 } else {227 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d", i,228 ds->GetFieldData()->GetArrayName(i),229 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(),230 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples());231 }232 }233 }234 }235 236 void DataSet::setDefaultArrays()237 {238 if (_dataSet->GetPointData() != NULL &&239 _dataSet->GetPointData()->GetScalars() == NULL &&240 _dataSet->GetPointData()->GetNumberOfArrays() > 0) {241 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {242 if (_dataSet->GetPointData()->GetArray(i) != NULL &&243 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) {244 TRACE("Setting point scalars to '%s'", _dataSet->GetPointData()->GetArrayName(i));245 _dataSet->GetPointData()->SetActiveScalars(_dataSet->GetPointData()->GetArrayName(i));246 break;247 }248 }249 }250 if (_dataSet->GetPointData() != NULL &&251 _dataSet->GetPointData()->GetVectors() == NULL &&252 _dataSet->GetPointData()->GetNumberOfArrays() > 0) {253 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {254 if (_dataSet->GetPointData()->GetArray(i) != NULL &&255 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) {256 TRACE("Setting point vectors to '%s'", _dataSet->GetPointData()->GetArrayName(i));257 _dataSet->GetPointData()->SetActiveVectors(_dataSet->GetPointData()->GetArrayName(i));258 break;259 }260 }261 }262 if (_dataSet->GetCellData() != NULL &&263 _dataSet->GetCellData()->GetScalars() == NULL &&264 _dataSet->GetCellData()->GetNumberOfArrays() > 0) {265 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {266 if (_dataSet->GetCellData()->GetArray(i) != NULL &&267 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) {268 TRACE("Setting cell scalars to '%s'", _dataSet->GetCellData()->GetArrayName(i));269 _dataSet->GetCellData()->SetActiveScalars(_dataSet->GetCellData()->GetArrayName(i));270 break;271 }272 }273 }274 if (_dataSet->GetCellData() != NULL &&275 _dataSet->GetCellData()->GetVectors() == NULL &&276 _dataSet->GetCellData()->GetNumberOfArrays() > 0) {277 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {278 if (_dataSet->GetCellData()->GetArray(i) != NULL &&279 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) {280 TRACE("Setting cell vectors to '%s'", _dataSet->GetCellData()->GetArrayName(i));281 _dataSet->GetCellData()->SetActiveVectors(_dataSet->GetCellData()->GetArrayName(i));282 break;283 }284 }285 }286 }287 288 148 /** 289 149 * \brief Read dataset using supplied reader … … 303 163 if (_dataSet == NULL) 304 164 return false; 165 166 if (vtkUnstructuredGrid::SafeDownCast(_dataSet) != NULL) { 167 vtkSmartPointer<vtkExtractUnstructuredGrid> filter = vtkSmartPointer<vtkExtractUnstructuredGrid>::New(); 168 #ifdef USE_VTK6 169 filter->SetInputData(_dataSet); 170 #else 171 filter->SetInput(_dataSet); 172 #endif 173 filter->MergingOn(); 174 filter->ReleaseDataFlagOn(); 175 filter->Update(); 176 _dataSet = filter->GetOutput(); 177 } 178 305 179 #ifndef USE_VTK6 306 180 _dataSet->SetPipelineInformation(NULL); … … 560 434 return _dataSet->GetPointData()->GetScalars()->GetName(); 561 435 } 436 #ifdef DEBUG 562 437 TRACE("No point scalars"); 438 #endif 563 439 if (_dataSet->GetCellData() != NULL && 564 440 _dataSet->GetCellData()->GetScalars() != NULL) { 565 441 return _dataSet->GetCellData()->GetScalars()->GetName(); 566 442 } 443 #ifdef DEBUG 567 444 TRACE("No cell scalars"); 445 #endif 568 446 } 569 447 return NULL; … … 580 458 return POINT_DATA; 581 459 } 460 #ifdef DEBUG 582 461 TRACE("No point scalars"); 462 #endif 583 463 if (_dataSet->GetCellData() != NULL && 584 464 _dataSet->GetCellData()->GetScalars() != NULL) { 585 465 return CELL_DATA; 586 466 } 467 #ifdef DEBUG 587 468 TRACE("No cell scalars"); 469 #endif 588 470 } 589 471 return POINT_DATA; … … 624 506 return POINT_DATA; 625 507 } 508 #ifdef DEBUG 626 509 TRACE("No point vectors"); 510 #endif 627 511 if (_dataSet->GetCellData() != NULL && 628 512 _dataSet->GetCellData()->GetVectors() != NULL) { 629 513 return CELL_DATA; 630 514 } 515 #ifdef DEBUG 631 516 TRACE("No cell vectors"); 517 #endif 632 518 } 633 519 return POINT_DATA; … … 644 530 return _dataSet->GetPointData()->GetVectors()->GetName(); 645 531 } 532 #ifdef DEBUG 646 533 TRACE("No point vectors"); 534 #endif 647 535 if (_dataSet->GetCellData() != NULL && 648 536 _dataSet->GetCellData()->GetVectors() != NULL) { 649 537 return _dataSet->GetCellData()->GetVectors()->GetName(); 650 538 } 539 #ifdef DEBUG 651 540 TRACE("No cell vectors"); 541 #endif 652 542 } 653 543 return NULL; 544 } 545 546 void DataSet::setDefaultArrays() 547 { 548 if (_dataSet->GetPointData() != NULL && 549 _dataSet->GetPointData()->GetScalars() == NULL && 550 _dataSet->GetPointData()->GetNumberOfArrays() > 0) { 551 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 552 if (_dataSet->GetPointData()->GetArray(i) != NULL && 553 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) { 554 TRACE("Setting point scalars to '%s'", _dataSet->GetPointData()->GetArrayName(i)); 555 _dataSet->GetPointData()->SetActiveScalars(_dataSet->GetPointData()->GetArrayName(i)); 556 break; 557 } 558 } 559 } 560 if (_dataSet->GetPointData() != NULL && 561 _dataSet->GetPointData()->GetVectors() == NULL && 562 _dataSet->GetPointData()->GetNumberOfArrays() > 0) { 563 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 564 if (_dataSet->GetPointData()->GetArray(i) != NULL && 565 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) { 566 TRACE("Setting point vectors to '%s'", _dataSet->GetPointData()->GetArrayName(i)); 567 _dataSet->GetPointData()->SetActiveVectors(_dataSet->GetPointData()->GetArrayName(i)); 568 break; 569 } 570 } 571 } 572 if (_dataSet->GetCellData() != NULL && 573 _dataSet->GetCellData()->GetScalars() == NULL && 574 _dataSet->GetCellData()->GetNumberOfArrays() > 0) { 575 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 576 if (_dataSet->GetCellData()->GetArray(i) != NULL && 577 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) { 578 TRACE("Setting cell scalars to '%s'", _dataSet->GetCellData()->GetArrayName(i)); 579 _dataSet->GetCellData()->SetActiveScalars(_dataSet->GetCellData()->GetArrayName(i)); 580 break; 581 } 582 } 583 } 584 if (_dataSet->GetCellData() != NULL && 585 _dataSet->GetCellData()->GetVectors() == NULL && 586 _dataSet->GetCellData()->GetNumberOfArrays() > 0) { 587 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 588 if (_dataSet->GetCellData()->GetArray(i) != NULL && 589 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) { 590 TRACE("Setting cell vectors to '%s'", _dataSet->GetCellData()->GetArrayName(i)); 591 _dataSet->GetCellData()->SetActiveVectors(_dataSet->GetCellData()->GetArrayName(i)); 592 break; 593 } 594 } 595 } 654 596 } 655 597 … … 973 915 return true; 974 916 } 917 918 void DataSet::print() const 919 { 920 print(_dataSet); 921 } 922 923 void DataSet::print(vtkDataSet *ds) 924 { 925 if (ds == NULL) 926 return; 927 928 TRACE("DataSet class: %s", ds->GetClassName()); 929 930 TRACE("DataSet memory: %g MiB", ds->GetActualMemorySize()/1024.); 931 932 double bounds[6]; 933 ds->GetBounds(bounds); 934 935 // Topology 936 TRACE("DataSet bounds: %g %g %g %g %g %g", 937 bounds[0], bounds[1], 938 bounds[2], bounds[3], 939 bounds[4], bounds[5]); 940 TRACE("Points: %d Cells: %d", ds->GetNumberOfPoints(), ds->GetNumberOfCells()); 941 942 double dataRange[2]; 943 if (ds->GetPointData() != NULL) { 944 TRACE("PointData arrays: %d", ds->GetPointData()->GetNumberOfArrays()); 945 for (int i = 0; i < ds->GetPointData()->GetNumberOfArrays(); i++) { 946 if (ds->GetPointData()->GetArray(i) != NULL) { 947 ds->GetPointData()->GetArray(i)->GetRange(dataRange, -1); 948 TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i, 949 ds->GetPointData()->GetArrayName(i), 950 ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents(), 951 dataRange[0], dataRange[1]); 952 } else { 953 TRACE("PointData[%d]: '%s' comp:%d", i, 954 ds->GetPointData()->GetArrayName(i), 955 ds->GetPointData()->GetAbstractArray(i)->GetNumberOfComponents()); 956 } 957 } 958 if (ds->GetPointData()->GetScalars() != NULL) { 959 TRACE("Active point scalars: %s", ds->GetPointData()->GetScalars()->GetName()); 960 } 961 if (ds->GetPointData()->GetVectors() != NULL) { 962 TRACE("Active point vectors: %s", ds->GetPointData()->GetVectors()->GetName()); 963 } 964 } 965 if (ds->GetCellData() != NULL) { 966 TRACE("CellData arrays: %d", ds->GetCellData()->GetNumberOfArrays()); 967 for (int i = 0; i < ds->GetCellData()->GetNumberOfArrays(); i++) { 968 if (ds->GetCellData()->GetArray(i) != NULL) { 969 ds->GetCellData()->GetArray(i)->GetRange(dataRange, -1); 970 TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i, 971 ds->GetCellData()->GetArrayName(i), 972 ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents(), 973 dataRange[0], dataRange[1]); 974 } else { 975 TRACE("CellData[%d]: '%s' comp:%d", i, 976 ds->GetCellData()->GetArrayName(i), 977 ds->GetCellData()->GetAbstractArray(i)->GetNumberOfComponents()); 978 } 979 } 980 if (ds->GetCellData()->GetScalars() != NULL) { 981 TRACE("Active cell scalars: %s", ds->GetCellData()->GetScalars()->GetName()); 982 } 983 if (ds->GetCellData()->GetVectors() != NULL) { 984 TRACE("Active cell vectors: %s", ds->GetCellData()->GetVectors()->GetName()); 985 } 986 } 987 if (ds->GetFieldData() != NULL) { 988 TRACE("FieldData arrays: %d", ds->GetFieldData()->GetNumberOfArrays()); 989 for (int i = 0; i < ds->GetFieldData()->GetNumberOfArrays(); i++) { 990 if (ds->GetFieldData()->GetArray(i) != NULL) { 991 ds->GetFieldData()->GetArray(i)->GetRange(dataRange, -1); 992 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i, 993 ds->GetFieldData()->GetArrayName(i), 994 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(), 995 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples(), 996 dataRange[0], dataRange[1]); 997 } else { 998 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d", i, 999 ds->GetFieldData()->GetArrayName(i), 1000 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfComponents(), 1001 ds->GetFieldData()->GetAbstractArray(i)->GetNumberOfTuples()); 1002 } 1003 } 1004 } 1005 } 1006 -
branches/1.3/packages/vizservers/vtkvis/DataSet.h
r3680 r3844 26 26 class DataSet { 27 27 public: 28 /** 29 * These enum values intentionally match vtkDataObject::FieldAssociations 30 * and vtkDataObject::AttributeTypes 31 */ 28 32 enum DataAttributeType { 29 33 POINT_DATA, -
branches/1.3/packages/vizservers/vtkvis/Glyphs.cpp
r3696 r3844 29 29 #include <vtkTransformPolyDataFilter.h> 30 30 #include <vtkPolyDataNormals.h> 31 #include <vtkDelaunay2D.h> 32 #include <vtkDelaunay3D.h> 33 #include <vtkPolyData.h> 34 #include <vtkUnstructuredGrid.h> 31 35 32 36 #include "Glyphs.h" 33 37 #include "Renderer.h" 38 #include "Math.h" 34 39 #include "Trace.h" 35 40 … … 280 285 _glyphMapper = vtkSmartPointer<vtkGlyph3DMapper>::New(); 281 286 _glyphMapper->SetResolveCoincidentTopologyToPolygonOffset(); 287 // If there are color scalars, use them without lookup table (if scalar visibility is on) 288 _glyphMapper->SetColorModeToDefault(); 282 289 _glyphMapper->ScalarVisibilityOn(); 283 290 } … … 323 330 } 324 331 325 double cellSizeRange[2]; 326 double avgSize; 327 _dataSet->getCellSizeRange(cellSizeRange, &avgSize); 328 //_dataScale = cellSizeRange[0] + (cellSizeRange[1] - cellSizeRange[0])/2.; 329 _dataScale = avgSize; 330 331 TRACE("Cell size range: %g,%g, Data scale factor: %g", 332 cellSizeRange[0], cellSizeRange[1], _dataScale); 332 if (_dataSet->isCloud()) { 333 PrincipalPlane plane; 334 double offset; 335 if (_dataSet->is2D(&plane, &offset)) { 336 // 2D cloud 337 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 338 if (plane == PLANE_ZY) { 339 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 340 trans->RotateWXYZ(90, 0, 1, 0); 341 if (offset != 0.0) { 342 trans->Translate(-offset, 0, 0); 343 } 344 mesher->SetTransform(trans); 345 } else if (plane == PLANE_XZ) { 346 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 347 trans->RotateWXYZ(-90, 1, 0, 0); 348 if (offset != 0.0) { 349 trans->Translate(0, -offset, 0); 350 } 351 mesher->SetTransform(trans); 352 } else if (offset != 0.0) { 353 // XY with Z offset 354 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 355 trans->Translate(0, 0, -offset); 356 mesher->SetTransform(trans); 357 } 358 #ifdef USE_VTK6 359 mesher->SetInputData(ds); 360 #else 361 mesher->SetInput(ds); 362 #endif 363 mesher->Update(); 364 vtkPolyData *pd = mesher->GetOutput(); 365 if (pd->GetNumberOfPolys() == 0) { 366 // Meshing failed, fall back to scale based on bounds 367 double bounds[6]; 368 _dataSet->getBounds(bounds); 369 double xlen = bounds[1] - bounds[0]; 370 double ylen = bounds[3] - bounds[2]; 371 double zlen = bounds[5] - bounds[4]; 372 double max = max3(xlen, ylen, zlen); 373 _dataScale = max / 64.0; 374 } else { 375 double cellSizeRange[2]; 376 double avgSize; 377 DataSet::getCellSizeRange(pd, cellSizeRange, &avgSize); 378 _dataScale = avgSize * 2.0; 379 } 380 } else { 381 // 3D cloud 382 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 383 #ifdef USE_VTK6 384 mesher->SetInputData(ds); 385 #else 386 mesher->SetInput(ds); 387 #endif 388 mesher->Update(); 389 vtkUnstructuredGrid *ugrid = mesher->GetOutput(); 390 if (ugrid->GetNumberOfCells() == 0) { 391 // Meshing failed, fall back to scale based on bounds 392 double bounds[6]; 393 _dataSet->getBounds(bounds); 394 double xlen = bounds[1] - bounds[0]; 395 double ylen = bounds[3] - bounds[2]; 396 double zlen = bounds[5] - bounds[4]; 397 double max = max3(xlen, ylen, zlen); 398 _dataScale = max / 64.0; 399 } else { 400 double cellSizeRange[2]; 401 double avgSize; 402 DataSet::getCellSizeRange(ugrid, cellSizeRange, &avgSize); 403 _dataScale = avgSize * 2.0; 404 } 405 } 406 } else { 407 double cellSizeRange[2]; 408 double avgSize; 409 _dataSet->getCellSizeRange(cellSizeRange, &avgSize); 410 _dataScale = avgSize * 2.0; 411 } 412 413 TRACE("Data scale factor: %g", _dataScale); 333 414 334 415 // Normalize sizes to [0,1] * ScaleFactor 335 416 _glyphMapper->SetClamping(_normalizeScale ? 1 : 0); 336 _glyphMapper->SetScaleFactor(_scaleFactor * _dataScale); 417 if (_normalizeScale) { 418 _glyphMapper->SetScaleFactor(_scaleFactor * _dataScale); 419 TRACE("Setting scale factor: %g", _scaleFactor * _dataScale); 420 } else { 421 _glyphMapper->SetScaleFactor(_scaleFactor); 422 TRACE("Setting scale factor: %g", _scaleFactor); 423 } 337 424 _glyphMapper->ScalingOn(); 338 425 … … 363 450 if (_glyphMapper != NULL) { 364 451 _glyphMapper->SetClamping(_normalizeScale ? 1 : 0); 452 if (_normalizeScale) { 453 _glyphMapper->SetScaleFactor(_scaleFactor * _dataScale); 454 TRACE("Setting scale factor: %g", _scaleFactor * _dataScale); 455 } else { 456 _glyphMapper->SetScaleFactor(_scaleFactor); 457 TRACE("Setting scale factor: %g", _scaleFactor); 458 } 365 459 } 366 460 } … … 667 761 _scaleFactor = scale; 668 762 if (_glyphMapper != NULL) { 669 _glyphMapper->SetScaleFactor(_scaleFactor * _dataScale); 763 if (_normalizeScale) { 764 _glyphMapper->SetScaleFactor(_scaleFactor * _dataScale); 765 TRACE("Setting scale factor: %g", _scaleFactor * _dataScale); 766 } else { 767 _glyphMapper->SetScaleFactor(_scaleFactor); 768 TRACE("Setting scale factor: %g", _scaleFactor); 769 } 670 770 } 671 771 } … … 787 887 788 888 /** 889 * \brief Limit the number of glyphs displayed 890 * 891 * The choice of glyphs to display can be based on sampling every 892 * n-th point (ratio) or by random sample 893 * 894 * \param max Maximum number of glyphs to display, negative means display all 895 * \param random Flag to enable/disable random sampling 896 * \param offset If random is false, this controls the first sample point 897 * \param ratio If random is false, this ratio controls every n-th point sampling 898 */ 899 void Glyphs::setMaximumNumberOfGlyphs(int max, bool random, int offset, int ratio) 900 { 901 if (_dataSet == NULL || _glyphMapper == NULL) 902 return; 903 904 if (max < 0) { 905 if (_maskPoints != NULL) { 906 #ifdef USE_VTK6 907 _glyphMapper->SetInputData(_dataSet->getVtkDataSet()); 908 #else 909 _glyphMapper->SetInputConnection(_dataSet->getVtkDataSet()->GetProducerPort()); 910 #endif 911 _maskPoints = NULL; 912 } 913 } else { 914 if (_maskPoints == NULL) { 915 _maskPoints = vtkSmartPointer<vtkMaskPoints>::New(); 916 } 917 #ifdef USE_VTK6 918 _maskPoints->SetInputData(_dataSet->getVtkDataSet()); 919 #else 920 _maskPoints->SetInput(_dataSet->getVtkDataSet()); 921 #endif 922 _maskPoints->SetMaximumNumberOfPoints(max); 923 _maskPoints->SetOffset(offset); 924 _maskPoints->SetOnRatio(ratio); 925 _maskPoints->SetRandomMode((random ? 1 : 0)); 926 _maskPoints->GenerateVerticesOff(); 927 _glyphMapper->SetInputConnection(_maskPoints->GetOutputPort()); 928 } 929 } 930 931 /** 789 932 * \brief Set a group of world coordinate planes to clip rendering 790 933 * -
branches/1.3/packages/vizservers/vtkvis/Glyphs.h
r3677 r3844 16 16 #include <vtkVersion.h> 17 17 #include <vtkGlyph3DMapper.h> 18 #include <vtkMaskPoints.h> 18 19 #include <vtkLookupTable.h> 19 20 #include <vtkPlaneCollection.h> … … 92 93 void setScaleFactor(double scale); 93 94 95 void setMaximumNumberOfGlyphs(int max, bool random = true, 96 int offset = 0, int ratio = 1); 97 94 98 void setColorMap(ColorMap *colorMap); 95 99 … … 136 140 vtkSmartPointer<vtkPolyDataAlgorithm> _glyphSource; 137 141 vtkSmartPointer<vtkGlyph3DMapper> _glyphMapper; 142 vtkSmartPointer<vtkMaskPoints> _maskPoints; 138 143 }; 139 144 -
branches/1.3/packages/vizservers/vtkvis/GraphicsObject.cpp
r3621 r3844 13 13 14 14 void GraphicsObject::setDataSet(DataSet *dataSet, 15 15 Renderer *renderer) 16 16 { 17 17 if (_dataSet != dataSet) { -
branches/1.3/packages/vizservers/vtkvis/GraphicsObject.h
r3683 r3844 14 14 #include <vtkSmartPointer.h> 15 15 #include <vtkProp.h> 16 #include <vtkActor2D.h> 16 17 #include <vtkProp3D.h> 17 18 #include <vtkProp3DCollection.h> 18 19 #include <vtkAssembly.h> 19 20 #include <vtkActor.h> 21 #include <vtkImageActor.h> 20 22 #include <vtkVolume.h> 21 23 #include <vtkProperty.h> 24 #include <vtkImageProperty.h> 22 25 #include <vtkVolumeProperty.h> 23 26 #include <vtkMath.h> … … 114 117 115 118 /** 119 * \brief Cast the vktProp to a vtkActor2D 120 * 121 * \return NULL or a vtkActor2D pointer 122 */ 123 inline vtkActor2D *getActor2D() 124 { 125 return vtkActor2D::SafeDownCast(_prop); 126 } 127 128 /** 116 129 * \brief Cast the vktProp to a vtkProp3D 117 130 * … … 131 144 { 132 145 return vtkActor::SafeDownCast(_prop); 146 } 147 148 /** 149 * \brief Cast the vktProp to a vtkImageActor 150 * 151 * \return NULL or a vtkImageActor pointer 152 */ 153 inline vtkImageActor *getImageActor() 154 { 155 return vtkImageActor::SafeDownCast(_prop); 133 156 } 134 157 … … 484 507 TRACE("Culling on"); 485 508 } 486 } 487 } 509 } else if (vtkImageActor::SafeDownCast(prop) != NULL) { 510 vtkImageActor::SafeDownCast(prop)->GetProperty()->SetOpacity(opacity); 511 } 512 } 513 } else if (getImageActor() != NULL) { 514 getImageActor()->GetProperty()->SetOpacity(_opacity); 488 515 } 489 516 } … … 504 531 if (getActor() != NULL) { 505 532 getActor()->GetProperty()->SetAmbient(ambient); 533 } else if (getImageActor() != NULL) { 534 getImageActor()->GetProperty()->SetAmbient(ambient); 506 535 } else if (getVolume() != NULL) { 507 536 getVolume()->GetProperty()->SetAmbient(ambient); … … 513 542 if (vtkActor::SafeDownCast(prop) != NULL) { 514 543 vtkActor::SafeDownCast(prop)->GetProperty()->SetAmbient(ambient); 544 } else if (vtkImageActor::SafeDownCast(prop) != NULL) { 545 vtkImageActor::SafeDownCast(prop)->GetProperty()->SetAmbient(ambient); 515 546 } else if (vtkVolume::SafeDownCast(prop) != NULL) { 516 547 vtkVolume::SafeDownCast(prop)->GetProperty()->SetAmbient(ambient); … … 527 558 if (getActor() != NULL) { 528 559 getActor()->GetProperty()->SetDiffuse(diffuse); 560 } else if (getImageActor() != NULL) { 561 getImageActor()->GetProperty()->SetDiffuse(diffuse); 529 562 } else if (getVolume() != NULL) { 530 563 getVolume()->GetProperty()->SetDiffuse(diffuse); … … 536 569 if (vtkActor::SafeDownCast(prop) != NULL) { 537 570 vtkActor::SafeDownCast(prop)->GetProperty()->SetDiffuse(diffuse); 571 } else if (vtkImageActor::SafeDownCast(prop) != NULL) { 572 vtkImageActor::SafeDownCast(prop)->GetProperty()->SetDiffuse(diffuse); 538 573 } else if (vtkVolume::SafeDownCast(prop) != NULL) { 539 574 vtkVolume::SafeDownCast(prop)->GetProperty()->SetDiffuse(diffuse); … … 581 616 property->SetSpecular(specular); 582 617 property->SetSpecularPower(specPower); 618 } else if (getImageActor() != NULL) { 619 vtkImageProperty *property = getImageActor()->GetProperty(); 620 property->SetAmbient(ambient); 621 property->SetDiffuse(diffuse); 583 622 } else if (getVolume() != NULL) { 584 623 vtkVolumeProperty *property = getVolume()->GetProperty(); … … 598 637 property->SetSpecular(specular); 599 638 property->SetSpecularPower(specPower); 639 } else if (vtkImageActor::SafeDownCast(prop) != NULL) { 640 vtkImageProperty *property = vtkImageActor::SafeDownCast(prop)->GetProperty(); 641 property->SetAmbient(ambient); 642 property->SetDiffuse(diffuse); 600 643 } else if (vtkVolume::SafeDownCast(prop) != NULL) { 601 644 vtkVolumeProperty *property = vtkVolume::SafeDownCast(prop)->GetProperty(); -
branches/1.3/packages/vizservers/vtkvis/HeightMap.cpp
r3680 r3844 478 478 if (_contours.empty()) { 479 479 // Evenly spaced isovalues 480 _contourFilter->GenerateValues(_numContours, _dataRange[0], _dataRange[1]); 480 if (_colorFieldRange[0] <= _colorFieldRange[1]) { 481 _contourFilter->GenerateValues(_numContours, _colorFieldRange[0], _colorFieldRange[1]); 482 } else { 483 _contourFilter->GenerateValues(_numContours, _dataRange[0], _dataRange[1]); 484 } 481 485 } else { 482 486 // User-supplied isovalues -
branches/1.3/packages/vizservers/vtkvis/Makefile.in
r3679 r3844 2 2 TRACE = #yes 3 3 USE_CUSTOM_AXES = yes 4 USE_FONT_CONFIG = #yes 4 5 USE_GPU_RAYCASTING = yes 5 6 USE_OFFSCREEN_RENDERING = #yes 6 7 USE_THREADS = yes 7 USE_VTK6 =yes8 NEW_SCALAR_BAR = #yes 8 9 9 10 bindir = @bindir@ … … 40 41 41 42 VTK_LIB_DIR = @VTK_LIB_DIR@ 42 VTK_LIB_SPEC = -L$(VTK_LIB_DIR) \43 -lvtkChemistry \44 -lvtkIO \45 -lvtkWidgets \46 -lvtkFiltering \47 -lvtkVolumeRendering \48 -lvtkRendering \49 -lvtkHybrid \50 -lvtkGraphics \51 -lvtkImaging \52 -lvtkCommon53 43 VTK_INC_SPEC = @VTK_INC_SPEC@ 54 VTK 6_LIB_SPEC= \44 VTK_LIB_SPEC = \ 55 45 -lvtkDomainsChemistry-6.0 \ 56 46 -lvtkIOCore-6.0 \ 57 47 -lvtkIOLegacy-6.0 \ 48 -lvtkFiltersExtraction-6.0 \ 58 49 -lvtkFiltersModeling-6.0 \ 59 50 -lvtkFiltersFlowPaths-6.0 \ … … 69 60 -lvtkRenderingHybridOpenGL-6.0 \ 70 61 -lvtkRenderingFreeTypeOpenGL-6.0 \ 62 -lvtkRenderingFreeTypeFontConfig-6.0 \ 71 63 -lvtkRenderingFreeType-6.0 \ 72 64 -lvtkRenderingVolumeOpenGL-6.0 \ … … 80 72 -lvtkCommonMisc-6.0 \ 81 73 -lvtkCommonTransforms-6.0 \ 82 -lvtkCommonMath-6.0 83 84 ifdef USE_VTK6 85 VTK_LIB_SPEC = $(VTK6_LIB_SPEC) 86 endif 87 88 ifdef USE_VTK6 74 -lvtkCommonMath-6.0 \ 75 -lvtksys-6.0 76 89 77 LD_RUN_PATH = $(libdir) 90 else91 LD_RUN_PATH = $(libdir):$(VTK_LIB_DIR)92 endif93 78 94 79 LIBS = \ … … 119 104 DEFINES += -DUSE_CUSTOM_AXES 120 105 endif 106 ifdef USE_FONT_CONFIG 107 DEFINES += -DUSE_FONT_CONFIG 108 endif 121 109 ifdef USE_OFFSCREEN_RENDERING 122 110 DEFINES += -DUSE_OFFSCREEN_RENDERING … … 128 116 DEFINES += -DUSE_THREADS 129 117 endif 130 ifdef USE_VTK6 131 VTK_MOD_DEFS = -DvtkRenderingCore_AUTOINIT="4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)" -DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)" 118 VTK_MOD_DEFS = -DvtkRenderingCore_AUTOINIT="5(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeFontConfig,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)" -DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)" 132 119 DEFINES += -DUSE_VTK6 $(VTK_MOD_DEFS) 120 ifdef NEW_SCALAR_BAR 121 DEFINES += -DNEW_SCALAR_BAR 133 122 endif 134 123 … … 153 142 Group.cpp \ 154 143 HeightMap.cpp \ 144 Image.cpp \ 155 145 LIC.cpp \ 156 146 Line.cpp \ … … 169 159 Sphere.cpp \ 170 160 Streamlines.cpp \ 161 Text3D.cpp \ 171 162 TGAWriter.cpp \ 172 163 Trace.cpp \ … … 233 224 Group.o: Group.h GraphicsObject.h DataSet.h Renderer.h Trace.h 234 225 HeightMap.o: HeightMap.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h 226 Image.o: Image.h GraphicsObject.h DataSet.h Renderer.h Trace.h 235 227 LIC.o: LIC.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h RenderServer.h 236 228 Line.o: Line.h Shape.h GraphicsObject.h DataSet.h Renderer.h Trace.h … … 243 235 PseudoColor.o: PseudoColor.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h 244 236 ReadBuffer.o: ReadBuffer.h Trace.h 245 Renderer.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h Math.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Volume.h Warp.h ColorMap.h Trace.h246 RendererCmd.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Volume.h Warp.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h247 RendererGraphicsObjs.o: Renderer.h RendererGraphicsObjs.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Volume.h Warp.h ColorMap.h Trace.h237 Renderer.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h Math.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h Trace.h 238 RendererCmd.o: Renderer.h RendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h 239 RendererGraphicsObjs.o: Renderer.h RendererGraphicsObjs.h DataSet.h Arc.h Arrow.h Box.h Cone.h Contour2D.h Contour3D.h Cutplane.h Cylinder.h Disk.h Glyphs.h Group.h HeightMap.h Image.h LIC.h Line.h Molecule.h Outline.h PolyData.h Polygon.h PseudoColor.h Sphere.h Streamlines.h Text3D.h Volume.h Warp.h ColorMap.h Trace.h 248 240 RenderServer.o: RenderServer.h RendererCmd.h Renderer.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h 249 241 ResponseQueue.o: ResponseQueue.h Trace.h … … 251 243 Sphere.o: Sphere.h Shape.h GraphicsObject.h DataSet.h Renderer.h Trace.h 252 244 Streamlines.o: Streamlines.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h 245 Text3D.o: Text3D.h GraphicsObject.h DataSet.h Renderer.h Trace.h 253 246 TGAWriter.o: TGAWriter.h ResponseQueue.h Trace.h 254 247 Trace.o: Trace.h -
branches/1.3/packages/vizservers/vtkvis/Math.h
r3616 r3844 217 217 } 218 218 219 inline double min3(double a, double b, double c) 220 { 221 return min2(min2(a, b), c); 222 } 223 224 inline double max3(double a, double b, double c) 225 { 226 return max2(max2(a, b), c); 227 } 228 219 229 } 220 230 -
branches/1.3/packages/vizservers/vtkvis/Molecule.cpp
r3693 r3844 29 29 #include <vtkLabelPlacementMapper.h> 30 30 #include <vtkTextProperty.h> 31 #include <vtkTransformPolyDataFilter.h> 31 32 32 33 #include "Molecule.h" … … 108 109 _atomProp->GetProperty()->SetOpacity(_opacity); 109 110 _atomProp->GetProperty()->SetAmbient(.2); 111 _atomProp->GetProperty()->SetSpecular(.2); 112 _atomProp->GetProperty()->SetSpecularPower(80.0); 110 113 if (!_lighting) 111 114 _atomProp->GetProperty()->LightingOff(); … … 121 124 _bondProp->GetProperty()->SetOpacity(_opacity); 122 125 _bondProp->GetProperty()->SetAmbient(.2); 126 _bondProp->GetProperty()->SetSpecular(.2); 127 _bondProp->GetProperty()->SetSpecularPower(80.0); 123 128 if (!_lighting) 124 129 _bondProp->GetProperty()->LightingOff(); … … 178 183 addLabelArray(ds); 179 184 addRadiusArray(ds, _atomScaling, _radiusScale); 185 computeBonds(ds); 180 186 181 187 vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); … … 231 237 _labelHierarchy = vtkSmartPointer<vtkPointSetToLabelHierarchy>::New(); 232 238 } 233 #ifdef USE_VTK6 234 _labelHierarchy->SetInputData(pd); 239 if (_labelTransform == NULL) { 240 _labelTransform = vtkSmartPointer<vtkTransform>::New(); 241 } 242 vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); 243 #ifdef USE_VTK6 244 transformFilter->SetInputData(pd); 235 245 #else 236 _labelHierarchy->SetInput(pd);246 transformFilter->SetInput(pd); 237 247 #endif 248 transformFilter->SetTransform(_labelTransform); 249 _labelHierarchy->SetInputConnection(transformFilter->GetOutputPort()); 238 250 _labelHierarchy->SetLabelArrayName("_atom_labels"); 239 251 _labelHierarchy->GetTextProperty()->SetColor(0, 0, 0); … … 255 267 _atomMapper->SetInputConnection(pd->GetProducerPort()); 256 268 #endif 257 if (ds->GetPointData() != NULL && 258 ds->GetPointData()->GetVectors() != NULL) { 259 _atomMapper->SetScaleArray(vtkDataSetAttributes::VECTORS); 260 _atomMapper->SetScaleModeToScaleByMagnitude(); 261 _atomMapper->ScalingOn(); 262 } else { 263 _atomMapper->SetScaleModeToNoDataScaling(); 264 _atomMapper->ScalingOff(); 265 } 269 _atomMapper->SetScaleArray("_radii"); 270 _atomMapper->SetScaleModeToScaleByMagnitude(); 271 _atomMapper->ScalingOn(); 266 272 _atomMapper->OrientOff(); 267 273 … … 283 289 if (pd->GetNumberOfLines() > 0) { 284 290 _bondMapper->Update(); 291 } 292 } 293 294 void Molecule::updateLabelTransform() 295 { 296 if (_labelTransform != NULL && getAssembly() != NULL) { 297 _labelTransform->SetMatrix(getAssembly()->GetMatrix()); 285 298 } 286 299 } … … 797 810 if (_atomMapper != NULL) { 798 811 assert(ds->GetPointData() != NULL && 799 ds->GetPointData()->Get Vectors() != NULL);812 ds->GetPointData()->GetArray("_radii") != NULL); 800 813 _atomMapper->SetScaleModeToScaleByMagnitude(); 801 _atomMapper->SetScaleArray( vtkDataSetAttributes::VECTORS);814 _atomMapper->SetScaleArray("_radii"); 802 815 _atomMapper->ScalingOn(); 803 816 } … … 887 900 bondPoints->InsertNextPoint(newPt1); 888 901 902 #ifdef DEBUG 889 903 TRACE("Bond %d: (%g,%g,%g)-(%g,%g,%g)-(%g,%g,%g)", i, 890 904 pt0[0], pt0[1], pt0[2], 891 905 center[0], center[1], center[2], 892 906 pt1[0], pt1[1], pt1[2]); 907 #endif 893 908 894 909 double vec[3]; … … 898 913 bondVectors->InsertNextTupleValue(vec); 899 914 bondVectors->InsertNextTupleValue(vec); 915 #ifdef DEBUG 900 916 TRACE("Bond %d, vec: %g,%g,%g", i, vec[0], vec[1], vec[2]); 917 #endif 901 918 902 919 double scale[3]; … … 910 927 if (elements != NULL) { 911 928 int element = (int)elements->GetComponent(pts[0], 0); 929 #ifdef DEBUG 912 930 TRACE("Bond %d, elt 0: %d", i, element); 931 #endif 913 932 bondElements->InsertNextValue(element); 914 933 element = (int)elements->GetComponent(pts[1], 0); 934 #ifdef DEBUG 915 935 TRACE("Bond %d, elt 1: %d", i, element); 936 #endif 916 937 bondElements->InsertNextValue(element); 917 938 } … … 984 1005 ; 985 1006 } 986 vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New();987 radii->SetName("_radii");988 radii->SetNumberOfComponents(3);989 1007 vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet); 990 1008 if (pd == NULL) { … … 992 1010 return; 993 1011 } 1012 vtkDataArray *array = dataSet->GetPointData()->GetArray("_radii"); 1013 vtkSmartPointer<vtkFloatArray> radii; 1014 if (array == NULL) { 1015 radii = vtkSmartPointer<vtkFloatArray>::New(); 1016 radii->SetName("_radii"); 1017 radii->SetNumberOfComponents(1); 1018 radii->SetNumberOfValues(pd->GetNumberOfPoints()); 1019 } else { 1020 radii = vtkFloatArray::SafeDownCast(array); 1021 assert(radii != NULL); 1022 } 994 1023 for (int i = 0; i < pd->GetNumberOfPoints(); i++) { 995 float tuple[3]; 996 tuple[1] = tuple[2] = 0; 1024 float value; 997 1025 if (elements != NULL && radiusSource != NULL) { 998 1026 int elt = (int)elements->GetComponent(i, 0); 999 tuple[0]= radiusSource[elt] * scaleFactor;1027 value = radiusSource[elt] * scaleFactor; 1000 1028 } else { 1001 tuple[0] = scaleFactor; 1002 } 1003 radii->InsertNextTupleValue(tuple); 1004 } 1005 dataSet->GetPointData()->SetVectors(radii); 1029 value = scaleFactor; 1030 } 1031 radii->SetValue(i, value); 1032 } 1033 radii->Modified(); 1034 if (array == NULL) { 1035 dataSet->GetPointData()->AddArray(radii); 1036 } 1006 1037 } 1007 1038 … … 1037 1068 return elementCmap; 1038 1069 } 1070 1071 int Molecule::computeBonds(vtkDataSet *dataSet, float tolerance) 1072 { 1073 vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet); 1074 if (pd == NULL) { 1075 ERROR("DataSet not a PolyData"); 1076 return -1; 1077 } 1078 1079 if (pd->GetNumberOfPoints() < 2 || 1080 pd->GetNumberOfLines() > 0) { 1081 return 0; 1082 } 1083 1084 vtkDataArray *elements = NULL; 1085 if (pd->GetPointData() != NULL && 1086 pd->GetPointData()->GetScalars() != NULL && 1087 strcmp(pd->GetPointData()->GetScalars()->GetName(), "element") == 0) { 1088 elements = pd->GetPointData()->GetScalars(); 1089 } else { 1090 TRACE("Can't compute bonds without an element array"); 1091 return -1; 1092 } 1093 int numAtoms = pd->GetNumberOfPoints(); 1094 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); 1095 for (int i = 0; i < numAtoms; i++) { 1096 double pt1[3]; 1097 int elem1 = (int)elements->GetComponent(i, 0); 1098 float r1 = g_covalentRadii[elem1]; 1099 pd->GetPoint(i, pt1); 1100 for (int j = i+1; j < numAtoms; j++) { 1101 float r2, dist; 1102 double pt2[3]; 1103 int elem2 = (int)elements->GetComponent(j, 0); 1104 1105 if (elem1 == 1 && elem2 == 1) 1106 continue; 1107 1108 r2 = g_covalentRadii[elem2]; 1109 pd->GetPoint(j, pt2); 1110 1111 double x = pt1[0] - pt2[0]; 1112 double y = pt1[1] - pt2[1]; 1113 double z = pt1[2] - pt2[2]; 1114 dist = (float)sqrt(x*x + y*y + z*z); 1115 //TRACE("i=%d,j=%d elem1=%d,elem2=%d r1=%g,r2=%g, dist=%g", i, j, elem1, elem2, r1, r2, dist); 1116 if (dist < (r1 + r2 + tolerance)) { 1117 vtkIdType pts[2]; 1118 pts[0] = i; 1119 pts[1] = j; 1120 cells->InsertNextCell(2, pts); 1121 } 1122 } 1123 } 1124 1125 if (cells->GetNumberOfCells() > 0) { 1126 pd->SetLines(cells); 1127 } 1128 1129 TRACE("Generated %d bonds", cells->GetNumberOfCells()); 1130 return cells->GetNumberOfCells(); 1131 } -
branches/1.3/packages/vizservers/vtkvis/Molecule.h
r3693 r3844 22 22 #include <vtkPointSetToLabelHierarchy.h> 23 23 #include <vtkLabelPlacementMapper.h> 24 #include <vtkTransform.h> 24 25 25 26 #include "ColorMap.h" … … 78 79 } 79 80 81 virtual void setTransform(vtkMatrix4x4 *matrix) 82 { 83 GraphicsObject::setTransform(matrix); 84 updateLabelTransform(); 85 } 86 87 virtual void setOrigin(double origin[3]) 88 { 89 GraphicsObject::setOrigin(origin); 90 updateLabelTransform(); 91 } 92 93 virtual void setOrientation(double quat[4]) 94 { 95 GraphicsObject::setOrientation(quat); 96 updateLabelTransform(); 97 } 98 99 virtual void setOrientation(double angle, double axis[3]) 100 { 101 GraphicsObject::setOrientation(angle, axis); 102 updateLabelTransform(); 103 } 104 105 virtual void setPosition(double pos[3]) 106 { 107 GraphicsObject::setPosition(pos); 108 updateLabelTransform(); 109 } 110 111 virtual void setAspect(double aspect) 112 { 113 GraphicsObject::setAspect(aspect); 114 updateLabelTransform(); 115 } 116 117 virtual void setScale(double scale[3]) 118 { 119 GraphicsObject::setScale(scale); 120 updateLabelTransform(); 121 } 122 80 123 virtual void setDataSet(DataSet *dataSet, 81 124 Renderer *renderer); … … 141 184 void setupBondPolyData(); 142 185 186 void updateLabelTransform(); 187 143 188 static void addLabelArray(vtkDataSet *dataSet); 144 189 145 190 static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor); 191 192 static int computeBonds(vtkDataSet *dataSet, float tolerance = 0.45f); 146 193 147 194 float _bondColor[3]; … … 171 218 vtkSmartPointer<vtkPointSetToLabelHierarchy> _labelHierarchy; 172 219 vtkSmartPointer<vtkLabelPlacementMapper> _labelMapper; 220 vtkSmartPointer<vtkTransform> _labelTransform; 173 221 }; 174 222 -
branches/1.3/packages/vizservers/vtkvis/PolyData.cpp
r3680 r3844 10 10 #include <vtkDataSet.h> 11 11 #include <vtkPolyData.h> 12 #include <vtkPolyDataNormals.h> 13 #include <vtkPointData.h> 14 #include <vtkCellData.h> 12 15 #include <vtkUnstructuredGrid.h> 13 16 #include <vtkPolyDataMapper.h> … … 19 22 #include <vtkDataSetSurfaceFilter.h> 20 23 #include <vtkVertexGlyphFilter.h> 24 #include <vtkLookupTable.h> 21 25 22 26 #include "PolyData.h" 27 #include "Renderer.h" 23 28 #include "Trace.h" 24 29 … … 27 32 PolyData::PolyData() : 28 33 GraphicsObject(), 34 _colorMap(NULL), 35 _colorMode(COLOR_CONSTANT), 36 _colorFieldType(DataSet::POINT_DATA), 37 _renderer(NULL), 29 38 _cloudStyle(CLOUD_MESH) 30 39 { 40 _colorFieldRange[0] = DBL_MAX; 41 _colorFieldRange[1] = -DBL_MAX; 31 42 } 32 43 … … 41 52 } 42 53 54 void PolyData::setDataSet(DataSet *dataSet, 55 Renderer *renderer) 56 { 57 if (_dataSet != dataSet) { 58 _dataSet = dataSet; 59 60 _renderer = renderer; 61 62 if (renderer->getUseCumulativeRange()) { 63 renderer->getCumulativeDataRange(_dataRange, 64 _dataSet->getActiveScalarsName(), 65 1); 66 renderer->getCumulativeDataRange(_vectorMagnitudeRange, 67 _dataSet->getActiveVectorsName(), 68 3); 69 for (int i = 0; i < 3; i++) { 70 renderer->getCumulativeDataRange(_vectorComponentRange[i], 71 _dataSet->getActiveVectorsName(), 72 3, i); 73 } 74 } else { 75 _dataSet->getScalarRange(_dataRange); 76 _dataSet->getVectorRange(_vectorMagnitudeRange); 77 for (int i = 0; i < 3; i++) { 78 _dataSet->getVectorRange(_vectorComponentRange[i], i); 79 } 80 } 81 82 update(); 83 } 84 } 85 43 86 /** 44 87 * \brief Internal method to set up pipeline after a state change … … 50 93 } 51 94 52 if (_pdMapper == NULL) {53 _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New();54 _pdMapper->SetResolveCoincidentTopologyToPolygonOffset();55 _pdMapper->ScalarVisibilityOff();56 }57 58 95 vtkDataSet *ds = _dataSet->getVtkDataSet(); 96 97 if (_mapper == NULL) { 98 _mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 99 _mapper->SetResolveCoincidentTopologyToPolygonOffset(); 100 // If there are color scalars, use them without lookup table (if scalar visibility is on) 101 _mapper->SetColorModeToDefault(); 102 // Use Point data if available, else cell data 103 _mapper->SetScalarModeToDefault(); 104 _mapper->ScalarVisibilityOff(); 105 } 106 59 107 vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); 60 108 if (pd) { … … 66 114 pd->GetNumberOfStrips()); 67 115 } 116 bool hasNormals = false; 117 if ((ds->GetPointData() != NULL && 118 ds->GetPointData()->GetNormals() != NULL) || 119 (ds->GetCellData() != NULL && 120 ds->GetCellData()->GetNormals() != NULL)) { 121 hasNormals = true; 122 } 123 68 124 if (_dataSet->isCloud()) { 69 125 // DataSet is a point cloud … … 78 134 vgf->SetInput(ds); 79 135 #endif 80 _ pdMapper->SetInputConnection(vgf->GetOutputPort());136 _mapper->SetInputConnection(vgf->GetOutputPort()); 81 137 } else if (_dataSet->is2D(&plane, &offset)) { 82 138 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); … … 122 178 vgf->SetInput(ds); 123 179 #endif 124 _ pdMapper->SetInputConnection(vgf->GetOutputPort());180 _mapper->SetInputConnection(vgf->GetOutputPort()); 125 181 } else { 126 _pdMapper->SetInputConnection(mesher->GetOutputPort()); 182 vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New(); 183 normalFilter->SetInputConnection(mesher->GetOutputPort()); 184 _mapper->SetInputConnection(normalFilter->GetOutputPort()); 127 185 } 128 186 } else { … … 146 204 vgf->SetInput(ds); 147 205 #endif 148 _ pdMapper->SetInputConnection(vgf->GetOutputPort());206 _mapper->SetInputConnection(vgf->GetOutputPort()); 149 207 } else { 150 208 // Delaunay3D returns an UnstructuredGrid, so feed it … … 153 211 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 154 212 gf->UseStripsOn(); 213 gf->ReleaseDataFlagOn(); 155 214 gf->SetInputConnection(mesher->GetOutputPort()); 156 gf->ReleaseDataFlagOn(); 157 _pdMapper->SetInputConnection(gf->GetOutputPort()); 215 vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New(); 216 normalFilter->SetInputConnection(gf->GetOutputPort()); 217 _mapper->SetInputConnection(normalFilter->GetOutputPort()); 158 218 } 159 219 } 160 220 } else if (pd) { 161 221 // DataSet is a vtkPolyData with cells 162 #ifdef USE_VTK6 163 _pdMapper->SetInputData(pd); 164 #else 165 _pdMapper->SetInput(pd); 166 #endif 222 if (hasNormals) { 223 #ifdef USE_VTK6 224 _mapper->SetInputData(pd); 225 #else 226 _mapper->SetInput(pd); 227 #endif 228 } else { 229 vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New(); 230 #ifdef USE_VTK6 231 normalFilter->SetInputData(pd); 232 #else 233 normalFilter->SetInput(pd); 234 #endif 235 _mapper->SetInputConnection(normalFilter->GetOutputPort()); 236 } 167 237 } else { 168 238 // DataSet is NOT a vtkPolyData … … 170 240 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 171 241 gf->UseStripsOn(); 242 gf->ReleaseDataFlagOn(); 172 243 #ifdef USE_VTK6 173 244 gf->SetInputData(ds); … … 175 246 gf->SetInput(ds); 176 247 #endif 177 gf->ReleaseDataFlagOn(); 178 _pdMapper->SetInputConnection(gf->GetOutputPort()); 248 vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New(); 249 normalFilter->SetInputConnection(gf->GetOutputPort()); 250 _mapper->SetInputConnection(normalFilter->GetOutputPort()); 251 } 252 253 setInterpolateBeforeMapping(true); 254 255 if (_lut == NULL) { 256 setColorMap(ColorMap::getDefault()); 257 if (_dataSet->getActiveScalarsName() != NULL) { 258 int numComp; 259 _dataSet->getFieldInfo(_dataSet->getActiveScalarsName(), 260 _dataSet->getActiveScalarsType(), 261 &numComp); 262 // If DataSet is a PolyData with a scalar field, or has color scalars 263 if (pd != NULL || numComp > 1) { 264 if (numComp > 1) { 265 // If we have color scalars, use triangle interpolation 266 setInterpolateBeforeMapping(false); 267 } 268 setColorMode(COLOR_BY_SCALAR); 269 } else { 270 setColorMode(_colorMode); 271 } 272 } else { 273 setColorMode(_colorMode); 274 } 275 } else { 276 double *rangePtr = _colorFieldRange; 277 if (_colorFieldRange[0] > _colorFieldRange[1]) { 278 rangePtr = NULL; 279 } 280 setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr); 179 281 } 180 282 181 283 initProp(); 182 getActor()->SetMapper(_ pdMapper);183 _ pdMapper->Update();284 getActor()->SetMapper(_mapper); 285 _mapper->Update(); 184 286 #ifdef WANT_TRACE 185 287 double *b = getBounds(); 186 288 TRACE("bounds: %g %g %g %g %g %g", b[0], b[1], b[2], b[3], b[4], b[5]); 187 289 #endif 290 } 291 292 void PolyData::setInterpolateBeforeMapping(bool state) 293 { 294 if (_mapper != NULL) { 295 _mapper->SetInterpolateScalarsBeforeMapping((state ? 1 : 0)); 296 } 297 } 298 299 void PolyData::updateRanges(Renderer *renderer) 300 { 301 if (_dataSet == NULL) { 302 ERROR("called before setDataSet"); 303 return; 304 } 305 306 if (renderer->getUseCumulativeRange()) { 307 renderer->getCumulativeDataRange(_dataRange, 308 _dataSet->getActiveScalarsName(), 309 1); 310 renderer->getCumulativeDataRange(_vectorMagnitudeRange, 311 _dataSet->getActiveVectorsName(), 312 3); 313 for (int i = 0; i < 3; i++) { 314 renderer->getCumulativeDataRange(_vectorComponentRange[i], 315 _dataSet->getActiveVectorsName(), 316 3, i); 317 } 318 } else { 319 _dataSet->getScalarRange(_dataRange); 320 _dataSet->getVectorRange(_vectorMagnitudeRange); 321 for (int i = 0; i < 3; i++) { 322 _dataSet->getVectorRange(_vectorComponentRange[i], i); 323 } 324 } 325 326 // Need to update color map ranges 327 double *rangePtr = _colorFieldRange; 328 if (_colorFieldRange[0] > _colorFieldRange[1]) { 329 rangePtr = NULL; 330 } 331 setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr); 332 } 333 334 void PolyData::setColorMode(ColorMode mode) 335 { 336 _colorMode = mode; 337 if (_dataSet == NULL) 338 return; 339 340 switch (mode) { 341 case COLOR_BY_SCALAR: 342 setColorMode(mode, 343 _dataSet->getActiveScalarsType(), 344 _dataSet->getActiveScalarsName(), 345 _dataRange); 346 break; 347 case COLOR_BY_VECTOR_MAGNITUDE: 348 setColorMode(mode, 349 _dataSet->getActiveVectorsType(), 350 _dataSet->getActiveVectorsName(), 351 _vectorMagnitudeRange); 352 break; 353 case COLOR_BY_VECTOR_X: 354 setColorMode(mode, 355 _dataSet->getActiveVectorsType(), 356 _dataSet->getActiveVectorsName(), 357 _vectorComponentRange[0]); 358 break; 359 case COLOR_BY_VECTOR_Y: 360 setColorMode(mode, 361 _dataSet->getActiveVectorsType(), 362 _dataSet->getActiveVectorsName(), 363 _vectorComponentRange[1]); 364 break; 365 case COLOR_BY_VECTOR_Z: 366 setColorMode(mode, 367 _dataSet->getActiveVectorsType(), 368 _dataSet->getActiveVectorsName(), 369 _vectorComponentRange[2]); 370 break; 371 case COLOR_CONSTANT: 372 default: 373 setColorMode(mode, DataSet::POINT_DATA, NULL, NULL); 374 break; 375 } 376 } 377 378 void PolyData::setColorMode(ColorMode mode, 379 const char *name, double range[2]) 380 { 381 if (_dataSet == NULL) 382 return; 383 DataSet::DataAttributeType type = DataSet::POINT_DATA; 384 int numComponents = 1; 385 if (name != NULL && strlen(name) > 0 && 386 !_dataSet->getFieldInfo(name, &type, &numComponents)) { 387 ERROR("Field not found: %s", name); 388 return; 389 } 390 setColorMode(mode, type, name, range); 391 } 392 393 void PolyData::setColorMode(ColorMode mode, DataSet::DataAttributeType type, 394 const char *name, double range[2]) 395 { 396 _colorMode = mode; 397 _colorFieldType = type; 398 if (name == NULL) 399 _colorFieldName.clear(); 400 else 401 _colorFieldName = name; 402 if (range == NULL) { 403 _colorFieldRange[0] = DBL_MAX; 404 _colorFieldRange[1] = -DBL_MAX; 405 } else { 406 memcpy(_colorFieldRange, range, sizeof(double)*2); 407 } 408 409 if (_dataSet == NULL || _mapper == NULL) 410 return; 411 412 switch (type) { 413 case DataSet::POINT_DATA: 414 _mapper->SetScalarModeToUsePointFieldData(); 415 break; 416 case DataSet::CELL_DATA: 417 _mapper->SetScalarModeToUseCellFieldData(); 418 break; 419 case DataSet::FIELD_DATA: 420 _mapper->SetScalarModeToUseFieldData(); 421 break; 422 default: 423 ERROR("Unsupported DataAttributeType: %d", type); 424 return; 425 } 426 427 if (name != NULL && strlen(name) > 0) { 428 _mapper->SelectColorArray(name); 429 } else { 430 _mapper->SetScalarModeToDefault(); 431 } 432 433 if (_lut != NULL) { 434 if (range != NULL) { 435 _lut->SetRange(range); 436 } else if (name != NULL && strlen(name) > 0) { 437 double r[2]; 438 int comp = -1; 439 if (mode == COLOR_BY_VECTOR_X) 440 comp = 0; 441 else if (mode == COLOR_BY_VECTOR_Y) 442 comp = 1; 443 else if (mode == COLOR_BY_VECTOR_Z) 444 comp = 2; 445 446 if (_renderer->getUseCumulativeRange()) { 447 int numComponents; 448 if (!_dataSet->getFieldInfo(name, type, &numComponents)) { 449 ERROR("Field not found: %s, type: %d", name, type); 450 return; 451 } else if (numComponents < comp+1) { 452 ERROR("Request for component %d in field with %d components", 453 comp, numComponents); 454 return; 455 } 456 _renderer->getCumulativeDataRange(r, name, type, numComponents, comp); 457 } else { 458 _dataSet->getDataRange(r, name, type, comp); 459 } 460 _lut->SetRange(r); 461 } 462 } 463 464 switch (mode) { 465 case COLOR_BY_SCALAR: 466 _mapper->ScalarVisibilityOn(); 467 break; 468 case COLOR_BY_VECTOR_MAGNITUDE: 469 _mapper->ScalarVisibilityOn(); 470 if (_lut != NULL) { 471 _lut->SetVectorModeToMagnitude(); 472 } 473 break; 474 case COLOR_BY_VECTOR_X: 475 _mapper->ScalarVisibilityOn(); 476 if (_lut != NULL) { 477 _lut->SetVectorModeToComponent(); 478 _lut->SetVectorComponent(0); 479 } 480 break; 481 case COLOR_BY_VECTOR_Y: 482 _mapper->ScalarVisibilityOn(); 483 if (_lut != NULL) { 484 _lut->SetVectorModeToComponent(); 485 _lut->SetVectorComponent(1); 486 } 487 break; 488 case COLOR_BY_VECTOR_Z: 489 _mapper->ScalarVisibilityOn(); 490 if (_lut != NULL) { 491 _lut->SetVectorModeToComponent(); 492 _lut->SetVectorComponent(2); 493 } 494 break; 495 case COLOR_CONSTANT: 496 default: 497 _mapper->ScalarVisibilityOff(); 498 break; 499 } 500 } 501 502 /** 503 * \brief Called when the color map has been edited 504 */ 505 void PolyData::updateColorMap() 506 { 507 setColorMap(_colorMap); 508 } 509 510 /** 511 * \brief Associate a colormap lookup table with the DataSet 512 */ 513 void PolyData::setColorMap(ColorMap *cmap) 514 { 515 if (cmap == NULL) 516 return; 517 518 _colorMap = cmap; 519 520 if (_lut == NULL) { 521 _lut = vtkSmartPointer<vtkLookupTable>::New(); 522 if (_mapper != NULL) { 523 _mapper->UseLookupTableScalarRangeOn(); 524 _mapper->SetLookupTable(_lut); 525 } 526 _lut->DeepCopy(cmap->getLookupTable()); 527 switch (_colorMode) { 528 case COLOR_CONSTANT: 529 case COLOR_BY_SCALAR: 530 _lut->SetRange(_dataRange); 531 break; 532 case COLOR_BY_VECTOR_MAGNITUDE: 533 _lut->SetRange(_vectorMagnitudeRange); 534 break; 535 case COLOR_BY_VECTOR_X: 536 _lut->SetRange(_vectorComponentRange[0]); 537 break; 538 case COLOR_BY_VECTOR_Y: 539 _lut->SetRange(_vectorComponentRange[1]); 540 break; 541 case COLOR_BY_VECTOR_Z: 542 _lut->SetRange(_vectorComponentRange[2]); 543 break; 544 default: 545 break; 546 } 547 } else { 548 double range[2]; 549 _lut->GetTableRange(range); 550 _lut->DeepCopy(cmap->getLookupTable()); 551 _lut->SetRange(range); 552 _lut->Modified(); 553 } 554 555 switch (_colorMode) { 556 case COLOR_BY_VECTOR_MAGNITUDE: 557 _lut->SetVectorModeToMagnitude(); 558 break; 559 case COLOR_BY_VECTOR_X: 560 _lut->SetVectorModeToComponent(); 561 _lut->SetVectorComponent(0); 562 break; 563 case COLOR_BY_VECTOR_Y: 564 _lut->SetVectorModeToComponent(); 565 _lut->SetVectorComponent(1); 566 break; 567 case COLOR_BY_VECTOR_Z: 568 _lut->SetVectorModeToComponent(); 569 _lut->SetVectorComponent(2); 570 break; 571 default: 572 break; 573 } 188 574 } 189 575 … … 195 581 void PolyData::setClippingPlanes(vtkPlaneCollection *planes) 196 582 { 197 if (_ pdMapper != NULL) {198 _ pdMapper->SetClippingPlanes(planes);583 if (_mapper != NULL) { 584 _mapper->SetClippingPlanes(planes); 199 585 } 200 586 } -
branches/1.3/packages/vizservers/vtkvis/PolyData.h
r3680 r3844 12 12 #include <vtkPolyDataMapper.h> 13 13 #include <vtkActor.h> 14 #include <vtkLookupTable.h> 14 15 16 #include "ColorMap.h" 15 17 #include "GraphicsObject.h" 16 #include "DataSet.h"17 18 18 19 namespace VtkVis { … … 29 30 CLOUD_POINTS 30 31 }; 32 enum ColorMode { 33 COLOR_BY_SCALAR, 34 COLOR_BY_VECTOR_MAGNITUDE, 35 COLOR_BY_VECTOR_X, 36 COLOR_BY_VECTOR_Y, 37 COLOR_BY_VECTOR_Z, 38 COLOR_CONSTANT 39 }; 31 40 32 41 PolyData(); … … 38 47 } 39 48 49 virtual void setDataSet(DataSet *dataSet, 50 Renderer *renderer); 51 40 52 virtual void setClippingPlanes(vtkPlaneCollection *planes); 41 53 42 54 void setCloudStyle(CloudStyle style); 43 55 56 void setInterpolateBeforeMapping(bool state); 57 58 void setColorMode(ColorMode mode, DataSet::DataAttributeType type, 59 const char *name, double range[2] = NULL); 60 61 void setColorMode(ColorMode mode, 62 const char *name, double range[2] = NULL); 63 64 void setColorMode(ColorMode mode); 65 66 void setColorMap(ColorMap *colorMap); 67 68 /** 69 * \brief Return the ColorMap in use 70 */ 71 ColorMap *getColorMap() 72 { 73 return _colorMap; 74 } 75 76 void updateColorMap(); 77 78 virtual void updateRanges(Renderer *renderer); 79 44 80 private: 45 81 virtual void update(); 46 82 83 ColorMap *_colorMap; 84 ColorMode _colorMode; 85 std::string _colorFieldName; 86 DataSet::DataAttributeType _colorFieldType; 87 double _colorFieldRange[2]; 88 double _vectorMagnitudeRange[2]; 89 double _vectorComponentRange[3][2]; 90 Renderer *_renderer; 91 47 92 CloudStyle _cloudStyle; 48 vtkSmartPointer<vtkPolyDataMapper> _pdMapper; 93 vtkSmartPointer<vtkLookupTable> _lut; 94 vtkSmartPointer<vtkPolyDataMapper> _mapper; 49 95 }; 50 96 -
branches/1.3/packages/vizservers/vtkvis/PseudoColor.cpp
r3680 r3844 99 99 if (_mapper == NULL) { 100 100 _mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 101 _mapper->SetResolveCoincidentTopologyToPolygonOffset(); 101 102 // Map scalars through lookup table regardless of type 102 103 _mapper->SetColorModeToMapScalars(); … … 106 107 if (_dataSet->isCloud()) { 107 108 // DataSet is a point cloud 108 if (_cloudStyle == CLOUD_POINTS) { 109 if (_cloudStyle == CLOUD_POINTS || 110 _dataSet->numDimensions() < 2 || ds->GetNumberOfPoints() < 3) { 109 111 vtkSmartPointer<vtkVertexGlyphFilter> vgf = vtkSmartPointer<vtkVertexGlyphFilter>::New(); 110 112 #ifdef USE_VTK6 … … 385 387 _mapper->SetScalarModeToUseCellFieldData(); 386 388 break; 389 case DataSet::FIELD_DATA: 390 _mapper->SetScalarModeToUseFieldData(); 391 break; 387 392 default: 388 393 ERROR("Unsupported DataAttributeType: %d", type); … … 392 397 if (_splatter != NULL) { 393 398 if (name != NULL && strlen(name) > 0) { 394 _splatter->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, name);399 _splatter->SetInputArrayToProcess(0, 0, 0, type, name); 395 400 } 396 401 _mapper->SelectColorArray("SplatterValues"); -
branches/1.3/packages/vizservers/vtkvis/RenderServer.cpp
r3621 r3844 22 22 23 23 #include <tcl.h> 24 25 #include <vtksys/SystemInformation.hxx> 24 26 25 27 #include "Trace.h" … … 494 496 TRACE("Starting VTKVis Server"); 495 497 498 #ifdef WANT_TRACE 499 vtksys::SystemInformation::SetStackTraceOnError(1); 500 #endif 501 496 502 /* This synchronizes the client with the server, so that the client 497 503 * doesn't start writing commands before the server is ready. It could -
branches/1.3/packages/vizservers/vtkvis/RenderServer.h
r3683 r3844 16 16 class Renderer; 17 17 18 #define VTKVIS_VERSION_STRING "1. 4"18 #define VTKVIS_VERSION_STRING "1.5" 19 19 20 20 #define MSECS_ELAPSED(t1, t2) \ -
branches/1.3/packages/vizservers/vtkvis/Renderer.cpp
r3683 r3844 17 17 #endif 18 18 19 #ifdef USE_FONT_CONFIG 20 #include <vtkFreeTypeTools.h> 21 #endif 19 22 #include <vtkMath.h> 20 23 #include <vtkCamera.h> … … 42 45 #include "ColorMap.h" 43 46 #include "Trace.h" 44 45 #define NEW_SCALAR_BAR46 47 47 48 #define MSECS_ELAPSED(t1, t2) \ … … 120 121 if (_cameraMode == IMAGE) 121 122 _activeClipPlanes->AddItem(_cameraClipPlanes[3]); 123 124 #ifdef USE_FONT_CONFIG 125 vtkFreeTypeTools *typeTools = vtkFreeTypeTools::GetInstance(); 126 typeTools->ForceCompiledFontsOff(); 127 TRACE("FreeTypeTools impl: %s", typeTools->GetClassName()); 128 #endif 129 122 130 _renderer = vtkSmartPointer<vtkRenderer>::New(); 123 131 … … 184 192 deleteAllGraphicsObjects<Group>(); 185 193 deleteAllGraphicsObjects<HeightMap>(); 194 deleteAllGraphicsObjects<Image>(); 186 195 deleteAllGraphicsObjects<LIC>(); 187 196 deleteAllGraphicsObjects<Line>(); … … 193 202 deleteAllGraphicsObjects<Sphere>(); 194 203 deleteAllGraphicsObjects<Streamlines>(); 204 deleteAllGraphicsObjects<Text3D>(); 195 205 deleteAllGraphicsObjects<Volume>(); 196 206 deleteAllGraphicsObjects<Warp>(); … … 264 274 deleteGraphicsObject<Glyphs>(itr->second->getName()); 265 275 deleteGraphicsObject<HeightMap>(itr->second->getName()); 276 deleteGraphicsObject<Image>(itr->second->getName()); 266 277 deleteGraphicsObject<LIC>(itr->second->getName()); 267 278 deleteGraphicsObject<Molecule>(itr->second->getName()); … … 1555 1566 updateGraphicsObjectColorMap<Glyphs>(cmap); 1556 1567 updateGraphicsObjectColorMap<HeightMap>(cmap); 1568 updateGraphicsObjectColorMap<Image>(cmap); 1557 1569 updateGraphicsObjectColorMap<LIC>(cmap); 1558 1570 updateGraphicsObjectColorMap<Molecule>(cmap); 1571 updateGraphicsObjectColorMap<PolyData>(cmap); 1559 1572 updateGraphicsObjectColorMap<PseudoColor>(cmap); 1560 1573 updateGraphicsObjectColorMap<Streamlines>(cmap); … … 1579 1592 if (graphicsObjectColorMapUsed<HeightMap>(cmap)) 1580 1593 return true; 1594 if (graphicsObjectColorMapUsed<Image>(cmap)) 1595 return true; 1581 1596 if (graphicsObjectColorMapUsed<LIC>(cmap)) 1582 1597 return true; 1583 1598 if (graphicsObjectColorMapUsed<Molecule>(cmap)) 1599 return true; 1600 if (graphicsObjectColorMapUsed<PolyData>(cmap)) 1584 1601 return true; 1585 1602 if (graphicsObjectColorMapUsed<PseudoColor>(cmap)) … … 1931 1948 #ifdef NEW_SCALAR_BAR 1932 1949 _scalarBarActor->SetBarRatio(1); 1950 _scalarBarActor->SetTitleRatio(0); 1933 1951 #endif 1934 1952 if (width > height) { … … 1958 1976 #ifdef NEW_SCALAR_BAR 1959 1977 _scalarBarActor->SetBarRatio(0.375); 1978 _scalarBarActor->SetTitleRatio(0.5); 1960 1979 _scalarBarActor->SetDisplayPosition(0, 0); 1961 1980 _scalarBarActor->GetPosition2Coordinate()->SetCoordinateSystemToDisplay(); … … 2125 2144 _scalarBarActor->GetLabelTextProperty()->ShadowOff(); 2126 2145 #ifdef NEW_SCALAR_BAR 2127 if ( title.empty()&& numLabels == 0) {2146 if (!drawTitle && numLabels == 0) { 2128 2147 _scalarBarActor->DrawAnnotationsOff(); 2129 2148 _scalarBarActor->SetAnnotationLeaderPadding(0); … … 2137 2156 2138 2157 _legendRenderWindow->Render(); 2158 int *sz = _legendRenderWindow->GetSize(); 2159 if (sz[0] != width || sz[1] != height) { 2160 ERROR("Window size: %dx%d, but expected %dx%d", sz[0], sz[1], width, height); 2161 } 2162 2163 #ifdef RENDER_TARGA 2164 _legendRenderWindow->MakeCurrent(); 2165 // Must clear previous errors first. 2166 while (glGetError() != GL_NO_ERROR){ 2167 ; 2168 } 2169 int bytesPerPixel = TARGA_BYTES_PER_PIXEL; 2170 int size = bytesPerPixel * width * height; 2171 2172 if (imgData->GetMaxId() + 1 != size) 2173 { 2174 imgData->SetNumberOfComponents(bytesPerPixel); 2175 imgData->SetNumberOfValues(size); 2176 } 2177 glDisable(GL_TEXTURE_2D); 2178 if (_legendRenderWindow->GetDoubleBuffer()) { 2179 glReadBuffer(static_cast<GLenum>(vtkOpenGLRenderWindow::SafeDownCast(_legendRenderWindow)->GetBackLeftBuffer())); 2180 } else { 2181 glReadBuffer(static_cast<GLenum>(vtkOpenGLRenderWindow::SafeDownCast(_legendRenderWindow)->GetFrontLeftBuffer())); 2182 } 2183 glPixelStorei(GL_PACK_ALIGNMENT, 1); 2184 if (bytesPerPixel == 4) { 2185 glReadPixels(0, 0, width, height, GL_BGRA, 2186 GL_UNSIGNED_BYTE, imgData->GetPointer(0)); 2187 } else { 2188 glReadPixels(0, 0, width, height, GL_BGR, 2189 GL_UNSIGNED_BYTE, imgData->GetPointer(0)); 2190 } 2191 if (glGetError() != GL_NO_ERROR) { 2192 ERROR("glReadPixels"); 2193 } 2194 #else 2195 _legendRenderWindow->GetPixelData(0, 0, width-1, height-1, 2196 !_legendRenderWindow->GetDoubleBuffer(), 2197 imgData); 2198 #endif 2199 TRACE("Leave"); 2200 return true; 2201 } 2202 2203 bool Renderer::renderColorMap(const ColorMapId& id, 2204 int width, int height, 2205 bool opaque, 2206 vtkUnsignedCharArray *imgData) 2207 { 2208 TRACE("Enter"); 2209 ColorMap *colorMap = getColorMap(id); 2210 if (colorMap == NULL) 2211 return false; 2212 2213 if (_legendRenderWindow == NULL) { 2214 _legendRenderWindow = vtkSmartPointer<vtkRenderWindow>::New(); 2215 _legendRenderWindow->SetMultiSamples(0); 2216 #ifdef USE_OFFSCREEN_RENDERING 2217 _legendRenderWindow->DoubleBufferOff(); 2218 _legendRenderWindow->OffScreenRenderingOn(); 2219 #else 2220 _legendRenderWindow->DoubleBufferOn(); 2221 _legendRenderWindow->SwapBuffersOff(); 2222 #endif 2223 } 2224 2225 _legendRenderWindow->SetSize(width, height); 2226 2227 if (_legendRenderer == NULL) { 2228 _legendRenderer = vtkSmartPointer<vtkRenderer>::New(); 2229 _legendRenderWindow->AddRenderer(_legendRenderer); 2230 } 2231 _legendRenderer->SetBackground(_bgColor[0], _bgColor[1], _bgColor[2]); 2232 2233 if (_scalarBarActor == NULL) { 2234 _scalarBarActor = vtkSmartPointer<vtkScalarBarActor>::New(); 2235 _scalarBarActor->DrawFrameOff(); 2236 _scalarBarActor->DrawBackgroundOff(); 2237 _scalarBarActor->DrawColorBarOn(); 2238 _legendRenderer->AddViewProp(_scalarBarActor); 2239 } 2240 2241 if (opaque) { 2242 _scalarBarActor->UseOpacityOff(); 2243 } else { 2244 _scalarBarActor->UseOpacityOn(); 2245 } 2246 2247 if (width > height) { 2248 _scalarBarActor->SetOrientationToHorizontal(); 2249 } else { 2250 _scalarBarActor->SetOrientationToVertical(); 2251 } 2252 2253 // Set viewport-relative width/height/pos 2254 #ifdef NEW_SCALAR_BAR 2255 _scalarBarActor->SetBarRatio(1); 2256 _scalarBarActor->SetTitleRatio(0); 2257 #endif 2258 if (width > height) { 2259 // horizontal 2260 #ifdef NEW_SCALAR_BAR 2261 _scalarBarActor->SetDisplayPosition(0, 0); 2262 _scalarBarActor->GetPosition2Coordinate()->SetCoordinateSystemToDisplay(); 2263 _scalarBarActor->GetPosition2Coordinate()->SetValue(width+4, height); 2264 #else 2265 _scalarBarActor->SetPosition(0, 0); 2266 _scalarBarActor->SetHeight((((double)height+1.5)/((double)height))/0.4); // VTK: floor(actorHeight * .4) 2267 _scalarBarActor->SetWidth(1); // VTK: actorWidth 2268 #endif 2269 } else { 2270 // vertical 2271 #ifdef NEW_SCALAR_BAR 2272 _scalarBarActor->SetDisplayPosition(0, -4); 2273 _scalarBarActor->GetPosition2Coordinate()->SetCoordinateSystemToDisplay(); 2274 _scalarBarActor->GetPosition2Coordinate()->SetValue(width+1, height+5); 2275 #else 2276 _scalarBarActor->SetPosition(0, 0); 2277 _scalarBarActor->SetHeight((((double)height+1.5)/((double)height))/0.86); // VTK: floor(actorHeight * .86) 2278 _scalarBarActor->SetWidth(((double)(width+5))/((double)width)); // VTK: actorWidth - 4 pixels 2279 #endif 2280 } 2281 2282 vtkSmartPointer<vtkLookupTable> lut = colorMap->getLookupTable(); 2283 2284 double range[2]; 2285 range[0] = 0.0; 2286 range[1] = 1.0; 2287 2288 lut->SetRange(range); 2289 2290 _scalarBarActor->SetLookupTable(lut); 2291 _scalarBarActor->SetMaximumNumberOfColors((width > height ? width : height)); 2292 _scalarBarActor->SetTitle(""); 2293 _scalarBarActor->SetNumberOfLabels(0); 2294 #ifdef NEW_SCALAR_BAR 2295 _scalarBarActor->DrawAnnotationsOff(); 2296 _scalarBarActor->SetAnnotationLeaderPadding(0); 2297 _scalarBarActor->SetTextPad(0); 2298 #endif 2299 2300 _legendRenderWindow->Render(); 2301 int *sz = _legendRenderWindow->GetSize(); 2302 if (sz[0] != width || sz[1] != height) { 2303 ERROR("Window size: %dx%d, but expected %dx%d", sz[0], sz[1], width, height); 2304 } 2139 2305 2140 2306 #ifdef RENDER_TARGA … … 2265 2431 setGraphicsObjectAspect<Glyphs>(aspectRatio); 2266 2432 setGraphicsObjectAspect<HeightMap>(aspectRatio); 2433 setGraphicsObjectAspect<Image>(aspectRatio); 2267 2434 setGraphicsObjectAspect<LIC>(aspectRatio); 2268 2435 setGraphicsObjectAspect<Line>(aspectRatio); … … 2274 2441 setGraphicsObjectAspect<Sphere>(aspectRatio); 2275 2442 setGraphicsObjectAspect<Streamlines>(aspectRatio); 2443 setGraphicsObjectAspect<Text3D>(aspectRatio); 2276 2444 setGraphicsObjectAspect<Volume>(aspectRatio); 2277 2445 setGraphicsObjectAspect<Warp>(aspectRatio); … … 3184 3352 mergeGraphicsObjectBounds<Group>(bounds, onlyVisible); 3185 3353 mergeGraphicsObjectBounds<HeightMap>(bounds, onlyVisible); 3354 mergeGraphicsObjectBounds<Image>(bounds, onlyVisible); 3186 3355 mergeGraphicsObjectBounds<LIC>(bounds, onlyVisible); 3187 3356 mergeGraphicsObjectBounds<Line>(bounds, onlyVisible); … … 3193 3362 mergeGraphicsObjectBounds<Sphere>(bounds, onlyVisible); 3194 3363 mergeGraphicsObjectBounds<Streamlines>(bounds, onlyVisible); 3364 mergeGraphicsObjectBounds<Text3D>(bounds, onlyVisible); 3195 3365 mergeGraphicsObjectBounds<Volume>(bounds, onlyVisible); 3196 3366 mergeGraphicsObjectBounds<Warp>(bounds, onlyVisible); … … 3253 3423 mergeGraphicsObjectUnscaledBounds<Glyphs>(bounds, onlyVisible); 3254 3424 mergeGraphicsObjectUnscaledBounds<HeightMap>(bounds, onlyVisible); 3425 mergeGraphicsObjectUnscaledBounds<Image>(bounds, onlyVisible); 3255 3426 mergeGraphicsObjectUnscaledBounds<LIC>(bounds, onlyVisible); 3256 3427 mergeGraphicsObjectUnscaledBounds<Line>(bounds, onlyVisible); … … 3262 3433 mergeGraphicsObjectUnscaledBounds<Sphere>(bounds, onlyVisible); 3263 3434 mergeGraphicsObjectUnscaledBounds<Streamlines>(bounds, onlyVisible); 3435 mergeGraphicsObjectUnscaledBounds<Text3D>(bounds, onlyVisible); 3264 3436 mergeGraphicsObjectUnscaledBounds<Volume>(bounds, onlyVisible); 3265 3437 mergeGraphicsObjectUnscaledBounds<Warp>(bounds, onlyVisible); … … 3308 3480 updateGraphicsObjectFieldRanges<Glyphs>(); 3309 3481 updateGraphicsObjectFieldRanges<HeightMap>(); 3482 updateGraphicsObjectFieldRanges<Image>(); 3310 3483 updateGraphicsObjectFieldRanges<LIC>(); 3311 3484 updateGraphicsObjectFieldRanges<Molecule>(); 3485 updateGraphicsObjectFieldRanges<PolyData>(); 3312 3486 updateGraphicsObjectFieldRanges<PseudoColor>(); 3313 3487 updateGraphicsObjectFieldRanges<Streamlines>(); … … 3368 3542 } 3369 3543 _scalarCellDataRange.clear(); 3544 for (FieldRangeHashmap::iterator itr = _scalarFieldDataRange.begin(); 3545 itr != _scalarFieldDataRange.end(); ++itr) { 3546 delete [] itr->second; 3547 } 3548 _scalarFieldDataRange.clear(); 3370 3549 for (FieldRangeHashmap::iterator itr = _vectorPointDataRange.begin(); 3371 3550 itr != _vectorPointDataRange.end(); ++itr) { … … 3392 3571 _vectorCompCellDataRange[i].clear(); 3393 3572 } 3573 for (FieldRangeHashmap::iterator itr = _vectorFieldDataRange.begin(); 3574 itr != _vectorFieldDataRange.end(); ++itr) { 3575 delete [] itr->second; 3576 } 3577 _vectorFieldDataRange.clear(); 3578 for (int i = 0; i < 3; i++) { 3579 for (FieldRangeHashmap::iterator itr = _vectorCompFieldDataRange[i].begin(); 3580 itr != _vectorCompFieldDataRange[i].end(); ++itr) { 3581 delete [] itr->second; 3582 } 3583 _vectorCompFieldDataRange[i].clear(); 3584 } 3394 3585 } 3395 3586 … … 3410 3601 } 3411 3602 _userScalarCellDataRange.clear(); 3603 for (FieldRangeHashmap::iterator itr = _userScalarFieldDataRange.begin(); 3604 itr != _userScalarFieldDataRange.end(); ++itr) { 3605 delete [] itr->second; 3606 } 3607 _userScalarFieldDataRange.clear(); 3412 3608 for (FieldRangeHashmap::iterator itr = _userVectorPointDataRange.begin(); 3413 3609 itr != _userVectorPointDataRange.end(); ++itr) { … … 3433 3629 } 3434 3630 _userVectorCompCellDataRange[i].clear(); 3631 } 3632 for (FieldRangeHashmap::iterator itr = _userVectorFieldDataRange.begin(); 3633 itr != _userVectorFieldDataRange.end(); ++itr) { 3634 delete [] itr->second; 3635 } 3636 _userVectorFieldDataRange.clear(); 3637 for (int i = 0; i < 3; i++) { 3638 for (FieldRangeHashmap::iterator itr = _userVectorCompFieldDataRange[i].begin(); 3639 itr != _userVectorCompFieldDataRange[i].end(); ++itr) { 3640 delete [] itr->second; 3641 } 3642 _userVectorCompFieldDataRange[i].clear(); 3435 3643 } 3436 3644 } … … 3472 3680 _scalarCellDataRange[*itr][0] = 0; 3473 3681 _scalarCellDataRange[*itr][1] = 1; 3682 } 3683 } 3684 names.clear(); 3685 ds->getFieldNames(names, DataSet::FIELD_DATA, 1); 3686 for (std::vector<std::string>::iterator itr = names.begin(); 3687 itr != names.end(); ++itr) { 3688 FieldRangeHashmap::iterator fritr = 3689 _scalarFieldDataRange.find(*itr); 3690 if (fritr == _scalarFieldDataRange.end()) { 3691 _scalarFieldDataRange[*itr] = new double[2]; 3692 _scalarFieldDataRange[*itr][0] = 0; 3693 _scalarFieldDataRange[*itr][1] = 1; 3474 3694 } 3475 3695 } … … 3511 3731 _vectorCompCellDataRange[i][*itr][0] = 0; 3512 3732 _vectorCompCellDataRange[i][*itr][1] = 1; 3733 } 3734 } 3735 } 3736 names.clear(); 3737 ds->getFieldNames(names, DataSet::FIELD_DATA, 3); 3738 for (std::vector<std::string>::iterator itr = names.begin(); 3739 itr != names.end(); ++itr) { 3740 FieldRangeHashmap::iterator fritr = 3741 _vectorFieldDataRange.find(*itr); 3742 if (fritr == _vectorFieldDataRange.end()) { 3743 _vectorFieldDataRange[*itr] = new double[2]; 3744 _vectorFieldDataRange[*itr][0] = 0; 3745 _vectorFieldDataRange[*itr][1] = 1; 3746 } 3747 for (int i = 0; i < 3; i++) { 3748 fritr = _vectorCompFieldDataRange[i].find(*itr); 3749 if (fritr == _vectorCompFieldDataRange[i].end()) { 3750 _vectorCompFieldDataRange[i][*itr] = new double[2]; 3751 _vectorCompFieldDataRange[i][*itr][0] = 0; 3752 _vectorCompFieldDataRange[i][*itr][1] = 1; 3513 3753 } 3514 3754 } … … 3610 3850 } 3611 3851 break; 3852 case DataSet::FIELD_DATA: { 3853 FieldRangeHashmap::iterator itr; 3854 if (numComponents == 1) { 3855 itr = _userScalarFieldDataRange.find(name); 3856 if (itr == _userScalarFieldDataRange.end()) { 3857 _userScalarFieldDataRange[name] = new double[2]; 3858 memcpy(_userScalarFieldDataRange[name], range, sizeof(double)*2); 3859 } else { 3860 found = true; 3861 memcpy(itr->second, range, sizeof(double)*2); 3862 } 3863 } else if (numComponents == 3) { 3864 if (component == -1) { 3865 itr = _userVectorFieldDataRange.find(name); 3866 if (itr == _userVectorFieldDataRange.end()) { 3867 _userVectorFieldDataRange[name] = new double[2]; 3868 memcpy(_userVectorFieldDataRange[name], range, sizeof(double)*2); 3869 } else { 3870 found = true; 3871 memcpy(itr->second, range, sizeof(double)*2); 3872 } 3873 } else if (component >= 0 && component <= 3) { 3874 itr = _userVectorCompFieldDataRange[component].find(name); 3875 if (itr == _userVectorCompFieldDataRange[component].end()) { 3876 _userVectorCompFieldDataRange[component][name] = new double[2]; 3877 memcpy(_userVectorCompFieldDataRange[component][name], range, sizeof(double)*2); 3878 } else { 3879 found = true; 3880 memcpy(itr->second, range, sizeof(double)*2); 3881 } 3882 } 3883 } 3884 } 3885 break; 3612 3886 default: 3613 3887 ERROR("Bad Field Type"); … … 3626 3900 /** 3627 3901 * \brief Get the cumulative range across all DataSets for a point 3628 * data field if it exists, otherwise a cell data field if it exists 3902 * data field if it exists, otherwise a cell data field if it exists, 3903 * otherwise a field data field if it exists 3629 3904 * 3630 3905 * \param[out] range Pointer to an array of 2 doubles … … 3639 3914 { 3640 3915 bool ret; 3641 if (!(ret = getCumulativeDataRange(range, name, DataSet::POINT_DATA, 3642 numComponents, component))) 3643 ret = getCumulativeDataRange(range, name, DataSet::CELL_DATA, 3916 if ((ret = getCumulativeDataRange(range, name, DataSet::POINT_DATA, 3917 numComponents, component))) { 3918 ; // Found point data 3919 } else if ((ret = getCumulativeDataRange(range, name, DataSet::CELL_DATA, 3920 numComponents, component))) { 3921 ; // Found cell data 3922 3923 } else { 3924 ret = getCumulativeDataRange(range, name, DataSet::FIELD_DATA, 3644 3925 numComponents, component); 3926 } 3645 3927 return ret; 3646 3928 } … … 3739 4021 } 3740 4022 break; 4023 case DataSet::FIELD_DATA: { 4024 FieldRangeHashmap::iterator itr; 4025 if (numComponents == 1) { 4026 itr = _userScalarFieldDataRange.find(name); 4027 if (itr == _userScalarFieldDataRange.end()) { 4028 itr = _scalarFieldDataRange.find(name); 4029 if (itr == _scalarFieldDataRange.end()) { 4030 return false; 4031 } 4032 } 4033 memcpy(range, itr->second, sizeof(double)*2); 4034 return true; 4035 } else if (numComponents == 3) { 4036 if (component == -1) { 4037 itr = _userVectorFieldDataRange.find(name); 4038 if (itr == _userVectorFieldDataRange.end()) { 4039 itr = _vectorFieldDataRange.find(name); 4040 if (itr == _vectorFieldDataRange.end()) { 4041 return false; 4042 } 4043 } 4044 memcpy(range, itr->second, sizeof(double)*2); 4045 return true; 4046 } else if (component >= 0 && component <= 3) { 4047 itr = _userVectorCompFieldDataRange[component].find(name); 4048 if (itr == _userVectorCompFieldDataRange[component].end()) { 4049 itr = _vectorCompFieldDataRange[component].find(name); 4050 if (itr == _vectorCompFieldDataRange[component].end()) { 4051 return false; 4052 } 4053 } 4054 memcpy(range, itr->second, sizeof(double)*2); 4055 return true; 4056 } 4057 } 4058 } 4059 break; 3741 4060 default: 3742 4061 break; … … 3757 4076 collectDataRanges(itr->second, itr->first.c_str(), 3758 4077 DataSet::CELL_DATA, -1, 4078 _cumulativeRangeOnlyVisible); 4079 } 4080 for (FieldRangeHashmap::iterator itr = _scalarFieldDataRange.begin(); 4081 itr != _scalarFieldDataRange.end(); ++itr) { 4082 collectDataRanges(itr->second, itr->first.c_str(), 4083 DataSet::FIELD_DATA, -1, 3759 4084 _cumulativeRangeOnlyVisible); 3760 4085 } … … 3784 4109 collectDataRanges(itr->second, itr->first.c_str(), 3785 4110 DataSet::CELL_DATA, i, 4111 _cumulativeRangeOnlyVisible); 4112 } 4113 } 4114 for (FieldRangeHashmap::iterator itr = _vectorFieldDataRange.begin(); 4115 itr != _vectorFieldDataRange.end(); ++itr) { 4116 collectDataRanges(itr->second, itr->first.c_str(), 4117 DataSet::FIELD_DATA, -1, 4118 _cumulativeRangeOnlyVisible); 4119 } 4120 for (int i = 0; i < 3; i++) { 4121 for (FieldRangeHashmap::iterator itr = _vectorCompFieldDataRange[i].begin(); 4122 itr != _vectorCompFieldDataRange[i].end(); ++itr) { 4123 collectDataRanges(itr->second, itr->first.c_str(), 4124 DataSet::FIELD_DATA, i, 3786 4125 _cumulativeRangeOnlyVisible); 3787 4126 } … … 4024 4363 if (id.compare("all") == 0 || getGraphicsObject<HeightMap>(id) != NULL) 4025 4364 setGraphicsObjectOpacity<HeightMap>(id, opacity); 4365 if (id.compare("all") == 0 || getGraphicsObject<Image>(id) != NULL) 4366 setGraphicsObjectOpacity<Image>(id, opacity); 4026 4367 if (id.compare("all") == 0 || getGraphicsObject<LIC>(id) != NULL) 4027 4368 setGraphicsObjectOpacity<LIC>(id, opacity); … … 4080 4421 if (id.compare("all") == 0 || getGraphicsObject<HeightMap>(id) != NULL) 4081 4422 setGraphicsObjectVisibility<HeightMap>(id, state); 4423 if (id.compare("all") == 0 || getGraphicsObject<Image>(id) != NULL) 4424 setGraphicsObjectVisibility<Image>(id, state); 4082 4425 if (id.compare("all") == 0 || getGraphicsObject<LIC>(id) != NULL) 4083 4426 setGraphicsObjectVisibility<LIC>(id, state); … … 4229 4572 setGraphicsObjectClippingPlanes<Group>(_activeClipPlanes); 4230 4573 setGraphicsObjectClippingPlanes<HeightMap>(_activeClipPlanes); 4574 setGraphicsObjectClippingPlanes<Image>(_activeClipPlanes); 4231 4575 setGraphicsObjectClippingPlanes<LIC>(_activeClipPlanes); 4232 4576 setGraphicsObjectClippingPlanes<Line>(_activeClipPlanes); … … 4238 4582 setGraphicsObjectClippingPlanes<Sphere>(_activeClipPlanes); 4239 4583 setGraphicsObjectClippingPlanes<Streamlines>(_activeClipPlanes); 4584 setGraphicsObjectClippingPlanes<Text3D>(_activeClipPlanes); 4240 4585 setGraphicsObjectClippingPlanes<Volume>(_activeClipPlanes); 4241 4586 setGraphicsObjectClippingPlanes<Warp>(_activeClipPlanes); … … 4293 4638 setCameraClippingPlanes(); 4294 4639 _renderWindow->Render(); 4640 int *sz = _renderWindow->GetSize(); 4641 if (sz[0] != _windowWidth || sz[1] != _windowHeight) { 4642 ERROR("Window size: %dx%d, but expected %dx%d", sz[0], sz[1], _windowWidth, _windowHeight); 4643 } 4295 4644 _needsRedraw = false; 4296 4645 return true; -
branches/1.3/packages/vizservers/vtkvis/Renderer.h
r3696 r3844 40 40 #include "Group.h" 41 41 #include "HeightMap.h" 42 #include "Image.h" 42 43 #include "LIC.h" 43 44 #include "Line.h" … … 49 50 #include "Sphere.h" 50 51 #include "Streamlines.h" 52 #include "Text3D.h" 51 53 #include "Volume.h" 52 54 #include "Warp.h" … … 420 422 421 423 void setColorMapNumberOfTableEntries(const ColorMapId& id, int numEntries); 424 425 bool renderColorMap(const ColorMapId& id, 426 int width, int height, 427 bool opaque, 428 vtkUnsignedCharArray *imgData); 422 429 423 430 bool renderColorMap(const ColorMapId& id, … … 699 706 void setGlyphsScaleFactor(const DataSetId& id, double scale); 700 707 708 void setGlyphsMaximumNumberOfGlyphs(const DataSetId& id, int max, 709 bool random = true, 710 int offset = 0, int ratio = 1); 711 701 712 // Groups 702 713 … … 741 752 const char *name, double range[2] = NULL); 742 753 754 // Images 755 756 void setImageBackground(const DataSetId& id, bool state); 757 758 void setImageBacking(const DataSetId& id, bool state); 759 760 void setImageBorder(const DataSetId& id, bool state); 761 762 void setImageExtents(const DataSetId& id, int extents[6]); 763 764 void setImageLevel(const DataSetId& id, double level); 765 766 void setImageWindow(const DataSetId& id, double window); 767 768 void setImageZSlice(const DataSetId& id, int z); 743 769 744 770 // Lines … … 792 818 PolyData::CloudStyle style); 793 819 820 void setPolyDataColorMode(const DataSetId& id, 821 PolyData::ColorMode mode, 822 const char *name, double range[2] = NULL); 823 824 void setPolyDataColorMode(const DataSetId& id, 825 PolyData::ColorMode mode, 826 DataSet::DataAttributeType type, 827 const char *name, double range[2] = NULL); 828 794 829 // Color-mapped surfaces 795 830 … … 876 911 877 912 void setStreamlinesTypeToRibbons(const DataSetId& id, double width, double angle); 913 914 // Text3Ds 915 916 bool addText3D(const DataSetId& id, const char *string, 917 const char *fontFamily, int fontSize, 918 bool bold = false, bool italic = false, bool shadow = false); 919 920 void setText3DBold(const DataSetId& id, bool state); 921 922 void setText3DFollowCamera(const DataSetId& id, bool state); 923 924 void setText3DFont(const DataSetId& id, const char *fontFamily); 925 926 void setText3DFontSize(const DataSetId& id, int size); 927 928 void setText3DItalic(const DataSetId& id, bool state); 929 930 void setText3DShadow(const DataSetId& id, bool state); 931 932 void setText3DText(const DataSetId& id, const char *text); 878 933 879 934 // Volumes … … 915 970 typedef std::tr1::unordered_map<DataSetId, Group *> GroupHashmap; 916 971 typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap; 972 typedef std::tr1::unordered_map<DataSetId, Image *> ImageHashmap; 917 973 typedef std::tr1::unordered_map<DataSetId, LIC *> LICHashmap; 918 974 typedef std::tr1::unordered_map<DataSetId, Line *> LineHashmap; … … 924 980 typedef std::tr1::unordered_map<DataSetId, Sphere *> SphereHashmap; 925 981 typedef std::tr1::unordered_map<DataSetId, Streamlines *> StreamlinesHashmap; 982 typedef std::tr1::unordered_map<DataSetId, Text3D *> Text3DHashmap; 926 983 typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap; 927 984 typedef std::tr1::unordered_map<DataSetId, Warp *> WarpHashmap; … … 1019 1076 FieldRangeHashmap _vectorCellDataRange; 1020 1077 FieldRangeHashmap _vectorCompCellDataRange[3]; 1078 FieldRangeHashmap _scalarFieldDataRange; 1079 FieldRangeHashmap _vectorFieldDataRange; 1080 FieldRangeHashmap _vectorCompFieldDataRange[3]; 1021 1081 1022 1082 FieldRangeHashmap _userScalarPointDataRange; … … 1026 1086 FieldRangeHashmap _userVectorCellDataRange; 1027 1087 FieldRangeHashmap _userVectorCompCellDataRange[3]; 1088 FieldRangeHashmap _userScalarFieldDataRange; 1089 FieldRangeHashmap _userVectorFieldDataRange; 1090 FieldRangeHashmap _userVectorCompFieldDataRange[3]; 1028 1091 1029 1092 bool _axesAutoBounds[3]; … … 1046 1109 GroupHashmap _groups; 1047 1110 HeightMapHashmap _heightMaps; 1111 ImageHashmap _images; 1048 1112 LICHashmap _lics; 1049 1113 LineHashmap _lines; … … 1055 1119 SphereHashmap _spheres; 1056 1120 StreamlinesHashmap _streamlines; 1121 Text3DHashmap _text3Ds; 1057 1122 VolumeHashmap _volumes; 1058 1123 WarpHashmap _warps; -
branches/1.3/packages/vizservers/vtkvis/RendererCmd.cpp
r3696 r3844 2049 2049 {"orient", 4, BoxOrientOp, 6, 7, "qw qx qy qz ?name?"}, 2050 2050 {"origin", 4, BoxOriginOp, 5, 6, "x y z ?name?"}, 2051 {"pos", 2, BoxPositionOp, 5, 6, "x y z ?name?"},2051 {"pos", 1, BoxPositionOp, 5, 6, "x y z ?name?"}, 2052 2052 {"scale", 2, BoxScaleOp, 5, 6, "sx sy sz ?name?"}, 2053 2053 {"shading", 2, BoxShadingOp, 3, 4, "val ?name?"}, … … 2891 2891 {"orient", 4, ConeOrientOp, 6, 7, "qw qx qy qz ?name?"}, 2892 2892 {"origin", 4, ConeOriginOp, 5, 6, "x y z ?name?"}, 2893 {"pos", 2, ConePositionOp, 5, 6, "x y z ?name?"},2893 {"pos", 1, ConePositionOp, 5, 6, "x y z ?name?"}, 2894 2894 {"resolution",1, ConeResolutionOp, 3, 4, "res ?name?"}, 2895 2895 {"scale", 2, ConeScaleOp, 5, 6, "sx sy sz ?name?"}, … … 3026 3026 Contour2D::ColorMode mode; 3027 3027 const char *str = Tcl_GetString(objv[2]); 3028 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 3028 if (str[0] == 'c' && 3029 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 3029 3030 mode = Contour2D::COLOR_CONSTANT; 3030 3031 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 3040 3041 } else { 3041 3042 Tcl_AppendResult(interp, "bad color mode option \"", str, 3042 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);3043 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 3043 3044 return TCL_ERROR; 3044 3045 } … … 3253 3254 {"add", 1, Contour2DAddOp, 4, 5, "oper value ?dataSetName?"}, 3254 3255 {"ccolor", 2, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 3256 {"color", 5, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"}, 3255 3257 {"colormap", 7, Contour2DColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 3256 3258 {"colormode", 7, Contour2DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 3401 3403 Contour3D::ColorMode mode; 3402 3404 const char *str = Tcl_GetString(objv[2]); 3403 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 3405 if (str[0] == 'c' && 3406 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 3404 3407 mode = Contour3D::COLOR_CONSTANT; 3405 3408 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 3415 3418 } else { 3416 3419 Tcl_AppendResult(interp, "bad color mode option \"", str, 3417 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);3420 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 3418 3421 return TCL_ERROR; 3419 3422 } … … 3688 3691 {"add", 1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"}, 3689 3692 {"ccolor", 2, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"}, 3693 {"color", 5, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"}, 3690 3694 {"colormap", 7, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 3691 3695 {"colormode", 7, Contour3DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 4122 4126 {"ccolor", 2, CutplaneColorOp, 5, 6, "r g b ?dataSetName?"}, 4123 4127 {"cloudstyle", 2, CutplaneCloudStyleOp, 3, 4, "style ?dataSetName?"}, 4128 {"color", 5, CutplaneColorOp, 5, 6, "r g b ?dataSetName?"}, 4124 4129 {"colormap", 7, CutplaneColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4125 4130 {"colormode", 7, CutplaneColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 4518 4523 {"orient", 4, CylinderOrientOp, 6, 7, "qw qx qy qz ?name?"}, 4519 4524 {"origin", 4, CylinderOriginOp, 5, 6, "x y z ?name?"}, 4520 {"pos", 2, CylinderPositionOp, 5, 6, "x y z ?name?"},4525 {"pos", 1, CylinderPositionOp, 5, 6, "x y z ?name?"}, 4521 4526 {"resolution",1, CylinderResolutionOp, 3, 4, "res ?name?"}, 4522 4527 {"scale", 2, CylinderScaleOp, 5, 6, "sx sy sz ?name?"}, … … 5334 5339 {"orient", 4, DiskOrientOp, 6, 7, "qw qx qy qz ?name?"}, 5335 5340 {"origin", 4, DiskOriginOp, 5, 6, "x y z ?name?"}, 5336 {"pos", 2, DiskPositionOp, 5, 6, "x y z ?name?"},5341 {"pos", 1, DiskPositionOp, 5, 6, "x y z ?name?"}, 5337 5342 {"resolution",1, DiskResolutionOp, 4, 5, "resRadial resCircum ?name?"}, 5338 5343 {"scale", 2, DiskScaleOp, 5, 6, "sx sy sz ?name?"}, … … 5446 5451 Glyphs::ColorMode mode; 5447 5452 const char *str = Tcl_GetString(objv[2]); 5448 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 5453 if (str[0] == 'c' && 5454 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 5449 5455 mode = Glyphs::COLOR_CONSTANT; 5450 5456 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 5460 5466 } else { 5461 5467 Tcl_AppendResult(interp, "bad color mode option \"", str, 5462 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);5468 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 5463 5469 return TCL_ERROR; 5464 5470 } … … 5555 5561 } else { 5556 5562 g_renderer->setGraphicsObjectEdgeWidth<Glyphs>("all", width); 5563 } 5564 return TCL_OK; 5565 } 5566 5567 static int 5568 GlyphsMaxNumberOfGlyphsOp(ClientData clientData, Tcl_Interp *interp, int objc, 5569 Tcl_Obj *const *objv) 5570 { 5571 int max; 5572 bool random = true; 5573 int offset = 0; 5574 int ratio = 1; 5575 if (Tcl_GetIntFromObj(interp, objv[2], &max) != TCL_OK) { 5576 return TCL_ERROR; 5577 } 5578 if (objc > 3) { 5579 if (GetBooleanFromObj(interp, objv[3], &random) != TCL_OK) { 5580 return TCL_ERROR; 5581 } 5582 if (Tcl_GetIntFromObj(interp, objv[4], &offset) != TCL_OK) { 5583 return TCL_ERROR; 5584 } 5585 if (Tcl_GetIntFromObj(interp, objv[5], &ratio) != TCL_OK) { 5586 return TCL_ERROR; 5587 } 5588 } 5589 if (objc == 7) { 5590 const char *name = Tcl_GetString(objv[6]); 5591 g_renderer->setGlyphsMaximumNumberOfGlyphs(name, max, random, offset, ratio); 5592 } else { 5593 g_renderer->setGlyphsMaximumNumberOfGlyphs("all", max, random, offset, ratio); 5557 5594 } 5558 5595 return TCL_OK; … … 5830 5867 {"add", 1, GlyphsAddOp, 3, 4, "shape ?dataSetName?"}, 5831 5868 {"ccolor", 2, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"}, 5869 {"color", 5, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"}, 5832 5870 {"colormap", 7, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 5833 5871 {"colormode", 7, GlyphsColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 5839 5877 {"linecolor", 5, GlyphsLineColorOp, 5, 6, "r g b ?dataSetName?"}, 5840 5878 {"linewidth", 5, GlyphsLineWidthOp, 3, 4, "width ?dataSetName?"}, 5841 {"normscale", 1, GlyphsNormalizeScaleOp, 3, 4, "bool ?dataSetName?"}, 5879 {"normscale", 2, GlyphsNormalizeScaleOp, 3, 4, "bool ?dataSetName?"}, 5880 {"numglyphs", 2, GlyphsMaxNumberOfGlyphsOp, 3, 7, "max ?random? ?offset? ?ratio? ?dataSetName?"}, 5842 5881 {"opacity", 2, GlyphsOpacityOp, 3, 4, "value ?dataSetName?"}, 5843 5882 {"orient", 2, GlyphsOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, … … 6024 6063 {"pos", 1, GroupPositionOp, 5, 6, "x y z ?name?"}, 6025 6064 {"remove", 1, GroupRemoveChildOp, 3, 4, "nodeList ?name?"}, 6026 {"scale", 2, GroupScaleOp, 5, 6, "sx sy sz ?name?"},6065 {"scale", 1, GroupScaleOp, 5, 6, "sx sy sz ?name?"}, 6027 6066 {"visible", 1, GroupVisibleOp, 3, 4, "bool ?name?"}, 6028 6067 }; … … 6212 6251 HeightMap::ColorMode mode; 6213 6252 const char *str = Tcl_GetString(objv[2]); 6214 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 6253 if (str[0] == 'c' && 6254 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 6215 6255 mode = HeightMap::COLOR_CONSTANT; 6216 6256 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 6226 6266 } else { 6227 6267 Tcl_AppendResult(interp, "bad color mode option \"", str, 6228 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);6268 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 6229 6269 return TCL_ERROR; 6230 6270 } … … 6238 6278 } else { 6239 6279 g_renderer->setHeightMapColorMode("all", mode, fieldName); 6280 } 6281 return TCL_OK; 6282 } 6283 6284 static int 6285 HeightMapColorMode2Op(ClientData clientData, Tcl_Interp *interp, int objc, 6286 Tcl_Obj *const *objv) 6287 { 6288 HeightMap::ColorMode mode; 6289 const char *str = Tcl_GetString(objv[2]); 6290 if (str[0] == 'c' && 6291 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 6292 mode = HeightMap::COLOR_CONSTANT; 6293 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { 6294 mode = HeightMap::COLOR_BY_SCALAR; 6295 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 6296 mode = HeightMap::COLOR_BY_VECTOR_MAGNITUDE; 6297 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 6298 mode = HeightMap::COLOR_BY_VECTOR_X; 6299 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 6300 mode = HeightMap::COLOR_BY_VECTOR_Y; 6301 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 6302 mode = HeightMap::COLOR_BY_VECTOR_Z; 6303 } else { 6304 Tcl_AppendResult(interp, "bad color mode option \"", str, 6305 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL); 6306 return TCL_ERROR; 6307 } 6308 const char *fieldName = Tcl_GetString(objv[3]); 6309 if (mode == HeightMap::COLOR_CONSTANT) { 6310 fieldName = NULL; 6311 } 6312 str = Tcl_GetString(objv[4]); 6313 DataSet::DataAttributeType association = DataSet::POINT_DATA; 6314 bool haveAssoc = false; 6315 if (str[0] == 'p' && strcmp(str, "point_data") == 0) { 6316 association = DataSet::POINT_DATA; 6317 haveAssoc = true; 6318 } else if (str[0] == 'c' && strcmp(str, "cell_data") == 0) { 6319 association = DataSet::CELL_DATA; 6320 haveAssoc = true; 6321 } else if (str[0] == 'f' && strcmp(str, "field_data") == 0) { 6322 association = DataSet::FIELD_DATA; 6323 haveAssoc = true; 6324 } else if (str[0] == 'a' && strcmp(str, "any") == 0) { 6325 haveAssoc = false; 6326 } else { 6327 Tcl_AppendResult(interp, "bad color mode association option \"", str, 6328 "\": should be one of: 'point_data', 'cell_data', 'field_data', 'any'", (char*)NULL); 6329 return TCL_ERROR; 6330 } 6331 double *range = NULL; 6332 if (objc >= 7) { 6333 range = new double[2]; 6334 if (Tcl_GetDoubleFromObj(interp, objv[5], &range[0]) != TCL_OK || 6335 Tcl_GetDoubleFromObj(interp, objv[6], &range[1]) != TCL_OK) { 6336 return TCL_ERROR; 6337 } 6338 } 6339 if (objc == 6 || objc == 8) { 6340 const char *name = Tcl_GetString((objc == 6 ? objv[5] : objv[7])); 6341 if (haveAssoc) { 6342 g_renderer->setHeightMapColorMode(name, mode, association, fieldName, range); 6343 } else { 6344 g_renderer->setHeightMapColorMode(name, mode, fieldName, range); 6345 } 6346 } else { 6347 if (haveAssoc) { 6348 g_renderer->setHeightMapColorMode("all", mode, association, fieldName, range); 6349 } else { 6350 g_renderer->setHeightMapColorMode("all", mode, fieldName, range); 6351 } 6352 } 6353 if (range != NULL) { 6354 delete [] range; 6240 6355 } 6241 6356 return TCL_OK; … … 6639 6754 {"ccolor", 2, HeightMapColorOp, 5, 6, "r g b ?dataSetName?"}, 6640 6755 {"cloudstyle", 2, HeightMapCloudStyleOp, 3, 4, "style ?dataSetName?"}, 6756 {"color", 5, HeightMapColorOp, 5, 6, "r g b ?dataSetName?"}, 6641 6757 {"colormap", 7, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 6642 {"colormode", 7, HeightMapColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, 6758 {"colormode", 9, HeightMapColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, 6759 {"colormode2", 10,HeightMapColorMode2Op, 5, 8, "mode fieldName association ?min max? ?dataSetName?"}, 6643 6760 {"contourlist", 3, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"}, 6644 6761 {"delete", 1, HeightMapDeleteOp, 2, 3, "?dataSetName?"}, … … 6680 6797 6681 6798 static int 6799 ImageAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 6800 Tcl_Obj *const *objv) 6801 { 6802 if (objc == 3) { 6803 const char *name = Tcl_GetString(objv[2]); 6804 if (!g_renderer->addGraphicsObject<Image>(name)) { 6805 Tcl_AppendResult(interp, "Failed to create image", (char*)NULL); 6806 return TCL_ERROR; 6807 } 6808 } else { 6809 if (!g_renderer->addGraphicsObject<Image>("all")) { 6810 Tcl_AppendResult(interp, "Failed to create iamge for one or more data sets", (char*)NULL); 6811 return TCL_ERROR; 6812 } 6813 } 6814 return TCL_OK; 6815 } 6816 6817 static int 6818 ImageBackgroundOp(ClientData clientData, Tcl_Interp *interp, int objc, 6819 Tcl_Obj *const *objv) 6820 { 6821 bool state; 6822 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6823 return TCL_ERROR; 6824 } 6825 if (objc == 4) { 6826 const char *name = Tcl_GetString(objv[3]); 6827 g_renderer->setImageBackground(name, state); 6828 } else { 6829 g_renderer->setImageBackground("all", state); 6830 } 6831 return TCL_OK; 6832 } 6833 6834 static int 6835 ImageBackingOp(ClientData clientData, Tcl_Interp *interp, int objc, 6836 Tcl_Obj *const *objv) 6837 { 6838 bool state; 6839 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6840 return TCL_ERROR; 6841 } 6842 if (objc == 4) { 6843 const char *name = Tcl_GetString(objv[3]); 6844 g_renderer->setImageBacking(name, state); 6845 } else { 6846 g_renderer->setImageBacking("all", state); 6847 } 6848 return TCL_OK; 6849 } 6850 6851 static int 6852 ImageBorderOp(ClientData clientData, Tcl_Interp *interp, int objc, 6853 Tcl_Obj *const *objv) 6854 { 6855 bool state; 6856 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6857 return TCL_ERROR; 6858 } 6859 if (objc == 4) { 6860 const char *name = Tcl_GetString(objv[3]); 6861 g_renderer->setImageBorder(name, state); 6862 } else { 6863 g_renderer->setImageBorder("all", state); 6864 } 6865 return TCL_OK; 6866 } 6867 6868 static int 6869 ImageColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 6870 Tcl_Obj *const *objv) 6871 { 6872 float color[3]; 6873 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 6874 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 6875 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 6876 return TCL_ERROR; 6877 } 6878 if (objc == 6) { 6879 const char *name = Tcl_GetString(objv[5]); 6880 g_renderer->setGraphicsObjectColor<Image>(name, color); 6881 } else { 6882 g_renderer->setGraphicsObjectColor<Image>("all", color); 6883 } 6884 return TCL_OK; 6885 } 6886 6887 static int 6888 ImageColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 6889 Tcl_Obj *const *objv) 6890 { 6891 const char *colorMapName = Tcl_GetString(objv[2]); 6892 if (objc == 4) { 6893 const char *dataSetName = Tcl_GetString(objv[3]); 6894 g_renderer->setGraphicsObjectColorMap<Image>(dataSetName, colorMapName); 6895 } else { 6896 g_renderer->setGraphicsObjectColorMap<Image>("all", colorMapName); 6897 } 6898 return TCL_OK; 6899 } 6900 6901 static int 6902 ImageDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 6903 Tcl_Obj *const *objv) 6904 { 6905 if (objc == 3) { 6906 const char *name = Tcl_GetString(objv[2]); 6907 g_renderer->deleteGraphicsObject<Image>(name); 6908 } else { 6909 g_renderer->deleteGraphicsObject<Image>("all"); 6910 } 6911 return TCL_OK; 6912 } 6913 6914 static int 6915 ImageExtentsOp(ClientData clientData, Tcl_Interp *interp, int objc, 6916 Tcl_Obj *const *objv) 6917 { 6918 int extents[6]; 6919 if (Tcl_GetIntFromObj(interp, objv[2], &extents[0]) != TCL_OK || 6920 Tcl_GetIntFromObj(interp, objv[3], &extents[1]) != TCL_OK || 6921 Tcl_GetIntFromObj(interp, objv[4], &extents[2]) != TCL_OK || 6922 Tcl_GetIntFromObj(interp, objv[5], &extents[3]) != TCL_OK || 6923 Tcl_GetIntFromObj(interp, objv[6], &extents[4]) != TCL_OK || 6924 Tcl_GetIntFromObj(interp, objv[7], &extents[5]) != TCL_OK) { 6925 return TCL_ERROR; 6926 } 6927 if (objc == 9) { 6928 const char *name = Tcl_GetString(objv[8]); 6929 g_renderer->setImageExtents(name, extents); 6930 } else { 6931 g_renderer->setImageExtents("all", extents); 6932 } 6933 return TCL_OK; 6934 } 6935 6936 static int 6937 ImageLevelOp(ClientData clientData, Tcl_Interp *interp, int objc, 6938 Tcl_Obj *const *objv) 6939 { 6940 double level; 6941 if (Tcl_GetDoubleFromObj(interp, objv[2], &level) != TCL_OK) { 6942 return TCL_ERROR; 6943 } 6944 if (objc == 4) { 6945 const char *name = Tcl_GetString(objv[3]); 6946 g_renderer->setImageLevel(name, level); 6947 } else { 6948 g_renderer->setImageLevel("all", level); 6949 } 6950 return TCL_OK; 6951 } 6952 6953 static int 6954 ImageOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 6955 Tcl_Obj *const *objv) 6956 { 6957 double opacity; 6958 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 6959 return TCL_ERROR; 6960 } 6961 if (objc == 4) { 6962 const char *name = Tcl_GetString(objv[3]); 6963 g_renderer->setGraphicsObjectOpacity<Image>(name, opacity); 6964 } else { 6965 g_renderer->setGraphicsObjectOpacity<Image>("all", opacity); 6966 } 6967 return TCL_OK; 6968 } 6969 6970 static int 6971 ImageOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 6972 Tcl_Obj *const *objv) 6973 { 6974 double quat[4]; 6975 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 6976 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 6977 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 6978 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 6979 return TCL_ERROR; 6980 } 6981 if (objc == 7) { 6982 const char *name = Tcl_GetString(objv[6]); 6983 g_renderer->setGraphicsObjectOrientation<Image>(name, quat); 6984 } else { 6985 g_renderer->setGraphicsObjectOrientation<Image>("all", quat); 6986 } 6987 return TCL_OK; 6988 } 6989 6990 static int 6991 ImagePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 6992 Tcl_Obj *const *objv) 6993 { 6994 double pos[3]; 6995 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 6996 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 6997 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 6998 return TCL_ERROR; 6999 } 7000 if (objc == 6) { 7001 const char *name = Tcl_GetString(objv[5]); 7002 g_renderer->setGraphicsObjectPosition<Image>(name, pos); 7003 } else { 7004 g_renderer->setGraphicsObjectPosition<Image>("all", pos); 7005 } 7006 return TCL_OK; 7007 } 7008 7009 static int 7010 ImageScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 7011 Tcl_Obj *const *objv) 7012 { 7013 double scale[3]; 7014 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 7015 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 7016 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 7017 return TCL_ERROR; 7018 } 7019 if (objc == 6) { 7020 const char *name = Tcl_GetString(objv[5]); 7021 g_renderer->setGraphicsObjectScale<Image>(name, scale); 7022 } else { 7023 g_renderer->setGraphicsObjectScale<Image>("all", scale); 7024 } 7025 return TCL_OK; 7026 } 7027 7028 static int 7029 ImageVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 7030 Tcl_Obj *const *objv) 7031 { 7032 bool state; 7033 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 7034 return TCL_ERROR; 7035 } 7036 if (objc == 4) { 7037 const char *name = Tcl_GetString(objv[3]); 7038 g_renderer->setGraphicsObjectVisibility<Image>(name, state); 7039 } else { 7040 g_renderer->setGraphicsObjectVisibility<Image>("all", state); 7041 } 7042 return TCL_OK; 7043 } 7044 7045 static int 7046 ImageWindowOp(ClientData clientData, Tcl_Interp *interp, int objc, 7047 Tcl_Obj *const *objv) 7048 { 7049 double window; 7050 if (Tcl_GetDoubleFromObj(interp, objv[2], &window) != TCL_OK) { 7051 return TCL_ERROR; 7052 } 7053 if (objc == 4) { 7054 const char *name = Tcl_GetString(objv[3]); 7055 g_renderer->setImageLevel(name, window); 7056 } else { 7057 g_renderer->setImageLevel("all", window); 7058 } 7059 return TCL_OK; 7060 } 7061 7062 static int 7063 ImageZSliceOp(ClientData clientData, Tcl_Interp *interp, int objc, 7064 Tcl_Obj *const *objv) 7065 { 7066 int slice; 7067 if (Tcl_GetIntFromObj(interp, objv[2], &slice) != TCL_OK) { 7068 return TCL_ERROR; 7069 } 7070 if (objc == 4) { 7071 const char *name = Tcl_GetString(objv[3]); 7072 g_renderer->setImageZSlice(name, slice); 7073 } else { 7074 g_renderer->setImageZSlice("all", slice); 7075 } 7076 return TCL_OK; 7077 } 7078 7079 static Rappture::CmdSpec imageOps[] = { 7080 {"add", 1, ImageAddOp, 2, 3, "?dataSetName?"}, 7081 {"backing", 2, ImageBackingOp, 3, 4, "bool ?dataSetName?"}, 7082 {"bg", 2, ImageBackgroundOp, 3, 4, "bool ?dataSetName?"}, 7083 {"border", 2, ImageBorderOp, 3, 4, "bool ?dataSetName?"}, 7084 {"color", 5, ImageColorOp, 5, 6, "r g b ?dataSetName?"}, 7085 {"colormap", 6, ImageColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 7086 {"delete", 1, ImageDeleteOp, 2, 3, "?dataSetName?"}, 7087 {"extents", 1, ImageExtentsOp, 8, 9, "xmin xmax ymin ymax zmin zmax ?dataSetName?"}, 7088 {"level", 1, ImageLevelOp, 3, 4, "val ?dataSetName?"}, 7089 {"opacity", 2, ImageOpacityOp, 3, 4, "value ?dataSetName?"}, 7090 {"orient", 2, ImageOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 7091 {"pos", 1, ImagePositionOp, 5, 6, "x y z ?dataSetName?"}, 7092 {"scale", 1, ImageScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 7093 {"visible", 1, ImageVisibleOp, 3, 4, "bool ?dataSetName?"}, 7094 {"window", 1, ImageWindowOp, 3, 4, "val ?dataSetName?"}, 7095 {"zslice", 1, ImageZSliceOp, 3, 4, "val ?dataSetName?"} 7096 }; 7097 static int nImageOps = NumCmdSpecs(imageOps); 7098 7099 static int 7100 ImageCmd(ClientData clientData, Tcl_Interp *interp, int objc, 7101 Tcl_Obj *const *objv) 7102 { 7103 Tcl_ObjCmdProc *proc; 7104 7105 proc = Rappture::GetOpFromObj(interp, nImageOps, imageOps, 7106 Rappture::CMDSPEC_ARG1, objc, objv, 0); 7107 if (proc == NULL) { 7108 return TCL_ERROR; 7109 } 7110 return (*proc) (clientData, interp, objc, objv); 7111 } 7112 7113 static int 6682 7114 ImageFlushCmd(ClientData clientData, Tcl_Interp *interp, int objc, 6683 7115 Tcl_Obj *const *objv) … … 6786 7218 6787 7219 static int 7220 LegendSimpleCmd(ClientData clientData, Tcl_Interp *interp, int objc, 7221 Tcl_Obj *const *objv) 7222 { 7223 if (objc != 4) { 7224 Tcl_AppendResult(interp, "wrong # args: should be \"", 7225 Tcl_GetString(objv[0]), " colormapName width height\"", (char*)NULL); 7226 return TCL_ERROR; 7227 } 7228 const char *colorMapName = Tcl_GetString(objv[1]); 7229 7230 int width, height; 7231 if (Tcl_GetIntFromObj(interp, objv[2], &width) != TCL_OK || 7232 Tcl_GetIntFromObj(interp, objv[3], &height) != TCL_OK) { 7233 return TCL_ERROR; 7234 } 7235 7236 vtkSmartPointer<vtkUnsignedCharArray> imgData = 7237 vtkSmartPointer<vtkUnsignedCharArray>::New(); 7238 7239 if (!g_renderer->renderColorMap(colorMapName, width, height, true, imgData)) { 7240 Tcl_AppendResult(interp, "Color map \"", 7241 colorMapName, "\" was not found", (char*)NULL); 7242 return TCL_ERROR; 7243 } 7244 7245 #ifdef DEBUG 7246 # ifdef RENDER_TARGA 7247 writeTGAFile("/tmp/legend.tga", imgData->GetPointer(0), width, height, 7248 TARGA_BYTES_PER_PIXEL); 7249 # else 7250 writeTGAFile("/tmp/legend.tga", imgData->GetPointer(0), width, height, 7251 TARGA_BYTES_PER_PIXEL, true); 7252 # endif 7253 #else 7254 char cmd[256]; 7255 snprintf(cmd, sizeof(cmd), "nv>legend {%s} {} 0 1", colorMapName); 7256 7257 # ifdef USE_THREADS 7258 # ifdef RENDER_TARGA 7259 ResponseQueue *queue = (ResponseQueue *)clientData; 7260 queueTGA(queue, cmd, imgData->GetPointer(0), width, height, 7261 TARGA_BYTES_PER_PIXEL); 7262 # else 7263 ResponseQueue *queue = (ResponseQueue *)clientData; 7264 queuePPM(queue, cmd, imgData->GetPointer(0), width, height); 7265 # endif 7266 # else 7267 # ifdef RENDER_TARGA 7268 writeTGA(g_fdOut, cmd, imgData->GetPointer(0), width, height, 7269 TARGA_BYTES_PER_PIXEL); 7270 # else 7271 writePPM(g_fdOut, cmd, imgData->GetPointer(0), width, height); 7272 # endif 7273 # endif // USE_THREADS 7274 #endif // DEBUG 7275 return TCL_OK; 7276 } 7277 7278 static int 6788 7279 LICAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 6789 7280 Tcl_Obj *const *objv) … … 7271 7762 {"orient", 4, LineOrientOp, 6, 7, "qw qx qy qz ?name?"}, 7272 7763 {"origin", 4, LineOriginOp, 5, 6, "x y z ?name?"}, 7273 {"pos", 2, LinePositionOp, 5, 6, "x y z ?name?"},7274 {"scale", 2, LineScaleOp, 5, 6, "sx sy sz ?name?"},7764 {"pos", 1, LinePositionOp, 5, 6, "x y z ?name?"}, 7765 {"scale", 1, LineScaleOp, 5, 6, "sx sy sz ?name?"}, 7275 7766 {"visible", 1, LineVisibleOp, 3, 4, "bool ?name?"} 7276 7767 }; … … 7579 8070 if (str[0] == 'b' && strcmp(str, "by_elements") == 0) { 7580 8071 mode = Molecule::COLOR_BY_ELEMENTS; 7581 } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 8072 } else if (str[0] == 'c' && 8073 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 7582 8074 mode = Molecule::COLOR_CONSTANT; 7583 8075 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 7593 8085 } else { 7594 8086 Tcl_AppendResult(interp, "bad color mode option \"", str, 7595 "\": should be one of: 'by_elements', 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);8087 "\": should be one of: 'by_elements', 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 7596 8088 return TCL_ERROR; 7597 8089 } … … 7693 8185 } else { 7694 8186 g_renderer->setGraphicsObjectEdgeWidth<Molecule>("all", width); 8187 } 8188 return TCL_OK; 8189 } 8190 8191 static int 8192 MoleculeMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc, 8193 Tcl_Obj *const *objv) 8194 { 8195 double ambient, diffuse, specCoeff, specPower; 8196 if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK || 8197 Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK || 8198 Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK || 8199 Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) { 8200 return TCL_ERROR; 8201 } 8202 8203 if (objc == 7) { 8204 const char *name = Tcl_GetString(objv[6]); 8205 g_renderer->setGraphicsObjectAmbient<Molecule>(name, ambient); 8206 g_renderer->setGraphicsObjectDiffuse<Molecule>(name, diffuse); 8207 g_renderer->setGraphicsObjectSpecular<Molecule>(name, specCoeff, specPower); 8208 } else { 8209 g_renderer->setGraphicsObjectAmbient<Molecule>("all", ambient); 8210 g_renderer->setGraphicsObjectDiffuse<Molecule>("all", diffuse); 8211 g_renderer->setGraphicsObjectSpecular<Molecule>("all", specCoeff, specPower); 7695 8212 } 7696 8213 return TCL_OK; … … 7818 8335 {"bstyle", 3, MoleculeBondStyleOp, 3, 4, "value ?dataSetName?"}, 7819 8336 {"ccolor", 2, MoleculeColorOp, 5, 6, "r g b ?dataSetName?"}, 8337 {"color", 5, MoleculeColorOp, 5, 6, "r g b ?dataSetName?"}, 7820 8338 {"colormap", 7, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 7821 8339 {"colormode", 7, MoleculeColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 7827 8345 {"linecolor", 5, MoleculeLineColorOp, 5, 6, "r g b ?dataSetName?"}, 7828 8346 {"linewidth", 5, MoleculeLineWidthOp, 3, 4, "width ?dataSetName?"}, 8347 {"material", 1, MoleculeMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"}, 7829 8348 {"opacity", 2, MoleculeOpacityOp, 3, 4, "value ?dataSetName?"}, 7830 8349 {"orient", 2, MoleculeOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, … … 8019 8538 {"opacity", 2, OutlineOpacityOp, 3, 4, "value ?dataSetName?"}, 8020 8539 {"orient", 2, OutlineOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 8021 {"pos", 2, OutlinePositionOp, 5, 6, "x y z ?dataSetName?"},8022 {"scale", 2, OutlineScaleOp, 5, 6, "sx sy sz ?dataSetName?"},8540 {"pos", 1, OutlinePositionOp, 5, 6, "x y z ?dataSetName?"}, 8541 {"scale", 1, OutlineScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 8023 8542 {"visible", 1, OutlineVisibleOp, 3, 4, "bool ?dataSetName?"} 8024 8543 }; … … 8103 8622 8104 8623 static int 8624 PolyDataColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 8625 Tcl_Obj *const *objv) 8626 { 8627 const char *colorMapName = Tcl_GetString(objv[2]); 8628 if (objc == 4) { 8629 const char *dataSetName = Tcl_GetString(objv[3]); 8630 g_renderer->setGraphicsObjectColorMap<PolyData>(dataSetName, colorMapName); 8631 } else { 8632 g_renderer->setGraphicsObjectColorMap<PolyData>("all", colorMapName); 8633 } 8634 return TCL_OK; 8635 } 8636 8637 static int 8638 PolyDataColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 8639 Tcl_Obj *const *objv) 8640 { 8641 PolyData::ColorMode mode; 8642 const char *str = Tcl_GetString(objv[2]); 8643 if (str[0] == 'c' && 8644 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 8645 mode = PolyData::COLOR_CONSTANT; 8646 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { 8647 mode = PolyData::COLOR_BY_SCALAR; 8648 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 8649 mode = PolyData::COLOR_BY_VECTOR_MAGNITUDE; 8650 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 8651 mode = PolyData::COLOR_BY_VECTOR_X; 8652 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 8653 mode = PolyData::COLOR_BY_VECTOR_Y; 8654 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 8655 mode = PolyData::COLOR_BY_VECTOR_Z; 8656 } else { 8657 Tcl_AppendResult(interp, "bad color mode option \"", str, 8658 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 8659 return TCL_ERROR; 8660 } 8661 const char *fieldName = Tcl_GetString(objv[3]); 8662 if (mode == PolyData::COLOR_CONSTANT) { 8663 fieldName = NULL; 8664 } 8665 if (objc == 5) { 8666 const char *name = Tcl_GetString(objv[4]); 8667 g_renderer->setPolyDataColorMode(name, mode, fieldName); 8668 } else { 8669 g_renderer->setPolyDataColorMode("all", mode, fieldName); 8670 } 8671 return TCL_OK; 8672 } 8673 8674 static int 8105 8675 PolyDataCullingOp(ClientData clientData, Tcl_Interp *interp, int objc, 8106 8676 Tcl_Obj *const *objv) … … 8315 8885 } else { 8316 8886 g_renderer->setGraphicsObjectPosition<PolyData>("all", pos); 8887 } 8888 return TCL_OK; 8889 } 8890 8891 static int 8892 PolyDataPreInterpOp(ClientData clientData, Tcl_Interp *interp, int objc, 8893 Tcl_Obj *const *objv) 8894 { 8895 bool state; 8896 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 8897 return TCL_ERROR; 8898 } 8899 if (objc == 4) { 8900 const char *name = Tcl_GetString(objv[3]); 8901 g_renderer->setGraphicsObjectInterpolateBeforeMapping<PolyData>(name, state); 8902 } else { 8903 g_renderer->setGraphicsObjectInterpolateBeforeMapping<PolyData>("all", state); 8317 8904 } 8318 8905 return TCL_OK; … … 8398 8985 static Rappture::CmdSpec polyDataOps[] = { 8399 8986 {"add", 1, PolyDataAddOp, 2, 3, "?dataSetName?"}, 8987 {"ccolor", 2, PolyDataColorOp, 5, 6, "r g b ?dataSetName?"}, 8400 8988 {"cloudstyle",2, PolyDataCloudStyleOp, 3, 4, "style ?dataSetName?"}, 8401 {"color", 2, PolyDataColorOp, 5, 6, "r g b ?dataSetName?"}, 8989 {"color", 5, PolyDataColorOp, 5, 6, "r g b ?dataSetName?"}, 8990 {"colormap", 7, PolyDataColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 8991 {"colormode", 7, PolyDataColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, 8402 8992 {"culling", 2, PolyDataCullingOp, 3, 4, "bool ?name?"}, 8403 8993 {"delete", 1, PolyDataDeleteOp, 2, 3, "?dataSetName?"}, … … 8411 9001 {"origin", 4, PolyDataOriginOp, 5, 6, "x y z ?name?"}, 8412 9002 {"pos", 2, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"}, 9003 {"preinterp", 2, PolyDataPreInterpOp, 3, 4, "bool ?dataSetName?"}, 8413 9004 {"ptsize", 2, PolyDataPointSizeOp, 3, 4, "size ?dataSetName?"}, 8414 9005 {"scale", 2, PolyDataScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, … … 8891 9482 PseudoColor::ColorMode mode; 8892 9483 const char *str = Tcl_GetString(objv[2]); 8893 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 9484 if (str[0] == 'c' && 9485 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 8894 9486 mode = PseudoColor::COLOR_CONSTANT; 8895 9487 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 8905 9497 } else { 8906 9498 Tcl_AppendResult(interp, "bad color mode option \"", str, 8907 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);9499 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 8908 9500 return TCL_ERROR; 8909 9501 } … … 9151 9743 {"ccolor", 2, PseudoColorColorOp, 5, 6, "r g b ?dataSetName?"}, 9152 9744 {"cloudstyle", 2, PseudoColorCloudStyleOp, 3, 4, "style ?dataSetName?"}, 9745 {"color", 5, PseudoColorColorOp, 5, 6, "r g b ?dataSetName?"}, 9153 9746 {"colormap", 7, PseudoColorColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 9154 9747 {"colormode", 7, PseudoColorColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 9811 10404 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 9812 10405 mode = Streamlines::COLOR_BY_VECTOR_Z; 9813 } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 10406 } else if (str[0] == 'c' && 10407 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 9814 10408 mode = Streamlines::COLOR_CONSTANT; 9815 10409 } else { 9816 10410 Tcl_AppendResult(interp, "bad color mode option \"", str, 9817 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);10411 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 9818 10412 return TCL_ERROR; 9819 10413 } … … 10460 11054 static Rappture::CmdSpec streamlinesOps[] = { 10461 11055 {"add", 1, StreamlinesAddOp, 2, 3, "?dataSetName?"}, 10462 {"ccolor", 1, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"}, 11056 {"ccolor", 2, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"}, 11057 {"color", 5, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"}, 10463 11058 {"colormap", 7, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 10464 11059 {"colormode", 7, StreamlinesColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 10497 11092 10498 11093 static int 11094 Text3DAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 11095 Tcl_Obj *const *objv) 11096 { 11097 int fontSize; 11098 const char *fontFamily = Tcl_GetString(objv[2]); 11099 if (Tcl_GetIntFromObj(interp, objv[3], &fontSize) != TCL_OK) { 11100 return TCL_ERROR; 11101 } 11102 const char *text = Tcl_GetString(objv[4]); 11103 const char *name = Tcl_GetString(objv[5]); 11104 if (!g_renderer->addText3D(name, text, fontFamily, fontSize)) { 11105 Tcl_AppendResult(interp, "Failed to create text3d", (char*)NULL); 11106 return TCL_ERROR; 11107 } 11108 return TCL_OK; 11109 } 11110 11111 static int 11112 Text3DBoldOp(ClientData clientData, Tcl_Interp *interp, int objc, 11113 Tcl_Obj *const *objv) 11114 { 11115 bool state; 11116 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 11117 return TCL_ERROR; 11118 } 11119 if (objc == 4) { 11120 const char *name = Tcl_GetString(objv[3]); 11121 g_renderer->setText3DBold(name, state); 11122 } else { 11123 g_renderer->setText3DBold("all", state); 11124 } 11125 return TCL_OK; 11126 } 11127 11128 static int 11129 Text3DColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 11130 Tcl_Obj *const *objv) 11131 { 11132 float color[3]; 11133 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 11134 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 11135 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 11136 return TCL_ERROR; 11137 } 11138 if (objc == 6) { 11139 const char *name = Tcl_GetString(objv[5]); 11140 g_renderer->setGraphicsObjectColor<Text3D>(name, color); 11141 } else { 11142 g_renderer->setGraphicsObjectColor<Text3D>("all", color); 11143 } 11144 return TCL_OK; 11145 } 11146 11147 static int 11148 Text3DDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 11149 Tcl_Obj *const *objv) 11150 { 11151 if (objc == 3) { 11152 const char *name = Tcl_GetString(objv[2]); 11153 g_renderer->deleteGraphicsObject<Text3D>(name); 11154 } else { 11155 g_renderer->deleteGraphicsObject<Text3D>("all"); 11156 } 11157 return TCL_OK; 11158 } 11159 11160 static int 11161 Text3DFollowCameraOp(ClientData clientData, Tcl_Interp *interp, int objc, 11162 Tcl_Obj *const *objv) 11163 { 11164 bool state; 11165 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 11166 return TCL_ERROR; 11167 } 11168 if (objc == 4) { 11169 const char *name = Tcl_GetString(objv[3]); 11170 g_renderer->setText3DFollowCamera(name, state); 11171 } else { 11172 g_renderer->setText3DFollowCamera("all", state); 11173 } 11174 return TCL_OK; 11175 } 11176 11177 static int 11178 Text3DFontFamilyOp(ClientData clientData, Tcl_Interp *interp, int objc, 11179 Tcl_Obj *const *objv) 11180 { 11181 const char *fontFamily = Tcl_GetString(objv[2]); 11182 if (objc == 4) { 11183 const char *name = Tcl_GetString(objv[3]); 11184 g_renderer->setText3DFont(name, fontFamily); 11185 } else { 11186 g_renderer->setText3DFont("all", fontFamily); 11187 } 11188 return TCL_OK; 11189 } 11190 11191 static int 11192 Text3DFontSizeOp(ClientData clientData, Tcl_Interp *interp, int objc, 11193 Tcl_Obj *const *objv) 11194 { 11195 int fontSize; 11196 if (Tcl_GetIntFromObj(interp, objv[2], &fontSize) != TCL_OK) { 11197 return TCL_ERROR; 11198 } 11199 if (objc == 4) { 11200 const char *name = Tcl_GetString(objv[3]); 11201 g_renderer->setText3DFontSize(name, fontSize); 11202 } else { 11203 g_renderer->setText3DFontSize("all", fontSize); 11204 } 11205 return TCL_OK; 11206 } 11207 11208 static int 11209 Text3DItalicOp(ClientData clientData, Tcl_Interp *interp, int objc, 11210 Tcl_Obj *const *objv) 11211 { 11212 bool state; 11213 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 11214 return TCL_ERROR; 11215 } 11216 if (objc == 4) { 11217 const char *name = Tcl_GetString(objv[3]); 11218 g_renderer->setText3DItalic(name, state); 11219 } else { 11220 g_renderer->setText3DItalic("all", state); 11221 } 11222 return TCL_OK; 11223 } 11224 11225 static int 11226 Text3DOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 11227 Tcl_Obj *const *objv) 11228 { 11229 double opacity; 11230 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 11231 return TCL_ERROR; 11232 } 11233 if (objc == 4) { 11234 const char *name = Tcl_GetString(objv[3]); 11235 g_renderer->setGraphicsObjectOpacity<Text3D>(name, opacity); 11236 } else { 11237 g_renderer->setGraphicsObjectOpacity<Text3D>("all", opacity); 11238 } 11239 return TCL_OK; 11240 } 11241 11242 static int 11243 Text3DOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 11244 Tcl_Obj *const *objv) 11245 { 11246 double quat[4]; 11247 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 11248 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 11249 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 11250 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 11251 return TCL_ERROR; 11252 } 11253 if (objc == 7) { 11254 const char *name = Tcl_GetString(objv[6]); 11255 g_renderer->setGraphicsObjectOrientation<Text3D>(name, quat); 11256 } else { 11257 g_renderer->setGraphicsObjectOrientation<Text3D>("all", quat); 11258 } 11259 return TCL_OK; 11260 } 11261 11262 static int 11263 Text3DOriginOp(ClientData clientData, Tcl_Interp *interp, int objc, 11264 Tcl_Obj *const *objv) 11265 { 11266 double origin[3]; 11267 if (Tcl_GetDoubleFromObj(interp, objv[2], &origin[0]) != TCL_OK || 11268 Tcl_GetDoubleFromObj(interp, objv[3], &origin[1]) != TCL_OK || 11269 Tcl_GetDoubleFromObj(interp, objv[4], &origin[2]) != TCL_OK) { 11270 return TCL_ERROR; 11271 } 11272 if (objc == 6) { 11273 const char *name = Tcl_GetString(objv[5]); 11274 g_renderer->setGraphicsObjectOrigin<Text3D>(name, origin); 11275 } else { 11276 g_renderer->setGraphicsObjectOrigin<Text3D>("all", origin); 11277 } 11278 return TCL_OK; 11279 } 11280 11281 static int 11282 Text3DPositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 11283 Tcl_Obj *const *objv) 11284 { 11285 double pos[3]; 11286 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 11287 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 11288 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 11289 return TCL_ERROR; 11290 } 11291 if (objc == 6) { 11292 const char *name = Tcl_GetString(objv[5]); 11293 g_renderer->setGraphicsObjectPosition<Text3D>(name, pos); 11294 } else { 11295 g_renderer->setGraphicsObjectPosition<Text3D>("all", pos); 11296 } 11297 return TCL_OK; 11298 } 11299 11300 static int 11301 Text3DScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 11302 Tcl_Obj *const *objv) 11303 { 11304 double scale[3]; 11305 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 11306 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 11307 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 11308 return TCL_ERROR; 11309 } 11310 if (objc == 6) { 11311 const char *name = Tcl_GetString(objv[5]); 11312 g_renderer->setGraphicsObjectScale<Text3D>(name, scale); 11313 } else { 11314 g_renderer->setGraphicsObjectScale<Text3D>("all", scale); 11315 } 11316 return TCL_OK; 11317 } 11318 11319 static int 11320 Text3DShadowOp(ClientData clientData, Tcl_Interp *interp, int objc, 11321 Tcl_Obj *const *objv) 11322 { 11323 bool state; 11324 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 11325 return TCL_ERROR; 11326 } 11327 if (objc == 4) { 11328 const char *name = Tcl_GetString(objv[3]); 11329 g_renderer->setText3DShadow(name, state); 11330 } else { 11331 g_renderer->setText3DShadow("all", state); 11332 } 11333 return TCL_OK; 11334 } 11335 11336 static int 11337 Text3DTextOp(ClientData clientData, Tcl_Interp *interp, int objc, 11338 Tcl_Obj *const *objv) 11339 { 11340 char *str = Tcl_GetString(objv[2]); 11341 if (objc == 4) { 11342 const char *name = Tcl_GetString(objv[3]); 11343 g_renderer->setText3DText(name, str); 11344 } else { 11345 g_renderer->setText3DText("all", str); 11346 } 11347 return TCL_OK; 11348 } 11349 11350 static int 11351 Text3DVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 11352 Tcl_Obj *const *objv) 11353 { 11354 bool state; 11355 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 11356 return TCL_ERROR; 11357 } 11358 if (objc == 4) { 11359 const char *name = Tcl_GetString(objv[3]); 11360 g_renderer->setGraphicsObjectVisibility<Text3D>(name, state); 11361 } else { 11362 g_renderer->setGraphicsObjectVisibility<Text3D>("all", state); 11363 } 11364 return TCL_OK; 11365 } 11366 11367 static Rappture::CmdSpec text3DOps[] = { 11368 {"add", 1, Text3DAddOp, 6, 6, "font size text name"}, 11369 {"bold", 1, Text3DBoldOp, 3, 4, "bool ?name?"}, 11370 {"color", 1, Text3DColorOp, 5, 6, "r g b ?name?"}, 11371 {"delete", 1, Text3DDeleteOp, 2, 3, "?name?"}, 11372 {"fntfamily", 4, Text3DFontFamilyOp, 3, 4, "font ?name?"}, 11373 {"fntsize", 4, Text3DFontSizeOp, 3, 4, "size ?name?"}, 11374 {"followcam", 2, Text3DFollowCameraOp, 3, 4, "bool ?name?"}, 11375 {"italic", 1, Text3DItalicOp, 3, 4, "bool ?name?"}, 11376 {"opacity", 2, Text3DOpacityOp, 3, 4, "value ?name?"}, 11377 {"orient", 4, Text3DOrientOp, 6, 7, "qw qx qy qz ?name?"}, 11378 {"origin", 4, Text3DOriginOp, 5, 6, "x y z ?name?"}, 11379 {"pos", 1, Text3DPositionOp, 5, 6, "x y z ?name?"}, 11380 {"scale", 1, Text3DScaleOp, 5, 6, "sx sy sz ?name?"}, 11381 {"shadow", 1, Text3DShadowOp, 3, 4, "bool ?name?"}, 11382 {"text", 1, Text3DTextOp, 3, 4, "text ?name?"}, 11383 {"visible", 1, Text3DVisibleOp, 3, 4, "bool ?name?"}, 11384 }; 11385 static int nText3DOps = NumCmdSpecs(text3DOps); 11386 11387 static int 11388 Text3DCmd(ClientData clientData, Tcl_Interp *interp, int objc, 11389 Tcl_Obj *const *objv) 11390 { 11391 Tcl_ObjCmdProc *proc; 11392 11393 proc = Rappture::GetOpFromObj(interp, nText3DOps, text3DOps, 11394 Rappture::CMDSPEC_ARG1, objc, objv, 0); 11395 if (proc == NULL) { 11396 return TCL_ERROR; 11397 } 11398 return (*proc) (clientData, interp, objc, objv); 11399 } 11400 11401 static int 10499 11402 VolumeAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 10500 11403 Tcl_Obj *const *objv) … … 10869 11772 Warp::ColorMode mode; 10870 11773 const char *str = Tcl_GetString(objv[2]); 10871 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 11774 if (str[0] == 'c' && 11775 (strcmp(str, "ccolor") == 0 || strcmp(str, "constant") == 0)) { 10872 11776 mode = Warp::COLOR_CONSTANT; 10873 11777 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 10883 11787 } else { 10884 11788 Tcl_AppendResult(interp, "bad color mode option \"", str, 10885 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor' ", (char*)NULL);11789 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor', 'constant'", (char*)NULL); 10886 11790 return TCL_ERROR; 10887 11791 } … … 11146 12050 {"ccolor", 2, WarpColorOp, 5, 6, "r g b ?dataSetName?"}, 11147 12051 {"cloudstyle", 2, WarpCloudStyleOp, 3, 4, "style ?dataSetName?"}, 12052 {"color", 5, WarpColorOp, 5, 6, "r g b ?dataSetName?"}, 11148 12053 {"colormap", 7, WarpColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 11149 12054 {"colormode", 7, WarpColorModeOp, 4, 5, "mode fieldName ?dataSetName?"}, … … 11158 12063 {"preinterp", 2, WarpPreInterpOp, 3, 4, "bool ?dataSetName?"}, 11159 12064 {"ptsize", 2, WarpPointSizeOp, 3, 4, "size ?dataSetName?"}, 11160 {"scale", 2, WarpScaleOp, 5, 6, "sx sy sz ?dataSetName?"},12065 {"scale", 1, WarpScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 11161 12066 {"visible", 1, WarpVisibleOp, 3, 4, "bool ?dataSetName?"}, 11162 12067 {"warpscale", 2, WarpWarpScaleOp, 3, 4, "value ?dataSetName?"}, … … 11340 12245 Tcl_CreateObjCommand(interp, "group", GroupCmd, clientData, NULL); 11341 12246 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, clientData, NULL); 12247 Tcl_CreateObjCommand(interp, "image", ImageCmd, clientData, NULL); 11342 12248 Tcl_CreateObjCommand(interp, "imgflush", ImageFlushCmd, clientData, NULL); 11343 12249 Tcl_CreateObjCommand(interp, "legend", LegendCmd, clientData, NULL); 12250 Tcl_CreateObjCommand(interp, "legend2", LegendSimpleCmd,clientData, NULL); 11344 12251 Tcl_CreateObjCommand(interp, "lic", LICCmd, clientData, NULL); 11345 12252 Tcl_CreateObjCommand(interp, "line", LineCmd, clientData, NULL); … … 11353 12260 Tcl_CreateObjCommand(interp, "sphere", SphereCmd, clientData, NULL); 11354 12261 Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL); 12262 Tcl_CreateObjCommand(interp, "text3d", Text3DCmd, clientData, NULL); 11355 12263 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, clientData, NULL); 11356 12264 Tcl_CreateObjCommand(interp, "warp", WarpCmd, clientData, NULL); … … 11379 12287 Tcl_DeleteCommand(interp, "group"); 11380 12288 Tcl_DeleteCommand(interp, "heightmap"); 12289 Tcl_DeleteCommand(interp, "image"); 11381 12290 Tcl_DeleteCommand(interp, "imgflush"); 11382 12291 Tcl_DeleteCommand(interp, "legend"); 12292 Tcl_DeleteCommand(interp, "legend2"); 11383 12293 Tcl_DeleteCommand(interp, "lic"); 11384 12294 Tcl_DeleteCommand(interp, "line"); … … 11392 12302 Tcl_DeleteCommand(interp, "sphere"); 11393 12303 Tcl_DeleteCommand(interp, "streamlines"); 12304 Tcl_DeleteCommand(interp, "text3d"); 11394 12305 Tcl_DeleteCommand(interp, "volume"); 11395 12306 Tcl_DeleteCommand(interp, "warp"); -
branches/1.3/packages/vizservers/vtkvis/RendererGraphicsObjs.cpp
r3696 r3844 100 100 101 101 template<> 102 Renderer::ImageHashmap & 103 Renderer::getGraphicsObjectHashmap<Image>() 104 { return _images; } 105 106 template<> 102 107 Renderer::LICHashmap & 103 108 Renderer::getGraphicsObjectHashmap<LIC>() … … 145 150 146 151 template<> 152 Renderer::Text3DHashmap & 153 Renderer::getGraphicsObjectHashmap<Text3D>() 154 { return _text3Ds; } 155 156 template<> 147 157 Renderer::VolumeHashmap & 148 158 Renderer::getGraphicsObjectHashmap<Volume>() … … 154 164 { return _warps; } 155 165 166 #if 0 156 167 template Arc *Renderer::getGraphicsObject(const DataSetId&); 157 168 template Arrow *Renderer::getGraphicsObject(const DataSetId&); … … 164 175 template Polygon *Renderer::getGraphicsObject(const DataSetId&); 165 176 template Sphere *Renderer::getGraphicsObject(const DataSetId&); 177 template Text3D *Renderer::getGraphicsObject(const DataSetId&); 178 #endif 166 179 167 180 template <> … … 214 227 } 215 228 216 template <>217 bool Renderer::addGraphicsObject<Box>(const DataSetId& id)218 {219 Box *gobj;220 if ((gobj = getGraphicsObject<Box>(id)) != NULL) {221 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());222 deleteGraphicsObject<Box>(id);223 }224 225 gobj = new Box();226 227 gobj->setDataSet(NULL, this);228 229 if (gobj->getProp() == NULL &&230 gobj->getOverlayProp() == NULL) {231 delete gobj;232 return false;233 } else {234 if (gobj->getProp())235 _renderer->AddViewProp(gobj->getProp());236 if (gobj->getOverlayProp())237 _renderer->AddViewProp(gobj->getOverlayProp());238 }239 240 getGraphicsObjectHashmap<Box>()[id] = gobj;241 242 sceneBoundsChanged();243 _needsRedraw = true;244 return true;245 }246 247 template <>248 bool Renderer::addGraphicsObject<Sphere>(const DataSetId& id)249 {250 Sphere *gobj;251 if ((gobj = getGraphicsObject<Sphere>(id)) != NULL) {252 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());253 deleteGraphicsObject<Sphere>(id);254 }255 256 gobj = new Sphere();257 258 gobj->setDataSet(NULL, this);259 260 if (gobj->getProp() == NULL &&261 gobj->getOverlayProp() == NULL) {262 delete gobj;263 return false;264 } else {265 if (gobj->getProp())266 _renderer->AddViewProp(gobj->getProp());267 if (gobj->getOverlayProp())268 _renderer->AddViewProp(gobj->getOverlayProp());269 }270 271 getGraphicsObjectHashmap<Sphere>()[id] = gobj;272 273 sceneBoundsChanged();274 _needsRedraw = true;275 return true;276 }277 278 229 /** 279 230 * \brief Set the volume slice used for mapping volumetric data … … 342 293 } 343 294 if ((gobj = getGraphicsObject<Sphere>(id)) != NULL) { 295 return gobj; 296 } 297 if ((gobj = getGraphicsObject<Text3D>(id)) != NULL) { 344 298 return gobj; 345 299 } … … 358 312 } 359 313 if ((gobj = getGraphicsObject<HeightMap>(id)) != NULL) { 314 return gobj; 315 } 316 if ((gobj = getGraphicsObject<Image>(id)) != NULL) { 360 317 return gobj; 361 318 } … … 1554 1511 do { 1555 1512 itr->second->setScalingMode(mode, name, range); 1513 } while (doAll && ++itr != _glyphs.end()); 1514 1515 sceneBoundsChanged(); 1516 _needsRedraw = true; 1517 } 1518 1519 /** 1520 * \brief Limit the number of glyphs displayed 1521 * 1522 * The choice of glyphs to display can be based on sampling every 1523 * n-th point (ratio) or by random sample 1524 * 1525 * \param max Maximum number of glyphs to display, negative means display all 1526 * \param random Flag to enable/disable random sampling 1527 * \param offset If random is false, this controls the first sample point 1528 * \param ratio If random is false, this ratio controls every n-th point sampling 1529 */ 1530 void Renderer::setGlyphsMaximumNumberOfGlyphs(const DataSetId& id, int max, 1531 bool random, int offset, int ratio) 1532 { 1533 GlyphsHashmap::iterator itr; 1534 1535 bool doAll = false; 1536 1537 if (id.compare("all") == 0) { 1538 itr = _glyphs.begin(); 1539 if (itr == _glyphs.end()) 1540 return; 1541 doAll = true; 1542 } else { 1543 itr = _glyphs.find(id); 1544 } 1545 if (itr == _glyphs.end()) { 1546 ERROR("Glyphs not found: %s", id.c_str()); 1547 return; 1548 } 1549 1550 do { 1551 itr->second->setMaximumNumberOfGlyphs(max, random, offset, ratio); 1556 1552 } while (doAll && ++itr != _glyphs.end()); 1557 1553 … … 2269 2265 } 2270 2266 2267 void Renderer::setImageBackground(const DataSetId& id, bool state) 2268 { 2269 ImageHashmap::iterator itr; 2270 2271 bool doAll = false; 2272 2273 if (id.compare("all") == 0) { 2274 itr = _images.begin(); 2275 if (itr == _images.end()) 2276 return; 2277 doAll = true; 2278 } else { 2279 itr = _images.find(id); 2280 } 2281 if (itr == _images.end()) { 2282 ERROR("Image not found: %s", id.c_str()); 2283 return; 2284 } 2285 2286 do { 2287 itr->second->setBackground(state); 2288 } while (doAll && ++itr != _images.end()); 2289 2290 _needsRedraw = true; 2291 } 2292 2293 void Renderer::setImageBacking(const DataSetId& id, bool state) 2294 { 2295 ImageHashmap::iterator itr; 2296 2297 bool doAll = false; 2298 2299 if (id.compare("all") == 0) { 2300 itr = _images.begin(); 2301 if (itr == _images.end()) 2302 return; 2303 doAll = true; 2304 } else { 2305 itr = _images.find(id); 2306 } 2307 if (itr == _images.end()) { 2308 ERROR("Image not found: %s", id.c_str()); 2309 return; 2310 } 2311 2312 do { 2313 itr->second->setBacking(state); 2314 } while (doAll && ++itr != _images.end()); 2315 2316 _needsRedraw = true; 2317 } 2318 2319 void Renderer::setImageBorder(const DataSetId& id, bool state) 2320 { 2321 ImageHashmap::iterator itr; 2322 2323 bool doAll = false; 2324 2325 if (id.compare("all") == 0) { 2326 itr = _images.begin(); 2327 if (itr == _images.end()) 2328 return; 2329 doAll = true; 2330 } else { 2331 itr = _images.find(id); 2332 } 2333 if (itr == _images.end()) { 2334 ERROR("Image not found: %s", id.c_str()); 2335 return; 2336 } 2337 2338 do { 2339 itr->second->setBorder(state); 2340 } while (doAll && ++itr != _images.end()); 2341 2342 _needsRedraw = true; 2343 } 2344 2345 void Renderer::setImageExtents(const DataSetId& id, int extents[6]) 2346 { 2347 ImageHashmap::iterator itr; 2348 2349 bool doAll = false; 2350 2351 if (id.compare("all") == 0) { 2352 itr = _images.begin(); 2353 if (itr == _images.end()) 2354 return; 2355 doAll = true; 2356 } else { 2357 itr = _images.find(id); 2358 } 2359 if (itr == _images.end()) { 2360 ERROR("Image not found: %s", id.c_str()); 2361 return; 2362 } 2363 2364 do { 2365 itr->second->setExtents(extents); 2366 } while (doAll && ++itr != _images.end()); 2367 2368 _needsRedraw = true; 2369 } 2370 2371 void Renderer::setImageLevel(const DataSetId& id, double level) 2372 { 2373 ImageHashmap::iterator itr; 2374 2375 bool doAll = false; 2376 2377 if (id.compare("all") == 0) { 2378 itr = _images.begin(); 2379 if (itr == _images.end()) 2380 return; 2381 doAll = true; 2382 } else { 2383 itr = _images.find(id); 2384 } 2385 if (itr == _images.end()) { 2386 ERROR("Image not found: %s", id.c_str()); 2387 return; 2388 } 2389 2390 do { 2391 itr->second->setLevel(level); 2392 } while (doAll && ++itr != _images.end()); 2393 2394 _needsRedraw = true; 2395 } 2396 2397 void Renderer::setImageWindow(const DataSetId& id, double window) 2398 { 2399 ImageHashmap::iterator itr; 2400 2401 bool doAll = false; 2402 2403 if (id.compare("all") == 0) { 2404 itr = _images.begin(); 2405 if (itr == _images.end()) 2406 return; 2407 doAll = true; 2408 } else { 2409 itr = _images.find(id); 2410 } 2411 if (itr == _images.end()) { 2412 ERROR("Image not found: %s", id.c_str()); 2413 return; 2414 } 2415 2416 do { 2417 itr->second->setWindow(window); 2418 } while (doAll && ++itr != _images.end()); 2419 2420 _needsRedraw = true; 2421 } 2422 2423 void Renderer::setImageZSlice(const DataSetId& id, int z) 2424 { 2425 ImageHashmap::iterator itr; 2426 2427 bool doAll = false; 2428 2429 if (id.compare("all") == 0) { 2430 itr = _images.begin(); 2431 if (itr == _images.end()) 2432 return; 2433 doAll = true; 2434 } else { 2435 itr = _images.find(id); 2436 } 2437 if (itr == _images.end()) { 2438 ERROR("Image not found: %s", id.c_str()); 2439 return; 2440 } 2441 2442 do { 2443 itr->second->setZSlice(z); 2444 } while (doAll && ++itr != _images.end()); 2445 2446 _needsRedraw = true; 2447 } 2448 2271 2449 /** 2272 2450 * \brief Create a new Line and associate it with an ID … … 2829 3007 2830 3008 /** 3009 * \brief Set the color mode for the specified DataSet 3010 */ 3011 void Renderer::setPolyDataColorMode(const DataSetId& id, 3012 PolyData::ColorMode mode, 3013 DataSet::DataAttributeType type, 3014 const char *name, double range[2]) 3015 { 3016 PolyDataHashmap::iterator itr; 3017 3018 bool doAll = false; 3019 3020 if (id.compare("all") == 0) { 3021 itr = _polyDatas.begin(); 3022 if (itr == _polyDatas.end()) 3023 return; 3024 doAll = true; 3025 } else { 3026 itr = _polyDatas.find(id); 3027 } 3028 if (itr == _polyDatas.end()) { 3029 ERROR("PolyData not found: %s", id.c_str()); 3030 return; 3031 } 3032 3033 do { 3034 itr->second->setColorMode(mode, type, name, range); 3035 } while (doAll && ++itr != _polyDatas.end()); 3036 3037 _needsRedraw = true; 3038 } 3039 3040 /** 3041 * \brief Set the color mode for the specified DataSet 3042 */ 3043 void Renderer::setPolyDataColorMode(const DataSetId& id, 3044 PolyData::ColorMode mode, 3045 const char *name, double range[2]) 3046 { 3047 PolyDataHashmap::iterator itr; 3048 3049 bool doAll = false; 3050 3051 if (id.compare("all") == 0) { 3052 itr = _polyDatas.begin(); 3053 if (itr == _polyDatas.end()) 3054 return; 3055 doAll = true; 3056 } else { 3057 itr = _polyDatas.find(id); 3058 } 3059 if (itr == _polyDatas.end()) { 3060 ERROR("PolyData not found: %s", id.c_str()); 3061 return; 3062 } 3063 3064 do { 3065 itr->second->setColorMode(mode, name, range); 3066 } while (doAll && ++itr != _polyDatas.end()); 3067 3068 _needsRedraw = true; 3069 } 3070 3071 /** 2831 3072 * \brief Set the point cloud render style for the specified DataSet 2832 3073 */ … … 2953 3194 2954 3195 getGraphicsObjectHashmap<Sphere>()[id] = gobj; 3196 3197 sceneBoundsChanged(); 3198 _needsRedraw = true; 3199 return true; 3200 } 3201 3202 /** 3203 * \brief Create a new Text3D label and associate it with an ID 3204 */ 3205 bool Renderer::addText3D(const DataSetId& id, const char *string, 3206 const char *fontFamily, int fontSize, 3207 bool bold, bool italic, bool shadow) 3208 { 3209 Text3D *gobj; 3210 if ((gobj = getGraphicsObject<Text3D>(id)) != NULL) { 3211 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 3212 deleteGraphicsObject<Text3D>(id); 3213 } 3214 3215 gobj = new Text3D(); 3216 3217 gobj->setDataSet(NULL, this); 3218 3219 gobj->setText(string); 3220 gobj->setFont(fontFamily); 3221 gobj->setFontSize(fontSize); 3222 gobj->setBold(bold); 3223 gobj->setItalic(italic); 3224 gobj->setShadow(shadow); 3225 3226 if (gobj->getProp() == NULL && 3227 gobj->getOverlayProp() == NULL) { 3228 delete gobj; 3229 return false; 3230 } else { 3231 if (gobj->getProp()) 3232 _renderer->AddViewProp(gobj->getProp()); 3233 if (gobj->getOverlayProp()) 3234 _renderer->AddViewProp(gobj->getOverlayProp()); 3235 } 3236 3237 getGraphicsObjectHashmap<Text3D>()[id] = gobj; 2955 3238 2956 3239 sceneBoundsChanged(); … … 3655 3938 } 3656 3939 3940 void Renderer::setText3DBold(const DataSetId& id, bool state) 3941 { 3942 Text3DHashmap::iterator itr; 3943 3944 bool doAll = false; 3945 3946 if (id.compare("all") == 0) { 3947 itr = _text3Ds.begin(); 3948 if (itr == _text3Ds.end()) 3949 return; 3950 doAll = true; 3951 } else { 3952 itr = _text3Ds.find(id); 3953 } 3954 if (itr == _text3Ds.end()) { 3955 ERROR("Text3D not found: %s", id.c_str()); 3956 return; 3957 } 3958 3959 do { 3960 itr->second->setBold(state); 3961 } while (doAll && ++itr != _text3Ds.end()); 3962 3963 sceneBoundsChanged(); 3964 _needsRedraw = true; 3965 } 3966 3967 /** 3968 * \brief Set the font family for the Text3D 3969 */ 3970 void Renderer::setText3DFont(const DataSetId& id, const char *fontFamily) 3971 { 3972 Text3DHashmap::iterator itr; 3973 3974 bool doAll = false; 3975 3976 if (id.compare("all") == 0) { 3977 itr = _text3Ds.begin(); 3978 if (itr == _text3Ds.end()) 3979 return; 3980 doAll = true; 3981 } else { 3982 itr = _text3Ds.find(id); 3983 } 3984 if (itr == _text3Ds.end()) { 3985 ERROR("Text3D not found: %s", id.c_str()); 3986 return; 3987 } 3988 3989 do { 3990 itr->second->setFont(fontFamily); 3991 } while (doAll && ++itr != _text3Ds.end()); 3992 3993 sceneBoundsChanged(); 3994 _needsRedraw = true; 3995 } 3996 3997 /** 3998 * \brief Set the font family for the Text3D 3999 */ 4000 void Renderer::setText3DFontSize(const DataSetId& id, int size) 4001 { 4002 Text3DHashmap::iterator itr; 4003 4004 bool doAll = false; 4005 4006 if (id.compare("all") == 0) { 4007 itr = _text3Ds.begin(); 4008 if (itr == _text3Ds.end()) 4009 return; 4010 doAll = true; 4011 } else { 4012 itr = _text3Ds.find(id); 4013 } 4014 if (itr == _text3Ds.end()) { 4015 ERROR("Text3D not found: %s", id.c_str()); 4016 return; 4017 } 4018 4019 do { 4020 itr->second->setFontSize(size); 4021 } while (doAll && ++itr != _text3Ds.end()); 4022 4023 sceneBoundsChanged(); 4024 _needsRedraw = true; 4025 } 4026 4027 void Renderer::setText3DFollowCamera(const DataSetId& id, bool state) 4028 { 4029 Text3DHashmap::iterator itr; 4030 4031 bool doAll = false; 4032 4033 if (id.compare("all") == 0) { 4034 itr = _text3Ds.begin(); 4035 if (itr == _text3Ds.end()) 4036 return; 4037 doAll = true; 4038 } else { 4039 itr = _text3Ds.find(id); 4040 } 4041 if (itr == _text3Ds.end()) { 4042 ERROR("Text3D not found: %s", id.c_str()); 4043 return; 4044 } 4045 4046 do { 4047 itr->second->setFollowCamera(state, _renderer); 4048 } while (doAll && ++itr != _text3Ds.end()); 4049 4050 sceneBoundsChanged(); 4051 _needsRedraw = true; 4052 } 4053 4054 void Renderer::setText3DItalic(const DataSetId& id, bool state) 4055 { 4056 Text3DHashmap::iterator itr; 4057 4058 bool doAll = false; 4059 4060 if (id.compare("all") == 0) { 4061 itr = _text3Ds.begin(); 4062 if (itr == _text3Ds.end()) 4063 return; 4064 doAll = true; 4065 } else { 4066 itr = _text3Ds.find(id); 4067 } 4068 if (itr == _text3Ds.end()) { 4069 ERROR("Text3D not found: %s", id.c_str()); 4070 return; 4071 } 4072 4073 do { 4074 itr->second->setItalic(state); 4075 } while (doAll && ++itr != _text3Ds.end()); 4076 4077 sceneBoundsChanged(); 4078 _needsRedraw = true; 4079 } 4080 4081 void Renderer::setText3DShadow(const DataSetId& id, bool state) 4082 { 4083 Text3DHashmap::iterator itr; 4084 4085 bool doAll = false; 4086 4087 if (id.compare("all") == 0) { 4088 itr = _text3Ds.begin(); 4089 if (itr == _text3Ds.end()) 4090 return; 4091 doAll = true; 4092 } else { 4093 itr = _text3Ds.find(id); 4094 } 4095 if (itr == _text3Ds.end()) { 4096 ERROR("Text3D not found: %s", id.c_str()); 4097 return; 4098 } 4099 4100 do { 4101 itr->second->setShadow(state); 4102 } while (doAll && ++itr != _text3Ds.end()); 4103 4104 sceneBoundsChanged(); 4105 _needsRedraw = true; 4106 } 4107 4108 void Renderer::setText3DText(const DataSetId& id, const char *text) 4109 { 4110 Text3DHashmap::iterator itr; 4111 4112 bool doAll = false; 4113 4114 if (id.compare("all") == 0) { 4115 itr = _text3Ds.begin(); 4116 if (itr == _text3Ds.end()) 4117 return; 4118 doAll = true; 4119 } else { 4120 itr = _text3Ds.find(id); 4121 } 4122 if (itr == _text3Ds.end()) { 4123 ERROR("Text3D not found: %s", id.c_str()); 4124 return; 4125 } 4126 4127 do { 4128 itr->second->setText(text); 4129 } while (doAll && ++itr != _text3Ds.end()); 4130 4131 sceneBoundsChanged(); 4132 _needsRedraw = true; 4133 } 4134 3657 4135 /** 3658 4136 * \brief Set the sample rate for the volume shader -
branches/1.3/packages/vizservers/vtkvis/RendererGraphicsObjs.h
r3683 r3844 1034 1034 1035 1035 ColorMap *cmap = getColorMap(colorMapId); 1036 if (cmap == NULL ) {1036 if (cmap == NULL && colorMapId.compare("none") != 0) { 1037 1037 ERROR("Unknown colormap: %s", colorMapId.c_str()); 1038 1038 return; -
branches/1.3/packages/vizservers/vtkvis/Volume.cpp
r3680 r3844 83 83 double spacing[3]; 84 84 getSpacing(spacing); 85 TRACE("Spacing: %g %g %g", spacing[0], spacing[1], spacing[2]); 85 86 return (spacing[0] + spacing[1] + spacing[2]) * 0.333; 86 87 } … … 120 121 #endif 121 122 vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite(); 123 } else if (_dataSet->isCloud()) { 124 // DataSet is a 3D point cloud 125 vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New(); 126 #ifdef USE_VTK6 127 splatter->SetInputData(ds); 128 #else 129 splatter->SetInput(ds); 130 #endif 131 int dims[3]; 132 dims[0] = dims[1] = dims[2] = 64; 133 TRACE("Generating volume with dims (%d,%d,%d) from point cloud", 134 dims[0], dims[1], dims[2]); 135 splatter->SetSampleDimensions(dims); 136 splatter->Update(); 137 TRACE("Done generating volume"); 138 #ifdef USE_GPU_RAYCAST_MAPPER 139 _volumeMapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New(); 140 vtkGPUVolumeRayCastMapper::SafeDownCast(_volumeMapper)->AutoAdjustSampleDistancesOff(); 141 #else 142 _volumeMapper = vtkSmartPointer<vtkVolumeTextureMapper3D>::New(); 143 #endif 144 _volumeMapper->SetInputConnection(splatter->GetOutputPort()); 145 vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite(); 122 146 } else if (vtkUnstructuredGrid::SafeDownCast(ds) != NULL) { 147 // Unstructured grid with cells (not a cloud) 123 148 vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast(ds); 124 149 // DataSet is unstructured grid … … 144 169 #endif 145 170 filter->TetrahedraOnlyOn(); 171 TRACE("Decomposing grid to tets"); 172 filter->Update(); 173 TRACE("Decomposing done"); 146 174 _volumeMapper->SetInputConnection(filter->GetOutputPort()); 147 175 } … … 149 177 vtkUnstructuredGridVolumeMapper::SafeDownCast(_volumeMapper)-> 150 178 SetBlendModeToComposite(); 151 } else if (_dataSet->isCloud()) {152 // DataSet is a 3D point cloud153 vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New();154 #ifdef USE_VTK6155 splatter->SetInputData(ds);156 #else157 splatter->SetInput(ds);158 #endif159 int dims[3];160 dims[0] = dims[1] = dims[2] = 64;161 TRACE("Generating volume with dims (%d,%d,%d) from point cloud",162 dims[0], dims[1], dims[2]);163 splatter->SetSampleDimensions(dims);164 #ifdef USE_GPU_RAYCAST_MAPPER165 _volumeMapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();166 vtkGPUVolumeRayCastMapper::SafeDownCast(_volumeMapper)->AutoAdjustSampleDistancesOff();167 #else168 _volumeMapper = vtkSmartPointer<vtkVolumeTextureMapper3D>::New();169 #endif170 _volumeMapper->SetInputConnection(splatter->GetOutputPort());171 vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite();172 179 } else { 173 180 ERROR("Unsupported DataSet type: %s", _dataSet->getVtkType()); -
branches/1.3/packages/vizservers/vtkvis/protocol.txt
r3696 r3844 342 342 contour2d add contourlist <list> <?datasetName?> 343 343 list = {isoval1 isoval2 isoval3...} 344 contour2d c color <r> <g> <b> <?datasetName?>344 contour2d color <r> <g> <b> <?datasetName?> 345 345 synonym for linecolor 346 346 contour2d colormap <colormapName> <?datasetName?> 347 contour2d colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>348 Set the field used to color the object. 'c color' means to use349 the constant color defined by the c color subcommand. 'scalar' uses347 contour2d colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 348 Set the field used to color the object. 'constant' means to use 349 the constant color defined by the color subcommand. 'scalar' uses 350 350 the active scalar field. 'vmag' uses the magnitude of the current 351 351 vector field, and 'vx','vy','vz' use the corresponding component of … … 369 369 contour3d add contourlist <list> <?datasetName?> 370 370 list = {isoval1 isoval2 isoval3...} 371 contour3d c color r g b <?datasetName?>371 contour3d color r g b <?datasetName?> 372 372 contour3d colormap <colorMapName> <?dataSetName?> 373 contour3d colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>374 Set the field used to color the object. 'c color' means to use375 the constant color defined by the c color subcommand. 'scalar' uses373 contour3d colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 374 Set the field used to color the object. 'constant' means to use 375 the constant color defined by the color subcommand. 'scalar' uses 376 376 the active scalar field. 'vmag' uses the magnitude of the current 377 377 vector field, and 'vx','vy','vz' use the corresponding component of … … 394 394 cutplane axis <axis> <bool> <?dataSetName?> 395 395 Toggle visibility of the 3 principal axis cutplanes 396 cutplane c color r g b <?datasetName?>396 cutplane color r g b <?datasetName?> 397 397 Set color of outline bounding box 398 398 cutplane cloudstyle <style> <?datasetName?> … … 471 471 glyphs add <shape> <?dataSetName?> 472 472 See 'glyphs shape' for list of shapes 473 glyphs c color r g b <?datasetName?>473 glyphs color r g b <?datasetName?> 474 474 glyphs colormap <colorMapName> <?dataSetName?> 475 glyphs colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?dataSetName?>475 glyphs colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?dataSetName?> 476 476 Set the color mode: color by scalar field or 477 477 vector magnitude -- uses the current color map, 478 or c color for constant color478 or color for constant color 479 479 glyphs delete <?dataSetName?> 480 480 glyphs edges <bool> <?datasetName?> … … 490 490 Control if data values are normalized to [0,1] range before applying 491 491 glyph scaling factor (gscale) 492 glyphs numglyphs <max> <random> <offset> <ratio> <?dataSetName?> 493 Limit the maximum number of glyphs displayed. Can use either a random 494 sampling or every nth point sampling (useful for uniform grids) 495 <max> = integer maximum number of glyphs 496 <random> = bool indicating if random sampling should be used 497 <offset> = offset point index from which to start sampling 498 <ratio> = If random is false, use this to control every nth point sampling 492 499 glyphs opacity <val> <?datasetName?> 493 500 glyphs orient <qw> <qx> <qy> <qz> <?dataSetName?> … … 505 512 506 513 group add <nodeList> <name> 514 Add listed nodes to group named <name>. Group will be created if 515 it doesn't exist, but nodes may be added to existing groups. The 516 nodes will be removed from the virtual root scene. 507 517 group delete <?name?> 508 518 group orient <qw> <qx> <qy> <qz> <?name?> … … 510 520 group pos <x> <y> <z> <?name?> 511 521 group remove <nodeList> <name> 522 Remove listed nodes from group. Currently, nodes will be added back 523 to the virtual root scene, and so nodes must be explicitly deleted to 524 remove them from the scene. 512 525 group scale <sx> <sy> <sz> <?name?> 513 526 group visible <bool> <?name?> … … 524 537 <style> = mesh | splat 525 538 heightmap colormap <colorMapName> <?dataSetName?> 526 heightmap colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>527 Set the field used to color the object. 'c color' means to use528 the constant color defined by the c color subcommand. 'scalar' uses539 heightmap colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 540 Set the field used to color the object. 'constant' means to use 541 the constant color defined by the color subcommand. 'scalar' uses 529 542 the active scalar field. 'vmag' uses the magnitude of the current 530 543 vector field, and 'vx','vy','vz' use the corresponding component of … … 560 573 heightmap wireframe <bool> <?datasetName?> 561 574 575 image add <?dataSetName?> 576 Create an image from a vtkImageData data set 577 image backing <bool> <?dataSetName?> 578 image bg <bool> <?dataSetName?> 579 image border <bool> <?dataSetName?> 580 image color <r> <g> <b> <?dataSetName?> 581 image colormap <colorMapName> <?dataSetName?> 582 image delete <?dataSetName?> 583 image extents <xmin> <xmax> <ymin> <ymax> <zmin> <zmax> <?dataSetName?> 584 image level <level> <?dataSetName?> 585 image opacity <opacity> <?dataSetName?> 586 image orient <qw> <qx> <qy> <qz> <?dataSetName?> 587 image pos <x> <y> <z> <?dataSetName?> 588 image scale <sx> <sy> <sz> <?dataSetName?> 589 image visible <bool> <?dataSetName?> 590 image window <windowWidth> <?dataSetName?> 591 image zslice <sliceNum> <?dataSetName?> 592 562 593 lic add <?datasetName?> 563 594 lic colormap <colormapName> <?datasetName?> … … 615 646 molecule bstyle <cylinder|line> <?datasetName?> 616 647 Set bond render style 617 molecule c color r g b <?datasetName?>648 molecule color r g b <?datasetName?> 618 649 molecule colormap <colormapName> <?datasetName?> 619 molecule colormode <by_elements|scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>620 Set the field used to color the object. 'c color' means to use621 the constant color defined by the c color subcommand. 'scalar' uses650 molecule colormode <by_elements|scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 651 Set the field used to color the object. 'constant' means to use 652 the constant color defined by the color subcommand. 'scalar' uses 622 653 the active scalar field. 'vmag' uses the magnitude of the current 623 654 vector field, and 'vx','vy','vz' use the corresponding component of … … 632 663 molecule linecolor <r> <g> <b> <?datasetName?> 633 664 molecule linewidth <val> <?datasetName?> 665 molecule material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?datasetName?> 634 666 molecule opacity <val> <?datasetName?> 635 667 molecule orient <qw> <qx> <qy> <qz> <?dataSetName?> … … 655 687 656 688 polydata add <?datasetName?> 689 polydata color <r> <g> <b> <?datasetName?> 657 690 polydata cloudstyle <style> <?datasetName?> 658 691 <style> = mesh | points 659 polydata color <r> <g> <b> <?datasetName?> 692 polydata colormap <colormapName> <?datasetName?> 693 polydata colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 694 Set the field used to color the object. 'constant' means to use 695 the constant color defined by the color subcommand. 'scalar' uses 696 the active scalar field. 'vmag' uses the magnitude of the current 697 vector field, and 'vx','vy','vz' use the corresponding component of 698 the active vector field. 660 699 polydata culling <bool> <?name?> 661 700 polydata delete <?datasetName?> … … 669 708 polydata origin <x> <y> <z> <?name?> 670 709 polydata pos <x> <y> <z> <?dataSetName?> 710 polydata preinterp <bool> <?dataSetName?> 711 Controls if VTK's InterpolateScalarsBeforeMapping option is set. 712 Setting this on will give more correct colors, as the interpolation 713 is done on texture coordinates that lookup into a 1D texture instead 714 of using color interpolation from triangle vertices. 671 715 polydata ptsize <size> <?dataSetName?> 672 716 polydata scale <sx> <sy> <sz> <?dataSetName?> … … 697 741 698 742 pseudocolor add <?datasetName?> 699 pseudocolor c color <r> <g> <b> <?datasetName?>743 pseudocolor color <r> <g> <b> <?datasetName?> 700 744 pseudocolor cloudstyle <style> <?datasetName?> 701 745 <style> = mesh | points | splat 702 746 pseudocolor colormap <colormapName> <?datasetName?> 703 pseudocolor colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>704 Set the field used to color the object. 'c color' means to use705 the constant color defined by the c color subcommand. 'scalar' uses747 pseudocolor colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 748 Set the field used to color the object. 'constant' means to use 749 the constant color defined by the color subcommand. 'scalar' uses 706 750 the active scalar field. 'vmag' uses the magnitude of the current 707 751 vector field, and 'vx','vy','vz' use the corresponding component of … … 749 793 750 794 streamlines add <?datasetName?> 751 streamlines c color <r> <g> <b> <?datasetName?>752 Set the constant color of streamlines used for color mode 'c color'795 streamlines color <r> <g> <b> <?datasetName?> 796 Set the constant color of streamlines used for color mode 'constant' 753 797 streamlines colormap <colormapName> <?datasetName?> 754 798 Colormap used to color streamlines/tubes/ribbons by vector magnitude 755 streamlines colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>756 Set the field used to color the streamlines. 'c color' means to use757 the constant color defined by the c color subcommand. 'scalar' uses799 streamlines colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 800 Set the field used to color the streamlines. 'constant' means to use 801 the constant color defined by the color subcommand. 'scalar' uses 758 802 the active scalar field. 'vmag' uses the magnitude of the current 759 803 vector field, and 'vx','vy','vz' use the corresponding component of … … 812 856 streamlines visible <bool> <?datasetName?> 813 857 858 text3d add <textString> <name> 859 text3d color <r> <g> <b> <?name?> 860 text3d delete <?name?> 861 text3d fntfamily <fontName> <?name?> 862 text3d fntsize <fontSize> <?name?> 863 text3d opacity <opacity> <?name?> 864 text3d orient <qw> <qx> <qy> <qz> <?name?> 865 text3d origin <x> <y> <z> <?name?> 866 text3d pos <x> <y> <z> <?name?> 867 text3d scale <sx> <sy> <sz> <?name?> 868 text3d visible <bool> <?name?> 869 814 870 volume add <?datasetName?> 815 871 volume colormap <colorMapName> <?datasetName?> … … 827 883 828 884 warp add <?dataSetName?> 829 warp c color <r> <g> <b> <?datasetName?>885 warp color <r> <g> <b> <?datasetName?> 830 886 warp cloudstyle <style> <?datasetName?> 831 887 <style> = mesh | points 832 888 warp colormap <colormapName> <?datasetName?> 833 warp colormode <scalar|vmag|vx|vy|vz|c color> <fieldName> <?datasetName?>834 Set the field used to color the object. 'c color' means to use835 the constant color defined by the c color subcommand. 'scalar' uses889 warp colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?datasetName?> 890 Set the field used to color the object. 'constant' means to use 891 the constant color defined by the color subcommand. 'scalar' uses 836 892 the active scalar field. 'vmag' uses the magnitude of the current 837 893 vector field, and 'vx','vy','vz' use the corresponding component of
Note: See TracChangeset
for help on using the changeset viewer.