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>
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;
89 for (
int i = 0; i<6; i++) {
90 savedBoxVoxExts[i] =0;
109 virtual const std::string& getShortName()=0;
116 return currentParamsInstance[make_pair(pType,winnum)];
124 return GetCurrentParamsInstanceIndex(GetTypeFromTag(tag),winnum);
132 currentParamsInstance[make_pair(pType,winnum)] = instance;
141 static Params* GetParamsInstance(
int pType,
int winnum = -1,
int instance = -1);
150 return GetParamsInstance(GetTypeFromTag(tag), winnum, instance);
158 Params* p = GetParamsInstance(pType, winnum, -1);
160 return GetDefaultParams(pType);
168 return defaultParamsInstance[pType];
177 return defaultParamsInstance[GetTypeFromTag(tag)];
185 defaultParamsInstance[pType] = p;
194 defaultParamsInstance[GetTypeFromTag(tag)] = p;
211 return paramsInstances[make_pair(pType, winnum)].size();
221 return GetNumParamsInstances(GetTypeFromTag(tag), winnum);
230 paramsInstances[make_pair(pType,winnum)].push_back(p);
240 AppendParamsInstance(GetTypeFromTag(tag),winnum, p);
248 static void RemoveParamsInstance(
int pType,
int winnum,
int instance);
257 vector<Params*>& instances = paramsInstances[make_pair(pType,winnum)];
258 instances.insert(instances.begin()+posn, dp);
267 return paramsInstances[make_pair(pType,winnum)];
277 return GetAllParamsInstances(GetTypeFromTag(tag),winnum);
284 static map <int, vector<Params*> >* cloneAllParamsInstances(
int winnum);
290 static vector <Params*>* cloneAllDefaultParams();
295 static bool IsRenderingEnabled(
int winnum);
308 virtual void restart() = 0;
330 virtual void SetVisualizerNum(
int viznum);
331 virtual int GetVisualizerNum();
338 virtual bool reinit(
bool) {
return false;}
358 {
if (!rotated) calcStretchedBoxExtentsInCube(extents, -1);
359 else calcRotatedStretchedBoxExtentsInCube(extents);}
361 void calcRotatedStretchedBoxExtentsInCube(
float extents[6]);
371 #ifndef DOXYGEN_SKIP_THIS
372 void setLocalBox(
const float boxMin[3],
const float boxMax[3],
int timestep = -1 ) {
380 for (
int i = 0; i<3; i++){
381 extents[i] = boxMin[i];
382 extents[i+3] = boxMax[i];
384 GetBox()->SetLocalExtents(extents,timestep);
386 void setLocalBox(
const double boxMin[3],
const double boxMax[3],
int timestep = -1 ) {
388 for (
int i = 0; i<3; i++){
389 extents[i] = boxMin[i];
390 extents[i+3] = boxMax[i];
392 GetBox()->SetLocalExtents(extents,timestep);
395 void mapBoxToVox(DataMgr* dataMgr,
double bxmin[3],
double bxmax[3],
int refLevel,
int lod,
size_t timestep,
size_t voxExts[6]);
396 void setTheta(
float th) {
398 GetBox()->GetAngles(angles);
400 GetBox()->SetAngles(angles);
402 void setPhi(
float ph) {
404 GetBox()->GetAngles(angles);
406 GetBox()->SetAngles(angles);
408 void setPsi(
float ps) {
410 GetBox()->GetAngles(angles);
412 GetBox()->SetAngles(angles);
421 void getLocalBox(
float boxMin[3],
float boxMax[3],
int timestep = -1) {
423 GetBox()->GetLocalExtents(extents, timestep);
424 for (
int i = 0; i<3; i++){
425 boxMin[i] = extents[i];
426 boxMax[i] = extents[i+3];
429 void getLocalBox(
double boxMin[3],
double boxMax[3],
int timestep = -1) {
431 GetBox()->GetLocalExtents(extents, timestep);
432 for (
int i = 0; i<3; i++){
433 boxMin[i] = extents[i];
434 boxMax[i] = extents[i+3];
439 if (GetBox()->GetAngles().size() < 2)
return 0.f;
440 return((
float)GetBox()->GetAngles()[1]);
443 if (GetBox()->GetAngles().size() < 1)
return 0.f;
444 return((
float)GetBox()->GetAngles()[0]);
447 if (GetBox()->GetAngles().size() < 3)
return 0.f;
448 return((
float)GetBox()->GetAngles()[2]);
451 static Params* CreateDummyParams(std::string tag);
452 static void BailOut (
const char *errstr,
const char *fname,
int lineno);
454 static int getNumDummyClasses(){
return dummyParamsInstances.size();}
455 static Params* getDummyParamsInstance(
int i) {
return dummyParamsInstances[i];}
456 static void addDummyParamsInstance(Params*
const & p ) {dummyParamsInstances.push_back(p);}
458 static void clearDummyParamsInstances();
459 static const std::string& paramName(ParamsBaseType t);
460 static const string _dvrParamsTag;
461 static const string _isoParamsTag;
463 static const string _probeParamsTag;
464 static const string _twoDParamsTag;
465 static const string _twoDDataParamsTag;
466 static const string _twoDImageParamsTag;
467 static const string _regionParamsTag;
468 static const string _viewpointParamsTag;
469 static const string _animationParamsTag;
470 static const string _flowParamsTag;
471 static const string _RefinementLevelTag;
472 static const string _CompressionLevelTag;
473 static const string _FidelityLevelTag;
474 static const string _IgnoreFidelityTag;
475 static const string _VariableNameTag;
476 static const string _VariableNamesTag;
477 static const string _VisualizerNumTag;
478 static const string _VariablesTag;
479 static const string _Variables2DTag;
480 static const string _Variables3DTag;
482 static const string _vizNumAttr;
483 static const string _localAttr;
484 static const string _numVariablesAttr;
485 static const string _variableTag;
486 static const string _leftEditBoundAttr;
487 static const string _rightEditBoundAttr;
488 static const string _variableNumAttr;
489 static const string _variableNameAttr;
490 static const string _opacityScaleAttr;
491 static const string _numTransformsAttr;
492 static const string _useTimestepSampleListAttr;
493 static const string _timestepSampleListAttr;
496 void setStretchedBox(
const float[3],
const float[3],
int);
497 void getStretchedBox(
float boxmin[3],
float boxmax[3],
int timestep);
499 void calcStretchedBoxExtentsInCube(
float extents[6],
int timestep);
501 void calcStretchedBoxExtents(
float* extents,
int timestep);
502 void calcBoxExtents(
float* extents,
int timestep);
504 virtual void calcLocalBoxCorners(
float corners[8][3],
float extraThickness,
int timestep,
float rotation = 0.f,
int axis = -1);
508 void buildLocalCoordTransform(
float transformMatrix[12],
float extraThickness,
int timestep,
float rotation = 0.f,
int axis = -1);
509 void buildLocalCoordTransform(
double transformMatrix[12],
double extraThickness,
int timestep,
float rotation = 0.f,
int axis = -1);
513 void buildLocal2DTransform(
int dataOrientation,
float a[2],
float b[2],
float* constVal,
int mappedDims[3]);
517 virtual bool isPlanar() {
return false;}
523 static float distanceToCube(
const float point[3],
const float faceNormals[6][3],
const float faceCorners[6][3]);
526 static float distancesToCube(
const float point[3],
const float faceNormals[6][3],
const float faceCorners[6][3],
float maxDist[3]);
532 static bool searchCmdLine(
const char *flag);
533 static const char* parseCmdLine(
const char *flag);
537 void convertThetaPhiPsi(
float *newTheta,
float* newPhi,
float* newPsi,
int axis,
float rotation);
538 static int getGrids(
size_t ts,
const vector<string>& varnames,
double extents[6],
int* refLevel,
int* lod,
RegularGrid** grids);
547 double savedBoxExts[6];
548 int savedBoxVoxExts[6];
552 static map<pair<int,int>,vector<Params*> > paramsInstances;
554 static map<pair<int,int>,
int> currentParamsInstance;
558 static map<int, Params*> defaultParamsInstance;
559 static vector<Params*> dummyParamsInstances;
560 #endif //DOXYGEN_SKIP_THIS
585 virtual void setEnabled(
bool value) {enabled = value; stopFlag =
false;}
590 virtual bool usingVariable(
const std::string& varname) = 0;
592 GetRootNode()->SetElementLong(_RefinementLevelTag, level);
596 const vector<long>defaultRefinement(1,0);
597 return (GetRootNode()->GetElementLong(_RefinementLevelTag,defaultRefinement)[0]);
602 virtual int GetCompressionLevel();
606 virtual int GetFidelityLevel();
610 virtual void SetFidelityLevel(
int level);
614 virtual bool GetIgnoreFidelity();
618 virtual void SetIgnoreFidelity(
bool val);
622 virtual void SetCompressionLevel(
int val);
637 static float getCameraDistance(
ViewpointParams* vpp,
const double exts[6]);
641 virtual bool IsOpaque()=0;
647 void setBypass(
int timestep) {bypassFlags[timestep] = 2;}
659 void setAllBypass(
bool val);
664 bool doBypass(
int ts) {
return ((ts < bypassFlags.size()) && bypassFlags[ts]);}
670 bool doAlwaysBypass(
int ts) {
return ((ts < bypassFlags.size()) && bypassFlags[ts]>1);}
684 #ifndef DOXYGEN_SKIP_THIS
703 minColorEditBounds = 0;
704 maxColorEditBounds = 0;
705 minOpacEditBounds = 0;
706 maxOpacEditBounds = 0;
709 virtual ~RenderParams(){
710 if (minColorEditBounds)
delete [] minColorEditBounds;
711 if (maxColorEditBounds)
delete [] maxColorEditBounds;
712 if (minOpacEditBounds)
delete [] minOpacEditBounds;
713 if (maxOpacEditBounds)
delete [] maxOpacEditBounds;
717 virtual Params* deepCopy(ParamNode* nd = 0);
718 virtual bool isRenderParams() {
return true;}
721 virtual void setLocal(
bool ){ assert(0);}
723 virtual int getSessionVarNum(){assert(0);
return -1;}
724 virtual float GetHistoStretch() { assert(0);
return 1.f;}
725 virtual bool getEditMode() {assert(0);
return true;}
726 virtual const float* getCurrentDatarange(){assert(0);
return(0);}
727 virtual void hookupTF(TransferFunction* ,
int ) {assert(0);}
731 virtual void setMinColorMapBound(
float) {assert(0);}
732 virtual void setMaxColorMapBound(
float){assert(0);}
733 virtual void setMinOpacMapBound(
float){assert(0);}
734 virtual void setMaxOpacMapBound(
float){assert(0);}
737 float getMinColorMapBound();
738 float getMaxColorMapBound();
740 virtual void setMinColorEditBound(
float val,
int var) {
741 minColorEditBounds[var] = val;
743 virtual void setMaxColorEditBound(
float val,
int var) {
744 maxColorEditBounds[var] = val;
746 virtual float getMinColorEditBound(
int var) {
747 return minColorEditBounds[var];
749 virtual float getMaxColorEditBound(
int var) {
750 return maxColorEditBounds[var];
754 virtual float getMinOpacMapBound();
755 virtual float getMaxOpacMapBound();
758 virtual void setMinOpacEditBound(
float val,
int var) {
759 minOpacEditBounds[var] = val;
761 virtual void setMaxOpacEditBound(
float val,
int var) {
762 maxOpacEditBounds[var] = val;
764 virtual float getMinOpacEditBound(
int var) {
765 return minOpacEditBounds[var];
767 virtual float getMaxOpacEditBound(
int var) {
768 return maxOpacEditBounds[var];
771 virtual MapperFunction* GetMapperFunc() {
return 0;}
773 void setStopFlag(
bool val =
true) {stopFlag = val;}
774 bool getStopFlag() {
return stopFlag;}
775 int getBypassValue(
int i) {
return bypassFlags[i];}
777 void initializeBypassFlags();
779 bool cropToBox(
const double boxExts[6]);
780 bool intersectRotatedBox(
double boxexts[6],
double pointFound[3],
double probeCoords[2]);
781 bool fitToBox(
const double boxExts[6]);
782 int interceptBox(
const double boxExts[6],
double intercept[6][3]);
784 void rotateAndRenormalizeBox(
int axis,
float rotVal);
786 void getLocalContainingRegion(
float regMin[3],
float regMax[3]);
787 void getRotatedVoxelExtents(
float voxdims[2]);
789 void calcSliceHistogram(
int ts, Histo* histo);
791 virtual int getInterpolationOrder() {
return 1;}
800 float* minColorEditBounds;
801 float* maxColorEditBounds;
802 float* minOpacEditBounds;
803 float* maxOpacEditBounds;
805 vector<int> bypassFlags;
806 #endif //DOXYGEN_SKIP_THIS
808 #ifndef DOXYGEN_SKIP_THIS
809 class DummyParams :
public Params {
811 DummyParams(XmlNode *parent,
const std::string tag,
int winnum);
812 virtual ~DummyParams(){}
813 virtual void restart(){}
814 virtual int GetRefinementLevel() {
818 virtual int GetCompressionLevel() {
return 0;}
820 virtual void SetCompressionLevel(
int){}
822 virtual bool reinit(
bool){
return false;}
824 virtual bool IsOpaque() {
return true;}
826 virtual bool usingVariable(
const std::string& ){
829 const std::string &getShortName(){
return myTag;}
837 Point4() {point[0]=point[1]=point[2]=point[3]=0.f;}
838 Point4(
const float data[4]){setVal(data);}
839 void setVal(
const float sourceData[4]){
840 for (
int i = 0; i< 4; i++) point[i] = sourceData[i];
842 void set3Val(
const float sourceData[3]){
843 for (
int i = 0; i< 3; i++) point[i] = sourceData[i];
845 void set1Val(
int index,
float sourceData){
846 point[index] = sourceData;
848 float getVal(
int i){
return point[i];}
849 void copy3Vals(
float* dest) {dest[0]=point[0];dest[1]=point[1];dest[2]=point[2];}
853 #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.
virtual bool VariablesAre3D()
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.