COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems

#include <print_utils.h>

Collaboration diagram for PrintUtils:

Public Member Functions

 PrintUtils ()
 
void vector (string prefix, rvector v, double scale, string suffix, int precision, int fieldwidth)
 
void vector (rvector v)
 
void vector (string prefix, rvector v)
 
void vector (string vector_name, rvector v, string suffix)
 
void vector (string prefix, rvector v, string suffix, int precision)
 
void vectorAndMag (string vector_name, rvector v)
 
void vectorAndMag (string vector_name, rvector v, string suffix)
 
void vector_endl (rvector v, double factor, string units, int precision)
 
void vector2 (string name_v1, rvector v1, string name_v2, rvector v2)
 
void vector2 (string name_v1, rvector v1, string name_v2, rvector v2, int precision)
 
void endline ()
 
string quat (string prefix, quaternion q, string suffix, int precision, int fieldwidth)
 
string quat (quaternion q)
 
void quat (quaternion q, int precision)
 
void quat (string prefix, quaternion q)
 
void quat (string prefix, quaternion q, int precision)
 
void quat (string prefix, quaternion q, string suffix)
 
void quat (string prefix, quaternion q, string suffix, int precision)
 
void reset ()
 
void text (string text)
 
void scalar (string prefix, double s, string suffix)
 
void scalar (string prefix, double s, double scale, string suffix, int precision, int fieldwidth)
 
void scalar (double s, string suffix)
 
void scalar (string prefix, double s)
 
void scalar (double s)
 

Public Attributes

bool printOn
 
int precision
 
int fieldwidth
 
double scale
 
string prefix
 
string suffix
 
string delimiter
 
bool delimiter_flag
 
bool use_brackets
 
string fullMessage
 

Constructor & Destructor Documentation

PrintUtils::PrintUtils ( )
40 {
41  reset();
42 }
void reset()
Definition: print_utils.cpp:44

Member Function Documentation

void PrintUtils::vector ( string  prefix,
rvector  v,
double  scale,
string  suffix,
int  precision,
int  fieldwidth 
)
92 {
93 
94  std::ostringstream out;
95 
96  out << prefix;
97 
98  // if (delimiter_flag)
99  // {
100  // out << delimiter;
101  // }
102 
103  if (use_brackets)
104  {
105  out << "[";
106  }
107 
108  // in case we don't want to print the vector with fixed width
109  if (precision != -1)
110  {
111  // with set precision
112  //std::cout.precision(precision);
113  out << std::fixed;
114  out << std::setprecision(precision);
115  }
116 
117  if (fieldwidth != -1)
118  {
119  // print with fixed width
120  // std::cout.width(filedwidth);
121 
122  out << std::setw(fieldwidth) << v.col[0]*scale << ","
123  << std::setw(fieldwidth) << v.col[1]*scale << ","
124  << std::setw(fieldwidth) << v.col[2]*scale;
125 
126  }
127  else
128  {
129  // simple print, no fixed width
130  out << v.col[0]*scale << ","
131  << v.col[1]*scale << ","
132  << v.col[2]*scale;
133  }
134 
135  if (use_brackets)
136  {
137  out << "]";
138  }
139 
140  out << suffix;
141 
142  if (delimiter_flag)
143  {
144  out << delimiter;
145  }
146 
147  if (printOn) {
148  std::cout << out.str();
149  }
150 
151  fullMessage += out.str();
152 }
bool delimiter_flag
Definition: print_utils.h:124
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
string delimiter
Definition: print_utils.h:123
string fullMessage
Definition: print_utils.h:126
bool printOn
Definition: print_utils.h:117
bool use_brackets
Definition: print_utils.h:125
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
double col[3]
Definition: vector.h:55
string suffix
Definition: print_utils.h:122
void PrintUtils::vector ( rvector  v)
156 {
157  // simple print
159 }
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
void vector(string prefix, rvector v, double scale, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:85
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::vector ( string  prefix,
rvector  v 
)
169 {
171 }
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
void vector(string prefix, rvector v, double scale, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:85
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::vector ( string  vector_name,
rvector  v,
string  suffix 
)
185 {
186  vector(vector_name, v, scale, suffix, precision, fieldwidth);
187 }
double scale
Definition: print_utils.h:120
void vector(string prefix, rvector v, double scale, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:85
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::vector ( string  prefix,
rvector  v,
string  suffix,
int  precision 
)
190 {
192 }
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
void vector(string prefix, rvector v, double scale, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:85
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::vectorAndMag ( string  vector_name,
rvector  v 
)
398 {
399  vectorAndMag(vector_name, v, "");
400 }
void vectorAndMag(string vector_name, rvector v)
Definition: print_utils.cpp:397
void PrintUtils::vectorAndMag ( string  vector_name,
rvector  v,
string  suffix 
)
403 {
404  vector(vector_name, v, scale, "", precision, fieldwidth);
405 
406  double magnitude = length_rv(v)*scale;
407 
408  std::ostringstream out;
409 
410  if (delimiter_flag)
411  {
412  out << " M,";
413  }
414  else
415  {
416  out << ", M,";
417  }
418 
419  if (use_brackets)
420  {
421  out << "[";
422  }
423 
424  if (precision != -1)
425  {
426  out << std::fixed;
427  out << std::setprecision(precision);
428  }
429 
430  if (fieldwidth != -1)
431  {
432  out << std::fixed;
433  out << std::setw(fieldwidth) << magnitude;
434  }
435  else
436  {
437  out << magnitude;
438  }
439 
440 
441  out << suffix;
442 
443  if (use_brackets)
444  {
445  out << "]";
446  }
447 
448  if (delimiter_flag)
449  {
450  out << ",";
451  }
452  else
453  {
454  out << "";
455  }
456 
457  // reset scale so that the next prints are not affected
458  scale = 1;
459 
460  if (printOn) {
461  std::cout << out.str();
462  }
463 
464  fullMessage += out.str();
465 
466 }
bool delimiter_flag
Definition: print_utils.h:124
double scale
Definition: print_utils.h:120
string fullMessage
Definition: print_utils.h:126
double length_rv(rvector v)
Length of row vector.
Definition: vector.cpp:748
bool printOn
Definition: print_utils.h:117
void vector(string prefix, rvector v, double scale, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:85
bool use_brackets
Definition: print_utils.h:125
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::vector_endl ( rvector  v,
double  factor,
string  units,
int  precision 
)
void PrintUtils::vector2 ( string  name_v1,
rvector  v1,
string  name_v2,
rvector  v2 
)
381 {
382  std::cout << name_v1 << ": " << v1 << " | " << name_v2 << ": " << v2 << std::endl;
383 }
void PrintUtils::vector2 ( string  name_v1,
rvector  v1,
string  name_v2,
rvector  v2,
int  precision 
)
390 {
391  std::cout.precision(precision);
392  std::cout << name_v1 << std::fixed << "[" << v1.col[0] << ", " << v1.col[1] << ", " << v1.col[2] << "]" << " | " << name_v2 << "[" << v2.col[0] << ", " << v2.col[1] << ", " << v2.col[2] << "]" << std::endl;
393 }
int precision
Definition: print_utils.h:118
double col[3]
Definition: vector.h:55
void PrintUtils::endline ( )
607 {
608  std::cout << std::endl;
609 }
string PrintUtils::quat ( string  prefix,
quaternion  q,
string  suffix,
int  precision,
int  fieldwidth = 6 
)
479 {
480 
481  std::ostringstream out;
482 
483  out << prefix;
484 
485  // if (delimiter_flag)
486  // {
487  // out << delimiter;
488  // }
489 
490  if (use_brackets)
491  {
492  out << "[";
493  }
494 
495  if (precision != -1){
496  // with set precision
497  out << std::fixed;
498  out << std::setprecision(precision);
499  }
500 
501  if (use_brackets)
502  {
503  out << "[xyzw],";
504  }
505 
506  if (fieldwidth != -1)
507  {
508  // print with fixed width
509  if (use_brackets)
510  {
511  out << "(";
512  }
513  out << std::setw(fieldwidth) << q.d.x << ","
514  << std::setw(fieldwidth) << q.d.y << ","
515  << std::setw(fieldwidth) << q.d.z << ",";
516 
517  if (use_brackets)
518  {
519  out << ")";
520  }
521  out << std::setw(fieldwidth) << q.w;
522 
523  }
524  else
525  {
526  // simple print, no fixed width
527 
528  if (use_brackets)
529  {
530  out << "(";
531  }
532  out << q.d.x << ","
533  << q.d.y << ","
534  << q.d.z << ",";
535 
536  if (use_brackets)
537  {
538  out << ")";
539  }
540  out << q.w;
541  }
542 
543 
544  if (use_brackets)
545  {
546  out << "]";
547  }
548 
549  out << suffix;
550 
551  if (delimiter_flag)
552  {
553  out << delimiter;
554  }
555 
556  if (printOn) {
557  std::cout << out.str();
558  }
559 
560  // add to the message so it can be printed later
561  fullMessage += out.str();
562 
563  //std::cout << prefix << "[[" << q.d.x*scale << "," << q.d.y*scale << "," << q.d.z*scale << "] " << q.w*scale << "]" << text_suffix;
564 
565  // return the string produced
566  return out.str();
567 }
double y
Y value.
Definition: vector.h:114
bool delimiter_flag
Definition: print_utils.h:124
string prefix
Definition: print_utils.h:121
string delimiter
Definition: print_utils.h:123
cvector d
Orientation.
Definition: vector.h:405
string fullMessage
Definition: print_utils.h:126
bool printOn
Definition: print_utils.h:117
double x
X value.
Definition: vector.h:112
bool use_brackets
Definition: print_utils.h:125
int precision
Definition: print_utils.h:118
double w
Rotation.
Definition: vector.h:407
double z
Z value.
Definition: vector.h:116
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
string PrintUtils::quat ( quaternion  q)
570 {
571  // this prints the quaternion q enclosed in brackets like this: [[x,y,z] w]
572  //std::cout << q;
573  return quat(prefix, q, suffix, -1, fieldwidth);
574 }
string prefix
Definition: print_utils.h:121
string quat(string prefix, quaternion q, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:473
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::quat ( quaternion  q,
int  precision 
)
577 {
579 }
string prefix
Definition: print_utils.h:121
string quat(string prefix, quaternion q, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:473
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::quat ( string  prefix,
quaternion  q 
)
582 {
584 }
string prefix
Definition: print_utils.h:121
string quat(string prefix, quaternion q, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:473
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::quat ( string  prefix,
quaternion  q,
int  precision 
)
587 {
589 }
string prefix
Definition: print_utils.h:121
string quat(string prefix, quaternion q, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:473
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::quat ( string  prefix,
quaternion  q,
string  suffix 
)
594 {
596 }
string prefix
Definition: print_utils.h:121
string quat(string prefix, quaternion q, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:473
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::quat ( string  prefix,
quaternion  q,
string  suffix,
int  precision 
)
602 {
604 }
string prefix
Definition: print_utils.h:121
string quat(string prefix, quaternion q, string suffix, int precision, int fieldwidth)
Definition: print_utils.cpp:473
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::reset ( )
45 {
46  // default values
47  printOn = true; // start with a default printing behaviour
48  precision = -1; // start with no set precision
49  fieldwidth = -1; // start with no set fieldwidth
50  scale = 1; // start with no scale factor
51  prefix = ""; // start with no prefix text
52  suffix = ""; // start with no suffix text
53  use_brackets = false; // start with no brackets around text
54  delimiter = ","; // start with coma delimiter
55  delimiter_flag = false; // start with no delimiter flags, user has to turn on this flag for use
56  fullMessage = ""; // clear the full message
57 }
bool delimiter_flag
Definition: print_utils.h:124
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
string delimiter
Definition: print_utils.h:123
string fullMessage
Definition: print_utils.h:126
bool printOn
Definition: print_utils.h:117
bool use_brackets
Definition: print_utils.h:125
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::text ( string  text)
60 {
61  string out;
62 
63  if (delimiter_flag)
64  {
65  out = text + delimiter;
66  }
67  else
68  {
69  out = text;
70  }
71 
72  if (printOn) {
73  std::cout << out;
74  }
75 
76  // add to full message
77  fullMessage += out;
78 
79 }
bool delimiter_flag
Definition: print_utils.h:124
string delimiter
Definition: print_utils.h:123
string fullMessage
Definition: print_utils.h:126
bool printOn
Definition: print_utils.h:117
void text(string text)
Definition: print_utils.cpp:59
void PrintUtils::scalar ( string  prefix,
double  s,
string  suffix 
)
282 {
284 }
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
void scalar(string prefix, double s, string suffix)
Definition: print_utils.cpp:279
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::scalar ( string  prefix,
double  s,
double  scale,
string  suffix,
int  precision,
int  fieldwidth 
)
206 {
207 
208  std::ostringstream out;
209 
210  out << prefix;
211 
212  if (prefix == "")
213  {
214  // don't print delimiter
215  }
216  else
217  {
218  if (delimiter_flag)
219  {
220  out << delimiter;
221  }
222  }
223 
224  if (use_brackets)
225  {
226  out << "[";
227  }
228 
229  // in case we don't want to print the vector with fixed width
230  if (precision != -1)
231  {
232  out << std::fixed;
233  out << std::setprecision(precision);
234  }
235 
236  if (fieldwidth != -1)
237  {
238  out << std::setw(fieldwidth);
239  }
240 
241  out << s*scale;
242 
243  if (suffix == "")
244  {
245  // don't print delimiter
246  }
247  else
248  {
249  if (delimiter_flag)
250  {
251  out << delimiter;
252  }
253  }
254 
255  out << suffix;
256 
257  if (use_brackets)
258  {
259  out << "]";
260  }
261 
262  if (delimiter_flag)
263  {
264  out << delimiter;
265  }
266 
267  if (printOn) {
268  std::cout << out.str();
269  }
270 
271  fullMessage += out.str();
272 }
bool delimiter_flag
Definition: print_utils.h:124
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
string delimiter
Definition: print_utils.h:123
string fullMessage
Definition: print_utils.h:126
bool printOn
Definition: print_utils.h:117
bool use_brackets
Definition: print_utils.h:125
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::scalar ( double  s,
string  suffix 
)
304 {
306 }
double scale
Definition: print_utils.h:120
void scalar(string prefix, double s, string suffix)
Definition: print_utils.cpp:279
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::scalar ( string  prefix,
double  s 
)
288 {
289  // if (delimiter_flag)
290  // {
291  // scalar(prefix + delimiter, s, scale, suffix, precision, fieldwidth);
292  // }
293  // else
294  // {
295  // scalar(prefix, s, scale, suffix, precision, fieldwidth);
296  // }
297 
299 }
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
void scalar(string prefix, double s, string suffix)
Definition: print_utils.cpp:279
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122
void PrintUtils::scalar ( double  s)
275 {
277 }
string prefix
Definition: print_utils.h:121
double scale
Definition: print_utils.h:120
void scalar(string prefix, double s, string suffix)
Definition: print_utils.cpp:279
int precision
Definition: print_utils.h:118
int fieldwidth
Definition: print_utils.h:119
string suffix
Definition: print_utils.h:122

Member Data Documentation

bool PrintUtils::printOn
int PrintUtils::precision
int PrintUtils::fieldwidth
double PrintUtils::scale
string PrintUtils::prefix
string PrintUtils::suffix
string PrintUtils::delimiter
bool PrintUtils::delimiter_flag
bool PrintUtils::use_brackets
string PrintUtils::fullMessage

The documentation for this class was generated from the following files: