Notation used in Ruby API documentation
Module: lay
Description: The plugin object
Class hierarchy: Plugin » PluginBase
This class provides the actual plugin implementation. Each view gets its own instance of the plugin class. The plugin factory PluginFactory class must be specialized to provide a factory for new objects of the Plugin class. See the documentation there for details about the plugin mechanism and the basic concepts.
This class has been introduced in version 0.22.
[const] | Plugin ptr | _const_cast | Returns a non-const reference to self. | |
void | _create | Ensures the C++ object is created | ||
void | _destroy | Explicitly destroys the object | ||
[const] | bool | _destroyed? | Returns a value indicating whether the object was already destroyed | |
[const] | bool | _is_const_object? | Returns a value indicating whether the reference is a const reference | |
void | _manage | Marks the object as managed by the script side. | ||
void | _unmanage | Marks the object as no longer owned by the script side. | ||
[virtual] | void | activated | Gets called when the plugin is activated (selected in the tool bar) | |
void | add_edge_marker | (const DEdge e, bool emphasize = false) | Creates a cursor to indicate an edge | |
void | add_edge_marker | (const Edge e, int cv_index, const LayerInfo layer, bool emphasize = false) | Creates a cursor to indicate an edge | |
void | add_mouse_cursor | (const DPoint p, bool emphasize = false) | Creates a cursor to indicate the mouse position | |
void | add_mouse_cursor | (const Point p, int cv_index, const LayerInfo layer, bool emphasize = false) | Creates a cursor to indicate the mouse position | |
void | clear_mouse_cursors | Clears all existing mouse cursors | ||
[virtual] | void | config_finalize | Sends the post-configuration request to the plugin | |
[virtual] | bool | configure | (string name, string value) | Sends configuration requests to the plugin |
[virtual] | void | deactivated | Gets called when the plugin is deactivated and another plugin is activated | |
[const] | Dispatcher ptr | dispatcher | Gets the dispatcher object the plugin is associated with | |
[virtual] | void | drag_cancel | Gets called on various occasions when some mouse drag operation should be canceled | |
EditorOptionsPageBase ptr[] | editor_options_pages | Gets the editor options pages which are associated with the view | ||
[virtual] | bool | enter_event | (bool prio) | Handles the enter event (mouse enters canvas area of view) |
EditorOptionsPageBase ptr | focus_page | Gets the (first) focus page | ||
[virtual] | int | focus_page_open | Gets called when the focus page wants to be opened - i.e. if 'Tab' is pressed during editing | |
void | grab_mouse | Redirects mouse events to this plugin, even if the plugin is not active. | ||
[virtual,const] | bool | has_tracking_position | Gets a value indicating whether the plugin provides a tracking position | |
[virtual] | bool | key_event | (unsigned int key, unsigned int buttons) | Handles the key pressed event |
[virtual] | bool | leave_event | (bool prio) | Handles the leave event (mouse leaves canvas area of view) |
[virtual] | void | menu_activated | (string symbol) | Gets called when a custom menu item is selected |
[virtual] | bool | mouse_button_pressed_event | (DPoint p, unsigned int buttons, bool prio) | Handles the mouse button pressed event |
[virtual] | bool | mouse_button_released_event | (DPoint p, unsigned int buttons, bool prio) | Handles the mouse button release event |
[virtual] | bool | mouse_click_event | (DPoint p, unsigned int buttons, bool prio) | Handles the mouse button click event (after the button has been released) |
[virtual] | bool | mouse_double_click_event | (DPoint p, unsigned int buttons, bool prio) | Handles the mouse button double-click event |
[virtual] | bool | mouse_moved_event | (DPoint p, unsigned int buttons, bool prio) | Handles the mouse move event |
void | set_cursor | (int cursor_type) | Sets the cursor in the view area to the given type | |
[const] | DPoint | snap | (DPoint p) | Snaps a point to the edit grid |
[const] | DVector | snap | (DVector v) | Snaps a vector to the edit grid |
[const] | DPoint | snap | (const DPoint p, const DPoint plast, bool connect = false, AngleConstraintType ac = AC_Global) | Snaps a point to the edit grid with an angle constraint |
[const] | DVector | snap | (const DVector v, bool connect = false, AngleConstraintType ac = AC_Global) | Snaps a move vector to the edit grid with and implies an angle constraint |
DPoint | snap2 | (const DPoint p, bool visualize = false) | Snaps a point to the edit grid with advanced snapping (including object snapping) | |
DPoint | snap2 | (const DPoint p, const DPoint plast, bool connect = false, AngleConstraintType ac = AC_Global, bool visualize = false) | Snaps a point to the edit grid with an angle constraint with advanced snapping (including object snapping) | |
[virtual,const] | DPoint | tracking_position | Gets the tracking position | |
void | ungrab_mouse | Removes a mouse grab registered with grab_mouse. | ||
[virtual] | void | update | Gets called when the view has changed | |
[const] | LayoutView ptr | view | Gets the view object the plugin is associated with | |
[virtual] | bool | wheel_event | (int delta, bool horizontal, DPoint p, unsigned int buttons, bool prio) | Handles the mouse wheel event |
[static,const] | AngleConstraintType | AC_Any | Specifies to use any angle and not snap to a specific direction. | |
[static,const] | AngleConstraintType | AC_Diagonal | Specifies to use multiples of 45 degree. | |
[static,const] | AngleConstraintType | AC_Global | Specifies to use the global angle constraint. | |
[static,const] | AngleConstraintType | AC_Horizontal | Specifies to use horizontal direction only. | |
[static,const] | AngleConstraintType | AC_Ortho | Specifies to use multiples of 90 degree. | |
[static,const] | AngleConstraintType | AC_Vertical | Specifies to use vertical direction only. | |
AngleConstraintType | ac_from_buttons | (unsigned int buttons) | Creates an angle constraint from a button combination |
AC_Any | Signature: [static,const] AngleConstraintType AC_Any Description: Specifies to use any angle and not snap to a specific direction. Python specific notes: | |||||||||
AC_Diagonal | Signature: [static,const] AngleConstraintType AC_Diagonal Description: Specifies to use multiples of 45 degree. Python specific notes: | |||||||||
AC_Global | Signature: [static,const] AngleConstraintType AC_Global Description: Specifies to use the global angle constraint. Python specific notes: | |||||||||
AC_Horizontal | Signature: [static,const] AngleConstraintType AC_Horizontal Description: Specifies to use horizontal direction only. Python specific notes: | |||||||||
AC_Ortho | Signature: [static,const] AngleConstraintType AC_Ortho Description: Specifies to use multiples of 90 degree. Python specific notes: | |||||||||
AC_Vertical | Signature: [static,const] AngleConstraintType AC_Vertical Description: Specifies to use vertical direction only. Python specific notes: | |||||||||
_const_cast | Signature: [const] Plugin ptr _const_cast Description: Returns a non-const reference to self. Basically, this method allows turning a const object reference to a non-const one. This method is provided as last resort to remove the constness from an object. Usually there is a good reason for a const object reference, so using this method may have undesired side effects. This method has been introduced in version 0.29.6. | |||||||||
_create | Signature: void _create Description: Ensures the C++ object is created Use this method to ensure the C++ object is created, for example to ensure that resources are allocated. Usually C++ objects are created on demand and not necessarily when the script object is created. | |||||||||
_destroy | Signature: void _destroy Description: Explicitly destroys the object Explicitly destroys the object on C++ side if it was owned by the script interpreter. Subsequent access to this object will throw an exception. If the object is not owned by the script, this method will do nothing. | |||||||||
_destroyed? | Signature: [const] bool _destroyed? Description: Returns a value indicating whether the object was already destroyed This method returns true, if the object was destroyed, either explicitly or by the C++ side. The latter may happen, if the object is owned by a C++ object which got destroyed itself. | |||||||||
_is_const_object? | Signature: [const] bool _is_const_object? Description: Returns a value indicating whether the reference is a const reference This method returns true, if self is a const reference. In that case, only const methods may be called on self. | |||||||||
_manage | Signature: void _manage Description: Marks the object as managed by the script side. After calling this method on an object, the script side will be responsible for the management of the object. This method may be called if an object is returned from a C++ function and the object is known not to be owned by any C++ instance. If necessary, the script side may delete the object if the script's reference is no longer required. Usually it's not required to call this method. It has been introduced in version 0.24. | |||||||||
_unmanage | Signature: void _unmanage Description: Marks the object as no longer owned by the script side. Calling this method will make this object no longer owned by the script's memory management. Instead, the object must be managed in some other way. Usually this method may be called if it is known that some C++ object holds and manages this object. Technically speaking, this method will turn the script's reference into a weak reference. After the script engine decides to delete the reference, the object itself will still exist. If the object is not managed otherwise, memory leaks will occur. Usually it's not required to call this method. It has been introduced in version 0.24. | |||||||||
ac_from_buttons | Signature: [static] AngleConstraintType ac_from_buttons (unsigned int buttons) Description: Creates an angle constraint from a button combination This method provides the angle constraints implied by a specific modifier combination, i.e. 'Shift' will render ortho snapping. Use this function to generate angle constraints following the established conventions. This method has been added in version 0.30.4. | |||||||||
activated | Signature: [virtual] void activated Description: Gets called when the plugin is activated (selected in the tool bar) | |||||||||
add_edge_marker | (1) Signature: void add_edge_marker (const DEdge e, bool emphasize = false) Description: Creates a cursor to indicate an edge This function will create a marker that indicates an edge - for example the edge that a point is snapping to. If 'emphasize' is true, the cursor is displayed in a 'stronger' style. Before you use this method, clear existing edge markers and cursors with clear_mouse_cursors. This method has been added in version 0.30.4. | |||||||||
(2) Signature: void add_edge_marker (const Edge e, int cv_index, const LayerInfo layer, bool emphasize = false) Description: Creates a cursor to indicate an edge This version of this method creates an edge marker based on the integer-unit edge and a source cellview index plus a layer info. The cellview index and layer info is used to derive the transformation rules to apply to the edge and to compute the final position. This method has been added in version 0.30.4. | ||||||||||
add_mouse_cursor | (1) Signature: void add_mouse_cursor (const DPoint p, bool emphasize = false) Description: Creates a cursor to indicate the mouse position This function will create a marker that indicates the (for example snapped) mouse position. In addition to this, it will establish the position for the tracking cursor, if mouse tracking is enabled in the application. You can override the tracking position by reimplementing tracking_position and has_tracking_position. To enable tracking, make sure a reimplementation of mouse_moved_event does not consume the event and returns 'false'. Multiple cursors can be created. In that case, the tracking position is given by the last cursor. If 'emphasize' is true, the cursor is displayed in a 'stronger' style - i.e. with a double circle instead of a single one. Before you use this method, clear existing cursors with clear_mouse_cursors. This method has been added in version 0.30.4. | |||||||||
(2) Signature: void add_mouse_cursor (const Point p, int cv_index, const LayerInfo layer, bool emphasize = false) Description: Creates a cursor to indicate the mouse position This version of this method creates a mouse cursor based on the integer-unit point and a source cellview index plus a layer info. The cellview index and layer info is used to derive the transformation rules to apply to the point and to compute the final position. This method has been added in version 0.30.4. | ||||||||||
clear_mouse_cursors | Signature: void clear_mouse_cursors Description: Clears all existing mouse cursors Use this function to remove exisiting mouse cursors (see add_mouse_cursor and add_edge_marker). This method is automatically called when the plugin becomes deactivated. This method has been added in version 0.30.4. | |||||||||
config_finalize | Signature: [virtual] void config_finalize Description: Sends the post-configuration request to the plugin After all configuration parameters have been sent, 'config_finalize' is called to given the plugin a chance to update its internal state according to the new configuration. | |||||||||
configure | Signature: [virtual] bool configure (string name, string value) Description: Sends configuration requests to the plugin
When a configuration variable is changed, the new value is reported to the plugin by calling the 'configure' method. | |||||||||
deactivated | Signature: [virtual] void deactivated Description: Gets called when the plugin is deactivated and another plugin is activated | |||||||||
dispatcher | Signature: [const] Dispatcher ptr dispatcher Description: Gets the dispatcher object the plugin is associated with This method returns the dispatcher object that the plugin is associated with. The dispatcher object manages the configuration parameters. 'set_config', 'get_config' and 'commit_config' can be used on this object to get or set configuration parameters. Configuration parameters are a way to persist information and the preferred way of communicating with editor option pages and configuration pages. This convenience method has been added in version 0.30.4. | |||||||||
drag_cancel | Signature: [virtual] void drag_cancel Description: Gets called on various occasions when some mouse drag operation should be canceled If the plugin implements some press-and-drag or a click-and-drag operation, this callback should cancel this operation and return to some state waiting for a new mouse event. | |||||||||
editor_options_pages | Signature: EditorOptionsPageBase ptr[] editor_options_pages Description: Gets the editor options pages which are associated with the view The editor options pages are created by the plugin factory class and are associated with this plugin. This method allows locating them and using them for plugin-specific purposes. This method has been added in version 0.30.4. | |||||||||
enter_event | Signature: [virtual] bool enter_event (bool prio) Description: Handles the enter event (mouse enters canvas area of view) The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse enters the canvas area. This method does not have a position nor button flags. | |||||||||
focus_page | Signature: EditorOptionsPageBase ptr focus_page Description: Gets the (first) focus page Focus pages are editor options pages that have a true value for EditorOptionsPage#is_focus_page. The pages can be navigated to quickly or can be shown in a modal dialog from the editor function. This method returns the first focus page present in the editor options pages stack. This method has been added in version 0.30.4. | |||||||||
focus_page_open | Signature: [virtual] int focus_page_open Description: Gets called when the focus page wants to be opened - i.e. if 'Tab' is pressed during editing The default implementation calls EditorOptionsPage#show on the focus page. This method can be overloaded to provide certain actions before or after the page is shown, specifically if the page is a modal one. For example, it can update the page with current dimensions of a shape that is created and after committing the page, adjust the shape accordingly. This method has been added in version 0.30.4. | |||||||||
grab_mouse | Signature: void grab_mouse Description: Redirects mouse events to this plugin, even if the plugin is not active. | |||||||||
has_tracking_position | Signature: [virtual,const] bool has_tracking_position Description: Gets a value indicating whether the plugin provides a tracking position The tracking position is shown in the lower-left corner of the layout window to indicate the current position. If this method returns true for the active service, the application will fetch the position by calling tracking_position rather than displaying the original mouse position. The default implementation enables tracking if a mouse cursor has been set using add_mouse_cursor. When enabling tracking, make sure a reimplementation of mouse_moved_event does not consume the event and returns 'false'. This method has been added in version 0.27.6. | |||||||||
key_event | Signature: [virtual] bool key_event (unsigned int key, unsigned int buttons) Description: Handles the key pressed event
This method will called by the view on the active plugin when a button is pressed on the mouse. If the plugin handles the event, it should return true to indicate that the event should not be processed further. | |||||||||
leave_event | Signature: [virtual] bool leave_event (bool prio) Description: Handles the leave event (mouse leaves canvas area of view) The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse leaves the canvas area. This method does not have a position nor button flags. | |||||||||
menu_activated | Signature: [virtual] void menu_activated (string symbol) Description: Gets called when a custom menu item is selected When a menu item is clicked which was registered with the plugin factory, the plugin's 'menu_activated' method is called for the current view. The symbol registered for the menu item is passed in the 'symbol' argument. | |||||||||
mouse_button_pressed_event | Signature: [virtual] bool mouse_button_pressed_event (DPoint p, unsigned int buttons, bool prio) Description: Handles the mouse button pressed event
This method will called by the view when a button is pressed on the mouse. First, the plugins that grabbed the mouse with grab_mouse will receive this event with 'prio' set to true in the reverse order the plugins grabbed the mouse. The loop will terminate if one of the mouse event handlers returns true. If that is not the case or no plugin has grabbed the mouse, the active plugin receives the mouse event with 'prio' set to true. If no receiver accepted the mouse event by returning true, it is sent again to all plugins with 'prio' set to false. Again, the loop terminates if one of the receivers returns true. The second pass gives inactive plugins a chance to monitor the mouse and implement specific actions - i.e. displaying the current position. This event is not sent immediately when the mouse button is pressed but when a signification movement for the mouse cursor away from the original position is detected. If the mouse button is released before that, a mouse_clicked_event is sent rather than a press-move-release sequence. | |||||||||
mouse_button_released_event | Signature: [virtual] bool mouse_button_released_event (DPoint p, unsigned int buttons, bool prio) Description: Handles the mouse button release event The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse button is released. | |||||||||
mouse_click_event | Signature: [virtual] bool mouse_click_event (DPoint p, unsigned int buttons, bool prio) Description: Handles the mouse button click event (after the button has been released) The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse button has been released without moving it. | |||||||||
mouse_double_click_event | Signature: [virtual] bool mouse_double_click_event (DPoint p, unsigned int buttons, bool prio) Description: Handles the mouse button double-click event The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse button has been double-clicked. | |||||||||
mouse_moved_event | Signature: [virtual] bool mouse_moved_event (DPoint p, unsigned int buttons, bool prio) Description: Handles the mouse move event The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse is moved in the canvas area. The mouse move event is important for a number of background jobs, such as coordinate display in the status bar. Hence, you should not consume the event - i.e. you should return 'false' from this method. | |||||||||
set_cursor | Signature: void set_cursor (int cursor_type) Description: Sets the cursor in the view area to the given type Setting the cursor has an effect only inside event handlers, i.e. mouse_button_pressed_event. The cursor is not set permanently. Is is reset in the mouse move handler unless a button is pressed or the cursor is explicitly set again in mouse_moved_event. The cursor type is one of the cursor constants in the Cursor class, i.e. 'CursorArrow' for the normal cursor. | |||||||||
snap | (1) Signature: [const] DPoint snap (DPoint p) Description: Snaps a point to the edit grid
If the edit grid is given, the point's x and y components are snapped to the edit grid. Otherwise the global grid is used. Edit and global grid are set by configuration options. This method has been added in version 0.30.4. | |||||||||
(2) Signature: [const] DVector snap (DVector v) Description: Snaps a vector to the edit grid
If the edit grid is given, the vector's x and y components are snapped to the edit grid. Otherwise the global grid is used. Edit and global grid are set by configuration options. This method has been added in version 0.30.4. | ||||||||||
(3) Signature: [const] DPoint snap (const DPoint p, const DPoint plast, bool connect = false, AngleConstraintType ac = AC_Global) Description: Snaps a point to the edit grid with an angle constraint
This method snaps point "p" relative to the initial point "plast". This method tries to snap "p" to the edit or global grid (edit grid with higher priority), while trying to observe the angle constraint that imposes a constraint on the way "p" can move relative to "plast". The "connect" parameter will decide which angle constraint to use, unless "ac" specifies an angle constraint already. If "connect" is true, the line between "p" and "plast" is regarded a connection between points (e.g. a polygon edge) and the connection angle constraint applies. Otherwise the move constraint applies. The angle constraint determines how "p" can move in relation to "plast" - for example, if the angle constraint is Plugin#AC_Ortho, "p" can only move away from "plast" in horizontal or vertical direction. This method has been added in version 0.30.4. | ||||||||||
(4) Signature: [const] DVector snap (const DVector v, bool connect = false, AngleConstraintType ac = AC_Global) Description: Snaps a move vector to the edit grid with and implies an angle constraint
The "connect" parameter will decide which angle constraint to use, unless "ac" specifies an angle constraint already. If "connect" is true, the vector is regarded a connection line between points (e.g. a polygon edge) and the connection angle constraint applies. Otherwise the move constraint applies. The angle constraint determines how "p" can move in relation to "plast" - for example, if the angle constraint is Plugin#AC_Ortho, "p" can only move away from "plast" in horizontal or vertical direction. This method has been added in version 0.30.4. | ||||||||||
snap2 | (1) Signature: DPoint snap2 (const DPoint p, bool visualize = false) Description: Snaps a point to the edit grid with advanced snapping (including object snapping)
This method behaves like the other "snap2" variant, but does not allow to specify an angle constraint. Only grid constraints and snapping to objects is supported. If "visualize" is true, the function will generate calls to add_mouse_cursor or add_edge_marker to provide a visualization of the edges or vertexes that the point is snapping to. clear_mouse_cursors will be called before. This method has been added in version 0.30.4. | |||||||||
(2) Signature: DPoint snap2 (const DPoint p, const DPoint plast, bool connect = false, AngleConstraintType ac = AC_Global, bool visualize = false) Description: Snaps a point to the edit grid with an angle constraint with advanced snapping (including object snapping)
This method will snap the point p, given an initial point "plast". This includes an angle constraint. If "connect" is true, the line between "plast" and "p" is regarded a connection (e.g. a polygon edge). If not, the line is regarded a move vector. If "ac" is Plugin#AC_Global, the angle constraint is taken from the connect or move angle constraint, depending on the value of "connect". The angle constraint determines how "p" can move in relation to "plast" - for example, if the angle constraint is Plugin#AC_Ortho, "p" can only move away from "plast" in horizontal or vertical direction. This method considers options like global or editing grid or whether the target point will snap to another object. The behavior is given by the respective configuration. If "visualize" is true, the function will generate calls to add_mouse_cursor or add_edge_marker to provide a visualization of the edges or vertexes that the point is snapping to. clear_mouse_cursors will be called before. This method has been added in version 0.30.4. | ||||||||||
tracking_position | Signature: [virtual,const] DPoint tracking_position Description: Gets the tracking position See has_tracking_position for details. The default implementation takes the tracking position from a mouse cursor, if you have created one using add_mouse_cursor. When enabling tracking, make sure a reimplementation of mouse_moved_event does not consume the event and returns 'false'. This method has been added in version 0.27.6. | |||||||||
ungrab_mouse | Signature: void ungrab_mouse Description: Removes a mouse grab registered with grab_mouse. | |||||||||
update | Signature: [virtual] void update Description: Gets called when the view has changed This method is called in particular if the view has changed the visible rectangle, i.e. after zooming in or out or panning. This callback can be used to update any internal states that depend on the view's state. | |||||||||
view | Signature: [const] LayoutView ptr view Description: Gets the view object the plugin is associated with This method returns the view object that the plugin is associated with. This convenience method has been added in version 0.30.4. | |||||||||
wheel_event | Signature: [virtual] bool wheel_event (int delta, bool horizontal, DPoint p, unsigned int buttons, bool prio) Description: Handles the mouse wheel event The behaviour of this callback is the same than for mouse_press_event, except that it is called when the mouse wheel is rotated. Additional parameters for this event are 'delta' (the rotation angle in units of 1/8th degree) and 'horizontal' which is true when the horizontal wheel was rotated and false if the vertical wheel was rotated. |