Пример #1
0
 def __init__(self,winTitle='Rotate WP', icon='rotWP.svg'):
   super(rotWPForm,self).__init__()
   self.move(QPoint(100,250))
   self.setWindowFlags(Qt.WindowStaysOnTopHint)
   self.setWindowTitle(winTitle)
   iconPath=join(dirname(abspath(__file__)),"icons",icon)
   from PySide.QtGui import QIcon
   Icon=QIcon()
   Icon.addFile(iconPath)
   self.setWindowIcon(Icon) 
   self.grid=QGridLayout()
   self.setLayout(self.grid)
   self.radioX=QRadioButton('X')
   self.radioX.setChecked(True)
   self.radioY=QRadioButton('Y')
   self.radioZ=QRadioButton('Z')
   self.lab1=QLabel('Angle:')
   self.edit1=QLineEdit('45')
   self.edit1.setAlignment(Qt.AlignCenter)
   self.edit1.setValidator(QDoubleValidator())
   self.btn1=QPushButton('Rotate working plane')
   self.btn1.clicked.connect(self.rotate)
   self.grid.addWidget(self.radioX,0,0,1,1,Qt.AlignCenter)
   self.grid.addWidget(self.radioY,0,1,1,1,Qt.AlignCenter)
   self.grid.addWidget(self.radioZ,0,2,1,1,Qt.AlignCenter)
   self.grid.addWidget(self.lab1,1,0,1,1)
   self.grid.addWidget(self.edit1,1,1,1,2)
   self.grid.addWidget(self.btn1,2,0,1,3,Qt.AlignCenter)
   self.show()
   self.sg=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
   s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize")
   sc=[float(x*s) for x in [1,1,.2]]
   from polarUtilsCmd import arrow
   self.arrow =arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s)
Пример #2
0
 def selectAction(self):
     edged = [
         objex for objex in FreeCADGui.Selection.getSelectionEx()
         if frameCmd.edges([objex])
     ]
     if edged:
         self.Axis = frameCmd.edges([edged[0]])[0]
         self.deleteArrow()
         from polarUtilsCmd import arrow
         where = FreeCAD.Placement()
         where.Base = self.Axis.valueAt(self.Axis.LastParameter)
         where.Rotation = FreeCAD.Rotation(
             FreeCAD.Vector(0, 0, 1),
             self.Axis.tangentAt(self.Axis.LastParameter))
         size = [
             self.Axis.Length / 20.0, self.Axis.Length / 10.0,
             self.Axis.Length / 20.0
         ]
         self.arrow = arrow(pl=where,
                            scale=size,
                            offset=self.Axis.Length / 10.0)
         if self.Axis.curvatureAt(0):
             O = self.Axis.centerOfCurvatureAt(0)
             n = self.Axis.tangentAt(0).cross(self.Axis.normalAt(0))
             from Part import Edge, Line
             self.Axis = (Edge(
                 Line(FreeCAD.Vector(O), FreeCAD.Vector(O + n))))
         self.form.lab1.setText(edged[0].Object.Label + ": edge")
Пример #3
0
 def Activated(self):
   if hasattr(FreeCAD,'DraftWorkingPlane') and hasattr(FreeCADGui,'Snapper'):
     import polarUtilsCmd
     s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize")
     sc=[float(x*s) for x in [1,1,.2]]
     arrow =polarUtilsCmd.arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s)
     from PySide.QtGui import QInputDialog as qid
     offset=qid.getInteger(None,'Offset Work Plane','Offset: ')
     if offset[1]:
       polarUtilsCmd.offsetWP(offset[0])
     #FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().removeChild(arrow.node)
     arrow.closeArrow()
Пример #4
0
 def selectAction(self):
   edged = [objex for objex in FreeCADGui.Selection.getSelectionEx() if frameCmd.edges([objex])]
   if edged:
     self.Axis=frameCmd.edges([edged[0]])[0]
     self.deleteArrow()
     from polarUtilsCmd import arrow
     where=FreeCAD.Placement()
     where.Base=self.Axis.valueAt(self.Axis.LastParameter)
     where.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),self.Axis.tangentAt(self.Axis.LastParameter))
     size=[self.Axis.Length/20.0,self.Axis.Length/10.0,self.Axis.Length/20.0]
     self.arrow=arrow(pl=where,scale=size,offset=self.Axis.Length/10.0)
     if self.Axis.curvatureAt(0):
       O=self.Axis.centerOfCurvatureAt(0)
       n=self.Axis.tangentAt(0).cross(self.Axis.normalAt(0))
       from Part import Edge, Line
       self.Axis=(Edge(Line(FreeCAD.Vector(O),FreeCAD.Vector(O+n))))
     self.form.lab1.setText(edged[0].Object.Label+": edge")
Пример #5
0
 def getLength(self):
   roundDigits=3
   if len(frameCmd.edges())>0:
     edge=frameCmd.edges()[0]
     self.form.edit4.setText(str(edge.Length))
     self.form.edit5.setText('1')
     dx,dy,dz=list(edge.tangentAt(0))
     self.form.edit1.setText(str(round(dx,roundDigits)))
     self.form.edit2.setText(str(round(dy,roundDigits)))
     self.form.edit3.setText(str(round(dz,roundDigits)))
     FreeCADGui.Selection.clearSelection()
     self.deleteArrow()
     from polarUtilsCmd import arrow
     where=FreeCAD.Placement()
     where.Base=edge.valueAt(0)
     where.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),edge.tangentAt(0))
     size=[edge.Length/20.0,edge.Length/10.0,edge.Length/20.0]
     self.arrow=arrow(pl=where,scale=size,offset=edge.Length/2.0)
Пример #6
0
 def getLength(self):
   roundDigits=3
   if len(frameCmd.edges())>0:
     edge=frameCmd.edges()[0]
     self.form.edit4.setText(str(edge.Length))
     self.form.edit5.setText('1')
     dx,dy,dz=list(edge.tangentAt(0))
     self.form.edit1.setText(str(round(dx,roundDigits)))
     self.form.edit2.setText(str(round(dy,roundDigits)))
     self.form.edit3.setText(str(round(dz,roundDigits)))
     FreeCADGui.Selection.clearSelection()
     self.deleteArrow()
     from polarUtilsCmd import arrow
     where=FreeCAD.Placement()
     where.Base=edge.valueAt(0)
     where.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),edge.tangentAt(0))
     size=[edge.Length/20.0,edge.Length/10.0,edge.Length/20.0]
     self.arrow=arrow(pl=where,scale=size,offset=edge.Length/2.0)
Пример #7
0
 def __init__(self, winTitle='Rotate WP', icon='rotWP.svg'):
     super(rotWPForm, self).__init__()
     self.move(QPoint(100, 250))
     self.setWindowFlags(Qt.WindowStaysOnTopHint)
     self.setWindowTitle(winTitle)
     iconPath = join(dirname(abspath(__file__)), "icons", icon)
     from PySide.QtGui import QIcon
     Icon = QIcon()
     Icon.addFile(iconPath)
     self.setWindowIcon(Icon)
     self.grid = QGridLayout()
     self.setLayout(self.grid)
     self.radioX = QRadioButton('X')
     self.radioX.setChecked(True)
     self.radioY = QRadioButton('Y')
     self.radioZ = QRadioButton('Z')
     self.lab1 = QLabel('Angle:')
     self.edit1 = QLineEdit('45')
     self.edit1.setAlignment(Qt.AlignCenter)
     self.edit1.setValidator(QDoubleValidator())
     self.btn1 = QPushButton('Rotate working plane')
     self.btn1.clicked.connect(self.rotate)
     self.grid.addWidget(self.radioX, 0, 0, 1, 1, Qt.AlignCenter)
     self.grid.addWidget(self.radioY, 0, 1, 1, 1, Qt.AlignCenter)
     self.grid.addWidget(self.radioZ, 0, 2, 1, 1, Qt.AlignCenter)
     self.grid.addWidget(self.lab1, 1, 0, 1, 1)
     self.grid.addWidget(self.edit1, 1, 1, 1, 2)
     self.grid.addWidget(self.btn1, 2, 0, 1, 3, Qt.AlignCenter)
     self.show()
     self.sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
     s = FreeCAD.ParamGet(
         "User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize")
     sc = [float(x * s) for x in [1, 1, .2]]
     from polarUtilsCmd import arrow
     self.arrow = arrow(FreeCAD.DraftWorkingPlane.getPlacement(),
                        scale=sc,
                        offset=s)