Ignore:
Timestamp:
Mar 1, 2011, 1:54:57 PM (14 years ago)
Author:
ldelgass
Message:

Add lighting toggle for graphics objects. Make camera pan/zoom commands work for image camera type (as alternative to setting rectangle), make camera rotate a no-op for image camera type.

File:
1 edited

Legend:

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

    r2113 r2114  
    368368
    369369/**
    370  * \brief Create a new PseudoColor rendering for the specified DataSet
    371  */
    372 void Renderer::addPseudoColor(DataSetId id)
    373 {
    374     DataSet *ds = getDataSet(id);
    375     if (ds == NULL)
    376         return;
    377 
    378     if (getPseudoColor(id)) {
    379         WARN("Replacing existing pseudocolor %s", id.c_str());
    380         deletePseudoColor(id);
    381     }
    382     PseudoColor *pc = new PseudoColor();
    383     _pseudoColors[id] = pc;
    384 
    385     pc->setDataSet(ds);
    386 
    387     _renderer->AddActor(pc->getActor());
    388 
    389     initCamera();
    390     _needsRedraw = true;
    391 }
    392 
    393 /**
    394  * \brief Get the PseudoColor associated with the specified DataSet
    395  */
    396 PseudoColor *Renderer::getPseudoColor(DataSetId id)
    397 {
    398     PseudoColorHashmap::iterator itr = _pseudoColors.find(id);
    399 
    400     if (itr == _pseudoColors.end()) {
    401         TRACE("PseudoColor not found: %s", id.c_str());
    402         return NULL;
    403     } else
    404         return itr->second;
    405 }
    406 
    407 /**
    408370 * \brief Turn on/off rendering of all axes gridlines
    409371 */
     
    630592
    631593/**
     594 * \brief Create a new PseudoColor rendering for the specified DataSet
     595 */
     596void Renderer::addPseudoColor(DataSetId id)
     597{
     598    DataSet *ds = getDataSet(id);
     599    if (ds == NULL)
     600        return;
     601
     602    if (getPseudoColor(id)) {
     603        WARN("Replacing existing pseudocolor %s", id.c_str());
     604        deletePseudoColor(id);
     605    }
     606    PseudoColor *pc = new PseudoColor();
     607    _pseudoColors[id] = pc;
     608
     609    pc->setDataSet(ds);
     610
     611    _renderer->AddActor(pc->getActor());
     612
     613    initCamera();
     614    _needsRedraw = true;
     615}
     616
     617/**
     618 * \brief Get the PseudoColor associated with the specified DataSet
     619 */
     620PseudoColor *Renderer::getPseudoColor(DataSetId id)
     621{
     622    PseudoColorHashmap::iterator itr = _pseudoColors.find(id);
     623
     624    if (itr == _pseudoColors.end()) {
     625        TRACE("PseudoColor not found: %s", id.c_str());
     626        return NULL;
     627    } else
     628        return itr->second;
     629}
     630
     631/**
    632632 * \brief Associate an existing named color map with a DataSet
    633633 */
     
    716716
    717717/**
     718 * \brief Turn mesh lighting on/off for the specified DataSet
     719 */
     720void Renderer::setPseudoColorLighting(DataSetId id, bool state)
     721{
     722    PseudoColor *pc = getPseudoColor(id);
     723    if (pc) {
     724        pc->setLighting(state);
     725        _needsRedraw = true;
     726    }
     727}
     728
     729/**
    718730 * \brief Create a new Contour2D and associate it with the named DataSet
    719731 */
     
    791803
    792804/**
     805 * \brief Set the RGB isoline color for the specified DataSet
     806 */
     807void Renderer::setContourEdgeColor(DataSetId id, float color[3])
     808{
     809    Contour2D *contour = getContour2D(id);
     810    if (contour) {
     811        contour->setEdgeColor(color);
     812        _needsRedraw = true;
     813    }
     814}
     815
     816/**
     817 * \brief Set the isoline width for the specified DataSet (may be a no-op)
     818 *
     819 * If the OpenGL implementation/hardware does not support wide lines,
     820 * this function may not have an effect.
     821 */
     822void Renderer::setContourEdgeWidth(DataSetId id, float edgeWidth)
     823{
     824    Contour2D *contour = getContour2D(id);
     825    if (contour) {
     826        contour->setEdgeWidth(edgeWidth);
     827        _needsRedraw = true;
     828    }
     829}
     830
     831/**
     832 * \brief Turn contour lighting on/off for the specified DataSet
     833 */
     834void Renderer::setContourLighting(DataSetId id, bool state)
     835{
     836    Contour2D *contour = getContour2D(id);
     837    if (contour) {
     838        contour->setLighting(state);
     839        _needsRedraw = true;
     840    }
     841}
     842
     843/**
    793844 * \brief Create a new PolyData and associate it with the named DataSet
    794845 */
     
    839890    if (polyData) {
    840891        polyData->setVisibility(state);
     892        _needsRedraw = true;
     893    }
     894}
     895
     896/**
     897 * \brief Set the RGB polygon face color for the specified DataSet
     898 */
     899void Renderer::setPolyDataColor(DataSetId id, float color[3])
     900{
     901    PolyData *polyData = getPolyData(id);
     902    if (polyData) {
     903        polyData->setColor(color);
     904        _needsRedraw = true;
     905    }
     906}
     907
     908/**
     909 * \brief Set the visibility of polygon edges for the specified DataSet
     910 */
     911void Renderer::setPolyDataEdgeVisibility(DataSetId id, bool state)
     912{
     913    PolyData *polyData = getPolyData(id);
     914    if (polyData) {
     915        polyData->setEdgeVisibility(state);
     916        _needsRedraw = true;
     917    }
     918}
     919
     920/**
     921 * \brief Set the RGB polygon edge color for the specified DataSet
     922 */
     923void Renderer::setPolyDataEdgeColor(DataSetId id, float color[3])
     924{
     925    PolyData *polyData = getPolyData(id);
     926    if (polyData) {
     927        polyData->setEdgeColor(color);
     928        _needsRedraw = true;
     929    }
     930}
     931
     932/**
     933 * \brief Set the polygon edge width for the specified DataSet (may be a no-op)
     934 *
     935 * If the OpenGL implementation/hardware does not support wide lines,
     936 * this function may not have an effect.
     937 */
     938void Renderer::setPolyDataEdgeWidth(DataSetId id, float edgeWidth)
     939{
     940    PolyData *polyData = getPolyData(id);
     941    if (polyData) {
     942        polyData->setEdgeWidth(edgeWidth);
     943        _needsRedraw = true;
     944    }
     945}
     946
     947/**
     948 * \brief Set wireframe rendering for the specified DataSet
     949 */
     950void Renderer::setPolyDataWireframe(DataSetId id, bool state)
     951{
     952    PolyData *polyData = getPolyData(id);
     953    if (polyData) {
     954        polyData->setWireframe(state);
     955        _needsRedraw = true;
     956    }
     957}
     958
     959/**
     960 * \brief Turn mesh lighting on/off for the specified DataSet
     961 */
     962void Renderer::setPolyDataLighting(DataSetId id, bool state)
     963{
     964    PolyData *polyData = getPolyData(id);
     965    if (polyData) {
     966        polyData->setLighting(state);
    841967        _needsRedraw = true;
    842968    }
     
    9561082void Renderer::rotateCamera(double yaw, double pitch, double roll)
    9571083{
     1084    if (_cameraMode == IMAGE)
     1085        return;
    9581086    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    9591087    camera->Azimuth(yaw); // Rotate about object
     
    9751103void Renderer::panCamera(double x, double y)
    9761104{
     1105    if (_cameraMode == IMAGE) {
     1106        _imgWorldOrigin[0] += x;
     1107        _imgWorldOrigin[1] += y;
     1108        setCameraZoomRegion(_imgWorldOrigin[0], _imgWorldOrigin[1],
     1109                            _imgWorldDims[0], _imgWorldDims[1]);
     1110        _needsRedraw = true;
     1111        return;
     1112    }
    9771113    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    9781114    vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New();
     
    9911127void Renderer::zoomCamera(double z)
    9921128{
     1129    if (_cameraMode == IMAGE) {
     1130        double dx = _imgWorldDims[0];
     1131        double dy = _imgWorldDims[1];
     1132        _imgWorldDims[0] /= z;
     1133        _imgWorldDims[1] /= z;
     1134        dx -= _imgWorldDims[0];
     1135        dy -= _imgWorldDims[1];
     1136        _imgWorldOrigin[0] += dx/2.0;
     1137        _imgWorldOrigin[1] += dy/2.0;
     1138        setCameraZoomRegion(_imgWorldOrigin[0], _imgWorldOrigin[1],
     1139                            _imgWorldDims[0], _imgWorldDims[1]);
     1140        _needsRedraw = true;
     1141        return;
     1142    }
    9931143    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    9941144    camera->Zoom(z); // Change perspective FOV angle or ortho parallel scale
     
    12081358    setContourVisibility(id, state);
    12091359    setPolyDataVisibility(id, state);
    1210 }
    1211 
    1212 /**
    1213  * \brief Set the RGB isoline color for the specified DataSet
    1214  */
    1215 void Renderer::setContourEdgeColor(DataSetId id, float color[3])
    1216 {
    1217     Contour2D *contour = getContour2D(id);
    1218     if (contour) {
    1219         contour->setEdgeColor(color);
    1220         _needsRedraw = true;
    1221     }
    1222 }
    1223 
    1224 /**
    1225  * \brief Set the isoline width for the specified DataSet (may be a no-op)
    1226  *
    1227  * If the OpenGL implementation/hardware does not support wide lines,
    1228  * this function may not have an effect.
    1229  */
    1230 void Renderer::setContourEdgeWidth(DataSetId id, float edgeWidth)
    1231 {
    1232     Contour2D *contour = getContour2D(id);
    1233     if (contour) {
    1234         contour->setEdgeWidth(edgeWidth);
    1235         _needsRedraw = true;
    1236     }
    1237 }
    1238 
    1239 /**
    1240  * \brief Set the RGB polygon face color for the specified DataSet
    1241  */
    1242 void Renderer::setPolyDataColor(DataSetId id, float color[3])
    1243 {
    1244     PolyData *polyData = getPolyData(id);
    1245     if (polyData) {
    1246         polyData->setColor(color);
    1247         _needsRedraw = true;
    1248     }
    1249 }
    1250 
    1251 /**
    1252  * \brief Set the visibility of polygon edges for the specified DataSet
    1253  */
    1254 void Renderer::setPolyDataEdgeVisibility(DataSetId id, bool state)
    1255 {
    1256     PolyData *polyData = getPolyData(id);
    1257     if (polyData) {
    1258         polyData->setEdgeVisibility(state);
    1259         _needsRedraw = true;
    1260     }
    1261 }
    1262 
    1263 /**
    1264  * \brief Set the RGB polygon edge color for the specified DataSet
    1265  */
    1266 void Renderer::setPolyDataEdgeColor(DataSetId id, float color[3])
    1267 {
    1268     PolyData *polyData = getPolyData(id);
    1269     if (polyData) {
    1270         polyData->setEdgeColor(color);
    1271         _needsRedraw = true;
    1272     }
    1273 }
    1274 
    1275 /**
    1276  * \brief Set the polygon edge width for the specified DataSet (may be a no-op)
    1277  *
    1278  * If the OpenGL implementation/hardware does not support wide lines,
    1279  * this function may not have an effect.
    1280  */
    1281 void Renderer::setPolyDataEdgeWidth(DataSetId id, float edgeWidth)
    1282 {
    1283     PolyData *polyData = getPolyData(id);
    1284     if (polyData) {
    1285         polyData->setEdgeWidth(edgeWidth);
    1286         _needsRedraw = true;
    1287     }
    1288 }
    1289 
    1290 /**
    1291  * \brief Set wireframe rendering for the specified DataSet
    1292  */
    1293 void Renderer::setPolyDataWireframe(DataSetId id, bool state)
    1294 {
    1295     PolyData *polyData = getPolyData(id);
    1296     if (polyData) {
    1297         polyData->setWireframe(state);
    1298         _needsRedraw = true;
    1299     }
    13001360}
    13011361
Note: See TracChangeset for help on using the changeset viewer.