Refreshing Viewport

Apr 23, 2012 at 4:33 AM

Hi Objo

I am having issues with drawing of a line on the viewport.

I am drawing by mousedown and mousemove. With the mousemove reseting the second point in the line LineVisual3D.

What I am not getting is the line being drawn on the viewport. Even once I stop the drawing (using MouseUp) it is not until I rotate the viewport that the line is drawn on the viewport.

I am sure I am missing something simple here but I can't work out what it is. Any ideas what I might be doing wrong to not have the viewport automatically refreshing. Is there a method I can call to force the redraw?

thanks


Murray

  private void HViewPortMouseDown(object sender, MouseButtonEventArgs e)
        {
            // first see if they have selected an item only allow selection of drillholes
            var helix = (HelixViewport3D) sender;
            Point position = e.GetPosition(helix);
            Visual3D obj = helix.FindNearestVisual(position);
            if (obj != null)
            {
                // First create a new line

                _measureline = new LinesVisual3D {Color = Colors.White};
                _measureline.DepthOffset = 0.001;
                _measureLinePoint2 = new Point3D();

                Point3D? findNearestPoint = helix.FindNearestPoint(position);

                if (findNearestPoint != null)
                {
                    _measureline.Points.Add((Point3D) findNearestPoint);
                    _measureLinePoint2 = (Point3D) findNearestPoint;
                    _measureline.Points.Add(_measureLinePoint2);

                    Children.Add(_measureline);
                    RaisePropertyChanged("_measureline");
                    _measuring = true;
                    MouseMove += HViewPortMouseMove;
                }
            }
        }

        private void HViewPortMouseMove(object sender, MouseEventArgs e)
        {
            if (_measuring)
            {
                var helix = (HelixViewport3D) sender;
                Point position = e.GetPosition(helix);
                Point3D? obj = helix.FindNearestPoint(position);
                _measureline.Points.Remove(_measureLinePoint2);
                if (obj != null) _measureLinePoint2 = (Point3D) obj;
                _measureline.Points.Add(_measureLinePoint2);


                RaisePropertyChanged("_measureline");
                RaisePropertyChanged("Objects");
            }
        }

        private void HViewPortMouseUp(object sender, MouseButtonEventArgs e)
        {
            if (_measuring)
            {
                //   Objects.Remove(_measureline);
                _measuring = false;
            }
        }

Apr 23, 2012 at 4:55 AM

Ok

So I have discovered this is a bug with LinesVisual3d.

Because If I change the code to use a PipeVisual3d it works fine.

Regards

Murray

Apr 25, 2012 at 6:05 AM

Notice that the LinesVisual3D.Points property is an IList (not implementing INotifyCollectionChanged). This means the visual will not be redrawn until you change the property (replace the points collection) or change the camera (since this is a visual in screen space). 

PipeVisual3D is updated every time you change the Point1 or Point2 properties.

Feb 14, 2014 at 12:28 PM
Hello,

i guess i have the same Problem. I want to use the LinesVisual3d and not the pipes. At this time, i have a one Question. How can i reset the camera without move to start position? As i right understand, to redraw the LinesVisual3d i have to move the camera a little bit. Or can i use a special event or methode to redraw the screen and the camera pos is still?

Here my short code:
        public void refreshCamera(){
            camera.UpDirection = new Vector3D(camera.UpDirection.X, camera.UpDirection.Y, camera.UpDirection.Z);
            camera.Position = new Point3D(camera.Position.X, camera.Position.Y, camera.Position.Z);
            camera.LookDirection = new Vector3D(camera.LookDirection.X - 0.001, camera.LookDirection.Y, camera.LookDirection.Z);
            camera.LookAt(new Point3D(0, 0, 0), 1);

            viewport.ResetCamera();
        }
Please help :)
Feb 19, 2014 at 9:03 PM
This may be a defect. It should be possible to change the points on the line and redraw without changing camera position. Please create an example and add an issue!