프로젝트

일반

사용자정보

개정판 adf0d8aa

IDadf0d8aa150d8b014246a06f590cf744b582a9e9
상위 5a049576
하위 96b89249

함의성이(가) 약 2년 전에 추가함

fix cad

Change-Id: I8acf3037fc1109067d4b8121140e77dd9c2c58fb

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
1701 1701
                    ret = True
1702 1702
                except Exception as ex:
1703 1703
                    conn.rollback()
1704
                    print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1705
                                                              sys.exc_info()[-1].tb_lineno))
1704
                    from App import App
1705
                    message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1706
                                                                sys.exc_info()[-1].tb_lineno)
1707
                    App.mainWnd().addMessage.emit(MessageType.Error, message)
1706 1708
                    ret = False
1707 1709
            finally:
1708 1710
                self._symbolBase = {}
DTI_PID/DTI_PID/ImportTextFromCADDialog.py
1275 1275

  
1276 1276
            if angle > 6.28:
1277 1277
                angle = angle - 2 * math.pi
1278
            elif angle == 6.28:
1279
                angle = 0.0
1278 1280

  
1279 1281
            """check if maxtents or minextents attribute exists"""
1280 1282
            if 'MaxExtents' not in blk_ref_node.attrib or 'MinExtents' not in blk_ref_node.attrib:
DTI_PID/DTI_PID/LineDetector.py
600 600

  
601 601
                    lhs.set_line([lhs_start, lhs_end])
602 602
                else:
603
                    if self.distanceTo(lhs_start, (pt.x, pt.y)) < toler:
603
                    if self.distanceTo(lhs_start, (pt.x, pt.y)) < toler and self.distanceTo(lhs_start, (pt.x, pt.y)) < self.distanceTo(lhs_end, (pt.x, pt.y)):
604 604
                        lhs_start[0] = pt.x
605 605
                        lhs_start[1] = pt.y
606 606
                    elif self.distanceTo(lhs_end, (pt.x, pt.y)) < toler:
......
618 618
                        rhs_end[1] = pt.y
619 619

  
620 620
                    rhs.set_line([rhs_start, rhs_end])
621

  
622 621
                else:
623
                    if self.distanceTo(rhs_start, (pt.x, pt.y)) < toler:
622
                    if self.distanceTo(rhs_start, (pt.x, pt.y)) < toler and self.distanceTo(rhs_start, (pt.x, pt.y)) < self.distanceTo(rhs_end, (pt.x, pt.y)):
624 623
                        rhs_start[0] = pt.x
625 624
                        rhs_start[1] = pt.y
626 625
                    elif self.distanceTo(rhs_end, (pt.x, pt.y)) < toler:
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
474 474
        import math
475 475
        from EngineeringConnectorItem import QEngineeringConnectorItem
476 476

  
477
        if type(item) is QEngineeringLineItem:
478
            startPt = item.start_point()
479
            endPt = item.end_point()
480

  
481
            dx = endPt[0] - startPt[0]
482
            dy = endPt[1] - startPt[1]
483
            length = math.sqrt(dx * dx + dy * dy)
484
            if length == 0:
485
                return False
486
            dx /= length
487
            dy /= length
488
            extendedLine = [(startPt[0] - dx * toler, startPt[1] - dy * toler),
489
                            (endPt[0] + dx * toler, endPt[1] + dy * toler)]
490
            pt = self.intersection(extendedLine)
491

  
492
            return (pt is not None) and (type(pt) == shapely.geometry.point.Point)
493
        elif type(item) is QEngineeringConnectorItem:
494
            start_pt = self.start_point()
495
            end_pt = self.end_point()
477
        try:
478
            if type(item) is QEngineeringLineItem:
479
                startPt = item.start_point()
480
                endPt = item.end_point()
481

  
482
                dx = endPt[0] - startPt[0]
483
                dy = endPt[1] - startPt[1]
484
                length = math.sqrt(dx * dx + dy * dy)
485
                if length == 0:
486
                    return False
487
                dx /= length
488
                dy /= length
489
                extendedLine = [(startPt[0] - dx * toler, startPt[1] - dy * toler),
490
                                (endPt[0] + dx * toler, endPt[1] + dy * toler)]
491
                pt = self.intersection(extendedLine)
492

  
493
                return (pt is not None) and (type(pt) == shapely.geometry.point.Point)
494
            elif type(item) is QEngineeringConnectorItem:
495
                start_pt = self.start_point()
496
                end_pt = self.end_point()
497

  
498
                lhs = [end_pt[0] - start_pt[0], end_pt[1] - start_pt[1]]
499
                length = math.sqrt(lhs[0] * lhs[0] + lhs[1] * lhs[1])
500
                if length == 0:
501
                    return False
502

  
503
                rhs = [item.dir().x(), item.dir().y()]
504
                dot = sum([lhs[i] * rhs[i] for i in range(len(lhs))])
505
                angle = math.degrees(math.acos(dot / length))
506
                if (abs(angle) < 5) or (abs(angle - 180) < 5):
507
                    _center = item.center()
508
                    dx = [start_pt[0] - _center[0], end_pt[0] - _center[0]]
509
                    dy = [start_pt[1] - _center[1], end_pt[1] - _center[1]]
510
                    length = [math.sqrt(dx[0] * dx[0] + dy[0] * dy[0]), math.sqrt(dx[1] * dx[1] + dy[1] * dy[1])]
511
                    return length[0] < toler or length[1] < toler
496 512

  
497
            lhs = [end_pt[0] - start_pt[0], end_pt[1] - start_pt[1]]
498
            length = math.sqrt(lhs[0] * lhs[0] + lhs[1] * lhs[1])
499
            if length == 0:
500 513
                return False
501 514

  
502
            rhs = [item.dir().x(), item.dir().y()]
503
            dot = sum([lhs[i] * rhs[i] for i in range(len(lhs))])
504
            angle = math.degrees(math.acos(dot / length))
505
            if (abs(angle) < 5) or (abs(angle - 180) < 5):
506
                _center = item.center()
507
                dx = [start_pt[0] - _center[0], end_pt[0] - _center[0]]
508
                dy = [start_pt[1] - _center[1], end_pt[1] - _center[1]]
509
                length = [math.sqrt(dx[0] * dx[0] + dy[0] * dy[0]), math.sqrt(dx[1] * dx[1] + dy[1] * dy[1])]
510
                return length[0] < toler or length[1] < toler
515
        except Exception as ex:
516
            from App import App
517
            from AppDocData import MessageType
511 518

  
512
            return False
519
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
520
                                                           sys.exc_info()[-1].tb_lineno) + ' Item UID : ' + str(self.uid)
521
            App.mainWnd().addMessage.emit(MessageType.Error, message)
513 522

  
514 523
        return False
515 524

  
......
726 735
                        res.append(obj.connectors[i].center())
727 736
                        res.append(dist[0][2])
728 737
                    """
729
                    if Point(start_pt[0], start_pt[1]).distance(Point(pt[0], pt[1])) < toler:
738
                    if Point(start_pt[0], start_pt[1]).distance(Point(pt[0], pt[1])) < toler and \
739
                        Point(start_pt[0], start_pt[1]).distance(Point(pt[0], pt[1])) < Point(end_pt[0], end_pt[1]).distance(Point(pt[0], pt[1])):
730 740
                        if self.connectors[0].connectedItem is None and obj.connectors[i].connectedItem is None:
731 741
                            self.connectors[0].connect(obj)
732 742
                            obj.connectors[i].connect(self)
......
1662 1672
                                                           sys.exc_info()[-1].tb_lineno)
1663 1673
            App.mainWnd().addMessage.emit(MessageType.Error, message)
1664 1674

  
1675
        #print(str(item.length()))
1665 1676
        return item if item.length() > 1 else None
1666 1677

  
1667 1678
    '''
DTI_PID/DTI_PID/SymbolTreeWidget.py
195 195

  
196 196
    def handleDeleteSymbolAction(self, result, itemType, itemName):
197 197
        if result == QMessageBox.Ok:
198
            project = AppDocData.instance().getCurrentProject()
199
            imagePath = os.path.join(project.getImageFilePath(), itemType,
200
                                     itemName + '.png')  # itemName DOESN'T includes ".png"
201
            imageDisplayPath = os.path.join(project.getImageFilePath(), itemType,
202
                                     itemName + '_display' + '.png')  # itemName DOESN'T includes ".png"
203
            if os.path.exists(imagePath):
204
                os.remove(imagePath)
205
            if os.path.exists(imageDisplayPath):
206
                os.remove(imageDisplayPath)
207

  
208
            svgPath = os.path.join(project.getSvgFilePath(), itemType, itemName + '.svg')
209
            if os.path.exists(svgPath):
210
                os.remove(svgPath)
211

  
212
            AppDocData.instance().deleteSymbol(itemName)
198
            res, _ = AppDocData.instance().deleteSymbol(itemName)
199
            if res:
200
                project = AppDocData.instance().getCurrentProject()
201
                imagePath = os.path.join(project.getImageFilePath(), itemType,
202
                                        itemName + '.png')  # itemName DOESN'T includes ".png"
203
                imageDisplayPath = os.path.join(project.getImageFilePath(), itemType,
204
                                        itemName + '_display' + '.png')  # itemName DOESN'T includes ".png"
205
                if os.path.exists(imagePath):
206
                    os.remove(imagePath)
207
                if os.path.exists(imageDisplayPath):
208
                    os.remove(imageDisplayPath)
209

  
210
                svgPath = os.path.join(project.getSvgFilePath(), itemType, itemName + '.svg')
211
                if os.path.exists(svgPath):
212
                    os.remove(svgPath)
213

  
213 214
            self.initSymbolTreeView()
214 215
        else:
215 216
            pass

내보내기 Unified diff

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