CollisionObject.ViewProviderCollisionProxy Class Reference

Proxy class for a Gui.ViewProviderDocumentObject Collision.ViewObject. More...

Inheritance diagram for CollisionObject.ViewProviderCollisionProxy:

Public Member Functions

def __init__ (self, vp, color=None)
 Initialization method for ViewProviderCollisionProxy. More...
 
def doubleClicked (self, vp)
 Method called when CollisionDetector is double-clicked in the Tree View. More...
 
def setupContextMenu (self, vp, menu)
 Method editing a context menu for right click on a Collision. More...
 
def getIcon (self)
 Method used to get a path to an icon which will appear in the tree view. More...
 
def setProperties (self, vp)
 Method to hide unused properties. More...
 

Detailed Description

Proxy class for a Gui.ViewProviderDocumentObject Collision.ViewObject.

A ViewProviderServerProxy instance changes a FeaturePython Collision's icon. It prevents user from transforming a Collision object after double-clicking it in the Tree View. It also removes options to Transform and Set colors... from a context menu.

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

    a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                         "Collision")
    CollisionProxy(a, shape, cause1, cause2)

Definition at line 140 of file CollisionObject.py.

Constructor & Destructor Documentation

◆ __init__()

def CollisionObject.ViewProviderCollisionProxy.__init__ (   self,
  vp,
  color = None 
)

Initialization method for ViewProviderCollisionProxy.

A class instance is created and made a Proxy for a generic Gui.ViewProviderDocumentObject Collision.ViewObject. This method changes LineColor, PointColor, ShapeColor,LineWidthandPointSize` properties of a Collision instance and hides unnecessary unused View properties.

Parameters
vpA barebone Gui.ViewProviderDocumentObject Collision.ViewObject.
colorA tuple of floats specifying Point, Line and Shape RGB color.

Definition at line 154 of file CollisionObject.py.

154  def __init__(self, vp, color=None):
155  if color is None:
156  color = (1.0, 0.0, 0.0)
157  vp.LineColor = vp.PointColor = vp.ShapeColor = color
158  vp.LineWidth = 10.0
159  vp.PointSize = 10.0
160  self.setProperties(vp)
161  vp.Proxy = self
162 

Member Function Documentation

◆ doubleClicked()

def CollisionObject.ViewProviderCollisionProxy.doubleClicked (   self,
  vp 
)

Method called when CollisionDetector is double-clicked in the Tree View.

It just prevents user from accessing transformation panel and transforming a Collision object. It's enough to just implement it and return True for this purpose.

Parameters
vpA double-clicked Collision.ViewObject.
Returns
True to specify that it was implemented and executed.

Definition at line 176 of file CollisionObject.py.

176  def doubleClicked(self, vp):
177  return True
178 

◆ getIcon()

def CollisionObject.ViewProviderCollisionProxy.getIcon (   self)

Method used to get a path to an icon which will appear in the tree view.

Returns
A path to the icon.

Definition at line 199 of file CollisionObject.py.

199  def getIcon(self):
200  return path.join(PATH_TO_ICONS, "Collision.png")
201 

◆ setProperties()

def CollisionObject.ViewProviderCollisionProxy.setProperties (   self,
  vp 
)

Method to hide unused properties.

All unused unnecessary FeaturePythons properties are hidden except for Transparency and Visibility.

Parameters
vpA Gui.ViewProviderDocumentObject Collision.ViewObject.

Definition at line 211 of file CollisionObject.py.

211  def setProperties(self, vp):
212  vp.setEditorMode("AngularDeflection", 2)
213  vp.setEditorMode("BoundingBox", 2)
214  vp.setEditorMode("Deviation", 2)
215  vp.setEditorMode("DisplayMode", 2)
216  vp.setEditorMode("DrawStyle", 2)
217  vp.setEditorMode("Lighting", 2)
218  vp.setEditorMode("LineColor", 2)
219  vp.setEditorMode("LineWidth", 2)
220  vp.setEditorMode("PointColor", 2)
221  vp.setEditorMode("PointSize", 2)
222  vp.setEditorMode("Selectable", 2)
223  vp.setEditorMode("SelectionStyle", 2)
224  vp.setEditorMode("ShapeColor", 2)

◆ setupContextMenu()

def CollisionObject.ViewProviderCollisionProxy.setupContextMenu (   self,
  vp,
  menu 
)

Method editing a context menu for right click on a Collision.

The Transform and Set colors... items are removed from the context menu shown upon right click on the Collision in the Tree View. This is done to prevent user from transforming the Collision object or changing its color.

Parameters
vpA right-clicked Collision.ViewObject.
menuA Qt's QMenu to be edited.

Definition at line 190 of file CollisionObject.py.

190  def setupContextMenu(self, vp, menu):
191  menu.clear()
192 

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