Skip to content
Snippets Groups Projects
Commit f9f7b376 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

corr: intercept out-of-range points; implement 'force'

parent f1a26514
No related branches found
No related tags found
No related merge requests found
......@@ -379,8 +379,14 @@ void CPlot::Line( const bool as_line, const int style_no,
FILE *gp_fd;
if (!(gp_fd = fopen(gp_fnam, "w")))
throw string("cannot save gnuplot data to ") + gp_fnam;
for (uint i=0; i<np; i++)
for (uint i=0; i<np; i++){
// invalid points should be intercepted outside Line(..)
if( xp[i]<X.R.inf || xp[i]>X.R.sup )
throw "Plot::Line: x["+strg(i)+"]="+strg(xp[i])+" out of range";
if( yp[i]<Y.R.inf || yp[i]>Y.R.sup )
throw "Plot::Line: y["+strg(i)+"]="+strg(yp[i])+" out of range";
fprintf(gp_fd, "%16.8g %16.8g\n", xp[i], yp[i]);
}
fclose(gp_fd);
// Live display:
......
......@@ -27,7 +27,7 @@ class CAxis {
bool log;
bool force;
CAxis( bool _log ) : log(_log) {};
CAxis( bool _log ) : log(_log), force(false) {};
void Ask( const string& quest );
void SetLog( const bool _log );
......
......@@ -1114,21 +1114,37 @@ void NEdif::Plot( CPlot *plot, bool add )
size_t np=0, nxl=0, nxh=0, nyl=0, nyh=0;
vector<double> xp, yp;
for ( size_t i=0; i<n; i++ ) {
if( !plot->X.force && !plot->X.R.contained(s->x[i]) ) {
if (s->x[i]<=plot->X.R.inf) nxl++;
if (s->x[i]>=plot->X.R.sup) nxh++;
continue;
double x = s->x[i];
if( !plot->X.R.contained(x) ) {
if ( x<=plot->X.R.inf ){
x = plot->X.R.inf;
nxl++;
}
if ( x>=plot->X.R.sup ){
x = plot->X.R.sup;
nxh++;
}
if ( !plot->X.force )
continue;
}
if( !plot->Y.force && !plot->Y.R.contained(s->y[i]) ) {
if (s->y[i]<=plot->Y.R.inf) nyl++;
if (s->y[i]>=plot->Y.R.sup) nyh++;
continue;
double y = s->y[i];
if( !plot->Y.R.contained(y) ) {
if ( y<=plot->Y.R.inf ){
y = plot->Y.R.inf;
nyl++;
}
if ( y>=plot->Y.R.sup ){
y = plot->Y.R.sup;
nyh++;
}
if ( !plot->Y.force )
continue;
}
if( np==plot->maxpoints && np<n ) {
printf("reached maxpoints at %g\n", s->x[i]);
}
xp.push_back( s->x[i] );
yp.push_back( s->y[i] );
xp.push_back( x );
yp.push_back( y );
np = xp.size();
if( np > plot->maxpoints ) // continue in large steps
i += plot->maxpoints;
......
......@@ -263,6 +263,7 @@ int main()
" gp plot to complete .ps file\n"
" gf plot to short .psX file\n"
" gl list of plot windows\n"
" g<n> switch to plot window <n>\n"
" gd dialog (within gnuplot)\n"
" p plot\n"
" pp plot with new autoranges\n"
......
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