<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Bill,<br>
      <br>
      Thanks for the reply.<br>
      <br>
      This example don't reproduce my bug, but if I add a vtkTexture to
      superquadricActor and I add a vtkActor2D to the sceneRenderer<span
        class="sy2"></span>, the vtkActor2D doesn't display correctly.<br>
      <br>
      you can check my precedent simple example if you want with this<br>
      <br>
      CMakeLists.txt:<br>
      <blockquote>cmake_minimum_required(VERSION 2.8)<br>
        <br>
        PROJECT(ImageMapper)<br>
        <br>
        # This project uses Qt4<br>
        find_package(Qt4 REQUIRED)<br>
        add_definitions(${QT_DEFINITIONS})<br>
        include(${QT_USE_FILE})<br>
        <br>
        # VTK<br>
        find_package(VTK REQUIRED)<br>
        include(${VTK_USE_FILE})<br>
        <br>
        add_executable(ImageMapper ImageMapper)<br>
        <br>
        target_link_libraries(ImageMapper ${VTK_LIBRARIES}
        ${QT_LIBRARIES})<br>
      </blockquote>
      <br>
      Thanks<br>
      Dominic Plourde<br>
      <br>
      On 13-01-31 08:37 AM, Bill Lorensen wrote:<br>
    </div>
    <blockquote
cite="mid:CADZJ4hOHOfNrOG2bfSSoLav1Mi0-4YhJbGKpF-uQwY69JYb06g@mail.gmail.com"
      type="cite">
      <pre wrap="">See if this example helps:
<a class="moz-txt-link-freetext" href="http://vtk.org/Wiki/VTK/Examples/Cxx/Images/BackgroundImage">http://vtk.org/Wiki/VTK/Examples/Cxx/Images/BackgroundImage</a>


On Tue, Jan 29, 2013 at 10:57 AM, Dominic <a class="moz-txt-link-rfc2396E" href="mailto:domaniak@gmail.com">&lt;domaniak@gmail.com&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">On 13-01-18 10:45 AM, Dominic Plourde wrote:

I have a similar problem. I'm using VTK 5.10.1 on Ubuntu 11.10 The
vtkActor2D disappear when I moving other 3D actors outside the viewport. If
I remove the vtkAxesActor, my vtkActor2D is not visible. My test code:

#include &lt;vtkVersion.h&gt;
#include &lt;vtkImageData.h&gt;
#include &lt;vtkSmartPointer.h&gt;
#include &lt;vtkRenderWindow.h&gt;
#include &lt;vtkRenderWindowInteractor.h&gt;
#include &lt;vtkInteractorStyleImage.h&gt;
#include &lt;vtkRenderer.h&gt;
#include &lt;vtkImageMapper.h&gt;
#include &lt;vtkActor2D.h&gt;


#include &lt;vtkPolygon.h&gt;
#include &lt;vtkPolyData.h&gt;
#include &lt;vtkProperty.h&gt;
#include &lt;vtkPolyDataMapper.h&gt;
#include &lt;vtkCellData.h&gt;
#include &lt;vtkCellArray.h&gt;

#include &lt;vtkTexture.h&gt;
#include &lt;vtkImageData.h&gt;
#include &lt;vtkFloatArray.h&gt;
#include &lt;vtkPointData.h&gt;
#include &lt;vtkQImageToImageSource.h&gt;
#include &lt;vtkAxesActor.h&gt;
#include &lt;vtkVersion.h&gt;

#include &lt;QImage&gt;
#include &lt;QApplication&gt;

static void CreateColorImage(vtkImageData*);

int main(int i, char** c)
{
  QApplication qapp(i, c);

  vtkSmartPointer&lt;vtkImageData&gt; colorImage =
vtkSmartPointer&lt;vtkImageData&gt;::New();
  CreateColorImage(colorImage);

  vtkSmartPointer&lt;vtkImageMapper&gt; imageMapper =
vtkSmartPointer&lt;vtkImageMapper&gt;::New();
  imageMapper-&gt;SetInputConnection(colorImage-&gt;GetProducerPort());
  imageMapper-&gt;SetColorWindow(255);
  imageMapper-&gt;SetColorLevel(127.5);

  vtkSmartPointer&lt;vtkActor2D&gt; imageActor =
vtkSmartPointer&lt;vtkActor2D&gt;::New();
  imageActor-&gt;SetMapper(imageMapper);
  imageActor-&gt;SetPosition(0, 0);

  // Create a vtkPoints object and store the points in it
  vtkSmartPointer&lt;vtkPoints&gt; points = vtkSmartPointer&lt;vtkPoints&gt;::New();

  // Create a cell array to store the polygon in and add the polygon to it
  vtkSmartPointer&lt;vtkCellArray&gt; polygons =
vtkSmartPointer&lt;vtkCellArray&gt;::New();

  // Read the image which will be the texture
  QImage* qimage = new QImage("logo.png");

  vtkSmartPointer&lt;vtkQImageToImageSource&gt; qImageToVtk =
vtkSmartPointer&lt;vtkQImageToImageSource&gt;::New();
  qImageToVtk-&gt;SetQImage(qimage);

  vtkSmartPointer&lt;vtkTexture&gt; texture = vtkSmartPointer&lt;vtkTexture&gt;::New();
  texture-&gt;SetInputConnection(qImageToVtk-&gt;GetOutputPort());

  vtkSmartPointer&lt;vtkFloatArray&gt; textureCoordinates =
vtkSmartPointer&lt;vtkFloatArray&gt;::New();
  textureCoordinates-&gt;SetNumberOfComponents(3);
  textureCoordinates-&gt;SetName("TextureCoordinates");

  // Create a polydata to store everything in
  vtkSmartPointer&lt;vtkPolyData&gt; polygonPolyData =
vtkSmartPointer&lt;vtkPolyData&gt;::New();

  float tuple[3] = {0.0, 0.0, 0.0};
  textureCoordinates-&gt;InsertNextTuple(tuple);
  tuple[0] = 1.0; tuple[1] = 0.0; tuple[2] = 0.0;
  textureCoordinates-&gt;InsertNextTuple(tuple);
  tuple[0] = 1.0; tuple[1] = 1.0; tuple[2] = 0.0;
  textureCoordinates-&gt;InsertNextTuple(tuple);
  tuple[0] = 0.0; tuple[1] = 1.0; tuple[2] = 0.0;
  textureCoordinates-&gt;InsertNextTuple(tuple);

  // Add the points to the dataset
  polygonPolyData-&gt;SetPoints(points);
  polygonPolyData-&gt;SetPolys(polygons);
  polygonPolyData-&gt;GetPointData()-&gt;SetTCoords(textureCoordinates);

  // Setup actor and mapper
  vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper =
vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
  mapper-&gt;SetInput(polygonPolyData);

  vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();
  actor-&gt;SetMapper(mapper);
  actor-&gt;SetTexture(texture);
  actor-&gt;GetProperty()-&gt;SetColor(0.0, 0.62, 0.85);

  points-&gt;SetNumberOfPoints(4);
  points-&gt;SetPoint(0, 0, 0, 0);
  points-&gt;SetPoint(1, 10, 0, 0);
  points-&gt;SetPoint(2, 10, 10, 0);
  points-&gt;SetPoint(3, 0, 10, 0);

  vtkSmartPointer&lt;vtkPolygon&gt; top = vtkSmartPointer&lt;vtkPolygon&gt;::New();
  top-&gt;GetPointIds()-&gt;SetNumberOfIds(4);
  top-&gt;GetPointIds()-&gt;SetId(3, 0);
  top-&gt;GetPointIds()-&gt;SetId(2, 1);
  top-&gt;GetPointIds()-&gt;SetId(1, 2);
  top-&gt;GetPointIds()-&gt;SetId(0, 3);

  polygons-&gt;InsertNextCell(top);

  vtkSmartPointer&lt;vtkAxesActor&gt; axes = vtkSmartPointer&lt;vtkAxesActor&gt;::New();

  vtkSmartPointer&lt;vtkRenderer&gt; renderer =
vtkSmartPointer&lt;vtkRenderer&gt;::New();
  vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =
vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
  renderWindow-&gt;AddRenderer(renderer);

  // Setup render window interactor
  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor =
vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();
  vtkSmartPointer&lt;vtkInteractorStyleImage&gt; style =
vtkSmartPointer&lt;vtkInteractorStyleImage&gt;::New();
  renderWindowInteractor-&gt;SetInteractorStyle(style);

  // Render and start interaction
  renderWindowInteractor-&gt;SetRenderWindow(renderWindow);

  renderer-&gt;AddActor(actor);
  renderer-&gt;AddActor(axes);
  renderer-&gt;AddActor2D(imageActor);

  renderWindow-&gt;Render();
  renderWindowInteractor-&gt;Start();

  return EXIT_SUCCESS;
}

void CreateColorImage(vtkImageData* image)
{
  unsigned int dim = 50;

  image-&gt;SetDimensions(dim, dim, 1);
#if VTK_MAJOR_VERSION &lt;= 5
  image-&gt;SetNumberOfScalarComponents(3);
  image-&gt;SetScalarTypeToUnsignedChar();
  image-&gt;AllocateScalars();
#else
  image-&gt;AllocateScalars(VTK_UNSIGNED_CHAR,3);
#endif
  for(unsigned int x = 0; x &lt; dim; x++)
  {
     for(unsigned int y = 0; y &lt; dim; y++)
     {
        unsigned char* pixel = static_cast&lt;unsigned
char*&gt;(image-&gt;GetScalarPointer(x,y,0));
        if(x &lt; dim/2)
        {
           pixel[0] = 255;
           pixel[1] = 0;
        }
        else
        {
           pixel[0] = 0;
           pixel[1] = 255;
        }

        pixel[2] = 0;
     }
  }
  image-&gt;Modified();
}

Elvis Dowson wrote
Hi, In the following code, I cannot get both vtkActor2D and vtkActor to
display simultaneously. If I enable 2D map source and text source, it
displays the map and the text. If I enable the 3D cylinder source, the 3D
cylinder doesnt get displayed. However, if I disable the 2D map source, the
cylinder and the text message appears. How can I get the 2D map to display
below, and the 3D cylinder to appear to hover above the 2D map ? Am I mixing
things here? Should I be using vtkImageActor instead of vtkActor2D, so that
there is a 3D image plane and then display the 3D source? I really dont want
to do that at the moment. Please help! :-) Best regards, Elvis Dowson

#include "qapplication.h"
#include &lt;QtGui&gt;

#include &lt;vtkActor.h&gt;
#include &lt;vtkActor2D.h&gt;
#include &lt;vtkImageActor.h&gt;
#include &lt;vtkTextActor.h&gt;
#include &lt;vtkJPEGReader.h&gt;
#include &lt;vtkRenderer.h&gt;
#include &lt;vtkRenderWindow.h&gt;
#include &lt;vtkRenderWindowInteractor.h&gt;
#include &lt;vtkImageMapper.h&gt;
#include &lt;vtkPolyDataMapper.h&gt;
#include &lt;vtkCylinderSource.h&gt;


#if QT_VERSION &gt;= 0x040000
# include "ui_GUI4.h"
#endif

#define PROTOTYPE_2D_MAP_SOURCE
#define PROTOTYPE_2D_TEXT_SOURCE
#define PROTOTYPE_3D_CYLINDER_SOURCE


int main(int argc, char** argv)
{
   QApplication app(argc, argv);
        
#if QT_VERSION &gt;= 0x040000
        Ui::Dialog ui;
        QDialog dialog;
#endif
        
        ui.setupUi(&amp;dialog);
        dialog.setAttribute(Qt::WA_QuitOnClose);
        
        // Qt vtk integration
        vtkRenderer* ren = NULL;
        ren = vtkRenderer::New();
                ui.qvtkWidget-&gt;GetRenderWindow()-&gt;AddRenderer(ren);
        
        // Prototype: 2D Map Source
        // ----------------------------
        #ifdef PROTOTYPE_2D_MAP_SOURCE
          {
        // Declare object instance variables
        vtkJPEGReader* imageReader        = NULL;
        vtkImageMapper* imageMapper = NULL;
        vtkActor2D* mapActor                = NULL;                        
                        
        // Read 2D image file
        imageReader = vtkJPEGReader::New();
                imageReader-&gt;SetFileName("/Users/elvis/Image/sample.jpg");
                imageReader-&gt;Update();
        
        // Map 2D image file
        imageMapper = vtkImageMapper::New();
                imageMapper-&gt;SetInput(imageReader-&gt;GetOutput());
                imageMapper-&gt;SetColorWindow(255);
                imageMapper-&gt;SetColorLevel(127.5);
                
        // Actor in scene
        mapActor = vtkActor2D::New();
                mapActor-&gt;SetMapper(imageMapper);        

        // Actor in scene
        mapActor = vtkActor2D::New();
                //mapActor-&gt;SetLayerNumber(0);
                mapActor-&gt;SetMapper(imageMapper);                        

        // Add Actor to renderer
        ren-&gt;AddActor2D(mapActor);
        }
        #endif

        // Prototype: 2D Text Source
        // -----------------------------
        #ifdef PROTOTYPE_2D_TEXT_SOURCE
        {
                // Declare object instance variables
                vtkTextActor* textActor;
                
                // Initialize objects
                textActor = NULL;
                
                // Actor in scene
                textActor = vtkTextActor::New();
                textActor-&gt;SetTextScaleMode(vtkTextActor::TEXT_SCALE_MODE_NONE);
                textActor-&gt;SetInput("This is a text message!");
                
                // Add Actor to renderer
                ren-&gt;AddActor2D(textActor);
        }
        #endif
        

        // Prototype: 3D Cyclinder Source
        // ----------------------------------
        #ifdef PROTOTYPE_3D_CYLINDER_SOURCE        
        {
        // Declare object instance variables
        vtkCylinderSource* source;
        vtkPolyDataMapper* mapper;
        vtkActor* actor;

        // Initialize objects
        source = NULL;
        mapper = NULL;
        actor = NULL;
        
        // Geometry
        source = vtkCylinderSource::New();
        
        // Mapper
        mapper = vtkPolyDataMapper::New();
        mapper-&gt;ImmediateModeRenderingOn();
        mapper-&gt;SetInputConnection(source-&gt;GetOutputPort());
        
        // Actor in scene
        actor = vtkActor::New();
        actor-&gt;SetMapper(mapper);
        
        // Add Actor to renderer
        ren-&gt;AddActor(actor);
        }
        #endif
        
        // Reset camera
        ren-&gt;ResetCamera();
        
        // Render the scene
        ren-&gt;GetRenderWindow()-&gt;Render();
        
        // Display the dialog window
        dialog.show();

   return app.exec();
}

_______________________________________________ This is the private VTK
discussion list. Please keep messages on-topic. Check the FAQ at:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a> Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>


________________________________
View this message in context: Re: Problem getting vtkActor2D and vtkActor to
render simultaneously
Sent from the VTK - Users mailing list archive at Nabble.com.


_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>


Has anyone encountered this?

Thanks,
Dominic


_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>

</pre>
      </blockquote>
      <pre wrap="">


</pre>
    </blockquote>
    <br>
  </body>
</html>