void CImconView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CImconDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (m_bScaleToWindow) return; m_ptScrollOffset = GetScrollPosition(); if (m_bSelection) DrawSelectionRect(&m_rectSelection); // Delete old selection m_bSelection = FALSE; m_ptStartPosition.x = point.x; m_ptStartPosition.y = point.y; m_rectSelection.left = m_ptStartPosition.x; m_rectSelection.top = m_ptStartPosition.y; m_rectSelection.right = point.x; m_rectSelection.bottom = point.y; m_rectSelection += m_ptScrollOffset; if (m_rectSelection.left >= (int) pDoc->m_uWidth) { m_rectSelection.left = 0; m_rectSelection.right = 0; m_ptStartPosition.x = pDoc->m_uWidth - 1; } if (m_rectSelection.top >= (int) pDoc->m_uHeight) { m_rectSelection.top = 0; m_rectSelection.bottom = 0; m_ptStartPosition.y = pDoc->m_uHeight - 1; } m_rectSelection.NormalizeRect(); CString strSelectionText; CPoint pixel; BYTE cGray; pixel.x = point.x + m_ptScrollOffset.x; pixel.y = ((int) pDoc->m_uHeight - 1) - (point.y + m_ptScrollOffset.y); if ((pixel.x >= (int) pDoc->m_uWidth) || ( (pixel.y >= (int) pDoc->m_uHeight) && (pixel.y >= 0) ) ) { strSelectionText.Format(""); } else { cGray = pDoc->m_Dib.GetPixelValue(pixel); strSelectionText.Format("Pixel (x,y): %d,%d mit Wert %d", pixel.x, pixel.y, cGray); } ((CMainFrame *) AfxGetMainWnd())->SetSelectionText((LPCSTR) strSelectionText); m_bSelectionStarted = TRUE; CScrollView::OnLButtonDown(nFlags, point); }
void TStageMovieCue::Draw(BRect updateRect) { if ( (m_Bitmap) && IsCueHidden() == true &&!IsHidden() ) { rgb_color saveColor = HighColor(); // Draw bitmap DrawBitmap(m_Offscreen, B_ORIGIN); // Data selection and resizing rect DrawSelectionRect(); SetHighColor(saveColor); } }
void CChildView::OnLButtonUp(UINT nFlags, CPoint point) { if (m_ptClick.x != -1) { if (!m_Moving) HideMarkDescriptions(); m_ptClick.x = -1; ReleaseCapture(); SetViewCursor(m_DefCur); if (!m_Selection.IsRectNull()) { CDC *dc; dc = GetDC(); DrawSelectionRect(*dc); ReleaseDC(dc); CContentObjects& objs = theApp.m_map.Content.Objects; CContentObj* o; CRect r; m_Selection.NormalizeRect(); ScreenToMapRect(&m_Selection); for (int i = 0; i < objs.GetSize(); i++) { o = objs[i]; if (!o->Selected && o->Plane == theApp.m_map.m_iLevel && r.IntersectRect(o->BoundsRect, m_Selection) && o->IsVisible() == ovVisible) if (theApp.m_map.Content.IsVisibleUser(o, o->BoundsRect)) { o->Selected = TRUE; InvalidateObj(o); m_ObjSelCount++; } } m_Selection.SetRectEmpty(); UpdateCurrentStyle(); } } CWnd ::OnLButtonUp(nFlags, point); }
void CImconView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if (m_bScaleToWindow) return; else { CImconDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CString strSelectionText; CPoint pixel; BYTE cGray; m_ptScrollOffset = GetScrollPosition(); pixel.x = point.x + m_ptScrollOffset.x; pixel.y = ((int) pDoc->m_uHeight - 1) - (point.y + m_ptScrollOffset.y); if ( (pixel.x >= (int) pDoc->m_uWidth) || (pixel.x < 0) || (pixel.y >= (int) pDoc->m_uHeight) || (pixel.y < 0) ) { strSelectionText.Format(""); // ((CMainFrame *) AfxGetMainWnd())->SetSelectionText((LPCSTR) strSelectionText); } else { if (!m_bSelectionPixel) { cGray = pDoc->m_Dib.GetPixelValue(pixel); m_cGrayValue = cGray; m_ptPixelPosition = pixel; // m_bSelectionPixel = TRUE; strSelectionText.Format("Pixel (x,y): %d,%d mit Wert %d", m_ptPixelPosition.x, m_ptPixelPosition.y, m_cGrayValue); } else { if (!m_bSelectionPixelValue1) { cGray = pDoc->m_Dib.GetPixelValue(pixel); m_cGrayValue1 = cGray; // m_bSelectionPixelValue1 = TRUE; strSelectionText.Format("Pixel (x,y): %d,%d mit Wert %d, SW1: %d", m_ptPixelPosition.x, m_ptPixelPosition.y, m_cGrayValue, m_cGrayValue1); } else { if (!m_bSelectionPixelValue2) { cGray = pDoc->m_Dib.GetPixelValue(pixel); m_cGrayValue2 = cGray; // m_bSelectionPixel = FALSE; // m_bSelectionPixelValue1 = FALSE; strSelectionText.Format("Pixel (x,y): %d,%d mit Wert %d, SW1: %d und SW2: %d", m_ptPixelPosition.x, m_ptPixelPosition.y, m_cGrayValue, m_cGrayValue1, m_cGrayValue2); } } } } ((CMainFrame *) AfxGetMainWnd())->SetSelectionText((LPCSTR) strSelectionText); } if (!m_bSelectionStarted) return; if (nFlags & MK_LBUTTON) { DrawSelectionRect(&m_rectSelection); m_rectSelection.left = m_ptStartPosition.x; m_rectSelection.top = m_ptStartPosition.y; m_rectSelection.right = point.x; m_rectSelection.bottom = point.y; m_rectSelection += m_ptScrollOffset; m_rectSelection.NormalizeRect(); // Check image boundaries CImconDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); m_rectSelection.right = min(m_rectSelection.right, (int) pDoc->m_uWidth - 1); m_rectSelection.bottom = min(m_rectSelection.bottom, (int) pDoc->m_uHeight - 1); DrawSelectionRect(&m_rectSelection); if (!m_rectSelection.IsRectEmpty()) m_bSelection = TRUE; if (m_rectSelection.Width() > 0 && m_rectSelection.Height() > 0) { CString strSelectionText; strSelectionText.Format("Auswahl: %d x %d", m_rectSelection.Width(), m_rectSelection.Height()); ((CMainFrame *) AfxGetMainWnd())->SetSelectionText((LPCSTR) strSelectionText); } } else m_bSelectionStarted = FALSE; CScrollView::OnMouseMove(nFlags, point); }
void MatrixViewer::Init (const QString &title, MatrixRaster* data[2]) { try { ui=new Ui::ui_MatrixViewer; } catch (...) { ui=NULL; return; } try { ui->setupUi(this); } catch (...) { delete ui; ui=NULL; return; } this->setWindowTitle(title); this->setFocusPolicy(Qt::ClickFocus); ui->Plot->setAxisScale(QwtPlot::yLeft,data[0]->GetRows(),0.0); ui->Plot->setAxisScale(QwtPlot::xBottom,0.0,data[0]->GetCols()); ui->Plot->enableAxis(QwtPlot::xTop,false); ui->Plot->enableAxis(QwtPlot::xBottom,false); ui->Plot->enableAxis(QwtPlot::yLeft,false); ui->Plot->enableAxis(QwtPlot::yRight,false); //QwtColorMap *c_map=_cntrl->AllocMainCMap(ui->S_Left->minValue(),ui->S_Right->maxValue()); QwtColorMap *c_map=_cntrl->AllocMainCMap(0.0,1.0); QwtPlotSpectrogram *dt=new QwtPlotSpectrogram; dt->setData(*(data[0])); dt->attach(ui->Plot); dt->setColorMap(*c_map); _cntrl->FreeMainCMap(c_map); _data[0]=dt; dt->show(); const QwtDoubleInterval tmp_range=_data[0]->data().range(); ui->S_Left->setRange(tmp_range.minValue(),tmp_range.maxValue()); ui->S_Left->setValue(ui->S_Left->minValue()); ui->S_Right->setRange(ui->S_Left->minValue(),ui->S_Left->maxValue()); ui->S_Right->setValue(ui->S_Right->maxValue()); if (data[1]!=NULL) { // then _cntrl->AllocAuxCMap()!=NULL too dt=new QwtPlotSpectrogram; dt->setData(*(data[1])); dt->attach(ui->Plot); c_map=_cntrl->AllocAuxCMap(); dt->setColorMap(*c_map); _cntrl->FreeAuxCMap(c_map); _data[1]=dt; dt->show(); } else _data[1]=NULL; QPen pen; /* a pen for cursor and selection rectangle */ pen.setColor((_cntrl->GetType()==2)/*comparator*/? Qt::green : Qt::cyan); pen.setWidth(1); /* cursor on the widget with matrices (looks like '+') */ const double data_x[]={0.5,0.5,0.5,0.0,1.0}; const double data_y[]={0.0,1.0,0.5,0.5,0.5}; cursor=new QwtPlotCurve; cursor->setPen(pen); cursor->setData(data_x,data_y,5); cursor->attach(ui->Plot); cursor->show(); selection_rect=new QwtPlotCurve; selection_rect->show(); selection_rect->setPen(pen); selection_rect->attach(ui->Plot); zoomer=new QwtPlotPicker(ui->Plot->canvas()); zoomer->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::CornerToCorner | QwtPicker::DragSelection); zoomer->setRubberBand(QwtPicker::RectRubberBand); zoomer->setRubberBandPen(QPen(pen.color(),1,Qt::DashLine)); zoomer->setEnabled(true); connect(ui->S_Left,SIGNAL(valueChanged(double)),this,SLOT(SetRightSldrMinVal(const double))); connect(ui->S_Right,SIGNAL(valueChanged(double)),this,SLOT(SetLeftSldrMaxVal(const double))); connect(ui->tB_showInfo,SIGNAL(clicked()),this,SLOT(ShowInfo())); connect(ui->SB_xFrom,SIGNAL(valueChanged(int)),this,SLOT(SetAim())); connect(ui->SB_yFrom,SIGNAL(valueChanged(int)),this,SLOT(SetAim())); connect(zoomer,SIGNAL(selected(const QwtDoubleRect&)),this,SLOT(RectSelected(const QwtDoubleRect&))); connect(ui->SB_xFrom,SIGNAL(valueChanged(int)),this,SLOT(DrawSelectionRect())); connect(ui->SB_yFrom,SIGNAL(valueChanged(int)),this,SLOT(DrawSelectionRect())); connect(ui->SB_xTo,SIGNAL(valueChanged(int)),this,SLOT(DrawSelectionRect())); connect(ui->SB_yTo,SIGNAL(valueChanged(int)),this,SLOT(DrawSelectionRect())); connect(ui->B_zoom,SIGNAL(clicked()),this,SLOT(ShowZoom())); connect(ui->SB_yFrom,SIGNAL(valueChanged(int)),this,SIGNAL(RowChng(int))); // 'y' means 'row'! connect(ui->SB_xFrom,SIGNAL(valueChanged(int)),this,SIGNAL(ColChng(int))); // 'x' means 'column'! ShowInfo(); DrawSelectionRect(); }
void CChildView::OnMouseMove(UINT nFlags, CPoint point) { if (m_ptClick.x != -1) { CPoint d; d.x = (m_ptClick.x - point.x)*100/theApp.m_map.m_iZoom; d.y = (m_ptClick.y - point.y)*100/theApp.m_map.m_iZoom; if (!m_EditorMode) { theApp.m_map.ScrollMap(d.x, d.y); m_Moving = TRUE; } else { if (!m_Selection.IsRectNull()) { CDC *dc; dc = GetDC(); DrawSelectionRect(*dc); m_Selection.right = point.x; m_Selection.bottom = point.y; DrawSelectionRect(*dc); ReleaseDC(dc); goto mend; } if (!m_Moving && abs(m_ptClick.x - point.x) < 4 && abs(m_ptClick.y - point.y) < 4) goto mend; m_Moving = TRUE; CContentObjects& objs = theApp.m_map.Content.Objects; CContentObj* o; int dx2, dy2; CRect r; CPoint pt; for (int i = 0; i < objs.GetSize(); i++) { o = objs[i]; if (o->Selected) { InvalidateObj(o); o->BoundsRect.OffsetRect(-d.x, -d.y); GetClientRect(&r); pt = ScreenToMap(CPoint(r.right, r.bottom)); if (o->BoundsRect.left < theApp.m_map.PosX) dx2 = o->BoundsRect.left - theApp.m_map.PosX; else if (o->BoundsRect.right > pt.x) dx2 = o->BoundsRect.right - pt.x; else dx2 = 0; if (o->BoundsRect.top < theApp.m_map.PosY) dy2 = o->BoundsRect.top - theApp.m_map.PosY; else if (o->BoundsRect.bottom > pt.y) dy2 = o->BoundsRect.bottom - pt.y; else dy2 = 0; if (dx2 || dy2) theApp.m_map.ScrollMap(dx2, dy2); theApp.m_map.Content.Modified = TRUE; InvalidateObj(o); } } } if (theApp.m_map.m_iZoom < 100) { if (d.x) m_ptClick.x = point.x; if (d.y) m_ptClick.y = point.y; /* m_ptClick.x -= d.x*theApp.m_map.m_iZoom/100; m_ptClick.y -= d.y*theApp.m_map.m_iZoom/100; */ } else { m_ptClick.x -= d.x*theApp.m_map.m_iZoom/100; m_ptClick.y -= d.y*theApp.m_map.m_iZoom/100; } } mend: CWnd ::OnMouseMove(nFlags, point); }