/*******************************************************************/ private void mouseMoved(object sender, HMouseEventArgs e) { if (inMeasureLine) { return; } double motionX, motionY; #if NativeCode if (Wrapper.ShowUnit.IsEmpty(viewPort.HalconWindow)) { return; } #else #endif double currX, currY; HTuple currX1 = 0, currY1 = 0; try { #if NativeCode string message = Wrapper.ShowUnit.GetPixMessage(viewPort.HalconWindow, out currX1, out currY1); #else if (HObjList.Count < 1 || HObjList[0].HObj == null || (HObjList[0].HObj is HImage) == false) { return; } int state; viewPort.HalconWindow.GetMpositionSubPix(out currY, out currX, out state); HImage hv_image = HObjList[0].HObj as HImage; string str_value = ""; string str_position = ""; bool _isXOut = true, _isYOut = true; int channel_count; string str_imgSize = string.Format("{0}*{1}", imageHeight, imageWidth); channel_count = hv_image.CountChannels(); str_position = string.Format("|{0:F0}*{1:F0}", currY, currX); _isXOut = (currX < 0 || currX >= imageWidth); _isYOut = (currY < 0 || currY >= imageHeight); if (!_isXOut && !_isYOut) { if ((int)channel_count == 1) { double grayVal; grayVal = hv_image.GetGrayval((int)currY, (int)currX); str_value = String.Format("|{0}", grayVal); } else if ((int)channel_count == 3) { double grayValRed, grayValGreen, grayValBlue; HImage _RedChannel, _GreenChannel, _BlueChannel; _RedChannel = hv_image.AccessChannel(1); _GreenChannel = hv_image.AccessChannel(2); _BlueChannel = hv_image.AccessChannel(3); grayValRed = _RedChannel.GetGrayval((int)currY, (int)currX); grayValGreen = _GreenChannel.GetGrayval((int)currY, (int)currX); grayValBlue = _BlueChannel.GetGrayval((int)currY, (int)currX); str_value = String.Format("| R:{0}, G:{1}, B:{2})", grayValRed, grayValGreen, grayValBlue); } else { str_value = ""; } } string message = str_imgSize + str_position + str_value; #endif if (message.Length > 0) { MousePosMessage = message; TriggerShowMessageEvent(new ShowMessageEventArgs(message)); } else { return; } if (!mousePressed) { return; } if (currX1.Length != 1 || currY1.Length != 1) { return; } #if NativeCode currX = currX1; currY = currY1; #endif if (roiManager != null && (roiManager.ActiveRoiIdx != -1) && (showMode == ShowMode.IncludeROI)) { roiManager.MouseMoveAction(currX, currY); } else { //qDebug()<<"xx.D():"<<xx.; motionX = ((currX - startX)); motionY = ((currY - startY)); if (((int)motionX != 0) || ((int)motionY != 0)) { moveImage(motionX, motionY); startX = currX - motionX; startY = currY - motionY; } } } catch (HOperatorException) { return; } catch (Exception) { return; } }