示例#1
0
def main():
    try:
        import FreeCAD
    except ValueError:
        print('FreeCAD library not found. Please check the FREECADPATH variable in this script is correct')
        sys.exit(1)
    simapp=QtGui.QApplication(sys.argv)
    simappwindow=QtGui.QMainWindow()
    simappwindow.setWindowTitle("EQ Simulator")


    s=None
    s=Simulator.Simulator()
    s.Build()
    manualsettingswidget=DockManualSetting(s)
    simulationwidget=DockSimulation(s, manualsettingswidget)
    simappwindow.addDockWidget(QtCore.Qt.BottomDockWidgetArea, manualsettingswidget)
    simappwindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, simulationwidget)
# FreeCAD integration: see http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Embedding_FreeCADGui/fr
# Utilisation d'un module tiers (en l'occurence Quarter ?)
#FreeCADGui.setupWithoutGUI()



    widget3D=QtGui.QWidget()
    widget3D.setMinimumSize(712,400)
    qw=QuarterWidget(widget3D)
    qw.setMinimumSize(712, 400)

    qw.setSceneGraph(s.scene)

    #Http server
    #server=BaseHTTPServer.HTTPServer(('', 8000), HTTPHandler)
    #server.serve_forever()
     
    #TCP Server
    server=QtNetwork.QTcpServer()
    server.setMaxPendingConnections(1)
    server.currentClient=None
    server.newConnection.connect(lambda:acceptClient(server, simulationwidget.process_config))
    server.listen(QtNetwork.QHostAddress.Any, 64101)

#s.Embed(widget3D)
    simappwindow.setCentralWidget(widget3D)
    simappwindow.show()
#SoGui.mainloop()
    simapp.exec_() 
示例#2
0
def main():
    app = QApplication(sys.argv)

    root = SoSeparator()
    col = SoBaseColor()
    col.rgb = SbColor(1, 1, 0)
    root.addChild(col)
    root.addChild(SoCone())

    viewer = QuarterWidget()
    viewer.setSceneGraph(root)

    viewer.setWindowTitle("minimal")
    viewer.show()
    sys.exit(app.exec_())
示例#3
0
def main():
    app = QApplication(sys.argv)

    root = SoSeparator()
    col = SoBaseColor()
    col.rgb = SbColor(1, 1, 0)
    root.addChild(col)
    root.addChild(SoCone())

    viewer = QuarterWidget()
    viewer.setSceneGraph(root)

    viewer.setWindowTitle("minimal")
    viewer.show()
    sys.exit(app.exec_())
示例#4
0
def main():
    try:
        import FreeCAD
    except ValueError:
        print(
            'FreeCAD library not found. Please check the FREECADPATH variable in this script is correct'
        )
        sys.exit(1)
    simapp = QtGui.QApplication(sys.argv)
    simappwindow = QtGui.QMainWindow()
    simappwindow.setWindowTitle("EQ Simulator")

    s = None
    s = Simulator.Simulator()
    s.Build()
    manualsettingswidget = DockManualSetting(s)
    simulationwidget = DockSimulation(s, manualsettingswidget)
    simappwindow.addDockWidget(QtCore.Qt.BottomDockWidgetArea,
                               manualsettingswidget)
    simappwindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, simulationwidget)
    # FreeCAD integration: see http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Embedding_FreeCADGui/fr
    # Utilisation d'un module tiers (en l'occurence Quarter ?)
    #FreeCADGui.setupWithoutGUI()

    widget3D = QtGui.QWidget()
    widget3D.setMinimumSize(712, 400)
    qw = QuarterWidget(widget3D)
    qw.setMinimumSize(712, 400)

    qw.setSceneGraph(s.scene)

    #Http server
    #server=BaseHTTPServer.HTTPServer(('', 8000), HTTPHandler)
    #server.serve_forever()

    #TCP Server
    server = QtNetwork.QTcpServer()
    server.setMaxPendingConnections(1)
    server.currentClient = None
    server.newConnection.connect(
        lambda: acceptClient(server, simulationwidget.process_config))
    server.listen(QtNetwork.QHostAddress.Any, 64101)

    #s.Embed(widget3D)
    simappwindow.setCentralWidget(widget3D)
    simappwindow.show()
    #SoGui.mainloop()
    simapp.exec_()
示例#5
0
 def setupGui(self):
     self.viewer = QuarterWidget()
     layout = QtGui.QVBoxLayout()
     layout.addWidget(self.viewer)
     self.setLayout(layout)
示例#6
0
class MinimalViewer(QWidget):
    """
    A QWidget which contains a child QuarterWidget
    """
    def __init__(self, colorLights=True):
        QWidget.__init__(self)
        # camera defaults
        self.camera_point_at = [coin.SbVec3f(0, 0, 0), coin.SbVec3f(0, 0, 1)]
        self.camera_position = (7, 7, 7)
        # call viewAll when switching to a new page
        self.camera_viewAll = True
        # the scene root
        self.root = self.getRoot()
        self.initializeViewer()
        self.setupGui()
        self.viewer.setSceneGraph(self.root)
        self.camera = self.viewer.getSoRenderManager().getCamera()
        self.setInitialCameraPosition()
        self.mouseEventCB = coin.SoEventCallback()
        self.getSRoot().addChild(self.mouseEventCB)
        if colorLights:
            self.addLights()
            self.setColorLightOn(True)
            # no need the default headlight in this case
            self.viewer.enableHeadlight(False)

    def getRoot(self):
        return coin.SoSeparator()

    @fluid
    def addChild(self, node):
        self.root.addChild(getattr(node, "root", node))

    def setupGui(self):
        self.viewer = QuarterWidget()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.viewer)
        self.setLayout(layout)

    def setCameraPosition(self, position):
        self.__camera_position = self.camera.position
        self.camera.position = position
        logger.debug('setCameraPosition: %s, %s, %s', position,
                     self.getCameraPosition(), self.camera)

    def getCameraPosition(self):
        return self.camera.position.getValue()

    cameraPosition = property(getCameraPosition, setCameraPosition)

    def setInitialCameraPosition(self):
        """Chose an adequate initial pov"""
        logger.debug('setInitialCameraPosition')
        self.setCameraPosition(self.camera_position)
        self.camera.pointAt(*self.camera_point_at)
        self.camera.farDistance = 25
        self.camera.nearDistance = .01

    def trackCameraPosition(self, val):
        if val:
            if not hasattr(self, "cameraSensor"):

                def print_pos(camera, sensor):
                    print "position:", camera.position.getValue()

                def print_or(camera, sensor):
                    print "orientation:", camera.orientation.getValue(
                    ).getAxisAngle()

                self.cameraSensor = callback(self.camera.position, print_pos,
                                             self.camera)
                self.cameraSensor2 = callback(self.camera.orientation,
                                              print_or, self.camera)
            else:
                self.cameraSensor.attach(self.camera.position)
                self.cameraSensor2.attach(self.camera.orientation)
        elif hasattr(self, "cameraSensor"):
            self.cameraSensor.detach()
            self.cameraSensor2.detach()

    def addLights(self):
        self.colorLights = readFile(filePath("viewer",
                                             "lights.iv")).getChild(0)
        self.insertLight(self.colorLights)
        self.colorLights.whichChild = coin.SO_SWITCH_ALL

    def setColorLightOn(self, val):
        if self.colorLights:
            self.colorLights.whichChild = coin.SO_SWITCH_ALL if val else coin.SO_SWITCH_NONE

    def insertLight(self, luz):
        self.getSRoot().insertChild(luz, 0)

    @fluid
    def viewAll(self):
        self.viewer.viewAll()

    def setTransparencyType(self, tr_type):
        self.viewer.setTransparencyType(tr_type)

    def buildRotor(self):
        rotor = coin.SoRotor()
        rotor.on = False
        rotor.setName("rotor")
        rotor.speed = 0.005
        rotor.rotation = (0, 0, 1, 0)
        return rotor

    def initializeViewer(self):
        fmt = QtOpenGL.QGLFormat()
        fmt.setAlpha(True)
        QtOpenGL.QGLFormat.setDefaultFormat(fmt)
        self.rotor = self.buildRotor()
        hints = coin.SoShapeHints()
        hints.vertexOrdering = coin.SoShapeHints.COUNTERCLOCKWISE
        hints.shapeType = coin.SoShapeHints.SOLID
        hints.faceType = coin.SoShapeHints.CONVEX
        self.root.addChild(self.rotor)
        self.root.addChild(hints)

    def getSRoot(self):
        return self.viewer.getSoRenderManager().getSceneGraph()

    def toText(self, root):
        wa = coin.SoWriteAction()
        return wa.apply(root)

    def setStereoAdjustment(self, val):
        self.camera.setStereoAdjustment(val)
示例#7
0
tabwidget.addTab(delcd, "DE steps")
motorstatusdockwidget=QtGui.QDockWidget("Motor status", simappwindow)
motorstatusdockwidget.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea | QtCore.Qt.RightDockWidgetArea)
motorstatusdockwidget.setWidget(tabwidget)
simappwindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, motorstatusdockwidget)

# FreeCAD integration: see http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Embedding_FreeCADGui/fr
# Utilisation d'un module tiers (en l'occurence Quarter ?)
#FreeCADGui.setupWithoutGUI()

s=Simulator()
s.Build()

widget3D=QtGui.QWidget()
widget3D.setMinimumSize(640,480)
qw=QuarterWidget(widget3D)
qw.setMinimumSize(640, 480)

qw.setSceneGraph(s.scene)

#s.Embed(widget3D)
simappwindow.setCentralWidget(widget3D)
simappwindow.show()
#SoGui.mainloop()
simapp.exec_() 

#if __name__ == "Simulator":
#if __name__ == "__main__":
#    main()

#print __name__
示例#8
0
 def setupGui(self):
     self.viewer = QuarterWidget()
     layout = QtGui.QVBoxLayout()
     layout.addWidget(self.viewer)
     self.setLayout(layout)
示例#9
0
class MinimalViewer(QWidget):
    """
    A QWidget which contains a child QuarterWidget
    """

    def __init__(self, colorLights=True):
        QWidget.__init__(self)
        # camera defaults
        self.camera_point_at = [coin.SbVec3f(0, 0, 0), coin.SbVec3f(0, 0, 1)]
        self.camera_position = (7, 7, 7)
        # call viewAll when switching to a new page
        self.camera_viewAll = True
        # the scene root
        self.root = self.getRoot()
        self.initializeViewer()
        self.setupGui()
        self.viewer.setSceneGraph(self.root)
        self.camera = self.viewer.getSoRenderManager().getCamera()
        self.setInitialCameraPosition()
        self.mouseEventCB = coin.SoEventCallback()
        self.getSRoot().addChild(self.mouseEventCB)
        if colorLights:
            self.addLights()
            self.setColorLightOn(True)
            # no need the default headlight in this case
            self.viewer.enableHeadlight(False)

    def getRoot(self):
        return coin.SoSeparator()

    @fluid
    def addChild(self, node):
        self.root.addChild(getattr(node, "root", node))

    def setupGui(self):
        self.viewer = QuarterWidget()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.viewer)
        self.setLayout(layout)

    def setCameraPosition(self, position):
        self.__camera_position = self.camera.position
        self.camera.position = position
        logger.debug('setCameraPosition: %s, %s, %s', position, self.getCameraPosition(), self.camera)

    def getCameraPosition(self):
        return self.camera.position.getValue()

    cameraPosition = property(getCameraPosition, setCameraPosition)

    def setInitialCameraPosition(self):
        """Chose an adequate initial pov"""
        logger.debug('setInitialCameraPosition')
        self.setCameraPosition(self.camera_position)
        self.camera.pointAt(*self.camera_point_at)
        self.camera.farDistance = 25
        self.camera.nearDistance = .01

    def trackCameraPosition(self, val):
        if val:
            if not hasattr(self, "cameraSensor"):
                def print_pos(camera, sensor):
                    print "position:", camera.position.getValue()

                def print_or(camera, sensor):
                    print "orientation:", camera.orientation.getValue().getAxisAngle()

                self.cameraSensor = callback(self.camera.position, print_pos, self.camera)
                self.cameraSensor2 = callback(self.camera.orientation, print_or, self.camera)
            else:
                self.cameraSensor.attach(self.camera.position)
                self.cameraSensor2.attach(self.camera.orientation)
        elif hasattr(self, "cameraSensor"):
            self.cameraSensor.detach()
            self.cameraSensor2.detach()

    def addLights(self):
        basedir = '.'
        if getattr(sys, 'frozen', None):
            basedir = sys._MEIPASS
        #else:
        #    basedir = os.path.dirname(__file__)

        self.colorLights = readFile(filePath("viewer", basedir+"/lights.iv")).getChild(0)
        self.insertLight(self.colorLights)
        self.colorLights.whichChild = coin.SO_SWITCH_ALL

    def setColorLightOn(self, val):
        if self.colorLights:
            self.colorLights.whichChild = coin.SO_SWITCH_ALL if val else coin.SO_SWITCH_NONE

    def insertLight(self, luz):
        self.getSRoot().insertChild(luz, 0)

    @fluid
    def viewAll(self):
        self.viewer.viewAll()

    def setTransparencyType(self, tr_type):
        self.viewer.setTransparencyType(tr_type)

    def buildRotor(self):
        rotor = coin.SoRotor()
        rotor.on = False
        rotor.setName("rotor")
        rotor.speed = 0.005
        rotor.rotation = (0, 0, 1, 0)
        return rotor

    def initializeViewer(self):
        fmt = QtOpenGL.QGLFormat()
        fmt.setAlpha(True)
        QtOpenGL.QGLFormat.setDefaultFormat(fmt)
        self.rotor = self.buildRotor()
        hints = coin.SoShapeHints()
        hints.vertexOrdering = coin.SoShapeHints.COUNTERCLOCKWISE
        hints.shapeType = coin.SoShapeHints.SOLID
        hints.faceType = coin.SoShapeHints.CONVEX
        self.root.addChild(self.rotor)
        self.root.addChild(hints)

    def getSRoot(self):
        return self.viewer.getSoRenderManager().getSceneGraph()

    def toText(self, root):
        wa = coin.SoWriteAction()
        return wa.apply(root)

    def setStereoAdjustment(self, val):
        self.camera.setStereoAdjustment(val)
示例#10
0
 def __init__(self, parent, sharewidget):
     QuarterWidget.__init__(self, parent=parent, sharewidget=sharewidget)
示例#11
0
文件: mdi.py 项目: bleepbloop/Pivy
 def __init__(self, parent, sharewidget):
     QuarterWidget.__init__(self, parent=parent, sharewidget=sharewidget)