Beispiel #1
0
    def upd_sp_vgutter(self):
        vertical_gutter = self.sp_vgutter.value()
        if vertical_gutter > 0 and vertical_gutter < self.vgutter_max:
            self.sl_vgutter.setValue(vertical_gutter)
        self.rcpg_object.vertical_gutter = vertical_gutter

        if self.cb_gutter_equal.isChecked() == True:
            self.hgutter_updated = False
            self.sp_hgutter.setValue(vertical_gutter)
            if vertical_gutter > 0 and vertical_gutter < self.hgutter_max:
                self.sl_hgutter.setValue(vertical_gutter)
            self.rcpg_object.horizontal_gutter = vertical_gutter

        if self.vgutter_updated == True:
            self.preview.scene().clear()
            self.rcpg_object.upd_everything()
            self.rcpg_object.standard_grid()
            self.rcpg_object.refresh_svg_renderer()
            self.svg_item = QGraphicsSvgItem()
            self.svg_item.setSharedRenderer(self.rcpg_object.svg_renderer)
            self.preview.scene().addItem(self.svg_item)
            self.set_clickable_gutters()
            self.svg_item.update()
        else:
            self.vgutter_max = True
Beispiel #2
0
    def init (self):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemHand = QGraphicsSvgItem(":/qfi/images/vsi/vsi_hand.svg")
        self.m_itemHand.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand.setZValue( self.m_handZ )
        self.m_itemHand.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemHand)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/vsi/vsi_face.svg")
        self.m_itemFace.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace.setZValue( self.m_faceZ )
        self.m_itemFace.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemFace)


        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/vsi/vsi_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()
    def initialize_loading_page(self):
        svg_container = QGraphicsScene(self.window().loading_svg_view)
        svg_item = QGraphicsSvgItem()

        svg = QSvgRenderer(get_image_path("loading_animation.svg"))
        svg.repaintNeeded.connect(svg_item.update)
        svg_item.setSharedRenderer(svg)
        svg_container.addItem(svg_item)

        self.window().loading_svg_view.setScene(svg_container)
        self.window().core_manager.events_manager.upgrader_tick.connect(self.set_loading_text)
        self.window().core_manager.events_manager.upgrader_started.connect(
            lambda: self.set_loading_text("Upgrading..."))
        self.window().core_manager.events_manager.upgrader_finished.connect(lambda: self.loading_label.hide())

        # Create a loading label that displays the status during upgrading
        self.loading_label = QLabel(self)
        self.loading_label.setStyleSheet("color: #ddd; font-size: 22px;")
        self.loading_label.setAlignment(Qt.AlignCenter)

        self.on_window_resize()
        self.loading_label.hide()

        # Hide the force shutdown button initially. Should be triggered by shutdown timer from main window.
        self.window().force_shutdown_btn.hide()
Beispiel #4
0
 def importSVG(self):
     # Imports svg file through user input, adds it to the scene and stores it as a reference
     self.name = QFileDialog.getOpenFileName(self, 'Open SVG File', '', 'Scalable Vector Graphics (*svg)')
     if self.name:
         self.graphic = QGraphicsSvgItem(self.name[0])
         self.graphic.setZValue(-1)
         self.painter.addItem(self.graphic)
Beispiel #5
0
    def openFile(self, svg_file: QFile):
        if not svg_file.exists():
            return

        if self.backgroundItem:
            drawBackground = self.backgroundItem.isVisible()
        else:
            drawBackground = False

        s = self.scene()
        s.clear()
        self.resetTransform()

        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)
        tmp = self.svgItem.renderer().defaultSize()
        self.default_width = tmp.width()
        self.default_height = tmp.height()

        self.backgroundItem = QGraphicsRectItem(self.svgItem.boundingRect())
        self.backgroundItem.setBrush(Qt.white)
        self.backgroundItem.setPen(QPen(Qt.NoPen))
        self.backgroundItem.setVisible(drawBackground)
        self.backgroundItem.setZValue(-1)

        s.addItem(self.backgroundItem)
        s.addItem(self.svgItem)
Beispiel #6
0
    def openFile(self, svg_file):
        if not svg_file.exists():
            return

        s = self.scene()

        if self.backgroundItem:
            drawBackground = self.backgroundItem.isVisible()
        else:
            drawBackground = False

        if self.outlineItem:
            drawOutline = self.outlineItem.isVisible()
        else:
            drawOutline = True

        s.clear()
        self.resetTransform()

        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)

        s.addItem(self.svgItem)
Beispiel #7
0
 def __init__(self, filename, scene):
     super(Vectorgraphic, self).__init__(scene)
     self.renderer = QSvgRenderer()
     self.renderer.load(filename)
     self.svg = QGraphicsSvgItem(self)
     self.svg.setSharedRenderer(self.renderer)
     self.setRect(0, 0,
                  self.svg.boundingRect().width(),
                  self.svg.boundingRect().height())
Beispiel #8
0
def load_gears_animation():
    svg_container = QGraphicsScene()
    svg_item = QGraphicsSvgItem()

    svg = QSvgRenderer(get_image_path("loading_animation.svg"))
    svg.repaintNeeded.connect(svg_item.update)
    svg_item.setSharedRenderer(svg)

    svg_container.addItem(svg_item)
    return svg_container
Beispiel #9
0
    def paint(self, painter, option, widget):
        if not self.m_renderer:
            QGraphicsSvgItem.paint(self, painter, option, widget)
            return

        painter.save()
        painter.setRenderHint(QPainter.Antialiasing, False)
        painter.setRenderHint(QPainter.TextAntialiasing, False)
        self.m_renderer.render(painter, self.p_size)
        painter.restore()
Beispiel #10
0
 def loadSvgContent(self, content):
     s = self.scene()
     s.clear()
     self.resetTransform()
     item = QGraphicsSvgItem()
     item.setSharedRenderer(QSvgRenderer(content))
     item.setFlags(QGraphicsItem.ItemClipsToShape)
     item.setCacheMode(QGraphicsItem.NoCache)
     item.setZValue(0)
     s.addItem(item)
Beispiel #11
0
    def __init__(self, icon, name, parent):
        QGraphicsSvgItem.__init__(self)
        self.setParentItem(parent)

        self.m_renderer = None
        self.p_size = QRectF(0, 0, 0, 0)

        self.m_colorFX = QGraphicsColorizeEffect(self)
        self.m_colorFX.setColor(canvas.theme.box_text.color())

        self.setGraphicsEffect(self.m_colorFX)
        self.setIcon(icon, name)
Beispiel #12
0
    def initialize_discovering_page(self):
        svg_container = QGraphicsScene(self.window().discovering_svg_view)
        svg_item = QGraphicsSvgItem()

        svg = QSvgRenderer(get_image_path("loading_animation.svg"))
        svg.repaintNeeded.connect(svg_item.update)
        svg_item.setSharedRenderer(svg)
        svg_container.addItem(svg_item)

        self.window().discovering_svg_view.setScene(svg_container)

        self.window().core_manager.events_manager.discovered_channel.connect(self.on_discovered_channel)
Beispiel #13
0
    def upd_sp_outline(self):
        self.preview.scene().clear()
        outline = self.sp_outline.value()
        self.rcpg_object.outline = outline

        self.rcpg_object.upd_everything()
        self.rcpg_object.standard_grid()
        self.rcpg_object.refresh_svg_renderer()
        self.svg_item = QGraphicsSvgItem()
        self.svg_item.setSharedRenderer(self.rcpg_object.svg_renderer)
        self.preview.scene().addItem(self.svg_item)
        self.set_clickable_gutters()
        self.svg_item.update()
Beispiel #14
0
 def paint(self, painter, option, widget):
     """
         Paints the contents of an item in local coordinates.
         :param painter: QPainter instance
         :param option: QStyleOptionGraphicsItem instance
         :param widget: QWidget instance
     """
     # check if render is set
     if not self.m_renderer:
         QGraphicsSvgItem.paint(self, painter, option, widget)
     else:
         self.m_renderer.render(
             painter, self.boundingRect())  # render svg using painter
Beispiel #15
0
    def initialize_discovering_page(self):
        svg_container = QGraphicsScene(self.window().discovering_svg_view)
        svg_item = QGraphicsSvgItem()

        svg = QSvgRenderer(get_image_path("loading_animation.svg"))
        connect(svg.repaintNeeded, svg_item.update)
        svg_item.setSharedRenderer(svg)
        svg_container.addItem(svg_item)

        self.window().discovering_svg_view.setScene(svg_container)

        connect(self.window().core_manager.events_manager.discovered_channel,
                self.on_discovered_channel)
    def __init__(self, engine, is_ai=False, name=None):
        super().__init__(engine, is_ai=is_ai)

        icon = choice(icons)
        if name is None:
            name = "Detective " + icon.capitalize()

        iconspath = pkg_resources.resource_filename("ScotlandPYard.resources",
                                                    "icons")
        iconpath = join(iconspath, icon + ".svg")

        self.icon = QGraphicsSvgItem(iconpath)
        self.icon.setScale(0.05)
        self.name = name
        self.tickets = {"Bus": 8, "Taxi": 10, "Underground": 4}
    def autotrace(self):
        despeckle = 10
        gradient_mid = self.ui.prepa_slider_despeckle.value()/100
        errorthresh = self.ui.prepa_slider_errorthreshold.value()/10
        cornerdetect = self.ui.prepa_slider_corner.value()
        try:
            self.bg.make_vector(self.png_temp.name,
                                self.svg_temp_us.name,
                                despeckle = despeckle,
                                errorthresh = errorthresh,
                                cornerdetect = cornerdetect)
            self.bg.recolor_svg_file('black',
                                     self.svg_temp_us.name,
                                     self.svg_temp.name,
                                     gradient_mid = gradient_mid)
                
            self.scene_svg_eu.clear()
            svg_eu = QGraphicsSvgItem(self.svg_temp.name)


            #scaled = svg_eu.scaled(191, 191, Qt.KeepAspectRatio)
            self.scene_svg_eu.addItem(svg_eu)
            self.scene_svg_eu.update()
            self.ui.graphic_svg_eu.fitInView(svg_eu)
        except Exception as err:
            print(str(err))
Beispiel #18
0
    def update_package_view(self):

        package = self.current_package

        try:
            mod = importlib.import_module('packages.{}'.format(
                package['type']))
        except ImportError:
            return

        # Draw package


#		f = tempfile.NamedTemporaryFile()
        f = open('tmp.svg', 'wb')
        import target_svg
        target = target_svg.get_target()
        target.add_package(package)

        process = {'F': TolLen(0, 0.05, 1), 'P': TolLen(0, 0.05, 1)}
        pac = mod.get_package(package['values'], 'IPC7351-B', process)
        pac.gen(target)

        target.output(f)
        f.flush()

        # Draw SVG output
        svg = QGraphicsSvgItem(f.name)
        scene = QGraphicsScene()
        scene.addItem(svg)

        self.package_ui.graphicsView.setScene(scene)

        f.close()
Beispiel #19
0
    def __init__(self, text, scene):
        super(Text, self).__init__(scene)
        self.font = QFont("Arial")
        self.font.setPointSize(14)
        self.font.setStyleName("Standard")
        self.text = text
        self.textcolor = QColor(Qt.black)

        self.data = str.encode(self.getSvg())
        self.renderer = QSvgRenderer()
        self.renderer.load(self.data)
        self.svg = QGraphicsSvgItem(self)
        self.svg.setSharedRenderer(self.renderer)
        self.setRect(0, 0,
                     self.svg.boundingRect().width(),
                     self.svg.boundingRect().height())
 def setImg(self, svg_path):
     self.scene = QGraphicsScene()
     item = QGraphicsSvgItem(svg_path)
     self.scene.addItem(item)
     self.setScene(self.scene)
     self.fitInView(self.scene.sceneRect(),
                    Qt.AspectRatioMode.KeepAspectRatio)
Beispiel #21
0
    def openFile(self, svg_file):
        if not svg_file.exists():
            return

        s = self.scene()

        s.clear()
        self.resetTransform()

        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)

        s.addItem(self.svgItem)

        self.printHotRectangles()
Beispiel #22
0
    def initialize_loading_page(self):
        svg_container = QGraphicsScene(self.window().loading_svg_view)
        svg_item = QGraphicsSvgItem()

        svg = QSvgRenderer(get_image_path("loading_animation.svg"))
        svg.repaintNeeded.connect(svg_item.update)
        svg_item.setSharedRenderer(svg)
        svg_container.addItem(svg_item)

        self.window().loading_svg_view.setScene(svg_container)
        self.window().core_manager.events_manager.upgrader_tick.connect(
            self.on_upgrader_tick)
        self.window().core_manager.events_manager.upgrader_finished.connect(
            self.upgrader_finished)
        self.window().skip_conversion_btn.hide()

        # Hide the force shutdown button initially. Should be triggered by shutdown timer from main window.
        self.window().force_shutdown_btn.hide()
Beispiel #23
0
    def openFile(self, svg_file):
        if not svg_file.exists():
            return

        s = self.scene()

        if self.backgroundItem:
            drawBackground = self.backgroundItem.isVisible()
        else:
            drawBackground = False

        if self.outlineItem:
            drawOutline = self.outlineItem.isVisible()
        else:
            drawOutline = True

        s.clear()
        self.resetTransform()

        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)

        self.backgroundItem = QGraphicsRectItem(self.svgItem.boundingRect())
        self.backgroundItem.setBrush(Qt.white)
        self.backgroundItem.setPen(QPen(Qt.NoPen))
        self.backgroundItem.setVisible(drawBackground)
        self.backgroundItem.setZValue(-1)

        self.outlineItem = QGraphicsRectItem(self.svgItem.boundingRect())
        outline = QPen(Qt.black, 2, Qt.DashLine)
        outline.setCosmetic(True)
        self.outlineItem.setPen(outline)
        self.outlineItem.setBrush(QBrush(Qt.NoBrush))
        self.outlineItem.setVisible(drawOutline)
        self.outlineItem.setZValue(1)

        s.addItem(self.backgroundItem)
        s.addItem(self.svgItem)
        s.addItem(self.outlineItem)

        s.setSceneRect(self.outlineItem.boundingRect().adjusted(
            -10, -10, 10, 10))
    def init (self):
        #os.chdir('/Users/zeyneptuna/Desktop/during_flight/widget/flight_duration')
        
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight
                
        self.m_itemFace = QGraphicsSvgItem("widget/flight_duration/fd_face.svg")
        self.m_itemFace.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemFace.setZValue(self.m_faceZ)
        self.m_itemFace.setTransform(QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemFace.setTransformOriginPoint(self.m_originalFdCtr)
        self.m_scene.addItem(self.m_itemFace)

        self.m_itemCase = QGraphicsSvgItem("widget/flight_duration/fd_case.svg")        
        self.m_itemCase.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemCase.setZValue(self.m_caseZ)
        self.m_itemCase.setTransform(QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemCase.setTransformOriginPoint(self.m_originalFdCtr)
        self.m_scene.addItem(self.m_itemCase)
        
        #self.m_itemMark1 = QGraphicsSvgItem("fd_mark_1.svg")        
        #self.m_itemMark1.setCacheMode(QGraphicsItem.NoCache)
        #self.m_itemMark1.setZValue(self.m_mark1Z)
        #self.m_itemMark1.setTransformOriginPoint(self.m_originalMarkCtr)
        #self.m_itemMark1.setTransform(QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        #self.m_scene.addItem(self.m_itemMark1)       
        
        #self.m_itemMark2 = QGraphicsSvgItem("fd_mark_2.svg")        
        #self.m_itemMark2.setCacheMode(QGraphicsItem.NoCache)
        #self.m_itemMark2.setZValue(self.m_mark2Z)
        #self.m_itemMark2.setTransformOriginPoint(self.m_originalMarkCtr)
        #self.m_itemMark2.setTransform(QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        #self.m_scene.addItem(self.m_itemMark2)        
        
        #self.m_itemMark3 = QGraphicsSvgItem("fd_mark_3.svg")               
        #self.m_itemMark3.setCacheMode(QGraphicsItem.NoCache)
        #self.m_itemMark3.setZValue(self.m_mark3Z)
        #self.m_itemMark3.setTransformOriginPoint(self.m_originalMarkCtr)
        #self.m_itemMark3.setTransform(QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        #self.m_scene.addItem(self.m_itemMark3)                

        self.centerOn (self.width()/2, self.height()/2)
        self.updateView()
Beispiel #25
0
    def upd_sp_num_rows(self):
        self.preview.scene().clear()
        rows = self.sp_num_rows.value()
        if rows > 0 and rows < 7:
            self.sl_num_rows.setValue(rows)

        self.hgutter_max = int(self.rcpg_object.height_page / (rows + 1))
        self.sp_hgutter.setMaximum(self.hgutter_max)
        self.sl_hgutter.setMaximum(self.hgutter_max)

        self.rcpg_object.rows = rows
        self.rcpg_object.upd_everything()
        self.rcpg_object.standard_grid()
        self.rcpg_object.refresh_svg_renderer()
        self.svg_item = QGraphicsSvgItem()
        self.svg_item.setSharedRenderer(self.rcpg_object.svg_renderer)
        self.preview.scene().addItem(self.svg_item)
        self.set_clickable_gutters()
        self.svg_item.update()
Beispiel #26
0
    def upd_sp_num_columns(self):
        self.preview.scene().clear()
        columns = self.sp_num_columns.value()
        if columns > 0 and columns < 7:
            self.sl_num_columns.setValue(columns)

        self.vgutter_max = int(self.rcpg_object.width_page / (columns + 1))
        self.sp_vgutter.setMaximum(self.vgutter_max)
        self.sl_vgutter.setMaximum(self.vgutter_max)

        self.rcpg_object.columns = columns
        self.rcpg_object.upd_everything()
        self.rcpg_object.standard_grid()
        self.rcpg_object.refresh_svg_renderer()
        self.svg_item = QGraphicsSvgItem()
        self.svg_item.setSharedRenderer(self.rcpg_object.svg_renderer)
        self.preview.scene().addItem(self.svg_item)
        self.set_clickable_gutters()
        self.svg_item.update()
Beispiel #27
0
 def __init__(self, unitOperationType=None, parent=None):
     QGraphicsSvgItem.__init__(self, parent)
     self.m_type = str(unitOperationType)
     self.m_renderer = QSvgRenderer(
         fileImporter(f'{unitOperationType}.svg'))
     self.setSharedRenderer(self.m_renderer)
     # set initial size of item
     self.width = self.m_renderer.defaultSize().width()
     self.height = self.m_renderer.defaultSize().height()
     # set graphical settings for this item
     self.setFlags(QGraphicsSvgItem.ItemIsMovable
                   | QGraphicsSvgItem.ItemIsSelectable
                   | QGraphicsSvgItem.ItemSendsGeometryChanges)
     self.setAcceptHoverEvents(True)
     self.setZValue(2)
     # items connected to this item
     self.lineGripItems = []
     self.sizeGripItems = []
     self.label = None
     self._rotation = 0
     self.flipState = [False, False]
    def init(self):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight

        self.m_itemHand = QGraphicsSvgItem(":/qfi/images/vsi/vsi_hand.svg")
        self.m_itemHand.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemHand.setZValue(self.m_handZ)
        self.m_itemHand.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemHand.setTransformOriginPoint(self.m_originalVsiCtr)
        self.m_scene.addItem(self.m_itemHand)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/vsi/vsi_face.svg")
        self.m_itemFace.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemFace.setZValue(self.m_faceZ)
        self.m_itemFace.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemFace.setTransformOriginPoint(self.m_originalVsiCtr)
        self.m_scene.addItem(self.m_itemFace)

        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/vsi/vsi_case.svg")
        self.m_itemCase.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemCase.setZValue(self.m_caseZ)
        self.m_itemCase.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemCase.setTransformOriginPoint(self.m_originalVsiCtr)
        self.m_scene.addItem(self.m_itemCase)

        self.centerOn(self.width() / 2, self.height() / 2)

        self.updateView()
Beispiel #29
0
class SymbolItem(QGraphicsItemGroup):
    _cache = {}

    def __init__(self, symbol, parent=None, cache_dir=None):
        super().__init__(parent)

        self._symbol = symbol

        try:
            renderer, svg_symbol = self._cache[self._symbol]
        except KeyError:
            path = os.path.join(DATA_DIR, 'symbols', '%s.svg' % self._symbol)
            svg_symbol = SvgSymbol(path, cache_dir=cache_dir)
            renderer = QSvgRenderer(svg_symbol.get_xml())
            self._cache[self._symbol] = (renderer, svg_symbol)

        self.grp = QGraphicsItemGroup(self)
        origin_x, origin_y = svg_symbol.get_origin()
        self.grp.setPos(-origin_x, -origin_y)

        self.body = QGraphicsSvgItem(self.grp)
        self.body.setSharedRenderer(renderer)
Beispiel #30
0
 def canvasChanged(self, canvas):
     app = Krita.instance()
     doc = app.activeDocument()
     if doc != None:
         self.preview.scene().clear()
         self.rcpg_object.height_page = doc.height()
         self.rcpg_object.width_page = doc.width()
         self.rcpg_object.upd_everything()
         self.rcpg_object.standard_grid()
         self.rcpg_object.refresh_svg_renderer()
         self.svg_item = QGraphicsSvgItem()
         self.svg_item.setSharedRenderer(self.rcpg_object.svg_renderer)
         self.preview.scene().addItem(self.svg_item)
         self.set_clickable_gutters()
         self.svg_item.update()
         iii = self.preview.scene().sceneRect()
         if doc.height() > doc.width():
             iii.setHeight(doc.height())
         else:
             iii.setHeight(doc.height())
             iii.setWidth(doc.width())
         self.preview.scene().setSceneRect(iii)
         self.preview.updateView()
Beispiel #31
0
    def init (self):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemBack = QGraphicsSvgItem(":/qfi/images/adi/adi_back.svg")
        self.m_itemBack.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemBack.setZValue( self.m_backZ )
        self.m_itemBack.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemBack.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemBack)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/adi/adi_face.svg")
        self.m_itemFace.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace.setZValue( self.m_faceZ )
        self.m_itemFace.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemFace)

        self.m_itemRing = QGraphicsSvgItem(":/qfi/images/adi/adi_ring.svg")
        self.m_itemRing.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemRing.setZValue( self.m_ringZ )
        self.m_itemRing.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemRing.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemRing)


        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/alt/alt_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()
Beispiel #32
0
    def open_file(self, filename):
        svg_file = QFile(filename)

        if not svg_file.exists():
            return

        self.file_name = svg_file
        self.resetTransform()
        self.scale(2.0, 2.0)
        svg_item = QGraphicsSvgItem(svg_file.fileName())
        svg_item.setFlags(QGraphicsItem.ItemClipsToShape)
        svg_item.setCacheMode(QGraphicsItem.NoCache)
        svg_item.setZValue(0)

        s = self.scene()
        s.clear()
        s.addItem(svg_item)
Beispiel #33
0
    def __init(self):
        self.__scaleX = width() / self.__originalWidth
        self.__scaleY = height() / self.__originalHeight

        self.__reset()
        # "border-image: url(:/side_btn/LightGCS_image/setter.png);"
        self.__itemBack = QGraphicsSvgItem(
            ":/fi_img/monitor/flightInstruments/img/adi/adi_back.svg")
        self.__itemBack.setCacheMode(QGraphicsItem.NoCache)
        self.__itemBack.setZvalue(self.__backZ)
        self.__itemBack.setTransform(
            QTransform.fromScale(self.__scaleX, self.__scaleY), True)
        self.__itemBack.setTransformOriginPoint(self.__originalAdiCtr)
        self.__scene.addItem(self.__itemBack)

        self.__itemFace = QGraphicsSvgItem(
            ":/fi_img/monitor/flightInstruments/img/adi/adi_face.svg")
        self.__itemFace.setCacheMode(QGraphicsItem.NoCache)
        self.__itemFace.setZvalue(self.__faceZ)
        self.__itemFace.setTransform(
            QTransform.fromScale(self.__scaleX, self.__scaleY), True)
        self.__itemFace.setTransformOriginPoint(self.__originalAdiCtr)
        self.__scene.addItem(self.__itemFace)

        self.__itemRing = QGraphicsSvgItem(
            ":/fi_img/monitor/flightInstruments/img/adi/adi_ring.svg")
        self.__itemRing.setCacheMode(QGraphicsItem.NoCache)
        self.__itemRing.setZvalue(self.__ringZ)
        self.__itemRing.setTransform(
            QTransform.fromScale(self.__scaleX, self.__scaleY), True)
        self.__itemRing.setTransformOriginPoint(self.__originalAdiCtr)
        self.__scene.addItem(self.__itemRing)

        self.__itemCase = QGraphicsSvgItem(
            ":/fi_img/monitor/flightInstruments/img/adi/adi_case.svg")
        self.__itemCase.setCacheMode(QGraphicsItem.NoCache)
        self.__itemCase.setZvalue(self.__ringZ)
        self.__itemCase.setTransform(
            QTransform.fromScale(self.__scaleX, self.__scaleY), True)
        self.__itemCase.setTransformOriginPoint(self.__originalAdiCtr)
        self.__scene.addItem(self.__itemCase)

        centerOn(width() / 2.0, height() / 2.0)

        self.__updateView()
Beispiel #34
0
    def openFile(self, svg_file):
        if not svg_file.exists():
            return
  
        s = self.scene()
    
        s.clear()
        self.resetTransform()
  
        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)
    
        s.addItem(self.svgItem)

        self.printHotRectangles()
Beispiel #35
0
    def openFile(self, svg_file):
        if not svg_file.exists():
            return

        s = self.scene()

        if self.backgroundItem:
            drawBackground = self.backgroundItem.isVisible()
        else:
            drawBackground = False

        if self.outlineItem:
            drawOutline = self.outlineItem.isVisible()
        else:
            drawOutline = True

        s.clear()
        self.resetTransform()

        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)

        self.backgroundItem = QGraphicsRectItem(self.svgItem.boundingRect())
        self.backgroundItem.setBrush(Qt.white)
        self.backgroundItem.setPen(QPen(Qt.NoPen))
        self.backgroundItem.setVisible(drawBackground)
        self.backgroundItem.setZValue(-1)

        self.outlineItem = QGraphicsRectItem(self.svgItem.boundingRect())
        outline = QPen(Qt.black, 2, Qt.DashLine)
        outline.setCosmetic(True)
        self.outlineItem.setPen(outline)
        self.outlineItem.setBrush(QBrush(Qt.NoBrush))
        self.outlineItem.setVisible(drawOutline)
        self.outlineItem.setZValue(1)

        s.addItem(self.backgroundItem)
        s.addItem(self.svgItem)
        s.addItem(self.outlineItem)

        s.setSceneRect(self.outlineItem.boundingRect().adjusted(-10, -10, 10, 10))
Beispiel #36
0
    def init (self):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemFace_1 = QGraphicsSvgItem(":/qfi/images/alt/alt_face_1.svg")
        self.m_itemFace_1.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace_1.setZValue( self.m_face1Z )
        self.m_itemFace_1.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace_1.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemFace_1)

        self.m_itemFace_2 = QGraphicsSvgItem(":/qfi/images/alt/alt_face_2.svg")
        self.m_itemFace_2.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace_2.setZValue( self.m_face2Z )
        self.m_itemFace_2.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace_2.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemFace_2)

        self.m_itemFace_3 = QGraphicsSvgItem(":/qfi/images/alt/alt_face_3.svg")
        self.m_itemFace_3.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace_3.setZValue( self.m_face3Z )
        self.m_itemFace_3.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace_3.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemFace_3)

        self.m_itemHand_1 = QGraphicsSvgItem(":/qfi/images/alt/alt_hand_1.svg")
        self.m_itemHand_1.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand_1.setZValue( self.m_hand1Z )
        self.m_itemHand_1.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand_1.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemHand_1)

        self.m_itemHand_2 = QGraphicsSvgItem(":/qfi/images/alt/alt_hand_2.svg")
        self.m_itemHand_2.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand_2.setZValue( self.m_hand2Z )
        self.m_itemHand_2.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand_2.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemHand_2)

        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/alt/alt_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()
    def init(self):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight

        self.m_itemBack = QGraphicsSvgItem(":/qfi/images/adi/adi_back.svg")
        self.m_itemBack.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemBack.setZValue(self.m_backZ)
        self.m_itemBack.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemBack.setTransformOriginPoint(self.m_originalAdiCtr)
        self.m_scene.addItem(self.m_itemBack)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/adi/adi_face.svg")
        self.m_itemFace.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemFace.setZValue(self.m_faceZ)
        self.m_itemFace.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemFace.setTransformOriginPoint(self.m_originalAdiCtr)
        self.m_scene.addItem(self.m_itemFace)

        self.m_itemRing = QGraphicsSvgItem(":/qfi/images/adi/adi_ring.svg")
        self.m_itemRing.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemRing.setZValue(self.m_ringZ)
        self.m_itemRing.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemRing.setTransformOriginPoint(self.m_originalAdiCtr)
        self.m_scene.addItem(self.m_itemRing)

        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/alt/alt_case.svg")
        self.m_itemCase.setCacheMode(QGraphicsItem.NoCache)
        self.m_itemCase.setZValue(self.m_caseZ)
        self.m_itemCase.setTransform(
            QTransform.fromScale(self.m_scaleX, self.m_scaleY), True)
        self.m_itemCase.setTransformOriginPoint(self.m_originalAdiCtr)
        self.m_scene.addItem(self.m_itemCase)

        self.centerOn(self.width() / 2, self.height() / 2)

        self.updateView()
Beispiel #38
0
class SvgView(QGraphicsView):
    def __init__(self, parent=None):
        super(SvgView, self).__init__(parent)
  
        self.setViewport(QWidget())
        self.svgItem = None
        self.image = QImage()
  
        self.setScene(QGraphicsScene(self))
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setDragMode(QGraphicsView.ScrollHandDrag)
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
  
    def openFile(self, svg_file):
        if not svg_file.exists():
            return
  
        s = self.scene()
    
        s.clear()
        self.resetTransform()
  
        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)
    
        s.addItem(self.svgItem)

        self.printHotRectangles()

    def printHotRectangles(self):
        names="GND0,GND1,GND2,GND3,A1,A2,PVS,OUT,IN,MIC,SINE,IN1,IN2,SEN,SQR1,SQR2,OD1,CCS".split(",")
        for n in names:
            print(n, self.svgItem.renderer().boundsOnElement(n))

        
    def wheelEvent(self, event):
        factor = pow(1.2, event.angleDelta().y() / 240.0)
        self.scale(factor, factor)
        event.accept()
Beispiel #39
0
class SvgView(QGraphicsView):
    Native, OpenGL, Image = range(3)

    def __init__(self, parent=None):
        super(SvgView, self).__init__(parent)

        self.renderer = SvgView.Native
        self.svgItem = None
        self.backgroundItem = None
        self.outlineItem = None
        self.image = QImage()

        self.setScene(QGraphicsScene(self))
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setDragMode(QGraphicsView.ScrollHandDrag)
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)

        # Prepare background check-board pattern.
        tilePixmap = QPixmap(64, 64)
        tilePixmap.fill(Qt.white)
        tilePainter = QPainter(tilePixmap)
        color = QColor(220, 220, 220)
        tilePainter.fillRect(0, 0, 32, 32, color)
        tilePainter.fillRect(32, 32, 32, 32, color)
        tilePainter.end()

        self.setBackgroundBrush(QBrush(tilePixmap))

    def drawBackground(self, p, rect):
        p.save()
        p.resetTransform()
        p.drawTiledPixmap(self.viewport().rect(),
                self.backgroundBrush().texture())
        p.restore()

    def openFile(self, svg_file):
        if not svg_file.exists():
            return

        s = self.scene()

        if self.backgroundItem:
            drawBackground = self.backgroundItem.isVisible()
        else:
            drawBackground = False

        if self.outlineItem:
            drawOutline = self.outlineItem.isVisible()
        else:
            drawOutline = True

        s.clear()
        self.resetTransform()

        self.svgItem = QGraphicsSvgItem(svg_file.fileName())
        self.svgItem.setFlags(QGraphicsItem.ItemClipsToShape)
        self.svgItem.setCacheMode(QGraphicsItem.NoCache)
        self.svgItem.setZValue(0)

        self.backgroundItem = QGraphicsRectItem(self.svgItem.boundingRect())
        self.backgroundItem.setBrush(Qt.white)
        self.backgroundItem.setPen(QPen(Qt.NoPen))
        self.backgroundItem.setVisible(drawBackground)
        self.backgroundItem.setZValue(-1)

        self.outlineItem = QGraphicsRectItem(self.svgItem.boundingRect())
        outline = QPen(Qt.black, 2, Qt.DashLine)
        outline.setCosmetic(True)
        self.outlineItem.setPen(outline)
        self.outlineItem.setBrush(QBrush(Qt.NoBrush))
        self.outlineItem.setVisible(drawOutline)
        self.outlineItem.setZValue(1)

        s.addItem(self.backgroundItem)
        s.addItem(self.svgItem)
        s.addItem(self.outlineItem)

        s.setSceneRect(self.outlineItem.boundingRect().adjusted(-10, -10, 10, 10))

    def setRenderer(self, renderer):
        self.renderer = renderer

        if self.renderer == SvgView.OpenGL:
            if QGLFormat.hasOpenGL():
                self.setViewport(QGLWidget(QGLFormat(QGL.SampleBuffers)))
        else:
            self.setViewport(QWidget())

    def setHighQualityAntialiasing(self, highQualityAntialiasing):
        if QGLFormat.hasOpenGL():
            self.setRenderHint(QPainter.HighQualityAntialiasing,
                    highQualityAntialiasing)

    def setViewBackground(self, enable):
        if self.backgroundItem:
            self.backgroundItem.setVisible(enable)

    def setViewOutline(self, enable):
        if self.outlineItem:
            self.outlineItem.setVisible(enable)

    def paintEvent(self, event):
        if self.renderer == SvgView.Image:
            if self.image.size() != self.viewport().size():
                self.image = QImage(self.viewport().size(),
                        QImage.Format_ARGB32_Premultiplied)

            imagePainter = QPainter(self.image)
            QGraphicsView.render(self, imagePainter)
            imagePainter.end()

            p = QPainter(self.viewport())
            p.drawImage(0, 0, self.image)
        else:
            super(SvgView, self).paintEvent(event)

    def wheelEvent(self, event):
        print(event.angleDelta().y())
        factor = pow(1.2, event.angleDelta().y() / 240.0)
        self.scale(factor, factor)
        event.accept()
Beispiel #40
0
class qfi_VSI (QGraphicsView):

    viewUpdate = pyqtSignal()


    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):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemHand = QGraphicsSvgItem(":/qfi/images/vsi/vsi_hand.svg")
        self.m_itemHand.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand.setZValue( self.m_handZ )
        self.m_itemHand.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemHand)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/vsi/vsi_face.svg")
        self.m_itemFace.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace.setZValue( self.m_faceZ )
        self.m_itemFace.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemFace)


        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/vsi/vsi_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalVsiCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()

    def reinit(self):
        if (self.m_scene):
            self.m_scene.clear()
            self.init()


    def update(self):
        self.updateView()


    def setClimbRate (self, climbRate):
        self.m_climbRate = climbRate

        if (self.m_climbRate < -2000):
            self.m_climbRate = -2000
        if (self.m_climbRate > 2000):
            self.m_climbRate = 2000


    def resizeEvent (self, event):
        QGraphicsView.resizeEvent (self,event)
        self.reinit()

    def reset (self):
        self.m_itemHand = None
        self.m_itemFace = None
        self.m_itemCase   = None

        self.m_climbRate =  0.0


    def updateView(self):

        self.m_itemHand.setRotation( self.m_climbRate * 0.086 )

        self.m_scene.update()
Beispiel #41
0
class qfi_ADI (QGraphicsView):

    viewUpdate = pyqtSignal()

    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):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemBack = QGraphicsSvgItem(":/qfi/images/adi/adi_back.svg")
        self.m_itemBack.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemBack.setZValue( self.m_backZ )
        self.m_itemBack.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemBack.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemBack)

        self.m_itemFace = QGraphicsSvgItem(":/qfi/images/adi/adi_face.svg")
        self.m_itemFace.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace.setZValue( self.m_faceZ )
        self.m_itemFace.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemFace)

        self.m_itemRing = QGraphicsSvgItem(":/qfi/images/adi/adi_ring.svg")
        self.m_itemRing.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemRing.setZValue( self.m_ringZ )
        self.m_itemRing.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemRing.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemRing)


        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/alt/alt_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalAdiCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()

    def reinit(self):
        if (self.m_scene):
            self.m_scene.clear()
            self.init()


    def update(self):
        self.updateView()
        self.m_faceDeltaX_old  = self.m_faceDeltaX_new
        self.m_faceDeltaY_old  = self.m_faceDeltaY_new


    def setRoll (self, roll):
        self.m_roll = roll

        if (self.m_roll < -180):
            self.m_roll = -180
        if (self.m_roll > 180):
            self.m_roll = 180


    def setPitch (self, pitch):
        self.m_pitch = pitch
        if (self.m_pitch < -25):
            self.m_pitch = -25
        if (self.m_pitch > 25):
            self.m_pitch = 25

    def resizeEvent (self, event):
        QGraphicsView.resizeEvent (self,event)
        self.reinit()

    def reset (self):
        self.m_itemBack = None
        self.m_itemFace = None
        self.m_itemRing = None
        self.m_itemCase   = None

        self.m_roll =  0.0
        self.m_pitch = 0.0


    def updateView(self):

        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight
        
        self.m_itemBack.setRotation(- self.m_roll)
        self.m_itemRing.setRotation(- self.m_roll)
        self.m_itemFace.setRotation(- self.m_roll)

        roll_rad = math.pi * self.m_roll / 180.0
        delta  = self.m_originalPixPerDeg * self.m_pitch

        self.m_faceDeltaX_new = self.m_scaleX * delta * math.sin( roll_rad )
        self.m_faceDeltaY_new = self.m_scaleY * delta * math.cos( roll_rad )

        self.m_itemFace.moveBy( self.m_faceDeltaX_new - self.m_faceDeltaX_old, self.m_faceDeltaY_new - self.m_faceDeltaY_old )


        self.m_scene.update()
Beispiel #42
0
class qfi_ALT (QGraphicsView):

    viewUpdate = pyqtSignal()

    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):
        self.m_scaleX = self.width() / self.m_originalWidth
        self.m_scaleY = self.height() / self.m_originalHeight


        self.m_itemFace_1 = QGraphicsSvgItem(":/qfi/images/alt/alt_face_1.svg")
        self.m_itemFace_1.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace_1.setZValue( self.m_face1Z )
        self.m_itemFace_1.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace_1.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemFace_1)

        self.m_itemFace_2 = QGraphicsSvgItem(":/qfi/images/alt/alt_face_2.svg")
        self.m_itemFace_2.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace_2.setZValue( self.m_face2Z )
        self.m_itemFace_2.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace_2.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemFace_2)

        self.m_itemFace_3 = QGraphicsSvgItem(":/qfi/images/alt/alt_face_3.svg")
        self.m_itemFace_3.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemFace_3.setZValue( self.m_face3Z )
        self.m_itemFace_3.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemFace_3.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemFace_3)

        self.m_itemHand_1 = QGraphicsSvgItem(":/qfi/images/alt/alt_hand_1.svg")
        self.m_itemHand_1.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand_1.setZValue( self.m_hand1Z )
        self.m_itemHand_1.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand_1.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemHand_1)

        self.m_itemHand_2 = QGraphicsSvgItem(":/qfi/images/alt/alt_hand_2.svg")
        self.m_itemHand_2.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemHand_2.setZValue( self.m_hand2Z )
        self.m_itemHand_2.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemHand_2.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemHand_2)

        self.m_itemCase = QGraphicsSvgItem(":/qfi/images/alt/alt_case.svg")
        self.m_itemCase.setCacheMode (QGraphicsItem.NoCache)
        self.m_itemCase.setZValue( self.m_caseZ )
        self.m_itemCase.setTransform( QTransform.fromScale( self.m_scaleX, self.m_scaleY ), True )
        self.m_itemCase.setTransformOriginPoint( self.m_originalAltCtr )
        self.m_scene.addItem (self.m_itemCase)

        self.centerOn (self.width()/2, self.height()/2)

        self.updateView()

    def reinit(self):
        if (self.m_scene):
            self.m_scene.clear()
            self.init()

    def update(self):
        self.updateView()

    def setAltitude (self, altitude):
        self.m_altitude = altitude

    def setPressure (self, pressure):
        self.m_pressure = pressure
        if (self.m_pressure < 28):
            self.m_pressure = 28
        if (self.m_pressure > 31.5):
            self.m_pressure = 31.5

    def resizeEvent (self, event):
        QGraphicsView.resizeEvent (self,event)
        self.reinit()

    def reset (self):
        self.m_itemFace_1 = None
        self.m_itemFace_2 = None
        self.m_itemFace_3 = None
        self.m_itemHand_1 = None
        self.m_itemHand_2 = None
        self.m_itemCase   = None

        self.m_altitude =  0.0
        self.m_pressure = 28.0


    def updateView(self):
        altitude = math.ceil(self.m_altitude + 0.5)
        angleH1 = self.m_altitude * 0.036
        angleH2 = ( altitude % 1000 ) * 0.36
        angleF1 = (self.m_pressure - 28.0 ) * 100.0
        angleF3 = self.m_altitude * 0.0036

        self.m_itemHand_1.setRotation(angleH1)
        self.m_itemHand_2.setRotation(angleH2)
        self.m_itemFace_1.setRotation(- angleF1)
        self.m_itemFace_3.setRotation(angleF3)

        self.m_scene.update()