Exemple #1
0
        private void tsmLoadFile_Click(object sender, EventArgs e)
        {
            if (dLoadFile.ShowDialog() != DialogResult.OK)
                return;

            ViewControl view = new ViewControl();
            view.Dock = DockStyle.Fill;
            view.Document = Document.createFromFile(dLoadFile.FileName);

            view.Document.Style.FontName = "Courier New";
            view.Document.Style.FontHeight = 10f;
            view.Document.Style.Foreground = Color.Black;
            view.Document.Style.Background = Color.FromArgb(239, 239, 228);

            TabPage page = new TabPage(Path.GetFileName(dLoadFile.FileName));
            page.Controls.Add(view);

            tbPages.TabPages.Add(page);
            tbPages.SelectedTab = page;
        }
Exemple #2
0
        public override void OnEndDrag(ViewControl vc, Point scrPt)
        {
            if (NodeList.Count > 0)
            {
                for (int k = 0; k < NodeList.Count; k++)
                {
                    IManipulatorNotify notifier = NodeList[k].As <IManipulatorNotify>();
                    if (notifier != null)
                    {
                        notifier.OnEndDrag();
                    }
                }
                var transactionContext = DesignView.Context.As <ITransactionContext>();
                try
                {
                    if (transactionContext.InTransaction)
                    {
                        transactionContext.End();
                    }
                }
                catch (InvalidTransactionException ex)
                {
                    if (transactionContext.InTransaction)
                    {
                        transactionContext.Cancel();
                    }

                    if (ex.ReportError)
                    {
                        Outputs.WriteLine(OutputMessageType.Error, ex.Message);
                    }
                }
            }

            NodeList.Clear();
            m_originalValues = null;
            m_hitRegion      = HitRegion.None;
            m_scale          = new Vec3F(1, 1, 1);
        }
Exemple #3
0
        public void Init()
        {
            MyProjectPara            = ProjectParaManager.Instance.GetProjectPara(0);
            LeftDnCamLeftVisionPara  = MyProjectPara.GetVisionPara("左侧下相机左上角拍照位");
            LeftDnCamRightVisionPara = MyProjectPara.GetVisionPara("左侧下相机右下角拍照位");
            UpCamLeftUpVisionPara    = MyProjectPara.GetVisionPara("上相机左上角拍照位1");
            UpCamRightUpVisionPara   = MyProjectPara.GetVisionPara("上相机右下角拍照位1");

            LeftDnCamLeftView   = DisplaySystem.GetViewControl("左侧下相机左上角拍照位");
            LeftDnCamRightView  = DisplaySystem.GetViewControl("左侧下相机右下角拍照位");
            UpCamLeftUpView     = DisplaySystem.GetViewControl("上相机左上角拍照位1");
            UpCamRightUpCamView = DisplaySystem.GetViewControl("上相机右下角拍照位1");

            VisionStateBaseUpCamLeftUp  = new VisionStateBase(UpCamLeftUpVisionPara, "左侧下相机左上角拍照位", UpCamLeftUpView);
            VisionStateBaseUpCamRightUp = new VisionStateBase(UpCamRightUpVisionPara, "左侧下相机右下角拍照位", UpCamRightUpCamView);
            VisionStateDnLeftCamLeft    = new VisionStateBase(LeftDnCamLeftVisionPara, "上相机左上角拍照位1", LeftDnCamLeftView);
            VisionStateDnLeftCamRight   = new VisionStateBase(LeftDnCamRightVisionPara, "上相机右下角拍照位1", LeftDnCamRightView);

            VisionStateDnLeftCamLeft.SetCamLight();
            VisionStateBaseUpCamRightUp.SetCamLight();
            VisionStateDnLeftCamLeft.SetCamLight();
            VisionStateDnLeftCamRight.SetCamLight();
        }
Exemple #4
0
        bool IManipulator.Pick(ViewControl vc, System.Drawing.Point scrPt)
        {
            TerrainGob   terrain = m_terrainEditor.TerrainEditorControl.SelectedTerrain;
            TerrainBrush brush   = m_terrainEditor.TerrainEditorControl.SelectedBrush;

            if (terrain != null && brush != null)
            {
                FlattenBrush fbrush = brush as FlattenBrush;
                if (fbrush != null)
                {
                    Ray3F rayw = vc.GetWorldRay(scrPt);
                    TerrainGob.RayPickRetVal retval;
                    if (terrain.RayPick(rayw, out retval))
                    {
                        Point     pt = terrain.WorldToSurfaceSpace(retval.hitpos);
                        ImageData hm = terrain.GetSurface();
                        fbrush.Height = hm.GetPixelFloat(pt.X, pt.Y);
                    }
                }
                return(true);
            }
            return(false);
        }
Exemple #5
0
        public void Init()
        {
            MyProjectPara          = ProjectParaManager.Instance.GetProjectPara(0);
            RightDnLeftVisionPara  = MyProjectPara.GetVisionPara("右侧下相机左上角拍照位");
            RightDnRightVisionPara = MyProjectPara.GetVisionPara("右侧下相机右下角拍照位");
            UpCamLeftDnVisionPara  = MyProjectPara.GetVisionPara("上相机左上角拍照位2");
            UpCamRightDnVisionPara = MyProjectPara.GetVisionPara("上相机右下角拍照位2");

            RightDnCamLeftStaView  = DisplaySystem.GetViewControl("右侧下相机左上角拍照位");
            RightDnCamRightStaView = DisplaySystem.GetViewControl("右侧下相机右下角拍照位");
            UpCamLeftDnStaView     = DisplaySystem.GetViewControl("上相机左上角拍照位2");
            UpCamRightDnStaView    = DisplaySystem.GetViewControl("上相机右下角拍照位2");

            VisionStateUpCamLeftDn     = new VisionStateBase(UpCamLeftDnVisionPara, "右侧下相机左上角拍照位", UpCamLeftDnStaView);
            VisionStateUpCamRightDn    = new VisionStateBase(UpCamRightDnVisionPara, "右侧下相机右下角拍照位", UpCamRightDnStaView);
            VisionStateRightDnCamLeft  = new VisionStateBase(RightDnLeftVisionPara, "上相机左上角拍照位2", RightDnCamLeftStaView);
            VisionStateRightDnCamRight = new VisionStateBase(RightDnRightVisionPara, "上相机右下角拍照位2", RightDnCamRightStaView);

            VisionStateUpCamLeftDn.SetCamLight();
            VisionStateUpCamRightDn.SetCamLight();
            VisionStateRightDnCamLeft.SetCamLight();
            VisionStateRightDnCamRight.SetCamLight();
        }
Exemple #6
0
        public void Navigate(TabViewType type, object p = null)
        {
            switch (type)
            {
            case TabViewType.Warehouse:
                ViewControl.SelectedItem = WarehouseTab;
                break;

            case TabViewType.Deal:
                ViewControl.SelectedItem = DealTab;
                break;

            case TabViewType.Item:
                ViewControl.SelectedItem = ItemTab;
                break;

            case TabViewType.Salesman:
                ViewControl.SelectedItem = SalemanTab;
                break;

            case TabViewType.Customer:
                ViewControl.SelectedItem = CustomerTab;
                break;

            case TabViewType.Keeper:
                ViewControl.SelectedItem = KeeperTab;
                break;

            case TabViewType.KeeperInfo:
                ViewControl.SelectedItem = KeeperInfoTab;
                break;

            default:
                break;
            }
            ViewControl.FindVisualChildren <TabView>().FirstOrDefault()?.Init(p);
        }
 protected override Validation <string, InventoryView> CreateService(
     Option <string> closeAction,
     IPlayerControl playerControl,
     Godot.Control node,
     ILoggerFactory loggerFactory)
 {
     return
         (from viewControl in ViewControl
          .ToValidation("Failed to find the view control.")
          from itemStand in ItemStand
          .ToValidation("Failed to find the item stand.")
          from tree in Tree
          .ToValidation("Failed to find the tree view.")
          from buttonContainer in Buttons
          .ToValidation("Failed to find the button container.")
          from infoPanel in InfoPanel
          .ToValidation("Failed to find the information panel.")
          from titleLabel in Title
          .ToValidation("Failed to find the title label.")
          from actionButton in Optional(ActionButton)
          .ToValidation("Failed to find action button template.")
          select new InventoryView(
              playerControl,
              viewControl,
              itemStand,
              PauseWhenVisible,
              closeAction,
              node,
              tree,
              buttonContainer,
              infoPanel,
              titleLabel,
              Type,
              Description,
              actionButton,
              loggerFactory));
 }
        private void addVisualControl(ViewControl tag)
        {
            var b = new Border();

            b.Background = new SolidColorBrush(tag.Background);
            b.Width      = tag.Width;
            b.Height     = tag.Height;
            Canvas.SetLeft(b, tag.Left);
            Canvas.SetTop(b, tag.Top);
            b.Tag   = tag;
            b.Child = new TextBlock()
            {
                Text = tag.ControlId + "\n" + tag.ControlName, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };
            b.Opacity = 0.7;

            b.MouseLeftButtonDown  += B_MouseLeftButtonDown;
            b.MouseLeftButtonUp    += B_MouseLeftButtonUp;
            b.MouseMove            += B_MouseMove;
            b.MouseWheel           += B_MouseWheel;
            b.MouseRightButtonDown += B_MouseRightButtonDown;

            ControlsCanvas.Children.Add(b);
        }
        public static void ResetOptions_Hit(object sender, EventArgs e)
        {
            try
            {
                lib.Ticker           = 100;
                MainView.Ticker.Text = lib.Ticker.ToString();

                lib.Element = 0;
                MainView.Element.Current = lib.Element;

                lib.Behaviour = 0;
                MainView.Behaviour.Current = lib.Behaviour;

                lib.Range           = 120;
                MainView.Range.Text = lib.Range.ToString();

                lib.Timer           = 120;
                MainView.Timer.Text = lib.Timer.ToString();

                lib.Comps           = 50;
                MainView.Comps.Text = lib.Comps.ToString();

                lib.Slots           = 3;
                MainView.Slots.Text = lib.Slots.ToString();

                lib.UseMacroLogic = true;
                MainView.UseMacroLogic.Checked = lib.UseMacroLogic;

                lib.UseLogDie = false;
                MainView.UseLogDie.Checked = lib.UseLogDie;

                ViewControl.SaveUI();
                Utility.AddChatText("Options reset to default.", 6);
            }
            catch (Exception ex) { Repo.RecordException(ex); }
        }
        private void D_ControlChange(ControlChangeMessage msg)
        {
            Dispatcher.Invoke(() =>
            {
                lbLog.Items.Add(string.Format("Cnt: {0} {1} {2}", msg.Channel, msg.Control, msg.Value));

                ControlsHandler.HighlightControl(((int)msg.Control).ToString());

                if (Device != null)
                {
                    var cc = Device.Controls.Find(x => x.ControlId == ((int)msg.Control).ToString());

                    if (autonewControl && cc == null)
                    {
                        var c = new ViewControl()
                        {
                            ControlId = ((int)msg.Control).ToString(), ControlName = msg.Control.ToString(), Type = Ktos.DjToKey.Plugins.Device.ControlType.Analog
                        };
                        Device.Controls.Add(c);
                        ControlsHandler.SynchronizeView();
                    }
                }
            });
        }
Exemple #11
0
        private void StartDrawing()
        {
            myDrawing           = true;
            myTileSprite.Colour = new Color4(0.0f, 1.0f, 0.0f, 0.25f);

            if (TilePlaceRB.Checked && PlacementBoxRB.Checked)
            {
                Point viewOrigin = ViewControl.PointToScreen(new Point(256, 256));

                myBoxOrigin = new Point()
                {
                    X = (int)Math.Floor((Cursor.Position.X - viewOrigin.X) / (16 * MapRenderer.CameraScale) + MapRenderer.CameraX),
                    Y = (int)Math.Floor((Cursor.Position.Y - viewOrigin.Y) / (16 * MapRenderer.CameraScale) + MapRenderer.CameraY)
                };

                if (myBoxOrigin.X < 0)
                {
                    myBoxOrigin.X = 0;
                }
                if (myBoxOrigin.X >= myCurrentMap.Width)
                {
                    myBoxOrigin.X = myCurrentMap.Width - 1;
                }
                if (myBoxOrigin.Y < 0)
                {
                    myBoxOrigin.Y = 0;
                }
                if (myBoxOrigin.Y >= myCurrentMap.Height)
                {
                    myBoxOrigin.Y = myCurrentMap.Height - 1;
                }
            }

            DrawWithCursor();
            RenderMap();
        }
Exemple #12
0
        /// <summary>
        /// Loads the context.
        /// </summary>
        private void LoadContext()
        {
            //if (SegmentId > 0)
            {
                SegmentDto    segment    = null;
                ExpressionDto expression = null;
                if (!this.IsPostBack && (!this.Request.QueryString.ToString().Contains("Callback=yes")))                 // load fresh on initial load
                {
                    segment    = LoadFresh();
                    expression = LoadFreshExpression();
                }
                else                 // load from session
                {
                    segment    = (SegmentDto)Session[_SegmentDtoEditSessionKey];
                    expression = (ExpressionDto)Session[_ExpressionDtoEditSessionKey];

                    if (segment == null)
                    {
                        segment = LoadFresh();
                    }

                    if (expression == null)
                    {
                        expression = LoadFreshExpression();
                    }
                }

                // Put a dictionary key that can be used by other tabs
                IDictionary dic = new ListDictionary();
                dic.Add(_SegmentDtoString, segment);
                dic.Add(_ExpressionDtoString, expression);

                // Call tabs load context
                ViewControl.LoadContext(dic);
            }
        }
        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
            {
                return(false);
            }

            Camera camera = vc.Camera;
            float  s;

            Util.CalcAxisLengths(camera, HitMatrix.Translation, out s);
            Matrix4F view = camera.ViewMatrix;
            Matrix4F vp   = view * camera.ProjectionMatrix;
            Matrix4F wvp  = HitMatrix * vp;

            Ray3F rayL = vc.GetRay(scrPt, wvp);

            m_hitRegion = m_translatorControl.Pick(HitMatrix, view, rayL, HitRayV, s);

            bool picked = m_hitRegion != HitRegion.None;

            return(picked);
        }
Exemple #14
0
        public override void Render(ViewControl vc)
        {
            Matrix4F normWorld = GetManipulatorMatrix();

            if (normWorld == null)
            {
                return;
            }

            Util3D.RenderFlag = BasicRendererFlags.WireFrame | BasicRendererFlags.DisableDepthTest;
            Color xcolor = (m_hitRegion == HitRegion.XAxis) ? Color.LightSalmon : Color.Red;
            Color ycolor = (m_hitRegion == HitRegion.YAxis) ? Color.LightGreen : Color.Green;
            Color Zcolor = (m_hitRegion == HitRegion.ZAxis) ? Color.LightBlue : Color.Blue;

            float s;

            Util.CalcAxisLengths(vc.Camera, normWorld.Translation, out s);
            Vec3F axScale = new Vec3F(s, s, s);

            Matrix4F scale = new Matrix4F();

            scale.Scale(axScale);
            Matrix4F xform = scale * normWorld;

            Util3D.DrawCircle(xform, Zcolor);

            Matrix4F rot = new Matrix4F();

            rot.RotY(MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawCircle(xform, xcolor);

            rot.RotX(MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawCircle(xform, ycolor);
        }
Exemple #15
0
		/*public void Show(IEnumerable<TransformedImage> images)
		{
			foreach(TransformedImage image in images)
			{
				image.visible = true;
				Viewer.visible.Add(image);
			}
			Status("Show images");
		}
		public void Hide(IEnumerable<TransformedImage> images)
		{
			foreach(TransformedImage image in images)
			{
				image.visible = false;
				Viewer.visible.Remove(image);
			}
			Status("Hide images");
		}*/
		private void SetViewControl(ViewControl vc)
		{
			// Set view mode
			viewControl = vc;
			Status("View control: " + viewControl.ToString());
		}
        public override ManipulatorPickResult Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == ManipulatorPickResult.Miss)
            {
                return(ManipulatorPickResult.Miss);
            }

            Camera camera = vc.Camera;
            float  s      = Util.CalcAxisScale(vc.Camera, HitMatrix.Translation, AxisLength, vc.Height);

            Matrix4F vp  = camera.ViewMatrix * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;

            // get ray in object space  space.
            Ray3F rayL = vc.GetRay(scrPt, wvp);

            m_scale    = new Vec3F(1, 1, 1);
            m_hitScale = s;


            Vec3F    min      = new Vec3F(-0.5f, -0.5f, -0.5f);
            Vec3F    max      = new Vec3F(0.5f, 0.5f, 0.5f);
            AABB     box      = new AABB(min, max);
            Matrix4F boxScale = new Matrix4F();
            Matrix4F boxTrans = new Matrix4F();
            Matrix4F BoxMtrx  = new Matrix4F();

            float handleScale = s * AxisHandle;

            // +X axis
            boxScale.Scale(new Vec3F(s, handleScale, handleScale));
            boxTrans.Translation = new Vec3F(s / 2, 0, 0);
            BoxMtrx = boxScale * boxTrans;

            Ray3F ray = rayL;

            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);

            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.XAxis;
                return(ManipulatorPickResult.DeferredBeginDrag);
            }

            // -X
            boxTrans.Translation = new Vec3F(-s / 2, 0, 0);
            BoxMtrx = boxScale * boxTrans;

            ray = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);

            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.NegXAxis;
                return(ManipulatorPickResult.DeferredBeginDrag);
            }

            // y axis
            boxScale.Scale(new Vec3F(handleScale, s, handleScale));
            boxTrans.Translation = new Vec3F(0, s / 2, 0);
            BoxMtrx = boxScale * boxTrans;

            ray = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.YAxis;
                return(ManipulatorPickResult.DeferredBeginDrag);
            }

            // -Y
            boxTrans.Translation = new Vec3F(0, -s / 2, 0);
            BoxMtrx = boxScale * boxTrans;
            ray     = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.NegYAxis;
                return(ManipulatorPickResult.DeferredBeginDrag);
            }


            // z axis
            boxScale.Scale(new Vec3F(handleScale, handleScale, s));
            boxTrans.Translation = new Vec3F(0, 0, s / 2);
            BoxMtrx = boxScale * boxTrans;

            ray = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.ZAxis;
                return(ManipulatorPickResult.DeferredBeginDrag);
            }

            // -Z
            boxTrans.Translation = new Vec3F(0, 0, -s / 2);
            BoxMtrx = boxScale * boxTrans;

            ray = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.NegZAxis;
                return(ManipulatorPickResult.DeferredBeginDrag);
            }

            return(ManipulatorPickResult.Miss);
        }
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None || m_activeOp == null || m_activeOp.NodeList.Count == 0)
            {
                return;
            }

            Matrix4F view = vc.Camera.ViewMatrix;
            // compute world * view
            Matrix4F wv = new Matrix4F();

            wv.Mul(HitMatrix, view);

            // create ray in view space.
            Ray3F rayV = vc.GetRay(scrPt, vc.Camera.ProjectionMatrix);

            Vec3F xAxis  = wv.XAxis;
            Vec3F yAxis  = wv.YAxis;
            Vec3F zAxis  = wv.ZAxis;
            Vec3F origin = wv.Translation;

            m_scale = new Vec3F(1, 1, 1);
            float scale = 1;
            float a1, a2;

            switch (m_hitRegion)
            {
            case HitRegion.XAxis:
            case HitRegion.NegXAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, yAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, zAxis));
                Vec3F axis       = (a1 > a2 ? yAxis : zAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), xAxis);
                if (m_hitRegion == HitRegion.NegXAxis)
                {
                    dragAmount *= -1;
                }
                m_scale.X = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.X;
            }

            break;

            case HitRegion.YAxis:
            case HitRegion.NegYAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, zAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, xAxis));
                Vec3F axis       = (a1 > a2 ? zAxis : xAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), yAxis);
                if (m_hitRegion == HitRegion.NegYAxis)
                {
                    dragAmount *= -1;
                }
                m_scale.Y = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.Y;
            }
            break;

            case HitRegion.ZAxis:
            case HitRegion.NegZAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, xAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, yAxis));
                Vec3F axis       = (a1 > a2 ? xAxis : yAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), zAxis);
                if (m_hitRegion == HitRegion.NegZAxis)
                {
                    dragAmount *= -1;
                }
                m_scale.Z = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.Z;
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (m_isUniformScaling)
            {
                m_scale = new Vec3F(scale, scale, scale);
            }


            // scale
            for (int i = 0; i < m_activeOp.NodeList.Count; i++)
            {
                ITransformable node = m_activeOp.NodeList[i];
                node.Scale = Vec3F.Mul(m_originalScales[i], m_scale);

                Matrix4F mtrx = TransformUtils.CalcTransform(
                    Vec3F.ZeroVector,
                    node.Rotation,
                    node.Scale,
                    m_pivotOffset[i]);
                node.Translation = m_originalTranslations[i] + mtrx.Translation;
            }
        }
        public override void OnBeginDrag(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None)
            {
                return;
            }

            m_activeOp = null;

            var op = new ManipulatorActiveOperation(
                "Extend", DesignView.Context.As <ISelectionContext>(),
                (ITransformable node) => (node.TransformationType & TransformationTypes.Scale) != 0,
                false);

            // to compute offset use bounding box in local space.
            Vec3F offset = Vec3F.ZeroVector;// 0.5f; // use bounding box in local space

            switch (m_hitRegion)
            {
            case HitRegion.XAxis:
            case HitRegion.YAxis:
            case HitRegion.ZAxis:
                offset = new Vec3F(-1, -1, -1);
                break;

            case HitRegion.NegXAxis:
            case HitRegion.NegYAxis:
            case HitRegion.NegZAxis:
                offset = new Vec3F(1, 1, 1);
                break;

            default:
                break;
            }

            m_isUniformScaling     = false;
            m_originalScales       = new Vec3F[op.NodeList.Count];
            m_originalTranslations = new Vec3F[op.NodeList.Count];
            m_pivotOffset          = new Vec3F[op.NodeList.Count];
            int k = 0;

            foreach (ITransformable node in op.NodeList)
            {
                //  if any of the selected nodes are marked as "UniformScale", then the
                //  entire operation must be a uniform scale operaion
                if ((node.TransformationType & TransformationTypes.UniformScale) == TransformationTypes.UniformScale)
                {
                    m_isUniformScaling = true;
                }

                IBoundable boundable = node.As <IBoundable>();
                Vec3F      pivot     = Vec3F.Mul(boundable.LocalBoundingBox.Radius, offset);
                m_pivotOffset[k] = pivot;

                m_originalScales[k] = node.Scale;

                Matrix4F mtrx = TransformUtils.CalcTransform(
                    Vec3F.ZeroVector,
                    node.Rotation,
                    node.Scale,
                    pivot
                    );

                m_originalTranslations[k] = node.Translation - mtrx.Translation;
                k++;
            }

            m_activeOp = op;
        }
        public override void Render(object opaqueContext, ViewControl vc)
        {
            Matrix4F normWorld = GetManipulatorMatrix();

            if (normWorld == null)
            {
                return;
            }

            var context = opaqueContext as GUILayer.SimpleRenderingContext;

            if (context == null)
            {
                return;
            }

            int axis = (int)m_hitRegion;

            // axis colors
            Color saveColor = m_axisColor[axis];

            m_axisColor[axis] = m_highlightColor;
            Color xcolor  = m_axisColor[(int)HitRegion.XAxis];
            Color ycolor  = m_axisColor[(int)HitRegion.YAxis];
            Color zcolor  = m_axisColor[(int)HitRegion.ZAxis];
            Color nxcolor = m_axisColor[(int)HitRegion.NegXAxis];
            Color nycolor = m_axisColor[(int)HitRegion.NegYAxis];
            Color nzcolor = m_axisColor[(int)HitRegion.NegZAxis];

            m_axisColor[axis] = saveColor;


            if (m_hitRegion != HitRegion.None)
            {
                normWorld.Translation = HitMatrix.Translation;
            }

            Vec3F pos = normWorld.Translation;
            float s   = Util.CalcAxisScale(vc.Camera, pos, AxisLength, vc.Height);

            Vec3F sv           = new Vec3F(s, s, s);
            Vec3F axscale      = new Vec3F(s * AxisThickness, s, s * AxisThickness);
            bool  negativeAxis = m_hitRegion == HitRegion.NegXAxis || m_hitRegion == HitRegion.NegYAxis || m_hitRegion == HitRegion.NegZAxis;
            Vec3F dragScale    = new Vec3F(Math.Abs(m_scale.X),
                                           Math.Abs(m_scale.Y), Math.Abs(m_scale.Z));



            Matrix4F rot   = new Matrix4F();
            Matrix4F scale = new Matrix4F();

            axscale.Y = negativeAxis ? s : s * dragScale.X;
            scale.Scale(axscale);
            rot.RotZ(-MathHelper.PiOver2);
            Matrix4F xform = scale * rot * normWorld;

            Util3D.DrawCylinder(context, xform, xcolor);

            axscale.Y = negativeAxis ? s : s * dragScale.Y;
            scale.Scale(axscale);
            xform = scale * normWorld;
            Util3D.DrawCylinder(context, xform, ycolor);

            axscale.Y = negativeAxis ? s : s * dragScale.Z;
            scale.Scale(axscale);
            rot.RotX(MathHelper.PiOver2);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(context, xform, zcolor);


            rot.RotZ(MathHelper.PiOver2);
            axscale.Y = negativeAxis ? s * dragScale.X : s;
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(context, xform, nxcolor);

            rot.RotZ(MathHelper.Pi);
            axscale.Y = negativeAxis ? s * dragScale.Y : s;
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(context, xform, nycolor);

            rot.RotX(-MathHelper.PiOver2);
            axscale.Y = negativeAxis ? s * dragScale.Z : s;
            scale.Scale(axscale);
            xform = scale * rot * normWorld;
            Util3D.DrawCylinder(context, xform, nzcolor);


            // draw center cube
            scale.Scale(s * (1.0f / 16.0f));
            xform = scale * normWorld;
            Util3D.DrawCube(context, xform, Color.White);

            Vec3F handle      = sv * AxisHandle;
            float handleWidth = handle.X / 2;

            scale.Scale(handle);
            Matrix4F trans = new Matrix4F();


            // X handle
            float drag = m_hitRegion == HitRegion.XAxis ? dragScale.X : 1.0f;

            trans.Translation = new Vec3F(drag * sv.X - handleWidth, 0, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(context, xform, xcolor);

            // y handle
            drag = m_hitRegion == HitRegion.YAxis ? dragScale.Y : 1.0f;
            trans.Translation = new Vec3F(0, drag * sv.Y - handleWidth, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(context, xform, ycolor);

            // z handle
            drag = m_hitRegion == HitRegion.ZAxis ? dragScale.Z : 1.0f;
            trans.Translation = new Vec3F(0, 0, drag * sv.Z - handleWidth);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(context, xform, zcolor);


            // -x handle
            drag = m_hitRegion == HitRegion.NegXAxis ? dragScale.X : 1.0f;
            trans.Translation = new Vec3F(-sv.X * drag + handleWidth, 0, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(context, xform, nxcolor);

            // -y handle
            drag = m_hitRegion == HitRegion.NegYAxis ? dragScale.Y : 1.0f;
            trans.Translation = new Vec3F(0, -sv.Y * drag + handleWidth, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(context, xform, nycolor);

            // -z handle
            drag = m_hitRegion == HitRegion.NegZAxis ? dragScale.Z : 1.0f;
            trans.Translation = new Vec3F(0, 0, -sv.Z * drag + handleWidth);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(context, xform, nzcolor);
        }
 void IViewEvents.OnCheckboxChecked(ViewControl control)
 {
 }
        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
            {
                return(false);
            }

            Camera camera = vc.Camera;
            float  s;

            Util.CalcAxisLengths(camera, HitMatrix.Translation, out s);

            Matrix4F vp  = camera.ViewMatrix * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;

            // get ray in object space  space.
            Ray3F rayL = vc.GetRay(scrPt, wvp);

            m_scale    = new Vec3F(1, 1, 1);
            m_hitScale = s;

            float    rectScale   = s * FreeRectRatio;
            Vec3F    topRight    = rectScale * (new Vec3F(1, 1, 0));
            Vec3F    topLeft     = rectScale * (new Vec3F(-1, 1, 0));
            Vec3F    bottomLeft  = rectScale * (new Vec3F(-1, -1, 0));
            Vec3F    bottomRight = rectScale * (new Vec3F(1, -1, 0));
            Matrix4F planeXform  = Util.CreateBillboard(HitMatrix.Translation, camera.WorldEye, camera.Up, camera.LookAt);
            Matrix4F wvpPlane    = planeXform * vp;

            // create ray in plane's local space.
            Ray3F rayP = vc.GetRay(scrPt, wvpPlane);

            Plane3F plane = new Plane3F(topRight, topLeft, bottomLeft);
            Vec3F   p;

            bool intersect = rayP.IntersectPlane(plane, out p);

            if (intersect)
            {
                bool inside = p.X > topLeft.X &&
                              p.X <topRight.X &&
                                   p.Y> bottomLeft.Y &&
                              p.Y < topLeft.Y;
                if (inside)
                {
                    m_hitRegion = HitRegion.FreeRect;
                    return(true);
                }
            }

            Vec3F    min      = new Vec3F(-0.5f, -0.5f, -0.5f);
            Vec3F    max      = new Vec3F(0.5f, 0.5f, 0.5f);
            AABB     box      = new AABB(min, max);
            Matrix4F boxScale = new Matrix4F();
            Matrix4F boxTrans = new Matrix4F();
            Matrix4F BoxMtrx  = new Matrix4F();

            float handleScale = s * HandleRatio;

            // X axis

            boxScale.Scale(new Vec3F(s, handleScale, handleScale));
            boxTrans.Translation = new Vec3F(s / 2, 0, 0);
            BoxMtrx = boxScale * boxTrans;
            Ray3F ray = rayL;

            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);

            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.XAxis;
                return(true);
            }

            // y axis
            boxScale.Scale(new Vec3F(handleScale, s, handleScale));
            boxTrans.Translation = new Vec3F(0, s / 2, 0);
            BoxMtrx = boxScale * boxTrans;
            ray     = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.YAxis;
                return(true);
            }

            // z axis
            boxScale.Scale(new Vec3F(handleScale, handleScale, s));
            boxTrans.Translation = new Vec3F(0, 0, s / 2);
            BoxMtrx = boxScale * boxTrans;

            ray = rayL;
            BoxMtrx.Invert(BoxMtrx);
            ray.Transform(BoxMtrx);
            if (box.Intersect(ray))
            {
                m_hitRegion = HitRegion.ZAxis;
                return(true);
            }

            return(false);
        }
 /// <summary>
 /// Make the provided control parented to ourself.
 /// </summary>
 /// <param name="c">Control to reparent.</param>
 public void MakeParent(Control c) =>
 // Ask the view control to perform reparenting
 ViewControl.MakeParent(c);
 public LoadSongsCommand(IJukeController controller, ViewControl view, SelectionModel model) : base(controller,
                                                                                                    view, model)
 {
 }
Exemple #24
0
 public DeleteAlbumCommand(IJukeController controller, ViewControl view, SelectionModel model) : base(controller,
                                                                                                      view, model)
 {
     model.PropertyChanged += Model_PropertyChanged;
 }
        public override void Render(ViewControl vc)
        {
            BasicRendererFlags solid = BasicRendererFlags.Solid
                                       | BasicRendererFlags.DisableDepthTest;
            BasicRendererFlags wire = BasicRendererFlags.WireFrame
                                      | BasicRendererFlags.DisableDepthTest;


            Matrix4F normWorld = GetManipulatorMatrix();

            if (normWorld == null)
            {
                return;
            }

            Camera camera = vc.Camera;
            Vec3F  pos    = normWorld.Translation;
            float  s;

            Util.CalcAxisLengths(vc.Camera, pos, out s);

            Vec3F sv      = new Vec3F(s, s, s);
            Vec3F axscale = new Vec3F(Math.Abs(s * m_scale.X), Math.Abs(s * m_scale.Y), Math.Abs(s * m_scale.Z));

            Color xcolor   = (m_hitRegion == HitRegion.XAxis || m_hitRegion == HitRegion.FreeRect) ? Color.Gold : Color.Red;
            Color ycolor   = (m_hitRegion == HitRegion.YAxis || m_hitRegion == HitRegion.FreeRect) ? Color.Gold : Color.Green;
            Color Zcolor   = (m_hitRegion == HitRegion.ZAxis || m_hitRegion == HitRegion.FreeRect) ? Color.Gold : Color.Blue;
            Color freeRect = (m_hitRegion == HitRegion.FreeRect) ? Color.Gold : Color.White;


            Matrix4F scale = new Matrix4F();

            scale.Scale(axscale);
            Matrix4F xform = scale * normWorld;

            Util3D.RenderFlag = wire;
            Util3D.DrawX(xform, xcolor);
            Util3D.DrawY(xform, ycolor);
            Util3D.DrawZ(xform, Zcolor);

            Vec3F rectScale = sv * FreeRectRatio;

            scale.Scale(rectScale);
            Matrix4F b        = Util.CreateBillboard(pos, camera.WorldEye, camera.Up, camera.LookAt);
            Matrix4F recXform = Matrix4F.Multiply(scale, b);

            Util3D.DrawRect(recXform, freeRect);

            Vec3F handle      = sv * HandleRatio;
            float handleWidth = handle.X / 2;

            scale.Scale(handle);
            Matrix4F trans = new Matrix4F();

            trans.Translation = new Vec3F(axscale.X - handleWidth, 0, 0);
            xform             = scale * trans * normWorld;

            Util3D.RenderFlag = solid;

            Util3D.DrawCube(xform, xcolor);

            trans.Translation = new Vec3F(0, axscale.Y - handleWidth, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, ycolor);

            trans.Translation = new Vec3F(0, 0, axscale.Z - handleWidth);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, Zcolor);
        }
 public override void OnMouseWheel(ViewControl vc, Point scrPt, int delta)
 {
 }
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_cancelDrag || m_hitRegion == HitRegion.None || NodeList.Count == 0)
            {
                return;
            }

            bool hitAxis = m_hitRegion == HitRegion.XAxis ||
                           m_hitRegion == HitRegion.YAxis ||
                           m_hitRegion == HitRegion.ZAxis;


            Matrix4F view = vc.Camera.ViewMatrix;
            Matrix4F proj = vc.Camera.ProjectionMatrix;
            Matrix4F vp   = view * proj;

            // create ray in world space.
            Ray3F rayW = vc.GetRay(scrPt, vp);

            // create ray in view space.
            Ray3F rayV      = vc.GetRay(scrPt, proj);
            Vec3F translate = m_translatorControl.OnDragging(rayV);

            ISnapSettings snapSettings = (ISnapSettings)DesignView;
            bool          snapToGeom   = Control.ModifierKeys == m_snapGeometryKey;

            if (snapToGeom)
            {
                Vec3F manipPos = HitMatrix.Translation;
                Vec3F manipMove;
                if (hitAxis)
                {
                    //Make rayw to point toward moving axis and starting
                    // from manipulator’s world position.
                    rayW.Direction = Vec3F.Normalize(translate);
                    rayW.Origin    = manipPos;
                    manipMove      = Vec3F.ZeroVector;
                    m_cancelDrag   = true; //stop further snap-to's
                }
                else
                {
                    manipMove = rayW.ProjectPoint(manipPos) - manipPos;
                }

                for (int i = 0; i < NodeList.Count; i++)
                {
                    ITransformable node               = NodeList[i];
                    Vec3F          snapOffset         = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);
                    Path <DomNode> path               = new Path <DomNode>(Adapters.Cast <DomNode>(node).GetPath());
                    Matrix4F       parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
                    Vec3F          orgPosW;
                    parentLocalToWorld.Transform(m_originalValues[i], out orgPosW);

                    Matrix4F parentWorldToLocal = new Matrix4F();
                    parentWorldToLocal.Invert(parentLocalToWorld);

                    rayW.MoveToIncludePoint(orgPosW + snapOffset + manipMove);

                    HitRecord[] hits    = GameEngine.RayPick(view, proj, rayW, true);
                    bool        cansnap = false;
                    HitRecord   target  = new HitRecord();
                    if (hits.Length > 0)
                    {
                        // find hit record.
                        foreach (var hit in hits)
                        {
                            if (m_snapFilter.CanSnapTo(node, GameEngine.GetAdapterFromId(hit.instanceId)))
                            {
                                target  = hit;
                                cansnap = true;
                                break;
                            }
                        }
                    }

                    if (cansnap)
                    {
                        Vec3F pos;
                        if (target.hasNearestVert && snapSettings.SnapVertex)
                        {
                            pos = target.nearestVertex;
                        }
                        else
                        {
                            pos = target.hitPt;
                        }

                        pos -= snapOffset;
                        parentWorldToLocal.Transform(ref pos);
                        Vec3F diff = pos - node.Transform.Translation;
                        node.Translation += diff;
                        bool rotateOnSnap = snapSettings.RotateOnSnap &&
                                            target.hasNormal &&
                                            (node.TransformationType & TransformationTypes.Rotation) != 0;
                        if (rotateOnSnap)
                        {
                            Vec3F localSurfaceNormal;
                            parentWorldToLocal.TransformNormal(target.normal, out localSurfaceNormal);
                            node.Rotation = TransformUtils.RotateToVector(
                                m_originalRotations[i],
                                localSurfaceNormal,
                                AxisSystemType.YIsUp);
                        }
                    }
                }
            }
            else
            {
                IGrid grid       = DesignView.Context.Cast <IGame>().Grid;
                bool  snapToGrid = Control.ModifierKeys == m_snapGridKey &&
                                   grid.Visible &&
                                   vc.Camera.ViewType == ViewTypes.Perspective;
                float gridHeight = grid.Height;
                // translate.
                for (int i = 0; i < NodeList.Count; i++)
                {
                    ITransformable node = NodeList[i];
                    Path <DomNode> path = new Path <DomNode>(Adapters.Cast <DomNode>(node).GetPath());
                    Matrix4F       parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
                    Matrix4F       parentWorldToLocal = new Matrix4F();
                    parentWorldToLocal.Invert(parentLocalToWorld);
                    Vec3F localTranslation;
                    parentWorldToLocal.TransformVector(translate, out localTranslation);
                    Vec3F trans = m_originalValues[i] + localTranslation;

                    if (snapToGrid)
                    {
                        if (grid.Snap)
                        {
                            trans = grid.SnapPoint(trans);
                        }
                        else
                        {
                            trans.Y = gridHeight;
                        }
                    }

                    node.Translation = trans;
                }
            }
        }
Exemple #28
0
        public override void Render(ViewControl vc)
        {
            BasicRendererFlags solid = BasicRendererFlags.Solid
                                       | BasicRendererFlags.DisableDepthTest;
            BasicRendererFlags wire = BasicRendererFlags.WireFrame
                                      | BasicRendererFlags.DisableDepthTest;

            Matrix4F normWorld = GetManipulatorMatrix();

            if (normWorld == null)
            {
                return;
            }
            Camera camera = vc.Camera;

            int axis = (int)m_hitRegion;

            // axis colors
            Color saveColor = m_axisColor[axis];

            m_axisColor[axis] = m_highlightColor;
            Color xcolor  = m_axisColor[(int)HitRegion.XAxis];
            Color ycolor  = m_axisColor[(int)HitRegion.YAxis];
            Color zcolor  = m_axisColor[(int)HitRegion.ZAxis];
            Color nxcolor = m_axisColor[(int)HitRegion.NegXAxis];
            Color nycolor = m_axisColor[(int)HitRegion.NegYAxis];
            Color nzcolor = m_axisColor[(int)HitRegion.NegZAxis];

            m_axisColor[axis] = saveColor;

            Vec3F deltaTrans = Vec3F.ZeroVector;

            if (m_hitRegion != HitRegion.None)
            {
                normWorld.Translation = HitMatrix.Translation;
            }

            Vec3F pos = normWorld.Translation;
            float s;

            Util.CalcAxisLengths(vc.Camera, pos, out s);

            Vec3F sv           = new Vec3F(s, s, s);
            Vec3F axscale      = new Vec3F(s, s, s);
            Vec3F negAxscale   = new Vec3F(-s, -s, -s);
            bool  negativeAxis = m_hitRegion == HitRegion.NegXAxis || m_hitRegion == HitRegion.NegYAxis || m_hitRegion == HitRegion.NegZAxis;

            if (negativeAxis)
            {
                negAxscale.X *= Math.Abs(m_scale.X);
                negAxscale.Y *= Math.Abs(m_scale.Y);
                negAxscale.Z *= Math.Abs(m_scale.Z);
            }
            else
            {
                axscale.X *= Math.Abs(m_scale.X);
                axscale.Y *= Math.Abs(m_scale.Y);
                axscale.Z *= Math.Abs(m_scale.Z);
            }

            Matrix4F scale = new Matrix4F();

            scale.Scale(axscale);
            Matrix4F xform = scale * normWorld;

            Util3D.RenderFlag = wire;

            Util3D.DrawX(xform, xcolor);
            Util3D.DrawY(xform, ycolor);
            Util3D.DrawZ(xform, zcolor);

            scale.Scale(negAxscale);
            xform = scale * normWorld;

            Util3D.DrawX(xform, nxcolor);
            Util3D.DrawY(xform, nycolor);
            Util3D.DrawZ(xform, nzcolor);

            Vec3F handle      = sv * HandleRatio;
            float handleWidth = handle.X / 2;

            scale.Scale(handle);
            Matrix4F trans = new Matrix4F();



            Util3D.RenderFlag = solid;

            // X handle
            trans.Translation = new Vec3F(axscale.X - handleWidth, 0, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, xcolor);

            // y handle
            trans.Translation = new Vec3F(0, axscale.Y - handleWidth, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, ycolor);

            // z handle
            trans.Translation = new Vec3F(0, 0, axscale.Z - handleWidth);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, zcolor);


            // -x handle
            trans.Translation = new Vec3F(negAxscale.X + handleWidth, 0, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, nxcolor);

            // -y handle
            trans.Translation = new Vec3F(0, negAxscale.Y + handleWidth, 0);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, nycolor);

            // -z handle
            trans.Translation = new Vec3F(0, 0, negAxscale.Z + handleWidth);
            xform             = scale * trans * normWorld;
            Util3D.DrawCube(xform, nzcolor);
        }
Exemple #29
0
        /// <summary>
        /// Handles the SaveChanges event of the EditSaveControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void EditSaveControl_SaveChanges(object sender, EventArgs e)
        {
            OrderGroup order      = (OrderGroup)Session[_OrderGroupDtoSessionKey];
            bool       cartLoaded = false;
            Cart       cart       = null;

            if (order == null && OrderGroupId > 0)
            {
                if (this.ViewId.StartsWith(_PaymentPlanViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetPaymentPlan(CustomerId, OrderGroupId);
                }
                else if (this.ViewId.StartsWith(_PurchaseOrderViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetPurchaseOrder(CustomerId, OrderGroupId);
                }
                else if (this.ViewId.StartsWith(_ShoppingCartViewId, StringComparison.OrdinalIgnoreCase))
                {
                    order = OrderContext.Current.GetCart(CustomerId, OrderGroupId);
                }
            }

            // if order is still null, create an empty cart
            if (order == null)
            {
                cart       = CreateFreshCart();
                cartLoaded = true;
                Session[_OrderGroupDtoSessionKey] = cart;
            }

            // Put a dictionary key that can be used by other tabs
            IDictionary dic = new ListDictionary();

            if (cartLoaded)
            {
                dic.Add(_OrderContextObjectString, cart);
            }
            else
            {
                dic.Add(_OrderContextObjectString, order);
            }

            // Call tabs save
            OrderGroupEdit.SaveChanges(dic);
            ViewControl.SaveChanges(dic);

            Cart cartFromSession = order as Cart;

            if (cartFromSession != null)             // if we're in create mode, save cart as order (payment plan, cart)
            {
                if (this.ViewId.StartsWith(_PaymentPlanViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.SaveAsPaymentPlan();
                }
                else if (this.ViewId.StartsWith(_PurchaseOrderViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.SaveAsPurchaseOrder();
                }
                else if (this.ViewId.StartsWith(_ShoppingCartViewId, StringComparison.OrdinalIgnoreCase))
                {
                    cartFromSession.AcceptChanges();
                }
            }
            else
            {
                // Persist changes to the database
                order.AcceptChanges();
            }

            Session.Remove(_OrderGroupDtoSessionKey);
        }
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None || NodeList.Count == 0)
            {
                return;
            }

            Matrix4F view = vc.Camera.ViewMatrix;
            // compute world * view
            Matrix4F wv = new Matrix4F();

            wv.Mul(HitMatrix, view);

            // create ray in view space.
            Ray3F rayV = vc.GetRay(scrPt, vc.Camera.ProjectionMatrix);


            Vec3F xAxis  = wv.XAxis;
            Vec3F yAxis  = wv.YAxis;
            Vec3F zAxis  = wv.ZAxis;
            Vec3F origin = wv.Translation;

            //Vec3F pos;
            m_scale = new Vec3F(1, 1, 1);
            float scale = 1;
            float a1, a2;

            switch (m_hitRegion)
            {
            case HitRegion.XAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, yAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, zAxis));
                Vec3F axis       = (a1 > a2 ? yAxis : zAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), xAxis);
                m_scale.X = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.X;
            }

            break;

            case HitRegion.YAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, zAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, xAxis));
                Vec3F axis       = (a1 > a2 ? zAxis : xAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), yAxis);
                m_scale.Y = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.Y;
            }
            break;

            case HitRegion.ZAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, xAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, yAxis));
                Vec3F axis       = (a1 > a2 ? xAxis : yAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), zAxis);
                m_scale.Z = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.Z;
            }
            break;

            case HitRegion.FreeRect:
            {
                Vec3F axis    = new Vec3F(0, 0, 1);
                Vec3F p0      = HitRayV.IntersectPlane(axis, -origin.Z);
                Vec3F p1      = rayV.IntersectPlane(axis, -origin.Z);
                Vec3F dragVec = p1 - p0;

                float dragAmount = 1.0f + dragVec.X / m_hitScale;
                m_scale.X = dragAmount;
                m_scale.Y = dragAmount;
                m_scale.Z = dragAmount;
                scale     = m_scale.X;
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (m_isUniformScaling)
            {
                m_scale = new Vec3F(scale, scale, scale);
            }

            // scale
            for (int i = 0; i < NodeList.Count; i++)
            {
                ITransformable transformable = NodeList[i];
                transformable.Scale = Vec3F.Mul(m_originalValues[i], m_scale);
            }
        }
Exemple #31
0
 public override void UpdateRubberBandLines()
 {
     viewModel.CursorPoint = ViewControl.GetCursorPoint(CancellationToken.None).Result;
 }
Exemple #32
0
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None || NodeList.Count == 0)
            {
                return;
            }
            Camera cam = vc.Camera;

            Matrix4F view = cam.ViewMatrix;
            Matrix4F mtrx = cam.ProjectionMatrix;

            Matrix4F axisMtrx = HitMatrix * view;
            Ray3F    hitRay   = HitRayV;
            Ray3F    dragRay  = vc.GetRay(scrPt, mtrx);

            Vec3F xAxis  = axisMtrx.XAxis;
            Vec3F yAxis  = axisMtrx.YAxis;
            Vec3F zAxis  = axisMtrx.ZAxis;
            Vec3F origin = axisMtrx.Translation;

            Vec3F rotAxis = new Vec3F();
            float theta   = 0;

            float snapAngle = ((ISnapSettings)DesignView).SnapAngle;

            switch (m_hitRegion)
            {
            case HitRegion.XAxis:
            {
                Plane3F xplane = new Plane3F(xAxis, origin);
                theta   = CalcAngle(origin, xplane, hitRay, dragRay, snapAngle);
                rotAxis = HitMatrix.XAxis;
            }
            break;

            case HitRegion.YAxis:
            {
                Plane3F yplane = new Plane3F(yAxis, origin);
                theta   = CalcAngle(origin, yplane, hitRay, dragRay, snapAngle);
                rotAxis = HitMatrix.YAxis;
            }
            break;

            case HitRegion.ZAxis:
            {
                Plane3F zplane = new Plane3F(zAxis, origin);
                theta   = CalcAngle(origin, zplane, hitRay, dragRay, snapAngle);
                rotAxis = HitMatrix.ZAxis;
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            AngleAxisF axf       = new AngleAxisF(-theta, rotAxis);
            Matrix4F   deltaMtrx = new Matrix4F(axf);
            Matrix4F   rotMtrx   = new Matrix4F();

            for (int i = 0; i < NodeList.Count; i++)
            {
                ITransformable node = NodeList[i];
                rotMtrx.Mul(m_rotations[i], deltaMtrx);
                float ax, ay, az;
                rotMtrx.GetEulerAngles(out ax, out ay, out az);
                node.Rotation = new Vec3F(ax, ay, az);
            }
        }