예제 #1
0
        public MainWindow()
        {
            InitializeComponent();
            view1.Background = Brushes.Black;
            G1.Children.Add(view1);
            DefaultLights 光源 = new DefaultLights();

            view1.Children.Add(光源);
            for (int i = 0; i < 5; i++)
            {
                CreateFlag(i);
                //  <ModelVisual3D Content="{Binding FlagModel}"/>
                ModelVisual3D        M3D = new ModelVisual3D();
                TranslateTransform3D TR  = new TranslateTransform3D(i * 3, 0, 0);
                M3D.Transform = TR;
                M3D.Content   = FlagModel[i];
                view1.Children.Add(M3D);
            }
            DataContext = this;
            Loaded     += MainWindow_Loaded;

            watch = new Stopwatch();
            watch.Start();
            integratorThread = new Thread(IntegrationWorker);
            integratorThread.Start();

            CompositionTarget.Rendering += this.OnCompositionTargetRendering;
            this.Closing += MainWindow_Closing;
        }
예제 #2
0
        public void UpdateData()
        {
            R[0, 0] = 1;
            R[1, 0] = 0;
            R[2, 0] = 0;

            R[0, 1] = 0;
            R[1, 1] = 1;
            R[2, 1] = 0;

            R[0, 2] = 0;
            R[1, 2] = 0;
            R[2, 2] = 1;

            hVp3D.Children.Clear();

            var lights = new DefaultLights();

            hVp3D.Children.Add(lights);
            try
            {
                Point3DCollection path = ComputePath();
                CreateTube(path);
            }
            catch { }
        }
        private void Create3DViewPort()
        {
            var hVp3D  = new HelixViewport3D();
            var lights = new DefaultLights();
            var teaPot = new Teapot();

            hVp3D.Children.Add(lights);
            hVp3D.Children.Add(teaPot);
        }
예제 #4
0
        private void Create3DViewPort()
        {
            var hVp3D  = new HelixViewport3D();
            var lights = new DefaultLights();
            var sphere = new SphereVisual3D();
            var cube   = new CubeVisual3D();

            hVp3D.Children.Add(lights);
            hVp3D.Children.Add(sphere);
        }
예제 #5
0
        private void Create3DViewPort()
        {
            //var viewport = new HelixViewport3D();
            HelixViewport3D viewport = new HelixViewport3D();

            this.grid.Children.Add(viewport);
            var lights = new DefaultLights();

            viewport.Children.Add(new GridLinesVisual3D());
            viewport.Children.Add(lights);
            box.Width  = 6;
            box.Height = 6;
            box.Length = 6;
            box.Fill   = Brushes.Yellow;
            viewport.Children.Add(box);

            BoxVisual3D bPlane = new BoxVisual3D();

            bPlane.Height = 1;
            bPlane.Width  = 30;
            bPlane.Length = 30;
            bPlane.Fill   = Brushes.Pink;
            bPlane.Center = new Point3D(35, 30, -1);

            // Plane3D bPlane = new Plane3D();
            viewport.Children.Add(bPlane);


            BoxVisual3D cPlane = new BoxVisual3D();

            cPlane.Height = 30;
            cPlane.Width  = 1;
            cPlane.Length = 30;
            cPlane.Fill   = Brushes.Pink;
            cPlane.Center = new Point3D(35, 15, 14);
            viewport.Children.Add(cPlane);

            BoxVisual3D dPlane = new BoxVisual3D();

            dPlane.Height = 30;
            dPlane.Width  = 30;
            dPlane.Length = 1;
            dPlane.Fill   = Brushes.Pink;
            dPlane.Center = new Point3D(20, 30, 14);
            viewport.Children.Add(dPlane);

            BoxVisual3D ePlane = new BoxVisual3D();

            ePlane.Height = 30;
            ePlane.Width  = 30;
            ePlane.Length = 1;
            ePlane.Fill   = Brushes.Pink;
            ePlane.Center = new Point3D(50, 30, 14);
            viewport.Children.Add(ePlane);
        }
예제 #6
0
        //private double angle;
        //private void AnimateTimer_Tick(object sender, EventArgs e)
        //{
        //    angle += 0.1;
        //    if (angle > 360) angle = 0;

        //    ViewPortModel.Children.Where(o => o.GetName() == "Aircraft").ToList().ForEach(el =>
        //    {
        //        Matrix3D matrix = el.GetTransform();

        //        // el.GetTransform().RotatePrepend(new Quaternion(1, 0, 0, 1));

        //        Transform3DGroup group = new Transform3DGroup();
        //        group.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), angle)));
        //        group.Children.Add(new TranslateTransform3D(new Vector3D(matrix.OffsetX, matrix.OffsetY, matrix.OffsetZ)));
        //        el.Transform = group;



        //    });


        //}

        private void initialHelix3DViewPort()
        {
            ViewPortModel = new HelixViewport3D();
            ViewPortModel.ZoomExtentsWhenLoaded = true;
            var lights = new DefaultLights();

            ViewPortModel.Children.Add(lights);

            Terrain = new Models.TerrainModel();

            ViewPortModel.Children.Add(Terrain.Model3D);
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LoadObj();
            view1.ZoomExtents();
            NameScope scope = new NameScope();
            FrameworkContentElement element = new FrameworkContentElement();

            NameScope.SetNameScope(element, scope);

            // Create a box  that will be the target
            // of the animation.
            // Material material = HelixToolkit.Wpf.MaterialHelper.CreateMaterial(Colors.DarkBlue);
            // MeshBuilder meshBuilder = new MeshBuilder();
            // meshBuilder.AddBox(new Point3D(0, 0, 0), 200, 200, 200);
            // GeometryModel3D modelFloor = new GeometryModel3D(meshBuilder.ToMesh(), material);
            // modelFloor.SetName("floor");
            // MainModel3Dgroup.Children.Add(modelFloor);

            var lights = new DefaultLights();

            view1.Children.Add(lights);

            ModelVisual3D model_visual = new ModelVisual3D();

            model_visual.Content = modelFloor;
            view1.Children.Add(model_visual);
            view1.ZoomExtents();

            AxisAngleRotation3D rotation            = new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0);
            RotateTransform3D   myRotateTransform3D = new RotateTransform3D(rotation, new Point3D(0, 0, 0));

            modelFloor.Transform = myRotateTransform3D;

            element.RegisterName("rotation", rotation);

            // Create two DoubleAnimations and set their properties.
            DoubleAnimation animation = new DoubleAnimation();

            animation.From     = 0;
            animation.To       = 200;
            animation.Duration = TimeSpan.FromSeconds(2);

            Storyboard.SetTargetProperty(animation, new PropertyPath("Angle"));
            Storyboard.SetTargetName(animation, "rotation");
            myStoryboard.Children.Add(animation);
            myStoryboard.Duration = TimeSpan.FromSeconds(2);

            // Make the Storyboard a resource.
            this.Resources.Add("unique_id1", myStoryboard);
            myStoryboard.Begin(element, HandoffBehavior.Compose);
        }
예제 #8
0
        //bron: powerpoints
        private void Create3DViewPort()
        {
            var           lights       = new DefaultLights();
            ModelVisual3D modelsVisual = new ModelVisual3D
            {
                Content = modelGroup
            };

            hVp3.Camera.Position      = new Point3D(0, 30, 200);
            hVp3.Camera.LookDirection = new Vector3D(0, 0, -1);
            hVp3.Camera.UpDirection   = new Vector3D(0, 1, 0);
            hVp3.Children.Add(modelsVisual);
            hVp3.Children.Add(lights);
        }
예제 #9
0
        public Window_ShowModel(string PathToModel)
        {
            InitializeComponent();

            DefaultLights lights = new DefaultLights();
            Teapot        teaPot = new Teapot();

            Mviewport.Children.Add(lights);
            Mviewport.Children.Add(teaPot);

            GridModelViewer.Children.Add(Mviewport);

            LoadModel(PathToModel, Colors.LightGray, true, false);
        }
예제 #10
0
        private void InitModel()
        {
            Vector3D center = new Vector3D((_minCorner[0] + _maxCorner[0]) / 2.0, (_minCorner[1] + _maxCorner[1]) / 2.0, (_minCorner[2] + _maxCorner[2]) / 2.0);

            hVp3D.Children.Clear();
            var lights = new DefaultLights();

            hVp3D.Children.Add(lights);
            CreateMeshes(center);
            CreateWireframes(center);
            var bound = hVp3D.Children.FindBounds();

            hVp3D.ZoomExtents(bound);
        }
예제 #11
0
        protected override void UpdateLights()
        {
            switch (LightMode)
            {
            case 1:
                Light = new ThreePointLights();
                break;

            case 2:
                Light = new DefaultLights();
                break;

            default:
                Light = new SunLight();
                break;
            }
            RaisePropertyChanged("Light");
        }
예제 #12
0
        private void Create3DViewPort()
        {
            var lights = new DefaultLights();

            hVp3D.PanGesture    = new MouseGesture(MouseAction.LeftClick);
            hVp3D.RotateGesture = new MouseGesture(MouseAction.MiddleClick);

            camera.Position      = new Point3D(100, 50, 200);
            camera.LookDirection = new Vector3D(-100, 0, -100);
            camera.UpDirection   = new Vector3D(0, 1, 0);
            camera.FieldOfView   = 60;

            hVp3D.Camera = camera;

            hVp3D.Children.Add(lights);

            this.AddChild(hVp3D);
        }
예제 #13
0
        /// <summary>
        /// Creates viewport and sets lighting and camera.
        /// </summary>
        private void Create3DViewport()
        {
            Log.Info("Creating a viewer");
            this.helixViewport = new HelixViewport3D
            {
                ShowFrameRate        = true,
                ShowCoordinateSystem = true,
                ModelUpDirection     = new Vector3D(0, 1, 0)
            };

            DefaultLights     lights = new DefaultLights();
            PerspectiveCamera camera = new PerspectiveCamera()
            {
                Position      = new Point3D(0, 0, 0),
                LookDirection = new Vector3D(0, 0, -1)
            };

            this.helixViewport.Children.Add(lights);
            this.helixViewport.Camera = camera;
            this.AddChild(this.helixViewport);
        }
예제 #14
0
        public void InitGraphics(Control destControl, TreeView destTreeControl)
        {
            _destControl = destControl;
            _treeControl = destTreeControl;
            hVp3D        = new HelixViewport3D();
            var host = new ElementHost();

            host.Dock  = DockStyle.Fill;
            host.Child = hVp3D;
            _destControl.Controls.Add(host);

            BindMouseHandler();

            var lights = new DefaultLights();

            hVp3D.Children.Add(lights);

            var teaPot = new Teapot();

            hVp3D.Children.Add(teaPot);
        }
예제 #15
0
        private void RadioButtonLight_Checked(object sender, RoutedEventArgs e)
        {
            if (cont != null)
            {
                List <LightSetup> lights = new List <LightSetup>();

                foreach (object obj in cont.Children)
                {
                    if (obj is LightSetup)
                    {
                        lights.Add((LightSetup)obj);
                    }
                }

                foreach (LightSetup lsetup in lights)
                {
                    cont.Children.Remove(lsetup);
                }


                if (RB_DefaultLight.IsChecked == true)
                {
                    Debug.WriteLine("DEFAULTLIGHT");
                    DefaultLights defaultLights = new DefaultLights();
                    cont.Children.Add(defaultLights);
                }
                else if (RB_SunLight.IsChecked == true)
                {
                    Debug.WriteLine("SUNLIGHT");
                    SunLight sunLight = new SunLight();
                    cont.Children.Add(sunLight);
                }
                else if (RB_SpotLight.IsChecked == true)
                {
                    Debug.WriteLine("SPOTLIGHT");
                    SpotHeadLight spotHeadLight = new SpotHeadLight();
                    cont.Children.Add(spotHeadLight);
                }
            }
        }
예제 #16
0
        public void DrawCube()
        {
            RectangleVisual3D myCube = new RectangleVisual3D();

            myCube.Origin          = new Point3D(50, 50, 50);          //Set this value to whatever you want your Cube Origen to be.
            myCube.Width           = 50;                               //whatever width you would like.
            myCube.Length          = 50;                               //Set Length = Width
            myCube.Normal          = new Vector3D(0, 1, 0);            // if you want a cube that is not at some angle then use a vector in the direction of an axis such as this one or <1,0,0> and <0,0,1>
            myCube.LengthDirection = new Vector3D(0, 1, 0);            //This will depend on the orientation of the cube however since it is equilateral just set it to the same thing as normal.
            myCube.Material        = new DiffuseMaterial(Brushes.Red); // Set this with whatever you want or just set the myCube.Fill Property with a brush type.

            var hVp3D  = new HelixViewport3D();
            var lights = new DefaultLights();
            var teaPot = new Teapot();

            hVp3D.Children.Add(lights);
            //hVp3D.Children.Add(teaPot);
            hVp3D.Children.Add(myCube);
            this.Content = hVp3D;

            //this.AddChild(hVp3D);
        }
예제 #17
0
        private void create3DViewPort(List <Mesh> rMesh, bool hasViewcube)
        {
            hVp3D = new HelixViewport3D();
            //hVp3D = new HelixToolkit.Wpf.SharpDX.Viewport3DX();

            //Settings
            hVp3D.ShowFrameRate      = false;
            hVp3D.ViewCubeOpacity    = 0.1;
            hVp3D.ViewCubeTopText    = "T";
            hVp3D.ViewCubeBottomText = "B";
            hVp3D.ViewCubeFrontText  = "E";
            hVp3D.ViewCubeRightText  = "N";
            hVp3D.ViewCubeLeftText   = "S";
            hVp3D.ViewCubeBackText   = "W";
            hVp3D.ViewCubeHeight     = 40;
            hVp3D.ViewCubeWidth      = 40;
            hVp3D.ShowViewCube       = hasViewcube;
            var lights = new DefaultLights();

            hVp3D.Children.Add(lights);
            hVp3D.IsInertiaEnabled      = true;
            hVp3D.ZoomExtentsWhenLoaded = true;
            //hVp3D.Camera = Friends.dummyHelix.Camera;

            List <ModelVisual3D> vis = new List <ModelVisual3D>();

            for (int i = 0; i < rMesh.Count; i++)
            {
                if (rMesh[i] != null)
                {
                    MeshGeometry3D  wMesh    = new MeshGeometry3D();
                    DiffuseMaterial material = new DiffuseMaterial();
                    Friends.ConvertRhinotoWpfMesh(rMesh[i], wMesh, material);
                    GeometryModel3D model = new GeometryModel3D(wMesh, material);

                    model.BackMaterial = material;
                    ModelVisual3D v = new ModelVisual3D();
                    v.Content = model;

                    vis.Add(v);
                }
            }

            for (int i = 0; i < vis.Count; i++)
            {
                hVp3D.Children.Add(vis[i]);
            }

            //Add viewport to user control
            this.AddChild(hVp3D);


            /*
             * ContextMenu myMenu = new ContextMenu();
             *
             * MenuItem item1 = new MenuItem();
             * MenuItem item2 = new MenuItem();
             *
             * item1.Header = "item1";
             * //item1.Click += new RoutedEventHandler(item1_Click);
             * myMenu.Items.Add(item1);
             *
             * item2.Header = "item2";
             * //item2.Click += new RoutedEventHandler(item2_Click);
             * myMenu.Items.Add(item2);
             *
             * //this.ContextMenu = myMenu;
             * //myMenu.IsOpen = true;
             * hVp3D.ContextMenu = myMenu;
             */
        }
예제 #18
0
        /// <summary>
        /// Create the 3d viewport
        /// </summary>
        private void Create3DViewPort(Mesh myRhinoMesh)
        {
            var hVp3D = new HelixViewport3D();

            //hVp3D.Background = Brushes.LightGray;

            hVp3D.ShowFrameRate      = true;
            hVp3D.ViewCubeOpacity    = 0.2;
            hVp3D.ViewCubeTopText    = "T";
            hVp3D.ViewCubeFrontText  = "R";
            hVp3D.ViewCubeRightText  = "";
            hVp3D.ViewCubeBottomText = "";
            hVp3D.ViewCubeLeftText   = "F";
            hVp3D.ViewCubeBackText   = "";

            var lights = new DefaultLights();
            var teaPot = new Teapot();

            hVp3D.Children.Add(lights);

            /*
             * Whenever you can, use Visual3D objects for unique instances of objects within your scene.
             * This usage contrasts with that of Model3D objects, which are lightweight objects that are optimized to be shared and reused.
             * For example, use a Model3Dobject to build a model of a car; and use ten ModelVisual3D objects to place ten cars in your scene.
             */

            //List<int> indexList = new List<int>();
            MeshGeometry3D myMesh = new MeshGeometry3D();
            //Mesh3D myMesh3d;
            Point3DCollection myPoints = new Point3DCollection();


            if (myRhinoMesh != null)
            {
                for (int i = 0; i < myRhinoMesh.Vertices.Count; i++)
                {
                    myPoints.Add(new Point3D(myRhinoMesh.Vertices[i].X, myRhinoMesh.Vertices[i].Y, myRhinoMesh.Vertices[i].Z));
                }

                myMesh.Positions = myPoints;

                for (int i = 0; i < myRhinoMesh.Faces.Count; i++)
                {
                    myMesh.TriangleIndices.Add(myRhinoMesh.Faces[i].A);
                    myMesh.TriangleIndices.Add(myRhinoMesh.Faces[i].B);
                    myMesh.TriangleIndices.Add(myRhinoMesh.Faces[i].C);

                    //indexList.Add(myRhinoMesh.Faces[i].A);
                    //indexList.Add(myRhinoMesh.Faces[i].B);
                    //indexList.Add(myRhinoMesh.Faces[i].C);
                }

                //myMesh3d = new Mesh3D(myPoints, indexList);
            }

            //PipeVisual3D myPipe = new PipeVisual3D();

            // Define material that will use the gradient.
            // DiffuseMaterial myDiffuseMaterial = new DiffuseMaterial(Brushes.Black);
            // Add this gradient to a MaterialGroup.
            // MaterialGroup myMaterialGroup = new MaterialGroup();
            // myMaterialGroup.Children.Add(myDiffuseMaterial);

            DiffuseMaterial wireframe_material = new DiffuseMaterial(Brushes.Yellow);
            GeometryModel3D WireframeModel     = new GeometryModel3D(myMesh, wireframe_material);
            ModelVisual3D   monkey             = new ModelVisual3D();

            monkey.Content = WireframeModel;

            // TODO: Figure out a way to define a grid
            // GridLines fishsticks = new GridLines();

            hVp3D.Children.Add(monkey);
            hVp3D.ZoomExtentsWhenLoaded = true;

            //hVp3D.IsEnabled = false;

            this.AddChild(hVp3D);
        }
예제 #19
0
        public void AddLevel1Control(Point p)
        {
            switch (ControlTag)
            {
            case 12:
            {
                Label label = new Label();
                label.Content = Strings.ResStrings.Label;

                if ((CanvasW + CanvasH) > 6000)
                {
                    label.FontSize = 42;
                }
                else if ((CanvasW + CanvasH) > 4000)
                {
                    label.FontSize = 32;
                }
                else if ((CanvasW + CanvasH) > 2500)
                {
                    label.FontSize = 24;
                }
                else
                {
                    label.FontSize = 14;
                }

                label.Focusable = true;

                label.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Panel.SetZIndex(label, 2);
                Canvas.SetLeft(label, p.X - label.DesiredSize.Width / 2);
                Canvas.SetTop(label, p.Y - label.DesiredSize.Height / 2);


                label.MouseLeftButtonDown += Control_MouseLeftButtonDown;
                label.MouseLeftButtonUp   += Control_MouseLeftButtonUp;
                label.MouseMove           += Control_MouseMove;
                label.MouseLeave          += Control_MouseLeave;

                AddEvents(label);
                DesignCanvas.Children.Add(label);
            }
            break;

            case 11:
            {
                RichTextBox txt = new RichTextBox();
                txt.Document.Blocks.Clear();
                txt.Document.Blocks.Add(new Paragraph(new Run("Text")));
                txt.FontSize = 12;

                txt.Width  = 400;
                txt.Height = 300;

                txt.IsUndoEnabled     = true;
                txt.UndoLimit         = 150;
                txt.IsDocumentEnabled = true;

                txt.SpellCheck.IsEnabled = true;
                txt.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Panel.SetZIndex(txt, 1);
                Canvas.SetLeft(txt, p.X - txt.DesiredSize.Width / 2);
                Canvas.SetTop(txt, p.Y - txt.DesiredSize.Height / 2);

                AddEvents(txt);
                DesignCanvas.Children.Add(txt);
            }
            break;

            case 13:

            {
                Image con = new Image();
                con.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/Controls/image.png"));

                con.Width  = 128;
                con.Height = 128;

                con.Focusable = true;

                Panel.SetZIndex(con, 2);

                con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2);
                Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2);

                AddEvents(con);
                DesignCanvas.Children.Add(con);
            }
            break;

            case 14:
            {
                HelixViewport3D Mviewport = new HelixViewport3D();
                Teapot          teaPot    = new Teapot();
                Mviewport.Children.Add(teaPot);

                DefaultLights lights = new DefaultLights();
                Mviewport.Children.Add(lights);

                Mviewport.Width  = 600;
                Mviewport.Height = 400;

                Mviewport.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Panel.SetZIndex(Mviewport, 3);
                Canvas.SetLeft(Mviewport, p.X - Mviewport.DesiredSize.Width / 2);
                Canvas.SetTop(Mviewport, p.Y - Mviewport.DesiredSize.Height / 2);

                AddEvents(Mviewport);
                DesignCanvas.Children.Add(Mviewport);
            }
            break;

            case 15:
            {
                WebPage_Control web = new WebPage_Control();

                web.Width  = 600;
                web.Height = 400;
                //web.BackForwardVisibility = Visibility.Collapsed;

                web.webBrowser.Navigate("");

                web.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                web.WebUrl = "";

                Panel.SetZIndex(web, 100);
                Canvas.SetLeft(web, p.X - web.DesiredSize.Width / 2);
                Canvas.SetTop(web, p.Y - web.DesiredSize.Height / 2);

                web.ControlPanelBack = new LinearGradientBrush(Color.FromRgb(222, 222, 222), Colors.White, 90);

                web.Name = "ID_" + data.pages[SelectedPosition].LastID++;

                AddEvents(web);
                DesignCanvas.Children.Add(web);
            }
            break;

            case 16:
            {
                MediaPlayer_Control con = new MediaPlayer_Control();

                Panel.SetZIndex(con, 5);


                con.Width  = 600;
                con.Height = 400;

                con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2);
                Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2);

                AddEvents(con);
                DesignCanvas.Children.Add(con);
            }
            break;

            case 17:
            {
                ContentViewer con = new ContentViewer();

                Panel.SetZIndex(con, 3);

                con.Width  = 220;
                con.Height = 50;

                con.contentCreator.contents.Add(new Content_Text(Strings.ResStrings.ContentViewer, 20, 0));
                con.Content = con.contentCreator.Create(data);

                con.HorizontalContentAlignment = HorizontalAlignment.Center;
                con.VerticalContentAlignment   = VerticalAlignment.Center;

                con.Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));

                con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2);
                Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2);

                AddEvents(con);
                DesignCanvas.Children.Add(con);
            }
            break;


            case 18:
            {
                Gallery con = new Gallery();

                Panel.SetZIndex(con, 3);

                con.Width  = 600;
                con.Height = 400;

                con.Foreground = new SolidColorBrush(Colors.White);

                con.HorizontalContentAlignment = HorizontalAlignment.Center;
                con.VerticalContentAlignment   = VerticalAlignment.Center;

                con.AddGalleryImage(new Class.Controls.GalleryImage(Strings.ResStrings.Text, ""), new BitmapImage(new Uri("pack://application:,,,/Resources/Background/SelectModelBackground.jpg")));
                con.AddGalleryImage(new Class.Controls.GalleryImage(Strings.ResStrings.Text, ""), new BitmapImage(new Uri("pack://application:,,,/Resources/Background/BackgroundMat.jpg")));
                con.AddGalleryImage(new Class.Controls.GalleryImage(Strings.ResStrings.Text, ""), new BitmapImage(new Uri("pack://application:,,,/Resources/Background/ImgBackground.jpg")));

                con.Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));

                con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2);
                Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2);

                con.RefreshAndUpdate();

                con.Tag = "D";

                AddEvents(con);
                DesignCanvas.Children.Add(con);
            }
            break;


            case 19:
            {
                MediaPlayerController_Control con = new MediaPlayerController_Control();

                Panel.SetZIndex(con, 6);

                con.Width  = 600;
                con.Height = 400;

                con.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Canvas.SetLeft(con, p.X - con.DesiredSize.Width / 2);
                Canvas.SetTop(con, p.Y - con.DesiredSize.Height / 2);

                con.G_ControlPanel.Background = new LinearGradientBrush(Color.FromRgb(162, 162, 162), Color.FromRgb(230, 230, 230), 90);

                con.Name = "ID_" + data.pages[SelectedPosition].LastID++;

                AddEvents(con);
                DesignCanvas.Children.Add(con);
            }
            break;
            }
        }
예제 #20
0
        bool LoadModel(string PathToModel, Color DModelColor, bool LoadTexture, bool NewModel)
        {
            try
            {
                if (NewModel)
                {
                    LocalPath.CopyDirectoryToResources(System.IO.Path.GetDirectoryName(PathToModel));
                }

                Debug.WriteLine("Dir Name: " + System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(PathToModel)) + "   FileName: " + System.IO.Path.GetFileName(PathToModel));

                string Lpathtomod = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(PathToModel)) + "\\" + System.IO.Path.GetFileName(PathToModel);
                string pathtomod  = System.IO.Path.Combine(LocalPath.GetResourcesPath(), Lpathtomod);

                Debug.WriteLine("Lpath: " + Lpathtomod + " path: " + pathtomod);

                Model3DGroup mgroup = new Model3DGroup();

                string ext = System.IO.Path.GetExtension(PathToModel);
                if (ext == ".obj")
                {
                    ObjReader reader = new HelixToolkit.Wpf.ObjReader();
                    try
                    {
                        reader.DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(DModelColor));


                        if (LoadTexture)
                        {
                            mgroup = reader.Read(pathtomod);
                        }
                        else
                        {
                            reader.TexturePath = ".";
                            mgroup             = reader.Read(RichTextBoxWorker.StreamFromString(File.ReadAllText(pathtomod)));
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Error Load obj First Try: Loading texture error?: " + LoadTexture);
                        if (LoadTexture)
                        {
                            reader = new HelixToolkit.Wpf.ObjReader();
                            reader.DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(DModelColor));
                            reader.TexturePath     = ".";
                            mgroup = reader.Read(RichTextBoxWorker.StreamFromString(File.ReadAllText(pathtomod)));
                        }
                        else
                        {
                            Debug.WriteLine("Error Load 3D model: " + ex);
                            MessageBox.Show(Strings.ResStrings.NotSaved, Strings.ResStrings.NotSavedTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                }
                else
                {
                    ModelImporter modelImporter = new ModelImporter();
                    modelImporter.DefaultMaterial = new DiffuseMaterial(new SolidColorBrush(DModelColor));
                    mgroup = modelImporter.Load(pathtomod);
                }

                ModelVisual3D model = new ModelVisual3D();
                model.Content = mgroup;

                DefaultLights defaultLights = new DefaultLights();

                cont.Children.Clear();
                cont.Children.Add(model);
                cont.Children.Add(defaultLights);

                Debug.WriteLine("Adding model tag: " + Lpathtomod);

                if (cont.Tag == null)
                {
                    List <object> list = new List <object>(2);
                    list.Add(null);
                    list.Add(null);
                    cont.Tag = list;
                    ((List <object>)cont.Tag)[0] = new ModelPath(Lpathtomod, LoadTexture, DModelColor);
                }
                else
                {
                    ((List <object>)cont.Tag)[0] = new ModelPath(Lpathtomod, LoadTexture, DModelColor);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error Load 3D model: " + ex);
                MessageBox.Show(Strings.ResStrings.ErrorLoadModel, Strings.ResStrings.Error, MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }
            return(true);
        }
예제 #21
0
        private static void DrawCube()
        {
            if (Battle3DViewPort == null)
            {
                Battle3DViewPort = Application.Current.FindResource("Battle3DViewPort") as HelixViewport3D;
            }

            // Battle3DViewPort = new HelixViewport3D();

            //var view = new HelixViewport3D();


            int roomSize = 20;
            var lights   = new DefaultLights();

            LinearGradientBrush horGradBrushBlue = new LinearGradientBrush();

            horGradBrushBlue.StartPoint = new Point(0, 0.5);
            horGradBrushBlue.EndPoint   = new Point(1, 0.5);
            horGradBrushBlue.GradientStops.Add(new GradientStop(Colors.RoyalBlue, 0.0));
            horGradBrushBlue.GradientStops.Add(new GradientStop(Colors.Blue, 0.4));

            LinearGradientBrush horGradBrushGreen = new LinearGradientBrush();

            horGradBrushGreen.StartPoint = new Point(0, 0.5);
            horGradBrushGreen.EndPoint   = new Point(1, 0.5);
            horGradBrushGreen.GradientStops.Add(new GradientStop(Colors.Green, 0.5));
            horGradBrushGreen.GradientStops.Add(new GradientStop(Colors.ForestGreen, 1.0));

            RadialGradientBrush radGradBrush = new RadialGradientBrush();

            radGradBrush.GradientOrigin = new Point(0.75, 0.75);
            radGradBrush.Center         = new Point(0.5, 0.5);
            radGradBrush.RadiusX        = 0.5;
            radGradBrush.RadiusY        = 0.5;
            radGradBrush.GradientStops.Add(new GradientStop(Colors.RoyalBlue, 0.0));
            radGradBrush.GradientStops.Add(new GradientStop(Colors.Blue, 0.4));

            radGradBrush.Freeze();
            horGradBrushBlue.Freeze();

            Rectangle myRectangle = new Rectangle();

            myRectangle.Width  = 200;
            myRectangle.Height = 100;
            myRectangle.Fill   = radGradBrush;

            CubeVisual3D cube = new CubeVisual3D();

            int x = 0;
            int y = 0;
            int z = 0;

            for (x = 0; x < roomSize; x++)
            {
                for (y = 0; y < roomSize; y++)
                {
                    for (z = 0; z < roomSize; z++)
                    {
                        if (z == 0)
                        {
                            cube = new CubeVisual3D();

                            cube.SideLength = 1;
                            cube.Center     = new Point3D(x, y, z);
                            cube.Fill       = horGradBrushGreen;



                            Battle3DViewPort.Children.Add(cube);
                        }
                        else if (z == 1 && x >= 5 && y >= 5)
                        {
                            cube = new CubeVisual3D();

                            cube.SideLength = 1;
                            cube.Center     = new Point3D(x, y, z);
                            cube.Fill       = horGradBrushGreen;

                            Battle3DViewPort.Children.Add(cube);
                        }
                        else if (z >= 2 && z <= 10 && x > 10 && y > 10 && x < roomSize - 5 && y < roomSize - 5)
                        {
                            cube = new CubeVisual3D();

                            cube.SideLength = 1;
                            cube.Center     = new Point3D(x, y, z);
                            cube.Fill       = horGradBrushBlue;

                            Battle3DViewPort.Children.Add(cube);
                        }
                    }
                }
            }

            GridLinesVisual3D grid2 = new GridLinesVisual3D();

            grid2.Center        = new Point3D(12, 12, 1.52);
            grid2.Length        = 15;
            grid2.Width         = 15;
            grid2.MajorDistance = 5;
            grid2.MinorDistance = 1;
            grid2.Thickness     = .02;
            grid2.Fill          = Brushes.Black;


            Battle3DViewPort.Children.Add(grid2);

            GridLinesVisual3D grid = new GridLinesVisual3D();

            grid.Center        = new Point3D(9.5, 9.5, .52);
            grid.Length        = 20;
            grid.Width         = 20;
            grid.MajorDistance = 5;
            grid.MinorDistance = 1;
            grid.Thickness     = .02;
            grid.Fill          = Brushes.Black;


            Battle3DViewPort.Children.Add(grid);

            foreach (KeyValuePair <Guid, SphereVisual3D> sphere in Players.UnitSpheres)
            {
                Battle3DViewPort.Children.Add(sphere.Value);
            }
            //foreach(SphereVisual3D sphere in Players.UnitSpheres)
            //{

            //}
            //    Players.UnitSpheres.Add(Guid.NewGuid(), new SphereVisual3D());


            //Players.UnitSpheres.Last().Value.Center = new Point3D(5, 5, 3);
            //Players.UnitSpheres.Last().Value.Fill = Brushes.DarkOrange;
            //Players.UnitSpheres.Last().Value.Radius = 0.5;
            //Battle3DViewPort.Children.Add(Players.UnitSpheres.Last().Value);

            //UnitModel.Content = Display3d("CuteDarkVador.STL");

            //var transGroup = new Transform3DGroup();
            //transGroup.Children.Add(new ScaleTransform3D(new Vector3D(.01, .01, .01)));
            //transGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90)));
            //transGroup.Children.Add(new TranslateTransform3D(new Vector3D(5, 10, 2)));

            //UnitModel.Transform = transGroup;


            Battle3DViewPort.ZoomExtents();

            //view.Children.Add(cube);
            //BattleScreenCanvas.Children.Add(BattleViewPort);
        }
예제 #22
0
        private void btnChangeWorkshop_Click(object sender, RoutedEventArgs e)
        {
            workshopIndex = Convert.ToInt32(txtWorkshopIndex.Text);

            if ((workshopIndex >= mWorkshopInfoList.Count) || (workshopIndex < 0))
            {
                MessageBox.Show("작업장 번호를 잘못 입력하였습니다.");
            }
            else
            {
                seletedDateIndex = lstArrDateList.SelectedIndex;

                //조회하고자 하는 특정 날짜 index
                int target_date = seletedDateIndex;

                //Grid에 상세 정보 출력
                List <BlockDTO> targetBlockList = new List <BlockDTO>();

                for (int i = 0; i < mResultsInfo.TotalDailyArragnementedBlockList[seletedDateIndex].Count; i++)
                {
                    if (mResultsInfo.TotalDailyArragnementedBlockList[seletedDateIndex][i].CurrentLocatedWorkshopIndex == workshopIndex)
                    {
                        targetBlockList.Add(mResultsInfo.TotalDailyArragnementedBlockList[seletedDateIndex][i]);
                    }
                }


                //3차원 가시화
                HelixResultViewer.Children.Clear();
                main3DGroup.Children.Clear();

                //카메라 초기화
                PerspectiveCamera myCamera = (PerspectiveCamera)HelixResultViewer.Camera;
                myCamera = SetCameraPosition(myCamera, mWorkshopInfoList[workshopIndex]);

                //조명 설정
                var lights = new DefaultLights();
                HelixResultViewer.Children.Add(lights);

                //작업장 가시화
                main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[workshopIndex].RowCount, mWorkshopInfoList[workshopIndex].ColumnCount, 0, new Point3D(0, 0, 0), Colors.White));

                DateTime      CurrentDate = mResultsInfo.ArrangementStartDate.AddDays(seletedDateIndex);
                ModelVisual3D model1      = new ModelVisual3D();

                //배치불가구역 가시화

                foreach (ArrangementMatrixInfoDTO Object in mWorkshopInfoList[workshopIndex].ArrangementMatrixInfoList)
                {
                    main3DGroup.Children.Add(CreateRectModel(Math.Ceiling(Object.RowCount), Math.Ceiling(Object.ColumnCount), 0, new Point3D(Math.Ceiling(Object.RowLocation), Math.Ceiling(Object.ColumnLocation), 0), Colors.LightCyan, 3, new string[4] {
                        "NotAvailable", "", "", ""
                    }));
                }



                //블록 가시화

                foreach (BlockDTO Block in targetBlockList)
                {
                    //리드타임 계산 (출고일 - 입고일)
                    TimeSpan ts       = Block.ExportDate - Block.ImportDate;
                    int      Leadtime = ts.Days;
                    Leadtime++;

                    //실제 반출일 계산 (실제 입고일 + 리드타임)
                    DateTime ActualExportDate = Block.ActualImportDate.AddDays(Leadtime - 1);

                    //남아 있는 작업일 계산 (실제 반출일 - 현재 날짜)
                    TimeSpan ts1          = ActualExportDate - CurrentDate;
                    int      ResidualTime = ts1.Days;
                    ResidualTime++;

                    //방향에 따른 가로세로 길이 조정
                    double tempRow = Math.Ceiling(Block.RowCount);
                    double tempCol = Math.Ceiling(Block.ColumnCount);
                    if (Block.Orientation == 1)
                    {
                        tempRow = Math.Ceiling(Block.ColumnCount);
                        tempCol = Math.Ceiling(Block.RowCount);
                    }


                    //일반 블록은 검정 테두리
                    Color blockColor = Colors.Black;
                    //blockColor.A = 220;

                    //당일 입고 블록은 초록색
                    if (CurrentDate == Block.ActualImportDate)
                    {
                        blockColor = Colors.Green;
                    }
                    //blockColor.A = 100;


                    //조건 만족 블록은 파란색
                    if (Block.IsRoadSide == true)
                    {
                        blockColor = Colors.Blue;
                    }

                    //지연 블록은 빨간색
                    if (Block.IsDelayed == true)
                    {
                        blockColor = Colors.Red;
                    }

                    //출고 블록은 노란색
                    if (ResidualTime == 1)
                    {
                        blockColor = Colors.Yellow;
                    }
                    //blockColor.A = 100;

                    string[] arrprintedstring = { Block.Project, "-" + Block.Name, Block.ImportDate.ToShortDateString().Substring(5), Block.ExportDate.ToShortDateString().Substring(5) };
                    //블록 위에 출력되는 정보 확인을 위하여 minSize 계산
                    double minSize = Block.RowCount;
                    if (Block.RowCount > Block.ColumnCount)
                    {
                        minSize = Block.ColumnCount;
                    }
                    minSize = minSize / arrprintedstring[0].Length;
                    if (minSize > 3.0)
                    {
                        minSize = 3.0;
                    }

                    main3DGroup.Children.Add(CreateRectModel(tempRow, tempCol, 0, new Point3D(Math.Ceiling(Block.LocatedRow), Math.Ceiling(Block.LocatedColumn), 0), blockColor));
                    main3DGroup.Children.Add(CreateRectModel(tempRow - 0.8, tempCol - 0.8, 0, new Point3D(Math.Ceiling(Block.LocatedRow) + 0.4, Math.Ceiling(Block.LocatedColumn) + 0.4, 0), Colors.Silver, minSize, arrprintedstring));
                }
                model1.Content = main3DGroup;
                HelixResultViewer.Children.Add(model1);
            }
        }
예제 #23
0
        /// <summary>
        /// 실제로 가시화를 수행하는 이벤트 (BLF 알고리즘에서 날짜 선택시)
        /// 주수헌 수정,
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstArrDateList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            seletedDateIndex = lstArrDateList.SelectedIndex;

            //조회하고자 하는 특정 날짜 index
            int target_date = seletedDateIndex;

            List <BlockDTO> targetBlockList = new List <BlockDTO>();

            //블록배치와 주판 배치에 따라 다른 대상 설정

            //특정 날짜에 배치되어 있는 블록 호출

            targetBlockList = mResultsInfo.TotalDailyArragnementedBlockList[seletedDateIndex];

            // 배치 블록 가시화 창 밑의 배치 블록 리스트에 현재 블록 정보 입력하는 코드
            //grdBlockDetails.ItemsSource = targetBlockList;


            //작업장 원점 좌표
            //List<double[]> ws = new List<double[]>();
            //foreach (WorkshopDTO workshop in mWorkshopInfoList)
            //{
            //    ws.Add(new double[2] { workshop.RowLocation, workshop.ColumnLocation });
            //}



            //카메라 초기화를 위한 임시 작업장 생성
            WorkshopDTO tempWorkshopDTO = new WorkshopDTO();

            tempWorkshopDTO.RowCount    = 199;
            tempWorkshopDTO.ColumnCount = 809;
            //3차원 가시화
            HelixResultViewer.Children.Clear();
            if (main3DGroup.Children.Count == 0)
            {
                //카메라 초기화
                PerspectiveCamera myCamera = (PerspectiveCamera)HelixResultViewer.Camera;
                myCamera = SetCameraPosition(myCamera, tempWorkshopDTO);
            }
            else
            {
                main3DGroup.Children.Clear();
            }

            //조명 설정
            var lights = new DefaultLights();

            HelixResultViewer.Children.Add(lights);

            DateTime      CurrentDate = mResultsInfo.ArrangementStartDate.AddDays(seletedDateIndex);
            ModelVisual3D model1      = new ModelVisual3D();

            //작업장 가시화
            foreach (WorkshopDTO Workshop in mWorkshopInfoList)
            {
                if (Workshop.Type != -1)
                {
                    main3DGroup.Children.Add(CreateRectModel(Workshop.RowCount, Workshop.ColumnCount, 0, new Point3D(Workshop.RowLocation, Workshop.ColumnLocation, 0), Colors.White));
                }
                else
                {
                    main3DGroup.Children.Add(CreateRectModel(Workshop.RowCount, Workshop.ColumnCount, 0, new Point3D(Workshop.RowLocation, Workshop.ColumnLocation, 0), Colors.Gray, 10, new string[4] {
                        Workshop.Name, "", "", ""
                    }));
                }
            }
            //main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[0].RowCount, mWorkshopInfoList[0].ColumnCount, 0, new Point3D(ws[0][0], ws[0][1], 0), Colors.White));
            //main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[1].RowCount, mWorkshopInfoList[1].ColumnCount, 0, new Point3D(ws[1][0], ws[1][1], 0), Colors.White));
            //main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[2].RowCount, mWorkshopInfoList[2].ColumnCount, 0, new Point3D(ws[2][0], ws[2][1], 0), Colors.White));
            //main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[3].RowCount, mWorkshopInfoList[3].ColumnCount, 0, new Point3D(ws[3][0], ws[3][1], 0), Colors.White));
            ////도크 가시화
            //main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[3].RowCount, ws[2][1] - mWorkshopInfoList[3].ColumnCount, 0.000000, new Point3D(0, mWorkshopInfoList[3].ColumnCount, 0), Colors.Gray, 10, new string[4] { "Main Dock", "", "", ""}));
            ////입고장(북) 가시화
            ////main3DGroup.Children.Add(CreateRectModel(mWorkshopInfoList[0].RowCount, ws[1][1] - ws[0][1] - mWorkshopInfoList[0].ColumnCount, 1, new Point3D(ws[0][0], ws[0][1] + mWorkshopInfoList[0].ColumnCount, 0), Colors.Gray));


            //배치불가구역 가시화
            foreach (WorkshopDTO Workshop in mWorkshopInfoList)
            {
                foreach (ArrangementMatrixInfoDTO Object in Workshop.ArrangementMatrixInfoList)
                {
                    main3DGroup.Children.Add(CreateRectModel(Math.Ceiling(Object.RowCount), Math.Ceiling(Object.ColumnCount), 0, new Point3D(Workshop.RowLocation + Math.Ceiling(Object.RowLocation), Workshop.ColumnLocation + Math.Ceiling(Object.ColumnLocation), 0), Colors.LightCyan, 3, new string[4] {
                        "NA", "", "", ""
                    }));
                }
            }


            //블록 가시화

            foreach (BlockDTO Block in targetBlockList)
            {
                //리드타임 계산 (출고일 - 입고일)
                TimeSpan ts       = Block.ExportDate - Block.ImportDate;
                int      Leadtime = ts.Days;
                Leadtime++;

                //실제 반출일 계산 (실제 입고일 + 리드타임)
                DateTime ActualExportDate = Block.ActualImportDate.AddDays(Leadtime - 1);

                //남아 있는 작업일 계산 (실제 반출일 - 현재 날짜)
                TimeSpan ts1          = ActualExportDate - CurrentDate;
                int      ResidualTime = ts1.Days;
                ResidualTime++;

                //방향에 따른 가로세로 길이 조정
                double tempRow = Math.Ceiling(Block.RowCount);
                double tempCol = Math.Ceiling(Block.ColumnCount);
                if (Block.Orientation == 1)
                {
                    tempRow = Math.Ceiling(Block.ColumnCount);
                    tempCol = Math.Ceiling(Block.RowCount);
                }


                //일반 블록은 검정 테두리
                Color blockColor = Colors.Black;
                //blockColor.A = 220;

                //당일 입고 블록은 초록색
                if (CurrentDate == Block.ActualImportDate)
                {
                    blockColor = Colors.LightGreen;
                }
                //blockColor.A = 100;


                //조건 만족 블록은 파란색
                if (Block.IsRoadSide == true)
                {
                    blockColor = Colors.Blue;
                }

                //지연 블록은 빨간색
                if (Block.IsDelayed == true)
                {
                    blockColor = Colors.Red;
                }

                //출고 블록은 노란색
                if (ResidualTime == 1)
                {
                    blockColor = Colors.Yellow;
                }
                //blockColor.A = 100;

                DateTime tempdate         = Block.InitialExportDate.AddDays(2);
                string[] arrprintedstring = { Block.Project, "-" + Block.Name, Block.ImportDate.ToShortDateString().Substring(5), Block.ExportDate.ToShortDateString().Substring(5) };
                if (Block.IsPrior == true & Block.IsFloatingCraneExportBlock == false)
                {
                    arrprintedstring[3] = "aaa";
                }
                else if (Block.IsFloatingCraneExportBlock == true)
                {
                    arrprintedstring[2] = Block.InitialImportDate.ToShortDateString().Substring(5);
                }
                arrprintedstring[3] = Block.InitialExportDate.ToShortDateString().Substring(5);

                //블록 위에 출력되는 정보 확인을 위하여 minSize 계산
                double minSize = Block.RowCount;
                if (Block.RowCount > Block.ColumnCount)
                {
                    minSize = Block.ColumnCount;
                }
                minSize = minSize / arrprintedstring[0].Length;
                if (minSize > 3.0)
                {
                    minSize = 3.0;
                }

                main3DGroup.Children.Add(CreateRectModel(tempRow, tempCol, 0, new Point3D(mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].RowLocation + Math.Ceiling(Block.LocatedRow), mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].ColumnLocation + Math.Ceiling(Block.LocatedColumn), 0), blockColor));
                //우선순위 블록은 노란색으로 채우기
                if (Block.IsPrior == true & Block.IsFloatingCraneExportBlock == false)
                {
                    main3DGroup.Children.Add(CreateRectModel(tempRow - 0.8, tempCol - 0.8, 0, new Point3D(mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].RowLocation + Math.Ceiling(Block.LocatedRow) + 0.4, mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].ColumnLocation + Math.Ceiling(Block.LocatedColumn) + 0.4, 0), Colors.Yellow, minSize, arrprintedstring));
                }
                //출고장용 블록
                else if (Block.IsFloatingCraneExportBlock == true)
                {
                    main3DGroup.Children.Add(CreateRectModel(tempRow - 0.8, tempCol - 0.8, 0, new Point3D(mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].RowLocation + Math.Ceiling(Block.LocatedRow) + 0.4, mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].ColumnLocation + Math.Ceiling(Block.LocatedColumn) + 0.4, 0), Colors.Yellow, minSize, arrprintedstring));
                }
                else
                {
                    main3DGroup.Children.Add(CreateRectModel(tempRow - 0.8, tempCol - 0.8, 0, new Point3D(mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].RowLocation + Math.Ceiling(Block.LocatedRow) + 0.4, mWorkshopInfoList[Block.CurrentLocatedWorkshopIndex].ColumnLocation + Math.Ceiling(Block.LocatedColumn) + 0.4, 0), Colors.Silver, minSize, arrprintedstring));
                }
            }


            model1.Content = main3DGroup;
            HelixResultViewer.Children.Add(model1);
        }
예제 #24
0
        public void Deserialize(HelixViewport3D control, DataStore data)
        {
            List <object> list = new List <object>(2);

            list.Add(null);
            list.Add(null);

            DeserializeDefault(control);
            brush.Deserialize(control, data);

            list[1] = control.Tag;

            Debug.WriteLine("ModelP:  Path: " + modelp.LocalPathToModel);

            if (modelp != null)
            {
                if (!String.IsNullOrWhiteSpace(modelp.LocalPathToModel))
                {
                    string lpath = System.IO.Path.Combine(LocalPath.GetResourcesPath(), modelp.LocalPathToModel);
                    if (File.Exists(lpath))
                    {
                        LoadModel(control, lpath);
                        list[0] = control.Tag;
                    }
                    else
                    {
                        DefaultModel(control);
                    }
                }
                else
                {
                    DefaultModel(control);
                }
            }
            else
            {
                DefaultModel(control);
            }

            if (camera != null)
            {
                camera.Deserialize(control.Camera);
            }

            if (lightType == ModelLightType.LightType.SpotHeadlight)
            {
                SpotHeadLight spotHeadLight = new SpotHeadLight();
                control.Children.Add(spotHeadLight);
            }
            else if (lightType == ModelLightType.LightType.SunLight)
            {
                SunLight sunLight = new SunLight();
                control.Children.Add(sunLight);
            }
            else
            {
                DefaultLights defaultLights = new DefaultLights();
                control.Children.Add(defaultLights);
            }

            control.Tag = list;


            control.Loaded += (s, e) => {
                if (control.CameraController != null)
                {
                    control.CameraController.IsEnabled = CameraControl;
                }

                control.ShowViewCube = CameraControl;
            };
        }
예제 #25
0
        private void create3DViewPort(List <Mesh> meshes, List <PolylineCurve> polys, bool hasViewcube)
        {
            hVp3D = new HelixViewport3D();
            //hVp3D = new HelixToolkit.Wpf.SharpDX.Viewport3DX();

            //Settings
            hVp3D.ShowFrameRate = false;
            //hVp3D.ViewCubeOpacity = 0.1;
            hVp3D.ViewCubeTopText    = "T";
            hVp3D.ViewCubeBottomText = "B";
            hVp3D.ViewCubeFrontText  = "E";
            hVp3D.ViewCubeRightText  = "N";
            hVp3D.ViewCubeLeftText   = "S";
            hVp3D.ViewCubeBackText   = "W";
            hVp3D.ViewCubeHeight     = 40;
            hVp3D.ViewCubeWidth      = 40;
            hVp3D.ShowViewCube       = hasViewcube;
            DefaultLights lights = new DefaultLights();

            hVp3D.Children.Add(lights);
            hVp3D.IsInertiaEnabled      = true;
            hVp3D.ZoomExtentsWhenLoaded = true;

            List <ModelVisual3D> vis = new List <ModelVisual3D>();

            for (int i = 0; i < meshes.Count; i++)
            {
                if (meshes[i] != null)
                {
                    MeshGeometry3D  wMesh    = new MeshGeometry3D();
                    DiffuseMaterial material = new DiffuseMaterial();
                    Friends.ConvertRhinotoWpfMesh(meshes[i], wMesh, material);
                    GeometryModel3D model = new GeometryModel3D(wMesh, material);

                    model.BackMaterial = material;
                    ModelVisual3D v = new ModelVisual3D();
                    v.Content = model;

                    vis.Add(v);
                }
            }

            for (int i = 0; i < polys.Count; i++)
            {
                if (polys[i] != null)
                {
                    LinesVisual3D line = new LinesVisual3D();
                    line.Color     = Colors.Black;
                    line.Thickness = 1;

                    Rhino.Geometry.Polyline result = new Rhino.Geometry.Polyline();
                    polys[i].TryGetPolyline(out result);

                    for (int j = 0; j < result.Count - 1; j++)
                    {
                        line.Points.Add(new Point3D(result[j].X, result[j].Y, result[j].Z));
                        line.Points.Add(new Point3D(result[j + 1].X, result[j + 1].Y, result[j + 1].Z));
                    }
                    vis.Add(line);
                }
            }


            for (int i = 0; i < vis.Count; i++)
            {
                hVp3D.Children.Add(vis[i]);
            }

            //Add viewport to user control
            this.AddChild(hVp3D);

            /*
             * ContextMenu myMenu = new ContextMenu();
             *
             * MenuItem item1 = new MenuItem();
             * MenuItem item2 = new MenuItem();
             *
             * item1.Header = "item1";
             * //item1.Click += new RoutedEventHandler(item1_Click);
             * myMenu.Items.Add(item1);
             *
             * item2.Header = "item2";
             * //item2.Click += new RoutedEventHandler(item2_Click);
             * myMenu.Items.Add(item2);
             *
             * //this.ContextMenu = myMenu;
             * //myMenu.IsOpen = true;
             * hVp3D.ContextMenu = myMenu;
             */
        }
예제 #26
0
        /// <summary>
        /// Creates a simple viewport without helix
        /// </summary>
        /// <param name="chromo"></param>
        /// <param name="owner"></param>
        public ViewportBasic(Chromosome chromo, BiomorpherWindow owner)
        {
            InitializeComponent();

            Owner        = owner;
            thisDesign   = chromo;
            this.ToolTip = "double click to display in main viewport";

            myViewport = new HelixViewport3D();
            myViewport.ZoomExtentsWhenLoaded = true;
            myViewport.ShowViewCube          = false;
            DefaultLights lights = new DefaultLights();

            myViewport.Children.Add(lights);

            List <Mesh>          rMesh = thisDesign.phenoMesh;
            List <PolylineCurve> polys = thisDesign.phenoPoly;

            List <ModelVisual3D> vis = new List <ModelVisual3D>();

            for (int i = 0; i < rMesh.Count; i++)
            {
                if (rMesh[i] != null)
                {
                    MeshGeometry3D  wMesh    = new MeshGeometry3D();
                    DiffuseMaterial material = new DiffuseMaterial();
                    Friends.ConvertRhinotoWpfMesh(rMesh[i], wMesh, material);

                    GeometryModel3D model = new GeometryModel3D(wMesh, material);

                    model.BackMaterial = material;

                    // DirectionalLight myLight = new DirectionalLight(Colors.White, new Vector3D(-0.5, -1, -1));

                    Model3DGroup modelGroup = new Model3DGroup();
                    modelGroup.Children.Add(model);
                    //modelGroup.Children.Add(myLight);
                    ModelVisual3D v = new ModelVisual3D();
                    v.Content = modelGroup;
                    vis.Add(v);
                }
            }


            for (int i = 0; i < polys.Count; i++)
            {
                if (polys[i] != null)
                {
                    LinesVisual3D line = new LinesVisual3D();
                    line.Color     = Colors.Black;
                    line.Thickness = 1;

                    Rhino.Geometry.Polyline result = new Rhino.Geometry.Polyline();
                    polys[i].TryGetPolyline(out result);

                    for (int j = 0; j < result.Count - 1; j++)
                    {
                        line.Points.Add(new Point3D(result[j].X, result[j].Y, result[j].Z));
                        line.Points.Add(new Point3D(result[j + 1].X, result[j + 1].Y, result[j + 1].Z));
                    }
                    vis.Add(line);
                }
            }

            for (int i = 0; i < vis.Count; i++)
            {
                myViewport.Children.Add(vis[i]);
            }

            myViewport.IsEnabled = false;

            //Add viewport to user control
            this.AddChild(myViewport);
        }