Commit a57fad25 authored by Edward Vigmond's avatar Edward Vigmond

Can now set colour of drawing objets whose data falls out of a specified...

Can now set colour of drawing objets whose data falls out of a specified range. This is convenient for dealing with nodes where no data is present and a placeholder value is used.
parent 43447409
#include "Colourscale.h"
Colourscale :: Colourscale( int ts, CScale_t tcs ) : n(0), mindat(0.),maxdat(1.)
Colourscale :: Colourscale( int ts, CScale_t tcs ) : n(0), mindat(0.),maxdat(1.),
_deadRange(NO_DEAD), _deadColour({0.,0.,0.,1.}),_deadMin(0.), _deadMax(1.)
{
scaletype = tcs;
size( ts );
......@@ -186,12 +187,6 @@ void Colourscale :: scale( CScale_t cs )
cmap[i][0] = cmap[i][1] = 0;
}
break;
case CS_IGREY: /* bw */
for ( i=0; i<n; i++ ) {
cmap[i][0] = cmap[i][2] = 0.0;
cmap[i][1] = ((float)i)/ispan;
}
break;
case CS_HOT:
intrvl = roundf(ispan/3.);
for ( i=0; i<intrvl; i++ ) {
......@@ -403,6 +398,12 @@ void Colourscale :: scale( CScale_t cs )
void Colourscale :: colourize( float val )
{
if( ( _deadRange==DEAD_MIN && val<_deadMin ) ||
( _deadRange==DEAD_MAX && val>_deadMax ) ||
( _deadRange==DEAD_RANGE && (val<_deadMin||val>_deadMax) ) ) {
glColor4fv( _deadColour );
return;
}
int indx=int(rint(a*val+b));
if ( indx<0 ) indx = 0;
else if ( indx>=n ) indx = n-1;
......@@ -412,6 +413,12 @@ void Colourscale :: colourize( float val )
void Colourscale :: colourize( float val, float alpha )
{
if( ( _deadRange==DEAD_MIN && val<_deadMin ) ||
( _deadRange==DEAD_MAX && val>_deadMax ) ||
( _deadRange==DEAD_RANGE && (val<_deadMin||val>_deadMax) ) ) {
glColor4fv( _deadColour );
return;
}
int indx=int(rint(a*val+b));
if ( indx<0 ) indx = 0;
else if ( indx>=n ) indx = n-1;
......@@ -438,6 +445,11 @@ void Colourscale :: size( int s )
GLfloat* Colourscale :: colorvec( double val )
{
if( ( _deadRange==DEAD_MIN && val<_deadMin ) ||
( _deadRange==DEAD_MAX && val>_deadMax ) ||
( _deadRange==DEAD_RANGE && (val<_deadMin||val>_deadMax) ) ) {
return _deadColour;
}
int indx=int(rint(a*val+b));
if ( indx<0 ) indx = 0;
else if ( indx>=n ) indx = n-1;
......@@ -470,3 +482,19 @@ Colourscale :: output_png( const char *filename )
}
cbar.write( buffer, 1 );
}
void
Colourscale::deadColour( GLfloat *dc, GLfloat dopac )
{
memcpy( _deadColour, dc, 3*sizeof(GLfloat) );
_deadColour[3] = dopac;
}
void
Colourscale::deadRange( double min, double max, DeadRange dr )
{
_deadMin = min;
_deadMax = max;
_deadRange = dr;
}
......@@ -10,10 +10,14 @@
#include "PNGwrite.h"
typedef enum {
CS_HOT, CS_GREY, CS_RGREY, CS_GGREY, CS_BGREY, CS_IGREY, CS_RAINBOW, CS_BL_RAINBOW,
CS_HOT, CS_GREY, CS_RGREY, CS_GGREY, CS_BGREY, CS_RAINBOW, CS_BL_RAINBOW,
CS_COLD_HOT, CS_CG, CS_MATLAB_REV, CS_MATLAB, CS_ACID, CS_P2G, CS_VIRIDIS, CS_VIRIDIS_LIGHT
} CScale_t;
typedef enum {
NO_DEAD, DEAD_MIN, DEAD_MAX, DEAD_RANGE
} DeadRange;
class Colourscale
{
public:
......@@ -26,16 +30,25 @@ class Colourscale
void colourize( float ); // colour vector for data value
void colourize( float, float ); // same as above, specify alpha
inline int size(){ return n; } // get the size
void size( int ); // set the size
inline GLfloat* entry(int a){return cmap[a];} // return an entry
void size( int ); // set the size
inline GLfloat* entry(int a){return cmap[a];} // return an entry
GLfloat *colorvec( double );
void output_png( const char * ); // output the map
void output_png( const char * ); // output the map
void deadColour( GLfloat *, GLfloat );
GLfloat *deadColour(){return _deadColour;}
void deadRange( double min, double max, DeadRange dr=DEAD_RANGE );
void deadRange( void ){_deadRange=NO_DEAD;};
void get_deadRange( double &min, double &max, DeadRange &dr )
{ min=_deadMin;max=_deadMax;dr=_deadRange;}
private:
GLfloat** cmap; // the map
int n; // size of map
double a, b; // map data to colour map
CScale_t scaletype;
double mindat, maxdat;
DeadRange _deadRange; // what to ignore
double _deadMin, _deadMax; // ignore below and above these values
GLfloat _deadColour[4]; // how to colour dead data
};
#endif
......
HOSTMACHINE := $(shell uname)
HDF5=1
#HDF5=1
include make.conf
......@@ -81,7 +81,7 @@ ifdef HDF5
endif
%.h %.cc: %.fl
fluid -c $<
fluid -c -o .cc $<
-include $(OBJS:.o=.d)
......
......@@ -113,7 +113,8 @@ TBmeshWin ::TBmeshWin(int x, int y, int w, int h, const char *l )
disp(asSurface),data(NULL),facetshading(false),numframes(0),
headlamp_mode(true),_cutsurface(new CutSurfaces*[NUM_CP] ),
iso0(NULL),iso1(NULL),isosurfwin(new IsosurfControl(this)),isoline(NULL),
bgd_trans(false),_norot(false),forcedThreaded(false),_branch_cut(false)
bgd_trans(false),_norot(false),forcedThreaded(false),_branch_cut(false),
deadData(new DeadDataGUI(this))
{
model = new Model();
memset( hilight, 0, sizeof(int)*maxobject );
......
......@@ -22,6 +22,7 @@
#include "IsoSurface.h"
#include "IsoLines.h"
#include "TimeLink.h"
#include "DeadDataGUI.h"
#ifdef USE_HDF5
#include "hdf5.h"
#endif
......@@ -214,6 +215,7 @@ class TBmeshWin:public Fl_Gl_Tb_Window
static unsigned int MAX_MESSAGES_READ;
bool _branch_cut;
double _branch_range[2];
DeadDataGUI *deadData;
};
#include "DataOpacity.h"
......
......@@ -861,7 +861,16 @@ the data colour scale, otherwise all lines are drawn with the same
specified ``colour''.
The thickness of the lines can also be controlled.
\subsection{Branch cut}
\subsubsection{Dead range}
Often, one does not have data for all vertices in the mesh and one uses a bogus placeholder value.
In this case, it is conventient to draw the nondatified objects in a different colour so that they stand out, or
not even draw them at all. We consider data outside of a specified range to be ``dead''. You can specifiy a \emph{minimum valid value} and any data below this
value will be considered dead. Likewise a \emph{maximum valid value} can be selected, or both. The colour and opacity of the dead vertices can be selected
arbitrarily.
The \emph{Apply} button must be pressed to enact the changes. \emph{Recalibrate} scales the colour scale for the nondead range.
\subsubsection{Branch cut}
Branch cuts represent discontinuities in the value of a function which are artificial.
An example is the branch cut in
......@@ -873,7 +882,8 @@ should not be interpolated to contain a zero value.
Choosing the appropriate branch cut range will ignore interpolation within such elements,
especially when calculating isolines and surfaces.
Four common ranges are available.
It is suggested that an appropriate colour scale is used which has the same value at the two extremes.
It is suggested that an appropriate colour scale is used which wraps around,
i.e., has the same value at the two extremes.
\subsection{Output Menu}
......
......@@ -76,7 +76,7 @@ class Controls {open
} {
Fl_Window window {
label {Meshalyzer Controls} open
xywh {1090 251 350 645} type Double box UP_BOX
xywh {614 257 350 645} type Double box UP_BOX
code0 {\#include <FL/Fl_Color_Chooser.H>}
code1 {\#include "VecData.h"} visible
} {
......@@ -84,7 +84,7 @@ class Controls {open
xywh {0 0 350 30} labelcolor 1
} {
Submenu {} {
label File open
label File
xywh {0 0 100 20}
} {
MenuItem {} {
......@@ -175,7 +175,7 @@ if( fn ) mwtb->read_dynamic_pts( fn, tmslider );}
label {Read HDF5 Data}
callback {\#ifdef USE_HDF5
HDF5DataBrowser *brow = new HDF5DataBrowser( fl_file_chooser("Choose HDF5 data file", "*.datH5", NULL ), mwtb );
\#endif} selected
\#endif}
xywh {0 0 30 20}
}
MenuItem read_recalibrate {
......@@ -464,7 +464,7 @@ mwtb->redraw();}
}
}
Submenu {} {
label Data
label Data open
xywh {0 0 100 20}
} {
MenuItem {} {
......@@ -482,8 +482,13 @@ mwtb->redraw();}
callback {mwtb->isosurfwin->isowin->show();}
xywh {0 0 31 20}
}
MenuItem {} {
label {Dead range}
callback {mwtb->deadData->window->show();}
xywh {0 0 34 20}
}
Submenu brcut {
label {Branch cut} open
label {Branch cut}
tooltip {Do not interpolqte betzeen limits} xywh {0 0 70 20}
} {
MenuItem brcutNone {
......@@ -782,7 +787,7 @@ op->win->show();}
xywh {260 165 70 25} labelsize 12
}
}
Fl_Tabs tabwidget {open
Fl_Tabs tabwidget {
xywh {10 270 330 220} align 0
} {
Fl_Group hilightgrp {
......@@ -1837,7 +1842,7 @@ hdfreadbut->deactivate();
}
decl {TBmeshWin *mwtb;} {private local
}
decl {Fl_Window* proginfo;} {public local
decl {Fl_Window* proginfo;} {selected public local
}
Function {pickcolor(Object_t obj, const char* wintitle )} {} {
code {bool* sel=regselected();
......@@ -2118,6 +2123,16 @@ save_colour( mshzf, mwtb->isosurfwin->issColor(0) );
mshzf << endl;
mshzf << "ISOSURF_COLOUR 1 = ";
save_colour( mshzf, mwtb->isosurfwin->issColor(1) );
mshzf << endl;
SAVE_WIDGET( mshzf, mwtb->deadData->minValid );
SAVE_WIDGET( mshzf, mwtb->deadData->minValidVal );
SAVE_WIDGET( mshzf, mwtb->deadData->maxValid );
SAVE_WIDGET( mshzf, mwtb->deadData->maxValidVal );
SAVE_WIDGET( mshzf, mwtb->deadData->deadopac );
SAVE_WIDGET( mshzf, mwtb->deadData->showDeadData );
mshzf << "DEAD_COLOUR = ";
save_colour( mshzf, mwtb->cs->deadColour() );
mshzf << endl;} {}
}
Function {save_colour( ofstream&ofs, const GLfloat *col )} {} {
......@@ -2143,7 +2158,8 @@ colourChoice *cc = new colourChoice( col, cs, msz, ot, mwtb );
cc->window->label(winlab);
cc->window->show();} {}
}
Function {restore_state(const char* fname=NULL)} {} {
Function {restore_state(const char* fname=NULL)} {open
} {
code {ifstream mshzf;
if( fname==NULL ) {
char *fn=fl_file_chooser("Meshalyzer state file", "*.mshz", NULL );
......@@ -2433,6 +2449,22 @@ while( mshzf.getline( buf, BUFLEN ) ) {
continue;
}
TEST_VAR( mwtb->deadData->minValid, var, val )
TEST_VAR( mwtb->deadData->minValidVal, var, val )
TEST_VAR( mwtb->deadData->maxValid, var, val )
TEST_VAR( mwtb->deadData->maxValidVal, var, val )
TEST_VAR( mwtb->deadData->deadopac, var, val )
TEST_VAR( mwtb->deadData->showDeadData, var, val )
if( !strcmp( var, "DEAD_COLOUR" ) ){
sscanf( buf, "%*s = %f %f %f %f", &r, &g, &b, &a );
mwtb->deadData->dead_color->rgb(r,g,b);
mwtb->deadData->dead_color->do_callback();
mwtb->deadData->deadApp->do_callback();
continue;
}
TEST_VAR( mwtb->deadData->minValid, var, val )
if( !strcmp( "BGD_COLOUR", var )) { mwtb->bgd(val); continue; }
cerr << "Unknown variable specified: " << var << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment