RobWorld.RobWorldProxy Class Reference

Proxy class for a DocumentObjectGroupPython RobWorld instance. More...

Public Member Functions

def __init__ (self, fp)
 Initialization method for RobWorldProxy. More...
 
def onChanged (self, fp, prop)
 Method called after DocumentObjectGroupPython RobWorld was changed. More...
 
def execute (self, fp)
 Method called when recomputing a DocumentObjectGroupPython. More...
 
def onDocumentRestored (self, fp)
 Method called when document is restored to make sure everything is as it was. More...
 
def setProperties (self, fp)
 Method to set properties during initialization or document restoration. More...
 

Detailed Description

Proxy class for a DocumentObjectGroupPython RobWorld instance.

A RobWorldProxy instance adds properties to a DocumentObjectGroupPython RobWorld instance and responds to their changes.

To connect this Proxy object to a DocumentObjectGroupPython RobWorld do:

    a = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",
                                         "RobWorld")
    RobWorldProxy(a)

Definition at line 60 of file RobWorld.py.

Constructor & Destructor Documentation

◆ __init__()

def RobWorld.RobWorldProxy.__init__ (   self,
  fp 
)

Initialization method for RobWorldProxy.

A class instance is created and made a Proxy for a generic DocumentObjectGroupPython RobWorld object. During initialization number of properties are specified and preset.

Parameters
fpA DocumentObjectGroupPython RobWorld object to be extended.

Definition at line 72 of file RobWorld.py.

72  def __init__(self, fp):
73  # Add (and preset) properties
74  self.setProperties(fp)
75  fp.Proxy = self
76 

Member Function Documentation

◆ execute()

def RobWorld.RobWorldProxy.execute (   self,
  fp 
)

Method called when recomputing a DocumentObjectGroupPython.

Placement is computed from Yaw, Pitch and Roll angle rotations about Z, Y and X axes originating in (0, 0, 0).

Parameters
fpA DocumentObjectGroupPython RobWorld object.

Definition at line 105 of file RobWorld.py.

105  def execute(self, fp):
106  rotation = FreeCAD.Rotation(fp.AngleYaw, fp.AnglePitch, fp.AngleRoll)
107  rotation_center = FreeCAD.Vector(0, 0, 0)
108  position = FreeCAD.Vector(fp.PositionX, fp.PositionY, fp.PositionZ)
109  fp.Placement = FreeCAD.Placement(position, rotation, rotation_center)
110 

◆ onChanged()

def RobWorld.RobWorldProxy.onChanged (   self,
  fp,
  prop 
)

Method called after DocumentObjectGroupPython RobWorld was changed.

A RobWorld is checked for its validity. If the Placement property is changed, then ParentFramePlacement property of a RobWorld's children is set to equal the new Placement.

Parameters
fpA DocumentObjectGroupPython RobWorld object.
propA str name of a changed property.

Definition at line 88 of file RobWorld.py.

88  def onChanged(self, fp, prop):
89  if prop == "Placement":
90  # Propagate the Placement updates down the chain
91  if hasattr(fp, "Group") and len(fp.Group) != 0:
92  for child in fp.Group:
93  child.ParentFramePlacement = fp.Placement
94  child.purgeTouched()
95 

◆ onDocumentRestored()

def RobWorld.RobWorldProxy.onDocumentRestored (   self,
  fp 
)

Method called when document is restored to make sure everything is as it was.

Reinitialization it creates properties and sets them to default, if they were not restored automatically. Properties of connected ViewObject are also recreated and reset if necessary.

Parameters
fpA restored DocumentObjectGroupPython RobWorld object.

Definition at line 121 of file RobWorld.py.

121  def onDocumentRestored(self, fp):
122  fp.ViewObject.Proxy.setProperties(fp.ViewObject)
123  self.setProperties(fp)
124 

◆ setProperties()

def RobWorld.RobWorldProxy.setProperties (   self,
  fp 
)

Method to set properties during initialization or document restoration.

The properties are set if they are not already present and an AnimateDocumentObserver is recreated.

Parameters
fpA restored or barebone DocumentObjectGroupPython RobWorld object.

Definition at line 135 of file RobWorld.py.

135  def setProperties(self, fp):
136  # Add (and preset) properties
137  # Animation properties
138  if not hasattr(fp, "AllowServer"):
139  fp.addProperty("App::PropertyBool", "AllowServer", "General",
140  "Should this object allow a Server object to "
141  + "change it.").AllowServer = True
142 
143  # Frame Placement
144  if not hasattr(fp, "PositionX"):
145  fp.addProperty("App::PropertyFloat", "PositionX", "FramePlacement",
146  "X position of the world frame.").PositionX = 0
147  if not hasattr(fp, "PositionY"):
148  fp.addProperty("App::PropertyFloat", "PositionY", "FramePlacement",
149  "Y position of the world frame.").PositionY = 0
150  if not hasattr(fp, "PositionZ"):
151  fp.addProperty("App::PropertyFloat", "PositionZ", "FramePlacement",
152  "Z position of the world frame.").PositionZ = 0
153  if not hasattr(fp, "AngleYaw"):
154  fp.addProperty("App::PropertyFloat", "AngleYaw", "FramePlacement",
155  "Yaw angle (rotation about Z axis) of the world"
156  + " frame in degrees.").AngleYaw = 0
157  if not hasattr(fp, "AnglePitch"):
158  fp.addProperty("App::PropertyFloat", "AnglePitch",
159  "FramePlacement", "Pitch angle (rotation about Y"
160  + " axis) of the world frame in degrees."
161  ).AnglePitch = 0
162  if not hasattr(fp, "AngleRoll"):
163  fp.addProperty("App::PropertyFloat", "AngleRoll", "FramePlacement",
164  "Roll angle (rotation about X axis) of the world"
165  + " frame in degrees.").AngleRoll = 0
166 
167  # Frame properties
168  if not hasattr(fp, "ShowFrame"):
169  fp.addProperty("App::PropertyBool", "ShowFrame", "Frame",
170  "Show a frame for current pose."
171  ).ShowFrame = True
172  if not hasattr(fp, "FrameTransparency"):
173  fp.addProperty("App::PropertyPercent", "FrameTransparency",
174  "Frame", "Transparency of the frame in percents."
175  ).FrameTransparency = 0
176  if not hasattr(fp, "ShowFrameArrowheads"):
177  fp.addProperty("App::PropertyBool", "ShowFrameArrowheads", "Frame",
178  "Show arrowheads for frame axis arrow's."
179  ).ShowFrameArrowheads = True
180  if not hasattr(fp, "FrameArrowheadLength"):
181  fp.addProperty("App::PropertyFloatConstraint",
182  "FrameArrowheadLength", "Frame",
183  "Frame axis arrow's arrowhead length.\n"
184  + "Range is < 1.0 | 1e6 >."
185  ).FrameArrowheadLength = (10, 1.0, 1e6, 1)
186  else:
187  fp.FrameArrowheadLength = (fp.FrameArrowheadLength, 1.0, 1e6, 1)
188  if not hasattr(fp, "FrameArrowheadRadius"):
189  fp.addProperty("App::PropertyFloatConstraint",
190  "FrameArrowheadRadius", "Frame",
191  "Frame axis arrow's arrowhead bottom radius.\n"
192  + "Range is < 0.5 | 1e6 >."
193  ).FrameArrowheadRadius = (5, 0.5, 1e6, 0.5)
194  else:
195  fp.FrameArrowheadRadius = (fp.FrameArrowheadRadius, 0.5, 1e6, 0.5)
196  if not hasattr(fp, "ShaftLength"):
197  fp.addProperty("App::PropertyFloatConstraint", "ShaftLength",
198  "Frame", "Frame axis arrow's shaft length.\n"
199  + "Range is < 1.0 | 1e6 >."
200  ).ShaftLength = (20, 1.0, 1e6, 1)
201  else:
202  fp.ShaftLength = (fp.ShaftLength, 1.0, 1e6, 1)
203  if not hasattr(fp, "ShaftWidth"):
204  fp.addProperty("App::PropertyFloatConstraint", "ShaftWidth",
205  "Frame", "Frame axis arrow's shaft width.\n"
206  + "Range is < 1.0 | 64 >."
207  ).ShaftWidth = (4, 1.0, 64, 1)
208  else:
209  fp.ShaftWidth = (fp.ShaftWidth, 1.0, 64, 1)
210  if not hasattr(fp, "ShowFrameLabels"):
211  fp.addProperty("App::PropertyBool", "ShowFrameLabels",
212  "Frame", "Show label for frame axes."
213  ).ShowFrameLabels = True
214 
215  # Label properties
216  if not hasattr(fp, "FontSize"):
217  fp.addProperty("App::PropertyIntegerConstraint", "FontSize",
218  "Labels", "Label font size.\n"
219  + "Range is < 1 | 100 >."
220  ).FontSize = (10, 1, 100, 1)
221  else:
222  fp.FontSize = (fp.FontSize, 1, 100, 1)
223  if not hasattr(fp, "DistanceToAxis"):
224  fp.addProperty("App::PropertyFloatConstraint", "DistanceToAxis",
225  "Labels", "Distance from label to its axis.\n"
226  + "Range is < 0.5 | 1e6 >."
227  ).DistanceToAxis = (5, 0.5, 1e6, 0.5)
228  else:
229  fp.DistanceToAxis = (fp.DistanceToAxis, 0.5, 1e6, 0.5)
230  if not hasattr(fp, "Subscription"):
231  fp.addProperty("App::PropertyString", "Subscription", "Labels",
232  "Subscription added to an axis name."
233  ).Subscription = ""
234  if not hasattr(fp, "Superscription"):
235  fp.addProperty("App::PropertyString", "Superscription", "Labels",
236  "Superscription added to an axis name."
237  ).Superscription = ""
238  if not hasattr(fp, "FontFamily"):
239  fp.addProperty("App::PropertyEnumeration", "FontFamily",
240  "Labels", "Label font family."
241  ).FontFamily = ["SERIF", "SANS", "TYPEWRITER"]
242  if not hasattr(fp, "FontStyle"):
243  fp.addProperty("App::PropertyEnumeration", "FontStyle",
244  "Labels", "Label font style."
245  ).FontStyle = ["NONE", "BOLD", "ITALIC",
246  "BOLD ITALIC"]
247 
248  # Placement properties
249  if not hasattr(fp, "Placement"):
250  fp.addProperty("App::PropertyPlacement", "Placement", "Base",
251  "Current placement for animated objects in "
252  + "world frame.")
253 
254  # Hide some properties
255  fp.setEditorMode("Placement", 2)
256 
257  import AnimateDocumentObserver
259 
260 
def addObserver()
Adds an AnimateDocumentObserver between FreeCAD's document observers safely.

The documentation for this class was generated from the following file: