public void ComputeClipPlaneDistances_ClosestObjectCoincidentWithCamera_NearClipDistance_IsDefault()
 {
     double near, far;
     var planeOrigin = farPoint.Bounds().Minimum;
     var planeNormal = new Vector3(1, 0, 0);
     var geometry = new GeometryModel3D[] { closePoint, farPoint, cube };
     HelixWatch3DViewModel.ComputeClipPlaneDistances(planeOrigin, planeNormal, geometry, 0.001, out near, out far,
         HelixWatch3DViewModel.DefaultNearClipDistance, HelixWatch3DViewModel.DefaultFarClipDistance);
     Assert.AreEqual(near, HelixWatch3DViewModel.DefaultNearClipDistance);
 }
 public void ComputeClipPlaneDistances_ObjectsInFrontAndBehind_ClipDistance_IsCorrect()
 {
     double near, far;
     var planeOrigin = new Vector3(-10, 0, 0);
     var planeNormal = new Vector3(1, 0, 0);
     var geometry = new GeometryModel3D[] { closePoint, farPoint, cube };
     HelixWatch3DViewModel.ComputeClipPlaneDistances(planeOrigin, planeNormal, geometry, 0.001, out near, out far,
         HelixWatch3DViewModel.DefaultNearClipDistance, HelixWatch3DViewModel.DefaultFarClipDistance);
     Assert.Less(near, closePoint.Bounds().GetCorners().Min(c => c.DistanceToPlane(planeOrigin, planeNormal)));
     Assert.Greater(far, farPoint.Bounds().GetCorners().Max(c => c.DistanceToPlane(planeOrigin, planeNormal)));
 }
 public void ComputeClipPlaneDistances_AllObjectsBehind__ClipDistances_AreDefault()
 {
     double near, far;
     var planeOrigin = new Vector3(50000, 0, 0);
     var planeNormal = new Vector3(1, 0, 0);
     var geometry = new GeometryModel3D[] { closePoint, farPoint, cube };
     HelixWatch3DViewModel.ComputeClipPlaneDistances(planeOrigin, planeNormal, geometry, 0.001, out near, out far,
         HelixWatch3DViewModel.DefaultNearClipDistance, HelixWatch3DViewModel.DefaultFarClipDistance);
     Assert.AreEqual(near, HelixWatch3DViewModel.DefaultNearClipDistance);
     Assert.AreEqual(far, HelixWatch3DViewModel.DefaultFarClipDistance);
 }
Esempio n. 4
0
        public static bool IsDead(this GeometryModel3D geometry)
        {
            if (geometry is PointGeometryModel3D || geometry is LineGeometryModel3D)
            {
                return(geometry.Geometry.Colors.All(c => c == HelixWatch3DViewModel.DefaultDeadColor));
            }

            if (geometry is DynamoGeometryModel3D)
            {
                return(geometry.Geometry.Colors.All(c => c.Alpha < 1.0f));
            }

            return(false);
        }
Esempio n. 5
0
        public MachineView()
        {
            InitializeComponent();

            var machineViewModel = new MachineViewModel();

            DataContext = machineViewModel;

            view3DX.AddHandler(Element3D.MouseDown3DEvent, new RoutedEventHandler((s, e) =>
            {
                var arg = e as HelixToolkit.Wpf.SharpDX.MouseDown3DEventArgs;

                if (arg.HitTestResult == null)
                {
                    return;
                }

                if (machineViewModel.EnableSelectionByView)
                {
                    var selectedModel   = arg.HitTestResult.ModelHit as GeometryModel3D;
                    var updateSelection = true;


                    if (_selectedModel != null)
                    {
                        updateSelection           = !ReferenceEquals(selectedModel, _selectedModel);
                        _selectedModel.IsSelected = false;
                        _selectedModel            = null;
                    }

                    if (updateSelection)
                    {
                        selectedModel.IsSelected = true;
                        _selectedModel           = selectedModel;
                    }
                }
                else if (machineViewModel.AddProbePoint)
                {
                    var selectedModel = arg.HitTestResult.ModelHit as GeometryModel3D;
                    var point         = arg.HitTestResult.PointHit.ToPoint3D();
                    var vm            = selectedModel.DataContext as IProbableElementViewModel;

                    vm?.AddProbePoint(point);
                }
            }));
        }
Esempio n. 6
0
 /// <summary>
 /// Binds this manipulator to a given Model3D.
 /// </summary>
 /// <param name="target">
 /// Source Visual3D which receives the manipulator transforms. 
 /// </param>
 public void Bind(GeometryModel3D source)
 {
     BindingOperations.SetBinding(this, TargetTransformProperty, new Binding("Transform") { Source = source });
     BindingOperations.SetBinding(this, TransformProperty, new Binding("Transform") { Source = source });
 }
Esempio n. 7
0
 private void UnsubscribeBoundChangeEvent(GeometryModel3D item)
 {
     item.OnTransformBoundChanged -= Item_OnBoundChanged;
 }
Esempio n. 8
0
 /// <summary>
 /// Exports the model.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="inheritedTransform">
 /// The inherited transform.
 /// </param>
 protected virtual void ExportModel(GeometryModel3D model, Transform3D inheritedTransform)
 {
 }