Class ConstructAction
- Namespace
- CADability.Actions
- Assembly
- CADability.dll
Base class for construct actions.
public abstract class ConstructAction : Action, ICommandHandler, IPropertyEntry
- Inheritance
-
ConstructAction
- Implements
- Derived
- Inherited Members
Constructors
ConstructAction()
Initializes some properties. Set the properties you need in your constructor.
protected ConstructAction()
Fields
CurrentMousePoint
The current mouse position for this action
public Point CurrentMousePoint
Field Value
MultiSolution
The ConstructAction may have several solutions. If set to true, the PgUp/PgDown key will call OnDifferentSolution and the context menue will have appropriate entries.
public bool MultiSolution
Field Value
MultiSolutionCount
TheConstruction may have several solutions. If set to a value !=0 the ContextMenu will have that number of entries and OnSolution() will be called if the user selects one of these
public int MultiSolutionCount
Field Value
ShowAttributes
Display the attributes of the active object.
public bool ShowAttributes
Field Value
TitleId
The title id (resource id) for the title of the action in the control center
public string TitleId
Field Value
Properties
ActiveObject
The object that is displayed on top of the drawing while the action runs, usually the object under construction. Set it to null to display nothing. Several objects can only be displayed as a Block.
public IGeoObject ActiveObject { get; set; }
Property Value
BasePoint
Sets the BasePoint. This point is needed for some snap modes like the orthogonal snap mode or snap to tangent point. As long as this point is not set, these snap modes don't work.
public GeoPoint BasePoint { get; set; }
Property Value
CurrentInput
The input object that currently has the focus, i.e. receives the mouse and keyboard input, or null if there is none. Derived actions compare it with their inputs to find out what the mouse currently defines (e.g. the radius or the center of a circle).
protected object CurrentInput { get; }
Property Value
CurrentMousePosition
returns the last mouse position in model coordinates.
public GeoPoint CurrentMousePosition { get; }
Property Value
DisassembleBlock
If true and the ActiveObject is a Block, OnDone() adds the children of the block to the model as individual objects instead of the block itself. Used by actions that compose their result in a block only for the feedback, e.g. the extrusion of several faces. Default: false.
public bool DisassembleBlock { get; set; }
Property Value
FeedBack
Gets the container that handles feedback objects (see ActionFeedBack).
public ActionFeedBack FeedBack { get; }
Property Value
HideButtons
If true, the OK and Cancel buttons are not shown in the title entry of the action in the property page; the action is then finished with Enter or the mouse and cancelled with Escape. Must be set before the action is displayed. Default: false.
public bool HideButtons { get; set; }
Property Value
IsBackgroundTaskActive
True while a task started with StartBackgroundTask(Delegate, Delegate, params object[]) is running (including its callback).
protected bool IsBackgroundTaskActive { get; }
Property Value
LastSnapMode
Returns the last snap mode, i.e. the reason why the snap took place. E.g. did snap to an endpoint or did snap to the surface of a face.
public SnapPointFinder.DidSnapModes LastSnapMode { get; }
Property Value
LastSnapObject
Returns the GeoObject which was involved in the last snap operation. May be null;
public IGeoObject LastSnapObject { get; }
Property Value
ShowActiveObject
Switches the display of the ActiveObject on and off.
public bool ShowActiveObject { get; set; }
Property Value
Methods
AutoRepeat()
Detremins whether this action supports autorepeat. Autorepeat is enabled in the GlobalSettings.
public override bool AutoRepeat()
Returns
CancelBackgroundTask()
Aborts the running background task (see StartBackgroundTask(Delegate, Delegate, params object[])) and waits until its thread has ended. The callback is not invoked. Does nothing when no task is running.
protected void CancelBackgroundTask()
ClearBasePoint()
Clears the BasePoint.
public void ClearBasePoint()
FindShape(GeoPoint, Plane)
Tries to find a CompoundShape that encloses the point p on the plane plane.
public CompoundShape FindShape(GeoPoint p, Plane plane)
Parameters
pGeoPointPoint in the inside of the requested shape
planePlanePlane in which the search should happen
Returns
- CompoundShape
A shape or null
FindTangentialPoint(MouseEventArgs, IView, out GeoPoint)
Additional posibility for the derived action to specify a tangential point besides the tangential point from the base point
protected virtual bool FindTangentialPoint(MouseEventArgs e, IView vw, out GeoPoint found)
Parameters
eMouseEventArgsvwIViewfoundGeoPoint
Returns
Finish()
Explicitly finish this action. OnDone will be called.
protected void Finish()
GetInputObjects()
Returns the input objects of this action in the order in which they were passed to SetInput(params object[]). Must not be called before SetInput(params object[]).
public List<ConstructAction.InputObject> GetInputObjects()
Returns
- List<ConstructAction.InputObject>
A new list with the input objects
InputChanged(object)
Called when the input focus moves to another input object, activeInput is the
newly active input object, or null when the action is done. Override it to adapt the feedback
or the state of the inputs to the active input.
protected virtual void InputChanged(object activeInput)
Parameters
activeInputobjectthe input object which now has the focus, or null
KeepAsLastStyle(IGeoObject)
Sets the Styleof the provided GeoObject go as the last style.
If new objects are created with construct method and last style is used, this style will be used.
protected virtual void KeepAsLastStyle(IGeoObject go)
Parameters
goIGeoObjectObject to get the style from
MayFinish()
Tells whether the action could be finished in its current state: true when all inputs other than the one that currently has the focus are fixed, optional or read-only, and the ActiveObject has valid data; false when there is no active object. Available to derived actions; ConstructAction itself does not call it at present.
protected virtual bool MayFinish()
Returns
- bool
true if the action could be finished now
OnActivate(Action, bool)
Implements OnActivate(Action, bool). If you override this method don't forget to call the base implementation.
public override void OnActivate(Action OldActiveAction, bool SettingAction)
Parameters
OnCommand(string)
Handles a few context menu commands. Don't forget to call the base implementation if you override this method. See ICommandHandler.
public override bool OnCommand(string MenuId)
Parameters
MenuIdstring
Returns
OnDifferentSolution(bool)
Will be called when MultiSolution is true and the user presses the PgUp/PgDown key or selects the appropriate entries of the context menu. Override this method to implement a multi-solution construction. Default implementation is empty.
public virtual void OnDifferentSolution(bool next)
Parameters
nextbooltrue: forward, false: backward
OnDisplayChanged(DisplayChangeArg)
Can be overridden to react on zooming and scrolling
public override void OnDisplayChanged(DisplayChangeArg d)
Parameters
OnDone()
Called, when the ConstructAction is done, i.e. all non-optional inputs have been fixed. The default implementation adds the active object (if it exists and HasValidData() returns true) to the active model and removes this action. Override this method if you need a different behaviour.
public virtual void OnDone()
OnEnter()
This method will be called when the user presses the enter key. The default implementation does nothing.
public override bool OnEnter()
Returns
OnEnter(object)
Overrides OnEnter(object). Usually you don't override this method, but handle the appropriate events of the input objects.
public override bool OnEnter(object sender)
Parameters
senderobject
Returns
OnEscape()
This method will be called when the user presses the escape key. The default implementation does nothing.
public override bool OnEscape()
Returns
OnEscape(object)
Overrides OnEscape(object). Usually you don't override this method, but handle the appropriate events of the input objects.
public override bool OnEscape(object sender)
Parameters
senderobject
Returns
OnInactivate(Action, bool)
Implements OnInactivate(Action, bool). If you override this method don't forget to call the bas implementation.
public override void OnInactivate(Action NewActiveAction, bool RemovingAction)
Parameters
NewActiveActionActionthe action that will become active
RemovingActionbooltrue: if called because the action is removed, false: if called when a new action is set on top of this action
OnMouseDown(MouseEventArgs, IView)
Implements OnMouseDown(MouseEventArgs, IView). If you override this method don't forget to call the bas implementation.
public override void OnMouseDown(MouseEventArgs e, IView vw)
Parameters
eMouseEventArgsMouseEventArgs of the call
vwIViewthe IView which contains the mouse
OnMouseLeave(EventArgs, IView)
Overrides OnMouseLeave(EventArgs, IView). Usually you don't override this method, but handle the appropriate events of the input objects.
public override void OnMouseLeave(EventArgs e, IView vw)
Parameters
OnMouseMove(MouseEventArgs, IView)
Implements OnMouseMove(MouseEventArgs, IView). If you override this method don't forget to call the bas implementation.
public override void OnMouseMove(MouseEventArgs e, IView vw)
Parameters
eMouseEventArgsMouseEventArgs of the call
vwIViewthe IView which contains the mouse
OnMouseUp(MouseEventArgs, IView)
Implements OnMouseUp(MouseEventArgs, IView). If you override this method don't forget to call the bas implementation.
public override void OnMouseUp(MouseEventArgs e, IView vw)
Parameters
eMouseEventArgsMouseEventArgs of the call
vwIViewthe IView which contains the mouse
OnRemoveAction()
Implements OnRemoveAction(). If you override this method don't forget to call the bas implementation.
public override void OnRemoveAction()
OnSetAction()
Implements OnSetAction(). If you override this method don't forget to call the base implementation.
public override void OnSetAction()
OnSolution(int)
Will be called when MultiSolution is true and the user presses the PgUp/PgDown key or selects the appropriate entries of the context menu. Override this method to implement a multi-solution construction. Default implementation is empty.
public virtual void OnSolution(int solutionNumber)
Parameters
solutionNumberintthe 0-based number of solution
OnTab(object)
The tab key was pressed: select the next input field, also accept optional fields
public override bool OnTab(object sender)
Parameters
senderobject
Returns
OnUpdateCommand(string, CommandState)
Override if you also override OnCommand(string) to manipulate the appearance of the corresponding menu item or the state of the toolbar button. The default implementation checks whether the MenuId from the parameter corresponds to the menuId member variable and checks the item if appropriate
public override bool OnUpdateCommand(string MenuId, CommandState CommandState)
Parameters
MenuIdstringmenu id the command state is queried for
CommandStateCommandStatethe command state to manipulate
Returns
OnViewsChanged()
Implements OnViewsChanged(). This implementation aborts the action.
public override void OnViewsChanged()
SetFocus(object, bool)
Sets the input focus to the given input object. The input object must be one of those given in the SetInput(params object[]) method.
public void SetFocus(object InputObject, bool ActivateMouse)
Parameters
InputObjectobjectInput object which should become active
ActivateMouseboolMouse actions also apply to this input object
SetInput(params object[])
Call this method in an override to OnSetAction() to specify the input parameters of this action. Objects given as parameters may be any of ConstructAction.AngleInput, ConstructAction.LengthInput, ConstructAction.DoubleInput, ConstructAction.GeoPointInput, ConstructAction.GeoVectorInput, ConstructAction.BooleanInput, ConstructAction.MultiPointInput, ConstructAction.GeoObjectInput, ConstructAction.PlaneInput.
public void SetInput(params object[] TheInput)
Parameters
TheInputobject[]Objects specifying the input parameters of this action
SnapPoint(MouseEventArgs, GeoPoint, IView, out DidSnapModes)
Gets a point from the MouseEventArgs and the view, snapped according to the view's snap settings, with
basePoint as the base point for the snap modes that need one (perpendicular foot point,
tangent point, orthogonal adjustment). Like SnapPoint(MouseEventArgs, IView, out DidSnapModes)
it also takes a tangential point from FindTangentialPoint(MouseEventArgs, IView, out GeoPoint) into account.
public virtual GeoPoint SnapPoint(MouseEventArgs e, GeoPoint basePoint, IView vw, out SnapPointFinder.DidSnapModes DidSnap)
Parameters
eMouseEventArgsMouseEventArgs with the mouse position
basePointGeoPointthe base point for the snapping, in model coordinates
vwIViewthe view
DidSnapSnapPointFinder.DidSnapModesreturns the snap mode that was applied, or DidNotSnap if no snapping took place
Returns
- GeoPoint
point in model space
SnapPoint(MouseEventArgs, IView, out DidSnapModes)
Gets a point from the MouseEventArgs and the view. The point will be in the appropriate model and will be snapped according to the views snap setting.
public virtual GeoPoint SnapPoint(MouseEventArgs e, IView vw, out SnapPointFinder.DidSnapModes DidSnap)
Parameters
eMouseEventArgsMouseEventArgs with the mouse position
vwIViewthe view
DidSnapSnapPointFinder.DidSnapModesreturns the snap mode that was applied, i.e. the reason why the point was snapped, or DidNotSnap if no snapping took place
Returns
- GeoPoint
point in model space
StartBackgroundTask(Delegate, Delegate, params object[])
Runs MethodToInvoke on a separate thread, e.g. to compute a new active object while the user
goes on moving the mouse, and invokes CallbackOnDone once it has completed. The callback runs on
the background thread as well (or on the calling thread when WaitForBackgroundTask() finishes the
task), so UI work must be marshalled by the caller. Only one background task per action is supported: check
IsBackgroundTaskActive and call CancelBackgroundTask() before starting a new one. If
the method throws, the task ends without invoking the callback.
protected void StartBackgroundTask(Delegate MethodToInvoke, Delegate CallbackOnDone, params object[] invokeParameters)
Parameters
MethodToInvokeDelegateThe method to run in the background; it receives
invokeParametersCallbackOnDoneDelegateParameterless method invoked after
MethodToInvokehas completedinvokeParametersobject[]The arguments passed to
MethodToInvoke
WaitForBackgroundTask()
Blocks, showing the wait cursor, until the running background task has finished, so that its result is available, e.g. in OnDone(). If the computation has already completed but the callback has not run yet, the callback is invoked here on the calling thread. Does nothing when no task is running.
protected void WaitForBackgroundTask()
Events
ActionDoneEvent
Event that is fired when this action is done. If your class is derived from ConstructAction you better override OnDone().
public event ConstructAction.ActionDoneDelegate ActionDoneEvent
Event Type
StateChangedEvent
Raised when the entry of this action in the property page is expanded or collapsed, with OpenSubEntries or CollapseSubEntries. Part of the IPropertyEntry implementation of the action.
public event PropertyEntryChangedStateDelegate StateChangedEvent