From 06affa5b5e1def13524602a6271d61aedefff985 Mon Sep 17 00:00:00 2001 From: Daniel Lins de Albuquerque Date: Mon, 9 Feb 2015 20:39:57 -0200 Subject: [PATCH 1/4] Test for ssh. --- test.dat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test.dat b/test.dat index 2bfd8ab..56dede4 100644 --- a/test.dat +++ b/test.dat @@ -403621,3 +403621,5 @@ 1.000000e+01 5.000000e-01 2.000000e+00 2.500000e+00 + + -- GitLab From 68f370725502edd92856ed3dd854aa36f1eb50e1 Mon Sep 17 00:00:00 2001 From: Daniel Lins de Albuquerque Date: Thu, 8 Sep 2016 21:43:32 -0300 Subject: [PATCH 2/4] Fixes to compile and start debugging. --- Plot.cc | 18 +++++++++++------- Plot.h | 2 +- command/PlotCommand.cc | 7 +++++++ main.cc | 3 ++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Plot.cc b/Plot.cc index 13c6522..4018ca1 100644 --- a/Plot.cc +++ b/Plot.cc @@ -4,11 +4,13 @@ #include -Plot :: Plot(Profile profile_) : - profile(&profile_) +Plot :: Plot(Profile *profile_) : + profile(profile_) { for (int i = 0; i < profile->nProjs(); i++) { + cout << "argvComp " << i << " : " << profile->argvComp(i) << endl; + cout << "argvType " << i << " : " << profile->argvType(i) << endl; projection.push_back(new Projection(i, profile->argvComp(i), profile->argvType(i), profile->inputComps())); } } @@ -31,6 +33,7 @@ void Plot :: eventloop() execute(new SetDecorCommand); execute(new SetLinesCommand); + changemode(1); while ( cont ) @@ -113,6 +116,7 @@ void Plot :: eventloop() optionMenu(); console::consolecolor(); break; +/* case 82: // 'R' - reset range int p2; if ( projection[p2]->sRange() ) @@ -122,6 +126,7 @@ void Plot :: eventloop() } replot = true; break; +*/ case 82: // 'R' - reset range int p2; changemode(0); @@ -195,9 +200,6 @@ void Plot :: eventloop() cin >> p1; changemode(1); if ( p1 >= projection.size() || p1 < 0) - { - changemode(0); - if ( p1 >= projection.size() || p1 < 0) { cout << "There's no projection " << p1 << "!!" << endl; changemode(1); @@ -221,7 +223,6 @@ void Plot :: eventloop() replot = true; break; case 115: // 's' - print eps image - { float xdim, ydim, fontSize; string p_; changemode(0); @@ -243,7 +244,6 @@ void Plot :: eventloop() console::eraser(); execute(new PrintEpsCommand); break; - } /* case 116: // 't' - draw triangle int in; @@ -257,6 +257,7 @@ void Plot :: eventloop() // DEBUG routine break; */ +/* case 119: // 'w' - line width float linew; changemode(0); @@ -271,6 +272,7 @@ void Plot :: eventloop() } replot = true; break; +*/ } } @@ -284,7 +286,9 @@ void Plot :: execute(Command * cmd) for (int i=0; iexecute(projection[i], profile); + cout << "exec DEBUG 4" << endl; projection[i]->projection()->cmd(command); + cout << "exec DEBUG 5" << endl; command = ""; } } diff --git a/Plot.h b/Plot.h index 4b3fe51..efcadc1 100644 --- a/Plot.h +++ b/Plot.h @@ -15,7 +15,7 @@ private: Profile *profile; public: - Plot(Profile); + Plot(Profile *); void eventloop(void); void execute(Command * cmd); void optionMenu(void); diff --git a/command/PlotCommand.cc b/command/PlotCommand.cc index a45b336..1911d74 100644 --- a/command/PlotCommand.cc +++ b/command/PlotCommand.cc @@ -22,6 +22,7 @@ string PlotCommand :: execute(Projection *projection, Profile *profile, int inde Gnuplot * gplt = projection->projection(); stringstream lineStyle, ii; + if ( profile->decoration() ) withTitle = ""; else @@ -30,10 +31,15 @@ string PlotCommand :: execute(Projection *projection, Profile *profile, int inde ii << index_; index = ii.str(); +cout << "PlotCommand::execute - DEBUG 0" << projection->compToLabel(1) << endl; compName = projection->compToLabel(1); +cout << "PlotCommand::execute - DEBUG 1" << endl; command = "plot '" + profile->fileName() + "' index " + index; +cout << "PlotCommand::execute - DEBUG 2" << endl; command += " using (" + projection->compToProj(0) + "):(" + projection->compToProj(1) + ")"; +cout << "PlotCommand::execute - DEBUG 3" << endl; command += " " + withTitle + "title '" + compName + "' w l ls 1"; +cout << "PlotCommand::execute - DEBUG 4" << endl; for (int j = 2; j < projection->nComps(); j++) { @@ -46,6 +52,7 @@ string PlotCommand :: execute(Projection *projection, Profile *profile, int inde } +cout << "PlotCommand::execute - DEBUG 1" << endl; // add particular projection commands for (int j=0; j nCmd(); j++) command += projection->cmd(j)->execute(projection, profile); diff --git a/main.cc b/main.cc index c64699e..619d393 100644 --- a/main.cc +++ b/main.cc @@ -9,8 +9,9 @@ using namespace std; int main (int argc, char ** argv) { - Profile profile(argc, argv); + Profile *profile = new Profile(argc, argv); Plot plot(profile); + cout << "Begin." << profile->nProjs() << endl; plot.eventloop(); -- GitLab From 6b960d083c5418f1d5ca0e333242ed8f5f6e86f3 Mon Sep 17 00:00:00 2001 From: Daniel Lins de Albuquerque Date: Fri, 9 Sep 2016 09:06:19 -0300 Subject: [PATCH 3/4] Bug fix. Code compiles and run. --- Plot.cc | 4 ---- Profile.cc | 15 ++++++++++++++- command/PlotCommand.cc | 6 ------ command/tpl | 8 ++++++++ main.cc | 3 +-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Plot.cc b/Plot.cc index 4018ca1..0402b03 100644 --- a/Plot.cc +++ b/Plot.cc @@ -9,8 +9,6 @@ Plot :: Plot(Profile *profile_) : { for (int i = 0; i < profile->nProjs(); i++) { - cout << "argvComp " << i << " : " << profile->argvComp(i) << endl; - cout << "argvType " << i << " : " << profile->argvType(i) << endl; projection.push_back(new Projection(i, profile->argvComp(i), profile->argvType(i), profile->inputComps())); } } @@ -286,9 +284,7 @@ void Plot :: execute(Command * cmd) for (int i=0; iexecute(projection[i], profile); - cout << "exec DEBUG 4" << endl; projection[i]->projection()->cmd(command); - cout << "exec DEBUG 5" << endl; command = ""; } } diff --git a/Profile.cc b/Profile.cc index 72bddc5..c03e22c 100644 --- a/Profile.cc +++ b/Profile.cc @@ -7,6 +7,7 @@ #include #include +#define MAX_COMPS 50 Profile :: Profile(int argc, char **argv) { @@ -40,9 +41,21 @@ Profile :: Profile(int argc, char **argv) fileName_ = optarg; break; case 'p': // projection + { + optind--; +/* + // Use the code below to get multiple entries for an option. + string comps(""); + for( ;optind < argc && *argv[optind] != '-'; optind++){ + if ( comps != "" ) comps = comps + " "; + comps = comps + string(argv[optind]); + } + argvComps_.push_back(comps); +*/ argvComps_.push_back(optarg); argvTypes_.push_back(PROJECTION); break; + } case 't': // triangular projection argvComps_.push_back(optarg); argvTypes_.push_back(TRIANGLE); @@ -94,7 +107,7 @@ Profile :: Profile(int argc, char **argv) cout << "No projection: " << argvComps_.size() << endl; for ( int i = 0; i < argvComps_.size(); i++ ) { - cout << " Projection components " << i << ": " << argvComps_[i] << endl; + cout << " Projection " << i << " components: " << argvComps_[i] << endl; } cout << endl; cout << endl; diff --git a/command/PlotCommand.cc b/command/PlotCommand.cc index 1911d74..5c1656a 100644 --- a/command/PlotCommand.cc +++ b/command/PlotCommand.cc @@ -31,15 +31,10 @@ string PlotCommand :: execute(Projection *projection, Profile *profile, int inde ii << index_; index = ii.str(); -cout << "PlotCommand::execute - DEBUG 0" << projection->compToLabel(1) << endl; compName = projection->compToLabel(1); -cout << "PlotCommand::execute - DEBUG 1" << endl; command = "plot '" + profile->fileName() + "' index " + index; -cout << "PlotCommand::execute - DEBUG 2" << endl; command += " using (" + projection->compToProj(0) + "):(" + projection->compToProj(1) + ")"; -cout << "PlotCommand::execute - DEBUG 3" << endl; command += " " + withTitle + "title '" + compName + "' w l ls 1"; -cout << "PlotCommand::execute - DEBUG 4" << endl; for (int j = 2; j < projection->nComps(); j++) { @@ -52,7 +47,6 @@ cout << "PlotCommand::execute - DEBUG 4" << endl; } -cout << "PlotCommand::execute - DEBUG 1" << endl; // add particular projection commands for (int j=0; j nCmd(); j++) command += projection->cmd(j)->execute(projection, profile); diff --git a/command/tpl b/command/tpl index 06d2b3f..6f7f552 100755 --- a/command/tpl +++ b/command/tpl @@ -1,7 +1,15 @@ #!/bin/bash +if [ "$1" == "" ]; then + echo "Create source code for a new command." + echo "Usage: $0 " + exit 0 +fi + cp TCommand.h $1Command.h cp TCommand.cc $1Command.cc sed -i -e "s/Sin/$1/g" $1Command.h sed -i -e "s/Sin/$1/g" $1Command.cc + +echo "Command source files '$1Command.[h,cc]' created!" diff --git a/main.cc b/main.cc index 619d393..2919db8 100644 --- a/main.cc +++ b/main.cc @@ -11,9 +11,8 @@ int main (int argc, char ** argv) Profile *profile = new Profile(argc, argv); Plot plot(profile); - cout << "Begin." << profile->nProjs() << endl; + cout << "Begin." << endl; plot.eventloop(); - cout << "End." << endl; } -- GitLab From 3e6d385aac911949a8df0bdfeaed8b84bab5f994 Mon Sep 17 00:00:00 2001 From: Daniel Lins de Albuquerque Date: Fri, 9 Sep 2016 09:11:03 -0300 Subject: [PATCH 4/4] Usage message was not showing program name. --- Profile.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Profile.cc b/Profile.cc index c03e22c..d815fb3 100644 --- a/Profile.cc +++ b/Profile.cc @@ -513,7 +513,7 @@ void Profile :: toggleVerbose() void Profile :: printUsage(int exitCode = -1) { - cerr << "\n Usage: %s -i [ -c ] [-p ] [-t ] [...] \n\n"; + cerr << "\n Usage: nplot -i [ -c ] [-p ] [-t ] [...] \n\n"; if ( exitCode != -1 ) exit(exitCode); -- GitLab