Changeset 3198 for trunk


Ignore:
Timestamp:
Dec 12, 2012, 11:40:06 AM (12 years ago)
Author:
ldelgass
Message:

When built for VTK 6, use 2D mode of CubeAxesActor? instead of CubeAxesActor2D

Location:
trunk/packages/vizservers/vtkvis
Files:
2 edited

Legend:

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

    r3194 r3198  
    421421{
    422422    TRACE("Resetting axes");
    423     if (_cubeAxesActor == NULL ||
    424         _cubeAxesActor2D == NULL) {
     423    if (_cubeAxesActor == NULL
     424#ifndef USE_VTK6
     425        || _cubeAxesActor2D == NULL
     426#endif
     427       ) {
    425428        initAxes();
    426429    }
    427430    if (_cameraMode == IMAGE) {
     431#if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES)
     432        _cubeAxesActor->SetUse2DMode(1);
     433#else
    428434        if (_renderer->HasViewProp(_cubeAxesActor)) {
    429435            TRACE("Removing 3D axes");
     
    434440            _renderer->AddViewProp(_cubeAxesActor2D);
    435441        }
     442#endif
    436443    } else {
     444#if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES)
     445        _cubeAxesActor->SetUse2DMode(0);
     446#else
    437447        if (_renderer->HasViewProp(_cubeAxesActor2D)) {
    438448            TRACE("Removing 2D axes");
     
    443453            _renderer->AddViewProp(_cubeAxesActor);
    444454        }
    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]);
    476510    }
    477511}
     
    497531#if defined(USE_VTK6) && !defined(USE_CUSTOM_AXES)
    498532    _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);
    499542    _cubeAxesActor->SetEnableDistanceLOD(0);
     543    _cubeAxesActor->SetViewAngleLODThreshold(0);
    500544    _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);
    501552#endif
    502553
     
    504555    if (_cubeAxesActor2D == NULL)
    505556        _cubeAxesActor2D = vtkSmartPointer<vtkRpCubeAxesActor2D>::New();
    506 #else
     557#elif !defined(USE_VTK6)
    507558    if (_cubeAxesActor2D == NULL)
    508559        _cubeAxesActor2D = vtkSmartPointer<vtkCubeAxesActor2D>::New();
    509560#endif
    510561
     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
    511575    _cubeAxesActor2D->SetCamera(_renderer->GetActiveCamera());
    512576    _cubeAxesActor2D->ZAxisVisibilityOff();
     
    564628            _renderer->AddViewProp(_cubeAxesActor);
    565629    }
     630#endif
    566631}
    567632
     
    572637{
    573638    if (_cubeAxesActor == NULL)
    574         initAxes();
     639        return;
     640
    575641    switch (mode) {
    576642    case FLY_STATIC_EDGES:
     
    620686            _cubeAxesActor->GetTitleTextProperty(i)->SetColor(color);
    621687            _cubeAxesActor->GetLabelTextProperty(i)->SetColor(color);
     688            _cubeAxesActor->GetLabelTextProperty(i)->SetOpacity(1.0);
    622689        }
    623690        _cubeAxesActor->GetXAxesLinesProperty()->SetColor(color);
     
    630697        _needsRedraw = true;
    631698    }
     699#if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES)
    632700    if (_cubeAxesActor2D != NULL) {
    633701        _cubeAxesActor2D->GetProperty()->SetColor(color);
     
    645713        _needsRedraw = true;
    646714    }
     715#endif
    647716}
    648717
     
    656725        _needsRedraw = true;
    657726    }
     727#if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES)
    658728    if (_cubeAxesActor2D != NULL) {
    659729        _cubeAxesActor2D->SetVisibility((state ? 1 : 0));
    660730        _needsRedraw = true;
    661731    }
     732#endif
    662733}
    663734
     
    730801        _needsRedraw = true;
    731802    }
     803#if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES)
    732804    if (_cubeAxesActor2D != NULL) {
    733805        if (axis == X_AXIS) {
     
    740812        _needsRedraw = true;
    741813    }
     814#endif
    742815}
    743816
     
    774847        _needsRedraw = true;
    775848    }
     849#if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES)
    776850    if (_cubeAxesActor2D != NULL) {
    777851        if (axis == X_AXIS) {
     
    784858        _needsRedraw = true;
    785859    }
     860#endif
    786861}
    787862
     
    801876        _needsRedraw = true;
    802877    }
     878#if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES)
    803879    if (_cubeAxesActor2D != NULL) {
    804880        if (axis == X_AXIS) {
     
    811887        _needsRedraw = true;
    812888    }
     889#endif
    813890}
    814891
     
    828905        _needsRedraw = true;
    829906    }
     907#if !defined(USE_VTK6) || defined(USE_CUSTOM_AXES)
    830908    if (_cubeAxesActor2D != NULL) {
    831909        if (axis == X_AXIS) {
     
    838916        _needsRedraw = true;
    839917    }
     918#endif
    840919}
    841920
     
    19522031    double offsetX = pxOffsetX * pxToWorld;
    19532032    double offsetY = pxOffsetY * pxToWorld;
     2033    double winWidthWorld = _windowWidth * pxToWorld;
     2034    double winHeightWorld = _windowHeight * pxToWorld;
    19542035    double plotWidthWorld = imgWidthPx * pxToWorld;
    19552036    double plotHeightWorld = imgHeightPx * pxToWorld;
     
    19672048    _imgWorldDims[1] = height;
    19682049
    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;
    19712052
    19722053    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
     
    19742055    camera->SetClippingRange(1, 2);
    19752056    // Half of world coordinate height of viewport (Documentation is wrong)
    1976     camera->SetParallelScale(_windowHeight * pxToWorld / 2.0);
     2057    camera->SetParallelScale(winHeightWorld / 2.0);
    19772058
    19782059    if (_imgCameraPlane == PLANE_XY) {
     
    19932074        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0);
    19942075        _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
    19952085        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld,
    19962086                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld,
     
    19992089        _cubeAxesActor2D->YAxisVisibilityOn();
    20002090        _cubeAxesActor2D->ZAxisVisibilityOff();
     2091#endif
    20012092    } else if (_imgCameraPlane == PLANE_ZY) {
    20022093        // ZY plane
     
    20162107        _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + plotWidthWorld);
    20172108        _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
    20182117        _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset,
    20192118                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld,
     
    20222121        _cubeAxesActor2D->YAxisVisibilityOn();
    20232122        _cubeAxesActor2D->ZAxisVisibilityOn();
     2123#endif
    20242124    } else {
    20252125        // XZ plane
     
    20392139        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0);
    20402140        _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
    20412149        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld,
    20422150                                    _imgCameraOffset, _imgCameraOffset,
     
    20452153        _cubeAxesActor2D->YAxisVisibilityOff();
    20462154        _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
    20482165
    20492166    // Compute screen world coordinates
     
    27812898        setCameraZoomRegion(_imgWorldOrigin[0], _imgWorldOrigin[1],
    27822899                            _imgWorldDims[0], _imgWorldDims[1]);
    2783         resetAxes();
     2900        resetAxes(bounds);
    27842901        break;
    27852902    case ORTHO:
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r3177 r3198  
    1414#include <typeinfo>
    1515
     16#include <vtkVersion.h>
     17#if (VTK_MAJOR_VERSION >= 6)
     18#define USE_VTK6
     19#endif
    1620#include <vtkSmartPointer.h>
    1721#ifdef USE_CUSTOM_AXES
     
    753757#else
    754758    vtkSmartPointer<vtkCubeAxesActor> _cubeAxesActor; // For 3D view
     759#ifndef USE_VTK6
    755760    vtkSmartPointer<vtkCubeAxesActor2D> _cubeAxesActor2D; // For 2D view
     761#endif
    756762#endif
    757763    vtkSmartPointer<vtkScalarBarActor> _scalarBarActor;
Note: See TracChangeset for help on using the changeset viewer.