VTK6.0 label size problem of vtkScalarBarActor

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

VTK6.0 label size problem of vtkScalarBarActor

chasank
Hi,

In vtk5.10.1 we can arrange label size of vtkScalarBarActor as we want, as you see below.



But after we ported our project from vtk5.10.1 to vtk6.0, we cannot arrange label size.



Code we wrote for this operation is below.

    this->colorBar = vtkSmartPointer < vtkScalarBarActor> :: New();
    this->colorBar->SetMaximumNumberOfColors(256);
    this->colorBar->SetLookupTable(this->lookupTable);
    this->colorBar->SetHeight(0.10);
    this->colorBar->SetWidth(0.90);
    this->colorBar->SetPosition(0.04, 0.02);
    this->colorBar->SetOrientationToHorizontal();
    this->colorBar->SetNumberOfLabels(3);
    this->colorBar->SetLabelFormat("%.4g");
    this->colorBar->VisibilityOn();

We ask your help to size label as we wish. Which method(s) do we need to use?

Sincerely.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
Can you provide a small, compilable example that illustrates the problem?

Bill



On Tue, Jun 25, 2013 at 9:46 AM, chasank <[hidden email]> wrote:
Hi,

In vtk5.10.1 we can arrange label size of vtkScalarBarActor as we want, as
you see below.

<http://vtk.1045678.n5.nabble.com/file/n5721585/colorbar_calisan.png>

But after we ported our project from vtk5.10.1 to vtk6.0, we cannot arrange
label size.

<http://vtk.1045678.n5.nabble.com/file/n5721585/colorbar_calismayan.png>

Code we wrote for this operation is below.

    this->colorBar = vtkSmartPointer < vtkScalarBarActor> :: New();
    this->colorBar->SetMaximumNumberOfColors(256);
    this->colorBar->SetLookupTable(this->lookupTable);
    this->colorBar->SetHeight(0.10);
    this->colorBar->SetWidth(0.90);
    this->colorBar->SetPosition(0.04, 0.02);
    this->colorBar->SetOrientationToHorizontal();
    this->colorBar->SetNumberOfLabels(3);
    this->colorBar->SetLabelFormat("%.4g");
    this->colorBar->VisibilityOn();

We ask your help to size label as we wish. Which method(s) do we need to
use?

Sincerely.



--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK6-0-label-size-problem-of-vtkScalarBarActor-tp5721585.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

chasank
It's not small enough but it will illustrate the problem;

int main(int argc, char **argv)
{
    vtkSmartPointer< vtkImageData > imageData = vtkSmartPointer < vtkImageData > :: New();
   
    itk::Image< signed short, 3 > ImageType3D;

    try
    {
        itk::ImageFileReader< ImageType3D >::Pointer reader = itk::ImageFileReader< ImageType3D >::New();
        itk::NiftiImageIO::Pointer niftiIO = itk::NiftiImageIO::New();
        reader->SetFileName("C:\\niftis\\ch2better.nii.gz");
        reader->SetImageIO(niftiIO);
        reader->UpdateLargestPossibleRegion();
        reader->Update();

        itk::ImageToVTKImageFilter< ImageType3D >::Pointer connector = itk::ImageToVTKImageFilter< ImageType3D >::New();
        connector->SetInput(reader->GetOutput());
        connector->Update();

        imageData->DeepCopy(connector->GetOutput());

    }
    catch ( itk::ExceptionObject & excp )
    {
        std::cerr << excp << std::endl;
    }

    vtkSmartPointer< vtkLookupTable > table = vtkSmartPointer< vtkLookupTable >::New();
    table->SetNumberOfTableValues(256);
    table->SetTableRange(range[0], range[1]);
    table->SetRampToLinear();
    table->SetScaleToLinear();
    table->GlobalWarningDisplayOff();
    table->Build();

    LookupTableReader *lutReader = new LookupTableReader("..\\luts\\grayscale");
    unsigned char *r = lutReader->GetRed();
    unsigned char *g = lutReader->GetGreen();
    unsigned char *b = lutReader->GetBlue();

    for (int i = 0; i <= 255; i++)
    {
        if ( i < 5 )
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b + i)/255.0, 0.0);
        }
        else if ( i > 250)
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b + i)/255.0, 1.0);
        }
        else
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b + i)/255.0, i/255.0);
        }
    }

    vtkSmartPointer< vtkScalarBarActor > colorBar = vtkSmartPointer< vtkScalarBarActor >::New();
    colorBar->SetMaximumNumberOfColors(256);
    colorBar->SetLookupTable(table);
    colorBar->SetHeight(0.12);
    colorBar->SetWidth(0.90);
    colorBar->SetPosition(0.04, 0.02);
    colorBar->SetPosition2(0.90, 0.20);
    colorBar->SetOrientationToHorizontal();
    colorBar->SetNumberOfLabels(3);
    colorBar->SetLabelFormat("%.4g");
    colorBar->VisibilityOn();

    vtkSmartPointer< vtkRenderer > renderer = vtkSmartPointer< vtkRenderer >::New();
    vtkSmartPointer< vtkRenderWindow > renderWindow = vtkSmartPointer< vtkRenderWindow >::New();
    vtkSmartPointer< vtkRenderWindowInteractor > iren = vtkSmartPointer< vtkRenderWindowInteractor >::New();
    vtkSmartPointer< vtkInteractorStyleImage > interactorStyle = vtkSmartPointer< vtkInteractorStyleImage >::New();

    double xViewRightVector[3] = {0, 1, 0};
    double xViewUpVector[3] = {0, 0, 1};

    double yViewRightVector[3] = {1, 0, 0};
    double yViewUpVector[3] = {0, 0, 1};

    double zViewRightVector[3] = { 1, 0, 0 };
    double ZViewUpVector[3] = {0, 1, 0};

    vtkSmartPointer< CallBack > callBack = vtkSmartPointer< CallBack >::New();

    interactorStyle->AddObserver(vtkCommand::MouseWheelForwardEvent, callBack);
    interactorStyle->AddObserver(vtkCommand::MouseWheelBackwardEvent, callBack);
    interactorStyle->AddObserver(vtkCommand::StartWindowLevelEvent, callBack);
    interactorStyle->AddObserver(vtkCommand::WindowLevelEvent, callBack);
    interactorStyle->AddObserver(vtkCommand::ResetWindowLevelEvent, callBack);
    interactorStyle->SetInteractionModeToImage3D();
    interactorStyle->SetXViewRightVector(xViewRightVector);
    interactorStyle->SetXViewUpVector(xViewUpVector);
    interactorStyle->SetYViewRightVector(yViewRightVector);
    interactorStyle->SetYViewUpVector(yViewUpVector);
    interactorStyle->SetZViewRightVector(zViewRightVector);
    interactorStyle->SetZViewUpVector(ZViewUpVector);
    interactorStyle->SetImageOrientation(xViewRightVector, xViewUpVector);

    renderWindow->AddRenderer(renderer);
    iren->SetInteractorStyle(interactorStyle);
    iren->SetRenderWindow(renderWindow);

    vtkSmartPointer< vtkImageResliceMapper > mapper = vtkSmartPointer< vtkImageResliceMapper >::New();
    mapper->SetInputDataObject(imageData);
    mapper->SliceFacesCameraOn();
    mapper->SliceAtFocalPointOn();
    mapper->SetImageSampleFactor(2);
    mapper->BorderOn();

    double level = 0.5 * (range[0] + range[1]);
    double window = range[1] - range[0];

    vtkSmartPointer< vtkImageProperty > property = vtkSmartPointer< vtkImageProperty >::New();
    property->SetColorLevel(level);
    property->SetColorWindow(window);
    property->SetInterpolationTypeToLinear();
    property->SetLookupTable(table);
    property->SetAmbient(1.0);
    property->SetDiffuse(1.0);
    property->SetOpacity(1.0);

    double *center = imageData->GetCenter();

    vtkSmartPointer< vtkMatrix4x4 > matrix = vtkSmartPointer< vtkMatrix4x4 >::New();
    matrix->Identity();
    matrix->SetElement(0, 3, center[0]);
    matrix->SetElement(1, 3, center[1]);
    matrix->SetElement(2, 3, center[2]);
    matrix->Modified();

    vtkSmartPointer< vtkImageSlice > slice = vtkSmartPointer< vtkImageSlice >::New();
    slice->SetMapper(mapper);
    slice->SetProperty(property);
    slice->SetUserMatrix(matrix);

    renderer->AddViewProp(slice);
    renderer->AddActor2D(colorBar);

    vtkSmartPointer< vtkCamera > camera = renderer->GetActiveCamera();
    camera->ParallelProjectionOn();
    camera->SetFocalPoint(0.0, 0.0, 0.0);
    camera->SetPosition(1.0, 0.0, 0.0);
    camera->SetViewUp(0.0, 0.0, 1.0);

    renderer->ResetCamera();

    iren->Initialize();
    iren->Start();
    renderWindow->Render();

    return 0;
}

Sample output is below;

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
Sorry. It won't compile without the include's. If you provide a cut/past compilable example, folks will help quicker.



On Tue, Jun 25, 2013 at 3:56 PM, chasank <[hidden email]> wrote:
It's not small enough but it will illustrate the problem;

int main(int argc, char **argv)
{
    vtkSmartPointer< vtkImageData > imageData = vtkSmartPointer <
vtkImageData > :: New();

    itk::Image< signed short, 3 > ImageType3D;

    try
    {
        itk::ImageFileReader< ImageType3D >::Pointer reader =
itk::ImageFileReader< ImageType3D >::New();
        itk::NiftiImageIO::Pointer niftiIO = itk::NiftiImageIO::New();
        reader->SetFileName("C:\\niftis\\ch2better.nii.gz");
        reader->SetImageIO(niftiIO);
        reader->UpdateLargestPossibleRegion();
        reader->Update();

        itk::ImageToVTKImageFilter< ImageType3D >::Pointer connector =
itk::ImageToVTKImageFilter< ImageType3D >::New();
        connector->SetInput(reader->GetOutput());
        connector->Update();

        imageData->DeepCopy(connector->GetOutput());

    }
    catch ( itk::ExceptionObject & excp )
    {
        std::cerr << excp << std::endl;
    }

    vtkSmartPointer< vtkLookupTable > table = vtkSmartPointer<
vtkLookupTable >::New();
    table->SetNumberOfTableValues(256);
    table->SetTableRange(range[0], range[1]);
    table->SetRampToLinear();
    table->SetScaleToLinear();
    table->GlobalWarningDisplayOff();
    table->Build();

    LookupTableReader *lutReader = new
LookupTableReader("..\\luts\\grayscale");
    unsigned char *r = lutReader->GetRed();
    unsigned char *g = lutReader->GetGreen();
    unsigned char *b = lutReader->GetBlue();

    for (int i = 0; i <= 255; i++)
    {
        if ( i < 5 )
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b +
i)/255.0, 0.0);
        }
        else if ( i > 250)
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b +
i)/255.0, 1.0);
        }
        else
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b +
i)/255.0, i/255.0);
        }
    }

    vtkSmartPointer< vtkScalarBarActor > colorBar = vtkSmartPointer<
vtkScalarBarActor >::New();
    colorBar->SetMaximumNumberOfColors(256);
    colorBar->SetLookupTable(table);
    colorBar->SetHeight(0.12);
    colorBar->SetWidth(0.90);
    colorBar->SetPosition(0.04, 0.02);
    colorBar->SetPosition2(0.90, 0.20);
    colorBar->SetOrientationToHorizontal();
    colorBar->SetNumberOfLabels(3);
    colorBar->SetLabelFormat("%.4g");
    colorBar->VisibilityOn();

    vtkSmartPointer< vtkRenderer > renderer = vtkSmartPointer< vtkRenderer
>::New();
    vtkSmartPointer< vtkRenderWindow > renderWindow = vtkSmartPointer<
vtkRenderWindow >::New();
    vtkSmartPointer< vtkRenderWindowInteractor > iren = vtkSmartPointer<
vtkRenderWindowInteractor >::New();
    vtkSmartPointer< vtkInteractorStyleImage > interactorStyle =
vtkSmartPointer< vtkInteractorStyleImage >::New();

    double xViewRightVector[3] = {0, 1, 0};
    double xViewUpVector[3] = {0, 0, 1};

    double yViewRightVector[3] = {1, 0, 0};
    double yViewUpVector[3] = {0, 0, 1};

    double zViewRightVector[3] = { 1, 0, 0 };
    double ZViewUpVector[3] = {0, 1, 0};

    vtkSmartPointer< CallBack > callBack = vtkSmartPointer< CallBack
>::New();

    interactorStyle->AddObserver(vtkCommand::MouseWheelForwardEvent,
callBack);
    interactorStyle->AddObserver(vtkCommand::MouseWheelBackwardEvent,
callBack);
    interactorStyle->AddObserver(vtkCommand::StartWindowLevelEvent,
callBack);
    interactorStyle->AddObserver(vtkCommand::WindowLevelEvent, callBack);
    interactorStyle->AddObserver(vtkCommand::ResetWindowLevelEvent,
callBack);
    interactorStyle->SetInteractionModeToImage3D();
    interactorStyle->SetXViewRightVector(xViewRightVector);
    interactorStyle->SetXViewUpVector(xViewUpVector);
    interactorStyle->SetYViewRightVector(yViewRightVector);
    interactorStyle->SetYViewUpVector(yViewUpVector);
    interactorStyle->SetZViewRightVector(zViewRightVector);
    interactorStyle->SetZViewUpVector(ZViewUpVector);
    interactorStyle->SetImageOrientation(xViewRightVector, xViewUpVector);

    renderWindow->AddRenderer(renderer);
    iren->SetInteractorStyle(interactorStyle);
    iren->SetRenderWindow(renderWindow);

    vtkSmartPointer< vtkImageResliceMapper > mapper = vtkSmartPointer<
vtkImageResliceMapper >::New();
    mapper->SetInputDataObject(imageData);
    mapper->SliceFacesCameraOn();
    mapper->SliceAtFocalPointOn();
    mapper->SetImageSampleFactor(2);
    mapper->BorderOn();

    double level = 0.5 * (range[0] + range[1]);
    double window = range[1] - range[0];

    vtkSmartPointer< vtkImageProperty > property = vtkSmartPointer<
vtkImageProperty >::New();
    property->SetColorLevel(level);
    property->SetColorWindow(window);
    property->SetInterpolationTypeToLinear();
    property->SetLookupTable(table);
    property->SetAmbient(1.0);
    property->SetDiffuse(1.0);
    property->SetOpacity(1.0);

    double *center = imageData->GetCenter();

    vtkSmartPointer< vtkMatrix4x4 > matrix = vtkSmartPointer< vtkMatrix4x4
>::New();
    matrix->Identity();
    matrix->SetElement(0, 3, center[0]);
    matrix->SetElement(1, 3, center[1]);
    matrix->SetElement(2, 3, center[2]);
    matrix->Modified();

    vtkSmartPointer< vtkImageSlice > slice = vtkSmartPointer< vtkImageSlice
>::New();
    slice->SetMapper(mapper);
    slice->SetProperty(property);
    slice->SetUserMatrix(matrix);

    renderer->AddViewProp(slice);
    renderer->AddActor2D(colorBar);

    vtkSmartPointer< vtkCamera > camera = renderer->GetActiveCamera();
    camera->ParallelProjectionOn();
    camera->SetFocalPoint(0.0, 0.0, 0.0);
    camera->SetPosition(1.0, 0.0, 0.0);
    camera->SetViewUp(0.0, 0.0, 1.0);

    renderer->ResetCamera();

    iren->Initialize();
    iren->Start();
    renderWindow->Render();

    return 0;
}

Sample output is below;
<http://vtk.1045678.n5.nabble.com/file/n5721597/colorBar_problem.png>




--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK6-0-label-size-problem-of-vtkScalarBarActor-tp5721585p5721597.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
Also, do not read a file no one can read. You are better off creating an image in the code.
See for example:
http://itk.org/Wiki/VTK/Examples/Cxx/Images/ImageRFFT
or
http://itk.org/Wiki/VTK/Examples/Cxx/Images/ImageShiftScale



On Tue, Jun 25, 2013 at 4:09 PM, Bill Lorensen <[hidden email]> wrote:
Sorry. It won't compile without the include's. If you provide a cut/past compilable example, folks will help quicker.



On Tue, Jun 25, 2013 at 3:56 PM, chasank <[hidden email]> wrote:
It's not small enough but it will illustrate the problem;

int main(int argc, char **argv)
{
    vtkSmartPointer< vtkImageData > imageData = vtkSmartPointer <
vtkImageData > :: New();

    itk::Image< signed short, 3 > ImageType3D;

    try
    {
        itk::ImageFileReader< ImageType3D >::Pointer reader =
itk::ImageFileReader< ImageType3D >::New();
        itk::NiftiImageIO::Pointer niftiIO = itk::NiftiImageIO::New();
        reader->SetFileName("C:\\niftis\\ch2better.nii.gz");
        reader->SetImageIO(niftiIO);
        reader->UpdateLargestPossibleRegion();
        reader->Update();

        itk::ImageToVTKImageFilter< ImageType3D >::Pointer connector =
itk::ImageToVTKImageFilter< ImageType3D >::New();
        connector->SetInput(reader->GetOutput());
        connector->Update();

        imageData->DeepCopy(connector->GetOutput());

    }
    catch ( itk::ExceptionObject & excp )
    {
        std::cerr << excp << std::endl;
    }

    vtkSmartPointer< vtkLookupTable > table = vtkSmartPointer<
vtkLookupTable >::New();
    table->SetNumberOfTableValues(256);
    table->SetTableRange(range[0], range[1]);
    table->SetRampToLinear();
    table->SetScaleToLinear();
    table->GlobalWarningDisplayOff();
    table->Build();

    LookupTableReader *lutReader = new
LookupTableReader("..\\luts\\grayscale");
    unsigned char *r = lutReader->GetRed();
    unsigned char *g = lutReader->GetGreen();
    unsigned char *b = lutReader->GetBlue();

    for (int i = 0; i <= 255; i++)
    {
        if ( i < 5 )
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b +
i)/255.0, 0.0);
        }
        else if ( i > 250)
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b +
i)/255.0, 1.0);
        }
        else
        {
            table->SetTableValue(i, *(r + i)/255.0, *(g + i)/255.0, *(b +
i)/255.0, i/255.0);
        }
    }

    vtkSmartPointer< vtkScalarBarActor > colorBar = vtkSmartPointer<
vtkScalarBarActor >::New();
    colorBar->SetMaximumNumberOfColors(256);
    colorBar->SetLookupTable(table);
    colorBar->SetHeight(0.12);
    colorBar->SetWidth(0.90);
    colorBar->SetPosition(0.04, 0.02);
    colorBar->SetPosition2(0.90, 0.20);
    colorBar->SetOrientationToHorizontal();
    colorBar->SetNumberOfLabels(3);
    colorBar->SetLabelFormat("%.4g");
    colorBar->VisibilityOn();

    vtkSmartPointer< vtkRenderer > renderer = vtkSmartPointer< vtkRenderer
>::New();
    vtkSmartPointer< vtkRenderWindow > renderWindow = vtkSmartPointer<
vtkRenderWindow >::New();
    vtkSmartPointer< vtkRenderWindowInteractor > iren = vtkSmartPointer<
vtkRenderWindowInteractor >::New();
    vtkSmartPointer< vtkInteractorStyleImage > interactorStyle =
vtkSmartPointer< vtkInteractorStyleImage >::New();

    double xViewRightVector[3] = {0, 1, 0};
    double xViewUpVector[3] = {0, 0, 1};

    double yViewRightVector[3] = {1, 0, 0};
    double yViewUpVector[3] = {0, 0, 1};

    double zViewRightVector[3] = { 1, 0, 0 };
    double ZViewUpVector[3] = {0, 1, 0};

    vtkSmartPointer< CallBack > callBack = vtkSmartPointer< CallBack
>::New();

    interactorStyle->AddObserver(vtkCommand::MouseWheelForwardEvent,
callBack);
    interactorStyle->AddObserver(vtkCommand::MouseWheelBackwardEvent,
callBack);
    interactorStyle->AddObserver(vtkCommand::StartWindowLevelEvent,
callBack);
    interactorStyle->AddObserver(vtkCommand::WindowLevelEvent, callBack);
    interactorStyle->AddObserver(vtkCommand::ResetWindowLevelEvent,
callBack);
    interactorStyle->SetInteractionModeToImage3D();
    interactorStyle->SetXViewRightVector(xViewRightVector);
    interactorStyle->SetXViewUpVector(xViewUpVector);
    interactorStyle->SetYViewRightVector(yViewRightVector);
    interactorStyle->SetYViewUpVector(yViewUpVector);
    interactorStyle->SetZViewRightVector(zViewRightVector);
    interactorStyle->SetZViewUpVector(ZViewUpVector);
    interactorStyle->SetImageOrientation(xViewRightVector, xViewUpVector);

    renderWindow->AddRenderer(renderer);
    iren->SetInteractorStyle(interactorStyle);
    iren->SetRenderWindow(renderWindow);

    vtkSmartPointer< vtkImageResliceMapper > mapper = vtkSmartPointer<
vtkImageResliceMapper >::New();
    mapper->SetInputDataObject(imageData);
    mapper->SliceFacesCameraOn();
    mapper->SliceAtFocalPointOn();
    mapper->SetImageSampleFactor(2);
    mapper->BorderOn();

    double level = 0.5 * (range[0] + range[1]);
    double window = range[1] - range[0];

    vtkSmartPointer< vtkImageProperty > property = vtkSmartPointer<
vtkImageProperty >::New();
    property->SetColorLevel(level);
    property->SetColorWindow(window);
    property->SetInterpolationTypeToLinear();
    property->SetLookupTable(table);
    property->SetAmbient(1.0);
    property->SetDiffuse(1.0);
    property->SetOpacity(1.0);

    double *center = imageData->GetCenter();

    vtkSmartPointer< vtkMatrix4x4 > matrix = vtkSmartPointer< vtkMatrix4x4
>::New();
    matrix->Identity();
    matrix->SetElement(0, 3, center[0]);
    matrix->SetElement(1, 3, center[1]);
    matrix->SetElement(2, 3, center[2]);
    matrix->Modified();

    vtkSmartPointer< vtkImageSlice > slice = vtkSmartPointer< vtkImageSlice
>::New();
    slice->SetMapper(mapper);
    slice->SetProperty(property);
    slice->SetUserMatrix(matrix);

    renderer->AddViewProp(slice);
    renderer->AddActor2D(colorBar);

    vtkSmartPointer< vtkCamera > camera = renderer->GetActiveCamera();
    camera->ParallelProjectionOn();
    camera->SetFocalPoint(0.0, 0.0, 0.0);
    camera->SetPosition(1.0, 0.0, 0.0);
    camera->SetViewUp(0.0, 0.0, 1.0);

    renderer->ResetCamera();

    iren->Initialize();
    iren->Start();
    renderWindow->Render();

    return 0;
}

Sample output is below;
<http://vtk.1045678.n5.nabble.com/file/n5721597/colorBar_problem.png>




--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK6-0-label-size-problem-of-vtkScalarBarActor-tp5721585p5721597.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com



--
Unpaid intern in BillsBasement at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

chasank
Include files;

#include <iostream>
#include <sstream>

#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkNiftiImageIO.h>
#include <itkImageToVTKImageFilter.h>

#include <vtkImageData.h>
#include <vtkSmartPointer.h>
#include <vtkLookupTable.h>
#include <vtkScalarBarActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleImage.h>
#include <vtkImageResliceMapper.h>
#include <vtkImageProperty.h>
#include <vtkMatrix4x4.h>
#include <vtkImageSlice.h>
#include <vtkCamera.h>
#include <vtkCommand.h>
#include <vtkTextProperty.h>

The grayscale file is a binary file for lookup table. It is not important, lookup table is built is identical with;

table = vtkSmartPointer< vtkLookupTable >::New();
table->SetValueRange(0.0, 1.0);
table->SetRampToLinear();
table->SetScaleToLinear();
table->Build();


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
I'm sorry. I think you missed my point. If you provide a complete, cut-able, compilable and runnable example that illustrates your problem, then it makes it easy for us to reproduce and possibly solve your problem.



On Tue, Jun 25, 2013 at 4:27 PM, chasank <[hidden email]> wrote:
Include files;

#include <iostream>
#include <sstream>

#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkNiftiImageIO.h>
#include <itkImageToVTKImageFilter.h>

#include <vtkImageData.h>
#include <vtkSmartPointer.h>
#include <vtkLookupTable.h>
#include <vtkScalarBarActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleImage.h>
#include <vtkImageResliceMapper.h>
#include <vtkImageProperty.h>
#include <vtkMatrix4x4.h>
#include <vtkImageSlice.h>
#include <vtkCamera.h>
#include <vtkCommand.h>
#include <vtkTextProperty.h>

The grayscale file is a binary file for lookup table. It is not important,
lookup table is built is identical with;

table = vtkSmartPointer< vtkLookupTable >::New();
table->SetValueRange(0.0, 1.0);
table->SetRampToLinear();
table->SetScaleToLinear();
table->Build();






--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK6-0-label-size-problem-of-vtkScalarBarActor-tp5721585p5721602.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

chasank
No I didn't miss the point you have mentioned about. The problem is, I didn't want to fill the page with full of code. Because the code is basic visualization pipeline. The problem is vtkScalarBarActor's new behaviors implemented in vtk6.0.0. The same code with 5.10.1 visualizes the scalar bar like at the first picture of my first post.

The problem is vtkScalarBarActor tries to rescale according to size of render window the labels always. It is not possible to assign a fixed font size with vtkTextProperty.  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
I can't help you.



On Tue, Jun 25, 2013 at 4:57 PM, chasank <[hidden email]> wrote:
No I didn't miss the point you have mentioned about. The problem is, I didn't
want to fill the page with full of code. Because the code is basic
visualization pipeline. The problem is vtkScalarBarActor's new behaviors
implemented in vtk6.0.0. The same code with 5.10.1 visualizes the scalar bar
like at the first picture of my first post.

The problem is vtkScalarBarActor tries to rescale according to size of
render window the labels always. It is not possible to assign a fixed font
size with vtkTextProperty.



--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK6-0-label-size-problem-of-vtkScalarBarActor-tp5721585p5721606.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

David Thompson-2
In reply to this post by chasank
> ... The problem is vtkScalarBarActor tries to rescale according to size of
> render window the labels always. It is not possible to assign a fixed font
> size with vtkTextProperty.   ...


If you would like a version of the scalar bar actor that does not resize fonts, see the version in ParaView named vtkPVScalarBarActor:

http://paraview.org/gitweb?p=ParaView.git;a=blob_plain;f=ParaViewCore/VTKExtensions/Rendering/vtkPVScalarBarActor.h;hb=HEAD
http://paraview.org/gitweb?p=ParaView.git;a=blob_plain;f=ParaViewCore/VTKExtensions/Rendering/vtkPVScalarBarActor.cxx;hb=HEAD

        David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: VTK6.0 label size problem of vtkScalarBarActor

Miguel
Hello,

I am taking David's suggestion on vtkPVScalarBarActor. However, I am facing an issue and, hopefully, someone here can help. I am on windows 64bit, vtk 7.1.1, visual studio 2013.

I am setting my scalebar with:

sbar->SetAddRangeAnnotations(0);
sbar->SetNumberOfLabels(0);

const double* range = GetLookUpTableForScaleBar()->GetRange();
double dr = range[1] - range[0];
sbar->AddValueLabelIfUnoccluded(0, 105, dr);
sbar->AddValueLabelIfUnoccluded(-1, 15, dr);
sbar->AddValueLabelIfUnoccluded(1, 200, dr);

But these labels are not drawn. When I set up SetNumberOfLabels(3), then 3 automatic labels are shown, and not the ones I indicated. As for the values (105, 15, 200) they are in line with the values returned from the vtkPVScalarBarActor automatic labels.

Any suggestions?

Another question, will this class be included in VTK 8.0 ?

Best regards,
Miguel
Loading...