Manipulator (hwx.inspire.gui)¶
Base class for manipulators
Extends Drawable to:
implement methods so it works with Context:
setObject - called from context when an object is selected
hide - called from context when it is deactivated
isMouseOverAny - dont process mouse events in the context
adds/remove itself to the ManipulatorRootNode
- Inherits:
 Drawable (hwx.inspire.gui)
Public Methods¶
classmethod isMouseOverAny (cls)
classmethod popup (cls, context, obj)
dragPoint (self, location)
draw (self)
drawHovered (self, node)
drawUnhovered (self, node)
flatArrow (self, origin, direction)
forceRedraw (self)
getGuiUnitsFactor (self, value=1, units=’length’)
getMousePosition (self, event, origin=None, direction=None, snapping=True)
getPointAlongLine (self, pt, direction, lengthInPixels)
getPointOnLine (self, event, origin, direction)
getPointOnXyPlane (self, event, xform, snapping=True)
getSnapPoint (self, event)
getViewNormal (self)
getViewScaleAtPoint (self, pt)
hide (self)
isMouseOver (self)
isPickable (self)
isactive (self)
linearRuler (self, pt1, pt2, axis)
noteState (self, state=None)
onObjectDeleted (self, obj)
onObjectModified (self, obj, attr)
redrawView (self)
setCursor (self, cursor)
setObject (self, obj)
show (self, redrawView=False)
worldToScreen (self, pt)
Method Details¶
- classmethod isMouseOverAny(cls)¶
 
Is the mouse over any pickable manipulators
This is used by the context not pass the mouse events to mouse enabled tools like the PickList and SelectList.
This checks all manipulators because it is possible to have manipulators associated with objects, that are not tied to the context.
- returns
 bool
- classmethod popup(cls, context, obj)¶
 
Create and show Manipulator for the selected object.
Should be called during Context.popupObjectEditors.
- param obj
 Object being edited.
- type obj
 Named
- param context
 The active context.
- type context
 Context
- dragPoint(self, location)¶
 
Create a drag point at specified location.
- param location
 location of the new drag point.
- type location
 math.Point
- returns
 new created drag point.
- rtype
 DragPointDrawable
- draw(self)¶
 
Overload in derived classes to render this.
- drawHovered(self, node)¶
 
Show that the mouse is over a Node.
- param node
 Node to be drawn hovered.
- type node
 Node
- drawUnhovered(self, node)¶
 
Show that the mouse is no longer over a Node
- param node
 Node to be drawn unhovered.
- type node
 Node
- flatArrow(self, origin, direction)¶
 
Create a flat arrow with specified origin and direction.
- param origin
 arrow origin.
- type origin
 math.Point
- param direction
 arrow direction.
- type direction
 math.Vector
- returns
 new created arrow.
- rtype
 FlatArrowDrawable
- forceRedraw(self)¶
 
When this is created or modified, make sure it is drawn.
- getGuiUnitsFactor(self, value=1, units='length')¶
 
Get a base to gui units scale factor.
- param value
 base value.
- type value
 float
- param units
 unit type.
- type units
 str
- returns
 scale factor to obtain gui value equivalent to base value.
- rtype
 float
- getMousePosition(self, event, origin=None, direction=None, snapping=True)¶
 
Returns mouse position. Give preference to the closest snap point if snapping argument is True or the closest apparent point on line if origin and direction of line are provided as arguments.
- param event
 mouse event.
- type event
 Event
- param origin
 line point.
- type origin
 math.Point
- param direction
 line direction.
- type direction
 math.Vector
- param snapping
 if True give preference to snap points.
- type snapping
 bool
- returns
 math.Point
- getPointAlongLine(self, pt, direction, lengthInPixels)¶
 
Returns a point projected on the line defined by pt and direction at the specified distance in pixels.
If you have a line/arrow/whatever 10 pixles long, you know its start point and its direction in model space, what is its end point in model space.
This is used to calculate snap gradients independent of the view zoom.
- param pt
 point of the line.
- type pt
 math.Point
- param direction
 direction of the line.
- type direction
 math.Vector
- param lengthInPixels
 distance in pixels to the point.
- type lengthInPixels
 int
- returns
 math.Point
- getPointOnLine(self, event, origin, direction)¶
 
Return the closest apparent point to a line. If the lines are parallel, or if the closest point is out of view, returns None.
- param event
 event being processed.
- type event
 Event
- param origin
 origin of the line.
- type origin
 math.Point
- param direction
 line direction.
- type direction
 math.Vector
- returns
 math.Point
- getPointOnXyPlane(self, event, xform, snapping=True)¶
 
Returns the closest apparent point to a plane.
- param event
 event being processed.
- type event
 Event
- param xform
 plane definition.
- type xform
 Matrix44
- param snapping
 give preference to snap points.
- type snapping
 bool
- returns
 math.Point
- getSnapPoint(self, event)¶
 
Return the closest snap point under the mouse.
- returns
 math.Point
- getViewNormal(self)¶
 
Return a vector pointing from the camera to the eye.
- getViewScaleAtPoint(self, pt)¶
 
Return a scale factor that is zoom/model independent. Used to scaleToScreen in one direction. For example we want the gradations of the LinearRuler a certain height independent of the view zoom, but because the length of the ruler changes we can not user scaleToScreen.
- param pt
 view point.
- type pt
 math.Point
- returns
 The scale factor.
- rtype
 float
- hide(self)¶
 
Deactivate this manipulator.
- isMouseOver(self)¶
 
Returns True if the mouse is over this manipulator and if it is pickable.
- isPickable(self)¶
 
Return False to disable picking. Used in derived some derived classes to disable picking the manipulator when the <Ctrl> key is down.
- isactive(self)¶
 
Return True if Manipulator is active.
- linearRuler(self, pt1, pt2, axis)¶
 
Create a linear ruler.
- param pt1
 one endpoint of ruler.
- type pt1
 math.Point
- param pt2
 one endpoint of ruler.
- type pt2
 math.Point
- param axis
 axis of the ruler.
- type axis
 math.Vector
- returns
 new created linear ruler.
- rtype
 LinearRulerDrawable
- noteState(self, state=None)¶
 
Shortcut to set a history noteState to support undo/redo.
- param state
 name for noteState.
- type state
 str
- onObjectDeleted(self, obj)¶
 
Hide manipulator when its object is deleted.
- param obj
 manipulator object.
- type obj
 Named | Feature | Hole
- onObjectModified(self, obj, attr)¶
 
Redraw manipulator when its object is modified.
- param obj
 event containing the object.
- type obj
 Event
- param attr
 modified Attribute.
- type attr
 Attribute
- redraw(self, alwaysOnTop=True, **kwds)¶
 
Overload from base class so this is drawn ‘on top’ of the model.
- param alwaysOnTop
 draw this ‘on top’ of the model.
- type alwaysOnTop
 bool
- param **kwds
 keyword arguments for Drawable.redraw()
- redrawView(self)¶
 
Force a redraw of the view.
- setCursor(self, cursor)¶
 
Set the named cursor if it is not the current one.
- param cursor
 name of the cursor, one of “” : the default cursor (arrow) “MAIN” : show the user whhat context he is in ‘+’ : show an object can be added to the pick list ‘-’ : show an object can be removed from the pick list ‘+- : show an object can be toggled (windowMode) ‘x’ : show an object is in the pick list .png : the name of an icon file other : the name of a registered cursor
- type cursor
 str
- setObject(self, obj)¶
 
Set manipulator object. Called from context when an object is selected.
- param obj
 selected object.
- type obj
 Named | Feature | Hole
- show(self, redrawView=False)¶
 
Activate this manipulator.
Called from setObject to add self to ManipulatorRootNode.
- worldToScreen(self, pt)¶
 
For a given point get screen projection point in pixels.
- param pt
 Point for which we want to get the screen projection.
- type pt
 math.Point
- returns
 screen projection point in pixels.
- rtype
 math.Point