def init_shaders(self): program = QOpenGLShaderProgram(self) if not program.addShaderFromSourceFile(QOpenGLShader.Vertex, get_resources_path("shader.vert")): return None if not program.addShaderFromSourceFile(QOpenGLShader.Fragment, get_resources_path("shader.frag")): return None if not program.link(): return None if not program.bind(): return None return program
def load_texture(material): # Note that the QImage is mirrored vertically to account for the fact that OpenGL and QImage use opposite directions for the y axis. # (https://doc.qt.io/qt-5/qopengltexture.html#details) texture = QOpenGLTexture(QImage(get_resources_path(material['diffuse_map'])).mirrored()) texture.setMinificationFilter(QOpenGLTexture.Nearest) texture.setMagnificationFilter(QOpenGLTexture.Nearest) texture.setWrapMode(QOpenGLTexture.ClampToEdge) return texture
def __init__(self, parent=None): super().__init__(get_resources_path(os.path.join('plugin_system', 'plugins', 'imu_v2', 'imu_v2.obj')), parent) self.save_orientation_flag = False self.has_save_orientation = False self.reference_orientation = QQuaternion() self.rotation = QQuaternion()
def highlight_debug_tab(self): """ SIGNAL function: Highlight the debug tab when an error occurs. """ if not self.tab_debug_warning and self.tab_widget.currentIndex() != self.tab_widget.indexOf(self.tab_debug): self.tab_debug_warning = True self.tab_set(self.tab_widget.indexOf(self.tab_debug), QColor(255, 0, 0), get_resources_path("warning-icon-16.png"))
def urlopen(*args, **kwargs): if 'context' in kwargs: raise ValueError("Don't pass an SSL context to this function, as it creates a custom one.") cert_path = get_resources_path('CertChain.crt', warn_on_missing_file=True) context = ssl.create_default_context() context.load_verify_locations(cert_path) return urllib.request.urlopen(*args, **kwargs, context=context)
def highlight_debug_tab(self): """ SIGNAL function: Highlight the debug tab when an error occurs. """ if not self.tab_debug_warning and self.tab_widget.currentWidget().objectName() != self.tab_debug.objectName(): self.tab_debug_warning = True self.tab_set(self.tab_widget.indexOf(self.tab_debug), QColor(255, 0, 0), os.path.join(get_resources_path(), "warning-icon.png"))
def load_texture(material): # Note that the QImage is mirrored vertically to account for the fact that OpenGL and QImage use opposite directions for the y axis. # (https://doc.qt.io/qt-5/qopengltexture.html#details) texture = QOpenGLTexture( QImage(get_resources_path(material['diffuse_map'])).mirrored()) texture.setMinificationFilter(QOpenGLTexture.Nearest) texture.setMagnificationFilter(QOpenGLTexture.Nearest) texture.setWrapMode(QOpenGLTexture.ClampToEdge) return texture
def init_shaders(self): program = QOpenGLShaderProgram(self) if not program.addShaderFromSourceFile( QOpenGLShader.Vertex, get_resources_path("shader.vert")): return None if not program.addShaderFromSourceFile( QOpenGLShader.Fragment, get_resources_path("shader.frag")): return None if not program.link(): return None if not program.bind(): return None return program
def load_pixmap(path, apply_mask=False): if image_data != None: data = QByteArray.fromBase64(image_data[path][1]) pixmap = QPixmap() pixmap.loadFromData(data, image_data[path][0]) else: absolute_path = os.path.join(get_resources_path(), path) pixmap = QPixmap(absolute_path) return pixmap
def __init__(self, parent=None): super().__init__( get_resources_path( os.path.join('plugin_system', 'plugins', 'imu_v2', 'imu_v2.obj')), parent) self.save_orientation_flag = False self.has_save_orientation = False self.reference_orientation = QQuaternion() self.rotation = QQuaternion()
def txt_console_highlight_tab(self): """ SIGNAL function: Highlight the console/message tab when an error occurs. """ if not self.tab_console_warning and self.tab_widget.currentWidget().objectName() != self.tab_console.objectName(): self.tab_console_warning = True from brickv.utils import get_resources_path from PyQt4.QtGui import QColor self.tab_set(self.tab_widget.indexOf(self.tab_console), QColor(255, 0, 0), os.path.join(get_resources_path(), "dialog-warning.png"))
def load_marker_file(name): try: # Don't warn if the file is missing, as it is expected when run from source. path = get_resources_path(name, warn_on_missing_file=False) if path is not None: with open(path, 'r') as f: return f.read().strip() except FileNotFoundError: pass return None
def txt_console_highlight_tab(self): """ SIGNAL function: Highlight the console/message tab when an error occurs. """ if not self.tab_console_warning and self.tab_widget.currentWidget( ).objectName() != self.tab_console.objectName(): self.tab_console_warning = True from brickv.utils import get_resources_path from PyQt4.QtGui import QColor self.tab_set( self.tab_widget.indexOf(self.tab_console), QColor(255, 0, 0), os.path.join(get_resources_path(), "dialog-warning.png"))
def load_pixmap(path): absolute_path = get_resources_path(path) pixmap = QPixmap(absolute_path) return pixmap