- Timestamp:
- Dec 12, 2012, 11:40:06 AM (12 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r3194 r3198 421 421 { 422 422 TRACE("Resetting axes"); 423 if (_cubeAxesActor == NULL || 424 _cubeAxesActor2D == NULL) { 423 if (_cubeAxesActor == NULL 424 #ifndef USE_VTK6 425 || _cubeAxesActor2D == NULL 426 #endif 427 ) { 425 428 initAxes(); 426 429 } 427 430 if (_cameraMode == IMAGE) { 431 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 432 _cubeAxesActor->SetUse2DMode(1); 433 #else 428 434 if (_renderer->HasViewProp(_cubeAxesActor)) { 429 435 TRACE("Removing 3D axes"); … … 434 440 _renderer->AddViewProp(_cubeAxesActor2D); 435 441 } 442 #endif 436 443 } else { 444 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 445 _cubeAxesActor->SetUse2DMode(0); 446 #else 437 447 if (_renderer->HasViewProp(_cubeAxesActor2D)) { 438 448 TRACE("Removing 2D axes"); … … 443 453 _renderer->AddViewProp(_cubeAxesActor); 444 454 } 445 if (bounds == NULL) { 446 double newBounds[6]; 447 collectBounds(newBounds, false); 448 #if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8)) 449 _cubeAxesActor->SetXAxisRange(newBounds[0], newBounds[1]); 450 _cubeAxesActor->SetYAxisRange(newBounds[2], newBounds[3]); 451 _cubeAxesActor->SetZAxisRange(newBounds[4], newBounds[5]); 452 #endif 453 _cubeAxesActor->SetBounds(newBounds); 454 TRACE("Bounds (computed): %g %g %g %g %g %g", 455 newBounds[0], 456 newBounds[1], 457 newBounds[2], 458 newBounds[3], 459 newBounds[4], 460 newBounds[5]); 461 } else { 462 #if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8)) 463 _cubeAxesActor->SetXAxisRange(bounds[0], bounds[1]); 464 _cubeAxesActor->SetYAxisRange(bounds[2], bounds[3]); 465 _cubeAxesActor->SetZAxisRange(bounds[4], bounds[5]); 466 #endif 467 _cubeAxesActor->SetBounds(bounds); 468 TRACE("Bounds (supplied): %g %g %g %g %g %g", 469 bounds[0], 470 bounds[1], 471 bounds[2], 472 bounds[3], 473 bounds[4], 474 bounds[5]); 475 } 455 #endif 456 } 457 458 if (_cameraMode == IMAGE) { 459 return; 460 } 461 462 if (bounds == NULL) { 463 double newBounds[6]; 464 collectBounds(newBounds, false); 465 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 466 double unscaledBounds[6]; 467 collectUnscaledBounds(unscaledBounds, false); 468 _cubeAxesActor->SetXAxisRange(unscaledBounds[0], unscaledBounds[1]); 469 _cubeAxesActor->SetYAxisRange(unscaledBounds[2], unscaledBounds[3]); 470 _cubeAxesActor->SetZAxisRange(unscaledBounds[4], unscaledBounds[5]); 471 TRACE("Axis ranges: %g %g %g %g %g %g", 472 unscaledBounds[0], 473 unscaledBounds[1], 474 unscaledBounds[2], 475 unscaledBounds[3], 476 unscaledBounds[4], 477 unscaledBounds[5]); 478 #endif 479 _cubeAxesActor->SetBounds(newBounds); 480 TRACE("Bounds (computed): %g %g %g %g %g %g", 481 newBounds[0], 482 newBounds[1], 483 newBounds[2], 484 newBounds[3], 485 newBounds[4], 486 newBounds[5]); 487 } else { 488 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 489 double unscaledBounds[6]; 490 collectUnscaledBounds(unscaledBounds, false); 491 _cubeAxesActor->SetXAxisRange(unscaledBounds[0], unscaledBounds[1]); 492 _cubeAxesActor->SetYAxisRange(unscaledBounds[2], unscaledBounds[3]); 493 _cubeAxesActor->SetZAxisRange(unscaledBounds[4], unscaledBounds[5]); 494 TRACE("Axis ranges: %g %g %g %g %g %g", 495 unscaledBounds[0], 496 unscaledBounds[1], 497 unscaledBounds[2], 498 unscaledBounds[3], 499 unscaledBounds[4], 500 unscaledBounds[5]); 501 #endif 502 _cubeAxesActor->SetBounds(bounds); 503 TRACE("Bounds (supplied): %g %g %g %g %g %g", 504 bounds[0], 505 bounds[1], 506 bounds[2], 507 bounds[3], 508 bounds[4], 509 bounds[5]); 476 510 } 477 511 } … … 497 531 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 498 532 _cubeAxesActor->SetGridLineLocation(VTK_GRID_LINES_ALL); 533 #endif 534 #if !defined(USE_CUSTOM_AXES) 535 _cubeAxesActor->SetDrawXInnerGridlines(0); 536 _cubeAxesActor->SetDrawYInnerGridlines(0); 537 _cubeAxesActor->SetDrawZInnerGridlines(0); 538 _cubeAxesActor->SetDrawXGridpolys(0); 539 _cubeAxesActor->SetDrawYGridpolys(0); 540 _cubeAxesActor->SetDrawZGridpolys(0); 541 _cubeAxesActor->SetDistanceLODThreshold(1); 499 542 _cubeAxesActor->SetEnableDistanceLOD(0); 543 _cubeAxesActor->SetViewAngleLODThreshold(0); 500 544 _cubeAxesActor->SetEnableViewAngleLOD(0); 545 _cubeAxesActor->SetScreenSize(12.0); 546 #endif 547 _cubeAxesActor->SetBounds(0, 1, 0, 1, 0, 1); 548 #if !defined(USE_CUSTOM_AXES) 549 _cubeAxesActor->SetXAxisRange(0, 1); 550 _cubeAxesActor->SetYAxisRange(0, 1); 551 _cubeAxesActor->SetZAxisRange(0, 1); 501 552 #endif 502 553 … … 504 555 if (_cubeAxesActor2D == NULL) 505 556 _cubeAxesActor2D = vtkSmartPointer<vtkRpCubeAxesActor2D>::New(); 506 #el se557 #elif !defined(USE_VTK6) 507 558 if (_cubeAxesActor2D == NULL) 508 559 _cubeAxesActor2D = vtkSmartPointer<vtkCubeAxesActor2D>::New(); 509 560 #endif 510 561 562 double axesColor[] = {1,1,1}; 563 setAxesColor(axesColor); 564 565 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 566 if (!_renderer->HasViewProp(_cubeAxesActor)) 567 _renderer->AddViewProp(_cubeAxesActor); 568 569 if (_cameraMode == IMAGE) { 570 _cubeAxesActor->SetUse2DMode(1); 571 } else { 572 _cubeAxesActor->SetUse2DMode(0); 573 } 574 #else 511 575 _cubeAxesActor2D->SetCamera(_renderer->GetActiveCamera()); 512 576 _cubeAxesActor2D->ZAxisVisibilityOff(); … … 564 628 _renderer->AddViewProp(_cubeAxesActor); 565 629 } 630 #endif 566 631 } 567 632 … … 572 637 { 573 638 if (_cubeAxesActor == NULL) 574 initAxes(); 639 return; 640 575 641 switch (mode) { 576 642 case FLY_STATIC_EDGES: … … 620 686 _cubeAxesActor->GetTitleTextProperty(i)->SetColor(color); 621 687 _cubeAxesActor->GetLabelTextProperty(i)->SetColor(color); 688 _cubeAxesActor->GetLabelTextProperty(i)->SetOpacity(1.0); 622 689 } 623 690 _cubeAxesActor->GetXAxesLinesProperty()->SetColor(color); … … 630 697 _needsRedraw = true; 631 698 } 699 #if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES) 632 700 if (_cubeAxesActor2D != NULL) { 633 701 _cubeAxesActor2D->GetProperty()->SetColor(color); … … 645 713 _needsRedraw = true; 646 714 } 715 #endif 647 716 } 648 717 … … 656 725 _needsRedraw = true; 657 726 } 727 #if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES) 658 728 if (_cubeAxesActor2D != NULL) { 659 729 _cubeAxesActor2D->SetVisibility((state ? 1 : 0)); 660 730 _needsRedraw = true; 661 731 } 732 #endif 662 733 } 663 734 … … 730 801 _needsRedraw = true; 731 802 } 803 #if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES) 732 804 if (_cubeAxesActor2D != NULL) { 733 805 if (axis == X_AXIS) { … … 740 812 _needsRedraw = true; 741 813 } 814 #endif 742 815 } 743 816 … … 774 847 _needsRedraw = true; 775 848 } 849 #if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES) 776 850 if (_cubeAxesActor2D != NULL) { 777 851 if (axis == X_AXIS) { … … 784 858 _needsRedraw = true; 785 859 } 860 #endif 786 861 } 787 862 … … 801 876 _needsRedraw = true; 802 877 } 878 #if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES) 803 879 if (_cubeAxesActor2D != NULL) { 804 880 if (axis == X_AXIS) { … … 811 887 _needsRedraw = true; 812 888 } 889 #endif 813 890 } 814 891 … … 828 905 _needsRedraw = true; 829 906 } 907 #if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES) 830 908 if (_cubeAxesActor2D != NULL) { 831 909 if (axis == X_AXIS) { … … 838 916 _needsRedraw = true; 839 917 } 918 #endif 840 919 } 841 920 … … 1952 2031 double offsetX = pxOffsetX * pxToWorld; 1953 2032 double offsetY = pxOffsetY * pxToWorld; 2033 double winWidthWorld = _windowWidth * pxToWorld; 2034 double winHeightWorld = _windowHeight * pxToWorld; 1954 2035 double plotWidthWorld = imgWidthPx * pxToWorld; 1955 2036 double plotHeightWorld = imgHeightPx * pxToWorld; … … 1967 2048 _imgWorldDims[1] = height; 1968 2049 1969 camPos[0] = _imgWorldOrigin[0] - offsetX + (_windowWidth * pxToWorld)/2.0;1970 camPos[1] = _imgWorldOrigin[1] - offsetY + (_windowHeight * pxToWorld)/2.0;2050 camPos[0] = _imgWorldOrigin[0] - offsetX + winWidthWorld / 2.0; 2051 camPos[1] = _imgWorldOrigin[1] - offsetY + winHeightWorld / 2.0; 1971 2052 1972 2053 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); … … 1974 2055 camera->SetClippingRange(1, 2); 1975 2056 // Half of world coordinate height of viewport (Documentation is wrong) 1976 camera->SetParallelScale( _windowHeight * pxToWorld / 2.0);2057 camera->SetParallelScale(winHeightWorld / 2.0); 1977 2058 1978 2059 if (_imgCameraPlane == PLANE_XY) { … … 1993 2074 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0); 1994 2075 _cameraClipPlanes[3]->SetNormal(-1, 0, 0); 2076 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 2077 _cubeAxesActor->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld, 2078 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld, 2079 _imgCameraOffset, _imgCameraOffset); 2080 2081 _cubeAxesActor->XAxisVisibilityOn(); 2082 _cubeAxesActor->YAxisVisibilityOn(); 2083 _cubeAxesActor->ZAxisVisibilityOff(); 2084 #else 1995 2085 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld, 1996 2086 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld, … … 1999 2089 _cubeAxesActor2D->YAxisVisibilityOn(); 2000 2090 _cubeAxesActor2D->ZAxisVisibilityOff(); 2091 #endif 2001 2092 } else if (_imgCameraPlane == PLANE_ZY) { 2002 2093 // ZY plane … … 2016 2107 _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + plotWidthWorld); 2017 2108 _cameraClipPlanes[3]->SetNormal(0, 0, -1); 2109 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 2110 _cubeAxesActor->SetBounds(_imgCameraOffset, _imgCameraOffset, 2111 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld, 2112 _imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld); 2113 _cubeAxesActor->XAxisVisibilityOff(); 2114 _cubeAxesActor->YAxisVisibilityOn(); 2115 _cubeAxesActor->ZAxisVisibilityOn(); 2116 #else 2018 2117 _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset, 2019 2118 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld, … … 2022 2121 _cubeAxesActor2D->YAxisVisibilityOn(); 2023 2122 _cubeAxesActor2D->ZAxisVisibilityOn(); 2123 #endif 2024 2124 } else { 2025 2125 // XZ plane … … 2039 2139 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0); 2040 2140 _cameraClipPlanes[3]->SetNormal(-1, 0, 0); 2141 #if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES) 2142 _cubeAxesActor->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld, 2143 _imgCameraOffset, _imgCameraOffset, 2144 _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld); 2145 _cubeAxesActor->XAxisVisibilityOn(); 2146 _cubeAxesActor->YAxisVisibilityOff(); 2147 _cubeAxesActor->ZAxisVisibilityOn(); 2148 #else 2041 2149 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld, 2042 2150 _imgCameraOffset, _imgCameraOffset, … … 2045 2153 _cubeAxesActor2D->YAxisVisibilityOff(); 2046 2154 _cubeAxesActor2D->ZAxisVisibilityOn(); 2047 } 2155 #endif 2156 } 2157 2158 #if !defined(USE_CUSTOM_AXES) 2159 double xmin, xmax, ymin, ymax, zmin, zmax; 2160 _cubeAxesActor->GetBounds(xmin, xmax, ymin, ymax, zmin, zmax); 2161 _cubeAxesActor->SetXAxisRange(xmin, xmax); 2162 _cubeAxesActor->SetYAxisRange(ymin, ymax); 2163 _cubeAxesActor->SetZAxisRange(zmin, zmax); 2164 #endif 2048 2165 2049 2166 // Compute screen world coordinates … … 2781 2898 setCameraZoomRegion(_imgWorldOrigin[0], _imgWorldOrigin[1], 2782 2899 _imgWorldDims[0], _imgWorldDims[1]); 2783 resetAxes( );2900 resetAxes(bounds); 2784 2901 break; 2785 2902 case ORTHO: -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r3177 r3198 14 14 #include <typeinfo> 15 15 16 #include <vtkVersion.h> 17 #if (VTK_MAJOR_VERSION >= 6) 18 #define USE_VTK6 19 #endif 16 20 #include <vtkSmartPointer.h> 17 21 #ifdef USE_CUSTOM_AXES … … 753 757 #else 754 758 vtkSmartPointer<vtkCubeAxesActor> _cubeAxesActor; // For 3D view 759 #ifndef USE_VTK6 755 760 vtkSmartPointer<vtkCubeAxesActor2D> _cubeAxesActor2D; // For 2D view 761 #endif 756 762 #endif 757 763 vtkSmartPointer<vtkScalarBarActor> _scalarBarActor;
Note: See TracChangeset
for help on using the changeset viewer.