/*************************************************************************/ /* Event handling for mouse */ /*************************************************************************/ private void mouseDown(object sender, HalconDotNet.HMouseEventArgs e) { _mousePressed = true; int activeROIidx = -1; double scale; if (_roiManager != null && (_dispROI == MODE_INCLUDE_ROI)) { activeROIidx = _roiManager.mouseDownAction(e.X, e.Y); } if (activeROIidx == -1) { switch (_stateView) { case MODE_VIEW_MOVE: _moveStartX = e.X; _moveStartY = e.Y; break; case MODE_VIEW_ZOOM: if (e.Button == System.Windows.Forms.MouseButtons.Left) { scale = 0.9; } else { scale = 1 / 0.9; } zoomImage(e.X, e.Y, scale); break; case MODE_VIEW_NONE: break; case MODE_VIEW_ZOOMWINDOW: activateZoomWindow((int)e.X, (int)e.Y); break; case MODE_VIEW_ZOOMCONTINUE: if (_roiManager != null && (_dispROI == MODE_INCLUDE_ROI)) { activeROIidx = _roiManager.mouseDownAction(e.X, e.Y); } break; default: break; } } //end of if }
private void ViewPort_HMouseDown(object sender, HMouseEventArgsWPF e) { if (stateView == MODE_ROI_Create) { return; } mousePressed = true; int activeROIidx = -1; double scale; if (roiManager != null && (dispROI == MODE_INCLUDE_ROI)) { activeROIidx = roiManager.mouseDownAction(e.Column, e.Row); } if (activeROIidx == -1) { switch (stateView) { case MODE_VIEW_MOVE: startX = e.Column; startY = e.Row; break; case MODE_VIEW_ZOOM: if (e.Button == System.Windows.Input.MouseButton.Left) { scale = 0.9; } else { scale = 1 / 0.9; } zoomImage(e.Column, e.Row, scale); break; case MODE_VIEW_NONE: break; case MODE_VIEW_ZOOMWINDOW: activateZoomWindow((int)e.Column, (int)e.Row); break; default: break; } } }
/*************************************************************************/ /* Event handling for mouse */ /*************************************************************************/ private void viewPort_HMouseWheel(object sender, HMouseEventArgs e) { int activeROIidx = -1; double scale; if (roiManager != null && (dispROI == MODE_INCLUDE_ROI)) { activeROIidx = roiManager.mouseDownAction(e.X, e.Y); } if (activeROIidx == -1) { if (e.Delta > 0) { scale = 0.9; } else { scale = 1 / 0.9; } zoomImage(e.X, e.Y, scale); } }
/*************************************************************************/ /* Event handling for mouse */ /*************************************************************************/ private void mouseDown(object sender, HalconDotNet.HMouseEventArgs e) { //lock (mmlocker) //{ mousePressed = true; int activeROIidx = -1; double scale; if (roiManager != null && (dispROI == MODE_INCLUDE_ROI)) { activeROIidx = roiManager.mouseDownAction(e.X, e.Y); } if (activeROIidx == -1) { switch (stateView) { case MODE_VIEW_MOVE: startX = e.X; startY = e.Y; break; case MODE_VIEW_ZOOM: if (e.Button == System.Windows.Forms.MouseButtons.Left) { scale = 0.9; } else { scale = 1 / 0.9; } zoomImage(e.X, e.Y, scale); break; case MODE_VIEW_NONE: break; case MODE_VIEW_ZOOMWINDOW: activateZoomWindow((int)e.X, (int)e.Y); break; default: break; } } //if ((myCircle.Count > 0) && SamplingMode) //{ // int myIdx = GetCircleIdx((int)e.X, (int)e.Y); // if (myIdx != -1) // { // myCircle[myIdx].Selected = !myCircle[myIdx].Selected; // repaint(); // } //} //} //end of if }
/*******************************************************************/ private void mouseMoved(object sender, HalconDotNet.HMouseEventArgs e) { if (e.Button != MouseButtons.Left) { mousePressed = true; int activeROIidx = -1; //double scale; startX = e.X; startY = e.Y; if (roiManager != null) { activeROIidx = roiManager.mouseDownAction(e.X, e.Y); } MouseMove me = new MouseMove(); try { if (HObjList.Count > 0) { HTuple gray = 0; HObjectEntry entry = (HObjectEntry)HObjList[0]; if ((e.Y >= 0) && (e.X >= 0)) { HOperatorSet.GetGrayval(entry.HObj, e.Y, e.X, out gray); me.Gray = (uint)gray.I; } } } catch { me.Gray = 0; } me.X = (int)e.X + 1; //图像从0开始,显示数据从1开始 me.Y = (int)e.Y + 1; MouseMoveEventOutput(me); } else { double motionX, motionY; if (!mousePressed) { return; } if (roiManager != null && (roiManager.activeROIidx != -1)) { roiManager.mouseMoveAction(e.X, e.Y); } else { if (!isCancelImageMove) { motionX = ((e.X - startX)); motionY = ((e.Y - startY)); if (((int)motionX != 0) || ((int)motionY != 0)) { moveImage(motionX, motionY); startX = e.X - motionX; startY = e.Y - motionY; } } } } }