~freecad-community/freecad-extras/drawing-dimensioning

« back to all changes in this revision

Viewing changes to drawingDimensioning/selectionOverlay/__init__.py

  • Committer: GitHub
  • Author(s): hamish2014
  • Date: 2019-05-07 09:17:42 UTC
  • mfrom: (137.1.3)
  • Revision ID: git-v1:c191c5544ea60cb115d3922cb9c066440b12868b
Merge pull request #122 from looooo/master

py3 and qt5 related diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
                                    doPoints=False, doTextItems=False, doLines=False, doCircles=False, doFittedCircles=False, doPathEndPoints=False, doMidPoints=False, doSelectViewObjectPoints=False, doEllipses=False, doArcCenters=True,
80
80
                                    pointWid=1.0 , maskPen=defaultMaskPen , maskBrush=defaultMaskBrush, maskHoverPen=defaultMaskHoverPen ):
81
81
    if clearPreviousSelectionItems:         
82
 
        if sceneToAddTo <> None:
 
82
        if sceneToAddTo != None:
83
83
            for gi in sceneToAddTo.items():
84
84
                if isinstance(gi, CircleSelectionGraphicsItem):
85
85
                    sceneToAddTo.removeItem(gi)
96
96
        gi.setAcceptHoverEvents(True)
97
97
        gi.setCursor( QtCore.Qt.CrossCursor ) # http://qt-project.org/doc/qt-5/qt.html#CursorShape-enum ; may not work for lines ...
98
98
        gi.setZValue(zValue)
99
 
        if transform <> None:
 
99
        if transform != None:
100
100
            gi.setTransform( transform )
101
 
        if sceneToAddTo <> None:
 
101
        if sceneToAddTo != None:
102
102
            sceneToAddTo.addItem(gi)
103
103
        graphicItems.append(gi)
104
104
    pointsAlreadyAdded = []
152
152
                    circlePoints( cx, cy, rx, ry)
153
153
                viewInfo.updateBounds_ellipse( cx, cy, rx, ry )
154
154
                
155
 
            if element.tag == 'text' and element.parms.has_key('x'):
 
155
            if element.tag == 'text' and 'x' in element.parms:
156
156
                if doTextItems:
157
157
                    addSelectionPoint( *element.applyTransforms( float( element.parms['x'] ), float( element.parms['y'] ) ) )
158
158
                elif doSelectViewObjectPoints:
214
214
                if doSelectViewObjectPoints and SelectViewObjectPoint_loc == None: #second check to textElementes preference
215
215
                    SelectViewObjectPoint_loc = x2, y2
216
216
 
217
 
        if doSelectViewObjectPoints and SelectViewObjectPoint_loc <> None:
 
217
        if doSelectViewObjectPoints and SelectViewObjectPoint_loc != None:
218
218
            addSelectionPoint( *SelectViewObjectPoint_loc )
219
219
                #if len(fitData) > 0: 
220
220
                #    x, y, r, r_error = fitCircle_to_path(fitData)
233
233
        if hideFunction == None or hideFunction(gi):
234
234
            try:
235
235
                gi.hide()
236
 
            except RuntimeError, msg:
 
236
            except RuntimeError as e:
237
237
                import FreeCAD
238
 
                FreeCAD.Console.PrintError('hideSelectionGraphicsItems unable to hide graphicItem, RuntimeError msg %s\n' % str(msg))
 
238
                FreeCAD.Console.PrintError('hideSelectionGraphicsItems unable to hide graphicItem, RuntimeError msg %s\n' % str(e))
239
239
            if deleteFromGraphicItemsList:
240
240
                delList.append( ind )
241
241
    for delInd in reversed(delList):
258
258
    def hoverMoveEvent(self, event):
259
259
        #FreeCAD.Console.PrintMessage('1\n')
260
260
        currentScale = self._graphicsView.transform().m11() #since no rotation...
261
 
        if currentScale <> self._previousScale :
 
261
        if currentScale != self._previousScale :
262
262
            #FreeCAD.Console.PrintMessage('adjusting Scale of graphics items\n')
263
263
            for gi in graphicItems:
264
264
                gi.adjustScale( 1 / currentScale  )