Skip to content
Snippets Groups Projects
Commit 48fc8ec5 authored by slevy's avatar slevy
Browse files

Add kira_HRplot for drawing in H-R diagram.

parent ea394a15
No related branches found
No related tags found
No related merge requests found
#ifdef USE_KIRA
#include <ostream.h>
#include <istream.h>
#include "worldline.h"
// #define CAVE 1 // NewN: use potentially-shared-memory malloc
......@@ -8,6 +10,8 @@
#include "partiviewc.h"
#include "kira_parti.h" // declare following as extern "C"
#include "Plot.H"
#include <sys/types.h>
#include <sys/time.h>
......@@ -17,6 +21,7 @@ extern struct specklist *kira_get_parti( struct stuff *st, double realtime );
extern int kira_parse_args( struct dyndata *dd, struct stuff *st, int argc, char **argv );
extern int kira_draw( struct dyndata *dd, struct stuff *st, struct specklist *slhead,
Matrix *Tc2w, float radperpix );
extern void kira_HRplot( Fl_Plot *, struct stuff *st, struct dyndata *dd );
typedef worldbundle *worldbundleptr;
......@@ -178,6 +183,7 @@ double kira_get( struct dyndata *dd, struct stuff *st, int what )
}
int hasdata( ifstream *s, double maxwait ) {
#ifdef OLDSTDIO
struct timeval tv;
fd_set fds;
if(s == NULL) return 0;
......@@ -188,6 +194,9 @@ int hasdata( ifstream *s, double maxwait ) {
FD_ZERO(&fds);
FD_SET(s->rdbuf()->fd(), &fds);
return(select(s->rdbuf()->fd() + 1, &fds, NULL, NULL, &tv) > 0);
#else
return 1;
#endif
}
int kira_help( struct dyndata *dd, struct stuff *st, int verbose )
......@@ -298,6 +307,10 @@ int kira_open( struct dyndata *dd, struct stuff *st, char *filename, int readfla
if(st->vdesc[st->curdata][i].name[0] == '\0')
strcpy(st->vdesc[st->curdata][i].name, fieldnames[i]);
}
// Register for H-R diagram display
static float xxyyrange[4] = { 3, 6, -4, 6 };
parti_register_plot( st, kira_HRplot, dd, xxyyrange );
return 1;
}
......@@ -771,4 +784,44 @@ int kira_parse_args( struct dyndata *dd, struct stuff *st, int argc, char **argv
return 1;
}
void kira_HRplot( Fl_Plot *plot, struct stuff *st, struct dyndata *dd )
{
if(dd == NULL) return;
worldstuff *ww = (worldstuff *)dd->data;
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glPointSize( 2.0 );
glBegin( GL_POINTS );
float x0 = plot->xmin();
float x1 = plot->xmax();
if(x0 > x1) x0 = x1, x1 = plot->xmin();
float y0 = plot->ymin();
float y1 = plot->ymax();
if(y0 > y1) y0 = y1, y1 = plot->ymin();
for(struct specklist *sl = ww->sl; sl != NULL; sl = sl->next) {
if(sl->special != SPECKS)
continue;
int ns = sl->nspecks;
struct speck *sp = sl->specks;
for(int i = 0; i < ns; i++, sp = NextSpeck(sp, sl, 1)) {
if(sp->val[SPECK_MU] != 0 || sp->val[SPECK_LUM] <= 0)
continue; /* leaf nodes only */
int rgba = sp->rgba;
((unsigned char *)&rgba)[3] = 128; /* alpha=0.5 */
glColor4ubv( (GLubyte *)&rgba );
float x = sp->val[SPECK_TLOG];
float y = sp->val[SPECK_LUM] > 0 ? log10f( sp->val[SPECK_LUM] ) : y0;
if(x < x0) x = x0; else if(x > x1) x = x1;
if(y < y0) y = y0; else if(y > y1) y = y1;
glVertex2f( x, y );
}
}
glEnd();
}
#endif /* USE_KIRA */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment