StarMgr.cpp   StarMgr.cpp 
skipping to change at line 23 skipping to change at line 23
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include <QTextStream> #include <QCryptographicHash>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QFileInfo>
#include <QRegExp>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QRegExp> #include <QTextStream>
#include <QDebug>
#include <QFileInfo>
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelTexture.hpp" #include "renderer/StelRenderer.hpp"
#include "renderer/StelTextureNew.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelGeodesicGrid.hpp" #include "StelGeodesicGrid.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelPainter.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "ZoneArray.hpp" #include "ZoneArray.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.hpp"
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
using namespace BigStarCatalogExtension; using namespace BigStarCatalogExtension;
skipping to change at line 121 skipping to change at line 121
return component_array.at(index); return component_array.at(index);
} }
void StarMgr::initTriangle(int lev,int index, const Vec3f &c0, const Vec3f &c1, const Vec3f &c2) void StarMgr::initTriangle(int lev,int index, const Vec3f &c0, const Vec3f &c1, const Vec3f &c2)
{ {
ZoneArrayMap::const_iterator it(zoneArrays.find(lev)); ZoneArrayMap::const_iterator it(zoneArrays.find(lev));
if (it!=zoneArrays.constEnd()) if (it!=zoneArrays.constEnd())
it.value()->initTriangle(index,c0,c1,c2); it.value()->initTriangle(index,c0,c1,c2);
} }
StarMgr::StarMgr(void) : hipIndex(new HipIndexStruct[NR_OF_HIP+1]) StarMgr::StarMgr(void)
: hipIndex(new HipIndexStruct[NR_OF_HIP+1])
, texPointer(NULL)
{ {
setObjectName("StarMgr"); setObjectName("StarMgr");
if (hipIndex == 0) if (hipIndex == 0)
{ {
qFatal("ERROR: StarMgr::StarMgr: no memory"); qFatal("ERROR: StarMgr::StarMgr: no memory");
} }
maxGeodesicGridLevel = -1; maxGeodesicGridLevel = -1;
lastMaxSearchLevel = -1; lastMaxSearchLevel = -1;
starFont.setPixelSize(StelApp::getInstance().getSettings()->value("g ui/base_font_size", 13).toInt()); starFont.setPixelSize(StelApp::getInstance().getSettings()->value("g ui/base_font_size", 13).toInt());
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
skipping to change at line 157 skipping to change at line 159
ZoneArrayMap::iterator it(zoneArrays.end()); ZoneArrayMap::iterator it(zoneArrays.end());
while (it!=zoneArrays.begin()) while (it!=zoneArrays.begin())
{ {
--it; --it;
delete it.value(); delete it.value();
it.value() = NULL; it.value() = NULL;
} }
zoneArrays.clear(); zoneArrays.clear();
if (hipIndex) if (hipIndex)
delete[] hipIndex; delete[] hipIndex;
if(NULL != texPointer)
{
delete texPointer;
}
} }
QString StarMgr::getCommonName(int hip) QString StarMgr::getCommonName(int hip)
{ {
QHash<int,QString>::const_iterator it(commonNamesMapI18n.find(hip)); QHash<int,QString>::const_iterator it(commonNamesMapI18n.find(hip));
if (it!=commonNamesMapI18n.end()) if (it!=commonNamesMapI18n.end())
return it.value(); return it.value();
return QString(); return QString();
} }
skipping to change at line 231 skipping to change at line 237
} }
loadData(starSettings); loadData(starSettings);
starFont.setPixelSize(StelApp::getInstance().getSettings()->value("g ui/base_font_size", 13).toInt()); starFont.setPixelSize(StelApp::getInstance().getSettings()->value("g ui/base_font_size", 13).toInt());
setFlagStars(conf->value("astro/flag_stars", true).toBool()); setFlagStars(conf->value("astro/flag_stars", true).toBool());
setFlagLabels(conf->value("astro/flag_star_name",true).toBool()); setFlagLabels(conf->value("astro/flag_star_name",true).toBool());
setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat()); setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat());
objectMgr->registerStelObjectMgr(this); objectMgr->registerStelObjectMgr(this);
texPointer = StelApp::getInstance().getTextureManager().createTextur e("textures/pointeur2.png"); // Load pointer texture
StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLev el)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this); StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLev el)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this);
for (ZoneArrayMap::const_iterator it(zoneArrays.begin()); it!=zoneAr rays.end();it++) for (ZoneArrayMap::const_iterator it(zoneArrays.begin()); it!=zoneAr rays.end();it++)
{ {
it.value()->scaleAxis(); it.value()->scaleAxis();
} }
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(u pdateSkyCulture(const QString&))); connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(u pdateSkyCulture(const QString&)));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&))); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&)));
} }
void StarMgr::drawPointer(StelPainter& sPainter, const StelCore* core) void StarMgr::drawPointer(StelRenderer* renderer, StelProjectorP projector, const StelCore* core)
{ {
const QList<StelObjectP> newSelected = objectMgr->getSelectedObject( "Star"); const QList<StelObjectP> newSelected = objectMgr->getSelectedObject( "Star");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core); Vec3d pos=obj->getJ2000EquatorialPos(core);
Vec3d screenpos; Vec3d win;
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!sPainter.getProjector()->project(pos, screenpos)) if (!projector->project(pos, win))
{
return; return;
}
if(NULL == texPointer)
{
texPointer = renderer->createTexture("textures/point
eur2.png"); // Load pointer texture
}
Vec3f c(obj->getInfoColor()); Vec3f c(obj->getInfoColor());
if (StelApp::getInstance().getVisionModeNight()) if (StelApp::getInstance().getVisionModeNight())
c = StelUtils::getNightColor(c); c = StelUtils::getNightColor(c);
sPainter.setColor(c[0], c[1], c[2]); renderer->setGlobalColor(c[0], c[1], c[2]);
texPointer->bind(); texPointer->bind();
sPainter.enableTexture2d(true); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND); const float angle = StelApp::getInstance().getTotalRunTime()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal * 40.0f;
transparency mode renderer->drawTexturedRect(win[0] - 13.0f, win[1] - 13.0f, 2
sPainter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, 6.0f, 26.0f, angle);
StelApp::getInstance().getTotalRunTime()*40.);
} }
} }
void StarMgr::setStelStyle(const QString& section) void StarMgr::setStelStyle(const QString& section)
{ {
// Load colors from config file // Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
setLabelColor(StelUtils::strToVec3f(conf->value(section+"/star_label _color", defaultColor).toString())); setLabelColor(StelUtils::strToVec3f(conf->value(section+"/star_label _color", defaultColor).toString()));
skipping to change at line 622 skipping to change at line 634
const float mag_min = 0.001f*it.value()->mag_min; const float mag_min = 0.001f*it.value()->mag_min;
float rcmag[2]; float rcmag[2];
if (StelApp::getInstance().getCore()->getSkyDrawer()->comput eRCMag(mag_min,rcmag)==false) if (StelApp::getInstance().getCore()->getSkyDrawer()->comput eRCMag(mag_min,rcmag)==false)
break; break;
rval = it.key(); rval = it.key();
} }
return rval; return rval;
} }
// Draw all the stars // Draw all the stars
void StarMgr::draw(StelCore* core) void StarMgr::draw(StelCore* core, StelRenderer* renderer)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
StelSkyDrawer* skyDrawer = core->getSkyDrawer(); StelSkyDrawer* skyDrawer = core->getSkyDrawer();
// If stars are turned off don't waste time below // If stars are turned off don't waste time below
// projecting all stars just to draw disembodied labels // projecting all stars just to draw disembodied labels
if (!starsFader.getInterstate()) if (!starsFader.getInterstate())
return; return;
int maxSearchLevel = getMaxSearchLevel(); int maxSearchLevel = getMaxSearchLevel();
const GeodesicSearchResult* geodesic_search_result = core->getGeodes icGrid(maxSearchLevel)->search(prj->getViewportConvexPolygon()->getBounding SphericalCaps(),maxSearchLevel); const GeodesicSearchResult* geodesic_search_result = core->getGeodes icGrid(maxSearchLevel)->search(prj->getViewportConvexPolygon()->getBounding SphericalCaps(),maxSearchLevel);
// Set temporary static variable for optimization // Set temporary static variable for optimization
const float names_brightness = labelsFader.getInterstate() * starsFa der.getInterstate(); const float names_brightness = labelsFader.getInterstate() * starsFa der.getInterstate();
// Prepare openGL for drawing many stars // Prepare for drawing many stars
StelPainter sPainter(prj); renderer->setFont(starFont);
sPainter.setFont(starFont); skyDrawer->preDrawPointSource();
skyDrawer->preDrawPointSource(&sPainter);
// draw all the stars of all the selected zones // draw all the stars of all the selected zones
// GZ: This table must be enlarged from 2x256 to many more entries. CORRELATE IN Zonearray.cpp! // GZ: This table must be enlarged from 2x256 to many more entries. CORRELATE IN Zonearray.cpp!
//float rcmag_table[2*256]; //float rcmag_table[2*256];
//float rcmag_table[2*16384]; //float rcmag_table[2*16384];
float rcmag_table[2*4096]; float rcmag_table[2 * RCMAG_TABLE_SIZE];
for (ZoneArrayMap::const_iterator it(zoneArrays.constBegin()); it!=z oneArrays.constEnd();++it) for (ZoneArrayMap::const_iterator it(zoneArrays.constBegin()); it!=z oneArrays.constEnd();++it)
{ {
const float mag_min = 0.001f*it.value()->mag_min; const float mag_min = 0.001f*it.value()->mag_min;
const float k = (0.001f*it.value()->mag_range)/it.value()->m ag_steps; // MagStepIncrement const float k = (0.001f*it.value()->mag_range)/it.value()->m ag_steps; // MagStepIncrement
// GZ: add a huge number of entries to rcMag // GZ: add a huge number of entries to rcMag
//for (int i=it.value()->mag_steps-1;i>=0;--i) //for (int i=it.value()->mag_steps-1;i>=0;--i)
for (int i=4096-1;i>=0;--i) for (int i=RCMAG_TABLE_SIZE-1;i>=0;--i)
{ {
const float mag = mag_min+k*i; const float mag = mag_min+k*i;
if (skyDrawer->computeRCMag(mag,rcmag_table + 2*i)== false) if (skyDrawer->computeRCMag(mag,rcmag_table + 2*i)== false)
{ {
if (i==0) goto exit_loop; if (i==0) goto exit_loop;
} }
if (skyDrawer->getFlagPointStar()) if (skyDrawer->getDrawStarsAsPoints())
{ {
rcmag_table[2*i+1] *= starsFader.getIntersta te(); rcmag_table[2*i+1] *= starsFader.getIntersta te();
} }
else else
{ {
rcmag_table[2*i] *= starsFader.getInterstate (); rcmag_table[2*i] *= starsFader.getInterstate ();
} }
} }
lastMaxSearchLevel = it.key(); lastMaxSearchLevel = it.key();
skipping to change at line 683 skipping to change at line 694
if (labelsFader.getInterstate()>0.f) if (labelsFader.getInterstate()>0.f)
{ {
// Adapt magnitude limit of the stars labels accordi ng to FOV and labelsAmount // Adapt magnitude limit of the stars labels accordi ng to FOV and labelsAmount
float maxMag = (skyDrawer->getLimitMagnitude()-6.5)* 0.7+(labelsAmount*1.2f)-2.f; float maxMag = (skyDrawer->getLimitMagnitude()-6.5)* 0.7+(labelsAmount*1.2f)-2.f;
int x = (int)((maxMag-mag_min)/k); int x = (int)((maxMag-mag_min)/k);
if (x > 0) if (x > 0)
maxMagStarName = x; maxMagStarName = x;
} }
int zone; int zone;
for (GeodesicSearchInsideIterator it1(*geodesic_search_resul t,it.key());(zone = it1.next()) >= 0;) for (GeodesicSearchInsideIterator it1(*geodesic_search_resul t,it.key());(zone = it1.next()) >= 0;)
it.value()->draw(&sPainter, zone, true, rcmag_table, core, maxMagStarName, names_brightness); it.value()->draw(prj, renderer, zone, true, rcmag_ta ble, core, maxMagStarName, names_brightness);
for (GeodesicSearchBorderIterator it1(*geodesic_search_resul t,it.key());(zone = it1.next()) >= 0;) for (GeodesicSearchBorderIterator it1(*geodesic_search_resul t,it.key());(zone = it1.next()) >= 0;)
it.value()->draw(&sPainter, zone, false, rcmag_table , core, maxMagStarName,names_brightness); it.value()->draw(prj, renderer, zone, false, rcmag_t able, core, maxMagStarName,names_brightness);
} }
exit_loop: exit_loop:
// Finish drawing many stars // Finish drawing many stars
skyDrawer->postDrawPointSource(&sPainter); skyDrawer->postDrawPointSource(prj);
if (objectMgr->getFlagSelectedObjectPointer()) if (objectMgr->getFlagSelectedObjectPointer())
drawPointer(sPainter, core); drawPointer(renderer, prj, core);
} }
// Return a stl vector containing the stars located // Return a stl vector containing the stars located
// inside the limFov circle around position v // inside the limFov circle around position v
QList<StelObjectP > StarMgr::searchAround(const Vec3d& vv, double limFov, c onst StelCore* core) const QList<StelObjectP > StarMgr::searchAround(const Vec3d& vv, double limFov, c onst StelCore* core) const
{ {
QList<StelObjectP > result; QList<StelObjectP > result;
if (!getFlagStars()) if (!getFlagStars())
return result; return result;
 End of changes. 25 change blocks. 
33 lines changed or deleted 45 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/