예제 #1
0
 def reject(self): #close button
     import previewDimension
     if hasattr(previewDimension.preview, 'drawingVars'):
         previewDimension.removePreviewGraphicItems( recomputeActiveDocument = True )
     else:
         recomputeWithOutViewReset(self.dimensiongProcess.drawingVars )
         FreeCADGui.Control.closeDialog()
예제 #2
0
 def reject(self): #close button
     import previewDimension
     if hasattr(previewDimension.preview, 'drawingVars'):
         previewDimension.removePreviewGraphicItems(recomputeActiveDocument = True)
     else:
         recomputeWithOutViewReset(self.dimensiongProcess.drawingVars )
         FreeCADGui.Control.closeDialog()
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 )
예제 #4
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 ):
    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):
        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 )
예제 #7
0
 def reject(self):
     previewDimension.removePreviewGraphicItems( recomputeActiveDocument = True )
     FreeCADGui.Control.closeDialog()
 def reject(self):
     previewDimension.removePreviewGraphicItems( recomputeActiveDocument = True )
     FreeCADGui.Control.closeDialog()
예제 #9
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)