FixedUpCameraFindP0.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <UserControl x:Class="TeamAAS_VP.Views.Calibration.FixedUpCameraFindP0"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:prism="http://prismlibrary.com/"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
  8. xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  9. xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
  10. xmlns:wf="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
  11. xmlns:vp="clr-namespace:Cognex.VisionPro.ToolBlock;assembly=Cognex.VisionPro.ToolGroup.Controls"
  12. xmlns:uControl="clr-namespace:TeamAAS_VP.Controls"
  13. xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.Calibration"
  14. xmlns:enums="clr-namespace:TeamAAS_VP.Enums"
  15. xmlns:convert="clr-namespace:TeamAAS_VP.ValueConverter"
  16. xmlns:lex="http://wpflocalizeextension.codeplex.com"
  17. lex:LocalizeDictionary.DesignCulture="zh-CN"
  18. lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
  19. lex:ResxLocalizationProvider.DefaultDictionary="Lang"
  20. prism:ViewModelLocator.AutoWireViewModel="True"
  21. mc:Ignorable="d"
  22. d:DataContext="{d:DesignInstance Type=vm:FixedUpCameraFindP0ViewModel}"
  23. d:Height="600"
  24. d:Width="1024"
  25. d:Background="White"
  26. FontFamily="{DynamicResource DefaultFont}">
  27. <b:Interaction.Triggers>
  28. <b:EventTrigger EventName="Loaded">
  29. <b:InvokeCommandAction Command="{Binding LoadedCommand}" />
  30. </b:EventTrigger>
  31. </b:Interaction.Triggers>
  32. <UserControl.Resources>
  33. <convert:JogConverter x:Key="JogConverter" />
  34. </UserControl.Resources>
  35. <Grid>
  36. <Grid.RowDefinitions>
  37. <RowDefinition Height="auto" />
  38. <RowDefinition Height="*" />
  39. <RowDefinition Height="auto" />
  40. </Grid.RowDefinitions>
  41. <Button Grid.Row="0"
  42. Content="{materialDesign:PackIcon Kind=ArrowLeftCircle}"
  43. Width="50"
  44. HorizontalAlignment="Left"
  45. VerticalAlignment="Top"
  46. ToolTip="{lex:Loc 返回}"
  47. Style="{StaticResource MaterialDesignIconButton}"
  48. Command="{Binding BackCommand}" />
  49. <StackPanel Grid.Row="0"
  50. Orientation="Horizontal"
  51. Margin="50,0"
  52. VerticalAlignment="Center">
  53. <materialDesign:PackIcon Kind="CrosshairsGps"
  54. Width="30"
  55. Height="30" />
  56. <TextBlock Text="{Binding SelectCalibration.Name,Converter={StaticResource StringFormatConverter},ConverterParameter=' [{0}] '}"
  57. VerticalAlignment="Center" />
  58. <TextBlock Text="{lex:Loc 校准视觉处理,Converter={StaticResource StringFormatConverter},ConverterParameter='- {0}'}"
  59. VerticalAlignment="Center" />
  60. </StackPanel>
  61. <materialDesign:DrawerHost Grid.Row="1"
  62. IsEnabled="{Binding IsAllowEdit}"
  63. OpenMode="Standard"
  64. x:Name="DrawerHost">
  65. <materialDesign:DrawerHost.RightDrawerContent>
  66. <uControl:RobotManual x:Name="robotManual" />
  67. </materialDesign:DrawerHost.RightDrawerContent>
  68. <Grid>
  69. <Grid.ColumnDefinitions>
  70. <ColumnDefinition Width="*" />
  71. <ColumnDefinition Width="auto" />
  72. </Grid.ColumnDefinitions>
  73. <wf:WindowsFormsHost Grid.Column="0"
  74. Margin="0,0,0,35">
  75. <vp:CogToolBlockEditV2 x:Name="ToolBlockEditV2" />
  76. </wf:WindowsFormsHost>
  77. <Button Content="{lex:Loc 运行流程}"
  78. Width="100"
  79. HorizontalAlignment="Left"
  80. VerticalAlignment="Bottom"
  81. Margin="5,3"
  82. Command="{Binding RunVisionProcessCommand}" />
  83. <Grid Grid.Column="1">
  84. <Grid.RowDefinitions>
  85. <RowDefinition Height="auto" />
  86. <RowDefinition Height="auto" />
  87. <RowDefinition Height="auto" />
  88. <RowDefinition Height="auto" />
  89. <RowDefinition Height="auto" />
  90. <RowDefinition Height="auto" />
  91. <RowDefinition Height="auto" />
  92. <RowDefinition Height="auto" />
  93. </Grid.RowDefinitions>
  94. <Grid.ColumnDefinitions>
  95. <ColumnDefinition Width="auto" />
  96. <ColumnDefinition Width="*" />
  97. </Grid.ColumnDefinitions>
  98. <TextBlock Text="选择下相机:"
  99. FontWeight="Bold"
  100. Grid.Row="0"
  101. VerticalAlignment="Center"
  102. Grid.Column="0" />
  103. <ComboBox Grid.Row="0"
  104. Grid.Column="1"
  105. ItemsSource="{Binding Cameras}"
  106. SelectedItem="{Binding SelectCamera}"
  107. materialDesign:HintAssist.Hint="{lex:Loc 选择相机}">
  108. <ComboBox.ItemTemplate>
  109. <DataTemplate>
  110. <StackPanel Orientation="Horizontal">
  111. <materialDesign:PackIcon Kind="Camera" />
  112. <TextBlock Text="{Binding CameraName}"
  113. Margin="6,0" />
  114. </StackPanel>
  115. </DataTemplate>
  116. </ComboBox.ItemTemplate>
  117. </ComboBox>
  118. <TextBlock Text="{lex:Loc 相机参数设置}"
  119. Grid.Row="1"
  120. FontWeight="Bold"
  121. Margin="0,10"
  122. Grid.ColumnSpan="2" />
  123. <TextBlock Grid.Row="2"
  124. Grid.Column="0"
  125. Margin="5"
  126. VerticalAlignment="Center"
  127. Text="{lex:Loc 曝光时间,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
  128. <mah:NumericUpDown Grid.Row="2"
  129. Grid.Column="1"
  130. Margin="5"
  131. Minimum="35"
  132. Maximum="999985"
  133. Interval="35"
  134. StringFormat="{}{0:N0} us"
  135. Value="{Binding ExposureTime,Mode=TwoWay}" />
  136. <TextBlock Grid.Row="3"
  137. Grid.Column="0"
  138. Margin="5"
  139. VerticalAlignment="Center"
  140. Text="{lex:Loc 增益,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
  141. <mah:NumericUpDown Grid.Row="3"
  142. Grid.Column="1"
  143. Margin="5"
  144. Minimum="0"
  145. Maximum="63"
  146. Interval="1"
  147. StringFormat="{}{0:N2} db"
  148. Value="{Binding Gain,Mode=TwoWay}" />
  149. <TextBlock Text="选择校准:"
  150. FontWeight="Bold"
  151. Grid.Row="4"
  152. VerticalAlignment="Center"
  153. Grid.Column="0" />
  154. <ComboBox Grid.Row="4"
  155. Grid.Column="1"
  156. ItemsSource="{Binding CalibrationList}"
  157. SelectedItem="{Binding SelectedCalibration}"
  158. materialDesign:HintAssist.Hint="选择校准">
  159. <ComboBox.ItemTemplate>
  160. <DataTemplate>
  161. <StackPanel Orientation="Horizontal">
  162. <materialDesign:PackIcon Kind="Camera" />
  163. <TextBlock Text="{Binding Name}"
  164. Margin="6,0" />
  165. </StackPanel>
  166. </DataTemplate>
  167. </ComboBox.ItemTemplate>
  168. </ComboBox>
  169. <StackPanel Grid.Row="6"
  170. Grid.ColumnSpan="2"
  171. VerticalAlignment="Center"
  172. Margin="0,10">
  173. <!--上下相机对拍获取P0-->
  174. <Grid d:Visibility="Visible">
  175. <Grid.RowDefinitions>
  176. <RowDefinition Height="auto" />
  177. <RowDefinition Height=" auto" />
  178. </Grid.RowDefinitions>
  179. <Grid.ColumnDefinitions>
  180. <ColumnDefinition Width="auto" />
  181. <ColumnDefinition Width="auto" />
  182. </Grid.ColumnDefinitions>
  183. <TextBlock Text="获取P0点:"
  184. FontWeight="Bold"
  185. Grid.Row="0"
  186. VerticalAlignment="Center"
  187. Grid.Column="0" />
  188. <Button Content="获取P0点"
  189. Grid.Row="0"
  190. Margin="0,10"
  191. Grid.Column="1"
  192. Command="{Binding FindP0Command}" />
  193. <TextBlock Grid.Row="1"
  194. Grid.ColumnSpan="2">
  195. <TextBlock.Text>
  196. <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{1:F3}">
  197. <Binding Path="SelectCalibration.MarkPoint.X"
  198. TargetNullValue="0.000"
  199. FallbackValue="0.000" />
  200. <Binding Path="SelectCalibration.MarkPoint.Y"
  201. TargetNullValue="0.000"
  202. FallbackValue="0.000" />
  203. </MultiBinding>
  204. </TextBlock.Text>
  205. </TextBlock>
  206. <Grid.Style>
  207. <Style TargetType="Grid">
  208. <Setter Property="Visibility"
  209. Value="Collapsed" />
  210. <Style.Triggers>
  211. <!-- 当 SelectedIndex == 0 时显示此面板 -->
  212. <DataTrigger Binding="{Binding SelectCalibration.CalibTechP0Mode}"
  213. Value="{x:Static enums:CalibTechP0Mode.CameraFindP0}">
  214. <Setter Property="Visibility"
  215. Value="Visible" />
  216. </DataTrigger>
  217. </Style.Triggers>
  218. </Style>
  219. </Grid.Style>
  220. </Grid>
  221. <!--通过移动至下相机拍照获取P0-->
  222. <Grid d:Visibility="Visible">
  223. <Grid.RowDefinitions>
  224. <RowDefinition Height="auto" />
  225. <RowDefinition Height=" auto" />
  226. <RowDefinition Height="auto" />
  227. <RowDefinition Height=" auto" />
  228. <RowDefinition Height="auto" />
  229. <RowDefinition Height=" auto" />
  230. <RowDefinition Height=" auto" />
  231. <RowDefinition Height=" auto" />
  232. </Grid.RowDefinitions>
  233. <Grid.ColumnDefinitions>
  234. <ColumnDefinition Width="auto" />
  235. <ColumnDefinition Width="auto" />
  236. <ColumnDefinition Width="auto" />
  237. </Grid.ColumnDefinitions>
  238. <TextBlock Text="放置产品的位置:"
  239. FontWeight="Bold"
  240. Grid.Row="0"
  241. VerticalAlignment="Center"
  242. Grid.Column="0" />
  243. <Button Content="示教"
  244. Grid.Row="0"
  245. Margin="0,5"
  246. Grid.Column="1"
  247. Command="{Binding TeachPutPosCommand}" />
  248. <Button Content="移动至"
  249. Grid.Row="0"
  250. Margin="5,5"
  251. Grid.Column="2"
  252. Command="{Binding MovePutPosCommand}" />
  253. <TextBlock Grid.Row="1"
  254. Grid.ColumnSpan="3">
  255. <TextBlock.Text>
  256. <MultiBinding StringFormat="{}X:{0:F3} Y:{1:F3} Z:{2:F3} U:{3:F3}">
  257. <Binding Path="SelectCalibration.PutPoint.X"
  258. TargetNullValue="0.000"
  259. FallbackValue="0.000" />
  260. <Binding Path="SelectCalibration.PutPoint.Y"
  261. TargetNullValue="0.000"
  262. FallbackValue="0.000" />
  263. <Binding Path="SelectCalibration.PutPoint.Z"
  264. TargetNullValue="0.000"
  265. FallbackValue="0.000" />
  266. <Binding Path="SelectCalibration.PutPoint.U"
  267. TargetNullValue="0.000"
  268. FallbackValue="0.000" />
  269. </MultiBinding>
  270. </TextBlock.Text>
  271. </TextBlock>
  272. <TextBlock Text="下相机拍照的位置:"
  273. FontWeight="Bold"
  274. Grid.Row="2"
  275. VerticalAlignment="Center"
  276. Grid.Column="0" />
  277. <Button Content="示教"
  278. Grid.Row="2"
  279. Margin="0,5"
  280. Grid.Column="1"
  281. Command="{Binding TeachDownCameraPosCommand}" />
  282. <Button Content="移动至"
  283. Grid.Row="2"
  284. Margin="5,5"
  285. Grid.Column="2"
  286. Command="{Binding MoveDownCameraPosCommand}" />
  287. <TextBlock Grid.Row="3"
  288. Grid.ColumnSpan="3">
  289. <TextBlock.Text>
  290. <MultiBinding StringFormat="{}X:{0:F3} Y:{1:F3} Z:{2:F3} U:{3:F3}">
  291. <Binding Path="SelectCalibration.DownCameraPoint.X"
  292. TargetNullValue="0.000"
  293. FallbackValue="0.000" />
  294. <Binding Path="SelectCalibration.DownCameraPoint.Y"
  295. TargetNullValue="0.000"
  296. FallbackValue="0.000" />
  297. <Binding Path="SelectCalibration.DownCameraPoint.Z"
  298. TargetNullValue="0.000"
  299. FallbackValue="0.000" />
  300. <Binding Path="SelectCalibration.DownCameraPoint.U"
  301. TargetNullValue="0.000"
  302. FallbackValue="0.000" />
  303. </MultiBinding>
  304. </TextBlock.Text>
  305. </TextBlock>
  306. <Button Content="开始校准"
  307. Grid.Row="4"
  308. Margin="5,5"
  309. Grid.ColumnSpan="3"
  310. Command="{Binding StartCalibP0Command}" />
  311. <TextBlock Grid.Row="5"
  312. Grid.ColumnSpan="3">
  313. <TextBlock.Text>
  314. <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{1:F3}">
  315. <Binding Path="SelectCalibration.MarkPoint.X"
  316. TargetNullValue="0.000"
  317. FallbackValue="0.000" />
  318. <Binding Path="SelectCalibration.MarkPoint.Y"
  319. TargetNullValue="0.000"
  320. FallbackValue="0.000" />
  321. </MultiBinding>
  322. </TextBlock.Text>
  323. </TextBlock>
  324. <Grid.Style>
  325. <Style TargetType="Grid">
  326. <Setter Property="Visibility"
  327. Value="Collapsed" />
  328. <Style.Triggers>
  329. <!-- 当 SelectedIndex == 0 时显示此面板 -->
  330. <DataTrigger Binding="{Binding SelectCalibration.CalibTechP0Mode}"
  331. Value="{x:Static enums:CalibTechP0Mode.CameraFindP0}">
  332. <Setter Property="Visibility"
  333. Value="Visible" />
  334. </DataTrigger>
  335. </Style.Triggers>
  336. </Style>
  337. </Grid.Style>
  338. </Grid>
  339. </StackPanel>
  340. </Grid>
  341. </Grid>
  342. </materialDesign:DrawerHost>
  343. <StackPanel Orientation="Horizontal"
  344. HorizontalAlignment="Right"
  345. VerticalAlignment="Bottom">
  346. <ToggleButton materialDesign:ToggleButtonAssist.OnContent="{materialDesign:PackIcon Kind=ArrowRight}"
  347. Content="{materialDesign:PackIcon Kind=RobotIndustrial}"
  348. IsEnabled="{Binding IsAllowEdit}"
  349. Style="{StaticResource MaterialDesignActionToggleButton}"
  350. ToolTip="{lex:Loc 机器人步进}"
  351. Margin="2,0"
  352. IsChecked="{Binding IsRightDrawerOpen,ElementName=DrawerHost}" />
  353. </StackPanel>
  354. <StackPanel Grid.Row="2"
  355. Orientation="Horizontal"
  356. HorizontalAlignment="Center"
  357. VerticalAlignment="Center"
  358. Margin="20">
  359. <Button Content="{lex:Loc 下一步}"
  360. IsEnabled="{Binding IsAllowEdit}"
  361. MinWidth="150"
  362. Margin="10,0"
  363. HorizontalAlignment="Center"
  364. VerticalAlignment="Center"
  365. materialDesign:ButtonAssist.CornerRadius="10"
  366. Style="{StaticResource MaterialDesignRaisedButton}"
  367. Command="{Binding NextCommand}" />
  368. </StackPanel>
  369. </Grid>
  370. </UserControl>