void kb_scan(void) { static int d[4][4]={{13,9,5,1},{14,10,6,2},{15,11,7,3},{16,12,8,4}}; static int scan[4]={0x7f,0xbf,0xdf,0xef}; static int hmk[4]={240,240,240,240}; static int lmk[4]={1,2,4,8}; static int i=0,j=0,c=0,test=1,s=0; for(j=0;j<4;j++) { set(200,255,0,240); fpt(0,hmk[j],0,scan[j]); for(i=0;i<4;i++) { set(200,255,0,240); fgt(100,lmk[i],i,&test); if(test==0) { c=0; while(c==0) { set(200,255,0,240); fgt(100,lmk[i],i,&test); if(test>0) { s=d[j][i]; printf("j=%d,i=%d\n",j,i ); printf("%d\n",s); c=1; } } } } } }
void SkyLine::draw(StelCore *core) const { if (!fader.getInterstate()) return; StelProjectorP prj = core->getProjection(frameType, frameType!=StelCore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff); // Get the bounding halfspace const SphericalCap& viewPortSphericalCap = prj->getBoundingCap(); // Initialize a painter and set openGL state StelPainter sPainter(prj); sPainter.setColor(color[0], color[1], color[2], fader.getInterstate()); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode Vec4f textColor(color[0], color[1], color[2], 0); textColor[3]=fader.getInterstate(); ViewportEdgeIntersectCallbackData userData(&sPainter); sPainter.setFont(font); userData.textColor = textColor; userData.text = label; ///////////////////////////////////////////////// // Draw the line SphericalCap meridianSphericalCap(Vec3d(0,0,1), 0); Vec3d fpt(1,0,0); if (line_type==MERIDIAN) { meridianSphericalCap.n.set(0,1,0); } Vec3d p1, p2; if (!SphericalCap::intersectionPoints(viewPortSphericalCap, meridianSphericalCap, p1, p2)) { if ((viewPortSphericalCap.d<meridianSphericalCap.d && viewPortSphericalCap.contains(meridianSphericalCap.n)) || (viewPortSphericalCap.d<-meridianSphericalCap.d && viewPortSphericalCap.contains(-meridianSphericalCap.n))) { // The meridian is fully included in the viewport, draw it in 3 sub-arcs to avoid length > 180. const Mat4d& rotLon120 = Mat4d::rotation(meridianSphericalCap.n, 120.*M_PI/180.); Vec3d rotFpt=fpt; rotFpt.transfo4d(rotLon120); Vec3d rotFpt2=rotFpt; rotFpt2.transfo4d(rotLon120); sPainter.drawGreatCircleArc(fpt, rotFpt, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt, rotFpt2, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt2, fpt, NULL, viewportEdgeIntersectCallback, &userData); return; } else return; } Vec3d middlePoint = p1+p2; middlePoint.normalize(); if (!viewPortSphericalCap.contains(middlePoint)) middlePoint*=-1.; // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); // // Johannes: use a big radius as a dirty workaround for the bug that the // // ecliptic line is not drawn around the observer, but around the sun: // const Vec3d vv(1000000,0,0); }
void SkyLine::draw(StelCore *core) const { if (!fader.getInterstate()) return; StelProjectorP prj = core->getProjection(frameType, frameType!=StelCore::FrameAltAz ? StelCore::RefractionAuto : StelCore::RefractionOff); // Get the bounding halfspace const SphericalCap& viewPortSphericalCap = prj->getBoundingCap(); // Initialize a painter and set openGL state StelPainter sPainter(prj); sPainter.setColor(color[0], color[1], color[2], fader.getInterstate()); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glEnable(GL_LINE_SMOOTH); #endif Vec4f textColor(color[0], color[1], color[2], 0); textColor[3]=fader.getInterstate(); ViewportEdgeIntersectCallbackData userData(&sPainter); sPainter.setFont(font); userData.textColor = textColor; userData.text = label; ///////////////////////////////////////////////// // Draw the line // Precession circles are Small Circles, all others are Great Circles. if (line_type==PRECESSIONCIRCLE_N || line_type==PRECESSIONCIRCLE_S) { const double lat=(line_type==PRECESSIONCIRCLE_S ? -1.0 : 1.0) * (M_PI/2.0-getPrecessionAngleVondrakCurrentEpsilonA()); SphericalCap declinationCap(Vec3d(0,0,1), std::sin(lat)); const Vec3d rotCenter(0,0,declinationCap.d); Vec3d p1, p2; if (!SphericalCap::intersectionPoints(viewPortSphericalCap, declinationCap, p1, p2)) { if ((viewPortSphericalCap.d<declinationCap.d && viewPortSphericalCap.contains(declinationCap.n)) || (viewPortSphericalCap.d<-declinationCap.d && viewPortSphericalCap.contains(-declinationCap.n))) { // The line is fully included in the viewport, draw it in 3 sub-arcs to avoid length > 180. Vec3d pt1; Vec3d pt2; Vec3d pt3; const double lon1=0.0; const double lon2=120.0*M_PI/180.0; const double lon3=240.0*M_PI/180.0; StelUtils::spheToRect(lon1, lat, pt1); pt1.normalize(); StelUtils::spheToRect(lon2, lat, pt2); pt2.normalize(); StelUtils::spheToRect(lon3, lat, pt3); pt3.normalize(); sPainter.drawSmallCircleArc(pt1, pt2, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(pt2, pt3, rotCenter, viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(pt3, pt1, rotCenter, viewportEdgeIntersectCallback, &userData); #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); return; } else { #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); return; } } // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg Vec3d middlePoint = p1-rotCenter+p2-rotCenter; middlePoint.normalize(); middlePoint*=(p1-rotCenter).length(); middlePoint+=rotCenter; if (!viewPortSphericalCap.contains(middlePoint)) { middlePoint-=rotCenter; middlePoint*=-1.; middlePoint+=rotCenter; } sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter,viewportEdgeIntersectCallback, &userData); sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, viewportEdgeIntersectCallback, &userData); // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); return; } // All the other "lines" are Great Circles SphericalCap meridianSphericalCap(Vec3d(0,0,1), 0); Vec3d fpt(1,0,0); if ((line_type==MERIDIAN) || (line_type==COLURE_1)) { meridianSphericalCap.n.set(0,1,0); } if ((line_type==PRIME_VERTICAL) || (line_type==COLURE_2)) { meridianSphericalCap.n.set(1,0,0); fpt.set(0,0,1); } if (line_type==LONGITUDE) { Vec3d coord; double lambda, beta; StelUtils::rectToSphe(&lambda, &beta, core->getCurrentPlanet()->getHeliocentricEclipticPos()); StelUtils::spheToRect(lambda + M_PI/2., 0., coord); meridianSphericalCap.n.set(coord[0],coord[1],coord[2]); fpt.set(0,0,1); } Vec3d p1, p2; if (!SphericalCap::intersectionPoints(viewPortSphericalCap, meridianSphericalCap, p1, p2)) { if ((viewPortSphericalCap.d<meridianSphericalCap.d && viewPortSphericalCap.contains(meridianSphericalCap.n)) || (viewPortSphericalCap.d<-meridianSphericalCap.d && viewPortSphericalCap.contains(-meridianSphericalCap.n))) { // The meridian is fully included in the viewport, draw it in 3 sub-arcs to avoid length > 180. const Mat4d& rotLon120 = Mat4d::rotation(meridianSphericalCap.n, 120.*M_PI/180.); Vec3d rotFpt=fpt; rotFpt.transfo4d(rotLon120); Vec3d rotFpt2=rotFpt; rotFpt2.transfo4d(rotLon120); sPainter.drawGreatCircleArc(fpt, rotFpt, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt, rotFpt2, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(rotFpt2, fpt, NULL, viewportEdgeIntersectCallback, &userData); return; } else return; } Vec3d middlePoint = p1+p2; middlePoint.normalize(); if (!viewPortSphericalCap.contains(middlePoint)) middlePoint*=-1.; // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg sPainter.drawGreatCircleArc(p1, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); sPainter.drawGreatCircleArc(p2, middlePoint, NULL, viewportEdgeIntersectCallback, &userData); // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH #ifdef GL_LINE_SMOOTH if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL) glDisable(GL_LINE_SMOOTH); #endif glDisable(GL_BLEND); // // Johannes: use a big radius as a dirty workaround for the bug that the // // ecliptic line is not drawn around the observer, but around the sun: // const Vec3d vv(1000000,0,0); }