Changeset 3479
- Timestamp:
- Mar 9, 2013, 4:26:48 PM (12 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 2 added
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/Doxyfile.in
r3436 r3479 598 598 # subdirectory from a directory tree whose root is specified with the INPUT tag. 599 599 600 EXCLUDE = 600 EXCLUDE = @srcdir@/vtkRpAxisActor.h @srcdir@/vtkRpAxisActor.cpp @srcdir@/vtkRpAxisFollower.h @srcdir@/vtkRpAxisFollower.cpp 601 601 602 602 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or -
trunk/packages/vizservers/vtkvis/Makefile.in
r3471 r3479 1 1 DEBUG = #yes 2 2 TRACE = #yes 3 USE_CUSTOM_AXES = #yes3 USE_CUSTOM_AXES = yes 4 4 USE_GPU_RAYCASTING = yes 5 5 USE_OFFSCREEN_RENDERING = yes … … 130 130 ifdef USE_VTK6 131 131 VTK_MOD_DEFS = -DvtkRenderingCore_AUTOINIT="4(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL)" -DvtkRenderingVolume_AUTOINIT"1(vtkRenderingVolumeOpenGL)" 132 DEFINES += -DUSE_VTK6 -DVTK_HYBRID_EXPORT="" -DVTK_RENDERING_EXPORT=""$(VTK_MOD_DEFS)132 DEFINES += -DUSE_VTK6 $(VTK_MOD_DEFS) 133 133 endif 134 134 … … 176 176 SERVER_SRCS+= \ 177 177 vtkRpAxisActor.cpp \ 178 vtkRpAxis Actor2D.cpp \178 vtkRpAxisFollower.cpp \ 179 179 vtkRpCubeAxesActor.cpp 180 180 endif … … 246 246 RpVtkDataSet.o: RpVtkDataSet.h Trace.h 247 247 RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h ColorMap.h Trace.h 248 RpVtkRenderer.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxis Actor.h vtkRpAxisActor2D.h RpMath.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h249 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxis Actor.h vtkRpAxisActor2D.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h248 RpVtkRenderer.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h RpMath.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h 249 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h 250 250 RpVtkRendererGraphicsObjs.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpVtkDataSet.h RpArc.h RpArrow.h RpBox.h RpCone.h RpContour2D.h RpContour3D.h RpCutplane.h RpCylinder.h RpDisk.h RpGlyphs.h RpGroup.h RpHeightMap.h RpLIC.h RpLine.h RpMolecule.h RpPolyData.h RpPolygon.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h 251 RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h vtkRpCubeAxesActor.h vtkRpAxis Actor.h vtkRpAxisActor2D.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h251 RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h 252 252 RpWarp.o: RpWarp.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h 253 253 Trace.o: Trace.h 254 254 TGAWriter.o: TGAWriter.h ResponseQueue.h Trace.h 255 255 vtkRpAxisActor.o: vtkRpAxisActor.h 256 vtkRpAxis Actor2D.o: vtkRpAxisActor2D.h257 vtkRpCubeAxesActor.o: vtkRpCubeAxesActor.h vtkRpAxis Actor.h vtkRpAxisActor2D.h256 vtkRpAxisFollower.o: vtkRpAxisFollower.h vtkRpAxisActor.h 257 vtkRpCubeAxesActor.o: vtkRpCubeAxesActor.h vtkRpAxisFollower.h vtkRpAxisActor.h 258 258 md5.o: md5.h -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r3455 r3479 23 23 #include <vtkTransform.h> 24 24 #include <vtkCharArray.h> 25 #include <vtkAxisActor2D.h>26 25 #ifdef USE_CUSTOM_AXES 27 26 #include "vtkRpCubeAxesActor.h" … … 1512 1511 if (axis == X_AXIS) { 1513 1512 _cubeAxesActor->SetXLabelFormat(format); 1513 _cubeAxesActor->XAutoLabelFormatOff(); 1514 1514 } else if (axis == Y_AXIS) { 1515 1515 _cubeAxesActor->SetYLabelFormat(format); 1516 _cubeAxesActor->YAutoLabelFormatOff(); 1516 1517 } else if (axis == Z_AXIS) { 1517 1518 _cubeAxesActor->SetZLabelFormat(format); 1519 _cubeAxesActor->ZAutoLabelFormatOff(); 1518 1520 } 1519 1521 _needsRedraw = true; -
trunk/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.h
r3330 r3479 313 313 * \brief Set the prop scaling based on a 2D aspect ratio 314 314 * 315 * \param aspectRatio The aspect ratio (width/height), zero means native aspect 315 * \param id The name of the DataSet 316 * \param aspect The aspect ratio (width/height), zero means native aspect 316 317 */ 317 318 template<class GraphicsObject> -
trunk/packages/vizservers/vtkvis/protocol.txt
r3330 r3479 753 753 nv>dataset vector world <x> <y> <z> <valueX> <valueY> <valueZ> <dataSetName> 754 754 nv>dataset vector pixel <x> <y> <valueX> <valueY> <valueZ> <dataSetName> 755 755 nv>ok -token <seqnum> 756 Reply indicated commands through <seqnum> (numbered beginning at 1) have been 757 processed, but no new image was rendered 756 758 ================================================================================ 757 759 Error Replies: -
trunk/packages/vizservers/vtkvis/vtkRpAxisActor.cpp
r3330 r3479 14 14 =========================================================================*/ 15 15 #include "vtkRpAxisActor.h" 16 17 #include "vtkRpAxisFollower.h" 16 18 #include "vtkCamera.h" 17 19 #include "vtkCellArray.h" 18 20 #include "vtkCoordinate.h" 19 21 #include "vtkFollower.h" 22 #include "vtkTextRenderer.h" 23 #include "vtkMath.h" 20 24 #include "vtkObjectFactory.h" 21 25 #include "vtkPolyData.h" 22 26 #include "vtkPolyDataMapper.h" 23 27 #include "vtkProperty.h" 28 #include "vtkProperty2D.h" 24 29 #include "vtkStringArray.h" 30 #include "vtkTextActor.h" 31 #include "vtkTextProperty.h" 25 32 #include "vtkVectorText.h" 26 33 #include "vtkViewport.h" 27 34 28 // ****************************************************************29 // Modifications:30 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 200231 // Replace 'New' method with macro to match VTK 4.0 API.32 // ****************************************************************33 34 35 vtkStandardNewMacro(vtkRpAxisActor); 35 36 vtkCxxSetObjectMacro(vtkRpAxisActor, Camera, vtkCamera); 37 vtkCxxSetObjectMacro(vtkRpAxisActor,LabelTextProperty,vtkTextProperty); 38 vtkCxxSetObjectMacro(vtkRpAxisActor,TitleTextProperty,vtkTextProperty); 36 39 37 40 // **************************************************************** 38 41 // Instantiate this object. 39 //40 // Modifications:41 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 200142 // Initialize new members mustAdjustValue and valueScaleFactor.43 //44 // Kathleen Bonnell, Wed Nov 7 16:19:16 PST 200145 // No longer allocate large amounts of memory for labels, instead46 // allocate dynamically. Initialize new members:47 // LastLabelStart; LastAxisPosition; LastTickLocation; LastTickVisibility;48 // LastDrawGridlines; LastMinorTicksVisible; LastRange; MinorTickPts;49 // MajorTickPts; GridlinePts.50 //51 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 200252 // Initialize new member AxisHasZeroLength.53 //54 // Kathleen Bonnell, Thu Aug 1 13:44:02 PDT 200255 // Initialize new member ForceLabelReset.56 //57 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 200358 // Removed mustAdjustValue, valueScaleFator, ForceLabelReset.59 //60 // Kathleen Bonnell, Thu Apr 29 17:02:10 PDT 200461 // Initialize MinorStart, MajorStart, DeltaMinor, DeltaMajor.62 //63 42 // **************************************************************** 64 43 … … 88 67 sprintf(this->LabelFormat, "%s", "%-#6.3g"); 89 68 69 this->TitleTextProperty = vtkTextProperty::New(); 70 this->TitleTextProperty->SetColor(0.,0.,0.); 71 this->TitleTextProperty->SetFontFamilyToArial(); 72 this->TitleTextProperty->SetFontSize(14); 73 90 74 this->TitleVector = vtkVectorText::New(); 91 75 this->TitleMapper = vtkPolyDataMapper::New(); 92 #ifdef USE_VTK6 93 this->TitleMapper->SetInputData(this->TitleVector->GetOutput()); 94 #else 95 this->TitleMapper->SetInput(this->TitleVector->GetOutput()); 96 #endif 97 this->TitleActor = vtkFollower::New(); 76 this->TitleMapper->SetInputConnection( 77 this->TitleVector->GetOutputPort()); 78 this->TitleActor = vtkRpAxisFollower::New(); 98 79 this->TitleActor->SetMapper(this->TitleMapper); 99 100 // to avoid deleting/rebuilding create once up front 80 this->TitleActor->SetEnableDistanceLOD(0); 81 this->TitleActor2D = vtkTextActor::New(); 82 101 83 this->NumberOfLabelsBuilt = 0; 102 84 this->LabelVectors = NULL; 103 85 this->LabelMappers = NULL; 104 86 this->LabelActors = NULL; 105 106 this->Axis = vtkPolyData::New(); 107 this->AxisMapper = vtkPolyDataMapper::New(); 108 #ifdef USE_VTK6 109 this->AxisMapper->SetInputData(this->Axis); 110 #else 111 this->AxisMapper->SetInput(this->Axis); 112 #endif 113 this->AxisActor = vtkActor::New(); 114 this->AxisActor->SetMapper(this->AxisMapper); 87 this->LabelActors2D = NULL; 88 89 this->LabelTextProperty = vtkTextProperty::New(); 90 this->LabelTextProperty->SetColor(0.,0.,0.); 91 this->LabelTextProperty->SetFontFamilyToArial(); 92 this->LabelTextProperty->SetFontSize(12); 93 94 this->AxisLines = vtkPolyData::New(); 95 this->AxisLinesMapper = vtkPolyDataMapper::New(); 96 this->AxisLinesMapper->SetInputData(this->AxisLines); 97 this->AxisLinesActor = vtkActor::New(); 98 this->AxisLinesActor->SetMapper(this->AxisLinesMapper); 99 this->Gridlines = vtkPolyData::New(); 100 this->GridlinesMapper = vtkPolyDataMapper::New(); 101 this->GridlinesMapper->SetInputData(this->Gridlines); 102 this->GridlinesActor = vtkActor::New(); 103 this->GridlinesActor->SetMapper(this->GridlinesMapper); 104 this->InnerGridlines = vtkPolyData::New(); 105 this->InnerGridlinesMapper = vtkPolyDataMapper::New(); 106 this->InnerGridlinesMapper->SetInputData(this->InnerGridlines); 107 this->InnerGridlinesActor = vtkActor::New(); 108 this->InnerGridlinesActor->SetMapper(this->InnerGridlinesMapper); 109 this->Gridpolys = vtkPolyData::New(); 110 this->GridpolysMapper = vtkPolyDataMapper::New(); 111 this->GridpolysMapper->SetInputData(this->Gridpolys); 112 this->GridpolysActor = vtkActor::New(); 113 this->GridpolysActor->SetMapper(this->GridpolysMapper); 115 114 116 115 this->AxisVisibility = 1; … … 120 119 121 120 this->DrawGridlines = 0; 121 this->DrawGridlinesOnly = 0; 122 122 this->GridlineXLength = 1.; 123 123 this->GridlineYLength = 1.; 124 124 this->GridlineZLength = 1.; 125 126 this->DrawInnerGridlines = 0; 127 128 this->DrawGridpolys = 0; 125 129 126 130 this->AxisType = VTK_AXIS_TYPE_X; … … 138 142 this->LastTickVisibility = -1; 139 143 this->LastDrawGridlines = -1; 144 this->LastDrawInnerGridlines = -1; 145 this->LastDrawGridpolys = -1; 140 146 this->LastMinorTicksVisible = -1; 141 147 this->LastRange[0] = -1.0; … … 145 151 this->MajorTickPts = vtkPoints::New(); 146 152 this->GridlinePts = vtkPoints::New(); 153 this->InnerGridlinePts = vtkPoints::New(); 154 this->GridpolyPts = vtkPoints::New(); 147 155 148 156 this->AxisHasZeroLength = false; 149 157 150 158 this->MinorStart = 0.; 151 this->MajorStart = 0.; 159 //this->MajorStart = 0.; 160 for(int i=0;i<3;i++) 161 { 162 this->MajorStart[i] = 0.; 163 } 152 164 this->DeltaMinor = 1.; 153 this->DeltaMajor = 1.; 165 //this->DeltaMajor = 1.; 166 for(int i=0;i<3;i++) 167 { 168 this->DeltaMajor[i] = 1.; 169 } 170 154 171 this->MinorRangeStart = 0.; 155 172 this->MajorRangeStart = 0.; 156 173 this->DeltaRangeMinor = 1.; 157 174 this->DeltaRangeMajor = 1.; 175 176 this->CalculateTitleOffset = 1; 177 this->CalculateLabelOffset = 1; 178 179 // Instance variables specific to 2D mode 180 this->Use2DMode = 0; 181 this->SaveTitlePosition = 0; 182 this->TitleConstantPosition[0] = this->TitleConstantPosition[1] = 0.; 183 this->VerticalOffsetXTitle2D = -40.; 184 this->HorizontalOffsetYTitle2D = -50.; 185 this->LastMinDisplayCoordinate[0] = 0; 186 this->LastMinDisplayCoordinate[1] = 0; 187 this->LastMinDisplayCoordinate[2] = 0; 188 this->LastMaxDisplayCoordinate[0] = 0; 189 this->LastMaxDisplayCoordinate[1] = 0; 190 this->LastMaxDisplayCoordinate[2] = 0; 191 192 // 0: All locations 193 this->DrawGridlinesLocation = this->LastDrawGridlinesLocation = 0; 194 195 // reset the base 196 for(int i=0;i<3;i++) 197 { 198 this->AxisBaseForX[i] = this->AxisBaseForY[i] = this->AxisBaseForZ[i] = 0.0; 199 } 200 this->AxisBaseForX[0] = this->AxisBaseForY[1] = this->AxisBaseForZ[2] = 1.0; 201 this->AxisOnOrigin = 0; 158 202 } 159 203 160 204 // **************************************************************** 161 // Modifications:162 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 2002163 // Added call to set camera to null.164 // ****************************************************************165 166 205 vtkRpAxisActor::~vtkRpAxisActor() 167 206 { … … 201 240 this->TitleActor = NULL; 202 241 } 242 if (this->TitleActor2D) 243 { 244 this->TitleActor2D->Delete(); 245 this->TitleActor2D = NULL; 246 } 203 247 204 248 if (this->Title) … … 206 250 delete [] this->Title; 207 251 this->Title = NULL; 252 } 253 254 if (this->TitleTextProperty) 255 { 256 this->TitleTextProperty->Delete(); 257 this->TitleTextProperty = NULL; 208 258 } 209 259 … … 215 265 this->LabelMappers[i]->Delete(); 216 266 this->LabelActors[i]->Delete(); 267 this->LabelActors2D[i]->Delete(); 217 268 } 218 269 this->NumberOfLabelsBuilt = 0; … … 220 271 delete [] this->LabelMappers; 221 272 delete [] this->LabelActors; 273 delete [] this->LabelActors2D; 222 274 this->LabelVectors = NULL; 223 275 this->LabelMappers = NULL; 224 276 this->LabelActors = NULL; 225 } 226 227 if (this->Axis) 228 { 229 this->Axis->Delete(); 230 this->Axis = NULL; 231 } 232 if (this->AxisMapper) 233 { 234 this->AxisMapper->Delete(); 235 this->AxisMapper = NULL; 236 } 237 if (this->AxisActor) 238 { 239 this->AxisActor->Delete(); 240 this->AxisActor = NULL; 277 this->LabelActors2D = NULL; 278 } 279 if (this->LabelTextProperty) 280 { 281 this->LabelTextProperty->Delete(); 282 this->LabelTextProperty = NULL; 283 } 284 285 if (this->AxisLines) 286 { 287 this->AxisLines->Delete(); 288 this->AxisLines = NULL; 289 } 290 if (this->AxisLinesMapper) 291 { 292 this->AxisLinesMapper->Delete(); 293 this->AxisLinesMapper = NULL; 294 } 295 if (this->AxisLinesActor) 296 { 297 this->AxisLinesActor->Delete(); 298 this->AxisLinesActor = NULL; 299 } 300 301 if (this->Gridlines) 302 { 303 this->Gridlines->Delete(); 304 this->Gridlines = NULL; 305 } 306 if (this->GridlinesMapper) 307 { 308 this->GridlinesMapper->Delete(); 309 this->GridlinesMapper = NULL; 310 } 311 if (this->GridlinesActor) 312 { 313 this->GridlinesActor->Delete(); 314 this->GridlinesActor = NULL; 315 } 316 317 if (this->InnerGridlines) 318 { 319 this->InnerGridlines->Delete(); 320 this->InnerGridlines = NULL; 321 } 322 if (this->InnerGridlinesMapper) 323 { 324 this->InnerGridlinesMapper->Delete(); 325 this->InnerGridlinesMapper = NULL; 326 } 327 if (this->InnerGridlinesActor) 328 { 329 this->InnerGridlinesActor->Delete(); 330 this->InnerGridlinesActor = NULL; 331 } 332 333 if (this->Gridpolys) 334 { 335 this->Gridpolys->Delete(); 336 this->Gridpolys = NULL; 337 } 338 if (this->GridpolysMapper) 339 { 340 this->GridpolysMapper->Delete(); 341 this->GridpolysMapper = NULL; 342 } 343 if (this->GridpolysActor) 344 { 345 this->GridpolysActor->Delete(); 346 this->GridpolysActor = NULL; 241 347 } 242 348 … … 256 362 this->GridlinePts = NULL; 257 363 } 258 } 259 260 // Release any graphics resources that are being consumed by this actor. 261 // The parameter window could be used to determine which graphic 262 // resources to release. 364 if (this->InnerGridlinePts) 365 { 366 this->InnerGridlinePts->Delete(); 367 this->InnerGridlinePts = NULL; 368 } 369 if (this->GridpolyPts) 370 { 371 this->GridpolyPts->Delete(); 372 this->GridpolyPts = NULL; 373 } 374 } 375 376 // **************************************************************** 263 377 void vtkRpAxisActor::ReleaseGraphicsResources(vtkWindow *win) 264 378 { 265 379 this->TitleActor->ReleaseGraphicsResources(win); 380 this->TitleActor2D->ReleaseGraphicsResources(win); 266 381 for (int i=0; i < this->NumberOfLabelsBuilt; i++) 267 382 { 268 383 this->LabelActors[i]->ReleaseGraphicsResources(win); 269 } 270 this->AxisActor->ReleaseGraphicsResources(win); 384 this->LabelActors2D[i]->ReleaseGraphicsResources(win); 385 } 386 this->AxisLinesActor->ReleaseGraphicsResources(win); 387 this->GridlinesActor->ReleaseGraphicsResources(win); 388 this->InnerGridlinesActor->ReleaseGraphicsResources(win); 389 this->GridpolysActor->ReleaseGraphicsResources(win); 271 390 } 272 391 273 392 // **************************************************************** 274 //275 // Modifications:276 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 2001277 // Copy over mustAdjustValue and valueScaleFactor.278 //279 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 2002280 // Call superclass's method in new VTK 4.0 way.281 //282 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003283 // Removed mustAdjustValue, valueScaleFator.284 //285 // ****************************************************************286 287 void vtkRpAxisActor::ShallowCopy(vtkProp *prop)288 {289 vtkRpAxisActor *a = vtkRpAxisActor::SafeDownCast(prop);290 if (a != NULL)291 {292 this->SetPoint1(a->GetPoint1());293 this->SetPoint2(a->GetPoint2());294 this->SetCamera(a->GetCamera());295 this->SetRange(a->GetRange());296 this->SetLabelFormat(a->GetLabelFormat());297 this->SetTitle(a->GetTitle());298 this->SetAxisVisibility(a->GetAxisVisibility());299 this->SetTickVisibility(a->GetTickVisibility());300 this->SetLabelVisibility(a->GetLabelVisibility());301 this->SetTitleVisibility(a->GetTitleVisibility());302 }303 304 // Now do superclass305 this->Superclass::ShallowCopy(prop);306 }307 308 // ****************************************************************309 // Build the axis, ticks, title, and labels and render.310 //311 // Modifications:312 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 2002313 // Don't render a zero-length axis.314 //315 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003316 // Added bool argument to BuildAxis.317 //318 // ****************************************************************319 320 393 int vtkRpAxisActor::RenderOpaqueGeometry(vtkViewport *viewport) 321 394 { … … 328 401 if (!this->AxisHasZeroLength) 329 402 { 403 if(this->DrawGridlinesOnly && this->DrawGridlines) 404 { 405 // Exit !!!! 406 return this->GridlinesActor->RenderOpaqueGeometry(viewport); 407 } 330 408 if (this->Title != NULL && this->Title[0] != 0 && this->TitleVisibility) 331 409 { 332 renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport); 333 } 334 410 if (this->Use2DMode == 0) 411 { 412 renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport); 413 } 414 else 415 { 416 renderedSomething += this->TitleActor2D->RenderOpaqueGeometry(viewport); 417 } 418 } 335 419 if (this->AxisVisibility || this->TickVisibility) 336 420 { 337 renderedSomething += this->AxisActor->RenderOpaqueGeometry(viewport); 338 } 339 421 renderedSomething += this->AxisLinesActor->RenderOpaqueGeometry(viewport); 422 } 423 if(this->DrawGridlines) 424 { 425 renderedSomething += this->GridlinesActor->RenderOpaqueGeometry(viewport); 426 } 427 if(this->DrawInnerGridlines) 428 { 429 renderedSomething += this->InnerGridlinesActor->RenderOpaqueGeometry(viewport); 430 } 340 431 if (this->LabelVisibility) 341 432 { 342 433 for (i=0; i<this->NumberOfLabelsBuilt; i++) 343 434 { 344 renderedSomething += 345 this->LabelActors[i]->RenderOpaqueGeometry(viewport); 435 if (this->Use2DMode == 0) 436 { 437 renderedSomething += 438 this->LabelActors[i]->RenderOpaqueGeometry(viewport); 439 } 440 else 441 { 442 renderedSomething += 443 this->LabelActors2D[i]->RenderOpaqueGeometry(viewport); 444 } 346 445 } 347 446 } … … 349 448 350 449 return renderedSomething; 450 } 451 452 // **************************************************************** 453 // Build the translucent poly actors and render. 454 // **************************************************************** 455 int vtkRpAxisActor::RenderTranslucentGeometry(vtkViewport *viewport) 456 { 457 return this->RenderTranslucentPolygonalGeometry(viewport); 458 } 459 460 // **************************************************************** 461 // Build the translucent poly actors and render. 462 // **************************************************************** 463 int vtkRpAxisActor::RenderTranslucentPolygonalGeometry(vtkViewport *viewport) 464 { 465 466 int renderedSomething=0; 467 468 this->BuildAxis(viewport, false); 469 470 // Everything is built, just have to render 471 472 if (!this->AxisHasZeroLength && !this->DrawGridlinesOnly) 473 { 474 if(this->DrawGridpolys) 475 { 476 renderedSomething += this->GridpolysActor->RenderTranslucentPolygonalGeometry(viewport); 477 } 478 } 479 480 return renderedSomething; 481 } 482 483 // **************************************************************** 484 // Render the 2d annotations. 485 // **************************************************************** 486 int vtkRpAxisActor::RenderOverlay(vtkViewport *viewport) 487 { 488 int i, renderedSomething=0; 489 490 // Everything is built, just have to render 491 if (!this->AxisHasZeroLength && !this->DrawGridlinesOnly) 492 { 493 if( this->Use2DMode == 1 ) 494 { 495 renderedSomething += this->TitleActor2D->RenderOverlay(viewport); 496 } 497 if (this->LabelVisibility) 498 { 499 for (i=0; i<this->NumberOfLabelsBuilt; i++) 500 { 501 if (this->Use2DMode == 1) 502 { 503 renderedSomething += this->LabelActors2D[i]->RenderOverlay(viewport); 504 } 505 } 506 } 507 } 508 509 return renderedSomething; 510 } 511 512 // ************************************************************************** 513 int vtkRpAxisActor::HasTranslucentPolygonalGeometry() 514 { 515 if (this->Visibility && !this->AxisHasZeroLength) 516 { 517 518 if (this->TitleVisibility) 519 { 520 if (this->Use2DMode) 521 { 522 if (this->TitleActor2D->HasTranslucentPolygonalGeometry()) 523 { 524 return 1; 525 } 526 } 527 else 528 { 529 if (this->TitleActor->HasTranslucentPolygonalGeometry()) 530 { 531 return 1; 532 } 533 } 534 } 535 536 if (this->LabelVisibility) 537 { 538 if (this->Use2DMode) 539 { 540 for (int i = 0; i < this->NumberOfLabelsBuilt; ++i) 541 { 542 if (this->LabelActors2D[i]->HasTranslucentPolygonalGeometry()) 543 { 544 return 1; 545 } // end if 546 } // end for 547 } // end 2D 548 else 549 { 550 for (int i = 0; i < this->NumberOfLabelsBuilt; ++i) 551 { 552 if (this->LabelActors[i]->HasTranslucentPolygonalGeometry()) 553 { 554 return 1; 555 } // end if 556 } // end for 557 } // end 3D 558 } // end label vis 559 560 if (this->AxisLinesActor->HasTranslucentPolygonalGeometry()) 561 { 562 return 1; 563 } 564 565 if (this->DrawGridlines && 566 this->GridlinesActor->HasTranslucentPolygonalGeometry()) 567 { 568 return 1; 569 } 570 571 if (this->DrawInnerGridlines && 572 this->InnerGridlinesActor->HasTranslucentPolygonalGeometry()) 573 { 574 return 1; 575 } 576 577 if (this->DrawGridpolys && 578 this-GridpolysActor->HasTranslucentPolygonalGeometry()) 579 { 580 return 1; 581 } 582 583 return this->Superclass::HasTranslucentPolygonalGeometry(); 584 585 } // end this vis 586 587 return 0; 351 588 } 352 589 353 590 // ************************************************************************** 354 591 // Perform some initialization, determine which Axis type we are 355 // and call the appropriate build method.356 //357 // Modifications:358 // Kathleen Bonnell, Wed Nov 7 17:45:20 PST 2001359 // Added logic to only rebuild sub-parts if necessary.360 //361 // Kathleen Bonnell, Fri Nov 30 17:02:41 PST 2001362 // Moved setting values for LastRange to end of method, so they363 // can be used in comparisons elsewhere.364 //365 // Kathleen Bonnell, Mon Dec 3 16:49:01 PST 2001366 // Compare vtkTimeStamps correctly.367 //368 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 2002369 // Test for zero length axis.370 //371 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003372 // Added bool argument that will allow all axis components to be built373 // if set to true. Removed call to AdjustTicksComputeRange (handled by374 // vtkCubeAxesActor. Remvoed call to Build?TypeAxis, added calls375 // to BuildLabels, SetAxisPointsAndLines and BuildTitle, (which used to376 // be handled in Build?TypeAxis). .377 //378 592 // ************************************************************************** 379 380 593 void vtkRpAxisActor::BuildAxis(vtkViewport *viewport, bool force) 381 594 { … … 409 622 if (force || this->GetProperty()->GetMTime() > this->BuildTime.GetMTime()) 410 623 { 411 this->AxisActor->SetProperty(this->GetProperty());624 //this->AxisLinesActor->SetProperty(this->GetProperty()); 412 625 this->TitleActor->SetProperty(this->GetProperty()); 626 this->TitleActor->GetProperty()->SetColor(this->TitleTextProperty->GetColor()); 413 627 } 414 628 … … 417 631 // 418 632 bool ticksRebuilt; 419 if (this->AxisType == VTK_AXIS_TYPE_X) 420 { 421 ticksRebuilt = this->BuildTickPointsForXType(p1, p2, force); 422 } 423 else if (this->AxisType == VTK_AXIS_TYPE_Y) 424 { 425 ticksRebuilt = this->BuildTickPointsForYType(p1, p2, force); 426 } 427 else 428 { 429 ticksRebuilt = this->BuildTickPointsForZType(p1, p2, force); 430 } 633 ticksRebuilt = this->BuildTickPoints(p1, p2, force); 431 634 432 635 bool tickVisChanged = this->TickVisibilityChanged(); 433 636 434 if (force || ticksRebuilt || tickVisChanged) 435 { 436 this->SetAxisPointsAndLines(); 437 } 438 439 this->BuildLabels(viewport, force); 637 if (force || ticksRebuilt || tickVisChanged || this->LastDrawGridlinesLocation != this->DrawGridlinesLocation) 638 { 639 this->LastDrawGridlinesLocation = this->DrawGridlinesLocation; 640 this->SetAxisPointsAndLines(); 641 } 642 643 // If the ticks have been rebuilt it is more than likely 644 // that the labels should follow... 645 this->BuildLabels(viewport, force || ticksRebuilt); 646 if (this->Use2DMode == 1) 647 { 648 this->BuildLabels2D(viewport, force || ticksRebuilt); 649 } 440 650 441 651 if (this->Title != NULL && this->Title[0] != 0) 442 652 { 443 this->BuildTitle(force); 653 this->BuildTitle(force || ticksRebuilt); 654 if( this->Use2DMode == 1 ) 655 { 656 this->BuildTitle2D(viewport, force || ticksRebuilt); 657 } 444 658 } 445 659 446 660 this->LastAxisPosition = this->AxisPosition; 447 this->LastTickLocation = this->TickLocation;448 661 449 662 this->LastRange[0] = this->Range[0]; … … 453 666 454 667 // **************************************************************** 455 //456 668 // Set label values and properties. 457 //458 // Modifications:459 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 2001460 // Use valueScaleFactor to scale value if necessary.461 //462 // Kathleen Bonnell, Wed Nov 7 17:45:20 PST 2001463 // Added code for early termination. Added call to SetNumberOfLabels464 // for dynamic memory allocation. Number of labels limited to 200.465 //466 // Kathleen Bonnell, Fri Nov 30 17:02:41 PST 2001467 // Added test for modified range to determine if labels really need to468 // be built.469 //470 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 2002471 // Use defined constant to limit number of labels.472 //473 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003474 // Remvoed determination of label text, added call to475 // SetLabelPositions.476 //477 669 // **************************************************************** 478 479 670 void 480 671 vtkRpAxisActor::BuildLabels(vtkViewport *viewport, bool force) … … 489 680 this->LabelActors[i]->SetCamera(this->Camera); 490 681 this->LabelActors[i]->SetProperty(this->GetProperty()); 682 this->LabelActors[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor()); 683 this->LabelActors[i]->SetOrientation(0., 0., this->LabelTextProperty->GetOrientation()); 684 685 if(!this->GetCalculateLabelOffset()) 686 { 687 this->LabelActors[i]->SetAutoCenter(1); 688 } 491 689 } 492 690 … … 505 703 // ******************************************************************* 506 704 // Determine and set scale factor and position for labels. 507 //508 // Modifications:509 // Kathleen Bonnell, Fri Nov 30 17:02:41 PST 2001510 // Reset labels scale to 1. before testing length, in order to511 // ensure proper scaling. Use Bounds[1] and Bounds[0] for bWidth512 // instead of Bounds[5] and Bounds[4].513 //514 // Kathleen Bonnell, Tue Dec 4 09:55:03 PST 2001515 // Ensure that scale does not go below MinScale.516 //517 // Kathleen Bonnell, Tue Apr 9 14:41:08 PDT 2002518 // Removed MinScale as it allowed axes with very small ranges519 // to have labels scaled too large for the dataset.520 //521 // Kathleen Bonnell, Fri Jul 18 09:09:31 PDT 2003522 // Renamed to SetLabelPosition. Removed calculation of label523 // scale factor, added check for no labels to early return test.524 //525 // Eric Brugger, Tue Jul 29 14:42:44 PDT 2003526 // Corrected the test that causes the routine to exit early when527 // no work needs to be done.528 //529 // David Gobbi, Fri Apr 8 16:50:00 MST 2011530 // Use mapper bounds, not actor bounds.531 //532 705 // ******************************************************************* 533 534 706 void vtkRpAxisActor::SetLabelPositions(vtkViewport *viewport, bool force) 535 707 { … … 580 752 this->LabelActors[i]->GetScale(scale); 581 753 582 double halfWidth = (bounds[1] - bounds[0]) * 0.5 * scale[0]; 583 double halfHeight = (bounds[3] - bounds[2]) * 0.5 * scale[1]; 584 585 center[0] = tick[0] + xmult * (halfWidth + this->MinorTickSize); 586 center[1] = tick[1] + ymult * (halfHeight + this->MinorTickSize); 587 pos[0] = (center[0] - xadjust *halfWidth); 588 pos[1] = (center[1] - yadjust *halfHeight); 589 pos[2] = tick[2]; 754 if(this->CalculateLabelOffset) 755 { 756 double halfWidth = (bounds[1] - bounds[0]) * 0.5 * scale[0]; 757 double halfHeight = (bounds[3] - bounds[2]) * 0.5 * scale[1]; 758 759 center[0] = tick[0] + xmult * (halfWidth + this->MinorTickSize); 760 center[1] = tick[1] + ymult * (halfHeight + this->MinorTickSize); 761 center[2] = tick[2]; 762 763 pos[0] = (center[0] - xadjust *halfWidth); 764 pos[1] = (center[1] - yadjust *halfHeight); 765 pos[2] = center[2]; 766 } 767 else 768 { 769 center[0] = tick[0] ; 770 center[1] = tick[1]; 771 center[2] = tick[2]; 772 773 pos[0] = center[0]; 774 pos[1] = center[1]; 775 pos[2] = center[2]; 776 } 777 590 778 this->LabelActors[i]->SetPosition(pos[0], pos[1], pos[2]); 591 779 } 592 780 } 781 782 // ******************************************************************* 783 // Set 2D label values and properties. 784 // ******************************************************************* 785 void 786 vtkRpAxisActor::BuildLabels2D(vtkViewport *viewport, bool force) 787 { 788 if (!force && (!this->LabelVisibility || this->NumberOfLabelsBuilt == 0)) 789 return; 790 791 for (int i = 0; i < this->NumberOfLabelsBuilt; i++) 792 { 793 this->LabelActors2D[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor()); 794 this->LabelActors2D[i]->GetProperty()->SetOpacity(1); 795 this->LabelActors2D[i]->GetTextProperty()->SetFontSize(this->LabelTextProperty->GetFontSize()); 796 this->LabelActors2D[i]->GetTextProperty()->SetVerticalJustificationToBottom(); 797 this->LabelActors2D[i]->GetTextProperty()->SetJustificationToLeft(); 798 } 799 800 this->NeedBuild2D = this->BoundsDisplayCoordinateChanged(viewport); 801 if (force || this->NeedBuild2D) 802 { 803 this->SetLabelPositions2D(viewport, force); 804 } 805 } 806 807 808 // ******************************************************************* 809 // Determine and set scale factor and position for 2D labels. 810 // ******************************************************************* 811 void 812 vtkRpAxisActor::SetLabelPositions2D(vtkViewport *viewport, bool force) 813 { 814 if (!force && (!this->LabelVisibility || this->NumberOfLabelsBuilt == 0) ) 815 return; 816 817 int xmult = 0; 818 int ymult = 0; 819 double xcoeff = 0.; 820 double ycoeff = 0.; 821 822 // we are in 2D mode, so no Z axis 823 switch (this->AxisType) 824 { 825 case VTK_AXIS_TYPE_X : 826 xmult = 0; 827 ymult = vtkRpAxisActorMultiplierTable1[this->AxisPosition]; 828 xcoeff = 0.5; 829 ycoeff = 1.0; 830 break; 831 case VTK_AXIS_TYPE_Y : 832 xmult = vtkRpAxisActorMultiplierTable1[this->AxisPosition]; 833 ymult = 0; 834 xcoeff = 1.0; 835 ycoeff = 0.5; 836 break; 837 } 838 839 840 int ptIdx; 841 // 842 // xadjust & yadjust are used for positioning the label correctly 843 // depending upon the 'orientation' of the axis as determined 844 // by its position in view space (via transformed bounds). 845 // 846 double displayBounds[6] = { 0., 0., 0., 0., 0., 0.}; 847 this->TransformBounds(viewport, displayBounds); 848 double xadjust = (displayBounds[0] > displayBounds[1] ? -1 : 1); 849 double yadjust = (displayBounds[2] > displayBounds[3] ? -1 : 1); 850 double transpos[3] = {0., 0., 0.}; 851 double center[3], tick[3], pos[2]; 852 853 vtkTextRenderer *tren = vtkTextRenderer::GetInstance(); 854 if (!tren) 855 { 856 vtkErrorMacro(<< "Unable to obtain the vtkTextRenderer instance!"); 857 return; 858 } 859 860 for (int i = 0; i < this->NumberOfLabelsBuilt; i++) 861 { 862 ptIdx = 4*i + 1; 863 864 this->MajorTickPts->GetPoint(ptIdx, tick); 865 866 center[0] = tick[0] + xmult * this->MinorTickSize; 867 center[1] = tick[1] + ymult * this->MinorTickSize; 868 center[2] = tick[2]; 869 870 viewport->SetWorldPoint(center[0], center[1], center[2], 1.0); 871 viewport->WorldToDisplay(); 872 viewport->GetDisplayPoint(transpos); 873 874 int bbox[4]; 875 if (!tren->GetBoundingBox(this->LabelActors2D[i]->GetTextProperty(), 876 this->LabelActors2D[i]->GetInput(), bbox)) 877 { 878 vtkErrorMacro(<< "Unable to calculate bounding box for label " 879 << this->LabelActors2D[i]->GetInput()); 880 continue; 881 } 882 883 double width = (bbox[1]-bbox[0]); 884 double height = (bbox[3]-bbox[2]); 885 886 pos[0] = (transpos[0] - xadjust*width*xcoeff); 887 pos[1] = (transpos[1] - yadjust*height*ycoeff); 888 this->LabelActors2D[i]->SetPosition( pos[0], pos[1] ); 889 } 890 } 891 593 892 594 893 // ********************************************************************** 595 894 // Determines scale and position for the Title. Currently, 596 895 // title can only be centered with respect to its axis. 597 //598 // Modifications:599 // Kathleen Bonnell, Wed Nov 7 17:45:20 PST 2001600 // Added logic for early-termination.601 //602 // Kathleen Bonnell, Mon Dec 3 16:49:01 PST 2001603 // Test for modified bounds before early termination, use604 // MinScale, modified target so title size is a bit more reasonable.605 //606 // Kathleen Bonnell, Tue Apr 9 14:41:08 PDT 2002607 // Removed MinScale as it allowed axes with very small ranges608 // to have labels scaled too large for the dataset.609 //610 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003611 // Added bool argument that allow the build to be forced, even if612 // the title won't be visible.613 //614 // Kathleen Bonnell, Tue Aug 31 16:17:43 PDT 2004615 // Added TitleTime test so that the title can be rebuilt when its616 // text has changed.617 //618 // Hank Childs, Sun May 13 11:06:12 PDT 2007619 // Fix bug with positioning of titles (the titles were being placed620 // far away from the bounding box in some cases).621 //622 // David Gobbi, Fri Apr 8 16:50:00 MST 2011623 // Use mapper bounds, not actor bounds.624 //625 896 // ********************************************************************** 626 627 897 void vtkRpAxisActor::BuildTitle(bool force) 628 898 { 899 this->NeedBuild2D = false; 629 900 if (!force && !this->TitleVisibility) 630 901 { … … 648 919 } 649 920 921 this->NeedBuild2D = true; 650 922 switch (this->AxisType) 651 923 { … … 676 948 maxHeight = (labHeight > maxHeight ? labHeight : maxHeight); 677 949 } 950 678 951 this->TitleVector->SetText(this->Title); 952 953 this->TitleActor->GetProperty()->SetColor(this->TitleTextProperty->GetColor()); 679 954 this->TitleActor->SetCamera(this->Camera); 680 955 this->TitleActor->SetPosition(p2[0], p2[1], p2[2]); 681 956 this->TitleActor->GetMapper()->GetBounds(titleBounds); 682 957 this->TitleActor->GetScale(scale); 683 halfTitleWidth = (titleBounds[1] - titleBounds[0]) * 0.5 * scale[0]; 684 halfTitleHeight = (titleBounds[3] - titleBounds[2]) * 0.5 * scale[1]; 958 if(!this->GetCalculateTitleOffset()) 959 { 960 this->TitleActor->SetAutoCenter(1); 961 } 685 962 686 963 center[0] = p1[0] + (p2[0] - p1[0]) / 2.0; … … 688 965 center[2] = p1[2] + (p2[2] - p1[2]) / 2.0; 689 966 690 center[0] += xmult * (halfTitleWidth + maxWidth); 691 center[1] += ymult * (halfTitleHeight + 2*maxHeight); 692 693 pos[0] = center[0] - xmult*halfTitleWidth; 694 pos[1] = center[1] - ymult*halfTitleHeight; 967 if(this->CalculateTitleOffset) 968 { 969 halfTitleWidth = (titleBounds[1] - titleBounds[0]) * 0.5 * scale[0]; 970 halfTitleHeight = (titleBounds[3] - titleBounds[2]) * 0.5 * scale[1]; 971 center[0] += xmult * (halfTitleWidth + maxWidth); 972 center[1] += ymult * (halfTitleHeight + 2*maxHeight); 973 } 974 975 pos[0] = center[0]; 976 pos[1] = center[1]; 695 977 pos[2] = center[2]; 978 696 979 this->TitleActor->SetPosition(pos[0], pos[1], pos[2]); 980 } 981 982 // ********************************************************************** 983 // Determines scale and position for the 2D Title. Currently, 984 // title can only be centered with respect to its axis. 985 // ********************************************************************** 986 void 987 vtkRpAxisActor::BuildTitle2D(vtkViewport *viewport, bool force) 988 { 989 if (!this->NeedBuild2D && !force && !this->TitleVisibility) 990 { 991 return; 992 } 993 994 // for textactor instead of follower 995 this->TitleActor2D->SetInput( this->TitleVector->GetText() ); 996 this->TitleActor2D->GetProperty()->SetColor( this->TitleTextProperty->GetColor() ); 997 this->TitleActor2D->GetProperty()->SetOpacity(1); 998 this->TitleActor2D->GetTextProperty()->SetFontSize( this->TitleTextProperty->GetFontSize() ); 999 this->TitleActor2D->GetTextProperty()->SetVerticalJustificationToCentered(); 1000 this->TitleActor2D->GetTextProperty()->SetJustificationToCentered(); 1001 1002 if (this->AxisType == VTK_AXIS_TYPE_Y) 1003 { 1004 if (strlen(this->TitleActor2D->GetInput()) > 2) 1005 { 1006 // warning : orientation have to be set on vtkTextActor and not on the vtkTextActor's vtkTextProperty 1007 // otherwise there is a strange effect (first letter is not align with the others) 1008 this->TitleActor2D->SetOrientation(90); 1009 } 1010 else 1011 { 1012 // if in the previous rendering, the orientation was set. 1013 this->TitleActor2D->SetOrientation(0); 1014 } 1015 } 1016 1017 // stuff for 2D axis with TextActor 1018 double transpos[3]; 1019 double* pos = this->TitleActor->GetPosition(); 1020 viewport->SetWorldPoint(pos[0], pos[1], pos[2], 1.0); 1021 viewport->WorldToDisplay(); 1022 viewport->GetDisplayPoint(transpos); 1023 if (this->AxisType == VTK_AXIS_TYPE_X) 1024 { 1025 transpos[1] += this->VerticalOffsetXTitle2D; 1026 } 1027 else if (this->AxisType == VTK_AXIS_TYPE_Y) 1028 { 1029 transpos[0] += this->HorizontalOffsetYTitle2D; 1030 } 1031 if (transpos[1] < 10.) transpos[1] = 10.; 1032 if (transpos[0] < 10.) transpos[0] = 10.; 1033 if (this->SaveTitlePosition == 0) 1034 { 1035 this->TitleActor2D->SetPosition(transpos[0], transpos[1]); 1036 } 1037 else 1038 { 1039 if (this->SaveTitlePosition == 1) 1040 { 1041 TitleConstantPosition[0] = transpos[0]; 1042 TitleConstantPosition[1] = transpos[1]; 1043 this->SaveTitlePosition = 2; 1044 } 1045 this->TitleActor2D->SetPosition(TitleConstantPosition[0], TitleConstantPosition[1]); 1046 } 697 1047 } 698 1048 … … 743 1093 744 1094 // **************************************************************** 745 // Modifications:746 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 2002747 // Call superclass's method in new VTK 4.0 way.748 // ****************************************************************749 750 1095 void vtkRpAxisActor::PrintSelf(ostream& os, vtkIndent indent) 751 1096 { … … 755 1100 os << indent << "Number Of Labels Built: " 756 1101 << this->NumberOfLabelsBuilt << "\n"; 757 os << indent << "Range: (" << this->Range[0] 758 << ", " << this->Range[1] << ")\n"; 1102 os << indent << "Range: (" 1103 << this->Range[0] << ", " 1104 << this->Range[1] << ")\n"; 759 1105 760 1106 os << indent << "Label Format: " << this->LabelFormat << "\n"; … … 795 1141 } 796 1142 797 os << indent << "DeltaMajor: " << this->DeltaMajor << endl; 1143 os << indent << "DeltaMajor: " 1144 << this->DeltaMajor[0] << "," 1145 << this->DeltaMajor[1] << "," 1146 << this->DeltaMajor[2] << endl; 798 1147 os << indent << "DeltaMinor: " << this->DeltaMinor << endl; 799 1148 os << indent << "DeltaRangeMajor: " << this->DeltaRangeMajor << endl; … … 804 1153 os << indent << "MinorTicksVisible: " << this->MinorTicksVisible << endl; 805 1154 1155 os << indent << "TitleActor: "; 1156 if(this->TitleActor) 1157 { 1158 os << indent << "TitleActor: (" << this->TitleActor << ")\n"; 1159 } 1160 else 1161 { 1162 os << "(none)" << endl; 1163 } 1164 806 1165 os << indent << "Camera: "; 807 1166 if (this->Camera) … … 819 1178 os << indent << "DrawGridlines: " << this->DrawGridlines << endl; 820 1179 821 os << indent << "MajorStart: " << this->MajorStart << endl; 822 os << indent << "MinorStart: " << this->MinorStart << endl; 1180 os << indent << "MajorStart: " 1181 << this->MajorStart[0] << "," 1182 << this->MajorStart[1] << "," 1183 << this->MajorStart[2] << endl; 823 1184 824 1185 os << indent << "AxisPosition: " << this->AxisPosition << endl; … … 828 1189 os << indent << "GridlineZLength: " << this->GridlineZLength << endl; 829 1190 1191 os << indent << "DrawInnerGridpolys: " << this->DrawGridpolys << endl; 1192 os << indent << "DrawInnerGridlines: " << this->DrawInnerGridlines << endl; 1193 830 1194 os << indent << "TickLocation: " << this->TickLocation << endl; 831 } 1195 1196 os << indent << "CalculateLabelOffset: " << this->CalculateLabelOffset << std::endl; 1197 os << indent << "CalculateTitleOffset: " << this->CalculateTitleOffset << std::endl; 1198 1199 os << indent << "LabelTextProperty: " << this->LabelTextProperty << endl; 1200 os << indent << "TitleTextProperty: " << this->TitleTextProperty << endl; 1201 1202 os << indent << "Use2DMode: " << this->Use2DMode << endl; 1203 os << indent << "SaveTitlePosition: " << this->SaveTitlePosition << endl; 1204 os << indent << "VerticalOffsetXTitle2D" << this->VerticalOffsetXTitle2D << endl; 1205 os << indent << "HorizontalOffsetYTitle2D" << this->HorizontalOffsetYTitle2D << endl; 1206 os << indent << "LastMinDisplayCoordinates: (" 1207 << this->LastMinDisplayCoordinate[0] << ", " 1208 << this->LastMinDisplayCoordinate[1] << ", " 1209 << this->LastMinDisplayCoordinate[2] << ")" << endl; 1210 os << indent << "LastMaxDisplayCoordinates: (" 1211 << this->LastMaxDisplayCoordinate[0] << ", " 1212 << this->LastMaxDisplayCoordinate[1] << ", " 1213 << this->LastMaxDisplayCoordinate[2] << ")" << endl; 1214 } 832 1215 833 1216 // ************************************************************************** 834 1217 // Sets text string for label vectors. Allocates memory if necessary. 835 //836 // Programmer: Kathleen Bonnell837 // Creation: July 18, 2003838 1218 // ************************************************************************** 839 1219 void vtkRpAxisActor::SetLabels(vtkStringArray *labels) … … 853 1233 this->LabelMappers[i]->Delete(); 854 1234 this->LabelActors[i]->Delete(); 1235 this->LabelActors2D[i]->Delete(); 855 1236 } 856 1237 delete [] this->LabelVectors; 857 1238 delete [] this->LabelMappers; 858 1239 delete [] this->LabelActors; 1240 delete [] this->LabelActors2D; 859 1241 } 860 1242 861 1243 this->LabelVectors = new vtkVectorText * [numLabels]; 862 1244 this->LabelMappers = new vtkPolyDataMapper * [numLabels]; 863 this->LabelActors = new vtkFollower * [numLabels]; 1245 this->LabelActors = new vtkRpAxisFollower * [numLabels]; 1246 this->LabelActors2D = new vtkTextActor * [numLabels]; 864 1247 865 1248 for (i = 0; i < numLabels; i++) … … 867 1250 this->LabelVectors[i] = vtkVectorText::New(); 868 1251 this->LabelMappers[i] = vtkPolyDataMapper::New(); 869 #ifdef USE_VTK6 870 this->LabelMappers[i]->SetInputData(this->LabelVectors[i]->GetOutput()); 871 #else 872 this->LabelMappers[i]->SetInput(this->LabelVectors[i]->GetOutput()); 873 #endif 874 this->LabelActors[i] = vtkFollower::New(); 1252 this->LabelMappers[i]->SetInputConnection( 1253 this->LabelVectors[i]->GetOutputPort()); 1254 this->LabelActors[i] = vtkRpAxisFollower::New(); 875 1255 this->LabelActors[i]->SetMapper(this->LabelMappers[i]); 1256 this->LabelActors[i]->SetEnableDistanceLOD(0); 1257 this->LabelActors[i]->GetProperty()->SetAmbient(1.); 1258 this->LabelActors[i]->GetProperty()->SetDiffuse(0.); 1259 this->LabelActors[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor()); 1260 this->LabelActors2D[i] = vtkTextActor::New(); 876 1261 } 877 1262 } … … 883 1268 { 884 1269 this->LabelVectors[i]->SetText(labels->GetValue(i).c_str()); 1270 this->LabelActors2D[i]->SetInput(this->LabelVectors[i]->GetText()); 885 1271 } 886 1272 this->NumberOfLabelsBuilt = numLabels; … … 889 1275 890 1276 // ************************************************************************** 891 // Creates points for ticks (minor, major, gridlines) in correct position892 // for X-type axsis.893 //894 // Programmer: Kathleen Bonnell895 // Creation: November 7, 2001896 //897 // Modifications:898 // Kathleen Bonnell, Mon Dec 3 16:49:01 PST 2001899 // Compare vtkTimeStamps correctly.900 //901 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 2002902 // Use defined constant VTK_MAX_TICKS to prevent infinite loops.903 //904 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003905 // Allow a forced build, despite previous build time.906 //907 // **************************************************************************908 bool vtkRpAxisActor::BuildTickPointsForXType(double p1[3], double p2[3],909 bool force)910 {911 if (!force && (this->AxisPosition == this->LastAxisPosition) &&912 (this->TickLocation == this->LastTickLocation ) &&913 (this->BoundsTime.GetMTime() < this->BuildTime.GetMTime()))914 {915 return false;916 }917 918 double xPoint1[3], xPoint2[3], yPoint[3], zPoint[3], x;919 int numTicks;920 921 this->MinorTickPts->Reset();922 this->MajorTickPts->Reset();923 this->GridlinePts->Reset();924 925 //926 // Ymult & Zmult control adjustments to tick position based927 // upon "where" this axis is located in relation to the underlying928 // assumed bounding box.929 //930 int yMult = vtkRpAxisActorMultiplierTable1[this->AxisPosition];931 int zMult = vtkRpAxisActorMultiplierTable2[this->AxisPosition];932 933 //934 // Build Minor Ticks935 //936 if (this->TickLocation == VTK_TICKS_OUTSIDE)937 {938 xPoint1[1] = xPoint2[1] = zPoint[1] = p1[1];939 xPoint1[2] = xPoint2[2] = yPoint[2] = p1[2];940 yPoint[1] = p1[1] + yMult * this->MinorTickSize;941 zPoint[2] = p1[2] + zMult * this->MinorTickSize;942 }943 else if (this->TickLocation == VTK_TICKS_INSIDE)944 {945 yPoint[1] = xPoint2[1] = zPoint[1] = p1[1];946 xPoint1[2] = yPoint[2] = zPoint[2] = p1[2];947 xPoint1[1] = p1[1] - yMult * this->MinorTickSize;948 xPoint2[2] = p1[2] - zMult * this->MinorTickSize;949 }950 else // both sides951 {952 xPoint2[1] = zPoint[1] = p1[1];953 xPoint1[2] = yPoint[2] = p1[2];954 yPoint[1] = p1[1] + yMult * this->MinorTickSize;955 zPoint[2] = p1[2] + zMult * this->MinorTickSize;956 xPoint1[1] = p1[1] - yMult * this->MinorTickSize;957 xPoint2[2] = p1[2] - zMult * this->MinorTickSize;958 }959 x = this->MinorStart;960 numTicks = 0;961 while (x <= p2[0] && numTicks < VTK_MAX_TICKS)962 {963 xPoint1[0] = xPoint2[0] = yPoint[0] = zPoint[0] = x;964 // xy-portion965 this->MinorTickPts->InsertNextPoint(xPoint1);966 this->MinorTickPts->InsertNextPoint(yPoint);967 // xz-portion968 this->MinorTickPts->InsertNextPoint(xPoint2);969 this->MinorTickPts->InsertNextPoint(zPoint);970 x+= this->DeltaMinor;971 numTicks++;972 }973 974 //975 // Gridline points976 //977 yPoint[1] = xPoint2[1] = zPoint[1] = p1[1];978 xPoint1[1] = p1[1] - yMult * this->GridlineYLength;979 xPoint1[2] = yPoint[2] = zPoint[2] = p1[2];980 xPoint2[2] = p1[2] - zMult * this->GridlineZLength;981 982 x = this->MajorStart;983 numTicks = 0;984 while (x <= p2[0] && numTicks < VTK_MAX_TICKS)985 {986 xPoint1[0] = xPoint2[0] = yPoint[0] = zPoint[0] = x;987 // xy-portion988 this->GridlinePts->InsertNextPoint(xPoint1);989 this->GridlinePts->InsertNextPoint(yPoint);990 // xz-portion991 this->GridlinePts->InsertNextPoint(xPoint2);992 this->GridlinePts->InsertNextPoint(zPoint);993 x += this->DeltaMajor;994 numTicks++;995 }996 997 //998 // Major ticks999 //1000 if (this->TickLocation == VTK_TICKS_OUTSIDE)1001 {1002 xPoint1[1] = xPoint2[1] = zPoint[1] = p1[1];1003 xPoint1[2] = xPoint2[2] = yPoint[2] = p1[2];1004 yPoint[1] = p1[1] + yMult * this->MajorTickSize;1005 zPoint[2] = p1[2] + zMult * this->MajorTickSize;1006 }1007 else if (this->TickLocation == VTK_TICKS_INSIDE)1008 {1009 yPoint[1] = xPoint2[1] = zPoint[1] = p1[1];1010 xPoint1[2] = yPoint[2] = zPoint[2] = p1[2];1011 xPoint1[1] = p1[1] - yMult * this->MajorTickSize;1012 xPoint2[2] = p1[2] - zMult * this->MajorTickSize;1013 }1014 else // both sides1015 {1016 xPoint2[1] = zPoint[1] = p1[1];1017 xPoint1[2] = yPoint[2] = p1[2];1018 yPoint[1] = p1[1] + yMult * this->MajorTickSize;1019 zPoint[2] = p1[2] + zMult * this->MajorTickSize;1020 xPoint1[1] = p1[1] - yMult * this->MajorTickSize;1021 xPoint2[2] = p1[2] - zMult * this->MajorTickSize;1022 }1023 x = this->MajorStart;1024 numTicks = 0;1025 while (x <= p2[0] && numTicks < VTK_MAX_TICKS)1026 {1027 xPoint1[0] = xPoint2[0] = yPoint[0] = zPoint[0] = x;1028 // xy-portion1029 this->MajorTickPts->InsertNextPoint(xPoint1);1030 this->MajorTickPts->InsertNextPoint(yPoint);1031 // xz-portion1032 this->MajorTickPts->InsertNextPoint(xPoint2);1033 this->MajorTickPts->InsertNextPoint(zPoint);1034 x += this->DeltaMajor;1035 numTicks++;1036 }1037 1038 return true;1039 }1040 1041 // **************************************************************************1042 // Creates points for ticks (minor, major, gridlines) in correct position1043 // for Y-type axis.1044 //1045 // Programmer: Kathleen Bonnell1046 // Creation: November 7, 20011047 //1048 // Modifications:1049 // Kathleen Bonnell, Mon Dec 3 16:49:01 PST 20011050 // Compare vtkTimeStamps correctly.1051 //1052 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 20021053 // Use defined constant VTK_MAX_TICKS to prevent infinite loops.1054 //1055 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 20031056 // Allow a forced build, despite previous build time.1057 //1058 // **************************************************************************1059 bool vtkRpAxisActor::BuildTickPointsForYType(double p1[3], double p2[3],1060 bool force)1061 {1062 if (!force && (this->AxisPosition == this->LastAxisPosition) &&1063 (this->TickLocation == this->LastTickLocation) &&1064 (this->BoundsTime.GetMTime() < this->BuildTime.GetMTime()))1065 {1066 return false;1067 }1068 1069 double yPoint1[3], yPoint2[3], xPoint[3], zPoint[3], y;1070 int numTicks;1071 1072 this->MinorTickPts->Reset();1073 this->MajorTickPts->Reset();1074 this->GridlinePts->Reset();1075 //1076 // xMult & zMult control adjustments to tick position based1077 // upon "where" this axis is located in relation to the underlying1078 // assumed bounding box.1079 //1080 1081 int xMult = vtkRpAxisActorMultiplierTable1[this->AxisPosition];1082 int zMult = vtkRpAxisActorMultiplierTable2[this->AxisPosition];1083 1084 //1085 // The ordering of the tick endpoints is important because1086 // label position is defined by them.1087 //1088 1089 //1090 // minor ticks1091 //1092 if (this->TickLocation == VTK_TICKS_INSIDE)1093 {1094 yPoint1[2] = xPoint[2] = zPoint[2] = p1[2];1095 yPoint2[0] = xPoint[0] = zPoint[0] = p1[0];1096 yPoint1[0] = p1[0] - xMult * this->MinorTickSize;1097 yPoint2[2] = p1[2] - zMult * this->MinorTickSize;1098 }1099 else if (this->TickLocation == VTK_TICKS_OUTSIDE)1100 {1101 yPoint1[0] = yPoint2[0] = zPoint[0] = p1[0];1102 yPoint1[2] = yPoint2[2] = xPoint[2] = p1[2];1103 xPoint[0] = p1[0] + xMult * this->MinorTickSize;1104 zPoint[2] = p1[2] + zMult * this->MinorTickSize;1105 }1106 else // both sides1107 {1108 yPoint1[2] = xPoint[2] = p1[2];1109 yPoint2[0] = zPoint[0] = p1[0];1110 yPoint1[0] = p1[0] - xMult * this->MinorTickSize;1111 yPoint2[2] = p1[2] + zMult * this->MinorTickSize;1112 xPoint[0] = p1[0] + xMult * this->MinorTickSize;1113 zPoint[2] = p1[2] - zMult * this->MinorTickSize;1114 }1115 y = this->MinorStart;1116 numTicks = 0;1117 while (y < p2[1] && numTicks < VTK_MAX_TICKS)1118 {1119 yPoint1[1] = xPoint[1] = yPoint2[1] = zPoint[1] = y;1120 // yx portion1121 this->MinorTickPts->InsertNextPoint(yPoint1);1122 this->MinorTickPts->InsertNextPoint(xPoint);1123 // yz portion1124 this->MinorTickPts->InsertNextPoint(yPoint2);1125 this->MinorTickPts->InsertNextPoint(zPoint);1126 y += this->DeltaMinor;1127 numTicks++;1128 }1129 1130 //1131 // gridlines1132 //1133 yPoint1[0] = p1[0] - xMult * this->GridlineXLength;1134 yPoint2[2] = p1[2] - zMult * this->GridlineZLength;1135 yPoint2[0] = xPoint[0] = zPoint[0] = p1[0];1136 yPoint1[2] = xPoint[2] = zPoint[2] = p1[2];1137 1138 y = this->MajorStart;1139 numTicks = 0;1140 while (y <= p2[1] && numTicks < VTK_MAX_TICKS)1141 {1142 yPoint1[1] = xPoint[1] = yPoint2[1] = zPoint[1] = y;1143 // yx portion1144 this->GridlinePts->InsertNextPoint(yPoint1);1145 this->GridlinePts->InsertNextPoint(xPoint);1146 // yz portion1147 this->GridlinePts->InsertNextPoint(yPoint2);1148 this->GridlinePts->InsertNextPoint(zPoint);1149 y += this->DeltaMajor;1150 numTicks++;1151 }1152 1153 //1154 // major ticks1155 //1156 if (this->TickLocation == VTK_TICKS_INSIDE)1157 {1158 yPoint1[2] = xPoint[2] = zPoint[2] = p1[2];1159 yPoint2[0] = xPoint[0] = zPoint[0] = p1[0];1160 yPoint1[0] = p1[0] - xMult * this->MajorTickSize;1161 yPoint2[2] = p1[2] - zMult * this->MajorTickSize;1162 }1163 else if (this->TickLocation == VTK_TICKS_OUTSIDE)1164 {1165 yPoint1[0] = yPoint2[0] = zPoint[0] = p1[0];1166 yPoint1[2] = yPoint2[2] = xPoint[2] = p1[2];1167 xPoint[0] = p1[0] + xMult * this->MajorTickSize;1168 zPoint[2] = p1[2] + zMult * this->MajorTickSize;1169 }1170 else // both sides1171 {1172 yPoint1[2] = xPoint[2] = p1[2];1173 yPoint2[0] = zPoint[0] = p1[0];1174 yPoint1[0] = p1[0] - xMult * this->MajorTickSize;1175 yPoint2[2] = p1[2] + zMult * this->MajorTickSize;1176 xPoint[0] = p1[0] + xMult * this->MajorTickSize;1177 zPoint[2] = p1[2] - zMult * this->MajorTickSize;1178 }1179 y = this->MajorStart;1180 numTicks = 0;1181 while (y <= p2[1] && numTicks < VTK_MAX_TICKS)1182 {1183 yPoint1[1] = xPoint[1] = yPoint2[1] = zPoint[1] = y;1184 // yx portion1185 this->MajorTickPts->InsertNextPoint(yPoint1);1186 this->MajorTickPts->InsertNextPoint(xPoint);1187 // yz portion1188 this->MajorTickPts->InsertNextPoint(yPoint2);1189 this->MajorTickPts->InsertNextPoint(zPoint);1190 y += this->DeltaMajor;1191 numTicks++;1192 }1193 return true;1194 }1195 1196 // **************************************************************************1197 // Creates points for ticks (minor, major, gridlines) in correct position1198 // for Z-type axis.1199 //1200 // Programmer: Kathleen Bonnell1201 // Creation: November 7, 20011202 //1203 // Modifications:1204 // Kathleen Bonnell, Mon Dec 3 16:49:01 PST 20011205 // Compare vtkTimeStamps correctly.1206 //1207 // Kathleen Bonnell, Thu May 16 10:13:56 PDT 20021208 // Use defined constant VTK_MAX_TICKS to prevent infinite loops.1209 //1210 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 20031211 // Allow a forced build, despite previous build time.1212 //1213 // **************************************************************************1214 1215 bool vtkRpAxisActor::BuildTickPointsForZType(double p1[3], double p2[3],1216 bool force)1217 {1218 if (!force && (this->AxisPosition == this->LastAxisPosition) &&1219 (this->TickLocation == this->LastTickLocation) &&1220 (this->BoundsTime.GetMTime() < this->BuildTime.GetMTime()))1221 {1222 return false;1223 }1224 1225 this->MinorTickPts->Reset();1226 this->MajorTickPts->Reset();1227 this->GridlinePts->Reset();1228 1229 //1230 // xMult & yMult control adjustments to tick position based1231 // upon "where" this axis is located in relation to the underlying1232 // assumed bounding box.1233 //1234 int xMult = vtkRpAxisActorMultiplierTable1[this->AxisPosition];1235 int yMult = vtkRpAxisActorMultiplierTable2[this->AxisPosition];1236 1237 double zPoint1[3], zPoint2[3], xPoint[3], yPoint[3], z;1238 int numTicks;1239 1240 //1241 // The ordering of the tick endpoints is important because1242 // label position is defined by them.1243 //1244 1245 //1246 // minor ticks1247 //1248 if (this->TickLocation == VTK_TICKS_INSIDE)1249 {1250 zPoint1[0] = p1[0] - xMult * this->MinorTickSize;1251 zPoint2[1] = p1[1] - yMult * this->MinorTickSize;1252 zPoint2[0] = xPoint[0] = yPoint[0] = p1[0];1253 zPoint1[1] = xPoint[1] = yPoint[1] = p1[1];1254 }1255 else if (this->TickLocation == VTK_TICKS_OUTSIDE)1256 {1257 xPoint[0] = p1[0] + xMult * this->MinorTickSize;1258 yPoint[1] = p1[1] +yMult * this->MinorTickSize;1259 zPoint1[0] = zPoint2[0] = yPoint[0] = p1[0];1260 zPoint1[1] = zPoint2[1] = xPoint[1] = p1[1];1261 }1262 else // both sides1263 {1264 zPoint1[0] = p1[0] - xMult * this->MinorTickSize;1265 xPoint[0] = p1[0] + xMult * this->MinorTickSize;1266 zPoint2[1] = p1[1] - yMult * this->MinorTickSize;1267 yPoint[1] = p1[1] + yMult * this->MinorTickSize;1268 zPoint1[1] = xPoint[1] = p1[1];1269 zPoint2[0] = yPoint[0] = p1[0];1270 }1271 z = this->MinorStart;1272 numTicks = 0;1273 while (z < p2[2] && numTicks < VTK_MAX_TICKS)1274 {1275 zPoint1[2] = zPoint2[2] = xPoint[2] = yPoint[2] = z;1276 // zx-portion1277 this->MinorTickPts->InsertNextPoint(zPoint1);1278 this->MinorTickPts->InsertNextPoint(xPoint);1279 // zy-portion1280 this->MinorTickPts->InsertNextPoint(zPoint2);1281 this->MinorTickPts->InsertNextPoint(yPoint);1282 z += this->DeltaMinor;1283 numTicks++;1284 }1285 1286 //1287 // gridlines1288 //1289 zPoint1[0] = p1[0] - xMult * this->GridlineXLength;1290 zPoint2[1] = p1[1] - yMult * this->GridlineYLength;1291 zPoint1[1] = xPoint[1] = yPoint[1] = p1[1];1292 zPoint2[0] = xPoint[0] = yPoint[0] = p1[0];1293 1294 z = this->MajorStart;1295 numTicks = 0;1296 while (z <= p2[2] && numTicks < VTK_MAX_TICKS)1297 {1298 zPoint1[2] = zPoint2[2] = xPoint[2] = yPoint[2] = z;1299 // zx-portion1300 this->GridlinePts->InsertNextPoint(zPoint1);1301 this->GridlinePts->InsertNextPoint(xPoint);1302 // zy-portion1303 this->GridlinePts->InsertNextPoint(zPoint2);1304 this->GridlinePts->InsertNextPoint(yPoint);1305 z += this->DeltaMajor;1306 numTicks++;1307 }1308 1309 //1310 // major ticks1311 //1312 1313 if (this->TickLocation == VTK_TICKS_INSIDE)1314 {1315 zPoint1[0] = p1[0] - xMult * this->MajorTickSize;1316 zPoint2[1] = p1[1] - yMult * this->MajorTickSize;1317 zPoint2[0] = xPoint[0] = yPoint[0] = p1[0];1318 zPoint1[1] = xPoint[1] = yPoint[1] = p1[1];1319 }1320 else if (this->TickLocation == VTK_TICKS_OUTSIDE)1321 {1322 xPoint[0] = p1[0] + xMult * this->MajorTickSize;1323 yPoint[2] = p1[1] + yMult * this->MajorTickSize;1324 zPoint1[0] = zPoint2[0] = yPoint[0] = p1[0];1325 zPoint1[1] = zPoint2[1] = xPoint[1] = p1[1];1326 }1327 else // both sides1328 {1329 zPoint1[0] = p1[0] - xMult * this->MajorTickSize;1330 xPoint[0] = p1[0] + xMult * this->MajorTickSize;1331 zPoint2[1] = p1[1] - yMult * this->MajorTickSize;1332 yPoint[1] = p1[1] + yMult * this->MajorTickSize;1333 zPoint1[1] = xPoint[1] = p1[1];1334 zPoint2[0] = yPoint[0] = p1[0];1335 }1336 z = this->MajorStart;1337 numTicks = 0;1338 while (z <= p2[2] && numTicks < VTK_MAX_TICKS)1339 {1340 zPoint1[2] = zPoint2[2] = xPoint[2] = yPoint[2] = z;1341 // zx-portion1342 this->MajorTickPts->InsertNextPoint(zPoint1);1343 this->MajorTickPts->InsertNextPoint(xPoint);1344 // zy-portion1345 this->MajorTickPts->InsertNextPoint(zPoint2);1346 this->MajorTickPts->InsertNextPoint(yPoint);1347 z += this->DeltaMajor;1348 numTicks++;1349 }1350 return true;1351 }1352 1353 // **************************************************************************1354 1277 // Creates Poly data (lines) from tickmarks (minor/major), gridlines, and axis. 1355 //1356 // Programmer: Kathleen Bonnell1357 // Creation: November 7, 20011358 //1359 // Modifications:1360 // Kathleen Bonnell, Thu Nov 15 13:20:44 PST 20011361 // Make ptIds of type vtkIdType to match VTK 4.0 API.1362 //1363 // Kathleen Bonnell, Thu Jul 18 13:24:03 PDT 20021364 // Allow gridlines to be drawn when enabled, even if ticks are disabled.1365 //1366 // Kathleen Bonnell, Fri Jul 25 15:10:24 PDT 20031367 // Removed arguments.1368 //1369 1278 // ************************************************************************** 1370 1279 void vtkRpAxisActor::SetAxisPointsAndLines() … … 1372 1281 vtkPoints *pts = vtkPoints::New(); 1373 1282 vtkCellArray *lines = vtkCellArray::New(); 1374 this->Axis->SetPoints(pts); 1375 this->Axis->SetLines(lines); 1283 vtkCellArray *gridlines = vtkCellArray::New(); 1284 vtkCellArray *innerGridlines = vtkCellArray::New(); 1285 vtkCellArray *polys = vtkCellArray::New(); 1286 this->AxisLines->SetPoints(pts); 1287 this->AxisLines->SetLines(lines); 1288 this->Gridlines->SetPoints(this->GridlinePts); 1289 this->Gridlines->SetLines(gridlines); 1290 this->InnerGridlines->SetPoints(this->InnerGridlinePts); 1291 this->InnerGridlines->SetLines(innerGridlines); 1292 this->Gridpolys->SetPoints(this->GridpolyPts); 1293 this->Gridpolys->SetPolys(polys); 1376 1294 pts->Delete(); 1377 1295 lines->Delete(); 1378 int i, numPts, numLines; 1296 gridlines->Delete(); 1297 innerGridlines->Delete(); 1298 polys->Delete(); 1299 int i, numMinorTickPts, numGridlines, numInnerGridlines, numMajorTickPts, numGridpolys, numLines; 1379 1300 vtkIdType ptIds[2]; 1301 vtkIdType polyPtIds[4]; 1380 1302 1381 1303 if (this->TickVisibility) … … 1383 1305 if (this->MinorTicksVisible) 1384 1306 { 1385 numPts = this->MinorTickPts->GetNumberOfPoints(); 1386 for (i = 0; i < numPts; i++) 1307 // In 2D mode, the minorTickPts for yz portion or xz portion have been removed. 1308 numMinorTickPts = this->MinorTickPts->GetNumberOfPoints(); 1309 for (i = 0; i < numMinorTickPts; i++) 1387 1310 { 1388 1311 pts->InsertNextPoint(this->MinorTickPts->GetPoint(i)); 1389 1312 } 1390 1313 } 1391 1392 if (this->DrawGridlines) 1393 { 1394 numPts = this->GridlinePts->GetNumberOfPoints(); 1395 for (i = 0; i < numPts; i++) 1396 { 1397 pts->InsertNextPoint(this->GridlinePts->GetPoint(i)); 1398 } 1399 } 1400 else // major tick points 1401 { 1402 numPts = this->MajorTickPts->GetNumberOfPoints(); 1403 for (i = 0; i < numPts; i++) 1314 numMajorTickPts = this->MajorTickPts->GetNumberOfPoints(); 1315 if (this->Use2DMode == 0) 1316 { 1317 for (i = 0; i < numMajorTickPts; i++) 1404 1318 { 1405 1319 pts->InsertNextPoint(this->MajorTickPts->GetPoint(i)); 1406 1320 } 1407 1321 } 1408 } 1409 else if (this->DrawGridlines) // grids are enabled but ticks are off 1410 { 1411 numPts = this->GridlinePts->GetNumberOfPoints(); 1412 for (i = 0; i < numPts; i++) 1413 { 1414 pts->InsertNextPoint(this->GridlinePts->GetPoint(i)); 1322 else 1323 { 1324 // In 2D mode, we don't need the pts for the xz portion or yz portion of the major tickmarks 1325 // majorTickPts not modified because all points are used for labels' positions. 1326 for (i = 0; i < numMajorTickPts; i+=4) 1327 { 1328 pts->InsertNextPoint(this->MajorTickPts->GetPoint(i)); 1329 pts->InsertNextPoint(this->MajorTickPts->GetPoint(i+1)); 1330 } 1415 1331 } 1416 1332 } … … 1433 1349 lines->InsertNextCell(2, ptIds); 1434 1350 } 1351 // create grid lines 1352 if (this->DrawGridlines && this->AxisOnOrigin == 0) 1353 { 1354 numGridlines = this->GridlinePts->GetNumberOfPoints()/2; 1355 int start = 1356 (this->DrawGridlinesLocation == 0 || this->DrawGridlinesLocation == 1) 1357 ? 0 : 1; 1358 int increment = (this->DrawGridlinesLocation == 0) ? 1 : 2; 1359 for (i = start; i < numGridlines; i+=increment) 1360 { 1361 ptIds[0] = 2*i; 1362 ptIds[1] = 2*i + 1; 1363 gridlines->InsertNextCell(2, ptIds); 1364 } 1365 } 1366 1367 // create inner grid lines 1368 if (this->DrawInnerGridlines && this->AxisOnOrigin == 0) 1369 { 1370 numInnerGridlines = this->InnerGridlinePts->GetNumberOfPoints()/2; 1371 for (i=0; i < numInnerGridlines; i++) 1372 { 1373 ptIds[0] = 2*i; 1374 ptIds[1] = 2*i + 1; 1375 innerGridlines->InsertNextCell(2, ptIds); 1376 } 1377 } 1378 1379 // create polys (grid polys) 1380 if (this->DrawGridpolys && this->AxisOnOrigin == 0) 1381 { 1382 numGridpolys = this->GridpolyPts->GetNumberOfPoints()/4; 1383 for (i = 0; i < numGridpolys; i++) 1384 { 1385 polyPtIds[0] = 4*i; 1386 polyPtIds[1] = 4*i + 1; 1387 polyPtIds[2] = 4*i + 2; 1388 polyPtIds[3] = 4*i + 3; 1389 polys->InsertNextCell(4,polyPtIds); 1390 } 1391 } 1435 1392 } 1436 1393 1437 1394 // ********************************************************************* 1438 1395 // Returns true if any tick vis attribute has changed since last check. 1439 //1440 // Programmer: Kathleen Bonnell1441 // Creation: November 7, 20011442 1396 // ********************************************************************* 1443 1397 bool vtkRpAxisActor::TickVisibilityChanged() … … 1456 1410 // ********************************************************************* 1457 1411 // Set the bounds for this actor to use. Sets timestamp BoundsModified. 1458 //1459 // Programmer: Kathleen Bonnell1460 // Creation: November 7, 20011461 1412 // ********************************************************************* 1462 1413 void … … 1480 1431 // ********************************************************************* 1481 1432 // Retrieves the bounds of this actor. 1482 // Set the bounds for this actor to use. Sets timestamp BoundsModified.1483 //1484 // Programmer: Will Schroeder1485 // Creation: December 8, 20101486 1433 // ********************************************************************* 1487 1434 void vtkRpAxisActor:: … … 1508 1455 // ********************************************************************* 1509 1456 // Retrieves the bounds of this actor. 1510 //1511 // Programmer: Kathleen Bonnell1512 // Creation: November 7, 20011513 1457 // ********************************************************************* 1514 1458 double* vtkRpAxisActor::GetBounds() … … 1519 1463 // ********************************************************************* 1520 1464 // Retrieves the bounds of this actor. 1521 //1522 // Programmer: Kathleen Bonnell1523 // Creation: November 7, 20011524 1465 // ********************************************************************* 1525 1466 … … 1534 1475 // ********************************************************************* 1535 1476 // Method: vtkRpAxisActor::ComputeMaxLabelLength 1536 //1537 // Purpose: Determines the maximum length that a label will occupy1538 // if placed at point 'center' and with a scale of 1.1539 //1540 // Arguments:1541 // center The position to use for the label actor1542 //1543 // Returns:1544 // the maximum length of all the labels, 0 if there are no labels.1545 //1546 // Programmer: Kathleen Bonnell1547 // Creation: July 18, 20031548 //1549 // Modifications:1550 // Kathleen Bonnell, Tue Dec 16 11:06:21 PST 20031551 // Reset the actor's position and scale.1552 //1553 // Modifications:1554 // David Gobbi, Fri Apr 8 16:50:00 MST 20111555 // Use mapper bounds, not actor bounds, so centering is not necessary.1556 //1557 1477 // ********************************************************************* 1558 1559 1478 double vtkRpAxisActor::ComputeMaxLabelLength(const double vtkNotUsed(center)[3]) 1560 1479 { 1561 double length, maxLength = 0.;1562 1480 double bounds[6]; 1563 1481 double xsize, ysize; 1482 vtkProperty *newProp = this->NewLabelProperty(); 1483 double maxXSize = 0; 1484 double maxYSize = 0; 1564 1485 for (int i = 0; i < this->NumberOfLabelsBuilt; i++) 1565 1486 { 1566 1487 this->LabelActors[i]->SetCamera(this->Camera); 1567 this->LabelActors[i]->SetProperty( this->GetProperty());1488 this->LabelActors[i]->SetProperty(newProp); 1568 1489 this->LabelActors[i]->GetMapper()->GetBounds(bounds); 1490 this->LabelActors[i]->GetProperty()->SetColor(this->LabelTextProperty->GetColor()); 1569 1491 xsize = bounds[1] - bounds[0]; 1570 1492 ysize = bounds[3] - bounds[2]; 1571 length = sqrt(xsize*xsize + ysize*ysize); 1572 maxLength = (length > maxLength ? length : maxLength); 1573 } 1574 return maxLength; 1493 maxXSize = (xsize > maxXSize ? xsize : maxXSize); 1494 maxYSize = (ysize > maxYSize ? ysize : maxYSize); 1495 } 1496 newProp->Delete(); 1497 return sqrt(maxXSize*maxXSize + maxYSize*maxYSize); 1575 1498 } 1576 1499 1577 1500 // ********************************************************************* 1578 1501 // Method: vtkRpAxisActor::ComputeTitleLength 1579 //1580 // Purpose: Determines the length that the title will occupy1581 // if placed at point 'center' and with a scale of 1.1582 //1583 // Arguments:1584 // center The position to use for the title actor1585 //1586 // Returns:1587 // the length of all the title,1588 //1589 // Programmer: Kathleen Bonnell1590 // Creation: July 25, 20031591 //1592 // Modifications:1593 // Kathleen Bonnell, Tue Dec 16 11:06:21 PST 20031594 // Reset the actor's position and scale.1595 //1596 // Modifications:1597 // David Gobbi, Fri Apr 8 16:50:00 MST 20111598 // Use mapper bounds, not actor bounds, so centering is not necessary.1599 //1600 1502 // ********************************************************************* 1601 1602 1503 double vtkRpAxisActor::ComputeTitleLength(const double vtkNotUsed(center)[3]) 1603 1504 { … … 1608 1509 this->TitleVector->SetText(this->Title); 1609 1510 this->TitleActor->SetCamera(this->Camera); 1610 this->TitleActor->SetProperty(this->GetProperty()); 1511 vtkProperty * newProp = this->NewTitleProperty(); 1512 this->TitleActor->SetProperty(newProp); 1513 newProp->Delete(); 1611 1514 this->TitleActor->GetMapper()->GetBounds(bounds); 1515 this->TitleActor->GetProperty()->SetColor(this->TitleTextProperty->GetColor()); 1612 1516 xsize = bounds[1] - bounds[0]; 1613 1517 ysize = bounds[3] - bounds[2]; 1614 1518 length = sqrt(xsize*xsize + ysize*ysize); 1519 1615 1520 return length; 1616 1521 } 1617 1522 1618 1523 // ********************************************************************* 1619 // Method: vtkRpAxisActor::SetLabelScale 1620 // 1621 // Purpose: Sets the scaling factor for label actors. 1622 // 1623 // Arguments: 1624 // s The scale factor to use. 1625 // 1626 // Programmer: Kathleen Bonnell 1627 // Creation: July 18, 2003 1628 // 1524 void vtkRpAxisActor::SetLabelScale(const double s) 1525 { 1526 for (int i=0; i < this->NumberOfLabelsBuilt; i++) 1527 { 1528 this->LabelActors[i]->SetScale(s); 1529 } 1530 } 1531 1629 1532 // ********************************************************************* 1630 1631 void vtkRpAxisActor::SetLabelScale(const double s) 1632 { 1633 for (int i=0; i < this->NumberOfLabelsBuilt; i++) 1634 { 1635 this->LabelActors[i]->SetScale(s); 1636 } 1533 void vtkRpAxisActor::SetTitleScale(const double s) 1534 { 1535 this->TitleActor->SetScale(s); 1637 1536 } 1638 1537 1639 1538 // ********************************************************************* 1640 // Method: vtkRpAxisActor::SetTitleScale1641 //1642 // Purpose: Sets the scaling factor for the title actor.1643 //1644 // Arguments:1645 // s The scale factor to use.1646 //1647 // Programmer: Kathleen Bonnell1648 // Creation: July 18, 20031649 //1650 // *********************************************************************1651 1652 void vtkRpAxisActor::SetTitleScale(const double s)1653 {1654 this->TitleActor->SetScale(s);1655 }1656 1657 // *********************************************************************1658 // Method: vtkRpAxisActor::SetTitle1659 //1660 // Purpose: Sets the text for the title.1661 //1662 // Notes: Not using vtkSetStringMacro so that the modification time of1663 // the text can be kept (so the title will be updated as1664 // appropriate when the text changes.)1665 //1666 // Arguments:1667 // t The text to use.1668 //1669 // Programmer: Kathleen Bonnell1670 // Creation: August 31, 20041671 //1672 // *********************************************************************1673 1674 1539 void vtkRpAxisActor::SetTitle(const char *t) 1675 1540 { … … 1699 1564 } 1700 1565 1566 // **************************************************************************** 1567 void vtkRpAxisActor::SetAxisLinesProperty(vtkProperty *prop) 1568 { 1569 this->AxisLinesActor->SetProperty(prop); 1570 this->Modified(); 1571 } 1572 1573 // **************************************************************************** 1574 vtkProperty* vtkRpAxisActor::GetAxisLinesProperty() 1575 { 1576 return this->AxisLinesActor->GetProperty(); 1577 } 1578 1579 // **************************************************************************** 1580 void vtkRpAxisActor::SetGridlinesProperty(vtkProperty *prop) 1581 { 1582 this->GridlinesActor->SetProperty(prop); 1583 this->Modified(); 1584 } 1585 1586 // **************************************************************************** 1587 vtkProperty* vtkRpAxisActor::GetGridlinesProperty() 1588 { 1589 return this->GridlinesActor->GetProperty(); 1590 } 1591 1592 // **************************************************************************** 1593 void vtkRpAxisActor::SetInnerGridlinesProperty(vtkProperty *prop) 1594 { 1595 this->InnerGridlinesActor->SetProperty(prop); 1596 this->Modified(); 1597 } 1598 1599 // **************************************************************************** 1600 vtkProperty* vtkRpAxisActor::GetInnerGridlinesProperty() 1601 { 1602 return this->InnerGridlinesActor->GetProperty(); 1603 } 1604 1605 // **************************************************************************** 1606 void vtkRpAxisActor::SetGridpolysProperty(vtkProperty *prop) 1607 { 1608 this->GridpolysActor->SetProperty(prop); 1609 this->Modified(); 1610 } 1611 1612 // **************************************************************************** 1613 vtkProperty* vtkRpAxisActor::GetGridpolysProperty() 1614 { 1615 return this->GridpolysActor->GetProperty(); 1616 } 1617 1618 // **************************************************************************** 1619 vtkProperty* vtkRpAxisActor::NewTitleProperty() 1620 { 1621 vtkProperty *newProp = vtkProperty::New(); 1622 newProp->DeepCopy(this->GetProperty()); 1623 newProp->SetColor(this->TitleTextProperty->GetColor()); 1624 // We pass the opacity in the line offset. 1625 //newProp->SetOpacity(this->TitleTextProperty->GetLineOffset()); 1626 return newProp; 1627 } 1628 1629 // **************************************************************************** 1630 vtkProperty* vtkRpAxisActor::NewLabelProperty() 1631 { 1632 vtkProperty *newProp = vtkProperty::New(); 1633 newProp->DeepCopy(this->GetProperty()); 1634 newProp->SetColor(this->LabelTextProperty->GetColor()); 1635 // We pass the opacity in the line offset. 1636 //newProp->SetOpacity(this->LabelTextProperty->GetLineOffset()); 1637 return newProp; 1638 } 1639 1640 1641 // **************************************************************************** 1642 double vtkRpAxisActor::GetDeltaMajor(int axis){ 1643 if(axis>=0 && axis<=2) 1644 { 1645 return (this->DeltaMajor[axis]); 1646 } 1647 return 0; 1648 } 1649 1650 void vtkRpAxisActor::SetDeltaMajor(int axis, double value){ 1651 if(axis>=0 && axis<=2) 1652 { 1653 this->DeltaMajor[axis] = value; 1654 } 1655 } 1656 1657 // **************************************************************************** 1658 double vtkRpAxisActor::GetMajorStart(int axis){ 1659 if(axis>=0 && axis<=2) 1660 { 1661 return (this->MajorStart[axis]); 1662 } 1663 return 0; 1664 } 1665 1666 // **************************************************************************** 1667 void vtkRpAxisActor::SetMajorStart(int axis, double value){ 1668 if(axis>=0 && axis<=2) 1669 { 1670 this->MajorStart[axis] = value; 1671 } 1672 } 1673 1674 // **************************************************************************** 1675 bool vtkRpAxisActor::BoundsDisplayCoordinateChanged(vtkViewport *viewport) 1676 { 1677 double transMinPt[3], transMaxPt[3]; 1678 viewport->SetWorldPoint(this->Bounds[0], this->Bounds[2], this->Bounds[4], 1.0); 1679 viewport->WorldToDisplay(); 1680 viewport->GetDisplayPoint(transMinPt); 1681 viewport->SetWorldPoint(this->Bounds[1], this->Bounds[3], this->Bounds[5], 1.0); 1682 viewport->WorldToDisplay(); 1683 viewport->GetDisplayPoint(transMaxPt); 1684 1685 if( this->LastMinDisplayCoordinate[0] != transMinPt[0] 1686 || this->LastMinDisplayCoordinate[1] != transMinPt[1] 1687 || this->LastMinDisplayCoordinate[2] != transMinPt[2] 1688 || this->LastMaxDisplayCoordinate[0] != transMaxPt[0] 1689 || this->LastMaxDisplayCoordinate[1] != transMaxPt[1] 1690 || this->LastMaxDisplayCoordinate[2] != transMaxPt[2] ) 1691 { 1692 int i = 0; 1693 for( i=0 ; i<3 ; ++i ) 1694 { 1695 this->LastMinDisplayCoordinate[i] = transMinPt[i]; 1696 this->LastMaxDisplayCoordinate[i] = transMaxPt[i]; 1697 } 1698 return true; 1699 } 1700 1701 return false; 1702 } 1701 1703 //--------------------------------------------------------------------------- 1702 1704 // endpoint-related methods … … 1709 1711 } 1710 1712 1713 //--------------------------------------------------------------------------- 1711 1714 vtkCoordinate* vtkRpAxisActor::GetPoint2Coordinate() 1712 1715 { … … 1717 1720 } 1718 1721 1722 //--------------------------------------------------------------------------- 1719 1723 void vtkRpAxisActor::SetPoint1(double x, double y, double z) 1720 1724 { … … 1722 1726 } 1723 1727 1728 //--------------------------------------------------------------------------- 1724 1729 void vtkRpAxisActor::SetPoint2(double x, double y, double z) 1725 1730 { … … 1727 1732 } 1728 1733 1734 //--------------------------------------------------------------------------- 1729 1735 double* vtkRpAxisActor::GetPoint1() 1730 1736 { … … 1732 1738 } 1733 1739 1740 //--------------------------------------------------------------------------- 1734 1741 double* vtkRpAxisActor::GetPoint2() 1735 1742 { 1736 1743 return this->Point2Coordinate->GetValue(); 1737 1744 } 1745 // ************************************************************************** 1746 // Creates points for ticks (minor, major, gridlines) in correct position 1747 // for a generic axis. 1748 // ************************************************************************** 1749 bool vtkRpAxisActor::BuildTickPoints(double p1[3], double p2[3], bool force) 1750 { 1751 // Prevent any unwanted computation 1752 if (!force && (this->AxisPosition == this->LastAxisPosition) && 1753 (this->TickLocation == this->LastTickLocation ) && 1754 (this->BoundsTime.GetMTime() < this->BuildTime.GetMTime()) && 1755 (this->Point1Coordinate->GetMTime() < this->BuildTickPointsTime.GetMTime()) && 1756 (this->Point2Coordinate->GetMTime() < this->BuildTickPointsTime.GetMTime()) && 1757 (this->Range[0] == this->LastRange[0]) && 1758 (this->Range[1] == this->LastRange[1])) 1759 { 1760 return false; 1761 } 1762 1763 // Local tmp vars 1764 double uPointInside[3], vPointInside[3], uPointOutside[3], vPointOutside[3]; 1765 double gridPointClosest[3], gridPointFarest[3], gridPointU[3], gridPointV[3]; 1766 double innerGridPointClosestU[3], innerGridPointClosestV[3]; 1767 double innerGridPointFarestU[3], innerGridPointFarestV[3]; 1768 double deltaVector[3]; 1769 double axisLength, axisShift, rangeScale, nbIterationAsDouble; 1770 int nbTicks, i, nbIteration, uIndex, vIndex; 1771 uIndex = vIndex = 0; 1772 bool hasOrthogonalVectorBase = 1773 (this->AxisBaseForX[0] == 1 && this->AxisBaseForX[1] == 0 && this->AxisBaseForX[2] == 0 1774 && this->AxisBaseForY[0] == 0 && this->AxisBaseForY[1] == 1 && this->AxisBaseForY[2] == 0 1775 && this->AxisBaseForZ[0] == 0 && this->AxisBaseForZ[1] == 0 && this->AxisBaseForZ[2] == 1); 1776 1777 // Reset previous objects 1778 this->MinorTickPts->Reset(); 1779 this->MajorTickPts->Reset(); 1780 this->GridlinePts->Reset(); 1781 this->InnerGridlinePts->Reset(); 1782 this->GridpolyPts->Reset(); 1783 1784 // As we assume that the Axis is not necessery alined to the absolute X/Y/Z 1785 // axis, we will convert the absolut XYZ information to relative one 1786 // using a base composed as follow (axis, u, v) 1787 double uGridLength, vGridLength; 1788 uGridLength = vGridLength = 0; 1789 double *axisVector, *uVector, *vVector; 1790 axisVector = uVector = vVector = NULL; 1791 int uMult = vtkRpAxisActorMultiplierTable1[this->AxisPosition]; 1792 int vMult = vtkRpAxisActorMultiplierTable2[this->AxisPosition]; 1793 1794 switch(this->AxisType) 1795 { 1796 case VTK_AXIS_TYPE_X: 1797 uGridLength = this->GridlineYLength; 1798 vGridLength = this->GridlineZLength; 1799 axisVector = this->AxisBaseForX; 1800 uVector = this->AxisBaseForY; 1801 vVector = this->AxisBaseForZ; 1802 uIndex = 1; vIndex = 2; 1803 break; 1804 case VTK_AXIS_TYPE_Y: 1805 uGridLength = this->GridlineXLength; 1806 vGridLength = this->GridlineZLength; 1807 uVector = this->AxisBaseForX; 1808 axisVector = this->AxisBaseForY; 1809 vVector = this->AxisBaseForZ; 1810 uIndex = 0; vIndex = 2; 1811 break; 1812 case VTK_AXIS_TYPE_Z: 1813 uGridLength = this->GridlineXLength; 1814 vGridLength = this->GridlineYLength; 1815 uVector = this->AxisBaseForX; 1816 vVector = this->AxisBaseForY; 1817 axisVector = this->AxisBaseForZ; 1818 uIndex = 0; vIndex = 1; 1819 break; 1820 } 1821 1822 // ************************************************************************** 1823 // Build Minor Ticks 1824 // ************************************************************************** 1825 { 1826 // - Initialize all points to be on the axis 1827 for(i=0;i<3;i++) 1828 { 1829 uPointInside[i] = vPointInside[i] = uPointOutside[i] = vPointOutside[i] = p1[i]; 1830 deltaVector[i] = (p2[i] - p1[i]); 1831 } 1832 axisLength = vtkMath::Norm(deltaVector); 1833 rangeScale = axisLength/(this->Range[1] - this->Range[0]); 1834 1835 // - Reduce the deltaVector to correspond to a tick step 1836 vtkMath::Normalize(deltaVector); 1837 for(i=0;i<3;i++) 1838 { 1839 deltaVector[i] *= this->DeltaMinor; 1840 } 1841 1842 // - Move outside points if needed (Axis -> Outside) 1843 if (this->TickLocation == VTK_TICKS_OUTSIDE || this->TickLocation == VTK_TICKS_BOTH) 1844 { 1845 for(i=0;i<3;i++) 1846 { 1847 uPointOutside[i] += uVector[i] * uMult * this->MinorTickSize; 1848 vPointOutside[i] += vVector[i] * vMult * this->MinorTickSize; 1849 } 1850 } 1851 1852 // - Move inside points if needed (Axis -> Inside) 1853 if (this->TickLocation == VTK_TICKS_INSIDE || this->TickLocation == VTK_TICKS_BOTH) 1854 { 1855 for(i=0;i<3;i++) 1856 { 1857 uPointInside[i] -= uVector[i] * uMult * this->MinorTickSize; 1858 vPointInside[i] -= vVector[i] * vMult * this->MinorTickSize; 1859 } 1860 } 1861 1862 // - Add the initial shift if any 1863 axisShift = (this->MinorRangeStart - this->Range[0])*rangeScale; 1864 for(i=0;i<3;i++) 1865 { 1866 uPointInside[i] += axisVector[i] * axisShift; 1867 vPointInside[i] += axisVector[i] * axisShift; 1868 uPointOutside[i] += axisVector[i] * axisShift; 1869 vPointOutside[i] += axisVector[i] * axisShift; 1870 } 1871 1872 // - Insert tick points along the axis using the deltaVector 1873 nbIterationAsDouble = axisLength / vtkMath::Norm(deltaVector); 1874 nbIteration = vtkMath::Floor(nbIterationAsDouble+2*DBL_EPSILON); 1875 nbIteration = (nbIteration < VTK_MAX_TICKS) ? nbIteration : VTK_MAX_TICKS; 1876 for (nbTicks = 0; nbTicks < nbIteration; nbTicks++) 1877 { 1878 // axis/u side 1879 this->MinorTickPts->InsertNextPoint(uPointInside); 1880 this->MinorTickPts->InsertNextPoint(uPointOutside); 1881 vtkMath::Add(deltaVector, uPointInside, uPointInside); 1882 vtkMath::Add(deltaVector, uPointOutside, uPointOutside); 1883 if( this->Use2DMode == 0 ) 1884 { 1885 // axis/v side 1886 this->MinorTickPts->InsertNextPoint(vPointInside); 1887 this->MinorTickPts->InsertNextPoint(vPointOutside); 1888 vtkMath::Add(deltaVector, vPointInside, vPointInside); 1889 vtkMath::Add(deltaVector, vPointOutside, vPointOutside); 1890 } 1891 } 1892 } 1893 // ************************************************************************** 1894 // Build Gridline + GridPoly points + InnerGrid (Only for Orthonormal base) 1895 // ************************************************************************** 1896 { 1897 // - Initialize all points to be on the axis 1898 for(i=0;i<3;i++) 1899 { 1900 gridPointClosest[i] = gridPointFarest[i] = gridPointU[i] = gridPointV[i] = p1[i]; 1901 deltaVector[i] = (p2[i] - p1[i]); 1902 } 1903 1904 // - Reduce the deltaVector to correspond to a major tick step 1905 vtkMath::Normalize(deltaVector); 1906 for(i=0;i<3;i++) 1907 { 1908 deltaVector[i] *= this->DeltaMajor[this->AxisType]; 1909 } 1910 1911 // - Move base points 1912 for(i=0;i<3;i++) 1913 { 1914 gridPointU[i] -= uVector[i] * uMult * uGridLength; 1915 gridPointV[i] -= vVector[i] * vMult * vGridLength; 1916 gridPointFarest[i] -= uVector[i] * uMult * uGridLength + vVector[i] * vMult * vGridLength; 1917 } 1918 1919 // - Add the initial shift if any 1920 axisShift = (this->MajorRangeStart - this->Range[0])*rangeScale; 1921 for(i=0;i<3;i++) 1922 { 1923 gridPointU[i] += axisVector[i] * axisShift; 1924 gridPointV[i] += axisVector[i] * axisShift; 1925 gridPointFarest[i] += axisVector[i] * axisShift; 1926 gridPointClosest[i] += axisVector[i] * axisShift; 1927 } 1928 1929 // - Insert Gridlines points along the axis using the DeltaMajor vector 1930 nbIterationAsDouble = (axisLength - axisShift) / vtkMath::Norm(deltaVector); 1931 nbIteration = vtkMath::Floor(nbIterationAsDouble+2*FLT_EPSILON) + 1; 1932 nbIteration = (nbIteration < VTK_MAX_TICKS) ? nbIteration : VTK_MAX_TICKS; 1933 for (nbTicks = 0; nbTicks < nbIteration; nbTicks++) 1934 { 1935 // Closest U 1936 this->GridlinePts->InsertNextPoint(gridPointClosest); 1937 this->GridlinePts->InsertNextPoint(gridPointU); 1938 1939 // Farest U 1940 this->GridlinePts->InsertNextPoint(gridPointFarest); 1941 this->GridlinePts->InsertNextPoint(gridPointU); 1942 1943 // Closest V 1944 this->GridlinePts->InsertNextPoint(gridPointClosest); 1945 this->GridlinePts->InsertNextPoint(gridPointV); 1946 1947 // Farest V 1948 this->GridlinePts->InsertNextPoint(gridPointFarest); 1949 this->GridlinePts->InsertNextPoint(gridPointV); 1950 1951 // PolyPoints 1952 this->GridpolyPts->InsertNextPoint(gridPointClosest); 1953 this->GridpolyPts->InsertNextPoint(gridPointU); 1954 this->GridpolyPts->InsertNextPoint(gridPointFarest); 1955 this->GridpolyPts->InsertNextPoint(gridPointV); 1956 1957 // Move forward along the axis 1958 for(i=0;i<3;i++) 1959 { 1960 gridPointClosest[i] += deltaVector[i]; 1961 gridPointU[i] += deltaVector[i]; 1962 gridPointFarest[i] += deltaVector[i]; 1963 gridPointV[i] += deltaVector[i]; 1964 } 1965 } 1966 1967 // - Insert InnerGridLines points 1968 1969 // We can only handle inner grid line with orthonormal base, otherwise 1970 // we would need to change the API of AxisActor which we don't want for 1971 // backward compatibility. 1972 if(hasOrthogonalVectorBase) 1973 { 1974 double axis, u, v; 1975 axis = this->MajorStart[this->AxisType]; 1976 innerGridPointClosestU[vIndex] = this->GetBounds()[vIndex*2]; 1977 innerGridPointFarestU[vIndex] = this->GetBounds()[vIndex*2+1]; 1978 innerGridPointClosestV[uIndex] = this->GetBounds()[uIndex*2]; 1979 innerGridPointFarestV[uIndex] = this->GetBounds()[uIndex*2+1]; 1980 while (axis <= p2[this->AxisType]) 1981 { 1982 innerGridPointClosestU[this->AxisType] 1983 = innerGridPointClosestV[this->AxisType] 1984 = innerGridPointFarestU[this->AxisType] 1985 = innerGridPointFarestV[this->AxisType] 1986 = axis; 1987 1988 // u lines 1989 u = this->MajorStart[uIndex]; 1990 while (u <= p2[uIndex] && this->DeltaMajor[uIndex] > 0) 1991 { 1992 innerGridPointClosestU[uIndex] 1993 = innerGridPointFarestU[uIndex] 1994 = u; 1995 this->InnerGridlinePts->InsertNextPoint(innerGridPointClosestU); 1996 this->InnerGridlinePts->InsertNextPoint(innerGridPointFarestU); 1997 u += this->DeltaMajor[uIndex]; 1998 } 1999 2000 // v lines 2001 v = this->MajorStart[vIndex]; 2002 while (v <= p2[vIndex] && this->DeltaMajor[vIndex] > 0) 2003 { 2004 innerGridPointClosestV[vIndex] 2005 = innerGridPointFarestV[vIndex] 2006 = v; 2007 this->InnerGridlinePts->InsertNextPoint(innerGridPointClosestV); 2008 this->InnerGridlinePts->InsertNextPoint(innerGridPointFarestV); 2009 v += this->DeltaMajor[vIndex]; 2010 } 2011 2012 axis += this->DeltaMajor[this->AxisType]; 2013 } 2014 } 2015 } 2016 // ************************************************************************** 2017 // Build Major ticks 2018 // ************************************************************************** 2019 { 2020 // Delta vector is already initialized with the Major tick scale 2021 // - Initialize all points to be on the axis 2022 for(i=0;i<3;i++) 2023 { 2024 uPointInside[i] = vPointInside[i] = uPointOutside[i] = vPointOutside[i] = p1[i]; 2025 } 2026 2027 // - Move outside points if needed (Axis -> Outside) 2028 if (this->TickLocation == VTK_TICKS_OUTSIDE || this->TickLocation == VTK_TICKS_BOTH) 2029 { 2030 for(i=0;i<3;i++) 2031 { 2032 uPointOutside[i] += uVector[i] * uMult * this->MajorTickSize; 2033 vPointOutside[i] += vVector[i] * vMult * this->MajorTickSize; 2034 } 2035 } 2036 2037 // - Move inside points if needed (Axis -> Inside) 2038 if (this->TickLocation == VTK_TICKS_INSIDE || this->TickLocation == VTK_TICKS_BOTH) 2039 { 2040 for(i=0;i<3;i++) 2041 { 2042 uPointInside[i] -= uVector[i] * uMult * this->MajorTickSize; 2043 vPointInside[i] -= vVector[i] * vMult * this->MajorTickSize; 2044 } 2045 } 2046 2047 // - Add the initial shift if any 2048 for(i=0;i<3;i++) 2049 { 2050 uPointInside[i] += axisVector[i] * axisShift; 2051 vPointInside[i] += axisVector[i] * axisShift; 2052 uPointOutside[i] += axisVector[i] * axisShift; 2053 vPointOutside[i] += axisVector[i] * axisShift; 2054 } 2055 2056 // - Insert tick points along the axis using the deltaVector 2057 for (nbTicks = 0; nbTicks < nbIteration; nbTicks++) 2058 { 2059 // axis/u side 2060 this->MajorTickPts->InsertNextPoint(uPointInside); 2061 this->MajorTickPts->InsertNextPoint(uPointOutside); 2062 vtkMath::Add(deltaVector, uPointInside, uPointInside); 2063 vtkMath::Add(deltaVector, uPointOutside, uPointOutside); 2064 2065 // axis/v side 2066 this->MajorTickPts->InsertNextPoint(vPointInside); 2067 this->MajorTickPts->InsertNextPoint(vPointOutside); 2068 vtkMath::Add(deltaVector, vPointInside, vPointInside); 2069 vtkMath::Add(deltaVector, vPointOutside, vPointOutside); 2070 } 2071 } 2072 2073 this->BuildTickPointsTime.Modified(); 2074 this->LastTickLocation = this->TickLocation; 2075 return true; 2076 } -
trunk/packages/vizservers/vtkvis/vtkRpAxisActor.h
r2864 r3479 1 1 /*========================================================================= 2 2 3 4 5 6 7 8 3 Program: Visualization Toolkit 4 Module: vtkRpAxisActor.h 5 Language: C++ 6 Date: $Date$ 7 Version: $Revision$ 8 Thanks: Kathleen Bonnell, B Division, Lawrence Livermore Nat'l Laboratory 9 9 10 10 Copyright (c) 1993-2000 Ken Martin, Will Schroeder, Bill Lorensen 11 11 All rights reserved. 12 13 14 12 This software is distributed WITHOUT ANY WARRANTY; without even 13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 PURPOSE. See the above copyright notice for more information. 15 15 =========================================================================*/ 16 16 // .NAME vtkRpAxisActor - Create an axis with tick marks and labels … … 37 37 // All calculations and references are in World Coordinates. 38 38 // 39 // .SECTION Notes 40 // This class was adapted from a 2D version created by Hank Childs called 41 // vtkHankAxisActor2D. 39 // .SECTION Thanks 40 // This class was written by: 41 // Hank Childs, Kathleen Bonnell, Amy Squillacote, Brad Whitlock, 42 // Eric Brugger, Claire Guilbaud, Nicolas Dolegieviez, Will Schroeder, 43 // Karthik Krishnan, Aashish Chaudhary, Philippe Pebay, David Gobbi, 44 // David Partyka, Utkarsh Ayachit David Cole, Francois Bertel, and Mark Olesen 45 // Part of this work was supported by CEA/DIF - Commissariat a l'Energie Atomique, 46 // Centre DAM Ile-De-France, BP12, F-91297 Arpajon, France. 42 47 // 43 48 // .SECTION See Also … … 47 52 #define __vtkRpAxisActor_h 48 53 54 #include "vtkRenderingAnnotationModule.h" // For export macro 49 55 #include "vtkActor.h" 50 56 … … 65 71 #define VTK_AXIS_POS_MAXMIN 3 66 72 67 // **************************************************************************** 68 // Modifications: 69 // Kathleen Bonnell, Tue Aug 31 16:17:43 PDT 2004 70 // Added TitleTextTime timestamp, so that title can be updated appropriately 71 // when its text changes. Changed Titles Set macro for a user-defined 72 // set so TitleTextTime can be updated. 73 // 74 // **************************************************************************** 75 73 class vtkRpAxisFollower; 76 74 class vtkCamera; 77 75 class vtkCoordinate; … … 80 78 class vtkPolyData; 81 79 class vtkPolyDataMapper; 80 class vtkProperty2D; 82 81 class vtkStringArray; 82 class vtkTextActor; 83 class vtkTextProperty; 83 84 class vtkVectorText; 84 85 85 class VTK _HYBRID_EXPORT vtkRpAxisActor : public vtkActor86 class VTKRENDERINGANNOTATION_EXPORT vtkRpAxisActor : public vtkActor 86 87 { 87 public:88 public: 88 89 vtkTypeMacro(vtkRpAxisActor,vtkActor); 89 90 void PrintSelf(ostream& os, vtkIndent indent); … … 97 98 virtual vtkCoordinate *GetPoint1Coordinate(); 98 99 virtual void SetPoint1(double x[3]) 99 100 { this->SetPoint1(x[0], x[1], x[2]); } 100 101 virtual void SetPoint1(double x, double y, double z); 101 102 virtual double *GetPoint1(); … … 105 106 virtual vtkCoordinate *GetPoint2Coordinate(); 106 107 virtual void SetPoint2(double x[3]) 107 108 { this->SetPoint2(x[0], x[1], x[2]); } 108 109 virtual void SetPoint2(double x, double y, double z); 109 110 virtual double *GetPoint2(); … … 155 156 156 157 void SetTickLocationToInside(void) 157 158 { this->SetTickLocation(VTK_TICKS_INSIDE); }; 158 159 void SetTickLocationToOutside(void) 159 160 { this->SetTickLocation(VTK_TICKS_OUTSIDE); }; 160 161 void SetTickLocationToBoth(void) 161 162 { this->SetTickLocation(VTK_TICKS_BOTH); }; 162 163 163 164 // Description: … … 186 187 187 188 // Description: 189 // Set/Get the axis title text property. 190 virtual void SetTitleTextProperty(vtkTextProperty *p); 191 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); 192 193 // Description: 194 // Set/Get the axis labels text property. 195 virtual void SetLabelTextProperty(vtkTextProperty *p); 196 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); 197 198 // Description: 199 // Get/Set axis actor property (axis and its ticks) 200 void SetAxisLinesProperty(vtkProperty *); 201 vtkProperty* GetAxisLinesProperty(); 202 203 // Description: 204 // Get/Set gridlines actor property (outer grid lines) 205 void SetGridlinesProperty(vtkProperty *); 206 vtkProperty* GetGridlinesProperty(); 207 208 // Description: 209 // Get/Set inner gridlines actor property 210 void SetInnerGridlinesProperty(vtkProperty *); 211 vtkProperty* GetInnerGridlinesProperty(); 212 213 // Description: 214 // Get/Set gridPolys actor property (grid quads) 215 void SetGridpolysProperty(vtkProperty *); 216 vtkProperty* GetGridpolysProperty(); 217 218 // Description: 188 219 // Set/Get whether gridlines should be drawn. 189 220 vtkSetMacro(DrawGridlines, int); 190 221 vtkGetMacro(DrawGridlines, int); 191 222 vtkBooleanMacro(DrawGridlines, int); 223 224 // Description: 225 // Set/Get whether ONLY the gridlines should be drawn. 226 // This will only draw GridLines and will skip any other part of the rendering 227 // such as Axis/Tick/Title/... 228 vtkSetMacro(DrawGridlinesOnly, int); 229 vtkGetMacro(DrawGridlinesOnly, int); 230 vtkBooleanMacro(DrawGridlinesOnly, int); 231 232 vtkSetMacro(DrawGridlinesLocation, int); 233 vtkGetMacro(DrawGridlinesLocation, int); 234 235 // Description: 236 // Set/Get whether inner gridlines should be drawn. 237 vtkSetMacro(DrawInnerGridlines, int); 238 vtkGetMacro(DrawInnerGridlines, int); 239 vtkBooleanMacro(DrawInnerGridlines, int); 192 240 193 241 // Description: … … 199 247 vtkSetMacro(GridlineZLength, double); 200 248 vtkGetMacro(GridlineZLength, double); 249 250 // Description: 251 // Set/Get whether gridpolys should be drawn. 252 vtkSetMacro(DrawGridpolys, int); 253 vtkGetMacro(DrawGridpolys, int); 254 vtkBooleanMacro(DrawGridpolys, int); 201 255 202 256 // Description: … … 219 273 220 274 void SetAxisPositionToMinMin(void) 221 275 { this->SetAxisPosition(VTK_AXIS_POS_MINMIN); }; 222 276 void SetAxisPositionToMinMax(void) 223 277 { this->SetAxisPosition(VTK_AXIS_POS_MINMAX); }; 224 278 void SetAxisPositionToMaxMax(void) 225 279 { this->SetAxisPosition(VTK_AXIS_POS_MAXMAX); }; 226 280 void SetAxisPositionToMaxMin(void) 227 281 { this->SetAxisPosition(VTK_AXIS_POS_MAXMIN); }; 228 282 229 283 // Description: … … 236 290 // Draw the axis. 237 291 virtual int RenderOpaqueGeometry(vtkViewport* viewport); 238 virtual int RenderTranslucentGeometry(vtkViewport *) {return 0;} 292 virtual int RenderTranslucentGeometry(vtkViewport* viewport); 293 virtual int RenderTranslucentPolygonalGeometry(vtkViewport* viewport); 294 virtual int RenderOverlay(vtkViewport* viewport); 295 int HasTranslucentPolygonalGeometry(); 239 296 240 297 // Description: … … 243 300 // resources to release. 244 301 void ReleaseGraphicsResources(vtkWindow *); 245 246 // Description:247 // Shallow copy of an axis actor. Overloads the virtual vtkProp method.248 void ShallowCopy(vtkProp *prop);249 302 250 303 //BTX … … 255 308 void SetTitleScale(const double); 256 309 257 258 310 // Description: 259 311 // Set/Get the starting position for minor and major tick points, … … 261 313 vtkSetMacro(MinorStart, double); 262 314 vtkGetMacro(MinorStart, double); 263 vtkSetMacro(MajorStart, double); 264 vtkGetMacro(MajorStart, double); 315 double GetMajorStart(int axis); 316 void SetMajorStart(int axis,double value); 317 //vtkSetMacro(MajorStart, double); 318 //vtkGetMacro(MajorStart, double); 265 319 vtkSetMacro(DeltaMinor, double); 266 320 vtkGetMacro(DeltaMinor, double); 267 vtkSetMacro(DeltaMajor, double); 268 vtkGetMacro(DeltaMajor, double); 321 double GetDeltaMajor(int axis); 322 void SetDeltaMajor(int axis,double value); 323 //vtkSetMacro(DeltaMajor, double); 324 //vtkGetMacro(DeltaMajor, double); 269 325 270 326 // Description: … … 288 344 void BuildAxis(vtkViewport *viewport, bool); 289 345 290 protected: 346 //BTX 347 // Description: 348 // Get title actor and it is responsible for drawing 349 // title text. 350 vtkGetObjectMacro(TitleActor, vtkRpAxisFollower); 351 352 // Description: 353 // Get label actors responsigle for drawing label text. 354 inline vtkRpAxisFollower** GetLabelActors() 355 { 356 return this->LabelActors; 357 } 358 //ETX 359 360 // Description: 361 // Get total number of labels built. Once built 362 // this count does not change. 363 vtkGetMacro(NumberOfLabelsBuilt, int); 364 365 // Description: 366 // Set/Get flag whether to calculate title offset. 367 // Default is true. 368 vtkSetMacro(CalculateTitleOffset, int); 369 vtkGetMacro(CalculateTitleOffset, int); 370 vtkBooleanMacro(CalculateTitleOffset, int); 371 372 // Description: 373 // Set/Get flag whether to calculate label offset. 374 // Default is true. 375 vtkSetMacro(CalculateLabelOffset, int); 376 vtkGetMacro(CalculateLabelOffset, int); 377 vtkBooleanMacro(CalculateLabelOffset, int); 378 379 // Description: 380 // Set/Get the 2D mode 381 vtkSetMacro(Use2DMode, int); 382 vtkGetMacro(Use2DMode, int); 383 384 // Description: 385 // Set/Get the 2D mode the vertical offset for X title in 2D mode 386 vtkSetMacro(VerticalOffsetXTitle2D, double); 387 vtkGetMacro(VerticalOffsetXTitle2D, double); 388 389 // Description: 390 // Set/Get the 2D mode the horizontal offset for Y title in 2D mode 391 vtkSetMacro(HorizontalOffsetYTitle2D, double); 392 vtkGetMacro(HorizontalOffsetYTitle2D, double); 393 394 // Description: 395 // Set/Get whether title position must be saved in 2D mode 396 vtkSetMacro(SaveTitlePosition, int); 397 vtkGetMacro(SaveTitlePosition, int); 398 399 // Description: 400 // Provide real vector for non aligned axis 401 vtkSetVector3Macro(AxisBaseForX, double); 402 vtkGetVector3Macro(AxisBaseForX, double); 403 404 // Description: 405 // Provide real vector for non aligned axis 406 vtkSetVector3Macro(AxisBaseForY, double); 407 vtkGetVector3Macro(AxisBaseForY, double); 408 409 // Description: 410 // Provide real vector for non aligned axis 411 vtkSetVector3Macro(AxisBaseForZ, double); 412 vtkGetVector3Macro(AxisBaseForZ, double); 413 414 // Description: 415 // Notify the axes that is not part of a cube anymore 416 vtkSetMacro(AxisOnOrigin,int); 417 vtkGetMacro(AxisOnOrigin,int); 418 419 420 protected: 291 421 vtkRpAxisActor(); 292 422 ~vtkRpAxisActor(); … … 302 432 303 433 int DrawGridlines; 434 int DrawGridlinesOnly; 304 435 int LastDrawGridlines; 305 double GridlineXLength; 306 double GridlineYLength; 307 double GridlineZLength; 436 int DrawGridlinesLocation; // 0: all | 1: closest | 2: farest 437 int LastDrawGridlinesLocation; // 0: all | 1: closest | 2: farest 438 double GridlineXLength; 439 double GridlineYLength; 440 double GridlineZLength; 441 442 int DrawInnerGridlines; 443 int LastDrawInnerGridlines; 444 445 int DrawGridpolys; 446 int LastDrawGridpolys; 308 447 309 448 int AxisVisibility; … … 317 456 double Bounds[6]; 318 457 319 private: 458 double AxisBaseForX[3]; 459 double AxisBaseForY[3]; 460 double AxisBaseForZ[3]; 461 462 private: 320 463 vtkRpAxisActor(const vtkRpAxisActor&); // Not implemented 321 464 void operator=(const vtkRpAxisActor&); // Not implemented … … 324 467 325 468 void BuildLabels(vtkViewport *, bool); 469 void BuildLabels2D(vtkViewport *, bool); 326 470 void SetLabelPositions(vtkViewport *, bool); 471 void SetLabelPositions2D(vtkViewport *, bool); 327 472 328 473 void BuildTitle(bool); 474 void BuildTitle2D(vtkViewport *viewport, bool); 329 475 330 476 void SetAxisPointsAndLines(void); 331 bool BuildTickPointsForXType(double p1[3], double p2[3], bool); 332 bool BuildTickPointsForYType(double p1[3], double p2[3], bool); 333 bool BuildTickPointsForZType(double p1[3], double p2[3], bool); 477 bool BuildTickPoints(double p1[3], double p2[3], bool force); 334 478 335 479 bool TickVisibilityChanged(void); 480 vtkProperty *NewTitleProperty(); 481 vtkProperty2D *NewTitleProperty2D(); 482 vtkProperty *NewLabelProperty(); 483 484 bool BoundsDisplayCoordinateChanged(vtkViewport *viewport); 336 485 337 486 vtkCoordinate *Point1Coordinate; … … 341 490 double MinorTickSize; 342 491 343 // for the positions 344 double MajorStart; 492 // For each axis (for the inner gridline generation) 493 double MajorStart[3]; 494 double DeltaMajor[3]; 345 495 double MinorStart; 346 347 496 double DeltaMinor; 348 double DeltaMajor;349 497 350 498 // For the ticks, w.r.t to the set range … … 357 505 int LastAxisType; 358 506 int LastTickLocation; 359 double 507 double LastLabelStart; 360 508 361 509 vtkPoints *MinorTickPts; 362 510 vtkPoints *MajorTickPts; 363 511 vtkPoints *GridlinePts; 512 vtkPoints *InnerGridlinePts; 513 vtkPoints *GridpolyPts; 364 514 365 515 vtkVectorText *TitleVector; 366 516 vtkPolyDataMapper *TitleMapper; 367 vtkFollower *TitleActor; 517 vtkRpAxisFollower *TitleActor; 518 vtkTextActor *TitleActor2D; 519 vtkTextProperty *TitleTextProperty; 368 520 369 521 vtkVectorText **LabelVectors; 370 522 vtkPolyDataMapper **LabelMappers; 371 vtkFollower **LabelActors; 372 373 vtkPolyData *Axis; 374 vtkPolyDataMapper *AxisMapper; 375 vtkActor *AxisActor; 523 vtkRpAxisFollower **LabelActors; 524 vtkTextActor **LabelActors2D; 525 vtkTextProperty *LabelTextProperty; 526 527 vtkPolyData *AxisLines; 528 vtkPolyDataMapper *AxisLinesMapper; 529 vtkActor *AxisLinesActor; 530 vtkPolyData *Gridlines; 531 vtkPolyDataMapper *GridlinesMapper; 532 vtkActor *GridlinesActor; 533 vtkPolyData *InnerGridlines; 534 vtkPolyDataMapper *InnerGridlinesMapper; 535 vtkActor *InnerGridlinesActor; 536 vtkPolyData *Gridpolys; 537 vtkPolyDataMapper *GridpolysMapper; 538 vtkActor *GridpolysActor; 376 539 377 540 vtkCamera *Camera; 378 541 vtkTimeStamp BuildTime; 542 vtkTimeStamp BuildTickPointsTime; 379 543 vtkTimeStamp BoundsTime; 380 544 vtkTimeStamp LabelBuildTime; 381 545 vtkTimeStamp TitleTextTime; 382 546 547 int AxisOnOrigin; 548 383 549 int AxisHasZeroLength; 550 551 int CalculateTitleOffset; 552 int CalculateLabelOffset; 553 554 // Description: 555 // Use xy-axis only when Use2DMode=1: 556 int Use2DMode; 557 558 // Description: 559 // Vertical offset in display coordinates for X axis title (used in 2D mode only) 560 // Default: -40 561 double VerticalOffsetXTitle2D; 562 563 // Description: 564 // Vertical offset in display coordinates for X axis title (used in 2D mode only) 565 // Default: -50 566 double HorizontalOffsetYTitle2D; 567 568 // Description: 569 // Save title position (used in 2D mode only): 570 // val = 0 : no need to save position (doesn't stick actors in a position) 571 // val = 1 : positions have to be saved during the next render pass 572 // val = 2 : positions are saved; use them 573 int SaveTitlePosition; 574 575 // Description: 576 // Constant position for the title (used in 2D mode only) 577 double TitleConstantPosition[2]; 578 579 // Description: 580 // True if the 2D title has to be built, false otherwise 581 bool NeedBuild2D; 582 583 double LastMinDisplayCoordinate[3]; 584 double LastMaxDisplayCoordinate[3]; 384 585 }; 385 586 -
trunk/packages/vizservers/vtkvis/vtkRpCubeAxesActor.cpp
r2864 r3479 16 16 #include "vtkRpCubeAxesActor.h" 17 17 18 #include "vtkRpAxisActor.h" 19 #include "vtkRpAxisFollower.h" 20 #include "vtkBoundingBox.h" 18 21 #include "vtkCamera.h" 19 22 #include "vtkCoordinate.h" 20 #include "vtk RpAxisActor.h"23 #include "vtkFollower.h" 21 24 #include "vtkMath.h" 22 25 #include "vtkObjectFactory.h" 23 26 #include "vtkProperty.h" 24 27 #include "vtkStringArray.h" 28 #include "vtkTextProperty.h" 25 29 #include "vtkViewport.h" 26 30 27 // *************************************************************************28 // Modifications:29 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 200230 // Replace 'New' method with Macro to match VTK 4.0 API.31 //32 // *************************************************************************33 31 34 32 vtkStandardNewMacro(vtkRpCubeAxesActor); 35 33 vtkCxxSetObjectMacro(vtkRpCubeAxesActor, Camera,vtkCamera); 36 37 34 // ************************************************************************* 38 35 // Instantiate this object. 39 //40 // Modifications:41 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 200142 // Intialize new members lastPow, last*AxisDigits.43 //44 // Kathleen Bonnell, Wed Nov 7 16:19:16 PST 200145 // Intialize new members: Last*Extent, LastFlyMode,46 // renderAxes*, numAxes*.47 //48 // Hank Childs, Fri Sep 27 17:15:07 PDT 200249 // Initialize new members for units.50 //51 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 200352 // Remove 'Input' and 'Prop' members, initialize new members53 // valueScaleFactor, mustAdjustValue, ForceLabelReset.54 //55 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 200356 // Remove valueScaleFactor, replace mustAdjustValue and ForceLabelReset57 // with one for each axis type.58 //59 // Kathleen Bonnell, Tue Dec 16 11:27:30 PST 200360 // Replace Last*Extent with Last*Range. (* = X, Y, Z)61 // Add AutoLabelScaling, UserXPow, UserYPow, UserZPow.62 //63 // Brad Whitlock, Fri Jul 23 18:18:41 PST 200464 // Added ActualXLabel et al so we can keep title separate from what's65 // actually displayed so information is not lost.66 //67 36 // ************************************************************************* 68 69 vtkRpCubeAxesActor::vtkRpCubeAxesActor() 37 vtkRpCubeAxesActor::vtkRpCubeAxesActor() : vtkActor() 70 38 { 71 39 this->Bounds[0] = -1.0; this->Bounds[1] = 1.0; 72 40 this->Bounds[2] = -1.0; this->Bounds[3] = 1.0; 73 41 this->Bounds[4] = -1.0; this->Bounds[5] = 1.0; 74 75 this->TickLocation = VTK_TICKS_INSIDE; 42 for(int i=0; i < 6; ++i) 43 { 44 this->RenderedBounds[i] = this->Bounds[i]; 45 } 46 47 this->OrientedBounds[0] = -1.0; this->OrientedBounds[1] = 1.0; 48 this->OrientedBounds[2] = -1.0; this->OrientedBounds[3] = 1.0; 49 this->OrientedBounds[4] = -1.0; this->OrientedBounds[5] = 1.0; 50 51 // Disable oriented bounds and Axis origin 52 this->UseOrientedBounds = this->UseAxisOrigin = 0; 53 54 // Init default axis origin 55 this->AxisOrigin[0] = this->AxisOrigin[1] = this->AxisOrigin[2] = 0.0; 56 57 // Init default axis base 58 this->AxisBaseForX[0] = this->AxisBaseForX[1] = this->AxisBaseForX[2] = 0; 59 this->AxisBaseForY[0] = this->AxisBaseForY[1] = this->AxisBaseForY[2] = 0; 60 this->AxisBaseForZ[0] = this->AxisBaseForZ[1] = this->AxisBaseForZ[2] = 0; 61 this->AxisBaseForX[0] = this->AxisBaseForY[1] = this->AxisBaseForZ[2] = 1.0; 62 63 this->RebuildAxes = false; 64 76 65 this->Camera = NULL; 66 77 67 this->FlyMode = VTK_FLY_CLOSEST_TRIAD; 78 int i; 79 for (i = 0; i < 4; i++) 68 this->GridLineLocation = VTK_GRID_LINES_ALL; 69 70 // By default enable distance based LOD 71 this->EnableDistanceLOD = 1; 72 this->DistanceLODThreshold = .8; 73 74 // By default enable view angle based LOD 75 this->EnableViewAngleLOD = 1; 76 this->ViewAngleLODThreshold = .2; 77 78 // Title and label text properties 79 for (int i = 0; i < 3; i++) 80 { 81 this->TitleTextProperty[i] = vtkTextProperty::New(); 82 this->TitleTextProperty[i]->SetColor(1.,1.,1.); 83 this->TitleTextProperty[i]->SetFontFamilyToArial(); 84 this->TitleTextProperty[i]->SetFontSize(14); 85 86 this->LabelTextProperty[i] = vtkTextProperty::New(); 87 this->LabelTextProperty[i]->SetColor(1.,1.,1.); 88 this->LabelTextProperty[i]->SetFontFamilyToArial(); 89 this->LabelTextProperty[i]->SetFontSize(12); 90 } 91 92 // Axis lines 93 this->XAxesLinesProperty = vtkProperty::New(); 94 this->YAxesLinesProperty = vtkProperty::New(); 95 this->ZAxesLinesProperty = vtkProperty::New(); 96 97 // Outer grid lines 98 this->XAxesGridlinesProperty = vtkProperty::New(); 99 this->YAxesGridlinesProperty = vtkProperty::New(); 100 this->ZAxesGridlinesProperty = vtkProperty::New(); 101 102 // Inner grid lines 103 this->XAxesInnerGridlinesProperty = vtkProperty::New(); 104 this->YAxesInnerGridlinesProperty = vtkProperty::New(); 105 this->ZAxesInnerGridlinesProperty = vtkProperty::New(); 106 this->XAxesInnerGridlinesProperty->SetColor(.3,.6,.1); 107 this->YAxesInnerGridlinesProperty->SetColor(.3,.6,.1); 108 this->ZAxesInnerGridlinesProperty->SetColor(.3,.6,.1); 109 110 this->XAxesGridpolysProperty = vtkProperty::New(); 111 this->YAxesGridpolysProperty = vtkProperty::New(); 112 this->ZAxesGridpolysProperty = vtkProperty::New(); 113 this->XAxesGridpolysProperty->SetOpacity(.6); // Default grid polys opacity 114 this->YAxesGridpolysProperty->SetOpacity(.6); // Default grid polys opacity 115 this->ZAxesGridpolysProperty->SetOpacity(.6); // Default grid polys opacity 116 //this->XAxesGridpolysProperty->LightingOff(); // To be able to see the polys from high camera angles 117 //this->YAxesGridpolysProperty->LightingOff(); // To be able to see the polys from high camera angles 118 //this->ZAxesGridpolysProperty->LightingOff(); // To be able to see the polys from high camera angles 119 120 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 80 121 { 81 122 this->XAxes[i] = vtkRpAxisActor::New(); … … 86 127 this->XAxes[i]->SetAxisTypeToX(); 87 128 this->XAxes[i]->SetAxisPosition(i); 129 this->XAxes[i]->SetAxisLinesProperty(this->XAxesLinesProperty); 130 this->XAxes[i]->SetGridlinesProperty(this->XAxesGridlinesProperty); 131 this->XAxes[i]->SetInnerGridlinesProperty(this->XAxesInnerGridlinesProperty); 132 this->XAxes[i]->SetGridpolysProperty(this->XAxesGridpolysProperty); 133 this->XAxes[i]->SetCalculateTitleOffset(0); 134 this->XAxes[i]->SetCalculateLabelOffset(0); 88 135 89 136 this->YAxes[i] = vtkRpAxisActor::New(); … … 94 141 this->YAxes[i]->SetAxisTypeToY(); 95 142 this->YAxes[i]->SetAxisPosition(i); 143 this->YAxes[i]->SetAxisLinesProperty(this->YAxesLinesProperty); 144 this->YAxes[i]->SetGridlinesProperty(this->YAxesGridlinesProperty); 145 this->YAxes[i]->SetInnerGridlinesProperty(this->YAxesInnerGridlinesProperty); 146 this->YAxes[i]->SetGridpolysProperty(this->YAxesGridpolysProperty); 147 this->YAxes[i]->SetCalculateTitleOffset(0); 148 this->YAxes[i]->SetCalculateLabelOffset(0); 96 149 97 150 this->ZAxes[i] = vtkRpAxisActor::New(); … … 102 155 this->ZAxes[i]->SetAxisTypeToZ(); 103 156 this->ZAxes[i]->SetAxisPosition(i); 104 } 105 106 this->XLabelFormat = new char[8]; 107 sprintf(this->XLabelFormat, "%s", "%-#6.3g"); 108 this->YLabelFormat = new char[8]; 109 sprintf(this->YLabelFormat, "%s", "%-#6.3g"); 110 this->ZLabelFormat = new char[8]; 111 sprintf(this->ZLabelFormat, "%s", "%-#6.3g"); 112 this->CornerOffset = 0.0; 113 this->Inertia = 1; 114 this->RenderCount = 0; 115 116 this->XAxisVisibility = 1; 117 this->YAxisVisibility = 1; 118 this->ZAxisVisibility = 1; 119 120 this->XAxisTickVisibility = 1; 121 this->YAxisTickVisibility = 1; 122 this->ZAxisTickVisibility = 1; 123 124 this->XAxisMinorTickVisibility = 1; 125 this->YAxisMinorTickVisibility = 1; 126 this->ZAxisMinorTickVisibility = 1; 127 128 this->XAxisLabelVisibility = 1; 129 this->YAxisLabelVisibility = 1; 130 this->ZAxisLabelVisibility = 1; 131 132 this->DrawXGridlines = 0; 133 this->DrawYGridlines = 0; 134 this->DrawZGridlines = 0; 157 this->ZAxes[i]->SetAxisLinesProperty(this->ZAxesLinesProperty); 158 this->ZAxes[i]->SetGridlinesProperty(this->ZAxesGridlinesProperty); 159 this->ZAxes[i]->SetInnerGridlinesProperty(this->ZAxesInnerGridlinesProperty); 160 this->ZAxes[i]->SetGridpolysProperty(this->ZAxesGridpolysProperty); 161 this->ZAxes[i]->SetCalculateTitleOffset(0); 162 this->ZAxes[i]->SetCalculateLabelOffset(0); 163 164 this->ScreenSize = 10.0; 165 166 this->LabelScreenOffset = 20.0 + this->ScreenSize * 0.5; 167 this->TitleScreenOffset = 168 this->LabelScreenOffset * 2.0 + this->ScreenSize * 0.5; 169 170 // Pass information to axes followers. 171 vtkRpAxisFollower* follower = this->XAxes[i]->GetTitleActor(); 172 follower->SetAxis(this->XAxes[i]); 173 follower->SetScreenOffset(this->TitleScreenOffset); 174 follower->SetEnableDistanceLOD( this->EnableDistanceLOD ); 175 follower->SetDistanceLODThreshold( this->DistanceLODThreshold ); 176 follower->SetEnableViewAngleLOD( this->EnableViewAngleLOD ); 177 follower->SetViewAngleLODThreshold( this->ViewAngleLODThreshold ); 178 179 follower = this->YAxes[i]->GetTitleActor(); 180 follower->SetAxis(this->YAxes[i]); 181 follower->SetScreenOffset(this->TitleScreenOffset); 182 follower->SetEnableDistanceLOD( this->EnableDistanceLOD ); 183 follower->SetDistanceLODThreshold( this->DistanceLODThreshold ); 184 follower->SetEnableViewAngleLOD( this->EnableViewAngleLOD ); 185 follower->SetViewAngleLODThreshold( this->ViewAngleLODThreshold ); 186 187 follower = this->ZAxes[i]->GetTitleActor(); 188 follower->SetAxis(this->ZAxes[i]); 189 follower->SetScreenOffset(this->TitleScreenOffset); 190 follower->SetEnableDistanceLOD( this->EnableDistanceLOD ); 191 follower->SetDistanceLODThreshold( this->DistanceLODThreshold ); 192 follower->SetEnableViewAngleLOD( this->EnableViewAngleLOD ); 193 follower->SetViewAngleLODThreshold( this->ViewAngleLODThreshold ); 194 } 135 195 136 196 this->XTitle = new char[7]; … … 148 208 this->ActualZLabel = 0; 149 209 210 this->TickLocation = VTK_TICKS_INSIDE; 211 212 this->XAxisVisibility = 1; 213 this->YAxisVisibility = 1; 214 this->ZAxisVisibility = 1; 215 216 this->XAxisTickVisibility = 1; 217 this->YAxisTickVisibility = 1; 218 this->ZAxisTickVisibility = 1; 219 220 this->XAxisMinorTickVisibility = 1; 221 this->YAxisMinorTickVisibility = 1; 222 this->ZAxisMinorTickVisibility = 1; 223 224 this->XAxisLabelVisibility = 1; 225 this->YAxisLabelVisibility = 1; 226 this->ZAxisLabelVisibility = 1; 227 228 this->DrawXGridlines = 0; 229 this->DrawYGridlines = 0; 230 this->DrawZGridlines = 0; 231 232 this->DrawXInnerGridlines = 0; 233 this->DrawYInnerGridlines = 0; 234 this->DrawZInnerGridlines = 0; 235 236 this->DrawXGridpolys = 0; 237 this->DrawYGridpolys = 0; 238 this->DrawZGridpolys = 0; 239 240 this->XLabelFormat = new char[8]; 241 sprintf(this->XLabelFormat, "%s", "%-#6.3g"); 242 this->YLabelFormat = new char[8]; 243 sprintf(this->YLabelFormat, "%s", "%-#6.3g"); 244 this->ZLabelFormat = new char[8]; 245 sprintf(this->ZLabelFormat, "%s", "%-#6.3g"); 246 247 this->XAutoLabelFormat = 1; 248 this->YAutoLabelFormat = 1; 249 this->ZAutoLabelFormat = 1; 250 251 this->CornerOffset = 0.0; 252 253 this->Inertia = 1; 254 255 this->RenderCount = 0; 256 257 this->InertiaLocs[0] = this->InertiaLocs[1] = this->InertiaLocs[2] = -1; 258 259 this->RenderSomething = 0; 260 261 this->LastUseOrientedBounds = 0; 262 150 263 this->LastXPow = 0; 151 264 this->LastYPow = 0; 152 265 this->LastZPow = 0; 266 267 this->UserXPow = 0; 268 this->UserYPow = 0; 269 this->UserZPow = 0; 270 271 this->AutoLabelScaling = true; 272 153 273 this->LastXAxisDigits = 3; 154 274 this->LastYAxisDigits = 3; … … 162 282 this->LastZRange[1] = VTK_FLOAT_MAX; 163 283 284 this->LastBounds[0] = VTK_DOUBLE_MAX; 285 this->LastBounds[1] = VTK_DOUBLE_MAX; 286 this->LastBounds[2] = VTK_DOUBLE_MAX; 287 this->LastBounds[3] = VTK_DOUBLE_MAX; 288 this->LastBounds[4] = VTK_DOUBLE_MAX; 289 this->LastBounds[5] = VTK_DOUBLE_MAX; 290 164 291 this->LastFlyMode = -1; 165 for (i = 0; i < 4; i++) 292 293 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 166 294 { 167 295 this->RenderAxesX[i] = i; … … 178 306 this->ForceYLabelReset = false; 179 307 this->ForceZLabelReset = false; 180 181 this->AutoLabelScaling = true;182 this->UserXPow = 0;183 this->UserYPow = 0;184 this->UserZPow = 0;185 308 186 309 this->XAxisRange[0] = VTK_DOUBLE_MAX; … … 190 313 this->ZAxisRange[0] = VTK_DOUBLE_MAX; 191 314 this->ZAxisRange[1] = VTK_DOUBLE_MAX; 315 316 for (int i = 0; i < 3; ++i) 317 { 318 this->AxisLabels[i] = NULL; 319 } 320 this->LabelScale = -1.0; 321 this->TitleScale = -1.0; 322 } 323 324 void vtkRpCubeAxesActor::SetUse2DMode( int val ) 325 { 326 for( int i = 0 ; i < NUMBER_OF_ALIGNED_AXIS ; ++ i ) 327 { 328 this->XAxes[i]->SetUse2DMode( val ); 329 this->YAxes[i]->SetUse2DMode( val ); 330 this->ZAxes[i]->SetUse2DMode( val ); 331 } 332 if( ! val ) 333 { 334 this->SetZAxisVisibility( 1 ); 335 } 336 else 337 { 338 this->SetZAxisVisibility( 0 ); 339 } 340 } 341 342 int vtkRpCubeAxesActor::GetUse2DMode() 343 { 344 // It is assumed that all axes have the same value 345 return this->XAxes[0]->GetUse2DMode(); 346 } 347 348 void vtkRpCubeAxesActor::SetSaveTitlePosition( int val ) 349 { 350 // For 2D mode only : 351 // val = 0: no need to save position (3D axis) 352 // val = 1: positions have to be saved during the next render pass 353 // val = 2: positions are saved -> use them 354 for( int i = 0 ; i < NUMBER_OF_ALIGNED_AXIS ; ++ i ) 355 { 356 this->XAxes[i]->SetSaveTitlePosition( val ); 357 this->YAxes[i]->SetSaveTitlePosition( val ); 358 } 192 359 } 193 360 194 361 // **************************************************************************** 195 // Shallow copy of an actor.196 //197 // Modifications:198 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 2002199 // Call superclass method the new VTK 4.0 way.200 //201 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003202 // Remove 'Input' and 'Prop' members, added new members203 // valueScaleFactor, mustAdjustValue, ForceLabelReset.204 //205 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 2003206 // Remove valueScaleFactor, replace mustAdjustValue and ForceLabelReset207 // with one for each axis type.208 //209 // ****************************************************************************210 211 void vtkRpCubeAxesActor::ShallowCopy(vtkRpCubeAxesActor *actor)212 {213 this->Superclass::ShallowCopy(actor);214 this->SetXLabelFormat(actor->GetXLabelFormat());215 this->SetYLabelFormat(actor->GetYLabelFormat());216 this->SetZLabelFormat(actor->GetZLabelFormat());217 this->SetCornerOffset(actor->GetCornerOffset());218 this->SetInertia(actor->GetInertia());219 this->SetXTitle(actor->GetXTitle());220 this->SetYTitle(actor->GetYTitle());221 this->SetZTitle(actor->GetZTitle());222 this->SetFlyMode(actor->GetFlyMode());223 this->SetCamera(actor->GetCamera());224 this->SetBounds(actor->GetBounds());225 this->MustAdjustXValue = actor->MustAdjustXValue;226 this->MustAdjustYValue = actor->MustAdjustYValue;227 this->MustAdjustZValue = actor->MustAdjustZValue;228 this->ForceXLabelReset = actor->ForceXLabelReset;229 this->ForceYLabelReset = actor->ForceYLabelReset;230 this->ForceZLabelReset = actor->ForceZLabelReset;231 }232 233 // ****************************************************************************234 // Modifications:235 //236 // Hank Childs, Fri Sep 27 17:15:07 PDT 2002237 // Destruct new data members for units.238 //239 // Brad Whitlock, Fri Jul 23 18:21:16 PST 2004240 // Added more items and fixed a small memory leak.241 //242 // ****************************************************************************243 244 362 vtkRpCubeAxesActor::~vtkRpCubeAxesActor() 245 363 { 246 364 this->SetCamera(NULL); 247 365 248 for (int i = 0; i < 4; i++)366 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 249 367 { 250 368 if (this->XAxes[i]) … … 263 381 this->ZAxes[i] = NULL; 264 382 } 383 } 384 385 if (this->XAxesLinesProperty) 386 { 387 this->XAxesLinesProperty->Delete(); 388 } 389 if (this->XAxesGridlinesProperty) 390 { 391 this->XAxesGridlinesProperty->Delete(); 392 } 393 if (this->XAxesInnerGridlinesProperty) 394 { 395 this->XAxesInnerGridlinesProperty->Delete(); 396 } 397 if (this->XAxesGridpolysProperty) 398 { 399 this->XAxesGridpolysProperty->Delete(); 400 } 401 if (this->YAxesLinesProperty) 402 { 403 this->YAxesLinesProperty->Delete(); 404 } 405 if (this->YAxesGridlinesProperty) 406 { 407 this->YAxesGridlinesProperty->Delete(); 408 } 409 if (this->YAxesInnerGridlinesProperty) 410 { 411 this->YAxesInnerGridlinesProperty->Delete(); 412 } 413 if (this->YAxesGridpolysProperty) 414 { 415 this->YAxesGridpolysProperty->Delete(); 416 } 417 if (this->ZAxesLinesProperty) 418 { 419 this->ZAxesLinesProperty->Delete(); 420 } 421 if (this->ZAxesGridlinesProperty) 422 { 423 this->ZAxesGridlinesProperty->Delete(); 424 } 425 if (this->ZAxesInnerGridlinesProperty) 426 { 427 this->ZAxesInnerGridlinesProperty->Delete(); 428 } 429 if (this->ZAxesGridpolysProperty) 430 { 431 this->ZAxesGridpolysProperty->Delete(); 432 } 433 434 for (int i = 0; i < 3; i++) 435 { 436 if(this->TitleTextProperty[i] != NULL) 437 { 438 this->TitleTextProperty[i]->Delete(); 439 } 440 this->TitleTextProperty[i] = NULL; 441 442 if(this->LabelTextProperty[i] != NULL) 443 { 444 this->LabelTextProperty[i]->Delete(); 445 } 446 this->LabelTextProperty[i] = NULL; 265 447 } 266 448 … … 336 518 // cube. Determine which parts of the edges are visible via intersection 337 519 // with the boundary of the viewport (minus borders). 338 //339 // Modifications:340 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 2001341 // Added calls to AdjustValues, AdjustRange.342 //343 // Kathleen Bonnell, Wed Nov 7 16:19:16 PST 2001344 // Only render those axes needed for current FlyMode.345 // Moved bulk of 'build' code to BuildAxes method, added calls to346 // BuildAxes and DetermineRenderAxes methods.347 //348 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003349 // Added initial build of each axis.350 520 // ************************************************************************* 351 352 521 int vtkRpCubeAxesActor::RenderOpaqueGeometry(vtkViewport *viewport) 353 522 { 354 int i, renderedSomething=0;355 523 static bool initialRender = true; 356 // Initialization 357 if (!this->Camera) 358 { 359 vtkErrorMacro(<<"No camera!"); 360 this->RenderSomething = 0; 361 return 0; 362 } 363 364 this->BuildAxes(viewport); 365 366 if (initialRender) 367 { 368 for (i = 0; i < 4; i++) 369 { 370 this->XAxes[i]->BuildAxis(viewport, true); 371 this->YAxes[i]->BuildAxis(viewport, true); 372 this->ZAxes[i]->BuildAxis(viewport, true); 373 } 374 } 375 initialRender = false; 376 377 this->DetermineRenderAxes(viewport); 378 379 //Render the axes 380 if (this->XAxisVisibility) 381 { 382 for (i = 0; i < this->NumberOfAxesX; i++) 383 { 384 renderedSomething += 385 this->XAxes[this->RenderAxesX[i]]->RenderOpaqueGeometry(viewport); 386 } 387 } 388 389 if (this->YAxisVisibility) 390 { 391 for (i = 0; i < this->NumberOfAxesY; i++) 392 { 393 renderedSomething += 394 this->YAxes[this->RenderAxesY[i]]->RenderOpaqueGeometry(viewport); 395 } 396 } 397 398 if (this->ZAxisVisibility) 399 { 400 for (i = 0; i < this->NumberOfAxesZ; i++) 401 { 402 renderedSomething += 403 this->ZAxes[this->RenderAxesZ[i]]->RenderOpaqueGeometry(viewport); 404 } 405 } 406 return renderedSomething; 407 } 408 524 return this->RenderGeometry( 525 initialRender, viewport, true, 526 &vtkRpAxisActor::RenderOpaqueGeometry); 527 } 528 529 // ************************************************************************* 530 // Project the bounding box and compute edges on the border of the bounding 531 // cube. Determine which parts of the edges are visible via intersection 532 // with the boundary of the viewport (minus borders). 533 // ************************************************************************* 534 int vtkRpCubeAxesActor::RenderTranslucentGeometry(vtkViewport *viewport) 535 { 536 static bool initialRender = true; 537 return this->RenderGeometry( 538 initialRender, viewport, true, 539 &vtkRpAxisActor::RenderTranslucentGeometry); 540 } 541 542 // ************************************************************************* 543 // Project the bounding box and compute edges on the border of the bounding 544 // cube. Determine which parts of the edges are visible via intersection 545 // with the boundary of the viewport (minus borders). 546 // ************************************************************************* 547 int vtkRpCubeAxesActor::RenderTranslucentPolygonalGeometry(vtkViewport *viewport) 548 { 549 static bool initialRender = true; 550 return this->RenderGeometry( 551 initialRender, viewport, true, 552 &vtkRpAxisActor::RenderTranslucentPolygonalGeometry); 553 } 554 555 // ************************************************************************* 556 // RenderOverlay : render 2D annotations. 557 // ************************************************************************* 558 int vtkRpCubeAxesActor::RenderOverlay(vtkViewport *viewport) 559 { 560 static bool initialRender = true; 561 return this->RenderGeometry( 562 initialRender, viewport, false, 563 &vtkRpAxisActor::RenderOverlay); 564 } 565 566 // -------------------------------------------------------------------------- 567 int vtkRpCubeAxesActor::HasTranslucentPolygonalGeometry() 568 { 569 if ((this->NumberOfAxesX > 0 && 570 this->XAxes[0]->HasTranslucentPolygonalGeometry()) || 571 (this->NumberOfAxesY > 0 && 572 this->YAxes[0]->HasTranslucentPolygonalGeometry()) || 573 (this->NumberOfAxesZ > 0 && 574 this->ZAxes[0]->HasTranslucentPolygonalGeometry())) 575 { 576 return 1; 577 } 578 579 return 0; 580 } 581 582 // -------------------------------------------------------------------------- 409 583 // Do final adjustment of axes to control offset, etc. 410 void vtkRpCubeAxesActor::AdjustAxes(double bounds[6], double xCoords[4][6], 411 double yCoords[4][6], double zCoords[4][6], 584 void vtkRpCubeAxesActor::AdjustAxes(double bounds[6], 585 double xCoords[NUMBER_OF_ALIGNED_AXIS][6], 586 double yCoords[NUMBER_OF_ALIGNED_AXIS][6], 587 double zCoords[NUMBER_OF_ALIGNED_AXIS][6], 412 588 double xRange[2], double yRange[2], 413 589 double zRange[2]) … … 433 609 if (this->CornerOffset > 0.0) 434 610 { 435 for (int i = 0; i < 4; i++)611 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 436 612 { 437 613 double ave; … … 491 667 } 492 668 669 // ************************************************************************* 670 // Screen size affects the screen offset as well. 671 // ************************************************************************* 672 void vtkRpCubeAxesActor::SetScreenSize(double screenSize) 673 { 674 this->ScreenSize = screenSize; 675 // Considering pivot point at center of the geometry hence (this->ScreenSize * 0.5). 676 this->LabelScreenOffset = 20.0 + this->ScreenSize * 0.5; 677 this->TitleScreenOffset = this->LabelScreenOffset * 2.0 + 678 this->ScreenSize * 0.5; 679 680 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 681 { 682 this->XAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset); 683 this->YAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset); 684 this->ZAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset); 685 686 int numberOfLabelsBuild = this->XAxes[i]->GetNumberOfLabelsBuilt(); 687 vtkRpAxisFollower **labelActors = this->XAxes[i]->GetLabelActors(); 688 for(int k=0; k < numberOfLabelsBuild; ++k) 689 { 690 labelActors[k]->SetScreenOffset(this->LabelScreenOffset); 691 } 692 693 numberOfLabelsBuild = this->YAxes[i]->GetNumberOfLabelsBuilt(); 694 labelActors = this->YAxes[i]->GetLabelActors(); 695 for(int k=0; k < numberOfLabelsBuild; ++k) 696 { 697 labelActors[k]->SetScreenOffset(this->LabelScreenOffset); 698 } 699 700 numberOfLabelsBuild = this->ZAxes[i]->GetNumberOfLabelsBuilt(); 701 labelActors = this->ZAxes[i]->GetLabelActors(); 702 for(int k=0; k < numberOfLabelsBuild; ++k) 703 { 704 labelActors[k]->SetScreenOffset(this->LabelScreenOffset); 705 } 706 } 707 708 this->Modified(); 709 } 710 711 // ************************************************************************* 493 712 // Release any graphics resources that are being consumed by this actor. 494 713 // The parameter window could be used to determine which graphic 495 714 // resources to release. 715 // ************************************************************************* 496 716 void vtkRpCubeAxesActor::ReleaseGraphicsResources(vtkWindow *win) 497 717 { 498 for (int i = 0; i < 4; i++)718 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 499 719 { 500 720 this->XAxes[i]->ReleaseGraphicsResources(win); … … 504 724 } 505 725 506 // *************************************************************************507 // Compute the bounds508 //509 // Modifications:510 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003511 // Removed support for Prop and Input.512 // *************************************************************************513 void vtkRpCubeAxesActor::GetBounds(double bounds[6])514 {515 for (int i=0; i< 6; i++)516 {517 bounds[i] = this->Bounds[i];518 }519 }520 521 // Compute the bounds522 void vtkRpCubeAxesActor::GetBounds(double& xmin, double& xmax,523 double& ymin, double& ymax,524 double& zmin, double& zmax)525 {526 xmin = this->Bounds[0];527 xmax = this->Bounds[1];528 ymin = this->Bounds[2];529 ymax = this->Bounds[3];530 zmin = this->Bounds[4];531 zmax = this->Bounds[5];532 }533 534 // Compute the bounds535 double *vtkRpCubeAxesActor::GetBounds()536 {537 return this->Bounds;538 }539 540 726 // ****************************************************************** 541 // Modifications:542 // Kathleen Bonnell, Wed Mar 6 13:48:48 PST 2002543 // Call superclass method the new VTK 4.0 way.544 //545 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 2003546 // Removed Input and Prop.547 //548 // ******************************************************************549 550 727 void vtkRpCubeAxesActor::PrintSelf(ostream& os, vtkIndent indent) 551 728 { … … 554 731 os << indent << "Bounds: \n"; 555 732 os << indent << " Xmin,Xmax: (" << this->Bounds[0] << ", " 556 << this->Bounds[1] << ") \n";733 << this->Bounds[1] << ")" << endl; 557 734 os << indent << " Ymin,Ymax: (" << this->Bounds[2] << ", " 558 << this->Bounds[3] << ") \n";735 << this->Bounds[3] << ")" << endl; 559 736 os << indent << " Zmin,Zmax: (" << this->Bounds[4] << ", " 560 << this->Bounds[5] << ") \n";737 << this->Bounds[5] << ")" << endl; 561 738 562 739 … … 568 745 << this->ZAxisRange[1] << "] " << endl; 569 746 747 os << indent << "ScreenSize: (" << this->ScreenSize << ")" << endl; 748 570 749 if (this->Camera) 571 750 { … … 578 757 } 579 758 759 os << indent << "RebuildAxes: " << this->RebuildAxes << endl; 760 580 761 if (this->FlyMode == VTK_FLY_CLOSEST_TRIAD) 581 762 { 582 os << indent << "Fly Mode: CLOSEST_TRIAD \n";763 os << indent << "Fly Mode: CLOSEST_TRIAD"<< endl; 583 764 } 584 765 else if (this->FlyMode == VTK_FLY_FURTHEST_TRIAD) 585 766 { 586 os << indent << "Fly Mode: FURTHEST_TRIAD \n";767 os << indent << "Fly Mode: FURTHEST_TRIAD"<< endl; 587 768 } 588 769 else if (this->FlyMode == VTK_FLY_STATIC_TRIAD) 589 770 { 590 os << indent << "Fly Mode: STATIC_TRIAD \n";771 os << indent << "Fly Mode: STATIC_TRIAD"<< endl; 591 772 } 592 773 else if (this->FlyMode == VTK_FLY_STATIC_EDGES) 593 774 { 594 os << indent << "Fly Mode: STATIC_EDGES \n";775 os << indent << "Fly Mode: STATIC_EDGES"<< endl; 595 776 } 596 777 else 597 778 { 598 os << indent << "Fly Mode: OUTER_EDGES\n"; 599 } 600 601 os << indent << "X Axis Title: " << this->XTitle << "\n"; 602 os << indent << "Y Axis Title: " << this->YTitle << "\n"; 603 os << indent << "Z Axis Title: " << this->ZTitle << "\n"; 779 os << indent << "Fly Mode: OUTER_EDGES"<< endl; 780 } 781 782 os << indent << "EnableDistanceLOD: " 783 << ( this->EnableDistanceLOD ? "On" : "Off" ) << endl; 784 os << indent << "DistanceLODThreshold: " << this->DistanceLODThreshold << endl; 785 786 os << indent << "EnableViewAngleLOD: " 787 << ( this->EnableViewAngleLOD ? "On" : "Off" ) << endl; 788 os << indent << "ViewAngleLODThreshold: " << this->ViewAngleLODThreshold << endl; 789 790 os << indent << "X Axis Title: " << this->XTitle << endl; 791 os << indent << "Y Axis Title: " << this->YTitle << endl; 792 os << indent << "Z Axis Title: " << this->ZTitle << endl; 604 793 605 794 os << indent << "X Axis Visibility: " … … 610 799 << (this->ZAxisVisibility ? "On\n" : "Off\n"); 611 800 612 os << indent << "X Axis Label Format: " << this->XLabelFormat << "\n"; 613 os << indent << "Y Axis Label Format: " << this->YLabelFormat << "\n"; 614 os << indent << "Z Axis Label Format: " << this->ZLabelFormat << "\n"; 615 os << indent << "Inertia: " << this->Inertia << "\n"; 616 os << indent << "Corner Offset: " << this->CornerOffset << "\n"; 801 os << indent << "X Axis Label Format: " << this->XLabelFormat << endl; 802 os << indent << "Y Axis Label Format: " << this->YLabelFormat << endl; 803 os << indent << "Z Axis Label Format: " << this->ZLabelFormat << endl; 804 805 os << indent << "XAutoLabelFormat: " 806 << (this->XAutoLabelFormat ? "On" : "Off") << endl; 807 os << indent << "YAutoLabelFormat: " 808 << (this->YAutoLabelFormat ? "On" : "Off") << endl; 809 os << indent << "ZAutoLabelFormat: " 810 << (this->ZAutoLabelFormat ? "On" : "Off") << endl; 811 812 os << indent << "Inertia: " << this->Inertia << endl; 813 os << indent << "Corner Offset: " << this->CornerOffset << endl; 617 814 618 815 os << indent << "XAxisTickVisibility: " … … 649 846 os << indent << "DrawYGridlines: " << this->DrawYGridlines << endl; 650 847 os << indent << "DrawZGridlines: " << this->DrawZGridlines << endl; 651 } 652 848 849 switch(this->GridLineLocation) 850 { 851 case VTK_GRID_LINES_ALL: 852 os << indent << "GridLineLocation: VTK_GRID_LINES_ALL (0)" << endl; 853 break; 854 case VTK_GRID_LINES_CLOSEST: 855 os << indent << "GridLineLocation: VTK_GRID_LINES_CLOSEST (1)" << endl; 856 break; 857 case VTK_GRID_LINES_FURTHEST: 858 os << indent << "GridLineLocation: VTK_GRID_LINES_FURTHEST (2)" << endl; 859 break; 860 } 861 862 os << indent << "DrawXInnerGridlines: " << this->DrawXInnerGridlines << endl; 863 os << indent << "DrawYInnerGridlines: " << this->DrawYInnerGridlines << endl; 864 os << indent << "DrawZInnerGridlines: " << this->DrawZInnerGridlines << endl; 865 866 os << indent << "DrawXGridpolys: " << this->DrawXGridpolys << endl; 867 os << indent << "DrawYGridpolys: " << this->DrawYGridpolys << endl; 868 os << indent << "DrawZGridpolys: " << this->DrawZGridpolys << endl; 869 870 871 os << indent << "UseOrientedBounds: " << this->UseOrientedBounds << endl; 872 if(this->UseOrientedBounds) 873 { 874 os << indent << "OrientedBounds: \n"; 875 os << indent << " Xmin,Xmax: (" << this->OrientedBounds[0] << ", " 876 << this->OrientedBounds[1] << ")" << endl; 877 os << indent << " Ymin,Ymax: (" << this->OrientedBounds[2] << ", " 878 << this->OrientedBounds[3] << ")" << endl; 879 os << indent << " Zmin,Zmax: (" << this->OrientedBounds[4] << ", " 880 << this->OrientedBounds[5] << ")" << endl; 881 } 882 883 os << indent << "Base: \n"; 884 os << indent << " For X: (" << this->AxisBaseForX[0] << ", " 885 << this->AxisBaseForX[1] << ", " << this->AxisBaseForX[2] << ")" << endl; 886 os << indent << " For Y: (" << this->AxisBaseForY[0] << ", " 887 << this->AxisBaseForY[1] << ", " << this->AxisBaseForY[2] << ")" << endl; 888 os << indent << " For Z: (" << this->AxisBaseForZ[0] << ", " 889 << this->AxisBaseForZ[1] << ", " << this->AxisBaseForZ[2] << ")" << endl; 890 891 os << indent << "UseAxisOrigin: " << this->UseAxisOrigin << endl; 892 if(this->UseAxisOrigin) 893 { 894 os << indent << "AxisOrigin: (" << this->AxisOrigin[0] << ", " 895 << this->AxisOrigin[1] << ", " << this->AxisOrigin[2] << ")" << endl; 896 } 897 } 898 899 // -------------------------------------------------------------------------- 653 900 void vtkRpCubeAxesActor::TransformBounds(vtkViewport *viewport, 654 901 const double bounds[6], 655 902 double pts[8][3]) 656 903 { 657 int i, j, k, idx;658 904 double x[3]; 659 905 660 906 //loop over verts of bounding box 661 for ( k=0; k<2; k++)662 { 663 x[2] = bounds[4 +k];664 for ( j=0; j<2; j++)665 { 666 x[1] = bounds[2 +j];667 for ( i=0; i<2; i++)907 for ( int k = 0; k < 2; ++ k ) 908 { 909 x[2] = bounds[4 + k]; 910 for ( int j = 0; j < 2; ++ j ) 911 { 912 x[1] = bounds[2 + j]; 913 for ( int i = 0; i < 2; ++ i ) 668 914 { 669 i dx = i + 2*j + 4*k;915 int idx = i + 2 * j + 4 * k; 670 916 x[0] = bounds[i]; 671 viewport->SetWorldPoint( x[0],x[1],x[2],1.0);917 viewport->SetWorldPoint( x[0], x[1], x[2], 1. ); 672 918 viewport->WorldToDisplay(); 673 viewport->GetDisplayPoint( pts[idx]);919 viewport->GetDisplayPoint( pts[idx] ); 674 920 } 675 921 } … … 678 924 679 925 // *********************************************************************** 680 //681 926 // Calculate the size (length) of major and minor ticks, 682 927 // based on an average of the coordinate direction ranges. … … 684 929 // 685 930 // Returns: false if tick size not recomputed, true otherwise. 686 //687 // Modifications:688 // Kathleen Bonnell, Wed Nov 7 16:19:16 PST 2001689 // Added logic for early-termination.690 //691 // Kathleen Bonnell, Fri Jul 18 09:09:31 PDT 2003692 // Added return value, added calls to AdjustTicksComputeRange and693 // BuildLabels.694 //695 // Kathleen Bonnell, Mon Dec 15 14:59:26 PST 2003696 // Use the actual range values instead of range-extents to determine697 // if tick size needs to be recomputed.698 //699 931 // *********************************************************************** 700 701 932 bool vtkRpCubeAxesActor::ComputeTickSize(double bounds[6]) 702 933 { 703 bool xRangeChanged = this->LastXRange[0] != bounds[0] || 704 this->LastXRange[1] != bounds[1]; 705 706 bool yRangeChanged = this->LastYRange[0] != bounds[2] || 707 this->LastYRange[1] != bounds[3]; 708 709 bool zRangeChanged = this->LastZRange[0] != bounds[4] || 710 this->LastZRange[1] != bounds[5]; 711 712 if (!(xRangeChanged || yRangeChanged || zRangeChanged)) 934 bool xPropsChanged = this->LabelTextProperty[0]->GetMTime() > this->BuildTime.GetMTime(); 935 bool yPropsChanged = this->LabelTextProperty[1]->GetMTime() > this->BuildTime.GetMTime(); 936 bool zPropsChanged = this->LabelTextProperty[2]->GetMTime() > this->BuildTime.GetMTime(); 937 938 bool xRangeChanged = this->LastXRange[0] != this->XAxisRange[0] || 939 this->LastXRange[1] != this->XAxisRange[1]; 940 941 bool yRangeChanged = this->LastYRange[0] != this->YAxisRange[0] || 942 this->LastYRange[1] != this->YAxisRange[1]; 943 944 bool zRangeChanged = this->LastZRange[0] != this->ZAxisRange[0] || 945 this->LastZRange[1] != this->ZAxisRange[1]; 946 947 bool boundsChanged = this->LastBounds[0] != bounds[0] || 948 this->LastBounds[1] != bounds[1] || 949 this->LastBounds[2] != bounds[2] || 950 this->LastBounds[3] != bounds[3] || 951 this->LastBounds[4] != bounds[4] || 952 this->LastBounds[5] != bounds[5]; 953 954 if (!(xRangeChanged || yRangeChanged || zRangeChanged) && 955 !(xPropsChanged || yPropsChanged || zPropsChanged || boundsChanged)) 713 956 { 714 957 // no need to re-compute ticksize. … … 716 959 } 717 960 718 int i;719 961 double xExt = bounds[1] - bounds[0]; 720 962 double yExt = bounds[3] - bounds[2]; 721 963 double zExt = bounds[5] - bounds[4]; 722 964 723 if (xRangeChanged )965 if (xRangeChanged || boundsChanged) 724 966 { 725 967 this->AdjustTicksComputeRange(this->XAxes, bounds[0], bounds[1]); 726 968 this->BuildLabels(this->XAxes); 727 } 728 if (yRangeChanged) 969 this->UpdateLabels(this->XAxes, 0); 970 } 971 if (yRangeChanged || boundsChanged) 729 972 { 730 973 this->AdjustTicksComputeRange(this->YAxes, bounds[2], bounds[3]); 731 974 this->BuildLabels(this->YAxes); 732 } 733 if (zRangeChanged) 975 this->UpdateLabels(this->YAxes, 1); 976 } 977 if (zRangeChanged || boundsChanged) 734 978 { 735 979 this->AdjustTicksComputeRange(this->ZAxes, bounds[4], bounds[5]); 736 980 this->BuildLabels(this->ZAxes); 981 this->UpdateLabels(this->ZAxes, 2); 982 } 983 984 // We give information on deltas for the inner grid lines generation 985 for(int i = 0 ; i < NUMBER_OF_ALIGNED_AXIS ; i++) 986 { 987 for(int j = 0 ; j < 3 ; j++) 988 { 989 this->XAxes[i]->SetMajorStart(j,this->MajorStart[j]); 990 this->XAxes[i]->SetDeltaMajor(j,this->DeltaMajor[j]); 991 this->YAxes[i]->SetMajorStart(j,this->MajorStart[j]); 992 this->YAxes[i]->SetDeltaMajor(j,this->DeltaMajor[j]); 993 this->ZAxes[i]->SetMajorStart(j,this->MajorStart[j]); 994 this->ZAxes[i]->SetDeltaMajor(j,this->DeltaMajor[j]); 995 } 737 996 } 738 997 … … 749 1008 this->LastZRange[1] = (this->ZAxisRange[1] == VTK_DOUBLE_MAX ? 750 1009 bounds[5] : this->ZAxisRange[1]); 1010 for(int i=0; i < 6; i++) 1011 { 1012 this->LastBounds[i] = bounds[i]; 1013 } 751 1014 752 1015 double major = 0.02 * (xExt + yExt + zExt) / 3.; 753 1016 double minor = 0.5 * major; 754 for (i = 0; i < 4; i++)1017 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 755 1018 { 756 1019 this->XAxes[i]->SetMajorTickSize(major); … … 792 1055 // /meshtvx/toolkit/plotgrid.c, axlab[x|y]. 793 1056 // 794 // Programmer: Hank Childs795 // Creation: July 11, 2000796 //797 // Modifications:798 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 2001799 // Regardless of individual ranges, if any coord direction has too800 // small/large a range, all will have a scale factor set for scaling their801 // label values, and their titles adjusted accordingly.802 //803 // Kathleen Bonnell, Thu Sep 5 17:32:16 PDT 2002804 // Only use dimensions with range > 0 for determining scale factor.805 //806 // Hank Childs, Fri Sep 27 17:15:07 PDT 2002807 // Account for units.808 //809 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 2003810 // Each axis type now has its own 'mustAdjustValue' and 'lastPow'.811 //812 // Kathleen Bonnell, Tue Dec 16 11:23:31 PST 2003813 // Allow the LabelExponent to be user-settable (autLabelScaling is off).814 // For title use '10e' instead of just 'e' to designate that exponent815 // has been used.816 //817 // Kathleen Bonnell, Tue Jul 20 11:41:45 PDT 2004818 // For title use 'x10^' instead of '10e' to designate that exponent.819 //820 // Brad Whitlock, Fri Jul 23 18:27:30 PST 2004821 // Added support for using user-defined titles for axes.822 //823 1057 // **************************************************************************** 824 825 1058 void vtkRpCubeAxesActor::AdjustValues(const double xRange[2], 826 1059 const double yRange[2], … … 833 1066 if (AutoLabelScaling) 834 1067 { 835 xPow = this->LabelExponent(xRange[0], xRange[1]); 836 yPow = this->LabelExponent(yRange[0], yRange[1]); 837 zPow = this->LabelExponent(zRange[0], zRange[1]); 1068 if (this->AxisLabels[0] == NULL) 1069 { 1070 xPow = this->LabelExponent(xRange[0], xRange[1]); 1071 } 1072 else 1073 { 1074 xPow = 0; 1075 } 1076 if (this->AxisLabels[1] == NULL) 1077 { 1078 yPow = this->LabelExponent(yRange[0], yRange[1]); 1079 } 1080 else 1081 { 1082 yPow = 0; 1083 } 1084 if (this->AxisLabels[2] == NULL) 1085 { 1086 zPow = this->LabelExponent(zRange[0], zRange[1]); 1087 } 1088 else 1089 { 1090 zPow = 0; 1091 } 838 1092 } 839 1093 else … … 994 1248 // bnds The minimum and maximum values in each coordinate direction 995 1249 // (min_x, max_x, min_y, max_y, min_z, max_z). 996 //997 // Programmer: Hank Childs998 // Creation: July 11, 2000999 //1000 // Modifications:1001 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 20011002 // Moved from VisWinAxes3D.1003 //1004 // Kathleen Bonnell, Thu Aug 1 14:05:05 PDT 20021005 // Send lastPos as argument to Digits.1006 //1007 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 20031008 // Adjust the range values using LastXPow, LastYPow, LastZPow.1009 //1010 1250 // **************************************************************************** 1011 1012 1251 void vtkRpCubeAxesActor::AdjustRange(const double bnds[6]) 1013 1252 { 1014 double xrange[2], yrange[2], zrange[2]; 1015 1016 xrange[0] = (this->XAxisRange[0] == VTK_DOUBLE_MAX ? 1017 bnds[0] : this->XAxisRange[0]); 1018 xrange[1] = (this->XAxisRange[1] == VTK_DOUBLE_MAX ? 1019 bnds[1] : this->XAxisRange[1]); 1020 yrange[0] = (this->YAxisRange[0] == VTK_DOUBLE_MAX ? 1021 bnds[2] : this->YAxisRange[0]); 1022 yrange[1] = (this->YAxisRange[1] == VTK_DOUBLE_MAX ? 1023 bnds[3] : this->YAxisRange[1]); 1024 zrange[0] = (this->ZAxisRange[0] == VTK_DOUBLE_MAX ? 1025 bnds[4] : this->ZAxisRange[0]); 1026 zrange[1] = (this->ZAxisRange[1] == VTK_DOUBLE_MAX ? 1027 bnds[5] : this->ZAxisRange[1]); 1028 1029 if (this->LastXPow != 0) 1030 { 1031 xrange[0] /= pow(10., this->LastXPow); 1032 xrange[1] /= pow(10., this->LastXPow); 1033 } 1034 if (this->LastYPow != 0) 1035 { 1036 yrange[0] /= pow(10., this->LastYPow); 1037 yrange[1] /= pow(10., this->LastYPow); 1038 } 1039 if (this->LastZPow != 0) 1040 { 1041 zrange[0] /= pow(10., this->LastZPow); 1042 zrange[1] /= pow(10., this->LastZPow); 1043 } 1044 1045 int xAxisDigits = this->Digits(xrange[0], xrange[1]); 1046 if (xAxisDigits != this->LastXAxisDigits) 1047 { 1048 char format[16]; 1049 sprintf(format, "%%.%df", xAxisDigits); 1050 this->SetXLabelFormat(format); 1051 this->LastXAxisDigits = xAxisDigits; 1052 } 1053 1054 int yAxisDigits = this->Digits(yrange[0], yrange[1]); 1055 if (yAxisDigits != this->LastYAxisDigits) 1056 { 1057 char format[16]; 1058 sprintf(format, "%%.%df", yAxisDigits); 1059 this->SetYLabelFormat(format); 1060 this->LastYAxisDigits = yAxisDigits; 1061 } 1062 1063 int zAxisDigits = this->Digits(zrange[0], zrange[1]); 1064 if (zAxisDigits != this->LastZAxisDigits) 1065 { 1066 char format[16]; 1067 sprintf(format, "%%.%df", zAxisDigits); 1068 this->SetZLabelFormat(format); 1069 this->LastZAxisDigits = zAxisDigits; 1253 if (this->XAutoLabelFormat) 1254 { 1255 double xrange[2]; 1256 1257 xrange[0] = (this->XAxisRange[0] == VTK_DOUBLE_MAX ? 1258 bnds[0] : this->XAxisRange[0]); 1259 xrange[1] = (this->XAxisRange[1] == VTK_DOUBLE_MAX ? 1260 bnds[1] : this->XAxisRange[1]); 1261 if (this->LastXPow != 0) 1262 { 1263 xrange[0] /= pow(10., this->LastXPow); 1264 xrange[1] /= pow(10., this->LastXPow); 1265 } 1266 1267 int xAxisDigits = this->Digits(xrange[0], xrange[1]); 1268 if (xAxisDigits != this->LastXAxisDigits) 1269 { 1270 char format[16]; 1271 sprintf(format, "%%.%df", xAxisDigits); 1272 this->SetXLabelFormat(format); 1273 this->LastXAxisDigits = xAxisDigits; 1274 } 1275 } 1276 if (this->YAutoLabelFormat) 1277 { 1278 double yrange[2]; 1279 1280 yrange[0] = (this->YAxisRange[0] == VTK_DOUBLE_MAX ? 1281 bnds[2] : this->YAxisRange[0]); 1282 yrange[1] = (this->YAxisRange[1] == VTK_DOUBLE_MAX ? 1283 bnds[3] : this->YAxisRange[1]); 1284 1285 if (this->LastYPow != 0) 1286 { 1287 yrange[0] /= pow(10., this->LastYPow); 1288 yrange[1] /= pow(10., this->LastYPow); 1289 } 1290 1291 int yAxisDigits = this->Digits(yrange[0], yrange[1]); 1292 if (yAxisDigits != this->LastYAxisDigits) 1293 { 1294 char format[16]; 1295 sprintf(format, "%%.%df", yAxisDigits); 1296 this->SetYLabelFormat(format); 1297 this->LastYAxisDigits = yAxisDigits; 1298 } 1299 } 1300 if (this->ZAutoLabelFormat) 1301 { 1302 double zrange[2]; 1303 1304 zrange[0] = (this->ZAxisRange[0] == VTK_DOUBLE_MAX ? 1305 bnds[4] : this->ZAxisRange[0]); 1306 zrange[1] = (this->ZAxisRange[1] == VTK_DOUBLE_MAX ? 1307 bnds[5] : this->ZAxisRange[1]); 1308 1309 if (this->LastZPow != 0) 1310 { 1311 zrange[0] /= pow(10., this->LastZPow); 1312 zrange[1] /= pow(10., this->LastZPow); 1313 } 1314 1315 int zAxisDigits = this->Digits(zrange[0], zrange[1]); 1316 if (zAxisDigits != this->LastZAxisDigits) 1317 { 1318 char format[16]; 1319 sprintf(format, "%%.%df", zAxisDigits); 1320 this->SetZLabelFormat(format); 1321 this->LastZAxisDigits = zAxisDigits; 1322 } 1070 1323 } 1071 1324 } … … 1082 1335 // 1083 1336 // Returns: The appropriate number of digits. 1084 //1085 // Programmer: Hank Childs1086 // Creation: July 11, 20001087 //1088 // Modifications:1089 //1090 // Hank Childs, Tue Sep 18 11:58:33 PDT 20011091 // Cast ipow10 to get rid of compiler warning.1092 //1093 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 20011094 // Moved from VisWinAxes3D.1095 //1096 // Kathleen Bonnell, Thu Aug 1 13:44:02 PDT 20021097 // Added lastPow argument, it specifies whether or not scientific notation1098 // is being used on the labels.1099 //1100 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 20031101 // Removed lastPow argment, as the adjustment necessary is now taking1102 // place in AdjustRange.1103 //1104 1337 // **************************************************************************** 1105 1106 1338 int vtkRpCubeAxesActor::Digits(double min, double max ) 1107 1339 { … … 1152 1384 // Note: This code is mostly stolen from old MeshTV code, 1153 1385 // /meshtvx/toolkit/plotgrid.c, axlab_format. 1154 //1155 // Programmer: Hank Childs1156 // Creation: July 11, 20001157 //1158 // Modifications:1159 // Eric Brugger, Tue Sep 18 09:18:17 PDT 20011160 // Change a few static local variables to be non-static to get around a1161 // compiler bug with the MIPSpro 7.2.1.3 compiler.1162 //1163 // Hank Childs, Tue Sep 18 11:58:33 PDT 20011164 // Cast return value to get rid of compiler warning.1165 //1166 // Kathleen Bonnell, Wed Oct 31 07:57:49 PST 20011167 // Moved from VisWinAxes3D.1168 //1169 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 20031170 // Added test for min==max.1171 //1172 1386 // **************************************************************************** 1173 1387 … … 1213 1427 // ************************************************************************* 1214 1428 // Build the axes. Determine coordinates, position, etc. 1215 //1216 // Note: Bulk of code moved here from RenderOpaqueGeomtry.1217 // Early-termination test added.1218 //1219 // Programmer: Kathleen Bonnell1220 // Creation: November 7, 20011221 //1222 // Modifications:1223 // Kathleen Bonnell, Mon Dec 3 16:49:01 PST 20011224 // Compare vtkTimeStamps correctly.1225 //1226 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 20031227 // Added logic to compute and set for each axis the labels and title1228 // scale size.1229 //1230 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 20031231 // Indivdual axes now have their own ForceLabelReset.1232 //1233 1429 // ************************************************************************* 1234 1235 1430 void vtkRpCubeAxesActor::BuildAxes(vtkViewport *viewport) 1236 1431 { 1432 if ((this->GetMTime() < this->BuildTime.GetMTime())) 1433 { 1434 this->AutoScale(viewport); 1435 return; 1436 } 1437 1438 this->SetNonDependentAttributes(); 1439 1440 // Reset range in case of bounds type changed 1441 if(this->LastUseOrientedBounds != this->UseOrientedBounds) 1442 { 1443 this->XAxisRange[0] = this->XAxisRange[1] = VTK_DOUBLE_MAX; 1444 this->YAxisRange[0] = this->YAxisRange[1] = VTK_DOUBLE_MAX; 1445 this->ZAxisRange[0] = this->ZAxisRange[1] = VTK_DOUBLE_MAX; 1446 this->LastUseOrientedBounds = this->UseOrientedBounds; 1447 } 1448 1449 // determine the bounds to use (input, prop, or user-defined) 1237 1450 double bounds[6]; 1238 double pts[8][3]; 1239 int i; 1240 1241 if ((this->GetMTime() < this->BuildTime.GetMTime())) 1242 { 1243 return; 1244 } 1245 1246 this->SetNonDependentAttributes(); 1247 // determine the bounds to use (input, prop, or user-defined) 1248 this->GetBounds(bounds); 1249 1250 // Build the axes (almost always needed so we don't check mtime) 1251 // Transform all points into display coordinates (to determine which closest 1252 // to camera). 1253 this->TransformBounds(viewport, bounds, pts); 1451 if(this->UseOrientedBounds != 0) 1452 { 1453 this->GetOrientedBounds(bounds); 1454 } 1455 else 1456 { 1457 this->GetBounds(bounds); 1458 } 1254 1459 1255 1460 // Setup the axes for plotting 1256 double xCoords[4][6], yCoords[4][6], zCoords[4][6]; 1461 double xCoords[NUMBER_OF_ALIGNED_AXIS][6]; 1462 double yCoords[NUMBER_OF_ALIGNED_AXIS][6]; 1463 double zCoords[NUMBER_OF_ALIGNED_AXIS][6]; 1257 1464 1258 1465 // these arrays are accessed by 'location': mm, mX, XX, or Xm. … … 1260 1467 int mm2[4] = { 0, 1, 1, 0 }; 1261 1468 1262 for (i = 0; i < 4; i++) 1263 { 1264 this->XAxes[i]->SetAxisPosition(i); 1265 xCoords[i][0] = bounds[0]; 1266 xCoords[i][3] = bounds[1]; 1267 xCoords[i][1] = xCoords[i][4] = bounds[2+mm1[i]]; 1268 xCoords[i][2] = xCoords[i][5] = bounds[4+mm2[i]]; 1269 1270 this->YAxes[i]->SetAxisPosition(i); 1271 yCoords[i][0] = yCoords[i][3] = bounds[0+mm1[i]]; 1272 yCoords[i][1] = bounds[2]; 1273 yCoords[i][4] = bounds[3]; 1274 yCoords[i][2] = yCoords[i][5] = bounds[4+mm2[i]]; 1275 1276 this->ZAxes[i]->SetAxisPosition(i); 1277 zCoords[i][0] = zCoords[i][3] = bounds[0+mm1[i]]; 1278 zCoords[i][1] = zCoords[i][4] = bounds[2+mm2[i]]; 1279 zCoords[i][2] = bounds[4]; 1280 zCoords[i][5] = bounds[5]; 1469 // Compute axes end-points 1470 int i; 1471 for (i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 1472 { 1473 if(this->UseAxisOrigin == 0) 1474 { 1475 xCoords[i][0] = bounds[0]*this->AxisBaseForX[0] + bounds[2+mm1[i]]*this->AxisBaseForY[0] + bounds[4+mm2[i]]*this->AxisBaseForZ[0]; 1476 xCoords[i][1] = bounds[0]*this->AxisBaseForX[1] + bounds[2+mm1[i]]*this->AxisBaseForY[1] + bounds[4+mm2[i]]*this->AxisBaseForZ[1]; 1477 xCoords[i][2] = bounds[0]*this->AxisBaseForX[2] + bounds[2+mm1[i]]*this->AxisBaseForY[2] + bounds[4+mm2[i]]*this->AxisBaseForZ[2]; 1478 xCoords[i][3] = bounds[1]*this->AxisBaseForX[0] + bounds[2+mm1[i]]*this->AxisBaseForY[0] + bounds[4+mm2[i]]*this->AxisBaseForZ[0]; 1479 xCoords[i][4] = bounds[1]*this->AxisBaseForX[1] + bounds[2+mm1[i]]*this->AxisBaseForY[1] + bounds[4+mm2[i]]*this->AxisBaseForZ[1]; 1480 xCoords[i][5] = bounds[1]*this->AxisBaseForX[2] + bounds[2+mm1[i]]*this->AxisBaseForY[2] + bounds[4+mm2[i]]*this->AxisBaseForZ[2]; 1481 } 1482 else 1483 { 1484 xCoords[i][0] = bounds[0]*this->AxisBaseForX[0] + this->AxisOrigin[1]*this->AxisBaseForY[0] + this->AxisOrigin[2]*this->AxisBaseForZ[0]; 1485 xCoords[i][1] = bounds[0]*this->AxisBaseForX[1] + this->AxisOrigin[1]*this->AxisBaseForY[1] + this->AxisOrigin[2]*this->AxisBaseForZ[1]; 1486 xCoords[i][2] = bounds[0]*this->AxisBaseForX[2] + this->AxisOrigin[1]*this->AxisBaseForY[2] + this->AxisOrigin[2]*this->AxisBaseForZ[2]; 1487 xCoords[i][3] = bounds[1]*this->AxisBaseForX[0] + this->AxisOrigin[1]*this->AxisBaseForY[0] + this->AxisOrigin[2]*this->AxisBaseForZ[0]; 1488 xCoords[i][4] = bounds[1]*this->AxisBaseForX[1] + this->AxisOrigin[1]*this->AxisBaseForY[1] + this->AxisOrigin[2]*this->AxisBaseForZ[1]; 1489 xCoords[i][5] = bounds[1]*this->AxisBaseForX[2] + this->AxisOrigin[1]*this->AxisBaseForY[2] + this->AxisOrigin[2]*this->AxisBaseForZ[2]; 1490 } 1491 1492 if(this->UseAxisOrigin == 0) 1493 { 1494 yCoords[i][0] = bounds[2]*this->AxisBaseForY[0] + bounds[0+mm1[i]]*this->AxisBaseForX[0] + bounds[4+mm2[i]]*this->AxisBaseForZ[0]; 1495 yCoords[i][1] = bounds[2]*this->AxisBaseForY[1] + bounds[0+mm1[i]]*this->AxisBaseForX[1] + bounds[4+mm2[i]]*this->AxisBaseForZ[1]; 1496 yCoords[i][2] = bounds[2]*this->AxisBaseForY[2] + bounds[0+mm1[i]]*this->AxisBaseForX[2] + bounds[4+mm2[i]]*this->AxisBaseForZ[2]; 1497 yCoords[i][3] = bounds[3]*this->AxisBaseForY[0] + bounds[0+mm1[i]]*this->AxisBaseForX[0] + bounds[4+mm2[i]]*this->AxisBaseForZ[0]; 1498 yCoords[i][4] = bounds[3]*this->AxisBaseForY[1] + bounds[0+mm1[i]]*this->AxisBaseForX[1] + bounds[4+mm2[i]]*this->AxisBaseForZ[1]; 1499 yCoords[i][5] = bounds[3]*this->AxisBaseForY[2] + bounds[0+mm1[i]]*this->AxisBaseForX[2] + bounds[4+mm2[i]]*this->AxisBaseForZ[2]; 1500 } 1501 else 1502 { 1503 yCoords[i][0] = bounds[2]*this->AxisBaseForY[0] + this->AxisOrigin[0]*this->AxisBaseForX[0] + this->AxisOrigin[2]*this->AxisBaseForZ[0]; 1504 yCoords[i][1] = bounds[2]*this->AxisBaseForY[1] + this->AxisOrigin[0]*this->AxisBaseForX[1] + this->AxisOrigin[2]*this->AxisBaseForZ[1]; 1505 yCoords[i][2] = bounds[2]*this->AxisBaseForY[2] + this->AxisOrigin[0]*this->AxisBaseForX[2] + this->AxisOrigin[2]*this->AxisBaseForZ[2]; 1506 yCoords[i][3] = bounds[3]*this->AxisBaseForY[0] + this->AxisOrigin[0]*this->AxisBaseForX[0] + this->AxisOrigin[2]*this->AxisBaseForZ[0]; 1507 yCoords[i][4] = bounds[3]*this->AxisBaseForY[1] + this->AxisOrigin[0]*this->AxisBaseForX[1] + this->AxisOrigin[2]*this->AxisBaseForZ[1]; 1508 yCoords[i][5] = bounds[3]*this->AxisBaseForY[2] + this->AxisOrigin[0]*this->AxisBaseForX[2] + this->AxisOrigin[2]*this->AxisBaseForZ[2]; 1509 } 1510 1511 if(this->UseAxisOrigin == 0) 1512 { 1513 zCoords[i][0] = bounds[4]*this->AxisBaseForZ[0] + bounds[0+mm1[i]]*this->AxisBaseForX[0] + bounds[2+mm2[i]]*this->AxisBaseForY[0]; 1514 zCoords[i][1] = bounds[4]*this->AxisBaseForZ[1] + bounds[0+mm1[i]]*this->AxisBaseForX[1] + bounds[2+mm2[i]]*this->AxisBaseForY[1]; 1515 zCoords[i][2] = bounds[4]*this->AxisBaseForZ[2] + bounds[0+mm1[i]]*this->AxisBaseForX[2] + bounds[2+mm2[i]]*this->AxisBaseForY[2]; 1516 zCoords[i][3] = bounds[5]*this->AxisBaseForZ[0] + bounds[0+mm1[i]]*this->AxisBaseForX[0] + bounds[2+mm2[i]]*this->AxisBaseForY[0]; 1517 zCoords[i][4] = bounds[5]*this->AxisBaseForZ[1] + bounds[0+mm1[i]]*this->AxisBaseForX[1] + bounds[2+mm2[i]]*this->AxisBaseForY[1]; 1518 zCoords[i][5] = bounds[5]*this->AxisBaseForZ[2] + bounds[0+mm1[i]]*this->AxisBaseForX[2] + bounds[2+mm2[i]]*this->AxisBaseForY[2]; 1519 } 1520 else 1521 { 1522 zCoords[i][0] = bounds[4]*this->AxisBaseForZ[0] + this->AxisOrigin[0]*this->AxisBaseForX[0] + this->AxisOrigin[1]*this->AxisBaseForY[0]; 1523 zCoords[i][1] = bounds[4]*this->AxisBaseForZ[1] + this->AxisOrigin[0]*this->AxisBaseForX[1] + this->AxisOrigin[1]*this->AxisBaseForY[1]; 1524 zCoords[i][2] = bounds[4]*this->AxisBaseForZ[2] + this->AxisOrigin[0]*this->AxisBaseForX[2] + this->AxisOrigin[1]*this->AxisBaseForY[2]; 1525 zCoords[i][3] = bounds[5]*this->AxisBaseForZ[0] + this->AxisOrigin[0]*this->AxisBaseForX[0] + this->AxisOrigin[1]*this->AxisBaseForY[0]; 1526 zCoords[i][4] = bounds[5]*this->AxisBaseForZ[1] + this->AxisOrigin[0]*this->AxisBaseForX[1] + this->AxisOrigin[1]*this->AxisBaseForY[1]; 1527 zCoords[i][5] = bounds[5]*this->AxisBaseForZ[2] + this->AxisOrigin[0]*this->AxisBaseForX[2] + this->AxisOrigin[1]*this->AxisBaseForY[2]; 1528 } 1281 1529 } 1282 1530 … … 1290 1538 // be scaled, may change title of each axis, may change label format. 1291 1539 this->AdjustValues(xRange, yRange, zRange); 1292 this->AdjustRange( this->Bounds);1540 this->AdjustRange(bounds); 1293 1541 1294 1542 // Prepare axes for rendering with user-definable options 1295 for (i = 0; i < 4; i++) 1296 { 1543 for (i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 1544 { 1545 this->XAxes[i]->SetAxisOnOrigin(this->UseAxisOrigin); 1297 1546 this->XAxes[i]->GetPoint1Coordinate()->SetValue(xCoords[i][0], 1298 1547 xCoords[i][1], … … 1301 1550 xCoords[i][4], 1302 1551 xCoords[i][5]); 1552 this->YAxes[i]->SetAxisOnOrigin(this->UseAxisOrigin); 1303 1553 this->YAxes[i]->GetPoint1Coordinate()->SetValue(yCoords[i][0], 1304 1554 yCoords[i][1], … … 1307 1557 yCoords[i][4], 1308 1558 yCoords[i][5]); 1559 this->ZAxes[i]->SetAxisOnOrigin(this->UseAxisOrigin); 1309 1560 this->ZAxes[i]->GetPoint1Coordinate()->SetValue(zCoords[i][0], 1310 1561 zCoords[i][1], … … 1335 1586 { 1336 1587 this->BuildLabels(this->XAxes); 1588 this->UpdateLabels(this->XAxes, 0); 1337 1589 } 1338 1590 if (this->ForceYLabelReset) 1339 1591 { 1340 1592 this->BuildLabels(this->YAxes); 1593 this->UpdateLabels(this->YAxes, 1); 1341 1594 } 1342 1595 if (this->ForceZLabelReset) 1343 1596 { 1344 1597 this->BuildLabels(this->ZAxes); 1598 this->UpdateLabels(this->ZAxes, 2); 1345 1599 } 1346 1600 } … … 1370 1624 1371 1625 double target = bLength *0.04; 1372 double labelscale = 1.;1626 this->LabelScale = 1.; 1373 1627 if (maxLabelLength != 0.) 1374 1628 { 1375 labelscale = target / maxLabelLength;1629 this->LabelScale = target / maxLabelLength; 1376 1630 } 1377 1631 target = bLength *0.10; 1378 double titlescale = 1.;1632 this->TitleScale = 1.; 1379 1633 if (maxTitleLength != 0.) 1380 1634 { 1381 t itlescale = target / maxTitleLength;1635 this->TitleScale = target / maxTitleLength; 1382 1636 } 1383 1637 … … 1388 1642 if (XUnits != NULL && XUnits[0] != '\0') 1389 1643 { 1390 titlescale *= 2; 1391 } 1392 1393 for (i = 0; i < 4; i++) 1394 { 1395 this->XAxes[i]->SetLabelScale(labelscale); 1396 this->YAxes[i]->SetLabelScale(labelscale); 1397 this->ZAxes[i]->SetLabelScale(labelscale); 1398 this->XAxes[i]->SetTitleScale(titlescale); 1399 this->YAxes[i]->SetTitleScale(titlescale); 1400 this->ZAxes[i]->SetTitleScale(titlescale); 1401 } 1402 } 1644 this->TitleScale *= 2; 1645 } 1646 1647 for (i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 1648 { 1649 this->XAxes[i]->SetLabelScale(this->LabelScale); 1650 this->YAxes[i]->SetLabelScale(this->LabelScale); 1651 this->ZAxes[i]->SetLabelScale(this->LabelScale); 1652 this->XAxes[i]->SetTitleScale(this->TitleScale); 1653 this->YAxes[i]->SetTitleScale(this->TitleScale); 1654 this->ZAxes[i]->SetTitleScale(this->TitleScale); 1655 } 1656 } 1657 1658 // Scale appropriately. 1659 this->AutoScale(viewport); 1660 1403 1661 this->RenderSomething = 1; 1404 1662 this->BuildTime.Modified(); … … 1410 1668 // not dependent upon viewport changes, and thus do not need to be set 1411 1669 // very often. 1412 //1413 // Programmer: Kathleen Bonnell1414 // Creation: November 7, 20011415 //1416 // Modifications:1417 // Kathleen Bonnell, Thu Oct 3 14:33:15 PDT 20021418 // Disable lighting for the axes by setting the ambient coefficient to 11419 // and the diffuse coeeficient to 0.1420 1670 // ************************************************************************* 1421 1422 1671 void vtkRpCubeAxesActor::SetNonDependentAttributes() 1423 1672 { … … 1425 1674 prop->SetAmbient(1.0); 1426 1675 prop->SetDiffuse(0.0); 1427 for (int i = 0; i < 4; i++) 1428 { 1676 1677 // Make sure our Axis Base is normalized 1678 vtkMath::Normalize(this->AxisBaseForX); 1679 vtkMath::Normalize(this->AxisBaseForY); 1680 vtkMath::Normalize(this->AxisBaseForZ); 1681 1682 // Manage custome grid visibility location if FLY and STATIC axis 1683 int gridLocationBasedOnAxis = (this->GridLineLocation == VTK_GRID_LINES_ALL) 1684 ? VTK_GRID_LINES_ALL : VTK_GRID_LINES_CLOSEST; 1685 1686 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 1687 { 1688 this->XAxes[i]->SetAxisPosition(i); 1689 this->XAxes[i]->SetAxisBaseForX(this->AxisBaseForX); 1690 this->XAxes[i]->SetAxisBaseForY(this->AxisBaseForY); 1691 this->XAxes[i]->SetAxisBaseForZ(this->AxisBaseForZ); 1429 1692 this->XAxes[i]->SetCamera(this->Camera); 1430 1693 this->XAxes[i]->SetProperty(prop); 1694 this->XAxes[i]->SetTitleTextProperty(this->TitleTextProperty[0]); 1695 this->XAxes[i]->SetLabelTextProperty(this->LabelTextProperty[0]); 1696 this->XAxes[i]->SetAxisLinesProperty(this->XAxesLinesProperty); 1697 this->XAxes[i]->SetGridlinesProperty(this->XAxesGridlinesProperty); 1698 this->XAxes[i]->SetGridpolysProperty(this->XAxesGridpolysProperty); 1431 1699 this->XAxes[i]->SetTickLocation(this->TickLocation); 1432 1700 this->XAxes[i]->SetDrawGridlines(this->DrawXGridlines); 1701 this->XAxes[i]->SetDrawGridlinesLocation(gridLocationBasedOnAxis); 1702 this->XAxes[i]->SetDrawInnerGridlines(this->DrawXInnerGridlines); 1703 this->XAxes[i]->SetDrawGridpolys(this->DrawXGridpolys); 1433 1704 this->XAxes[i]->SetBounds(this->Bounds); 1434 this->XAxes[i]-> AxisVisibilityOn();1705 this->XAxes[i]->SetAxisVisibility(this->XAxisVisibility); 1435 1706 this->XAxes[i]->SetLabelVisibility(this->XAxisLabelVisibility); 1436 1707 this->XAxes[i]->SetTitleVisibility(this->XAxisLabelVisibility); … … 1438 1709 this->XAxes[i]->SetMinorTicksVisible(this->XAxisMinorTickVisibility); 1439 1710 1711 this->YAxes[i]->SetAxisPosition(i); 1712 this->YAxes[i]->SetAxisBaseForX(this->AxisBaseForX); 1713 this->YAxes[i]->SetAxisBaseForY(this->AxisBaseForY); 1714 this->YAxes[i]->SetAxisBaseForZ(this->AxisBaseForZ); 1440 1715 this->YAxes[i]->SetCamera(this->Camera); 1441 1716 this->YAxes[i]->SetProperty(prop); 1717 this->YAxes[i]->SetTitleTextProperty(this->TitleTextProperty[1]); 1718 this->YAxes[i]->SetLabelTextProperty(this->LabelTextProperty[1]); 1719 this->YAxes[i]->SetAxisLinesProperty(this->YAxesLinesProperty); 1720 this->YAxes[i]->SetGridlinesProperty(this->YAxesGridlinesProperty); 1721 this->YAxes[i]->SetGridpolysProperty(this->YAxesGridpolysProperty); 1442 1722 this->YAxes[i]->SetTickLocation(this->TickLocation); 1443 1723 this->YAxes[i]->SetDrawGridlines(this->DrawYGridlines); 1724 this->YAxes[i]->SetDrawGridlinesLocation(gridLocationBasedOnAxis); 1725 this->YAxes[i]->SetDrawInnerGridlines(this->DrawYInnerGridlines); 1726 this->YAxes[i]->SetDrawGridpolys(this->DrawYGridpolys); 1444 1727 this->YAxes[i]->SetBounds(this->Bounds); 1445 this->YAxes[i]-> AxisVisibilityOn();1728 this->YAxes[i]->SetAxisVisibility(this->YAxisVisibility); 1446 1729 this->YAxes[i]->SetLabelVisibility(this->YAxisLabelVisibility); 1447 1730 this->YAxes[i]->SetTitleVisibility(this->YAxisLabelVisibility); … … 1449 1732 this->YAxes[i]->SetMinorTicksVisible(this->YAxisMinorTickVisibility); 1450 1733 1734 this->ZAxes[i]->SetAxisPosition(i); 1735 this->ZAxes[i]->SetAxisBaseForX(this->AxisBaseForX); 1736 this->ZAxes[i]->SetAxisBaseForY(this->AxisBaseForY); 1737 this->ZAxes[i]->SetAxisBaseForZ(this->AxisBaseForZ); 1451 1738 this->ZAxes[i]->SetCamera(this->Camera); 1452 1739 this->ZAxes[i]->SetProperty(prop); 1740 this->ZAxes[i]->SetTitleTextProperty(this->TitleTextProperty[2]); 1741 this->ZAxes[i]->SetLabelTextProperty(this->LabelTextProperty[2]); 1742 this->ZAxes[i]->SetAxisLinesProperty(this->ZAxesLinesProperty); 1743 this->ZAxes[i]->SetGridlinesProperty(this->ZAxesGridlinesProperty); 1744 this->ZAxes[i]->SetGridpolysProperty(this->ZAxesGridpolysProperty); 1453 1745 this->ZAxes[i]->SetTickLocation(this->TickLocation); 1454 1746 this->ZAxes[i]->SetDrawGridlines(this->DrawZGridlines); 1747 this->ZAxes[i]->SetDrawGridlinesLocation(gridLocationBasedOnAxis); 1748 this->ZAxes[i]->SetDrawInnerGridlines(this->DrawZInnerGridlines); 1749 this->ZAxes[i]->SetDrawGridpolys(this->DrawZGridpolys); 1455 1750 this->ZAxes[i]->SetBounds(this->Bounds); 1456 this->ZAxes[i]-> AxisVisibilityOn();1751 this->ZAxes[i]->SetAxisVisibility(this->ZAxisVisibility); 1457 1752 this->ZAxes[i]->SetLabelVisibility(this->ZAxisLabelVisibility); 1458 1753 this->ZAxes[i]->SetTitleVisibility(this->ZAxisLabelVisibility); … … 1481 1776 // be rendered. For STATIC FlyMode, all axes are rendered. For other 1482 1777 // FlyModes, either 1 or 2 per coordinate direction are rendered. 1483 //1484 // Programmer: Kathleen Bonnell1485 // Creation: November 7, 20011486 //1487 // Modifications:1488 // Kathleen Bonnell, Thu Jul 18 10:33:07 PDT 20021489 // Ensure that primary axes visibility flags are set properly, and1490 // that secondary axes visibility flags are turned off.1491 1778 // ************************************************************************* 1492 1779 void vtkRpCubeAxesActor::DetermineRenderAxes(vtkViewport *viewport) 1493 1780 { 1494 double bounds[6], slope = 0.0, minSlope, num, den; 1495 double pts[8][3], d2, d2Min, min, max; 1496 int i = 0, idx = 0; 1497 int xIdx = 0, yIdx = 0, zIdx = 0, zIdx2 = 0; 1498 int xAxes = 0, yAxes = 0, zAxes = 0, xloc = 0, yloc = 0, zloc = 0; 1499 1500 if (this->FlyMode == VTK_FLY_STATIC_EDGES) 1501 { 1502 for (i = 0; i < 4; i++) 1503 { 1504 this->RenderAxesX[i] = i; 1505 this->RenderAxesY[i] = i; 1506 this->RenderAxesZ[i] = i; 1507 } 1508 this->NumberOfAxesX = this->NumberOfAxesY = this->NumberOfAxesZ = 4; 1781 double bounds[6]; 1782 double pts[8][3]; 1783 int i = 0, closestIdx = -1, furtherstIdx = -1; 1784 int xloc = 0, yloc = 0, zloc = 0; 1785 1786 // Make sure we start with only one axis by default, then we might extend it 1787 this->NumberOfAxesX = this->NumberOfAxesY = this->NumberOfAxesZ = 1; 1788 1789 // Compute relevant axis points only if a axis/grid visibility change based 1790 // on the viewpoint 1791 if( !( this->GridLineLocation == VTK_GRID_LINES_ALL 1792 && ( this->FlyMode == VTK_FLY_STATIC_EDGES 1793 || this->FlyMode == VTK_FLY_STATIC_TRIAD))) 1794 { 1795 // determine the bounds to use (input, prop, or user-defined) 1796 this->GetBounds(bounds); 1797 this->TransformBounds(viewport, bounds, pts); 1798 } 1799 1800 // Check closest point if needed 1801 if( this->GridLineLocation == VTK_GRID_LINES_CLOSEST 1802 || this->FlyMode == VTK_FLY_CLOSEST_TRIAD ) 1803 { 1804 closestIdx = this->FindClosestAxisIndex(pts); 1805 } 1806 1807 // Check furtherst point if needed 1808 if( this->GridLineLocation == VTK_GRID_LINES_FURTHEST 1809 || this->FlyMode == VTK_FLY_FURTHEST_TRIAD ) 1810 { 1811 furtherstIdx = this->FindFurtherstAxisIndex(pts); 1812 } 1813 1814 // Manage fast static axis visibility 1815 if (this->FlyMode == VTK_FLY_STATIC_EDGES || this->FlyMode == VTK_FLY_STATIC_TRIAD) 1816 { 1817 if(this->FlyMode == VTK_FLY_STATIC_EDGES) 1818 { 1819 this->NumberOfAxesX = this->NumberOfAxesY = this->NumberOfAxesZ 1820 = NUMBER_OF_ALIGNED_AXIS; 1821 } 1822 1823 for (i = 0; i < this->NumberOfAxesX; i++) 1824 { 1825 this->RenderAxesX[i] = this->RenderAxesY[i] = this->RenderAxesZ[i] = i; 1826 } 1827 1828 this->UpdateGridLineVisibility( 1829 (this->GridLineLocation == VTK_GRID_LINES_CLOSEST) 1830 ? closestIdx : furtherstIdx); 1509 1831 return; 1510 1832 } 1511 if (this->FlyMode == VTK_FLY_STATIC_TRIAD) 1512 { 1513 this->RenderAxesX[0] = 0; 1514 this->RenderAxesY[0] = 0; 1515 this->RenderAxesZ[0] = 0; 1516 if (this->DrawXGridlines && 0) 1517 { 1518 this->RenderAxesX[1] = 2; 1519 this->NumberOfAxesX = 2; 1520 this->XAxes[RenderAxesX[1]]->SetTickVisibility(0); 1521 this->XAxes[RenderAxesX[1]]->SetLabelVisibility(0); 1522 this->XAxes[RenderAxesX[1]]->SetTitleVisibility(0); 1523 this->XAxes[RenderAxesX[1]]->SetMinorTicksVisible(0); 1524 } 1525 else 1526 { 1527 this->NumberOfAxesX = 1; 1528 } 1529 if (this->DrawYGridlines && 0) 1530 { 1531 this->RenderAxesY[1] = 2; 1532 this->NumberOfAxesY = 2; 1533 this->YAxes[RenderAxesY[1]]->SetTickVisibility(0); 1534 this->YAxes[RenderAxesY[1]]->SetLabelVisibility(0); 1535 this->YAxes[RenderAxesY[1]]->SetTitleVisibility(0); 1536 this->YAxes[RenderAxesY[1]]->SetMinorTicksVisible(0); 1537 } 1538 else 1539 { 1540 this->NumberOfAxesY = 1; 1541 } 1542 if (this->DrawZGridlines && 0) 1543 { 1544 this->RenderAxesZ[1] = 2; 1545 this->NumberOfAxesZ = 2; 1546 this->ZAxes[RenderAxesZ[1]]->SetTickVisibility(0); 1547 this->ZAxes[RenderAxesZ[1]]->SetLabelVisibility(0); 1548 this->ZAxes[RenderAxesZ[1]]->SetTitleVisibility(0); 1549 this->ZAxes[RenderAxesZ[1]]->SetMinorTicksVisible(0); 1550 } 1551 else 1552 { 1553 this->NumberOfAxesZ = 1; 1554 } 1555 return; 1556 } 1557 1558 // determine the bounds to use (input, prop, or user-defined) 1559 this->GetBounds(bounds); 1560 this->TransformBounds(viewport, bounds, pts); 1833 1561 1834 1562 1835 // Take into account the inertia. Process only so often. … … 1565 1838 if (this->FlyMode == VTK_FLY_CLOSEST_TRIAD) 1566 1839 { 1567 // Loop over points and find the closest point to the camera 1568 min = VTK_LARGE_FLOAT; 1569 for (i=0; i < 8; i++) 1570 { 1571 if (pts[i][2] < min) 1572 { 1573 idx = i; 1574 min = pts[i][2]; 1575 } 1576 } 1577 xloc = vtkRpCubeAxesActorTriads[idx][0]; 1578 yloc = vtkRpCubeAxesActorTriads[idx][1]; 1579 zloc = vtkRpCubeAxesActorTriads[idx][2]; 1580 1581 } // closest-triad 1840 xloc = vtkRpCubeAxesActorTriads[closestIdx][0]; 1841 yloc = vtkRpCubeAxesActorTriads[closestIdx][1]; 1842 zloc = vtkRpCubeAxesActorTriads[closestIdx][2]; 1843 } 1582 1844 else if (this->FlyMode == VTK_FLY_FURTHEST_TRIAD) 1583 1845 { 1584 // Loop over points and find the furthest point from the camera 1585 max = -VTK_LARGE_FLOAT; 1586 for (i=0; i < 8; i++) 1587 { 1588 if (pts[i][2] > max) 1589 { 1590 idx = i; 1591 max = pts[i][2]; 1592 } 1593 } 1594 xloc = vtkRpCubeAxesActorTriads[idx][0]; 1595 yloc = vtkRpCubeAxesActorTriads[idx][1]; 1596 zloc = vtkRpCubeAxesActorTriads[idx][2]; 1597 1598 } // furthest-triad 1599 else 1600 { 1601 double e1[3], e2[3], e3[3]; 1602 1603 // Find distance to origin 1604 d2Min = VTK_LARGE_FLOAT; 1605 for (i=0; i < 8; i++) 1606 { 1607 d2 = pts[i][0]*pts[i][0] + pts[i][1]*pts[i][1]; 1608 if (d2 < d2Min) 1609 { 1610 d2Min = d2; 1611 idx = i; 1612 } 1613 } 1614 1615 // find minimum slope point connected to closest point and on 1616 // right side (in projected coordinates). This is the first edge. 1617 minSlope = VTK_LARGE_FLOAT; 1618 for (xIdx=0, i=0; i<3; i++) 1619 { 1620 num = (pts[vtkRpCubeAxesActorConn[idx][i]][1] - pts[idx][1]); 1621 den = (pts[vtkRpCubeAxesActorConn[idx][i]][0] - pts[idx][0]); 1622 if (den != 0.0) 1623 { 1624 slope = num / den; 1625 } 1626 if (slope < minSlope && den > 0) 1627 { 1628 xIdx = vtkRpCubeAxesActorConn[idx][i]; 1629 yIdx = vtkRpCubeAxesActorConn[idx][(i+1)%3]; 1630 zIdx = vtkRpCubeAxesActorConn[idx][(i+2)%3]; 1631 xAxes = i; 1632 minSlope = slope; 1633 } 1634 } 1635 1636 // find edge (connected to closest point) on opposite side 1637 for ( i=0; i<3; i++) 1638 { 1639 e1[i] = (pts[xIdx][i] - pts[idx][i]); 1640 e2[i] = (pts[yIdx][i] - pts[idx][i]); 1641 e3[i] = (pts[zIdx][i] - pts[idx][i]); 1642 } 1643 vtkMath::Normalize(e1); 1644 vtkMath::Normalize(e2); 1645 vtkMath::Normalize(e3); 1646 1647 if (vtkMath::Dot(e1,e2) < vtkMath::Dot(e1,e3)) 1648 { 1649 yAxes = (xAxes + 1) % 3; 1650 } 1651 else 1652 { 1653 yIdx = zIdx; 1654 yAxes = (xAxes + 2) % 3; 1655 } 1656 1657 // Find the final point by determining which global x-y-z axes have not 1658 // been represented, and then determine the point closest to the viewer. 1659 zAxes = (xAxes != 0 && yAxes != 0 ? 0 : 1660 (xAxes != 1 && yAxes != 1 ? 1 : 2)); 1661 if (pts[vtkRpCubeAxesActorConn[xIdx][zAxes]][2] < 1662 pts[vtkRpCubeAxesActorConn[yIdx][zAxes]][2]) 1663 { 1664 zIdx = xIdx; 1665 zIdx2 = vtkRpCubeAxesActorConn[xIdx][zAxes]; 1666 } 1667 else 1668 { 1669 zIdx = yIdx; 1670 zIdx2 = vtkRpCubeAxesActorConn[yIdx][zAxes]; 1671 } 1672 1673 int mini = (idx < xIdx ? idx : xIdx); 1674 switch (xAxes) 1675 { 1676 case 0: 1677 xloc = vtkRpCubeAxesActorTriads[mini][0]; 1678 break; 1679 case 1: 1680 yloc = vtkRpCubeAxesActorTriads[mini][1]; 1681 break; 1682 case 2: 1683 zloc = vtkRpCubeAxesActorTriads[mini][2]; 1684 break; 1685 } 1686 mini = (idx < yIdx ? idx : yIdx); 1687 switch (yAxes) 1688 { 1689 case 0: 1690 xloc = vtkRpCubeAxesActorTriads[mini][0]; 1691 break; 1692 case 1: 1693 yloc =vtkRpCubeAxesActorTriads[mini][1]; 1694 break; 1695 case 2: 1696 zloc = vtkRpCubeAxesActorTriads[mini][2]; 1697 break; 1698 } 1699 mini = (zIdx < zIdx2 ? zIdx : zIdx2); 1700 switch (zAxes) 1701 { 1702 case 0: 1703 xloc = vtkRpCubeAxesActorTriads[mini][0]; 1704 break; 1705 case 1: 1706 yloc = vtkRpCubeAxesActorTriads[mini][1]; 1707 break; 1708 case 2: 1709 zloc = vtkRpCubeAxesActorTriads[mini][2]; 1710 break; 1711 } 1712 1713 }//else boundary edges fly mode 1846 xloc = vtkRpCubeAxesActorTriads[furtherstIdx][0]; 1847 yloc = vtkRpCubeAxesActorTriads[furtherstIdx][1]; 1848 zloc = vtkRpCubeAxesActorTriads[furtherstIdx][2]; 1849 } 1850 else // else boundary edges fly mode 1851 { 1852 this->FindBoundaryEdge(xloc, yloc, zloc, pts); 1853 } 1714 1854 1715 1855 this->InertiaLocs[0] = xloc; 1716 1856 this->InertiaLocs[1] = yloc; 1717 1857 this->InertiaLocs[2] = zloc; 1718 } // inertia1858 } // inertia 1719 1859 else 1720 1860 { 1721 // don't change anything, use locations from last render1861 // Do not change anything, use locations from last render 1722 1862 xloc = this->InertiaLocs[0]; 1723 1863 yloc = this->InertiaLocs[1]; … … 1725 1865 } 1726 1866 1727 this->RenderAxesX[0] = xloc % 4; 1728 if (this->DrawXGridlines && 0) 1729 { 1730 this->RenderAxesX[1] = (xloc + 2) % 4; 1731 this->NumberOfAxesX = 2; 1732 this->XAxes[RenderAxesX[1]]->SetTickVisibility(0); 1733 this->XAxes[RenderAxesX[1]]->SetLabelVisibility(0); 1734 this->XAxes[RenderAxesX[1]]->SetTitleVisibility(0); 1735 this->XAxes[RenderAxesX[1]]->SetMinorTicksVisible(0); 1736 } 1737 else 1738 { 1739 this->NumberOfAxesX = 1; 1740 } 1741 1742 this->RenderAxesY[0] = yloc % 4; 1743 if (this->DrawYGridlines && 0) 1744 { 1745 this->RenderAxesY[1] = (yloc + 2) % 4; 1746 this->NumberOfAxesY = 2; 1747 this->YAxes[RenderAxesY[1]]->SetTickVisibility(0); 1748 this->YAxes[RenderAxesY[1]]->SetLabelVisibility(0); 1749 this->YAxes[RenderAxesY[1]]->SetTitleVisibility(0); 1750 this->YAxes[RenderAxesY[1]]->SetMinorTicksVisible(0); 1751 } 1752 else 1753 { 1754 this->NumberOfAxesY = 1; 1755 } 1756 1757 this->RenderAxesZ[0] = zloc % 4; 1758 if (this->DrawZGridlines && 0) 1759 { 1760 this->RenderAxesZ[1] = (zloc + 2) % 4; 1761 this->NumberOfAxesZ = 2; 1762 this->ZAxes[RenderAxesZ[1]]->SetTickVisibility(0); 1763 this->ZAxes[RenderAxesZ[1]]->SetLabelVisibility(0); 1764 this->ZAxes[RenderAxesZ[1]]->SetTitleVisibility(0); 1765 this->ZAxes[RenderAxesZ[1]]->SetMinorTicksVisible(0); 1766 } 1767 else 1768 { 1769 this->NumberOfAxesZ = 1; 1770 } 1771 // 1772 // Make sure that the primary axis visibility flags are set correctly. 1773 // 1774 this->XAxes[RenderAxesX[0]]->SetLabelVisibility(this->XAxisLabelVisibility); 1775 this->XAxes[RenderAxesX[0]]->SetTitleVisibility(this->XAxisLabelVisibility); 1776 this->XAxes[RenderAxesX[0]]->SetTickVisibility(this->XAxisTickVisibility); 1777 this->XAxes[RenderAxesX[0]]->SetMinorTicksVisible( 1778 this->XAxisMinorTickVisibility); 1779 this->XAxes[RenderAxesX[0]]->SetDrawGridlines(this->DrawXGridlines); 1780 1781 this->YAxes[RenderAxesY[0]]->SetLabelVisibility(this->YAxisLabelVisibility); 1782 this->YAxes[RenderAxesY[0]]->SetTitleVisibility(this->YAxisLabelVisibility); 1783 this->YAxes[RenderAxesY[0]]->SetTickVisibility(this->YAxisTickVisibility); 1784 this->YAxes[RenderAxesY[0]]->SetMinorTicksVisible( 1785 this->YAxisMinorTickVisibility); 1786 this->YAxes[RenderAxesY[0]]->SetDrawGridlines(this->DrawYGridlines); 1787 1788 this->ZAxes[RenderAxesZ[0]]->SetLabelVisibility(this->ZAxisLabelVisibility); 1789 this->ZAxes[RenderAxesZ[0]]->SetTitleVisibility(this->ZAxisLabelVisibility); 1790 this->ZAxes[RenderAxesZ[0]]->SetTickVisibility(this->ZAxisTickVisibility); 1791 this->ZAxes[RenderAxesZ[0]]->SetMinorTicksVisible( 1792 this->ZAxisMinorTickVisibility); 1793 this->ZAxes[RenderAxesZ[0]]->SetDrawGridlines(this->DrawZGridlines); 1794 } 1795 1867 // Set axes to be rendered 1868 this->RenderAxesX[0] = xloc % NUMBER_OF_ALIGNED_AXIS; 1869 this->RenderAxesY[0] = yloc % NUMBER_OF_ALIGNED_AXIS; 1870 this->RenderAxesZ[0] = zloc % NUMBER_OF_ALIGNED_AXIS; 1871 1872 // Manage grid visibility (can increase the number of axis to render) 1873 this->UpdateGridLineVisibility( 1874 (this->GridLineLocation == VTK_GRID_LINES_CLOSEST) 1875 ? closestIdx : furtherstIdx); 1876 } 1877 1878 // -------------------------------------------------------------------------- 1796 1879 double vtkRpCubeAxesActor::MaxOf(double a, double b) 1797 1880 { … … 1799 1882 } 1800 1883 1884 // -------------------------------------------------------------------------- 1801 1885 double vtkRpCubeAxesActor::MaxOf(double a, double b, double c, double d) 1802 1886 { … … 1804 1888 } 1805 1889 1890 // -------------------------------------------------------------------------- 1806 1891 inline double vtkRpCubeAxesActor::FFix(double value) 1807 1892 { … … 1810 1895 } 1811 1896 1897 inline int vtkRpCubeAxesActor::FRound(double value) 1898 { 1899 return value <= 0.5 ? static_cast<int>(this->FFix(value)) : static_cast<int>(this->FFix(value) + 1); 1900 } 1901 1902 inline int vtkRpCubeAxesActor::GetNumTicks(double range, double fxt) 1903 { 1904 // Find the number of integral points in the interval. 1905 double fnt = range/fxt; 1906 fnt = this->FFix(fnt); 1907 return this->FRound(fnt); 1908 } 1909 1910 // -------------------------------------------------------------------------- 1812 1911 inline double vtkRpCubeAxesActor::FSign(double value, double sign) 1813 1912 { … … 1828 1927 // Arguments: 1829 1928 // inRange The range for this axis. 1830 //1831 // Note: The bulk of this method was taken from vtkHankAxisActor.C1832 // The original method was reduced to serve the purposes1833 // of this class.1834 //1835 // Programmer: Kathleen Bonnell1836 // Creation: 29 August, 20011837 //1838 // Modifications:1839 // Kathleen Bonnell, Fri Jul 25 14:37:32 PDT 20031840 // Moved from vtkRpAxisActor. Added calls to set inividual axis'1841 // MajorStart, MinorStart, deltaMajor, deltaMinor.1842 //1843 1929 // ******************************************************************* 1844 1930 1845 void vtkRpCubeAxesActor::AdjustTicksComputeRange(vtkRpAxisActor *axes[ 4],1931 void vtkRpCubeAxesActor::AdjustTicksComputeRange(vtkRpAxisActor *axes[NUMBER_OF_ALIGNED_AXIS], 1846 1932 double boundsMin, double boundsMax) 1847 1933 { 1848 1934 double sortedRange[2], range; 1849 double fxt , fnt, frac;1935 double fxt; 1850 1936 double div, major, minor; 1851 1937 double majorStart, minorStart; 1852 1938 int numTicks; 1853 1939 double *inRange = axes[0]->GetRange(); 1940 vtkStringArray* customizedLabels = NULL; 1854 1941 1855 1942 sortedRange[0] = inRange[0] < inRange[1] ? inRange[0] : inRange[1]; … … 1876 1963 fxt = pow(10., this->FFix(pow10)); 1877 1964 1878 // Find the number of integral points in the interval. 1879 fnt = range/fxt; 1880 fnt = this->FFix(fnt); 1881 frac = fnt; 1882 numTicks = frac <= 0.5 ? static_cast<int>(this->FFix(fnt)) : static_cast<int>(this->FFix(fnt) + 1); 1965 numTicks = this->GetNumTicks(range, fxt); 1883 1966 1884 1967 div = 1.; … … 1899 1982 major /= div; 1900 1983 } 1901 minor = (fxt/div) / 10.; 1902 1903 // Figure out the first major and minor tick locations, relative to the 1984 1985 int axis = 0; 1986 switch(axes[0]->GetAxisType()) 1987 { 1988 case VTK_AXIS_TYPE_X: 1989 axis = 0; 1990 break; 1991 case VTK_AXIS_TYPE_Y: 1992 axis = 1; 1993 break; 1994 case VTK_AXIS_TYPE_Z: 1995 axis = 2; 1996 break; 1997 } 1998 customizedLabels = this->AxisLabels[axis]; 1999 2000 if (customizedLabels == NULL) 2001 { 2002 // Figure out the first major tick locations, relative to the 2003 // start of the axis. 2004 if (sortedRange[0] <= 0.) 2005 { 2006 majorStart = major*(this->FFix(sortedRange[0]*(1./major)) + 0.); 2007 } 2008 else 2009 { 2010 majorStart = major*(this->FFix(sortedRange[0]*(1./major)) + 1.); 2011 } 2012 } 2013 else 2014 { 2015 // If we have custom labels, they are supposed to be uniformly distributed 2016 // inside the values range. 2017 majorStart = sortedRange[0]; 2018 numTicks = this->GetNumTicks(range, major); 2019 int labelsCount = customizedLabels->GetNumberOfValues(); 2020 if (numTicks > labelsCount) 2021 { 2022 major = range / (labelsCount - 1.); 2023 } 2024 } 2025 2026 minor = major / 10.; 2027 // Figure out the first minor tick locations, relative to the 1904 2028 // start of the axis. 1905 2029 if (sortedRange[0] <= 0.) 1906 2030 { 1907 majorStart = major*(this->FFix(sortedRange[0]*(1./major)) + 0.);1908 2031 minorStart = minor*(this->FFix(sortedRange[0]*(1./minor)) + 0.); 1909 2032 } 1910 2033 else 1911 2034 { 1912 majorStart = major*(this->FFix(sortedRange[0]*(1./major)) + 1.);1913 2035 minorStart = minor*(this->FFix(sortedRange[0]*(1./minor)) + 1.); 1914 2036 } 1915 2037 1916 for (int i = 0; i < 4; i++)2038 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 1917 2039 { 1918 2040 axes[i]->SetMinorRangeStart(minorStart); … … 1931 2053 major *= scale; 1932 2054 1933 for (int i = 0; i < 4; i++) 2055 // Set major start and delta for the corresponding cube axis 2056 switch(axes[0]->GetAxisType()) 2057 { 2058 case VTK_AXIS_TYPE_X: 2059 this->MajorStart[0] = majorStart; 2060 this->DeltaMajor[0] = major; 2061 break; 2062 case VTK_AXIS_TYPE_Y: 2063 this->MajorStart[1] = majorStart; 2064 this->DeltaMajor[1] = major; 2065 break; 2066 case VTK_AXIS_TYPE_Z: 2067 this->MajorStart[2] = majorStart; 2068 this->DeltaMajor[2] = major; 2069 break; 2070 } 2071 2072 // Set major and minor starts and deltas for all underlying axes 2073 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 1934 2074 { 1935 2075 axes[i]->SetMinorStart(minorStart); 1936 axes[i]->SetMajorStart( majorStart);2076 axes[i]->SetMajorStart(axes[0]->GetAxisType(), majorStart); 1937 2077 1938 2078 axes[i]->SetDeltaMinor(minor); 1939 axes[i]->SetDeltaMajor(major); 1940 } 2079 axes[i]->SetDeltaMajor(axes[0]->GetAxisType(), major); 2080 } 2081 } 2082 2083 // **************************************************************** 2084 void vtkRpCubeAxesActor::AutoScale(vtkViewport *viewport) 2085 { 2086 // Current implementation only for perspective projections. 2087 this->AutoScale(viewport, this->XAxes); 2088 this->AutoScale(viewport, this->YAxes); 2089 this->AutoScale(viewport, this->ZAxes); 2090 } 2091 2092 // **************************************************************** 2093 void vtkRpCubeAxesActor::AutoScale(vtkViewport *viewport, vtkRpAxisActor *axis[NUMBER_OF_ALIGNED_AXIS]) 2094 { 2095 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; ++i) 2096 { 2097 double newTitleScale 2098 = this->AutoScale(viewport, 2099 this->ScreenSize, 2100 axis[i]->GetTitleActor()->GetPosition()); 2101 2102 axis[i]->SetTitleScale(newTitleScale); 2103 2104 // Now labels. 2105 vtkRpAxisFollower** labelActors = axis[i]->GetLabelActors(); 2106 2107 for(int j = 0; j < axis[i]->GetNumberOfLabelsBuilt(); ++j) 2108 { 2109 double newLabelScale 2110 = this->AutoScale(viewport, 2111 this->ScreenSize, 2112 labelActors[j]->GetPosition()); 2113 2114 labelActors[j]->SetScale(newLabelScale); 2115 } 2116 } 2117 } 2118 2119 // **************************************************************** 2120 double vtkRpCubeAxesActor::AutoScale(vtkViewport *viewport, double screenSize, 2121 double position[3]) 2122 { 2123 double factor = 1; 2124 if (viewport->GetSize()[1] > 0) 2125 { 2126 factor = 2.0 * screenSize 2127 * tan(vtkMath::RadiansFromDegrees(this->Camera->GetViewAngle()/2.0)) 2128 / viewport->GetSize()[1]; 2129 } 2130 2131 double dist = sqrt( 2132 vtkMath::Distance2BetweenPoints(position, 2133 this->Camera->GetPosition())); 2134 double newScale = factor * dist; 2135 2136 return newScale; 1941 2137 } 1942 2138 1943 2139 // **************************************************************** 1944 2140 // Determine what the labels should be and set them in each axis. 1945 //1946 // Modification:1947 // Kathleen Bonnell, Wed Aug 6 13:59:15 PDT 20031948 // Each axis type now has it's own 'mustAdjustValue' and 'pow'.1949 //1950 // Kathleen Bonnell, Tue Jul 20 14:29:10 PDT 20041951 // Ensure that '-0.0' is never used as a label.1952 //1953 // Eric Brugger, Mon Jul 26 16:09:26 PDT 20041954 // Correct a bug with a misplaced closing parenthesis.1955 //1956 2141 // **************************************************************** 1957 1958 void vtkRpCubeAxesActor::BuildLabels(vtkRpAxisActor *axes[4]) 2142 void vtkRpCubeAxesActor::BuildLabels(vtkRpAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]) 1959 2143 { 1960 2144 char label[64]; 1961 int i, labelCount = 0; 1962 double deltaMajor = axes[0]->GetDeltaMajor(); 1963 const double *p2 = axes[0]->GetPoint2Coordinate()->GetValue(); 1964 double *range = axes[0]->GetRange(); 1965 double lastVal = 0, val = axes[0]->GetMajorStart(); 2145 int labelCount = 0; 2146 double deltaMajor = axes[0]->GetDeltaMajor(axes[0]->GetAxisType()); 2147 double val = axes[0]->GetMajorRangeStart(); 2148 double p2[3], p1[3]; 2149 axes[0]->GetPoint1Coordinate()->GetValue(p1); 2150 axes[0]->GetPoint2Coordinate()->GetValue(p2); 2151 double *range = axes[0]->GetRange(); 2152 double axis[3] = { p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2] }; 2153 double axisLength = vtkMath::Norm(axis); 1966 2154 double extents = range[1] - range[0]; 2155 double rangeScale = axisLength / extents; 2156 double labelCountAsDouble = (axisLength - (val-range[0])*rangeScale) / deltaMajor; 1967 2157 bool mustAdjustValue = 0; 1968 2158 int lastPow = 0; 2159 int axisIndex = 0; 2160 vtkStringArray* customizedLabels = NULL; 1969 2161 1970 2162 vtkStringArray *labels = vtkStringArray::New(); … … 1973 2165 { 1974 2166 case VTK_AXIS_TYPE_X: 1975 lastVal = p2[0];2167 axisIndex = 0; 1976 2168 format = this->XLabelFormat; 1977 2169 mustAdjustValue = this->MustAdjustXValue; … … 1979 2171 break; 1980 2172 case VTK_AXIS_TYPE_Y: 1981 lastVal = p2[1];2173 axisIndex = 1; 1982 2174 format = this->YLabelFormat; 1983 2175 mustAdjustValue = this->MustAdjustYValue; … … 1985 2177 break; 1986 2178 case VTK_AXIS_TYPE_Z: 1987 lastVal = p2[2];2179 axisIndex = 2; 1988 2180 format = this->ZLabelFormat; 1989 2181 mustAdjustValue = this->MustAdjustZValue; … … 1991 2183 break; 1992 2184 } 1993 2185 customizedLabels = this->AxisLabels[axisIndex]; 1994 2186 // figure out how many labels we need: 1995 while (val <= lastVal && labelCount < VTK_MAX_LABELS) 1996 { 1997 labelCount++; 1998 val += deltaMajor; 2187 if(extents == 0 || vtkMath::IsNan(labelCountAsDouble)) 2188 { 2189 labelCount = 0; 2190 } 2191 else 2192 { 2193 labelCount = vtkMath::Floor(labelCountAsDouble+2*FLT_EPSILON) + 1; 1999 2194 } 2000 2195 2001 2196 labels->SetNumberOfValues(labelCount); 2002 2197 2003 val = axes[0]->GetMajorRangeStart(); 2004 deltaMajor = axes[0]->GetDeltaRangeMajor(); 2005 2006 double scaleFactor = 1.; 2007 if (lastPow != 0) 2008 { 2009 scaleFactor = 1.0/pow(10., lastPow); 2010 } 2011 2012 for (i = 0; i < labelCount; i++) 2013 { 2014 if (fabs(val) < 0.01 && extents > 1) 2015 { 2016 // We just happened to fall at something near zero and the range is 2017 // large, so set it to zero to avoid ugliness. 2018 val = 0.; 2019 } 2020 if (mustAdjustValue) 2021 { 2022 sprintf(label, format, val*scaleFactor); 2023 } 2024 else 2025 { 2026 sprintf(label, format, val); 2027 } 2028 if (fabs(val) < 0.01) 2029 { 2030 // 2031 // Ensure that -0.0 is never a label 2032 // The maximum number of digits that we allow past the decimal is 5. 2033 // 2034 if (strcmp(label, "-0") == 0) 2198 if (customizedLabels == NULL) 2199 { 2200 // Convert deltaMajor from world coord to range scale 2201 deltaMajor = extents * deltaMajor/axisLength; 2202 2203 double scaleFactor = 1.; 2204 if (lastPow != 0) 2205 { 2206 scaleFactor = 1.0/pow(10., lastPow); 2207 } 2208 2209 for (int i = 0; i < labelCount; i++) 2210 { 2211 if (fabs(val) < 0.01 && extents > 1) 2035 2212 { 2036 sprintf(label, "0"); 2213 // We just happened to fall at something near zero and the range is 2214 // large, so set it to zero to avoid ugliness. 2215 val = 0.; 2037 2216 } 2038 else if (strcmp(label, "-0.0") == 0)2217 if (mustAdjustValue) 2039 2218 { 2040 sprintf(label, "0.0");2219 sprintf(label, format, val*scaleFactor); 2041 2220 } 2042 else if (strcmp(label, "-0.00") == 0)2221 else 2043 2222 { 2044 sprintf(label, "0.00");2223 sprintf(label, format, val); 2045 2224 } 2046 else if (strcmp(label, "-0.000") == 0)2225 if (fabs(val) < 0.01) 2047 2226 { 2048 sprintf(label, "0.000"); 2227 // 2228 // Ensure that -0.0 is never a label 2229 // The maximum number of digits that we allow past the decimal is 5. 2230 // 2231 if (strcmp(label, "-0") == 0) 2232 { 2233 sprintf(label, "0"); 2234 } 2235 else if (strcmp(label, "-0.0") == 0) 2236 { 2237 sprintf(label, "0.0"); 2238 } 2239 else if (strcmp(label, "-0.00") == 0) 2240 { 2241 sprintf(label, "0.00"); 2242 } 2243 else if (strcmp(label, "-0.000") == 0) 2244 { 2245 sprintf(label, "0.000"); 2246 } 2247 else if (strcmp(label, "-0.0000") == 0) 2248 { 2249 sprintf(label, "0.0000"); 2250 } 2251 else if (strcmp(label, "-0.00000") == 0) 2252 { 2253 sprintf(label, "0.00000"); 2254 } 2049 2255 } 2050 else if (strcmp(label, "-0.0000") == 0) 2256 labels->SetValue(i, label); 2257 val += deltaMajor; 2258 } 2259 } 2260 else 2261 { 2262 if (labelCount > 0) 2263 { 2264 double delta = customizedLabels->GetNumberOfValues() / labelCount; 2265 for (int i = 0; i < labelCount; ++i) 2051 2266 { 2052 sprintf(label, "0.0000");2267 labels->SetValue(i, customizedLabels->GetValue(i * delta)); 2053 2268 } 2054 else if (strcmp(label, "-0.00000") == 0) 2055 { 2056 sprintf(label, "0.00000"); 2057 } 2058 } 2059 labels->SetValue(i, label); 2060 val += deltaMajor; 2061 } 2062 for (i = 0; i < 4; i++) 2269 } 2270 } 2271 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 2063 2272 { 2064 2273 axes[i]->SetLabels(labels); 2065 2274 } 2066 2275 labels->Delete(); 2276 } 2277 2278 vtkStringArray* vtkRpCubeAxesActor::GetAxisLabels(int axis) 2279 { 2280 return (axis >= 0 && axis < 3) ? this->AxisLabels[axis] : NULL; 2281 } 2282 2283 void vtkRpCubeAxesActor::SetAxisLabels(int axis, vtkStringArray* value) 2284 { 2285 if (axis >= 0 && axis < 3 && value != this->AxisLabels[axis]) 2286 { 2287 vtkStringArray* previous = this->AxisLabels[axis]; 2288 if (value != NULL) 2289 { 2290 value->Register(this); 2291 } 2292 this->AxisLabels[axis] = value; 2293 if (previous != NULL) 2294 { 2295 previous->UnRegister(this); 2296 } 2297 this->Modified(); 2298 } 2067 2299 } 2068 2300 2069 2301 // **************************************************************************** 2070 2302 // Set automatic label scaling mode, set exponents for each axis type. 2071 //2072 2303 // **************************************************************************** 2073 2304 void vtkRpCubeAxesActor::SetLabelScaling(bool autoscale, int upowX, int upowY, … … 2084 2315 } 2085 2316 } 2317 2318 // **************************************************************************** 2319 // Set the i-th title text property. 2320 // **************************************************************************** 2321 2322 vtkTextProperty* vtkRpCubeAxesActor::GetTitleTextProperty(int axis) 2323 { 2324 return (axis >= 0 && axis < 3) ? this->TitleTextProperty[axis] : NULL; 2325 } 2326 2327 // **************************************************************************** 2328 // Get the i-th label text property. 2329 // **************************************************************************** 2330 2331 vtkTextProperty* vtkRpCubeAxesActor::GetLabelTextProperty(int axis) 2332 { 2333 return (axis >= 0 && axis < 3) ? this->LabelTextProperty[axis] : NULL; 2334 } 2335 2336 // **************************************************************************** 2337 // Set axes and screen size of the labels. 2338 // **************************************************************************** 2339 void vtkRpCubeAxesActor::UpdateLabels(vtkRpAxisActor **axis, int index) 2340 { 2341 for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 2342 { 2343 int numberOfLabelsBuild = axis[i]->GetNumberOfLabelsBuilt(); 2344 vtkRpAxisFollower **labelActors = axis[i]->GetLabelActors(); 2345 for(int k=0; k < numberOfLabelsBuild; ++k) 2346 { 2347 if(index == 0) 2348 { 2349 labelActors[k]->SetAxis(this->XAxes[i]); 2350 } 2351 else if(index == 1) 2352 { 2353 labelActors[k]->SetAxis(this->YAxes[i]); 2354 } 2355 else if(index == 2) 2356 { 2357 labelActors[k]->SetAxis(this->ZAxes[i]); 2358 } 2359 else 2360 { 2361 // Do nothing. 2362 } 2363 2364 labelActors[k]->SetScreenOffset(this->LabelScreenOffset); 2365 labelActors[k]->SetEnableDistanceLOD( this->EnableDistanceLOD ); 2366 labelActors[k]->SetDistanceLODThreshold( this->DistanceLODThreshold ); 2367 labelActors[k]->SetEnableViewAngleLOD( this->EnableViewAngleLOD ); 2368 labelActors[k]->SetViewAngleLODThreshold( this->ViewAngleLODThreshold ); 2369 } 2370 } 2371 } 2372 // **************************************************************************** 2373 void vtkRpCubeAxesActor::SetXAxesLinesProperty(vtkProperty *prop) 2374 { 2375 this->XAxesLinesProperty->DeepCopy(prop); 2376 this->Modified(); 2377 } 2378 void vtkRpCubeAxesActor::SetYAxesLinesProperty(vtkProperty *prop) 2379 { 2380 this->YAxesLinesProperty->DeepCopy(prop); 2381 this->Modified(); 2382 } 2383 void vtkRpCubeAxesActor::SetZAxesLinesProperty(vtkProperty *prop) 2384 { 2385 this->ZAxesLinesProperty->DeepCopy(prop); 2386 this->Modified(); 2387 } 2388 2389 // **************************************************************************** 2390 vtkProperty* vtkRpCubeAxesActor::GetXAxesLinesProperty() 2391 { 2392 return this->XAxesLinesProperty; 2393 } 2394 vtkProperty* vtkRpCubeAxesActor::GetYAxesLinesProperty() 2395 { 2396 return this->YAxesLinesProperty; 2397 } 2398 vtkProperty* vtkRpCubeAxesActor::GetZAxesLinesProperty() 2399 { 2400 return this->ZAxesLinesProperty; 2401 } 2402 2403 // **************************************************************************** 2404 void vtkRpCubeAxesActor::SetXAxesGridlinesProperty(vtkProperty *prop) 2405 { 2406 this->XAxesGridlinesProperty->DeepCopy(prop); 2407 this->Modified(); 2408 } 2409 void vtkRpCubeAxesActor::SetYAxesGridlinesProperty(vtkProperty *prop) 2410 { 2411 this->YAxesGridlinesProperty->DeepCopy(prop); 2412 this->Modified(); 2413 } 2414 void vtkRpCubeAxesActor::SetZAxesGridlinesProperty(vtkProperty *prop) 2415 { 2416 this->ZAxesGridlinesProperty->DeepCopy(prop); 2417 this->Modified(); 2418 } 2419 2420 // **************************************************************************** 2421 vtkProperty* vtkRpCubeAxesActor::GetXAxesGridlinesProperty() 2422 { 2423 return this->XAxesGridlinesProperty; 2424 } 2425 vtkProperty* vtkRpCubeAxesActor::GetYAxesGridlinesProperty() 2426 { 2427 return this->YAxesGridlinesProperty; 2428 } 2429 vtkProperty* vtkRpCubeAxesActor::GetZAxesGridlinesProperty() 2430 { 2431 return this->ZAxesGridlinesProperty; 2432 } 2433 2434 // **************************************************************************** 2435 void vtkRpCubeAxesActor::SetXAxesInnerGridlinesProperty(vtkProperty *prop) 2436 { 2437 this->XAxesInnerGridlinesProperty->DeepCopy(prop); 2438 this->Modified(); 2439 } 2440 void vtkRpCubeAxesActor::SetYAxesInnerGridlinesProperty(vtkProperty *prop) 2441 { 2442 this->YAxesInnerGridlinesProperty->DeepCopy(prop); 2443 this->Modified(); 2444 } 2445 void vtkRpCubeAxesActor::SetZAxesInnerGridlinesProperty(vtkProperty *prop) 2446 { 2447 this->ZAxesInnerGridlinesProperty->DeepCopy(prop); 2448 this->Modified(); 2449 } 2450 2451 // **************************************************************************** 2452 vtkProperty* vtkRpCubeAxesActor::GetXAxesInnerGridlinesProperty() 2453 { 2454 return this->XAxesInnerGridlinesProperty; 2455 } 2456 vtkProperty* vtkRpCubeAxesActor::GetYAxesInnerGridlinesProperty() 2457 { 2458 return this->YAxesInnerGridlinesProperty; 2459 } 2460 vtkProperty* vtkRpCubeAxesActor::GetZAxesInnerGridlinesProperty() 2461 { 2462 return this->ZAxesInnerGridlinesProperty; 2463 } 2464 2465 // **************************************************************************** 2466 void vtkRpCubeAxesActor::SetXAxesGridpolysProperty(vtkProperty *prop) 2467 { 2468 this->XAxesGridpolysProperty->DeepCopy(prop); 2469 this->Modified(); 2470 } 2471 void vtkRpCubeAxesActor::SetYAxesGridpolysProperty(vtkProperty *prop) 2472 { 2473 this->YAxesGridpolysProperty->DeepCopy(prop); 2474 this->Modified(); 2475 } 2476 void vtkRpCubeAxesActor::SetZAxesGridpolysProperty(vtkProperty *prop) 2477 { 2478 this->ZAxesGridpolysProperty->DeepCopy(prop); 2479 this->Modified(); 2480 } 2481 2482 // **************************************************************************** 2483 vtkProperty* vtkRpCubeAxesActor::GetXAxesGridpolysProperty() 2484 { 2485 return this->XAxesGridpolysProperty; 2486 } 2487 vtkProperty* vtkRpCubeAxesActor::GetYAxesGridpolysProperty() 2488 { 2489 return this->YAxesGridpolysProperty; 2490 } 2491 vtkProperty* vtkRpCubeAxesActor::GetZAxesGridpolysProperty() 2492 { 2493 return this->ZAxesGridpolysProperty; 2494 } 2495 // -------------------------------------------------------------------------- 2496 void vtkRpCubeAxesActor::UpdateGridLineVisibility(int idx) 2497 { 2498 if( this->GridLineLocation != VTK_GRID_LINES_ALL && 2499 (this->DrawXGridlines || this->DrawYGridlines || this->DrawZGridlines) ) 2500 { 2501 for(int i=0; i < NUMBER_OF_ALIGNED_AXIS; ++i) 2502 { 2503 this->XAxes[i]->SetDrawGridlines(0); 2504 this->YAxes[i]->SetDrawGridlines(0); 2505 this->ZAxes[i]->SetDrawGridlines(0); 2506 this->XAxes[i]->SetDrawGridlinesOnly(0); 2507 this->YAxes[i]->SetDrawGridlinesOnly(0); 2508 this->ZAxes[i]->SetDrawGridlinesOnly(0); 2509 } 2510 2511 this->XAxes[vtkRpCubeAxesActorTriads[idx][0]]->SetDrawGridlines(this->DrawXGridlines); 2512 this->YAxes[vtkRpCubeAxesActorTriads[idx][1]]->SetDrawGridlines(this->DrawYGridlines); 2513 this->ZAxes[vtkRpCubeAxesActorTriads[idx][2]]->SetDrawGridlines(this->DrawZGridlines); 2514 2515 // Update axis render list 2516 int id = 0; 2517 if(this->NumberOfAxesX == 1) 2518 { 2519 id = this->RenderAxesX[this->NumberOfAxesX] = vtkRpCubeAxesActorTriads[idx][0]; 2520 this->XAxes[id]->SetDrawGridlinesOnly((this->RenderAxesX[0] != id) ? 1 : 0); 2521 this->NumberOfAxesX += (this->RenderAxesX[0] != id) ? 1 : 0; 2522 } 2523 if(this->NumberOfAxesY == 1) 2524 { 2525 id = this->RenderAxesY[this->NumberOfAxesY] = vtkRpCubeAxesActorTriads[idx][1]; 2526 this->YAxes[id]->SetDrawGridlinesOnly((this->RenderAxesY[0] != id) ? 1 : 0); 2527 this->NumberOfAxesY += (this->RenderAxesY[0] != id) ? 1 : 0; 2528 } 2529 if(this->NumberOfAxesZ == 1) 2530 { 2531 id = this->RenderAxesZ[this->NumberOfAxesZ] = vtkRpCubeAxesActorTriads[idx][2]; 2532 this->ZAxes[id]->SetDrawGridlinesOnly((this->RenderAxesZ[0] != id) ? 1 : 0); 2533 this->NumberOfAxesZ += (this->RenderAxesZ[0] != id) ? 1 : 0; 2534 } 2535 } 2536 } 2537 // -------------------------------------------------------------------------- 2538 int vtkRpCubeAxesActor::FindClosestAxisIndex(double pts[8][3]) 2539 { 2540 // Loop over points and find the closest point to the camera 2541 double min = VTK_LARGE_FLOAT; 2542 int idx = 0; 2543 for (int i=0; i < 8; i++) 2544 { 2545 if (pts[i][2] < min) 2546 { 2547 idx = i; 2548 min = pts[i][2]; 2549 } 2550 } 2551 return idx; 2552 } 2553 2554 // -------------------------------------------------------------------------- 2555 int vtkRpCubeAxesActor::FindFurtherstAxisIndex(double pts[8][3]) 2556 { 2557 // Loop over points and find the furthest point from the camera 2558 double max = -VTK_LARGE_FLOAT; 2559 int idx = 0; 2560 for (int i=0; i < 8; i++) 2561 { 2562 if (pts[i][2] > max) 2563 { 2564 idx = i; 2565 max = pts[i][2]; 2566 } 2567 } 2568 return idx; 2569 } 2570 // -------------------------------------------------------------------------- 2571 void vtkRpCubeAxesActor::FindBoundaryEdge( int &xloc, int &yloc, 2572 int &zloc, double pts[8][3]) 2573 { 2574 // boundary edges fly mode 2575 xloc = yloc = zloc = 1; 2576 int i, xIdx = 0, yIdx = 0, zIdx = 0, zIdx2 = 0; 2577 int xAxes = 0, yAxes = 0, zAxes = 0; 2578 double slope = 0.0, minSlope, num, den, d2; 2579 double e1[3], e2[3], e3[3]; 2580 int idx = 0; 2581 2582 // Find distance to origin 2583 double d2Min = VTK_LARGE_FLOAT; 2584 for (i=0; i < 8; i++) 2585 { 2586 d2 = pts[i][0]*pts[i][0] + pts[i][1]*pts[i][1]; 2587 if (d2 < d2Min) 2588 { 2589 d2Min = d2; 2590 idx = i; 2591 } 2592 } 2593 2594 // find minimum slope point connected to closest point and on 2595 // right side (in projected coordinates). This is the first edge. 2596 minSlope = VTK_LARGE_FLOAT; 2597 for (xIdx=0, i=0; i<3; i++) 2598 { 2599 num = (pts[vtkRpCubeAxesActorConn[idx][i]][1] - pts[idx][1]); 2600 den = (pts[vtkRpCubeAxesActorConn[idx][i]][0] - pts[idx][0]); 2601 if (den != 0.0) 2602 { 2603 slope = num / den; 2604 } 2605 if (slope < minSlope && den > 0) 2606 { 2607 xIdx = vtkRpCubeAxesActorConn[idx][i]; 2608 yIdx = vtkRpCubeAxesActorConn[idx][(i+1)%3]; 2609 zIdx = vtkRpCubeAxesActorConn[idx][(i+2)%3]; 2610 xAxes = i; 2611 minSlope = slope; 2612 } 2613 } 2614 2615 // find edge (connected to closest point) on opposite side 2616 for ( i=0; i<3; i++) 2617 { 2618 e1[i] = (pts[xIdx][i] - pts[idx][i]); 2619 e2[i] = (pts[yIdx][i] - pts[idx][i]); 2620 e3[i] = (pts[zIdx][i] - pts[idx][i]); 2621 } 2622 vtkMath::Normalize(e1); 2623 vtkMath::Normalize(e2); 2624 vtkMath::Normalize(e3); 2625 2626 if (vtkMath::Dot(e1,e2) < vtkMath::Dot(e1,e3)) 2627 { 2628 yAxes = (xAxes + 1) % 3; 2629 } 2630 else 2631 { 2632 yIdx = zIdx; 2633 yAxes = (xAxes + 2) % 3; 2634 } 2635 2636 // Find the final point by determining which global x-y-z axes have not 2637 // been represented, and then determine the point closest to the viewer. 2638 zAxes = (xAxes != 0 && yAxes != 0 ? 0 : 2639 (xAxes != 1 && yAxes != 1 ? 1 : 2)); 2640 if (pts[vtkRpCubeAxesActorConn[xIdx][zAxes]][2] < 2641 pts[vtkRpCubeAxesActorConn[yIdx][zAxes]][2]) 2642 { 2643 zIdx = xIdx; 2644 zIdx2 = vtkRpCubeAxesActorConn[xIdx][zAxes]; 2645 } 2646 else 2647 { 2648 zIdx = yIdx; 2649 zIdx2 = vtkRpCubeAxesActorConn[yIdx][zAxes]; 2650 } 2651 2652 int mini = (idx < xIdx ? idx : xIdx); 2653 switch (xAxes) 2654 { 2655 case 0: 2656 xloc = vtkRpCubeAxesActorTriads[mini][0]; 2657 break; 2658 case 1: 2659 yloc = vtkRpCubeAxesActorTriads[mini][1]; 2660 break; 2661 case 2: 2662 zloc = vtkRpCubeAxesActorTriads[mini][2]; 2663 break; 2664 } 2665 mini = (idx < yIdx ? idx : yIdx); 2666 switch (yAxes) 2667 { 2668 case 0: 2669 xloc = vtkRpCubeAxesActorTriads[mini][0]; 2670 break; 2671 case 1: 2672 yloc =vtkRpCubeAxesActorTriads[mini][1]; 2673 break; 2674 case 2: 2675 zloc = vtkRpCubeAxesActorTriads[mini][2]; 2676 break; 2677 } 2678 mini = (zIdx < zIdx2 ? zIdx : zIdx2); 2679 switch (zAxes) 2680 { 2681 case 0: 2682 xloc = vtkRpCubeAxesActorTriads[mini][0]; 2683 break; 2684 case 1: 2685 yloc = vtkRpCubeAxesActorTriads[mini][1]; 2686 break; 2687 case 2: 2688 zloc = vtkRpCubeAxesActorTriads[mini][2]; 2689 break; 2690 } 2691 } 2692 2693 // -------------------------------------------------------------------------- 2694 int vtkRpCubeAxesActor::RenderGeometry( 2695 bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility, 2696 int (vtkRpAxisActor::*renderMethod)(vtkViewport*)) 2697 { 2698 int i, renderedSomething = 0; 2699 2700 // Make sure axes are initialized and visibility is properly set 2701 if(checkAxisVisibility) 2702 { 2703 // Initialization 2704 if (!this->Camera) 2705 { 2706 vtkErrorMacro(<<"No camera!"); 2707 this->RenderSomething = 0; 2708 return 0; 2709 } 2710 2711 this->BuildAxes(viewport); 2712 2713 if (initialRender) 2714 { 2715 for (i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) 2716 { 2717 this->XAxes[i]->BuildAxis(viewport, true); 2718 this->YAxes[i]->BuildAxis(viewport, true); 2719 this->ZAxes[i]->BuildAxis(viewport, true); 2720 } 2721 } 2722 initialRender = false; 2723 2724 this->DetermineRenderAxes(viewport); 2725 } 2726 2727 // Render the axes 2728 for (i = 0; i < this->NumberOfAxesX; i++) 2729 { 2730 renderedSomething += 2731 (this->XAxes[this->RenderAxesX[i]]->*renderMethod)(viewport); 2732 } 2733 2734 for (i = 0; i < this->NumberOfAxesY; i++) 2735 { 2736 renderedSomething += 2737 (this->YAxes[this->RenderAxesY[i]]->*renderMethod)(viewport); 2738 } 2739 2740 for (i = 0; i < this->NumberOfAxesZ; i++) 2741 { 2742 renderedSomething += 2743 (this->ZAxes[this->RenderAxesZ[i]]->*renderMethod)(viewport); 2744 } 2745 return renderedSomething; 2746 } 2747 2748 // -------------------------------------------------------------------------- 2749 void vtkRpCubeAxesActor::GetRenderedBounds(double *b) 2750 { 2751 vtkBoundingBox bbox(this->GetBounds()); // Data bounds 2752 2753 // Make a heuristic on the final bounds that embed test labels 2754 // Just inflate the box based on its max length 2755 bbox.Inflate(bbox.GetMaxLength()); 2756 2757 bbox.GetBounds(b); 2758 } 2759 2760 // -------------------------------------------------------------------------- 2761 double* vtkRpCubeAxesActor::GetRenderedBounds() 2762 { 2763 this->GetRenderedBounds(this->RenderedBounds); 2764 // Return our data holder 2765 return this->RenderedBounds; 2766 } -
trunk/packages/vizservers/vtkvis/vtkRpCubeAxesActor.h
r2864 r3479 42 42 // the bounding box. 43 43 // 44 // .SECTION See Also 45 // vtkActor vtkRpAxisActor vtkRpCubeAxesActor2D 44 // .SECTION Thanks 45 // This class was written by: 46 // Hank Childs, Kathleen Bonnell, Amy Squillacote, Brad Whitlock, Will Schroeder, 47 // Eric Brugger, Daniel Aguilera, Claire Guilbaud, Nicolas Dolegieviez, 48 // Aashish Chaudhary, Philippe Pebay, David Gobbi, David Partyka, Utkarsh Ayachit 49 // David Cole, Francois Bertel, and Mark Olesen 50 // Part of this work was supported by CEA/DIF - Commissariat a l'Energie Atomique, 51 // Centre DAM Ile-De-France, BP12, F-91297 Arpajon, France. 52 // 53 // .section See Also 54 // vtkActor vtkAxisActor vtkCubeAxesActor2D 46 55 47 56 #ifndef __vtkRpCubeAxesActor_h … … 58 67 #define VTK_TICKS_BOTH 2 59 68 69 #define VTK_GRID_LINES_ALL 0 70 #define VTK_GRID_LINES_CLOSEST 1 71 #define VTK_GRID_LINES_FURTHEST 2 72 73 #define NUMBER_OF_ALIGNED_AXIS 4 74 75 #include "vtkRenderingAnnotationModule.h" // For export macro 60 76 #include "vtkActor.h" 61 77 62 78 class vtkRpAxisActor; 63 79 class vtkCamera; 64 65 class VTK_HYBRID_EXPORT vtkRpCubeAxesActor : public vtkActor 80 class vtkTextProperty; 81 class vtkStringArray; 82 83 class VTKRENDERINGANNOTATION_EXPORT vtkRpCubeAxesActor : public vtkActor 66 84 { 67 85 public: … … 77 95 // Draw the axes as per the vtkProp superclass' API. 78 96 virtual int RenderOpaqueGeometry(vtkViewport*); 79 virtual int RenderTranslucentGeometry(vtkViewport *) {return 0;} 97 virtual int RenderTranslucentGeometry(vtkViewport*); 98 virtual int RenderTranslucentPolygonalGeometry(vtkViewport*); 99 virtual int RenderOverlay(vtkViewport*); 100 int HasTranslucentPolygonalGeometry(); 101 102 // Description: 103 // Gets/Sets the RebuildAxes flag 104 vtkSetMacro( RebuildAxes, bool ); 105 vtkGetMacro( RebuildAxes, bool ); 80 106 81 107 // Description: … … 85 111 // sure that the min's are less than the max's. 86 112 vtkSetVector6Macro(Bounds,double); 87 double *GetBounds(); 88 void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax, 89 double& zmin, double& zmax); 90 void GetBounds(double bounds[6]); 113 vtkGetVector6Macro(Bounds,double); 114 115 // Description: 116 // Method used to properly return the bounds of the cube axis itself with all 117 // its labels. 118 virtual void GetRenderedBounds(double rBounds[6]); 119 virtual double* GetRenderedBounds(); 91 120 92 121 // Description: … … 102 131 vtkGetVector2Macro( XAxisRange, double ); 103 132 vtkGetVector2Macro( YAxisRange, double ); 133 // Description 134 // Explicitly specify the axis labels along an axis as an array of strings 135 // instead of using the values. 136 vtkStringArray* GetAxisLabels(int axis); 137 void SetAxisLabels(int axis, vtkStringArray* value); 138 104 139 vtkGetVector2Macro( ZAxisRange, double ); 140 141 // Description: 142 // Explicitly specify the screen size of title and label text. 143 // ScreenSize detemines the size of the text in terms of screen 144 // pixels. Default is 10.0. 145 void SetScreenSize(double screenSize); 146 vtkGetMacro(ScreenSize, double); 105 147 106 148 // Description: … … 174 216 175 217 // Description: 218 // Enable and disable the use of distance based LOD for titles and labels. 219 vtkSetMacro( EnableDistanceLOD, int ); 220 vtkGetMacro( EnableDistanceLOD, int ); 221 222 // Description:a 223 // Set distance LOD threshold [0.0 - 1.0] for titles and labels. 224 vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 ); 225 vtkGetMacro( DistanceLODThreshold, double); 226 227 // Description: 228 // Enable and disable the use of view angle based LOD for titles and labels. 229 vtkSetMacro( EnableViewAngleLOD, int ); 230 vtkGetMacro( EnableViewAngleLOD, int ); 231 232 // Description: 233 // Set view angle LOD threshold [0.0 - 1.0] for titles and labels. 234 vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. ); 235 vtkGetMacro( ViewAngleLODThreshold, double ); 236 237 // Description: 176 238 // Turn on and off the visibility of each axis. 177 239 vtkSetMacro(XAxisVisibility,int); … … 239 301 vtkBooleanMacro(DrawZGridlines,int); 240 302 303 vtkSetMacro(DrawXInnerGridlines,int); 304 vtkGetMacro(DrawXInnerGridlines,int); 305 vtkBooleanMacro(DrawXInnerGridlines,int); 306 307 vtkSetMacro(DrawYInnerGridlines,int); 308 vtkGetMacro(DrawYInnerGridlines,int); 309 vtkBooleanMacro(DrawYInnerGridlines,int); 310 311 vtkSetMacro(DrawZInnerGridlines,int); 312 vtkGetMacro(DrawZInnerGridlines,int); 313 vtkBooleanMacro(DrawZInnerGridlines,int); 314 315 vtkSetMacro(DrawXGridpolys,int); 316 vtkGetMacro(DrawXGridpolys,int); 317 vtkBooleanMacro(DrawXGridpolys,int); 318 319 vtkSetMacro(DrawYGridpolys,int); 320 vtkGetMacro(DrawYGridpolys,int); 321 vtkBooleanMacro(DrawYGridpolys,int); 322 323 vtkSetMacro(DrawZGridpolys,int); 324 vtkGetMacro(DrawZGridpolys,int); 325 vtkBooleanMacro(DrawZGridpolys,int); 326 327 // Description: 328 // Returns the text property for the title on an axis. 329 vtkTextProperty *GetTitleTextProperty(int); 330 331 // Description: 332 // Returns the text property for the labels on an axis. 333 vtkTextProperty *GetLabelTextProperty(int); 334 335 // Description: 336 // Get/Set axes actors properties. 337 void SetXAxesLinesProperty(vtkProperty *); 338 vtkProperty* GetXAxesLinesProperty(); 339 void SetYAxesLinesProperty(vtkProperty *); 340 vtkProperty* GetYAxesLinesProperty(); 341 void SetZAxesLinesProperty(vtkProperty *); 342 vtkProperty* GetZAxesLinesProperty(); 343 344 // Description: 345 // Get/Set axes (outer) gridlines actors properties. 346 void SetXAxesGridlinesProperty(vtkProperty *); 347 vtkProperty* GetXAxesGridlinesProperty(); 348 void SetYAxesGridlinesProperty(vtkProperty *); 349 vtkProperty* GetYAxesGridlinesProperty(); 350 void SetZAxesGridlinesProperty(vtkProperty *); 351 vtkProperty* GetZAxesGridlinesProperty(); 352 353 // Description: 354 // Get/Set axes inner gridlines actors properties. 355 void SetXAxesInnerGridlinesProperty(vtkProperty *); 356 vtkProperty* GetXAxesInnerGridlinesProperty(); 357 void SetYAxesInnerGridlinesProperty(vtkProperty *); 358 vtkProperty* GetYAxesInnerGridlinesProperty(); 359 void SetZAxesInnerGridlinesProperty(vtkProperty *); 360 vtkProperty* GetZAxesInnerGridlinesProperty(); 361 362 // Description: 363 // Get/Set axes gridPolys actors properties. 364 void SetXAxesGridpolysProperty(vtkProperty *); 365 vtkProperty* GetXAxesGridpolysProperty(); 366 void SetYAxesGridpolysProperty(vtkProperty *); 367 vtkProperty* GetYAxesGridpolysProperty(); 368 void SetZAxesGridpolysProperty(vtkProperty *); 369 vtkProperty* GetZAxesGridpolysProperty(); 370 241 371 // Description: 242 372 // Set/Get the location of ticks marks. … … 252 382 253 383 void SetLabelScaling(bool, int, int, int); 254 // Description: 255 // Shallow copy of a KatCubeAxesActor. 256 void ShallowCopy(vtkRpCubeAxesActor *actor); 384 385 // Description: 386 // Get/Set 2D mode 387 // NB: Use vtkTextActor for titles in 2D instead of vtkRpAxisFollower 388 void SetUse2DMode( int val ); 389 int GetUse2DMode(); 390 391 // Description: 392 // For 2D mode only: save axis title positions for later use 393 void SetSaveTitlePosition( int val ); 394 395 // Description: 396 // Provide an oriented bounded box when using AxisBaseFor. 397 vtkSetVector6Macro(OrientedBounds,double); 398 vtkGetVector6Macro(OrientedBounds, double); 399 400 // Description: 401 // Enable/Disable the usage of the OrientedBounds 402 vtkSetMacro(UseOrientedBounds, int); 403 vtkGetMacro(UseOrientedBounds, int); 404 405 // Description: 406 // Vector that should be use as the base for X 407 vtkSetVector3Macro(AxisBaseForX,double); 408 vtkGetVector3Macro(AxisBaseForX, double); 409 410 // Description: 411 // Vector that should be use as the base for Y 412 vtkSetVector3Macro(AxisBaseForY,double); 413 vtkGetVector3Macro(AxisBaseForY, double); 414 415 // Description: 416 // Vector that should be use as the base for Z 417 vtkSetVector3Macro(AxisBaseForZ,double); 418 vtkGetVector3Macro(AxisBaseForZ, double); 419 420 // Description: 421 // Provide a custom AxisOrigin. This point must be inside the bouding box and 422 // will represent the point where the 3 axes will interesect 423 vtkSetVector3Macro(AxisOrigin,double); 424 vtkGetVector3Macro(AxisOrigin, double); 425 426 // Description: 427 // Enable/Disable the usage of the AxisOrigin 428 vtkSetMacro(UseAxisOrigin, int); 429 vtkGetMacro(UseAxisOrigin, int); 430 431 // Description: 432 // Specify the mode in which the cube axes should render its gridLines 433 vtkSetMacro(GridLineLocation,int); 434 vtkGetMacro(GridLineLocation,int); 435 436 vtkSetMacro(XAutoLabelFormat,int); 437 vtkGetMacro(XAutoLabelFormat,int); 438 vtkBooleanMacro(XAutoLabelFormat,int); 439 vtkSetMacro(YAutoLabelFormat,int); 440 vtkGetMacro(YAutoLabelFormat,int); 441 vtkBooleanMacro(YAutoLabelFormat,int); 442 vtkSetMacro(ZAutoLabelFormat,int); 443 vtkGetMacro(ZAutoLabelFormat,int); 444 vtkBooleanMacro(ZAutoLabelFormat,int); 257 445 258 446 protected: … … 261 449 262 450 int LabelExponent(double min, double max); 451 263 452 int Digits(double min, double max); 453 264 454 double MaxOf(double, double); 265 455 double MaxOf(double, double, double, double); 456 266 457 double FFix(double); 267 458 double FSign(double, double); 268 269 double Bounds[6]; //Define bounds explicitly 459 int FRound( double fnt ); 460 int GetNumTicks( double range, double fxt); 461 462 void UpdateLabels(vtkRpAxisActor **axis, int index); 463 464 double Bounds[6]; //Define bounds explicitly 270 465 271 466 vtkCamera *Camera; 467 272 468 int FlyMode; 273 469 274 // to control all axes 275 // [0] always for 'Major' axis during non-static fly modes. 276 vtkRpAxisActor *XAxes[4]; 277 vtkRpAxisActor *YAxes[4]; 278 vtkRpAxisActor *ZAxes[4]; 470 // Expose internally closest axis index computation 471 int FindClosestAxisIndex(double pts[8][3]); 472 473 // Expose internally furthest axis index computation 474 int FindFurtherstAxisIndex(double pts[8][3]); 475 476 // Expose internally the boundary edge fly mode axis index computation 477 void FindBoundaryEdge(int &indexOfAxisX, int &indexOfAxisY, int &indexOfAxisZ, 478 double pts[8][3]); 479 480 // Description: 481 // This will Update AxisActors with GridVisibility when those should be 482 // dynamaic regarding the viewport. 483 // GridLineLocation = [VTK_CLOSEST_GRID_LINES, VTK_FURTHEST_GRID_LINES] 484 void UpdateGridLineVisibility(int axisIndex); 485 486 // VTK_ALL_GRID_LINES 0 487 // VTK_CLOSEST_GRID_LINES 1 488 // VTK_FURTHEST_GRID_LINES 2 489 int GridLineLocation; 490 491 // Description: 492 // If enabled the actor will not be visible at a certain distance from the camera. 493 // Default is true 494 int EnableDistanceLOD; 495 496 // Description: 497 // Default is 0.80 498 // This determines at what fraction of camera far clip range, actor is not visible. 499 double DistanceLODThreshold; 500 501 // Description: 502 // If enabled the actor will not be visible at a certain view angle. 503 // Default is true. 504 int EnableViewAngleLOD; 505 506 // Description: 507 // This determines at what view angle to geometry will make the geometry not visibile. 508 // Default is 0.3. 509 double ViewAngleLODThreshold; 510 511 // Description: 512 // Control variables for all axes 513 // NB: [0] always for 'Major' axis during non-static fly modes. 514 vtkRpAxisActor *XAxes[NUMBER_OF_ALIGNED_AXIS]; 515 vtkRpAxisActor *YAxes[NUMBER_OF_ALIGNED_AXIS]; 516 vtkRpAxisActor *ZAxes[NUMBER_OF_ALIGNED_AXIS]; 517 518 bool RebuildAxes; 279 519 280 520 char *XTitle; … … 311 551 int DrawZGridlines; 312 552 553 int DrawXInnerGridlines; 554 int DrawYInnerGridlines; 555 int DrawZInnerGridlines; 556 557 int DrawXGridpolys; 558 int DrawYGridpolys; 559 int DrawZGridpolys; 560 313 561 char *XLabelFormat; 314 562 char *YLabelFormat; 315 563 char *ZLabelFormat; 564 316 565 double CornerOffset; 566 317 567 int Inertia; 568 318 569 int RenderCount; 570 319 571 int InertiaLocs[3]; 320 572 321 573 int RenderSomething; 574 575 double LabelScreenOffset; 576 double TitleScreenOffset; 577 578 vtkTextProperty* TitleTextProperty[3]; 579 vtkStringArray* AxisLabels[3]; 580 581 vtkTextProperty* LabelTextProperty[3]; 582 583 vtkProperty *XAxesLinesProperty; 584 vtkProperty *YAxesLinesProperty; 585 vtkProperty *ZAxesLinesProperty; 586 vtkProperty *XAxesGridlinesProperty; 587 vtkProperty *YAxesGridlinesProperty; 588 vtkProperty *ZAxesGridlinesProperty; 589 vtkProperty *XAxesInnerGridlinesProperty; 590 vtkProperty *YAxesInnerGridlinesProperty; 591 vtkProperty *ZAxesInnerGridlinesProperty; 592 vtkProperty *XAxesGridpolysProperty; 593 vtkProperty *YAxesGridpolysProperty; 594 vtkProperty *ZAxesGridpolysProperty; 595 596 double RenderedBounds[6]; 597 double OrientedBounds[6]; 598 int UseOrientedBounds; 599 600 double AxisOrigin[3]; 601 int UseAxisOrigin; 602 603 double AxisBaseForX[3]; 604 double AxisBaseForY[3]; 605 double AxisBaseForZ[3]; 322 606 323 607 private: … … 330 614 331 615 vtkTimeStamp BuildTime; 616 int LastUseOrientedBounds; 332 617 int LastXPow; 333 618 int LastYPow; 334 619 int LastZPow; 620 335 621 int UserXPow; 336 622 int UserYPow; 337 623 int UserZPow; 624 338 625 bool AutoLabelScaling; 626 int XAutoLabelFormat; 627 int YAutoLabelFormat; 628 int ZAutoLabelFormat; 629 339 630 int LastXAxisDigits; 340 631 int LastYAxisDigits; 341 632 int LastZAxisDigits; 633 342 634 double LastXRange[2]; 343 635 double LastYRange[2]; 344 636 double LastZRange[2]; 345 int LastFlyMode; 346 347 int RenderAxesX[4]; 348 int RenderAxesY[4]; 349 int RenderAxesZ[4]; 637 double LastBounds[6]; 638 639 int LastFlyMode; 640 641 int RenderAxesX[NUMBER_OF_ALIGNED_AXIS]; 642 int RenderAxesY[NUMBER_OF_ALIGNED_AXIS]; 643 int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS]; 644 350 645 int NumberOfAxesX; 351 646 int NumberOfAxesY; … … 355 650 bool MustAdjustYValue; 356 651 bool MustAdjustZValue; 652 357 653 bool ForceXLabelReset; 358 654 bool ForceYLabelReset; … … 363 659 double ZAxisRange[2]; 364 660 365 // various helper methods 661 double LabelScale; 662 double TitleScale; 663 664 double ScreenSize; 665 666 // Description: 667 // Major start and delta values, in each direction. 668 // These values are needed for inner grid lines generation 669 double MajorStart[3]; 670 double DeltaMajor[3]; 671 672 int RenderGeometry(bool &initialRender, vtkViewport *viewport, bool checkAxisVisibility,int (vtkRpAxisActor::*renderMethod)(vtkViewport*)); 673 366 674 void TransformBounds(vtkViewport *viewport, const double bounds[6], 367 675 double pts[8][3]); 368 676 void AdjustAxes(double bounds[6], 369 double xCoords[4][6], double yCoords[4][6], 370 double zCoords[4][6], 677 double xCoords[NUMBER_OF_ALIGNED_AXIS][6], 678 double yCoords[NUMBER_OF_ALIGNED_AXIS][6], 679 double zCoords[NUMBER_OF_ALIGNED_AXIS][6], 371 680 double xRange[2], double yRange[2], double zRange[2]); 372 681 … … 379 688 void DetermineRenderAxes(vtkViewport *); 380 689 void SetNonDependentAttributes(void); 381 void BuildLabels(vtkRpAxisActor *axes[ 4]);382 void AdjustTicksComputeRange(vtkRpAxisActor *axes[ 4],690 void BuildLabels(vtkRpAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]); 691 void AdjustTicksComputeRange(vtkRpAxisActor *axes[NUMBER_OF_ALIGNED_AXIS], 383 692 double rangeMin, double rangeMax); 384 693 385 // hide the superclass' ShallowCopy() from the user and the compiler. 386 void ShallowCopy(vtkProp *prop) { this->vtkProp::ShallowCopy( prop ); }; 694 void AutoScale(vtkViewport *viewport); 695 void AutoScale(vtkViewport *viewport, vtkRpAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]); 696 double AutoScale(vtkViewport *viewport, double screenSize, double position[3]); 387 697 }; 388 698
Note: See TracChangeset
for help on using the changeset viewer.