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

.. line plotting ..

parent 2646dfea
Branches
Tags
No related merge requests found
...@@ -278,8 +278,7 @@ void NPlot::Open() ...@@ -278,8 +278,7 @@ void NPlot::Open()
} }
fcntl(gp_fifo,F_SETFL,O_NONBLOCK); fcntl(gp_fifo,F_SETFL,O_NONBLOCK);
// gp_write(string("plot 1 2 3")); // test gp_write( string("set terminal x11") );
gp_write(string("set terminal x11"));
ps_fnum=0; ps_fnum=0;
} }
...@@ -369,7 +368,7 @@ void NPlot::Box() ...@@ -369,7 +368,7 @@ void NPlot::Box()
ps_accu.push_back( "\n%% modeDD\nplotbefore\n" ); ps_accu.push_back( "\n%% modeDD\nplotbefore\n" );
} }
void NPlot::Line( const int lstyle, void NPlot::Line( const bool as_line, const int style_no,
const vector<double> xp, const vector<double> yp, const vector<double> xp, const vector<double> yp,
const vector<double>* z, const vector<double>* z,
const string xco, const string yco, const string xco, const string yco,
...@@ -382,7 +381,7 @@ void NPlot::Line( const int lstyle, ...@@ -382,7 +381,7 @@ void NPlot::Line( const int lstyle,
if ( np!=yp.size() ) if ( np!=yp.size() )
throw string( "PROG ERR NPLot::Line x.size<>y.size" ); throw string( "PROG ERR NPLot::Line x.size<>y.size" );
// Save to file: // Data to tmp file:
char gp_fnam[40]; char gp_fnam[40];
sprintf( gp_fnam, "/tmp/%s-%03d.gnu", getenv("LOGNAME"), gp_fno++); sprintf( gp_fnam, "/tmp/%s-%03d.gnu", getenv("LOGNAME"), gp_fno++);
if (gp_fnames!="") gp_fnames += ", "; if (gp_fnames!="") gp_fnames += ", ";
...@@ -390,7 +389,7 @@ void NPlot::Line( const int lstyle, ...@@ -390,7 +389,7 @@ void NPlot::Line( const int lstyle,
// string(" title \"") + xco + string (" -> ") // string(" title \"") + xco + string (" -> ")
// + yco + string ("\""); // + yco + string ("\"");
" notitle"; " notitle";
if (lstyle<0) if ( as_line )
gp_fnames += " with lines"; gp_fnames += " with lines";
FILE *gp_fd; FILE *gp_fd;
if (!(gp_fd = fopen(gp_fnam, "w"))) if (!(gp_fd = fopen(gp_fnam, "w")))
...@@ -399,27 +398,29 @@ void NPlot::Line( const int lstyle, ...@@ -399,27 +398,29 @@ void NPlot::Line( const int lstyle,
fprintf(gp_fd, "%16.8g %16.8g\n", xp[i], yp[i]); fprintf(gp_fd, "%16.8g %16.8g\n", xp[i], yp[i]);
fclose(gp_fd); fclose(gp_fd);
// Plot command: // Live display:
string cmd = "plot ";
char aux[80]; char aux[80];
sprintf( aux, "[%12.8g:%12.8g] [%12.8g:%12.8g] ", sprintf( aux, "[%12.8g:%12.8g] [%12.8g:%12.8g] ",
X.R.inf, X.R.sup, Y.R.inf, Y.R.sup); X.R.inf, X.R.sup, Y.R.inf, Y.R.sup);
gp_write(string("plot ") + aux + gp_fnames); cmd += aux + gp_fnames;
gp_write( cmd );
snprintf( outlin, LINSIZ, "\n%3u [", ++ps_snum); // Postscript copy:
snprintf( outlin, LINSIZ, "\n%3u [", ++ps_snum );
ps_accu.push_back( outlin ); ps_accu.push_back( outlin );
for (uint i=0; i<z->size(); i++){ for (uint i=0; i<z->size(); i++){
snprintf( outlin, LINSIZ, " %12g", (*z)[i]); snprintf( outlin, LINSIZ, " %12g", (*z)[i]);
ps_accu.push_back( outlin ); ps_accu.push_back( outlin );
} }
snprintf( outlin, LINSIZ, " ] zValues\n"); snprintf( outlin, LINSIZ, " ] zValues\n" );
ps_accu.push_back( outlin ); ps_accu.push_back( outlin );
if ( as_line )
if (lstyle>=0) snprintf( outlin, LINSIZ, "%2d cstyle", 1 );
snprintf( outlin, LINSIZ, "%2d pstyle", ++ps_pnum);
else else
snprintf( outlin, LINSIZ, "%2d cstyle", 1); snprintf( outlin, LINSIZ, "%2d pstyle", style_no );
ps_accu.push_back( outlin ); ps_accu.push_back( outlin );
snprintf( outlin, LINSIZ-2, " %% (%s -> %s)", xco.c_str(), yco.c_str()); snprintf( outlin, LINSIZ-2, " %% (%s -> %s)", xco.c_str(), yco.c_str() );
strncat( outlin, "\n", LINSIZ ); strncat( outlin, "\n", LINSIZ );
ps_accu.push_back( outlin ); ps_accu.push_back( outlin );
for (uint i=0; i<np; i++) { for (uint i=0; i<np; i++) {
...@@ -512,11 +513,11 @@ void NPlot::Dialog() ...@@ -512,11 +513,11 @@ void NPlot::Dialog()
} }
} }
void NPlot::gp_write(string in) void NPlot::gp_write( string in )
{ {
// cout << "DEBUG gp_write " << in << "\n";
string out = in + "\n"; string out = in + "\n";
write(gp_fifo, out.c_str(), out.size()); printf( "DEBUG GNUPLOT '%s'\n", out.c_str() );
write( gp_fifo, out.c_str(), out.size() );
} }
void NPlot::ps_ticktack(uint ntack, double *tack, int ntpt, double *ticklim, void NPlot::ps_ticktack(uint ntack, double *tack, int ntpt, double *ticklim,
......
...@@ -46,7 +46,7 @@ namespace NPlot { // additional declarations in dualplot.cpp ...@@ -46,7 +46,7 @@ namespace NPlot { // additional declarations in dualplot.cpp
void Clear(); void Clear();
void Box(); void Box();
void Line( const int lstyle, void Line( const bool as_line, const int style_no,
const vector<double> x, const vector<double> y, const vector<double> x, const vector<double> y,
const vector<double>* z, const vector<double>* z,
const string xco, const string yco, const string xco, const string yco,
......
...@@ -954,11 +954,15 @@ void NEdif::Plot( bool add ) ...@@ -954,11 +954,15 @@ void NEdif::Plot( bool add )
const COld *fd; const COld *fd;
const COlc *fc; const COlc *fc;
CScan S; CScan S;
static int pstyle = 0, cstyle = 0;
NOlm::JSelAsk( "Plot which scans", &JSel ); NOlm::JSelAsk( "Plot which scans", &JSel );
if (!add) { if (!add) {
pstyle = 0;
cstyle = 0;
// determine x-range ? // determine x-range ?
double inf, sup; double inf, sup;
...@@ -1058,7 +1062,6 @@ void NEdif::Plot( bool add ) ...@@ -1058,7 +1062,6 @@ void NEdif::Plot( bool add )
} }
// plot data: // plot data:
int lstyle;
NOlm::IterateEle eiter; NOlm::IterateEle eiter;
while( (e=eiter()) ){ while( (e=eiter()) ){
k = eiter.SelNo(); k = eiter.SelNo();
...@@ -1109,8 +1112,8 @@ void NEdif::Plot( bool add ) ...@@ -1109,8 +1112,8 @@ void NEdif::Plot( bool add )
if( nyh ) if( nyh )
printf( " %d points > ymax\n", nyh ); printf( " %d points > ymax\n", nyh );
} else { } else {
lstyle = 0; NPlot::Line( false, pstyle++,
NPlot::Line( lstyle, fd->VS[j].x, fd->VS[j].y, e->Z(j), fd->VS[j].x, fd->VS[j].y, e->Z(j),
e->P()->xco.str(), e->P()->yco.str(), e->P()->xco.str(), e->P()->yco.str(),
"data file "+strg(k)+" scan "+strg(j) ); "data file "+strg(k)+" scan "+strg(j) );
} }
...@@ -1123,8 +1126,7 @@ void NEdif::Plot( bool add ) ...@@ -1123,8 +1126,7 @@ void NEdif::Plot( bool add )
xp[i] = NPlot::X.R.plotcoord2value( xp[i] = NPlot::X.R.plotcoord2value(
NPlot::X.log, i/(npts-1.0) ); NPlot::X.log, i/(npts-1.0) );
fc->T->tree_curve_val_vec( &yp, xp, k, j ); fc->T->tree_curve_val_vec( &yp, xp, k, j );
lstyle = -1; NPlot::Line( true, cstyle++, xp, yp, e->Z(j),
NPlot::Line( lstyle, xp, yp, e->Z(j),
e->P()->xco.str(), e->P()->yco.str(), e->P()->xco.str(), e->P()->yco.str(),
"curve file "+strg(k)+" scan "+strg(j) ); "curve file "+strg(k)+" scan "+strg(j) );
} else if ( fc ) { } else if ( fc ) {
...@@ -1153,7 +1155,6 @@ void NEdif::Plot( bool add ) ...@@ -1153,7 +1155,6 @@ void NEdif::Plot( bool add )
s->Clear(); s->Clear();
} }
s->push_back( arg, val ); s->push_back( arg, val );
printf( "DEB %g %g %g %i\n", pos, arg, val, SS.size() );
incr_pos: incr_pos:
was_inside = is_inside; was_inside = is_inside;
if( pos>= 1 ) if( pos>= 1 )
...@@ -1162,13 +1163,13 @@ void NEdif::Plot( bool add ) ...@@ -1162,13 +1163,13 @@ void NEdif::Plot( bool add )
if( pos>1 ) if( pos>1 )
pos = 1; pos = 1;
} }
lstyle = -1;
for( int iS=0; iS<SS.size(); ++iS ){ for( int iS=0; iS<SS.size(); ++iS ){
NPlot::Line( lstyle, SS[iS].x, SS[iS].y, e->Z(j), NPlot::Line( true, cstyle, SS[iS].x, SS[iS].y, e->Z(j),
e->P()->xco.str(), e->P()->yco.str(), e->P()->xco.str(), e->P()->yco.str(),
"curve file "+strg(k)+" scan "+strg(j)+ "curve file "+strg(k)+" scan "+strg(j)+
" segment "+strg(iS) ); " segment "+strg(iS) );
} }
cstyle++;
} else } else
throw string( "PROGRAM ERROR plot invalid *e" ); throw string( "PROGRAM ERROR plot invalid *e" );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment