Changeset 2146


Ignore:
Timestamp:
Mar 24, 2011, 9:41:10 AM (14 years ago)
Author:
ldelgass
Message:

Checkpoint commit of cumulative range support for VTK viz. server

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

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp

    r2137 r2146  
    9595    _lut->SetRange(dataRange);
    9696
     97    _dsMapper->UseLookupTableScalarRangeOn();
    9798    _dsMapper->SetLookupTable(_lut);
    98     _dsMapper->SetScalarRange(dataRange);
    99     //_dsMapper->GetLookupTable()->SetRange(dataRange);
    10099    //_dsMapper->InterpolateScalarsBeforeMappingOn();
    101100
    102101    initActor();
    103102    _dsActor->SetMapper(_dsMapper);
    104     //_dsActor->GetProperty()->SetRepresentationToWireframe();
    105103}
    106104
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2137 r2146  
    3838    _needsRedraw(true),
    3939    _windowWidth(320),
    40     _windowHeight(320)
     40    _windowHeight(320),
     41    _useCumulativeRanges(true)
    4142{
    4243    _bgColor[0] = 0;
     
    4849    _clippingPlanes = vtkSmartPointer<vtkPlaneCollection>::New();
    4950    // bottom
    50     vtkPlane *plane0 = vtkPlane::New();
     51    vtkSmartPointer<vtkPlane> plane0 = vtkSmartPointer<vtkPlane>::New();
    5152    plane0->SetNormal(0, 1, 0);
    5253    plane0->SetOrigin(0, 0, 0);
    5354    _clippingPlanes->AddItem(plane0);
    5455    // left
    55     vtkPlane *plane1 = vtkPlane::New();
     56    vtkSmartPointer<vtkPlane> plane1 = vtkSmartPointer<vtkPlane>::New();
    5657    plane1->SetNormal(1, 0, 0);
    5758    plane1->SetOrigin(0, 0, 0);
    5859    _clippingPlanes->AddItem(plane1);
    5960   // top
    60     vtkPlane *plane2 = vtkPlane::New();
     61    vtkSmartPointer<vtkPlane> plane2 = vtkSmartPointer<vtkPlane>::New();
    6162    plane2->SetNormal(0, -1, 0);
    6263    plane2->SetOrigin(0, 1, 0);
    6364    _clippingPlanes->AddItem(plane2);
    6465    // right
    65     vtkPlane *plane3 = vtkPlane::New();
     66    vtkSmartPointer<vtkPlane> plane3 = vtkSmartPointer<vtkPlane>::New();
    6667    plane3->SetNormal(-1, 0, 0);
    6768    plane3->SetOrigin(1, 0, 0);
     
    300301    if (ds) {
    301302        bool ret = ds->setDataFile(filename);
    302         PseudoColor *ps = getPseudoColor(id);
    303         if (ps) {
    304             ps->setDataSet(ds);
    305         }
     303        collectDataRanges(_cumulativeDataRange);
     304        updateRanges(_useCumulativeRanges);
    306305        _needsRedraw = true;
    307306        return ret;
     
    317316    DataSet *ds = getDataSet(id);
    318317    if (ds) {
     318        bool ret = ds->setData(data, nbytes);
     319        collectDataRanges(_cumulativeDataRange);
     320        updateRanges(_useCumulativeRanges);
    319321        _needsRedraw = true;
    320         return ds->setData(data, nbytes);
    321         collectDataRanges(_cumulativeDataRange);
     322        return ret;
    322323    } else
    323324        return false;
     
    628629
    629630    do {
     631        TRACE("Deleting ColorMap %s", itr->second->getName().c_str());
     632
    630633        // TODO: Check if color map is used in PseudoColors?
    631634        delete itr->second;
     
    640643 * returned if the color map is not found
    641644 */
    642 bool Renderer::renderColorMap(const ColorMapId& id, const char *title,
     645bool Renderer::renderColorMap(const ColorMapId& id,
     646                              const DataSetId& dataSetID,
     647                              const char *title,
    643648                              int width, int height,
    644649                              vtkUnsignedCharArray *imgData)
     
    667672        _legendRenderer->AddActor(_scalarBarActor);
    668673    }
    669     _scalarBarActor->SetLookupTable(colorMap->getLookupTable());
     674
     675    vtkSmartPointer<vtkLookupTable> lut = colorMap->getLookupTable();
     676    if (dataSetID.compare("all") == 0) {
     677        lut->SetRange(_cumulativeDataRange);
     678    } else {
     679        DataSet *dataSet = getDataSet(dataSetID);
     680        if (dataSet == NULL) {
     681            lut->SetRange(_cumulativeDataRange);
     682        } else {
     683            double range[2];
     684            dataSet->getDataRange(range);
     685            lut->SetRange(range);
     686        }
     687    }
     688    _scalarBarActor->SetLookupTable(lut);
     689
    670690    // Set viewport-relative width/height/pos
    671691    if (width > height) {
     
    776796              itr->second->getDataSet()->getName().c_str());
    777797
    778         itr->second->setLookupTable(cmap->getLookupTable());
     798        // Make a copy of the generic colormap lookup table, so
     799        // data range can be set in the copy table to match the
     800        // dataset being plotted
     801        vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
     802        lut->DeepCopy(cmap->getLookupTable());
     803
     804        itr->second->setLookupTable(lut);
    779805    } while (doAll && ++itr != _pseudoColors.end());
    780806
     
    17781804            if (bounds[i] == -DBL_MAX)
    17791805                bounds[i] = 1;
     1806        }
     1807    }
     1808}
     1809
     1810/**
     1811 * \brief Update data ranges for color-mapping
     1812 *
     1813 * \param[in] useCumulative Use cumulative range of all DataSets
     1814 */
     1815void Renderer::updateRanges(bool useCumulative)
     1816{
     1817    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
     1818         itr != _pseudoColors.end(); ++itr) {
     1819        vtkLookupTable *lut = itr->second->getLookupTable();
     1820        if (lut) {
     1821            if (useCumulative) {
     1822                lut->SetRange(_cumulativeDataRange);
     1823            } else {
     1824                double range[2];
     1825                if (itr->second->getDataSet()) {
     1826                    itr->second->getDataSet()->getDataRange(range);
     1827                    lut->SetRange(range);
     1828                }
     1829            }
    17801830        }
    17811831    }
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2137 r2146  
    138138    ColorMap *getColorMap(const ColorMapId& id);
    139139
    140     bool renderColorMap(const ColorMapId& id, const char *title,
     140    bool renderColorMap(const ColorMapId& id,
     141                        const DataSetId& dataSetID,
     142                        const char *title,
    141143                        int width, int height,
    142144                        vtkUnsignedCharArray *imgData);
     
    228230    void collectDataRanges(double *range);
    229231
     232    void updateRanges(bool useCumulative);
     233
    230234    void storeCameraOrientation();
    231235    void restoreCameraOrientation();
     
    242246    double _cameraUp[3];
    243247    float _bgColor[3];
     248    bool _useCumulativeRanges;
    244249    double _cumulativeDataRange[2];
    245250
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2137 r2146  
    827827    if (objc < 4) {
    828828        Tcl_AppendResult(interp, "wrong # args: should be \"",
    829                 Tcl_GetString(objv[0]), " colormapName title width height\"", (char*)NULL);
     829                Tcl_GetString(objv[0]), " colormapName title width height ?dataSetName?\"", (char*)NULL);
    830830        return TCL_ERROR;
    831831    }
     
    842842        vtkSmartPointer<vtkUnsignedCharArray>::New();
    843843
    844     if (!g_renderer->renderColorMap(name, title, width, height, imgData)) {
    845         Tcl_AppendResult(interp, "Color map \"",
    846                 name, "\" was not found", (char*)NULL);
    847         return TCL_ERROR;
     844    if (objc == 6) {
     845        const char *dataSetName = Tcl_GetString(objv[5]);
     846        if (!g_renderer->renderColorMap(name, dataSetName, title, width, height, imgData)) {
     847            Tcl_AppendResult(interp, "Color map \"",
     848                             name, "\" was not found", (char*)NULL);
     849            return TCL_ERROR;
     850        }
     851    } else {
     852        if (!g_renderer->renderColorMap(name, "all", title, width, height, imgData)) {
     853            Tcl_AppendResult(interp, "Color map \"",
     854                             name, "\" was not found", (char*)NULL);
     855            return TCL_ERROR;
     856        }
    848857    }
    849858
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r2137 r2146  
    3636colormap delete <?colorMapName?>
    3737
    38 legend <colormapName> <legendTitle> <width> <height>
     38legend <colormapName> <legendTitle> <width> <height> <?datasetName?>
    3939       Causes legend to be rendered and written back with labels and title
    4040
Note: See TracChangeset for help on using the changeset viewer.