Ignore:
Timestamp:
Aug 27, 2011 1:59:23 AM (13 years ago)
Author:
ldelgass
Message:

Handle 2D datasets with offset from origin or in principal planes other than XY.
Add return value for many methods, e.g. creating graphics objects
Add query for server's current list of datasets
Add pixel/world coordinate query of vector fields
Add pixel coordinate support for setting image camera zoom region
Add Heightmap wireframe, surface visibility toggles
Add Point size setting for polydata
Use custom version of 2D axes, fixes tick/label direction in XZ view
Put contour isolines through stripper to remove gaps in line rasterization

Location:
trunk/packages/vizservers/vtkvis
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/Makefile.in

    r2402 r2423  
    4747DEBUG                   = #yes
    4848TRACE                   = #yes
    49 USE_CUSTOM_AXES         = #yes
     49USE_CUSTOM_AXES         = yes
    5050USE_GPU_RAYCASTING      = yes
    5151USE_OFFSCREEN_RENDERING = yes
  • trunk/packages/vizservers/vtkvis/RpContour2D.cpp

    r2402 r2423  
    1313#include <vtkCellDataToPointData.h>
    1414#include <vtkContourFilter.h>
     15#include <vtkStripper.h>
    1516#include <vtkPolyDataMapper.h>
    1617#include <vtkUnstructuredGrid.h>
    1718#include <vtkProperty.h>
     19#include <vtkTransform.h>
    1820#include <vtkDelaunay2D.h>
    1921#include <vtkDelaunay3D.h>
     
    107109            pd->GetNumberOfStrips() == 0) {
    108110            // DataSet is a point cloud
    109             if (_dataSet->is2D()) {
     111            DataSet::PrincipalPlane plane;
     112            double offset;
     113            if (_dataSet->is2D(&plane, &offset)) {
    110114                vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
     115                if (plane == DataSet::PLANE_ZY) {
     116                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     117                    trans->RotateWXYZ(90, 0, 1, 0);
     118                    if (offset != 0.0) {
     119                        trans->Translate(-offset, 0, 0);
     120                    }
     121                    mesher->SetTransform(trans);
     122                } else if (plane == DataSet::PLANE_XZ) {
     123                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     124                    trans->RotateWXYZ(-90, 1, 0, 0);
     125                    if (offset != 0.0) {
     126                        trans->Translate(0, -offset, 0);
     127                    }
     128                    mesher->SetTransform(trans);
     129                } else if (offset != 0.0) {
     130                    // XY with Z offset
     131                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     132                    trans->Translate(0, 0, -offset);
     133                    mesher->SetTransform(trans);
     134                }
    111135                mesher->SetInput(pd);
    112136                _contourFilter->SetInputConnection(mesher->GetOutputPort());
     
    154178        _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    155179        _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
    156         _contourMapper->SetInputConnection(_contourFilter->GetOutputPort());
     180        vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
     181        stripper->SetInputConnection(_contourFilter->GetOutputPort());
     182        _contourMapper->SetInputConnection(stripper->GetOutputPort());
    157183        getActor()->SetMapper(_contourMapper);
    158184    }
  • trunk/packages/vizservers/vtkvis/RpGlyphs.h

    r2402 r2423  
    2727 * \brief Oriented and scaled 3D glyph shapes
    2828 *
    29  * The DataSet must be a PolyData point set
    30  * with vectors and/or scalars
     29 * The DataSet must have vectors and/or scalars
    3130 */
    3231class Glyphs : public VtkGraphicsObject {
  • trunk/packages/vizservers/vtkvis/RpHeightMap.cpp

    r2402 r2423  
    1818#include <vtkImageData.h>
    1919#include <vtkLookupTable.h>
     20#include <vtkTransform.h>
    2021#include <vtkDelaunay2D.h>
    2122#include <vtkDelaunay3D.h>
     
    2526#include <vtkDataSetSurfaceFilter.h>
    2627#include <vtkContourFilter.h>
     28#include <vtkStripper.h>
    2729#include <vtkWarpScalar.h>
    2830#include <vtkPropAssembly.h>
     
    3537#define MESH_POINT_CLOUDS
    3638
    37 HeightMap::HeightMap(int numContours) :
     39HeightMap::HeightMap(int numContours, double heightScale) :
    3840    VtkGraphicsObject(),
    3941    _numContours(numContours),
    4042    _colorMap(NULL),
    4143    _contourEdgeWidth(1.0),
    42     _warpScale(1.0),
     44    _warpScale(heightScale),
    4345    _sliceAxis(Z_AXIS),
    4446    _pipelineInitialized(false)
     
    4951}
    5052
    51 HeightMap::HeightMap(const std::vector<double>& contours) :
     53HeightMap::HeightMap(const std::vector<double>& contours, double heightScale) :
    5254    VtkGraphicsObject(),
    5355    _numContours(contours.size()),
     
    5557    _colorMap(NULL),
    5658    _contourEdgeWidth(1.0),
    57     _warpScale(1.0),
     59    _warpScale(heightScale),
    5860    _sliceAxis(Z_AXIS),
    5961    _pipelineInitialized(false)
     
    194196                pd->GetNumberOfStrips() == 0) {
    195197                // DataSet is a point cloud
    196                 if (_dataSet->is2D()) {
     198                DataSet::PrincipalPlane plane;
     199                double offset;
     200                if (_dataSet->is2D(&plane, &offset)) {
    197201#ifdef MESH_POINT_CLOUDS
    198202                    // Result of Delaunay2D is a PolyData
    199203                    vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
     204                    if (plane == DataSet::PLANE_ZY) {
     205                        vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     206                        trans->RotateWXYZ(90, 0, 1, 0);
     207                        if (offset != 0.0) {
     208                            trans->Translate(-offset, 0, 0);
     209                        }
     210                        mesher->SetTransform(trans);
     211                        _sliceAxis = X_AXIS;
     212                    } else if (plane == DataSet::PLANE_XZ) {
     213                        vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     214                        trans->RotateWXYZ(-90, 1, 0, 0);
     215                        if (offset != 0.0) {
     216                            trans->Translate(0, -offset, 0);
     217                        }
     218                        mesher->SetTransform(trans);
     219                        _sliceAxis = Y_AXIS;
     220                    } else if (offset != 0.0) {
     221                        // XY with Z offset
     222                        vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     223                        trans->Translate(0, 0, -offset);
     224                        mesher->SetTransform(trans);
     225                    }
    200226                    mesher->SetInput(pd);
    201227                    vtkAlgorithmOutput *warpOutput = initWarp(mesher->GetOutputPort());
     
    205231                    if (_pointSplatter == NULL)
    206232                        _pointSplatter = vtkSmartPointer<vtkGaussianSplatter>::New();
     233                    if (_volumeSlicer == NULL)
     234                        _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New();
    207235                    _pointSplatter->SetInput(pd);
    208236                    int dims[3];
    209237                    _pointSplatter->GetSampleDimensions(dims);
    210238                    TRACE("Sample dims: %d %d %d", dims[0], dims[1], dims[2]);
    211                     dims[2] = 3;
     239                    if (plane == DataSet::PLANE_ZY) {
     240                        dims[0] = 3;
     241                        _volumeSlicer->SetVOI(1, 1, 0, dims[1]-1, 0, dims[1]-1);
     242                        _sliceAxis = X_AXIS;
     243                    } else if (plane == DataSet::PLANE_XZ) {
     244                        dims[1] = 3;
     245                        _volumeSlicer->SetVOI(0, dims[0]-1, 1, 1, 0, dims[2]-1);
     246                        _sliceAxis = Y_AXIS;
     247                    } else {
     248                        dims[2] = 3;
     249                        _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1);
     250                    }
    212251                    _pointSplatter->SetSampleDimensions(dims);
    213252                    double bounds[6];
     
    218257                          bounds[2], bounds[3],
    219258                          bounds[4], bounds[5]);
    220                     if (_volumeSlicer == NULL)
    221                         _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New();
    222259                    _volumeSlicer->SetInputConnection(_pointSplatter->GetOutputPort());
    223                     _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1);
    224260                    _volumeSlicer->SetSampleRate(1, 1, 1);
    225261                    vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
     
    324360                _probeFilter->SetSource(ds);
    325361                vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New();
     362                DataSet::PrincipalPlane plane;
     363                double offset;
    326364                int xdim = 256;
    327365                int ydim = 256;
    328366                int zdim = 1;
     367                double origin[3];
     368                double spacing[3];
     369                origin[0] = bounds[0];
     370                origin[1] = bounds[2];
     371                origin[2] = bounds[4] + (bounds[5]-bounds[4])/2.;
     372                spacing[0] = (bounds[1]-bounds[0])/((double)(xdim-1));
     373                spacing[1] = (bounds[3]-bounds[2])/((double)(ydim-1));
     374                spacing[2] = 0;
     375                if (_dataSet->is2D(&plane, &offset)) {
     376                    if (plane == DataSet::PLANE_ZY) {
     377                        xdim = 1;
     378                        zdim = 256;
     379                        origin[2] = bounds[4];
     380                        spacing[0] = 0;
     381                        spacing[2] = (bounds[5]-bounds[4])/((double)(zdim-1));
     382                        _sliceAxis = X_AXIS;
     383                    } else if (plane == DataSet::PLANE_XZ) {
     384                        ydim = 1;
     385                        zdim = 256;
     386                        origin[2] = bounds[4];
     387                        spacing[1] = 0;
     388                        spacing[2] = (bounds[5]-bounds[4])/((double)(zdim-1));
     389                        _sliceAxis = Y_AXIS;
     390                    }
     391                }
    329392                imageData->SetDimensions(xdim, ydim, zdim);
    330                 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])/2.);
    331                 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(xdim-1)),
    332                                       (bounds[3]-bounds[2])/((double)(ydim-1)),
    333                                       0);
     393                imageData->SetOrigin(origin);
     394                imageData->SetSpacing(spacing);
    334395                _probeFilter->SetInput(imageData);
    335396                gf->SetInputConnection(_probeFilter->GetOutputPort());
     
    377438        _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
    378439        _contourMapper->SetResolveCoincidentTopologyToPolygonOffset();
    379         _contourMapper->SetInputConnection(_contourFilter->GetOutputPort());
     440        vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New();
     441        stripper->SetInputConnection(_contourFilter->GetOutputPort());
     442        _contourMapper->SetInputConnection(stripper->GetOutputPort());
    380443        _contourActor->SetMapper(_contourMapper);
    381444    }
     
    582645            break;
    583646        case Y_AXIS:
    584             voi[2] = voi[3] = (int)((dims[1]-1) * ratio);
    585647            voi[0] = 0;
    586648            voi[1] = dims[0]-1;
     649            voi[2] = voi[3] = (int)((dims[1]-1) * ratio);
    587650            voi[4] = 0;
    588651            voi[5] = dims[2]-1;
    589652            break;
    590653        case Z_AXIS:
    591             voi[4] = voi[5] = (int)((dims[2]-1) * ratio);
    592654            voi[0] = 0;
    593655            voi[1] = dims[0]-1;
    594656            voi[2] = 0;
    595657            voi[3] = dims[1]-1;
     658            voi[4] = voi[5] = (int)((dims[2]-1) * ratio);
    596659            break;
    597660        default:
     
    666729 * Will override any existing contours
    667730 */
    668 void HeightMap::setContours(int numContours)
     731void HeightMap::setNumContours(int numContours)
    669732{
    670733    _contours.clear();
     
    724787
    725788/**
     789 * \brief Turn on/off rendering of colormaped surface
     790 */
     791void HeightMap::setContourSurfaceVisibility(bool state)
     792{
     793    if (_dsActor != NULL) {
     794        _dsActor->SetVisibility((state ? 1 : 0));
     795    }
     796}
     797
     798/**
    726799 * \brief Turn on/off rendering of contour isolines
    727800 */
    728 void HeightMap::setContourVisibility(bool state)
     801void HeightMap::setContourLineVisibility(bool state)
    729802{
    730803    if (_contourActor != NULL) {
  • trunk/packages/vizservers/vtkvis/RpHeightMap.h

    r2402 r2423  
    4242    };
    4343
    44     HeightMap(int numContours);
     44    HeightMap(int numContours, double heightScale = 1.0);
    4545
    46     HeightMap(const std::vector<double>& contours);
     46    HeightMap(const std::vector<double>& contours, double heightScale = 1.0);
    4747
    4848    virtual ~HeightMap();
     
    7373    void setHeightScale(double scale);
    7474
    75     void setContours(int numContours);
    76 
    77     void setContours(int numContours, double range[2]);
     75    void setNumContours(int numContours);
    7876
    7977    void setContourList(const std::vector<double>& contours);
     
    10098                              double vectorComponentRange[3][2]);
    10199
    102     void setContourVisibility(bool state);
     100    void setContourLineVisibility(bool state);
     101
     102    void setContourSurfaceVisibility(bool state);
    103103
    104104    void setContourEdgeColor(float color[3]);
  • trunk/packages/vizservers/vtkvis/RpPolyData.cpp

    r2402 r2423  
    1414#include <vtkActor.h>
    1515#include <vtkProperty.h>
     16#include <vtkTransform.h>
    1617#include <vtkDelaunay2D.h>
    1718#include <vtkDelaunay3D.h>
     
    7879    vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
    7980    if (pd) {
    80         TRACE("Verts: %d Lines: %d Polys: %d Strips: %d",
    81                   pd->GetNumberOfVerts(),
    82                   pd->GetNumberOfLines(),
    83                   pd->GetNumberOfPolys(),
    84                   pd->GetNumberOfStrips());
     81        TRACE("Points: %d Verts: %d Lines: %d Polys: %d Strips: %d",
     82              pd->GetNumberOfPoints(),
     83              pd->GetNumberOfVerts(),
     84              pd->GetNumberOfLines(),
     85              pd->GetNumberOfPolys(),
     86              pd->GetNumberOfStrips());
    8587        // DataSet is a vtkPolyData
    8688        if (pd->GetNumberOfLines() == 0 &&
     
    8890            pd->GetNumberOfStrips() == 0) {
    8991            // DataSet is a point cloud
    90             if (_dataSet->is2D()) {
     92            DataSet::PrincipalPlane plane;
     93            double offset;
     94            if (_dataSet->numDimensions() < 2 || pd->GetNumberOfPoints() < 3) {
     95                // 0D or 1D or not enough points to mesh
     96                _pdMapper->SetInput(pd);
     97            } else if (_dataSet->is2D(&plane, &offset)) {
    9198                vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
     99                if (plane == DataSet::PLANE_ZY) {
     100                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     101                    trans->RotateWXYZ(90, 0, 1, 0);
     102                    if (offset != 0.0) {
     103                        trans->Translate(-offset, 0, 0);
     104                    }
     105                    mesher->SetTransform(trans);
     106                } else if (plane == DataSet::PLANE_XZ) {
     107                     vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     108                    trans->RotateWXYZ(-90, 1, 0, 0);
     109                    if (offset != 0.0) {
     110                        trans->Translate(0, -offset, 0);
     111                    }
     112                    mesher->SetTransform(trans);
     113                } else if (offset != 0.0) {
     114                    // XY with Z offset
     115                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     116                    trans->Translate(0, 0, -offset);
     117                    mesher->SetTransform(trans);
     118                }
    92119                mesher->SetInput(pd);
    93120                mesher->ReleaseDataFlagOn();
    94                 _pdMapper->SetInputConnection(mesher->GetOutputPort());
    95 #if defined(DEBUG) && defined(WANT_TRACE)
    96121                mesher->Update();
    97122                vtkPolyData *outpd = mesher->GetOutput();
     
    101126                      outpd->GetNumberOfPolys(),
    102127                      outpd->GetNumberOfStrips());
    103 #endif
     128                if (outpd->GetNumberOfPolys() == 0) {
     129                    WARN("Delaunay2D mesher failed");
     130                    _pdMapper->SetInput(pd);
     131                } else {
     132                    _pdMapper->SetInputConnection(mesher->GetOutputPort());
     133                }
    104134            } else {
    105135                vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New();
    106136                mesher->SetInput(pd);
    107137                mesher->ReleaseDataFlagOn();
    108                 // Delaunay3D returns an UnstructuredGrid, so feed it through a surface filter
    109                 // to get the grid boundary as a PolyData
    110                 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    111                 gf->UseStripsOn();
    112                 gf->SetInputConnection(mesher->GetOutputPort());
    113                 gf->ReleaseDataFlagOn();
    114                 _pdMapper->SetInputConnection(gf->GetOutputPort());
    115             }
     138                mesher->Update();
     139                vtkUnstructuredGrid *grid = mesher->GetOutput();
     140                TRACE("Delaunay3D Cells: %d",
     141                      grid->GetNumberOfCells());
     142                if (grid->GetNumberOfCells() == 0) {
     143                    WARN("Delaunay3D mesher failed");
     144                    _pdMapper->SetInput(pd);
     145                } else {
     146                    // Delaunay3D returns an UnstructuredGrid, so feed it
     147                    // through a surface filter to get the grid boundary
     148                    // as a PolyData
     149                    vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
     150                    gf->UseStripsOn();
     151                    gf->SetInputConnection(mesher->GetOutputPort());
     152                    gf->ReleaseDataFlagOn();
     153                    _pdMapper->SetInputConnection(gf->GetOutputPort());
     154                }
     155             }
    116156        } else {
    117157            // DataSet is a vtkPolyData with lines and/or polygons
  • trunk/packages/vizservers/vtkvis/RpPolyData.h

    r2328 r2423  
    2222 * \brief VTK Mesh (Polygon data)
    2323 *
    24  * The DataSet must be a PolyData object
     24 * This class creates a boundary mesh of a DataSet
    2525 */
    2626class PolyData : public VtkGraphicsObject {
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp

    r2402 r2423  
    1515#include <vtkImageData.h>
    1616#include <vtkLookupTable.h>
     17#include <vtkTransform.h>
    1718#include <vtkDelaunay2D.h>
    1819#include <vtkDelaunay3D.h>
     
    8485            pd->GetNumberOfStrips() == 0) {
    8586            // DataSet is a point cloud
    86             if (_dataSet->is2D()) {
     87            DataSet::PrincipalPlane plane;
     88            double offset;
     89            if (_dataSet->is2D(&plane, &offset)) {
    8790#ifdef MESH_POINT_CLOUDS
    8891                vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
     92                if (plane == DataSet::PLANE_ZY) {
     93                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     94                    trans->RotateWXYZ(90, 0, 1, 0);
     95                    if (offset != 0.0) {
     96                        trans->Translate(-offset, 0, 0);
     97                    }
     98                    mesher->SetTransform(trans);
     99                } else if (plane == DataSet::PLANE_XZ) {
     100                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     101                    trans->RotateWXYZ(-90, 1, 0, 0);
     102                    if (offset != 0.0) {
     103                        trans->Translate(0, -offset, 0);
     104                    }
     105                    mesher->SetTransform(trans);
     106                } else if (offset != 0.0) {
     107                    // XY with Z offset
     108                    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     109                    trans->Translate(0, 0, -offset);
     110                    mesher->SetTransform(trans);
     111                }
    89112                mesher->SetInput(pd);
    90                 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    91                 gf->SetInputConnection(mesher->GetOutputPort());
    92                 _dsMapper->SetInputConnection(gf->GetOutputPort());
     113                _dsMapper->SetInputConnection(mesher->GetOutputPort());
    93114#else
    94115                vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New();
     116                vtkSmartPointer<vtkExtractVOI> slicer = vtkSmartPointer<vtkExtractVOI>::New();
    95117                splatter->SetInput(pd);
    96118                int dims[3];
    97119                splatter->GetSampleDimensions(dims);
    98120                TRACE("Sample dims: %d %d %d", dims[0], dims[1], dims[2]);
    99                 dims[2] = 3;
     121                if (plane == DataSet::PLANE_ZY) {
     122                    dims[0] = 3;
     123                    slicer->SetVOI(1, 1, 0, dims[1]-1, 0, dims[1]-1);
     124                } else if (plane == DataSet::PLANE_XZ) {
     125                    dims[1] = 3;
     126                    slicer->SetVOI(0, dims[0]-1, 1, 1, 0, dims[2]-1);
     127                } else {
     128                    dims[2] = 3;
     129                    slicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1);
     130                }
    100131                splatter->SetSampleDimensions(dims);
    101132                double bounds[6];
     
    106137                      bounds[2], bounds[3],
    107138                      bounds[4], bounds[5]);
    108                 vtkSmartPointer<vtkExtractVOI> slicer = vtkSmartPointer<vtkExtractVOI>::New();
    109139                slicer->SetInputConnection(splatter->GetOutputPort());
    110                 slicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1);
    111140                slicer->SetSampleRate(1, 1, 1);
    112141                vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.h

    r2402 r2423  
    2323/**
    2424 * \brief Color-mapped plot of data set
    25  *
    26  * Currently the DataSet must be image data (2D uniform grid)
    2725 */
    2826class PseudoColor : public VtkGraphicsObject {
  • trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp

    r2404 r2423  
    66 */
    77
     8#include <cassert>
    89#include <cstring>
    910#include <cfloat>
     
    162163}
    163164
     165void DataSet::setDefaultArrays()
     166{
     167    if (_dataSet->GetPointData() != NULL &&
     168        _dataSet->GetPointData()->GetScalars() == NULL &&
     169        _dataSet->GetPointData()->GetNumberOfArrays() > 0) {
     170        for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {
     171            if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) {
     172                TRACE("Setting point scalars to '%s'", _dataSet->GetPointData()->GetArrayName(i));
     173                _dataSet->GetPointData()->SetActiveScalars(_dataSet->GetPointData()->GetArrayName(i));
     174                break;
     175            }
     176        }
     177    }
     178    if (_dataSet->GetPointData() != NULL &&
     179        _dataSet->GetPointData()->GetVectors() == NULL &&
     180        _dataSet->GetPointData()->GetNumberOfArrays() > 0) {
     181        for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) {
     182            if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) {
     183                TRACE("Setting point vectors to '%s'", _dataSet->GetPointData()->GetArrayName(i));
     184                _dataSet->GetPointData()->SetActiveVectors(_dataSet->GetPointData()->GetArrayName(i));
     185                break;
     186            }
     187        }
     188    }
     189    if (_dataSet->GetCellData() != NULL &&
     190        _dataSet->GetCellData()->GetScalars() == NULL &&
     191        _dataSet->GetCellData()->GetNumberOfArrays() > 0) {
     192        for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {
     193            if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) {
     194                TRACE("Setting cell scalars to '%s'", _dataSet->GetCellData()->GetArrayName(i));
     195                _dataSet->GetCellData()->SetActiveScalars(_dataSet->GetCellData()->GetArrayName(i));
     196                break;
     197            }
     198        }
     199    }
     200    if (_dataSet->GetCellData() != NULL &&
     201        _dataSet->GetCellData()->GetVectors() == NULL &&
     202        _dataSet->GetCellData()->GetNumberOfArrays() > 0) {
     203        for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) {
     204            if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) {
     205                TRACE("Setting cell vectors to '%s'", _dataSet->GetCellData()->GetArrayName(i));
     206                _dataSet->GetCellData()->SetActiveVectors(_dataSet->GetCellData()->GetArrayName(i));
     207                break;
     208            }
     209        }
     210    }
     211}
     212
    164213/**
    165214 * \brief Read dataset using supplied reader
     
    183232        ERROR("No lookup table should be specified in DataSets");
    184233    }
     234
     235    setDefaultArrays();
    185236
    186237#ifdef WANT_TRACE
     
    205256        ERROR("No lookup table should be specified in DataSets");
    206257    }
     258
     259    setDefaultArrays();
    207260
    208261#ifdef WANT_TRACE
     
    250303 * \brief Does DataSet lie in the XY plane (z = 0)
    251304 */
    252 bool DataSet::is2D() const
     305bool DataSet::isXY() const
    253306{
    254307    double bounds[6];
    255308    getBounds(bounds);
    256309    return (bounds[4] == 0. && bounds[4] == bounds[5]);
     310}
     311
     312/**
     313 * \brief Returns the dimensionality of the AABB
     314 */
     315int DataSet::numDimensions() const
     316{
     317    double bounds[6];
     318    getBounds(bounds);
     319    int numDims = 0;
     320    if (bounds[0] != bounds[1])
     321        numDims++;
     322    if (bounds[2] != bounds[3])
     323        numDims++;
     324    if (bounds[4] != bounds[5])
     325        numDims++;
     326
     327    return numDims;
     328}
     329
     330/**
     331 * \brief Determines if DataSet lies in a principal axis plane
     332 * and if so, returns the plane normal and offset from origin
     333 */
     334bool DataSet::is2D(DataSet::PrincipalPlane *plane, double *offset) const
     335{
     336    double bounds[6];
     337    getBounds(bounds);
     338    if (bounds[4] == bounds[5]) {
     339        // Z = 0, XY plane
     340        if (plane != NULL) {
     341            *plane = PLANE_XY;
     342        }
     343        if (offset != NULL)
     344            *offset = bounds[4];
     345        return true;
     346    } else if (bounds[0] == bounds[1]) {
     347        // X = 0, ZY plane
     348        if (plane != NULL) {
     349            *plane = PLANE_ZY;
     350        }
     351        if (offset != NULL)
     352            *offset = bounds[0];
     353        return true;
     354    } else if (bounds[2] == bounds[3]) {
     355        // Y = 0, XZ plane
     356        if (plane != NULL) {
     357            *plane = PLANE_XZ;
     358         }
     359        if (offset != NULL)
     360            *offset = bounds[2];
     361        return true;
     362    }
     363    return false;
     364}
     365
     366/**
     367 * \brief Determines a principal plane with the
     368 * largest two dimensions of the AABB
     369 */
     370DataSet::PrincipalPlane DataSet::principalPlane() const
     371{
     372    double bounds[6];
     373    getBounds(bounds);
     374    double xlen = bounds[1] - bounds[0];
     375    double ylen = bounds[3] - bounds[2];
     376    double zlen = bounds[5] - bounds[4];
     377    if (zlen <= xlen && zlen <= ylen) {
     378        return PLANE_XY;
     379    } else if (xlen <= ylen && xlen <= zlen) {
     380        return PLANE_ZY;
     381    } else {
     382        return PLANE_XZ;
     383    }
    257384}
    258385
     
    324451void DataSet::getScalarRange(double minmax[2]) const
    325452{
    326     _dataSet->GetScalarRange(minmax);
     453    if (_dataSet == NULL)
     454        return;
     455    if (_dataSet->GetPointData() != NULL &&
     456        _dataSet->GetPointData()->GetScalars() != NULL) {
     457        _dataSet->GetPointData()->GetScalars()->GetRange(minmax, -1);
     458    } else if (_dataSet->GetCellData() != NULL &&
     459               _dataSet->GetCellData()->GetScalars() != NULL) {
     460        _dataSet->GetCellData()->GetScalars()->GetRange(minmax, -1);
     461    }
    327462}
    328463
     
    419554 * \return the value of the nearest point or 0 if no scalar data available
    420555 */
    421 double DataSet::getDataValue(double x, double y, double z) const
     556bool DataSet::getScalarValue(double x, double y, double z, double *value) const
    422557{
    423558    if (_dataSet == NULL)
    424         return 0;
     559        return false;
    425560    if (_dataSet->GetPointData() == NULL ||
    426561        _dataSet->GetPointData()->GetScalars() == NULL) {
    427         return 0.0;
     562        return false;
    428563    }
    429564    vtkIdType pt = _dataSet->FindPoint(x, y, z);
    430     return _dataSet->GetPointData()->GetScalars()->GetComponent(pt, 0);
    431 }
     565    if (pt < 0)
     566        return false;
     567    *value = _dataSet->GetPointData()->GetScalars()->GetComponent(pt, 0);
     568    return true;
     569}
     570
     571/**
     572 * \brief Get nearest vector data value given world coordinates x,y,z
     573 *
     574 * Note: no interpolation is performed on data
     575 *
     576 * \param[in] x World x coordinate to probe
     577 * \param[in] y World y coordinate to probe
     578 * \param[in] z World z coordinate to probe
     579 * \param[out] vector On success, contains the data values
     580 * \return boolean indicating success or failure
     581 */
     582bool DataSet::getVectorValue(double x, double y, double z, double vector[3]) const
     583{
     584    if (_dataSet == NULL)
     585        return false;
     586    if (_dataSet->GetPointData() == NULL ||
     587        _dataSet->GetPointData()->GetVectors() == NULL) {
     588        return false;
     589    }
     590    vtkIdType pt = _dataSet->FindPoint(x, y, z);
     591    if (pt < 0)
     592        return false;
     593    assert(_dataSet->GetPointData()->GetVectors()->GetNumberOfComponents() == 3);
     594    _dataSet->GetPointData()->GetVectors()->GetTuple(pt, vector);
     595    return true;
     596}
  • trunk/packages/vizservers/vtkvis/RpVtkDataSet.h

    r2404 r2423  
    2424class DataSet {
    2525public:
     26    enum PrincipalPlane {
     27        PLANE_XY,
     28        PLANE_ZY,
     29        PLANE_XZ
     30    };
    2631    DataSet(const std::string& name);
    2732    virtual ~DataSet();
     
    3742    vtkDataSet *copyData(vtkDataSet *ds);
    3843
    39     bool is2D() const;
     44    bool isXY() const;
     45
     46    int numDimensions() const;
     47
     48    bool is2D(PrincipalPlane *plane = NULL, double *offset = NULL) const;
     49
     50    PrincipalPlane principalPlane() const;
    4051
    4152    const std::string& getName() const;
     
    5970    void getCellSizeRange(double minmax[6], double *average) const;
    6071
    61     double getDataValue(double x, double y, double z) const;
     72    bool getScalarValue(double x, double y, double z, double *value) const;
     73
     74    bool getVectorValue(double x, double y, double z, double vector[3]) const;
    6275
    6376    void setVisibility(bool state);
     
    6780private:
    6881    DataSet();
     82
     83    void setDefaultArrays();
    6984    void print() const;
    7085
  • trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h

    r2404 r2423  
    4646        _opacity(1.0),
    4747        _edgeWidth(1.0f),
     48        _pointSize(1.0f),
    4849        _lighting(true),
    4950        _cullFace(CULL_BACK),
     
    607608     * \brief Set pixel width of edges
    608609     *
    609      * NOTE: May be a no-op if OpenGL implementation doesn't support fat lines
     610     * NOTE: May be a no-op if OpenGL implementation doesn't support wide lines
    610611     */
    611612    virtual void setEdgeWidth(float width)
     
    621622                if (vtkActor::SafeDownCast(prop) != NULL) {
    622623                    vtkActor::SafeDownCast(prop)->GetProperty()->SetLineWidth(width);
     624                }
     625            }
     626        }
     627    }
     628
     629    /**
     630     * \brief Set point size
     631     *
     632     * NOTE: May be a no-op if OpenGL implementation doesn't support wide points
     633     */
     634    virtual void setPointSize(float size)
     635    {
     636        _pointSize = size;
     637        if (getActor() != NULL) {
     638            getActor()->GetProperty()->SetPointSize(size);
     639        } else if (getAssembly() != NULL) {
     640            vtkProp3DCollection *props = getAssembly()->GetParts();
     641            vtkProp3D *prop;
     642            props->InitTraversal();
     643            while ((prop = props->GetNextProp3D()) != NULL) {
     644                if (vtkActor::SafeDownCast(prop) != NULL) {
     645                    vtkActor::SafeDownCast(prop)->GetProperty()->SetPointSize(size);
    623646                }
    624647            }
     
    748771    float _edgeColor[3];
    749772    float _edgeWidth;
     773    float _pointSize;
    750774    bool _lighting;
    751775    CullFace _cullFace;
  • trunk/packages/vizservers/vtkvis/RpVtkRenderServer.cpp

    r2381 r2423  
    7070    if (g_renderer->getCameraMode() == Renderer::IMAGE) {
    7171        double xywh[4];
    72         g_renderer->getScreenWorldCoords(xywh);
     72        g_renderer->getCameraZoomRegion(xywh);
    7373        std::ostringstream oss;
    7474        oss.precision(12);
     
    7777            << std::scientific
    7878            << xywh[0] << " "
    79             << (xywh[1] + xywh[3]) << " "
    80             << (xywh[0] + xywh[2]) << " "
    81             << xywh[1] << "} -bytes";
     79            << xywh[1] << " "
     80            << xywh[2] << " "
     81            << xywh[3] << "} -bytes";
    8282
    8383#ifdef RENDER_TARGA
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2404 r2423  
    2424#include <vtkCharArray.h>
    2525#include <vtkAxisActor2D.h>
     26#include <vtkCubeAxesActor.h>
    2627#ifdef USE_CUSTOM_AXES
    27 #include <vtkRpCubeAxesActor2D.h>
     28#include "vtkRpCubeAxesActor2D.h"
    2829#else
    29 #include <vtkCubeAxesActor.h>
    3030#include <vtkCubeAxesActor2D.h>
    3131#endif
     
    5353Renderer::Renderer() :
    5454    _needsRedraw(true),
    55     _windowWidth(320),
    56     _windowHeight(320),
     55    _windowWidth(500),
     56    _windowHeight(500),
     57    _imgCameraPlane(PLANE_XY),
     58    _imgCameraOffset(0),
    5759    _cameraZoomRatio(1),
    5860    _useCumulativeRange(true),
     
    657659}
    658660
     661void Renderer::getDataSetNames(std::vector<std::string>& names)
     662{
     663    names.clear();
     664    for (DataSetHashmap::iterator itr = _dataSets.begin();
     665         itr != _dataSets.end(); ++itr) {
     666        names.push_back(itr->second->getName());
     667    }
     668}
     669
    659670/**
    660671 * \brief Find the DataSet for the given DataSetId key
     
    850861    _cubeAxesActor2D->GetXAxisActor2D()->AdjustLabelsOn();
    851862    _cubeAxesActor2D->GetYAxisActor2D()->AdjustLabelsOn();
     863    _cubeAxesActor2D->GetZAxisActor2D()->AdjustLabelsOn();
    852864
    853865#ifdef USE_CUSTOM_AXES
     
    869881    _cubeAxesActor2D->GetYAxisActor2D()->GetLabelTextProperty()->ItalicOff();
    870882    _cubeAxesActor2D->GetYAxisActor2D()->GetLabelTextProperty()->ShadowOff();
     883
     884    //_cubeAxesActor2D->GetZAxisActor2D()->SizeFontRelativeToAxisOn();
     885    _cubeAxesActor2D->GetZAxisActor2D()->GetTitleTextProperty()->BoldOn();
     886    _cubeAxesActor2D->GetZAxisActor2D()->GetTitleTextProperty()->ItalicOff();
     887    _cubeAxesActor2D->GetZAxisActor2D()->GetTitleTextProperty()->ShadowOn();
     888    _cubeAxesActor2D->GetZAxisActor2D()->GetLabelTextProperty()->BoldOff();
     889    _cubeAxesActor2D->GetZAxisActor2D()->GetLabelTextProperty()->ItalicOff();
     890    _cubeAxesActor2D->GetZAxisActor2D()->GetLabelTextProperty()->ShadowOff();
    871891#else
    872892    _cubeAxesActor2D->GetAxisTitleTextProperty()->BoldOn();
     
    14591479 * \brief Create a new Contour2D and associate it with the named DataSet
    14601480 */
    1461 void Renderer::addContour2D(const DataSetId& id, int numContours)
     1481bool Renderer::addContour2D(const DataSetId& id, int numContours)
    14621482{
    14631483    DataSetHashmap::iterator itr;
     
    14721492    if (itr == _dataSets.end()) {
    14731493        ERROR("Unknown dataset %s", id.c_str());
    1474         return;
     1494        return false;
    14751495    }
    14761496
     
    14851505
    14861506        Contour2D *contour = new Contour2D(numContours);
    1487         _contour2Ds[dsID] = contour;
    1488 
     1507 
    14891508        contour->setDataSet(ds,
    14901509                            _useCumulativeRange,
     
    14931512                            _cumulativeVectorComponentRange);
    14941513
    1495         _renderer->AddViewProp(contour->getProp());
     1514        if (contour->getProp() == NULL) {
     1515            delete contour;
     1516            return false;
     1517        } else {
     1518            _renderer->AddViewProp(contour->getProp());
     1519        }
     1520
     1521        _contour2Ds[dsID] = contour;
    14961522    } while (doAll && ++itr != _dataSets.end());
    14971523
    14981524    initCamera();
    14991525    _needsRedraw = true;
     1526    return true;
    15001527}
    15011528
     
    15031530 * \brief Create a new Contour2D and associate it with the named DataSet
    15041531 */
    1505 void Renderer::addContour2D(const DataSetId& id, const std::vector<double>& contours)
     1532bool Renderer::addContour2D(const DataSetId& id, const std::vector<double>& contours)
    15061533{
    15071534    DataSetHashmap::iterator itr;
     
    15161543    if (itr == _dataSets.end()) {
    15171544        ERROR("Unknown dataset %s", id.c_str());
    1518         return;
     1545        return false;
    15191546    }
    15201547
     
    15291556
    15301557        Contour2D *contour = new Contour2D(contours);
    1531         _contour2Ds[dsID] = contour;
    15321558
    15331559        contour->setDataSet(ds,
     
    15371563                            _cumulativeVectorComponentRange);
    15381564
    1539         _renderer->AddViewProp(contour->getProp());
     1565        if (contour->getProp() == NULL) {
     1566            delete contour;
     1567            return false;
     1568        } else {
     1569            _renderer->AddViewProp(contour->getProp());
     1570        }
     1571
     1572        _contour2Ds[dsID] = contour;
    15401573    } while (doAll && ++itr != _dataSets.end());
    15411574
    15421575    initCamera();
    15431576    _needsRedraw = true;
     1577    return true;
    15441578}
    15451579
     
    18941928 * \brief Create a new Contour3D and associate it with the named DataSet
    18951929 */
    1896 void Renderer::addContour3D(const DataSetId& id, int numContours)
     1930bool Renderer::addContour3D(const DataSetId& id, int numContours)
    18971931{
    18981932    DataSetHashmap::iterator itr;
     
    19071941    if (itr == _dataSets.end()) {
    19081942        ERROR("Unknown dataset %s", id.c_str());
    1909         return;
     1943        return false;
    19101944    }
    19111945
     
    19201954
    19211955        Contour3D *contour = new Contour3D(numContours);
    1922         _contour3Ds[dsID] = contour;
    19231956
    19241957        contour->setDataSet(ds,
     
    19281961                            _cumulativeVectorComponentRange);
    19291962
    1930         _renderer->AddViewProp(contour->getProp());
     1963        if (contour->getProp() == NULL) {
     1964            delete contour;
     1965            return false;
     1966        } else {
     1967            _renderer->AddViewProp(contour->getProp());
     1968        }
     1969
     1970        _contour3Ds[dsID] = contour;
    19311971    } while (doAll && ++itr != _dataSets.end());
    19321972
     
    19351975    initCamera();
    19361976    _needsRedraw = true;
     1977    return true;
    19371978}
    19381979
     
    19401981 * \brief Create a new Contour3D and associate it with the named DataSet
    19411982 */
    1942 void Renderer::addContour3D(const DataSetId& id,const std::vector<double>& contours)
     1983bool Renderer::addContour3D(const DataSetId& id,const std::vector<double>& contours)
    19431984{
    19441985    DataSetHashmap::iterator itr;
     
    19531994    if (itr == _dataSets.end()) {
    19541995        ERROR("Unknown dataset %s", id.c_str());
    1955         return;
     1996        return false;
    19561997    }
    19571998
     
    19662007
    19672008        Contour3D *contour = new Contour3D(contours);
    1968         _contour3Ds[dsID] = contour;
    19692009
    19702010        contour->setDataSet(ds,
     
    19742014                            _cumulativeVectorComponentRange);
    19752015
    1976         _renderer->AddViewProp(contour->getProp());
     2016        if (contour->getProp() == NULL) {
     2017            delete contour;
     2018            return false;
     2019        } else {
     2020            _renderer->AddViewProp(contour->getProp());
     2021        }
     2022
     2023        _contour3Ds[dsID] = contour;
    19772024    } while (doAll && ++itr != _dataSets.end());
    19782025
     
    19812028    initCamera();
    19822029    _needsRedraw = true;
     2030    return true;
    19832031}
    19842032
     
    24532501 * \brief Create a new Glyphs and associate it with the named DataSet
    24542502 */
    2455 void Renderer::addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape)
     2503bool Renderer::addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape)
    24562504{
    24572505    DataSetHashmap::iterator itr;
     
    24662514    if (itr == _dataSets.end()) {
    24672515        ERROR("Unknown dataset %s", id.c_str());
    2468         return;
     2516        return false;
    24692517    }
    24702518
     
    24792527
    24802528        Glyphs *glyphs = new Glyphs(shape);
    2481         _glyphs[dsID] = glyphs;
    24822529
    24832530        glyphs->setDataSet(ds,
     
    24872534                           _cumulativeVectorComponentRange);
    24882535
    2489         _renderer->AddViewProp(glyphs->getProp());
     2536        if (glyphs->getProp() == NULL) {
     2537            delete glyphs;
     2538            return false;
     2539        } else {
     2540            _renderer->AddViewProp(glyphs->getProp());
     2541        }
     2542
     2543        _glyphs[dsID] = glyphs;
    24902544    } while (doAll && ++itr != _dataSets.end());
    24912545
     
    24952549
    24962550    _needsRedraw = true;
     2551    return true;
    24972552}
    24982553
     
    30223077 * \brief Create a new HeightMap and associate it with the named DataSet
    30233078 */
    3024 void Renderer::addHeightMap(const DataSetId& id, int numContours)
     3079bool Renderer::addHeightMap(const DataSetId& id, int numContours, double heightScale)
    30253080{
    30263081    DataSetHashmap::iterator itr;
     
    30353090    if (itr == _dataSets.end()) {
    30363091        ERROR("Unknown dataset %s", id.c_str());
    3037         return;
     3092        return false;
    30383093    }
    30393094
     
    30473102        }
    30483103
    3049         HeightMap *hmap = new HeightMap(numContours);
    3050         _heightMaps[dsID] = hmap;
     3104        HeightMap *hmap = new HeightMap(numContours, heightScale);
    30513105
    30523106        hmap->setDataSet(ds,
     
    30563110                         _cumulativeVectorComponentRange);
    30573111
    3058         _renderer->AddViewProp(hmap->getProp());
     3112        if (hmap->getProp() == NULL) {
     3113            delete hmap;
     3114            return false;
     3115        } else {
     3116            _renderer->AddViewProp(hmap->getProp());
     3117        }
     3118
     3119        _heightMaps[dsID] = hmap;
    30593120    } while (doAll && ++itr != _dataSets.end());
    30603121
     
    30643125
    30653126    _needsRedraw = true;
     3127    return true;
    30663128}
    30673129
     
    30693131 * \brief Create a new HeightMap and associate it with the named DataSet
    30703132 */
    3071 void Renderer::addHeightMap(const DataSetId& id, const std::vector<double>& contours)
     3133bool Renderer::addHeightMap(const DataSetId& id, const std::vector<double>& contours, double heightScale)
    30723134{
    30733135    DataSetHashmap::iterator itr;
     
    30823144    if (itr == _dataSets.end()) {
    30833145        ERROR("Unknown dataset %s", id.c_str());
    3084         return;
     3146        return false;
    30853147    }
    30863148
     
    30943156        }
    30953157
    3096         HeightMap *hmap = new HeightMap(contours);
    3097         _heightMaps[dsID] = hmap;
     3158        HeightMap *hmap = new HeightMap(contours, heightScale);
    30983159
    30993160        hmap->setDataSet(ds,
     
    31033164                         _cumulativeVectorComponentRange);
    31043165
    3105         _renderer->AddViewProp(hmap->getProp());
     3166        if (hmap->getProp() == NULL) {
     3167            delete hmap;
     3168            return false;
     3169        } else {
     3170            _renderer->AddViewProp(hmap->getProp());
     3171        }
     3172
     3173        _heightMaps[dsID] = hmap;
    31063174    } while (doAll && ++itr != _dataSets.end());
    31073175
     
    31113179
    31123180    _needsRedraw = true;
     3181    return true;
    31133182}
    31143183
     
    33683437 * \brief Set the number of equally spaced contour isolines for the given DataSet
    33693438 */
    3370 void Renderer::setHeightMapContours(const DataSetId& id, int numContours)
     3439void Renderer::setHeightMapNumContours(const DataSetId& id, int numContours)
    33713440{
    33723441    HeightMapHashmap::iterator itr;
     
    33863455
    33873456    do {
    3388         itr->second->setContours(numContours);
     3457        itr->second->setNumContours(numContours);
    33893458    } while (doAll && ++itr != _heightMaps.end());
    33903459
     
    34683537    do {
    34693538        itr->second->setVisibility(state);
     3539    } while (doAll && ++itr != _heightMaps.end());
     3540
     3541    _needsRedraw = true;
     3542}
     3543
     3544/**
     3545 * \brief Set wireframe rendering for the specified DataSet
     3546 */
     3547void Renderer::setHeightMapWireframe(const DataSetId& id, bool state)
     3548{
     3549    HeightMapHashmap::iterator itr;
     3550
     3551    bool doAll = false;
     3552
     3553    if (id.compare("all") == 0) {
     3554        itr = _heightMaps.begin();
     3555        doAll = true;
     3556    } else {
     3557        itr = _heightMaps.find(id);
     3558    }
     3559    if (itr == _heightMaps.end()) {
     3560        ERROR("HeightMap not found: %s", id.c_str());
     3561        return;
     3562    }
     3563
     3564    do {
     3565        itr->second->setWireframe(state);
    34703566    } while (doAll && ++itr != _heightMaps.end());
    34713567
     
    35603656 * \brief Turn on/off rendering height map contour lines for the given DataSet
    35613657 */
    3562 void Renderer::setHeightMapContourVisibility(const DataSetId& id, bool state)
     3658void Renderer::setHeightMapContourLineVisibility(const DataSetId& id, bool state)
    35633659{
    35643660    HeightMapHashmap::iterator itr;
     
    35783674
    35793675    do {
    3580         itr->second->setContourVisibility(state);
     3676        itr->second->setContourLineVisibility(state);
     3677    } while (doAll && ++itr != _heightMaps.end());
     3678
     3679    _needsRedraw = true;
     3680}
     3681
     3682/**
     3683 * \brief Turn on/off rendering height map colormap surface for the given DataSet
     3684 */
     3685void Renderer::setHeightMapContourSurfaceVisibility(const DataSetId& id, bool state)
     3686{
     3687    HeightMapHashmap::iterator itr;
     3688
     3689    bool doAll = false;
     3690
     3691    if (id.compare("all") == 0) {
     3692        itr = _heightMaps.begin();
     3693        doAll = true;
     3694    } else {
     3695        itr = _heightMaps.find(id);
     3696    }
     3697    if (itr == _heightMaps.end()) {
     3698        ERROR("HeightMap not found: %s", id.c_str());
     3699        return;
     3700    }
     3701
     3702    do {
     3703        itr->second->setContourSurfaceVisibility(state);
    35813704    } while (doAll && ++itr != _heightMaps.end());
    35823705
     
    36703793 * \brief Create a new LIC and associate it with the named DataSet
    36713794 */
    3672 void Renderer::addLIC(const DataSetId& id)
     3795bool Renderer::addLIC(const DataSetId& id)
    36733796{
    36743797    DataSetHashmap::iterator itr;
     
    36833806    if (itr == _dataSets.end()) {
    36843807        ERROR("Unknown dataset %s", id.c_str());
    3685         return;
     3808        return false;
    36863809    }
    36873810
     
    37113834    initCamera();
    37123835    _needsRedraw = true;
     3836    return true;
    37133837}
    37143838
     
    41034227 * \brief Create a new Molecule and associate it with the named DataSet
    41044228 */
    4105 void Renderer::addMolecule(const DataSetId& id)
     4229bool Renderer::addMolecule(const DataSetId& id)
    41064230{
    41074231    DataSetHashmap::iterator itr;
     
    41164240    if (itr == _dataSets.end()) {
    41174241        ERROR("Unknown dataset %s", id.c_str());
    4118         return;
     4242        return false;
    41194243    }
    41204244
     
    41404264    initCamera();
    41414265    _needsRedraw = true;
     4266    return true;
    41424267}
    41434268
     
    46114736 * \brief Create a new PolyData and associate it with the named DataSet
    46124737 */
    4613 void Renderer::addPolyData(const DataSetId& id)
     4738bool Renderer::addPolyData(const DataSetId& id)
    46144739{
    46154740    DataSetHashmap::iterator itr;
     
    46244749    if (itr == _dataSets.end()) {
    46254750        ERROR("Unknown dataset %s", id.c_str());
    4626         return;
     4751        return false;
    46274752    }
    46284753
     
    46484773    initCamera();
    46494774    _needsRedraw = true;
     4775    return true;
    46504776}
    46514777
     
    49715097
    49725098/**
    4973  * \brief Set wireframe rendering for the specified DataSet
    4974  */
    4975 void Renderer::setPolyDataWireframe(const DataSetId& id, bool state)
     5099 * \brief Set the point size for the specified DataSet (may be a no-op)
     5100 *
     5101 * If the OpenGL implementation/hardware does not support wide points,
     5102 * this function may not have an effect.
     5103 */
     5104void Renderer::setPolyDataPointSize(const DataSetId& id, float size)
    49765105{
    49775106    PolyDataHashmap::iterator itr;
     
    49915120
    49925121    do {
     5122        itr->second->setPointSize(size);
     5123    } while (doAll && ++itr != _polyDatas.end());
     5124
     5125    _needsRedraw = true;
     5126}
     5127
     5128/**
     5129 * \brief Set wireframe rendering for the specified DataSet
     5130 */
     5131void Renderer::setPolyDataWireframe(const DataSetId& id, bool state)
     5132{
     5133    PolyDataHashmap::iterator itr;
     5134
     5135    bool doAll = false;
     5136
     5137    if (id.compare("all") == 0) {
     5138        itr = _polyDatas.begin();
     5139        doAll = true;
     5140    } else {
     5141        itr = _polyDatas.find(id);
     5142    }
     5143    if (itr == _polyDatas.end()) {
     5144        ERROR("PolyData not found: %s", id.c_str());
     5145        return;
     5146    }
     5147
     5148    do {
    49935149        itr->second->setWireframe(state);
    49945150    } while (doAll && ++itr != _polyDatas.end());
     
    50275183 * \brief Create a new PseudoColor rendering for the specified DataSet
    50285184 */
    5029 void Renderer::addPseudoColor(const DataSetId& id)
     5185bool Renderer::addPseudoColor(const DataSetId& id)
    50305186{
    50315187    DataSetHashmap::iterator itr;
     
    50405196    if (itr == _dataSets.end()) {
    50415197        ERROR("Unknown dataset %s", id.c_str());
    5042         return;
     5198        return false;
    50435199    }
    50445200
     
    50655221    initCamera();
    50665222    _needsRedraw = true;
     5223    return true;
    50675224}
    50685225
     
    54615618 * \brief Create a new Streamlines and associate it with the named DataSet
    54625619 */
    5463 void Renderer::addStreamlines(const DataSetId& id)
     5620bool Renderer::addStreamlines(const DataSetId& id)
    54645621{
    54655622    DataSetHashmap::iterator itr;
     
    54745631    if (itr == _dataSets.end()) {
    54755632        ERROR("Unknown dataset %s", id.c_str());
    5476         return;
     5633        return false;
    54775634    }
    54785635
     
    55005657    initCamera();
    55015658    _needsRedraw = true;
     5659    return true;
    55025660}
    55035661
     
    62306388 * \brief Create a new Volume and associate it with the named DataSet
    62316389 */
    6232 void Renderer::addVolume(const DataSetId& id)
     6390bool Renderer::addVolume(const DataSetId& id)
    62336391{
    62346392    DataSetHashmap::iterator itr;
     
    62436401    if (itr == _dataSets.end()) {
    62446402        ERROR("Unknown dataset %s", id.c_str());
    6245         return;
     6403        return false;
    62466404    }
    62476405
     
    62716429    initCamera();
    62726430    _needsRedraw = true;
     6431    return true;
    62736432}
    62746433
     
    66526811void Renderer::setWindowSize(int width, int height)
    66536812{
    6654     setViewAngle(height);
     6813    if (_windowWidth == width &&
     6814        _windowHeight == height)
     6815        return;
     6816
     6817    //setViewAngle(height);
    66556818
    66566819    // FIXME: Fix up panning on aspect change
     
    66916854    CameraMode origMode = _cameraMode;
    66926855    _cameraMode = mode;
     6856    resetAxes();
     6857
    66936858    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    66946859    switch (mode) {
     
    67196884        ERROR("Unkown camera mode: %d", mode);
    67206885    }
    6721     resetAxes();
    6722 
    67236886    _needsRedraw = true;
    67246887}
     
    71737336        setCameraZoomRegion(_imgWorldOrigin[0], _imgWorldOrigin[1],
    71747337                            _imgWorldDims[0], _imgWorldDims[1]);
    7175     } else if (_cameraMode == ORTHO) {
    7176         camera->Zoom(z); // Change ortho parallel scale (Dolly has no effect in ortho)
    7177         _renderer->ResetCameraClippingRange();
    7178     } else {
    7179         camera->Dolly(z); // Move camera forward/back
     7338    } else {
     7339        // Keep ortho and perspective modes in sync
     7340        // Move camera forward/back for perspective camera
     7341        camera->Dolly(z);
     7342        // Change ortho parallel scale
     7343        camera->SetParallelScale(camera->GetParallelScale()/z);
    71807344        _renderer->ResetCameraClippingRange();
    71817345        //computeScreenWorldCoords();
     
    71867350
    71877351    _needsRedraw = true;
     7352}
     7353
     7354/**
     7355 * \brief Set the pan/zoom using a corner and dimensions in pixel coordinates
     7356 *
     7357 * \param[in] x left pixel coordinate
     7358 * \param[in] y bottom  pixel coordinate (with y=0 at top of window)
     7359 * \param[in] width Width of zoom region in pixel coordinates
     7360 * \param[in] height Height of zoom region in pixel coordinates
     7361 */
     7362void Renderer::setCameraZoomRegionPixels(int x, int y, int width, int height)
     7363{
     7364    double wx, wy, ww, wh;
     7365
     7366    y = _windowHeight - y;
     7367    double pxToWorldX = _screenWorldCoords[2] / (double)_windowWidth;
     7368    double pxToWorldY = _screenWorldCoords[3] / (double)_windowHeight;
     7369
     7370    wx = _screenWorldCoords[0] + x * pxToWorldX;
     7371    wy = _screenWorldCoords[1] + y * pxToWorldY;
     7372    ww = abs(width) *  pxToWorldX;
     7373    wh = abs(height) * pxToWorldY;
     7374    setCameraZoomRegion(wx, wy, ww, wh);
     7375
     7376    TRACE("\npx: %d %d %d %d\nworld: %g %g %g %g",
     7377          x, y, width, height,
     7378          wx, wy, ww, wh);
    71887379}
    71897380
     
    72007391    double camPos[2];
    72017392
    7202     int pxOffsetX = 85;
    7203     int pxOffsetY = 75;
    7204     int outerGutter = 15;
     7393    int pxOffsetX = (int)(0.17 * (double)_windowWidth);
     7394    pxOffsetX = (pxOffsetX > 100 ? 100 : pxOffsetX);
     7395    int pxOffsetY = (int)(0.15 * (double)_windowHeight);
     7396    pxOffsetY = (pxOffsetY > 75 ? 75 : pxOffsetY);
     7397    int outerGutter = (int)(0.03 * (double)_windowWidth);
     7398    outerGutter = (outerGutter > 15 ? 15 : outerGutter);
    72057399
    72067400    int imgHeightPx = _windowHeight - pxOffsetY - outerGutter;
     
    72387432    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    72397433    camera->ParallelProjectionOn();
    7240     camera->SetPosition(camPos[0], camPos[1], 1);
    7241     camera->SetFocalPoint(camPos[0], camPos[1], 0);
    7242     camera->SetViewUp(0, 1, 0);
    72437434    camera->SetClippingRange(1, 2);
    72447435    // Half of world coordinate height of viewport (Documentation is wrong)
    72457436    camera->SetParallelScale(_windowHeight * pxToWorld / 2.0);
    72467437
    7247     // bottom
    7248     _cameraClipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0);
    7249     // left
    7250     _cameraClipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0);
    7251     // top
    7252     _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
    7253     // right
    7254     _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
    7255 
    7256     _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
    7257                                 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1], 0, 0);
     7438    if (_imgCameraPlane == PLANE_XY) {
     7439        // XY plane
     7440        camera->SetPosition(camPos[0], camPos[1], _imgCameraOffset + 1.);
     7441        camera->SetFocalPoint(camPos[0], camPos[1], _imgCameraOffset);
     7442        camera->SetViewUp(0, 1, 0);
     7443        // bottom
     7444        _cameraClipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0);
     7445        _cameraClipPlanes[0]->SetNormal(0, 1, 0);
     7446        // left
     7447        _cameraClipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0);
     7448        _cameraClipPlanes[1]->SetNormal(1, 0, 0);
     7449        // top
     7450        _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
     7451        _cameraClipPlanes[2]->SetNormal(0, -1, 0);
     7452        // right
     7453        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
     7454        _cameraClipPlanes[3]->SetNormal(-1, 0, 0);
     7455        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
     7456                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],
     7457                                    _imgCameraOffset, _imgCameraOffset);
     7458        _cubeAxesActor2D->XAxisVisibilityOn();
     7459        _cubeAxesActor2D->YAxisVisibilityOn();
     7460        _cubeAxesActor2D->ZAxisVisibilityOff();
     7461    } else if (_imgCameraPlane == PLANE_ZY) {
     7462        // ZY plane
     7463        camera->SetPosition(_imgCameraOffset - 1., camPos[1], camPos[0]);
     7464        camera->SetFocalPoint(_imgCameraOffset, camPos[1], camPos[0]);
     7465        camera->SetViewUp(0, 1, 0);
     7466        // bottom
     7467        _cameraClipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0);
     7468        _cameraClipPlanes[0]->SetNormal(0, 1, 0);
     7469        // left
     7470        _cameraClipPlanes[1]->SetOrigin(0, 0, _imgWorldOrigin[0]);
     7471        _cameraClipPlanes[1]->SetNormal(0, 0, 1);
     7472        // top
     7473        _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
     7474        _cameraClipPlanes[2]->SetNormal(0, -1, 0);
     7475        // right
     7476        _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + _imgWorldDims[0]);
     7477        _cameraClipPlanes[3]->SetNormal(0, 0, -1);
     7478        _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset,
     7479                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],
     7480                                    _imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0]);
     7481        _cubeAxesActor2D->XAxisVisibilityOff();
     7482        _cubeAxesActor2D->YAxisVisibilityOn();
     7483        _cubeAxesActor2D->ZAxisVisibilityOn();
     7484    } else {
     7485        // XZ plane
     7486        camera->SetPosition(camPos[0], _imgCameraOffset - 1., camPos[1]);
     7487        camera->SetFocalPoint(camPos[0], _imgCameraOffset, camPos[1]);
     7488        camera->SetViewUp(0, 0, 1);
     7489        // bottom
     7490        _cameraClipPlanes[0]->SetOrigin(0, 0, _imgWorldOrigin[1]);
     7491        _cameraClipPlanes[0]->SetNormal(0, 0, 1);
     7492        // left
     7493        _cameraClipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0);
     7494        _cameraClipPlanes[1]->SetNormal(1, 0, 0);
     7495        // top
     7496        _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + _imgWorldDims[1]);
     7497        _cameraClipPlanes[2]->SetNormal(0, 0, -1);
     7498        // right
     7499        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
     7500        _cameraClipPlanes[3]->SetNormal(-1, 0, 0);
     7501        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
     7502                                    _imgCameraOffset, _imgCameraOffset,
     7503                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1]);
     7504        _cubeAxesActor2D->XAxisVisibilityOn();
     7505        _cubeAxesActor2D->YAxisVisibilityOff();
     7506        _cubeAxesActor2D->ZAxisVisibilityOn();
     7507    }
    72587508
    72597509    // Compute screen world coordinates
     
    73477597    mat->Delete();
    73487598
    7349     _screenWorldCoords[0] = x0;
    7350     _screenWorldCoords[1] = y0;
    7351     _screenWorldCoords[2] = x1 - x0;
    7352     _screenWorldCoords[3] = y1 - y0;
     7599    if (_imgCameraPlane == PLANE_XZ) {
     7600        _screenWorldCoords[0] = x0;
     7601        _screenWorldCoords[1] = z0;
     7602        _screenWorldCoords[2] = x1 - x0;
     7603        _screenWorldCoords[3] = z1 - z0;
     7604    } else if (_imgCameraPlane == PLANE_ZY) {
     7605        _screenWorldCoords[0] = z0;
     7606        _screenWorldCoords[1] = y0;
     7607        _screenWorldCoords[2] = z1 - z0;
     7608        _screenWorldCoords[3] = y1 - y0;
     7609    } else {
     7610        // XY
     7611        _screenWorldCoords[0] = x0;
     7612        _screenWorldCoords[1] = y0;
     7613        _screenWorldCoords[2] = x1 - x0;
     7614        _screenWorldCoords[3] = y1 - y0;
     7615    }
    73537616}
    73547617
     
    74657728            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    74667729    }
    7467     for (int i = 0; i < 6; i++) {
    7468         if (i % 2 == 0) {
    7469             if (bounds[i] == DBL_MAX)
    7470                 bounds[i] = 0;
    7471         } else {
    7472             if (bounds[i] == -DBL_MAX)
    7473                 bounds[i] = 1;
     7730
     7731    for (int i = 0; i < 6; i += 2) {
     7732        if (bounds[i+1] < bounds[i]) {
     7733            bounds[i] = -0.5;
     7734            bounds[i+1] = 0.5;
    74747735        }
    74757736    }
     7737
     7738    int numDims = 0;
     7739    if (bounds[0] != bounds[1])
     7740        numDims++;
     7741    if (bounds[2] != bounds[3])
     7742        numDims++;
     7743    if (bounds[4] != bounds[5])
     7744        numDims++;
     7745
     7746    if (numDims == 0) {
     7747        bounds[0] -= .5;
     7748        bounds[1] += .5;
     7749        bounds[2] -= .5;
     7750        bounds[3] += .5;
     7751    }
     7752
    74767753    TRACE("Bounds: %g %g %g %g %g %g",
    74777754          bounds[0],
     
    75647841        collectVectorComponentRanges(_cumulativeVectorComponentRange[i], i,
    75657842                                     _cumulativeRangeOnlyVisible);
     7843    }
     7844
     7845    TRACE("Cumulative scalar range: %g, %g",
     7846          _cumulativeScalarRange[0],
     7847          _cumulativeScalarRange[1]);
     7848    TRACE("Cumulative vmag range: %g, %g",
     7849          _cumulativeVectorMagnitudeRange[0],
     7850          _cumulativeVectorMagnitudeRange[1]);
     7851    for (int i = 0; i < 3; i++) {
     7852        TRACE("Cumulative v[%d] range: %g, %g", i,
     7853              _cumulativeVectorComponentRange[i][0],
     7854              _cumulativeVectorComponentRange[i][1]);
    75667855    }
    75677856}
     
    76447933        range[1] = 1;
    76457934 }
     7935
     7936/**
     7937 * \brief Determines if AABB lies in a principal axis plane
     7938 * and if so, returns the plane normal
     7939 */
     7940bool Renderer::is2D(const double bounds[6],
     7941                    Renderer::PrincipalPlane *plane,
     7942                    double *offset) const
     7943{
     7944    if (bounds[4] == bounds[5]) {
     7945        // Z = 0, XY plane
     7946        if (plane)
     7947            *plane = PLANE_XY;
     7948        if (offset)
     7949            *offset = bounds[4];
     7950        return true;
     7951    } else if (bounds[0] == bounds[1]) {
     7952        // X = 0, ZY plane
     7953        if (plane)
     7954            *plane = PLANE_ZY;
     7955        if (offset)
     7956            *offset = bounds[0];
     7957        return true;
     7958    } else if (bounds[2] == bounds[3]) {
     7959        // Y = 0, XZ plane
     7960        if (plane)
     7961            *plane = PLANE_XZ;
     7962        if (offset)
     7963            *offset = bounds[2];
     7964        return true;
     7965    }
     7966    *plane = PLANE_XY;
     7967    *offset = 0;
     7968    return false;
     7969}
    76467970
    76477971/**
     
    76677991    double bounds[6];
    76687992    collectBounds(bounds, false);
    7669     _imgWorldOrigin[0] = bounds[0];
    7670     _imgWorldOrigin[1] = bounds[2];
    7671     _imgWorldDims[0] = bounds[1] - bounds[0];
    7672     _imgWorldDims[1] = bounds[3] - bounds[2];
     7993    bool twod = is2D(bounds, &_imgCameraPlane, &_imgCameraOffset);
     7994    if (twod) {
     7995        _cameraMode = IMAGE;
     7996        if (_imgCameraPlane == PLANE_ZY) {
     7997            _imgWorldOrigin[0] = bounds[4];
     7998            _imgWorldOrigin[1] = bounds[2];
     7999            _imgWorldDims[0] = bounds[5] - bounds[4];
     8000            _imgWorldDims[1] = bounds[3] - bounds[2];
     8001        } else if (_imgCameraPlane == PLANE_XZ) {
     8002            _imgWorldOrigin[0] = bounds[0];
     8003            _imgWorldOrigin[1] = bounds[4];
     8004            _imgWorldDims[0] = bounds[1] - bounds[0];
     8005            _imgWorldDims[1] = bounds[5] - bounds[4];
     8006        } else {
     8007            _imgWorldOrigin[0] = bounds[0];
     8008            _imgWorldOrigin[1] = bounds[2];
     8009            _imgWorldDims[0] = bounds[1] - bounds[0];
     8010            _imgWorldDims[1] = bounds[3] - bounds[2];
     8011        }
     8012    } else {
     8013        _imgWorldOrigin[0] = bounds[0];
     8014        _imgWorldOrigin[1] = bounds[2];
     8015        _imgWorldDims[0] = bounds[1] - bounds[0];
     8016        _imgWorldDims[1] = bounds[3] - bounds[2];
     8017    }
     8018
    76738019    _cameraPan[0] = 0;
    76748020    _cameraPan[1] = 0;
     
    76978043        ERROR("Unknown camera mode");
    76988044    }
     8045
    76998046#ifdef WANT_TRACE
    77008047    printCameraInfo(_renderer->GetActiveCamera());
     
    77078054void Renderer::printCameraInfo(vtkCamera *camera)
    77088055{
    7709     TRACE("Parallel Scale: %g, View angle: %g, Cam pos: %g %g %g, focal pt: %g %g %g, view up: %g %g %g, Clipping range: %g %g",
     8056    TRACE("pscale: %g, angle: %g, d: %g pos: %g %g %g, fpt: %g %g %g, vup: %g %g %g, clip: %g %g",
    77108057          camera->GetParallelScale(),
    77118058          camera->GetViewAngle(),
     8059          camera->GetDistance(),
    77128060          camera->GetPosition()[0],
    77138061          camera->GetPosition()[1],
     
    80968444 * Note: no interpolation is performed on data
    80978445 */
    8098 double Renderer::getDataValueAtPixel(const DataSetId& id, int x, int y)
     8446bool Renderer::getScalarValueAtPixel(const DataSetId& id, int x, int y, double *value)
    80998447{
    81008448    vtkSmartPointer<vtkCoordinate> coord = vtkSmartPointer<vtkCoordinate>::New();
    81018449    coord->SetCoordinateSystemToDisplay();
    8102     coord->SetValue(x, y, 0);
     8450    coord->SetValue(x, _windowHeight - y, 0);
    81038451    double *worldCoords = coord->GetComputedWorldValue(_renderer);
    81048452
    8105     TRACE("Pixel coords: %d, %d\nWorld coords: %.12e, %.12e, %12e", x, y,
     8453    TRACE("Pixel coords: %d, %d\nWorld coords: %g, %g, %g", x, y,
    81068454          worldCoords[0],
    81078455          worldCoords[1],
    81088456          worldCoords[2]);
    81098457
    8110     return getDataValue(id, worldCoords[0], worldCoords[1], worldCoords[2]);
     8458    return getScalarValue(id, worldCoords[0], worldCoords[1], worldCoords[2], value);
    81118459}
    81128460
     
    81168464 * Note: no interpolation is performed on data
    81178465 */
    8118 double Renderer::getDataValue(const DataSetId& id, double x, double y, double z)
     8466bool Renderer::getScalarValue(const DataSetId& id, double x, double y, double z, double *value)
    81198467{
    81208468    DataSet *ds = getDataSet(id);
    81218469    if (ds == NULL)
    8122         return 0;
    8123     vtkDataSet *vtkds = ds->getVtkDataSet();
    8124     vtkIdType pt = vtkds->FindPoint(x, y, z);
    8125     return vtkds->GetPointData()->GetScalars()->GetComponent(pt, 0);
    8126 }
     8470        return false;
     8471
     8472    return ds->getScalarValue(x, y, z, value);
     8473}
     8474
     8475/**
     8476 * \brief Get nearest data value given display coordinates x,y
     8477 *
     8478 * Note: no interpolation is performed on data
     8479 */
     8480bool Renderer::getVectorValueAtPixel(const DataSetId& id, int x, int y, double vector[3])
     8481{
     8482    vtkSmartPointer<vtkCoordinate> coord = vtkSmartPointer<vtkCoordinate>::New();
     8483    coord->SetCoordinateSystemToDisplay();
     8484    coord->SetValue(x, _windowHeight - y, 0);
     8485    double *worldCoords = coord->GetComputedWorldValue(_renderer);
     8486
     8487    TRACE("Pixel coords: %d, %d\nWorld coords: %g, %g, %g", x, y,
     8488          worldCoords[0],
     8489          worldCoords[1],
     8490          worldCoords[2]);
     8491
     8492    return getVectorValue(id, worldCoords[0], worldCoords[1], worldCoords[2], vector);
     8493}
     8494
     8495/**
     8496 * \brief Get nearest data value given world coordinates x,y,z
     8497 *
     8498 * Note: no interpolation is performed on data
     8499 */
     8500bool Renderer::getVectorValue(const DataSetId& id, double x, double y, double z, double vector[3])
     8501{
     8502    DataSet *ds = getDataSet(id);
     8503    if (ds == NULL)
     8504        return false;
     8505
     8506    return ds->getVectorValue(x, y, z, vector);
     8507}
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2402 r2423  
    1212#include <vtkCubeAxesActor.h>
    1313#ifdef USE_CUSTOM_AXES
    14 #include <vtkRpCubeAxesActor2D.h>
     14#include "vtkRpCubeAxesActor2D.h"
    1515#else
    1616#include <vtkCubeAxesActor2D.h>
     
    5959        Y_AXIS,
    6060        Z_AXIS
     61    };
     62
     63    enum PrincipalPlane {
     64        PLANE_XY,
     65        PLANE_ZY,
     66        PLANE_XZ
    6167    };
    6268
     
    104110    DataSet *getDataSet(const DataSetId& id);
    105111
     112    void getDataSetNames(std::vector<std::string>& names);
     113
    106114    bool setData(const DataSetId& id, char *data, int nbytes);
    107115
     
    112120    bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName);
    113121
    114     double getDataValueAtPixel(const DataSetId& id, int x, int y);
    115 
    116     double getDataValue(const DataSetId& id, double x, double y, double z);
     122    bool getScalarValueAtPixel(const DataSetId& id, int x, int y, double *value);
     123
     124    bool getScalarValue(const DataSetId& id, double x, double y, double z, double *value);
     125
     126    bool getVectorValueAtPixel(const DataSetId& id, int x, int y, double vector[3]);
     127
     128    bool getVectorValue(const DataSetId& id, double x, double y, double z, double vector[3]);
    117129
    118130    void setOpacity(const DataSetId& id, double opacity);
     
    148160    void resetCameraClippingRange();
    149161
     162    void setCameraZoomRegionPixels(int x, int y, int width, int height);
     163
    150164    void setCameraZoomRegion(double x, double y, double width, double height);
    151165
     
    232246    // 2D Contour plots
    233247
    234     void addContour2D(const DataSetId& id, int numContours);
    235 
    236     void addContour2D(const DataSetId& id, const std::vector<double>& contours);
     248    bool addContour2D(const DataSetId& id, int numContours);
     249
     250    bool addContour2D(const DataSetId& id, const std::vector<double>& contours);
    237251
    238252    void deleteContour2D(const DataSetId& id);
     
    266280    // 3D Contour (isosurface) plots
    267281
    268     void addContour3D(const DataSetId& id, int numContours);
    269 
    270     void addContour3D(const DataSetId& id, const std::vector<double>& contours);
     282    bool addContour3D(const DataSetId& id, int numContours);
     283
     284    bool addContour3D(const DataSetId& id, const std::vector<double>& contours);
    271285
    272286    void deleteContour3D(const DataSetId& id);
     
    308322    // Glyphs
    309323
    310     void addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape);
     324    bool addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape);
    311325
    312326    void deleteGlyphs(const DataSetId& id);
     
    352366    // Height maps
    353367
    354     void addHeightMap(const DataSetId& id, int numContours);
    355 
    356     void addHeightMap(const DataSetId& id, const std::vector<double>& contours);
     368    bool addHeightMap(const DataSetId& id, int numContours, double heightScale);
     369
     370    bool addHeightMap(const DataSetId& id, const std::vector<double>& contours, double heightScale);
    357371
    358372    void deleteHeightMap(const DataSetId& id);
     
    382396    void setHeightMapVisibility(const DataSetId& id, bool state);
    383397
     398    void setHeightMapWireframe(const DataSetId& id, bool state);
     399
    384400    void setHeightMapVolumeSlice(const DataSetId& id, HeightMap::Axis axis, double ratio);
    385401
     
    388404    void setHeightMapColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    389405
    390     void setHeightMapContours(const DataSetId& id, int numContours);
     406    void setHeightMapNumContours(const DataSetId& id, int numContours);
    391407
    392408    void setHeightMapContourList(const DataSetId& id, const std::vector<double>& contours);
    393409
    394     void setHeightMapContourVisibility(const DataSetId& id, bool state);
     410    void setHeightMapContourSurfaceVisibility(const DataSetId& id, bool state);
     411
     412    void setHeightMapContourLineVisibility(const DataSetId& id, bool state);
    395413
    396414    void setHeightMapContourEdgeColor(const DataSetId& id, float color[3]);
     
    400418    // LIC plots
    401419
    402     void addLIC(const DataSetId& id);
     420    bool addLIC(const DataSetId& id);
    403421   
    404422    void deleteLIC(const DataSetId& id);
     
    434452    // Molecules
    435453
    436     void addMolecule(const DataSetId& id);
     454    bool addMolecule(const DataSetId& id);
    437455   
    438456    void deleteMolecule(const DataSetId& id);
     
    474492    // PolyData Meshes
    475493
    476     void addPolyData(const DataSetId& id);
     494    bool addPolyData(const DataSetId& id);
    477495   
    478496    void deletePolyData(const DataSetId& id);
     
    498516    void setPolyDataEdgeWidth(const DataSetId& id, float edgeWidth);
    499517
     518    void setPolyDataPointSize(const DataSetId& id, float size);
     519
    500520    void setPolyDataLighting(const DataSetId& id, bool state);
    501521
     
    509529    // Color-mapped surfaces
    510530
    511     void addPseudoColor(const DataSetId& id);
     531    bool addPseudoColor(const DataSetId& id);
    512532
    513533    void deletePseudoColor(const DataSetId& id);
     
    543563    // Streamlines
    544564
    545     void addStreamlines(const DataSetId& id);
     565    bool addStreamlines(const DataSetId& id);
    546566
    547567    void deleteStreamlines(const DataSetId& id);
     
    612632    // Volumes
    613633
    614     void addVolume(const DataSetId& id);
     634    bool addVolume(const DataSetId& id);
    615635
    616636    void deleteVolume(const DataSetId& id);
     
    678698    void computeScreenWorldCoords();
    679699
     700    bool is2D(const double bounds[6],
     701              PrincipalPlane *plane,
     702              double *offset) const;
    680703    void initCamera();
    681704    void initAxes();
     
    687710    double _imgWorldOrigin[2];
    688711    double _imgWorldDims[2];
     712    PrincipalPlane _imgCameraPlane;
     713    double _imgCameraOffset;
    689714    double _screenWorldCoords[4];
    690715    double _cameraOrientation[4];
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2402 r2423  
    1010#include <cstring>
    1111#include <cerrno>
     12#include <string>
     13#include <sstream>
    1214#include <unistd.h>
    1315#include <sys/uio.h>
     
    2426using namespace Rappture::VtkVis;
    2527
     28static ssize_t
     29SocketWrite(const void *bytes, size_t len)
     30{
     31    size_t ofs = 0;
     32    ssize_t bytesWritten;
     33    while ((bytesWritten = write(g_fdOut, (const char *)bytes + ofs, len - ofs)) > 0) {
     34        ofs += bytesWritten;
     35        if (ofs == len)
     36            break;
     37    }
     38    if (bytesWritten < 0) {
     39        ERROR("write: %s", strerror(errno));
     40    }
     41    return bytesWritten;
     42}
     43
    2644static int
    2745ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr)
     
    3553}
    3654
    37 static bool
     55static int
    3856GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, bool *boolPtr)
    3957{
     
    4765}
    4866
    49 int
     67static int
    5068GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, float *valuePtr)
    5169{
     
    324342
    325343    char buf[256];
    326     snprintf(buf, sizeof(buf), "nv>camera set %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e",
     344    snprintf(buf, sizeof(buf), "nv>camera set %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e\n",
    327345             pos[0], pos[1], pos[2], focalPt[0], focalPt[1], focalPt[2], viewUp[0], viewUp[1], viewUp[2]);
    328     ssize_t bytesWritten;
    329     size_t len = strlen(buf);
    330     size_t ofs = 0;
    331     while ((bytesWritten = write(g_fdOut, buf + ofs, len - ofs)) > 0) {
    332         ofs += bytesWritten;
    333         if (ofs == len)
    334             break;
    335     }
     346
     347    ssize_t bytesWritten = SocketWrite(buf, strlen(buf));
     348
    336349    if (bytesWritten < 0) {
    337350        return TCL_ERROR;
     
    361374              Tcl_Obj *const *objv)
    362375{
    363     double x, y, width, height;
    364 
    365     if (Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK ||
    366         Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK ||
    367         Tcl_GetDoubleFromObj(interp, objv[4], &width) != TCL_OK ||
    368         Tcl_GetDoubleFromObj(interp, objv[5], &height) != TCL_OK) {
    369         return TCL_ERROR;
    370     }
    371 
    372     g_renderer->setCameraZoomRegion(x, y, width, height);
     376    const char *string = Tcl_GetString(objv[2]);
     377
     378    if (string[0] == 'p' && strcmp(string, "pixel") == 0) {
     379        int x, y, width, height;
     380        if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK ||
     381            Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK ||
     382            Tcl_GetIntFromObj(interp, objv[5], &width) != TCL_OK ||
     383            Tcl_GetIntFromObj(interp, objv[6], &height) != TCL_OK) {
     384            return TCL_ERROR;
     385        }
     386        g_renderer->setCameraZoomRegionPixels(x, y, width, height);
     387    } else if (string[0] == 'w' && strcmp(string, "world") == 0) {
     388        double x, y, width, height;
     389        if (Tcl_GetDoubleFromObj(interp, objv[3], &x) != TCL_OK ||
     390            Tcl_GetDoubleFromObj(interp, objv[4], &y) != TCL_OK ||
     391            Tcl_GetDoubleFromObj(interp, objv[5], &width) != TCL_OK ||
     392            Tcl_GetDoubleFromObj(interp, objv[6], &height) != TCL_OK) {
     393            return TCL_ERROR;
     394        }
     395        g_renderer->setCameraZoomRegion(x, y, width, height);
     396    } else {
     397        Tcl_AppendResult(interp, "bad camera ortho option \"", string,
     398                         "\": should be pixel or world", (char*)NULL);
     399        return TCL_ERROR;
     400    }
     401
    373402    return TCL_OK;
    374403}
     
    466495    {"mode", 1, CameraModeOp, 3, 3, "mode"},
    467496    {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"},
    468     {"ortho", 1, CameraOrthoOp, 6, 6, "x y width height"},
     497    {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"},
    469498    {"pan", 1, CameraPanOp, 4, 4, "panX panY"},
    470499    {"reset", 2, CameraResetOp, 2, 3, "?all?"},
     
    625654    if (objc == 5) {
    626655        const char *name = Tcl_GetString(objv[4]);
    627         g_renderer->addContour2D(name, contourList);
    628     } else {
    629         g_renderer->addContour2D("all", contourList);
     656        if (!g_renderer->addContour2D(name, contourList)) {
     657            Tcl_AppendResult(interp, "Failed to create contour2d", (char*)NULL);
     658            return TCL_ERROR;
     659        }
     660    } else {
     661        if (!g_renderer->addContour2D("all", contourList)) {
     662            Tcl_AppendResult(interp, "Failed to create contour2d for one or more data sets", (char*)NULL);
     663            return TCL_ERROR;
     664        }
    630665    }
    631666    return TCL_OK;
     
    642677    if (objc == 5) {
    643678        const char *name = Tcl_GetString(objv[4]);
    644         g_renderer->addContour2D(name, numContours);
    645     } else {
    646         g_renderer->addContour2D("all", numContours);
     679        if (!g_renderer->addContour2D(name, numContours)) {
     680            Tcl_AppendResult(interp, "Failed to create contour2d", (char*)NULL);
     681            return TCL_ERROR;
     682        }
     683    } else {
     684       if (!g_renderer->addContour2D("all", numContours)) {
     685            Tcl_AppendResult(interp, "Failed to create contour2d for one or more data sets", (char*)NULL);
     686            return TCL_ERROR;
     687       }
    647688    }
    648689    return TCL_OK;
     
    878919    if (objc == 5) {
    879920        const char *name = Tcl_GetString(objv[4]);
    880         g_renderer->addContour3D(name, contourList);
    881     } else {
    882         g_renderer->addContour3D("all", contourList);
     921        if (!g_renderer->addContour3D(name, contourList)) {
     922            Tcl_AppendResult(interp, "Failed to create contour3d", (char*)NULL);
     923            return TCL_ERROR;
     924        }
     925    } else {
     926        if (!g_renderer->addContour3D("all", contourList)) {
     927            Tcl_AppendResult(interp, "Failed to create contour3d for one or more data sets", (char*)NULL);
     928            return TCL_ERROR;
     929        }
    883930    }
    884931    return TCL_OK;
     
    895942    if (objc == 5) {
    896943        const char *name = Tcl_GetString(objv[4]);
    897         g_renderer->addContour3D(name, numContours);
    898     } else {
    899         g_renderer->addContour3D("all", numContours);
     944        if (!g_renderer->addContour3D(name, numContours)) {
     945            Tcl_AppendResult(interp, "Failed to create contour3d", (char*)NULL);
     946            return TCL_ERROR;
     947        }
     948    } else {
     949        if (!g_renderer->addContour3D("all", numContours)) {
     950            Tcl_AppendResult(interp, "Failed to create contour3d for one or more data sets", (char*)NULL);
     951            return TCL_ERROR;
     952        }
    900953    }
    901954    return TCL_OK;
     
    12901343
    12911344static int
    1292 DataSetGetValuePixelOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1293                        Tcl_Obj *const *objv)
     1345DataSetGetScalarPixelOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1346                        Tcl_Obj *const *objv)
    12941347{
    12951348    const char *name = Tcl_GetString(objv[5]);
     
    12991352        return TCL_ERROR;
    13001353    }
    1301     double value = g_renderer->getDataValueAtPixel(name, x, y);
    1302     char buf[128];
    1303     snprintf(buf, sizeof(buf), "nv>dataset value pixel %d %d %.12e", x, y, value);
    1304     ssize_t bytesWritten;
    1305     size_t len = strlen(buf);
    1306     size_t ofs = 0;
    1307     while ((bytesWritten = write(g_fdOut, buf + ofs, len - ofs)) > 0) {
    1308         ofs += bytesWritten;
    1309         if (ofs == len)
    1310             break;
    1311     }
     1354    double value;
     1355    if (!g_renderer->getScalarValueAtPixel(name, x, y, &value)) {
     1356        Tcl_AppendResult(interp, "Pixel out of dataset bounds or no scalar data available", (char*)NULL);
     1357        return TCL_ERROR;
     1358    }
     1359
     1360    char buf[256];
     1361    snprintf(buf, sizeof(buf), "nv>dataset scalar pixel %d %d %g %s\n", x, y, value, name);
     1362
     1363    ssize_t bytesWritten = SocketWrite(buf, strlen(buf));
     1364
    13121365    if (bytesWritten < 0) {
    13131366        return TCL_ERROR;
     
    13171370
    13181371static int
    1319 DataSetGetValueWorldOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1320                        Tcl_Obj *const *objv)
     1372DataSetGetScalarWorldOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1373                        Tcl_Obj *const *objv)
    13211374{
    13221375    const char *name = Tcl_GetString(objv[6]);
     
    13271380        return TCL_ERROR;
    13281381    }
    1329     double value = g_renderer->getDataValue(name, x, y, z);
    1330     char buf[128];
    1331     snprintf(buf, sizeof(buf), "nv>dataset value world %.12e %.12e %.12e %.12e", x, y, z, value);
    1332     ssize_t bytesWritten;
    1333     size_t len = strlen(buf);
    1334     size_t ofs = 0;
    1335     while ((bytesWritten = write(g_fdOut, buf + ofs, len - ofs)) > 0) {
    1336         ofs += bytesWritten;
    1337         if (ofs == len)
    1338             break;
    1339     }
     1382    double value;
     1383    if (!g_renderer->getScalarValue(name, x, y, z, &value)) {
     1384        Tcl_AppendResult(interp, "Coordinate out of dataset bounds or no scalar data available", (char*)NULL);
     1385        return TCL_ERROR;
     1386    }
     1387
     1388    char buf[256];
     1389    snprintf(buf, sizeof(buf), "nv>dataset scalar world %g %g %g %g %s\n", x, y, z, value, name);
     1390
     1391    ssize_t bytesWritten = SocketWrite(buf, strlen(buf));
     1392
    13401393    if (bytesWritten < 0) {
    13411394        return TCL_ERROR;
     
    13441397}
    13451398
    1346 static Rappture::CmdSpec dataSetGetValueOps[] = {
    1347     {"pixel", 1, DataSetGetValuePixelOp, 6, 6, "x y dataSetName"},
    1348     {"world", 1, DataSetGetValueWorldOp, 7, 7, "x y z dataSetName"}
     1399static Rappture::CmdSpec dataSetGetScalarOps[] = {
     1400    {"pixel", 1, DataSetGetScalarPixelOp, 6, 6, "x y dataSetName"},
     1401    {"world", 1, DataSetGetScalarWorldOp, 7, 7, "x y z dataSetName"}
    13491402};
    1350 static int nDataSetGetValueOps = NumCmdSpecs(dataSetGetValueOps);
    1351 
    1352 static int
    1353 DataSetGetValueOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1354                   Tcl_Obj *const *objv)
     1403static int nDataSetGetScalarOps = NumCmdSpecs(dataSetGetScalarOps);
     1404
     1405static int
     1406DataSetGetScalarOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1407                   Tcl_Obj *const *objv)
    13551408{
    13561409    Tcl_ObjCmdProc *proc;
    13571410
    1358     proc = Rappture::GetOpFromObj(interp, nDataSetGetValueOps, dataSetGetValueOps,
     1411    proc = Rappture::GetOpFromObj(interp, nDataSetGetScalarOps, dataSetGetScalarOps,
     1412                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1413    if (proc == NULL) {
     1414        return TCL_ERROR;
     1415    }
     1416    return (*proc) (clientData, interp, objc, objv);
     1417}
     1418
     1419static int
     1420DataSetGetVectorPixelOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1421                        Tcl_Obj *const *objv)
     1422{
     1423    const char *name = Tcl_GetString(objv[5]);
     1424    int x, y;
     1425    if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK ||
     1426        Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) {
     1427        return TCL_ERROR;
     1428    }
     1429    double value[3];
     1430    if (!g_renderer->getVectorValueAtPixel(name, x, y, value)) {
     1431        Tcl_AppendResult(interp, "Pixel out of dataset bounds or no vector data available", (char*)NULL);
     1432        return TCL_ERROR;
     1433    }
     1434
     1435    char buf[256];
     1436    snprintf(buf, sizeof(buf), "nv>dataset vector pixel %d %d %g %g %g %s\n", x, y,
     1437             value[0], value[1], value[2], name);
     1438
     1439    ssize_t bytesWritten = SocketWrite(buf, strlen(buf));
     1440
     1441    if (bytesWritten < 0) {
     1442        return TCL_ERROR;
     1443    }
     1444    return TCL_OK;
     1445}
     1446
     1447static int
     1448DataSetGetVectorWorldOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1449                        Tcl_Obj *const *objv)
     1450{
     1451    const char *name = Tcl_GetString(objv[6]);
     1452    double x, y, z;
     1453    if (Tcl_GetDoubleFromObj(interp, objv[3], &x) != TCL_OK ||
     1454        Tcl_GetDoubleFromObj(interp, objv[4], &y) != TCL_OK ||
     1455        Tcl_GetDoubleFromObj(interp, objv[5], &z) != TCL_OK) {
     1456        return TCL_ERROR;
     1457    }
     1458    double value[3];
     1459    if (!g_renderer->getVectorValue(name, x, y, z, value)) {
     1460        Tcl_AppendResult(interp, "Coordinate out of dataset bounds or no vector data available", (char*)NULL);
     1461        return TCL_ERROR;
     1462    }
     1463
     1464    char buf[256];
     1465    snprintf(buf, sizeof(buf), "nv>dataset vector world %g %g %g %g %g %g %s\n", x, y, z,
     1466             value[0], value[1], value[2], name);
     1467
     1468    ssize_t bytesWritten = SocketWrite(buf, strlen(buf));
     1469
     1470    if (bytesWritten < 0) {
     1471        return TCL_ERROR;
     1472    }
     1473    return TCL_OK;
     1474}
     1475
     1476static Rappture::CmdSpec dataSetGetVectorOps[] = {
     1477    {"pixel", 1, DataSetGetVectorPixelOp, 6, 6, "x y dataSetName"},
     1478    {"world", 1, DataSetGetVectorWorldOp, 7, 7, "x y z dataSetName"}
     1479};
     1480static int nDataSetGetVectorOps = NumCmdSpecs(dataSetGetVectorOps);
     1481
     1482static int
     1483DataSetGetVectorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1484                   Tcl_Obj *const *objv)
     1485{
     1486    Tcl_ObjCmdProc *proc;
     1487
     1488    proc = Rappture::GetOpFromObj(interp, nDataSetGetVectorOps, dataSetGetVectorOps,
    13591489                                  Rappture::CMDSPEC_ARG2, objc, objv, 0);
    13601490    if (proc == NULL) {
     
    13931523        g_renderer->setUseCumulativeDataRange(false);
    13941524    } else {
     1525        Tcl_AppendResult(interp, "bad maprange option \"", value,
     1526                         "\": should be all, visible, or separate", (char*)NULL);
     1527        return TCL_ERROR;
     1528    }
     1529    return TCL_OK;
     1530}
     1531
     1532static int
     1533DataSetNamesOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1534               Tcl_Obj *const *objv)
     1535{
     1536    std::vector<std::string> dataSets;
     1537    g_renderer->getDataSetNames(dataSets);
     1538    std::ostringstream oss;
     1539    size_t len = 0;
     1540    oss << "nv>dataset names {";
     1541    len += 18;
     1542    for (size_t i = 0; i < dataSets.size(); i++) {
     1543        oss << "\"" << dataSets[i] << "\"";
     1544        len += 2 + dataSets[i].length();
     1545        if (i < dataSets.size() - 1) {
     1546            oss << " ";
     1547            len++;
     1548        }
     1549    }
     1550    oss << "}\n";
     1551    len += 2;
     1552
     1553    size_t bytesWritten = SocketWrite(oss.str().c_str(), len);
     1554
     1555    if (bytesWritten < 0) {
    13951556        return TCL_ERROR;
    13961557    }
     
    14161577
    14171578static Rappture::CmdSpec dataSetOps[] = {
    1418     {"add",      1, DataSetAddOp, 6, 6, "name data follows nBytes"},
    1419     {"delete",   1, DataSetDeleteOp, 2, 3, "?name?"},
    1420     {"getvalue", 1, DataSetGetValueOp, 6, 7, "oper x y ?z? name"},
    1421     {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"},
    1422     {"opacity",  1, DataSetOpacityOp, 3, 4, "value ?name?"},
    1423     {"scalar",   1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"},
    1424     {"vector",   2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"},
    1425     {"visible",  2, DataSetVisibleOp, 3, 4, "bool ?name?"}
     1579    {"add",       1, DataSetAddOp, 6, 6, "name data follows nBytes"},
     1580    {"delete",    1, DataSetDeleteOp, 2, 3, "?name?"},
     1581    {"getscalar", 4, DataSetGetScalarOp, 6, 7, "oper x y ?z? name"},
     1582    {"getvector", 4, DataSetGetVectorOp, 6, 7, "oper x y ?z? name"},
     1583    {"maprange",  1, DataSetMapRangeOp, 3, 3, "value"},
     1584    {"names",     1, DataSetNamesOp, 2, 2, ""},
     1585    {"opacity",   1, DataSetOpacityOp, 3, 4, "value ?name?"},
     1586    {"scalar",    1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"},
     1587    {"vector",    2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"},
     1588    {"visible",   2, DataSetVisibleOp, 3, 4, "bool ?name?"}
    14261589};
    14271590static int nDataSetOps = NumCmdSpecs(dataSetOps);
     
    14761639    if (objc == 4) {
    14771640        const char *name = Tcl_GetString(objv[3]);
    1478         g_renderer->addGlyphs(name, shape);
    1479     } else {
    1480         g_renderer->addGlyphs("all", shape);
     1641        if (!g_renderer->addGlyphs(name, shape)) {
     1642            Tcl_AppendResult(interp, "Failed to create glyphs", (char*)NULL);
     1643            return TCL_ERROR;
     1644        }
     1645    } else {
     1646        if (!g_renderer->addGlyphs("all", shape)) {
     1647            Tcl_AppendResult(interp, "Failed to create glyphs for one or more data sets", (char*)NULL);
     1648            return TCL_ERROR;
     1649        }
    14811650    }
    14821651    return TCL_OK;
     
    18642033{
    18652034    std::vector<double> contourList;
     2035    double heightScale;
    18662036
    18672037    int clistc;
     
    18802050    }
    18812051
    1882     if (objc == 5) {
    1883         const char *name = Tcl_GetString(objv[4]);
    1884         g_renderer->addHeightMap(name, contourList);
    1885     } else {
    1886         g_renderer->addHeightMap("all", contourList);
     2052    if (Tcl_GetDoubleFromObj(interp, objv[4], &heightScale) != TCL_OK) {
     2053        return TCL_ERROR;
     2054    }
     2055
     2056    if (objc == 6) {
     2057        const char *name = Tcl_GetString(objv[5]);
     2058        if (!g_renderer->addHeightMap(name, contourList, heightScale)) {
     2059            Tcl_AppendResult(interp, "Failed to create heightmap", (char*)NULL);
     2060            return TCL_ERROR;
     2061        }
     2062    } else {
     2063        if (!g_renderer->addHeightMap("all", contourList, heightScale)) {
     2064            Tcl_AppendResult(interp, "Failed to create heightmap for one or more data sets", (char*)NULL);
     2065            return TCL_ERROR;
     2066        }
    18872067    }
    18882068    return TCL_OK;
     
    18942074{
    18952075    int numContours;
     2076    double heightScale;
    18962077    if (Tcl_GetIntFromObj(interp, objv[3], &numContours) != TCL_OK) {
    18972078        return TCL_ERROR;
    18982079    }
    1899     if (objc == 5) {
    1900         const char *name = Tcl_GetString(objv[4]);
    1901         g_renderer->addHeightMap(name, numContours);
    1902     } else {
    1903         g_renderer->addHeightMap("all", numContours);
     2080    if (Tcl_GetDoubleFromObj(interp, objv[4], &heightScale) != TCL_OK) {
     2081        return TCL_ERROR;
     2082    }
     2083    if (objc == 6) {
     2084        const char *name = Tcl_GetString(objv[5]);
     2085        if (!g_renderer->addHeightMap(name, numContours, heightScale)) {
     2086            Tcl_AppendResult(interp, "Failed to create heightmap", (char*)NULL);
     2087            return TCL_ERROR;
     2088        }
     2089    } else {
     2090        if (!g_renderer->addHeightMap("all", numContours, heightScale)) {
     2091            Tcl_AppendResult(interp, "Failed to create heightmap for one or more data sets", (char*)NULL);
     2092            return TCL_ERROR;
     2093        }
    19042094    }
    19052095    return TCL_OK;
     
    19072097
    19082098static Rappture::CmdSpec heightmapAddOps[] = {
    1909     {"contourlist", 1, HeightMapAddContourListOp, 4, 5, "contourList ?dataSetName?"},
    1910     {"numcontours", 1, HeightMapAddNumContoursOp, 4, 5, "numContours ?dataSetName?"}
     2099    {"contourlist", 1, HeightMapAddContourListOp, 5, 6, "contourList heightscale ?dataSetName?"},
     2100    {"numcontours", 1, HeightMapAddNumContoursOp, 5, 6, "numContours heightscale ?dataSetName?"}
    19112101};
    19122102static int nHeightmapAddOps = NumCmdSpecs(heightmapAddOps);
     
    19772167
    19782168static int
    1979 HeightMapContourVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1980                           Tcl_Obj *const *objv)
     2169HeightMapContourListOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2170                       Tcl_Obj *const *objv)
     2171{
     2172    std::vector<double> contourList;
     2173
     2174    int clistc;
     2175    Tcl_Obj **clistv;
     2176
     2177    if (Tcl_ListObjGetElements(interp, objv[2], &clistc, &clistv) != TCL_OK) {
     2178        return TCL_ERROR;
     2179    }
     2180
     2181    for (int i = 0; i < clistc; i++) {
     2182        double val;
     2183        if (Tcl_GetDoubleFromObj(interp, clistv[i], &val) != TCL_OK) {
     2184            return TCL_ERROR;
     2185        }
     2186        contourList.push_back(val);
     2187    }
     2188
     2189    if (objc == 4) {
     2190        const char *name = Tcl_GetString(objv[3]);
     2191        g_renderer->setHeightMapContourList(name, contourList);
     2192    } else {
     2193        g_renderer->setHeightMapContourList("all", contourList);
     2194    }
     2195    return TCL_OK;
     2196}
     2197
     2198static int
     2199HeightMapContourLineVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2200                              Tcl_Obj *const *objv)
    19812201{
    19822202    bool state;
     
    19862206    if (objc == 4) {
    19872207        const char *name = Tcl_GetString(objv[3]);
    1988         g_renderer->setHeightMapContourVisibility(name, state);
    1989     } else {
    1990         g_renderer->setHeightMapContourVisibility("all", state);
     2208        g_renderer->setHeightMapContourLineVisibility(name, state);
     2209    } else {
     2210        g_renderer->setHeightMapContourLineVisibility("all", state);
     2211    }
     2212    return TCL_OK;
     2213}
     2214
     2215static int
     2216HeightMapContourSurfaceVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2217                                 Tcl_Obj *const *objv)
     2218{
     2219    bool state;
     2220    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     2221        return TCL_ERROR;
     2222    }
     2223    if (objc == 4) {
     2224        const char *name = Tcl_GetString(objv[3]);
     2225        g_renderer->setHeightMapContourSurfaceVisibility(name, state);
     2226    } else {
     2227        g_renderer->setHeightMapContourSurfaceVisibility("all", state);
    19912228    }
    19922229    return TCL_OK;
     
    20892326    } else {
    20902327        g_renderer->setHeightMapEdgeWidth("all", width);
     2328    }
     2329    return TCL_OK;
     2330}
     2331
     2332static int
     2333HeightMapNumContoursOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2334                       Tcl_Obj *const *objv)
     2335{
     2336    int numContours;
     2337
     2338    if (Tcl_GetIntFromObj(interp, objv[2], &numContours) != TCL_OK) {
     2339        return TCL_ERROR;
     2340    }
     2341    if (objc == 4) {
     2342        const char *name = Tcl_GetString(objv[3]);
     2343        g_renderer->setHeightMapNumContours(name, numContours);
     2344    } else {
     2345        g_renderer->setHeightMapNumContours("all", numContours);
    20912346    }
    20922347    return TCL_OK;
     
    22162471}
    22172472
     2473static int
     2474HeightMapWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2475                     Tcl_Obj *const *objv)
     2476{
     2477    bool state;
     2478    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     2479        return TCL_ERROR;
     2480    }
     2481    if (objc == 4) {
     2482        const char *name = Tcl_GetString(objv[3]);
     2483        g_renderer->setHeightMapWireframe(name, state);
     2484    } else {
     2485        g_renderer->setHeightMapWireframe("all", state);
     2486    }
     2487    return TCL_OK;
     2488}
     2489
    22182490static Rappture::CmdSpec heightmapOps[] = {
    2219     {"add",          1, HeightMapAddOp, 4, 5, "oper value ?dataSetName?"},
    2220     {"colormap",     1, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     2491    {"add",          1, HeightMapAddOp, 5, 6, "oper value ?dataSetName?"},
     2492    {"colormap",     2, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     2493    {"contourlist",  2, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"},
    22212494    {"delete",       1, HeightMapDeleteOp, 2, 3, "?dataSetName?"},
    22222495    {"edges",        1, HeightMapEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
    22232496    {"heightscale",  1, HeightMapHeightScaleOp, 3, 4, "value ?dataSetName?"},
    22242497    {"isolinecolor", 8, HeightMapContourLineColorOp, 5, 6, "r g b ?dataSetName?"},
    2225     {"isolines",     8, HeightMapContourVisibleOp, 3, 4, "bool ?dataSetName?"},
     2498    {"isolines",     8, HeightMapContourLineVisibleOp, 3, 4, "bool ?dataSetName?"},
    22262499    {"isolinewidth", 8, HeightMapContourLineWidthOp, 3, 4, "width ?dataSetName?"},
    22272500    {"lighting",     3, HeightMapLightingOp, 3, 4, "bool ?dataSetName?"},
    22282501    {"linecolor",    5, HeightMapLineColorOp, 5, 6, "r g b ?dataSetName?"},
    22292502    {"linewidth",    5, HeightMapLineWidthOp, 3, 4, "width ?dataSetName?"},
     2503    {"numcontours",  1, HeightMapNumContoursOp, 3, 4, "numContours ?dataSetName?"},
    22302504    {"opacity",      2, HeightMapOpacityOp, 3, 4, "value ?dataSetName?"},
    22312505    {"orient",       2, HeightMapOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
    22322506    {"pos",          1, HeightMapPositionOp, 5, 6, "x y z ?dataSetName?"},
    22332507    {"scale",        1, HeightMapScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
     2508    {"surface",      2, HeightMapContourSurfaceVisibleOp, 3, 4, "bool ?dataSetName?"},
    22342509    {"visible",      2, HeightMapVisibleOp, 3, 4, "bool ?dataSetName?"},
    2235     {"volumeslice",  2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}
     2510    {"volumeslice",  2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"},
     2511    {"wireframe",    1, HeightMapWireframeOp, 3, 4, "bool ?dataSetName?"}
    22362512};
    22372513static int nHeightmapOps = NumCmdSpecs(heightmapOps);
     
    23102586    if (objc == 3) {
    23112587        const char *name = Tcl_GetString(objv[2]);
    2312         g_renderer->addLIC(name);
    2313     } else {
    2314         g_renderer->addLIC("all");
     2588        if (!g_renderer->addLIC(name)) {
     2589            Tcl_AppendResult(interp, "Failed to create lic", (char*)NULL);
     2590            return TCL_ERROR;
     2591        }
     2592    } else {
     2593        if (!g_renderer->addLIC("all")) {
     2594            Tcl_AppendResult(interp, "Failed to create lic for one or more data sets", (char*)NULL);
     2595            return TCL_ERROR;
     2596        }
    23152597    }
    23162598    return TCL_OK;
     
    25742856    if (objc == 3) {
    25752857        const char *name = Tcl_GetString(objv[2]);
    2576         g_renderer->addMolecule(name);
    2577     } else {
    2578         g_renderer->addMolecule("all");
     2858        if (!g_renderer->addMolecule(name)) {
     2859            Tcl_AppendResult(interp, "Failed to create molecule", (char*)NULL);
     2860            return TCL_ERROR;
     2861        }
     2862    } else {
     2863        if (!g_renderer->addMolecule("all")) {
     2864            Tcl_AppendResult(interp, "Failed to create molecule for one or more data sets", (char*)NULL);
     2865            return TCL_ERROR;
     2866        }
    25792867    }
    25802868    return TCL_OK;
     
    28893177    if (objc == 3) {
    28903178        const char *name = Tcl_GetString(objv[2]);
    2891         g_renderer->addPolyData(name);
    2892     } else {
    2893         g_renderer->addPolyData("all");
     3179        if (!g_renderer->addPolyData(name)) {
     3180            Tcl_AppendResult(interp, "Failed to create polydata", (char*)NULL);
     3181            return TCL_ERROR;
     3182        }
     3183    } else {
     3184        if (!g_renderer->addPolyData("all")) {
     3185            Tcl_AppendResult(interp, "Failed to create polydata for one or more data sets", (char*)NULL);
     3186            return TCL_ERROR;
     3187        }
    28943188    }
    28953189    return TCL_OK;
     
    30313325    } else {
    30323326        g_renderer->setPolyDataOrientation("all", quat);
     3327    }
     3328    return TCL_OK;
     3329}
     3330
     3331static int
     3332PolyDataPointSizeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3333                    Tcl_Obj *const *objv)
     3334{
     3335    float size;
     3336    if (GetFloatFromObj(interp, objv[2], &size) != TCL_OK) {
     3337        return TCL_ERROR;
     3338    }
     3339    if (objc == 4) {
     3340        const char *name = Tcl_GetString(objv[3]);
     3341        g_renderer->setPolyDataPointSize(name, size);
     3342    } else {
     3343        g_renderer->setPolyDataPointSize("all", size);
    30333344    }
    30343345    return TCL_OK;
     
    31173428    {"opacity",   2, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"},
    31183429    {"orient",    2, PolyDataOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
    3119     {"pos",       1, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"},
     3430    {"pos",       2, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"},
     3431    {"ptsize",    2, PolyDataPointSizeOp, 3, 4, "size ?dataSetName?"},
    31203432    {"scale",     1, PolyDataScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
    31213433    {"visible",   1, PolyDataVisibleOp, 3, 4, "bool ?dataSetName?"},
     
    31443456    if (objc == 3) {
    31453457        const char *name = Tcl_GetString(objv[2]);
    3146         g_renderer->addPseudoColor(name);
    3147     } else {
    3148         g_renderer->addPseudoColor("all");
     3458        if (!g_renderer->addPseudoColor(name)) {
     3459            Tcl_AppendResult(interp, "Failed to create pseudocolor", (char*)NULL);
     3460            return TCL_ERROR;
     3461        }
     3462    } else {
     3463        if (!g_renderer->addPseudoColor("all")) {
     3464            Tcl_AppendResult(interp, "Failed to create pseudocolor for one or more data sets", (char*)NULL);
     3465            return TCL_ERROR;
     3466        }
    31493467    }
    31503468    return TCL_OK;
     
    35293847    if (objc == 3) {
    35303848        const char *name = Tcl_GetString(objv[2]);
    3531         g_renderer->addStreamlines(name);
    3532     } else {
    3533         g_renderer->addStreamlines("all");
     3849        if (!g_renderer->addStreamlines(name)) {
     3850            Tcl_AppendResult(interp, "Failed to create streamlines", (char*)NULL);
     3851            return TCL_ERROR;
     3852        }
     3853    } else {
     3854        if (!g_renderer->addStreamlines("all")) {
     3855            Tcl_AppendResult(interp, "Failed to create streamlines for one or more data sets", (char*)NULL);
     3856            return TCL_ERROR;
     3857        }
    35343858    }
    35353859    return TCL_OK;
     
    41034427    if (objc == 3) {
    41044428        const char *name = Tcl_GetString(objv[2]);
    4105         g_renderer->addVolume(name);
    4106     } else {
    4107         g_renderer->addVolume("all");
     4429        if (!g_renderer->addVolume(name)) {
     4430            Tcl_AppendResult(interp, "Failed to create volume", (char*)NULL);
     4431            return TCL_ERROR;
     4432        }
     4433    } else {
     4434        if (!g_renderer->addVolume("all")) {
     4435            Tcl_AppendResult(interp, "Failed to create volume for one or more data sets", (char*)NULL);
     4436            return TCL_ERROR;
     4437        }
    41084438    }
    41094439    return TCL_OK;
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r2402 r2423  
    4747camera orient <quatW> <quatX> <quatY> <quatZ>
    4848       Set scene orientation using a quaternion
    49 camera ortho <x> <y> <width> <height>
    50        Supply world coordinate bounds of plot area for image camera mode
    51        Data is assumed to lie in XY plane (z = 0)
     49camera ortho <coordMode> <x> <y> <width> <height>
     50       <coordMode> = pixel|world
     51       Supply bounds of plot area for image camera mode
    5252camera pan <x> <y>
    5353       <x,y> viewport coordinates (window center at 0,0).  Positive x pan
     
    7575dataset add <datasetName> data follows <nbytes>
    7676dataset delete <?datasetName?>
    77 dataset getvalue world <x> <y> <z> <datasetName>
    78 dataset getvalue pixel <x> <y> <datasetName>
     77dataset getscalar world <x> <y> <z> <datasetName>
     78dataset getscalar pixel <x> <y> <datasetName>
     79dataset getvector world <x> <y> <z> <datasetName>
     80dataset getvector pixel <x> <y> <datasetName>
    7981        Use pixel for image camera mode
    8082dataset maprange <val>
     
    149151glyphs wireframe <bool> <?datasetName?>
    150152
    151 heightmap add numcontours <n> <?dataSetName?>
     153heightmap add numcontours <n> <heightScale> <?dataSetName?>
    152154          Generate evenly spaced contours including range endpoints.  See also
    153155          'dataset maprange' command.
    154 heightmap add contourlist <list> <?dataSetName?>
     156heightmap add contourlist <list> <heightScale> <?dataSetName?>
    155157          list = {isoval1 isoval2 isoval3...}
    156158heightmap colormap <colorMapName> <?dataSetName?>
     159heightmap contourlist <list> <?dataSetName?>
    157160heightmap delete <?dataSetName?>
    158161heightmap edges <bool> <?dataSetName?>
     
    164167heightmap linecolor <r> <g> <b> <?dataSetName?>
    165168heightmap linewidth <width> <?dataSetName?>
     169heightmap numcontours <n> <?dataSetName?>
    166170heightmap opacity <value> <?dataSetName?>
    167171heightmap orient <qw> <qx> <qy> <qz> <?dataSetName?>
    168172heightmap pos <x> <y> <z> <?dataSetName?>
    169173heightmap scale <sx> <sy> <sz> <?dataSetName?>
     174heightmap surface <bool> <?dataSetName?>
     175          Toggle rendering of colormapped surface (mountain plot or cutplane)
    170176heightmap visible <bool> <?dataSetName?>
    171177heightmap volumeslice axis ratio <?dataSetName?>
    172178          For 3D data, select a slice along a principle axis of the volume. The
    173179          ratio is [0,1]
     180heightmap wireframe <bool> <?datasetName?>
    174181
    175182lic add <?datasetName?>
     
    218225polydata orient <qw> <qx> <qy> <qz> <?dataSetName?>
    219226polydata pos <x> <y> <z> <?dataSetName?>
     227polydata ptsize <size> <?dataSetName?>
    220228polydata scale <sx> <sy> <sz> <?dataSetName?>
    221229polydata visible <bool> <?datasetName?>
     
    301309nv>image -type image -bytes <nbytes>
    302310  <binary RGB data>
    303 nv>image -type image -bbox {x1 y1 x2 y2} -bytes <nbytes>
     311nv>image -type image -bbox {x y w h} -bytes <nbytes>
    304312  <binary RGB data>
    305   Note: in this form, the bbox is the upper left and lower right screen corners
    306   in world coordinates.  This form is currently used only if the camera mode is
    307   set to 'image'.
     313  The bounding box of the 2D image camera zoom region is supplied
     314  Note: The bbox coordinates are in the form used by 'camera ortho world ...':
     315  x,y - world coordinate of lower left corner, w,h - width height in world coords
     316  This form is currently used only if the camera mode is set to 'image'.
    308317nv>legend <colormapName> <nbytes>
    309318  <binary RGB data>
    310 nv>dataset value world <x> <y> <z> <value>
    311 nv>dataset value pixel <x> <y> <value>
     319nv>dataset scalar world <x> <y> <z> <value> <dataSetName>
     320nv>dataset scalar pixel <x> <y> <value> <dataSetName>
     321nv>dataset vector world <x> <y> <z> <valueX> <valueY> <valueZ> <dataSetName>
     322nv>dataset vector pixel <x> <y> <valueX> <valueY> <valueZ> <dataSetName>
    312323
    313324================================================================================
  • trunk/packages/vizservers/vtkvis/vtkRpCubeAxesActor2D.cpp

    r2100 r2423  
    419419  this->YAxis->SetFontFactor(AxisFontFactor);
    420420  this->YAxis->SetProperty(this->GetProperty());
    421 
    422   this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[0], zCoords[1]);
    423   this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[2], zCoords[3]);
    424   this->ZAxis->SetRange(zRange[0], zRange[1]);
     421  if ( this->YAxisVisibility ) {
     422      this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[0], zCoords[1]);
     423      this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[2], zCoords[3]);
     424      this->ZAxis->SetRange(zRange[0], zRange[1]);
     425  } else {
     426      this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[2], zCoords[3]);
     427      this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[0], zCoords[1]);
     428      this->ZAxis->SetRange(zRange[1], zRange[0]);
     429  }
    425430  this->ZAxis->SetTitle(this->Labels[zAxes]);
    426431  this->ZAxis->SetNumberOfLabels(this->NumberOfLabels);
Note: See TracChangeset for help on using the changeset viewer.