============================= 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: - :ref:`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) | +-----------------------------------------------------------------------------+ | redraw_ (self, alwaysOnTop=True, **kwds) | +-----------------------------------------------------------------------------+ | redrawView_ (self) | +-----------------------------------------------------------------------------+ | setCursor_ (self, cursor) | +-----------------------------------------------------------------------------+ | setObject_ (self, obj) | +-----------------------------------------------------------------------------+ | show_ (self, redrawView=False) | +-----------------------------------------------------------------------------+ | worldToScreen_ (self, pt) | +-----------------------------------------------------------------------------+ -------------- Method Details -------------- .. _isMouseOverAny: .. 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 .. _popup: .. 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: .. method:: 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: .. method:: draw(self) Overload in derived classes to render this. .. _drawHovered: .. method:: drawHovered(self, node) Show that the mouse is over a Node. :param node: Node to be drawn hovered. :type node: Node .. _drawUnhovered: .. method:: drawUnhovered(self, node) Show that the mouse is no longer over a Node :param node: Node to be drawn unhovered. :type node: Node .. _flatArrow: .. method:: 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: .. method:: forceRedraw(self) When this is created or modified, make sure it is drawn. .. _getGuiUnitsFactor: .. method:: 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: .. method:: 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: .. method:: 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: .. method:: 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: .. method:: 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: .. method:: getSnapPoint(self, event) Return the closest snap point under the mouse. :returns: math.Point .. _getViewNormal: .. method:: getViewNormal(self) Return a vector pointing from the camera to the eye. .. _getViewScaleAtPoint: .. method:: 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: .. method:: hide(self) Deactivate this manipulator. .. _isMouseOver: .. method:: isMouseOver(self) Returns True if the mouse is over this manipulator and if it is pickable. .. _isPickable: .. method:: isPickable(self) Return False to disable picking. Used in derived some derived classes to disable picking the manipulator when the key is down. .. _isactive: .. method:: isactive(self) Return True if Manipulator is active. .. _linearRuler: .. method:: 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: .. method:: noteState(self, state=None) Shortcut to set a history noteState to support undo/redo. :param state: name for noteState. :type state: str .. _onObjectDeleted: .. method:: onObjectDeleted(self, obj) Hide manipulator when its object is deleted. :param obj: manipulator object. :type obj: Named | Feature | Hole .. _onObjectModified: .. method:: 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: .. method:: 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: .. method:: redrawView(self) Force a redraw of the view. .. _setCursor: .. method:: 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: .. method:: setObject(self, obj) Set manipulator object. Called from context when an object is selected. :param obj: selected object. :type obj: Named | Feature | Hole .. _show: .. method:: show(self, redrawView=False) Activate this manipulator. Called from setObject to add self to ManipulatorRootNode. .. _worldToScreen: .. method:: 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