Changeset 3844 for branches/1.3/packages


Ignore:
Timestamp:
Jul 26, 2013, 6:00:09 PM (11 years ago)
Author:
ldelgass
Message:

Sync with trunk. Branch now differs only from trunk by r3722 (branch is version
1.3, trunk is version 1.4)

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  
    151151#endif
    152152            _contourFilter->SetInputConnection(mesher->GetOutputPort());
    153         } else if (vtkPolyData::SafeDownCast(ds) != NULL) {
    154             // DataSet is a vtkPolyData with lines and/or polygons
    155             ERROR("Not a 3D DataSet");
    156             return;
    157153        } 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
    159157#ifdef USE_VTK6
    160158            _contourFilter->SetInputData(ds);
  • branches/1.3/packages/vizservers/vtkvis/DataSet.cpp

    r3710 r3844  
    2424#include <vtkCell.h>
    2525#include <vtkLookupTable.h>
     26#include <vtkExtractUnstructuredGrid.h>
    2627
    2728#include "DataSet.h"
     
    145146}
    146147
    147 void DataSet::print() const
    148 {
    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     // Topology
    165     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 
    288148/**
    289149 * \brief Read dataset using supplied reader
     
    303163    if (_dataSet == NULL)
    304164        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
    305179#ifndef USE_VTK6
    306180    _dataSet->SetPipelineInformation(NULL);
     
    560434            return _dataSet->GetPointData()->GetScalars()->GetName();
    561435        }
     436#ifdef DEBUG
    562437        TRACE("No point scalars");
     438#endif
    563439        if (_dataSet->GetCellData() != NULL &&
    564440            _dataSet->GetCellData()->GetScalars() != NULL) {
    565441            return _dataSet->GetCellData()->GetScalars()->GetName();
    566442        }
     443#ifdef DEBUG
    567444        TRACE("No cell scalars");
     445#endif
    568446    }
    569447    return NULL;
     
    580458            return POINT_DATA;
    581459        }
     460#ifdef DEBUG
    582461        TRACE("No point scalars");
     462#endif
    583463        if (_dataSet->GetCellData() != NULL &&
    584464            _dataSet->GetCellData()->GetScalars() != NULL) {
    585465            return CELL_DATA;
    586466        }
     467#ifdef DEBUG
    587468        TRACE("No cell scalars");
     469#endif
    588470    }
    589471    return POINT_DATA;
     
    624506            return POINT_DATA;
    625507        }
     508#ifdef DEBUG
    626509        TRACE("No point vectors");
     510#endif
    627511        if (_dataSet->GetCellData() != NULL &&
    628512            _dataSet->GetCellData()->GetVectors() != NULL) {
    629513            return CELL_DATA;
    630514        }
     515#ifdef DEBUG
    631516        TRACE("No cell vectors");
     517#endif
    632518    }
    633519    return POINT_DATA;
     
    644530            return _dataSet->GetPointData()->GetVectors()->GetName();
    645531        }
     532#ifdef DEBUG
    646533        TRACE("No point vectors");
     534#endif
    647535        if (_dataSet->GetCellData() != NULL &&
    648536            _dataSet->GetCellData()->GetVectors() != NULL) {
    649537            return _dataSet->GetCellData()->GetVectors()->GetName();
    650538        }
     539#ifdef DEBUG
    651540        TRACE("No cell vectors");
     541#endif
    652542    }
    653543    return NULL;
     544}
     545
     546void 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    }
    654596}
    655597
     
    973915    return true;
    974916}
     917
     918void DataSet::print() const
     919{
     920    print(_dataSet);
     921}
     922
     923void 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  
    2626class DataSet {
    2727public:
     28    /**
     29     * These enum values intentionally match vtkDataObject::FieldAssociations
     30     * and vtkDataObject::AttributeTypes
     31     */
    2832    enum DataAttributeType {
    2933        POINT_DATA,
  • branches/1.3/packages/vizservers/vtkvis/Glyphs.cpp

    r3696 r3844  
    2929#include <vtkTransformPolyDataFilter.h>
    3030#include <vtkPolyDataNormals.h>
     31#include <vtkDelaunay2D.h>
     32#include <vtkDelaunay3D.h>
     33#include <vtkPolyData.h>
     34#include <vtkUnstructuredGrid.h>
    3135
    3236#include "Glyphs.h"
    3337#include "Renderer.h"
     38#include "Math.h"
    3439#include "Trace.h"
    3540
     
    280285        _glyphMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
    281286        _glyphMapper->SetResolveCoincidentTopologyToPolygonOffset();
     287        // If there are color scalars, use them without lookup table (if scalar visibility is on)
     288        _glyphMapper->SetColorModeToDefault();
    282289        _glyphMapper->ScalarVisibilityOn();
    283290    }
     
    323330    }
    324331
    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);
    333414
    334415    // Normalize sizes to [0,1] * ScaleFactor
    335416    _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    }
    337424    _glyphMapper->ScalingOn();
    338425
     
    363450        if (_glyphMapper != NULL) {
    364451            _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            }
    365459        }
    366460    }
     
    667761    _scaleFactor = scale;
    668762    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        }
    670770    }
    671771}
     
    787887
    788888/**
     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 */
     899void 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/**
    789932 * \brief Set a group of world coordinate planes to clip rendering
    790933 *
  • branches/1.3/packages/vizservers/vtkvis/Glyphs.h

    r3677 r3844  
    1616#include <vtkVersion.h>
    1717#include <vtkGlyph3DMapper.h>
     18#include <vtkMaskPoints.h>
    1819#include <vtkLookupTable.h>
    1920#include <vtkPlaneCollection.h>
     
    9293    void setScaleFactor(double scale);
    9394
     95    void setMaximumNumberOfGlyphs(int max, bool random = true,
     96                                  int offset = 0, int ratio = 1);
     97
    9498    void setColorMap(ColorMap *colorMap);
    9599
     
    136140    vtkSmartPointer<vtkPolyDataAlgorithm> _glyphSource;
    137141    vtkSmartPointer<vtkGlyph3DMapper> _glyphMapper;
     142    vtkSmartPointer<vtkMaskPoints> _maskPoints;
    138143};
    139144
  • branches/1.3/packages/vizservers/vtkvis/GraphicsObject.cpp

    r3621 r3844  
    1313
    1414void GraphicsObject::setDataSet(DataSet *dataSet,
    15                                    Renderer *renderer)
     15                                Renderer *renderer)
    1616{
    1717    if (_dataSet != dataSet) {
  • branches/1.3/packages/vizservers/vtkvis/GraphicsObject.h

    r3683 r3844  
    1414#include <vtkSmartPointer.h>
    1515#include <vtkProp.h>
     16#include <vtkActor2D.h>
    1617#include <vtkProp3D.h>
    1718#include <vtkProp3DCollection.h>
    1819#include <vtkAssembly.h>
    1920#include <vtkActor.h>
     21#include <vtkImageActor.h>
    2022#include <vtkVolume.h>
    2123#include <vtkProperty.h>
     24#include <vtkImageProperty.h>
    2225#include <vtkVolumeProperty.h>
    2326#include <vtkMath.h>
     
    114117
    115118    /**
     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    /**
    116129     * \brief Cast the vktProp to a vtkProp3D
    117130     *
     
    131144    {
    132145        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);
    133156    }
    134157
     
    484507                        TRACE("Culling on");
    485508                    }
    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);
    488515        }
    489516    }
     
    504531        if (getActor() != NULL) {
    505532            getActor()->GetProperty()->SetAmbient(ambient);
     533        } else if (getImageActor() != NULL) {
     534            getImageActor()->GetProperty()->SetAmbient(ambient);
    506535        } else if (getVolume() != NULL) {
    507536            getVolume()->GetProperty()->SetAmbient(ambient);
     
    513542                if (vtkActor::SafeDownCast(prop) != NULL) {
    514543                    vtkActor::SafeDownCast(prop)->GetProperty()->SetAmbient(ambient);
     544                } else if (vtkImageActor::SafeDownCast(prop) != NULL) {
     545                    vtkImageActor::SafeDownCast(prop)->GetProperty()->SetAmbient(ambient);
    515546                } else if (vtkVolume::SafeDownCast(prop) != NULL) {
    516547                    vtkVolume::SafeDownCast(prop)->GetProperty()->SetAmbient(ambient);
     
    527558        if (getActor() != NULL) {
    528559            getActor()->GetProperty()->SetDiffuse(diffuse);
     560        } else if (getImageActor() != NULL) {
     561            getImageActor()->GetProperty()->SetDiffuse(diffuse);
    529562        } else if (getVolume() != NULL) {
    530563            getVolume()->GetProperty()->SetDiffuse(diffuse);
     
    536569                if (vtkActor::SafeDownCast(prop) != NULL) {
    537570                    vtkActor::SafeDownCast(prop)->GetProperty()->SetDiffuse(diffuse);
     571                } else if (vtkImageActor::SafeDownCast(prop) != NULL) {
     572                    vtkImageActor::SafeDownCast(prop)->GetProperty()->SetDiffuse(diffuse);
    538573                } else if (vtkVolume::SafeDownCast(prop) != NULL) {
    539574                    vtkVolume::SafeDownCast(prop)->GetProperty()->SetDiffuse(diffuse);
     
    581616            property->SetSpecular(specular);
    582617            property->SetSpecularPower(specPower);
     618        } else if (getImageActor() != NULL) {
     619            vtkImageProperty *property = getImageActor()->GetProperty();
     620            property->SetAmbient(ambient);
     621            property->SetDiffuse(diffuse);
    583622        } else if (getVolume() != NULL) {
    584623            vtkVolumeProperty *property = getVolume()->GetProperty();
     
    598637                    property->SetSpecular(specular);
    599638                    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);
    600643                } else if (vtkVolume::SafeDownCast(prop) != NULL) {
    601644                    vtkVolumeProperty *property = vtkVolume::SafeDownCast(prop)->GetProperty();
  • branches/1.3/packages/vizservers/vtkvis/HeightMap.cpp

    r3680 r3844  
    478478    if (_contours.empty()) {
    479479        // 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        }
    481485    } else {
    482486        // User-supplied isovalues
  • branches/1.3/packages/vizservers/vtkvis/Makefile.in

    r3679 r3844  
    22TRACE                   = #yes
    33USE_CUSTOM_AXES         = yes
     4USE_FONT_CONFIG         = #yes
    45USE_GPU_RAYCASTING      = yes
    56USE_OFFSCREEN_RENDERING = #yes
    67USE_THREADS             = yes
    7 USE_VTK6                = yes
     8NEW_SCALAR_BAR          = #yes
    89
    910bindir          = @bindir@
     
    4041
    4142VTK_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                 -lvtkCommon
    5343VTK_INC_SPEC    = @VTK_INC_SPEC@
    54 VTK6_LIB_SPEC   = \
     44VTK_LIB_SPEC    = \
    5545                -lvtkDomainsChemistry-6.0 \
    5646                -lvtkIOCore-6.0 \
    5747                -lvtkIOLegacy-6.0 \
     48                -lvtkFiltersExtraction-6.0 \
    5849                -lvtkFiltersModeling-6.0 \
    5950                -lvtkFiltersFlowPaths-6.0 \
     
    6960                -lvtkRenderingHybridOpenGL-6.0 \
    7061                -lvtkRenderingFreeTypeOpenGL-6.0 \
     62                -lvtkRenderingFreeTypeFontConfig-6.0 \
    7163                -lvtkRenderingFreeType-6.0  \
    7264                -lvtkRenderingVolumeOpenGL-6.0 \
     
    8072                -lvtkCommonMisc-6.0  \
    8173                -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
    8977LD_RUN_PATH     = $(libdir)
    90 else
    91 LD_RUN_PATH     = $(libdir):$(VTK_LIB_DIR)
    92 endif
    9378
    9479LIBS            = \
     
    119104DEFINES         += -DUSE_CUSTOM_AXES
    120105endif
     106ifdef USE_FONT_CONFIG
     107DEFINES         += -DUSE_FONT_CONFIG
     108endif
    121109ifdef USE_OFFSCREEN_RENDERING
    122110DEFINES         += -DUSE_OFFSCREEN_RENDERING
     
    128116DEFINES         += -DUSE_THREADS
    129117endif
    130 ifdef USE_VTK6
    131 VTK_MOD_DEFS    = -DvtkRenderingCore_AUTOINIT="4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)" -DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)"
     118VTK_MOD_DEFS    = -DvtkRenderingCore_AUTOINIT="5(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeFontConfig,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)" -DvtkRenderingVolume_AUTOINIT="1(vtkRenderingVolumeOpenGL)"
    132119DEFINES         += -DUSE_VTK6 $(VTK_MOD_DEFS)
     120ifdef NEW_SCALAR_BAR
     121DEFINES         += -DNEW_SCALAR_BAR
    133122endif
    134123
     
    153142                Group.cpp \
    154143                HeightMap.cpp \
     144                Image.cpp \
    155145                LIC.cpp \
    156146                Line.cpp \
     
    169159                Sphere.cpp \
    170160                Streamlines.cpp \
     161                Text3D.cpp \
    171162                TGAWriter.cpp \
    172163                Trace.cpp \
     
    233224Group.o: Group.h GraphicsObject.h DataSet.h Renderer.h Trace.h
    234225HeightMap.o: HeightMap.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h
     226Image.o: Image.h GraphicsObject.h DataSet.h Renderer.h Trace.h
    235227LIC.o: LIC.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h RenderServer.h
    236228Line.o: Line.h Shape.h GraphicsObject.h DataSet.h Renderer.h Trace.h
     
    243235PseudoColor.o: PseudoColor.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h
    244236ReadBuffer.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.h
    246 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.h
    247 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.h
     237Renderer.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
     238RendererCmd.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
     239RendererGraphicsObjs.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
    248240RenderServer.o: RenderServer.h RendererCmd.h Renderer.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h
    249241ResponseQueue.o: ResponseQueue.h Trace.h
     
    251243Sphere.o: Sphere.h Shape.h GraphicsObject.h DataSet.h Renderer.h Trace.h
    252244Streamlines.o: Streamlines.h GraphicsObject.h DataSet.h Renderer.h ColorMap.h Trace.h
     245Text3D.o: Text3D.h GraphicsObject.h DataSet.h Renderer.h Trace.h
    253246TGAWriter.o: TGAWriter.h ResponseQueue.h Trace.h
    254247Trace.o: Trace.h
  • branches/1.3/packages/vizservers/vtkvis/Math.h

    r3616 r3844  
    217217}
    218218
     219inline double min3(double a, double b, double c)
     220{
     221    return min2(min2(a, b), c);
     222}
     223
     224inline double max3(double a, double b, double c)
     225{
     226    return max2(max2(a, b), c);
     227}
     228
    219229}
    220230
  • branches/1.3/packages/vizservers/vtkvis/Molecule.cpp

    r3693 r3844  
    2929#include <vtkLabelPlacementMapper.h>
    3030#include <vtkTextProperty.h>
     31#include <vtkTransformPolyDataFilter.h>
    3132
    3233#include "Molecule.h"
     
    108109        _atomProp->GetProperty()->SetOpacity(_opacity);
    109110        _atomProp->GetProperty()->SetAmbient(.2);
     111        _atomProp->GetProperty()->SetSpecular(.2);
     112        _atomProp->GetProperty()->SetSpecularPower(80.0);
    110113        if (!_lighting)
    111114            _atomProp->GetProperty()->LightingOff();
     
    121124        _bondProp->GetProperty()->SetOpacity(_opacity);
    122125        _bondProp->GetProperty()->SetAmbient(.2);
     126        _bondProp->GetProperty()->SetSpecular(.2);
     127        _bondProp->GetProperty()->SetSpecularPower(80.0);
    123128        if (!_lighting)
    124129            _bondProp->GetProperty()->LightingOff();
     
    178183    addLabelArray(ds);
    179184    addRadiusArray(ds, _atomScaling, _radiusScale);
     185    computeBonds(ds);
    180186
    181187    vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
     
    231237                _labelHierarchy = vtkSmartPointer<vtkPointSetToLabelHierarchy>::New();
    232238            }
    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);
    235245#else
    236             _labelHierarchy->SetInput(pd);
     246            transformFilter->SetInput(pd);
    237247#endif
     248            transformFilter->SetTransform(_labelTransform);
     249            _labelHierarchy->SetInputConnection(transformFilter->GetOutputPort());
    238250            _labelHierarchy->SetLabelArrayName("_atom_labels");
    239251            _labelHierarchy->GetTextProperty()->SetColor(0, 0, 0);
     
    255267            _atomMapper->SetInputConnection(pd->GetProducerPort());
    256268#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();
    266272            _atomMapper->OrientOff();
    267273
     
    283289    if (pd->GetNumberOfLines() > 0) {
    284290        _bondMapper->Update();
     291    }
     292}
     293
     294void Molecule::updateLabelTransform()
     295{
     296    if (_labelTransform != NULL && getAssembly() != NULL) {
     297        _labelTransform->SetMatrix(getAssembly()->GetMatrix());
    285298    }
    286299}
     
    797810        if (_atomMapper != NULL) {
    798811             assert(ds->GetPointData() != NULL &&
    799                     ds->GetPointData()->GetVectors() != NULL);
     812                    ds->GetPointData()->GetArray("_radii") != NULL);
    800813            _atomMapper->SetScaleModeToScaleByMagnitude();
    801             _atomMapper->SetScaleArray(vtkDataSetAttributes::VECTORS);
     814            _atomMapper->SetScaleArray("_radii");
    802815            _atomMapper->ScalingOn();
    803816        }
     
    887900        bondPoints->InsertNextPoint(newPt1);
    888901
     902#ifdef DEBUG
    889903        TRACE("Bond %d: (%g,%g,%g)-(%g,%g,%g)-(%g,%g,%g)", i,
    890904              pt0[0], pt0[1], pt0[2],
    891905              center[0], center[1], center[2],
    892906              pt1[0], pt1[1], pt1[2]);
     907#endif
    893908
    894909        double vec[3];
     
    898913        bondVectors->InsertNextTupleValue(vec);
    899914        bondVectors->InsertNextTupleValue(vec);
     915#ifdef DEBUG
    900916        TRACE("Bond %d, vec: %g,%g,%g", i, vec[0], vec[1], vec[2]);
     917#endif
    901918
    902919        double scale[3];
     
    910927        if (elements != NULL) {
    911928            int element = (int)elements->GetComponent(pts[0], 0);
     929#ifdef DEBUG
    912930            TRACE("Bond %d, elt 0: %d", i, element);
     931#endif
    913932            bondElements->InsertNextValue(element);
    914933            element = (int)elements->GetComponent(pts[1], 0);
     934#ifdef DEBUG
    915935            TRACE("Bond %d, elt 1: %d", i, element);
     936#endif
    916937            bondElements->InsertNextValue(element);
    917938        }
     
    9841005        ;
    9851006    }
    986     vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New();
    987     radii->SetName("_radii");
    988     radii->SetNumberOfComponents(3);
    9891007    vtkPolyData *pd = vtkPolyData::SafeDownCast(dataSet);
    9901008    if (pd == NULL) {
     
    9921010        return;
    9931011    }
     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    }
    9941023    for (int i = 0; i < pd->GetNumberOfPoints(); i++) {
    995         float tuple[3];
    996         tuple[1] = tuple[2] = 0;
     1024        float value;
    9971025        if (elements != NULL && radiusSource != NULL) {
    9981026            int elt = (int)elements->GetComponent(i, 0);
    999             tuple[0] = radiusSource[elt] * scaleFactor;
     1027            value = radiusSource[elt] * scaleFactor;
    10001028        } 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    }
    10061037}
    10071038
     
    10371068    return elementCmap;
    10381069}
     1070
     1071int 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  
    2222#include <vtkPointSetToLabelHierarchy.h>
    2323#include <vtkLabelPlacementMapper.h>
     24#include <vtkTransform.h>
    2425
    2526#include "ColorMap.h"
     
    7879    }
    7980
     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
    80123    virtual void setDataSet(DataSet *dataSet,
    81124                            Renderer *renderer);
     
    141184    void setupBondPolyData();
    142185
     186    void updateLabelTransform();
     187
    143188    static void addLabelArray(vtkDataSet *dataSet);
    144189
    145190    static void addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling, double scaleFactor);
     191
     192    static int computeBonds(vtkDataSet *dataSet, float tolerance = 0.45f);
    146193
    147194    float _bondColor[3];
     
    171218    vtkSmartPointer<vtkPointSetToLabelHierarchy> _labelHierarchy;
    172219    vtkSmartPointer<vtkLabelPlacementMapper> _labelMapper;
     220    vtkSmartPointer<vtkTransform> _labelTransform;
    173221};
    174222
  • branches/1.3/packages/vizservers/vtkvis/PolyData.cpp

    r3680 r3844  
    1010#include <vtkDataSet.h>
    1111#include <vtkPolyData.h>
     12#include <vtkPolyDataNormals.h>
     13#include <vtkPointData.h>
     14#include <vtkCellData.h>
    1215#include <vtkUnstructuredGrid.h>
    1316#include <vtkPolyDataMapper.h>
     
    1922#include <vtkDataSetSurfaceFilter.h>
    2023#include <vtkVertexGlyphFilter.h>
     24#include <vtkLookupTable.h>
    2125
    2226#include "PolyData.h"
     27#include "Renderer.h"
    2328#include "Trace.h"
    2429
     
    2732PolyData::PolyData() :
    2833    GraphicsObject(),
     34    _colorMap(NULL),
     35    _colorMode(COLOR_CONSTANT),
     36    _colorFieldType(DataSet::POINT_DATA),
     37    _renderer(NULL),
    2938    _cloudStyle(CLOUD_MESH)
    3039{
     40    _colorFieldRange[0] = DBL_MAX;
     41    _colorFieldRange[1] = -DBL_MAX;
    3142}
    3243
     
    4152}
    4253
     54void 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
    4386/**
    4487 * \brief Internal method to set up pipeline after a state change
     
    5093    }
    5194
    52     if (_pdMapper == NULL) {
    53         _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    54         _pdMapper->SetResolveCoincidentTopologyToPolygonOffset();
    55         _pdMapper->ScalarVisibilityOff();
    56     }
    57 
    5895    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
    59107    vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
    60108    if (pd) {
     
    66114              pd->GetNumberOfStrips());
    67115    }
     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
    68124    if (_dataSet->isCloud()) {
    69125        // DataSet is a point cloud
     
    78134            vgf->SetInput(ds);
    79135#endif
    80             _pdMapper->SetInputConnection(vgf->GetOutputPort());
     136            _mapper->SetInputConnection(vgf->GetOutputPort());
    81137        } else if (_dataSet->is2D(&plane, &offset)) {
    82138            vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
     
    122178                vgf->SetInput(ds);
    123179#endif
    124                 _pdMapper->SetInputConnection(vgf->GetOutputPort());
     180                _mapper->SetInputConnection(vgf->GetOutputPort());
    125181            } else {
    126                 _pdMapper->SetInputConnection(mesher->GetOutputPort());
     182                vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
     183                normalFilter->SetInputConnection(mesher->GetOutputPort());
     184                _mapper->SetInputConnection(normalFilter->GetOutputPort());
    127185            }
    128186        } else {
     
    146204                vgf->SetInput(ds);
    147205#endif
    148                 _pdMapper->SetInputConnection(vgf->GetOutputPort());
     206                _mapper->SetInputConnection(vgf->GetOutputPort());
    149207            } else {
    150208                // Delaunay3D returns an UnstructuredGrid, so feed it
     
    153211                vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    154212                gf->UseStripsOn();
     213                gf->ReleaseDataFlagOn();
    155214                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());
    158218            }
    159219        }
    160220    } else if (pd) {
    161221        // 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        }
    167237    } else {
    168238        // DataSet is NOT a vtkPolyData
     
    170240        vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    171241        gf->UseStripsOn();
     242        gf->ReleaseDataFlagOn();
    172243#ifdef USE_VTK6
    173244        gf->SetInputData(ds);
     
    175246        gf->SetInput(ds);
    176247#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);
    179281    }
    180282
    181283    initProp();
    182     getActor()->SetMapper(_pdMapper);
    183     _pdMapper->Update();
     284    getActor()->SetMapper(_mapper);
     285    _mapper->Update();
    184286#ifdef WANT_TRACE
    185287    double *b = getBounds();
    186288    TRACE("bounds: %g %g %g %g %g %g", b[0], b[1], b[2], b[3], b[4], b[5]);
    187289#endif
     290}
     291
     292void PolyData::setInterpolateBeforeMapping(bool state)
     293{
     294    if (_mapper != NULL) {
     295        _mapper->SetInterpolateScalarsBeforeMapping((state ? 1 : 0));
     296    }
     297}
     298
     299void 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
     334void 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
     378void 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
     393void 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 */
     505void PolyData::updateColorMap()
     506{
     507    setColorMap(_colorMap);
     508}
     509
     510/**
     511 * \brief Associate a colormap lookup table with the DataSet
     512 */
     513void 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    }
    188574}
    189575
     
    195581void PolyData::setClippingPlanes(vtkPlaneCollection *planes)
    196582{
    197     if (_pdMapper != NULL) {
    198         _pdMapper->SetClippingPlanes(planes);
     583    if (_mapper != NULL) {
     584        _mapper->SetClippingPlanes(planes);
    199585    }
    200586}
  • branches/1.3/packages/vizservers/vtkvis/PolyData.h

    r3680 r3844  
    1212#include <vtkPolyDataMapper.h>
    1313#include <vtkActor.h>
     14#include <vtkLookupTable.h>
    1415
     16#include "ColorMap.h"
    1517#include "GraphicsObject.h"
    16 #include "DataSet.h"
    1718
    1819namespace VtkVis {
     
    2930        CLOUD_POINTS
    3031    };
     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    };
    3140
    3241    PolyData();
     
    3847    }
    3948
     49    virtual void setDataSet(DataSet *dataSet,
     50                            Renderer *renderer);
     51
    4052    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    4153
    4254    void setCloudStyle(CloudStyle style);
    4355
     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
    4480private:
    4581    virtual void update();
    4682
     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
    4792    CloudStyle _cloudStyle;
    48     vtkSmartPointer<vtkPolyDataMapper> _pdMapper;
     93    vtkSmartPointer<vtkLookupTable> _lut;
     94    vtkSmartPointer<vtkPolyDataMapper> _mapper;
    4995};
    5096
  • branches/1.3/packages/vizservers/vtkvis/PseudoColor.cpp

    r3680 r3844  
    9999    if (_mapper == NULL) {
    100100        _mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
     101        _mapper->SetResolveCoincidentTopologyToPolygonOffset();
    101102        // Map scalars through lookup table regardless of type
    102103        _mapper->SetColorModeToMapScalars();
     
    106107    if (_dataSet->isCloud()) {
    107108        // DataSet is a point cloud
    108         if (_cloudStyle == CLOUD_POINTS) {
     109        if (_cloudStyle == CLOUD_POINTS ||
     110            _dataSet->numDimensions() < 2 || ds->GetNumberOfPoints() < 3) {
    109111            vtkSmartPointer<vtkVertexGlyphFilter> vgf = vtkSmartPointer<vtkVertexGlyphFilter>::New();
    110112#ifdef USE_VTK6
     
    385387        _mapper->SetScalarModeToUseCellFieldData();
    386388        break;
     389    case DataSet::FIELD_DATA:
     390        _mapper->SetScalarModeToUseFieldData();
     391        break;
    387392    default:
    388393        ERROR("Unsupported DataAttributeType: %d", type);
     
    392397    if (_splatter != NULL) {
    393398        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);
    395400        }
    396401        _mapper->SelectColorArray("SplatterValues");
  • branches/1.3/packages/vizservers/vtkvis/RenderServer.cpp

    r3621 r3844  
    2222
    2323#include <tcl.h>
     24
     25#include <vtksys/SystemInformation.hxx>
    2426
    2527#include "Trace.h"
     
    494496    TRACE("Starting VTKVis Server");
    495497
     498#ifdef WANT_TRACE
     499    vtksys::SystemInformation::SetStackTraceOnError(1);
     500#endif
     501
    496502    /* This synchronizes the client with the server, so that the client
    497503     * doesn't start writing commands before the server is ready. It could
  • branches/1.3/packages/vizservers/vtkvis/RenderServer.h

    r3683 r3844  
    1616class Renderer;
    1717
    18 #define VTKVIS_VERSION_STRING "1.4"
     18#define VTKVIS_VERSION_STRING "1.5"
    1919
    2020#define MSECS_ELAPSED(t1, t2) \
  • branches/1.3/packages/vizservers/vtkvis/Renderer.cpp

    r3683 r3844  
    1717#endif
    1818
     19#ifdef USE_FONT_CONFIG
     20#include <vtkFreeTypeTools.h>
     21#endif
    1922#include <vtkMath.h>
    2023#include <vtkCamera.h>
     
    4245#include "ColorMap.h"
    4346#include "Trace.h"
    44 
    45 #define NEW_SCALAR_BAR
    4647
    4748#define MSECS_ELAPSED(t1, t2) \
     
    120121    if (_cameraMode == IMAGE)
    121122        _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
    122130    _renderer = vtkSmartPointer<vtkRenderer>::New();
    123131
     
    184192    deleteAllGraphicsObjects<Group>();
    185193    deleteAllGraphicsObjects<HeightMap>();
     194    deleteAllGraphicsObjects<Image>();
    186195    deleteAllGraphicsObjects<LIC>();
    187196    deleteAllGraphicsObjects<Line>();
     
    193202    deleteAllGraphicsObjects<Sphere>();
    194203    deleteAllGraphicsObjects<Streamlines>();
     204    deleteAllGraphicsObjects<Text3D>();
    195205    deleteAllGraphicsObjects<Volume>();
    196206    deleteAllGraphicsObjects<Warp>();
     
    264274        deleteGraphicsObject<Glyphs>(itr->second->getName());
    265275        deleteGraphicsObject<HeightMap>(itr->second->getName());
     276        deleteGraphicsObject<Image>(itr->second->getName());
    266277        deleteGraphicsObject<LIC>(itr->second->getName());
    267278        deleteGraphicsObject<Molecule>(itr->second->getName());
     
    15551566    updateGraphicsObjectColorMap<Glyphs>(cmap);
    15561567    updateGraphicsObjectColorMap<HeightMap>(cmap);
     1568    updateGraphicsObjectColorMap<Image>(cmap);
    15571569    updateGraphicsObjectColorMap<LIC>(cmap);
    15581570    updateGraphicsObjectColorMap<Molecule>(cmap);
     1571    updateGraphicsObjectColorMap<PolyData>(cmap);
    15591572    updateGraphicsObjectColorMap<PseudoColor>(cmap);
    15601573    updateGraphicsObjectColorMap<Streamlines>(cmap);
     
    15791592    if (graphicsObjectColorMapUsed<HeightMap>(cmap))
    15801593        return true;
     1594    if (graphicsObjectColorMapUsed<Image>(cmap))
     1595        return true;
    15811596    if (graphicsObjectColorMapUsed<LIC>(cmap))
    15821597        return true;
    15831598    if (graphicsObjectColorMapUsed<Molecule>(cmap))
     1599        return true;
     1600    if (graphicsObjectColorMapUsed<PolyData>(cmap))
    15841601        return true;
    15851602    if (graphicsObjectColorMapUsed<PseudoColor>(cmap))
     
    19311948#ifdef NEW_SCALAR_BAR
    19321949        _scalarBarActor->SetBarRatio(1);
     1950        _scalarBarActor->SetTitleRatio(0);
    19331951#endif
    19341952        if (width > height) {
     
    19581976#ifdef NEW_SCALAR_BAR
    19591977        _scalarBarActor->SetBarRatio(0.375);
     1978        _scalarBarActor->SetTitleRatio(0.5);
    19601979        _scalarBarActor->SetDisplayPosition(0, 0);
    19611980        _scalarBarActor->GetPosition2Coordinate()->SetCoordinateSystemToDisplay();
     
    21252144    _scalarBarActor->GetLabelTextProperty()->ShadowOff();
    21262145#ifdef NEW_SCALAR_BAR
    2127     if (title.empty() && numLabels == 0) {
     2146    if (!drawTitle && numLabels == 0) {
    21282147        _scalarBarActor->DrawAnnotationsOff();
    21292148        _scalarBarActor->SetAnnotationLeaderPadding(0);
     
    21372156
    21382157    _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
     2203bool 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    }
    21392305
    21402306#ifdef RENDER_TARGA
     
    22652431    setGraphicsObjectAspect<Glyphs>(aspectRatio);
    22662432    setGraphicsObjectAspect<HeightMap>(aspectRatio);
     2433    setGraphicsObjectAspect<Image>(aspectRatio);
    22672434    setGraphicsObjectAspect<LIC>(aspectRatio);
    22682435    setGraphicsObjectAspect<Line>(aspectRatio);
     
    22742441    setGraphicsObjectAspect<Sphere>(aspectRatio);
    22752442    setGraphicsObjectAspect<Streamlines>(aspectRatio);
     2443    setGraphicsObjectAspect<Text3D>(aspectRatio);
    22762444    setGraphicsObjectAspect<Volume>(aspectRatio);
    22772445    setGraphicsObjectAspect<Warp>(aspectRatio);
     
    31843352    mergeGraphicsObjectBounds<Group>(bounds, onlyVisible);
    31853353    mergeGraphicsObjectBounds<HeightMap>(bounds, onlyVisible);
     3354    mergeGraphicsObjectBounds<Image>(bounds, onlyVisible);
    31863355    mergeGraphicsObjectBounds<LIC>(bounds, onlyVisible);
    31873356    mergeGraphicsObjectBounds<Line>(bounds, onlyVisible);
     
    31933362    mergeGraphicsObjectBounds<Sphere>(bounds, onlyVisible);
    31943363    mergeGraphicsObjectBounds<Streamlines>(bounds, onlyVisible);
     3364    mergeGraphicsObjectBounds<Text3D>(bounds, onlyVisible);
    31953365    mergeGraphicsObjectBounds<Volume>(bounds, onlyVisible);
    31963366    mergeGraphicsObjectBounds<Warp>(bounds, onlyVisible);
     
    32533423    mergeGraphicsObjectUnscaledBounds<Glyphs>(bounds, onlyVisible);
    32543424    mergeGraphicsObjectUnscaledBounds<HeightMap>(bounds, onlyVisible);
     3425    mergeGraphicsObjectUnscaledBounds<Image>(bounds, onlyVisible);
    32553426    mergeGraphicsObjectUnscaledBounds<LIC>(bounds, onlyVisible);
    32563427    mergeGraphicsObjectUnscaledBounds<Line>(bounds, onlyVisible);
     
    32623433    mergeGraphicsObjectUnscaledBounds<Sphere>(bounds, onlyVisible);
    32633434    mergeGraphicsObjectUnscaledBounds<Streamlines>(bounds, onlyVisible);
     3435    mergeGraphicsObjectUnscaledBounds<Text3D>(bounds, onlyVisible);
    32643436    mergeGraphicsObjectUnscaledBounds<Volume>(bounds, onlyVisible);
    32653437    mergeGraphicsObjectUnscaledBounds<Warp>(bounds, onlyVisible);
     
    33083480    updateGraphicsObjectFieldRanges<Glyphs>();
    33093481    updateGraphicsObjectFieldRanges<HeightMap>();
     3482    updateGraphicsObjectFieldRanges<Image>();
    33103483    updateGraphicsObjectFieldRanges<LIC>();
    33113484    updateGraphicsObjectFieldRanges<Molecule>();
     3485    updateGraphicsObjectFieldRanges<PolyData>();
    33123486    updateGraphicsObjectFieldRanges<PseudoColor>();
    33133487    updateGraphicsObjectFieldRanges<Streamlines>();
     
    33683542    }
    33693543    _scalarCellDataRange.clear();
     3544    for (FieldRangeHashmap::iterator itr = _scalarFieldDataRange.begin();
     3545         itr != _scalarFieldDataRange.end(); ++itr) {
     3546        delete [] itr->second;
     3547    }
     3548    _scalarFieldDataRange.clear();
    33703549    for (FieldRangeHashmap::iterator itr = _vectorPointDataRange.begin();
    33713550         itr != _vectorPointDataRange.end(); ++itr) {
     
    33923571        _vectorCompCellDataRange[i].clear();
    33933572    }
     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    }
    33943585}
    33953586
     
    34103601    }
    34113602    _userScalarCellDataRange.clear();
     3603    for (FieldRangeHashmap::iterator itr = _userScalarFieldDataRange.begin();
     3604         itr != _userScalarFieldDataRange.end(); ++itr) {
     3605        delete [] itr->second;
     3606    }
     3607    _userScalarFieldDataRange.clear();
    34123608    for (FieldRangeHashmap::iterator itr = _userVectorPointDataRange.begin();
    34133609         itr != _userVectorPointDataRange.end(); ++itr) {
     
    34333629        }
    34343630        _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();
    34353643    }
    34363644}
     
    34723680                _scalarCellDataRange[*itr][0] = 0;
    34733681                _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;
    34743694            }
    34753695        }
     
    35113731                    _vectorCompCellDataRange[i][*itr][0] = 0;
    35123732                    _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;
    35133753                }
    35143754            }
     
    36103850    }
    36113851        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;
    36123886    default:
    36133887        ERROR("Bad Field Type");
     
    36263900/**
    36273901 * \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
    36293904 *
    36303905 * \param[out] range Pointer to an array of 2 doubles
     
    36393914{
    36403915    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,
    36443925                                     numComponents, component);
     3926    }
    36453927    return ret;
    36463928}
     
    37394021    }
    37404022        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;
    37414060    default:
    37424061        break;
     
    37574076        collectDataRanges(itr->second, itr->first.c_str(),
    37584077                          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,
    37594084                          _cumulativeRangeOnlyVisible);
    37604085    }
     
    37844109            collectDataRanges(itr->second, itr->first.c_str(),
    37854110                              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,
    37864125                              _cumulativeRangeOnlyVisible);
    37874126        }
     
    40244363    if (id.compare("all") == 0 || getGraphicsObject<HeightMap>(id) != NULL)
    40254364        setGraphicsObjectOpacity<HeightMap>(id, opacity);
     4365    if (id.compare("all") == 0 || getGraphicsObject<Image>(id) != NULL)
     4366        setGraphicsObjectOpacity<Image>(id, opacity);
    40264367    if (id.compare("all") == 0 || getGraphicsObject<LIC>(id) != NULL)
    40274368        setGraphicsObjectOpacity<LIC>(id, opacity);
     
    40804421    if (id.compare("all") == 0 || getGraphicsObject<HeightMap>(id) != NULL)
    40814422        setGraphicsObjectVisibility<HeightMap>(id, state);
     4423    if (id.compare("all") == 0 || getGraphicsObject<Image>(id) != NULL)
     4424        setGraphicsObjectVisibility<Image>(id, state);
    40824425    if (id.compare("all") == 0 || getGraphicsObject<LIC>(id) != NULL)
    40834426        setGraphicsObjectVisibility<LIC>(id, state);
     
    42294572    setGraphicsObjectClippingPlanes<Group>(_activeClipPlanes);
    42304573    setGraphicsObjectClippingPlanes<HeightMap>(_activeClipPlanes);
     4574    setGraphicsObjectClippingPlanes<Image>(_activeClipPlanes);
    42314575    setGraphicsObjectClippingPlanes<LIC>(_activeClipPlanes);
    42324576    setGraphicsObjectClippingPlanes<Line>(_activeClipPlanes);
     
    42384582    setGraphicsObjectClippingPlanes<Sphere>(_activeClipPlanes);
    42394583    setGraphicsObjectClippingPlanes<Streamlines>(_activeClipPlanes);
     4584    setGraphicsObjectClippingPlanes<Text3D>(_activeClipPlanes);
    42404585    setGraphicsObjectClippingPlanes<Volume>(_activeClipPlanes);
    42414586    setGraphicsObjectClippingPlanes<Warp>(_activeClipPlanes);
     
    42934638        setCameraClippingPlanes();
    42944639        _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        }
    42954644        _needsRedraw = false;
    42964645        return true;
  • branches/1.3/packages/vizservers/vtkvis/Renderer.h

    r3696 r3844  
    4040#include "Group.h"
    4141#include "HeightMap.h"
     42#include "Image.h"
    4243#include "LIC.h"
    4344#include "Line.h"
     
    4950#include "Sphere.h"
    5051#include "Streamlines.h"
     52#include "Text3D.h"
    5153#include "Volume.h"
    5254#include "Warp.h"
     
    420422
    421423    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);
    422429
    423430    bool renderColorMap(const ColorMapId& id,
     
    699706    void setGlyphsScaleFactor(const DataSetId& id, double scale);
    700707
     708    void setGlyphsMaximumNumberOfGlyphs(const DataSetId& id, int max,
     709                                        bool random = true,
     710                                        int offset = 0, int ratio = 1);
     711
    701712    // Groups
    702713
     
    741752                               const char *name, double range[2] = NULL);
    742753
     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);
    743769
    744770    // Lines
     
    792818                               PolyData::CloudStyle style);
    793819
     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
    794829    // Color-mapped surfaces
    795830
     
    876911
    877912    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);
    878933
    879934    // Volumes
     
    915970    typedef std::tr1::unordered_map<DataSetId, Group *> GroupHashmap;
    916971    typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap;
     972    typedef std::tr1::unordered_map<DataSetId, Image *> ImageHashmap;
    917973    typedef std::tr1::unordered_map<DataSetId, LIC *> LICHashmap;
    918974    typedef std::tr1::unordered_map<DataSetId, Line *> LineHashmap;
     
    924980    typedef std::tr1::unordered_map<DataSetId, Sphere *> SphereHashmap;
    925981    typedef std::tr1::unordered_map<DataSetId, Streamlines *> StreamlinesHashmap;
     982    typedef std::tr1::unordered_map<DataSetId, Text3D *> Text3DHashmap;
    926983    typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap;
    927984    typedef std::tr1::unordered_map<DataSetId, Warp *> WarpHashmap;
     
    10191076    FieldRangeHashmap _vectorCellDataRange;
    10201077    FieldRangeHashmap _vectorCompCellDataRange[3];
     1078    FieldRangeHashmap _scalarFieldDataRange;
     1079    FieldRangeHashmap _vectorFieldDataRange;
     1080    FieldRangeHashmap _vectorCompFieldDataRange[3];
    10211081
    10221082    FieldRangeHashmap _userScalarPointDataRange;
     
    10261086    FieldRangeHashmap _userVectorCellDataRange;
    10271087    FieldRangeHashmap _userVectorCompCellDataRange[3];
     1088    FieldRangeHashmap _userScalarFieldDataRange;
     1089    FieldRangeHashmap _userVectorFieldDataRange;
     1090    FieldRangeHashmap _userVectorCompFieldDataRange[3];
    10281091
    10291092    bool _axesAutoBounds[3];
     
    10461109    GroupHashmap _groups;
    10471110    HeightMapHashmap _heightMaps;
     1111    ImageHashmap _images;
    10481112    LICHashmap _lics;
    10491113    LineHashmap _lines;
     
    10551119    SphereHashmap _spheres;
    10561120    StreamlinesHashmap _streamlines;
     1121    Text3DHashmap _text3Ds;
    10571122    VolumeHashmap _volumes;
    10581123    WarpHashmap _warps;
  • branches/1.3/packages/vizservers/vtkvis/RendererCmd.cpp

    r3696 r3844  
    20492049    {"orient",    4, BoxOrientOp, 6, 7, "qw qx qy qz ?name?"},
    20502050    {"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?"},
    20522052    {"scale",     2, BoxScaleOp, 5, 6, "sx sy sz ?name?"},
    20532053    {"shading",   2, BoxShadingOp, 3, 4, "val ?name?"},
     
    28912891    {"orient",    4, ConeOrientOp, 6, 7, "qw qx qy qz ?name?"},
    28922892    {"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?"},
    28942894    {"resolution",1, ConeResolutionOp, 3, 4, "res ?name?"},
    28952895    {"scale",     2, ConeScaleOp, 5, 6, "sx sy sz ?name?"},
     
    30263026    Contour2D::ColorMode mode;
    30273027    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)) {
    30293030        mode = Contour2D::COLOR_CONSTANT;
    30303031    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    30403041    } else {
    30413042        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);
    30433044        return TCL_ERROR;
    30443045    }
     
    32533254    {"add",          1, Contour2DAddOp, 4, 5, "oper value ?dataSetName?"},
    32543255    {"ccolor",       2, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
     3256    {"color",        5, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
    32553257    {"colormap",     7, Contour2DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    32563258    {"colormode",    7, Contour2DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    34013403    Contour3D::ColorMode mode;
    34023404    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)) {
    34043407        mode = Contour3D::COLOR_CONSTANT;
    34053408    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    34153418    } else {
    34163419        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);
    34183421        return TCL_ERROR;
    34193422    }
     
    36883691    {"add",          1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"},
    36893692    {"ccolor",       2, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"},
     3693    {"color",        5, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"},
    36903694    {"colormap",     7, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    36913695    {"colormode",    7, Contour3DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    41224126    {"ccolor",       2, CutplaneColorOp, 5, 6, "r g b ?dataSetName?"},
    41234127    {"cloudstyle",   2, CutplaneCloudStyleOp, 3, 4, "style ?dataSetName?"},
     4128    {"color",        5, CutplaneColorOp, 5, 6, "r g b ?dataSetName?"},
    41244129    {"colormap",     7, CutplaneColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    41254130    {"colormode",    7, CutplaneColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    45184523    {"orient",    4, CylinderOrientOp, 6, 7, "qw qx qy qz ?name?"},
    45194524    {"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?"},
    45214526    {"resolution",1, CylinderResolutionOp, 3, 4, "res ?name?"},
    45224527    {"scale",     2, CylinderScaleOp, 5, 6, "sx sy sz ?name?"},
     
    53345339    {"orient",    4, DiskOrientOp, 6, 7, "qw qx qy qz ?name?"},
    53355340    {"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?"},
    53375342    {"resolution",1, DiskResolutionOp, 4, 5, "resRadial resCircum ?name?"},
    53385343    {"scale",     2, DiskScaleOp, 5, 6, "sx sy sz ?name?"},
     
    54465451    Glyphs::ColorMode mode;
    54475452    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)) {
    54495455        mode = Glyphs::COLOR_CONSTANT;
    54505456    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    54605466    } else {
    54615467        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);
    54635469        return TCL_ERROR;
    54645470    }
     
    55555561    } else {
    55565562        g_renderer->setGraphicsObjectEdgeWidth<Glyphs>("all", width);
     5563    }
     5564    return TCL_OK;
     5565}
     5566
     5567static int
     5568GlyphsMaxNumberOfGlyphsOp(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);
    55575594    }
    55585595    return TCL_OK;
     
    58305867    {"add",          1, GlyphsAddOp, 3, 4, "shape ?dataSetName?"},
    58315868    {"ccolor",       2, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"},
     5869    {"color",        5, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"},
    58325870    {"colormap",     7, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    58335871    {"colormode",    7, GlyphsColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    58395877    {"linecolor",    5, GlyphsLineColorOp, 5, 6, "r g b ?dataSetName?"},
    58405878    {"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?"},
    58425881    {"opacity",      2, GlyphsOpacityOp, 3, 4, "value ?dataSetName?"},
    58435882    {"orient",       2, GlyphsOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
     
    60246063    {"pos",       1, GroupPositionOp, 5, 6, "x y z ?name?"},
    60256064    {"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?"},
    60276066    {"visible",   1, GroupVisibleOp, 3, 4, "bool ?name?"},
    60286067};
     
    62126251    HeightMap::ColorMode mode;
    62136252    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)) {
    62156255        mode = HeightMap::COLOR_CONSTANT;
    62166256    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    62266266    } else {
    62276267        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);
    62296269        return TCL_ERROR;
    62306270    }
     
    62386278    } else {
    62396279        g_renderer->setHeightMapColorMode("all", mode, fieldName);
     6280    }
     6281    return TCL_OK;
     6282}
     6283
     6284static int
     6285HeightMapColorMode2Op(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;
    62406355    }
    62416356    return TCL_OK;
     
    66396754    {"ccolor",       2, HeightMapColorOp, 5, 6, "r g b ?dataSetName?"},
    66406755    {"cloudstyle",   2, HeightMapCloudStyleOp, 3, 4, "style ?dataSetName?"},
     6756    {"color",        5, HeightMapColorOp, 5, 6, "r g b ?dataSetName?"},
    66416757    {"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?"},
    66436760    {"contourlist",  3, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"},
    66446761    {"delete",       1, HeightMapDeleteOp, 2, 3, "?dataSetName?"},
     
    66806797
    66816798static int
     6799ImageAddOp(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
     6817static int
     6818ImageBackgroundOp(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
     6834static int
     6835ImageBackingOp(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
     6851static int
     6852ImageBorderOp(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
     6868static int
     6869ImageColorOp(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
     6887static int
     6888ImageColorMapOp(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
     6901static int
     6902ImageDeleteOp(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
     6914static int
     6915ImageExtentsOp(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
     6936static int
     6937ImageLevelOp(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
     6953static int
     6954ImageOpacityOp(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
     6970static int
     6971ImageOrientOp(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
     6990static int
     6991ImagePositionOp(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
     7009static int
     7010ImageScaleOp(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
     7028static int
     7029ImageVisibleOp(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
     7045static int
     7046ImageWindowOp(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
     7062static int
     7063ImageZSliceOp(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
     7079static 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};
     7097static int nImageOps = NumCmdSpecs(imageOps);
     7098
     7099static int
     7100ImageCmd(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
     7113static int
    66827114ImageFlushCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    66837115              Tcl_Obj *const *objv)
     
    67867218
    67877219static int
     7220LegendSimpleCmd(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
     7278static int
    67887279LICAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    67897280         Tcl_Obj *const *objv)
     
    72717762    {"orient",    4, LineOrientOp, 6, 7, "qw qx qy qz ?name?"},
    72727763    {"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?"},
    72757766    {"visible",   1, LineVisibleOp, 3, 4, "bool ?name?"}
    72767767};
     
    75798070    if (str[0] == 'b' && strcmp(str, "by_elements") == 0) {
    75808071        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)) {
    75828074        mode = Molecule::COLOR_CONSTANT;
    75838075    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    75938085    } else {
    75948086        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);
    75968088        return TCL_ERROR;
    75978089    }
     
    76938185    } else {
    76948186        g_renderer->setGraphicsObjectEdgeWidth<Molecule>("all", width);
     8187    }
     8188    return TCL_OK;
     8189}
     8190
     8191static int
     8192MoleculeMaterialOp(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);
    76958212    }
    76968213    return TCL_OK;
     
    78188335    {"bstyle",       3, MoleculeBondStyleOp, 3, 4, "value ?dataSetName?"},
    78198336    {"ccolor",       2, MoleculeColorOp, 5, 6, "r g b ?dataSetName?"},
     8337    {"color",        5, MoleculeColorOp, 5, 6, "r g b ?dataSetName?"},
    78208338    {"colormap",     7, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    78218339    {"colormode",    7, MoleculeColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    78278345    {"linecolor",    5, MoleculeLineColorOp, 5, 6, "r g b ?dataSetName?"},
    78288346    {"linewidth",    5, MoleculeLineWidthOp, 3, 4, "width ?dataSetName?"},
     8347    {"material",     1, MoleculeMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
    78298348    {"opacity",      2, MoleculeOpacityOp, 3, 4, "value ?dataSetName?"},
    78308349    {"orient",       2, MoleculeOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
     
    80198538    {"opacity",   2, OutlineOpacityOp, 3, 4, "value ?dataSetName?"},
    80208539    {"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?"},
    80238542    {"visible",   1, OutlineVisibleOp, 3, 4, "bool ?dataSetName?"}
    80248543};
     
    81038622
    81048623static int
     8624PolyDataColorMapOp(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
     8637static int
     8638PolyDataColorModeOp(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
     8674static int
    81058675PolyDataCullingOp(ClientData clientData, Tcl_Interp *interp, int objc,
    81068676                  Tcl_Obj *const *objv)
     
    83158885    } else {
    83168886        g_renderer->setGraphicsObjectPosition<PolyData>("all", pos);
     8887    }
     8888    return TCL_OK;
     8889}
     8890
     8891static int
     8892PolyDataPreInterpOp(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);
    83178904    }
    83188905    return TCL_OK;
     
    83988985static Rappture::CmdSpec polyDataOps[] = {
    83998986    {"add",       1, PolyDataAddOp, 2, 3, "?dataSetName?"},
     8987    {"ccolor",    2, PolyDataColorOp, 5, 6, "r g b ?dataSetName?"},
    84008988    {"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?"},
    84028992    {"culling",   2, PolyDataCullingOp, 3, 4, "bool ?name?"},
    84038993    {"delete",    1, PolyDataDeleteOp, 2, 3, "?dataSetName?"},
     
    84119001    {"origin",    4, PolyDataOriginOp, 5, 6, "x y z ?name?"},
    84129002    {"pos",       2, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"},
     9003    {"preinterp", 2, PolyDataPreInterpOp, 3, 4, "bool ?dataSetName?"},
    84139004    {"ptsize",    2, PolyDataPointSizeOp, 3, 4, "size ?dataSetName?"},
    84149005    {"scale",     2, PolyDataScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
     
    88919482    PseudoColor::ColorMode mode;
    88929483    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)) {
    88949486        mode = PseudoColor::COLOR_CONSTANT;
    88959487    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    89059497    } else {
    89069498        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);
    89089500        return TCL_ERROR;
    89099501    }
     
    91519743    {"ccolor",       2, PseudoColorColorOp, 5, 6, "r g b ?dataSetName?"},
    91529744    {"cloudstyle",   2, PseudoColorCloudStyleOp, 3, 4, "style ?dataSetName?"},
     9745    {"color",        5, PseudoColorColorOp, 5, 6, "r g b ?dataSetName?"},
    91539746    {"colormap",     7, PseudoColorColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    91549747    {"colormode",    7, PseudoColorColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    981110404    } else if (str[0] == 'v' && strcmp(str, "vz") == 0) {
    981210405        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)) {
    981410408        mode = Streamlines::COLOR_CONSTANT;
    981510409    } else {
    981610410        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);
    981810412        return TCL_ERROR;
    981910413    }
     
    1046011054static Rappture::CmdSpec streamlinesOps[] = {
    1046111055    {"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?"},
    1046311058    {"colormap",     7, StreamlinesColorMapOp,       3, 4, "colorMapName ?dataSetName?"},
    1046411059    {"colormode",    7, StreamlinesColorModeOp,      4, 5, "mode fieldName ?dataSetName?"},
     
    1049711092
    1049811093static int
     11094Text3DAddOp(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
     11111static int
     11112Text3DBoldOp(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
     11128static int
     11129Text3DColorOp(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
     11147static int
     11148Text3DDeleteOp(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
     11160static int
     11161Text3DFollowCameraOp(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
     11177static int
     11178Text3DFontFamilyOp(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
     11191static int
     11192Text3DFontSizeOp(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
     11208static int
     11209Text3DItalicOp(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
     11225static int
     11226Text3DOpacityOp(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
     11242static int
     11243Text3DOrientOp(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
     11262static int
     11263Text3DOriginOp(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
     11281static int
     11282Text3DPositionOp(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
     11300static int
     11301Text3DScaleOp(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
     11319static int
     11320Text3DShadowOp(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
     11336static int
     11337Text3DTextOp(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
     11350static int
     11351Text3DVisibleOp(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
     11367static 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};
     11385static int nText3DOps = NumCmdSpecs(text3DOps);
     11386
     11387static int
     11388Text3DCmd(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
     11401static int
    1049911402VolumeAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1050011403            Tcl_Obj *const *objv)
     
    1086911772    Warp::ColorMode mode;
    1087011773    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)) {
    1087211776        mode = Warp::COLOR_CONSTANT;
    1087311777    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    1088311787    } else {
    1088411788        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);
    1088611790        return TCL_ERROR;
    1088711791    }
     
    1114612050    {"ccolor",       2, WarpColorOp, 5, 6, "r g b ?dataSetName?"},
    1114712051    {"cloudstyle",   2, WarpCloudStyleOp, 3, 4, "style ?dataSetName?"},
     12052    {"color",        5, WarpColorOp, 5, 6, "r g b ?dataSetName?"},
    1114812053    {"colormap",     7, WarpColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    1114912054    {"colormode",    7, WarpColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
     
    1115812063    {"preinterp",    2, WarpPreInterpOp, 3, 4, "bool ?dataSetName?"},
    1115912064    {"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?"},
    1116112066    {"visible",      1, WarpVisibleOp, 3, 4, "bool ?dataSetName?"},
    1116212067    {"warpscale",    2, WarpWarpScaleOp, 3, 4, "value ?dataSetName?"},
     
    1134012245    Tcl_CreateObjCommand(interp, "group",       GroupCmd,       clientData, NULL);
    1134112246    Tcl_CreateObjCommand(interp, "heightmap",   HeightMapCmd,   clientData, NULL);
     12247    Tcl_CreateObjCommand(interp, "image",       ImageCmd,       clientData, NULL);
    1134212248    Tcl_CreateObjCommand(interp, "imgflush",    ImageFlushCmd,  clientData, NULL);
    1134312249    Tcl_CreateObjCommand(interp, "legend",      LegendCmd,      clientData, NULL);
     12250    Tcl_CreateObjCommand(interp, "legend2",     LegendSimpleCmd,clientData, NULL);
    1134412251    Tcl_CreateObjCommand(interp, "lic",         LICCmd,         clientData, NULL);
    1134512252    Tcl_CreateObjCommand(interp, "line",        LineCmd,        clientData, NULL);
     
    1135312260    Tcl_CreateObjCommand(interp, "sphere",      SphereCmd,      clientData, NULL);
    1135412261    Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL);
     12262    Tcl_CreateObjCommand(interp, "text3d",      Text3DCmd,      clientData, NULL);
    1135512263    Tcl_CreateObjCommand(interp, "volume",      VolumeCmd,      clientData, NULL);
    1135612264    Tcl_CreateObjCommand(interp, "warp",        WarpCmd,        clientData, NULL);
     
    1137912287    Tcl_DeleteCommand(interp, "group");
    1138012288    Tcl_DeleteCommand(interp, "heightmap");
     12289    Tcl_DeleteCommand(interp, "image");
    1138112290    Tcl_DeleteCommand(interp, "imgflush");
    1138212291    Tcl_DeleteCommand(interp, "legend");
     12292    Tcl_DeleteCommand(interp, "legend2");
    1138312293    Tcl_DeleteCommand(interp, "lic");
    1138412294    Tcl_DeleteCommand(interp, "line");
     
    1139212302    Tcl_DeleteCommand(interp, "sphere");
    1139312303    Tcl_DeleteCommand(interp, "streamlines");
     12304    Tcl_DeleteCommand(interp, "text3d");
    1139412305    Tcl_DeleteCommand(interp, "volume");
    1139512306    Tcl_DeleteCommand(interp, "warp");
  • branches/1.3/packages/vizservers/vtkvis/RendererGraphicsObjs.cpp

    r3696 r3844  
    100100
    101101template<>
     102Renderer::ImageHashmap &
     103Renderer::getGraphicsObjectHashmap<Image>()
     104{ return _images; }
     105
     106template<>
    102107Renderer::LICHashmap &
    103108Renderer::getGraphicsObjectHashmap<LIC>()
     
    145150
    146151template<>
     152Renderer::Text3DHashmap &
     153Renderer::getGraphicsObjectHashmap<Text3D>()
     154{ return _text3Ds; }
     155
     156template<>
    147157Renderer::VolumeHashmap &
    148158Renderer::getGraphicsObjectHashmap<Volume>()
     
    154164{ return _warps; }
    155165
     166#if 0
    156167template Arc *Renderer::getGraphicsObject(const DataSetId&);
    157168template Arrow *Renderer::getGraphicsObject(const DataSetId&);
     
    164175template Polygon *Renderer::getGraphicsObject(const DataSetId&);
    165176template Sphere *Renderer::getGraphicsObject(const DataSetId&);
     177template Text3D *Renderer::getGraphicsObject(const DataSetId&);
     178#endif
    166179
    167180template <>
     
    214227}
    215228
    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 
    278229/**
    279230 * \brief Set the volume slice used for mapping volumetric data
     
    342293    }
    343294    if ((gobj = getGraphicsObject<Sphere>(id)) != NULL) {
     295        return gobj;
     296    }
     297    if ((gobj = getGraphicsObject<Text3D>(id)) != NULL) {
    344298        return gobj;
    345299    }
     
    358312    }
    359313    if ((gobj = getGraphicsObject<HeightMap>(id)) != NULL) {
     314        return gobj;
     315    }
     316    if ((gobj = getGraphicsObject<Image>(id)) != NULL) {
    360317        return gobj;
    361318    }
     
    15541511    do {
    15551512        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 */
     1530void 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);
    15561552    } while (doAll && ++itr != _glyphs.end());
    15571553
     
    22692265}
    22702266
     2267void 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
     2293void 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
     2319void 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
     2345void 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
     2371void 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
     2397void 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
     2423void 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
    22712449/**
    22722450 * \brief Create a new Line and associate it with an ID
     
    28293007
    28303008/**
     3009 * \brief Set the color mode for the specified DataSet
     3010 */
     3011void 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 */
     3043void 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/**
    28313072 * \brief Set the  point cloud render style for the specified DataSet
    28323073 */
     
    29533194
    29543195    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 */
     3205bool 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;
    29553238
    29563239    sceneBoundsChanged();
     
    36553938}
    36563939
     3940void 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 */
     3970void 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 */
     4000void 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
     4027void 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
     4054void 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
     4081void 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
     4108void 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
    36574135/**
    36584136 * \brief Set the sample rate for the volume shader
  • branches/1.3/packages/vizservers/vtkvis/RendererGraphicsObjs.h

    r3683 r3844  
    10341034
    10351035    ColorMap *cmap = getColorMap(colorMapId);
    1036     if (cmap == NULL) {
     1036    if (cmap == NULL && colorMapId.compare("none") != 0) {
    10371037        ERROR("Unknown colormap: %s", colorMapId.c_str());
    10381038        return;
  • branches/1.3/packages/vizservers/vtkvis/Volume.cpp

    r3680 r3844  
    8383    double spacing[3];
    8484    getSpacing(spacing);
     85    TRACE("Spacing: %g %g %g", spacing[0], spacing[1], spacing[2]);
    8586    return (spacing[0] + spacing[1] + spacing[2]) * 0.333;
    8687}
     
    120121#endif
    121122        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();
    122146    } else if (vtkUnstructuredGrid::SafeDownCast(ds) != NULL) {
     147        // Unstructured grid with cells (not a cloud)
    123148        vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast(ds);
    124149        // DataSet is unstructured grid
     
    144169#endif
    145170            filter->TetrahedraOnlyOn();
     171            TRACE("Decomposing grid to tets");
     172            filter->Update();
     173            TRACE("Decomposing done");
    146174            _volumeMapper->SetInputConnection(filter->GetOutputPort());
    147175        }
     
    149177        vtkUnstructuredGridVolumeMapper::SafeDownCast(_volumeMapper)->
    150178            SetBlendModeToComposite();
    151     } else if (_dataSet->isCloud()) {
    152         // DataSet is a 3D point cloud
    153         vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New();
    154 #ifdef USE_VTK6
    155         splatter->SetInputData(ds);
    156 #else
    157         splatter->SetInput(ds);
    158 #endif
    159         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_MAPPER
    165         _volumeMapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New();
    166         vtkGPUVolumeRayCastMapper::SafeDownCast(_volumeMapper)->AutoAdjustSampleDistancesOff();
    167 #else
    168         _volumeMapper = vtkSmartPointer<vtkVolumeTextureMapper3D>::New();
    169 #endif
    170         _volumeMapper->SetInputConnection(splatter->GetOutputPort());
    171         vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite();
    172179    } else {
    173180        ERROR("Unsupported DataSet type: %s", _dataSet->getVtkType());
  • branches/1.3/packages/vizservers/vtkvis/protocol.txt

    r3696 r3844  
    342342contour2d add contourlist <list> <?datasetName?>
    343343          list = {isoval1 isoval2 isoval3...}
    344 contour2d ccolor <r> <g> <b> <?datasetName?>
     344contour2d color <r> <g> <b> <?datasetName?>
    345345          synonym for linecolor
    346346contour2d colormap <colormapName> <?datasetName?>
    347 contour2d colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    348           Set the field used to color the object.  'ccolor' means to use
    349           the constant color defined by the ccolor subcommand.  'scalar' uses
     347contour2d 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
    350350          the active scalar field.  'vmag' uses the magnitude of the current
    351351          vector field, and 'vx','vy','vz' use the corresponding component of
     
    369369contour3d add contourlist <list> <?datasetName?>
    370370          list = {isoval1 isoval2 isoval3...}
    371 contour3d ccolor r g b <?datasetName?>
     371contour3d color r g b <?datasetName?>
    372372contour3d colormap <colorMapName> <?dataSetName?>
    373 contour3d colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    374           Set the field used to color the object.  'ccolor' means to use
    375           the constant color defined by the ccolor subcommand.  'scalar' uses
     373contour3d 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
    376376          the active scalar field.  'vmag' uses the magnitude of the current
    377377          vector field, and 'vx','vy','vz' use the corresponding component of
     
    394394cutplane axis <axis> <bool> <?dataSetName?>
    395395         Toggle visibility of the 3 principal axis cutplanes
    396 cutplane ccolor r g b <?datasetName?>
     396cutplane color r g b <?datasetName?>
    397397         Set color of outline bounding box
    398398cutplane cloudstyle <style> <?datasetName?>
     
    471471glyphs add <shape> <?dataSetName?>
    472472       See 'glyphs shape' for list of shapes
    473 glyphs ccolor r g b <?datasetName?>
     473glyphs color r g b <?datasetName?>
    474474glyphs colormap <colorMapName> <?dataSetName?>
    475 glyphs colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?dataSetName?>
     475glyphs colormode <scalar|vmag|vx|vy|vz|constant> <fieldName> <?dataSetName?>
    476476       Set the color mode: color by scalar field or
    477477       vector magnitude -- uses the current color map,
    478        or ccolor for constant color
     478       or color for constant color
    479479glyphs delete <?dataSetName?>
    480480glyphs edges <bool> <?datasetName?>
     
    490490       Control if data values are normalized to [0,1] range before applying
    491491       glyph scaling factor (gscale)
     492glyphs 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
    492499glyphs opacity <val> <?datasetName?>
    493500glyphs orient <qw> <qx> <qy> <qz> <?dataSetName?>
     
    505512
    506513group 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.
    507517group delete <?name?>
    508518group orient <qw> <qx> <qy> <qz> <?name?>
     
    510520group pos <x> <y> <z> <?name?>
    511521group 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.
    512525group scale <sx> <sy> <sz> <?name?>
    513526group visible <bool> <?name?>
     
    524537          <style> = mesh | splat
    525538heightmap colormap <colorMapName> <?dataSetName?>
    526 heightmap colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    527           Set the field used to color the object.  'ccolor' means to use
    528           the constant color defined by the ccolor subcommand.  'scalar' uses
     539heightmap 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
    529542          the active scalar field.  'vmag' uses the magnitude of the current
    530543          vector field, and 'vx','vy','vz' use the corresponding component of
     
    560573heightmap wireframe <bool> <?datasetName?>
    561574
     575image add <?dataSetName?>
     576      Create an image from a vtkImageData data set
     577image backing <bool> <?dataSetName?>
     578image bg <bool> <?dataSetName?>
     579image border <bool> <?dataSetName?>
     580image color <r> <g> <b> <?dataSetName?>
     581image colormap <colorMapName> <?dataSetName?>
     582image delete <?dataSetName?>
     583image extents <xmin> <xmax> <ymin> <ymax> <zmin> <zmax> <?dataSetName?>
     584image level <level> <?dataSetName?>
     585image opacity <opacity> <?dataSetName?>
     586image orient <qw> <qx> <qy> <qz> <?dataSetName?>
     587image pos <x> <y> <z> <?dataSetName?>
     588image scale <sx> <sy> <sz> <?dataSetName?>
     589image visible <bool> <?dataSetName?>
     590image window <windowWidth> <?dataSetName?>
     591image zslice <sliceNum> <?dataSetName?>
     592
    562593lic add <?datasetName?>
    563594lic colormap <colormapName> <?datasetName?>
     
    615646molecule bstyle <cylinder|line> <?datasetName?>
    616647         Set bond render style
    617 molecule ccolor r g b <?datasetName?>
     648molecule color r g b <?datasetName?>
    618649molecule colormap <colormapName> <?datasetName?>
    619 molecule colormode <by_elements|scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    620          Set the field used to color the object.  'ccolor' means to use
    621          the constant color defined by the ccolor subcommand.  'scalar' uses
     650molecule 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
    622653         the active scalar field.  'vmag' uses the magnitude of the current
    623654         vector field, and 'vx','vy','vz' use the corresponding component of
     
    632663molecule linecolor <r> <g> <b> <?datasetName?>
    633664molecule linewidth <val> <?datasetName?>
     665molecule material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?datasetName?>
    634666molecule opacity <val> <?datasetName?>
    635667molecule orient <qw> <qx> <qy> <qz> <?dataSetName?>
     
    655687
    656688polydata add <?datasetName?>
     689polydata color <r> <g> <b> <?datasetName?>
    657690polydata cloudstyle <style> <?datasetName?>
    658691         <style> = mesh | points
    659 polydata color <r> <g> <b> <?datasetName?>
     692polydata colormap <colormapName> <?datasetName?>
     693polydata 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.
    660699polydata culling <bool> <?name?>
    661700polydata delete <?datasetName?>
     
    669708polydata origin <x> <y> <z> <?name?>
    670709polydata pos <x> <y> <z> <?dataSetName?>
     710polydata 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.
    671715polydata ptsize <size> <?dataSetName?>
    672716polydata scale <sx> <sy> <sz> <?dataSetName?>
     
    697741
    698742pseudocolor add <?datasetName?>
    699 pseudocolor ccolor <r> <g> <b> <?datasetName?>
     743pseudocolor color <r> <g> <b> <?datasetName?>
    700744pseudocolor cloudstyle <style> <?datasetName?>
    701745            <style> = mesh | points | splat
    702746pseudocolor colormap <colormapName> <?datasetName?>
    703 pseudocolor colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    704             Set the field used to color the object.  'ccolor' means to use
    705             the constant color defined by the ccolor subcommand.  'scalar' uses
     747pseudocolor 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
    706750            the active scalar field.  'vmag' uses the magnitude of the current
    707751            vector field, and 'vx','vy','vz' use the corresponding component of
     
    749793
    750794streamlines add <?datasetName?>
    751 streamlines ccolor <r> <g> <b> <?datasetName?>
    752             Set the constant color of streamlines used for color mode 'ccolor'
     795streamlines color <r> <g> <b> <?datasetName?>
     796            Set the constant color of streamlines used for color mode 'constant'
    753797streamlines colormap <colormapName> <?datasetName?>
    754798            Colormap used to color streamlines/tubes/ribbons by vector magnitude
    755 streamlines colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    756             Set the field used to color the streamlines.  'ccolor' means to use
    757             the constant color defined by the ccolor subcommand.  'scalar' uses
     799streamlines 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
    758802            the active scalar field.  'vmag' uses the magnitude of the current
    759803            vector field, and 'vx','vy','vz' use the corresponding component of
     
    812856streamlines visible <bool> <?datasetName?>
    813857
     858text3d add <textString> <name>
     859text3d color <r> <g> <b> <?name?>
     860text3d delete <?name?>
     861text3d fntfamily <fontName> <?name?>
     862text3d fntsize <fontSize> <?name?>
     863text3d opacity <opacity> <?name?>
     864text3d orient <qw> <qx> <qy> <qz> <?name?>
     865text3d origin <x> <y> <z> <?name?>
     866text3d pos <x> <y> <z> <?name?>
     867text3d scale <sx> <sy> <sz> <?name?>
     868text3d visible <bool> <?name?>
     869
    814870volume add <?datasetName?>
    815871volume colormap <colorMapName> <?datasetName?>
     
    827883
    828884warp add <?dataSetName?>
    829 warp ccolor <r> <g> <b> <?datasetName?>
     885warp color <r> <g> <b> <?datasetName?>
    830886warp cloudstyle <style> <?datasetName?>
    831887     <style> = mesh | points
    832888warp colormap <colormapName> <?datasetName?>
    833 warp colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
    834      Set the field used to color the object.  'ccolor' means to use
    835      the constant color defined by the ccolor subcommand.  'scalar' uses
     889warp 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
    836892     the active scalar field.  'vmag' uses the magnitude of the current
    837893     vector field, and 'vx','vy','vz' use the corresponding component of
Note: See TracChangeset for help on using the changeset viewer.