MCPcopy Create free account
hub / github.com/JSBSim-Team/jsbsim / MakeArbitraryPlot

Function MakeArbitraryPlot

utils/simplot/prep_plot.cpp:553–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551// ############################################################################
552
553bool MakeArbitraryPlot(
554 const vector <string>& files,
555 const vector <string>& names,
556 const struct Plots& myPlot,
557 string Title,
558 stringstream& newPlot)
559{
560 bool have_all_terms=true;
561 int i;
562 vector <string> LeftYAxisNames = myPlot.Y_Variables;
563 vector <string> RightYAxisNames = myPlot.Y2_Variables;
564 string XAxisName = myPlot.X_Variable;
565 int numLeftYAxisNames = LeftYAxisNames.size();
566 int numRightYAxisNames = RightYAxisNames.size();
567 string time_range="";
568 string plotType = "lines";
569
570 if (myPlot.plotType == points) plotType = "points";
571
572 // This line assumes time is in column 1
573 if (GetTermIndex(names, XAxisName) == 1) time_range = plot_range;
574
575 have_all_terms = have_all_terms && !HaveTerm(names, XAxisName).empty();
576 for (i=0; i<numLeftYAxisNames; i++) have_all_terms = have_all_terms && !HaveTerm(names, LeftYAxisNames[i]).empty();
577 for (i=0; i<numRightYAxisNames; i++) have_all_terms = have_all_terms && !HaveTerm(names, RightYAxisNames[i]).empty();
578
579 if (have_all_terms) {
580 // Title
581 Title += myPlot.Title;
582 if (!Title.empty())
583 newPlot << "set title \"" << Title << "\" font \"" << LABEL_FONT << "\"" << endl;
584 else
585 newPlot << "unset title" << endl;
586
587 // X axis caption and ranges
588 if (!myPlot.Axis_Caption[eX].empty()) {
589 newPlot << "set xlabel \"" << myPlot.Axis_Caption[eX] << "\" font \"" << LABEL_FONT << "\"" << endl;
590 } else {
591 newPlot << "unset xlabel" << endl;
592 }
593
594 // Left Y axis caption and ranges
595 if (!myPlot.Axis_Caption[eY].empty()) {
596 newPlot << "set ylabel \"" << myPlot.Axis_Caption[eY] << "\" font \"" << LABEL_FONT << "\"" << endl;
597 } else {
598 newPlot << "unset ylabel" << endl;
599 }
600
601 // Right Y axis caption and ranges
602 if (!myPlot.Axis_Caption[eY2].empty()) {
603 newPlot << "set y2label \"" << myPlot.Axis_Caption[eY2] << "\" font \"" << LABEL_FONT << "\"" << endl;
604 } else {
605 newPlot << "unset y2label" << endl;
606 }
607
608 newPlot << "set xrange [" << myPlot.Min[0] << ":" << myPlot.Max[0] << "]" << endl;
609 newPlot << "set yrange [" << myPlot.Min[1] << ":" << myPlot.Max[1] << "]" << endl;
610 if (myPlot.Y2_Variables.size() > 0) {

Callers 1

mainFunction · 0.85

Calls 5

GetTermIndexFunction · 0.85
HaveTermFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected