Skip to content
Snippets Groups Projects
Commit 037155e7 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

custom abscissa range in 2d plots

parent e12c05f9
No related branches found
No related tags found
No related merge requests found
...@@ -1152,6 +1152,8 @@ StringXNumber PostProcessingOptions_Number[] = { ...@@ -1152,6 +1152,8 @@ StringXNumber PostProcessingOptions_Number[] = {
} ; } ;
StringXNumber ViewOptions_Number[] = { StringXNumber ViewOptions_Number[] = {
{ F|O, "AbscissaRangeType" , opt_view_abscissa_range_type , 1 ,
"Ascissa scale range type (1=default, 2=custom)" },
{ F|O, "AdaptVisualizationGrid" , opt_view_adapt_visualization_grid , 0. , { F|O, "AdaptVisualizationGrid" , opt_view_adapt_visualization_grid , 0. ,
"Use adaptive visualization grid (for high-order elements)?" }, "Use adaptive visualization grid (for high-order elements)?" },
{ F|O, "AngleSmoothNormals" , opt_view_angle_smooth_normals , 30.0 , { F|O, "AngleSmoothNormals" , opt_view_angle_smooth_normals , 30.0 ,
...@@ -1233,6 +1235,10 @@ StringXNumber ViewOptions_Number[] = { ...@@ -1233,6 +1235,10 @@ StringXNumber ViewOptions_Number[] = {
"Forced component 7 (if View.ForceComponents > 0)" }, "Forced component 7 (if View.ForceComponents > 0)" },
{ F|O, "ComponentMap8" , opt_view_component_map8 , 8, { F|O, "ComponentMap8" , opt_view_component_map8 , 8,
"Forced component 8 (if View.ForceComponents > 0)" }, "Forced component 8 (if View.ForceComponents > 0)" },
{ F, "CustomAbscissaMax" , opt_view_custom_abscissa_max , 0. ,
"User-defined maximum abscissa value" },
{ F, "CustomAbscissaMin" , opt_view_custom_abscissa_min , 0. ,
"User-defined minimum abscissa value" },
{ F, "CustomMax" , opt_view_custom_max , 0. , { F, "CustomMax" , opt_view_custom_max , 0. ,
"User-defined maximum value to be displayed" }, "User-defined maximum value to be displayed" },
{ F, "CustomMin" , opt_view_custom_min , 0. , { F, "CustomMin" , opt_view_custom_min , 0. ,
......
...@@ -5955,6 +5955,34 @@ double opt_view_custom_max(OPT_ARGS_NUM) ...@@ -5955,6 +5955,34 @@ double opt_view_custom_max(OPT_ARGS_NUM)
#endif #endif
} }
double opt_view_custom_abscissa_min(OPT_ARGS_NUM)
{
#if defined(HAVE_POST)
GET_VIEW(0.);
if(action & GMSH_SET) {
opt->customAbscissaMin = val;
if(view) view->setChanged(true);
}
return opt->customAbscissaMin;
#else
return 0.;
#endif
}
double opt_view_custom_abscissa_max(OPT_ARGS_NUM)
{
#if defined(HAVE_POST)
GET_VIEW(0.);
if(action & GMSH_SET) {
opt->customAbscissaMax = val;
if(view) view->setChanged(true);
}
return opt->customAbscissaMax;
#else
return 0.;
#endif
}
double opt_view_xmin(OPT_ARGS_NUM) double opt_view_xmin(OPT_ARGS_NUM)
{ {
#if defined(HAVE_POST) #if defined(HAVE_POST)
...@@ -7413,6 +7441,22 @@ double opt_view_range_type(OPT_ARGS_NUM) ...@@ -7413,6 +7441,22 @@ double opt_view_range_type(OPT_ARGS_NUM)
#endif #endif
} }
double opt_view_abscissa_range_type(OPT_ARGS_NUM)
{
#if defined(HAVE_POST)
GET_VIEW(0.);
if(action & GMSH_SET) {
opt->abscissaRangeType = (int)val;
if(opt->abscissaRangeType < 1 || opt->abscissaRangeType > 3)
opt->abscissaRangeType = 1;
if(view) view->setChanged(true);
}
return opt->abscissaRangeType;
#else
return 0.;
#endif
}
double opt_view_tensor_type(OPT_ARGS_NUM) double opt_view_tensor_type(OPT_ARGS_NUM)
{ {
#if defined(HAVE_POST) #if defined(HAVE_POST)
......
...@@ -485,6 +485,8 @@ double opt_view_min(OPT_ARGS_NUM); ...@@ -485,6 +485,8 @@ double opt_view_min(OPT_ARGS_NUM);
double opt_view_max(OPT_ARGS_NUM); double opt_view_max(OPT_ARGS_NUM);
double opt_view_custom_min(OPT_ARGS_NUM); double opt_view_custom_min(OPT_ARGS_NUM);
double opt_view_custom_max(OPT_ARGS_NUM); double opt_view_custom_max(OPT_ARGS_NUM);
double opt_view_custom_abscissa_min(OPT_ARGS_NUM);
double opt_view_custom_abscissa_max(OPT_ARGS_NUM);
double opt_view_xmin(OPT_ARGS_NUM); double opt_view_xmin(OPT_ARGS_NUM);
double opt_view_xmax(OPT_ARGS_NUM); double opt_view_xmax(OPT_ARGS_NUM);
double opt_view_ymin(OPT_ARGS_NUM); double opt_view_ymin(OPT_ARGS_NUM);
...@@ -579,6 +581,7 @@ double opt_view_draw_skin_only(OPT_ARGS_NUM); ...@@ -579,6 +581,7 @@ double opt_view_draw_skin_only(OPT_ARGS_NUM);
double opt_view_scale_type(OPT_ARGS_NUM); double opt_view_scale_type(OPT_ARGS_NUM);
double opt_view_tensor_type(OPT_ARGS_NUM); double opt_view_tensor_type(OPT_ARGS_NUM);
double opt_view_range_type(OPT_ARGS_NUM); double opt_view_range_type(OPT_ARGS_NUM);
double opt_view_abscissa_range_type(OPT_ARGS_NUM);
double opt_view_vector_type(OPT_ARGS_NUM); double opt_view_vector_type(OPT_ARGS_NUM);
double opt_view_glyph_location(OPT_ARGS_NUM); double opt_view_glyph_location(OPT_ARGS_NUM);
double opt_view_center_glyphs(OPT_ARGS_NUM); double opt_view_center_glyphs(OPT_ARGS_NUM);
......
...@@ -49,7 +49,8 @@ void drawContext::drawText2d() ...@@ -49,7 +49,8 @@ void drawContext::drawText2d()
} }
static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
double &xmax, std::vector<std::vector<double> > &y) double &xmax, std::vector<std::vector<double> > &y,
double &ymin, double &ymax)
{ {
PViewData *data = p->getData(true); // use adaptive data if available PViewData *data = p->getData(true); // use adaptive data if available
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
...@@ -155,6 +156,20 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, ...@@ -155,6 +156,20 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
if(x.empty()) return false; if(x.empty()) return false;
if(opt->abscissaRangeType == PViewOptions::Custom){
std::vector<double> x2;
std::vector<std::vector<double> > y2(y.size());
for(unsigned int i = 0; i < x.size(); i++){
if(x[i] >= opt->customAbscissaMin && x[i] <= opt->customAbscissaMax){
x2.push_back(x[i]);
for(unsigned int j = 0; j < y2.size(); j++)
y2[j].push_back(y[j][i]);
}
}
x = x2;
y = y2;
}
if(space){ if(space){
xmin = xmax = x[0]; xmin = xmax = x[0];
for(unsigned int i = 1; i < x.size(); i++){ for(unsigned int i = 1; i < x.size(); i++){
...@@ -172,6 +187,15 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, ...@@ -172,6 +187,15 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
for(unsigned int j = 0; j < y[i].size(); j++) for(unsigned int j = 0; j < y[i].size(); j++)
y[i][j] = log10(y[i][j]); y[i][j] = log10(y[i][j]);
ymin = VAL_INF;
ymax = -VAL_INF;
for(unsigned int i = 0; i < y.size(); i++){
for(unsigned int j = 0; j < y[i].size(); j++){
ymin = std::min(ymin, y[i][j]);
ymax = std::max(ymax, y[i][j]);
}
}
return true; return true;
} }
...@@ -440,9 +464,13 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto ...@@ -440,9 +464,13 @@ static void drawGraphCurves(drawContext *ctx, PView *p, double xleft, double yto
static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop, static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop,
double width, double height) double width, double height)
{ {
std::vector<double> x;
std::vector<std::vector<double> > y;
double xmin, xmax, ymin, ymax;
if(!getGraphData(p, x, xmin, xmax, y, ymin, ymax)) return;
PViewData *data = p->getData(); PViewData *data = p->getData();
PViewOptions *opt = p->getOptions(); PViewOptions *opt = p->getOptions();
if(opt->rangeType == PViewOptions::Custom){ if(opt->rangeType == PViewOptions::Custom){
opt->tmpMin = opt->customMin; opt->tmpMin = opt->customMin;
opt->tmpMax = opt->customMax; opt->tmpMax = opt->customMax;
...@@ -452,8 +480,8 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop, ...@@ -452,8 +480,8 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop,
opt->tmpMax = data->getMax(opt->timeStep); opt->tmpMax = data->getMax(opt->timeStep);
} }
else{ else{
opt->tmpMin = data->getMin(); opt->tmpMin = ymin;
opt->tmpMax = data->getMax(); opt->tmpMax = ymax;
} }
if(opt->scaleType == PViewOptions::Logarithmic){ if(opt->scaleType == PViewOptions::Logarithmic){
...@@ -461,10 +489,6 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop, ...@@ -461,10 +489,6 @@ static void drawGraph(drawContext *ctx, PView *p, double xleft, double ytop,
opt->tmpMax = log10(opt->tmpMax); opt->tmpMax = log10(opt->tmpMax);
} }
std::vector<double> x;
std::vector<std::vector<double> > y;
double xmin, xmax;
if(!getGraphData(p, x, xmin, xmax, y)) return;
drawGraphAxes(ctx, p, xleft, ytop, width, height, xmin, xmax); drawGraphAxes(ctx, p, xleft, ytop, width, height, xmin, xmax);
drawGraphCurves(ctx, p, xleft, ytop, width, height, x, xmin, xmax, y); drawGraphCurves(ctx, p, xleft, ytop, width, height, x, xmin, xmax, y);
} }
......
...@@ -65,6 +65,7 @@ class PViewOptions { ...@@ -65,6 +65,7 @@ class PViewOptions {
std::string axesFormat[3], axesLabel[3]; std::string axesFormat[3], axesLabel[3];
double axesPosition[6]; double axesPosition[6];
double customMin, customMax, tmpMin, tmpMax, externalMin, externalMax; double customMin, customMax, tmpMin, tmpMax, externalMin, externalMax;
double customAbscissaMin, customAbscissaMax;
SBoundingBox3d tmpBBox; SBoundingBox3d tmpBBox;
double offset[3], raise[3], transform[3][3], displacementFactor, normalRaise; double offset[3], raise[3], transform[3][3], displacementFactor, normalRaise;
double explode; double explode;
...@@ -75,7 +76,7 @@ class PViewOptions { ...@@ -75,7 +76,7 @@ class PViewOptions {
double angleSmoothNormals; double angleSmoothNormals;
int saturateValues, fakeTransparency; int saturateValues, fakeTransparency;
int showElement, showTime, showScale; int showElement, showTime, showScale;
int scaleType, rangeType; int scaleType, rangeType, abscissaRangeType;
int vectorType, tensorType, glyphLocation, centerGlyphs; int vectorType, tensorType, glyphLocation, centerGlyphs;
int timeStep; int timeStep;
int drawStrings; int drawStrings;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment