Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        public override void Stop()
        {
            if (CurrentTool != null)
            {
                StopTool();
            }

            if (Sketch != null)
            {
                if (Sketch.IsVisible)
                {
                    var visualSketchShape = WorkspaceController.VisualShapes.GetVisualShape(Sketch.Body);
                    if (visualSketchShape != null)
                    {
                        visualSketchShape.IsHidden = false;
                    }
                }

                Sketch.ElementsChanged -= _Sketch_ElementsChanged;
            }

            WorkspaceController.Selection.CloseContext(_SelectionContext);
            _SelectionContext = null;

            Elements.RemoveAll();

            WorkspaceController.Workspace.WorkingContext = null;
            WorkspaceController.LockWorkingPlane         = false;

            var vc = WorkspaceController.ActiveViewControlller;

            if (Sketch != null)
            {
                var editorSettings = SketchEditorSettingsCache.GetOrCreate(Sketch);
                editorSettings.ViewParameters   = vc.Viewport.GetViewParameters();
                editorSettings.ClipPlaneEnabled = ClipPlaneEnabled;
            }

            vc.Viewport.PropertyChanged -= _Viewport_PropertyChanged;
            vc.LockedToPlane             = false;
            if (_SavedViewParameters != null)
            {
                vc.Viewport.RestoreViewParameters(_SavedViewParameters);
            }

            EnableClipPlane(false);

            WorkspaceController.Invalidate();

            base.Stop();
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        public override bool Start()
        {
            _SelectionContext = WorkspaceController.Selection.OpenContext(SelectionContext.Options.NewSelectedList);
            var workspace = WorkspaceController.Workspace;

            var editorSettings = SketchEditorSettingsCache.GetOrCreate(Sketch);

            if (editorSettings.WorkingContext == null)
            {
                editorSettings.WorkingContext = workspace.WorkingContext.Clone();
            }

            workspace.WorkingContext             = editorSettings.WorkingContext;
            WorkspaceController.LockWorkingPlane = true;
            workspace.WorkingPlane = Sketch.Plane;

            var vc = WorkspaceController.ActiveViewControlller;

            _SavedViewParameters = vc.Viewport.GetViewParameters();
            vc.LockedToPlane     = true;

            if (editorSettings.ViewParameters != null)
            {
                vc.Viewport.RestoreViewParameters(editorSettings.ViewParameters);
                // Update direction
                var twist = vc.Viewport.Twist;
                vc.SetPredefinedView(ViewportController.PredefinedViews.WorkingPlane);
                vc.Viewport.Twist = twist;
            }
            else
            {
                _CenterView();
                RotateView(0);
            }
            vc.Viewport.PropertyChanged += _Viewport_PropertyChanged;

            EnableClipPlane(editorSettings.ClipPlaneEnabled);

            if (Sketch.IsVisible)
            {
                var visualSketchShape = WorkspaceController.VisualShapes.GetVisualShape(Sketch.Body, true);
                if (visualSketchShape != null)
                {
                    visualSketchShape.IsHidden = true;
                }
            }

            _LastGizmoScale = WorkspaceController.ActiveViewport.GizmoScale;

            _TempPoints = new Dictionary <int, Pnt2d>(Sketch.Points);
            Transform   = Sketch.GetTransformation();

            Elements.InitElements(_TempPoints);
            _UpdateSelections();

            Sketch.ElementsChanged += _Sketch_ElementsChanged;

            _SelectAction = new SelectSketchElementAction(this);
            if (!WorkspaceController.StartToolAction(_SelectAction))
            {
                return(false);
            }
            _SelectAction.Finished += _OnSelectionChanged;

            StatusText = UnselectedStatusText;

            return(true);
        }