cart: empty [ Login ]

Entity Highlight and Fit to Zoom

< previous  1 2 
sarge
3/29/2017 7:13 PM
private SimpleTransformationProvider3D transformationProvider; While trying to debug it, I found that the matrix4d of gdiGraphics3D is different then the one is within the transformationProvider. I don't know how or where I have to put the values from tp to gg3d. kind regards
Wout
3/29/2017 7:34 PM
Could you state your problem by the way, because I haven't seen your problem statement. - Wout
sarge
3/29/2017 7:41 PM
C# Code:
private Matrix4D CalculateTo2DTransform() { transformationProvider.ViewWindow = GetClientRectangle2D(); Matrix4D to2DTransform = Matrix4D.Identity; // <-- if (model != null && bounds != null) to2DTransform = transformationProvider.CompleteTransform; // <-- values from basic fitting System.Diagnostics.Debug.WriteLine("to2DTransform:" + to2DTransform.DebugString); System.Diagnostics.Debug.WriteLine("gd3D:" + gdiGraphics3D.To2DTransform.DebugString); gdiGraphics3D.To2DTransform = to2DTransform; // <-- here the basic fiting values are appliyed, but here it's incorrect. This value must be appliyed to the transformationProvider from2DTransform = gdiGraphics3D.To2DTransform.GetInverse(); return to2DTransform; }
DEBUG OUT: to2DTransform:6.5053823869162359, 0, 0, 515.73088065418824, 0, -6.5053823869162377, 0, 790.26911934581187, 0, 0, -0.005892556509887896, 0, 0, 0, 0, 1 gd3D:9.1899999999999977, 0, 0, 380.00000000000023, 0, -9.1900000000000013, 0, 923.99999999999989, 0, 0, -0.00832427536231884, 0, 0, 0, 0, 1 the values in the gdiGraphics3D are the one I need for panning or zooming. That correct values are calculate in the
C# Code:
private void FitToScreen() { int width = this.ClientRectangle.Width; int height = this.ClientRectangle.Height; //Reset transform transformationProvider.ViewScaling = 1; transformationProvider.ResetTransforms(); //Reset Events (Opcional) I don't know if it's necessary. zoomWheelInteractor.ResetState(); rectZoomInteractor.ResetState(); panInteractor.ResetState(); Matrix4D transform = CalculateTo2DTransform(); //Transformacion actual del dibujo por pantalla del modelo BoundsCalculator boundsCalculator = new BoundsCalculator(); boundsCalculator.GetBounds(model, transform); Bounds3D bounds = boundsCalculator.Bounds; if (bounds.Initialized) { const int margin = 5; Matrix4D scaleTransform = WW.Cad.Base.DxfUtil.GetScaleTransform( bounds.Corner1, // upper left model (transform inverts Y!) bounds.Corner2, // lower right model (transform inverts Y!) bounds.Center, // center model new Point3D(margin, margin, 0d), // upper left screen new Point3D(width - margin - 1, height - margin - 1, 0d), // lower right screen new Point3D(0.5 * (width - 1), 0.5 * (height - 1), 0d) // center screen ); // new transform transform = scaleTransform * transform; //transformationProvider. //My Code gdiGraphics3D.To2DTransform = transform; //transformationProvider.ResetTransforms(transform); from2DTransform = gdiGraphics3D.To2DTransform.GetInverse(); // maybe here the 'transform' must be set to transformProvider, so the .CompleteTransformation is equal to transformation //Caché Invalidate(); } }
Or is there another way ?
Wout
3/29/2017 7:56 PM
That code was not provided by us, I cannot recommend using the code above. Please just explain what it is that you need functionally, not in terms of matrix values, because they obviously depend on your Control size and drawing, so it's useless in terms of finding your problem. - Wout
sarge
3/29/2017 8:01 PM
Ok, I need to zoom in/out, pan with mouse and zoom to bound e.g. with double wheel click like its in many CAX System. Btw. some simliar code/functionality is provided by you/rammi in some other posts. Thanks so far kind regards
Wout
3/29/2017 8:33 PM
Try using SimpleTransformationProvider2D and then just call ResetTransforms() in the double click handler:
C# Code:
private void ViewControl_DoubleClick(object sender, EventArgs e) { transformationProvider.ResetTransforms(); }
- Wout
sarge
3/30/2017 4:56 AM
Good morning, that seems to work as wished. But what here the difference in 2D and 3D? Thanks so far :) kind regards
Wout
3/30/2017 7:51 AM
I wrote this in my first reply to your question: The 3D has some margin around the drawing by default to allow for 3D rotation within the window. It's better to create a new topic for your problem next time. Replying to a 6 year old post is confusing the matter more than it helps. - Wout
< previous  1 2