Changeset 4783
- Timestamp:
- Nov 23, 2014, 7:40:56 PM (10 years ago)
- Location:
- vtkvis/branches/1.7
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
vtkvis/branches/1.7/ColorMap.cpp
r4604 r4783 145 145 // Clamp value to [0,1] 146 146 if (cp.value < 0.0) 147 147 cp.value = 0.0; 148 148 if (cp.value > 1.0) 149 149 cp.value = 1.0; 150 150 151 151 #ifdef DEBUG 152 152 TRACE("New control point: %g = %g %g %g", 153 153 cp.value, cp.color[0], cp.color[1], cp.color[2]); 154 154 #endif 155 155 for (std::list<ControlPoint>::iterator itr = _controlPoints.begin(); 156 157 158 159 160 161 162 163 156 itr != _controlPoints.end(); ++itr) { 157 if (itr->value == cp.value) { 158 *itr = cp; 159 return; 160 } else if (itr->value > cp.value) { 161 _controlPoints.insert(itr, cp); 162 return; 163 } 164 164 } 165 165 // If we reach here, our control point goes at the end … … 176 176 // Clamp value to [0,1] 177 177 if (cp.value < 0.0) 178 178 cp.value = 0.0; 179 179 if (cp.value > 1.0) 180 180 cp.value = 1.0; 181 181 182 182 #ifdef DEBUG 183 183 TRACE("New opacity control point: %g = %g", 184 184 cp.value, cp.alpha); 185 185 #endif 186 186 for (std::list<OpacityControlPoint>::iterator itr = _opacityControlPoints.begin(); 187 188 189 190 191 192 193 194 187 itr != _opacityControlPoints.end(); ++itr) { 188 if (itr->value == cp.value) { 189 *itr = cp; 190 return; 191 } else if (itr->value > cp.value) { 192 _opacityControlPoints.insert(itr, cp); 193 return; 194 } 195 195 } 196 196 // If we reach here, our control point goes at the end … … 209 209 { 210 210 if (numEntries != _numTableEntries) { 211 212 213 214 215 211 _needsBuild = true; 212 _numTableEntries = numEntries; 213 if (_lookupTable != NULL) { 214 build(); 215 } 216 216 } 217 217 } … … 236 236 { 237 237 if (!_needsBuild) 238 238 return; 239 239 240 240 TRACE("%s", _name.c_str()); 241 241 242 242 if (_lookupTable == NULL) { 243 243 _lookupTable = vtkSmartPointer<vtkLookupTable>::New(); 244 244 } 245 245 … … 252 252 // constant range up to first specified cp 253 253 if (itr->value > 0.0) { 254 255 256 254 ControlPoint cp = *itr; 255 cp.value = 0.0; 256 itr = _controlPoints.insert(itr, cp); 257 257 } 258 258 if (oitr->value > 0.0) { 259 260 261 259 OpacityControlPoint ocp = *oitr; 260 ocp.value = 0.0; 261 oitr = _opacityControlPoints.insert(oitr, ocp); 262 262 } 263 263 … … 268 268 269 269 for (int i = 0; i < _numTableEntries; i++) { 270 270 double value = _numTableEntries < 2 ? 0.0 : ((double)i)/(_numTableEntries-1); 271 271 double color[4]; 272 273 274 275 276 277 278 279 280 272 while (itr2 != _controlPoints.end() && value > itr2->value) { 273 itr = itr2; 274 itr2++; 275 } 276 while (oitr2 != _opacityControlPoints.end() && value > oitr2->value) { 277 oitr = oitr2; 278 oitr2++; 279 } 280 if (itr2 == _controlPoints.end()) { 281 281 #ifdef DEBUG 282 283 282 TRACE("val: %g Range: %g - 1 Color: %g %g %g", value, itr->value, 283 itr->color[0], itr->color[1], itr->color[2]); 284 284 #endif 285 285 memcpy(color, itr->color, sizeof(double)*3); 286 287 288 289 286 } else { 287 assert(itr->value < itr2->value); 288 assert(value >= itr->value && value <= itr2->value); 289 lerp(color, *itr, *itr2, value); 290 290 #ifdef DEBUG 291 292 291 TRACE("val: %g Range: %g - %g Color: %g %g %g", value, itr->value, itr2->value, 292 color[0], color[1], color[2]); 293 293 #endif 294 295 294 } 295 if (oitr2 == _opacityControlPoints.end()) { 296 296 #ifdef DEBUG 297 298 297 TRACE("val: %g Range: %g - 1 Alpha %g", value, oitr->value, 298 oitr->alpha); 299 299 #endif 300 300 color[3] = oitr->alpha; 301 302 303 304 301 } else { 302 assert(oitr->value < oitr2->value); 303 assert(value >= oitr->value && value <= oitr2->value); 304 lerp(&color[3], *oitr, *oitr2, value); 305 305 #ifdef DEBUG 306 307 306 TRACE("val: %g Range: %g - %g Alpha: %g", value, oitr->value, oitr2->value, 307 color[3]); 308 308 #endif 309 309 } 310 310 _lookupTable->SetTableValue(i, color); 311 311 } … … 324 324 double factor = (value - cp1.value) / (cp2.value - cp1.value); 325 325 for (int i = 0; i < 3; i++) { 326 326 result[i] = cp1.color[i] * (1.0 - factor) + cp2.color[i] * factor; 327 327 } 328 328 } … … 384 384 cp[4].color[2] = 0.0; 385 385 for (int i = 0; i < 5; i++) { 386 386 _default->addControlPoint(cp[i]); 387 387 } 388 388 OpacityControlPoint ocp[2]; … … 462 462 cp[4].color[2] = 0.0; 463 463 for (int i = 0; i < 5; i++) { 464 464 _volumeDefault->addControlPoint(cp[i]); 465 465 } 466 466 OpacityControlPoint ocp[2]; -
vtkvis/branches/1.7/GraphicsObject.h
r4037 r4783 287 287 PrincipalPlane plane; 288 288 if (!_dataSet->is2D(&plane)) { 289 TRACE("Not setting aspect for 3D object ");289 TRACE("Not setting aspect for 3D object %s", getClassName()); 290 290 return; 291 291 } -
vtkvis/branches/1.7/Image.cpp
r4604 r4783 76 76 TRACE("Creating mapper"); 77 77 vtkSmartPointer<vtkImageResliceMapper> newMapper = vtkSmartPointer<vtkImageResliceMapper>::New(); 78 newMapper->AutoAdjustImageQualityOff(); 78 79 getImageSlice()->SetMapper(newMapper); 79 80 mapper = getImageMapper(); -
vtkvis/branches/1.7/Image.h
r4604 r4783 66 66 } 67 67 68 void setSlicePlane(double normal[3], double origin[3]) 69 { 70 setSliceFollowsCamera(false); 71 72 vtkImageMapper3D *mapper = getImageMapper(); 73 vtkImageResliceMapper *resliceMapper = vtkImageResliceMapper::SafeDownCast(mapper); 74 if (resliceMapper != NULL) { 75 vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New(); 76 plane->SetNormal(normal); 77 plane->SetOrigin(origin); 78 resliceMapper->SetSlicePlane(plane); 79 } 80 } 81 82 void setSliceFollowsCamera(bool state) 83 { 84 vtkImageMapper3D *mapper = getImageMapper(); 85 if (mapper != NULL) { 86 mapper->SetSliceFacesCamera(state ? 1 : 0); 87 mapper->SetSliceAtFocalPoint(state ? 1 : 0); 88 } 89 } 90 91 void setJumpToNearestSlice(bool state) 92 { 93 vtkImageMapper3D *mapper = getImageMapper(); 94 vtkImageResliceMapper *resliceMapper = vtkImageResliceMapper::SafeDownCast(mapper); 95 if (resliceMapper != NULL) { 96 resliceMapper->SetJumpToNearestSlice(state ? 1 : 0); 97 } 98 } 99 68 100 void setExtents(int extent[6]) 69 101 { -
vtkvis/branches/1.7/Renderer.h
r3993 r4783 512 512 void setGraphicsObjectVolumeSlice(const DataSetId& id, Axis axis, double ratio); 513 513 514 // 514 // Prop/Prop3D properties 515 515 516 516 template<class T> … … 538 538 void setGraphicsObjectVisibility(const DataSetId& id, bool state); 539 539 540 // 540 // Actor properties 541 541 542 542 template<class T> … … 765 765 void setImageBorder(const DataSetId& id, bool state); 766 766 767 // For ImageActor/ImageSliceMapper only 767 768 void setImageExtents(const DataSetId& id, int extents[6]); 768 769 … … 771 772 void setImageWindow(const DataSetId& id, double window); 772 773 774 void setImageSlicePlane(const DataSetId& id, double normal[3], double origin[3]); 775 776 void setImageSliceFollowsCamera(const DataSetId& id, bool state); 777 778 // For ImageActor/ImageSliceMapper only 773 779 void setImageZSlice(const DataSetId& id, int z); 774 780 -
vtkvis/branches/1.7/RendererCmd.cpp
r4777 r4783 2077 2077 Renderer::Aspect aspect; 2078 2078 const char *string = Tcl_GetString(objv[2]); 2079 if ( (strcmp(string, "native") == 0)) {2079 if (string[0] == 'n' && (strcmp(string, "native") == 0)) { 2080 2080 aspect = Renderer::ASPECT_NATIVE; 2081 } else if ( (strcmp(string, "square") == 0)) {2081 } else if (string[0] == 's' && (strcmp(string, "square") == 0)) { 2082 2082 aspect = Renderer::ASPECT_SQUARE; 2083 } else if ( (strcmp(string, "window") == 0)) {2083 } else if (string[0] == 'w' && (strcmp(string, "window") == 0)) { 2084 2084 aspect = Renderer::ASPECT_WINDOW; 2085 2085 } else { … … 2098 2098 Renderer::CameraMode mode; 2099 2099 const char *string = Tcl_GetString(objv[2]); 2100 if ( (strcmp(string, "persp") == 0)) {2100 if (string[0] == 'p' && (strcmp(string, "persp") == 0)) { 2101 2101 mode = Renderer::PERSPECTIVE; 2102 } else if ( (strcmp(string, "ortho") == 0)) {2102 } else if (string[0] == 'o' && (strcmp(string, "ortho") == 0)) { 2103 2103 mode = Renderer::ORTHO; 2104 } else if ( (strcmp(string, "image") == 0)) {2104 } else if (string[0] == 'i' && (strcmp(string, "image") == 0)) { 2105 2105 mode = Renderer::IMAGE; 2106 2106 } else { … … 2283 2283 2284 2284 static CmdSpec cameraOps[] = { 2285 {"aspect", 1, CameraAspectOp, 3, 3, "aspect"},2286 {"get", 1, CameraGetOp, 2, 2, ""},2287 {"mode", 1, CameraModeOp, 3, 3, "mode"},2288 {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"},2289 {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"},2290 {"pan", 1, CameraPanOp, 4, 4, "panX panY"},2291 {"reset", 2, CameraResetOp, 2, 3, "?all?"},2292 {"rotate", 2, CameraRotateOp, 5, 5, "angle angle angle"},2293 {"set", 1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"},2294 {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"}2285 {"aspect", 1, CameraAspectOp, 3, 3, "aspect"}, 2286 {"get", 1, CameraGetOp, 2, 2, ""}, 2287 {"mode", 1, CameraModeOp, 3, 3, "mode"}, 2288 {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"}, 2289 {"ortho", 3, CameraOrthoOp, 7, 7, "coordMode x y width height"}, 2290 {"pan", 1, CameraPanOp, 4, 4, "panX panY"}, 2291 {"reset", 2, CameraResetOp, 2, 3, "?all?"}, 2292 {"rotate", 2, CameraRotateOp, 5, 5, "angle angle angle"}, 2293 {"set", 1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"}, 2294 {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"} 2295 2295 }; 2296 2296 static int nCameraOps = NumCmdSpecs(cameraOps); … … 2485 2485 if (Tcl_GetIntFromObj(interp, objv[2], &numEntries) != TCL_OK) { 2486 2486 const char *str = Tcl_GetString(objv[2]); 2487 if (str cmp(str, "default") == 0) {2487 if (str[0] == 'd' && strcmp(str, "default") == 0) { 2488 2488 numEntries = -1; 2489 2489 } else { … … 4831 4831 { 4832 4832 const char *value = Tcl_GetString(objv[2]); 4833 if ( strcmp(value, "all") == 0) {4833 if (value[0] == 'a' && strcmp(value, "all") == 0) { 4834 4834 g_renderer->setUseCumulativeDataRange(true); 4835 } else if ( strcmp(value, "explicit") == 0) {4835 } else if (value[0] == 'e' && strcmp(value, "explicit") == 0) { 4836 4836 if (objc < 6 || objc > 9) { 4837 4837 Tcl_AppendResult(interp, "wrong number of arguments for explicit maprange", (char*)NULL); … … 4850 4850 if (objc > 6) { 4851 4851 const char *fieldType = Tcl_GetString(objv[6]); 4852 if ( strcmp(fieldType, "point_data") == 0) {4852 if (fieldType[0] == 'p' && strcmp(fieldType, "point_data") == 0) { 4853 4853 type = DataSet::POINT_DATA; 4854 } else if ( strcmp(fieldType, "cell_data") == 0) {4854 } else if (fieldType[0] == 'c' && strcmp(fieldType, "cell_data") == 0) { 4855 4855 type = DataSet::CELL_DATA; 4856 } else if ( strcmp(fieldType, "field_data") == 0) {4856 } else if (fieldType[0] == 'f' && strcmp(fieldType, "field_data") == 0) { 4857 4857 type = DataSet::FIELD_DATA; 4858 4858 } else { … … 4873 4873 } 4874 4874 g_renderer->setCumulativeDataRange(range, fieldName, type, numComponents, component); 4875 } else if ( strcmp(value, "separate") == 0) {4875 } else if (value[0] == 's' && strcmp(value, "separate") == 0) { 4876 4876 g_renderer->setUseCumulativeDataRange(false); 4877 } else if ( strcmp(value, "visible") == 0) {4877 } else if (value[0] == 'v' && strcmp(value, "visible") == 0) { 4878 4878 g_renderer->setUseCumulativeDataRange(true, true); 4879 4879 } else { … … 6937 6937 6938 6938 static int 6939 ImageFollowCameraOp(ClientData clientData, Tcl_Interp *interp, int objc, 6940 Tcl_Obj *const *objv) 6941 { 6942 bool state; 6943 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 6944 return TCL_ERROR; 6945 } 6946 if (objc == 4) { 6947 const char *name = Tcl_GetString(objv[3]); 6948 g_renderer->setImageSliceFollowsCamera(name, state); 6949 } else { 6950 g_renderer->setImageSliceFollowsCamera("all", state); 6951 } 6952 return TCL_OK; 6953 } 6954 6955 static int 6939 6956 ImageLevelOp(ClientData clientData, Tcl_Interp *interp, int objc, 6940 6957 Tcl_Obj *const *objv) … … 7024 7041 } else { 7025 7042 g_renderer->setGraphicsObjectScale<Image>("all", scale); 7043 } 7044 return TCL_OK; 7045 } 7046 7047 static int 7048 ImageSlicePlaneOp(ClientData clientData, Tcl_Interp *interp, int objc, 7049 Tcl_Obj *const *objv) 7050 { 7051 double normal[3], origin[3]; 7052 if (Tcl_GetDoubleFromObj(interp, objv[2], &normal[0]) != TCL_OK || 7053 Tcl_GetDoubleFromObj(interp, objv[3], &normal[1]) != TCL_OK || 7054 Tcl_GetDoubleFromObj(interp, objv[4], &normal[2]) != TCL_OK || 7055 Tcl_GetDoubleFromObj(interp, objv[5], &origin[0]) != TCL_OK || 7056 Tcl_GetDoubleFromObj(interp, objv[6], &origin[1]) != TCL_OK || 7057 Tcl_GetDoubleFromObj(interp, objv[7], &origin[2]) != TCL_OK) { 7058 return TCL_ERROR; 7059 } 7060 if (objc == 4) { 7061 const char *name = Tcl_GetString(objv[8]); 7062 g_renderer->setImageSlicePlane(name, normal, origin); 7063 } else { 7064 g_renderer->setImageSlicePlane("all", normal, origin); 7026 7065 } 7027 7066 return TCL_OK; … … 7088 7127 {"delete", 1, ImageDeleteOp, 2, 3, "?dataSetName?"}, 7089 7128 {"extents", 1, ImageExtentsOp, 8, 9, "xmin xmax ymin ymax zmin zmax ?dataSetName?"}, 7129 {"follow", 1, ImageFollowCameraOp, 3, 4, "bool ?dataSetName?"}, 7090 7130 {"level", 1, ImageLevelOp, 3, 4, "val ?dataSetName?"}, 7091 7131 {"opacity", 2, ImageOpacityOp, 3, 4, "value ?dataSetName?"}, 7092 7132 {"orient", 2, ImageOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 7093 7133 {"pos", 1, ImagePositionOp, 5, 6, "x y z ?dataSetName?"}, 7094 {"scale", 1, ImageScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 7134 {"scale", 2, ImageScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 7135 {"slice", 2, ImageSlicePlaneOp, 8, 9, "nx ny nz ox oy oz ?dataSetName?"}, 7095 7136 {"visible", 1, ImageVisibleOp, 3, 4, "bool ?dataSetName?"}, 7096 7137 {"window", 1, ImageWindowOp, 3, 4, "val ?dataSetName?"}, -
vtkvis/branches/1.7/RendererGraphicsObjs.cpp
r4604 r4783 2400 2400 } 2401 2401 2402 void Renderer::setImageSlicePlane(const DataSetId& id, double normal[3], double origin[3]) 2403 { 2404 ImageHashmap::iterator itr; 2405 2406 bool doAll = false; 2407 2408 if (id.compare("all") == 0) { 2409 itr = _images.begin(); 2410 if (itr == _images.end()) 2411 return; 2412 doAll = true; 2413 } else { 2414 itr = _images.find(id); 2415 } 2416 if (itr == _images.end()) { 2417 ERROR("Image not found: %s", id.c_str()); 2418 return; 2419 } 2420 2421 do { 2422 itr->second->setSlicePlane(normal, origin); 2423 } while (doAll && ++itr != _images.end()); 2424 2425 _needsRedraw = true; 2426 } 2427 2428 void Renderer::setImageSliceFollowsCamera(const DataSetId& id, bool state) 2429 { 2430 ImageHashmap::iterator itr; 2431 2432 bool doAll = false; 2433 2434 if (id.compare("all") == 0) { 2435 itr = _images.begin(); 2436 if (itr == _images.end()) 2437 return; 2438 doAll = true; 2439 } else { 2440 itr = _images.find(id); 2441 } 2442 if (itr == _images.end()) { 2443 ERROR("Image not found: %s", id.c_str()); 2444 return; 2445 } 2446 2447 do { 2448 itr->second->setSliceFollowsCamera(state); 2449 } while (doAll && ++itr != _images.end()); 2450 2451 _needsRedraw = true; 2452 } 2453 2402 2454 void Renderer::setImageZSlice(const DataSetId& id, int z) 2403 2455 { -
vtkvis/branches/1.7/protocol.txt
r4777 r4783 603 603 image delete <?dataSetName?> 604 604 image extents <xmin> <xmax> <ymin> <ymax> <zmin> <zmax> <?dataSetName?> 605 Deprecated 606 image follow <bool> <?dataSetName?> 607 Toggle camera following. When on, slice plane will face the camera and 608 camera focal point determines slice offset 605 609 image level <level> <?dataSetName?> 606 610 image opacity <opacity> <?dataSetName?> … … 608 612 image pos <x> <y> <z> <?dataSetName?> 609 613 image scale <sx> <sy> <sz> <?dataSetName?> 614 image slice <nx> <ny> <nz> <ox> <oy> <oz> <?dataSetName?> 615 Disable camera follow and set slice plane by plane normal (nx,ny,nz) and 616 origin (ox,oy,oz) 610 617 image visible <bool> <?dataSetName?> 611 618 image window <windowWidth> <?dataSetName?> 612 619 image zslice <sliceNum> <?dataSetName?> 620 Deprecated 613 621 614 622 lic add <?datasetName?>
Note: See TracChangeset
for help on using the changeset viewer.