Python PySide.QtGui 模块,QGraphicsScene() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PySide.QtGui.QGraphicsScene()

项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def initUI(self):
        scene = QtGui.QGraphicsScene(self)

        scene = QtGui.QGraphicsScene(self)
        scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
        scene.setSceneRect(-200, -200, 400, 400)
        self.setScene(scene)
        self.scene = scene
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        self.setRenderHint(QtGui.QPainter.Antialiasing)
        self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QtGui.QGraphicsView.AnchorViewCenter)
        self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
        self.setInteractive(True)

        self.NodeIds = []
        self.centrality = []
        self.Scene_to_be_updated = scene
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        i = 0
        self.dendogramPos()
        self.setSceneRect(self.Scene_to_be_updated.itemsBoundingRect())
        self.setScene(self.Scene_to_be_updated)
        self.fitInView(self.Scene_to_be_updated.itemsBoundingRect(),QtCore.Qt.KeepAspectRatio)
        self.scaleView(math.pow(2.5, -900/ 1040.0))
项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def __init__(self,parent):
        QtGui.QGraphicsView.__init__(self)
        self.parent = parent;
        self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse);
        self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag);
        self.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate);
        self.setRenderHints(0);
        self.scene = QtGui.QGraphicsScene();
        self.setScene(self.scene)
        self.offset_x = 0;
        self.offset_y = 0;
        self.marker_set = False
        self.marker_is_visible = True
        self.is_flipped = False
项目:BrainModulyzer    作者:sugeerth    | 项目源码 | 文件源码
def initUI(self):
        scene = QtGui.QGraphicsScene(self)
        scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
        self.setScene(scene)
        self.NodeIds = []
        self.centrality = []
        self.Scene_to_be_updated = scene
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        self.setRenderHint(QtGui.QPainter.Antialiasing)
        self.setInteractive(True)
        self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QtGui.QGraphicsView.AnchorViewCenter)
        self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)

        i = 0

        self.communityPos = nx.nx_pydot.graphviz_layout(self.induced_graph,prog='fdp',args='-Gsep=.25,-GK=20-Eweight=2')
        # self.communityPos = nx.spring_layout(self.induced_graph,pos=self.Pos,weight='weight',scale=450)
        for node in self.induced_graph.nodes():
            i = i + 1
            node_value=Node(self.Graph,i,self.correlationTableObject,True)
            self.NodeIds.append(node_value)
            scene.addItem(node_value)
            x,y=self.communityPos[node]
            node_value.setPos(x,y)
            node_value.PutColor(self.clut[i-1])
        k =0
        for i,j in self.induced_graph.edges():
                Weight = self.induced_graph[i][j]['weight'] 
                Edge_Value = 1+(float(Weight-self.Min1)/(self.Max1 - self.Min1))*5
                scene.addItem(Edge(self.Graph,self.NodeIds[i],self.NodeIds[j],k, i,j,self.Max,((self.Matrix[j,i]-self.Min1)/(self.Max1 - self.Min1))*5,True))
                k = k + 1 

        self.setSceneRect(self.Scene_to_be_updated.itemsBoundingRect())
        self.setScene(self.Scene_to_be_updated)
        self.fitInView(self.Scene_to_be_updated.itemsBoundingRect(),QtCore.Qt.KeepAspectRatio)
        self.scaleView(math.pow(2.5, -900 / 1040.0))

        self.nodes = [item for item in scene.items() if isinstance(item, Node)]
        self.edges = [item for item in scene.items() if isinstance(item, Edge)]
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def initUI(self):
        """
        initialize all the components required
        """
        self.presentNodeObjects = []
        self.centrality = []

        scene = QtGui.QGraphicsScene(self)
        scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
        scene.setSceneRect(-200, -200, 400, 400)
        self.setScene(scene)
        self.scene = scene
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        self.setRenderHint(QtGui.QPainter.Antialiasing)
        self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QtGui.QGraphicsView.AnchorViewCenter)

        self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
        self.setInteractive(True)
        self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)

        self.Scene_to_be_updated = scene
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        i = 0
        self.setSceneRect(self.Scene_to_be_updated.itemsBoundingRect())
        self.setScene(self.Scene_to_be_updated)
        self.fitInView(self.Scene_to_be_updated.itemsBoundingRect(),QtCore.Qt.KeepAspectRatio)
        self.scaleView(math.pow(2.0, -900/ 1040.0))
项目:shortcircuit    作者:farshield    | 项目源码 | 文件源码
def additional_gui_setup(self):
        # Additional GUI setup
        self.graphicsView_banner.mouseDoubleClickEvent = MainWindow.banner_double_click
        self.setWindowTitle(__appname__)
        self.scene_banner = QtGui.QGraphicsScene()
        self.graphicsView_banner.setScene(self.scene_banner)
        self.scene_banner.addPixmap(QtGui.QPixmap(":images/banner.png"))
        self._path_message("", MainWindow.MSG_OK)
        self._avoid_message("", MainWindow.MSG_OK)
        self.lineEdit_source.setFocus()

        # Auto-completion
        system_list = self.nav.eve_db.system_name_list()
        for line_edit_field in [
            self.lineEdit_source,
            self.lineEdit_destination,
            self.lineEdit_avoid_name,
            self.lineEdit_set_dest,
        ]:
            completer = QtGui.QCompleter(system_list, self)
            completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
            line_edit_field.setCompleter(completer)

        # Signals
        self.pushButton_eve_login.clicked.connect(self.btn_eve_login_clicked)
        self.pushButton_player_location.clicked.connect(self.btn_player_location_clicked)
        self.pushButton_find_path.clicked.connect(self.btn_find_path_clicked)
        self.pushButton_crest_config.clicked.connect(self.btn_crest_config_clicked)
        self.pushButton_trip_config.clicked.connect(self.btn_trip_config_clicked)
        self.pushButton_trip_get.clicked.connect(self.btn_trip_get_clicked)
        self.pushButton_avoid_add.clicked.connect(self.btn_avoid_add_clicked)
        self.pushButton_avoid_delete.clicked.connect(self.btn_avoid_delete_clicked)
        self.pushButton_avoid_clear.clicked.connect(self.btn_avoid_clear_clicked)
        self.pushButton_set_dest.clicked.connect(self.btn_set_dest_clicked)
        self.pushButton_reset.clicked.connect(self.btn_reset_clicked)
        self.lineEdit_source.returnPressed.connect(self.line_edit_source_return)
        self.lineEdit_destination.returnPressed.connect(self.line_edit_destination_return)
        self.lineEdit_avoid_name.returnPressed.connect(self.line_edit_avoid_name_return)
        self.lineEdit_set_dest.returnPressed.connect(self.btn_set_dest_clicked)
        self.tableWidget_path.itemSelectionChanged.connect(self.table_item_selection_changed)
项目:PipeLine    作者:draknova    | 项目源码 | 文件源码
def __init__(self):
        super(NodeView,self).__init__()
        self._scene = OPScene()

        # Obsolete
        self.nodeList = list()

        # Variables
        self.clickedItem = None
        self.itemMode = None        # Define which item is selected

        self.mousePositionX = 0
        self.mousePositionY = 0

        self.mode = None

        # Configure QGraphics View
        self.setSceneRect(0, 0, -1, -1)
        self.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.setMouseTracking(True)
        self.setRenderHints(QtGui.QPainter.Antialiasing)
        self.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate)

        # Init QGraphic Scene
        self.sc = QtGui.QGraphicsScene()
        self.setScene(self.sc)
        self.sceneScale = 0.7

        # Paint the background
        brush = QtGui.QBrush()
        brush.setTransform(QtGui.QTransform().scale(0.75, 0.75))
        brush.setTextureImage(QtGui.QImage("/Users/draknova/Documents/workspace/sPipe/bin/images/gridTexture.jpg"))
        self.sc.setBackgroundBrush(brush)


    ######################
    ####### EVENTS #######
    ######################

    ### KEYBOARD EVENTS ##
项目:GeneticAlgorithmLibraryPython    作者:ibarbech    | 项目源码 | 文件源码
def __init__(self):
        QtGui.QGraphicsScene.__init__(self)
        self.__N_cities=0
        self.__listCitys=[]
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def AddWidgets(self):
        im = self.dataProcess.im
        draw = ImageDraw.Draw(im)
        self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)

        # Saving the image file as an output file
        self.label = QtGui.QLabel()
        self.NodeSlider()
        im.save("BackgroundImage/output.png")

        # Loading the pixmap for better analysis
        loadedImage = QtGui.QImage()
        loadedImage.load("BackgroundImage/output.png")
        self.PixMap = QtGui.QPixmap.fromImage(loadedImage)

        self.ElectrodeView = ElectrodeView(self)
        x_interval = LayoutWidth/6 
        y_interval = LayoutHeight/6

        for i in range(self.Chunks+1):
            self.SmallMultipleElectrode.append(ElectrodeView(self, i, x_interval,y_interval))
            CommunitySelectPerTime = QtCore.Signal(list, int ,list, list)
            self.SmallMultipleElectrode[i].CommunitySelectPerTime.connect(self.SelectingCommunitiesInaTimestep)
            self.SmallMultipleElectrode[i].DataLink.connect(self.GettingDataFromSmallMultiples)
            self.SmallMultipleElectrode[i].CommunitySelectAcrossTime.connect(self.SelectingCommunitiesAcrossaTimestep)

        self.LayoutForSmallMultiples = LayoutForSmallMultiples(self,self.SmallMultipleElectrode,x_interval,y_interval)

        # # Use pycharm to have a better way to do it
        self.ImageView = QtGui.QHBoxLayout()
        self.ImageView2 = QtGui.QHBoxLayout()
        self.ImageView2.setContentsMargins(0, 0, 0, 0)
        self.ImageView2.addWidget(self.ElectrodeView)
        self.ImageView2.setContentsMargins(0, 0, 0, 0)

        # Image additions 
        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.addLayout(self.ImageView2)
        vbox.setContentsMargins(0, 0, 0, 0)

        self.scene = QtGui.QGraphicsScene(0, 0,500 ,600)
        self.setContentsMargins(0, 0, 0, 0)

        self.setLayout(vbox)