RobotPanel.RobotPanel Class Reference

Class providing funcionality to a RobRotation panel inside the TaskView. More...

Inheritance diagram for RobotPanel.RobotPanel:

Public Member Functions

def __init__ (self, robot_joints, forms)
 Initialization method for RobotPanel. More...
 
def sliderChanged (self, value, form, joint)
 Feedback method called when any slider position is changed. More...
 
def reject (self)
 Feedback method called when 'Close' button was pressed to close the panel. More...
 
def getStandardButtons (self, *args)
 Method to set just one button (close) to close the dialog. More...
 
def isAllowedAlterSelection (self)
 Method to tell FreeCAD if dialog is allowed to alter a selection. More...
 
def isAllowedAlterView (self)
 Method to tell FreeCAD if dialog is allowed to alter a view. More...
 
def isAllowedAlterDocument (self)
 Method to tell FreeCAD if dialog is allowed to alter a document. More...
 

Public Attributes

 robot_joints
 A list of RobRotation and RobTranslation instances. More...
 
 previous_joint_values
 
 form
 A list of QDialog instances to show in the TaskView. More...
 

Detailed Description

Class providing funcionality to a RobRotation panel inside the TaskView.

This class enables user to see a manipulator in different configurations. It provides a dialogs to be shown in the TaskView. These dialogs have sliders which allow user to go through a joint range.

Definition at line 51 of file RobotPanel.py.

Constructor & Destructor Documentation

◆ __init__()

def RobotPanel.RobotPanel.__init__ (   self,
  robot_joints,
  forms 
)

Initialization method for RobotPanel.

A class instance is created. A list of proxies for associated RobRotation and RobTranslation instances are loaded as well as corresponding QDialog forms. Previously visible properties are set to be read-only as not to change when a RobotPanel is open. Finally all sliders on dialogs are moved to a position corresponding to current a RobRotation angle / RobTranslation displacement. If current value exceeds given joint range, the slider is placed to minimum or maximum.

Parameters
robot_jointsA list of RobRotation and RobTranslation instances.
formsA list of QDialog instances to show in the TaskView.

Definition at line 74 of file RobotPanel.py.

74  def __init__(self, robot_joints, forms):
75  super(RobotPanel, self).__init__()
76  self.robot_joints = robot_joints
77 
78  # Disable editing of RobRotation properties, leave some properties
79  # hidden and store previous joint variable values
80  self.previous_joint_values = []
81  for joint in robot_joints:
82  if joint.Proxy.__class__.__name__ == "RobRotationProxy":
83  self.previous_joint_values.append(joint.theta)
84  joint.setEditorMode("ValidRotation", 2)
85  elif joint.Proxy.__class__.__name__ == "RobTranslationProxy":
86  self.previous_joint_values.append(joint.d)
87  joint.setEditorMode("ValidTranslation", 2)
88 
89  for prop in joint.PropertiesList:
90  joint.setEditorMode(prop, 1)
91  joint.setEditorMode("Placement", 2)
92  joint.setEditorMode("RobotPanelActive", 2)
93  joint.RobotPanelActive = True
94 
95  # Add QDialogs to be displayed in freeCAD
96  self.form = forms
97 
98  # Add callbacks to sliders on all forms and move sliders to a position
99  # corresponding with time values
100  for i in range(len(forms)):
101  rj = robot_joints[i]
102  forms[i].sld_value.valueChanged.connect(
103  lambda value, form=forms[i], joint=rj:
104  self.sliderChanged(value, form, joint))
105  if rj.Proxy.__class__.__name__ == "RobRotationProxy":
106  val = (100 * (rj.theta - rj.thetaOffset - rj.thetaMinimum)) / \
107  (rj.thetaMaximum - rj.thetaMinimum)
108  val = min([100, max([val, 0])])
109  elif rj.Proxy.__class__.__name__ == "RobTranslationProxy":
110  val = (100 * (rj.d - rj.dOffset - rj.dMinimum)) / \
111  (rj.dMaximum - rj.dMinimum)
112  val = min([100, max([val, 0])])
113 
114  forms[i].sld_value.setValue(val)
115 

Member Function Documentation

◆ getStandardButtons()

def RobotPanel.RobotPanel.getStandardButtons (   self,
args 
)

Method to set just one button (close) to close the dialog.

*args: A tuple of unused arguments from Qt.

Definition at line 195 of file RobotPanel.py.

195  def getStandardButtons(self, *args):
196  return QDialogButtonBox.Close
197 

◆ isAllowedAlterDocument()

def RobotPanel.RobotPanel.isAllowedAlterDocument (   self)

Method to tell FreeCAD if dialog is allowed to alter a document.

Returns
True this dialog does change a document.

Definition at line 222 of file RobotPanel.py.

222  def isAllowedAlterDocument(self):
223  return True

◆ isAllowedAlterSelection()

def RobotPanel.RobotPanel.isAllowedAlterSelection (   self)

Method to tell FreeCAD if dialog is allowed to alter a selection.

Returns
False this dialog does not change a selection.

Definition at line 204 of file RobotPanel.py.

204  def isAllowedAlterSelection(self):
205  return False
206 

◆ isAllowedAlterView()

def RobotPanel.RobotPanel.isAllowedAlterView (   self)

Method to tell FreeCAD if dialog is allowed to alter a view.

Returns
True this dialog does change a view.

Definition at line 213 of file RobotPanel.py.

213  def isAllowedAlterView(self):
214  return True
215 

◆ reject()

def RobotPanel.RobotPanel.reject (   self)

Feedback method called when 'Close' button was pressed to close the panel.

Joint properties are return to be editable/read-only/invisible as they were before. After that RobotPanel is closed.

RobRotation and RobTranslation joint variables are set to the original values. RobotPanel is closed. FreeCAD and FreeCADGui documents are updated.

Definition at line 154 of file RobotPanel.py.

154  def reject(self):
155  # Return RobRotation times to previous values
156  for i in range(len(self.robot_joints)):
157  if self.robot_joints[i].Proxy.__class__.__name__ \
158  == "RobRotationProxy":
159  self.robot_joints[i].theta = self.previous_joint_values[i]
160  elif self.robot_joints[i].Proxy.__class__.__name__ \
161  == "RobTranslationProxy":
162  self.robot_joints[i].d = self.previous_joint_values[i]
163 
164  # Close the panel and recompute the document to show changes
165  # Allow editing of properties again
166  for joint in self.robot_joints:
167  for prop in joint.PropertiesList:
168  joint.setEditorMode(prop, 0)
169  joint.ViewObject.Proxy.panel = None
170 
171  # Keep some properties in read-only or hidden state
172  # if they were in it before
173  joint.setEditorMode("ObjectPlacement", 1)
174  joint.setEditorMode("ParentFramePlacement", 1)
175  if joint.Proxy.__class__.__name__ == "RobRotationProxy":
176  joint.setEditorMode("theta", 1)
177  joint.setEditorMode("ValidRotation", 2)
178  elif joint.Proxy.__class__.__name__ == "RobTranslationProxy":
179  joint.setEditorMode("d", 1)
180  joint.setEditorMode("ValidTranslation", 2)
181  joint.setEditorMode("Placement", 2)
182  joint.setEditorMode("RobotPanelActive", 2)
183  joint.RobotPanelActive = False
184 
185  FreeCADGui.Control.closeDialog()
186  FreeCAD.ActiveDocument.recompute()
187  FreeCADGui.updateGui()
188 

◆ sliderChanged()

def RobotPanel.RobotPanel.sliderChanged (   self,
  value,
  form,
  joint 
)

Feedback method called when any slider position is changed.

A joint value is extrapolated from the slider position. The value is shown on the dialog and set to a joint. Finally, the FreeCAD document and the FreeCADGui document are updated.

Parameters
valueA slider position.
formA Dialog panel on which slider was moved.
jointA RobRotation or RobTranslation associated with the form.

Definition at line 128 of file RobotPanel.py.

128  def sliderChanged(self, value, form, joint):
129  # Compute a time from the slider position and joint variable range
130  if joint.Proxy.__class__.__name__ == "RobRotationProxy":
131  val = value * (joint.thetaMaximum - joint.thetaMinimum) / 100 \
132  + joint.thetaMinimum + joint.thetaOffset
133  joint.theta = val
134  elif joint.Proxy.__class__.__name__ == "RobTranslationProxy":
135  val = value * (joint.dMaximum - joint.dMinimum) / 100 \
136  + joint.dMinimum + joint.dOffset
137  joint.d = val
138 
139  form.lbl_value.setText("Value: " + ("%5.3f" % val))
140 
141  # Recompute the document to show changes
142  FreeCAD.ActiveDocument.recompute()
143  FreeCADGui.updateGui()
144 

Member Data Documentation

◆ form

RobotPanel.RobotPanel.form

A list of QDialog instances to show in the TaskView.

Definition at line 96 of file RobotPanel.py.

◆ robot_joints

RobotPanel.RobotPanel.robot_joints

A list of RobRotation and RobTranslation instances.

Definition at line 76 of file RobotPanel.py.


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