StelProjector.cpp   StelProjector.cpp 
skipping to change at line 47 skipping to change at line 47
{ {
if (s=="disk") if (s=="disk")
return MaskDisk; return MaskDisk;
return MaskNone; return MaskNone;
} }
void StelProjector::init(const StelProjectorParams& params) void StelProjector::init(const StelProjectorParams& params)
{ {
maskType = (StelProjectorMaskType)params.maskType; maskType = (StelProjectorMaskType)params.maskType;
zNear = params.zNear; zNear = params.zNear;
oneOverZNearMinusZFar = 1./(zNear-params.zFar); oneOverZNearMinusZFar = 1.f/(zNear-params.zFar);
viewportXywh = params.viewportXywh; viewportXywh = params.viewportXywh;
viewportCenter = params.viewportCenter; viewportCenter = params.viewportCenter;
gravityLabels = params.gravityLabels; gravityLabels = params.gravityLabels;
flipHorz = params.flipHorz ? -1. : 1.; flipHorz = params.flipHorz ? -1.f : 1.f;
flipVert = params.flipVert ? -1. : 1.; flipVert = params.flipVert ? -1.f : 1.f;
viewportFovDiameter = params.viewportFovDiameter; viewportFovDiameter = params.viewportFovDiameter;
pixelPerRad = 0.5 * viewportFovDiameter / fovToViewScalingFactor(par pixelPerRad = 0.5f * viewportFovDiameter / fovToViewScalingFactor(pa
ams.fov*(M_PI/360.0)); rams.fov*(M_PI/360.f));
//Q_ASSERT(params.fov<=getMaxFov()); computeBoundingCap();
} }
QString StelProjector::getHtmlSummary() const QString StelProjector::getHtmlSummary() const
{ {
return QString("<h3>%1</h3><p>%2</p><b>%3</b>%4").arg(getNameI18()). arg(getDescriptionI18()).arg(q_("Maximum FOV: ")).arg(getMaxFov())+QChar(0x 00B0); return QString("<h3>%1</h3><p>%2</p><b>%3</b>%4").arg(getNameI18()). arg(getDescriptionI18()).arg(q_("Maximum FOV: ")).arg(getMaxFov())+QChar(0x 00B0);
} }
/************************************************************************* /*************************************************************************
Return a convex polygon on the sphere which includes the viewport in the Return a convex polygon on the sphere which includes the viewport in the
current frame current frame
*************************************************************************/ *************************************************************************/
SphericalRegionP StelProjector::getViewportConvexPolygon(double marginX, do uble marginY) const SphericalRegionP StelProjector::getViewportConvexPolygon(float marginX, flo at marginY) const
{ {
Vec3d e0, e1, e2, e3; Vec3d e0, e1, e2, e3;
const Vec4i& vp = viewportXywh; const Vec4i& vp = viewportXywh;
bool ok = unProject(vp[0]-marginX,vp[1]-marginY,e0); bool ok = unProject(vp[0]-marginX,vp[1]-marginY,e0);
ok &= unProject(vp[0]+vp[2]+marginX,vp[1]-marginY,e1); ok &= unProject(vp[0]+vp[2]+marginX,vp[1]-marginY,e1);
ok &= unProject(vp[0]+vp[2]+marginX,vp[1]+vp[3]+marginY,e2); ok &= unProject(vp[0]+vp[2]+marginX,vp[1]+vp[3]+marginY,e2);
ok &= unProject(vp[0]-marginX,vp[1]+vp[3]+marginY,e3); ok &= unProject(vp[0]-marginX,vp[1]+vp[3]+marginY,e3);
if (!ok) if (!ok)
{ {
// Special case for handling degenerated cases, use full sky . // Special case for handling degenerated cases, use full sky .
skipping to change at line 106 skipping to change at line 106
{ {
SphericalConvexPolygon* res = new SphericalConvexPolygon(e0, e1, e2, e3); SphericalConvexPolygon* res = new SphericalConvexPolygon(e0, e1, e2, e3);
if (res->checkValid()) if (res->checkValid())
{ {
return SphericalRegionP(res); return SphericalRegionP(res);
} }
qDebug() << "!valid"; qDebug() << "!valid";
delete res; delete res;
} }
//return SphericalRegionP((SphericalRegion*)(new AllSkySphericalRegi on())); //return SphericalRegionP((SphericalRegion*)(new AllSkySphericalRegi on()));
const SphericalCap& hp = getBoundingSphericalCap(); const SphericalCap& hp = getBoundingCap();
return SphericalRegionP(new SphericalCap(hp)); return SphericalRegionP(new SphericalCap(hp));
} }
// Return a Halfspace containing the whole viewport void StelProjector::computeBoundingCap()
SphericalCap StelProjector::getBoundingSphericalCap() const
{ {
SphericalCap result; bool ok = unProject(viewportXywh[0]+0.5f*viewportXywh[2], viewportXy
wh[1]+0.5f*viewportXywh[3], boundingCap.n);
bool ok = unProject(viewportXywh[0]+0.5*viewportXywh[2], viewportXyw
h[1]+0.5*viewportXywh[3], result.n);
Q_ASSERT(ok); // The central point should be at a valid position b y definition Q_ASSERT(ok); // The central point should be at a valid position b y definition
Q_ASSERT(fabs(result.n.lengthSquared()-1.)<0.000001); const bool needNormalization = fabs(boundingCap.n.lengthSquared()-1. )>0.00000001;
// Now need to determine the aperture // Now need to determine the aperture
Vec3d e0,e1,e2,e3,e4,e5; Vec3d e0,e1,e2,e3,e4,e5;
const Vec4i& vp = viewportXywh; const Vec4i& vp = viewportXywh;
ok &= unProject(vp[0],vp[1],e0); ok &= unProject(vp[0],vp[1],e0);
ok &= unProject(vp[0]+vp[2],vp[1],e1); ok &= unProject(vp[0]+vp[2],vp[1],e1);
ok &= unProject(vp[0]+vp[2],vp[1]+vp[3],e2); ok &= unProject(vp[0]+vp[2],vp[1]+vp[3],e2);
ok &= unProject(vp[0],vp[1]+vp[3],e3); ok &= unProject(vp[0],vp[1]+vp[3],e3);
ok &= unProject(vp[0],vp[1]+vp[3]/2,e4); ok &= unProject(vp[0],vp[1]+vp[3]/2,e4);
ok &= unProject(vp[0]+vp[2],vp[1]+vp[3]/2,e5); ok &= unProject(vp[0]+vp[2],vp[1]+vp[3]/2,e5);
if (!ok) if (!ok)
{ {
// Some points were in invalid positions, use full sky. // Some points were in invalid positions, use full sky.
result.d = -1.; boundingCap.d = -1.;
return result; boundingCap.n.set(1,0,0);
return;
}
if (needNormalization)
{
boundingCap.n.normalize();
e0.normalize();
e1.normalize();
e2.normalize();
e3.normalize();
e4.normalize();
e5.normalize();
} }
result.d = result.n*e0; boundingCap.d = boundingCap.n*e0;
double h = result.n*e1; double h = boundingCap.n*e1;
if (result.d > h) if (boundingCap.d > h)
result.d=h; boundingCap.d=h;
h = result.n*e2; h = boundingCap.n*e2;
if (result.d > h) if (boundingCap.d > h)
result.d=h; boundingCap.d=h;
h = result.n*e3; h = boundingCap.n*e3;
if (result.d > h) if (boundingCap.d > h)
result.d=h; boundingCap.d=h;
h = result.n*e4; h = boundingCap.n*e4;
if (result.d > h) if (boundingCap.d > h)
result.d=h; boundingCap.d=h;
h = result.n*e5; h = boundingCap.n*e5;
if (result.d > h) if (boundingCap.d > h)
result.d=h; boundingCap.d=h;
return result;
} }
/************************************************************************* /*************************************************************************
Project the vector v from the viewport frame into the current frame Project the vector v from the viewport frame into the current frame
*************************************************************************/ *************************************************************************/
bool StelProjector::unProject(double x, double y, Vec3d &v) const bool StelProjector::unProject(double x, double y, Vec3d &v) const
{ {
v[0] = flipHorz * (x - viewportCenter[0]) / pixelPerRad; v[0] = flipHorz * (x - viewportCenter[0]) / pixelPerRad;
v[1] = flipVert * (y - viewportCenter[1]) / pixelPerRad; v[1] = flipVert * (y - viewportCenter[1]) / pixelPerRad;
v[2] = 0; v[2] = 0;
 End of changes. 10 change blocks. 
34 lines changed or deleted 41 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/