Original Message:
Sent: 06-26-2023 20:59
From: Ronny Schneider
Subject: how to use the Wpf:StationEdit
Hello Andy,
you'll have to compute the chainage with each mouse move. Not sure if there is a better solution.
i.e. add in OnLoad
self.startstation.MouseMoveInViewEvent += self.updatestation
and as separate function that's been called with each mouse move
def updatestation(self, sender, e): if not isinstance(sender, clr.GetClrType(I2DProjection)): return tt = Point3D(e.Location.X, e.Location.Y, 0) tt = self.startstation.WindowToWorldSpaceTransform(tt, False, sender.PageToWorld) sta = self.startstation.FindAnchorPoint(tt)[1] # returns a tuple - 1 is the chainage/station and 2 the offset self.startstation.Distance = sta # updating the value shown in the station edit
------------------------------
Ronny Schneider
Original Message:
Sent: 06-26-2023 19:31
From: ANDY ZHOU
Subject: how to use the Wpf:StationEdit
Hi Ronny,
Do you know how to also display the station/distance of the StationEdit on the cursor live?
At the moment the distance is only displayed when I click on the mouse, but not live.
I can compute the closest point with "tt" but the station doesn't seem to be accurate once the cursor is too far from the line.
def DrawCustomCursor(self, sender, e):
if not isinstance(e.MessagingView, clr.GetClrType(I2DProjection)):
return
dist = self.statctrl.Distance
tt = Point3D(e.MousePosition.X, e.MousePosition.Y, 0)
tt = self.statctrl.WindowToWorldSpaceTransform(tt, False, e.MessagingView.PageToWorld)
ExploreObjectControlHelper.DrawCursorText(e.MessagingView, e.MousePosition, 10, "X: " + str(tt.X) + "\nY: " + str(tt.Y) + "\nDist: " + str(dist))
------------------------------
ANDY ZHOU
Original Message:
Sent: 01-28-2021 23:18
From: Ronny Schneider
Subject: how to use the Wpf:StationEdit
Thanks Gary,
that works, I just had to figure out how to convert the view to world coordinates.
def OnLoad(self, cmd, buttons, event): self.Caption = cmd.Command.Caption wv = self.currentProject [Project.FixedSerial.WorldView] self.coordpick1.ShowGdiCursor += self.DrawCustomCursor def DrawCustomCursor(self, sender, e): if not isinstance(e.MessagingView, clr.GetClrType(I2DProjection)): return tt = Point3D(e.MousePosition.X, e.MousePosition.Y, 0) tt = self.coordpick1.WindowToWorldSpaceTransform(tt, False, e.MessagingView.PageToWorld) ExploreObjectControlHelper.DrawCursorText(e.MessagingView, e.MousePosition, 10, "X: " + str(tt.X) + "\nY: " + str(tt.Y));

------------------------------
Ronny Schneider
Original Message:
Sent: 01-25-2021 09:34
From: Gary Lantaff
Subject: how to use the Wpf:StationEdit
There is a helper method in BaseCommands that makes adding the text easy.
clr.AddReference("Trimble.Vce.UI.BaseCommands")
from Trimble.Vce.UI.BaseCommands import ExploreObjectControlHelper
In the OnLoad method, hook up a cursor callback.
self.startStaCtl.ShowGdiCursor += self.DrawCustomCursor
When the user moves the mouse, this method will be called.
def DrawCustomCursor(self, sender, e):
if not isinstance(e.MessagingView, clr.GetClrType(I2DProjection)):
return
ExploreObjectControlHelper.DrawCursorText(e.MessagingView, e.MousePosition, 10, "Hello\nWorld");
------------------------------
Gary Lantaff
Original Message:
Sent: 01-23-2021 03:12
From: Ronny Schneider
Subject: how to use the Wpf:StationEdit
Thanks Gary,
that works.
For other interested users:
in the Xaml:
<Wpf:SelectEntity x:Name="linepicker1"/><Wpf:StationEdit x:Name="station" />
in the .py
def OnLoad(self, cmd, buttons, event): self.Caption = cmd.Command.Caption self.lType = clr.GetClrType(IPolyseg) self.linepicker1.IsEntityValidCallback=self.IsValid self.linepicker1.ValueChanged += self.lineChanged def IsValid(self, serial): o=self.currentProject.Concordance.Lookup(serial) if isinstance(o, self.lType): return True return False def lineChanged(self, ctrl, e): l1=self.linepicker1.Entity if l1 != None: self.station.StationProvider = l1
Any idea on how that cursor with the running values works.
------------------------------
Ronny Schneider
Original Message:
Sent: 01-22-2021 08:16
From: Gary Lantaff
Subject: how to use the Wpf:StationEdit
The StationEdit control has a property called "StationProvider". Set that to the alignment you want the station to be measured from. If the command lets you select this line, then set this property in the ValueChanged event (of the line's SelectEntity or ComboBoxEntityPicker control)
------------------------------
Gary Lantaff
Original Message:
Sent: 01-21-2021 14:48
From: Ronny Schneider
Subject: how to use the Wpf:StationEdit
Hi,
how do I tell the Wpf:StationEdit which alignment/line to use and to show the value on screen like the "explore object" function. Right now the mouse cursor disappears when the focus is on that field.
I guess I have to have some kind of "def self.stationedit.OnLoad" with some TBC capture mouse function.

I guess something similar can be done with the coordinate edit to achieve a view like with the ANZ-Toolbox "Measure Surface" tool.

------------------------------
Ronny Schneider
------------------------------