/// <summary> /// Creates the smooth tween of the two specified ViewStates. /// </summary> /// <param name="startViewState">Start <see cref="ViewState"/> of the tween.</param> /// <param name="endViewState">End <see cref="ViewState"/> of the tween.</param> /// <param name="t">The interpolation coefficient.</param> /// <returns>A <see cref="ViewState"/> representing the tween of the specifed ViewStates.</returns> internal static ViewState CreateSmoothTween( ViewState startViewState, ViewState endViewState, double t) { t = 3 * Math.Pow(t, 2) - 2 * Math.Pow(t, 3); return startViewState.CreateTween(endViewState, t); }
/// <summary> /// Sets the view state for this viewer instance. /// </summary> /// <param name="viewState">New <see cref="ViewState"/> to apply to the view.</param> protected abstract void SetViewState(ViewState viewState);
/// <summary> /// Changes the view camera and transform settings to the specified <see cref="ViewState"/> /// through an animation. /// </summary> /// <param name="viewState">The target <see cref="ViewState"/> to animate to.</param> internal void AnimateToViewState(ViewState viewState) { this.StartViewStateAnimation(); this.startViewState = this.GetViewState(); this.endViewState = viewState; viewStateChangeStartTime = DateTime.Now; DispatcherTimer viewStateTimer = new DispatcherTimer(); viewStateTimer.Interval = TimeSpan.FromMilliseconds(20); viewStateTimer.Tick += this.ViewStateTimerTick; viewStateTimer.Start(); }
/// <summary> /// Sets the view state. /// </summary> /// <param name="viewState">New <see cref="ViewState"/> to apply to the view.</param> protected override void SetViewState(ViewState viewState) { PdbViewState pdbViewState = viewState as PdbViewState; if (pdbViewState != null) this.structureControl.SetViewState(pdbViewState); }
/// <summary> /// Creates the tween of the instance and the specified end ViewState. /// </summary> /// <param name="endViewState">End <see cref="ViewState"/> of the tween.</param> /// <param name="t">The interpolation coefficient.</param> /// <returns> /// A <see cref="ViewState"/> representing the tween of this instance and the specifed end ViewState. /// </returns> protected abstract ViewState CreateTween(ViewState endViewState, double t);
/// <summary> /// Creates the tween of the instance and the specified end ViewState. /// </summary> /// <param name="endViewState">End <see cref="ViewState"/> of the tween.</param> /// <param name="t">The interpolation coefficient.</param> /// <returns> /// A <see cref="ViewState"/> representing the tween of this instance and the specifed end ViewState. /// </returns> protected override ViewState CreateTween(ViewState endViewState, double t) { PdbViewState tweenViewState = new PdbViewState(); PdbViewState otherViewState = endViewState as PdbViewState; if (otherViewState != null) { tweenViewState.translation = this.translation + t * (otherViewState.translation - this.translation); tweenViewState.scale = this.scale + t * (otherViewState.scale - this.scale); tweenViewState.clip = this.clip + t * (otherViewState.clip - this.clip); tweenViewState.slab = this.slab + t * (otherViewState.slab - this.slab); tweenViewState.rotation = Quaternion.Slerp( this.rotation, otherViewState.rotation, t); } return tweenViewState; }