Commit c7294f2d authored by Edward Vigmond's avatar Edward Vigmond
Browse files

Added dynamic point display

Eliminated the point offset method of centering ther model.
parent a32f3601
......@@ -37,11 +37,9 @@ public:
* Indexes the associated file at construction
*
* \param filename to index (without extention)
* \param pt_offset in model to apply
*/
AuxGridIndexer(char * filename, GLfloat const * pt_offset)
: _pt_offset(pt_offset),
_model(0),
AuxGridIndexer(char * filename)
: _model(0),
_data(0),
_frame(-1)
{
......@@ -123,7 +121,7 @@ public:
// load model from file
_model = new Model();
_model->read_instance(_pts_in, _elem_in, _pt_offset);
_model->read_instance(_pts_in, _elem_in);
// load data
if (_dat_in) {
......@@ -284,8 +282,6 @@ private:
public:
Model * _model; //!< current frame model
DATA_TYPE *_data; //!< current frame data
private:
GLfloat const * _pt_offset; //!< offset to pass in for model creation (shouldn't really be here)
};
......@@ -296,13 +292,12 @@ private:
/** constructor
*
* \param fn base file name
* \param pt_offset center of model coordinates
*
* \throw 1 if any error in input
*/
AuxGrid::AuxGrid( char *fn, const GLfloat* pt_offset )
AuxGrid::AuxGrid( char *fn )
: _display(true), _hilight(false), _hiVert(0), _plottable(false),
_indexer(new AuxGridIndexer(fn, pt_offset)),_timeplot(NULL)
_indexer(new AuxGridIndexer(fn)),_timeplot(NULL)
{
for (int i=0; i<sizeof(*_3D); i++)
_3D[i] = true;
......
......@@ -35,7 +35,7 @@ class AuxGrid {
double* _time_series;
public:
AuxGrid( char *fn, const GLfloat *ptoff=NULL );
AuxGrid( char *fn );
virtual ~AuxGrid();
Colourscale cs;
......
......@@ -8,7 +8,7 @@
using namespace std;
enum DataReaderEnum {AllInMem, Threaded };
enum fileType { FTIGB=1, FTascii, FTfileSeqCG, FTother };
enum fileType { FTIGB=1, FTascii, FTfileSeqCG, FTDynPt, FTother };
fileType FileTypeFinder ( const char *fn );
......
......@@ -8,6 +8,8 @@
#include "DataOpacity.h"
#include <zlib.h>
#include "Interpolator.h"
#include "DataAllInMem.h"
#include "ThreadedData.h"
gzFile openFile( const char*, const char* );
......@@ -43,7 +45,7 @@ class DrawingObj
class PPoint: public DrawingObj
{
public:
PPoint() : _pts(NULL), _base1(false) {}
PPoint() : _pts(NULL), _base1(false),_dynPt(NULL), _tm(-1) {}
virtual ~PPoint() { if ( _pts ) free(_pts); _pts = 0; }
virtual void draw( int, GLfloat*, float size=1 );
......@@ -63,12 +65,19 @@ class PPoint: public DrawingObj
void base1(bool b){ _base1 = b; }
void add( GLfloat *, int n=1 );
const GLfloat* operator[] (int i){ return _pts+3*i; }
void time( int a );
int time(){ return _tm; }
int dynamic( const char *, int );
int num_tm(){ return _dynPt? _dynPt->max_tm()+1:0; }
private:
GLfloat* _pts; //!< point list
vector<bool>*_visible; //!< points which get drawn
GLfloat _offset[3]; //!< centering offset
bool _base1; //!< true for base 1
vector<bool>_allvis; //!< all true
int _maxtm; //!< maximum time
int _tm; //!< current time
DataClass<float>* _dynPt; //!< dynamic point data
};
......
......@@ -24,6 +24,7 @@ using namespace std;
*
* - FTascii: one acsii number per line
* - FTIGB: IGB data
* - FTDynPt : Dynamic point data, stored in IGB_Vec3_f format
* - FTfileSeqCG: Cool Graphics format of one ascii file per time, with the
* first line of the form <TT> t = [0-9]+</TT>. Files are named
* <TT>basename.t[0-9]+</TT>
......@@ -60,6 +61,19 @@ fileType FileTypeFinder ( const char *fn )
return FTIGB;
}
} else if ( strstr( fn, ".dynpt" ) != NULL ) {
IGBheader* head = new IGBheader( in );
int res = head->read();
gzclose( in );
if ( res || head->type()!=IGB_VEC3_f ) {
return FTascii;
} else {
delete head;
return FTDynPt;
}
} else { // might be a CG file sequence
const char* tpos = strrchr( fn, 't' ); // look for last "t" in the file name
......
/* \file Graph.cc
*
* A class for drawing simple 2D plots on linear x and y scales (for now)
* The graph widget can draw multiple sets. The first is the curret and
* the second is the time indicator. Sets 3--? are static sets.
* The graph widget can draw multiple sets.
* Sets greater than 0 are the static sets.
*/
#include "plottingwin.h"
#include "Graph.h"
......@@ -10,8 +10,6 @@
#include <FL/fl_ask.H>
#include <sstream>
#define MIN_STATIC_CURVE 2
const int setcolour[]=
{
FL_RED, FL_GREEN, FL_BLUE, FL_DARK_MAGENTA,
......@@ -98,20 +96,20 @@ clear_curves_cb( Fl_Widget *w )
Fl_Menu_Item graph_pop_menu[] = {
{ "reset view", 'r', (Fl_Callback *)reset_cb, 0, 0, 0, 0, 14, 56 },
{ "X range", 'x', (Fl_Callback *)xrange_cb, 0, 0, 0, 0, 14, 56 },
{ "Y range", 'y', (Fl_Callback *)yrange_cb, 0, 0, 0, 0, 14, 56 },
{ "toggle button display", 'b', (Fl_Callback *)but_disp_toggle_cb, 0, 0, 0, 0, 14, 56 },
{ "clear static curves", 'c', (Fl_Callback *)clear_curves_cb, 0, 0, 0, 0, 14, 56 },
{ "close", 'c', (Fl_Callback *)close_graph_cb, 0, 0, 0, 0, 14, 56 },
{0}
};
{ "reset view", 'r', (Fl_Callback *)reset_cb, 0, 0, 0, 0, 14, 56 },
{ "X range", 'x', (Fl_Callback *)xrange_cb, 0, 0, 0, 0, 14, 56 },
{ "Y range", 'y', (Fl_Callback *)yrange_cb, 0, 0, 0, 0, 14, 56 },
{ "toggle button display", 'b', (Fl_Callback *)but_disp_toggle_cb, 0, 0, 0, 0, 14, 56 },
{ "clear static curves", 'c', (Fl_Callback *)clear_curves_cb, 0, 0, 0, 0, 14, 56 },
{ "close", 'c', (Fl_Callback *)close_graph_cb, 0, 0, 0, 0, 14, 56 },
{0}
};
// menu to display mouse coordinates
Fl_Menu_Item graph_mouse_pos[] = {
{ "mouse position", 0, (Fl_Callback *)NULL },
{0}
};
{ "mouse position", 0, (Fl_Callback *)NULL },
{0}
};
// plot the entire data set
void Graph::reset_view(void)
......@@ -122,7 +120,11 @@ void Graph::reset_view(void)
}
// make a static copy of the current curve
/** make a static copy of the current curve, allocating the necessary
* memory to make the copy
*
* \param curve index to copy
*/
void Graph::copy_curve( int c )
{
......@@ -149,7 +151,7 @@ void Graph::copy_curve( int c )
// clear curves
void Graph :: clear_curves()
{
for ( int c=MIN_STATIC_CURVE; c<numset; c++ ) {
for ( int c=num_dyn; c<numset; c++ ) {
delete[] xv[c];
delete[] yv[c];
np[c] = 0;
......@@ -240,6 +242,8 @@ void Graph :: draw()
/** Set the data for a set
*
* to add a new set, set it to the next available set
*
* \note no memeory is allocated, only the pointers are copied
\param x abscissa vector
\param y ordinate vector
......@@ -265,11 +269,11 @@ Graph :: set_2d_data(const double *x, const double *y, int n, int setno, int i)
return 0;
}
//* rotate graph by 90 degrees
void
Graph :: rotate()
{
for( int i=MIN_STATIC_CURVE; i<numset; i++ ) {
for( int i=num_dyn; i<numset; i++ ) {
const double *t = xv[i];
xv[i] = yv[i];
yv[i] = t;
......@@ -372,8 +376,8 @@ int Graph::handle(int event)
return 0;
}
//! return the range currently plotted
/*!
/** return the range currently plotted
\param a minimum x value
\param b maximum x value
\param c minimum y value
......@@ -417,7 +421,7 @@ void Graph::write( ostream& of, int s )
}
/** convert device coordinates top world coordinates
/** convert device coordinates to world coordinates
*
* \param x0 device x coord
* \param y0 device y coord
......
......@@ -65,13 +65,14 @@ class Graph : public Fl_Widget
public:
//! The contructor
/*!
* \param X x-position
* \param Y y-position
* \param W width
* \param H height
* \param X x-position
* \param Y y-position
* \param W width
* \param H height
* \param dc number of dynamic curves
*/
Graph(int X,int Y,int W,int H) : Fl_Widget(X,Y,W,H),v_autoscale(true),
numset(0){}
Graph(int X,int Y,int W,int H) : Fl_Widget(X,Y,W,H),
v_autoscale(true), numset(0){}
int set_2d_data(const double *, const double *, int n, int c, int id=-1 );
void reset_view( void );
void range( double &, double &, double &, double& );
......@@ -85,17 +86,19 @@ class Graph : public Fl_Widget
void to_world( int x, int y, double &wx, double &wy );
void rotate();
int id( int a ){ if(a<numset)return _id[a]; }
void num_dynamic( int a ){ num_dyn=a; }
private:
const double *xv[max_num_sets], *yv[max_num_sets];
double x0, x1, y0, y1; // data range being plotted
double xmin, xmax, ymin, ymax; // data extrema
int np[max_num_sets]; // #points/set
int _id[max_num_sets]; // identifier of set
int _id[max_num_sets]; // identifier of set
int numset;
char xlabel[num_labels][25], ylabel[num_labels][25];
void change_view( int, int, int, int );
void make_labels(void);
bool v_autoscale; // autoscale with set change
bool v_autoscale; // autoscale with set change
int num_dyn; //!< \# non-static curves
};
#endif
......@@ -332,6 +332,7 @@ class IGBheader
* \param dp data buffer
* \param numt \#time slices
* \param h IGB header
* \param buf temporary storage for a slice
*
* \return number of elements read
*/
......
......@@ -8,14 +8,14 @@ class IGBreader : public DataReader<T>
{
public:
IGBreader( Master<T>* _mthread, Slave<T>* _sthread, Maxmin<T>* _maxmin_ptr );
IGBreader(Master<T>* _mthread, Slave<T>* _sthread, Maxmin<T>* _maxmin_ptr);
~IGBreader();
virtual void reader();
virtual void local_maxmin();
virtual void tmsr();
virtual void find_maxtm();
float dt(void){return head->inc_t();}
float org_t(void){return head->org_t();}
virtual void find_maxtm();
float dt(void){return head->inc_t();}
float org_t(void){return head->org_t();}
private:
using DataReader<T>:: mthread;
......@@ -23,9 +23,9 @@ class IGBreader : public DataReader<T>
using DataReader<T>:: maxmin_ptr;
using DataReader<T>:: data;
using DataReader<T>:: in;
char* buf;
int slsz; //!< size of slice in bytes
IGBheader* head;
char* buf;
int slsz; //!< size of slice in bytes
IGBheader* head;
};
template<class T>
......@@ -63,7 +63,7 @@ IGBreader<T>::~IGBreader()
}
/** read in a particular time which is specidfied in the slave thread */
/** read in a particular time which is specified in the slave thread */
template<class T>
void IGBreader<T>::reader()
{
......
......@@ -3,7 +3,7 @@ HOSTMACHINE := $(shell uname)
FLTK_INC := $(shell fltk-config --use-gl --cxxflags)
FLTK_LD_FLAGS := $(shell fltk-config --use-images --use-gl --ldflags)
COMMON_LIBS = -lpng -lpthread -lm -lz
COMMON_INC = -I. -O3 -g -DOBJ_CLASS -D_REENTRANT -MMD -DNOMINMAX
COMMON_INC = -I. -O0 -g -DOBJ_CLASS -D_REENTRANT -MMD -DNOMINMAX
ifeq ($(HOSTMACHINE),Darwin)
LIBS = $(FLTK_LD_FLAGS) $(COMMON_LIBS)
......
......@@ -795,10 +795,8 @@ void Model::hilight_info( HiLiteInfoWin* hinfo, int* hilight, DATA_TYPE* data )
sprintf( txt, "value: %f", data[hilight[Vertex]] );
hinfo->add( txt );
}
const GLfloat*offset = pt.offset();
sprintf( txt, "( %.6g, %.6g, %.6g )", pt.pt()[hilight[Vertex]*3]+offset[0],
pt.pt()[hilight[Vertex]*3+1]+offset[1],
pt.pt()[hilight[Vertex]*3+2]+offset[2]);
sprintf( txt, "( %.6g, %.6g, %.6g )", pt.pt()[hilight[Vertex]*3],
pt.pt()[hilight[Vertex]*3+1], pt.pt()[hilight[Vertex]*3+2]);
hinfo->add( txt );
/*
string reginfo( "in surface: " );
......@@ -1144,8 +1142,7 @@ Model::surfKill( int s )
*
* \return
*/
bool Model :: read_instance( gzFile pt_in, gzFile elem_in,
const GLfloat* offset )
bool Model :: read_instance( gzFile pt_in, gzFile elem_in )
{
// read in points
if( pt_in != NULL ) {
......@@ -1154,10 +1151,8 @@ bool Model :: read_instance( gzFile pt_in, gzFile elem_in,
GLfloat *p = new GLfloat[num_pt*3];
for( int i=0; i< num_pt; i++ ) {
sscanf( get_line(pt_in), "%f %f %f", p+i*3, p+i*3+1, p+i*3+2 );
sub( p+i*3, offset, p+i*3 ); // center wrt fixed model
}
pt.add( p, num_pt );
pt.offset( offset );
pt.setVis( true );
delete[] p;
}
......
......@@ -21,7 +21,7 @@ class Model
Model();
~Model();
bool read(const char *fn, bool base1, bool no_elems);
bool read_instance( gzFile, gzFile, const GLfloat * );
bool read_instance( gzFile, gzFile );
int add_surface_from_tri( const char * );
int add_surface_from_surf( const char * );
int add_region_surfaces( void );
......
......@@ -10,6 +10,8 @@
* \param t current time
* \param xd abscissa
* \param torg initial time
*
* \note memory is allocated to hold the data
*/
void PlotWin :: set_data( int n, int id, double *d, int t, float dt,
float torg, double *xd )
......@@ -44,6 +46,8 @@ void PlotWin :: set_data( int n, int id, double *d, int t, float dt,
* \param t current time
* \param xd abscissa
* \param torg initial time
*
* \note memory is allocated to hold the data
*/
void PlotWin :: set_data( int id, int n, float *d, int t, float dt, float torg,
float *xd )
......@@ -111,6 +115,7 @@ void PlotWin :: rotate( bool a )
highlight();
}
}
#include <fstream>
void PlotWin :: writedata()
{
......
......@@ -68,12 +68,13 @@ void PPoint::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
}
} else { // all same colour
glColor4fv( colour );
for (int i=p0; i<=p1; i+=stride )
for (int i=p0; i<=p1; i+=stride ){
if ( (*_visible)[i] )
if( _3D )
draw_sphere( _pts+3*i, _size );
else
glVertex3fv( _pts+3*i );
}
}
glEnd();
......@@ -153,8 +154,8 @@ bool PPoint :: read( const char *fname )
// centre the model about the origin
for ( int ti=0; ti<3; ti++ ) _offset[ti] = (min[ti]+max[ti])/2;
for ( int i=0; i<3*_n; i+=3 )
for ( int ti=0; ti<3; ti++ ) _pts[i+ti] -= _offset[ti];
//for ( int i=0; i<3*_n; i+=3 )
//for ( int ti=0; ti<3; ti++ ) _pts[i+ti] -= _offset[ti];
gzclose(in);
_allvis.resize( _n );
......@@ -179,3 +180,48 @@ PPoint :: add( GLfloat *p, int n )
_allvis.assign( _n, true );
setVis( true );
}
/** make the points dynamic
*
* \param fn the name of the dynamic points file
* \param ntm the number of times currently loaded
*
* \retval 0 success
* \retval 1 invalid file
* \retval 2 incompatible number of points
*/
int
PPoint :: dynamic( const char *fn, int ntm )
{
ThreadedData<float>* newDynPt;
try{
newDynPt = new ThreadedData<float>( fn, _n*3, false );
}
catch(...) {
return 1;
}
if( ntm==1 || ntm==0 || ( newDynPt->max_tm()+1==ntm ) ) {
delete _dynPt;
_dynPt = newDynPt;
return 0;
} else
return 2;
}
/** set points to the current time
*
* \param a the time
*
* \note if the requested time is greater than the maximum and the
* maximum is greater than 0, it is an error
*/
void PPoint :: time( int a )
{
if( _dynPt==NULL || a==_tm || a>_dynPt->max_tm() ) return;
if( _pts = _dynPt->slice( a ) )
_tm = a;
}
......@@ -771,6 +771,8 @@ void TBmeshWin :: read_model( Fl_Window *flwindow, const char* fnt,
float maxdim = model->maxdim();
trackball.mouse.SetOglPosAndSize(-maxdim, maxdim, 2*maxdim, 2*maxdim );
trackball.size = maxdim;
const GLfloat *poff = model->pt_offset();
trackball.SetOrigin( -poff[0], -poff[1], -poff[2] );
cplane->set_dim( maxdim*1.3 );
if( model->twoD() ){
......@@ -856,7 +858,7 @@ DataReaderEnum TBmeshWin::getReaderType( const char *fn )
int getNumberTimes( const char * );
long long memoryAvail = getFreePages() +
numframes*model->pt.num()*sizeof(DATA_TYPE)/getpagesize();
numframes*model->pt.num()*sizeof(DATA_TYPE)/getpagesize();
long long memreq = getNumberTimes( fn );
......@@ -894,7 +896,7 @@ void TBmeshWin :: get_data( const char *fn, Myslider *mslide )
}
if( max_time(ScalarDataGrid)>0 && newDataBuffer->max_tm()>0 &&
newDataBuffer->max_tm()!=max_time() ) {
newDataBuffer->max_tm()!=max_time() ) {
fl_alert("%s","Incompatible number of frames in data" );
delete newDataBuffer;
return;
......@@ -1191,7 +1193,7 @@ TBmeshWin::getVecData( void *vp, char* vptfile )
VecData* newvd;
try {
newvd = new VecData( model->pt_offset(), vptfile );
newvd = new VecData( vptfile );
} catch (...) {
return 1;
}
......@@ -1221,7 +1223,7 @@ TBmeshWin::readAuxGrid( void *vp, char* agfile )
AuxGrid* newAuxGrid;
try {
newAuxGrid = new AuxGrid( agfile, model->pt_offset() );
newAuxGrid = new AuxGrid( agfile );
} catch (...) {
return 1;
}
......@@ -1245,7 +1247,7 @@ TBmeshWin::readAuxGrid( void *vp, char* agfile )
/** return maximum time to display
*
* \note There are 3 grids which must all agree on the number of time
* \note There are possibly 4 grids which must all agree on the number of time
* instances. Grids with no data or only 1 instance of data
* are compatible with any number of time frames since they are
* static
......@@ -1261,6 +1263,9 @@ int TBmeshWin::max_time( GridType ignore )
if( ignore!=AuxDataGrid && auxGrid && auxGrid->num_tm()>0 )
return auxGrid->num_tm()-1;
if( ignore!=DynPtGrid && DynPtGrid && model->pt.num_tm()>0 )
return model->pt.num_tm()-1;
return 0;
}
......@@ -1925,4 +1930,35 @@ TBmeshWin:: set_time(int a)
contwin->auxmincolval->value( auxGrid->cs.min() );
contwin->auxmaxcolval->value( auxGrid->cs.max() );
}
if( model->pt.num_tm() )
model->pt.time(tm);
}
/** read in the dynamic points file
*
* \param fn the file name
*
* \return nonzero on failure
*
* \note the dynamic points file is an IGB file of data type IBG_VEC3_f
*/
int
TBmeshWin :: read_dynamic_pts( const char *fn, Myslider *mslide )
{
int retval = model->pt.dynamic( fn, numframes );
if( retval == 2 ) {
fl_alert( "Incompatible number of time frames\n" );
return 1;
}
if( retval )
return 1;
model->pt.time(tm);
mslide->maximum( max_time() );
numframes = mslide->maximum()+1;
mslide->redraw();
return 0;
}
......@@ -30,7 +30,7 @@ class DataOpacity;
class ClipPlane;
class IsosurfControl;
enum GridType { ScalarDataGrid, VecDataGrid, AuxDataGrid, NoDataGrid };
enum GridType { ScalarDataGrid, VecDataGrid, AuxDataGrid, DynPtGrid, NoDataGrid };
class TBmeshWin:public Fl_Gl_Tb_Window
{
......@@ -126,6 +126,7 @@ class TBmeshWin:public Fl_Gl_Tb_Window
int ProcessLinkMessage(const LinkMessage::CommandMsg& msg);
void SendViewportSyncMessage();
void SendTimeSyncMessage();
int read_dynamic_pts( const char *, Myslider * );
private:
int hilight[maxobject]; // which object to highlight
......@@ -177,7 +178,7 @@ class TBmeshWin:public Fl_Gl_Tb_Window
CutSurfaces **_cutsurface; // clipped surfaces
IsoSurface *iso0, *iso1;
IsoLine *isoline;
set<int> timeLinks; // other meshalyzer processes linked to this one
set<int> timeLinks; // other processes linked to this one
bool bgd_trans; //!< transparent background
bool _norot; //!< allow rotations
float _dt; //!< increment between time slices
......
......@@ -33,9 +33,9 @@ class Maxmin
Maxmin():sl_ptr(NULL), lmax(NULL), lmin(NULL), lv_bit(NULL), read(false),
v_bit_local(false), v_bit_abs(false), num_slc(0){}
~Maxmin();
bool read; //!< offsets calculated
bool read; //!< offsets calculated
z_off_t** sl_ptr; //!< Slice pointer (byte offset)
int num_slc; //!< number of time slices