void FuncTest::inout_rectTest() { std::vector<cv::KeyPoint> keypoints; keypoints.push_back(cv::KeyPoint(10, 10, 1)); keypoints.push_back(cv::KeyPoint(21.5, 10, 1)); keypoints.push_back(cv::KeyPoint(50, 10, 1)); keypoints.push_back(cv::KeyPoint(10, 29.3, 1)); keypoints.push_back(cv::KeyPoint(31.1, 55.7, 1)); keypoints.push_back(cv::KeyPoint(50, 38.2, 1)); keypoints.push_back(cv::KeyPoint(10, 70, 1)); keypoints.push_back(cv::KeyPoint(41.12, 70, 1)); keypoints.push_back(cv::KeyPoint(50, 70, 1)); keypoints.push_back(cv::KeyPoint(100.1, 75.58, 1)); cv::Point2f topleft(10.0,10.0); cv::Point2f bottomright(50.0,70.0); std::vector<cv::KeyPoint> in; std::vector<cv::KeyPoint> out; inout_rect(keypoints, topleft, bottomright, in, out); std::vector<cv::KeyPoint> in_test; std::vector<cv::KeyPoint> out_test; out_test.push_back(cv::KeyPoint(10, 10, 1)); out_test.push_back(cv::KeyPoint(21.5, 10, 1)); out_test.push_back(cv::KeyPoint(50, 10, 1)); out_test.push_back(cv::KeyPoint(10, 29.3, 1)); in_test.push_back(cv::KeyPoint(31.1, 55.7, 1)); out_test.push_back(cv::KeyPoint(50, 38.2, 1)); out_test.push_back(cv::KeyPoint(10, 70, 1)); out_test.push_back(cv::KeyPoint(41.12, 70, 1)); out_test.push_back(cv::KeyPoint(50, 70, 1)); out_test.push_back(cv::KeyPoint(100.1, 75.58, 1)); QCOMPARE(in.size(), in_test.size()); QCOMPARE(out.size(), out_test.size()); }
Room* RoomLoader::LoadRoom( const std::string& aRoomName ) { Tmx::Map map; map.ParseFile(aRoomName); if (map.HasError()) { printf("error code: %d\n", map.GetErrorCode()); printf("error text: %s\n", map.GetErrorText().c_str()); return NULL; } Room* room = new Room(GetLayer(map, "background"), GetLayer(map, "middle"), GetLayer(map, "foreground")); std::vector<Entity*> entities = GetEntities(map, "entities"); float2 topleft(0,0); float2 bottomright((map.GetWidth()) * map.GetTileWidth(), (map.GetHeight()) * map.GetTileHeight()); std::vector<std::pair<float2, float2>> rects = GetCameraRects(map, "camera"); room->setCameraRect(topleft, bottomright); room->setCamera(new Camera(rects)); for (unsigned int i = 0; i < entities.size(); i++) { room->addEntity(entities[i]); } return room; }
bool GenericObjectDetector::ShiftWindow(const Point& seedPt, Size winSz, Point& newPt) { // define window Point topleft(seedPt.x-winSz.width/2, seedPt.y-winSz.height/2); topleft.x = MAX(0, topleft.x); topleft.y = MAX(0, topleft.y); Point bottomright(seedPt.x+winSz.width/2, seedPt.y+winSz.height/2); bottomright.x = MIN(bottomright.x, imgSize.width-1); bottomright.y = MIN(bottomright.y, imgSize.height-1); Rect win(topleft, bottomright); // start iteration for(int i=0; i<shiftCrit.maxCount; i++) { // compute edge orientation difference sum double sumgx = integralGx.at<double>(win.br().y, win.br().x); sumgx += integralGx.at<double>(win.tl().y, win.tl().x); sumgx -= integralGx.at<double>(win.tl().y, win.br().x); sumgx -= integralGx.at<double>(win.br().y, win.tl().x); double sumgy = integralGy.at<double>(win.br().y, win.br().x); sumgy += integralGy.at<double>(win.tl().y, win.tl().x); sumgy -= integralGy.at<double>(win.tl().y, win.br().x); sumgy -= integralGy.at<double>(win.br().y, win.tl().x); } return true; }
RectangleD MenuBar::getLabelFrame(const RectD&bounds) const { RectangleD frame = getFrame(); Vector2d topleft(bounds.left*frame.width, bounds.top*frame.height); Vector2d bottomright(bounds.right*frame.width, bounds.bottom*frame.height); return RectangleD(frame.x+topleft.x, frame.y+topleft.y, bottomright.x-topleft.x, bottomright.y-topleft.y); }
QStringList ImageInstance::getAnnotations() { QString topleft("Im: %1 Se: %3\n%4%5Scalor: 100mm"); QString topright("%1\n%2 %3/%4\n%5"); QString bottomleft("%1\n%2"); QString bottomright("%1 mAs %2 kV\n%3\n%4"); topleft = topleft.arg(instanceNumber, seriesNumber, studyDes.isEmpty()?studyDes:QString("\n").prepend(studyDes), seriesDes.isEmpty()?seriesDes:QString("\n").prepend(seriesDes)); topright = topright.arg(patientName, patientID, patientSex, patientAge, patientBirth.toString("yyyy/M/d")); bottomleft = bottomleft.arg(procId.isEmpty()?bodyPart:procId, manufacturer); bottomright = bottomright.arg(QString::number(mAs), QString::number(kvp), acquisitionTime.toString("yyyy/M/d hh:mm:ss"), institution); return QStringList() << topleft << topright << bottomleft << bottomright; }
void KoUniColorChooser::updateSelectorsB() { //kDebug(30004)() <<"B selected"; quint8 data[4]; data[2] = 0; data[1] = 255; data[0] = m_BIn->value(); data[3] = 255; KoColor topleft(data, rgbColorSpace()); data[2] = 255; data[1] = 255; KoColor topright(data, rgbColorSpace()); data[2] = 0; data[1] = 0; KoColor bottomleft(data, rgbColorSpace()); data[2] = 255; data[1] = 0; KoColor bottomright(data, rgbColorSpace()); m_xycolorselector->setColors(topleft,topright,bottomleft,bottomright); data[2] = m_RIn->value(); data[1] = m_GIn->value(); data[0] = 0; KoColor mincolor(data, rgbColorSpace()); data[0] = 255; KoColor maxcolor(data, rgbColorSpace()); m_colorSlider->setColors(mincolor, maxcolor); m_xycolorselector->blockSignals(true); m_colorSlider->blockSignals(true); m_xycolorselector->setValues(m_RIn->value(), m_GIn->value()); m_colorSlider->setValue(m_BIn->value()); m_xycolorselector->blockSignals(false); m_colorSlider->blockSignals(false); }
void CGetBlackOutDlg::OnMouseDown( UINT nflags, CPoint point) { if (mWon) return; int x,y,cx,cy,i,piece; x=y=cx=cy=piece=0; for(i = 0 ; i < mBoard.numpieces(); i++) { x = mBoard.pborder() + (mBoard.piece(i)->xpos() * (mBoard.pper() + mBoard.pborder())); y = mBoard.pborder() + (mBoard.piece(i)->ypos() * (mBoard.pper() + mBoard.pborder())); cx = (mBoard.piece(i)->width() * mBoard.pper()); if (mBoard.piece(i)->width() == 2) cx += mBoard.pborder(); cy = (mBoard.piece(i)->height() * mBoard.pper()); if (mBoard.piece(i)->height() == 2) cy += mBoard.pborder(); CRect piecerect(x,y,x+cx,y+cy); if (piecerect.PtInRect(point)) { piece=i; i=mBoard.numpieces(); mMoving = TRUE; mMouseStartPoint = point; mPieceMoving = piece; break; } } int moves = 0; if (mMoving) { int x,y,sx,sy,sx2,sy2; x=y=sx=sy=sx2=sy2=0; x = -mBoard.pper(); y = 0; if (mBoard.canmove(mPieceMoving,x,y)) { moves++; sx=x;sy=y; } x = mBoard.pper(); y = 0; if (mBoard.canmove(mPieceMoving,x,y)) { moves++; if (moves < 2) { sx=x;sy=y; } else { sx2=x;sy2=y; } } x = 0; y = mBoard.pper(); if (mBoard.canmove(mPieceMoving,x,y)) { moves++; if (moves < 2) { sx=x;sy=y; } else { sx2=x;sy2=y; } } x = 0; y = -mBoard.pper(); if (mBoard.canmove(mPieceMoving,x,y)) { moves++; if (moves < 2) { sx=x;sy=y; } else { sx2=x;sy2=y; } } if (moves == 1) { CPoint delta(point); delta += CPoint(sx,sy); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if (moves == 2) { CRect piecerect(mBoard.piece(mPieceMoving)->mPieceRect); int deltax, deltay;deltax=deltay=0; if (abs(sx) == mBoard.pper() && abs(sx2) == mBoard.pper()) { CRect lhalf(piecerect); CRect rhalf(piecerect); lhalf.BottomRight().x -= lhalf.Width() / 2; rhalf.TopLeft().x = lhalf.BottomRight().x; if (lhalf.PtInRect(point)) { deltax = sx2; } else { deltax = sx; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if (abs(sy) == mBoard.pper() && abs(sy2) == mBoard.pper()) { CRect thalf(piecerect); CRect bhalf(piecerect); thalf.BottomRight().y -= thalf.Height() / 2; bhalf.TopLeft().y = thalf.BottomRight().y; if (thalf.PtInRect(point)) { deltay = sy; } else { deltay = sy2; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == mBoard.pper() && sy2 == mBoard.pper() || sx2 == mBoard.pper() && sy == mBoard.pper() ) { if (distance(topright(piecerect),point) < distance(point, bottomleft(piecerect))) { deltay = sy2; } else { deltax = sx; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == -mBoard.pper() && sy2 == mBoard.pper() || sx2 == -mBoard.pper() && sy == mBoard.pper() ) { if (distance(topleft(piecerect),point) < distance(point, bottomright(piecerect))) { deltay = sy2; } else { deltax = sx; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == mBoard.pper() && sy2 == -mBoard.pper() || sx2 == mBoard.pper() && sy == -mBoard.pper() ) { if (distance(topleft(piecerect),point) < distance(point, bottomright(piecerect))) { deltax = sx; } else { deltay = sy2; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == -mBoard.pper() && sy2 == -mBoard.pper() || sx2 == -mBoard.pper() && sy == -mBoard.pper() ) { if (distance(topright(piecerect),point) < distance(point, bottomleft(piecerect))) { deltax = sx; } else { deltay = sy2; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } } } }
void openTableImageGroup::draw() { float current_rotation = m_rotation - 45.0; float rotation_inc = 90.0 / m_images.size(); ofPath path; ofPoint axis( 0, 0, 1.0); for ( int i = 0; i < m_images.size(); i++ ) { if ( m_images[ i ].isLoaded() ) { ofPushMatrix(); ofPoint dim(m_images[ i ].m_image->getWidth(),m_images[ i ].m_image->getHeight()); float scale = MIN(160./dim.x, 120./dim.y); dim *= scale; ofTranslate( m_position ); ofRotate( current_rotation ); m_images[ i ].m_image->draw( 0, 0, dim.x, dim.y ); ofPopMatrix(); // // update outline path // dim /= 2.; ofPoint topleft( -dim.x, -dim.y ); ofPoint topright( dim.x, -dim.y ); ofPoint bottomright( dim.x, dim.y ); ofPoint bottomleft( -dim.x, dim.y ); topleft.rotate(current_rotation, axis); topleft += m_position; topright.rotate(current_rotation, axis); topright += m_position; bottomright.rotate(current_rotation, axis); bottomright += m_position; bottomleft.rotate(current_rotation, axis); bottomleft += m_position; path.newSubPath(); path.moveTo( topleft ); path.lineTo( topright ); path.lineTo( bottomright ); path.lineTo( bottomleft ); path.close(); // // // current_rotation += rotation_inc; } } if ( m_annotation.length() > 0 ) { ofApp* app = ( ofApp* ) ofGetAppPtr(); //ofRectangle bounds = app->m_default_font.getStringBoundingBox(m_annotation, 0, 0, 24.); ofRectangle bounds = app->m_default_font.getBBox(m_annotation, 24., 0, 0); ofPoint dim( bounds.width, bounds.height ); ofPushStyle(); ofPushMatrix(); ofTranslate( m_position ); ofRotate( m_rotation ); ofTranslate( -( dim.x/2. ), 120.0 ); ofSetColor(255, 255, 255, 127); ofRect( -8, -( dim.y / 2 + 16 ), dim.x + 16, dim.y + 16 ); ofSetColor(ofColor::black); //app->m_default_font.drawString(m_annotation, 0, 0, 24.); app->m_default_font.draw(m_annotation, 24., 0, 0); ofPopMatrix(); ofPopStyle(); // // add to outline // ofPoint position = m_position; dim.x += 16; dim.y += 16; dim /= 2.; ofPoint topleft( -dim.x, -dim.y + 112. ); ofPoint topright( dim.x, -dim.y + 112. ); ofPoint bottomright( dim.x, dim.y + 112. ); ofPoint bottomleft( -dim.x, dim.y + 112. ); topleft.rotate(m_rotation, axis); topleft += position; topright.rotate(m_rotation, axis); topright += position; bottomright.rotate(m_rotation, axis); bottomright += position; bottomleft.rotate(m_rotation, axis); bottomleft += position; path.newSubPath(); path.moveTo( topleft ); path.lineTo( topright ); path.lineTo( bottomright ); path.lineTo( bottomleft ); path.close(); } // // convert path to polyline for hit test // m_hit_lock.lock(); m_outline = path.getOutline(); m_hit_lock.unlock(); /* ofPushStyle(); path.setStrokeWidth( 1 ); path.setStrokeColor( ofColor::red ); path.setFillColor( ofColor( 255, 0, 0, 128 ) ); path.draw(); ofSetColor( ofColor::green ); ofNoFill(); for ( auto& poly : m_outline ) { poly.draw(); } ofPopStyle(); */ }
void CPredView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default /*HCURSOR hCursor=AfxGetApp()->LoadCursorA(IDC_DESCEND); if(hCursor==NULL) TRACE("Invaidate cursor\n"); SetCursor(hCursor);*/ TRACE("%d\n",nFlags); CClientDC dc(this); OnPrepareDC(&dc); POINT m_point; CFCCDoc* pDoc=(CFCCDoc*)GetDocument(); m_point.x=point.x; m_point.y=point.y; dc.DPtoLP(&m_point); CRgn rgn; int i,j; int selCol=-1; int selRow=-1; for(i=0;i<nCol;i++) { bool bHitCaption=false; if(wnd_navi.nCurPage<wnd_navi.nTotalPage || (wnd_navi.nCurPage-1)*nCol+i+1 <= (pDoc->list_CompoundTest.GetCount()-1)/nItemPage+1) { CPoint topleft(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),30); CPoint bottomright(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { pDoc->MergeSort(SORT_BY_ID,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+10,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+10,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { pDoc->MergeSort(SORT_BY_NAME,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+20,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+widthClassName+widthYhat+30,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { pDoc->MergeSort(SORT_BY_VALUE,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); } if(bHitCaption) { TRACE("LButton down caption\n"); Invalidate(); UpdateWindow(); SortAscend=1-SortAscend; if(SortAscend) ::SetCursor(cursorAscend); else ::SetCursor(cursorDescend); bOldMouseInCaption=true; } for(j=0;j<nItemPage;j++) { rgn.CreateRectRgn(50+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),50+20*j, 20+(i+1)*(80+widthCompoundName+widthYhat+widthClassName+widthID),50+20*(j+1)); if(rgn.PtInRegion(m_point)) { selCol=i; selRow=j; } rgn.DeleteObject(); } } if(selCol>=0 && selRow>=0) { dlg.nIndex=(wnd_navi.nCurPage-1)*(nCol*nItemPage)+selCol*nItemPage+selRow+1; if(nFlags&MK_CONTROL) SendMessage(WM_FINDCOMPOUND,GOTOLINE,2); else SendMessage(WM_FINDCOMPOUND,GOTOLINE,1); } else { if(nFlags!=MK_CONTROL) { POSITION pos; pos=pDoc->list_CompoundTest.GetHeadPosition(); while(pos) { pCompound=(CCompound*)pDoc->list_CompoundTest.GetNext(pos); ((CCompound*)pCompound)->bSelect=false; } } Invalidate(0); } CScrollView::OnLButtonDown(nFlags, point); }
void CPredView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CScrollView::OnMouseMove(nFlags, point); int i; CClientDC dc(this); OnPrepareDC(&dc); POINT m_point; CFCCDoc* pDoc=(CFCCDoc*)GetDocument(); m_point.x=point.x; m_point.y=point.y; dc.DPtoLP(&m_point); CRgn rgn; bHitCaption=false; for(i=0;i<nCol;i++) { if(wnd_navi.nCurPage<wnd_navi.nTotalPage || (wnd_navi.nCurPage-1)*nCol+i+1 <= (pDoc->list_CompoundTest.GetCount()-1)/nItemPage+1) { CPoint topleft(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),30); CPoint bottomright(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { //pDoc->MergeSort(SORT_BY_ID,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+10,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+10,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { //pDoc->MergeSort(SORT_BY_NAME,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+20,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+widthClassName+widthYhat+30,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { //pDoc->MergeSort(SORT_BY_VALUE,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); } } if(bHitCaption) { if(bOldMouseInCaption==false && pDoc->list_CompoundTest.GetCount()>0) { if(SortAscend) ::SetCursor(cursorAscend); else ::SetCursor(cursorDescend); bOldMouseInCaption=true; //TRACE("hit caption change cursor\n"); } } else { //if(bOldMouseInCaption==true) { ::SetCursor(::LoadCursor(NULL,IDC_ARROW)); bOldMouseInCaption=false; //TRACE("not hit caption change cursor\n"); } } // TODO: Add your message handler code here }