TrailGroup.cpp   TrailGroup.cpp 
skipping to change at line 21 skipping to change at line 21
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "TrailGroup.hpp" #include "TrailGroup.hpp"
#include "StelNavigator.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include <QtOpenGL> #include <QtOpenGL>
TrailGroup::TrailGroup(float te) : timeExtent(te), opacity(1.f) TrailGroup::TrailGroup(float te) : timeExtent(te), opacity(1.f)
{ {
j2000ToTrailNative=Mat4d::identity(); j2000ToTrailNative=Mat4d::identity();
j2000ToTrailNativeInverted=Mat4d::identity(); j2000ToTrailNativeInverted=Mat4d::identity();
} }
static QVector<Vec3d> vertexArray; static QVector<Vec3d> vertexArray;
static QVector<Vec4f> colorArray; static QVector<Vec4f> colorArray;
void TrailGroup::draw(StelCore* core, StelPainter* sPainter) void TrailGroup::draw(StelCore* core, StelPainter* sPainter)
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float currentTime = core->getNavigator()->getJDay(); float currentTime = core->getJDay();
sPainter->setProjector(core->getProjection(core->getNavigator()->get StelProjector::ModelViewTranformP transfo = core->getJ2000ModelViewT
J2000ModelViewMat()*j2000ToTrailNativeInverted)); ransform();
transfo->combine(j2000ToTrailNativeInverted);
sPainter->setProjector(core->getProjection(transfo));
foreach (const Trail& trail, allTrails) foreach (const Trail& trail, allTrails)
{ {
Planet* hpl = dynamic_cast<Planet*>(trail.stelObject.data()) ; Planet* hpl = dynamic_cast<Planet*>(trail.stelObject.data()) ;
if (hpl!=NULL) if (hpl!=NULL)
{ {
// Avoid drawing the trails if the object is the hom e planet // Avoid drawing the trails if the object is the hom e planet
QString homePlanetName = hpl==NULL ? "" : hpl->getEn glishName(); QString homePlanetName = hpl==NULL ? "" : hpl->getEn glishName();
if (homePlanetName==StelApp::getInstance().getCore() ->getNavigator()->getCurrentLocation().planetName) if (homePlanetName==StelApp::getInstance().getCore() ->getCurrentLocation().planetName)
continue; continue;
} }
const QList<Vec3d>& posHistory = trail.posHistory; const QList<Vec3d>& posHistory = trail.posHistory;
vertexArray.resize(posHistory.size()); vertexArray.resize(posHistory.size());
colorArray.resize(posHistory.size()); colorArray.resize(posHistory.size());
for (int i=0;i<posHistory.size();++i) for (int i=0;i<posHistory.size();++i)
{ {
float colorRatio = 1.f-(currentTime-times.at(i))/tim eExtent; float colorRatio = 1.f-(currentTime-times.at(i))/tim eExtent;
colorArray[i].set(trail.color[0], trail.color[1], tr ail.color[2], colorRatio*opacity); colorArray[i].set(trail.color[0], trail.color[1], tr ail.color[2], colorRatio*opacity);
vertexArray[i]=posHistory.at(i); vertexArray[i]=posHistory.at(i);
skipping to change at line 72 skipping to change at line 74
sPainter->setColorPointer(4, GL_FLOAT, colorArray.constData( )); sPainter->setColorPointer(4, GL_FLOAT, colorArray.constData( ));
sPainter->enableClientStates(true, false, true); sPainter->enableClientStates(true, false, true);
sPainter->drawFromArray(StelPainter::LineStrip, vertexArray. size(), 0, true); sPainter->drawFromArray(StelPainter::LineStrip, vertexArray. size(), 0, true);
sPainter->enableClientStates(false); sPainter->enableClientStates(false);
} }
} }
// Add 1 point to all the curves at current time and suppress too old point s // Add 1 point to all the curves at current time and suppress too old point s
void TrailGroup::update() void TrailGroup::update()
{ {
StelNavigator* nav = StelApp::getInstance().getCore()->getNavigator( times.append(StelApp::getInstance().getCore()->getJDay());
);
times.append(nav->getJDay());
for (QList<Trail>::Iterator iter=allTrails.begin();iter!=allTrails.e nd();++iter) for (QList<Trail>::Iterator iter=allTrails.begin();iter!=allTrails.e nd();++iter)
{ {
iter->posHistory.append(j2000ToTrailNative*iter->stelObject- >getJ2000EquatorialPos(nav)); iter->posHistory.append(j2000ToTrailNative*iter->stelObject- >getJ2000EquatorialPos(StelApp::getInstance().getCore()));
} }
if (nav->getJDay()-times.at(0)>timeExtent) if (StelApp::getInstance().getCore()->getJDay()-times.at(0)>timeExte nt)
{ {
times.pop_front(); times.pop_front();
for (QList<Trail>::Iterator iter=allTrails.begin();iter!=all Trails.end();++iter) for (QList<Trail>::Iterator iter=allTrails.begin();iter!=all Trails.end();++iter)
{ {
iter->posHistory.pop_front(); iter->posHistory.pop_front();
} }
} }
} }
// Set the matrix to use to post process J2000 positions before storing in the trail // Set the matrix to use to post process J2000 positions before storing in the trail
 End of changes. 6 change blocks. 
10 lines changed or deleted 10 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/