Exemplo n.º 1
0
 def _viewer(self):
     if self.doc is None:
         gdoc = Gui.editDocument()
     else:
         gdoc = Gui.getDocument(self.doc.Name)
     v = gdoc.activeView()
     if not hasattr(v, 'toggleClippingPlane'):
         v = gdoc.mdiViewsOfType('Gui::View3DInventor')[0]
     return v
Exemplo n.º 2
0
 def onRollback(cls):
     doc = FreeCADGui.editDocument()
     if not doc:
         return
     vobj = doc.getInEdit()
     if vobj and isTypeOf(vobj, ViewProviderAssembly):
         movingPart = getattr(vobj.Proxy, '_movingPart', None)
         if movingPart:
             vobj.Object.recompute(True)
             movingPart.tracePoint = movingPart.TracePosition
Exemplo n.º 3
0
def quickMove():
    ret = logger.catch('exception when moving part', getMovingElementInfo)
    if not ret:
        return False
    doc = FreeCADGui.editDocument()
    if doc:
        doc.resetEdit()
    FreeCADGui.Selection.clearSelection()
    FreeCADGui.Selection.addSelection(ret.SelObj, ret.SelSubname)
    AsmDocumentObserver.quickMove(ret)
Exemplo n.º 4
0
def movePart(useCenterballDragger=None):
    ret = logger.catch('exception when moving part', getMovingElementInfo)
    if not ret:
        return False

    info = ret.ElementInfo
    doc = FreeCADGui.editDocument()
    if doc:
        doc.resetEdit()
    vobj = resolveAssembly(info.Parent).Object.ViewObject
    doc = info.Parent.ViewObject.Document
    if useCenterballDragger is not None:
        vobj.UseCenterballDragger = useCenterballDragger
    vobj.Proxy._movingPart = AsmMovingPart(ret.Hierarchy, info)
    FreeCADGui.Selection.clearSelection()
    return doc.setEdit(vobj, 1)
Exemplo n.º 5
0
    def sketchClipPlane(self, sketch, enable=None):
        '''sketchClipPlane(sketch, enable = None): Clips all objects by plane of sketch. 
        If enable argument is omitted, calling the routine repeatedly will toggle clipping plane.'''

        from .SceneDetails.ClipPlane import ClipPlane

        editDoc = Gui.editDocument()
        if editDoc is None:
            doc = sketch.Document
            pla = sketch.getGlobalPlacement()
        else:
            doc = editDoc.Document
            pla = App.Placement(editDoc.EditingTransform)
        toggle = {False: 0, True: 1, None: -1}[enable]

        self.modify(ClipPlane(doc, toggle, pla, 0.02))
Exemplo n.º 6
0
def movePart(useCenterballDragger=None, moveInfo=None):
    if not moveInfo:
        moveInfo = logger.catch('exception when moving part',
                                getMovingElementInfo)
        if not moveInfo:
            return False
    info = moveInfo.ElementInfo
    doc = FreeCADGui.editDocument()
    if doc:
        doc.resetEdit()
    vobj = resolveAssembly(info.Parent).Object.ViewObject
    vobj.Proxy._movingPart = AsmMovingPart(moveInfo.HierarchyList, info)
    if useCenterballDragger is not None:
        vobj.UseCenterballDragger = useCenterballDragger
    FreeCADGui.Selection.clearSelection()

    subname = moveInfo.SelSubname[:-len(info.SubnameRef)]
    topVObj = moveInfo.SelObj.ViewObject
    mode = 1 if info.Parent == vobj.Object else 0x8001
    return topVObj.Document.setEdit(topVObj, mode, subname)
Exemplo n.º 7
0
    def sketchClipPlane(self, sketch, enable = None):
        """sketchClipPlane(sketch, enable = None): Clips all objects by plane of sketch. 
        If enable argument is omitted, calling the routine repeatedly will toggle clipping plane."""
        
        editDoc = self.clippingDoc
        if not editDoc:
            editDoc = Gui.editDocument()
        if editDoc:
            self.clippingDoc = editDoc
            toggle = 1 if enable else -1 if enable is None else 0
            editDoc.ActiveView.toggleClippingPlane(
                    toggle, pla=App.Placement(editDoc.EditingTransform))
            return
        elif not sketch:
            return

        if enable is None:
            enable = not self.sketch_clipplane_on
            self.sketch_clipplane_on = enable
        self.clipPlane(self.allVisibleObjects(sketch), enable, sketch.getGlobalPlacement(), 0.02)
Exemplo n.º 8
0
 def TracePosition(self):
     pos = gui.AsmCmdTrace.getPosition()
     if pos:
         return pos
     mat = FreeCADGui.editDocument().EditingTransform
     return mat.multiply(self.draggerPlacement.Base)