def __init__(self, programa):
        QOpenGLWidget.__init__(self)
        self.programa = programa
        self.desviacion_x = 0
        self.desviacion_y = 0
        self.desviacion_z = 0
        self.theta = 405
        self.phi = 45
        self.zoom = 150
        self.x = sin(radians(self.theta)) * cos(radians(
            self.phi)) + self.desviacion_x
        self.z = sin(radians(self.theta)) * sin(radians(
            self.phi)) + self.desviacion_z
        self.y = cos(radians(self.theta)) + self.desviacion_y

        # Vértices de los planos
        self.vertices_plano_vertical_arriba = ((500, 0, 500), (500, 0, 0),
                                               (-500, 0, 0), (-500, 0, 500))
        self.vertices_plano_vertical_debajo = ((500, 0, 0), (-500, 0, 0),
                                               (-500, 0, -500), (500, 0, -500))
        self.vertices_plano_horizontal_delante = ((500, 0, 0), (500, 500, 0),
                                                  (-500, 500, 0), (-500, 0, 0))
        self.vertices_plano_horizontal_detras = ((500, 0, 0), (500, -500, 0),
                                                 (-500, -500, 0), (-500, 0, 0))
        self.vertices_borde_plano_vertical = ((500, 0, 500), (-500, 0, 500),
                                              (-500, 0, -500), (500, 0, -500))
        self.vertices_borde_plano_horizontal = ((500, 500, 0), (500, -500, 0),
                                                (-500, -500, 0), (-500, 500,
                                                                  0))

        self.ultima_posicion = QPoint()

        self.m = [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]
 def __init__(self, parent, radius, quality):
     QOpenGLWidget.__init__(self, parent)
     self.__radius = radius
     self.__quality = quality
     self.__xRotation = 0
     self.__yRotation = 0
     self.__zRotation = 0
     self.__lastPoint = QPoint()
Exemple #3
0
    def __init__(self, parent):
        QOpenGLWidget.__init__(self, parent)
        self.layers = []
        self.colorpalette_regions = [(1, 1, 1), (1, 0.7, 0.7), (0.7, 1, 0.7),
                                     (0.7, 0.7, 1)]

        self.colorpalette_paths = [(0, 0, 1), (0, 1, 0), (1, 0, 0), (0, 1, 1),
                                   (1, 0, 1), (1, 1, 0)]
        self.dim = 2
        self.zoom = 1.9
        self.rotation = np.zeros(2)
        self.translation = np.array([-0.5, -0.5, 0])
    def __init__(self, parent, debug=False):
        QOpenGLWidget.__init__(self, parent)
        global debugger
        debugger = Debug(debug, 'OpenGLWidget')
        self.debug = debug
        self.viewerTab = parent
        self.notebook = parent.notebook
        self.setMinimumSize(640, 672)
        self.lightingOn = True
        self.diffuseMaterialFactor = 0.9
        self.ambientMaterialFactor = 0.4
        self.specularMaterialFactor = 0.7
        self.glintMaterialFactor = 100.0
        self.diffuseLightFactor = 0.8
        self.ambientLightFactor = 0.6
        self.specularLightFactor = 1.0
        self.linearAttenuation = True
        self.image_size = 15.0
        self.white = np.array([1.0, 1.0, 1.0, 1.0])
        self.spheres = deque()
        self.cylinders = deque()
        self.arrows = deque()
        self.current_phase = 0
        self.phase_direction = 1
        self.number_of_phases = 1
        self.sphere_slices = 20
        self.sphere_stacks = 20
        self.cylinder_slices = 8
        self.cylinder_stacks = 2
        self.timer = None
        self.show_arrows = True
        self.timer_interval = 60
        self.my_width = None
        self.my_height = None
        self.background_colour = None

        self.show_full_screen = False
        self.writer = None
        self.rotation_centre = np.array([0.0, 0.0, 0.0])
        self.matrix = np.eye(4, dtype=np.float32)
        self.light_switches = None
        d = 200.0
        self.light_positions = [[-d, d, d], [d, -d, d], [-d, -d, d], [d, d, d],
                                [-d, d, -d], [d, -d, -d], [-d, -d, -d],
                                [d, d, -d]]
        self.lights = [
            GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5,
            GL_LIGHT6, GL_LIGHT7
        ]
Exemple #5
0
    def __init__(self, parent):
        QOpenGLWidget.__init__(self, parent=parent)

        # Adding samples
        format = QSurfaceFormat()
        format.setSamples(8)
        self.setFormat(format)

        self.programLocations: Dict[str, GLuint]

        self.view: View = View()
        self.functionModel = FunctionModel(2)
        self.axesModel = AxisModel()
        self.evalPointsModel = EvalPointsModel()
        self.evalLinesModel = EvalLinesModel()
        self.userModels = []
        self.locations = {}

        self.screenView = None
        self.mouse: List[int] = None
        self.setMouseTracking(True)
Exemple #6
0
 def __init__(self, parent, samplerate, duration, texsize, moreUniforms={}):
     QOpenGLWidget.__init__(self, parent)
     self.move(10000., 1000.)
     self.program = 0
     self.iSampleRateLocation = 0
     self.iBlockOffsetLocation = 0
     self.hasShader = False
     self.duration = duration
     self.samplerate = samplerate
     self.texsize = texsize
     self.blocksize = self.texsize * self.texsize
     self.nsamples = self.duration * self.samplerate  # it was *2
     self.nblocks = int(ceil(float(self.nsamples) / float(self.blocksize)))
     self.nsamples_real = self.nblocks * self.blocksize  # this too was *2
     self.duration_real = float(self.nsamples_real) / float(self.samplerate)
     self.music = None
     self.floatmusic = None
     self.moreUniforms = moreUniforms
     self.sequence_texture_handle = None
     self.sequence_texture = None
     self.sequence_texture_size = None
     self.setTextureFormat(GL_RGBA)
Exemple #7
0
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = Qt.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = Qt.NoModifier
        self.__saveButtons = Qt.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create qt-level widget
        if QVTKRWIBase == "QWidget":
            QWidget.__init__(self, parent)
        elif QVTKRWIBase == "QGLWidget":
            QGLWidget.__init__(self, parent)

        if rw:  # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtk.vtkRenderWindow()

        wid = self._get_win_id()
        self._RenderWindow.SetWindowInfo(wid)

        self._should_set_parent_info = (sys.platform == 'win32')

        if stereo:  # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtk.vtkGenericRenderWindowInteractor()

        self._Iren.SetRenderWindow(self._RenderWindow)

        # do all the necessary qt setup
        self.setAttribute(Qt.WA_OpaquePaintEvent)
        self.setAttribute(Qt.WA_PaintOnScreen)
        self.setMouseTracking(True)  # get all mouse events
        self.setFocusPolicy(Qt.WheelFocus)
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        # add wheel timer to fix scrolling issue with trackpad
        self.wheel_timer = None
        if PyQtImpl != 'PyQt5':
            self.wheel_timer = QTimer()
            self.wheel_timer.setSingleShot(True)
            self.wheel_timer.setInterval(25)
            self.wheel_timer.timeout.connect(self._emit_wheel_event)
            self._saved_wheel_event_info = ()

        self._Iren.AddObserver('CreateTimerEvent', messenger.send)
        messenger.connect(self._Iren, 'CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', messenger.send)
        messenger.connect(self._Iren, 'DestroyTimerEvent', self.DestroyTimer)
        self._RenderWindow.AddObserver('CursorChangedEvent', messenger.send)
        messenger.connect(self._RenderWindow, 'CursorChangedEvent',
                          self.CursorChangedEvent)

        # Create a hidden child widget and connect its destroyed signal to its
        # parent ``Finalize`` slot. The hidden children will be destroyed
        # before its parent thus allowing cleanup of VTK elements.
        self._hidden = QWidget(self)
        self._hidden.hide()
        self._hidden.destroyed.connect(self.Finalize)
Exemple #8
0
 def __init__(self, parent):
     QOpenGLWidget.__init__(self, parent)
     self.previous_mouse_position = [0,0]
Exemple #9
0
 def __init__(self, parent=None):
     QOpenGLWidget.__init__(self, parent)
     self.setMinimumSize(730, 380)
    def __init__(self, parent=None, **kw):
        # the current button
        self._ActiveButton = Qt.NoButton

        # private attributes
        self.__saveX = 0
        self.__saveY = 0
        self.__saveModifiers = Qt.NoModifier
        self.__saveButtons = Qt.NoButton
        self.__wheelDelta = 0

        # do special handling of some keywords:
        # stereo, rw

        try:
            stereo = bool(kw['stereo'])
        except KeyError:
            stereo = False

        try:
            rw = kw['rw']
        except KeyError:
            rw = None

        # create qt-level widget
        if QVTKRWIBase == "QWidget":
            if "wflags" in kw:
                wflags = kw['wflags']
            else:
                wflags = Qt.WindowFlags()
            QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC)
        elif QVTKRWIBase == "QGLWidget":
            QGLWidget.__init__(self, parent)

        if rw:  # user-supplied render window
            self._RenderWindow = rw
        else:
            self._RenderWindow = vtk.vtkRenderWindow()

        wid = self._get_win_id()
        self._RenderWindow.SetWindowInfo(wid)

        self._should_set_parent_info = (sys.platform == 'win32')

        if stereo:  # stereo mode
            self._RenderWindow.StereoCapableWindowOn()
            self._RenderWindow.SetStereoTypeToCrystalEyes()

        try:
            self._Iren = kw['iren']
        except KeyError:
            self._Iren = vtk.vtkGenericRenderWindowInteractor()

        self._Iren.SetRenderWindow(self._RenderWindow)

        if hasattr(self, 'devicePixelRatio'):
            self._pixel_ratio = self.devicePixelRatio()
        else:
            self._pixel_ratio = 1.0

        # do all the necessary qt setup
        self.setAttribute(Qt.WA_OpaquePaintEvent)
        self.setAttribute(Qt.WA_PaintOnScreen)
        self.setMouseTracking(True) # get all mouse events
        self.setFocusPolicy(Qt.WheelFocus)
        self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        self._Timer = QTimer(self)
        self._Timer.timeout.connect(self.TimerEvent)

        # add wheel timer to fix scrolling issue with trackpad
        self.wheel_timer = None
        if PyQtImpl != 'PyQt5':
            self.wheel_timer = QTimer()
            self.wheel_timer.setSingleShot(True)
            self.wheel_timer.setInterval(25)
            self.wheel_timer.timeout.connect(self._emit_wheel_event)
            self._saved_wheel_event_info = ()

        self._Iren.AddObserver('CreateTimerEvent', messenger.send)
        messenger.connect(self._Iren, 'CreateTimerEvent', self.CreateTimer)
        self._Iren.AddObserver('DestroyTimerEvent', messenger.send)
        messenger.connect(self._Iren, 'DestroyTimerEvent', self.DestroyTimer)
        self._RenderWindow.AddObserver('CursorChangedEvent', messenger.send)
        messenger.connect(self._RenderWindow, 'CursorChangedEvent',
                          self.CursorChangedEvent)

        # Create a hidden child widget and connect its destroyed signal to its
        # parent ``Finalize`` slot. The hidden children will be destroyed
        # before its parent thus allowing cleanup of VTK elements.
        self._hidden = QWidget(self)
        self._hidden.hide()
        self._hidden.destroyed.connect(self.Finalize)