From e18b762cbcc37ac76322013f1963301e85bcc6ac Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 22 Sep 2010 13:33:17 +0000 Subject: [PATCH] make min/max buttons use current visibility information (so we can easily get val ranges on parts of models using new model-based post-pro format) --- Fltk/optionWindow.cpp | 18 +++++++++++++----- Post/PViewData.h | 4 ++-- Post/PViewDataGModel.cpp | 36 ++++++++++++++++++++++++++++++++++-- Post/PViewDataGModel.h | 4 ++-- Post/PViewDataList.cpp | 4 ++-- Post/PViewDataList.h | 4 ++-- Post/PViewDataRemote.h | 4 ++-- doc/gmsh.html | 1 + 8 files changed, 58 insertions(+), 17 deletions(-) diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index c8fb6db7fc..9bd6d0e7f8 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -548,11 +548,19 @@ static void view_options_ok_cb(Fl_Widget *w, void *data) if(data){ const char *str = (const char*)data; - if(!strcmp(str, "range_min")){ - o->view.value[31]->value(opt_view_min(o->view.index, GMSH_GET, 0)); - } - else if(!strcmp(str, "range_max")){ - o->view.value[32]->value(opt_view_max(o->view.index, GMSH_GET, 0)); + if(!strcmp(str, "range_min") || !strcmp(str, "range_max")){ + double vmin = 0., vmax = 0.; + int vindex = o->view.index; + if(vindex >= 0 && vindex < (int)PView::list.size()){ + // compute min/max taking current visibility status into account + int step = opt_view_timestep(vindex, GMSH_GET, 0); + vmin = PView::list[vindex]->getData(true)->getMin(step, true); + vmax = PView::list[vindex]->getData(true)->getMax(step, true); + } + if(!strcmp(str, "range_min")) + o->view.value[31]->value(vmin); + else if(!strcmp(str, "range_max")) + o->view.value[32]->value(vmax); } } diff --git a/Post/PViewData.h b/Post/PViewData.h index d78559772d..100243ff7a 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -69,8 +69,8 @@ class PViewData { virtual double getTime(int step){ return 0.; } // get/set min/max for given step (global over all steps if step=-1) - virtual double getMin(int step=-1) = 0; - virtual double getMax(int step=-1) = 0; + virtual double getMin(int step=-1, bool onlyVisible=false) = 0; + virtual double getMax(int step=-1, bool onlyVisible=false) = 0; virtual void setMin(double min) = 0; virtual void setMax(double max) = 0; diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 397d506724..0aa736ce3c 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -136,14 +136,46 @@ double PViewDataGModel::getTime(int step) return _steps[step]->getTime(); } -double PViewDataGModel::getMin(int step) +double PViewDataGModel::getMin(int step, bool onlyVisible) { + if(onlyVisible){ + double vmin = VAL_INF; + for(int ent = 0; ent < getNumEntities(step); ent++){ + if(skipEntity(step, ent)) continue; + for(int ele = 0; ele < getNumElements(step, ent); ele++){ + if(skipElement(step, ent, ele, true)) continue; + for(int nod = 0; nod < getNumNodes(step, ent, ele); nod++){ + double val; + getScalarValue(step, ent, ele, nod, val); + vmin = std::min(vmin, val); + } + } + } + return vmin; + } + if(step < 0 || _steps.empty()) return _min; return _steps[step]->getMin(); } -double PViewDataGModel::getMax(int step) +double PViewDataGModel::getMax(int step, bool onlyVisible) { + if(onlyVisible){ + double vmax = -VAL_INF; + for(int ent = 0; ent < getNumEntities(step); ent++){ + if(skipEntity(step, ent)) continue; + for(int ele = 0; ele < getNumElements(step, ent); ele++){ + if(skipElement(step, ent, ele, true)) continue; + for(int nod = 0; nod < getNumNodes(step, ent, ele); nod++){ + double val; + getScalarValue(step, ent, ele, nod, val); + vmax = std::max(vmax, val); + } + } + } + return vmax; + } + if(step < 0 || _steps.empty()) return _max; return _steps[step]->getMax(); } diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index ff7365bfd2..d9656cd1e2 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -174,9 +174,9 @@ class PViewDataGModel : public PViewData { std::string getFileName(int step=-1); int getNumTimeSteps(); double getTime(int step); - double getMin(int step=-1); + double getMin(int step=-1, bool onlyVisible=false); + double getMax(int step=-1, bool onlyVisible=false); void setMin(double min){ _min = min; } - double getMax(int step=-1); void setMax(double max){ _max = max; } SBoundingBox3d getBoundingBox(int step=-1); void setBoundingBox(SBoundingBox3d& box){} diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp index a5f5924dfa..fbc6526f51 100644 --- a/Post/PViewDataList.cpp +++ b/Post/PViewDataList.cpp @@ -104,13 +104,13 @@ double PViewDataList::getTime(int step) return Time[step]; } -double PViewDataList::getMin(int step) +double PViewDataList::getMin(int step, bool onlyVisible) { if(step < 0 || step >= (int)TimeStepMin.size()) return Min; return TimeStepMin[step]; } -double PViewDataList::getMax(int step) +double PViewDataList::getMax(int step, bool onlyVisible) { if(step < 0 || step >= (int)TimeStepMax.size()) return Max; return TimeStepMax[step]; diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h index ff55893f34..b98dcbf567 100644 --- a/Post/PViewDataList.h +++ b/Post/PViewDataList.h @@ -61,9 +61,9 @@ class PViewDataList : public PViewData { bool finalize(bool computeMinMax=true); int getNumTimeSteps(){ return NbTimeStep; } double getTime(int step); - double getMin(int step=-1); + double getMin(int step=-1, bool onlyVisible=false); + double getMax(int step=-1, bool onlyVisible=false); void setMin(double min) {Min = min;} - double getMax(int step=-1); void setMax(double max) {Max = max;} SBoundingBox3d getBoundingBox(int step=-1){ return BBox; } void setBoundingBox(SBoundingBox3d& box) {BBox = box;} diff --git a/Post/PViewDataRemote.h b/Post/PViewDataRemote.h index da2f719c84..ade6645e03 100644 --- a/Post/PViewDataRemote.h +++ b/Post/PViewDataRemote.h @@ -31,8 +31,8 @@ class PViewDataRemote : public PViewData { ~PViewDataRemote(){} bool finalize(){ return true; } int getNumTimeSteps(){ return _numTimeSteps; } - double getMin(int step=-1){ return _min; } - double getMax(int step=-1){ return _max; } + double getMin(int step=-1, bool onlyVisible=false){ return _min; } + double getMax(int step=-1, bool onlyVisible=false){ return _max; } SBoundingBox3d getBoundingBox(int step=-1){ return _bbox; } double getTime(int step){ return _time; } // need to return != 0 for "empty" tests diff --git a/doc/gmsh.html b/doc/gmsh.html index e25b68091d..e9313b32cc 100644 --- a/doc/gmsh.html +++ b/doc/gmsh.html @@ -217,6 +217,7 @@ thumbnail"></a> <a href="/gmsh/gallery/piece2.gif">structured tet</a>, <a href="/gmsh/gallery/piece3.gif">structured hex/pri</a>. <li>Post-processing: + <a href="/gmsh/gallery/hugo.png">Isosurfaces and vector fields</a>, <a href="/gmsh/gallery/sebastian_lehmann.divx">Streamlines</a> (S. Lehmann), <a href="/gmsh/gallery/f16_stream.jpg">F16 streamlines</a>, <a href="/gmsh/gallery/f18_stream.jpg">F18 streamlines</a>, -- GitLab