diff --git a/Common/Options.cpp b/Common/Options.cpp index eaf89490e463d24e626203680a60870775aaaefb..e61cd42844c291ea3133d87eb4bfbb0b2b6eb48e 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -6343,7 +6343,7 @@ double opt_view_type(OPT_ARGS_NUM) GET_VIEW(0.); if(action & GMSH_SET) { opt->type = (int)val; - if(opt->type < 1 || opt->type > 3) + if(opt->type < 1 || opt->type > 4) opt->type = 1; if(view) view->setChanged(true); } diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index ec961b282cb1f998e5f597776e243315b08e095d..5255611d344376450285c7320211d82a5b9cbbe1 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -476,11 +476,11 @@ static void updateOnelabGraph(std::string num) yName = getShortName(numbers[i].getName(), numbers[i].getShortHelp()); } } - if(x.size() != y.size()){ - x.clear(); xName.clear(); + if(x.empty()){ + xName.clear(); for(unsigned int i = 0; i < y.size(); i++) x.push_back(i); } - if(y.size()){ + if(x.size() && y.size()){ PView *v = new PView(xName, yName, x, y); v->getData()->setFileName("ONELAB" + num); v->getOptions()->intervalsType = PViewOptions::Discrete; diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index bad3d05418366af369038681d11d0f20b6517392..cee1eecff22bc8dd4d2941439073027daf2da32a 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -2632,6 +2632,7 @@ optionWindow::optionWindow(int deltaFontSize) {"3D", 0, 0, 0}, {"2D space", 0, 0, 0}, {"2D time", 0, 0, 0}, + {"2D", 0, 0, 0}, {0} }; view.choice[13] = new Fl_Choice diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp index b840e52b8000084c02c6b9856bcac8eea798425c..c2051f4a699f00a104399887485525e9aee76b9c 100644 --- a/Graphics/drawGraph2d.cpp +++ b/Graphics/drawGraph2d.cpp @@ -57,7 +57,8 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, if(data->hasMultipleMeshes()) return false; // cannot handle multi-mesh int numy = 0; - if(opt->type == PViewOptions::Plot2DSpace){ + if(opt->type == PViewOptions::Plot2D || + opt->type == PViewOptions::Plot2DSpace){ numy = 1; } else if(opt->type == PViewOptions::Plot2DTime){ @@ -76,7 +77,8 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, if(!numy) return false; y.resize(numy); - bool space = (opt->type == PViewOptions::Plot2DSpace); + bool space = (opt->type == PViewOptions::Plot2D || + opt->type == PViewOptions::Plot2DSpace); SPoint3 p0(0., 0., 0.); @@ -109,7 +111,12 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, for(int k = 0; k < numComp; k++) data->getValue(ts, ent, ele, reorder[j], k, val[k]); double vy = ComputeScalarRep(numComp, val); - if(space){ + + if(opt->type == PViewOptions::Plot2D){ + x.push_back(xyz[0]); + y[0].push_back(vy); + } + else if(opt->type == PViewOptions::Plot2DSpace){ // store offset to origin + distance to first point if(x.empty()){ p0 = SPoint3(xyz[0], xyz[1], xyz[2]); @@ -124,6 +131,7 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, if(!numy) x.push_back(data->getTime(ts)); y[numy].push_back(vy); } + } } numy++; @@ -140,7 +148,7 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin, break; } } - if(monotone){ // use the "coordinate" + if(opt->type == PViewOptions::Plot2D || monotone){ // use the "coordinate" xmin = xmax = x[0]; for(unsigned int i = 1; i < x.size(); i++){ xmin = std::min(xmin, x[i]); @@ -200,7 +208,8 @@ static void drawGraphAxes(drawContext *ctx, PView *p, double xleft, double ytop, glEnd(); // y label - if(opt->type == PViewOptions::Plot2DSpace){ + if(opt->type == PViewOptions::Plot2D || + opt->type == PViewOptions::Plot2DSpace){ int nt = data->getNumTimeSteps(); if((opt->showTime == 1 && nt > 1) || opt->showTime == 2){ char tmp[256]; diff --git a/Post/PView.cpp b/Post/PView.cpp index 5e5b65f2378ff96a7ef49f79d359fa21a52fb813..25f22f1195aa7b852cc698248bd1b425ea78f153 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -85,14 +85,8 @@ PView::PView(std::string xname, std::string yname, { _init(); PViewDataList *data = new PViewDataList(); - for(unsigned int i = 0; i < y.size(); i++){ - if(x.size() == y.size()){ - data->SP.push_back(x[i]); - } - else{ - double d = y.size() > 1 ? (double)i / (double)(y.size() - 1) : 0.; - data->SP.push_back(d); - } + for(unsigned int i = 0; i < std::min(x.size(), y.size()); i++){ + data->SP.push_back(x[i]); data->SP.push_back(0.); data->SP.push_back(0.); data->SP.push_back(y[i]); @@ -103,7 +97,7 @@ PView::PView(std::string xname, std::string yname, data->finalize(); _data = data; _options = new PViewOptions(PViewOptions::reference); - _options->type = PViewOptions::Plot2DSpace; + _options->type = PViewOptions::Plot2D; _options->axes = 2; _options->axesLabel[0] = xname; } diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h index 0e33e2a59ca5e7f8a6db045db7f8ccba3f989be6..947e413478a8594aacd5a943ca19be9279c0944d 100644 --- a/Post/PViewOptions.h +++ b/Post/PViewOptions.h @@ -18,7 +18,8 @@ class PViewOptions { enum PlotType { Plot3D = 1, Plot2DSpace = 2, - Plot2DTime = 3 + Plot2DTime = 3, + Plot2D = 4 }; enum IntervalsType { Iso = 1,