diff --git a/src/framework/WindowManager.cpp b/src/framework/WindowManager.cpp index 7b67707..91cd3d6 100644 --- a/src/framework/WindowManager.cpp +++ b/src/framework/WindowManager.cpp @@ -328,6 +328,10 @@ void WindowManager::eventLoop() case SDLK_m: eventObservers.front()->keyboardPressEvent(AbstractGraphicsEngine::KeyM); break; + case SDLK_u: + eventObservers.front()->keyboardPressEvent(AbstractGraphicsEngine::KeyU); + break; + case SDLK_RETURN: toggleFullscreen(); default: diff --git a/src/starsphere/EinsteinS5R3Adapter.cpp b/src/starsphere/EinsteinS5R3Adapter.cpp index ebf74bd..a60a8e7 100644 --- a/src/starsphere/EinsteinS5R3Adapter.cpp +++ b/src/starsphere/EinsteinS5R3Adapter.cpp @@ -19,27 +19,54 @@ ***************************************************************************/ #include "EinsteinS5R3Adapter.h" +#include +#include +#include +#include "filesys.h" + const string EinsteinS5R3Adapter::SharedMemoryIdentifier = "EinsteinHS"; +const long EinsteinS5R3Adapter::MAX_RESULT_COUNT = 10000; + + EinsteinS5R3Adapter::EinsteinS5R3Adapter(BOINCClientAdapter *boincClient) { this->boincClient = boincClient; m_WUSkyPosRightAscension = 0.0; m_WUSkyPosDeclination = 0.0; + m_last_RA = 0.0; + m_last_dec = 0.0; m_WUFractionDone = 0.0; m_WUCPUTime = 0.0; + m_last_WUCPUTime = 0.0; + m_Nresults= 0; + m_results = new EinsteinS5R3Result[MAX_RESULT_COUNT]; } EinsteinS5R3Adapter::~EinsteinS5R3Adapter() { + delete [] m_results; } void EinsteinS5R3Adapter::refresh() { + boincClient->refresh(); parseApplicationInformation(); + + // check that some time has past since last checkpoint file loading + // if data is not loaded yet or marker position has changed + // try to load checkpoint_file + if( m_Nresults == 0 || + (m_WUCPUTime - m_last_WUCPUTime) > 60.0 && + (m_last_RA != wuSkyPosRightAscension() || m_last_dec != wuSkyPosDeclination())) { + loadCheckpointFile(); + m_last_WUCPUTime = m_WUCPUTime; + m_last_RA = wuSkyPosRightAscension(); + m_last_dec = wuSkyPosDeclination(); + } } void EinsteinS5R3Adapter::parseApplicationInformation() @@ -72,6 +99,49 @@ void EinsteinS5R3Adapter::parseApplicationInformation() } } +void EinsteinS5R3Adapter::loadCheckpointFile() { + UINT4 counter; + int res; + string fname(""); + // look for *.cpt file + + // directory traversal, not entirely portable, tho. + DIR *pdir; + struct dirent *pent; + + pdir=opendir("."); //"." refers to the current dir + if (!pdir){ + cerr << "opendir() failure;" << endl; + closedir(pdir); + return; + } + + while ((pent=readdir(pdir))){ + fname = pent->d_name; + + string::size_type pos1 = fname.find("h1_"); + string::size_type pos2 = fname.rfind(".cpt"); + + if(pos1 == 0 && pos2 == fname.length() -4) { + break; + } + } + closedir(pdir); + + + if(fname != "") { + boinc_copy(fname.c_str(),"temp.cpt"); + } + // try copying checkpoint file to tmp file + + + // open tmp file and read candidates + // plus normalize data + // and set the current buffer and result nr.. + res=read_hfs_checkpoint("temp.cpt", &counter); + // no error handling, we can't do anything about it anyways +} + double EinsteinS5R3Adapter::wuSkyPosRightAscension() const { return m_WUSkyPosRightAscension; @@ -91,3 +161,116 @@ double EinsteinS5R3Adapter::wuCPUTime() const { return m_WUCPUTime; } + +long EinsteinS5R3Adapter::copyCandidates(float res [][3] , long n) const +{ + long nr = m_Nresults; + + if(n < m_Nresults) { + nr = n; + } + + for (int i=0 ; i < nr ; i++) { + res[i][0]= m_results[i].ra; + res[i][1]= m_results[i].dec; + res[i][2]= m_results[i].meansig; + } + return nr; +} + + + +int EinsteinS5R3Adapter::read_hfs_checkpoint(const char*filename, UINT4*counter) { + FILE*fp; + UINT4 len; + UINT4 checksum; + UINT4 tl_elems; + HoughFStatOutputEntry buffer[MAX_RESULT_COUNT]; + /* counter should be 0 if we couldn't read a checkpoint */ + *counter = 0; + + /* try to open file */ + fp = fopen(filename, "rb"); + if(!fp) { + cerr << "Checkpoint "<< filename << " couldn't be opened\n"; + return(-1); + } + + /* read number of elements */ + len = fread(&(tl_elems), sizeof(tl_elems), 1, fp); + + + if(len != 1) { + cerr << "Couldn't read elems from " << filename << endl; + cerr << "fread() returned " << len << " , length was 1\n"; + if(fclose(fp)) + cerr << "In addition: couldn't close "<< filename << endl; + return(-1); + } + /* sanity check */ + if (tl_elems > MAX_RESULT_COUNT) { + cerr << "Number of elements read larger than max length of checkpoint data: " << tl_elems << " > " << MAX_RESULT_COUNT <<"\n"; + if(fclose(fp)) + cerr << "In addition: couldn't close\n"; + return(-2); + } + + /* read data */ + len = fread(buffer, sizeof(HoughFStatOutputEntry), tl_elems, fp); + if(len != tl_elems) { + cerr << "Couldn't read data from " << filename << endl; + if(fclose(fp)) + cerr << "In addition: couldn't close " << filename << endl; + return(-1); + } + + /* read counter */ + len = fread(counter, sizeof(*counter), 1, fp); + if(len != 1) { + cerr << "Couldn't read counter from " << filename << endl; + cerr << "fread() returned "<< len << ", length was 1\n"; + if(fclose(fp)) + cerr << "In addition: couldn't close " << filename << endl; + return(-1); + } + + /* read checksum */ + len = fread(&checksum, sizeof(checksum), 1, fp); + if(len != 1) { + cerr << "Couldn't read checksum to " << filename << endl; + cerr << "fread() returned "<< len << ", length was 1\n"; + if(fclose(fp)) + cerr << "In addition: couldn't close "<< filename << endl; + return(-1); + } + + /* close file */ + if(fclose(fp)) { + cerr << "Couldn't close " << filename << endl; + return(-1); + } + + /* verify checksum */ + for(len = 0; len < sizeof(tl_elems); len++) + checksum -= *(((char*)&(tl_elems)) + len); + for(len = 0; len < (tl_elems * sizeof(HoughFStatOutputEntry)); len++) + checksum -= *(((char*)buffer) + len); + for(len = 0; len < sizeof(*counter); len++) + checksum -= *(((char*)counter) + len); + if(checksum) { + cerr << "Checksum error: "<< checksum << endl; + return(-2); + } + + + for(UINT4 i=0 ; i < tl_elems ; i++) { + m_results[i].ra = buffer[i].Alpha / PI * 180.0; + m_results[i].dec= buffer[i].Delta / PI * 180.0; + m_results[i].maxsig = buffer[i].HoughFStat; + m_results[i].meansig = (buffer[i].MeanSig) > 0.0 ? buffer[i].MeanSig : 0.0 ; + } + m_Nresults= tl_elems; + /* all went well */ + return(0); +} + diff --git a/src/starsphere/EinsteinS5R3Adapter.h b/src/starsphere/EinsteinS5R3Adapter.h index 151e55f..6d46b76 100644 --- a/src/starsphere/EinsteinS5R3Adapter.h +++ b/src/starsphere/EinsteinS5R3Adapter.h @@ -29,6 +29,7 @@ using namespace std; #define PI 3.14159265 + /** * \addtogroup starsphere Starsphere * @{ @@ -44,9 +45,22 @@ using namespace std; * Max-Planck-Institute for Gravitational Physics\n * Hannover, Germany */ + +#define UINT4 uint32_t + +class EinsteinS5R3Result { +public: + float ra; // in deg + float dec; // in deg + float maxsig; + float meansig; +}; + class EinsteinS5R3Adapter { public: + + static const long MAX_RESULT_COUNT; /** * \brief Constructor * @@ -66,37 +80,45 @@ public: */ void refresh(); - /** + /** * \brief Retrieves the right ascension of the currently searched sky position * * \return The right ascension (in degrees) */ - double wuSkyPosRightAscension() const; + double wuSkyPosRightAscension() const; - /** + /** * \brief Retrieves the declination of the currently searched sky position * * \return The right ascension (in degrees) */ - double wuSkyPosDeclination() const; - - /** - * \brief Retrieves the completion fraction of the currently active work unit - * - * \return The completion fraction (range 0-1) - */ - double wuFractionDone() const; - - /** - * \brief Retrieves the amount of CPU time consumed for the currently active work unit - * during the active session - * - * \return The accumulated CPU time consumed during this work unit session (in seconds) - */ - double wuCPUTime() const; - - /// The identifier of the Einstein\@Home science application's shared memory area - static const string SharedMemoryIdentifier; + double wuSkyPosDeclination() const; + + /** + * \brief Retrieves the completion fraction of the currently active work unit + * + * \return The completion fraction (range 0-1) + */ + double wuFractionDone() const; + + /** + * \brief Retrieves the amount of CPU time consumed for the currently active work unit + * during the active session + * + * \return The accumulated CPU time consumed during this work unit session (in seconds) + */ + double wuCPUTime() const; + + /** + * \brief copy the candidates read from checkpointfile to array passed as argument, + * but at most n elements. + * + * \return The actual number of candidates coppied ( >=0, <= n) + */ + long copyCandidates(float res[][3], long n) const; + + /// The identifier of the Einstein\@Home science application's shared memory area + static const string SharedMemoryIdentifier; private: @@ -110,6 +132,20 @@ private: */ void parseApplicationInformation(); + /** + * \brief Load checkpoint file to retrieve current set of candidates + * + * the candidates are stored in a private member buffer + * + * + */ + + void loadCheckpointFile(); + + + + int read_hfs_checkpoint(const char*filename, UINT4*counter); + /// Pointer to the (parent) BOINC client adapter BOINCClientAdapter *boincClient; @@ -124,8 +160,36 @@ private: /// Amount of CPU time consumed for the work unit during the active session double m_WUCPUTime; + + /// nr of candidates read from che checkpointfile + long m_Nresults; + + /// candidates from checkpoint file + EinsteinS5R3Result * m_results ; + + /// Amount of CPU time consumed for the work unit at the time of last checkpoint reading + double m_last_WUCPUTime; + + /// Right ascension at the time of last checkpoint reading (in degrees) + double m_last_RA; + + /// Declination at the time of last checkpoint reading (in degrees) + double m_last_dec; }; + +typedef struct { + double Freq; /**< Frequency at maximum (?) of the cluster */ + double f1dot; /**< spindown value f1dot = df/dt */ + double Alpha; /**< Skyposition: longitude in equatorial coords, radians */ + double Delta; /**< skyposition: latitude */ + double HoughFStat; /**< Hough significance */ + double AlphaBest; /**< skyposition of best candidate: longitude */ + double DeltaBest; /**< skyposition of best candidate: latitude */ + double MeanSig; /**< mean of significance values in hough map*/ + double VarianceSig; /**< variance of significance values in hough map*/ +} HoughFStatOutputEntry; + /** * @} */ diff --git a/src/starsphere/Makefile b/src/starsphere/Makefile index b613bfc..db4c4b3 100644 --- a/src/starsphere/Makefile +++ b/src/starsphere/Makefile @@ -45,7 +45,7 @@ CPPFLAGS += $(shell $(STARSPHERE_INSTALL)/bin/xml2-config --cflags) CPPFLAGS += -I$(STARSPHERE_INSTALL)/include/BOINC -I/usr/include DEPS = Makefile -OBJS = Starsphere.o StarsphereS5R3.o StarsphereRadio.o EinsteinS5R3Adapter.o EinsteinRadioAdapter.o starlist.o snr_list.o pulsar_list.o $(RESOURCESPEC).o +OBJS = Starsphere.o StarsphereS5R3.o StarsphereRadio.o EinsteinS5R3Adapter.o EinsteinRadioAdapter.o starlist.o snr_list.o pulsar_list.o $(RESOURCESPEC).o RESOURCESPEC = resources # TODO: GraphicsEngineFactory obviously depends on the actual implementations (here starsphere)! need to change the structure! what about plugins? @@ -98,6 +98,7 @@ snr_list.o: $(DEPS) $(STARSPHERE_SRC)/snr_list.C pulsar_list.o: $(DEPS) $(STARSPHERE_SRC)/pulsar_list.C $(CXX) -g $(CPPFLAGS) -c $(STARSPHERE_SRC)/pulsar_list.C + # resource compiler $(RESOURCESPEC).o: $(STARSPHERE_SRC)/$(RESOURCESPEC).orc $(STARSPHERE_INSTALL)/bin/orc $(STARSPHERE_SRC)/$(RESOURCESPEC).orc $(RESOURCESPEC).cpp diff --git a/src/starsphere/Starsphere.cpp b/src/starsphere/Starsphere.cpp index 8a93220..ebf6347 100644 --- a/src/starsphere/Starsphere.cpp +++ b/src/starsphere/Starsphere.cpp @@ -32,7 +32,7 @@ Starsphere::Starsphere(string sharedMemoryAreaIdentifier) : m_FontHeader = 0; m_FontText = 0; - Axes=0, Stars=0, Constellations=0, Pulsars=0; + Axes=0, Stars=0, Constellations=0, Pulsars=0, Results=0; LLOmarker=0, LHOmarker=0, GEOmarker=0, VIRGOmarker=0; sphGrid=0, SNRs=0, SearchMarker=0; @@ -60,6 +60,8 @@ Starsphere::Starsphere(string sharedMemoryAreaIdentifier) : m_CurrentRightAscension = -1.0; m_CurrentDeclination = -1.0; m_RefreshSearchMarker = true; + + Nresults=0; } Starsphere::~Starsphere() @@ -68,6 +70,7 @@ Starsphere::~Starsphere() if(m_FontLogo2) delete m_FontLogo2; if(m_FontHeader) delete m_FontHeader; if(m_FontText) delete m_FontText; + } void Starsphere::sphVertex3D(GLfloat RAdeg, GLfloat DEdeg, GLfloat radius) @@ -100,6 +103,20 @@ void Starsphere::star_marker(float RAdeg, float DEdeg, float size) } /** + * Star Marker: + * Makes a marker for one star at a given position, angular size and radius + */ +void Starsphere::star_marker3D(float RAdeg, float DEdeg, float radius, float size) +{ + glPointSize((GLfloat) size); + glBegin(GL_POINTS); + sphVertex3D((GLfloat) RAdeg, (GLfloat) DEdeg, (GLfloat) (radius*sphRadius)); + glEnd(); + return; +} + + +/** * Create Stars: markers for each star */ void Starsphere::make_stars() @@ -141,6 +158,55 @@ void Starsphere::make_stars() glEndList(); } +void Starsphere::make_results() +{ + GLfloat mag_size=2.0; + int i; + float r,g,b; + float min_r, max_r; + // default values for max significance metric + resultMetricDefaults(min_r,max_r); + + + // delete existing, create new (required for windoze) + if(Results) glDeleteLists(Results, 1); + Results = glGenLists(1); + glNewList(Results, GL_COMPILE); + + + for (i=0; i < Nresults; i++) { + float radius=result_info[i][2]; + if (radius < min_r) { + min_r=radius; + } + if (radius > max_r) { + max_r=radius; + } + } + + if (min_r==max_r) min_r=max_r-1.0; + + for (i=0; i < Nresults; i++) { + + float radius=result_info[i][2]; + + float norm_radius = (radius - min_r) / (max_r-min_r); + int color_bin = (int) (255.0 * (1.0 - norm_radius)); + + if (color_bin < 0) color_bin=0; + if (color_bin > 255) color_bin = 255; + + r = rainbow_colormap[color_bin][0]; + g = rainbow_colormap[color_bin][1]; + b = rainbow_colormap[color_bin][2]; + glColor3f(r, g, b); + star_marker3D(result_info[i][0], result_info[i][1],norm_radius ,mag_size); + } + glEndList(); +} + + + /** * Pulsar Markers: */ @@ -577,9 +643,22 @@ void Starsphere::make_globe() glEndList(); } + +/** + * result metric info + * can be overwritten + */ + + +void Starsphere::resultMetricDefaults(float & min_default, float & max_default) { + min_default= 0.0; + max_default= 1.0; + +} /** * Window resize/remap */ + void Starsphere::resize(const int width, const int height) { // store current settings @@ -622,6 +701,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f setFeature(STARS, true); setFeature(CONSTELLATIONS, true); setFeature(PULSARS, true); + setFeature(RESULTS, true); setFeature(SNRS, true); setFeature(OBSERVATORIES, true); setFeature(SEARCHINFO, true); @@ -727,6 +807,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f make_stars(); make_constellations(); make_pulsars(); + make_results(); make_snrs(); make_axes(); make_globe(); @@ -798,12 +879,13 @@ void Starsphere::render(const double timeOfDay) glPushMatrix(); glRotatef(Zrot - rotation_offset, 0.0, 1.0, 0.0); - // stars, pulsars, supernovae, grid + // stars, pulsars, supernovae, grid, results if (isFeature(STARS)) glCallList(Stars); if (isFeature(PULSARS)) glCallList(Pulsars); if (isFeature(SNRS)) glCallList(SNRs); if (isFeature(CONSTELLATIONS)) glCallList(Constellations); if (isFeature(GLOBE)) glCallList(sphGrid); + if (isFeature(RESULTS)) glCallList(Results); // observatories move an extra 15 degrees/hr since they were drawn if (isFeature(OBSERVATORIES)) { @@ -823,12 +905,21 @@ void Starsphere::render(const double timeOfDay) if(m_RefreshSearchMarker) { make_search_marker(m_CurrentRightAscension, m_CurrentDeclination, 0.5); m_RefreshSearchMarker = false; + m_RefreshResults=true; } else { glCallList(SearchMarker); } } + if(isFeature(RESULTS)) { + if(m_RefreshResults) { + make_results(); + m_RefreshResults=false; + } + + } + glPopMatrix(); // draw 2D vectorized HUD @@ -911,6 +1002,9 @@ void Starsphere::keyboardPressEvent(const AbstractGraphicsEngine::KeyBoardKey ke case KeyP: setFeature(PULSARS, isFeature(PULSARS) ? false : true); break; + case KeyU: + setFeature(RESULTS, isFeature(RESULTS) ? false : true); + break; case KeyR: setFeature(SNRS, isFeature(SNRS) ? false : true); break; @@ -998,3 +1092,261 @@ void Starsphere::refreshLocalBOINCInformation() m_UserRACredit = buffer.str(); buffer.str(""); } +float Starsphere::rainbow_colormap [][3] = { +{ 1.000000f , 0.000000f , 0.000000f }, +{ 1.000000f , 0.009804f , 0.000000f }, +{ 1.000000f , 0.019608f , 0.000000f }, +{ 1.000000f , 0.029412f , 0.000000f }, +{ 1.000000f , 0.039216f , 0.000000f }, +{ 1.000000f , 0.049020f , 0.000000f }, +{ 1.000000f , 0.058824f , 0.000000f }, +{ 1.000000f , 0.068627f , 0.000000f }, +{ 1.000000f , 0.078431f , 0.000000f }, +{ 1.000000f , 0.088235f , 0.000000f }, +{ 1.000000f , 0.098039f , 0.000000f }, +{ 1.000000f , 0.107843f , 0.000000f }, +{ 1.000000f , 0.117647f , 0.000000f }, +{ 1.000000f , 0.127451f , 0.000000f }, +{ 1.000000f , 0.137255f , 0.000000f }, +{ 1.000000f , 0.147059f , 0.000000f }, +{ 1.000000f , 0.156863f , 0.000000f }, +{ 1.000000f , 0.166667f , 0.000000f }, +{ 1.000000f , 0.176471f , 0.000000f }, +{ 1.000000f , 0.186275f , 0.000000f }, +{ 1.000000f , 0.196078f , 0.000000f }, +{ 1.000000f , 0.205882f , 0.000000f }, +{ 1.000000f , 0.215686f , 0.000000f }, +{ 1.000000f , 0.225490f , 0.000000f }, +{ 1.000000f , 0.235294f , 0.000000f }, +{ 1.000000f , 0.245098f , 0.000000f }, +{ 1.000000f , 0.254902f , 0.000000f }, +{ 1.000000f , 0.264706f , 0.000000f }, +{ 1.000000f , 0.274510f , 0.000000f }, +{ 1.000000f , 0.284314f , 0.000000f }, +{ 1.000000f , 0.294118f , 0.000000f }, +{ 1.000000f , 0.303922f , 0.000000f }, +{ 1.000000f , 0.313725f , 0.000000f }, +{ 1.000000f , 0.323529f , 0.000000f }, +{ 1.000000f , 0.333333f , 0.000000f }, +{ 1.000000f , 0.343137f , 0.000000f }, +{ 1.000000f , 0.352941f , 0.000000f }, +{ 1.000000f , 0.362745f , 0.000000f }, +{ 1.000000f , 0.372549f , 0.000000f }, +{ 1.000000f , 0.382353f , 0.000000f }, +{ 1.000000f , 0.392157f , 0.000000f }, +{ 1.000000f , 0.401961f , 0.000000f }, +{ 1.000000f , 0.411765f , 0.000000f }, +{ 1.000000f , 0.421569f , 0.000000f }, +{ 1.000000f , 0.431373f , 0.000000f }, +{ 1.000000f , 0.441176f , 0.000000f }, +{ 1.000000f , 0.450980f , 0.000000f }, +{ 1.000000f , 0.460784f , 0.000000f }, +{ 1.000000f , 0.470588f , 0.000000f }, +{ 1.000000f , 0.480392f , 0.000000f }, +{ 1.000000f , 0.490196f , 0.000000f }, +{ 1.000000f , 0.500000f , 0.000000f }, +{ 1.000000f , 0.509804f , 0.000000f }, +{ 1.000000f , 0.519608f , 0.000000f }, +{ 1.000000f , 0.529412f , 0.000000f }, +{ 1.000000f , 0.539216f , 0.000000f }, +{ 1.000000f , 0.549020f , 0.000000f }, +{ 1.000000f , 0.558824f , 0.000000f }, +{ 1.000000f , 0.568627f , 0.000000f }, +{ 1.000000f , 0.578431f , 0.000000f }, +{ 1.000000f , 0.588235f , 0.000000f }, +{ 1.000000f , 0.598039f , 0.000000f }, +{ 1.000000f , 0.607843f , 0.000000f }, +{ 1.000000f , 0.617647f , 0.000000f }, +{ 1.000000f , 0.627451f , 0.000000f }, +{ 1.000000f , 0.637255f , 0.000000f }, +{ 1.000000f , 0.647059f , 0.000000f }, +{ 1.000000f , 0.656863f , 0.000000f }, +{ 1.000000f , 0.666667f , 0.000000f }, +{ 1.000000f , 0.676471f , 0.000000f }, +{ 1.000000f , 0.686275f , 0.000000f }, +{ 1.000000f , 0.696078f , 0.000000f }, +{ 1.000000f , 0.705882f , 0.000000f }, +{ 1.000000f , 0.715686f , 0.000000f }, +{ 1.000000f , 0.725490f , 0.000000f }, +{ 1.000000f , 0.735294f , 0.000000f }, +{ 1.000000f , 0.745098f , 0.000000f }, +{ 1.000000f , 0.754902f , 0.000000f }, +{ 1.000000f , 0.764706f , 0.000000f }, +{ 1.000000f , 0.774510f , 0.000000f }, +{ 1.000000f , 0.784314f , 0.000000f }, +{ 1.000000f , 0.794118f , 0.000000f }, +{ 1.000000f , 0.803922f , 0.000000f }, +{ 1.000000f , 0.813725f , 0.000000f }, +{ 1.000000f , 0.823529f , 0.000000f }, +{ 1.000000f , 0.833333f , 0.000000f }, +{ 1.000000f , 0.843137f , 0.000000f }, +{ 1.000000f , 0.852941f , 0.000000f }, +{ 1.000000f , 0.862745f , 0.000000f }, +{ 1.000000f , 0.872549f , 0.000000f }, +{ 1.000000f , 0.882353f , 0.000000f }, +{ 1.000000f , 0.892157f , 0.000000f }, +{ 1.000000f , 0.901961f , 0.000000f }, +{ 1.000000f , 0.911765f , 0.000000f }, +{ 1.000000f , 0.921569f , 0.000000f }, +{ 1.000000f , 0.931373f , 0.000000f }, +{ 1.000000f , 0.941176f , 0.000000f }, +{ 1.000000f , 0.950980f , 0.000000f }, +{ 1.000000f , 0.960784f , 0.000000f }, +{ 1.000000f , 0.970588f , 0.000000f }, +{ 1.000000f , 0.980392f , 0.000000f }, +{ 1.000000f , 0.990196f , 0.000000f }, +{ 1.000000f , 1.000000f , 0.000000f }, +{ 0.980392f , 1.000000f , 0.000000f }, +{ 0.960784f , 1.000000f , 0.000000f }, +{ 0.941176f , 1.000000f , 0.000000f }, +{ 0.921569f , 1.000000f , 0.000000f }, +{ 0.901961f , 1.000000f , 0.000000f }, +{ 0.882353f , 1.000000f , 0.000000f }, +{ 0.862745f , 1.000000f , 0.000000f }, +{ 0.843137f , 1.000000f , 0.000000f }, +{ 0.823529f , 1.000000f , 0.000000f }, +{ 0.803922f , 1.000000f , 0.000000f }, +{ 0.784314f , 1.000000f , 0.000000f }, +{ 0.764706f , 1.000000f , 0.000000f }, +{ 0.745098f , 1.000000f , 0.000000f }, +{ 0.725490f , 1.000000f , 0.000000f }, +{ 0.705882f , 1.000000f , 0.000000f }, +{ 0.686275f , 1.000000f , 0.000000f }, +{ 0.666667f , 1.000000f , 0.000000f }, +{ 0.647059f , 1.000000f , 0.000000f }, +{ 0.627451f , 1.000000f , 0.000000f }, +{ 0.607843f , 1.000000f , 0.000000f }, +{ 0.588235f , 1.000000f , 0.000000f }, +{ 0.568627f , 1.000000f , 0.000000f }, +{ 0.549020f , 1.000000f , 0.000000f }, +{ 0.529412f , 1.000000f , 0.000000f }, +{ 0.509804f , 1.000000f , 0.000000f }, +{ 0.490196f , 1.000000f , 0.000000f }, +{ 0.470588f , 1.000000f , 0.000000f }, +{ 0.450980f , 1.000000f , 0.000000f }, +{ 0.431373f , 1.000000f , 0.000000f }, +{ 0.411765f , 1.000000f , 0.000000f }, +{ 0.392157f , 1.000000f , 0.000000f }, +{ 0.372549f , 1.000000f , 0.000000f }, +{ 0.352941f , 1.000000f , 0.000000f }, +{ 0.333333f , 1.000000f , 0.000000f }, +{ 0.313725f , 1.000000f , 0.000000f }, +{ 0.294118f , 1.000000f , 0.000000f }, +{ 0.274510f , 1.000000f , 0.000000f }, +{ 0.254902f , 1.000000f , 0.000000f }, +{ 0.235294f , 1.000000f , 0.000000f }, +{ 0.215686f , 1.000000f , 0.000000f }, +{ 0.196078f , 1.000000f , 0.000000f }, +{ 0.176471f , 1.000000f , 0.000000f }, +{ 0.156863f , 1.000000f , 0.000000f }, +{ 0.137255f , 1.000000f , 0.000000f }, +{ 0.117647f , 1.000000f , 0.000000f }, +{ 0.098039f , 1.000000f , 0.000000f }, +{ 0.078431f , 1.000000f , 0.000000f }, +{ 0.058824f , 1.000000f , 0.000000f }, +{ 0.039216f , 1.000000f , 0.000000f }, +{ 0.019608f , 1.000000f , 0.000000f }, +{ 0.000000f , 1.000000f , 0.000000f }, +{ 0.000000f , 0.980392f , 0.019608f }, +{ 0.000000f , 0.960784f , 0.039216f }, +{ 0.000000f , 0.941176f , 0.058824f }, +{ 0.000000f , 0.921569f , 0.078431f }, +{ 0.000000f , 0.901961f , 0.098039f }, +{ 0.000000f , 0.882353f , 0.117647f }, +{ 0.000000f , 0.862745f , 0.137255f }, +{ 0.000000f , 0.843137f , 0.156863f }, +{ 0.000000f , 0.823529f , 0.176471f }, +{ 0.000000f , 0.803922f , 0.196078f }, +{ 0.000000f , 0.784314f , 0.215686f }, +{ 0.000000f , 0.764706f , 0.235294f }, +{ 0.000000f , 0.745098f , 0.254902f }, +{ 0.000000f , 0.725490f , 0.274510f }, +{ 0.000000f , 0.705882f , 0.294118f }, +{ 0.000000f , 0.686275f , 0.313725f }, +{ 0.000000f , 0.666667f , 0.333333f }, +{ 0.000000f , 0.647059f , 0.352941f }, +{ 0.000000f , 0.627451f , 0.372549f }, +{ 0.000000f , 0.607843f , 0.392157f }, +{ 0.000000f , 0.588235f , 0.411765f }, +{ 0.000000f , 0.568627f , 0.431373f }, +{ 0.000000f , 0.549020f , 0.450980f }, +{ 0.000000f , 0.529412f , 0.470588f }, +{ 0.000000f , 0.509804f , 0.490196f }, +{ 0.000000f , 0.490196f , 0.509804f }, +{ 0.000000f , 0.470588f , 0.529412f }, +{ 0.000000f , 0.450980f , 0.549020f }, +{ 0.000000f , 0.431373f , 0.568627f }, +{ 0.000000f , 0.411765f , 0.588235f }, +{ 0.000000f , 0.392157f , 0.607843f }, +{ 0.000000f , 0.372549f , 0.627451f }, +{ 0.000000f , 0.352941f , 0.647059f }, +{ 0.000000f , 0.333333f , 0.666667f }, +{ 0.000000f , 0.313725f , 0.686275f }, +{ 0.000000f , 0.294118f , 0.705882f }, +{ 0.000000f , 0.274510f , 0.725490f }, +{ 0.000000f , 0.254902f , 0.745098f }, +{ 0.000000f , 0.235294f , 0.764706f }, +{ 0.000000f , 0.215686f , 0.784314f }, +{ 0.000000f , 0.196078f , 0.803922f }, +{ 0.000000f , 0.176471f , 0.823529f }, +{ 0.000000f , 0.156863f , 0.843137f }, +{ 0.000000f , 0.137255f , 0.862745f }, +{ 0.000000f , 0.117647f , 0.882353f }, +{ 0.000000f , 0.098039f , 0.901961f }, +{ 0.000000f , 0.078431f , 0.921569f }, +{ 0.000000f , 0.058824f , 0.941176f }, +{ 0.000000f , 0.039216f , 0.960784f }, +{ 0.000000f , 0.019608f , 0.980392f }, +{ 0.000000f , 0.000000f , 1.000000f }, +{ 0.013072f , 0.000000f , 1.000000f }, +{ 0.026144f , 0.000000f , 1.000000f }, +{ 0.039216f , 0.000000f , 1.000000f }, +{ 0.052288f , 0.000000f , 1.000000f }, +{ 0.065359f , 0.000000f , 1.000000f }, +{ 0.078431f , 0.000000f , 1.000000f }, +{ 0.091503f , 0.000000f , 1.000000f }, +{ 0.104575f , 0.000000f , 1.000000f }, +{ 0.117647f , 0.000000f , 1.000000f }, +{ 0.130719f , 0.000000f , 1.000000f }, +{ 0.143791f , 0.000000f , 1.000000f }, +{ 0.156863f , 0.000000f , 1.000000f }, +{ 0.169935f , 0.000000f , 1.000000f }, +{ 0.183007f , 0.000000f , 1.000000f }, +{ 0.196078f , 0.000000f , 1.000000f }, +{ 0.209150f , 0.000000f , 1.000000f }, +{ 0.222222f , 0.000000f , 1.000000f }, +{ 0.235294f , 0.000000f , 1.000000f }, +{ 0.248366f , 0.000000f , 1.000000f }, +{ 0.261438f , 0.000000f , 1.000000f }, +{ 0.274510f , 0.000000f , 1.000000f }, +{ 0.287582f , 0.000000f , 1.000000f }, +{ 0.300654f , 0.000000f , 1.000000f }, +{ 0.313725f , 0.000000f , 1.000000f }, +{ 0.326797f , 0.000000f , 1.000000f }, +{ 0.339869f , 0.000000f , 1.000000f }, +{ 0.352941f , 0.000000f , 1.000000f }, +{ 0.366013f , 0.000000f , 1.000000f }, +{ 0.379085f , 0.000000f , 1.000000f }, +{ 0.392157f , 0.000000f , 1.000000f }, +{ 0.405229f , 0.000000f , 1.000000f }, +{ 0.418301f , 0.000000f , 1.000000f }, +{ 0.431373f , 0.000000f , 1.000000f }, +{ 0.444444f , 0.000000f , 1.000000f }, +{ 0.457516f , 0.000000f , 1.000000f }, +{ 0.470588f , 0.000000f , 1.000000f }, +{ 0.483660f , 0.000000f , 1.000000f }, +{ 0.496732f , 0.000000f , 1.000000f }, +{ 0.509804f , 0.000000f , 1.000000f }, +{ 0.522876f , 0.000000f , 1.000000f }, +{ 0.535948f , 0.000000f , 1.000000f }, +{ 0.549020f , 0.000000f , 1.000000f }, +{ 0.562092f , 0.000000f , 1.000000f }, +{ 0.575163f , 0.000000f , 1.000000f }, +{ 0.588235f , 0.000000f , 1.000000f }, +{ 0.601307f , 0.000000f , 1.000000f }, +{ 0.614379f , 0.000000f , 1.000000f }, +{ 0.627451f , 0.000000f , 1.000000f }, +{ 0.640523f , 0.000000f , 1.000000f }, +{ 0.653595f , 0.000000f , 1.000000f }, +{ 0.666667f , 0.000000f , 1.000000f } +}; diff --git a/src/starsphere/Starsphere.h b/src/starsphere/Starsphere.h index 7e73625..5ccee64 100644 --- a/src/starsphere/Starsphere.h +++ b/src/starsphere/Starsphere.h @@ -56,6 +56,8 @@ // needed to find OpenGL 1.4 prototypes in glext.h (alternatives?) #define GL_GLEXT_PROTOTYPES +#define MAX_RESULT_COUNT 10000 + using namespace std; /** @@ -109,11 +111,22 @@ public: */ virtual void resize(const int width, const int height); + + /** + * \brief This method is used to get an idea about the range of result metric values + * + * \param min_default (out) default minimum of result metric + * \param max_default (out) default maximum of result metric + */ + virtual void resultMetricDefaults(float & min_default, float & max_default); + + /** * \brief This method renders one frame of the animation * * \param timeOfDay The current time (e.g. BOINC's dtime(), used for time-based rendering evolution) */ + void render(const double timeOfDay); /** @@ -227,7 +240,8 @@ protected: AXES = 128, SEARCHINFO = 256, LOGO = 512, - MARKER = 1024 + MARKER = 1024, + RESULTS = 2048 }; /** @@ -359,6 +373,16 @@ protected: /// Refresh indicator when the search marker (gunsight) coordinates changed bool m_RefreshSearchMarker; + /// Refresh Results + bool m_RefreshResults; + + + /// Result (Candiate) coordinates and 'score' + float result_info[MAX_RESULT_COUNT][3]; + + /// nr of candidate results + int Nresults; + private: /// Generate OpenGL display list for stars void make_stars(); @@ -366,6 +390,9 @@ private: /// Generate OpenGL display list for pulsars void make_pulsars(); + /// Generate OpenGL display list for results + void make_results(); + /// Generate OpenGL display list for SNRs void make_snrs(); @@ -396,9 +423,21 @@ private: */ void star_marker(float RAdeg, float DEdeg, float size); + /** + * \brief Generate a single star vertex with radius + * + * \param RAdeg Right ascension in degrees + * \param DEdeg Declination in degrees + * \param radius radius as fraction of sphere radius + * \param size Point size of the star + */ + void star_marker3D(float RAdeg, float DEdeg, float radius, float size); + + /// rainbow-like color map (RGB) + static float rainbow_colormap [][3]; /// Feature display list ID's - GLuint Axes, Stars, Constellations, Pulsars, SNRs; + GLuint Axes, Stars, Constellations, Pulsars, SNRs, Results; /// Feature display list ID's GLuint LLOmarker, LHOmarker, GEOmarker, VIRGOmarker; @@ -463,6 +502,9 @@ private: * \see Starsphere::mouseMoveEvent() */ void zoomSphere(const int relativeZoom); + + + }; /// Constellation & star coordinates (starlist.C) @@ -474,6 +516,9 @@ extern int Nstars; /// Pulsar coordinates are (pulsar_list.C) extern float pulsar_info[][2]; +/// Result (Candiate) coordinates and 'score' +extern float result_info[][3]; + /// Total number of pulsars extern int Npulsars; @@ -483,6 +528,7 @@ extern float SNR_info[][2]; /// Total number of SNRs extern int NSNRs; + /** * @} */ diff --git a/src/starsphere/StarsphereS5R3.cpp b/src/starsphere/StarsphereS5R3.cpp index e93e332..223ee2a 100644 --- a/src/starsphere/StarsphereS5R3.cpp +++ b/src/starsphere/StarsphereS5R3.cpp @@ -19,7 +19,6 @@ ***************************************************************************/ #include "StarsphereS5R3.h" - #include StarsphereS5R3::StarsphereS5R3() : @@ -81,6 +80,12 @@ void StarsphereS5R3::initialize(const int width, const int height, const Resourc generateObservatories(1.0); } + +void StarsphereS5R3::resultMetricDefaults(float & min_default, float & max_default) { + min_default= -0.5; + max_default= 1.25; +} + void StarsphereS5R3::resize(const int width, const int height) { Starsphere::resize(width, height); @@ -92,6 +97,7 @@ void StarsphereS5R3::resize(const int width, const int height) void StarsphereS5R3::refreshBOINCInformation() { + bool refresh_results = false; // call base class implementation Starsphere::refreshLocalBOINCInformation(); @@ -111,8 +117,9 @@ void StarsphereS5R3::refreshBOINCInformation() m_CurrentRightAscension = m_EinsteinAdapter.wuSkyPosRightAscension(); m_RefreshSearchMarker = true; buffer.str(""); - buffer << "Ascension: " << fixed << m_CurrentRightAscension << " deg" << ends; + buffer << "RA: " << fixed << m_CurrentRightAscension << " deg" << ends; m_WUSkyPosRightAscension = buffer.str(); + refresh_results=true; } if(m_CurrentDeclination != m_EinsteinAdapter.wuSkyPosDeclination()) { @@ -120,8 +127,13 @@ void StarsphereS5R3::refreshBOINCInformation() m_CurrentDeclination = m_EinsteinAdapter.wuSkyPosDeclination(); m_RefreshSearchMarker = true; buffer.str(""); - buffer << "Declination: " << fixed << m_CurrentDeclination << " deg" << ends; + buffer << "dec: " << fixed << m_CurrentDeclination << " deg" << ends; m_WUSkyPosDeclination = buffer.str(); + refresh_results=true; + } + + if(refresh_results) { + Nresults=m_EinsteinAdapter.copyCandidates(result_info, MAX_RESULT_COUNT); } buffer.str(""); diff --git a/src/starsphere/StarsphereS5R3.h b/src/starsphere/StarsphereS5R3.h index 915dba5..e43f303 100644 --- a/src/starsphere/StarsphereS5R3.h +++ b/src/starsphere/StarsphereS5R3.h @@ -26,6 +26,8 @@ #include "Starsphere.h" #include "EinsteinS5R3Adapter.h" + + using namespace std; /** @@ -81,6 +83,18 @@ public: void resize(const int width, const int height); /** + * \brief This method is called to get a default range for the result metric + * + * this method overrides its parent's implementation, + * + * \param width The new width of the display surface + * \param height The new height of the display surface + */ + + virtual void resultMetricDefaults(float & min_default, float & max_default); + + + /** * \brief This method is called when the BOINC client information should be updated * * This method implements AbstractGraphicsEngine::refreshBOINCInformation() and calls