Ignore:
Timestamp:
Mar 8, 2011 2:43:17 PM (13 years ago)
Author:
ldelgass
Message:
  • First pass at making dataSetName optional in commands, pass 'all' to methods

in this case (can pass literal 'all' or leave name out). Currently implemented
for delete subcommands.

  • Return bool from rendering legend if color map not found - fixes crash
  • Delete DataSets? after graphics objects, since they hold pointers to their

DataSet?. (TODO: use TR1 shared pointers?)

  • Make hash keys (std::string) const reference parameters in methods
  • Add some debug traces to destructors
  • Fix indentation in CmdProc?.cpp
Location:
trunk/packages/vizservers/vtkvis
Files:
8 edited

Legend:

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

    r2100 r2123  
    2222 */
    2323static int
    24 BinaryOpSearch(
    25     Rappture::CmdSpec *specs,
    26     int nSpecs,
    27     char *string)       /* Name of minor operation to search for */
     24BinaryOpSearch(Rappture::CmdSpec *specs,
     25               int nSpecs,
     26               char *string)       /* Name of minor operation to search for */
    2827{
    2928    char c;
     
    7776 */
    7877static int
    79 LinearOpSearch(
    80     Rappture::CmdSpec *specs,
    81     int nSpecs,
    82     char *string)       /* Name of minor operation to search for */
     78LinearOpSearch(Rappture::CmdSpec *specs,
     79               int nSpecs,
     80               char *string)       /* Name of minor operation to search for */
    8381{
    8482    Rappture::CmdSpec *specPtr;
     
    9391    last = -1;
    9492    for (specPtr = specs, i = 0; i < nSpecs; i++, specPtr++) {
    95     if ((c == specPtr->name[0]) &&
    96         (strncmp(string, specPtr->name, length) == 0)) {
    97         last = i;
    98         nMatches++;
    99         if ((int)length == specPtr->minChars) {
    100         break;
    101         }
    102     }
     93        if ((c == specPtr->name[0]) &&
     94            (strncmp(string, specPtr->name, length) == 0)) {
     95            last = i;
     96            nMatches++;
     97            if ((int)length == specPtr->minChars) {
     98                break;
     99            }
     100        }
    103101    }
    104102    if (nMatches > 1) {
    105     return -2;      /* Ambiguous operation name */
     103        return -2;      /* Ambiguous operation name */
    106104    }
    107105    if (nMatches == 0) {
    108     return -1;      /* Can't find operation */
     106        return -1;      /* Can't find operation */
    109107    }
    110108    return last;        /* Op found. */
     
    122120 */
    123121Tcl_ObjCmdProc *
    124 Rappture::GetOpFromObj(
    125     Tcl_Interp *interp,                 /* Interpreter to report errors to */
    126     int nSpecs,                         /* Number of specifications in array */
    127     Rappture::CmdSpec *specs,           /* Op specification array */
    128     int operPos,                        /* Position of operation in argument
    129                                          * list. */
    130     int objc,                           /* Number of arguments in the argument
    131                                          * vector.  This includes any prefixed
    132                                          * arguments */
    133     Tcl_Obj *const *objv,               /* Argument vector */
    134     int flags)
     122Rappture::GetOpFromObj(Tcl_Interp *interp,              /* Interpreter to report errors to */
     123                       int nSpecs,                      /* Number of specifications in array */
     124                       Rappture::CmdSpec *specs,        /* Op specification array */
     125                       int operPos,                     /* Position of operation in argument
     126                                                         * list. */
     127                       int objc,                        /* Number of arguments in the argument
     128                                                         * vector.  This includes any prefixed
     129                                                         * arguments */
     130                       Tcl_Obj *const *objv,            /* Argument vector */
     131                       int flags)
    135132{
    136133    CmdSpec *specPtr;
     
    139136
    140137    if (objc <= operPos) {  /* No operation argument */
    141     Tcl_AppendResult(interp, "wrong # args: ", (char *)NULL);
    142       usage:
    143     Tcl_AppendResult(interp, "should be one of...", (char *)NULL);
    144     for (n = 0; n < nSpecs; n++) {
    145         int i;
    146 
    147         Tcl_AppendResult(interp, "\n  ", (char *)NULL);
    148         for (i = 0; i < operPos; i++) {
    149         Tcl_AppendResult(interp, Tcl_GetString(objv[i]), " ",
    150              (char *)NULL);
    151         }
    152         specPtr = specs + n;
    153         Tcl_AppendResult(interp, specPtr->name, " ", specPtr->usage,
    154         (char *)NULL);
    155     }
    156     return NULL;
     138        Tcl_AppendResult(interp, "wrong # args: ", (char *)NULL);
     139usage:
     140        Tcl_AppendResult(interp, "should be one of...", (char *)NULL);
     141        for (n = 0; n < nSpecs; n++) {
     142            int i;
     143
     144            Tcl_AppendResult(interp, "\n  ", (char *)NULL);
     145            for (i = 0; i < operPos; i++) {
     146                Tcl_AppendResult(interp, Tcl_GetString(objv[i]), " ",
     147                                 (char *)NULL);
     148            }
     149            specPtr = specs + n;
     150            Tcl_AppendResult(interp, specPtr->name, " ", specPtr->usage,
     151                             (char *)NULL);
     152        }
     153        return NULL;
    157154    }
    158155    string = Tcl_GetString(objv[operPos]);
    159156    if (flags & CMDSPEC_LINEAR_SEARCH) {
    160     n = LinearOpSearch(specs, nSpecs, string);
     157        n = LinearOpSearch(specs, nSpecs, string);
    161158    } else {
    162     n = BinaryOpSearch(specs, nSpecs, string);
     159        n = BinaryOpSearch(specs, nSpecs, string);
    163160    }
    164161    if (n == -2) {
    165     char c;
    166     size_t length;
    167 
    168     Tcl_AppendResult(interp, "ambiguous", (char *)NULL);
    169     if (operPos > 2) {
    170         Tcl_AppendResult(interp, " ", Tcl_GetString(objv[operPos - 1]),
    171         (char *)NULL);
    172     }
    173     Tcl_AppendResult(interp, " operation \"", string, "\" matches: ",
    174         (char *)NULL);
    175 
    176     c = string[0];
    177     length = strlen(string);
    178     for (n = 0; n < nSpecs; n++) {
    179         specPtr = specs + n;
    180         if ((c == specPtr->name[0]) &&
    181         (strncmp(string, specPtr->name, length) == 0)) {
    182         Tcl_AppendResult(interp, " ", specPtr->name, (char *)NULL);
    183         }
    184     }
    185     return NULL;
     162        char c;
     163        size_t length;
     164
     165        Tcl_AppendResult(interp, "ambiguous", (char *)NULL);
     166        if (operPos > 2) {
     167            Tcl_AppendResult(interp, " ", Tcl_GetString(objv[operPos - 1]),
     168                             (char *)NULL);
     169        }
     170        Tcl_AppendResult(interp, " operation \"", string, "\" matches: ",
     171                         (char *)NULL);
     172
     173        c = string[0];
     174        length = strlen(string);
     175        for (n = 0; n < nSpecs; n++) {
     176            specPtr = specs + n;
     177            if ((c == specPtr->name[0]) &&
     178                (strncmp(string, specPtr->name, length) == 0)) {
     179                Tcl_AppendResult(interp, " ", specPtr->name, (char *)NULL);
     180            }
     181        }
     182        return NULL;
    186183
    187184    } else if (n == -1) {   /* Can't find operation, display help */
    188     Tcl_AppendResult(interp, "bad", (char *)NULL);
    189     if (operPos > 2) {
    190         Tcl_AppendResult(interp, " ", Tcl_GetString(objv[operPos - 1]),
    191         (char *)NULL);
    192     }
    193     Tcl_AppendResult(interp, " operation \"", string, "\": ", (char *)NULL);
    194     goto usage;
     185        Tcl_AppendResult(interp, "bad", (char *)NULL);
     186        if (operPos > 2) {
     187            Tcl_AppendResult(interp, " ", Tcl_GetString(objv[operPos - 1]),
     188                             (char *)NULL);
     189        }
     190        Tcl_AppendResult(interp, " operation \"", string, "\": ", (char *)NULL);
     191        goto usage;
    195192    }
    196193    specPtr = specs + n;
    197194    if ((objc < specPtr->minArgs) ||
    198     ((specPtr->maxArgs > 0) && (objc > specPtr->maxArgs))) {
    199     int i;
    200 
    201     Tcl_AppendResult(interp, "wrong # args: should be \"", (char *)NULL);
    202     for (i = 0; i < operPos; i++) {
    203         Tcl_AppendResult(interp, Tcl_GetString(objv[i]), " ",
    204         (char *)NULL);
    205     }
    206     Tcl_AppendResult(interp, specPtr->name, " ", specPtr->usage, "\"",
    207         (char *)NULL);
    208     return NULL;
     195        ((specPtr->maxArgs > 0) && (objc > specPtr->maxArgs))) {
     196        int i;
     197
     198        Tcl_AppendResult(interp, "wrong # args: should be \"", (char *)NULL);
     199        for (i = 0; i < operPos; i++) {
     200            Tcl_AppendResult(interp, Tcl_GetString(objv[i]), " ",
     201                             (char *)NULL);
     202        }
     203        Tcl_AppendResult(interp, specPtr->name, " ", specPtr->usage, "\"",
     204                         (char *)NULL);
     205        return NULL;
    209206    }
    210207    return specPtr->proc;
  • trunk/packages/vizservers/vtkvis/CmdProc.h

    r2100 r2123  
    2020 */
    2121typedef struct {
    22     const char *name;           /* Name of operation */
    23     int minChars;               /* Minimum # characters to disambiguate */
     22    const char *name;           /**< Name of operation */
     23    int minChars;               /**< Minimum # characters to disambiguate */
    2424    Tcl_ObjCmdProc *proc;
    25     int minArgs;                /* Minimum # args required */
    26     int maxArgs;                /* Maximum # args required */
    27     const char *usage;          /* Usage message */
     25    int minArgs;                /**< Minimum # args required */
     26    int maxArgs;                /**< Maximum # args required */
     27    const char *usage;          /**< Usage message */
    2828} CmdSpec;
    2929
    3030typedef enum {
    31     CMDSPEC_ARG0,               /* Op is the first argument. */
    32     CMDSPEC_ARG1,               /* Op is the second argument. */
    33     CMDSPEC_ARG2,               /* Op is the third argument. */
    34     CMDSPEC_ARG3,               /* Op is the fourth argument. */
    35     CMDSPEC_ARG4                /* Op is the fifth argument. */
     31    CMDSPEC_ARG0,               /**< Op is the first argument. */
     32    CMDSPEC_ARG1,               /**< Op is the second argument. */
     33    CMDSPEC_ARG2,               /**< Op is the third argument. */
     34    CMDSPEC_ARG3,               /**< Op is the fourth argument. */
     35    CMDSPEC_ARG4                /**< Op is the fifth argument. */
    3636} CmdSpecIndex;
    3737
  • trunk/packages/vizservers/vtkvis/RpContour2D.cpp

    r2121 r2123  
    1111
    1212#include "RpContour2D.h"
     13#include "Trace.h"
    1314
    1415using namespace Rappture::VtkVis;
     
    2728Contour2D::~Contour2D()
    2829{
     30#ifdef WANT_TRACE
     31    if (_dataSet != NULL)
     32        TRACE("Deleting Contour2D for %s", _dataSet->getName().c_str());
     33    else
     34        TRACE("Deleting Contour2D with NULL DataSet");
     35#endif
    2936}
    3037
  • trunk/packages/vizservers/vtkvis/RpPolyData.cpp

    r2121 r2123  
    3232PolyData::~PolyData()
    3333{
     34#ifdef WANT_TRACE
     35    if (_dataSet != NULL)
     36        TRACE("Deleting PolyData for %s", _dataSet->getName().c_str());
     37    else
     38        TRACE("Deleting PolyData with NULL DataSet");
     39#endif
    3440}
    3541
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp

    r2121 r2123  
    2929PseudoColor::~PseudoColor()
    3030{
     31#ifdef WANT_TRACE
     32    if (_dataSet != NULL)
     33        TRACE("Deleting PseudoColor for %s", _dataSet->getName().c_str());
     34    else
     35        TRACE("Deleting PseudoColor with NULL DataSet");
     36#endif
    3137}
    3238
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2121 r2123  
    3030
    3131#include "RpVtkRenderer.h"
     32#include "ColorMap.h"
    3233#include "Trace.h"
    3334
     
    8687    }
    8788    _colorMaps.clear();
    88     for (DataSetHashmap::iterator itr = _dataSets.begin();
    89              itr != _dataSets.end(); ++itr) {
    90         delete itr->second;
    91     }
    92     _dataSets.clear();
    9389    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    9490             itr != _pseudoColors.end(); ++itr) {
     
    106102    }
    107103    _polyDatas.clear();
     104    for (DataSetHashmap::iterator itr = _dataSets.begin();
     105             itr != _dataSets.end(); ++itr) {
     106        delete itr->second;
     107    }
     108    _dataSets.clear();
    108109}
    109110
     
    115116 * be added to the Renderer.
    116117 */
    117 void Renderer::addDataSet(DataSetId id)
     118void Renderer::addDataSet(const DataSetId& id)
    118119{
    119120    if (getDataSet(id) != NULL) {
     
    129130 * The underlying PseudoColor object is deleted, freeing its memory
    130131 */
    131 void Renderer::deletePseudoColor(DataSetId id)
    132 {
    133     PseudoColorHashmap::iterator itr = _pseudoColors.find(id);
     132void Renderer::deletePseudoColor(const DataSetId& id)
     133{
     134    PseudoColorHashmap::iterator itr;
     135
     136    bool doAll = false;
     137
     138    if (id.compare("all") == 0) {
     139        itr = _pseudoColors.begin();
     140        doAll = true;
     141    } else {
     142        itr = _pseudoColors.find(id);
     143    }
    134144    if (itr == _pseudoColors.end()) {
    135145        ERROR("PseudoColor not found: %s", id.c_str());
     
    139149    TRACE("Deleting PseudoColors for %s", id.c_str());
    140150
    141     PseudoColor *ps = itr->second;
    142     if (ps->getActor())
    143         _renderer->RemoveActor(ps->getActor());
    144     delete ps;
    145 
    146     _pseudoColors.erase(itr);
     151    do  {
     152        PseudoColor *ps = itr->second;
     153        if (ps->getActor())
     154            _renderer->RemoveActor(ps->getActor());
     155        delete ps;
     156
     157        _pseudoColors.erase(itr);
     158    } while (doAll && ++itr != _pseudoColors.end());
     159
    147160    _needsRedraw = true;
    148161}
     
    153166 * The underlying Contour2D is deleted, freeing its memory
    154167 */
    155 void Renderer::deleteContour2D(DataSetId id)
    156 {
    157     Contour2DHashmap::iterator itr = _contours.find(id);
     168void Renderer::deleteContour2D(const DataSetId& id)
     169{
     170    Contour2DHashmap::iterator itr;
     171
     172    bool doAll = false;
     173
     174    if (id.compare("all") == 0) {
     175        itr = _contours.begin();
     176        doAll = true;
     177    } else {
     178        itr = _contours.find(id);
     179    }
    158180    if (itr == _contours.end()) {
    159181        ERROR("Contour2D not found: %s", id.c_str());
     
    163185    TRACE("Deleting Contour2Ds for %s", id.c_str());
    164186
    165     Contour2D *contour = itr->second;
    166     if (contour->getActor())
    167         _renderer->RemoveActor(contour->getActor());
    168     delete contour;
    169 
    170     _contours.erase(itr);
     187    do {
     188        Contour2D *contour = itr->second;
     189        if (contour->getActor())
     190            _renderer->RemoveActor(contour->getActor());
     191        delete contour;
     192
     193        _contours.erase(itr);
     194    } while (doAll && ++itr != _contours.end());
     195
    171196    _needsRedraw = true;
    172197}
     
    177202 * The underlying PolyData is deleted, freeing its memory
    178203 */
    179 void Renderer::deletePolyData(DataSetId id)
    180 {
    181     PolyDataHashmap::iterator itr = _polyDatas.find(id);
     204void Renderer::deletePolyData(const DataSetId& id)
     205{
     206    PolyDataHashmap::iterator itr;
     207   
     208    bool doAll = false;
     209
     210    if (id.compare("all") == 0) {
     211        itr = _polyDatas.begin();
     212        doAll = true;
     213    } else {
     214        itr = _polyDatas.find(id);
     215    }
    182216    if (itr == _polyDatas.end()) {
    183217        ERROR("PolyData not found: %s", id.c_str());
     
    187221    TRACE("Deleting PolyDatas for %s", id.c_str());
    188222
    189     PolyData *polyData = itr->second;
    190     if (polyData->getActor())
    191         _renderer->RemoveActor(polyData->getActor());
    192     delete polyData;
    193 
    194     _polyDatas.erase(itr);
     223    do {
     224        PolyData *polyData = itr->second;
     225        if (polyData->getActor())
     226            _renderer->RemoveActor(polyData->getActor());
     227        delete polyData;
     228
     229        _polyDatas.erase(itr);
     230    } while (doAll && ++itr != _polyDatas.end());
     231
    195232    _needsRedraw = true;
    196233}
     
    202239 * objects are deleted, freeing the memory used.
    203240 */
    204 void Renderer::deleteDataSet(DataSetId id)
    205 {
    206     DataSetHashmap::iterator itr = _dataSets.find(id);
     241void Renderer::deleteDataSet(const DataSetId& id)
     242{
     243    DataSetHashmap::iterator itr;
     244
     245    bool doAll = false;
     246
     247    if (id.compare("all") == 0) {
     248        itr = _dataSets.begin();
     249        doAll = true;
     250    } else {
     251        itr = _dataSets.find(id);
     252    }
    207253    if (itr == _dataSets.end()) {
    208254        ERROR("Unknown dataset %s", id.c_str());
    209255        return;
    210     } else {
    211         TRACE("Deleting dataset %s", id.c_str());
    212 
    213         deletePseudoColor(id);
    214         deleteContour2D(id);
    215         deletePolyData(id);
    216        
     256    }
     257
     258    do {
     259        TRACE("Deleting dataset %s", itr->second->getName().c_str());
     260
     261        deletePseudoColor(itr->second->getName());
     262        deleteContour2D(itr->second->getName());
     263        deletePolyData(itr->second->getName());
     264   
    217265        TRACE("After deleting graphics objects");
    218266
     
    222270        delete itr->second;
    223271        _dataSets.erase(itr);
    224          _needsRedraw = true;
    225     }
     272    } while (doAll && ++itr != _dataSets.end());
     273
     274    _needsRedraw = true;
    226275}
    227276
     
    231280 * \return A pointer to the DataSet, or NULL if not found
    232281 */
    233 DataSet *Renderer::getDataSet(DataSetId id)
     282DataSet *Renderer::getDataSet(const DataSetId& id)
    234283{
    235284    DataSetHashmap::iterator itr = _dataSets.find(id);
     
    244293 * \brief (Re-)load the data for the specified DataSet key from a file
    245294 */
    246 bool Renderer::setDataFile(DataSetId id, const char *filename)
     295bool Renderer::setDataFile(const DataSetId& id, const char *filename)
    247296{
    248297    DataSet *ds = getDataSet(id);
     
    262311 * \brief (Re-)load the data for the specified DataSet key from a memory buffer
    263312 */
    264 bool Renderer::setData(DataSetId id, char *data, int nbytes)
     313bool Renderer::setData(const DataSetId& id, char *data, int nbytes)
    265314{
    266315    DataSet *ds = getDataSet(id);
     
    525574 * \brief Add a color map for use in the Renderer
    526575 */
    527 void Renderer::addColorMap(ColorMapId id, ColorMap *colorMap)
     576void Renderer::addColorMap(const ColorMapId& id, ColorMap *colorMap)
    528577{
    529578    if (colorMap != NULL) {
     
    542591 * \brief Return the ColorMap associated with the colormap key given
    543592 */
    544 ColorMap *Renderer::getColorMap(ColorMapId id)
     593ColorMap *Renderer::getColorMap(const ColorMapId& id)
    545594{
    546595    ColorMapHashmap::iterator itr = _colorMaps.find(id);
     
    558607 * by any other objects
    559608 */
    560 void Renderer::deleteColorMap(ColorMapId id)
     609void Renderer::deleteColorMap(const ColorMapId& id)
    561610{
    562611    ColorMapHashmap::iterator itr = _colorMaps.find(id);
     
    572621 * \brief Render a labelled legend image for the given colormap
    573622 *
    574  * \return The image is rendered into the supplied array
    575  */
    576 void Renderer::renderColorMap(ColorMapId id, const char *title,
     623 * \return The image is rendered into the supplied array, false is
     624 * returned if the color map is not found
     625 */
     626bool Renderer::renderColorMap(const ColorMapId& id, const char *title,
    577627                              int width, int height,
    578628                              vtkUnsignedCharArray *imgData)
    579629{
     630    ColorMap *colorMap = getColorMap(id);
     631    if (colorMap == NULL)
     632        return false;
     633
    580634    if (_legendRenderWindow == NULL) {
    581635        _legendRenderWindow = vtkSmartPointer<vtkRenderWindow>::New();
     
    597651        _legendRenderer->AddActor(_scalarBarActor);
    598652    }
    599     _scalarBarActor->SetLookupTable(getColorMap(id)->getLookupTable());
     653    _scalarBarActor->SetLookupTable(colorMap->getLookupTable());
    600654    // Set viewport-relative width/height/pos
    601655    if (width > height) {
     
    619673
    620674    _legendRenderWindow->GetPixelData(0, 0, width-1, height-1, 1, imgData);
     675    return true;
    621676}
    622677
     
    624679 * \brief Create a new PseudoColor rendering for the specified DataSet
    625680 */
    626 void Renderer::addPseudoColor(DataSetId id)
     681void Renderer::addPseudoColor(const DataSetId& id)
    627682{
    628683    DataSet *ds = getDataSet(id);
     
    648703 * \brief Get the PseudoColor associated with the specified DataSet
    649704 */
    650 PseudoColor *Renderer::getPseudoColor(DataSetId id)
     705PseudoColor *Renderer::getPseudoColor(const DataSetId& id)
    651706{
    652707    PseudoColorHashmap::iterator itr = _pseudoColors.find(id);
     
    662717 * \brief Associate an existing named color map with a DataSet
    663718 */
    664 void Renderer::setPseudoColorColorMap(DataSetId id, ColorMapId colorMapId)
     719void Renderer::setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId)
    665720{
    666721    PseudoColor *pc = getPseudoColor(id);
     
    685740 * \return The associated lookup table or NULL if not found
    686741 */
    687 vtkLookupTable *Renderer::getPseudoColorColorMap(DataSetId id)
     742vtkLookupTable *Renderer::getPseudoColorColorMap(const DataSetId& id)
    688743{
    689744    PseudoColor *pc = getPseudoColor(id);
     
    697752 * \brief Turn on/off rendering of the PseudoColor mapper for the given DataSet
    698753 */
    699 void Renderer::setPseudoColorVisibility(DataSetId id, bool state)
     754void Renderer::setPseudoColorVisibility(const DataSetId& id, bool state)
    700755{
    701756    PseudoColor *pc = getPseudoColor(id);
     
    709764 * \brief Set the visibility of polygon edges for the specified DataSet
    710765 */
    711 void Renderer::setPseudoColorEdgeVisibility(DataSetId id, bool state)
     766void Renderer::setPseudoColorEdgeVisibility(const DataSetId& id, bool state)
    712767{
    713768    PseudoColor *pc = getPseudoColor(id);
     
    721776 * \brief Set the RGB polygon edge color for the specified DataSet
    722777 */
    723 void Renderer::setPseudoColorEdgeColor(DataSetId id, float color[3])
     778void Renderer::setPseudoColorEdgeColor(const DataSetId& id, float color[3])
    724779{
    725780    PseudoColor *pc = getPseudoColor(id);
     
    736791 * this function may not have an effect.
    737792 */
    738 void Renderer::setPseudoColorEdgeWidth(DataSetId id, float edgeWidth)
     793void Renderer::setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth)
    739794{
    740795    PseudoColor *pc = getPseudoColor(id);
     
    748803 * \brief Turn mesh lighting on/off for the specified DataSet
    749804 */
    750 void Renderer::setPseudoColorLighting(DataSetId id, bool state)
     805void Renderer::setPseudoColorLighting(const DataSetId& id, bool state)
    751806{
    752807    PseudoColor *pc = getPseudoColor(id);
     
    760815 * \brief Create a new Contour2D and associate it with the named DataSet
    761816 */
    762 void Renderer::addContour2D(DataSetId id)
     817void Renderer::addContour2D(const DataSetId& id)
    763818{
    764819    DataSet *ds = getDataSet(id);
     
    785840 * \brief Get the Contour2D associated with a named DataSet
    786841 */
    787 Contour2D *Renderer::getContour2D(DataSetId id)
     842Contour2D *Renderer::getContour2D(const DataSetId& id)
    788843{
    789844    Contour2DHashmap::iterator itr = _contours.find(id);
     
    799854 * \brief Set the number of equally spaced contour isolines for the given DataSet
    800855 */
    801 void Renderer::setContours(DataSetId id, int numContours)
     856void Renderer::setContours(const DataSetId& id, int numContours)
    802857{
    803858    Contour2D *contour = getContour2D(id);
     
    811866 * \brief Set a list of isovalues for the given DataSet
    812867 */
    813 void Renderer::setContourList(DataSetId id, const std::vector<double>& contours)
     868void Renderer::setContourList(const DataSetId& id, const std::vector<double>& contours)
    814869{
    815870    Contour2D *contour = getContour2D(id);
     
    823878 * \brief Turn on/off rendering contour lines for the given DataSet
    824879 */
    825 void Renderer::setContourVisibility(DataSetId id, bool state)
     880void Renderer::setContourVisibility(const DataSetId& id, bool state)
    826881{
    827882    Contour2D *contour = getContour2D(id);
     
    835890 * \brief Set the RGB isoline color for the specified DataSet
    836891 */
    837 void Renderer::setContourEdgeColor(DataSetId id, float color[3])
     892void Renderer::setContourEdgeColor(const DataSetId& id, float color[3])
    838893{
    839894    Contour2D *contour = getContour2D(id);
     
    850905 * this function may not have an effect.
    851906 */
    852 void Renderer::setContourEdgeWidth(DataSetId id, float edgeWidth)
     907void Renderer::setContourEdgeWidth(const DataSetId& id, float edgeWidth)
    853908{
    854909    Contour2D *contour = getContour2D(id);
     
    862917 * \brief Turn contour lighting on/off for the specified DataSet
    863918 */
    864 void Renderer::setContourLighting(DataSetId id, bool state)
     919void Renderer::setContourLighting(const DataSetId& id, bool state)
    865920{
    866921    Contour2D *contour = getContour2D(id);
     
    874929 * \brief Create a new PolyData and associate it with the named DataSet
    875930 */
    876 void Renderer::addPolyData(DataSetId id)
     931void Renderer::addPolyData(const DataSetId& id)
    877932{
    878933    DataSet *ds = getDataSet(id);
     
    901956 * \brief Get the PolyData associated with a named DataSet
    902957 */
    903 PolyData *Renderer::getPolyData(DataSetId id)
     958PolyData *Renderer::getPolyData(const DataSetId& id)
    904959{
    905960    PolyDataHashmap::iterator itr = _polyDatas.find(id);
     
    915970 * \brief Turn on/off rendering of the PolyData mapper for the given DataSet
    916971 */
    917 void Renderer::setPolyDataVisibility(DataSetId id, bool state)
     972void Renderer::setPolyDataVisibility(const DataSetId& id, bool state)
    918973{
    919974    PolyData *polyData = getPolyData(id);
     
    927982 * \brief Set the RGB polygon face color for the specified DataSet
    928983 */
    929 void Renderer::setPolyDataColor(DataSetId id, float color[3])
     984void Renderer::setPolyDataColor(const DataSetId& id, float color[3])
    930985{
    931986    PolyData *polyData = getPolyData(id);
     
    939994 * \brief Set the visibility of polygon edges for the specified DataSet
    940995 */
    941 void Renderer::setPolyDataEdgeVisibility(DataSetId id, bool state)
     996void Renderer::setPolyDataEdgeVisibility(const DataSetId& id, bool state)
    942997{
    943998    PolyData *polyData = getPolyData(id);
     
    9511006 * \brief Set the RGB polygon edge color for the specified DataSet
    9521007 */
    953 void Renderer::setPolyDataEdgeColor(DataSetId id, float color[3])
     1008void Renderer::setPolyDataEdgeColor(const DataSetId& id, float color[3])
    9541009{
    9551010    PolyData *polyData = getPolyData(id);
     
    9661021 * this function may not have an effect.
    9671022 */
    968 void Renderer::setPolyDataEdgeWidth(DataSetId id, float edgeWidth)
     1023void Renderer::setPolyDataEdgeWidth(const DataSetId& id, float edgeWidth)
    9691024{
    9701025    PolyData *polyData = getPolyData(id);
     
    9781033 * \brief Set wireframe rendering for the specified DataSet
    9791034 */
    980 void Renderer::setPolyDataWireframe(DataSetId id, bool state)
     1035void Renderer::setPolyDataWireframe(const DataSetId& id, bool state)
    9811036{
    9821037    PolyData *polyData = getPolyData(id);
     
    9901045 * \brief Turn mesh lighting on/off for the specified DataSet
    9911046 */
    992 void Renderer::setPolyDataLighting(DataSetId id, bool state)
     1047void Renderer::setPolyDataLighting(const DataSetId& id, bool state)
    9931048{
    9941049    PolyData *polyData = getPolyData(id);
     
    13841439 * \brief Set the opacity of the specified DataSet's associated graphics objects
    13851440 */
    1386 void Renderer::setOpacity(DataSetId id, double opacity)
     1441void Renderer::setOpacity(const DataSetId& id, double opacity)
    13871442{
    13881443    PseudoColor *pc = getPseudoColor(id);
     
    14061461 * \brief Turn on/off rendering of the specified DataSet's associated graphics objects
    14071462 */
    1408 void Renderer::setVisibility(DataSetId id, bool state)
     1463void Renderer::setVisibility(const DataSetId& id, bool state)
    14091464{
    14101465    setPseudoColorVisibility(id, state);
     
    14821537 * Note: no interpolation is performed on data
    14831538 */
    1484 double Renderer::getDataValueAtPixel(DataSetId id, int x, int y)
     1539double Renderer::getDataValueAtPixel(const DataSetId& id, int x, int y)
    14851540{
    14861541    vtkSmartPointer<vtkCoordinate> coord = vtkSmartPointer<vtkCoordinate>::New();
     
    15041559 * Note: no interpolation is performed on data
    15051560 */
    1506 double Renderer::getDataValue(DataSetId id, double x, double y, double z)
     1561double Renderer::getDataValue(const DataSetId& id, double x, double y, double z)
    15071562{
    15081563    DataSet *ds = getDataSet(id);
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2121 r2123  
    6666    // Data sets
    6767
    68     void addDataSet(DataSetId id);
    69 
    70     void deleteDataSet(DataSetId id);
    71 
    72     DataSet *getDataSet(DataSetId id);
    73 
    74     bool setData(DataSetId id, char *data, int nbytes);
    75 
    76     bool setDataFile(DataSetId id, const char *filename);
    77 
    78     double getDataValueAtPixel(DataSetId id, int x, int y);
    79 
    80     double getDataValue(DataSetId id, double x, double y, double z);
    81 
    82     void setOpacity(DataSetId id, double opacity);
    83 
    84     void setVisibility(DataSetId id, bool state);
     68    void addDataSet(const DataSetId& id);
     69
     70    void deleteDataSet(const DataSetId& id);
     71
     72    DataSet *getDataSet(const DataSetId& id);
     73
     74    bool setData(const DataSetId& id, char *data, int nbytes);
     75
     76    bool setDataFile(const DataSetId& id, const char *filename);
     77
     78    double getDataValueAtPixel(const DataSetId& id, int x, int y);
     79
     80    double getDataValue(const DataSetId& id, double x, double y, double z);
     81
     82    void setOpacity(const DataSetId& id, double opacity);
     83
     84    void setVisibility(const DataSetId& id, bool state);
    8585
    8686    // Render window
     
    132132    // Colormaps
    133133
    134     void addColorMap(ColorMapId id, ColorMap *colorMap);
    135 
    136     void deleteColorMap(ColorMapId id);
    137 
    138     ColorMap *getColorMap(ColorMapId id);
    139 
    140     void renderColorMap(ColorMapId id, const char *title,
     134    void addColorMap(const ColorMapId& id, ColorMap *colorMap);
     135
     136    void deleteColorMap(const ColorMapId& id);
     137
     138    ColorMap *getColorMap(const ColorMapId& id);
     139
     140    bool renderColorMap(const ColorMapId& id, const char *title,
    141141                        int width, int height,
    142142                        vtkUnsignedCharArray *imgData);
     
    144144    // Color-mapped surfaces
    145145
    146     void addPseudoColor(DataSetId id);
    147 
    148     void deletePseudoColor(DataSetId id);
    149 
    150     PseudoColor *getPseudoColor(DataSetId id);
    151 
    152     void setPseudoColorColorMap(DataSetId id, ColorMapId colorMapId);
    153 
    154     vtkLookupTable *getPseudoColorColorMap(DataSetId id);
    155 
    156     void setPseudoColorVisibility(DataSetId id, bool state);
    157 
    158     void setPseudoColorEdgeVisibility(DataSetId id, bool state);
    159 
    160     void setPseudoColorEdgeColor(DataSetId id, float color[3]);
    161 
    162     void setPseudoColorEdgeWidth(DataSetId id, float edgeWidth);
    163 
    164     void setPseudoColorLighting(DataSetId id, bool state);
     146    void addPseudoColor(const DataSetId& id);
     147
     148    void deletePseudoColor(const DataSetId& id);
     149
     150    PseudoColor *getPseudoColor(const DataSetId& id);
     151
     152    void setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId);
     153
     154    vtkLookupTable *getPseudoColorColorMap(const DataSetId& id);
     155
     156    void setPseudoColorVisibility(const DataSetId& id, bool state);
     157
     158    void setPseudoColorEdgeVisibility(const DataSetId& id, bool state);
     159
     160    void setPseudoColorEdgeColor(const DataSetId& id, float color[3]);
     161
     162    void setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth);
     163
     164    void setPseudoColorLighting(const DataSetId& id, bool state);
    165165
    166166    // Contour plots
    167167
    168     void addContour2D(DataSetId id);
    169 
    170     void deleteContour2D(DataSetId id);
    171 
    172     Contour2D *getContour2D(DataSetId id);
    173 
    174     void setContours(DataSetId id, int numContours);
    175 
    176     void setContourList(DataSetId id, const std::vector<double>& contours);
    177 
    178     void setContourVisibility(DataSetId id, bool state);
    179 
    180     void setContourEdgeColor(DataSetId id, float color[3]);
    181 
    182     void setContourEdgeWidth(DataSetId id, float edgeWidth);
    183 
    184     void setContourLighting(DataSetId id, bool state);
     168    void addContour2D(const DataSetId& id);
     169
     170    void deleteContour2D(const DataSetId& id);
     171
     172    Contour2D *getContour2D(const DataSetId& id);
     173
     174    void setContours(const DataSetId& id, int numContours);
     175
     176    void setContourList(const DataSetId& id, const std::vector<double>& contours);
     177
     178    void setContourVisibility(const DataSetId& id, bool state);
     179
     180    void setContourEdgeColor(const DataSetId& id, float color[3]);
     181
     182    void setContourEdgeWidth(const DataSetId& id, float edgeWidth);
     183
     184    void setContourLighting(const DataSetId& id, bool state);
    185185
    186186    // Meshes
    187187
    188     void addPolyData(DataSetId id);
     188    void addPolyData(const DataSetId& id);
    189189   
    190     void deletePolyData(DataSetId id);
    191 
    192     PolyData *getPolyData(DataSetId id);
    193 
    194     void setPolyDataVisibility(DataSetId id, bool state);
    195 
    196     void setPolyDataColor(DataSetId id, float color[3]);
    197 
    198     void setPolyDataEdgeVisibility(DataSetId id, bool state);
    199 
    200     void setPolyDataEdgeColor(DataSetId id, float color[3]);
    201 
    202     void setPolyDataEdgeWidth(DataSetId id, float edgeWidth);
    203 
    204     void setPolyDataWireframe(DataSetId id, bool state);
    205 
    206     void setPolyDataLighting(DataSetId id, bool state);
     190    void deletePolyData(const DataSetId& id);
     191
     192    PolyData *getPolyData(const DataSetId& id);
     193
     194    void setPolyDataVisibility(const DataSetId& id, bool state);
     195
     196    void setPolyDataColor(const DataSetId& id, float color[3]);
     197
     198    void setPolyDataEdgeVisibility(const DataSetId& id, bool state);
     199
     200    void setPolyDataEdgeColor(const DataSetId& id, float color[3]);
     201
     202    void setPolyDataEdgeWidth(const DataSetId& id, float edgeWidth);
     203
     204    void setPolyDataWireframe(const DataSetId& id, bool state);
     205
     206    void setPolyDataLighting(const DataSetId& id, bool state);
    207207
    208208private:
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2115 r2123  
    172172    {"name", 1, AxisNameOp, 4, 4, "axis title"},
    173173    {"units", 1, AxisUnitsOp, 4, 4, "axis units"},
    174     {"visible", 1, AxisVisibleOp, 4, 4, "axis bool"},
     174    {"visible", 1, AxisVisibleOp, 4, 4, "axis bool"}
    175175};
    176176static int nAxisOps = NumCmdSpecs(axisOps);
     
    298298    {"reset", 2, CameraResetOp, 2, 3, "?all?"},
    299299    {"rotate", 2, CameraRotateOp, 5, 5, "angle angle angle"},
    300     {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"},
     300    {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"}
    301301};
    302302static int nCameraOps = NumCmdSpecs(cameraOps);
     
    490490                  Tcl_Obj *const *objv)
    491491{
    492     const char *name = Tcl_GetString(objv[2]);
    493     g_renderer->deleteContour2D(name);
     492    if (objc == 3) {
     493        const char *name = Tcl_GetString(objv[2]);
     494        g_renderer->deleteContour2D(name);
     495    } else {
     496        g_renderer->deleteContour2D("all");
     497    }
    494498    return TCL_OK;
    495499}
     
    551555static Rappture::CmdSpec contour2dOps[] = {
    552556    {"add", 1, Contour2DAddOp, 5, 5, "oper value dataSetName"},
    553     {"delete", 1, Contour2DDeleteOp, 3, 3, "dataSetName"},
     557    {"delete", 1, Contour2DDeleteOp, 2, 3, "?dataSetName?"},
    554558    {"lighting", 3, Contour2DLightingOp, 4, 4, "bool dataSetName"},
    555559    {"linecolor", 5, Contour2DLineColorOp, 6, 6, "r g b dataSetName"},
    556560    {"linewidth", 5, Contour2DLineWidthOp, 4, 4, "width dataSetName"},
    557     {"visible", 1, Contour2DVisibleOp, 4, 4, "bool dataSetName"},
     561    {"visible", 1, Contour2DVisibleOp, 4, 4, "bool dataSetName"}
    558562};
    559563static int nContour2dOps = NumCmdSpecs(contour2dOps);
     
    627631                Tcl_Obj *const *objv)
    628632{
    629     const char *name = Tcl_GetString(objv[2]);
    630     TRACE("Deleting dataset %s", name);
    631     g_renderer->deleteDataSet(name);
     633    if (objc == 3) {
     634        const char *name = Tcl_GetString(objv[2]);
     635        TRACE("Deleting dataset %s", name);
     636        g_renderer->deleteDataSet(name);
     637    } else {
     638        g_renderer->deleteDataSet("all");
     639    }
    632640    return TCL_OK;
    633641}
     
    736744static Rappture::CmdSpec dataSetOps[] = {
    737745    {"add", 1, DataSetAddOp, 6, 6, "name data follows nBytes"},
    738     {"delete", 1, DataSetDeleteOp, 3, 3, "name"},
     746    {"delete", 1, DataSetDeleteOp, 2, 3, "?name?"},
    739747    {"getvalue", 1, DataSetGetValueOp, 6, 7, "oper x y ?z? name"},
    740748    {"opacity", 1, DataSetOpacityOp, 4, 4, "value name"},
     
    778786        vtkSmartPointer<vtkUnsignedCharArray>::New();
    779787
    780     g_renderer->renderColorMap(name, title, width, height, imgData);
     788    if (!g_renderer->renderColorMap(name, title, width, height, imgData)) {
     789        Tcl_AppendResult(interp, "Color map \"",
     790                name, "\" was not found", (char*)NULL);
     791        return TCL_ERROR;
     792    }
    781793
    782794#ifdef DEBUG
     
    814826                  Tcl_Obj *const *objv)
    815827{
    816     const char *name = Tcl_GetString(objv[2]);
    817     g_renderer->deletePseudoColor(name);
     828    if (objc == 3) {
     829        const char *name = Tcl_GetString(objv[2]);
     830        g_renderer->deletePseudoColor(name);
     831    } else {
     832        g_renderer->deletePseudoColor("all");
     833    }
    818834    return TCL_OK;
    819835}
     
    889905    {"add", 1, PseudoColorAddOp, 3, 3, "dataSetName"},
    890906    {"colormap", 1, PseudoColorColorMapOp, 4, 4, "colorMapName dataSetName"},
    891     {"delete", 1, PseudoColorDeleteOp, 3, 3, "dataSetName"},
     907    {"delete", 1, PseudoColorDeleteOp, 2, 3, "?dataSetName?"},
    892908    {"edges", 1, PseudoColorEdgeVisibilityOp, 4, 4, "bool dataSetName"},
    893909    {"lighting", 3, PseudoColorLightingOp, 4, 4, "bool dataSetName"},
     
    925941                 Tcl_Obj *const *objv)
    926942{
    927     const char *name = Tcl_GetString(objv[2]);
    928     g_renderer->deletePolyData(name);
     943    if (objc == 3) {
     944        const char *name = Tcl_GetString(objv[2]);
     945        g_renderer->deletePolyData(name);
     946    } else {
     947        g_renderer->deletePolyData("all");
     948    }
    929949    return TCL_OK;
    930950}
     
    10281048    {"add", 1, PolyDataAddOp, 3, 3, "dataSetName"},
    10291049    {"color", 1, PolyDataColorOp, 6, 6, "r g b dataSetName"},
    1030     {"delete", 1, PolyDataDeleteOp, 3, 3, "dataSetName"},
     1050    {"delete", 1, PolyDataDeleteOp, 2, 3, "?dataSetName?"},
    10311051    {"edges", 1, PolyDataEdgeVisibilityOp, 4, 4, "bool dataSetName"},
    10321052    {"lighting", 3, PolyDataLightingOp, 4, 4, "bool dataSetName"},
Note: See TracChangeset for help on using the changeset viewer.