def initilize(self):
        self._glFunc = QOpenGLFunctions()  # used in all OpenGL systems
        self._renderWindow = vtk.vtkGenericOpenGLRenderWindow(
        )  # Can not Resize
        # self._renderWindow = vtk.vtkExternalOpenGLRenderWindow()  # Recommend; vtk-8.1.2-py3-none-any.whl
        self._renderer: vtk.vtkRenderer = vtk.vtkRenderer()
        self._renderWindow.AddRenderer(self._renderer)

        # * Interactor
        self._rwInteractor = vtk.vtkGenericRenderWindowInteractor()
        self._rwInteractor.EnableRenderOff()
        self._rwInteractor.SetRenderWindow(self._renderWindow)

        # * Initialize the OpenGL context for the renderer
        self._renderWindow.OpenGLInitContext()

        # * Interactor Style
        style = vtk.vtkInteractorStyleTrackballCamera()
        style.SetDefaultRenderer(self._renderer)
        style.SetMotionFactor(10.0)
        self._rwInteractor.SetInteractorStyle(style)

        self.__m_mouseLeftButton: QMouseEvent = None
        self.__m_mouseEvent: QMouseEvent = None
        self.__m_moveEvent: QMouseEvent = None
        self.__m_wheelEvent: QWheelEvent = None
        self.__fboItem: "QmlVTKRenderWindowInteractor" = None
        self.__firstRender = True
        self.jointPose = np.array([0, 0, 0, 0, 0, 0])
        self._axis = [[0, 0, 1], [0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 0, 1],
                      [0, 1, 0]]
        self.__jointPoseChanged = False
Esempio n. 2
0
    def __init__(self):
        qDebug('RendererHelper::__init__()')
        super().__init__()
        self.__m_vtkFboItem = None
        self.gl = QOpenGLFunctions()

        self.__m_mouseLeftButton: QMouseEvent = None
        self.__m_mouseEvent: QMouseEvent = None
        self.__m_moveEvent: QMouseEvent = None
        self.__m_wheelEvent: QWheelEvent = None

        self.__m_firstRender: bool = True

        self.renderWindow: vtk.vtkGenericOpenGLRenderWindow = vtk.vtkGenericOpenGLRenderWindow(
        )
        self.renderer: vtk.vtkRenderer = vtk.vtkRenderer()
        self.renderWindow.AddRenderer(self.renderer)

        # * Interactor
        self.interactor: vtk.vtkGenericRenderWindowInteractor = vtk.vtkGenericRenderWindowInteractor(
        )
        self.interactor.EnableRenderOff()
        self.renderWindow.SetInteractor(self.interactor)

        # * Initialize the OpenGL context for the renderer
        self.renderWindow.OpenGLInitContext()

        # * Interactor Style
        style = vtk.vtkInteractorStyleTrackballCamera()
        style.SetDefaultRenderer(self.renderer)
        style.SetMotionFactor(10.0)
        self.interactor.SetInteractorStyle(style)
Esempio n. 3
0
    def testQVTKWidget2(self):

        w2 = vtk.QVTKWidget2()
        w2.resize(500, 500)

        ren = vtk.vtkRenderer()
        ren.SetBackground(0, 0, 0)
        ren.SetBackground2(1, 1, 1)
        ren.SetGradientBackground(1)
        win2 = vtk.vtkGenericOpenGLRenderWindow()
        win2.AddRenderer(ren)
        w2.SetRenderWindow(win2)

        renwin = w2.GetRenderWindow()
        cone = vtk.vtkConeSource()
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(cone.GetOutput())
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        ren.AddViewProp(actor)
        ren.ResetCamera()

        w2.show()
        if Testing.isInteractive():
            PyQt4.QtGui.qApp.exec_()
Esempio n. 4
0
def Init():

    global C,R,RW,RWI,OMW,grid_actor
    C=vtk.vtkCamera()
    R=vtk.vtkRenderer()
    R.SetActiveCamera(C)
    #R.AddActor(A)

    RW=vtk.vtkGenericOpenGLRenderWindow()
    RW.AddRenderer(R)
    RW.SetIsDirect(True)
    RW.SetSupportsOpenGL(True)

    RWI = vtk.vtkGenericRenderWindowInteractor()
    RWI.SetRenderWindow(RW)

    AA  = vtk.vtkAxesActor()
    OMW = vtk.vtkOrientationMarkerWidget()
    OMW.SetOrientationMarker( AA );
    OMW.SetInteractor( RWI );
    OMW.SetEnabled( 1 );
    OMW.SetInteractive(0);

    Lights = []
    for l in bpy.context.user_preferences.system.solid_lights:
        L = vtk.vtkLight()
        L.SetLightTypeToCameraLight()
        L.SetDiffuseColor( l.diffuse_color )
        L.SetSpecularColor( l.specular_color )
        L.SetPosition( l.direction )
        R.AddLight(L)
        Lights.append(L)
    grid_actor = None
    return R
Esempio n. 5
0
  def testQVTKWidget2(self):

    w2 = vtk.QVTKWidget2()
    w2.resize(500,500)

    ren = vtk.vtkRenderer()
    ren.SetBackground(0,0,0)
    ren.SetBackground2(1,1,1)
    ren.SetGradientBackground(1)
    win2 = vtk.vtkGenericOpenGLRenderWindow()
    win2.AddRenderer(ren)
    w2.SetRenderWindow(win2)

    renwin = w2.GetRenderWindow()
    cone = vtk.vtkConeSource()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(cone.GetOutput())
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    ren.AddViewProp(actor)
    ren.ResetCamera()

    w2.show()
    if Testing.isInteractive():
      PyQt4.QtGui.qApp.exec_()
    def __init__(self):
        super(QmlVTKOpenGLRenderWindowInteractor, self).__init__()

        self._glFunc = QOpenGLFunctions()

        self._RenderWindow = vtk.vtkGenericOpenGLRenderWindow()
        self._Iren = vtk.vtkGenericRenderWindowInteractor()
        self._ren = vtk.vtkRenderer()
        self._RenderWindow.AddRenderer(self._ren)
        self._Iren.SetRenderWindow(self._RenderWindow)
        self._RenderWindow.OpenGLInitContext()
Esempio n. 7
0
    def init(self):

        self.renderer = vtkRenderer()
        self.renderer.SetUseDepthPeeling(1); ####
        self.renderer.SetBackground(1,1,1)
        self.renderWindow = vtkGenericOpenGLRenderWindow()
        self.renderWindow.SetAlphaBitPlanes(True) ####
        self.renderWindow.AddRenderer(self.renderer)
        self.SetRenderWindow(self.renderWindow)
        
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        
        self.actors = vtkPropCollection()
Esempio n. 8
0
    def init(self):

        self.renderer = vtkRenderer()
        self.renderer.SetUseDepthPeeling(1); ####
        self.renderer.SetBackground(1,1,1)
        self.renderWindow = vtkGenericOpenGLRenderWindow()
        self.renderWindow.SetAlphaBitPlanes(True) ####
        self.renderWindow.AddRenderer(self.renderer)
        self.SetRenderWindow(self.renderWindow)
        
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        
        self.actors = vtkPropCollection()
    def __init__(self, *args, **kwargs):
        qDebug('FboItem::__init__')
        QQuickFramebufferObject.__init__(self)
        self._vtkFboRenderer = None
        BasePlotter.__init__(self, *args, **kwargs)

        self._opts = {
            'border': None,
            'border_color': 'k',
            'border_width': 2.0,
        }
        common_keys = self._opts.keys() & kwargs.keys()
        common_dict = {k: kwargs[k] for k in common_keys}
        self._opts.update(common_dict)

        self.ren_win = vtk.vtkGenericOpenGLRenderWindow = vtk.vtkGenericOpenGLRenderWindow(
        )
        self.iren: vtk.vtkGenericRenderWindowInteractor = vtk.vtkGenericRenderWindowInteractor(
        )
        self.iren.EnableRenderOff()
        self.ren_win.SetInteractor(self.iren)

        self.update_style()

        self.__m_lastMouseLeftButton: QMouseEvent = QMouseEvent(
            QEvent.Type.None_, QPointF(0, 0), Qt.NoButton, Qt.NoButton,
            Qt.NoModifier)
        self.__m_lastMouseButton: QMouseEvent = QMouseEvent(
            QEvent.Type.None_, QPointF(0, 0), Qt.NoButton, Qt.NoButton,
            Qt.NoModifier)
        self.__m_lastMouseMove: QMouseEvent = QMouseEvent(
            QEvent.Type.None_, QPointF(0, 0), Qt.NoButton, Qt.NoButton,
            Qt.NoModifier)
        self.__m_lastMouseWheel: QWheelEvent = None

        self.setMirrorVertically(
            True)  # QtQuick and OpenGL have opposite Y-Axis directions
        self.setAcceptedMouseButtons(Qt.RightButton | Qt.LeftButton)
    def __init__(self):
        qDebug('RendererHelper::__init__()')
        super().__init__()
        self.__m_vtkFboItem = None
        self.gl = QOpenGLFunctions()
        self.__m_processingEngine: ProcessingEngine = None

        self.__m_selectedModel: Model = None
        self.__m_selectedActor: vtk.vtkActor = None
        self.__m_isModelSelected: bool = False

        self.__m_selectedModelPositionX: float = 0.0
        self.__m_selectedModelPositionY: float = 0.0

        self.__m_mouseLeftButton: QMouseEvent = None
        self.__m_mouseEvent: QMouseEvent = None
        self.__m_moveEvent: QMouseEvent = None
        self.__m_wheelEvent: QWheelEvent = None

        self.__m_platformModel: vtk.vtkCubeSource = None
        self.__m_platformGrid: vtk.vtkPolyData = None
        self.__m_platformModelActor: vtk.vtkActor = None
        self.__m_platformGridActor: vtk.vtkActor = None

        self.__m_platformWidth: float = 200.0
        self.__m_platformDepth: float = 200.0
        # self.__m_platformHeight:float = 200.0
        self.__m_platformThickness: float = 2.0
        self.__m_gridBottomHeight: float = 0.15
        self.__m_gridSize: np.uint16 = 10

        # self.__m_camPositionX:float = 0.0
        # self.__m_camPositionY:float = 0.0
        # self.__m_camPositionZ:float = 0.0

        self.__m_clickPositionZ: float = 0.0

        self.__m_firstRender: bool = True

        self.__m_modelsRepresentationOption: int = 0
        self.__m_modelsOpacity: float = 1.0
        self.__m_modelsGouraudInterpolation: bool = False

        #* Renderer
        #* https://vtk.org/doc/nightly/html/classQVTKOpenGLNativeWidget.html#details
        # QSurfaceFormat.setDefaultFormat(QVTKOpenGLNativeWidget.defaultFormat()) # from vtk 8.2.0
        # QSurfaceFormat.setDefaultFormat(fmt)
        self.__m_vtkRenderWindow: vtk.vtkGenericOpenGLRenderWindow = vtk.vtkGenericOpenGLRenderWindow(
        )
        self.__m_renderer: vtk.vtkRenderer = vtk.vtkRenderer()
        self.__m_vtkRenderWindow.AddRenderer(self.__m_renderer)

        #* Interactor
        self.__m_vtkRenderWindowInteractor: vtk.vtkGenericRenderWindowInteractor = vtk.vtkGenericRenderWindowInteractor(
        )
        self.__m_vtkRenderWindowInteractor.EnableRenderOff()
        self.__m_vtkRenderWindow.SetInteractor(
            self.__m_vtkRenderWindowInteractor)

        #* Initialize the OpenGL context for the renderer
        self.__m_vtkRenderWindow.OpenGLInitContext()

        #* Interactor Style
        style = vtk.vtkInteractorStyleTrackballCamera()
        style.SetDefaultRenderer(self.__m_renderer)
        style.SetMotionFactor(10.0)
        self.__m_vtkRenderWindowInteractor.SetInteractorStyle(style)

        #* Picker
        self.__m_picker: vtk.vtkCellPicker = vtk.vtkCellPicker()
        self.__m_picker.SetTolerance(0.0)