VTK6.0 label size problem of vtkScalarBarActor

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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
3139 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

chasank
64 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
3139 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
3139 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

chasank
64 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
3139 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

chasank
64 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

Bill Lorensen
3139 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

David Thompson-2
225 posts
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 | More 

Re: VTK6.0 label size problem of vtkScalarBarActor

Miguel
21 posts
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

« Return to VTK - Users  |  2046 views

转:http://vtk.1045678.n5.nabble.com/VTK6-0-label-size-problem-of-vtkScalarBarActor-td5721585.html

Tree Size Problem

10-27

DescriptionnnTrees are used to represent the evolutionary relationship of species. An evolutionary tree is a edge-weighted tree with each leaf representing one species. The distance between two leaves on the tree represents the dissimilarity of these two species. An important issue in computational biology is to construct the evolutionary tree from the observed dissimilarities. nLet N = 1..n. An n*n matrix M is a metric over N if it is symmetric, nonnegative, and M[i, j] + M[j, k] >= M[i, k] for any 1<= i, j, k <=n (i.e., triangle inequality). A metric is a tree metric if it can be realized by a tree, i.e., there exists an edge-weighted tree T such that n1. the leaf set is N; n2. the weight of each edge is nonnegative; n3. and d(T, i, j) = M[i, j] for any i, j <= N, where d(T, i, j) is the shortest path length between i and j on the tree T. nFor example, the following matrix is a tree metric. The corresponding tree is given in Figure 8. nn![](http://poj.org/images/1344_1.jpg)nThe size of a tree is defined to be the total weight of the tree edges. For a tree metric, it has been shown that the tree size is unique, i.e., it is impossible to find two trees of different sizes realizing the same tree metric. Your task is to design a program to compute the tree sizes of the given tree metrics. The following simple example may be helpful. For the case of only two species, the tree has only one edge and the tree size is just the distance between the two species. Let us consider the case of three species a, b, and c. Let T be the corresponding tree. Since T has three leaves, there is an internal node x. By definition, the path length d(T, a, b) = M[a, b]. Since x is a vertex on the path between a and b, all we need to do is to determine the weight (length) of edge (x, c). Let w(x, c) denote the weight of edge (x, c). We have nw(x, c) + w(x, a) = M[a, c], nw(x, c) + w(x, b) = M[b, c], nand w(x, a) + w(x, b) = M[a, b]. nTherefore, w(x, c) = (M[a, c] +M[b, c] -M[a, b])/2. nInputnnThe input file consists of several test cases. The first line of each test case is a positive integer n, 2 < n < 30. The following n - 1 lines represent the upper triangle of the tree metric, but the diagonal is not included. Each line is for one row, and elements are separated by spaces. All the elements are nonnegative integers less than 100. The last case is followed by a "0" to indicate the end of input. You may assume that the test data are all tree metrics, and it is not necessary to check them. nFurthermore, the size of a tree is the sum of all integers in the test case except the integers in the first line of the test case. nOutputnnFor each test case, output the tree size in one line.nSample Inputnn5n5 9 12 8n8 11 7n5 1n4n4n15 36 60n31 55n36n0nSample Outputnn15n71

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭