Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into CURA-11102_qml_warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Nov 1, 2023
2 parents bfca4d9 + cc0f88f commit bc32a16
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
6 changes: 6 additions & 0 deletions UM/Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def initialize(self) -> None:
Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "Resources", self._app_name, "resources"))

if not hasattr(sys, "frozen"):
uranium_data_root = os.environ.get('URANIUM_DATA_ROOT', None)
if uranium_data_root:
Resources.addSearchPath(str(Path(uranium_data_root).joinpath("resources")))
Resources.addSearchPath(str(Path(__file__).parent.parent.joinpath("resources")))
Resources.addSearchPath(str(Path(__file__).parent.parent.joinpath("plugins")))

Expand Down Expand Up @@ -234,6 +237,9 @@ def initialize(self) -> None:
self._plugin_registry.addPluginLocation(local_path)

if not hasattr(sys, "frozen"):
uranium_plugin_root = os.environ.get('URANIUM_DATA_ROOT', None)
if uranium_plugin_root:
Resources.addSearchPath(str(Path(uranium_plugin_root).joinpath("plugins")))
self._plugin_registry.addPluginLocation(str(Path(__file__).parent.parent.joinpath("plugins")))
self._plugin_registry.addPluginLocation(str(Path(__file__).parent.parent.parent.joinpath("plugins")))

Expand Down
16 changes: 16 additions & 0 deletions UM/Math/AxisAlignedBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def minimum(self) -> Vector:
def maximum(self) -> Vector:
return self._max

@property
def points(self) -> Tuple[Vector, Vector, Vector, Vector, Vector, Vector, Vector, Vector]:
"""Get the 8 points of the bounding box.
:return: A tuple of 8 points.
"""
return (
Vector(self._min.x, self._min.y, self._min.z),
Vector(self._max.x, self._min.y, self._min.z),
Vector(self._min.x, self._max.y, self._min.z),
Vector(self._max.x, self._max.y, self._min.z),
Vector(self._min.x, self._min.y, self._max.z),
Vector(self._max.x, self._min.y, self._max.z),
Vector(self._min.x, self._max.y, self._max.z),
Vector(self._max.x, self._max.y, self._max.z),
)

def isValid(self) -> bool:
"""Check if the bounding box is valid.
Uses fuzzycompare to validate.
Expand Down
8 changes: 8 additions & 0 deletions UM/Qt/Bindings/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from UM.Scene.Camera import Camera
from typing import Optional

from UM.View.GL.OpenGL import OpenGL

@signalemitter
class MainWindow(QQuickWindow):
Expand Down Expand Up @@ -280,7 +281,14 @@ def hideEvent(self, event):

renderCompleted = Signal(type = Signal.Queued)

_OPEN_GL_INITIALIZED = False

def _render(self):
if not self._OPEN_GL_INITIALIZED:
# initialize OpenGL singleton
OpenGL()
self._OPEN_GL_INITIALIZED = True

self.beginExternalCommands()
if self._full_render_required:
renderer = self._app.getRenderer()
Expand Down
26 changes: 13 additions & 13 deletions UM/Qt/QtRenderer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 Ultimaker B.V.
# Copyright (c) 2023 UltiMaker
# Uranium is released under the terms of the LGPLv3 or higher.

import numpy
Expand Down Expand Up @@ -41,18 +41,18 @@ class QtRenderer(Renderer):
def __init__(self) -> None:
super().__init__()

self._initialized = False # type: bool
self._initialized: bool = False

self._light_position = Vector(0, 0, 0) # type: Vector
self._background_color = QColor(128, 128, 128) # type: QColor
self._viewport_width = 0 # type: int
self._viewport_height = 0 # type: int
self._window_width = 0 # type: int
self._window_height = 0 # type: int
self._light_position: Vector = Vector(0, 0, 0)
self._background_color: QColor = QColor(128, 128, 128)
self._viewport_width: int = 0
self._viewport_height: int = 0
self._window_width: int = 0
self._window_height: int = 0

self._batches = [] # type: List[RenderBatch]
self._named_batches = {} # type: Dict[str, RenderBatch]
self._quad_buffer = None # type: QOpenGLBuffer
self._batches: List[RenderBatch] = []
self._named_batches: Dict[str, RenderBatch] = {}
self._quad_buffer: QOpenGLBuffer = None

initialized = Signal()

Expand Down Expand Up @@ -210,10 +210,10 @@ def _initialize(self) -> None:
supports_vao = OpenGLContext.supportsVertexArrayObjects() # fill the OpenGLContext.properties
Logger.log("d", "Support for Vertex Array Objects: %s", supports_vao)

OpenGL()
self._gl = OpenGL.getInstance().getBindingsObject()

default_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "default.shader")) # type: Optional[ShaderProgram]
default_shader: Optional[ShaderProgram] = OpenGL.getInstance().createShaderProgram(
Resources.getPath(Resources.Shaders, "default.shader"))
if default_shader is None:
return
self._default_material = default_shader
Expand Down

0 comments on commit bc32a16

Please sign in to comment.