26 #include <vapor/XmlNode.h>
27 #include <vapor/ExpatParseMgr.h>
28 #include <vapor/ParamNode.h>
29 #include <vapor/common.h>
31 #include <vapor/RegularGrid.h>
36 using namespace VetsUtil;
38 #define ROUND_OFF 1.e-6f
40 #define OUT_OF_BOUNDS -1.e30f
64 class TransferFunction;
65 class ViewpointParams;
83 XmlNode *parent,
const string &name,
int winNum
88 if(winNum < 0) local =
false;
else local =
true;
104 virtual const std::string& getShortName()=0;
111 return currentParamsInstance[make_pair(pType,winnum)];
119 return GetCurrentParamsInstanceIndex(GetTypeFromTag(tag),winnum);
127 currentParamsInstance[make_pair(pType,winnum)] = instance;
136 static Params* GetParamsInstance(
int pType,
int winnum = -1,
int instance = -1);
145 return GetParamsInstance(GetTypeFromTag(tag), winnum, instance);
153 Params* p = GetParamsInstance(pType, winnum, -1);
155 return GetDefaultParams(pType);
163 return defaultParamsInstance[pType];
172 return defaultParamsInstance[GetTypeFromTag(tag)];
180 defaultParamsInstance[pType] = p;
189 defaultParamsInstance[GetTypeFromTag(tag)] = p;
206 return paramsInstances[make_pair(pType, winnum)].size();
216 return GetNumParamsInstances(GetTypeFromTag(tag), winnum);
225 paramsInstances[make_pair(pType,winnum)].push_back(p);
235 AppendParamsInstance(GetTypeFromTag(tag),winnum, p);
243 static void RemoveParamsInstance(
int pType,
int winnum,
int instance);
252 vector<Params*>& instances = paramsInstances[make_pair(pType,winnum)];
253 instances.insert(instances.begin()+posn, dp);
262 return paramsInstances[make_pair(pType,winnum)];
272 return GetAllParamsInstances(GetTypeFromTag(tag),winnum);
279 static map <int, vector<Params*> >* cloneAllParamsInstances(
int winnum);
285 static vector <Params*>* cloneAllDefaultParams();
290 static bool IsRenderingEnabled(
int winnum);
303 virtual void restart() = 0;
325 virtual void SetVisualizerNum(
int viznum);
326 virtual int GetVisualizerNum();
333 virtual bool reinit(
bool) {
return false;}
353 {
if (!rotated) calcStretchedBoxExtentsInCube(extents, -1);
354 else calcRotatedStretchedBoxExtentsInCube(extents);}
356 void calcRotatedStretchedBoxExtentsInCube(
float extents[6]);
366 #ifndef DOXYGEN_SKIP_THIS
367 void setLocalBox(
const float boxMin[3],
const float boxMax[3],
int timestep = -1 ) {
375 for (
int i = 0; i<3; i++){
376 extents[i] = boxMin[i];
377 extents[i+3] = boxMax[i];
379 GetBox()->SetLocalExtents(extents,timestep);
381 void setLocalBox(
const double boxMin[3],
const double boxMax[3],
int timestep = -1 ) {
383 for (
int i = 0; i<3; i++){
384 extents[i] = boxMin[i];
385 extents[i+3] = boxMax[i];
387 GetBox()->SetLocalExtents(extents,timestep);
390 void mapBoxToVox(DataMgr* dataMgr,
double bxmin[3],
double bxmax[3],
int refLevel,
int lod,
size_t timestep,
size_t voxExts[6]);
391 void setTheta(
float th) {
393 GetBox()->GetAngles(angles);
395 GetBox()->SetAngles(angles);
397 void setPhi(
float ph) {
399 GetBox()->GetAngles(angles);
401 GetBox()->SetAngles(angles);
403 void setPsi(
float ps) {
405 GetBox()->GetAngles(angles);
407 GetBox()->SetAngles(angles);
416 void getLocalBox(
float boxMin[3],
float boxMax[3],
int timestep = -1) {
418 GetBox()->GetLocalExtents(extents, timestep);
419 for (
int i = 0; i<3; i++){
420 boxMin[i] = extents[i];
421 boxMax[i] = extents[i+3];
424 void getLocalBox(
double boxMin[3],
double boxMax[3],
int timestep = -1) {
426 GetBox()->GetLocalExtents(extents, timestep);
427 for (
int i = 0; i<3; i++){
428 boxMin[i] = extents[i];
429 boxMax[i] = extents[i+3];
434 if (GetBox()->GetAngles().size() < 2)
return 0.f;
435 return((
float)GetBox()->GetAngles()[1]);
438 if (GetBox()->GetAngles().size() < 1)
return 0.f;
439 return((
float)GetBox()->GetAngles()[0]);
442 if (GetBox()->GetAngles().size() < 3)
return 0.f;
443 return((
float)GetBox()->GetAngles()[2]);
446 static Params* CreateDummyParams(std::string tag);
447 static void BailOut (
const char *errstr,
const char *fname,
int lineno);
449 static int getNumDummyClasses(){
return dummyParamsInstances.size();}
450 static Params* getDummyParamsInstance(
int i) {
return dummyParamsInstances[i];}
451 static void addDummyParamsInstance(Params*
const & p ) {dummyParamsInstances.push_back(p);}
453 static void clearDummyParamsInstances();
454 static const std::string& paramName(ParamsBaseType t);
455 static const string _dvrParamsTag;
456 static const string _isoParamsTag;
458 static const string _probeParamsTag;
459 static const string _twoDParamsTag;
460 static const string _twoDDataParamsTag;
461 static const string _twoDImageParamsTag;
462 static const string _regionParamsTag;
463 static const string _viewpointParamsTag;
464 static const string _animationParamsTag;
465 static const string _flowParamsTag;
466 static const string _RefinementLevelTag;
467 static const string _CompressionLevelTag;
468 static const string _FidelityLevelTag;
469 static const string _IgnoreFidelityTag;
470 static const string _VariableNameTag;
471 static const string _VariableNamesTag;
472 static const string _VisualizerNumTag;
473 static const string _VariablesTag;
474 static const string _Variables2DTag;
475 static const string _Variables3DTag;
477 static const string _vizNumAttr;
478 static const string _localAttr;
479 static const string _numVariablesAttr;
480 static const string _variableTag;
481 static const string _leftEditBoundAttr;
482 static const string _rightEditBoundAttr;
483 static const string _variableNumAttr;
484 static const string _variableNameAttr;
485 static const string _opacityScaleAttr;
486 static const string _numTransformsAttr;
487 static const string _useTimestepSampleListAttr;
488 static const string _timestepSampleListAttr;
491 void setStretchedBox(
const float[3],
const float[3],
int);
492 void getStretchedBox(
float boxmin[3],
float boxmax[3],
int timestep);
494 void calcStretchedBoxExtentsInCube(
float extents[6],
int timestep);
496 void calcStretchedBoxExtents(
float* extents,
int timestep);
497 void calcBoxExtents(
float* extents,
int timestep);
499 virtual void calcLocalBoxCorners(
float corners[8][3],
float extraThickness,
int timestep,
float rotation = 0.f,
int axis = -1);
503 void buildLocalCoordTransform(
float transformMatrix[12],
float extraThickness,
int timestep,
float rotation = 0.f,
int axis = -1);
504 void buildLocalCoordTransform(
double transformMatrix[12],
double extraThickness,
int timestep,
float rotation = 0.f,
int axis = -1);
508 void buildLocal2DTransform(
int dataOrientation,
float a[2],
float b[2],
float* constVal,
int mappedDims[3]);
512 virtual bool isPlanar() {
return false;}
518 static float distanceToCube(
const float point[3],
const float faceNormals[6][3],
const float faceCorners[6][3]);
521 static float distancesToCube(
const float point[3],
const float faceNormals[6][3],
const float faceCorners[6][3],
float maxDist[3]);
527 static bool searchCmdLine(
const char *flag);
528 static const char* parseCmdLine(
const char *flag);
532 void convertThetaPhiPsi(
float *newTheta,
float* newPhi,
float* newPsi,
int axis,
float rotation);
533 static int getGrids(
size_t ts,
const vector<string>& varnames,
double extents[6],
int* refLevel,
int* lod,
RegularGrid** grids);
542 double savedBoxExts[6];
543 int savedBoxVoxExts[6];
547 static map<pair<int,int>,vector<Params*> > paramsInstances;
549 static map<pair<int,int>,
int> currentParamsInstance;
553 static map<int, Params*> defaultParamsInstance;
554 static vector<Params*> dummyParamsInstances;
555 #endif //DOXYGEN_SKIP_THIS
580 virtual void setEnabled(
bool value) {enabled = value; stopFlag =
false;}
585 virtual bool usingVariable(
const std::string& varname) = 0;
587 GetRootNode()->SetElementLong(_RefinementLevelTag, level);
591 const vector<long>defaultRefinement(1,0);
592 return (GetRootNode()->GetElementLong(_RefinementLevelTag,defaultRefinement)[0]);
597 virtual int GetCompressionLevel();
601 virtual int GetFidelityLevel();
605 virtual void SetFidelityLevel(
int level);
609 virtual bool GetIgnoreFidelity();
613 virtual void SetIgnoreFidelity(
bool val);
617 virtual void SetCompressionLevel(
int val);
632 static float getCameraDistance(
ViewpointParams* vpp,
const double exts[6]);
636 virtual bool IsOpaque()=0;
642 void setBypass(
int timestep) {bypassFlags[timestep] = 2;}
654 void setAllBypass(
bool val);
659 bool doBypass(
int ts) {
return ((ts < bypassFlags.size()) && bypassFlags[ts]);}
665 bool doAlwaysBypass(
int ts) {
return ((ts < bypassFlags.size()) && bypassFlags[ts]>1);}
673 #ifndef DOXYGEN_SKIP_THIS
692 minColorEditBounds = 0;
693 maxColorEditBounds = 0;
694 minOpacEditBounds = 0;
695 maxOpacEditBounds = 0;
698 virtual ~RenderParams(){
699 if (minColorEditBounds)
delete [] minColorEditBounds;
700 if (maxColorEditBounds)
delete [] maxColorEditBounds;
701 if (minOpacEditBounds)
delete [] minOpacEditBounds;
702 if (maxOpacEditBounds)
delete [] maxOpacEditBounds;
706 virtual Params* deepCopy(ParamNode* nd = 0);
707 virtual bool isRenderParams() {
return true;}
710 virtual void setLocal(
bool ){ assert(0);}
712 virtual int getSessionVarNum(){assert(0);
return -1;}
713 virtual float GetHistoStretch() { assert(0);
return 1.f;}
714 virtual bool getEditMode() {assert(0);
return true;}
715 virtual const float* getCurrentDatarange(){assert(0);
return(0);}
716 virtual void hookupTF(TransferFunction* ,
int ) {assert(0);}
720 virtual void setMinColorMapBound(
float) {assert(0);}
721 virtual void setMaxColorMapBound(
float){assert(0);}
722 virtual void setMinOpacMapBound(
float){assert(0);}
723 virtual void setMaxOpacMapBound(
float){assert(0);}
726 float getMinColorMapBound();
727 float getMaxColorMapBound();
729 virtual void setMinColorEditBound(
float val,
int var) {
730 minColorEditBounds[var] = val;
732 virtual void setMaxColorEditBound(
float val,
int var) {
733 maxColorEditBounds[var] = val;
735 virtual float getMinColorEditBound(
int var) {
736 return minColorEditBounds[var];
738 virtual float getMaxColorEditBound(
int var) {
739 return maxColorEditBounds[var];
743 virtual float getMinOpacMapBound();
744 virtual float getMaxOpacMapBound();
747 virtual void setMinOpacEditBound(
float val,
int var) {
748 minOpacEditBounds[var] = val;
750 virtual void setMaxOpacEditBound(
float val,
int var) {
751 maxOpacEditBounds[var] = val;
753 virtual float getMinOpacEditBound(
int var) {
754 return minOpacEditBounds[var];
756 virtual float getMaxOpacEditBound(
int var) {
757 return maxOpacEditBounds[var];
760 virtual MapperFunction* GetMapperFunc() {
return 0;}
762 void setStopFlag(
bool val =
true) {stopFlag = val;}
763 bool getStopFlag() {
return stopFlag;}
764 int getBypassValue(
int i) {
return bypassFlags[i];}
766 void initializeBypassFlags();
768 bool cropToBox(
const double boxExts[6]);
769 bool intersectRotatedBox(
double boxexts[6],
double pointFound[3],
double probeCoords[2]);
770 bool fitToBox(
const double boxExts[6]);
771 int interceptBox(
const double boxExts[6],
double intercept[6][3]);
773 void rotateAndRenormalizeBox(
int axis,
float rotVal);
775 void getLocalContainingRegion(
float regMin[3],
float regMax[3]);
776 void getRotatedVoxelExtents(
float voxdims[2]);
778 void calcSliceHistogram(
int ts, Histo* histo);
780 virtual int getInterpolationOrder() {
return 1;}
789 float* minColorEditBounds;
790 float* maxColorEditBounds;
791 float* minOpacEditBounds;
792 float* maxOpacEditBounds;
794 vector<int> bypassFlags;
795 #endif //DOXYGEN_SKIP_THIS
797 #ifndef DOXYGEN_SKIP_THIS
798 class DummyParams :
public Params {
800 DummyParams(XmlNode *parent,
const std::string tag,
int winnum);
801 virtual ~DummyParams(){}
802 virtual void restart(){}
803 virtual int GetRefinementLevel() {
807 virtual int GetCompressionLevel() {
return 0;}
809 virtual void SetCompressionLevel(
int){}
811 virtual bool reinit(
bool){
return false;}
813 virtual bool IsOpaque() {
return true;}
815 virtual bool usingVariable(
const std::string& ){
818 const std::string &getShortName(){
return myTag;}
826 Point4() {point[0]=point[1]=point[2]=point[3]=0.f;}
827 Point4(
const float data[4]){setVal(data);}
828 void setVal(
const float sourceData[4]){
829 for (
int i = 0; i< 4; i++) point[i] = sourceData[i];
831 void set3Val(
const float sourceData[3]){
832 for (
int i = 0; i< 3; i++) point[i] = sourceData[i];
834 void set1Val(
int index,
float sourceData){
835 point[index] = sourceData;
837 float getVal(
int i){
return point[i];}
838 void copy3Vals(
float* dest) {dest[0]=point[0];dest[1]=point[1];dest[2]=point[2];}
842 #endif //DOXYGEN_SKIP_THIS
static void AppendParamsInstance(const std::string tag, int winnum, Params *p)
static Params * CreateDefaultParams(int pType)
virtual void setVizNum(int vnum)
3D or 2D box with options for orientation angles and extents changing in time. Intended to be used in...
A pure virtual class for managing parameters used in visualization.
virtual const float * getSelectedPointLocal()
A Params subclass for managing parameters used by Renderers.
static int GetCurrentParamsInstanceIndex(const std::string tag, int winnum)
virtual bool isDomainConstrained()
bool doAlwaysBypass(int ts)
static Params * GetParamsInstance(const std::string tag, int winnum=-1, int instance=-1)
virtual bool UsesMapperFunction()
static Params * GetCurrentParamsInstance(int pType, int winnum)
virtual int getOrientation()
Region bit indicates the region bounds have changed.
static int GetNumParamsInstances(int pType, int winnum)
A class for describing a 3D axis-aligned region in user space.
Nodes with state in Xml tree representation.
static void InsertParamsInstance(int pType, int winnum, int posn, Params *dp)
This class implements a 2D or 3D regular grid: a tessellation of Euculidean space by rectangles (2D) ...
static void SetCurrentParamsInstanceIndex(int pType, int winnum, int instance)
static Params * GetDefaultParams(ParamsBase::ParamsBaseType pType)
static void SetDefaultParams(const string &tag, Params *p)
virtual void calcContainingStretchedBoxExtentsInCube(float extents[6], bool rotated=false)
virtual void setLocal(bool lg)
A class for describing the viewpoint and lights.
virtual bool reinit(bool)
NavigatingBit indicates the viewpoint is currently moving.
LightingBit indicates there has been a change in lighting.
Params(int winNum, const string &name)
Deprecated constructor, needed for built-in classes that do not have associated XML node: ...
virtual bool isRenderParams()
virtual void SetRefinementLevel(int level)
virtual void setEnabled(bool value)
virtual int GetRefinementLevel()
static vector< Params * > & GetAllParamsInstances(const std::string tag, int winnum)
void setBypass(int timestep)
ProjMatrixBit indicates there has been a change in the projection matrix (e.g. viewpoint change) ...
void setPartialBypass(int timestep)
static Params * GetDefaultParams(const string &tag)
static int GetNumParamsInstances(const std::string tag, int winnum)
static void SetDefaultParams(int pType, Params *p)
static int GetCurrentParamsInstanceIndex(int pType, int winnum)
static vector< Params * > & GetAllParamsInstances(int pType, int winnum)
static void AppendParamsInstance(int pType, int winnum, Params *p)
ViewportBit indicates a change in viewport, e.g. resize of window.
AnimationBit indicates a change in current frame.