Ignore:
Timestamp:
Sep 1, 2011, 11:40:10 AM (13 years ago)
Author:
ldelgass
Message:

Add option to turn on wireframe outline of DataSet? bounds

File:
1 edited

Legend:

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

    r2454 r2455  
    3232    _name(name),
    3333    _visible(true),
     34    _opacity(1),
    3435    _cellSizeAverage(0)
    3536{
     
    4344
    4445/**
     46 * \brief Create and initialize a VTK Prop to render the outline
     47 */
     48void DataSet::initProp()
     49{
     50    if (_prop == NULL) {
     51        _prop = vtkSmartPointer<vtkActor>::New();
     52        vtkProperty *property = _prop->GetProperty();
     53        property->EdgeVisibilityOff();
     54        property->SetOpacity(_opacity);
     55        property->SetAmbient(.2);
     56        property->LightingOff();
     57        _prop->SetVisibility((_visible ? 1 : 0));
     58    }
     59}
     60
     61/**
     62 * \brief Create and initialize a wireframe outline
     63 */
     64void DataSet::showOutline(bool state)
     65{
     66    if (state) {
     67        if (_outlineFilter == NULL) {
     68            _outlineFilter = vtkSmartPointer<vtkOutlineFilter>::New();
     69            _outlineFilter->SetInput(_dataSet);
     70        }
     71        if (_outlineMapper == NULL) {
     72            _outlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
     73            _outlineMapper->SetInputConnection(_outlineFilter->GetOutputPort());
     74        }
     75        initProp();
     76        _prop->SetMapper(_outlineMapper);
     77    } else {
     78        if (_prop != NULL) {
     79            _prop->SetMapper(NULL);
     80        }
     81        if (_outlineMapper != NULL) {
     82            _outlineMapper = NULL;
     83        }
     84        if (_outlineFilter != NULL) {
     85            _outlineFilter = NULL;
     86        }
     87    }
     88}
     89
     90/**
     91 * \brief Set opacity of DataSet outline
     92 *
     93 * This method is used for record-keeping and opacity of the
     94 * DataSet bounds outline.  The renderer controls opacity
     95 * of other related graphics objects.
     96 */
     97void DataSet::setOpacity(double opacity)
     98{
     99    _opacity = opacity;
     100    if (_prop != NULL) {
     101        _prop->GetProperty()->SetOpacity(opacity);
     102    }
     103}
     104
     105/**
    45106 * \brief Set visibility flag in DataSet
    46107 *
    47  * This method is used for record-keeping.  The renderer controls
    48  * the visibility of related graphics objects.
     108 * This method is used for record-keeping and visibility of the
     109 * DataSet bounds outline.  The renderer controls visibility
     110 * of other related graphics objects.
    49111 */
    50112void DataSet::setVisibility(bool state)
    51113{
    52114    _visible = state;
     115    if (_prop != NULL) {
     116        _prop->SetVisibility((state ? 1 : 0));
     117    }
    53118}
    54119
Note: See TracChangeset for help on using the changeset viewer.