Original Message:
Sent: 01-19-2025 21:37
From: Ronny Schneider
Subject: How to Pan and Zoom in 2D and 3D Views
The following might be a bit shorter version of what you tried above.
# bl - bottom left; br - bottom right; tr - top right cgrav = Point3D.MidPoint(bl, tr) # rotation between target view and unrotated view rot = Vector3D(bl, br).Azimuth - Vector3D(1,0,0).Azimuth # temp vector for view extends from bottom left to top right vbltr = Vector3D(bl, tr) # rotate the temp vector to standard/unrotated orientation vbltr.RotateAboutZ(rot) # set the view extends with the temp vector in unrotated state activeForm.SetViewExtents(bl, bl + vbltr) # that will reset the view rotation and won't center the view properly activeForm.CenterView(cgrav) # reset the view rotation activeForm.SetCameraUpVector(Vector3D(bl, br))
I came across the same issue while trying to batch export the background imagery along a long stretch of road as georeferenced images while using my rotated plot frames as reference. You need those images if you want to plot the background imagery, the plot routine ignores the map background.
The issue is the half-heartedly thrown in plan-view rotation. It works, but that's about it, hasn't been touched/improved since it was introduced with V5.51. Without extra macros, that allow i.e. to align a view properly to a line/rectangle, it's still pretty useless. And as we've demonstrated here the Hoops2dView.SetViewExtends doesn't account properly for it either. Surface legends get screwed up and so on.
Furthermore, what I tried to do, to export a rotated geo-referenced image with Hoops2dView.ViewCaptureNoUI, that is aligned to a rotated view, doesn't work either. The world file is generated without the rotation and the imported image gets distorted. Will have to jump through more hoops to get this working.
Will have to report another bug to our dealer, that the "capture image" command doesn't account for the rotated plan view, if you don't use a plotbox. If you do use a rotated plotbox it will reset the view rotation first, before exporting a correctly trimmed/rotated image with a correct worldfile. Haven't found the assembly yet they're using for that, it can't be the Hoops2dView.ViewCaptureNoUI.
------------------------------
Ronny Schneider
Original Message:
Sent: 01-16-2025 21:27
From: Vitalii Vovk
Subject: How to Pan and Zoom in 2D and 3D Views
Good catch!
curCenterPoint = Point3D.MidPoint(pMin, pMax)
------------------------------
Vitalii Vovk
Original Message:
Sent: 01-16-2025 21:06
From: Ronny Schneider
Subject: How to Pan and Zoom in 2D and 3D Views
I see. Especially with a rotated view this becomes tricky if the original SetViewExtends is not sufficient. I'll have to contemplate about this a bit more.
your
def getCenterPointScreen
can probably be shortened to
pMin, pMax = v.GetViewExtents()curCenterPoint = Point3D.MidPoint(pMin, pMax)
for a Planview the extend coordinates should return as 2D with Z=0 anyway.
------------------------------
Ronny Schneider
Original Message:
Sent: 01-16-2025 20:28
From: Vitalii Vovk
Subject: How to Pan and Zoom in 2D and 3D Views
I wanted to move the screen to a specific location and set it to a specific size, either on the horizontal or vertical side of the screen.
This is a simplified version of the class that I ended up using.
class MoveView: def __init__(self, *args, **kwargs): self.activeForm = TrimbleOffice.TheOffice.MainWindow.AppViewManager.ActiveView def panView(self, delta_X, delta_Y): self.activeForm.PanView(delta_X, delta_X, 0) def panViewToP(self, newCenterPoint): curCenterPoint = self.getCenterPointScreen() delta_Vector = curCenterPoint - newCenterPoint # Correct axis values delta_X = delta_Vector.X delta_Y = delta_Vector.Y # Fixed Y-axis reference # Apply panning self.activeForm.PanView(delta_X, delta_Y, 0) return True def getCenterPointScreen(self): pMin, pMax = self.activeForm.GetViewExtents() screen_vector = pMax - pMin screen_vector.To2D() screen_vector.Length = screen_vector.Length / 2 # Scale vector length curCenterPoint = pMin + screen_vector curCenterPoint.Z = 0.0 return curCenterPoint def moveView(self, newCenterPoint): # Center view to the new point self.activeForm.CenterView(newCenterPoint) return True def adjustViewSize(self, length, x_Axis = True): side_length = length/2 #half side length of desired axis curCenterPoint = self.getCenterPointScreen() pMin, pMax = self.activeForm.GetViewExtents() yAxis_halfLength = curCenterPoint.Y - side_length p_center_btm_yAxis = Point3D(curCenterPoint.X, yAxis_halfLength ) v_yAxis = p_center_btm_yAxis - curCenterPoint # venctor pointing alon Y-axis #adjustment angle for fliping size requirement from X-axis to Y-axis ang_adjustment = Math.PI/2 if x_Axis else 0 v_screenDiagonal = pMin - curCenterPoint #vector along diagonal of the scren from center to the btm left corner v_screenDiagonal.To2D() # find horizontal angle between vectors and adjust if needed ang = abs(Vector3D.HzAngleBetween(v_screenDiagonal, v_yAxis)) ang = ang_adjustment - ang cos = 1 if Math.Cos(ang) == 0 else Math.Cos(ang) #find hypothenus legth of triangle that would be correct diagonal size from center to btm left corner of the screen half_diagonal_length = side_length / cos v_screenDiagonal.Length = half_diagonal_length #adjust diagonal vector to the correct size #find new min and max poins for the screen new_pMin = curCenterPoint + v_screenDiagonal v_screenDiagonal.Rotate180() new_Pmax = curCenterPoint + v_screenDiagonal self.activeForm.SetViewExtents(new_pMin, new_Pmax) return True
------------------------------
Vitalii Vovk
Original Message:
Sent: 01-16-2025 20:15
From: Vitalii Vovk
Subject: How to Pan and Zoom in 2D and 3D Views
Thank you @Arturas Grigorjevas! I will play with these classes over the weekend
------------------------------
Vitalii Vovk
Original Message:
Sent: 01-13-2025 13:29
From: Arturas Grigorjevas
Subject: How to Pan and Zoom in 2D and 3D Views
Hello Vitalii,
I think this code should do what you are looking for:
var view = (Trimble.Vce.UI.UIManager.TrimbleOffice.TheOffice.MainWindow.AppViewManager.ActiveView as I2DGraphicsForm).Viewing;view.SetTransformationMatrix(left, bottom, right, top);view.SetCameraToArea(left, bottom, right, top);
The 'Viewing' member is of the type 'I2DViewing'. I2DGraphicsForm is defined in Trimble.Vce.UI.UIManager and I2DViewing is defined in Trimble.Vce.UI.Hoops.
Hope this helps!
------------------------------
Arturas Grigorjevas
Original Message:
Sent: 01-05-2025 21:51
From: Vitalii Vovk
Subject: How to Pan and Zoom in 2D and 3D Views
Hey everyone,
I have a need to move my 2D view to a specific location and zoom to a certain level. However, I couldn't figure out which method to call to make it happen.
I looked at the Trimble.Vce.UI.Hoops.Hoops2dView namespace and tried using "SetCameraUpVector," but it does not seem to do anything.
This is strange because using "SetCameraUpVector" does rotate the view. Any help would be appreciated.
------------------------------
Vitalii Vovk
------------------------------