void getAngle(cv::Mat R,cv::Mat T,double f,std::vector<cv::Point2f> data,double&_sunAzimuth,double& _sunAltitude,double w,double h) { setWandH(w,h); setFlocallength(f); setRT(R,T); std::vector<XgyLine> lineArray(2); setVecA(lineArray,data); setSunAngleEx(lineArray); _sunAzimuth=sunAzimuth; _sunAltitude=sunAltitude; //printAngle(); }
void CColoredStatic::repaint(CDC &dc) { CFont *font = GetFont(); if(font == NULL) { font = GetParent()->GetFont(); } CFont *oldFont = dc.SelectObject(font); if(m_bkColorSet) { dc.SetBkColor(m_bkColor); } dc.SetTextColor(m_textColor); String text = getWindowText(this); StringArray lineArray(Tokenizer(text, "\n")); const int textAlign = GetStyle() & 0x3; int y = 0; switch(textAlign) { case SS_LEFT: { for(size_t i = 0; i < lineArray.size(); i++) { const String &line = lineArray[i]; const CSize lineSize = getTextExtent(dc, line); dc.TextOut(0,y,line.cstr()); y += lineSize.cy; } } break; case SS_RIGHT: { const CSize winSize = getWindowSize(this); for(size_t i = 0; i < lineArray.size(); i++) { const String &line = lineArray[i]; const CSize lineSize = getTextExtent(dc, line); dc.TextOut(max(0, winSize.cx - lineSize.cx), y, line.cstr()); y += lineSize.cy; } } break; case SS_CENTER: { const CSize winSize = getWindowSize(this); for(size_t i = 0; i < lineArray.size(); i++) { const String &line = lineArray[i]; const CSize lineSize = getTextExtent(dc, line); dc.TextOut(max(0, (winSize.cx - lineSize.cx)/2), y, line.cstr()); y += lineSize.cy; } } break; } dc.SelectObject(oldFont); }
void MHIDLA::DrawPoly(bool isFilled, int nPoints, const int *xArray, const int *yArray) { if (nPoints < 2) return; if (isFilled) { QVector <lineSeg> lineArray(nPoints); int nLines = 0; // Initialise the line segment array. Include all lines // apart from horizontal. Close the polygon by starting // with the last point in the array. int lastX = xArray[nPoints-1]; // Last point int lastY = yArray[nPoints-1]; int yMin = lastY, yMax = lastY; for (int k = 0; k < nPoints; k++) { int thisX = xArray[k]; int thisY = yArray[k]; if (lastY != thisY) { if (lastY > thisY) { lineArray[nLines].yBottom = thisY; lineArray[nLines].yTop = lastY; lineArray[nLines].xBottom = thisX; } else { lineArray[nLines].yBottom = lastY; lineArray[nLines].yTop = thisY; lineArray[nLines].xBottom = lastX; } lineArray[nLines++].slope = (float)(thisX-lastX) / (float)(thisY-lastY); } if (thisY < yMin) yMin = thisY; if (thisY > yMax) yMax = thisY; lastX = thisX; lastY = thisY; } // Find the intersections of each line in the line segment array // with the scan line. Because UK MHEG says that figures should be // convex we only need to consider two intersections. QRgb fillColour = qRgba(m_fillColour.red(), m_fillColour.green(), m_fillColour.blue(), m_fillColour.alpha()); for (int y = yMin; y < yMax; y++) { int crossings = 0, xMin = 0, xMax = 0; for (int l = 0; l < nLines; l++) { if (y >= lineArray[l].yBottom && y < lineArray[l].yTop) { int x = (int)round((float)(y - lineArray[l].yBottom) * lineArray[l].slope) + lineArray[l].xBottom; if (crossings == 0 || x < xMin) xMin = x; if (crossings == 0 || x > xMax) xMax = x; crossings++; } } if (crossings == 2) { for (int x = xMin; x <= xMax; x++) m_image.setPixel(x, y, fillColour); } } // Draw the boundary int lastXpoint = xArray[nPoints-1]; // Last point int lastYpoint = yArray[nPoints-1]; for (int i = 0; i < nPoints; i++) { DrawLine(xArray[i], yArray[i], lastXpoint, lastYpoint); lastXpoint = xArray[i]; lastYpoint = yArray[i]; } } else // PolyLine - draw lines between the points but don't close it. { for (int i = 1; i < nPoints; i++) { DrawLine(xArray[i], yArray[i], xArray[i-1], yArray[i-1]); } } }