프로젝트

일반

사용자정보

개정판 a67b3200

IDa67b320088e64531cde78915d4ca97f402b3a606
상위 14337a0e
하위 ce604b29

김정우 이(가) 6년 이상 전에 추가함

SymbolSvgItem 내에 addSvgItemToScene 메소드 생성 및 호출

차이점 보기:

DTI_PID/DTI_PID/MainWindow.py
290 290
        @brief  create a symbol
291 291
        @history    2018.05.02  Jeongwoo    Change return value of QSymbolEditorDialog (Single variable → Tuple)
292 292
                                            Add SymbolSvgItem
293
                    2018.05.03  Jeongwoo    Change method to draw Svg Item on Scene (svg.addSvgItemToScene)
293 294
    '''
294 295
    def createSymbol(self):
295 296
        image = self.graphicsView.image()
......
299 300
            self.dirTreeWidget.initDirTreeWidget()
300 301
            if isAccepted:
301 302
                if isImmediateInsert:
302
                    ''''''
303 303
                    svgPath = AppDocData.instance().getCurrentProject().getSvgFilePath() + "/" + newSym.getType() + "/" + newSym.getName() + ".svg"
304 304
                    img = cv2.imread(AppDocData.instance().getCurrentProject().getImageFilePath() + "/" + newSym.getType() + "/" + newSym.getName() + ".png", 1)
305 305
                    w, h = (0, 0)
......
314 314
                    #### If case of 'lambda svg=svg:', function uses the 'svg' value bound to lambda
315 315
                    svg.clicked.connect(lambda param=svg: self.resultTreeWidget.findItem(param))
316 316
                    svg.removed.connect(self.resultTreeWidget.itemRemoved)
317

  
318
                    transform = QTransform()
319
                    transform.translate(offsetX, offsetY)
320
                    svg.setTransform(transform)
321
                    self.graphicsView.scene.addItem(svg)
317
                    svg.addSvgItemToScene(self.graphicsView.scene)
322 318
                    for connector in svg.connectors:
323 319
                        self.graphicsView.scene.addItem(connector)
324 320

  
......
496 492
                    humkyung 2018.04.23 connect item remove slot to result tree
497 493
                    Jeongwoo 2018.04.25 Add if state with QEngineeringNoteItem
498 494
                    Jeongwoo 2018.04.26 Change method to create TextItem object with TextItemFactory
495
                    Jeongwoo 2018.05.03 Change method to draw Svg Item on Scene (svg.addSvgItemToScene)
499 496
    '''
500 497
    def loadRecognitionResult(self, xmlPath):
501 498
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree, parse
......
525 522
                    #### If case of 'lambda svg=svg:', function uses the 'svg' value bound to lambda
526 523
                    svg.clicked.connect(lambda param=svg: self.resultTreeWidget.findItem(param))
527 524
                    svg.removed.connect(self.resultTreeWidget.itemRemoved)
528

  
529
                    transform = QTransform()
530
                    if (1.57 == angle) or (4.71 == angle):
531
                        transform.translate(pt[0] + size[0]*0.5,pt[1] + size[1]*0.5)
532
                        transform.rotateRadians(-svg.angle)
533
                        transform.translate(-size[1]*0.5, -size[0]*0.5)
534
                    elif 3.14 == angle:
535
                        transform.translate(pt[0] + size[0]*0.5,pt[1] + size[1]*0.5)
536
                        transform.rotateRadians(-svg.angle)
537
                        transform.translate(-size[0]*0.5, -size[1]*0.5)
538
                    else:
539
                        transform.translate(pt[0],pt[1])
540
                    svg.setTransform(transform)
541
                    self.graphicsView.scene.addItem(svg)
525
                    svg.addSvgItemToScene(self.graphicsView.scene)
542 526
                    for connector in svg.connectors:
543 527
                        self.graphicsView.scene.addItem(connector)
544 528
                else:
DTI_PID/DTI_PID/Shapes/QEngineeringTextItem.py
98 98
        @history    .
99 99
    '''
100 100
    def addTextItemToScene(self, scene):
101
        print("Put text")
102 101
        sx = 1
103 102
        sy = 1
104 103
        width = self.size[0]
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
313 313
        if self.isUnderMouse() == True:
314 314
            pen = QPen(Qt.red, 10, Qt.SolidLine)
315 315
            painter.setPen(pen)
316
            painter.drawEllipse(self.center(), 5, 5)
316
            painter.drawEllipse(self.center(), 5, 5)
317

  
318
    '''
319
        @brief  Add Svg Item into ImageViewer's Scene
320
        @author Jeongwoo
321
        @date   2018.05.03
322
    '''
323
    def addSvgItemToScene(self, scene):
324
        transform = QTransform()
325
        if (1.57 == self.angle) or (4.71 == self.angle):
326
            transform.translate(self.loc[0] + self.size[0]*0.5,self.loc[1] + self.size[1]*0.5)
327
            transform.rotateRadians(-self.angle)
328
            transform.translate(-self.size[1]*0.5, -self.size[0]*0.5)
329
        elif 3.14 == self.angle:
330
            transform.translate(self.loc[0] + self.size[0]*0.5,self.loc[1] + self.size[1]*0.5)
331
            transform.rotateRadians(-self.angle)
332
            transform.translate(-self.size[0]*0.5, -self.size[1]*0.5)
333
        else:
334
            transform.translate(self.loc[0],self.loc[1])
335
        self.setTransform(transform)
336
        scene.addItem(self)

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)