def initializeGL(self): """Initialize OpenGL, VBOs, upload data on the GPU, etc.""" # First check for supported GL version gl_version = float(gl.glGetString(gl.GL_VERSION)[:3]) if gl_version < 3.3: return # background color gl.glClearColor(0, 0, 0, 0) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.globaldata = ndUBO() try: # Compile shaders and link color shader program self.color_shader = BlueSkyProgram('data/graphics/shaders/nd-normal.vert', 'data/graphics/shaders/nd-color.frag') self.color_shader.bind_uniform_buffer('global_data', self.globaldata) # Compile shaders and link text shader program self.text_shader = BlueSkyProgram('data/graphics/shaders/nd-text.vert', 'data/graphics/shaders/nd-text.frag') self.text_shader.bind_uniform_buffer('global_data', self.globaldata) except RuntimeError as e: qCritical('Error compiling shaders in radarwidget: ' + e.args[0]) return # Set initial zoom self.globaldata.set_zoom(4.0) self.create_objects()
def displayMeter(self, meter, level, forced=False): if not isinstance(meter, int): return qCritical("DigitalPeakMeter::displayMeter(,) - meter value must be an integer") if not isinstance(level, float): return qCritical("DigitalPeakMeter::displayMeter(%i,) - level value must be a float" % (meter,)) if meter <= 0 or meter > self.fChannelCount: return qCritical("DigitalPeakMeter::displayMeter(%i, %f) - invalid meter number" % (meter, level)) i = meter - 1 if self.fSmoothMultiplier > 0 and not forced: level = (self.fLastChannelData[i] * float(self.fSmoothMultiplier) + level) / float( self.fSmoothMultiplier + 1 ) if level < 0.001: level = 0.0 elif level > 0.999: level = 1.0 if self.fChannelData[i] != level: self.fChannelData[i] = level self.update() self.fLastChannelData[i] = level
def setGroupPosFull(group_id, group_pos_x_o, group_pos_y_o, group_pos_x_i, group_pos_y_i): if canvas.debug: print("PatchCanvas::setGroupPos(%i, %i, %i, %i, %i)" % (group_id, group_pos_x_o, group_pos_y_o, group_pos_x_i, group_pos_y_i)) for group in canvas.group_list: if group.group_id == group_id: group.widgets[0].blockSignals(True) group.widgets[0].setPos(group_pos_x_o, group_pos_y_o) group.widgets[0].checkItemPos() group.widgets[0].blockSignals(False) if group.split and group.widgets[1]: group.widgets[1].blockSignals(True) group.widgets[1].setPos(group_pos_x_i, group_pos_y_i) group.widgets[1].checkItemPos() group.widgets[1].blockSignals(False) QTimer.singleShot(0, canvas.scene.update) return qCritical( "PatchCanvas::setGroupPos(%i, %i, %i, %i, %i) - unable to find group to reposition" % (group_id, group_pos_x_o, group_pos_y_o, group_pos_x_i, group_pos_y_i))
def initializeGL(self): """Initialize OpenGL, VBOs, upload data on the GPU, etc.""" # First check for supported GL version gl_version = float(gl.glGetString(gl.GL_VERSION)[:3]) if gl_version < 3.3: return # background color gl.glClearColor(0, 0, 0, 0) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) try: self.shaderset.load_shaders() # Compile shaders and link color shader program self.color_shader = self.shaderset['normal'] # Compile shaders and link text shader program self.text_shader = self.shaderset['text'] except RuntimeError as e: qCritical('Error compiling shaders in radarwidget: ' + e.args[0]) return # Set initial zoom self.shaderset.set_zoom(4.0) self.create_objects()
def setIcon(self, icon, name): name = name.lower() icon_path = "" if icon == ICON_APPLICATION: self.p_size = QRectF(3, 2, 19, 18) if "audacious" in name: icon_path = ":/scalable/pb_audacious.svg" self.p_size = QRectF(5, 4, 16, 16) elif "clementine" in name: icon_path = ":/scalable/pb_clementine.svg" self.p_size = QRectF(5, 4, 16, 16) elif "distrho" in name: icon_path = ":/scalable/pb_distrho.svg" self.p_size = QRectF(5, 4, 16, 16) elif "jamin" in name: icon_path = ":/scalable/pb_jamin.svg" self.p_size = QRectF(5, 3, 16, 16) elif "mplayer" in name: icon_path = ":/scalable/pb_mplayer.svg" self.p_size = QRectF(5, 4, 16, 16) elif "vlc" in name: icon_path = ":/scalable/pb_vlc.svg" self.p_size = QRectF(5, 3, 16, 16) else: icon_path = ":/scalable/pb_generic.svg" self.p_size = QRectF(4, 3, 16, 16) elif icon == ICON_HARDWARE: icon_path = ":/scalable/pb_hardware.svg" self.p_size = QRectF(5, 2, 16, 16) elif icon == ICON_DISTRHO: icon_path = ":/scalable/pb_distrho.svg" self.p_size = QRectF(5, 4, 16, 16) elif icon == ICON_FILE: icon_path = ":/scalable/pb_file.svg" self.p_size = QRectF(5, 4, 16, 16) elif icon == ICON_PLUGIN: icon_path = ":/scalable/pb_plugin.svg" self.p_size = QRectF(5, 4, 16, 16) elif icon == ICON_LADISH_ROOM: # TODO - make a unique ladish-room icon icon_path = ":/scalable/pb_hardware.svg" self.p_size = QRectF(5, 2, 16, 16) else: self.p_size = QRectF(0, 0, 0, 0) qCritical("PatchCanvas::CanvasIcon.setIcon(%s, %s) - unsupported icon requested" % ( icon2str(icon), name.encode())) return self.m_renderer = QSvgRenderer(icon_path, canvas.scene) self.setSharedRenderer(self.m_renderer) self.update()
def displayMeter(self, meter, level, forced=False): if not isinstance(meter, int): return qCritical( "DigitalPeakMeter::displayMeter(,) - meter value must be an integer" ) if not isinstance(level, float): return qCritical( "DigitalPeakMeter::displayMeter(%i,) - level value must be a float" % (meter, )) if meter <= 0 or meter > self.fChannelCount: return qCritical( "DigitalPeakMeter::displayMeter(%i, %f) - invalid meter number" % (meter, level)) i = meter - 1 if self.fSmoothMultiplier > 0 and not forced: level = (self.fLastChannelData[i] * float(self.fSmoothMultiplier) + level) / float(self.fSmoothMultiplier + 1) if level < 0.001: level = 0.0 elif level > 0.999: level = 1.0 if self.fChannelData[i] != level: self.fChannelData[i] = level self.update() self.fLastChannelData[i] = level
def init(self, organizer): self._organizer = organizer if (not self._organizer.onAboutToRun( lambda appName: self._preventLoot(appName))): qCritical("Failed to register onAboutToRun callback!") return False return True
def initializeGL(self): init_glcontext(self.context()) # First check for supported GL version gl_version = float(gl.glGetString(gl.GL_VERSION)[:3]) if gl_version < 3.3: print(('OpenGL context created with GL version %.1f' % gl_version)) qCritical( """Your system reports that it supports OpenGL up to version %.1f. The minimum requirement for BlueSky is OpenGL 3.3. Generally, AMD/ATI/nVidia cards from 2008 and newer support OpenGL 3.3, and Intel integrated graphics from the Haswell generation and newer. If you think your graphics system should be able to support GL>=3.3 please open an issue report on the BlueSky Github page (https://github.com/TUDelft-CNS-ATM/bluesky/issues)""" % gl_version) return if self._shaderset is None and self._renderobjs: qCritical( "Cannot create render objects without an initialised shader set!" ) return # Initialise our shaderset if this hasn't been done yet if not self._shaderset.created(): self._shaderset.create() # Call the create method of all registered objects for obj in self._renderobjs.values(): obj.create()
def connectPorts(connection_id, group_out_id, port_out_id, group_in_id, port_in_id): if canvas.debug: print("PatchCanvas::connectPorts(%i, %i, %i, %i, %i)" % (connection_id, group_out_id, port_out_id, group_in_id, port_in_id)) port_out = None port_in = None port_out_parent = None port_in_parent = None for port in canvas.port_list: if port.group_id == group_out_id and port.port_id == port_out_id: port_out = port.widget port_out_parent = port_out.parentItem() elif port.group_id == group_in_id and port.port_id == port_in_id: port_in = port.widget port_in_parent = port_in.parentItem() # FIXME if not (port_out and port_in): qCritical( "PatchCanvas::connectPorts(%i, %i, %i, %i, %i) - unable to find ports to connect" % (connection_id, group_out_id, port_out_id, group_in_id, port_in_id)) return connection_dict = connection_dict_t() connection_dict.connection_id = connection_id connection_dict.group_in_id = group_in_id connection_dict.port_in_id = port_in_id connection_dict.group_out_id = group_out_id connection_dict.port_out_id = port_out_id if options.use_bezier_lines: connection_dict.widget = CanvasBezierLine(port_out, port_in, None) else: connection_dict.widget = CanvasLine(port_out, port_in, None) canvas.scene.addItem(connection_dict.widget) port_out_parent.addLineFromGroup(connection_dict.widget, connection_id) port_in_parent.addLineFromGroup(connection_dict.widget, connection_id) canvas.last_z_value += 1 port_out_parent.setZValue(canvas.last_z_value) port_in_parent.setZValue(canvas.last_z_value) canvas.last_z_value += 1 connection_dict.widget.setZValue(canvas.last_z_value) canvas.connection_list.append(connection_dict) if options.eyecandy == EYECANDY_FULL: item = connection_dict.widget CanvasItemFX(item, True, False) return QTimer.singleShot(0, canvas.scene.update)
def addPort(group_id, port_id, port_name, port_mode, port_type, is_alternate=False): if canvas.debug: print("PatchCanvas::addPort(%i, %i, %s, %s, %s, %s)" % (group_id, port_id, port_name.encode(), port_mode2str(port_mode), port_type2str(port_type), bool2str(is_alternate))) for port in canvas.port_list: if port.group_id == group_id and port.port_id == port_id: qWarning( "PatchCanvas::addPort(%i, %i, %s, %s, %s) - port already exists" % (group_id, port_id, port_name.encode(), port_mode2str(port_mode), port_type2str(port_type))) return box_widget = None port_widget = None for group in canvas.group_list: if group.group_id == group_id: if group.split and group.widgets[0].getSplittedMode( ) != port_mode and group.widgets[1]: n = 1 else: n = 0 box_widget = group.widgets[n] port_widget = box_widget.addPortFromGroup(port_id, port_mode, port_type, port_name, is_alternate) break if not (box_widget and port_widget): qCritical( "PatchCanvas::addPort(%i, %i, %s, %s, %s) - Unable to find parent group" % (group_id, port_id, port_name.encode(), port_mode2str(port_mode), port_type2str(port_type))) return port_dict = port_dict_t() port_dict.group_id = group_id port_dict.port_id = port_id port_dict.port_name = port_name port_dict.port_mode = port_mode port_dict.port_type = port_type port_dict.is_alternate = is_alternate port_dict.widget = port_widget canvas.port_list.append(port_dict) box_widget.updatePositions() if options.eyecandy == EYECANDY_FULL: CanvasItemFX(port_widget, True, False) return QTimer.singleShot(0, canvas.scene.update)
def initializeGL(self): """Initialize OpenGL, VBOs, upload data on the GPU, etc.""" # First check for supported GL version gl_version = float(gl.glGetString(gl.GL_VERSION)[:3]) if gl_version < 3.3: print('OpenGL context created with GL version %.1f' % gl_version) qCritical( """Your system reports that it supports OpenGL up to version %.1f. The minimum requirement for BlueSky is OpenGL 3.3. Generally, AMD/ATI/nVidia cards from 2008 and newer support OpenGL 3.3, and Intel integrated graphics from the Haswell generation and newer. If you think your graphics system should be able to support GL>=3.3 please open an issue report on the BlueSky Github page (https://github.com/ProfHoekstra/bluesky/issues)""" % gl_version) return # background color gl.glClearColor(0, 0, 0, 0) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.globaldata = radarUBO() try: # Compile shaders and link color shader program self.color_shader = BlueSkyProgram( 'data/graphics/shaders/radarwidget-normal.vert', 'data/graphics/shaders/radarwidget-color.frag') self.color_shader.bind_uniform_buffer('global_data', self.globaldata) # Compile shaders and link texture shader program self.texture_shader = BlueSkyProgram( 'data/graphics/shaders/radarwidget-normal.vert', 'data/graphics/shaders/radarwidget-texture.frag') self.texture_shader.bind_uniform_buffer('global_data', self.globaldata) # Compile shaders and link text shader program self.text_shader = BlueSkyProgram( 'data/graphics/shaders/radarwidget-text.vert', 'data/graphics/shaders/radarwidget-text.frag') self.text_shader.bind_uniform_buffer('global_data', self.globaldata) self.ssd_shader = BlueSkyProgram('data/graphics/shaders/ssd.vert', 'data/graphics/shaders/ssd.frag', 'data/graphics/shaders/ssd.geom') self.ssd_shader.bind_uniform_buffer('global_data', self.globaldata) self.ssd_shader.loc_vlimits = gl.glGetUniformLocation( self.ssd_shader.program, 'Vlimits') self.ssd_shader.loc_nac = gl.glGetUniformLocation( self.ssd_shader.program, 'n_ac') except RuntimeError as e: qCritical('Error compiling shaders in radarwidget: ' + e.args[0]) return # create all vertex array objects self.create_objects()
def openMergedModMenu(self, position): selectedItems = self.mergedModList.selectedItems() if selectedItems: menu = QtWidgets.QMenu() selectedItemsData = [item.data(0, Qt.UserRole) for item in selectedItems] selectedMods = [selectedItemData['modName'] for selectedItemData in selectedItemsData] selectedModsWithEnabled = [selectedItemData['modName'] for selectedItemData in selectedItemsData if (selectedItemData['modPluginsState'] in Dc.SomeModPluginsInactive)] selectedModsWithDisabled = [selectedItemData['modName'] for selectedItemData in selectedItemsData if (selectedItemData['modPluginsState'] in Dc.SomeModPluginsActive)] enableAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/active'), self.__tr('&Enable plugins'), self) enableAction.setEnabled(False) menu.addAction(enableAction) if selectedModsWithEnabled: enableAction.setEnabled(True) disableAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/inactive'), self.__tr('&Disable plugins'), self) disableAction.setEnabled(False) menu.addAction(disableAction) if selectedModsWithDisabled: disableAction.setEnabled(True) action = menu.exec_(self.mergedModList.mapToGlobal(position)) # Catch and log exceptional side-effects try: if action == enableAction: for selectedMod in selectedModsWithEnabled: for plugin in self.__mergedModInfo[selectedMod]['plugins']: if plugin in self.__pluginInfo: pluginInfo = self.__pluginInfo[plugin.lower()] for mod in pluginInfo['mods']: if self.__hide_type == "mohidden": Dc.tryMoveFile(os.path.join(mod['dirname'], pluginInfo['filename'] + '.mohidden'), os.path.join(mod['dirname'], pluginInfo['filename'])) if self.__hide_type == "optional": Dc.tryMoveFile(os.path.join(mod['dirname'], 'optional', pluginInfo['filename']), os.path.join(mod['dirname'], pluginInfo['filename'])) if self.__hide_type == "disable": Dc.setPluginStateByName(self.__organizer, pluginInfo['filename'], Dc.PluginState.ACTIVE) if action == disableAction: for selectedMod in selectedModsWithDisabled: for plugin in self.__mergedModInfo[selectedMod]['plugins']: if plugin in self.__pluginInfo: pluginInfo = self.__pluginInfo[plugin.lower()] for mod in pluginInfo['mods']: if self.__hide_type == "mohidden": Dc.tryMoveFile(os.path.join(mod['dirname'], pluginInfo['filename']), os.path.join(mod['dirname'], pluginInfo['filename'] + '.mohidden')) if self.__hide_type == "optional": Dc.tryCreateDir(os.path.join(mod['dirname'], 'optional')) Dc.tryMoveFile(os.path.join(mod['dirname'], pluginInfo['filename']), os.path.join(mod['dirname'], 'optional', pluginInfo['filename'])) if self.__hide_type == "disable": Dc.setPluginStateByName(self.__organizer, pluginInfo['filename'], Dc.PluginState.INACTIVE) self.refreshMergedModList() except Exception as e: qCritical(traceback.format_exc().encode('utf-8')) qCritical(str(e).encode('utf-8'))
def removeLineFromGroup(self, connection_id): for connection in self.m_connection_lines: if connection.connection_id == connection_id: self.m_connection_lines.remove(connection) return qCritical( "PatchCanvas::CanvasBox.removeLineFromGroup(%i) - unable to find line to remove" % connection_id)
def loadSkin(self): qDebug('Loading skin...') try: with open('resources/skin.css', 'r') as handle: skinCss = handle.read() self.setStyleSheet(skinCss) except IOError as err: qCritical('Failed to load skin file.')
def openProfileMenu(self, position): selectedItems = self.profileList.selectedItems() if selectedItems: menu = QtWidgets.QMenu() selectedItemsData = [ item.data(0, Qt.UserRole) for item in selectedItems ] selectedProfiles = [ selectedItemData['profileName'] for selectedItemData in selectedItemsData ] syncAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/next'), self.__tr('&Sync mod order'), self) syncAction.setEnabled(True) menu.addAction(syncAction) action = menu.exec_(self.profileList.mapToGlobal(position)) try: if action == syncAction: for profileName in selectedProfiles: profileInfo = self.__profileInfo[profileName] modListPath = os.path.join(profileInfo['path'], 'modlist.txt') modListBackupPath = modListPath + '.' + datetime.datetime.now( ).strftime('%Y%m%d%H%M%S%f') qDebug( self.__tr("Backing up to {}".format( modListBackupPath)).encode('utf-8')) shutil.copy(modListPath, modListBackupPath) selectedModListInfo = self.getModListInfoByPath( modListPath) mergedModListInfo = dict(self.__modListInfo, **selectedModListInfo) for modName in list(self.__modListInfo.keys()): mergedModListInfo[modName][ 'index'] = self.__modListInfo[modName]['index'] qDebug( self.__tr("Updating {} mod order".format( modListPath)).encode('utf-8')) with open(modListPath, 'w', encoding='utf-8') as modListFile: for modName, modListEntry in sorted( list(mergedModListInfo.items()), key=lambda x: x[1]['index']): modListFile.write(modListEntry['symbol'] + modListEntry['name'] + '\n') self.refreshProfileList() except Exception as e: qCritical(str(e).encode('utf-8'))
def load(self): with Path(self.fileName).open('rb') as file: magicNumber = file.read(4) if magicNumber != DDSDefinitions.DDS_MAGIC_NUMBER: qCritical(self.__tr("Magic number mismatch.")) raise DDSReadException() self.header.fromStream(file) if self.header.ddspf.dwFlags & DDSDefinitions.DDS_PIXELFORMAT.Flags.DDPF_FOURCC: fourCC = self.header.ddspf.dwFourCC if fourCC == b"DX10": self.dxt10Header = DDSDefinitions.DDS_HEADER_DXT10() self.dxt10Header.fromStream(file) else: fourCC = None self.glFormat = DDSDefinitions.getGLFormat(self.header.ddspf, self.dxt10Header) self.data = [] # Do this once per layer/mip level whatever, (times one per scanline if uncompressed). Also, potentially recompute this based on the format and size in case writers lie. #self.data.append(file.read(self.header.dwPitchOrLinearSize)) layerCount = 1 if self.header.dwCaps2 & DDSDefinitions.DDS_HEADER.Caps2.DDSCAPS2_CUBEMAP: self.isCubemap = True layerCount = 0 for face in ddsCubemapFaces: if self.header.dwCaps2 & face: layerCount += 1 else: self.isCubemap = False for layer in range(layerCount): nextWidth = self.header.dwWidth nextHeight = self.header.dwHeight mipCount = self.mipLevels() for level in range(mipCount): if self.header.ddspf.dwFlags & ( DDSDefinitions.DDS_PIXELFORMAT.Flags.DDPF_ALPHA | DDSDefinitions.DDS_PIXELFORMAT.Flags.DDPF_RGB | DDSDefinitions.DDS_PIXELFORMAT.Flags.DDPF_YUV | DDSDefinitions.DDS_PIXELFORMAT.Flags.DDPF_LUMINANCE ): size = nextWidth * nextHeight * ( (self.header.ddspf.dwRGBBitCount + 7) // 8) elif fourCC: if self.dxt10Header: dxgiFormat = self.dxt10Header.dxgiFormat else: dxgiFormat = DDSDefinitions.fourCCToDXGI(fourCC) size = DDSDefinitions.sizeFromFormat( dxgiFormat, nextWidth, nextHeight) self.data.append(file.read(size)) nextWidth = max(nextWidth // 2, 1) nextHeight = max(nextHeight // 2, 1)
def open(self, index: QModelIndex): model: QAbstractProxyModel = index.model() if model and index.isValid(): qDebug(f"Open address: {self.text()}") index = model.mapToSource(index) self.tab.openItem(index) else: qCritical(f"Index was not found for address {self.text()}") QMessageBox.critical(self, "Error", f"Item not found: {self.text()}")
def getGroupPos(group_id, port_mode=PORT_MODE_OUTPUT): if canvas.debug: print("PatchCanvas::getGroupPos(%i, %s)" % (group_id, port_mode2str(port_mode))) for group in canvas.group_list: if group.group_id == group_id: return group.widgets[1 if (group.split and port_mode == PORT_MODE_INPUT) else 0].pos() qCritical("PatchCanvas::getGroupPos(%i, %s) - unable to find group" % (group_id, port_mode2str(port_mode))) return QPointF(0, 0)
def init(self, organizer): self.__organizer = organizer if sys.version_info < (3, 6): qCritical(self.__tr("OpenMWExport plugin requires a Python {0} interpreter or newer, but is running on a Python {1} interpreter.").format("3.6", ".".join(map(str, sys.version_info[:3])))) QMessageBox.critical(self._parentWidget(), self.__tr("Incompatible Python version."), self.__tr("This version of the OpenMW Export plugin requires a Python {0} interpreter or newer, but Mod Organizer has provided a Python {1} interpreter. Mod Organizer {2} is the earliest compatible version. You should check for an update.").format("3.6", ".".join(map(str, sys.version_info[:3])), "2.1.6")) return False if self.__organizer.appVersion() >= mobase.VersionInfo(2, 3, 1): self.__nexusBridge = self.__organizer.createNexusBridge() self.__nexusBridge.descriptionAvailable.connect(self.__onDescriptionReceived) self.__organizer.onUserInterfaceInitialized(self.__checkForUpdate) return True
def run(self): # print("start") try: output = subprocess.getoutput(["sudo systemctl status v2rayL.service"]) if "Active: active" in output: subprocess.call(["sudo systemctl restart v2rayL.service"], shell=True) else: subprocess.call(["sudo systemctl start v2rayL.service"], shell=True) # subprocess.call(["sudo systemctl stop v2rayL.service"], shell=True) # print("end") except Exception as e: qCritical(e)
def setSmoothMultiplier(self, value): if self.fSmoothMultiplier == value: return if not isinstance(value, int): return qCritical("DigitalPeakMeter::setSmoothMultiplier() - value must be an integer") if value < 0: return qCritical("DigitalPeakMeter::setSmoothMultiplier(%i) - value must be >= 0" % value) if value > 5: return qCritical("DigitalPeakMeter::setSmoothMultiplier(%i) - value must be < 5" % value) self.fSmoothMultiplier = value
def init(self, organizer): self.__organizer = organizer if sys.version_info < (3, 0): qCritical( self.__tr( "OpenMWExport plugin requires a Python 3 interpreter, but is running on a Python 2 interpreter." )) QMessageBox.critical( self.__parentWidget, self.__tr("Incompatible Python version."), self.__tr( "This version of the OpenMW Export plugin requires a Python 3 interpreter, but Mod Organizer has provided a Python 2 interpreter. Mod Organizer 2.1.6 is the earliest compatible version. You should check for an update." )) return True
def initializeGL(self): """Initialize OpenGL, VBOs, upload data on the GPU, etc.""" # First check for supported GL version gl_version = float(gl.glGetString(gl.GL_VERSION)[:3]) if gl_version < 3.3: print(('OpenGL context created with GL version %.1f' % gl_version)) qCritical("""Your system reports that it supports OpenGL up to version %.1f. The minimum requirement for BlueSky is OpenGL 3.3. Generally, AMD/ATI/nVidia cards from 2008 and newer support OpenGL 3.3, and Intel integrated graphics from the Haswell generation and newer. If you think your graphics system should be able to support GL>=3.3 please open an issue report on the BlueSky Github page (https://github.com/ProfHoekstra/bluesky/issues)""" % gl_version) return # background color gl.glClearColor(*(palette.background + (0,))) gl.glEnable(gl.GL_BLEND) gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) self.globaldata = radarUBO() try: shpath = path.join(settings.gfx_path, 'shaders') # Compile shaders and link color shader program self.color_shader = BlueSkyProgram(path.join(shpath, 'radarwidget-normal.vert'), path.join(shpath, 'radarwidget-color.frag')) self.color_shader.bind_uniform_buffer('global_data', self.globaldata) # Compile shaders and link texture shader program self.texture_shader = BlueSkyProgram(path.join(shpath, 'radarwidget-normal.vert'), path.join(shpath, 'radarwidget-texture.frag')) self.texture_shader.bind_uniform_buffer('global_data', self.globaldata) # Compile shaders and link text shader program self.text_shader = BlueSkyProgram(path.join(shpath, 'radarwidget-text.vert'), path.join(shpath, 'radarwidget-text.frag')) self.text_shader.bind_uniform_buffer('global_data', self.globaldata) self.ssd_shader = BlueSkyProgram(path.join(shpath, 'ssd.vert'), path.join(shpath, 'ssd.frag'), path.join(shpath, 'ssd.geom')) self.ssd_shader.bind_uniform_buffer('global_data', self.globaldata) self.ssd_shader.loc_vlimits = gl.glGetUniformLocation(self.ssd_shader.program, 'Vlimits') self.ssd_shader.loc_nac = gl.glGetUniformLocation(self.ssd_shader.program, 'n_ac') except RuntimeError as e: print('Error compiling shaders in radarwidget: ' + e.args[0]) qCritical('Error compiling shaders in radarwidget: ' + e.args[0]) return # create all vertex array objects self.create_objects() try: pass # self.create_objects() except Exception as e: print('Error while creating RadarWidget objects: ' + e.args[0])
def init(self, organizer): self.__organizer = organizer if sys.version_info < (3, 0): qCritical( self.__tr( "FNISPatches plugin requires a Python 3 interpreter, but is running on a Python 2 interpreter." )) QMessageBox.critical( self.__parentWidget, self.__tr("Incompatible Python version."), self.__tr( "This version of the FNIS Patches plugin requires a Python 3 interpreter, but Mod Organizer has provided a Python 2 interpreter. You should check for an updated version, including in the Mod Organizer 2 Development Discord Server." )) return False return True
def removeGroup(group_id): if canvas.debug: print("PatchCanvas::removeGroup(%i)" % group_id) for group in canvas.group_list: if group.group_id == group_id: item = group.widgets[0] group_name = group.group_name if group.split: s_item = group.widgets[1] if features.handle_group_pos: canvas.settings.setValue( "CanvasPositions/%s_OUTPUT" % group_name, item.pos()) canvas.settings.setValue( "CanvasPositions/%s_INPUT" % group_name, s_item.pos()) canvas.settings.setValue( "CanvasPositions/%s_SPLIT" % group_name, SPLIT_YES) if options.eyecandy == EYECANDY_FULL: CanvasItemFX(s_item, False, True) else: s_item.removeIconFromScene() canvas.scene.removeItem(s_item) del s_item else: if features.handle_group_pos: canvas.settings.setValue("CanvasPositions/%s" % group_name, item.pos()) canvas.settings.setValue( "CanvasPositions/%s_SPLIT" % group_name, SPLIT_NO) if options.eyecandy == EYECANDY_FULL: CanvasItemFX(item, False, True) else: item.removeIconFromScene() canvas.scene.removeItem(item) del item canvas.group_list.remove(group) canvas.group_plugin_map.pop(group.plugin_id, None) QTimer.singleShot(0, canvas.scene.update) return qCritical("PatchCanvas::removeGroup(%i) - unable to find group to remove" % group_id)
def renamePort(group_id, port_id, new_port_name): if canvas.debug: print("PatchCanvas::renamePort(%i, %i, %s)" % (group_id, port_id, new_port_name.encode())) for port in canvas.port_list: if port.group_id == group_id and port.port_id == port_id: port.port_name = new_port_name port.widget.setPortName(new_port_name) port.widget.parentItem().updatePositions() QTimer.singleShot(0, canvas.scene.update) return qCritical("PatchCanvas::renamePort(%i, %i, %s) - Unable to find port to rename" % ( group_id, port_id, new_port_name.encode()))
def setMeterStyle(self, style): if self.fMeterStyle == style: return if style not in (self.STYLE_DEFAULT, self.STYLE_OPENAV, self.STYLE_RNCBC, self.STYLE_CALF): return qCritical("DigitalPeakMeter::setMeterStyle(%i) - invalid style" % style) if style == self.STYLE_DEFAULT: self.fMeterBackground = QColor("#070707") elif style == self.STYLE_OPENAV: self.fMeterBackground = QColor("#1A1A1A") elif style == self.STYLE_RNCBC: self.fMeterBackground = QColor("#070707") elif style == self.STYLE_CALF: self.fMeterBackground = QColor("#000") if style == self.STYLE_CALF: self.fMeterPixmaps = (QPixmap(":/bitmaps/meter_calf_off.png"), QPixmap(":/bitmaps/meter_calf_on.png")) if self.fChannelCount > 0: self.setFixedSize(100, 12 * self.fChannelCount) else: self.fMeterPixmaps = () self.setMinimumSize(0, 0) self.setMaximumSize(9999, 9999) self.fMeterStyle = style self.updateGrandient()
def setMeterStyle(self, style): if self.fMeterStyle == style: return if style not in (self.STYLE_DEFAULT, self.STYLE_OPENAV, self.STYLE_RNCBC, self.STYLE_CALF): return qCritical( "DigitalPeakMeter::setMeterStyle(%i) - invalid style" % style) if style == self.STYLE_DEFAULT: self.fMeterBackground = QColor("#070707") elif style == self.STYLE_OPENAV: self.fMeterBackground = QColor("#1A1A1A") elif style == self.STYLE_RNCBC: self.fMeterBackground = QColor("#070707") elif style == self.STYLE_CALF: self.fMeterBackground = QColor("#000") if style == self.STYLE_CALF: self.fMeterPixmaps = (QPixmap(":/bitmaps/meter_calf_off.png"), QPixmap(":/bitmaps/meter_calf_on.png")) if self.fChannelCount > 0: self.setFixedSize(100, 12 * self.fChannelCount) else: self.fMeterPixmaps = () self.setMinimumSize(0, 0) self.setMaximumSize(9999, 9999) self.fMeterStyle = style self.updateGrandient()
def __init__(self, DatabaseName: str): ''' Constructor: Initialises a connection to the database ''' super.__init__(self) self._schema = {} self._db = QSqlDatabase(QSqlDriver.SQLite) self._db.setDatabaseName(DatabaseName) if not self._db.open(): qCritical("Failed to establish connection with database " + DatabaseName) return self._initSchema()
def removePort(group_id, port_id): if canvas.debug: print("PatchCanvas::removePort(%i, %i)" % (group_id, port_id)) for port in canvas.port_list: if port.group_id == group_id and port.port_id == port_id: item = port.widget item.parentItem().removePortFromGroup(port_id) canvas.scene.removeItem(item) canvas.port_list.remove(port) del item QTimer.singleShot(0, canvas.scene.update) return qCritical("PatchCanvas::removePort(%i, %i) - Unable to find port to remove" % (group_id, port_id))
def setOrientation(self, orientation): self.fOrientation = orientation self.fGradientMeter = QLinearGradient(0, 0, 1, 1) if self.fMeterStyle == self.STYLE_OPENAV: self.fGradientMeter.setColorAt(0.0, self.fColorBase) self.fGradientMeter.setColorAt(1.0, self.fColorBase) elif self.fOrientation == self.HORIZONTAL: self.fGradientMeter.setColorAt(0.0, self.fColorBase) self.fGradientMeter.setColorAt(0.2, self.fColorBase) self.fGradientMeter.setColorAt(0.4, self.fColorBase) self.fGradientMeter.setColorAt(0.6, self.fColorBase) self.fGradientMeter.setColorAt(0.8, Qt.yellow) self.fGradientMeter.setColorAt(1.0, Qt.red) elif self.fOrientation == self.VERTICAL: self.fGradientMeter.setColorAt(0.0, Qt.red) self.fGradientMeter.setColorAt(0.2, Qt.yellow) self.fGradientMeter.setColorAt(0.4, self.fColorBase) self.fGradientMeter.setColorAt(0.6, self.fColorBase) self.fGradientMeter.setColorAt(0.8, self.fColorBase) self.fGradientMeter.setColorAt(1.0, self.fColorBase) else: return qCritical("DigitalPeakMeter::setOrientation(%i) - invalid orientation" % orientation) self.updateSizes()
def setGroupIcon(group_id, icon): if canvas.debug: print("PatchCanvas::setGroupIcon(%i, %s)" % (group_id, icon2str(icon))) for group in canvas.group_list: if group.group_id == group_id: group.icon = icon group.widgets[0].setIcon(icon) if group.split and group.widgets[1]: group.widgets[1].setIcon(icon) QTimer.singleShot(0, canvas.scene.update) return qCritical("PatchCanvas::setGroupIcon(%i, %s) - unable to find group to change icon" % (group_id, icon2str(icon)))
def renameGroup(group_id, new_group_name): if canvas.debug: print("PatchCanvas::renameGroup(%i, %s)" % (group_id, new_group_name.encode())) for group in canvas.group_list: if group.group_id == group_id: group.group_name = new_group_name group.widgets[0].setGroupName(new_group_name) if group.split and group.widgets[1]: group.widgets[1].setGroupName(new_group_name) QTimer.singleShot(0, canvas.scene.update) return qCritical("PatchCanvas::renameGroup(%i, %s) - unable to find group to rename" % (group_id, new_group_name.encode()))
def CanvasGetFullPortName(group_id, port_id): if canvas.debug: print("PatchCanvas::CanvasGetFullPortName(%i, %i)" % (group_id, port_id)) for port in canvas.port_list: if port.group_id == group_id and port.port_id == port_id: group_id = port.group_id for group in canvas.group_list: if group.group_id == group_id: return group.group_name + ":" + port.port_name break qCritical( "PatchCanvas::CanvasGetFullPortName(%i, %i) - unable to find port" % (group_id, port_id)) return ""
def setMode(self, mode): if mode == self.HORIZONTAL: self.fMidiMap = kMidiKey2RectMapHorizontal self.fPixmap.load(":/bitmaps/kbd_h_dark.png") self.fPixmapMode = self.HORIZONTAL self.fWidth = self.fPixmap.width() self.fHeight = self.fPixmap.height() / 2 elif mode == self.VERTICAL: self.fMidiMap = kMidiKey2RectMapVertical self.fPixmap.load(":/bitmaps/kbd_v_dark.png") self.fPixmapMode = self.VERTICAL self.fWidth = self.fPixmap.width() / 2 self.fHeight = self.fPixmap.height() else: qCritical("PixmapKeyboard::setMode(%i) - invalid mode" % mode) return self.setMode(self.HORIZONTAL) self.setOctaves(self.fOctaves)
def setMeterOrientation(self, orientation): if self.fMeterOrientation == orientation: return if orientation not in (self.HORIZONTAL, self.VERTICAL): return qCritical("DigitalPeakMeter::setMeterOrientation(%i) - invalid orientation" % orientation) self.fMeterOrientation = orientation self.updateGrandient()
def setChannels(self, channels): if channels < 0: return qCritical("DigitalPeakMeter::setChannels(%i) - 'channels' must be a positive integer" % channels) self.fChannels = channels self.fChannelsData = [] self.fLastValueData = [] for x in range(channels): self.fChannelsData.append(0.0) self.fLastValueData.append(0.0)
def setColor(self, color): if color == self.GREEN: self.fColorBase = QColor(93, 231, 61) self.fColorBaseAlt = QColor(15, 110, 15, 100) elif color == self.BLUE: self.fColorBase = QColor(82, 238, 248) self.fColorBaseAlt = QColor(15, 15, 110, 100) else: return qCritical("DigitalPeakMeter::setColor(%i) - invalid color" % color) self.setOrientation(self.fOrientation)
def setMeterColor(self, color): if self.fMeterColor == color: return if color not in (self.COLOR_GREEN, self.COLOR_BLUE): return qCritical("DigitalPeakMeter::setMeterColor(%i) - invalid color" % color) if color == self.COLOR_GREEN: self.fMeterColorBase = QColor(93, 231, 61) self.fMeterColorBaseAlt = QColor(15, 110, 15, 100) elif color == self.COLOR_BLUE: self.fMeterColorBase = QColor(82, 238, 248) self.fMeterColorBaseAlt = QColor(15, 15, 110, 100) self.fMeterColor = color self.updateGrandient()
def setChannelCount(self, count): if self.fChannelCount == count: return if count < 0: return qCritical( "DigitalPeakMeter::setChannelCount(%i) - channel count must be a positive integer or zero" % count ) self.fChannelCount = count self.fChannelData = [] self.fLastChannelData = [] for x in range(count): self.fChannelData.append(0.0) self.fLastChannelData.append(0.0) if self.fMeterStyle == self.STYLE_CALF: if self.fChannelCount > 0: self.setFixedSize(100, 12 * self.fChannelCount) else: self.setMinimumSize(0, 0) self.setMaximumSize(9999, 9999)