Changeset 2156 in ntrip
- Timestamp:
- Jan 1, 2010, 11:32:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncfigureppp.cpp
r2155 r2156 86 86 // 87 87 //////////////////////////////////////////////////////////////////////////// 88 QPoint bncFigurePPP::pltPoint(double tt, double yy) { 89 90 const static double scale0 = 0.8; 91 double tScale = scale0 * _width / _tRange; 92 double yScale = scale0 * _height / (2.0 * _xyzMax); 93 double tOffset = _tRange / 10.0; 94 95 int tNew = int( (tt-_tMin+tOffset) * tScale); 96 int yNew = int( (yy+_xyzMax) * yScale); 97 98 return QPoint(tNew, yNew); 99 } 100 101 // 102 //////////////////////////////////////////////////////////////////////////// 88 103 void bncFigurePPP::paintEvent(QPaintEvent *) { 89 104 90 105 QPainter painter(this); 106 _width = painter.viewport().width(); 107 _height = painter.viewport().height(); 91 108 92 109 // Plot X-coordinates as a function of time (in seconds) … … 96 113 // Find the minimum and maximum values 97 114 // ----------------------------------- 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 _tRange = _pos[_pos.size()-1]->time - _pos[0]->time; // in sec 116 _tMin = _pos[0]->time.gpssec(); 101 117 102 118 // Reduced Coordinates 103 119 // ------------------- 104 double xx[_pos.size()]; 105 double yy[_pos.size()]; 106 double zz[_pos.size()]; 107 108 double xyzMax = 0.0; 120 _xyzMax = 0.0; 121 double neu[_pos.size()][3]; 109 122 for (int ii = 0; ii < _pos.size(); ++ii) { 110 xx[ii] = _pos[ii]->xyz[0] - _pos[0]->xyz[0]; 111 yy[ii] = _pos[ii]->xyz[1] - _pos[0]->xyz[1]; 112 zz[ii] = _pos[ii]->xyz[2] - _pos[0]->xyz[2]; 113 if (fabs(xx[ii]) > xyzMax) { 114 xyzMax = fabs(xx[ii]); 115 } 116 if (fabs(yy[ii]) > xyzMax) { 117 xyzMax = fabs(yy[ii]); 118 } 119 if (fabs(zz[ii]) > xyzMax) { 120 xyzMax = fabs(zz[ii]); 123 for (int ic = 0; ic < 3; ++ic) { 124 neu[ii][ic] = _pos[ii]->xyz[ic] - _pos[0]->xyz[ic]; 125 if (fabs(neu[ii][ic]) > _xyzMax) { 126 _xyzMax = fabs(neu[ii][ic]); 127 } 121 128 } 122 129 } 123 if (xyzMax > 0.0 && tRange > 0.0) {124 130 125 const static double scale0 = 0.8; 126 double tOffset = tRange / 10.0; 127 double tScale = scale0 * frameSize().width() / tRange; 128 double xScale = scale0 * frameSize().height() / (2.0 * xyzMax); 129 130 QTransform transform; 131 transform.scale(tScale, xScale); 132 transform.translate(-tMin+tOffset, xyzMax); 133 painter.setTransform(transform); 131 if (_xyzMax > 0.0 && _tRange > 0.0) { 134 132 135 133 // x-axis 136 134 // ------ 137 painter.drawLine( QPointF(tMin, 0.0),QPointF(tMax, 0.0));135 painter.drawLine(pltPoint(_tMin, 0.0), pltPoint(_tMin+_tRange, 0.0)); 138 136 139 137 // y-axis 140 138 // ------ 141 painter.drawLine( QPointF(tMin, -xyzMax),QPointF(tMin,xyzMax));139 painter.drawLine(pltPoint(_tMin, -_xyzMax), pltPoint(_tMin, _xyzMax)); 142 140 143 141 for (int ii = 1; ii < _pos.size(); ++ii) { 144 double t1 = _pos[ii-1]->time .gpssec();145 double t2 = _pos[ii]->time .gpssec();142 double t1 = _tMin + (_pos[ii-1]->time - _pos[0]->time); 143 double t2 = _tMin + (_pos[ii]->time - _pos[0]->time); 146 144 painter.setPen(QColor(Qt::red)); 147 painter.drawLine( QPointF(t1, xx[ii-1]), QPointF(t2, xx[ii]));145 painter.drawLine(pltPoint(t1, neu[ii-1][0]), pltPoint(t2, neu[ii][0])); 148 146 painter.setPen(QColor(Qt::green)); 149 painter.drawLine( QPointF(t1, yy[ii-1]), QPointF(t2, yy[ii]));147 painter.drawLine(pltPoint(t1, neu[ii-1][1]), pltPoint(t2, neu[ii][1])); 150 148 painter.setPen(QColor(Qt::blue)); 151 painter.drawLine( QPointF(t1, zz[ii-1]), QPointF(t2, zz[ii]));149 painter.drawLine(pltPoint(t1, neu[ii-1][2]), pltPoint(t2, neu[ii][2])); 152 150 } 153 151 }
Note:
See TracChangeset
for help on using the changeset viewer.