Пример #1
0
    def do(self):
        try:
            rootGraph = self.pyFlowInstance.graphManager.get().findRootGraph()
            nodes = []
            connections = []
            global_config = {}
            for node in rootGraph.getNodesList():
                if node.name == GlobalPropertiesNode.__name__:
                    global_config["pipeline_version"] = "test"
                    global_config["Leon OS frequency [kHz]"] = get_pin_value(
                        node.inputs.values(), 'leon_os_freq')
                elif not isinstance(node, ExportableNode):
                    continue
                node, node_connections = node.export()
                nodes.append(node)
                connections += node_connections

            export = json.dumps({
                "globalProperties": global_config,
                "nodes": nodes,
                "connections": connections
            })

            outFilePath, filterString = QFileDialog.getSaveFileName(
                filter="Pipeline config (*.json)")
            if outFilePath != "":
                with open(outFilePath, 'w') as f:
                    f.write(export)
            print("saved!")
        except Exception as e:
            QMessageBox.warning(self.pyFlowInstance, "Warning", str(e))
Пример #2
0
    def do(self):
        try:
            import depthai
            pipeline = depthai.Pipeline()
            rootGraph = self.pyFlowInstance.graphManager.get().findRootGraph()
            device_nodes = list(
                filter(lambda node: isinstance(node, DeviceNode),
                       rootGraph.getNodesList()))
            for node in device_nodes:
                node.build_pipeline(pipeline)
            for node in device_nodes:
                node.build_connections()

            self.found, self.device_info = depthai.XLinkConnection.getFirstDevice(
                depthai.XLinkDeviceState.X_LINK_UNBOOTED)
            if not self.found:
                raise RuntimeError("Device not found")
            self.device = depthai.Device(pipeline, self.device_info, True)
            self.device.startPipeline()

            self.host_nodes = list(
                filter(lambda node: isinstance(node, HostNode),
                       rootGraph.getNodesList()))
            for node in self.host_nodes:
                node.run_node(self.device)

        except Exception as e:
            traceback.print_exc()
            QMessageBox.warning(self.pyFlowInstance, "Warning", str(e))
Пример #3
0
    def updateRestShape(self):
        sel = cmds.ls(sl=True)
        if not sel:
            QMessageBox.warning(self.window, "Nothing Selected",
                                "Nothing Selected")
            return
        sel = sel[0]
        mesh = self.system.DCC.mesh

        # TODO, Check vert number and blendshape input connections
        selVerts = cmds.polyEvaluate(sel, vertex=1)
        meshVerts = cmds.polyEvaluate(mesh, vertex=1)

        if selVerts != meshVerts:
            msg = "Selected object {0} has {1} verts\nBase Object has {2} verts".format(
                sel, selVerts, meshVerts)
            QMessageBox.warning(self.window, "Vert Mismatch", msg)
            return

        # TODO Check for live connections
        bs = self.system.DCC.shapeNode
        cnx = cmds.listConnections(bs, plugs=1, destination=0, type='mesh')
        if cnx:
            cnxs = ', '.join([i.split('.')[0] for i in cnx])
            cnxs = textwrap.fill(cnxs)
            msg = "Some shapes have a live input connection:\n{0}\n\nThese shapes will not get the update.\nContinue anyway?".format(
                cnxs)
            btns = QMessageBox.Ok | QMessageBox.Cancel
            bret = QMessageBox.question(self.window, "Live Connections", msg,
                                        btns)
            if not bret & QMessageBox.Ok:
                return

        updateRestShape(mesh, sel)
Пример #4
0
 def save(self, *args, **kwargs):
     try:
         data = {
             "name": self.nameEntry.text(),
             "color_count": int(self.colorEntry.text()),
             "mono_count": int(self.monoEntry.text()),
         }
         if self.depthPresent.isChecked():
             data.update({
                 "depth":
                 True,
                 "left_fov_deg":
                 float(self.leftfovEntry.text()),
                 "right_fov_deg":
                 float(self.rightfovEntry.text()),
                 "rgb_fov_deg":
                 float(self.rgbfovEntry.text()),
                 "left_to_right_distance_cm":
                 float(self.lrdistanceEntry.text()),
                 "left_to_rgb_distance_cm":
                 float(self.lrgbdistanceEntry.text()),
             })
         append_to_json(
             data,
             Path(__file__).parent.parent / Path('custom_devices.json'))
         self.close()
         INITIALIZE()
         self.instance.getRegisteredTools(['NodeBoxTool'])[0].refresh()
     except Exception as e:
         QMessageBox.warning(self, "Warning", str(e))
Пример #5
0
def warning(message):
    """
    Prints a warning message
    :param message: str
    :return:
    """

    QMessageBox.warning(dcc.get_main_window(), 'Warning', message)
Пример #6
0
    def doExport(pyFlowInstance):

        supportedDataTypes = {
            "IntPin", "FloatPin", "BoolPin", "StringPin", "ExecPin"
        }
        supportedStructures = {PinStructure.Single}

        script = "# -*- coding: utf-8 -*-\n\n"
        script += "# This file was auto-generated by PyFlow exporter '{0} v{1}'\n".format(
            PythonScriptExporter.displayName(),
            str(PythonScriptExporter.version()))
        script += "#\tCreated: {0}\n\n".format(
            PythonScriptExporter.creationDateString())
        script += "EXPORTER_NAME = '{}'\n".format(
            PythonScriptExporter.displayName())
        script += "EXPORTER_VERSION = '{}'\n\n".format(
            str(PythonScriptExporter.version()))

        rootGraph = pyFlowInstance.graphManager.get().findRootGraph()

        if len(rootGraph.getNodesList()) == 0:
            QMessageBox.warning(pyFlowInstance, "Warning",
                                "Nothing to export!")
            return

        try:
            # create root level nodes
            graphScript = ""
            for node in rootGraph.getNodesList():
                graphScript += nodeToScript(node, supportedDataTypes,
                                            supportedStructures)

            graphScript += "\n# connect pins\n"

            # create connections
            # for node in rootGraph.getNodesList():
            #     for outPin in node.outputs.values():
            #         for inPinName in outPin.linkedTo:
            #             inPin = pyFlowInstance.graphManager.get().findPinByName(inPinName)
            #             graphScript += "{0} = ROOT_GRAPH.graphManager.findPinByName('{1}')\n".format(outPin.getFullName(), outPin.getFullName())
            #             graphScript += "{0} = ROOT_GRAPH.graphManager.findPinByName('{1}')\n".format(inPin.getFullName(), inPin.getFullName())
            #             graphScript += "connectPins({0}, {1})\n".format(outPin.getFullName(), inPin.getFullName())

            wrappedGraphScript = wrapStringToFunctionDef(
                "createScene", graphScript, {"ROOT_GRAPH": None})

            script += wrappedGraphScript + "\n"

            outFilePath, filterString = QFileDialog.getSaveFileName(
                filter=PythonScriptExporter.name_filter)
            if outFilePath != "":
                with open(outFilePath, 'w') as f:
                    f.write(script)
            print("saved!")
        except Exception as e:
            QMessageBox.warning(pyFlowInstance, "Warning", str(e))
Пример #7
0
def qMsgBoxWarning(parentWidg, titleMsgBx, messageMsgBx):
    qmsgParent = None
    if(parentWidg is not None):
        qmsgParent = parentWidg
    reply = QMessageBox.Ok
    try:
        reply = QMessageBox.warning(qmsgParent, titleMsgBx, messageMsgBx)
    except:
        parentScreen = QtGui.QApplication.desktop().screen(QtGui.QApplication.desktop().primaryScreen())
        qmsgParent = QtGui.QMainWindow(parentScreen)
        reply = QMessageBox.warning(qmsgParent, titleMsgBx, messageMsgBx)
    return reply
Пример #8
0
def warning_message(message, parent=None):
    """
    Shows a warning message
    :param message: str
    :param parent: QWidget
    """

    parent = None
    message_box = QMessageBox(parent)
    flags = message_box.windowFlags(
    ) ^ Qt.WindowContextHelpButtonHint | Qt.WindowStaysOnTopHint
    message_box.setWindowFlags(flags)
    message_box.warning(parent, 'Warning', message)
Пример #9
0
	def grabDrvPose(self):
		if not self.isBuilt():
			msg = "PSD System hasn't been built"
			QMessageBox.warning(self, "Brigks", msg, QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
			return 
		
		# Set marker transforms to match rig objects
		for item in self.getObject(config.USE_RIG, localName=None):
			part = item.name().split("_")[-1]
			if part not in self.guide().markers().keys():
				continue
			marker = self.guide().markers(part)
			marker.setTransform(item.transform(world=True), world=True, childCompensation=True)
Пример #10
0
	def grabTwistFromRig(self, minMax):
		if not self.isBuilt()::
			msg = "PSD System hasn't been built"
			QMessageBox.warning(self, "Brigks", msg, QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
			return

		axis = "XYZ".index(self.settings("twistAxis"))
		currentValue = cmds.getAttr(self.getAttribute("OutRot"))[axis]
		self.__dict__["uiTwist{}".format(minMax)].setValue(currentValue)

		# set the value back into the rig, if created
		attr = self.getAttribute("Twist{}".format(minMax))
		if attr:
			cmds.setAttr(attr, currentValue)
Пример #11
0
def main():
    import sys

    app = QApplication(sys.argv)

    input_device = QAudioDeviceInfo.defaultInputDevice()
    if input_device.isNull():
        QMessageBox.warning(None, "audio",
                            "There is no audio input device available.")
        sys.exit(-1)

    w = Widget(input_device)
    w.show()

    sys.exit(app.exec_())
Пример #12
0
 def submit(self):
     self.model.database().transaction()
     if self.model.submitAll():
         self.model.database().commit()
     else:
         self.model.database().rollback()
         QMessageBox.warning(
             self,
             self.tr("Cached Table"),
             self.tr(
                 "The database reported an error: {}".format(
                     self.model.lastError().text()
                 )
             ),
         )
Пример #13
0
    def openFile(self, path: str) -> None:
        f = QFile(path)

        if not f.open(QIODevice.ReadOnly):

            QMessageBox.warning(
                self,
                self.windowTitle(),
                self.tr("Could not open file %s: %s" %
                        (QDir.toNativeSeparators(path), f.errorString())),
            )
            return

        self.m_filePath = path
        self.editor.setPlainText(f.readAll().data().decode())
Пример #14
0
    def doExport(pyFlowInstance):
        script = "// This file was auto-generated by PyFlow exporter '{0} v{1}'\n".format(
            CPPCompiler.displayName(), str(CPPCompiler.version()))
        script += "// Created: {0}\n\n".format(
            CPPCompiler.creationDateString())
        script += "#include <iostream>\n\n"
        script += "int main()\n"
        script += "{\n"

        rootGraph = pyFlowInstance.graphManager.get().findRootGraph()
        if len(rootGraph.getNodes()) == 0:
            QMessageBox.warning(pyFlowInstance, "Warning",
                                "Nothing to export!")
            return

        consoleOutNode = pyFlowInstance.graphManager.get().findNode(
            "consoleOutput")
        if consoleOutNode is None:
            QMessageBox.warning(pyFlowInstance, "Warning",
                                "Console out node not found")
            return

        consoleOutNode[DEFAULT_IN_EXEC_NAME].call()

        script += '\tstd::cout << "{}\\n";\n'.format(
            consoleOutNode["entity"].getData())

        script += "}\n"

        outFilePath, filterString = QFileDialog.getSaveFileName(
            filter="c++ source (*.cpp)")
        if outFilePath != "":
            with open(outFilePath, 'w') as f:
                f.write(script)
            cmd = [
                "g++.exe", outFilePath, "-std=c++11", "-o",
                outFilePath.replace(".cpp", ".exe")
            ]
            myEnv = os.environ.copy()
            proc = subprocess.Popen(cmd,
                                    shell=True,
                                    env=myEnv,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
            proc.communicate()
            print("EXE OUTPUT:",
                  subprocess.check_output(outFilePath.replace(".cpp", ".exe")))
Пример #15
0
    def validate(self):
        """
        Make sure everything has valid input.
        Make sure there are no duplicate extensions.
        Accepts or rejects accepted() signal accordingly.
        """
        for lineEdit in self.lineEditExts:
            if lineEdit.hasAcceptableInput():
                lineEdit.setStyleSheet("background-color:none")
            else:
                lineEdit.setStyleSheet("background-color:salmon")
                QMessageBox.warning(self, "Warning",
                                    "One or more extension is invalid.")
                return

        # Get file extensions for this app to handle.
        extText = self.lineEdit.text()
        # Strip out periods and spaces.
        extText = extText.replace(' ', '').replace('.', '')
        progList = [[x, ""] for x in extText.split(',') if x]

        for i in range(len(self.lineEditProgs)):
            extText = self.lineEditExts[i].text()
            progText = self.lineEditProgs[i].text()
            extText = extText.replace(' ', '').replace('.', '')
            for ext in extText.split(','):
                if ext:
                    progList.append([ext, progText])

        # Make sure there aren't any duplicate extensions.
        tmpSet = set()
        uniqueExt = [
            ext for ext, prog in progList
            if ext not in tmpSet and not tmpSet.add(ext)
        ]
        if len(uniqueExt) == len(progList):
            self.fileAssociations = dict(progList)
        else:
            QMessageBox.warning(
                self, "Warning",
                "You have entered the same extension for two or more programs."
            )
            return

        # Accept if we made it this far.
        self.accept()
Пример #16
0
def show_warning(parent, title, warning):
    """
    Shows a warning QMessageBox with the given warning text
    :param parent: QWidget
    :param title: str
    :param warning: str
    :return:
    """

    return QMessageBox.warning(parent, title, warning)
Пример #17
0
    def onFileSave(self):
        if not self.m_filePath:
            self.onFileSaveAs()
            return

        f = QFile(self.m_filePath)
        if not f.open(QIODevice.WriteOnly | QIODevice.Text):
            QMessageBox.warning(
                self,
                self.windowTitle(),
                self.tr("Could not write to file %s: %s" %
                        (QDir.toNativeSeparators(
                            self.m_filePath), f.errorString())),
            )
            return

        text = QTextStream(f)
        text << self.editor.toPlainText()

        self.editor.document().setModified(False)
Пример #18
0
def _choose_phenix_directory(session):
    satisfied = False
    from Qt.QtWidgets import QFileDialog, QMessageBox
    parent = session.ui.main_window
    import subprocess, os
    while not satisfied:
        result = QFileDialog.getExistingDirectory(parent, 'Please provide the directory containing the Phenix executables.', options=QFileDialog.Options())
        if not result:
            break
        try:
            subprocess.call([os.path.join(result,'phenix.version')])
            satisfied = True
        except FileNotFoundError:
            choice = QMessageBox.warning(parent, 'This directory does not appear to contain Phenix executables. Would you like to try again?',
                QMessageBox.Ok|QMessageBox.Cancel)
        except:
            raise
    if not satisfied:
        from chimerax.core.errors import UserError
        raise UserError('Could not find Phenix installation. Operation cancelled')
    return result
Пример #19
0
 def do(self):
     try:
         stop_pipeline(self.pyFlowInstance)
     except Exception as e:
         traceback.print_exc()
         QMessageBox.warning(self.pyFlowInstance, "Warning", str(e))