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

#include <testcontainer.h>

Inheritance diagram for TestContainer:
Collaboration diagram for TestContainer:

Signals

void selectionChanged ()
 

Public Member Functions

 TestContainer (MainWindow *parent=0, int testIndex=0)
 
 ~TestContainer ()
 
void toggleHidden (bool show)
 
void setError (double min, double max, double avg)
 
void setSelected (bool selected)
 
void runTest ()
 

Static Public Member Functions

static void skipLines (FILE *fp, int lines)
 
static int openFileLine (FILE **fp, const char filename[], int startLine)
 
static void listWriteRVec (QListWidgetItem *listItem, rvector vect, int *roleIndex)
 
static void listWriteCartpos (QListWidgetItem *listItem, cartpos pos, int *roleIndex)
 
static void listWriteKepstruc (QListWidgetItem *listItem, kepstruc kep, int *roleIndex)
 
static double angleDelta (double angle1, double angle2)
 
static kepstruc keplerDelta (kepstruc kep1, kepstruc kep2)
 

Public Attributes

bool isSelected
 
bool completed
 
bool hidden
 
double MinError
 
double MaxError
 
double AvgError
 
int number
 

Private Slots

void on_Expand_clicked ()
 
void on_checkBox_stateChanged (int arg1)
 

Private Member Functions

void fadeBanner (bool faded)
 

Private Attributes

Ui::TestContainer * ui
 

Constructor & Destructor Documentation

TestContainer::TestContainer ( MainWindow parent = 0,
int  testIndex = 0 
)
explicit
37  :
38  QWidget(parent),
39  ui(new Ui::TestContainer)
40 {
41  ui->setupUi(this);
42  hidden = true;
43  number = testNumber;
44  isSelected = true;
45  completed = false;
47  QString name = QString::fromAscii(parent->names[number], -1);
48  ui->nameLabel->setText(name);
49  fadeBanner(true);
50  ui->mainpanel->setLayout(new QVBoxLayout);
51  ui->mainpanel->layout()->setContentsMargins(0, 0, 0, 0);
52 }
bool completed
Definition: testcontainer.h:73
void fadeBanner(bool faded)
Definition: testcontainer.cpp:134
static char names[3][11]
Definition: mainwindow.h:48
int number
Definition: testcontainer.h:78
bool isSelected
Definition: testcontainer.h:72
string name
Definition: cubesat2obj.cpp:6
Ui::TestContainer * ui
Definition: testcontainer.h:89
bool hidden
Definition: testcontainer.h:74
void toggleHidden(bool show)
Definition: testcontainer.cpp:100
TestContainer::~TestContainer ( )
55 {
56  delete ui;
57 }
Ui::TestContainer * ui
Definition: testcontainer.h:89

Member Function Documentation

void TestContainer::toggleHidden ( bool  show)
100  {
101  ui->mainpanel->setEnabled(show);
102  if (show&&completed) {
103  ui->mainpanel->setMaximumHeight(16777215);
104  ui->mainpanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
105  ui->Expand->setText("Collapse");
106  } else {
107  ui->mainpanel->setMaximumHeight(0);
108  ui->mainpanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
109  if (completed) ui->Expand->setText("Expand");
110  }
111  hidden = !show;
112 }
bool completed
Definition: testcontainer.h:73
Ui::TestContainer * ui
Definition: testcontainer.h:89
bool hidden
Definition: testcontainer.h:74
void TestContainer::setError ( double  min,
double  max,
double  avg 
)
114  {
115  MinError = min;
116  MaxError = max;
117  AvgError = avg;
118  ui->MinErr->display(MinError);
119  ui->MaxErr->display(MaxError);
120  ui->AvgErr->display(AvgError);
121 }
double AvgError
Definition: testcontainer.h:77
Ui::TestContainer * ui
Definition: testcontainer.h:89
double MaxError
Definition: testcontainer.h:76
double MinError
Definition: testcontainer.h:75
void TestContainer::setSelected ( bool  selected)
130  {
131  ui->checkBox->setChecked(selected);
132 }
Ui::TestContainer * ui
Definition: testcontainer.h:89
void TestContainer::runTest ( )
59  {
60  if (completed&&number!=2) { //get rid of number!=2, just needed to prevent crashing by empty testcontainers.
61  delete ui->mainpanel->layout()->takeAt(0)->widget();
62  delete ui->mainpanel->layout()->takeAt(0);
63  delete ui->mainpanel->layout();
64  ui->mainpanel->setLayout(new QVBoxLayout);
65  ui->mainpanel->layout()->setContentsMargins(0, 0, 0, 0);
66  }
67  switch(number) {
68  case(0):
69  {
70  rearth_test* test = new rearth_test(this);
71  ui->mainpanel->layout()->addWidget(test);
72  break;
73  }
74  case(1):
75  {
76  eci2kep_test* test = new eci2kep_test(this);
77  ui->mainpanel->layout()->addWidget(test);
78  break;
79  }
80  default:
81  break;
82  }
83  fadeBanner(false);
84  if (!completed) {
85  ui->Expand->setText("Expand");
86  completed = true;
87  }
88  emit selectionChanged();
89 }
bool completed
Definition: testcontainer.h:73
Definition: eci2kep_test.h:41
void fadeBanner(bool faded)
Definition: testcontainer.cpp:134
int number
Definition: testcontainer.h:78
Definition: rearth_test.h:41
void selectionChanged()
void test()
Definition: testprofiler.c:34
Ui::TestContainer * ui
Definition: testcontainer.h:89
void TestContainer::skipLines ( FILE *  fp,
int  lines 
)
static
144  {
145  char c;
146  for (; lines>0; lines--) { //skip 'lines' many lines
147  c=0;
148  do { //scan through file untill the end of a line is reached
149  c = fgetc(fp);
150  if (c==EOF) return; //We've gone too far!!!
151  } while(c!='\n');
152  }
153 }
FILE * fp
Definition: rw_test.cpp:38
int TestContainer::openFileLine ( FILE **  fp,
const char  filename[],
int  startLine 
)
static
155  {
156  char filePath[40] = {"../convert_test_data/"};//the folder containing the test files
157  *fp = fopen(strcat(filePath, filename), "r"); //open the file
158  if (fp == NULL) return(0); //return 0 for failure....
159  skipLines(*fp, startLine); //move the pointer to startLine
160  return(1); //return 1 for sucess!!!!
161 }
static void skipLines(FILE *fp, int lines)
Definition: testcontainer.cpp:144
FILE * fp
Definition: rw_test.cpp:38
void TestContainer::listWriteRVec ( QListWidgetItem *  listItem,
rvector  vect,
int *  roleIndex 
)
static
163  {
164  QVariant vecX(vect.col[0]);
165  listItem->setData(Qt::UserRole+*roleIndex, vecX);
166  QVariant vecY(vect.col[1]);
167  listItem->setData(Qt::UserRole+*roleIndex+1, vecY);
168  QVariant vecZ(vect.col[2]);
169  listItem->setData(Qt::UserRole+*roleIndex+2, vecZ);
170  *roleIndex += 3;
171 }
double col[3]
Definition: vector.h:55
void TestContainer::listWriteCartpos ( QListWidgetItem *  listItem,
cartpos  pos,
int *  roleIndex 
)
static
173  {
174  listWriteRVec(listItem, pos.s, roleIndex);
175  listWriteRVec(listItem, pos.v, roleIndex);
176  listWriteRVec(listItem, pos.a, roleIndex);
177  QVariant UTC(pos.utc);
178  listItem->setData(Qt::UserRole+*roleIndex, UTC);
179  *roleIndex += 1;
180 }
rvector a
Acceleration.
Definition: convertdef.h:167
double utc
UTC of Position.
Definition: convertdef.h:161
rvector s
Location.
Definition: convertdef.h:163
static void listWriteRVec(QListWidgetItem *listItem, rvector vect, int *roleIndex)
Definition: testcontainer.cpp:163
rvector v
Velocity.
Definition: convertdef.h:165
void TestContainer::listWriteKepstruc ( QListWidgetItem *  listItem,
kepstruc  kep,
int *  roleIndex 
)
static
182  {
183  QVariant doubleVal(kep.utc);
184  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
185  *roleIndex += 1;
186  doubleVal = QVariant(kep.period);
187  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
188  *roleIndex += 1;
189  doubleVal = QVariant(kep.a);
190  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
191  *roleIndex += 1;
192  doubleVal = QVariant(kep.e);
193  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
194  *roleIndex += 1;
195  listWriteRVec(listItem, kep.h, roleIndex);
196  doubleVal = QVariant(kep.beta);
197  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
198  *roleIndex += 1;
199  doubleVal = QVariant(kep.eta);
200  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
201  *roleIndex += 1;
202  doubleVal = QVariant(kep.i);
203  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
204  *roleIndex += 1;
205  doubleVal = QVariant(kep.raan);
206  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
207  *roleIndex += 1;
208  doubleVal = QVariant(kep.ap);
209  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
210  *roleIndex += 1;
211  doubleVal = QVariant(kep.alat);
212  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
213  *roleIndex += 1;
214  doubleVal = QVariant(kep.ma);
215  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
216  *roleIndex += 1;
217  doubleVal = QVariant(kep.ta);
218  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
219  *roleIndex += 1;
220  doubleVal = QVariant(kep.ea);
221  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
222  *roleIndex += 1;
223  doubleVal = QVariant(kep.mm);
224  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
225  *roleIndex += 1;
226  doubleVal = QVariant(kep.fa);
227  listItem->setData(Qt::UserRole+*roleIndex, doubleVal);
228  *roleIndex += 1;
229 }
double ta
True Anomoly.
Definition: convertdef.h:557
double mm
Mean Motion.
Definition: convertdef.h:561
double utc
UTC time of state vector in MJD.
Definition: convertdef.h:532
double e
Eccentricity.
Definition: convertdef.h:540
double ma
Mean Anomoly.
Definition: convertdef.h:555
rvector h
Angular Momentum vector.
Definition: convertdef.h:542
double eta
Definition: convertdef.h:545
double period
Orbital Period in seconds.
Definition: convertdef.h:536
double fa
Definition: convertdef.h:562
double raan
Right Ascension of the Ascending Node in radians.
Definition: convertdef.h:549
double ap
Argument of Perigee.
Definition: convertdef.h:551
double i
Orbital Inclination in radians.
Definition: convertdef.h:547
static void listWriteRVec(QListWidgetItem *listItem, rvector vect, int *roleIndex)
Definition: testcontainer.cpp:163
double beta
Solar Beta Angle in radians.
Definition: convertdef.h:544
double a
Semi-Major Axis in meters.
Definition: convertdef.h:538
double ea
Eccentric Anomoly.
Definition: convertdef.h:559
double alat
Argument of Latitude.
Definition: convertdef.h:553
double TestContainer::angleDelta ( double  angle1,
double  angle2 
)
static
231  { //compares the two angles (radians) returns angle1-angle2
232  if (angle1>DPI) angle1 -= D2PI;
233  else if (angle1<-DPI) angle1 += D2PI;
234  if (angle2>DPI) angle2 -= D2PI;
235  else if (angle2<-DPI) angle2 += D2PI;
236  double delta = angle1 - angle2;
237  if (delta>DPI) delta -= D2PI;
238  else if (delta<-DPI) delta += D2PI;
239  return(delta);
240 }
static double delta
Definition: agent_exec-2-0.cpp:141
const double D2PI
Double precision 2*PI.
Definition: math/constants.h:16
const double DPI
Double precision PI.
Definition: math/constants.h:14
kepstruc TestContainer::keplerDelta ( kepstruc  kep1,
kepstruc  kep2 
)
static
242  { //compares two kepstrucs and returns kep1-kep2
243  kepstruc delta;
244  delta.utc = kep1.utc - kep2.utc;
245  delta.period = kep1.period - kep2.period;
246  delta.a = kep1.a - kep2.a;
247  delta.e = kep1.e - kep2.e;
248  delta.h = rv_sub(kep1.h, kep2.h);
249  delta.beta = angleDelta(kep1.beta, kep2.beta);
250  delta.eta = angleDelta(kep1.eta, kep2.eta);
251  delta.i = angleDelta(kep1.i, kep2.i);
252  delta.raan = angleDelta(kep1.raan, kep2.raan);
253  delta.ap = angleDelta(kep1.ap, kep2.ap);
254  delta.alat = angleDelta(kep1.alat, kep2.alat);
255  delta.ma = angleDelta(kep1.ma, kep2.ma);
256  delta.ta = angleDelta(kep1.ta, kep2.ta);
257  delta.ea = angleDelta(kep1.ea, kep2.ea);
258  delta.mm = angleDelta(kep1.mm, kep2.mm);
259  delta.fa = angleDelta(kep1.fa, kep2.fa);
260  return (delta);
261 }
double ta
True Anomoly.
Definition: convertdef.h:557
double mm
Mean Motion.
Definition: convertdef.h:561
static double delta
Definition: agent_exec-2-0.cpp:141
double utc
UTC time of state vector in MJD.
Definition: convertdef.h:532
double e
Eccentricity.
Definition: convertdef.h:540
double ma
Mean Anomoly.
Definition: convertdef.h:555
rvector h
Angular Momentum vector.
Definition: convertdef.h:542
double eta
Definition: convertdef.h:545
double period
Orbital Period in seconds.
Definition: convertdef.h:536
double fa
Definition: convertdef.h:562
static double angleDelta(double angle1, double angle2)
Definition: testcontainer.cpp:231
double raan
Right Ascension of the Ascending Node in radians.
Definition: convertdef.h:549
Classical elements structure.
Definition: convertdef.h:529
double ap
Argument of Perigee.
Definition: convertdef.h:551
double i
Orbital Inclination in radians.
Definition: convertdef.h:547
double beta
Solar Beta Angle in radians.
Definition: convertdef.h:544
double a
Semi-Major Axis in meters.
Definition: convertdef.h:538
double ea
Eccentric Anomoly.
Definition: convertdef.h:559
rvector rv_sub(rvector a, rvector b)
Subtract two vectors.
Definition: vector.cpp:315
double alat
Argument of Latitude.
Definition: convertdef.h:553
void TestContainer::on_Expand_clicked ( )
privateslot
92 {
94  else {
95  runTest();
97  }
98 }
bool completed
Definition: testcontainer.h:73
void runTest()
Definition: testcontainer.cpp:59
bool hidden
Definition: testcontainer.h:74
void toggleHidden(bool show)
Definition: testcontainer.cpp:100
void TestContainer::on_checkBox_stateChanged ( int  arg1)
privateslot
124 {
125  if (arg1==0) isSelected = false;
126  else if(arg1==2) isSelected = true;
127  emit selectionChanged();
128 }
void selectionChanged()
bool isSelected
Definition: testcontainer.h:72
void TestContainer::selectionChanged ( )
signal
void TestContainer::fadeBanner ( bool  faded)
private
134  {
135  ui->nameLabel->setEnabled(!faded);
136  ui->MinLabel->setEnabled(!faded);
137  ui->MinErr->setEnabled(!faded);
138  ui->MaxLabel->setEnabled(!faded);
139  ui->MaxErr->setEnabled(!faded);
140  ui->AvgLabel->setEnabled(!faded);
141  ui->AvgErr->setEnabled(!faded);
142 }
Ui::TestContainer * ui
Definition: testcontainer.h:89

Member Data Documentation

bool TestContainer::isSelected
bool TestContainer::completed
bool TestContainer::hidden
double TestContainer::MinError
double TestContainer::MaxError
double TestContainer::AvgError
int TestContainer::number
Ui::TestContainer* TestContainer::ui
private

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