Ignore:
Timestamp:
Oct 14, 2011 9:26:55 AM (13 years ago)
Author:
ldelgass
Message:

Allow data range to be specified for legend. A range with min > max means to
use the computed range of the field. Not yet included in protocol command.

File:
1 edited

Legend:

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

    r2617 r2627  
    299299}
    300300
     301/**
     302 * \brief Get a list of DataSets this Renderer knows about
     303 */
    301304void Renderer::getDataSetNames(std::vector<std::string>& names)
    302305{
     
    357360}
    358361
     362/**
     363 * \brief Set the active scalar field array by name for a DataSet
     364 */
    359365bool Renderer::setDataSetActiveScalars(const DataSetId& id, const char *scalarName)
    360366{
     
    394400}
    395401
     402/**
     403 * \brief Set the active vector field array by name for a DataSet
     404 */
    396405bool Renderer::setDataSetActiveVectors(const DataSetId& id, const char *vectorName)
    397406{
     
    10621071}
    10631072
     1073/**
     1074 * \brief Render a labelled legend image for the given colormap
     1075 *
     1076 * The field is assumed to be the active scalar or vector field
     1077 * based on the legendType.
     1078 *
     1079 * \param[in] id ColorMap name
     1080 * \param[in] dataSetID DataSet name
     1081 * \param[in] legendType scalar or vector field legend
     1082 * \param[in,out] title If supplied, draw title ("#auto" means to
     1083 * fill in field name and draw).  If blank, do not draw title. 
     1084 * If title was blank or "#auto", will be filled with field name on
     1085 * return
     1086 * \param[in,out] range Data range to use in legend.  Set min > max to have
     1087 * range computed, will be filled with valid min and max values
     1088 * \param[in] width Pixel width of legend (aspect controls orientation)
     1089 * \param[in] height Pixel height of legend (aspect controls orientation)
     1090 * \param[in] numLabels Number of labels to render (includes min/max)
     1091 * \param[in,out] imgData Pointer to array to fill with image bytes. Array
     1092 * will be resized if needed.
     1093 * \return The image is rendered into the supplied array, false is
     1094 * returned if the color map is not found
     1095 */
    10641096bool Renderer::renderColorMap(const ColorMapId& id,
    10651097                              const DataSetId& dataSetID,
     
    11031135}
    11041136
    1105 
     1137/**
     1138 * \brief Render a labelled legend image for the given colormap
     1139 *
     1140 * The field is assumed to be point data, if the field is not found
     1141 * as point data, cell data is used.
     1142 *
     1143 * \param[in] id ColorMap name
     1144 * \param[in] dataSetID DataSet name
     1145 * \param[in] legendType scalar or vector field legend
     1146 * \param[in] fieldName Name of the field array this legend is for
     1147 * \param[in,out] title If supplied, draw title ("#auto" means to
     1148 * fill in field name and draw).  If blank, do not draw title. 
     1149 * If title was blank or "#auto", will be filled with field name on
     1150 * return
     1151 * \param[in,out] range Data range to use in legend.  Set min > max to have
     1152 * range computed, will be filled with valid min and max values
     1153 * \param[in] width Pixel width of legend (aspect controls orientation)
     1154 * \param[in] height Pixel height of legend (aspect controls orientation)
     1155 * \param[in] numLabels Number of labels to render (includes min/max)
     1156 * \param[in,out] imgData Pointer to array to fill with image bytes. Array
     1157 * will be resized if needed.
     1158 * \return The image is rendered into the supplied array, false is
     1159 * returned if the color map is not found
     1160 */
    11061161bool Renderer::renderColorMap(const ColorMapId& id,
    11071162                              const DataSetId& dataSetID,
     
    11501205 * \param[in] dataSetID DataSet name
    11511206 * \param[in] legendType scalar or vector field legend
     1207 * \param[in] fieldName Name of the field array this legend is for
     1208 * \param[in] type DataAttributeType of the field
    11521209 * \param[in,out] title If supplied, draw title ("#auto" means to
    11531210 * fill in field name and draw).  If blank, do not draw title. 
    11541211 * If title was blank or "#auto", will be filled with field name on
    11551212 * return
    1156  * \param[out] range Filled with min and max values
     1213 * \param[in,out] range Data range to use in legend.  Set min > max to have
     1214 * range computed, will be filled with valid min and max values
    11571215 * \param[in] width Pixel width of legend (aspect controls orientation)
    11581216 * \param[in] height Pixel height of legend (aspect controls orientation)
     
    12631321    }
    12641322
    1265     range[0] = 0.0;
    1266     range[1] = 1.0;
     1323    bool needRange = false;
     1324    if (range[0] > range[1]) {
     1325        range[0] = 0.0;
     1326        range[1] = 1.0;
     1327        needRange = true;
     1328    }
    12671329
    12681330    switch (legendType) {
    12691331    case LEGEND_VECTOR_MAGNITUDE:
    1270         if (cumulative) {
    1271             getCumulativeDataRange(range, fieldName, type, 3);
    1272         } else if (dataSet != NULL) {
    1273             dataSet->getDataRange(range, fieldName, type);
     1332        if (needRange) {
     1333            if (cumulative) {
     1334                getCumulativeDataRange(range, fieldName, type, 3);
     1335            } else if (dataSet != NULL) {
     1336                dataSet->getDataRange(range, fieldName, type);
     1337            }
    12741338        }
    12751339
     
    12841348        break;
    12851349    case LEGEND_VECTOR_X:
    1286         if (cumulative) {
    1287             getCumulativeDataRange(range, fieldName, type, 3, 0);
    1288         } else if (dataSet != NULL) {
    1289             dataSet->getDataRange(range, fieldName, type, 0);
     1350        if (needRange) {
     1351            if (cumulative) {
     1352                getCumulativeDataRange(range, fieldName, type, 3, 0);
     1353            } else if (dataSet != NULL) {
     1354                dataSet->getDataRange(range, fieldName, type, 0);
     1355            }
    12901356        }
    12911357
     
    13001366        break;
    13011367    case LEGEND_VECTOR_Y:
    1302         if (cumulative) {
    1303             getCumulativeDataRange(range, fieldName, type, 3, 1);
    1304         } else if (dataSet != NULL) {
    1305             dataSet->getDataRange(range, fieldName, type, 1);
     1368        if (needRange) {
     1369            if (cumulative) {
     1370                getCumulativeDataRange(range, fieldName, type, 3, 1);
     1371            } else if (dataSet != NULL) {
     1372                dataSet->getDataRange(range, fieldName, type, 1);
     1373            }
    13061374        }
    13071375
     
    13161384        break;
    13171385    case LEGEND_VECTOR_Z:
    1318         if (cumulative) {
    1319             getCumulativeDataRange(range, fieldName, type, 3, 2);
    1320         } else if (dataSet != NULL) {
    1321             dataSet->getDataRange(range, fieldName, type, 1);
     1386        if (needRange) {
     1387            if (cumulative) {
     1388                getCumulativeDataRange(range, fieldName, type, 3, 2);
     1389            } else if (dataSet != NULL) {
     1390                dataSet->getDataRange(range, fieldName, type, 1);
     1391            }
    13221392        }
    13231393
     
    13331403    case LEGEND_SCALAR:
    13341404    default:
    1335         if (cumulative) {
    1336             getCumulativeDataRange(range, fieldName, type, 1);
    1337         } else if (dataSet != NULL) {
    1338             dataSet->getDataRange(range, fieldName, type);
    1339          }
     1405        if (needRange) {
     1406            if (cumulative) {
     1407                getCumulativeDataRange(range, fieldName, type, 1);
     1408            } else if (dataSet != NULL) {
     1409                dataSet->getDataRange(range, fieldName, type);
     1410            }
     1411        }
    13401412
    13411413        lut->SetRange(range);
Note: See TracChangeset for help on using the changeset viewer.