Trajectory.TrajectoryPanel Class Reference

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

Inheritance diagram for Trajectory.TrajectoryPanel:

Public Member Functions

def __init__ (self, trajectories, forms)
 Initialization method for TrajectoryPanel. More...
 
def sliderChanged (self, value, form, trajectory)
 Feedback method called when any slider position is changed. More...
 
def close (self)
 Method used to close TrajectoryPanel. More...
 
def reject (self)
 Feedback method called when 'Cancel' button was pressed to close the panel. More...
 
def accept (self)
 Feedback method called when 'OK' 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

 trajectories
 A list of DocumentObjectGroupPython Trajectory instances. More...
 
 previous_times
 A list of trajectory times before opening a panel. More...
 
 form
 A list of QDialog instances to show in the TaskView. More...
 

Detailed Description

Class providing funcionality to a Trajectory 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 trajectory.

Definition at line 63 of file Trajectory.py.

Constructor & Destructor Documentation

◆ __init__()

def Trajectory.TrajectoryPanel.__init__ (   self,
  trajectories,
  forms 
)

Initialization method for TrajectoryPanel.

A class instance is created. A list of proxies for associated Trajectory instances are loaded as well as corresponding QDialog forms. Previously visible properties are set to be read-only as not to change when a TrajectoryPanel is open. Finally all sliders on dialogs are moved to a position corresponding to a Trajectory time.

Parameters
trajectoriesA list of DocumentObjectGroupPython Trajectory instances.
formsA list of QDialog instances to show in the TaskView.

Definition at line 87 of file Trajectory.py.

87  def __init__(self, trajectories, forms):
88  super(TrajectoryPanel, self).__init__()
89  self.trajectories = trajectories
90 
91  # Disable editing of Trajectory properties and store previous
92  # times from trajectories
93  self.previous_times = []
94  for trajectory in trajectories:
95  self.previous_times.append(trajectory.Time)
96  for prop in trajectory.PropertiesList:
97  trajectory.setEditorMode(prop, 1)
98  # Leave some properties hidden
99  trajectory.setEditorMode("Placement", 2)
100  trajectory.setEditorMode("ValidTrajectory", 2)
101 
102  # Add QDialogs to be displayed in freeCAD
103  self.form = forms
104 
105  # Add callbacks to sliders on all forms and muve sliders to a position
106  # corresponding with time values
107  for i in range(len(forms)):
108  forms[i].sld_time.valueChanged.connect(
109  lambda value, form=forms[i],
110  trajectory=trajectories[i]:
111  self.sliderChanged(value, form, trajectory))
112  val = (100 * (trajectories[i].Time
113  - trajectories[i].Timestamps[0])) / \
114  (trajectory.Timestamps[-1]
115  - trajectory.Timestamps[0])
116  forms[i].sld_time.setValue(val)
117 

Member Function Documentation

◆ accept()

def Trajectory.TrajectoryPanel.accept (   self)

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

Trajectory Times are saved. TrajectoryPanel is closed. FreeCAD and FreeCADGui documents are updated.

Definition at line 187 of file Trajectory.py.

187  def accept(self):
188  # Close the panel
189  self.close()
190 

◆ close()

def Trajectory.TrajectoryPanel.close (   self)

Method used to close TrajectoryPanel.

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

Definition at line 149 of file Trajectory.py.

149  def close(self):
150  # Allow editing of Trajecotry properties again
151  for trajectory in self.trajectories:
152  for prop in trajectory.PropertiesList:
153  trajectory.setEditorMode(prop, 0)
154  trajectory.ViewObject.Proxy.panel = None
155 
156  # Keep some properties read-only state if they were in it before
157  trajectory.setEditorMode("ObjectPlacement", 1)
158  trajectory.setEditorMode("ParentFramePlacement", 1)
159 
160  # Keep some properties hidden state if they were hidden before
161  trajectory.setEditorMode("Placement", 2)
162  trajectory.setEditorMode("ValidTrajectory", 2)
163  FreeCADGui.Control.closeDialog()
164 

◆ getStandardButtons()

def Trajectory.TrajectoryPanel.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 197 of file Trajectory.py.

197  def getStandardButtons(self, *args):
198  return QDialogButtonBox.Ok | QDialogButtonBox.Cancel
199 

◆ isAllowedAlterDocument()

def Trajectory.TrajectoryPanel.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 224 of file Trajectory.py.

224  def isAllowedAlterDocument(self):
225  return True
226 
227 

◆ isAllowedAlterSelection()

def Trajectory.TrajectoryPanel.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 206 of file Trajectory.py.

206  def isAllowedAlterSelection(self):
207  return False
208 

◆ isAllowedAlterView()

def Trajectory.TrajectoryPanel.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 215 of file Trajectory.py.

215  def isAllowedAlterView(self):
216  return True
217 

◆ reject()

def Trajectory.TrajectoryPanel.reject (   self)

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

Trajectory Times are set to the original values. TrajectoryPanel is closed. FreeCAD and FreeCADGui documents are updated.

Definition at line 171 of file Trajectory.py.

171  def reject(self):
172  # Return Trajectory times to previous values
173  for i in range(len(self.trajectories)):
174  self.trajectories[i].Time = self.previous_times[i]
175 
176  # Close the panel and recompute the document to show changes
177  self.close()
178  FreeCAD.ActiveDocument.recompute()
179  FreeCADGui.updateGui()
180 

◆ sliderChanged()

def Trajectory.TrajectoryPanel.sliderChanged (   self,
  value,
  form,
  trajectory 
)

Feedback method called when any slider position is changed.

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

Parameters
valueA slider position.
formA Dialog panel on which slider was moved.
trajectoryA Trajectory associated with the form.

Definition at line 130 of file Trajectory.py.

130  def sliderChanged(self, value, form, trajectory):
131  # Compute a time from the slider position and timestamp range
132  t = value * (trajectory.Timestamps[-1]
133  - trajectory.Timestamps[0]) / 100 \
134  + trajectory.Timestamps[0]
135 
136  # Update the time in a trajectory and
137  # recompute the document to show changes
138  trajectory.Time = t
139  form.lbl_time.setText("Time: " + ("%5.3f" % t))
140  FreeCAD.ActiveDocument.recompute()
141  FreeCADGui.updateGui()
142 

Member Data Documentation

◆ form

Trajectory.TrajectoryPanel.form

A list of QDialog instances to show in the TaskView.

Definition at line 103 of file Trajectory.py.

◆ previous_times

Trajectory.TrajectoryPanel.previous_times

A list of trajectory times before opening a panel.

Definition at line 93 of file Trajectory.py.

◆ trajectories

Trajectory.TrajectoryPanel.trajectories

A list of DocumentObjectGroupPython Trajectory instances.

Definition at line 89 of file Trajectory.py.


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