Trajectory.ViewProviderTrajectoryProxy Class Reference

Proxy class for Gui.ViewProviderDocumentObject Trajectory.ViewObject. More...

Public Member Functions

def __init__ (self, vp)
 Initialization method for ViewProviderTrajectoryProxy. More...
 
def attach (self, vp)
 Method called by FreeCAD after initialization to attach Coin3D constructs. More...
 
def updateData (self, fp, prop)
 Method called after DocumentObjectGroupPython Trajectory was changed. More...
 
def onChanged (self, vp, prop)
 Method called after Trajectory.ViewObject was changed. More...
 
def claimChildren (self)
 Method called by FreeCAD to retrieve assigned children. More...
 
def canDropObject (self, obj)
 Method called by FreeCAD to ask if an object obj can be dropped into a Group. More...
 
def getIcon (self)
 Method called by FreeCAD to supply an icon for the Tree View. More...
 
def __getstate__ (self)
 Necessary method to avoid errors when trying to save unserializable objects. More...
 
def __setstate__ (self, state)
 Necessary method to avoid errors when trying to restore unserializable objects. More...
 
def setProperties (self, vp)
 Method to hide unused properties. More...
 
def doubleClicked (self, vp)
 Method called by FreeCAD when Trajectory is double-clicked in the Tree View. More...
 
def setupContextMenu (self, vp, menu)
 Method called by the FreeCAD to customize a context menu for a Trajectory. More...
 
def makeLabels (self)
 Method which makes Coin3D labels to be displayed in the FreeCAD View. More...
 
def makeFrame (self, frame_labels)
 Method which makes a Coin3D frame to show a current pose in a trajectory. More...
 
def makeRotationAxis (self, axis_label)
 Method which makes a Coin3D rotation axis to show in the FreeCAD View. More...
 

Public Attributes

 tf_object2world
 A SoTransform transformation from object to world frame. More...
 
 font
 A SoFontStyle font for axes labels. More...
 
 rot_axis
 A SoSwitch with a rotation axis in form of an arrow. More...
 
 frame
 A SoSeparator with a coordinate frame made from 3 RGB arrows. More...
 
 visualisations
 A SoSwitch with all visualisations (frame & rotation axis). More...
 
 label_texts
 A list of SoText2s labels denoting all axes and an origin. More...
 
 label_translations
 A list of SoTranslations moving labels. More...
 
 labels
 A list of SoSwitches containing colored translated labels. More...
 
 axis_label_color
 A SoPackedColor coloring a rotational axis(RA) label. More...
 
 frame_shaft
 A SoLineSet shaft for frame axes. More...
 
 frame_arrowhead_translation
 A SoTranslation moving frame arrowheads. More...
 
 frame_arrowhead_cone
 A SoCone arrowhead cone for frame axes. More...
 
 frame_arrowhead
 A SoSwitch translated cone for frame axes. More...
 
 frame_color_x
 A SoPackedColor red color for an X axis. More...
 
 frame_color_y
 A SoPackedColor green color for an Y axis. More...
 
 frame_color_z
 A SoPackedColor blue color for an Z axis. More...
 
 frame_drawstyle
 A SoDrawStyle controlling frame axes shaft line width. More...
 
 rot_axis_shaft
 A SoLineSet shaft for a rotation axis. More...
 
 rot_axis_arrowhead_translation
 A SoTranslation moving a RA arrowhead. More...
 
 rot_axis_arrowhead_cone
 A SoCone arrowhead cone for a rotation axis. More...
 
 rot_axis_arrowhead
 A SoSwitch translated cone for a rotation axis. More...
 
 tf_y2axis
 A SoTransform transformation from Y axis to a rotation axis. More...
 
 rot_axis_color
 A SoPackedColor coloring a rotational axis. More...
 
 rot_axis_drawstyle
 A SoDrawStyle controlling RA shaft line width. More...
 

Static Public Attributes

 panel = None
 A TrajectoryPanel if one is active or None. More...
 
 fp = None
 A Trajectory object. More...
 

Detailed Description

Proxy class for Gui.ViewProviderDocumentObject Trajectory.ViewObject.

A ViewProviderTrajectoryProxy instance provides a Trajectory's icon, double-click response and context menu with a Select Time option.

To connect this Proxy object to a Gui.ViewProviderDocumentObject Trajectory.ViewObject do:

a = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",
"Trajectory")
ViewProviderTrajectoryProxy(a.ViewObject)

Definition at line 824 of file Trajectory.py.

Constructor & Destructor Documentation

◆ __init__()

def Trajectory.ViewProviderTrajectoryProxy.__init__ (   self,
  vp 
)

Initialization method for ViewProviderTrajectoryProxy.

A class instance is created and made a Proxy for a generic Gui.ViewProviderDocumentObject Trajectory.ViewObject. During initialization number of properties are specified and preset.

Parameters
vpA barebone Gui.ViewProviderDocumentObject Trajectory.ViewObject.

Definition at line 918 of file Trajectory.py.

918  def __init__(self, vp):
919  self.setProperties(vp)
920  vp.Proxy = self
921 

Member Function Documentation

◆ __getstate__()

def Trajectory.ViewProviderTrajectoryProxy.__getstate__ (   self)

Necessary method to avoid errors when trying to save unserializable objects.

This method is used by JSON to serialize unserializable objects during autosave. Without this an Error would rise when JSON would try to do that itself.

We need this for unserializable fp attribute, but we don't serialize it, because it's enough to reset it when object is restored.

Returns
None, because we don't serialize anything.

Definition at line 1250 of file Trajectory.py.

1250  def __getstate__(self):
1251  return None
1252 

◆ __setstate__()

def Trajectory.ViewProviderTrajectoryProxy.__setstate__ (   self,
  state 
)

Necessary method to avoid errors when trying to restore unserializable objects.

This method is used during a document restoration. We need this for unserializable fp attribute, but we do not restore it, because it's enough to reset it.

Definition at line 1260 of file Trajectory.py.

1260  def __setstate__(self, state):
1261  pass
1262 

◆ attach()

def Trajectory.ViewProviderTrajectoryProxy.attach (   self,
  vp 
)

Method called by FreeCAD after initialization to attach Coin3D constructs.

A coordinate frame made of RGB arrows corresponding to X, Y and Z axes. This frame shows current pose in a trajectory. This method adds Trajectory as the fp attribute.

Parameters
vpA Trajectory.ViewObject after initialization.

Definition at line 932 of file Trajectory.py.

932  def attach(self, vp):
933  # prepare transformation to keep pose corresponding to placement
934  self.tf_object2world = coin.SoTransform()
935 
936  labels = self.makeLabels()
937  self.font = coin.SoFontStyle()
938 
939  axis = self.makeRotationAxis(labels[3])
940  axis.insertChild(self.tf_object2world, 0)
941  axis.insertChild(self.font, 1)
942  self.rot_axis = coin.SoSwitch()
943  self.rot_axis.addChild(axis)
944 
945  frame = self.makeFrame(labels[:3])
946  frame.insertChild(self.tf_object2world, 0)
947  frame.insertChild(self.font, 1)
948  self.frame = coin.SoSwitch()
949  self.frame.addChild(frame)
950 
951  self.visualisations = coin.SoSwitch()
952  self.visualisations.addChild(self.rot_axis)
953  self.visualisations.addChild(self.frame)
954  self.visualisations.whichChild.setValue(coin.SO_SWITCH_ALL)
955  vp.RootNode.addChild(self.visualisations)
956 
957  vp.Object.Proxy.setProperties(vp.Object)
958  self.setProperties(vp)
959  self.fp = vp.Object
960 

◆ canDropObject()

def Trajectory.ViewProviderTrajectoryProxy.canDropObject (   self,
  obj 
)

Method called by FreeCAD to ask if an object obj can be dropped into a Group.

Only FreeCAD objects of a Trajectory type are allowed to drop inside a Trajectory group.

Parameters
objA FreeCAD object hovering above a Trajectory item in the Tree View.

Definition at line 1220 of file Trajectory.py.

1220  def canDropObject(self, obj):
1221  if hasattr(obj, "Proxy") and \
1222  isinstance(obj.Proxy, self.fp.Proxy.__class__):
1223  return True
1224  return False
1225 

◆ claimChildren()

def Trajectory.ViewProviderTrajectoryProxy.claimChildren (   self)

Method called by FreeCAD to retrieve assigned children.

When a property of a Trajectory is touched the Trajectory and the FreeCAD ActiveDocument are notified. The FreeCAD ActiveDocument then emits a signal to inform all its observers e.g. the FreeCADGui ActiveDocument. The FreeCADGui document then emits a new signal to inform e.g. the tree view. The tree view then invokes claimChildren().

Definition at line 1206 of file Trajectory.py.

1206  def claimChildren(self):
1207  if hasattr(self, "fp") and self.fp:
1208  return self.fp.Group
1209  return []
1210 

◆ doubleClicked()

def Trajectory.ViewProviderTrajectoryProxy.doubleClicked (   self,
  vp 
)

Method called by FreeCAD when Trajectory is double-clicked in the Tree View.

If no dialog is opened in the Task View, a new TrajectoryPanel is opened. If another TrajectoryPanel is opened, it is closed and all its QDialogs are added to a new TrajectoryPanel. If a TrajectoryPanel is already opened, the Model tab on the Combo View is swapped for the Tasks tab so that the panel becomes visible. If another dialog is opened a warning is shown.

Parameters
vpA Gui.ViewProviderDocumentObject Trajectory.ViewObject.

Definition at line 1287 of file Trajectory.py.

1287  def doubleClicked(self, vp):
1288  # Switch to the Task View if a Trajectory panel is already opened
1289  if self.panel:
1290  FreeCADGui.Control.showTaskView()
1291 
1292  # Try to open new Trajectory panel
1293  else:
1294  # Check there is a valid trajectory
1295  if not vp.Object.ValidTrajectory:
1296  QMessageBox.warning(
1297  None,
1298  'Error while opening trajectory panel',
1299  "Valid trajectory is necessary to open "
1300  + "a trajectory panel.")
1301  return True
1302 
1303  # Load the QDialog from a file and name it after this object
1304  new_form = [FreeCADGui.PySideUic.loadUi(path.join(PATH_TO_UI,
1305  "AnimationTrajectory.ui"))]
1306  new_form[0].setWindowTitle(vp.Object.Label)
1307 
1308  # Create a control panel and try to show it
1309  self.panel = TrajectoryPanel([vp.Object], new_form)
1310  try:
1311  FreeCADGui.Control.showDialog(self.panel)
1312  except RuntimeError as e:
1313  # Reset the panel
1314  self.panel = None
1315 
1316  # Find all Trajectory feature python objects with
1317  # a reference to a Trajectory panel
1318  trajectories = []
1319  for obj in FreeCAD.ActiveDocument.Objects:
1320  if hasattr(obj, "Proxy") and \
1321  obj.Proxy.__class__.__name__ == "TrajectoryProxy":
1322  if obj.ViewObject.Proxy.panel is not None:
1323  trajectories.append(obj)
1324 
1325  if len(trajectories) > 0:
1326  # Close opened Trajecotry panel
1327  trajectories[0].ViewObject.Proxy.panel.reject()
1328 
1329  # Load the QDialog form for each Trajectory which
1330  # had a reference to the panel
1331  forms = []
1332  for trajectory in trajectories:
1333  form = FreeCADGui.PySideUic.loadUi(
1334  path.join(PATH_TO_UI,
1335  "AnimationTrajectory.ui"))
1336  form.setWindowTitle(trajectory.Label)
1337  forms.append(form)
1338 
1339  # Load one more QDialog for this Trajectory
1340  forms.append(new_form[0])
1341 
1342  # Add this Trajectory to the list of trajectories
1343  trajectories.append(vp.Object)
1344 
1345  # Add a reference to the new panel to view providers
1346  # of all trajectories
1347  self.panel = TrajectoryPanel(trajectories, forms)
1348  for trajectory in trajectories:
1349  trajectory.ViewObject.Proxy.panel = self.panel
1350  FreeCADGui.Control.showDialog(self.panel)
1351  return True
1352 
1353  # Diffeerent Task panel is opened, inform the user
1354  else:
1355  QMessageBox.warning(
1356  None,
1357  'Error while opening trajectory panel',
1358  "A different panel is already active.\n"
1359  + "Close it before opening this one.")
1360  FreeCADGui.Control.showTaskView()
1361  return True
1362 

◆ getIcon()

def Trajectory.ViewProviderTrajectoryProxy.getIcon (   self)

Method called by FreeCAD to supply an icon for the Tree View.

A full path to an icon is supplied for the FreeCADGui.

Returns
A str path to an icon.

Definition at line 1234 of file Trajectory.py.

1234  def getIcon(self):
1235  return path.join(PATH_TO_ICONS, "Trajectory.png")
1236 

◆ makeFrame()

def Trajectory.ViewProviderTrajectoryProxy.makeFrame (   self,
  frame_labels 
)

Method which makes a Coin3D frame to show a current pose in a trajectory.

A frame is made from 3 red, green and blue arrows representing X, Y and Z. Arrows are each constructed from a shaft and an arrowhead. Their dimensions and other attributes are unassigned as they are extracted from appropriate Trajectory properties.

Returns
A SoSeparator with the frame shown in the FreeCAD View.

Definition at line 1432 of file Trajectory.py.

1432  def makeFrame(self, frame_labels):
1433  # make a generic shaft from 0 in Y direction
1434  shaft_vertices = coin.SoVertexProperty()
1435  shaft_vertices.vertex.setNum(2)
1436  shaft_vertices.vertex.set1Value(0, 0, 0, 0)
1437  self.frame_shaft = coin.SoLineSet()
1438  self.frame_shaft.vertexProperty.setValue(shaft_vertices)
1439  self.frame_shaft.numVertices.setNum(1)
1440  self.frame_shaft.numVertices.setValue(2)
1441 
1442  # make a generic conic arrowhead oriented in Y axis direction and
1443  # move it at the end of the shaft
1444  self.frame_arrowhead_translation = coin.SoTranslation()
1445  self.frame_arrowhead_cone = coin.SoCone()
1446  self.frame_arrowhead = coin.SoSwitch()
1447  self.frame_arrowhead.addChild(self.frame_arrowhead_translation)
1448  self.frame_arrowhead.addChild(self.frame_arrowhead_cone)
1449 
1450  # make rotations to rotate prepared shaft and arrowhead for Y axis
1451  # direction also to X and Z
1452  rot_y2x = coin.SoRotation()
1453  rot_y2x.rotation.setValue(coin.SbRotation(coin.SbVec3f(0, 1, 0),
1454  coin.SbVec3f(1, 0, 0)))
1455  rot_y2z = coin.SoRotation()
1456  rot_y2z.rotation.setValue(coin.SbRotation(coin.SbVec3f(0, 1, 0),
1457  coin.SbVec3f(0, 0, 1)))
1458 
1459  # prepare colors for X,Y,Z which will correspond to R,G,B as customary
1460  self.frame_color_x = coin.SoPackedColor()
1461  self.frame_color_y = coin.SoPackedColor()
1462  self.frame_color_z = coin.SoPackedColor()
1463 
1464  # make complete colored and rotated arrows
1465  x_arrow = coin.SoSeparator()
1466  x_arrow.addChild(rot_y2x)
1467  x_arrow.addChild(self.frame_color_x)
1468  x_arrow.addChild(self.frame_shaft)
1469  x_arrow.addChild(self.frame_arrowhead)
1470  x_arrow.addChild(frame_labels[0])
1471  y_arrow = coin.SoSeparator()
1472  y_arrow.addChild(self.frame_color_y)
1473  y_arrow.addChild(self.frame_shaft)
1474  y_arrow.addChild(self.frame_arrowhead)
1475  y_arrow.addChild(frame_labels[1])
1476  z_arrow = coin.SoSeparator()
1477  z_arrow.addChild(rot_y2z)
1478  z_arrow.addChild(self.frame_color_z)
1479  z_arrow.addChild(self.frame_shaft)
1480  z_arrow.addChild(self.frame_arrowhead)
1481  z_arrow.addChild(frame_labels[2])
1482 
1483  # prepare draw style to control shaft width
1484  self.frame_drawstyle = coin.SoDrawStyle()
1485 
1486  # make complete frame and it to shaded display mode
1487  separated_frame = coin.SoSeparator()
1488  separated_frame.addChild(self.frame_drawstyle)
1489  separated_frame.addChild(x_arrow)
1490  separated_frame.addChild(y_arrow)
1491  separated_frame.addChild(z_arrow)
1492 
1493  return separated_frame
1494 

◆ makeLabels()

def Trajectory.ViewProviderTrajectoryProxy.makeLabels (   self)

Method which makes Coin3D labels to be displayed in the FreeCAD View.

Frame labels for axes X, Y and Z and a label for rotation axis are made. The labels have the same color as the axes.

Returns
A SoSwitch with colored text label to be shown in the FreeCAD View.

Definition at line 1389 of file Trajectory.py.

1389  def makeLabels(self):
1390  label_strings = ["X", "Y", "Z", "O"]
1391  colors = [0xFF0000FF, 0x00FF00FF, 0x0000FFFF]
1392  self.label_texts = []
1393  self.label_translations = []
1394  # frame translation
1395  self.label_translations.append(coin.SoTranslation())
1396  # axis translation
1397  self.label_translations.append(coin.SoTranslation())
1398  self.labels = []
1399  for i in range(4):
1400  label_group = coin.SoSeparator()
1401  if i < 3:
1402  label_group.addChild(self.label_translations[0])
1403  frame_axis_color = coin.SoPackedColor()
1404  frame_axis_color.orderedRGBA.setValue(colors[i])
1405  label_group.addChild(frame_axis_color)
1406  else:
1407  label_group.addChild(self.label_translations[1])
1408  self.axis_label_color = coin.SoPackedColor()
1409  label_group.addChild(self.axis_label_color)
1410  self.label_texts.append(coin.SoText2())
1411  self.label_texts[i].string.setValues(
1412  0, 3, ["", label_strings[i], ""])
1413  self.label_texts[i].justification.setValue(
1414  self.label_texts[i].CENTER)
1415  self.label_texts[i].spacing.setValue(0.45)
1416  label_group.addChild(self.label_texts[i])
1417  self.labels.append(coin.SoSwitch())
1418  self.labels[i].addChild(label_group)
1419  return self.labels
1420 

◆ makeRotationAxis()

def Trajectory.ViewProviderTrajectoryProxy.makeRotationAxis (   self,
  axis_label 
)

Method which makes a Coin3D rotation axis to show in the FreeCAD View.

A rotation axis is made from a shaft and an arrowhead. Its dimensions and other attributes are unassigned as they are extracted from appropriate Trajectory properties.

Returns
A SoSeparator with the rotation axis to be shown in the FreeCAD View.

Definition at line 1505 of file Trajectory.py.

1505  def makeRotationAxis(self, axis_label):
1506  # make a generic shaft from 0 in Y direction
1507  shaft_vertices = coin.SoVertexProperty()
1508  shaft_vertices.vertex.setNum(2)
1509  shaft_vertices.vertex.set1Value(0, 0, 0, 0)
1510  self.rot_axis_shaft = coin.SoLineSet()
1511  self.rot_axis_shaft.vertexProperty.setValue(shaft_vertices)
1512  self.rot_axis_shaft.numVertices.setNum(1)
1513  self.rot_axis_shaft.numVertices.setValue(2)
1514 
1515  # make a generic conic arrowhead oriented in Y axis direction and
1516  # move it at the end of the shaft
1517  self.rot_axis_arrowhead_translation = coin.SoTranslation()
1518  self.rot_axis_arrowhead_cone = coin.SoCone()
1519  self.rot_axis_arrowhead = coin.SoSwitch()
1520  self.rot_axis_arrowhead.addChild(self.rot_axis_arrowhead_translation)
1521  self.rot_axis_arrowhead.addChild(self.rot_axis_arrowhead_cone)
1522 
1523  # make rotations to rotate prepared shaft and arrowhead for Y axis
1524  # direction also to X and Z
1525  self.tf_y2axis = coin.SoTransform()
1526 
1527  # prepare colors for X,Y,Z which will correspond to R,G,B as customary
1528  self.rot_axis_color = coin.SoPackedColor()
1529 
1530  # prepare draw style to control shaft width
1531  self.rot_axis_drawstyle = coin.SoDrawStyle()
1532 
1533  # make complete frame and it to shaded display mode
1534  separated_axis = coin.SoSeparator()
1535  separated_axis.addChild(self.tf_y2axis)
1536  separated_axis.addChild(self.rot_axis_drawstyle)
1537  separated_axis.addChild(self.rot_axis_color)
1538  separated_axis.addChild(self.rot_axis_shaft)
1539  separated_axis.addChild(self.rot_axis_arrowhead)
1540  separated_axis.addChild(axis_label)
1541 
1542  return separated_axis
1543 
1544 

◆ onChanged()

def Trajectory.ViewProviderTrajectoryProxy.onChanged (   self,
  vp,
  prop 
)

Method called after Trajectory.ViewObject was changed.

If visibility changed, an appropriate Coin3D construct hides the frame showing current pose.

Parameters
vpA Trajectory.ViewObject.
propA str name of a changed property.

Definition at line 1190 of file Trajectory.py.

1190  def onChanged(self, vp, prop):
1191  if prop == "Visibility":
1192  if vp.Visibility:
1193  self.visualisations.whichChild.setValue(coin.SO_SWITCH_ALL)
1194  else:
1195  self.visualisations.whichChild.setValue(coin.SO_SWITCH_NONE)
1196 

◆ setProperties()

def Trajectory.ViewProviderTrajectoryProxy.setProperties (   self,
  vp 
)

Method to hide unused properties.

Property Display Mode is set to be invisible as they are unused.

Parameters
vpA Gui.ViewProviderDocumentObject Trajectory.ViewObject.

Definition at line 1271 of file Trajectory.py.

1271  def setProperties(self, vp):
1272  # hide unnecessary view properties
1273  vp.setEditorMode("DisplayMode", 2)
1274 

◆ setupContextMenu()

def Trajectory.ViewProviderTrajectoryProxy.setupContextMenu (   self,
  vp,
  menu 
)

Method called by the FreeCAD to customize a context menu for a Trajectory.

The Transform and Set colors... items are removed from the context menu shown upon right click on DocumentObjectGroupPython Trajectory in the Tree View. The option to Select Time is added instead.

Parameters
vpA right-clicked Gui.ViewProviderDocumentObject Trajectory.ViewObject.
menuA Qt's QMenu to be edited.

Definition at line 1374 of file Trajectory.py.

1374  def setupContextMenu(self, vp, menu):
1375  menu.clear()
1376  action = menu.addAction("Select Time")
1377  action.triggered.connect(lambda f=self.doubleClicked,
1378  arg=vp: f(arg))
1379 

◆ updateData()

def Trajectory.ViewProviderTrajectoryProxy.updateData (   self,
  fp,
  prop 
)

Method called after DocumentObjectGroupPython Trajectory was changed.

This method is used to update Coin3D constructs, if associated properties changed e.g. if the FrameArrowheadRadius changes, all Coin3D cones representing frame arrowheads will change their radius accordingly.

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

Definition at line 972 of file Trajectory.py.

972  def updateData(self, fp, prop):
973  # Placement changes
974  if prop == "Placement" and hasattr(fp, "Placement"):
975  trans = fp.Placement.Base
976  rot = fp.Placement.Rotation
977  self.tf_object2world.translation.setValue((trans.x, trans.y,
978  trans.z))
979  self.tf_object2world.rotation.setValue(rot.Q)
980  if len(fp.Proxy.pose["rot_point"]) == 3 and \
981  len(fp.Proxy.pose["rot_axis"]) == 3:
982  self.tf_y2axis.rotation.setValue(
983  coin.SbRotation(coin.SbVec3f(0, 1, 0),
984  coin.SbVec3f(fp.Proxy.pose["rot_axis"][0],
985  fp.Proxy.pose["rot_axis"][1],
986  fp.Proxy.pose["rot_axis"][2])
987  ))
988  self.tf_y2axis.translation.setValue(
989  (fp.Proxy.pose["rot_point"][0],
990  fp.Proxy.pose["rot_point"][1],
991  fp.Proxy.pose["rot_point"][2]))
992 
993  # Frame changes
994  elif prop == "ShowFrame" and hasattr(fp, "ShowFrame"):
995  if fp.ShowFrame:
996  self.frame.whichChild.setValue(coin.SO_SWITCH_ALL)
997  else:
998  self.frame.whichChild.setValue(coin.SO_SWITCH_NONE)
999 
1000  elif prop == "FrameTransparency" and hasattr(fp, "FrameTransparency"):
1001  self.frame_color_x.orderedRGBA.\
1002  setValue(0xff0000ff - (0xff*fp.FrameTransparency)//100)
1003  self.frame_color_y.orderedRGBA.\
1004  setValue(0x00ff00ff - (0xff*fp.FrameTransparency)//100)
1005  self.frame_color_z.orderedRGBA.\
1006  setValue(0x0000ffff - (0xff*fp.FrameTransparency)//100)
1007 
1008  elif prop == "ShaftLength" and hasattr(fp, "ShaftLength"):
1009  self.frame_shaft.vertexProperty.getValue().vertex.\
1010  set1Value(1, 0, fp.ShaftLength, 0)
1011  if hasattr(fp, "FrameArrowheadLength"):
1012  self.frame_arrowhead_translation.translation.setValue(
1013  0, fp.ShaftLength + fp.FrameArrowheadLength/2, 0)
1014  if not fp.ShowFrameArrowheads and hasattr(fp, "DistanceToAxis"):
1015  self.label_translations[0].translation.setValue(
1016  0, fp.ShaftLength + fp.DistanceToAxis, 0)
1017 
1018  elif prop == "FrameArrowheadLength" and \
1019  hasattr(fp, "FrameArrowheadLength"):
1020  self.frame_arrowhead_cone.height.setValue(fp.FrameArrowheadLength)
1021  if hasattr(fp, "ShaftLength"):
1022  self.frame_arrowhead_translation.translation.setValue(
1023  0, fp.ShaftLength + fp.FrameArrowheadLength/2, 0)
1024  if fp.ShowFrameArrowheads and hasattr(fp, "DistanceToAxis"):
1025  self.label_translations[0].translation.setValue(
1026  0, fp.FrameArrowheadLength/2 + fp.DistanceToAxis, 0)
1027 
1028  elif prop == "ShaftWidth" and hasattr(fp, "ShaftWidth"):
1029  self.frame_drawstyle.lineWidth.setValue(fp.ShaftWidth)
1030 
1031  elif prop == "FrameArrowheadRadius" and \
1032  hasattr(fp, "FrameArrowheadRadius"):
1033  self.frame_arrowhead_cone.bottomRadius.setValue(
1034  fp.FrameArrowheadRadius)
1035 
1036  elif prop == "ShowFrameArrowheads" and \
1037  hasattr(fp, "ShowFrameArrowheads"):
1038  if fp.ShowFrameArrowheads:
1039  self.frame_arrowhead.whichChild.setValue(coin.SO_SWITCH_ALL)
1040  if hasattr(fp, "FrameArrowheadLength") and \
1041  hasattr(fp, "DistanceToAxis"):
1042  self.label_translations[0].translation.setValue(
1043  0, fp.FrameArrowheadLength/2 + fp.DistanceToAxis, 0)
1044  else:
1045  self.frame_arrowhead.whichChild.setValue(coin.SO_SWITCH_NONE)
1046  if hasattr(fp, "ShaftLength") and \
1047  hasattr(fp, "DistanceToAxis"):
1048  self.label_translations[0].translation.setValue(
1049  0, fp.ShaftLength + fp.DistanceToAxis, 0)
1050 
1051  elif prop == "ShowFrameLabels" and hasattr(fp, "ShowFrameLabels"):
1052  for label in self.labels[:3]:
1053  if fp.ShowFrameLabels:
1054  label.whichChild.setValue(coin.SO_SWITCH_ALL)
1055  else:
1056  label.whichChild.setValue(coin.SO_SWITCH_NONE)
1057 
1058  # Axis changes
1059  elif prop == "ShowRotationAxis" and hasattr(fp, "ShowRotationAxis"):
1060  if fp.ShowRotationAxis:
1061  self.rot_axis.whichChild.setValue(coin.SO_SWITCH_ALL)
1062  else:
1063  self.rot_axis.whichChild.setValue(coin.SO_SWITCH_NONE)
1064 
1065  elif prop == "AxisTransparency" and \
1066  (hasattr(fp, "AxisColor") and hasattr(fp, "AxisTransparency")):
1067  self.rot_axis_color.orderedRGBA.setValue(
1068  (round(0xff*fp.AxisColor[0]) << 24)
1069  + (round(0xff*fp.AxisColor[1]) << 16)
1070  + (round(0xff*fp.AxisColor[2]) << 8)
1071  + 0xff*(100 - fp.AxisTransparency)//100)
1072 
1073  elif prop == "AxisColor" and \
1074  (hasattr(fp, "AxisColor") and hasattr(fp, "AxisTransparency")):
1075  self.rot_axis_color.orderedRGBA.setValue(
1076  (round(0xff*fp.AxisColor[0]) << 24)
1077  + (round(0xff*fp.AxisColor[1]) << 16)
1078  + (round(0xff*fp.AxisColor[2]) << 8)
1079  + 0xff*(100 - fp.AxisTransparency)//100)
1080  self.axis_label_color.orderedRGBA.setValue(
1081  (self.rot_axis_color.orderedRGBA.getValues()[0] & 0xFFFFFF00)
1082  + 0xFF)
1083 
1084  elif prop == "AxisWidth" and hasattr(fp, "AxisWidth"):
1085  self.rot_axis_drawstyle.lineWidth.setValue(fp.AxisWidth)
1086 
1087  elif prop == "AxisLength" and hasattr(fp, "AxisLength"):
1088  self.rot_axis_shaft.vertexProperty.getValue().vertex.\
1089  set1Value(1, 0, fp.AxisLength, 0)
1090  if hasattr(fp, "AxisArrowheadLength"):
1091  self.rot_axis_arrowhead_translation.translation.setValue(
1092  0, fp.AxisLength + fp.AxisArrowheadLength/2, 0)
1093  if not fp.ShowAxisArrowhead and hasattr(fp, "DistanceToAxis"):
1094  self.label_translations[1].translation.setValue(
1095  0, fp.AxisLength + fp.DistanceToAxis, 0)
1096 
1097  elif prop == "AxisArrowheadLength" and \
1098  hasattr(fp, "AxisArrowheadLength"):
1099  self.rot_axis_arrowhead_cone.height.setValue(
1100  fp.AxisArrowheadLength)
1101  if hasattr(fp, "AxisLength"):
1102  self.rot_axis_arrowhead_translation.translation.setValue(
1103  0, fp.AxisLength + fp.AxisArrowheadLength/2, 0)
1104  if fp.ShowAxisArrowhead and hasattr(fp, "DistanceToAxis"):
1105  self.label_translations[1].translation.setValue(
1106  0, fp.AxisArrowheadLength/2 + fp.DistanceToAxis, 0)
1107 
1108  elif prop == "AxisArrowheadRadius" and \
1109  hasattr(fp, "AxisArrowheadRadius"):
1110  self.rot_axis_arrowhead_cone.bottomRadius.setValue(
1111  fp.AxisArrowheadRadius)
1112 
1113  elif prop == "ShowAxisArrowhead" and hasattr(fp, "ShowAxisArrowhead"):
1114  if fp.ShowAxisArrowhead:
1115  self.rot_axis_arrowhead.whichChild.setValue(
1116  coin.SO_SWITCH_ALL)
1117  if hasattr(fp, "AxisArrowheadLength") and \
1118  hasattr(fp, "DistanceToAxis"):
1119  self.label_translations[1].translation.setValue(
1120  0, fp.AxisArrowheadLength/2 + fp.DistanceToAxis, 0)
1121  else:
1122  self.rot_axis_arrowhead.whichChild.setValue(
1123  coin.SO_SWITCH_NONE)
1124  if hasattr(fp, "AxisLength") and hasattr(fp, "DistanceToAxis"):
1125  self.label_translations[1].translation.setValue(
1126  0, fp.AxisLength + fp.DistanceToAxis, 0)
1127 
1128  elif prop == "ShowAxisLabel" and hasattr(fp, "ShowAxisLabel"):
1129  if fp.ShowAxisLabel:
1130  self.labels[-1].whichChild.setValue(coin.SO_SWITCH_ALL)
1131  else:
1132  self.labels[-1].whichChild.setValue(coin.SO_SWITCH_NONE)
1133 
1134  # Changes to the labels
1135  elif prop == "Subscription" and hasattr(fp, "Subscription"):
1136  for l in self.label_texts:
1137  l.string.setValues(2, 1, [fp.Subscription])
1138 
1139  elif prop == "Superscription" and hasattr(fp, "Superscription"):
1140  for l in self.label_texts:
1141  l.string.setValues(0, 1, [fp.Superscription])
1142 
1143  elif prop == "FontFamily" and hasattr(fp, "FontFamily"):
1144  if fp.FontFamily == "SERIF":
1145  self.font.family.setValue(self.font.SERIF)
1146  if fp.FontFamily == "SANS":
1147  self.font.family.setValue(self.font.SANS)
1148  if fp.FontFamily == "TYPEWRITER":
1149  self.font.family.setValue(self.font.TYPEWRITER)
1150 
1151  elif prop == "FontStyle" and hasattr(fp, "FontStyle"):
1152  if fp.FontStyle == "NONE":
1153  self.font.style.setValue(self.font.NONE)
1154  if fp.FontStyle == "BOLD":
1155  self.font.style.setValue(self.font.BOLD)
1156  if fp.FontStyle == "ITALIC":
1157  self.font.style.setValue(self.font.ITALIC)
1158  if fp.FontStyle == "BOLD ITALIC":
1159  self.font.style.setValue(self.font.BOLD | self.font.ITALIC)
1160 
1161  elif prop == "FontSize" and hasattr(fp, "FontSize"):
1162  self.font.size.setValue(fp.FontSize)
1163 
1164  elif prop == "DistanceToAxis" and hasattr(fp, "DistanceToAxis") and \
1165  hasattr(fp, "ShowFrameArrowheads") and \
1166  hasattr(fp, "ShowAxisArrowhead"):
1167  if fp.ShowFrameArrowheads and hasattr(fp, "FrameArrowheadLength"):
1168  self.label_translations[0].translation.setValue(
1169  0, fp.FrameArrowheadLength/2 + fp.DistanceToAxis, 0)
1170  elif hasattr(fp, "ShaftLength"):
1171  self.label_translations[0].translation.setValue(
1172  0, fp.ShaftLength + fp.DistanceToAxis, 0)
1173  if fp.ShowAxisArrowhead and hasattr(fp, "AxisArrowheadLength"):
1174  self.label_translations[1].translation.setValue(
1175  0, fp.AxisArrowheadLength/2 + fp.DistanceToAxis, 0)
1176  elif hasattr(fp, "AxisLength"):
1177  self.label_translations[1].translation.setValue(
1178  0, fp.AxisLength + fp.DistanceToAxis, 0)
1179 

Member Data Documentation

◆ axis_label_color

Trajectory.ViewProviderTrajectoryProxy.axis_label_color

A SoPackedColor coloring a rotational axis(RA) label.

Definition at line 1408 of file Trajectory.py.

◆ font

Trajectory.ViewProviderTrajectoryProxy.font

A SoFontStyle font for axes labels.

Definition at line 937 of file Trajectory.py.

◆ fp

Trajectory.ViewProviderTrajectoryProxy.fp = None
static

A Trajectory object.

Definition at line 905 of file Trajectory.py.

◆ frame

Trajectory.ViewProviderTrajectoryProxy.frame

A SoSeparator with a coordinate frame made from 3 RGB arrows.

Definition at line 948 of file Trajectory.py.

◆ frame_arrowhead

Trajectory.ViewProviderTrajectoryProxy.frame_arrowhead

A SoSwitch translated cone for frame axes.

Definition at line 1446 of file Trajectory.py.

◆ frame_arrowhead_cone

Trajectory.ViewProviderTrajectoryProxy.frame_arrowhead_cone

A SoCone arrowhead cone for frame axes.

Definition at line 1445 of file Trajectory.py.

◆ frame_arrowhead_translation

Trajectory.ViewProviderTrajectoryProxy.frame_arrowhead_translation

A SoTranslation moving frame arrowheads.

Definition at line 1444 of file Trajectory.py.

◆ frame_color_x

Trajectory.ViewProviderTrajectoryProxy.frame_color_x

A SoPackedColor red color for an X axis.

Definition at line 1460 of file Trajectory.py.

◆ frame_color_y

Trajectory.ViewProviderTrajectoryProxy.frame_color_y

A SoPackedColor green color for an Y axis.

Definition at line 1461 of file Trajectory.py.

◆ frame_color_z

Trajectory.ViewProviderTrajectoryProxy.frame_color_z

A SoPackedColor blue color for an Z axis.

Definition at line 1462 of file Trajectory.py.

◆ frame_drawstyle

Trajectory.ViewProviderTrajectoryProxy.frame_drawstyle

A SoDrawStyle controlling frame axes shaft line width.

Definition at line 1484 of file Trajectory.py.

◆ frame_shaft

Trajectory.ViewProviderTrajectoryProxy.frame_shaft

A SoLineSet shaft for frame axes.

Definition at line 1437 of file Trajectory.py.

◆ label_texts

Trajectory.ViewProviderTrajectoryProxy.label_texts

A list of SoText2s labels denoting all axes and an origin.

Definition at line 1392 of file Trajectory.py.

◆ label_translations

Trajectory.ViewProviderTrajectoryProxy.label_translations

A list of SoTranslations moving labels.

Definition at line 1393 of file Trajectory.py.

◆ labels

Trajectory.ViewProviderTrajectoryProxy.labels

A list of SoSwitches containing colored translated labels.

Definition at line 1398 of file Trajectory.py.

◆ panel

Trajectory.ViewProviderTrajectoryProxy.panel = None
static

A TrajectoryPanel if one is active or None.

Definition at line 904 of file Trajectory.py.

◆ rot_axis

Trajectory.ViewProviderTrajectoryProxy.rot_axis

A SoSwitch with a rotation axis in form of an arrow.

Definition at line 942 of file Trajectory.py.

◆ rot_axis_arrowhead

Trajectory.ViewProviderTrajectoryProxy.rot_axis_arrowhead

A SoSwitch translated cone for a rotation axis.

Definition at line 1519 of file Trajectory.py.

◆ rot_axis_arrowhead_cone

Trajectory.ViewProviderTrajectoryProxy.rot_axis_arrowhead_cone

A SoCone arrowhead cone for a rotation axis.

Definition at line 1518 of file Trajectory.py.

◆ rot_axis_arrowhead_translation

Trajectory.ViewProviderTrajectoryProxy.rot_axis_arrowhead_translation

A SoTranslation moving a RA arrowhead.

Definition at line 1517 of file Trajectory.py.

◆ rot_axis_color

Trajectory.ViewProviderTrajectoryProxy.rot_axis_color

A SoPackedColor coloring a rotational axis.

Definition at line 1528 of file Trajectory.py.

◆ rot_axis_drawstyle

Trajectory.ViewProviderTrajectoryProxy.rot_axis_drawstyle

A SoDrawStyle controlling RA shaft line width.

Definition at line 1531 of file Trajectory.py.

◆ rot_axis_shaft

Trajectory.ViewProviderTrajectoryProxy.rot_axis_shaft

A SoLineSet shaft for a rotation axis.

Definition at line 1510 of file Trajectory.py.

◆ tf_object2world

Trajectory.ViewProviderTrajectoryProxy.tf_object2world

A SoTransform transformation from object to world frame.

Definition at line 934 of file Trajectory.py.

◆ tf_y2axis

Trajectory.ViewProviderTrajectoryProxy.tf_y2axis

A SoTransform transformation from Y axis to a rotation axis.

Definition at line 1525 of file Trajectory.py.

◆ visualisations

Trajectory.ViewProviderTrajectoryProxy.visualisations

A SoSwitch with all visualisations (frame & rotation axis).

Definition at line 951 of file Trajectory.py.


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