- Timestamp:
- Mar 1, 2011, 1:54:57 PM (14 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpContour2D.cpp
r2112 r2114 199 199 } 200 200 } 201 202 /** 203 * \brief Turn on/off lighting of this object 204 */ 205 void Contour2D::setLighting(bool state) 206 { 207 if (_contourActor != NULL) 208 _contourActor->GetProperty()->SetLighting((state ? 1 : 0)); 209 } -
trunk/packages/vizservers/vtkvis/RpContour2D.h
r2112 r2114 49 49 void setClippingPlanes(vtkPlaneCollection *planes); 50 50 51 void setLighting(bool state); 52 51 53 private: 52 54 void initActor(); -
trunk/packages/vizservers/vtkvis/RpPolyData.cpp
r2112 r2114 19 19 PolyData::PolyData() : 20 20 _edgeWidth(1.0), 21 _opacity(1.0) 21 _opacity(1.0), 22 _lighting(true) 22 23 { 23 24 _color[0] = 0.0; … … 53 54 _pdActor->GetProperty()->SetLineWidth(_edgeWidth); 54 55 _pdActor->GetProperty()->SetOpacity(_opacity); 56 if (!_lighting) 57 _pdActor->GetProperty()->LightingOff(); 55 58 } 56 59 } … … 141 144 } else { 142 145 _pdActor->GetProperty()->SetRepresentationToSurface(); 143 _pdActor->GetProperty()-> LightingOn();146 _pdActor->GetProperty()->SetLighting((_lighting ? 1 : 0)); 144 147 } 145 148 } … … 204 207 } 205 208 } 209 210 /** 211 * \brief Turn on/off lighting of this object 212 */ 213 void PolyData::setLighting(bool state) 214 { 215 _lighting = state; 216 if (_pdActor != NULL) 217 _pdActor->GetProperty()->SetLighting((state ? 1 : 0)); 218 } -
trunk/packages/vizservers/vtkvis/RpPolyData.h
r2112 r2114 50 50 void setClippingPlanes(vtkPlaneCollection *planes); 51 51 52 void setLighting(bool state); 53 52 54 private: 53 55 void initActor(); … … 60 62 float _edgeWidth; 61 63 double _opacity; 64 bool _lighting; 62 65 vtkSmartPointer<vtkPolyDataMapper> _pdMapper; 63 66 vtkSmartPointer<vtkActor> _pdActor; -
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2112 r2114 236 236 } 237 237 } 238 239 /** 240 * \brief Turn on/off lighting of this object 241 */ 242 void PseudoColor::setLighting(bool state) 243 { 244 if (_dsActor != NULL) 245 _dsActor->GetProperty()->SetLighting((state ? 1 : 0)); 246 } -
trunk/packages/vizservers/vtkvis/RpPseudoColor.h
r2112 r2114 52 52 void setClippingPlanes(vtkPlaneCollection *planes); 53 53 54 void setLighting(bool state); 55 54 56 private: 55 57 void initActor(); -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2113 r2114 368 368 369 369 /** 370 * \brief Create a new PseudoColor rendering for the specified DataSet371 */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 DataSet395 */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 } else404 return itr->second;405 }406 407 /**408 370 * \brief Turn on/off rendering of all axes gridlines 409 371 */ … … 630 592 631 593 /** 594 * \brief Create a new PseudoColor rendering for the specified DataSet 595 */ 596 void 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 */ 620 PseudoColor *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 /** 632 632 * \brief Associate an existing named color map with a DataSet 633 633 */ … … 716 716 717 717 /** 718 * \brief Turn mesh lighting on/off for the specified DataSet 719 */ 720 void 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 /** 718 730 * \brief Create a new Contour2D and associate it with the named DataSet 719 731 */ … … 791 803 792 804 /** 805 * \brief Set the RGB isoline color for the specified DataSet 806 */ 807 void 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 */ 822 void 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 */ 834 void 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 /** 793 844 * \brief Create a new PolyData and associate it with the named DataSet 794 845 */ … … 839 890 if (polyData) { 840 891 polyData->setVisibility(state); 892 _needsRedraw = true; 893 } 894 } 895 896 /** 897 * \brief Set the RGB polygon face color for the specified DataSet 898 */ 899 void 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 */ 911 void 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 */ 923 void 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 */ 938 void 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 */ 950 void 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 */ 962 void Renderer::setPolyDataLighting(DataSetId id, bool state) 963 { 964 PolyData *polyData = getPolyData(id); 965 if (polyData) { 966 polyData->setLighting(state); 841 967 _needsRedraw = true; 842 968 } … … 956 1082 void Renderer::rotateCamera(double yaw, double pitch, double roll) 957 1083 { 1084 if (_cameraMode == IMAGE) 1085 return; 958 1086 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 959 1087 camera->Azimuth(yaw); // Rotate about object … … 975 1103 void Renderer::panCamera(double x, double y) 976 1104 { 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 } 977 1113 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 978 1114 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); … … 991 1127 void Renderer::zoomCamera(double z) 992 1128 { 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 } 993 1143 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 994 1144 camera->Zoom(z); // Change perspective FOV angle or ortho parallel scale … … 1208 1358 setContourVisibility(id, state); 1209 1359 setPolyDataVisibility(id, state); 1210 }1211 1212 /**1213 * \brief Set the RGB isoline color for the specified DataSet1214 */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 DataSet1241 */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 DataSet1253 */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 DataSet1265 */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 DataSet1292 */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 }1300 1360 } 1301 1361 -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2112 r2114 160 160 void setPseudoColorEdgeWidth(DataSetId id, float edgeWidth); 161 161 162 void setPseudoColorLighting(DataSetId id, bool state); 163 162 164 // Contour plots 163 165 … … 177 179 178 180 void setContourEdgeWidth(DataSetId id, float edgeWidth); 181 182 void setContourLighting(DataSetId id, bool state); 179 183 180 184 // Meshes … … 197 201 198 202 void setPolyDataWireframe(DataSetId id, bool state); 203 204 void setPolyDataLighting(DataSetId id, bool state); 199 205 200 206 private: -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2112 r2114 481 481 482 482 static int 483 Contour2DLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 484 Tcl_Obj *const *objv) 485 { 486 const char *name = Tcl_GetString(objv[3]); 487 bool state; 488 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 489 return TCL_ERROR; 490 } 491 g_renderer->setContourLighting(name, state); 492 return TCL_OK; 493 } 494 495 static int 483 496 Contour2DLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 484 497 Tcl_Obj *const *objv) … … 524 537 {"add", 1, Contour2DAddOp, 5, 5, "oper value dataSetName"}, 525 538 {"delete", 1, Contour2DDeleteOp, 3, 3, "dataSetName"}, 539 {"lighting", 3, Contour2DLightingOp, 4, 4, "bool dataSetName"}, 526 540 {"linecolor", 5, Contour2DLineColorOp, 6, 6, "r g b dataSetName"}, 527 541 {"linewidth", 5, Contour2DLineWidthOp, 4, 4, "width dataSetName"}, … … 817 831 818 832 static int 833 PseudoColorLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 834 Tcl_Obj *const *objv) 835 { 836 const char *name = Tcl_GetString(objv[3]); 837 bool state; 838 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 839 return TCL_ERROR; 840 } 841 g_renderer->setPseudoColorLighting(name, state); 842 return TCL_OK; 843 } 844 845 static int 819 846 PseudoColorLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 820 847 Tcl_Obj *const *objv) … … 849 876 {"delete", 1, PseudoColorDeleteOp, 3, 3, "dataSetName"}, 850 877 {"edges", 1, PseudoColorEdgeVisibilityOp, 4, 4, "bool dataSetName"}, 878 {"lighting", 3, PseudoColorLightingOp, 4, 4, "bool dataSetName"}, 851 879 {"linecolor", 5, PseudoColorLineColorOp, 6, 6, "r g b dataSetName"}, 852 880 {"linewidth", 5, PseudoColorLineWidthOp, 4, 4, "width dataSetName"}, … … 916 944 917 945 static int 946 PolyDataLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 947 Tcl_Obj *const *objv) 948 { 949 const char *name = Tcl_GetString(objv[3]); 950 bool state; 951 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 952 return TCL_ERROR; 953 } 954 g_renderer->setPolyDataLighting(name, state); 955 return TCL_OK; 956 } 957 958 static int 918 959 PolyDataLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 919 960 Tcl_Obj *const *objv) … … 974 1015 {"delete", 1, PolyDataDeleteOp, 3, 3, "dataSetName"}, 975 1016 {"edges", 1, PolyDataEdgeVisibilityOp, 4, 4, "bool dataSetName"}, 1017 {"lighting", 3, PolyDataLightingOp, 4, 4, "bool dataSetName"}, 976 1018 {"linecolor", 5, PolyDataLineColorOp, 6, 6, "r g b dataSetName"}, 977 1019 {"linewidth", 5, PolyDataLineWidthOp, 4, 4, "width dataSetName"},
Note: See TracChangeset
for help on using the changeset viewer.