<div dir="ltr">You can use two different vtkRenderer objects and use the "SetLayer" method to control which appears on top. I think you will also need to set the number of layers on the window: "vtkRenderWindow::SetNumberOfLayers".<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 27, 2018 at 9:37 AM, mafiaskafia <span dir="ltr"><<a href="mailto:tsilveira1993@gmail.com" target="_blank">tsilveira1993@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm trying to implement a gridline behind a vtkPolydata Object that<br>
represents a 2D mesh, so it's easier for the end-user to see it's<br>
dimensions. I managed to implement a gridline using vtkChartXY, but i<br>
couldn't figure out how i could set the origin of the gridline to be on the<br>
center of the vtkPolyData object, and also how i could make the gridline<br>
appear before the Object and not after like this:<br>
<br>
<<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__vtk.1045678.n5.nabble.com_file_t342418_halppp.png&d=DwICAg&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=h7heP8xwI1i_HikChvhFbEBurKirgfOCdwgBxB9lM8c&m=BABQFHs0jxxGdf8nxpi7I3bDZRMpEC4NFNnqRhnEbPw&s=vxGxgaNCkxP5q-nzL5RyEEFVx71Cw5A3BQcU_P1qzmo&e=" rel="noreferrer" target="_blank">https://urldefense.<wbr>proofpoint.com/v2/url?u=http-<wbr>3A__vtk.1045678.n5.nabble.com_<wbr>file_t342418_halppp.png&d=<wbr>DwICAg&c=<wbr>54IZrppPQZKX9mLzcGdPfFD1hxrcB_<wbr>_aEkJFOKJFd00&r=h7heP8xwI1i_<wbr>HikChvhFbEBurKirgfOCdwgBxB9lM8<wbr>c&m=<wbr>BABQFHs0jxxGdf8nxpi7I3bDZRMpEC<wbr>4NFNnqRhnEbPw&s=vxGxgaNCkxP5q-<wbr>nzL5RyEEFVx71Cw5A3BQcU_P1qzmo&<wbr>e=</a>> <br>
<br>
This is the code i used to make the gridline:<br>
<br>
        def openGL_Design(self):<br>
<br>
            self.chart = vtk.vtkChartXY()<br>
            self.plot = vtk.vtkPlotPoints()<br>
            self.chart.AddPlot(self.plot)<br>
<br>
            self.view = vtk.vtkContextActor()<br>
            self.view.GetScene().AddItem(<wbr>self.chart)<br>
<br>
            #Create a Window interactor using the central frame object from<br>
Qt<br>
            self.vtkDesign = QVTKRenderWindowInteractor(<wbr>self.centralFrame)<br>
            self.vl = Qt.QVBoxLayout()<br>
            self.vl.setContentsMargins(0, 0, 0, 0)<br>
            self.vl.setSpacing(0)              <br>
            self.vl.addWidget(self.<wbr>vtkDesign)<br>
<br>
            #Create a renderer and add it to the window<br>
            self.renDesign = vtk.vtkRenderer()<br>
            self.vtkDesign.<wbr>GetRenderWindow().AddRenderer(<wbr>self.renDesign)<br>
            self.renDesign.SetBackground(.<wbr>85, .85, .85) <br>
            self.irenDesign =<br>
self.vtkDesign.<wbr>GetRenderWindow().<wbr>GetInteractor()<br>
<br>
<br>
            #Set a dummy actor so i don't end up with repeated meshes<br>
            self.MeshActor = vtk.vtkActor()<br>
            self.centroidActor = vtk.vtkActor()<br>
            self.renDesign.AddActor(self.<wbr>view)<br>
            self.renDesign.AddActor(self.<wbr>MeshActor)<br>
            self.renDesign.AddActor(self.<wbr>centroidActor)<br>
<br>
            self.centralFrame.setLayout(<wbr>self.vl)<br>
<br>
            self.show()<br>
            self.irenDesign.Initialize()<br>
            self.irenDesign.Start()<br>
<br>
And this is the code i used to make the "Mesh Actor"<br>
<br>
    def addVisual_Mesh(self):<br>
<br>
        self.renDesign.RemoveActor(<wbr>self.MeshActor) #Removes the old actor<br>
<br>
        def mkVtkIdList(it):<br>
            vil = vtk.vtkIdList()<br>
            for i in it:<br>
                vil.InsertNextId(int(i))<br>
            return vil<br>
<br>
        colors = vtk.vtkNamedColors() <br>
<br>
        #Array of vectors containing the coordinates of each point<br>
        nodes = self.Results.nodes<br>
<br>
        #Array of tuples containing the nodes correspondent of each element<br>
        elements = self.Results.elements<br>
<br>
        #Make the building blocks of polyData attributes<br>
        Mesh = vtk.vtkPolyData()<br>
        Points = vtk.vtkPoints()<br>
        Cells = vtk.vtkCellArray()  <br>
<br>
        #Load the point and cell's attributes<br>
        for i in range(self.Results.numNodes):<br>
            Points.InsertPoint(i, nodes[i])<br>
<br>
        for i in range(self.Results.<wbr>numElements):<br>
            Cells.InsertNextCell(<wbr>mkVtkIdList(elements[i]))<br>
<br>
        #Assign pieces to vtkPolyData<br>
        Mesh.SetPoints(Points)<br>
        Mesh.SetPolys(Cells)<br>
<br>
        #Mapping the whole thing<br>
        MeshMapper = vtk.vtkPolyDataMapper()<br>
        if vtk.VTK_MAJOR_VERSION <= 5:<br>
            MeshMapper.SetInput(Mesh)<br>
        else:<br>
            MeshMapper.SetInputData(Mesh)<br>
<br>
        #Create an actor<br>
        self.MeshActor = vtk.vtkActor() <br>
        self.MeshActor.SetMapper(<wbr>MeshMapper)<br>
        #self.MeshActor.GetProperty().<wbr>EdgeVisibilityOn()<br>
        self.MeshActor.GetProperty().<wbr>SetColor(colors.GetColor3d("<wbr>Red"))<br>
<br>
#self.MeshActor.GetProperty().<wbr>SetEdgeColor(colors.<wbr>GetColor3d("Black"))<br>
<br>
        self.renDesign.AddActor(self.<wbr>MeshActor)<br>
<br>
        #Camera Stuff<br>
        camera = vtk.vtkCamera()<br>
        camera.SetPosition(1,1,<wbr>1000000)<br>
        camera.SetFocalPoint(0,0,0)<br>
<br>
        self.renDesign.<wbr>SetActiveCamera(camera)<br>
        self.renDesign.ResetCamera()<br>
<br>
        self.vtkDesign.<wbr>SetInteractorStyle(self.<wbr>Interactor2D())<br>
<br>
I would be very appreciated if anyone could help me out! Thanks in advance!<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__vtk.1045678.n5.nabble.com_VTK-2DUsers-2Df1224199.html&d=DwICAg&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=h7heP8xwI1i_HikChvhFbEBurKirgfOCdwgBxB9lM8c&m=BABQFHs0jxxGdf8nxpi7I3bDZRMpEC4NFNnqRhnEbPw&s=_rVA5V9ZjR6S9HFCvPDXsDZ6cPhFa29xy-q5fFR2VLE&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__vtk.<wbr>1045678.n5.nabble.com_VTK-<wbr>2DUsers-2Df1224199.html&d=<wbr>DwICAg&c=<wbr>54IZrppPQZKX9mLzcGdPfFD1hxrcB_<wbr>_aEkJFOKJFd00&r=h7heP8xwI1i_<wbr>HikChvhFbEBurKirgfOCdwgBxB9lM8<wbr>c&m=<wbr>BABQFHs0jxxGdf8nxpi7I3bDZRMpEC<wbr>4NFNnqRhnEbPw&s=_<wbr>rVA5V9ZjR6S9HFCvPDXsDZ6cPhFa29<wbr>xy-q5fFR2VLE&e=</a><br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=DwICAg&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=h7heP8xwI1i_HikChvhFbEBurKirgfOCdwgBxB9lM8c&m=BABQFHs0jxxGdf8nxpi7I3bDZRMpEC4NFNnqRhnEbPw&s=IOBcMazQV0OuHRsveg0B4Cn1alnxvbDGoXyFRV7li48&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__www.<wbr>kitware.com_opensource_<wbr>opensource.html&d=DwICAg&c=<wbr>54IZrppPQZKX9mLzcGdPfFD1hxrcB_<wbr>_aEkJFOKJFd00&r=h7heP8xwI1i_<wbr>HikChvhFbEBurKirgfOCdwgBxB9lM8<wbr>c&m=<wbr>BABQFHs0jxxGdf8nxpi7I3bDZRMpEC<wbr>4NFNnqRhnEbPw&s=<wbr>IOBcMazQV0OuHRsveg0B4Cn1alnxvb<wbr>DGoXyFRV7li48&e=</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.vtk.org_Wiki_VTK-5FFAQ&d=DwICAg&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=h7heP8xwI1i_HikChvhFbEBurKirgfOCdwgBxB9lM8c&m=BABQFHs0jxxGdf8nxpi7I3bDZRMpEC4NFNnqRhnEbPw&s=X517J-49oSESWpkye-qXsuX6IDYPg7pG5WYSU-WU7Uk&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__www.vtk.<wbr>org_Wiki_VTK-5FFAQ&d=DwICAg&c=<wbr>54IZrppPQZKX9mLzcGdPfFD1hxrcB_<wbr>_aEkJFOKJFd00&r=h7heP8xwI1i_<wbr>HikChvhFbEBurKirgfOCdwgBxB9lM8<wbr>c&m=<wbr>BABQFHs0jxxGdf8nxpi7I3bDZRMpEC<wbr>4NFNnqRhnEbPw&s=X517J-<wbr>49oSESWpkye-<wbr>qXsuX6IDYPg7pG5WYSU-WU7Uk&e=</a><br>
<br>
Search the list archives at: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__markmail.org_search_-3Fq-3Dvtkusers&d=DwICAg&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=h7heP8xwI1i_HikChvhFbEBurKirgfOCdwgBxB9lM8c&m=BABQFHs0jxxGdf8nxpi7I3bDZRMpEC4NFNnqRhnEbPw&s=Hp9usDPi61EkBCTLC8JtnDX3-Y-_ARqeNTA6xOAam28&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__<wbr>markmail.org_search_-3Fq-<wbr>3Dvtkusers&d=DwICAg&c=<wbr>54IZrppPQZKX9mLzcGdPfFD1hxrcB_<wbr>_aEkJFOKJFd00&r=h7heP8xwI1i_<wbr>HikChvhFbEBurKirgfOCdwgBxB9lM8<wbr>c&m=<wbr>BABQFHs0jxxGdf8nxpi7I3bDZRMpEC<wbr>4NFNnqRhnEbPw&s=<wbr>Hp9usDPi61EkBCTLC8JtnDX3-Y-_<wbr>ARqeNTA6xOAam28&e=</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__public.kitware.com_mailman_listinfo_vtkusers&d=DwICAg&c=54IZrppPQZKX9mLzcGdPfFD1hxrcB__aEkJFOKJFd00&r=h7heP8xwI1i_HikChvhFbEBurKirgfOCdwgBxB9lM8c&m=BABQFHs0jxxGdf8nxpi7I3bDZRMpEC4NFNnqRhnEbPw&s=9EGrEaOM2rmrlz4QHDkxZHSjgJLH5GuUVSq3r3ENNKA&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__public.<wbr>kitware.com_mailman_listinfo_<wbr>vtkusers&d=DwICAg&c=<wbr>54IZrppPQZKX9mLzcGdPfFD1hxrcB_<wbr>_aEkJFOKJFd00&r=h7heP8xwI1i_<wbr>HikChvhFbEBurKirgfOCdwgBxB9lM8<wbr>c&m=<wbr>BABQFHs0jxxGdf8nxpi7I3bDZRMpEC<wbr>4NFNnqRhnEbPw&s=<wbr>9EGrEaOM2rmrlz4QHDkxZHSjgJLH5G<wbr>uUVSq3r3ENNKA&e=</a><br>
</blockquote></div><br></div>