def __init__(self, *args, **kwargs): QGraphicsView.__init__(self, *args, **kwargs) self._absVal = 1 self._relZoom = 1 self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) # self.setStyleSheet(StyleSheet.scrollBar+StyleSheet.defaultButton) self._scrollZoomEnabled = True
def __init__(self, pickerView): scene = QGraphicsScene() scene.addText( "QGraphicsItem in QGraphicsView. Press mouse to mock pick, key to open dialog." ) QGraphicsView.__init__(self, scene) # Accept touch on both this widget and viewport (abstract scroll area) # Touch engenders LMB mouse press event since app attribute for that is set. self.setAttribute(Qt.WA_AcceptTouchEvents) self.viewport().setAttribute(Qt.WA_AcceptTouchEvents) self.qmlMaster = QmlMaster() ''' See the QML, created there? " A Person model which is mock-picked" self.model = Person() ''' if pickerView is not None: self.pickerView = pickerView self.pickDelegate = self.qmlMaster.findComponent( self.pickerView, className=model.person.Person, objectName="person") self.dialogDelegate = self.qmlMaster.findComponent( self.pickerView, className=model.qmlDelegate.QmlDelegate, objectName="dialogDelegate") else: self.pickDelegate = None self.dialogDelegate = None
def __init__(self): """ Function creates MyView object. """ QGraphicsView.__init__(self) self.__init_game() self.__init_ui()
def __init__(self, img=None, img_name=None): ''' Esta clase hereda atributos y métodos de la clase QgraphicsView La clase QgraphicsView permite añadir una escena y en dicha escena se pueden hacer los dibujos. ''' QGraphicsView.__init__(self) self.setSceneRect( QRectF(self.viewport().rect()) ) #El Tamaño de la escena va a tener el tamaño de la pantalla original que es Dialogo self.scene = QGraphicsScene() #Creamos un objeto tipo QgraphicsScene self.isObject = None #Esta variable inicialmente nula, permite controlar las opciones de que dibujo queremos realizar self.startX = None #Al momento de dibujar, esta variable guarda las cordenadas en x del primer clic self.startY = None #Al momento de dibujar, esta variable guarda las cordenadas en y del primer clic self.pointPolygon = None #Es una tubla de puntos del poligono en x e y self.arrayPolygon = [ ] #Es una lista con cada una de las tuplas de las coordenadas del poligono self.puntosX = [] #Es una lista que guarda solo los puntos de x self.puntosY = [] #Es una lista que guarda solo los puntos de y self.img_name = img_name self.pixi = img.scaled( 638, 478) #Reescalamos la imágen al tamaño de nuestra pantalla self.scene.addPixmap(self.pixi) #añadimos la imágen a la escena self.setScene(self.scene) #enviamso la escena al GraphicsVie
def __init__(self, lang, areaType, statusBar): QGraphicsView.__init__(self) self.ocrscene = OcrScene(self, lang, areaType) self.setScene(self.ocrscene) self.setCacheMode(QGraphicsView.CacheBackground) self.setRenderHint(QPainter.Antialiasing) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QGraphicsView.AnchorViewCenter) self.setMinimumSize(200, 200) self.language = lang self.statusBar = statusBar self.areaType = areaType self.resizingArea = None self.resizingAreaPos = None self.resizingAreaRect = None self.resizingEdge = None self.resizingStartingPos = None self.areaBorder = float() self.areaTextSize = float() self.setCursor(Qt.CrossCursor) self.scene().isModified = False self.bResizing = False self.filename = None Image.init()
def __init__(self, selfwindow): QGraphicsView.__init__(self) self.selfwindow = selfwindow self.panSelect = False self.zoomSelect = False self.rotate_value = 0 self.rotate_azimuth_value = 0 self.zoom_data = [] size = 36 self.scene = QGraphicsScene() if len(self.selfwindow.allpictures) > 1: self.leftClick = QPushButton(self) self.leftClick.setIcon(QIcon(self.selfwindow.path+'//svg//arrowLeft.png')) self.leftClick.clicked.connect(self.selfwindow.leftClickButton) self.leftClick.setToolTip('Show previous photo') self.leftClick.setStyleSheet("QPushButton{background: transparent;}") self.leftClick.setIconSize(QSize(size, size)) self.leftClick.setFocusPolicy(Qt.NoFocus) self.rightClick = QPushButton(self) self.rightClick.setIcon(QIcon(self.selfwindow.path+'//svg//arrowRight.png')) self.rightClick.clicked.connect(self.selfwindow.rightClickButton) self.rightClick.setToolTip('Show next photo') self.rightClick.setStyleSheet("QPushButton{background: transparent;}") self.rightClick.setIconSize(QSize(size, size)) self.rightClick.setFocusPolicy(Qt.NoFocus) self.setScene(self.scene) self.setMouseTracking(False) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setDragMode(QGraphicsView.NoDrag)
def __init__(self, wos_interface, field_size=QPoint(20, 20), field_dimension=QPoint(120, 120), parent=None): QGraphicsView.__init__(self, parent) scene = QGraphicsScene(self) scene.setSceneRect(0, 0, 10000, 10000) self.setScene(scene) # self.setDragMode(QGraphicsView.ScrollHandDrag) self.centerOn(0, 0) self.setBackgroundBrush(QBrush(QColor(0, 0, 200, 128))) self.map_data = None self.field_info = WosFieldInfo(QPoint(40, 40), field_size, field_dimension) self.field_lines = list() self.field_lines_items = list() self.labels = list() self.labels_items = list() self.boundaries = dict() self.boundary_items = dict() self.boundary_text_items = list() self.terrain_items = list() self.show_boundary_text_items = 'show_player_label' in wos_interface.client_cfg and \ wos_interface.client_cfg['show_player_label'] == 'true' self.field_types = [ cCommonGame.MapData.ISLAND, cCommonGame.MapData.CLOUD_FRIENDLY, cCommonGame.MapData.CLOUD_HOSTILE, cCommonGame.MapData.ISLAND ] self.update_field()
def __init__(self, pickerView): scene = QGraphicsScene() scene.addText( "QGraphicsItem in QGraphicsView. Press mouse to mock pick, key to open dialog." ) QGraphicsView.__init__(self, scene) self.qmlMaster = QmlMaster() ''' See the QML, created there? " A Person model which is mock-picked" self.model = Person() ''' if pickerView is not None: self.pickerView = pickerView self.pickDelegate = self.qmlMaster.findComponent( self.pickerView, className=model.person.Person, objectName="person") self.dialogDelegate = self.qmlMaster.findComponent( self.pickerView, className=model.qmlDelegate.QmlDelegate, objectName="dialogDelegate") else: self.pickDelegate = None self.dialogDelegate = None
def __init__(self): QGraphicsView.__init__(self) # SIZES OF THE BOARD VIEW self.viewHeight = self.boardHeight * self.fieldHeight + 3 * self.boardOffset self.viewWidht = self.boardWidht * self.fieldWidht + 3 * self.boardOffset self.setFixedHeight(self.viewHeight) self.setFixedWidth(self.viewWidht) # SCENE AND ALL VISUAL THINGS self.scene = QGraphicsScene(0, 0, self.viewWidht - self.boardOffset, self.viewHeight - self.boardOffset) # self.view = QGraphicsView(self.scene) self.setScene(self.scene) self.generateBoard() self.addingGameBoardToScene() self.printBoard() # MOVE MANAGE self.moveFigure = [(-1, -1), (-1, -1)] self.playerRound = "white" self.figureChosen = False self.possibleMoves = []
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.scene = QGraphicsScene(self) self.scene.setBackgroundBrush(Qt.yellow) self.setScene(self.scene) center_rect = QGraphicsRectItem(-10, -10, 20, 20) self.scene.addItem(center_rect) rect = QGraphicsRectItem(0, 0, 100, 100) rect.setPos(-100, -100) self.scene.addItem(rect) rect2 = QGraphicsRectItem(0, 0, 100, 100) self.scene.addItem(rect2) text = self.scene.addText("Hello WOrld") # self.scene.addLine(QLineF(0, 10, -20, -20), QPen(Qt.black)) rect2.moveBy(50, 50) rect2.setRotation(50) rect2.moveBy(-50, -50) print(self.scene.width(), self.scene.height()) self.resize(400, 400)
def __init__(self, parent=None): 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 = [] # Initialize values self.dragCrop = False self.cropRectangle = QRect(110, 68, 392, 365)
def __init__(self): QGraphicsView.__init__(self) # 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 = [] # Flags for enabling/disabling mouse interaction. self.canZoom = True self.canPan = True
def __init__(self, photoBaseDir, validPhotoFileExts, maxCols, maxRows, borders, xBetweenPics, yBetweenPics, animationSpeed, picChangeMs, parent=None): QGraphicsView.__init__(self, parent) # Vars self.maxCols = maxCols self.maxRows = maxRows self.borders = borders self.xBetweenPics = xBetweenPics self.yBetweenPics = yBetweenPics self.animationSpeed = animationSpeed self.animationTimeoutMs = 15000 self.picChangeMs = picChangeMs # Border self.setLineWidth(0) self.setFrameShape(QtWidgets.QFrame.NoFrame) # Size sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.setSizePolicy(sizePolicy) # Appearance self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # Widget self.scene = QGraphicsScene() self.setScene(self.scene) self.setBackgroundBrush(QColor("light green")) # Calc layout self.calcCellSize() self.animTimeout = QTimer() self.picManager = PicManager(self.scene, photoBaseDir, validPhotoFileExts, maxCols, maxRows, QSize(self.xCellSize, self.yCellSize), borders, xBetweenPics, yBetweenPics) # Class vars self.animationRunning = False self.curAnimationGroup = 0 self.animationGroups = [None] * 2 self.picChgTimer = None self.stepCount = 0
def __init__(self,appctxt, parent): QGraphicsView.__init__(self, parent) self.parent = parent self.setMouseTracking(True) self.staffScene = QGraphicsScene(self) self.setScene(self.staffScene) self.setAlignment(Qt.AlignTop | Qt.AlignLeft) # image = QtGui.QImage("paperTexture.jpg") backGroundPath = Path(appctxt.get_resource('Images/paperTextureWhiteRes.jpg')) backGroundPath = backGroundPath.as_posix() self.setStyleSheet(f"background-image:url({backGroundPath}); background-attachment:fixed") # print(backGroundPath) #self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag) #self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse) self.setTransformationAnchor(QGraphicsView.NoAnchor) self.viewport().setCursor(QtCore.Qt.CrossCursor) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # self.se #print(self.geometry()) #print(self.mapToScene(self.viewport().geometry()).boundingRect()) #self.setSceneRect(0,0,1000,500) #self.translate(100,100) # FLAGS self.ctrlPressed = False self.minZoomFactor = 0.1 self.maxZoomFactor = 10 self.currentZoomFactor = 1 self.current_timer = QTimer() self.current_timer.timeout.connect(self.addStaffs) self.current_timer.setSingleShot(True) self.current_timer.start(500)
def __init__(self,winParent): QGraphicsView.__init__(self) self.winParent=winParent self.viewUpdate.connect(self.updateView) self.m_altitude = 0 self.m_pressure = 28 self.m_originalHeight = 240 self.m_originalWidth = 240 self.m_originalAltCtr = QPointF(120,120) self.m_face1Z = -50 self.m_face2Z = -40 self.m_face3Z = -30 self.m_hand1Z = -20 self.m_hand2Z = -10 self.m_caseZ = 10 self.setStyleSheet("background: transparent; border: none") self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setInteractive(False) self.setEnabled(False) self.m_scene = QGraphicsScene(self) self.setScene(self.m_scene) self.init()
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self._scene = QGraphicsScene() self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) #self.connect(self._scene, SIGNAL('doubleClicked(QString)'), self._itemDoubleClicked) #self._scene.doubleClicked.connect(self._itemDoubleClicked) self._pixmaps = {} self._scale = 0.45 self._width = 450 self._height = 450 self.scale(self._scale, self._scale) self.setDragMode(QGraphicsView.ScrollHandDrag) imageOptions = QdImageOptions() imageOptions.setSize(self._width, self._height) self._loader = QdImageLoader(imageOptions, self, parent) self._loader.imageLoaded.connect(self.imageLoaded) self._loader.loadFinished.connect(self.finished) self._imagesPerRow = 5
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.updateSecs = 0.5 # Border self.setLineWidth(0) self.setFrameShape(QtWidgets.QFrame.NoFrame) # Size sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHeightForWidth(True) self.setSizePolicy(sizePolicy) # No scrollbars self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # Scene self.scene = QGraphicsScene() self.setScene(self.scene) self.setBackgroundBrush(QColor("black")) # Text of clock self.textItem = QGraphicsTextItem() self.textItem.color = QColor(QColor("black")) self.textItem.setFont(QFont("Segoe UI", 80)) self.textItem.setDefaultTextColor(QColor("white")) self.textItem.setHtml("") self.textItem.setZValue(20) self.scene.addItem(self.textItem) # Start ticking self.start()
def __init__(self, parent=None, rscene=QRectF(0, 0, 10, 10),\ origin='UL', scale_ctl='HV',\ show_mode=0) : """ Parameters - parent (QWidget) - parent object - rscene (QRectF) - default rect on scaene - origin (str) - location of origin U(T)=Upper(Top), L=Left, other letters are not used but mean Down(Bottom), Right - scale_ctl (str) - scale control at mouse move, scroll, H=Horizontal, V=Vertical - show_mode (int) - 0(def) - draw nothing, +1 - field of scene rect, +2 - ofigin """ self._name = self.__class__.__name__ self.rs = rscene # default rect on scene, restored at reset_original_size self.rs_old = self.rs # rs_old - is used to check if scene rect changed self.rs_item = None # item on scene to change cursor style at howering self.pos_click = None # QPoint at mousePress self.set_background_style() # sets self.sc_zvalue self.set_scene_item_rect_zvalue() # sets self.bkgd self.set_origin(origin) # sets self._origin_... self.set_scale_control(scale_ctl) # sets self._scale_ctl sc = QGraphicsScene() QGraphicsView.__init__(self, sc, parent) self.set_signs_of_transform() self.set_style() self.set_view() self.add_test_items_to_scene(show_mode) self.twheel_msec = 500 # timeout for wheelEvent self.timer = QTimer() self.timer.timeout.connect(self.on_timeout)
def __init__(self, pickerView): scene = QGraphicsScene() scene.addText("QGraphicsItem in QGraphicsView. Press mouse to mock pick, key to open dialog.") QGraphicsView.__init__(self, scene) # Accept touch on both this widget and viewport (abstract scroll area) # Touch engenders LMB mouse press event since app attribute for that is set. self.setAttribute(Qt.WA_AcceptTouchEvents) self.viewport().setAttribute(Qt.WA_AcceptTouchEvents) self.qmlMaster = QmlMaster() """ See the QML, created there? " A Person model which is mock-picked" self.model = Person() """ if pickerView is not None: self.pickerView = pickerView self.pickDelegate = self.qmlMaster.findComponent( self.pickerView, className=model.person.Person, objectName="person" ) self.dialogDelegate = self.qmlMaster.findComponent( self.pickerView, className=model.qmlDelegate.QmlDelegate, objectName="dialogDelegate" ) else: self.pickDelegate = None self.dialogDelegate = None
def __init__(self): QGraphicsView.__init__(self) self.setStyleSheet("background-color: rgb(40,40,40)") self.mode_list = ["NORMAL", "RECTS_ANNOTATION", "BLOBS_ANNOTATION", "POLYGONS_ANNOTATION"] self.current_mode = 0 self.mode = self.mode_list[self.current_mode] # 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._pxmapitem = None # current image size self.imgwidth = 0 self.imgheight = 0 # Image aspect ratio mode. self.aspectRatioMode = Qt.KeepAspectRatio # Set scrollbar self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.verticalScrollBar().valueChanged.connect(self.viewUpdated) self.horizontalScrollBar().valueChanged.connect(self.viewUpdated) # Panning is enabled if and only if the image is greater than the viewport. self.panEnabled = True self.zoomEnabled = True self.clicked_x = 0 self.clicked_y = 0 # zoom is always active self.zoom_factor = 1.0 self.ZOOM_FACTOR_MIN = 0.02 self.ZOOM_FACTOR_MAX = 10.0 # transparency self.opacity = 1.0 MIN_SIZE = 250 self.pixmap = QPixmap(MIN_SIZE, MIN_SIZE) self.overlay_image = QImage(1, 1, QImage.Format_ARGB32) self.viewport().setMinimumWidth(MIN_SIZE) self.viewport().setMinimumHeight(MIN_SIZE) self.resetTransform() self.setMouseTracking(True) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setContextMenuPolicy(Qt.CustomContextMenu)
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.parent = parent self.setContentsMargins(QMargins()) self.setStyleSheet("QGraphicsView {border:0px solid;margin:0px;}") self.setResizeAnchor(QGraphicsView.AnchorViewCenter) self.setScene(QGraphicsScene(self)) self.scene().addItem(QGraphicsPixmapItem(QPixmap(":/images/front.png")))
def __init__(self, clrs=colours, parent=None): QGraphicsView.__init__(self, parent) self.scene = QGraphicsScene(self) self.scene.setSceneRect(QtCore.QRectF(0, 0, 440, 340)) self.setScene(self.scene) self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(0, 0, 0, 0))) self.setMinimumSize(100, 100) self.colours = clrs
def __init__( self ): self.scene = QGraphicsScene() QGraphicsView.__init__( self, self.scene ) self.pix_map_item = QGraphicsPixmapItem( QPixmap( "TitleText.png" ) ) self.pix_map_item.scale() self.scene.addItem( self.pix_map_item ) self.size = self.pix_map_item.pixmap().size() self.setMaximumSize( self.size )
def __init__(self, parent): QGraphicsView.__init__(self, parent) self._panning = False try: self._middle_button = Qt.MiddleButton except: self._middle_button = Qt.MidButton
def __init__(self): QGraphicsView.__init__(self) self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setDragMode(QGraphicsView.ScrollHandDrag) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.mdiParent = ""
def __init__(self, parent): QGraphicsView.__init__(self, parent) self.fPanning = False try: self.fMiddleButton = Qt.MiddleButton except: self.fMiddleButton = Qt.MidButton
def __init__(self, window=None): QGraphicsView.__init__(self) self.window = window self.scene = QGraphicsScene(self) self.setScene(self.scene) self.setMouseTracking(True) self.image = None self.screen_scale = 1
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.go_prev_img = parent.go_prev_img self.go_next_img = parent.go_next_img pal = self.palette() pal.setColor(self.backgroundRole(), Qt.black) self.setPalette(pal) self.setFrameShape(QFrame.NoFrame)
def __init__(self, parent): QGraphicsView.__init__(self, parent) self.setScene(QGraphicsScene(self)) self.setSceneRect(QtCore.QRectF(self.viewport().rect())) self.penRadius = 5 self.rubberRadius = 10 self.mouseButton = None self.lastMousePos = None
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.setMouseTracking(True) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setBackgroundBrush(QColor('#131722')) self.setMinimumSize(400, 400) self.setWindowTitle(QObject.tr(self, 'Graph')) self.setFrameStyle(self.NoFrame)
def __init__(self, window=None): QGraphicsView.__init__(self) self.window = window self.scene = QGraphicsScene(self) self.setScene(self.scene) self.setFixedSize(240, 160) # self.fitInView(0, 0, 240, 160, Qt.KeepAspectRatio) self.image = QImage(240, 160, QImage.Format_ARGB32) self.screen_scale = 1
def __init__(self, parent=None): QGraphicsView.__init__(self, parent=parent) self.setMouseTracking(True) self.scene = QGraphicsScene(self) self.setScene(self.scene) pixmap = QPixmap(300, 300) self.scene.addItem(QGraphicsPixmapItem(pixmap)) #self.setTransform(QTransform().scale(1, 1).rotate(0)) self.scene.setBackgroundBrush(QBrush(Qt.lightGray)) self._brushItem = MouseBrushObject()
def __init__(self): QGraphicsView.__init__(self) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.scene = QGraphicsScene(self) self.item = GraphicsItem('item', 100, 50) self.item.moveBy(50, 50) self.scene.addItem(self.item) self.widget = GraphicsWidget('widget', 100, 50) self.scene.addItem(self.widget) self.setScene(self.scene)
def __init__(self, parent): QGraphicsView.__init__(self, parent) self.fPanning = False self.fCtrlDown = False try: self.fMiddleButton = Qt.MiddleButton except: self.fMiddleButton = Qt.MidButton
def __init__(self): QGraphicsView.__init__(self) self.setScene(NodeUIScene()) # Timer to update preview - need to introduce small delay to prevent bugs self._previewUpdateTimer = QTimer(self) # self.setSceneRect(-5000, -5000, 10000, 10000) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
def __init__(self, parent: QWidget = None): """ On initialization, we need to bind the Ctrl/command key to enable manipulation of the view. """ QGraphicsView.__init__(self, parent) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setRubberBandSelectionMode(Qt.IntersectsItemShape) self._no_drag = QGraphicsView.RubberBandDrag self._yes_drag = QGraphicsView.ScrollHandDrag # reset things that are state dependent self.clearGraphicsView() self._x0 = 0 self._y0 = 0 self._scale_size = 1.0 self._scale_limit_max = 16.0 # OLD 3.0 self._scale_limit_min = 0.21 self._scale_up_rate = 0.01 self._scale_down_rate = 0.01 self._scale_fit_factor = .5 # sets initial zoom level self._show_details = True self._last_scale_factor = 0.0 self.scene_root_item = None # the item to transform # Keyboard panning self._key_pan_delta_x = styles.PATH_BASE_WIDTH * 21 self._key_pan_delta_y = styles.PATH_HELIX_HEIGHT + styles.PATH_HELIX_PADDING/2 # Modifier keys and buttons self._key_mod = Qt.Key_Control self._button_pan: Qt.MouseButtons = Qt.LeftButton self._button_pan_alt: Qt.MouseButtons = Qt.MidButton self._button_zoom: Qt.MouseButtons = Qt.RightButton self.toolbar = None # custom hack for the paint tool palette self._name = None # a ``SelectionItemGroup`` object when not ``None`` self._selection_lock = None self.setContextMenuPolicy(Qt.CustomContextMenu) if GL: self.is_GL = True # self.glwidget = QGLWidget(QGLFormat(QGL.SampleBuffers)) self.glwidget = QOpenGLWidget() # self.setupGL() self.gl = self.glwidget.context().versionFunctions() self.setViewport(self.glwidget) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) # self.resetGL() else: self.is_GL = False self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate)
def __init__(self, width=10, parent=None): QGraphicsView.__init__(self, parent) self._frame = None self._instructions = None self.setScene(QGraphicsScene(self)) self._items = self.scene().createItemGroup([]) self.setMouseTracking(True) self.pen = QPen(Qt.black, width, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin) self.painting = False self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) self.viewport().setCursor(self.getCursor()) self.updateScene()
def __init__(self, parent, time_sig = '4/4', num_measures = 4, quantize_val = '1/8'): QGraphicsView.__init__(self, parent) self.piano = PianoRoll(time_sig, num_measures, quantize_val) self.setScene(self.piano) #self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) x = 0 * self.sceneRect().width() + self.sceneRect().left() y = 0.4 * self.sceneRect().height() + self.sceneRect().top() self.centerOn(x, y) self.setAlignment(Qt.AlignLeft) self.o_transform = self.transform() self.zoom_x = 1 self.zoom_y = 1
def __init__(self, parent = 0): QGraphicsView.__init__(self, parent) self.__current_scale = 1.0 self.__max_zoom = 20 self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) #self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate) #for panning with the left button: self.__pan_start_x = -1 self.__pan_start_y = -1 self.setTransformationAnchor(QGraphicsView.AnchorViewCenter)
def __init__(self, parent=None): """ On initialization, we need to bind the Ctrl/command key to enable manipulation of the view. """ QGraphicsView.__init__(self, parent) self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse) self.setRubberBandSelectionMode(Qt.IntersectsItemShape) self.setStyleSheet("QGraphicsView { background-color: rgb(96.5%, 96.5%, 96.5%); }") self._no_drag = QGraphicsView.RubberBandDrag self._yes_drag = QGraphicsView.ScrollHandDrag # reset things that are state dependent self.clearGraphicsView() self._x0 = 0 self._y0 = 0 self._scale_size = 1.0 self._scale_limit_max = 4.0 self._scale_limit_min = 0.15 self._scale_up_rate = 0.01 self._scale_down_rate = 0.01 self._scale_fit_factor = 1 # sets initial zoom level self._show_details = True self._last_scale_factor = 0.0 self.scene_root_item = None # the item to transform # Keyboard panning self._key_pan_delta_x = styles.PATH_BASE_WIDTH * 21 self._key_pan_delta_y = styles.PATH_HELIX_HEIGHT + styles.PATH_HELIX_PADDING/2 # Modifier keys and buttons self._key_mod = Qt.Key_Control self._key_select = Qt.Key_Shift self._button_pan = Qt.LeftButton self._button_pan_alt = Qt.MidButton self._button_zoom = Qt.RightButton self.toolbar = None # custom hack for the paint tool palette self._name = None if GL: self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers))) self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) else: self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate)
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self._model = None self.controller = None self.setAcceptDrops(True) # setup & render circuit diagram grid self.scene = QGraphicsScene() self.setScene(self.scene) self._shouldShowSelection = False self._selection = None self._dragging = False self.mousePosition = None self.draggingStart = None self.render()
def __init__(self): QGraphicsView.__init__(self) self.zoom = 2 self.scale(self.zoom, self.zoom) self.lastSize = 0 self.setDragMode(QGraphicsView.ScrollHandDrag) # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.installEventFilter(self) self.hudLayout = QVBoxLayout(self) self.hudLayout.setContentsMargins(0,0,0,0) self.ellipseLabel = QLabel() self.ellipseLabel.setMinimumWidth(self.width()) self.hudLayout.addWidget(self.ellipseLabel) self.ellipseLabel.setAttribute(Qt.WA_TransparentForMouseEvents, True)
def __init__(self, photoBaseDir, validPhotoFileExts, photoDeltas, picChangeMs, parent=None): QGraphicsView.__init__(self, parent) self.setAlignment(Qt.AlignLeft | Qt.AlignTop) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # Vars self.picChangeMs = picChangeMs self.photoBaseDir = photoBaseDir # Widget self.scene = QGraphicsScene() self.setScene(self.scene) self.setBackgroundBrush(QColor("black")) self.setLineWidth(0) self.setFrameShape(QtWidgets.QFrame.NoFrame) # Class vars self.picChgTimer = None self.photoFileManager = PhotoFileManager(validPhotoFileExts, self.photoBaseDir, 7200.00, photoDeltas) self.photoFileManager.startPhotoListUpdate() self.userMovedBack = False
def __init__(self,winParent): QGraphicsView.__init__(self) self.winParent=winParent self.viewUpdate.connect(self.update) self.m_roll = 0 self.m_pitch = 0 self.m_faceDeltaX_new = 0 self.m_faceDeltaX_old = 0 self.m_faceDeltaY_new = 0 self.m_faceDeltaY_old = 0 self.m_originalHeight = 240 self.m_originalWidth = 240 self.m_originalPixPerDeg = 1.7 self.m_originalAdiCtr = QPointF(120,120) self.m_backZ = -30 self.m_faceZ = -20 self.m_ringZ = -10 self.m_caseZ = 10 self.setStyleSheet("background: transparent; border: none"); self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setInteractive(False) self.setEnabled(False) self.m_scene = QGraphicsScene(self) self.setScene(self.m_scene) self.init()
def __init__(self,winParent): QGraphicsView.__init__(self) self.winParent=winParent self.viewUpdate.connect(self.update) self.m_climbRate = 0 self.m_scaleX = 0 self.m_scaleY = 0 self.m_originalHeight = 240 self.m_originalWidth = 240 self.m_originalVsiCtr = QPointF(120,120) self.m_faceZ = -20 self.m_handZ = -10 self.m_caseZ = 10 self.m_itemHand = None self.m_itemFace = None self.m_itemCase = None self.setStyleSheet("background: transparent; border: none"); self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setInteractive(False) self.setEnabled(False) self.m_scene = QGraphicsScene(self) self.setScene(self.m_scene) self.init()
def __init__(self): # Parent constructor(s) View.__init__(self) QGraphicsView.__init__(self) self.nodes = {} self.edges = {} self.nodeHasBeenMoved = False # Enable Antiliasing self.setRenderHint(QPainter.Antialiasing) # Rectangular selection self.setDragMode(QGraphicsView.RubberBandDrag) self.setRubberBandSelectionMode(Qt.IntersectsItemShape) # Init scene self.scene = QGraphicsScene() self.setScene(self.scene) self.resetSceneRect() self.scene.installEventFilter(self) self.show()
def __init__(self, parent): QGraphicsView.__init__(self, parent) self.scene = GraphicsGraph(self) self.setScene(self.scene); self.setSceneRect(QRectF(self.viewport().rect()));
def __init__(self, parent): QGraphicsView.__init__(self, parent) self.fPanning = False
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.setScene(QGraphicsScene())
def __init__(self, parent, cropModel, imagescene2d): """ Constructs a view upon a ImageScene2D imagescene2d -- a ImgeScene2D instance """ QGraphicsView.__init__(self, parent) # We can't use OpenGL because the HUD doesn't render properly on top. # Maybe this will be fixed in Qt5? if False: self.setViewport(QGLWidget()) self.setScene(imagescene2d) self.mousePos = QPointF(0, 0) # FIXME: These int members shadow QWidget.x() and QWidget.y(), which can lead to confusion when debugging... self.x, self.y = (0, 0) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self._isRubberBandZoom = False self._cursorBackup = None # these attributes are exposed as public properties above self._sliceShape = None # 2D shape of this view's shown image self._slices = None # number of slices that are stacked self._hud = None self._crossHairCursor = None self._sliceIntersectionMarker = None self._ticker = QTimer(self) self._ticker.timeout.connect(self._tickerEvent) # # Setup the Viewport for fast painting # # With these flags turned on we could handle the drawing of the # white background ourselves thus removing the flicker # when scrolling fast through the slices # self.viewport().setAttribute(Qt.WA_OpaquePaintEvent) # self.viewport().setAttribute(Qt.WA_NoSystemBackground) # self.viewport().setAttribute(Qt.WA_PaintOnScreen) # self.viewport().setAutoFillBackground(False) self.setViewportUpdateMode(QGraphicsView.MinimalViewportUpdate) # as rescaling images is slow if done in software, # we use Qt's built-in background caching mode so that the cached # image need only be blitted on the screen when we only move # the cursor self.setCacheMode(QGraphicsView.CacheBackground) self.setRenderHint(QPainter.Antialiasing, False) self._crossHairCursor = CrossHairCursor() self.scene().addItem(self._crossHairCursor) self._crossHairCursor.setZValue(99) self.posModel = self.scene()._posModel self.axis = self.scene()._along[1] - 1 # axis is 0,1,2 for X,Y,Z self._sliceIntersectionMarker = SliceIntersectionMarker(self.axis, self.posModel) self.scene().addItem(self._sliceIntersectionMarker) self._sliceIntersectionMarker.setZValue(100) self._sliceIntersectionMarker.setVisible(True) self._croppingMarkers = CroppingMarkers(self.axis, cropModel) self.scene().addItem(self._croppingMarkers) # FIXME: this should be private, but is currently used from # within the image scene renderer self.tempImageItems = [] self._zoomFactor = 1.0 # for panning self._lastPanPoint = QPoint() self._dragMode = False self._deltaPan = QPointF(0, 0) # FIXME: Is there are more elegant way to handle this? self.setMouseTracking(True) # invisible cursor to enable custom cursor self._hiddenCursor = QCursor(Qt.BlankCursor)