Esempio n. 1
0
 def __init__(self, parent):
     QGraphicsView.__init__(self)
     self.init(parent)
     self.initShape()
     self.initCall = 2
     self.minimumWidth = 550
     self.setEnabled(False)
Esempio n. 2
0
    def __init__(self, parent=None, path=None, static = False):
        """
        Constructor
        """
        QGraphicsView.__init__(self, parent)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        #self.setAutoFillBackground(True)
        #pal = self.palette();
        #br = QBrush(Qt.NoBrush)
        #pal.setBrush(QPalette.Background, br);
        #self.setPalette(pal);
        #self.setBackgroundBrush(br)
        # is the only thing seems to work to get the background transparent
        self.setStyleSheet("background-color: rgba(0, 0, 0, 0%);")
        self.setFrameShape(QFrame.NoFrame)

        #   self.setBackgroundOrigin( BackgroundOrigin background )
        self._static = static
        self.setDefaults()
        
        self.loadTheme(path)

        self.startTimers()
        self.resetEcoTimer()
Esempio n. 3
0
    def setUp(self):
        import logging

        from PyQt4.QtGui import QApplication, QGraphicsScene, QGraphicsView, \
                                QPainter

        from PyQt4.QtCore import QTimer

        logging.basicConfig()

        self.app = QApplication([])
        self.scene = QGraphicsScene()
        self.view = QGraphicsView(self.scene)
        self.view.setRenderHints(
            QPainter.Antialiasing | \
            QPainter.SmoothPixmapTransform | \
            QPainter.TextAntialiasing
            )
        self.view.resize(500, 300)
        self.view.show()
        QTimer.singleShot(10000, self.app.exit)

        def my_excepthook(*args):
            sys.setrecursionlimit(1010)
            traceback.print_exc(limit=4)

        self._orig_excepthook = sys.excepthook
        sys.excepthook = my_excepthook
        self.singleShot = QTimer.singleShot
Esempio n. 4
0
    def __init__(self, actions, parent=None):
        QWidget.__init__(self, parent)
        itab_item.ITabItem.__init__(self)
        self.actions = actions
        self.graphicView = QGraphicsView(self)
        self.scene = QGraphicsScene()
        self.graphicView.setScene(self.scene)
        self.graphicView.setViewportUpdateMode(
            QGraphicsView.BoundingRectViewportUpdate)

        vLayout = QVBoxLayout(self)
        self.setLayout(vLayout)
        vLayout.addWidget(self.graphicView)
        self.scene.setItemIndexMethod(QGraphicsScene.NoIndex)
        self.scene.setSceneRect(-200, -200, 400, 400)
        self.graphicView.setMinimumSize(400, 400)
        actualProject = self.actions.ide.explorer.get_actual_project()
        arrClasses = self.actions._locator.get_classes_from_project(
            actualProject)
        #FIXME:dirty need to fix
        self.mX = -400
        self.mY = -320
        self.hightestY = self.mY
        filesList = []
        for elem in arrClasses:
            #loking for paths
            filesList.append(elem[2])
        for path in set(filesList):
            self.create_class(path)
Esempio n. 5
0
 def __init__(self, parent):
     QGraphicsView.__init__(self)
     self.init(parent)
     self.initShape()
     self.initCall = 2
     self.minimumWidth = 550
     self.setEnabled(False)
Esempio n. 6
0
    def __init__(self):
        QWidget.__init__(self)
        self.setFixedSize(640,480)

        top = QWidget()
        topLayout = QHBoxLayout()
        top.setLayout(topLayout)

        title = QLabel("尋寶遊戲");
        title.setFont(QFont("verdana",25,QFont.Bold))
        topLayout.addWidget(title)

        lcd = QLCDNumber()
        lcd.setSegmentStyle(QLCDNumber.Flat)
        lcd.setFrameStyle(QFrame.StyledPanel|QFrame.Plain)
        topLayout.addWidget(lcd)

        self.myScene = scene.Scene()
        self.connect(self.myScene, SIGNAL("steroidTaken(int)"), lcd, SLOT("display(int)"))

        view = QGraphicsView()
        view.setAutoFillBackground(True)
        view.setScene(self.myScene)

        layout = QVBoxLayout()
        layout.addWidget(top)
        layout.addWidget(view)

        self.setLayout(layout)
Esempio n. 7
0
    def __init__(self):
        # init the widget
        #QWidget.__init__(self, parent)

        # set up the scene
        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, 800, 600)

        # add a view of that scene
        self.view = QGraphicsView()
        self.view.setScene(self.scene)
        self.view.setRenderHint(QPainter.Antialiasing)
        self.view.setFixedSize(800, 600)
        self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        # set the screen sync to vertical retrace
        val = "1"
        # Set for nVidia linux
        os.environ["__GL_SYNC_TO_VBLANK"] = val
        # Set for recent linux Mesa DRI Radeon
        os.environ["LIBGL_SYNC_REFRESH"] = val

        qglf = QGLFormat()
        qglf.setSampleBuffers(True)
        self.glw = QGLWidget(qglf)
        self.glw.setAutoBufferSwap(False)
        self.view.setViewport(self.glw)

        #self.view.showFullScreen()
        self.view.show()

        self.last_finish = 0

        QTimer.singleShot(0, self.glw.swapBuffers)
Esempio n. 8
0
    def mouseReleaseEvent(self, event):
        """Manage the mouse releasing.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mouseReleaseEvent(self, event)
Esempio n. 9
0
File: plot.py Progetto: khedron/Plot
def main():
	graph = Graph()
	view = QGraphicsView(graph.plotter.scene)
	view.scale(3,3)
	view.show()

	sys.exit(app.exec_())
Esempio n. 10
0
    def createWidget(self):
        """
        Create the widget
        """
        self.diagramScene = QGraphicsScene(self)

        self.view = QGraphicsView(self.diagramScene)

        self.view.setRenderHint(QPainter.Antialiasing)

        # set the main layout
        layout = QVBoxLayout()

        self.logEdit = QTextEdit()
        self.logEdit.setReadOnly(True)

        hSplitter2 = QSplitter(self)
        hSplitter2.setOrientation(Qt.Vertical)

        hSplitter2.addWidget(self.view)
        hSplitter2.addWidget(self.logEdit)

        hSplitter2.setStretchFactor(0, 1)

        layout.addWidget(hSplitter2)
        self.setLayout(layout)
 def mousePressEvent(self, event):
     self._start_pos = event.pos()
     if event.button() == Qt.LeftButton:
         # Save the current selection and restore it on mouse{Move,Release}
         if not event.modifiers() & Qt.ShiftModifier:
             self._selection = []
     QGraphicsView.mousePressEvent(self, event)
Esempio n. 12
0
    def __setupUi(self):
        layout = QVBoxLayout()

        # Scene with the link editor.
        self.scene = LinksEditScene()
        self.view = QGraphicsView(self.scene)
        self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.view.setRenderHint(QPainter.Antialiasing)

        self.scene.editWidget.geometryChanged.connect(self.__onGeometryChanged)

        # Ok/Cancel/Clear All buttons.
        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel
            | QDialogButtonBox.Reset, Qt.Horizontal)

        clear_button = buttons.button(QDialogButtonBox.Reset)
        clear_button.setText(self.tr("Clear All"))

        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        clear_button.clicked.connect(self.scene.editWidget.clearLinks)

        layout.addWidget(self.view)
        layout.addWidget(buttons)

        self.setLayout(layout)
        layout.setSizeConstraint(QVBoxLayout.SetFixedSize)

        self.setSizeGripEnabled(False)
Esempio n. 13
0
 def __init__(self, *args):
     QGraphicsView.__init__(self, *args)
     self.outerD = 125
     self.innerD = 25
     self.innerRange = 50
     self.inputRange = 256
     self.thresh = 3
     self.worker = JoystickThread()
     self.worker.valueUpdated.connect(self.moveJoystick)
     self.worker.start()
     self.move(30, 100)
     self.setContentsMargins(0, 0, 0, 0)
     self.setMaximumHeight(140)
     self.setMaximumWidth(140)
     self.adjustSize()
     self.scene = QGraphicsScene(self)
     self.outerCircle = QGraphicsEllipseItem(0, 0, self.outerD, self.outerD)
     self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.outerCircle.setBrush(Qt.gray)
     self.innerCircle = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2, self.innerD, self.innerD)
     self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.innerCircle.setBrush(Qt.lightGray)
     self.scene.addItem(self.outerCircle)
     self.scene.addItem(self.innerCircle)
     self.setScene(self.scene)
     self.setStyleSheet('background-color:transparent;color:red')
     self.currentX = 0
     self.currentY = 0
Esempio n. 14
0
 def __init__(self, *args):
     QGraphicsView.__init__(self, *args)
     self.move(20, 240)
     self.outerD = 125
     self.innerD = 35
     self.innerRange = 48
     self.inputRange = 256
     self.thresh = 3
     self.padding = 40
     self.marginTop = 10
     self.worker = QSixAxisThread()
     self.worker.valueUpdated.connect(self.moveJoysticks)
     self.worker.start()
     self.setContentsMargins(0, 0, 0, 0)
     self.setMaximumHeight(180)
     self.setMaximumWidth(420)
     self.setMinimumHeight(240)
     self.setMinimumWidth(300)
     self.adjustSize()
     self.scene = QGraphicsScene(self)
     self.outerCircle1 = QGraphicsEllipseItem(0, self.marginTop, self.outerD, self.outerD)
     self.outerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.outerCircle1.setBrush(Qt.gray)
     self.innerCircle1 = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
     self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.innerCircle1.setBrush(Qt.lightGray)
     self.scene.addItem(self.outerCircle1)
     self.scene.addItem(self.innerCircle1)
     self.outerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding, self.marginTop, self.outerD, self.outerD)
     self.outerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.outerCircle2.setBrush(Qt.gray)
     self.innerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding + self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
     self.innerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.innerCircle2.setBrush(Qt.lightGray)
     self.scene.addItem(self.outerCircle2)
     self.scene.addItem(self.innerCircle2)
     self.setScene(self.scene)
     self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
     self.currentX = 0
     self.currentY = 0
     self.currentA = 0
     self.currentZ = 0
     self.psBtn = QPixmap(os.getcwd() + '/../icons/bt_PS.png')
     self.psBtn = self.psBtn.scaled(50, 50, Qt.KeepAspectRatio)
     self.psItem = QGraphicsPixmapItem(self.psBtn)
     self.psItem.setOffset(QPointF(self.outerD - 4, 0))
     self.effect = QGraphicsDropShadowEffect()
     self.effect.setOffset(0, 0)
     self.effect.setBlurRadius(20)
     self.effect.setColor(Qt.green)
     self.psItem.setGraphicsEffect(self.effect)
     self.scene.addItem(self.psItem)
     self.tl2 = QTimeLine(10000)
     self.tl2.setFrameRange(0, 10000)
     self.c = QGraphicsItemAnimation()
     self.c.setItem(self.psItem)
     self.c.setTimeLine(self.tl2)
     self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
     self.effectd = 3
     self.tl2.start()
Esempio n. 15
0
 def mousePressEvent(self, event):
     self._start_pos = event.pos()
     if event.button() == Qt.LeftButton:
         # Save the current selection and restore it on mouse{Move,Release}
         if not event.modifiers() & Qt.ShiftModifier:
             self._selection = []
     QGraphicsView.mousePressEvent(self, event)
 def mouseReleaseEvent(self, event):
     """ Stop mouse pan or zoom mode (apply zoom if valid).
     """
     QGraphicsView.mouseReleaseEvent(self, event)
     scenePos = self.mapToScene(event.pos())
     if event.button() == Qt.LeftButton:
         self.setDragMode(QGraphicsView.NoDrag)
         if self.hasImage():
             self.leftMouseButtonReleased.emit(scenePos.x(), scenePos.y())
     elif event.button() == Qt.RightButton:
         self.setDragMode(QGraphicsView.NoDrag)
         if self.hasImage():
             self.viewport().setCursor(QCursor(Qt.OpenHandCursor))
             if self.dragSelect:
                 viewBBox = self.zoomStack[-1] if len(
                     self.zoomStack) else self.sceneRect()
                 selectionBBox = self.scene.selectionArea().boundingRect(
                 ).intersected(viewBBox)
                 print(selectionBBox)
                 self.areaSelected.emit(selectionBBox.x(),
                                        selectionBBox.y(),
                                        selectionBBox.width(),
                                        selectionBBox.height())
             else:
                 self.pixelSelected.emit(scenePos.x(), scenePos.y())
Esempio n. 17
0
 def __init__(self):
     self._scene = QGraphicsScene()
     QGraphicsView.__init__(self, self._scene)
     self._document = Document()
     self._document.changed.connect(self._update_scene)
     self.use_tool(PenTool)
     self.setMouseTracking(True)
Esempio n. 18
0
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)
        self.Running = False
        self.scene = QGraphicsScene(self)
        self.scene.setSceneRect(0, 0, SCENESIZEX, SCENESIZEY)
        self.view = QGraphicsView()
        self.view.setRenderHint(QPainter.Antialiasing)
        self.view.setScene(self.scene)
        self.view.setFocusPolicy(Qt.NoFocus)
        #self.zoomSlider = QSlider(Qt.Horizontal)
        #self.zoomSlider.setRange(5, 200)
        #self.zoomSlider.setValue(100)
        self.pauseButton = QPushButton("Pa&use")
        self.quitButton = QPushButton("&Quit")

        layout = QVBoxLayout()
        layout.addWidget(self.view)
        #layout.addWidget(self.zoomSlider)
        layout.addWidget(self.pauseButton)
        layout.addWidget(self.quitButton)
        self.setLayout(layout)

        #self.connect(self.zoomSlider, SIGNAL("valueChanged(int))"),
        #             self.zoom)
        self.connect(self.pauseButton, SIGNAL("clicked()"), self.pauseOrResume)
        self.connect(self.quitButton, SIGNAL("clicked()"), self.accept)

        self.readNodes()
        self.zoom(1.0)
        self.populate()
        #self.startTimer(INTERVAL)
        self.setWindowTitle("TdPaleo")
Esempio n. 19
0
	def __init__(self, parent=None):
		super(TestDlg, self).__init__(parent)
		self.mymodel = None
		self.myscene = DragEnabledScene(QRectF(-400,-300,800,600))
		self.myview = QGraphicsView()
		self.myview.setScene(self.myscene)
		self.myfile = None
		layout = QVBoxLayout()
		layout.addWidget(self.myview)
		buttonLayout = QHBoxLayout()
		self.savebutton = QPushButton('Save')
		self.loadbutton = QPushButton('Load')
		self.renderbutton = QPushButton('Accept')
		buttonLayout.addWidget(self.savebutton)
		buttonLayout.addWidget(self.loadbutton)
		buttonLayout.addWidget(self.renderbutton)
		layout.addLayout(buttonLayout)
		self.statusbar =  QStatusBar()
		layout.addWidget(self.statusbar)
		self.statusbar.showMessage("Ready.",2000)
		self.setLayout(layout)

		self.loadfromInitData()

		self.savebutton.pressed.connect(self.saveMatrix)
		self.loadbutton.pressed.connect(self.loadMatrix)
		self.myscene.selectionChanged.connect(self.updateStatus)
		self.myscene.modelchanged.connect(self.changeModel)

		self.renderbutton.pressed.connect(self.testDistance)
Esempio n. 20
0
 def drawForeground(self, painter, rect):
     QGraphicsView.drawForeground(self, painter, rect)
     if self._sel_accepted:
         painter.save()
         painter.resetTransform()
         rect = self._sel_rect
         viewport = self.viewport()
         option = QStyleOptionRubberBand()
         option.initFrom(viewport)
         option.rect = self._sel_rect
         option.shape = QRubberBand.Rectangle
         mask = QStyleHintReturnMask()
         self.style().drawControl(QStyle.CE_RubberBand, option, painter, viewport);
         painter.restore()
     elif self._div_accepted:
         painter.save()
         painter.resetTransform()
         line = self._div_line
         viewport = self.viewport()
         palette = viewport.palette()
         pen = QPen(Qt.DashDotLine)
         pen.setWidth(2)
         pen.setColor(Qt.red)
         painter.setPen(pen)
         painter.drawLine(self._div_line)
         painter.restore()
Esempio n. 21
0
 def drawForeground(self, painter, rect):
     QGraphicsView.drawForeground(self, painter, rect)
     if self._sel_accepted:
         painter.save()
         painter.resetTransform()
         rect = self._sel_rect
         viewport = self.viewport()
         option = QStyleOptionRubberBand()
         option.initFrom(viewport)
         option.rect = self._sel_rect
         option.shape = QRubberBand.Rectangle
         mask = QStyleHintReturnMask()
         self.style().drawControl(QStyle.CE_RubberBand, option, painter,
                                  viewport)
         painter.restore()
     elif self._div_accepted:
         painter.save()
         painter.resetTransform()
         line = self._div_line
         viewport = self.viewport()
         palette = viewport.palette()
         pen = QPen(Qt.DashDotLine)
         pen.setWidth(2)
         pen.setColor(Qt.red)
         painter.setPen(pen)
         painter.drawLine(self._div_line)
         painter.restore()
Esempio n. 22
0
 def mouseReleaseEvent(self, event):
     if self._start_sel:
         self._start_sel = False
         if self._sel_accepted:
             self.viewport().update(self.rubberBandRegion(self._sel_rect))
             sceneRegion = self.mapToScene(self._sel_rect)
             self._sel_accepted = False
             self._sel_rect = QRect()
             event.accept()
             if self.scene():
                 self.scene().setPointCellSelection(sceneRegion)
             return
     elif self._first_point is not None:
         scene = self.scene()
         div_accepted = self._div_accepted
         if div_accepted:
             event.accept()
             self.viewport().update(self.lineSelectionRect(self._div_line))
             if self._second_point is not None:
                 scene.setDivisionLine(self._first_point, self._second_point)
                 self._second_point.setSelected(False)
         self._first_point = None
         self._second_point = None
         self._div_line = QLine()
         self._div_accepted = False
         params = parameters.instance
         params.is_cell_editable = True
         if div_accepted:
             return
     QGraphicsView.mouseReleaseEvent(self, event)
    def __init__(self, parent=None, center=None, thumbnail=False):
        QGraphicsView.__init__(self, parent)

        # Image is displayed as a QPixmap in a QGraphicsScene attached to this QGraphicsView.
        self.scene = QGraphicsScene()
        self.setScene(self.scene)

        # Store a local handle to the scene's current image pixmap.
        self._pixmapHandle = None

        # Image aspect ratio mode.
        # !!! ONLY applies to full image. Aspect ratio is always ignored when zooming.
        #   Qt.IgnoreAspectRatio: Scale image to fit viewport.
        #   Qt.KeepAspectRatio: Scale image to fit inside viewport, preserving aspect ratio.
        #   Qt.KeepAspectRatioByExpanding: Scale image to fill the viewport, preserving aspect ratio.
        self.aspectRatioMode = Qt.KeepAspectRatio

        # Scroll bar behaviour.
        #   Qt.ScrollBarAlwaysOff: Never shows a scroll bar.
        #   Qt.ScrollBarAlwaysOn: Always shows a scroll bar.
        #   Qt.ScrollBarAsNeeded: Shows a scroll bar only when zoomed.
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        # Stack of QRectF zoom boxes in scene coordinates.
        self.zoomStack = []
        self.dragSelect = False
        # Flags for enabling/disabling mouse interaction.
        self.canZoom = True
        self.canPan = True
        self.center = center
        self.thumbnail = thumbnail
Esempio n. 24
0
 def mousePressEvent(self, event):
     scene = self.scene()
     if not isinstance(scene, TrackingScene):
         return QGraphicsView.mousePressEvent(self, event)
     QGraphicsView.mousePressEvent(self, event)
     if not event.isAccepted():
         if scene.mode == TrackingScene.AddCell and event.buttons(
         ) == Qt.LeftButton:
             event.accept()
             self._start_selection = QPoint(event.pos())
             if scene.has_current_cell:
                 items = scene.items(self.mapToScene(event.pos()))
                 try:
                     first_point = items[0]
                     if isinstance(
                             first_point, PointItem
                     ) and first_point.pt_id in scene.data_manager.cells[
                             scene.current_cell]:
                         self._first_point = first_point
                         params = parameters.instance
                         params.is_cell_editable = False
                         return
                 except IndexError:
                     pass
             self._start_sel = True
    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            if not self.__autoScrollTimer.isActive() and \
                    self.__shouldAutoScroll(event.pos()):
                self.__startAutoScroll()

        QGraphicsView.mouseMoveEvent(self, event)
Esempio n. 26
0
 def setUp(self):
     QAppTestCase.setUp(self)
     self.scene = CanvasScene()
     self.view = QGraphicsView(self.scene)
     self.view.setRenderHint(QPainter.Antialiasing)
     self.view.show()
     self.view.resize(600, 400)
Esempio n. 27
0
    def mouseReleaseEvent(self, event):
        """Manage the mouse releasing.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mouseReleaseEvent(self, event)
Esempio n. 28
0
 def mouseDoubleClickEvent(self, event):
     sc_pos = self.mapToScene(event.pos())
     if self.zoomSelect or self.panSelect:
         self.zoom_data = []
         self.fitInView(self.sceneRect(), Qt.KeepAspectRatio)
     self.afterDoubleClick.emit(sc_pos.x(), sc_pos.y())
     QGraphicsView.mouseDoubleClickEvent(self, event)
Esempio n. 29
0
 def mouseReleaseEvent(self, event):
     if self._start_sel:
         self._start_sel = False
         if self._sel_accepted:
             self.viewport().update(self.rubberBandRegion(self._sel_rect))
             sceneRegion = self.mapToScene(self._sel_rect)
             self._sel_accepted = False
             self._sel_rect = QRect()
             event.accept()
             if self.scene():
                 self.scene().setPointCellSelection(sceneRegion)
             return
     elif self._first_point is not None:
         scene = self.scene()
         div_accepted = self._div_accepted
         if div_accepted:
             event.accept()
             self.viewport().update(self.lineSelectionRect(self._div_line))
             if self._second_point is not None:
                 scene.setDivisionLine(self._first_point,
                                       self._second_point)
                 self._second_point.setSelected(False)
         self._first_point = None
         self._second_point = None
         self._div_line = QLine()
         self._div_accepted = False
         params = parameters.instance
         params.is_cell_editable = True
         if div_accepted:
             return
     QGraphicsView.mouseReleaseEvent(self, event)
Esempio n. 30
0
    def test_editlinksnode(self):
        from ...registry.tests import small_testing_registry

        reg = small_testing_registry()
        file_desc = reg.widget("Orange.OrangeWidgets.Data.OWFile.OWFile")
        bayes_desc = reg.widget("Orange.OrangeWidgets.Classify.OWNaiveBayes."
                                "OWNaiveBayes")
        source_node = SchemeNode(file_desc, title="This is File")
        sink_node = SchemeNode(bayes_desc)

        scene = QGraphicsScene()
        view = QGraphicsView(scene)

        node = EditLinksNode(node=source_node)
        scene.addItem(node)

        node = EditLinksNode(direction=Qt.RightToLeft)
        node.setSchemeNode(sink_node)

        node.setPos(300, 0)
        scene.addItem(node)

        view.show()
        view.resize(800, 300)
        self.app.exec_()
Esempio n. 31
0
 def wheelEvent( self, event ):
     """ Mouse wheel event """
     if QApplication.keyboardModifiers() == Qt.ControlModifier:
         factor = 1.41 ** ( event.delta() / 240.0 )
         self.scale( factor, factor )
     else:
         QGraphicsView.wheelEvent( self, event )
     return
Esempio n. 32
0
 def mousePressEvent(self, evt):
     # do nothing if we don't click on an item
     if not self.itemAt(evt.pos()):
         return
     # only one item can be selected at a time, so deselect if any
     for item in self.scene().selectedItems():
         item.setSelected(False)
     QGraphicsView.mousePressEvent(self, evt)
Esempio n. 33
0
 def mousePressEvent(self, evt):
     # do nothing if we don't click on an item
     if not self.itemAt(evt.pos()):
         return
     # only one item can be selected at a time, so deselect if any
     for item in self.scene().selectedItems():
         item.setSelected(False)
     QGraphicsView.mousePressEvent(self, evt)
Esempio n. 34
0
 def mousePressEvent(self, event):
     sc_pos = self.mapToScene(event.pos())
     if self.panSelect:
         self.setDragMode(QGraphicsView.ScrollHandDrag)
     if self.zoomSelect:
         self.setDragMode(QGraphicsView.RubberBandDrag)
     self.afterLeftClick.emit(sc_pos.x(), sc_pos.y())
     QGraphicsView.mousePressEvent(self, event)
Esempio n. 35
0
 def __init__(self, parent):
     QGraphicsView.__init__(self,parent)
     self.setDragMode(QGraphicsView.RubberBandDrag)
     #self.setDragMode(QGraphicsView.ScrollHandDrag)
     self.setRenderHint(QPainter.Antialiasing)
     self.setRenderHint(QPainter.TextAntialiasing)
     self.setAcceptDrops(True)
     self.setInteractive(True)
Esempio n. 36
0
 def mouseMoveEvent(self, mouse_event):
     if self._last_pan_point is not None:
         delta_scene = self.mapToScene(mouse_event.pos()) - self.mapToScene(self._last_pan_point)
         if not delta_scene.isNull():
             self.centerOn(self._last_scene_center - delta_scene)
             self._last_scene_center -= delta_scene
         self._last_pan_point = mouse_event.pos()
     QGraphicsView.mouseMoveEvent(self, mouse_event)
    def __init__(self, *args):
        QGraphicsView.__init__(self, *args)
        self.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        self.__autoScroll = False
        self.__autoScrollMargin = 16
        self.__autoScrollTimer = QTimer(self)
        self.__autoScrollTimer.timeout.connect(self.__autoScrollAdvance)
Esempio n. 38
0
 def wheelEvent(self, event):
     """ Mouse wheel event """
     if QApplication.keyboardModifiers() == Qt.ControlModifier:
         factor = 1.41**(event.delta() / 240.0)
         self.scale(factor, factor)
     else:
         QGraphicsView.wheelEvent(self, event)
     return
Esempio n. 39
0
    def __init__(self, parent=None):
        super().__init__(parent)

        ## Attributes
        self.data = None
        self.distances = None
        self.groups = None
        self.unique_pos = None
        self.base_group_index = 0

        ## GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.info_box = gui.widgetLabel(box, "\n")

        ## Separate By box
        box = gui.widgetBox(self.controlArea, "Separate By")
        self.split_by_model = itemmodels.PyListModel(parent=self)
        self.split_by_view = QListView()
        self.split_by_view.setSelectionMode(QListView.ExtendedSelection)
        self.split_by_view.setModel(self.split_by_model)
        box.layout().addWidget(self.split_by_view)

        self.split_by_view.selectionModel().selectionChanged.connect(
            self.on_split_key_changed)

        ## Sort By box
        box = gui.widgetBox(self.controlArea, "Sort By")
        self.sort_by_model = itemmodels.PyListModel(parent=self)
        self.sort_by_view = QListView()
        self.sort_by_view.setSelectionMode(QListView.ExtendedSelection)
        self.sort_by_view.setModel(self.sort_by_model)
        box.layout().addWidget(self.sort_by_view)

        self.sort_by_view.selectionModel().selectionChanged.connect(
            self.on_sort_key_changed)

        ## Distance box
        box = gui.widgetBox(self.controlArea, "Distance Measure")
        gui.comboBox(box,
                     self,
                     "selected_distance_index",
                     items=[name for name, _ in self.DISTANCE_FUNCTIONS],
                     callback=self.on_distance_measure_changed)

        self.scene = QGraphicsScene()
        self.scene_view = QGraphicsView(self.scene)
        self.scene_view.setRenderHints(QPainter.Antialiasing)
        self.scene_view.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.mainArea.layout().addWidget(self.scene_view)

        self.scene_view.installEventFilter(self)

        self._disable_updates = False
        self._cached_distances = {}
        self._base_index_hints = {}
        self.main_widget = None

        self.resize(800, 600)
Esempio n. 40
0
 def __init__(self,settings,parent,scene,client=None):
     QGraphicsView.__init__(self,parent)
     self.scene = scene
     self.settings = settings
     self.client = client
     self.setScene(scene)
     self.setGeometry(QtCore.QRect(10, 10,settings.gridWidth,settings.gridHeight)) # 571 581 for width and height.
     self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
Esempio n. 41
0
 def mouseMoveEvent(self, ev):
     QGraphicsView.mouseMoveEvent(self, ev)
     if self.pan_active and self._prev_mouse_pos:
         self.setTransformationAnchor(QGraphicsView.NoAnchor)
         delta = ev.pos() - self._prev_mouse_pos
         delta /= self.transform().m11()
         self.translate(delta.x(), delta.y())
         self._is_view_all = False
     self._prev_mouse_pos = ev.pos()
Esempio n. 42
0
    def mousePressEvent(self, event):
        """Manage the mouse pressing.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mousePressEvent(self, event)
        if event.buttons() == Qt.LeftButton:
            self._lastMousePos = event.pos()
Esempio n. 43
0
    def mousePressEvent(self, event):
        """Manage the mouse pressing.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mousePressEvent(self, event)
        if event.buttons() == Qt.LeftButton:
            self._lastMousePos = event.pos()
 def mouseMoveEvent(self, event):
     if self.hasImage():
         scenePos = self.mapToScene(event.pos())
         self.hover.emit(scenePos.x(), scenePos.y())
         if event.buttons() == Qt.RightButton:
             self.rightMouseButtonPressed.emit(scenePos.x(), scenePos.y())
         else:
             pass
     QGraphicsView.mouseMoveEvent(self, event)
Esempio n. 45
0
    def __init__(self,parent=None, signalManager = None):
        OWWidget.__init__(self, parent, signalManager, "Sieve diagram", True)

        #self.controlArea.setMinimumWidth(250)

        #set default settings
        self.data = None

        self.attrX = ""
        self.attrY = ""
        self.attrCondition = ""
        self.attrConditionValue = ""
        self.showLines = 1
        self.showCases = 0
        self.showInColor = 1
        self.attributeSelectionList = None
        self.stopCalculating = 0

        self.canvas = QGraphicsScene()
        self.canvasView = QGraphicsView(self.canvas, self.mainArea)
        self.mainArea.layout().addWidget(self.canvasView)
        self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        #GUI
        self.attrSelGroup = gui.widgetBox(self.controlArea, box = "Shown attributes")

        self.attrXCombo = gui.comboBox(self.attrSelGroup, self, value="attrX", label="X attribute:", orientation="horizontal", tooltip = "Select an attribute to be shown on the X axis", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, labelWidth = 70)
        self.attrYCombo = gui.comboBox(self.attrSelGroup, self, value="attrY", label="Y attribute:", orientation="horizontal", tooltip = "Select an attribute to be shown on the Y axis", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, labelWidth = 70)

        gui.separator(self.controlArea)

        self.conditionGroup = gui.widgetBox(self.controlArea, box = "Condition")
        self.attrConditionCombo      = gui.comboBox(self.conditionGroup, self, value="attrCondition", label="Attribute:", orientation="horizontal", callback = self.updateConditionAttr, sendSelectedValue = 1, valueType = str, labelWidth = 70)
        self.attrConditionValueCombo = gui.comboBox(self.conditionGroup, self, value="attrConditionValue", label="Value:", orientation="horizontal", callback = self.updateGraph, sendSelectedValue = 1, valueType = str, labelWidth = 70)

        gui.separator(self.controlArea)

        box2 = gui.widgetBox(self.controlArea, box = "Visual settings")
        gui.checkBox(box2, self, "showLines", "Show lines", callback = self.updateGraph)
        hbox = gui.widgetBox(box2, orientation = "horizontal")
        gui.checkBox(hbox, self, "showCases", "Show data examples...", callback = self.updateGraph)
        gui.checkBox(hbox, self, "showInColor", "...in color", callback = self.updateGraph)

        gui.separator(self.controlArea)
        # self.optimizationDlg = OWSieveOptimization(self, self.signalManager)
        # optimizationButtons = gui.widgetBox(self.controlArea, "Dialogs", orientation = "horizontal")
        # gui.button(optimizationButtons, self, "VizRank", callback = self.optimizationDlg.reshow, debuggingEnabled = 0, tooltip = "Find attribute groups with highest value dependency")

        gui.rubber(self.controlArea)

        # self.wdChildDialogs = [self.optimizationDlg]        # used when running widget debugging
        # self.graphButton.clicked.connect(self.saveToFileCanvas)
        self.icons = gui.attributeIconDict
        self.resize(800, 550)
        random.seed()
Esempio n. 46
0
 def paintEvent(self, event):
     QGraphicsView.paintEvent(self, event)
     if getattr(self, "_userMessage", None):
         painter = QPainter(self.viewport())
         font = QFont(self.font())
         font.setPointSize(15)
         painter.setFont(font)
         painter.drawText(self.viewport().geometry(), Qt.AlignCenter,
                          self._userMessage)
         painter.end()
Esempio n. 47
0
 def __init__(self, window, resultDict, imagePath):
     QGraphicsView.__init__(self)
     self.window = window
     self.pen = QPen(QColor("red"))
     self.pen.setWidth(0.5)
     self.canvasScene = QGraphicsScene()
     self.setScene(self.canvasScene)
     self.resultDict = resultDict
     self.imagePath = imagePath
     self.setBackgroundBrush(QBrush(Qt.black, Qt.SolidPattern))
Esempio n. 48
0
    def wheelEvent(self, event):
        """ Mouse wheel events cause zooming in and out. """

        if event.modifiers() & Qt.ControlModifier:
            if event.delta() > 0:
                self.zoom_in()
            else:
                self.zoom_out()
        else:
            QGraphicsView.wheelEvent(self, event)
Esempio n. 49
0
 def __init__(self, *args):
     QGraphicsView.__init__(self, *args)
     self._sel_rect = QRect()
     self._start_selection = None
     self._start_sel = False
     self._sel_accepted = False
     self._first_point = None
     self._second_point = None
     self._div_accepted = False
     self._div_line = QLine()
Esempio n. 50
0
 def __init__(self, *args):
     QGraphicsView.__init__(self, *args)
     self._sel_rect = QRect()
     self._start_selection = None
     self._start_sel = False
     self._sel_accepted = False
     self._first_point = None
     self._second_point = None
     self._div_accepted = False
     self._div_line = QLine()
Esempio n. 51
0
File: View0.py Progetto: iras/JADE
 def mousePressEvent(self, event):
     '''Re-implementation of the QGraphicsView's method mousePressEvent in order to differentiate how the pop-up menu is dealt with by Maya and by Qt.
     More specifically, this distinction with events needs to be made for the Maya integration, otherwise the cmds.popupmenu wouldn't work in the
     QGraphicsView as it would override the Maya cmds.popupmenu's signals.
     
     @param event event
     '''
     if (event.button()==Qt.RightButton): 
         event.ignore()
     else:
         QGraphicsView.mousePressEvent (self, event) # <-- added this line.
Esempio n. 52
0
    def test_graphicstextwidget(self):
        scene = QGraphicsScene()
        view = QGraphicsView(scene)

        text = GraphicsTextWidget()
        text.setHtml("<center><b>a text</b></center><p>paragraph</p>")
        scene.addItem(text)
        view.show()
        view.resize(400, 300)

        self.app.exec_()
Esempio n. 53
0
    def resizeEvent(self, event):
        """Resize the widget. Reimplemented from `QGraphicsView`.

        Resize the `MapGraphicScene`.

        Args:
            event(QResizeEvent): Resize event.
        """
        QGraphicsView.resizeEvent(self, event)
        size = event.size()
        self.scene().setSize(size.width(), size.height())
Esempio n. 54
0
 def wheelEvent( self, event ):
     """ Mouse wheel event """
     if QApplication.keyboardModifiers() == Qt.ControlModifier:
         factor = 1.41 ** ( -event.delta() / 240.0 )
         self.__currentFactor *= factor
         self.setTransform( QTransform.fromScale( self.__currentFactor,
                                                  self.__currentFactor ) )
         Settings().flowScale = self.__currentFactor
     else:
         QGraphicsView.wheelEvent( self, event )
     return
Esempio n. 55
0
    def mouseMoveEvent(self, event):
        """Manage the mouse movement while it is pressed.

        Args:
            event(QMouseEvent): Mouse event.
        """
        QGraphicsView.mouseMoveEvent(self, event)
        if event.buttons() == Qt.LeftButton:
            delta = self._lastMousePos - event.pos()
            self._lastMousePos = event.pos()
            self.scene().translate(delta.x(), delta.y())
Esempio n. 56
0
    def __init__( self, parent = None ):
        QGraphicsView.__init__( self, parent )

        self.setAcceptDrops( True )
        self.setScene( FlowScene( self ) )
        self.setRenderHints( QPainter.Antialiasing | QPainter.SmoothPixmapTransform )
        self.setAlignment( Qt.AlignLeft | Qt.AlignTop )

        self.autoConnecter = ItemAutoConnecter( self.scene() )

        self.setupMenu()
Esempio n. 57
0
File: plot.py Progetto: khedron/Plot
def qt_test():
	"""
	Test that Qt actually works
	"""
	scene = QGraphicsScene()
	text = QGraphicsTextItem(None, scene)
	text.setHtml("<h2 align=\"center\">hello</h2><h2 align=\"center\">world 12334345354444444444444444444444444</h2>123");
	text.setPos(QPointF(25,25))
	view = QGraphicsView(scene)
	view.show()
	sys.exit(app.exec_())