- Timestamp:
- Dec 31, 2009, 12:59:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncfigureppp.cpp
r2147 r2148 76 76 _pos.push_back(newPos); 77 77 78 //// beg test79 cout << newPos->time.timestr(1) << " "80 << newPos->xyz[0] << " "81 << newPos->xyz[1] << " "82 << newPos->xyz[2] << endl;83 //// end test84 85 78 if (_pos.size() > MAXNUMPOS) { 86 79 delete _pos[0]; … … 88 81 } 89 82 90 repaint();83 update(); 91 84 } 92 85 … … 95 88 void bncFigurePPP::paintEvent(QPaintEvent *) { 96 89 97 cout << "paintEvent" << endl;98 99 int tMin = 0;100 int tMax = 640;101 int xMin = 0;102 int xMax = 140;103 float xLine = .60;104 105 90 QPainter painter(this); 106 91 107 QFont font;108 font.setPointSize(int(font.QFont::pointSize()*0.8));109 painter.setFont(font);92 // Plot X-coordinates as a function of time (in seconds) 93 // ----------------------------------------------------- 94 if (_pos.size() > 1) { 110 95 111 // x-axis 112 // ------ 113 painter.drawLine(tMin+60, int((xMax-xMin)*xLine), tMax*3, 114 int((xMax-xMin)*xLine)); 96 // Find the minimum and maximum values 97 // ----------------------------------- 98 double tRange = _pos[_pos.size()-1]->time - _pos[0]->time; // in sec 99 double tMin = _pos[0]->time.gpssec(); 100 double tMax = tMin + tRange; 115 101 116 // y-axis 117 // ------ 118 painter.drawLine(tMin+60, int((xMax-xMin)*xLine), tMin+60, xMin+10); 119 120 // Plot X-coordinates 121 // ------------------ 122 if (_pos.size() > 1) { 123 double posXmin = _pos[0]->xyz[0]; 124 double posXmax = _pos[0]->xyz[0]; 102 double xMin = _pos[0]->xyz[0]; 103 double xMax = _pos[0]->xyz[0]; 125 104 for (int ii = 1; ii < _pos.size(); ++ii) { 126 if (_pos[ii]->xyz[0] < posXmin) {127 posXmin = _pos[ii]->xyz[0];105 if (_pos[ii]->xyz[0] < xMin) { 106 xMin = _pos[ii]->xyz[0]; 128 107 } 129 if (_pos[ii]->xyz[0] > posXmax) {130 posXmax = _pos[ii]->xyz[0];108 if (_pos[ii]->xyz[0] > xMax) { 109 xMax = _pos[ii]->xyz[0]; 131 110 } 132 111 } 133 double rangeX = posXmax - posXmin; // in meters 134 double rangeT = _pos[_pos.size()-1]->time - _pos[0]->time; // in seconds 112 double xRange = xMax - xMin; 135 113 136 if (rangeX > 0.0 && rangeT > 0.0) { 137 double factorX = (xMax - xMin) / rangeX; 138 double factorT = (tMax - tMin) / rangeT; 114 if (xRange > 0.0 && tRange > 0.0) { 115 116 double tScale = 640 / tRange; 117 double xScale = 140 / xRange; 118 119 QTransform transform; 120 transform.scale(tScale, xScale); 121 transform.translate(-tMin, -xMin); 122 painter.setTransform(transform); 123 124 //// beg test 125 double aa, bb; 126 transform.map(tMin, xMin, &aa, &bb); 127 cout << tMin << " " << xMin << " " << aa << " " << bb << endl; 128 129 transform.map(tMin, xMax, &aa, &bb); 130 cout << tMin << " " << xMax << " " << aa << " " << bb << endl; 131 132 transform.map(tMax, xMin, &aa, &bb); 133 cout << tMax << " " << xMin << " " << aa << " " << bb << endl; 134 135 transform.map(tMax, xMax, &aa, &bb); 136 cout << tMax << " " << xMax << " " << aa << " " << bb << endl; 137 138 cout << endl; 139 140 //// end test 141 142 // x-axis 143 // ------ 144 painter.drawLine(QPointF(tMin, xMax), QPointF(tMax, xMax)); 145 146 // y-axis 147 // ------ 148 painter.drawLine(QPointF(tMin, xMin), QPointF(tMin, xMax)); 149 150 for (int ii = 1; ii < _pos.size(); ++ii) { 151 double t1 = _pos[ii-1]->time.gpssec(); 152 double t2 = _pos[ii]->time.gpssec(); 153 double x1 = _pos[ii-1]->xyz[0]; 154 double x2 = _pos[ii]->xyz[0]; 139 155 140 for (int ii = 1; ii < _pos.size(); ++ii) { 141 int t1 = int( (_pos[ii-1]->time - _pos[0]->time) * factorT ) ; 142 int t2 = int( (_pos[ii]->time - _pos[0]->time) * factorT ) ; 143 int x1 = int( (_pos[ii-1]->xyz[0] - posXmin) * factorX ) ; 144 int x2 = int( (_pos[ii]->xyz[0] - posXmin) * factorX ) ; 145 146 painter.drawLine(t1, x1, t2, x2); 156 painter.drawLine(QPointF(t1, x1), QPointF(t2, x2)); 147 157 } 148 158 }
Note:
See TracChangeset
for help on using the changeset viewer.