Exemple #1
0
def recomputeWithOutViewReset( drawingVars ):
    '''
    By default app.recompute() resets the drawing view, which can be rather frustrating...
    '''
    printGraphicsViewInfo( drawingVars )
    gV =  drawingVars.graphicsView
    T = gV.transform()
    scale = T.m11()
    ##attempting to find centre of view
    #dx = gV.mapToScene( 0,0).x()
    #dy = gV.mapToScene( 0,0).y()
    ## now scene_x = view_x/scale + dx; so
    #centerView = [
    #    0.5*gV.width(),
    #    0.5*gV.height(),
    #    ]
    #centerScene = gV.mapToScene( *centerView )
    #centerOn approach did not work rather using scroll bars.
    h_scrollValue = gV.horizontalScrollBar().value()
    v_scrollValue = gV.verticalScrollBar().value()
    import selectionOverlay
    selectionOverlay.hideSelectionGraphicsItems()    
    drawingVars.page.touch()
    App.ActiveDocument.recompute()
    gV.scale( scale , scale )
    #scale correction
    for i in range(3):
        scale_actual = gV.transform().m11()
        debugPrint(4, 'scale_desired %1.3f scale_actual %1.3f' % (scale, scale_actual))
        s_correction = scale / scale_actual
        gV.scale( s_correction, s_correction )

    gV.horizontalScrollBar().setValue( h_scrollValue )
    gV.verticalScrollBar().setValue( v_scrollValue )
    printGraphicsViewInfo( drawingVars )
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    crudeDebuggerPrint(
        '''circularDimension.py:9  	    x,y = elementParms['x'], elementParms['y'] '''
    )
    x, y = elementParms['x'], elementParms['y']
    crudeDebuggerPrint(
        '''circularDimension.py:10  	    dimensioning.point1 = x, y ''')
    dimensioning.point1 = x, y
    crudeDebuggerPrint(
        '''circularDimension.py:11  	    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x,y)) '''
    )
    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x, y))
    crudeDebuggerPrint(
        '''circularDimension.py:12  	    dimensioning.radius = elementParms['r'] '''
    )
    dimensioning.radius = elementParms['r']
    crudeDebuggerPrint(
        '''circularDimension.py:13  	    dimensioning.dimScale = 1/elementXML.rootNode().scaling() '''
    )
    dimensioning.dimScale = 1 / elementXML.rootNode().scaling()
    crudeDebuggerPrint(
        '''circularDimension.py:14  	    dimensioning.stage = 1 ''')
    dimensioning.stage = 1
    crudeDebuggerPrint(
        '''circularDimension.py:15  	    selectionOverlay.hideSelectionGraphicsItems() '''
    )
    selectionOverlay.hideSelectionGraphicsItems()
    crudeDebuggerPrint(
        '''circularDimension.py:16  	    previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview ) '''
    )
    previewDimension.initializePreview(dimensioning.drawingVars,
                                       clickFunPreview, hoverFunPreview)
Exemple #3
0
def linearDimension_parallels_hide_non_parallel(elementParms,
                                                elementViewObject):
    x1, y1, x2, y2 = [elementParms[k] for k in ['x1', 'y1', 'x2', 'y2']]
    d = numpy.array([x2 - x1, y2 - y1])
    d_ref = d / numpy.linalg.norm(d)
    p = numpy.array([x1, y1])

    def hideFun(gi):
        if isinstance(gi, selectionOverlay.LineSelectionGraphicsItem):
            if gi.elementParms <> elementParms:
                x1, y1, x2, y2 = [
                    gi.elementParms[k] for k in ['x1', 'y1', 'x2', 'y2']
                ]
                d = numpy.array([x2 - x1, y2 - y1])
                d = d / numpy.linalg.norm(d)
                if abs(numpy.dot(d_ref, d)) > 1.0 - 10**-9:  #then parallel
                    d_rotated = rotate2D(d, numpy.pi / 2)
                    offset = numpy.array([x1, y1]) - p
                    if abs(numpy.dot(d_rotated,
                                     offset)) > 10**-6:  #then not colinear
                        return False
        elif isinstance(gi, selectionOverlay.PointSelectionGraphicsItem):
            return False
        return True

    selectionOverlay.hideSelectionGraphicsItems(hideFun)
 def selectFun(self, event, referer, elementXML, elementParms, elementViewObject):
     x, y = elementParms["x"], elementParms["y"]
     d.dArgs = [x, y]
     d.stage = 1
     debugPrint(2, "welding symbol to point at x=%3.1f y=%3.1f" % (x, y))
     selectionOverlay.hideSelectionGraphicsItems()
     previewDimension.initializePreview(d, self.preview_svgRenderer, self.preview_clickHandler)
def selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    crudeDebuggerPrint('''linearDimension.py:9  	    x, y = elementParms['x'], elementParms['y'] ''')
    x, y = elementParms['x'], elementParms['y']
    crudeDebuggerPrint('''linearDimension.py:10  	    referer.lockSelection() ''')
    referer.lockSelection()
    crudeDebuggerPrint('''linearDimension.py:11  	    if dimensioning.stage == 0: #then selectPoint1 ''')
    if dimensioning.stage == 0: #then selectPoint1
        crudeDebuggerPrint('''linearDimension.py:12  	        dimensioning.point1 =  x,y ''')
        dimensioning.point1 =  x,y
        crudeDebuggerPrint('''linearDimension.py:13  	        debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x,y)) ''')
        debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x,y))
        crudeDebuggerPrint('''linearDimension.py:14  	        dimensioning.stage = 1 ''')
        dimensioning.stage = 1
    else:
        crudeDebuggerPrint('''linearDimension.py:16  	        dimensioning.point2 =  x,y ''')
        dimensioning.point2 =  x,y
        crudeDebuggerPrint('''linearDimension.py:17  	        debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x,y)) ''')
        debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x,y))
        crudeDebuggerPrint('''linearDimension.py:18  	        dimensioning.stage = 2 ''')
        dimensioning.stage = 2 
        crudeDebuggerPrint('''linearDimension.py:19  	        dimensioning.dimScale = 1/elementXML.rootNode().scaling() ''')
        dimensioning.dimScale = 1/elementXML.rootNode().scaling()
        crudeDebuggerPrint('''linearDimension.py:20  	        selectionOverlay.hideSelectionGraphicsItems() ''')
        selectionOverlay.hideSelectionGraphicsItems()
        crudeDebuggerPrint('''linearDimension.py:21  	        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview ) ''')
        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
 def selectFun(self, event, referer, elementXML, elementParms,
               elementViewObject):
     viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
     d.selections = [PointSelection(elementParms, elementXML, viewInfo)]
     selectionOverlay.hideSelectionGraphicsItems()
     previewDimension.initializePreview(d, self.preview_svgRenderer,
                                        self.preview_clickHandler)
Exemple #7
0
def recomputeWithOutViewReset( drawingVars ):
    '''
    By default app.recompute() resets the drawing view, which can be rather frustrating...
    '''
    printGraphicsViewInfo( drawingVars )
    gV =  drawingVars.graphicsView
    T = gV.transform()
    scale = T.m11()
    ##attempting to find centre of view
    #dx = gV.mapToScene( 0,0).x()
    #dy = gV.mapToScene( 0,0).y()
    ## now scene_x = view_x/scale + dx; so
    #centerView = [
    #    0.5*gV.width(),
    #    0.5*gV.height(),
    #    ]
    #centerScene = gV.mapToScene( *centerView )
    #centerOn approach did not work rather using scroll bars.
    h_scrollValue = gV.horizontalScrollBar().value()
    v_scrollValue = gV.verticalScrollBar().value()
    import selectionOverlay
    selectionOverlay.hideSelectionGraphicsItems()    
    drawingVars.page.touch()
    App.ActiveDocument.recompute()
    gV.scale( scale , scale )
    #scale correction
    for i in range(3):
        scale_actual = gV.transform().m11()
        debugPrint(4, 'scale_desired %1.3f scale_actual %1.3f' % (scale, scale_actual))
        s_correction = scale / scale_actual
        gV.scale( s_correction, s_correction )

    gV.horizontalScrollBar().setValue( h_scrollValue )
    gV.verticalScrollBar().setValue( v_scrollValue )
    printGraphicsViewInfo( drawingVars )
Exemple #8
0
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    referer.lockSelection()
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    if isinstance(referer, selectionOverlay.LineSelectionGraphicsItem):
        d.selections.append(LineSelection(elementParms, elementXML, viewInfo))
        if len(d.selections) == 1:
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi, selectionOverlay.PointSelectionGraphicsItem):
                    gi.hide()
        else:
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(
                d, angularDimension_points_preview,
                angularDimension_points_clickHandler)
    else:  #user selecting 3 points
        if len(d.selections) == 0:
            d.selections = [ThreePointAngleSelection()]
            d.max_selections = 3
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi, selectionOverlay.LineSelectionGraphicsItem):
                    gi.hide()
        d.selections[0].addPoint(elementParms, elementXML, viewInfo)
        if len(d.selections[0].points) == 3:
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(
                d, angularDimension_points_preview,
                angularDimension_points_clickHandler)
def AddToleranceToText(event, referer, elementXML, elementParms,
                       elementViewObject):
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    d.selections = [TextSelection(elementParms, elementXML, viewInfo)]
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview(d, toleranceAdd_preview,
                                       toleranceAdd_clickHandler)
Exemple #10
0
def stack_selectDimensioningPoint(event, referer, elementXML, elementParms,
                                  elementViewObject):
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    if len(d.selections) == 0:
        if isinstance(referer, selectionOverlay.PointSelectionGraphicsItem):
            d.selections.append(
                PointSelection(elementParms, elementXML, viewInfo))
            d.selections[-1].condensed_args = True
            selectionOverlay.hideSelectionGraphicsItems(lambda gi: isinstance(
                gi, selectionOverlay.LineSelectionGraphicsItem))
        else:
            d.selections.append(
                LineSelection(elementParms, elementXML, viewInfo))
            linearDimension_parallels_hide_non_parallel(
                elementParms, elementViewObject)
        d.viewScale = 1 / elementXML.rootNode().scaling()
    else:
        if isinstance(referer, selectionOverlay.PointSelectionGraphicsItem):
            d.selections.append(
                PointSelection(elementParms, elementXML, viewInfo))
            d.selections[-1].condensed_args = True
        else:
            d.selections.append(
                LineSelection(elementParms, elementXML, viewInfo))
        if len(d.selections) == 2:
            previewDimension.initializePreview(
                d, linearDimension_stack_preview,
                linearDimension_stack_clickHandler)
def selectFun(  event, referer, elementXML, elementParms, elementViewObject ):
    x,y = elementParms['x'], elementParms['y']
    dimensioning.center = [x, y]
    dimensioning.stage = 1
    dimensioning.dimScale = elementXML.rootNode().scaling()
    debugPrint(3, 'center selected at x=%3.1f y=%3.1f scale %3.1f' % (x,y, dimensioning.dimScale))
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
 def selectFun(self, event, referer, elementXML, elementParms, elementViewObject ):
     viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
     d.selections = [ PointSelection( elementParms, elementXML, viewInfo) ]
     selectionOverlay.hideSelectionGraphicsItems()
     previewDimension.initializePreview( 
         d, 
         self.preview_svgRenderer, 
         self.preview_clickHandler )
def selectFun(  event, referer, elementXML, elementParms, elementViewObject ):
    x,y = elementParms['x'], elementParms['y']
    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x,y))
    d.args = [x, y, elementParms['r']]
    d.viewScale = 1/elementXML.rootNode().scaling()
    d.stage = 1
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( d, radiusDimensionSVG_preview, radiusDimensionSVG_clickHandler)
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    x,y = elementParms['x'], elementParms['y']
    dimensioning.point1 = x, y
    debugPrint(2, 'note start point selected at x=%3.1f y=%3.1f' % (x,y))
    dimensioning.dimScale = 1/elementXML.rootNode().scaling() / UnitConversionFactor()
    dimensioning.stage = 1
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
 def selectFun(self, event, referer, elementXML, elementParms,
               elementViewObject):
     x, y = elementParms['x'], elementParms['y']
     d.dArgs = [x, y]
     d.stage = 1
     debugPrint(2, 'welding symbol to point at x=%3.1f y=%3.1f' % (x, y))
     selectionOverlay.hideSelectionGraphicsItems()
     previewDimension.initializePreview(d, self.preview_svgRenderer,
                                        self.preview_clickHandler)
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    x, y = elementParms['x'], elementParms['y']
    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x, y))
    d.args = [x, y, elementParms['r']]
    d.viewScale = 1 / elementXML.rootNode().scaling()
    d.stage = 1
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview(d, circularDimensionSVG_preview,
                                       circularDimensionSVG_clickHandler)
Exemple #17
0
def linearDimension_points_clickHandler( x, y ):
    d.selections.append( PlacementClick( x, y ) )
    if isinstance( d.selections[0], LineSelection ):
        selectionOverlay.hideSelectionGraphicsItems()
    if len(d.selections) == d.max_selections - 1 and d.dimensionConstructorKWs['autoPlaceText']:
        d.selections.append( PlacementClick( x, y ) ) #to avoid crash when autoPlaceText switched off
        return 'createDimension:%s' % findUnusedObjectName('dim')
    elif len(d.selections) == d.max_selections :
        return 'createDimension:%s' % findUnusedObjectName('dim')
def linearDimension_points_clickHandler( x, y ):
    d.selections.append( PlacementClick( x, y ) )
    if isinstance( d.selections[0], LineSelection ):
        selectionOverlay.hideSelectionGraphicsItems()
    if len(d.selections) == d.max_selections - 1 and d.dimensionConstructorKWs['autoPlaceText']:
        d.selections.append( PlacementClick( x, y ) ) #to avoid crash when autoPlaceText switched off
        return 'createDimension:%s' % findUnusedObjectName('dim')
    elif len(d.selections) == d.max_selections :
        return 'createDimension:%s' % findUnusedObjectName('dim')
def linearDimension_points_clickHandler( x, y ):
    d.args = d.args + [ x, y ]
    d.stage = d.stage + 1
    if d.stage == 3:
        if d.dimensionConstructorKWs['autoPlaceText']:
            return 'createDimension:%s' % findUnusedObjectName('dim')
        else:
            selectionOverlay.hideSelectionGraphicsItems() # for distance between parallels case
    elif d.stage == 4 :
        return 'createDimension:%s' % findUnusedObjectName('dim')
 def selectFun(self, event, referer, elementXML, elementParms, elementViewObject ):
     x,y = elementParms['x'], elementParms['y']
     dimensioning.dArgs = [x,y]
     dimensioning.stage = 1
     debugPrint(2, 'welding symbol to point at x=%3.1f y=%3.1f' % (x,y))
     selectionOverlay.hideSelectionGraphicsItems()
     previewDimension.initializePreview( 
         dimensioning.drawingVars, 
         self.clickFunPreview, 
         self.hoverFunPreview )
 def selectFun(self, event, referer, elementXML, elementParms,
               elementViewObject):
     x, y = elementParms['x'], elementParms['y']
     dimensioning.dArgs = [x, y]
     dimensioning.stage = 1
     debugPrint(2, 'welding symbol to point at x=%3.1f y=%3.1f' % (x, y))
     selectionOverlay.hideSelectionGraphicsItems()
     previewDimension.initializePreview(dimensioning.drawingVars,
                                        self.clickFunPreview,
                                        self.hoverFunPreview)
Exemple #22
0
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    x, y = elementParms['x'], elementParms['y']
    dimensioning.center = [x, y]
    dimensioning.stage = 1
    dimensioning.dimScale = elementXML.rootNode().scaling()
    debugPrint(
        3, 'center selected at x=%3.1f y=%3.1f scale %3.1f' %
        (x, y, dimensioning.dimScale))
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview(dimensioning.drawingVars,
                                       clickFunPreview, hoverFunPreview)
Exemple #23
0
def linearDimension_points_clickHandler(x, y):
    d.args = d.args + [x, y]
    d.stage = d.stage + 1
    if d.stage == 3:
        if d.dimensionConstructorKWs['autoPlaceText']:
            return 'createDimension:%s' % findUnusedObjectName('dim')
        else:
            selectionOverlay.hideSelectionGraphicsItems(
            )  # for distance between parallels case
    elif d.stage == 4:
        return 'createDimension:%s' % findUnusedObjectName('dim')
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    x, y = elementParms['x'], elementParms['y']
    dimensioning.point1 = x, y
    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x, y))
    dimensioning.radius = elementParms['r']
    dimensioning._dimScale = 1 / elementXML.rootNode().scaling()
    dimensioning.stage = 1
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview(dimensioning.drawingVars,
                                       clickFunPreview,
                                       hoverFunPreview,
                                       launchControlDialog=True)
def AddToleranceToText( event, referer, elementXML, elementParms, elementViewObject ):
    try :
        dimensioning.dimToEdit = elementViewObject  
        dimensioning.elementXML = elementXML
        selectionOverlay.hideSelectionGraphicsItems()
        svgText = SvgTextParser( elementXML.XML[elementXML.pStart:elementXML.pEnd] )
        dimensioning.svgText = svgText
        debugPrint(3,'svgText.width() %s' % svgText.width())
        debugPrint(3,'adding tolerance %s' % repr(elementViewObject.Name))
        dialog.show()
    except:
        errorMessagebox_with_traceback()
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
    debugPrint(2, str(dimensioning) )
    debugPrint(2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (dimensioning.stage, x1,y1,x2,y2) )
    referer.lockSelection()
    if dimensioning.stage == 0: #then select line1
        dimensioning.line1 = x1,y1,x2,y2
        dimensioning.stage = 1
    else: 
        dimensioning.line2 = x1,y1,x2,y2
        dimensioning.stage = 2
        selectionOverlay.hideSelectionGraphicsItems()
        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
def clickFunPreview( x, y ):
    if dimensioning.stage == 2 :
        dimensioning.point3 = x, y
        debugPrint(2, 'point3 set to x=%3.1f y=%3.1f' % (x,y))
        dimensioning.stage = 3
        selectionOverlay.hideSelectionGraphicsItems() # for distance between parallels case
        return None, None
    else:
        p1,p2,p3 = dimensioning.point1,  dimensioning.point2,  dimensioning.point3
        XML = halfLinearDimensionSVG( p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], 
                                  x, y, scale=dimensioning.dimScale, 
                                  **dimensioning.dimensionConstructorKWs)
        return findUnusedObjectName('dim'), XML
Exemple #28
0
def MoveDimensionText( event, referer, elementXML, elementParms, elementViewObject ):
    d.dimToEdit = elementViewObject    
    d.elementXML = elementXML
    debugPrint(2, 'moving %s' % elementViewObject.Name)
    if elementXML.parms.has_key('transform'):
        transform = elementXML.parms['transform']
        t = transform[ XMLlib.findOffset(transform,'rotate(',0): ]
        d.textRotation =  XMLlib.splitMultiSep(t, ', ')[0]
        debugPrint(3, 'd.textRotation %s' % d.textRotation)
    else:
        d.textRotation = None
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( d, moveTextSvg, placeText )
def MoveDimensionText( event, referer, elementXML, elementParms, elementViewObject ):
    d.dimToEdit = elementViewObject    
    d.elementXML = elementXML
    debugPrint(2, 'moving %s' % elementViewObject.Name)
    if elementXML.parms.has_key('transform'):
        transform = elementXML.parms['transform']
        t = transform[ XMLlib.findOffset(transform,'rotate(',0): ]
        d.textRotation =  XMLlib.splitMultiSep(t, ', ')[0]
        debugPrint(3, 'd.textRotation %s' % d.textRotation)
    else:
        d.textRotation = None
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( d, moveTextSvg, placeText )
def selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    x, y = elementParms['x'], elementParms['y']
    referer.lockSelection()
    if dimensioning.stage == 0: #then selectPoint1
        dimensioning.point1 =  x,y
        debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x,y))
        dimensioning.stage = 1
    else:
        dimensioning.point2 =  x,y
        debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x,y))
        dimensioning.stage = 2 
        dimensioning.dimScale = 1/elementXML.rootNode().scaling()
        selectionOverlay.hideSelectionGraphicsItems()
        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
def AddToleranceToText(event, referer, elementXML, elementParms,
                       elementViewObject):
    try:
        dimensioning.dimToEdit = elementViewObject
        dimensioning.elementXML = elementXML
        selectionOverlay.hideSelectionGraphicsItems()
        svgText = SvgTextParser(
            elementXML.XML[elementXML.pStart:elementXML.pEnd])
        dimensioning.svgText = svgText
        debugPrint(3, 'svgText.width() %s' % svgText.width())
        debugPrint(3, 'adding tolerance %s' % repr(elementViewObject.Name))
        dialog.show()
    except:
        errorMessagebox_with_traceback()
def selectDimensioningPoint(event, referer, elementXML, elementParms,
                            elementViewObject):
    crudeDebuggerPrint(
        '''linearDimension.py:9  	    x, y = elementParms['x'], elementParms['y'] '''
    )
    x, y = elementParms['x'], elementParms['y']
    crudeDebuggerPrint(
        '''linearDimension.py:10  	    referer.lockSelection() ''')
    referer.lockSelection()
    crudeDebuggerPrint(
        '''linearDimension.py:11  	    if dimensioning.stage == 0: #then selectPoint1 '''
    )
    if dimensioning.stage == 0:  #then selectPoint1
        crudeDebuggerPrint(
            '''linearDimension.py:12  	        dimensioning.point1 =  x,y ''')
        dimensioning.point1 = x, y
        crudeDebuggerPrint(
            '''linearDimension.py:13  	        debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x,y)) '''
        )
        debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x, y))
        crudeDebuggerPrint(
            '''linearDimension.py:14  	        dimensioning.stage = 1 ''')
        dimensioning.stage = 1
    else:
        crudeDebuggerPrint(
            '''linearDimension.py:16  	        dimensioning.point2 =  x,y ''')
        dimensioning.point2 = x, y
        crudeDebuggerPrint(
            '''linearDimension.py:17  	        debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x,y)) '''
        )
        debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x, y))
        crudeDebuggerPrint(
            '''linearDimension.py:18  	        dimensioning.stage = 2 ''')
        dimensioning.stage = 2
        crudeDebuggerPrint(
            '''linearDimension.py:19  	        dimensioning.dimScale = 1/elementXML.rootNode().scaling() '''
        )
        dimensioning.dimScale = 1 / elementXML.rootNode().scaling()
        crudeDebuggerPrint(
            '''linearDimension.py:20  	        selectionOverlay.hideSelectionGraphicsItems() '''
        )
        selectionOverlay.hideSelectionGraphicsItems()
        crudeDebuggerPrint(
            '''linearDimension.py:21  	        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview ) '''
        )
        previewDimension.initializePreview(dimensioning.drawingVars,
                                           clickFunPreview, hoverFunPreview)
def AddToleranceToText( event, referer, elementXML, elementParms, elementViewObject ):
    try :
        d.dimToEdit = elementViewObject  
        d.elementXML = elementXML
        selectionOverlay.hideSelectionGraphicsItems()
        svgText = SvgTextParser( elementXML.XML[elementXML.pStart:elementXML.pEnd] )
        d.svgText = svgText
        debugPrint(3,'svgText.width() %s' % svgText.width())
        debugPrint(3,'adding tolerance %s' % repr(elementViewObject.Name))
        d.textRenderer = SvgTextRenderer(
            font_family = svgText.font_family,
            fill = svgText.fill,
            font_size = svgText.font_size
            )
        previewDimension.initializePreview(d, toleranceAdd_preview, toleranceAdd_clickHandler)
    except:
        errorMessagebox_with_traceback()
def selectFun(  event, referer, elementXML, elementParms, elementViewObject ):
    crudeDebuggerPrint('''circularDimension.py:9  	    x,y = elementParms['x'], elementParms['y'] ''')
    x,y = elementParms['x'], elementParms['y']
    crudeDebuggerPrint('''circularDimension.py:10  	    dimensioning.point1 = x, y ''')
    dimensioning.point1 = x, y
    crudeDebuggerPrint('''circularDimension.py:11  	    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x,y)) ''')
    debugPrint(2, 'center selected at x=%3.1f y=%3.1f' % (x,y))
    crudeDebuggerPrint('''circularDimension.py:12  	    dimensioning.radius = elementParms['r'] ''')
    dimensioning.radius = elementParms['r']
    crudeDebuggerPrint('''circularDimension.py:13  	    dimensioning.dimScale = 1/elementXML.rootNode().scaling() ''')
    dimensioning.dimScale = 1/elementXML.rootNode().scaling()
    crudeDebuggerPrint('''circularDimension.py:14  	    dimensioning.stage = 1 ''')
    dimensioning.stage = 1
    crudeDebuggerPrint('''circularDimension.py:15  	    selectionOverlay.hideSelectionGraphicsItems() ''')
    selectionOverlay.hideSelectionGraphicsItems()
    crudeDebuggerPrint('''circularDimension.py:16  	    previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview ) ''')
    previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
def EditDimensionText( event, referer, elementXML, elementParms, elementViewObject ):
    dimensioning.dimToEdit = elementViewObject    
    dimensioning.elementXML = elementXML
    selectionOverlay.hideSelectionGraphicsItems()
    e = elementXML
    debugPrint(3, e.XML[e.pStart:e.pEnd] )
    svgText = SvgTextParser( e.XML[e.pStart:e.pEnd] )
    dimensioning.svgText = svgText
    debugPrint(3, u'editing %s' % unicode(svgText))
    widgets = dict( [c.objectName(), c] for c in dialog.children() )
    widgets['textLineEdit'].setText( svgText.text )
    widgets['sizeLineEdit'].setText( svgText.font_size)
    widgets['colorLineEdit'].setText( svgText.fill )
    widgets['familyLineEdit'].setText( svgText.font_family )
    widgets['placeButton'].setText('Change')
    dialog.setWindowTitle('Editing %s' % elementViewObject.Name)
    dialog.show()
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    referer.lockSelection()
    if isinstance(referer, selectionOverlay.LineSelectionGraphicsItem):
        x1, y1, x2, y2 = [elementParms[k] for k in ['x1', 'y1', 'x2', 'y2']]
        debugPrint(
            2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' %
            (dimensioning.stage, x1, y1, x2, y2))
        if dimensioning.stage == 0:  #then select line1
            dimensioning.line1 = x1, y1, x2, y2
            dimensioning.stage = 1
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi, selectionOverlay.PointSelectionGraphicsItem):
                    gi.hide()
        else:
            dimensioning.line2 = x1, y1, x2, y2
            dimensioning.stage = 2
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(dimensioning.drawingVars,
                                               clickFunPreview,
                                               hoverFunPreview)
    else:  #user selecting 3 points
        x, y = elementParms['x'], elementParms['y']
        debugPrint(
            2, 'point %i selected at x=%3.1f y=%3.1f' %
            (dimensioning.stage + 1, x, y))
        if dimensioning.stage == 0:
            dimensioning.pointStart = x, y
            dimensioning.stage = 1
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi, selectionOverlay.LineSelectionGraphicsItem):
                    gi.hide()
        elif dimensioning.stage == 1:
            dimensioning.pointCenter = x, y
            dimensioning.stage = 2
        else:
            x_c, y_c = dimensioning.pointCenter
            x1, y1 = dimensioning.pointStart
            x2, y2 = x, y
            dimensioning.line1 = x_c, y_c, x1, y1
            dimensioning.line2 = x_c, y_c, x2, y2
            dimensioning.stage = 2  #hack to allow intergation with dim from 2 line code
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(dimensioning.drawingVars,
                                               clickFunPreview,
                                               hoverFunPreview)
def lineSelected_hideSelectionGraphicsItems(elementParms, elementViewObject):
    x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
    d = numpy.array([ x2 - x1, y2 - y1] )
    d_ref = d / numpy.linalg.norm(d)
    p = numpy.array([ x1, y1] )
    def hideFun( gi ):
        if isinstance(gi,selectionOverlay.LineSelectionGraphicsItem):
            if gi.elementParms <> elementParms:
                x1,y1,x2,y2 = [ gi.elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
                d = numpy.array([ x2 - x1, y2 - y1] )
                d = d / numpy.linalg.norm(d)
                if abs(numpy.dot(d_ref,d)) > 1.0 - 10**-9: #then parallel
                    d_rotated = rotate2D(d, numpy.pi/2)
                    offset =  numpy.array([ x1, y1] ) - p
                    if abs(numpy.dot(d_rotated, offset)) > 10**-6: #then not colinear
                        return False
        return True
    selectionOverlay.hideSelectionGraphicsItems(hideFun)
Exemple #38
0
def AddToleranceToText(event, referer, elementXML, elementParms,
                       elementViewObject):
    try:
        d.dimToEdit = elementViewObject
        d.elementXML = elementXML
        selectionOverlay.hideSelectionGraphicsItems()
        svgText = SvgTextParser(
            elementXML.XML[elementXML.pStart:elementXML.pEnd])
        d.svgText = svgText
        debugPrint(3, 'svgText.width() %s' % svgText.width())
        debugPrint(3, 'adding tolerance %s' % repr(elementViewObject.Name))
        d.textRenderer = SvgTextRenderer(font_family=svgText.font_family,
                                         fill=svgText.fill,
                                         font_size=svgText.font_size)
        previewDimension.initializePreview(d, toleranceAdd_preview,
                                           toleranceAdd_clickHandler)
    except:
        errorMessagebox_with_traceback()
Exemple #39
0
def EditDimensionText(event, referer, elementXML, elementParms,
                      elementViewObject):
    dimensioning.dimToEdit = elementViewObject
    dimensioning.elementXML = elementXML
    selectionOverlay.hideSelectionGraphicsItems()
    e = elementXML
    debugPrint(3, e.XML[e.pStart:e.pEnd])
    svgText = SvgTextParser(e.XML[e.pStart:e.pEnd])
    dimensioning.svgText = svgText
    debugPrint(3, u'editing %s' % unicode(svgText))
    widgets = dict([c.objectName(), c] for c in dialog.children())
    widgets['textLineEdit'].setText(svgText.text)
    widgets['sizeLineEdit'].setText(svgText.font_size)
    widgets['colorLineEdit'].setText(svgText.fill)
    widgets['familyLineEdit'].setText(svgText.font_family)
    widgets['placeButton'].setText('Change')
    dialog.setWindowTitle('Editing %s' % elementViewObject.Name)
    dialog.show()
def selectFun(event, referer, elementXML, elementParms, elementViewObject):
    crudeDebuggerPrint(
        '''angularDimension.py:9  	    x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ] '''
    )
    x1, y1, x2, y2 = [elementParms[k] for k in ['x1', 'y1', 'x2', 'y2']]
    crudeDebuggerPrint(
        '''angularDimension.py:10  	    debugPrint(2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (dimensioning.stage, x1,y1,x2,y2) ) '''
    )
    debugPrint(
        2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' %
        (dimensioning.stage, x1, y1, x2, y2))
    crudeDebuggerPrint(
        '''angularDimension.py:11  	    referer.lockSelection() ''')
    referer.lockSelection()
    crudeDebuggerPrint(
        '''angularDimension.py:12  	    if dimensioning.stage == 0: #then select line1 '''
    )
    if dimensioning.stage == 0:  #then select line1
        crudeDebuggerPrint(
            '''angularDimension.py:13  	        dimensioning.line1 = x1,y1,x2,y2 '''
        )
        dimensioning.line1 = x1, y1, x2, y2
        crudeDebuggerPrint(
            '''angularDimension.py:14  	        dimensioning.stage = 1 ''')
        dimensioning.stage = 1
    else:
        crudeDebuggerPrint(
            '''angularDimension.py:16  	        dimensioning.line2 = x1,y1,x2,y2 '''
        )
        dimensioning.line2 = x1, y1, x2, y2
        crudeDebuggerPrint(
            '''angularDimension.py:17  	        dimensioning.stage = 2 ''')
        dimensioning.stage = 2
        crudeDebuggerPrint(
            '''angularDimension.py:18  	        selectionOverlay.hideSelectionGraphicsItems() '''
        )
        selectionOverlay.hideSelectionGraphicsItems()
        crudeDebuggerPrint(
            '''angularDimension.py:19  	        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview ) '''
        )
        previewDimension.initializePreview(dimensioning.drawingVars,
                                           clickFunPreview, hoverFunPreview)
def stack_selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    if d.stage == 0:
        if isinstance(referer,selectionOverlay.PointSelectionGraphicsItem):
            d.reference_type = 'point'
            d.selections = [[elementParms['x'], elementParms['y']]]
            selectionOverlay.hideSelectionGraphicsItems(
                lambda gi: isinstance(gi,  selectionOverlay.LineSelectionGraphicsItem)
                )
        else:
            d.reference_type = 'line'
            d.selections = [[ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]]
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
        d.stage = 1
        d.viewScale = 1 / elementXML.rootNode().scaling()
    else:
        if isinstance(referer,selectionOverlay.PointSelectionGraphicsItem):
            d.selections.append( [elementParms['x'], elementParms['y']] )
        else:
            d.selections.append( [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ] )
        if len(d.selections) == 2:
            previewDimension.initializePreview( d, linearDimension_stack_preview, linearDimension_stack_clickHandler )
def stack_selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    if len(d.selections) == 0:
        if isinstance(referer, selectionOverlay.PointSelectionGraphicsItem):
            d.selections.append( PointSelection( elementParms, elementXML, viewInfo ) )
            d.selections[-1].condensed_args = True
            selectionOverlay.hideSelectionGraphicsItems(
                lambda gi: isinstance(gi, selectionOverlay.LineSelectionGraphicsItem)
                )
        else:
            d.selections.append( LineSelection( elementParms, elementXML, viewInfo ) )
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
        d.viewScale = 1 / elementXML.rootNode().scaling()
    else:
        if isinstance(referer, selectionOverlay.PointSelectionGraphicsItem):
            d.selections.append( PointSelection( elementParms, elementXML, viewInfo ) )
            d.selections[-1].condensed_args = True
        else:
            d.selections.append( LineSelection( elementParms, elementXML, viewInfo ) )
        if len(d.selections) == 2:
            previewDimension.initializePreview(d, linearDimension_stack_preview, linearDimension_stack_clickHandler)
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    crudeDebuggerPrint('''angularDimension.py:9  	    x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ] ''')
    x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
    crudeDebuggerPrint('''angularDimension.py:10  	    debugPrint(2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (dimensioning.stage, x1,y1,x2,y2) ) ''')
    debugPrint(2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (dimensioning.stage, x1,y1,x2,y2) )
    crudeDebuggerPrint('''angularDimension.py:11  	    referer.lockSelection() ''')
    referer.lockSelection()
    crudeDebuggerPrint('''angularDimension.py:12  	    if dimensioning.stage == 0: #then select line1 ''')
    if dimensioning.stage == 0: #then select line1
        crudeDebuggerPrint('''angularDimension.py:13  	        dimensioning.line1 = x1,y1,x2,y2 ''')
        dimensioning.line1 = x1,y1,x2,y2
        crudeDebuggerPrint('''angularDimension.py:14  	        dimensioning.stage = 1 ''')
        dimensioning.stage = 1
    else: 
        crudeDebuggerPrint('''angularDimension.py:16  	        dimensioning.line2 = x1,y1,x2,y2 ''')
        dimensioning.line2 = x1,y1,x2,y2
        crudeDebuggerPrint('''angularDimension.py:17  	        dimensioning.stage = 2 ''')
        dimensioning.stage = 2
        crudeDebuggerPrint('''angularDimension.py:18  	        selectionOverlay.hideSelectionGraphicsItems() ''')
        selectionOverlay.hideSelectionGraphicsItems()
        crudeDebuggerPrint('''angularDimension.py:19  	        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview ) ''')
        previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
Exemple #44
0
def selectFun(  event, referer, elementXML, elementParms, elementViewObject ):
    if not isinstance(referer,selectionOverlay.LineSelectionGraphicsItem):
        x,y = elementParms['x'], elementParms['y']
        d.args = [[x, y]]
        d.stage = 1
        d.dimScale = elementXML.rootNode().scaling()
        debugPrint(3, 'center selected at x=%3.1f y=%3.1f scale %3.1f' % (x,y, d.dimScale))
        selectionOverlay.hideSelectionGraphicsItems()
        previewDimension.initializePreview( d, centerLine_preview , centerLine_clickHandler)
    else:
        if d.stage == 0:
            d.line1 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
            d.stage = 1
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
        else:
            x1, y1, x2, y2 = d.line1
            x3, y3, x4, y4 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
            d.args = [[0.25*(x1 + x2 + x3 + x4), 0.25*(y1 + y2 + y3 + y4)]]
            d.stage = 1
            d.dimScale = elementXML.rootNode().scaling()
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview( d, centerLine_preview , centerLine_clickHandler)
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    referer.lockSelection()
    if isinstance(referer, selectionOverlay.LineSelectionGraphicsItem):
        x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
        debugPrint(2, 'selecting line %i with x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (dimensioning.stage, x1,y1,x2,y2) )
        if dimensioning.stage == 0: #then select line1
            dimensioning.line1 = x1,y1,x2,y2
            dimensioning.stage = 1
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi,  selectionOverlay.PointSelectionGraphicsItem):
                    gi.hide()
        else: 
            dimensioning.line2 = x1,y1,x2,y2
            dimensioning.stage = 2
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
    else: #user selecting 3 points
        x, y = elementParms['x'], elementParms['y']
        debugPrint(2, 'point %i selected at x=%3.1f y=%3.1f' %(dimensioning.stage +1,x,y))
        if dimensioning.stage == 0: 
            dimensioning.pointStart = x,y
            dimensioning.stage = 1
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi,  selectionOverlay.LineSelectionGraphicsItem):
                    gi.hide()
        elif dimensioning.stage == 1:
            dimensioning.pointCenter = x,y
            dimensioning.stage = 2
        else: 
            x_c, y_c = dimensioning.pointCenter
            x1, y1 = dimensioning.pointStart
            x2, y2 = x,y
            dimensioning.line1 = x_c, y_c, x1, y1
            dimensioning.line2 = x_c, y_c, x2, y2
            dimensioning.stage = 2 #hack to allow intergation with dim from 2 line code
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
Exemple #46
0
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    referer.lockSelection()
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    if isinstance(referer, selectionOverlay.LineSelectionGraphicsItem):
        d.selections.append( LineSelection( elementParms, elementXML, viewInfo) )
        if len(d.selections) == 1:
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi, selectionOverlay.PointSelectionGraphicsItem):
                    gi.hide()
        else: 
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(d, angularDimension_points_preview, angularDimension_points_clickHandler)
    else: #user selecting 3 points
        if len(d.selections) == 0: 
            d.selections = [ThreePointAngleSelection()]
            d.max_selections = 3
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi, selectionOverlay.LineSelectionGraphicsItem):
                    gi.hide()
        d.selections[0].addPoint( elementParms, elementXML, viewInfo )
        if len(d.selections[0].points) == 3: 
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(d, angularDimension_points_preview, angularDimension_points_clickHandler)
def selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    referer.lockSelection()
    d.viewScale = 1 / elementXML.rootNode().scaling()
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    if isinstance(referer,selectionOverlay.PointSelectionGraphicsItem) :
        if len( d.selections) == 0:
            d.selections.append( PointSelection( elementParms, elementXML, viewInfo ) )
            selectionOverlay.hideSelectionGraphicsItems(
                lambda gi: isinstance(gi,  selectionOverlay.LineSelectionGraphicsItem)
                )
        elif isinstance( d.selections[0], PointSelection ):
            d.selections.append( PointSelection( elementParms, elementXML, viewInfo ) )
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            d.proxy_svgFun = linearDimensionSVG_points
            previewDimension.initializePreview( d, linearDimension_points_preview, linearDimension_points_clickHandler )
        else : #first selection was a line
            d.selections[0].condensed_args = True
            d.selections.append( PointLinePertubationSelection( elementParms, elementXML, viewInfo, d.selections[0] ) )
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            d.proxy_svgFun = linearDimensionSVG_parallels
            previewDimension.removePreviewGraphicItems( False, closeDialog=False ) #required since previewDimension.initializePreview called when line selected
            previewDimension.initializePreview( d, linearDimension_parallels_preview, linearDimension_parallels_clickHandler )
    else: #then line slected
        if len( d.selections ) == 0: 
            d.selections.append( LineSelection( elementParms, elementXML, viewInfo) )
            d.selections[0].condensed_args = False
            d.max_selections = 3
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
            d.proxy_svgFun = linearDimensionSVG_points
            previewDimension.initializePreview( d, linearDimension_points_preview, linearDimension_points_clickHandler )
        else:
            d.selections[0].condensed_args = True
            d.selections.append( LineSelection( elementParms, elementXML, viewInfo) )
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            d.proxy_svgFun = linearDimensionSVG_parallels
            previewDimension.removePreviewGraphicItems( False, closeDialog=False )
            previewDimension.initializePreview( d, linearDimension_parallels_preview, linearDimension_parallels_clickHandler )
Exemple #48
0
def selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    referer.lockSelection()
    d.viewScale = 1 / elementXML.rootNode().scaling()
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    if isinstance(referer, selectionOverlay.PointSelectionGraphicsItem) :
        if len( d.selections) == 0:
            d.selections.append( PointSelection( elementParms, elementXML, viewInfo ) )
            selectionOverlay.hideSelectionGraphicsItems(
                lambda gi: isinstance(gi, selectionOverlay.LineSelectionGraphicsItem)
                )
        elif isinstance( d.selections[0], PointSelection ):
            d.selections.append( PointSelection( elementParms, elementXML, viewInfo ) )
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            d.proxy_svgFun = linearDimensionSVG_points
            previewDimension.initializePreview(d, linearDimension_points_preview, linearDimension_points_clickHandler)
        else : #first selection was a line
            d.selections[0].condensed_args = True
            d.selections.append( PointLinePertubationSelection( elementParms, elementXML, viewInfo, d.selections[0] ) )
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            d.proxy_svgFun = linearDimensionSVG_parallels
            previewDimension.removePreviewGraphicItems(False, closeDialog=False) #required since previewDimension.initializePreview called when line selected
            previewDimension.initializePreview(d, linearDimension_parallels_preview, linearDimension_parallels_clickHandler)
    else: #then line slected
        if len( d.selections ) == 0: 
            d.selections.append( LineSelection( elementParms, elementXML, viewInfo) )
            d.selections[0].condensed_args = False
            d.max_selections = 3
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
            d.proxy_svgFun = linearDimensionSVG_points
            previewDimension.initializePreview(d, linearDimension_points_preview, linearDimension_points_clickHandler)
        else:
            d.selections[0].condensed_args = True
            d.selections.append( LineSelection( elementParms, elementXML, viewInfo) )
            d.max_selections = 4
            selectionOverlay.hideSelectionGraphicsItems()
            d.proxy_svgFun = linearDimensionSVG_parallels
            previewDimension.removePreviewGraphicItems(False, closeDialog=False)
            previewDimension.initializePreview(d, linearDimension_parallels_preview, linearDimension_parallels_clickHandler)
def selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    if isinstance(referer,selectionOverlay.PointSelectionGraphicsItem) and d.stage < 2:
        x, y = elementParms['x'], elementParms['y']
        referer.lockSelection()
        if d.stage == 0: #then selectPoint1
            d.args =  [x,y]
            debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x,y))
            d.stage = 1
            selectionOverlay.hideSelectionGraphicsItems(
                lambda gi: isinstance(gi,  selectionOverlay.LineSelectionGraphicsItem)
                )
        else:
            d.args = d.args + [x,y]
            debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x,y))
            d.stage = 2 
            d.viewScale = 1 / elementXML.rootNode().scaling()
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview( d, linearDimension_points_preview, linearDimension_points_clickHandler )
    else:#then line
        if d.stage == 0: 
            x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
            debugPrint(2,'selecting line x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (x1,y1,x2,y2))
            d.args = [ x1,y1,x2,y2 ]
            d.stage = 2 
            d.viewScale = 1 / elementXML.rootNode().scaling()
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
            previewDimension.initializePreview( d, linearDimension_points_preview, linearDimension_points_clickHandler )
        else:
            if isinstance(referer, selectionOverlay.LineSelectionGraphicsItem): #then distance between parallels
                x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
                debugPrint(2,'distance between parallels, line2 x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (x1,y1,x2,y2))
                line1 = d.args
                d.args = [ line1, [ x1,y1,x2,y2 ] ]
            else: #distance between line and point
                line1 = d.args
                x1,y1,x2,y2 = line1
                dx = (x2-x1)*10**-6
                dy = (y2-y1)*10**-6
                debugPrint(3,'distance between line and point, dx %e dy %e' % (dx,dy))
                x, y =  elementParms['x'], elementParms['y']
                d.args = [ line1, [ x-dx,y-dy,x+dx,y+dy ] ]
            d.stage = 2 
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.removePreviewGraphicItems( False, closeDialog=False )
            previewDimension.initializePreview( d, linearDimension_parallels_preview, linearDimension_parallels_clickHandler )
def selectFun(  event, referer, elementXML, elementParms, elementViewObject ):
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    d.viewScale = elementXML.rootNode().scaling()
    # center line
    if isinstance(referer,selectionOverlay.PointSelectionGraphicsItem):
        d.selections = [ PointSelection( elementParms, elementXML, viewInfo, condensed_args=True ) ]
        selectionOverlay.hideSelectionGraphicsItems()
        previewDimension.initializePreview( d, centerLine_preview , centerLine_clickHandler)
    elif isinstance(referer,selectionOverlay.LineSelectionGraphicsItem):
        if len(d.selections) == 0:
            d.selections = [ TwoLineSelection() ]
            linearDimension_parallels_hide_non_parallel( elementParms, elementViewObject)
            for gi in selectionOverlay.graphicItems:
                if isinstance(gi,  selectionOverlay.PointSelectionGraphicsItem):
                    gi.hide()
        d.selections[0].addLine(  elementParms, elementXML, viewInfo )
        if len(d.selections[0].lines) == 2:
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview( d, centerLine_preview , centerLine_clickHandler)
    else: #centerlines selection overlay
        d.selections = [ CircularArcSelection( elementParms, elementXML, viewInfo, output_mode = 'xy' ) ]
        selectionOverlay.hideSelectionGraphicsItems()
        previewDimension.initializePreview( d, centerLine_preview , centerLine_clickHandler)
def selectDimensioningPoint( event, referer, elementXML, elementParms, elementViewObject ):
    if isinstance(referer,selectionOverlay.PointSelectionGraphicsItem):
        x, y = elementParms['x'], elementParms['y']
        referer.lockSelection()
        if dimensioning.stage == 0: #then selectPoint1
            dimensioning.point1 =  x,y
            debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x,y))
            dimensioning.stage = 1
            selectionOverlay.hideSelectionGraphicsItems(
                lambda gi: isinstance(gi,  selectionOverlay.LineSelectionGraphicsItem)
                )
        else:
            dimensioning.point2 =  x,y
            debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x,y))
            dimensioning.stage = 2 
            dimensioning.dimScale = 1 / elementXML.rootNode().scaling() / UnitConversionFactor()
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
    else:#then line
        if dimensioning.stage == 0: 
            x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
            debugPrint(2,'selecting line x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (x1,y1,x2,y2))
            dimensioning.point1 =  x1,y1
            dimensioning.point2 =  x2,y2
            dimensioning.stage = 2 
            dimensioning.dimScale = 1 / elementXML.rootNode().scaling() / UnitConversionFactor()
            lineSelected_hideSelectionGraphicsItems(elementParms, elementViewObject)
            previewDimension.initializePreview( dimensioning.drawingVars, clickFunPreview, hoverFunPreview )
        else: #then distance between parallels
            x1,y1,x2,y2 = [ elementParms[k] for k in [ 'x1', 'y1', 'x2', 'y2' ] ]
            debugPrint(2,'distance between parallels, line2 x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' % (x1,y1,x2,y2))
            dimensioning.line1 =  list(dimensioning.point1) + list(dimensioning.point2)
            dimensioning.line2 =  [ x1,y1,x2,y2 ]
            debugPrint(3,'dim scale %f' % dimensioning.dimScale)
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.removePreviewGraphicItems( False )
            previewDimension.initializePreview( dimensioning.drawingVars, distanceParallels_clickFunPreview, distanceParallels_hoverFunPreview )
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    x,y = elementParms['x'], elementParms['y']
    d.args = [x,y]
    d.stage = 1
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( d, noteCircle_preview, noteCircle_clickHandler)
Exemple #53
0
def selectFun( event, referer, elementXML, elementParms, elementViewObject ):
    x,y = elementParms['x'], elementParms['y']
    d.args = [x,y]
    d.stage = 1
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( d, noteCircle_preview, noteCircle_clickHandler)
Exemple #54
0
def selectDimensioningPoint(event, referer, elementXML, elementParms,
                            elementViewObject):
    if isinstance(referer,
                  selectionOverlay.PointSelectionGraphicsItem) and d.stage < 2:
        x, y = elementParms['x'], elementParms['y']
        referer.lockSelection()
        if d.stage == 0:  #then selectPoint1
            d.args = [x, y]
            debugPrint(2, 'point1 set to x=%3.1f y=%3.1f' % (x, y))
            d.stage = 1
            selectionOverlay.hideSelectionGraphicsItems(lambda gi: isinstance(
                gi, selectionOverlay.LineSelectionGraphicsItem))
        else:
            d.args = d.args + [x, y]
            debugPrint(2, 'point2 set to x=%3.1f y=%3.1f' % (x, y))
            d.stage = 2
            d.viewScale = 1 / elementXML.rootNode().scaling()
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.initializePreview(
                d, linearDimension_points_preview,
                linearDimension_points_clickHandler)
    else:  #then line
        if d.stage == 0:
            x1, y1, x2, y2 = [
                elementParms[k] for k in ['x1', 'y1', 'x2', 'y2']
            ]
            debugPrint(
                2, 'selecting line x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f' %
                (x1, y1, x2, y2))
            d.args = [x1, y1, x2, y2]
            d.stage = 2
            d.viewScale = 1 / elementXML.rootNode().scaling()
            linearDimension_parallels_hide_non_parallel(
                elementParms, elementViewObject)
            previewDimension.initializePreview(
                d, linearDimension_points_preview,
                linearDimension_points_clickHandler)
        else:
            if isinstance(referer, selectionOverlay.LineSelectionGraphicsItem
                          ):  #then distance between parallels
                x1, y1, x2, y2 = [
                    elementParms[k] for k in ['x1', 'y1', 'x2', 'y2']
                ]
                debugPrint(
                    2,
                    'distance between parallels, line2 x1=%3.1f y1=%3.1f, x2=%3.1f y2=%3.1f'
                    % (x1, y1, x2, y2))
                line1 = d.args
                d.args = [line1, [x1, y1, x2, y2]]
            else:  #distance between line and point
                line1 = d.args
                x1, y1, x2, y2 = line1
                dx = (x2 - x1) * 10**-6
                dy = (y2 - y1) * 10**-6
                debugPrint(
                    3,
                    'distance between line and point, dx %e dy %e' % (dx, dy))
                x, y = elementParms['x'], elementParms['y']
                d.args = [line1, [x - dx, y - dy, x + dx, y + dy]]
            d.stage = 2
            selectionOverlay.hideSelectionGraphicsItems()
            previewDimension.removePreviewGraphicItems(False,
                                                       closeDialog=False)
            previewDimension.initializePreview(
                d, linearDimension_parallels_preview,
                linearDimension_parallels_clickHandler)
Exemple #55
0
def selectFun(  event, referer, elementXML, elementParms, elementViewObject ):
    viewInfo = selectionOverlay.DrawingsViews_info[elementViewObject.Name]
    d.viewScale = 1/elementXML.rootNode().scaling()
    d.selections.append( CircularArcSelection( elementParms, elementXML, viewInfo ) )
    selectionOverlay.hideSelectionGraphicsItems()
    previewDimension.initializePreview( d, radiusDimensionSVG_preview, radiusDimensionSVG_clickHandler)