- Timestamp:
- Dec 31, 2009, 11:53:03 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncfigureppp.cpp
r2146 r2147 97 97 cout << "paintEvent" << endl; 98 98 99 int tMin = 0; 100 int tMax = 640; 99 101 int xMin = 0; 100 int xMax = 640; 101 int yMin = 0; 102 int yMax = 140; 102 int xMax = 140; 103 103 float xLine = .60; 104 104 … … 111 111 // x-axis 112 112 // ------ 113 painter.drawLine( xMin+60, int((yMax-yMin)*xLine), xMax*3,114 int(( yMax-yMin)*xLine));113 painter.drawLine(tMin+60, int((xMax-xMin)*xLine), tMax*3, 114 int((xMax-xMin)*xLine)); 115 115 116 116 // y-axis 117 117 // ------ 118 painter.drawLine( xMin+60, int((yMax-yMin)*xLine), xMin+60, yMin+10);118 painter.drawLine(tMin+60, int((xMax-xMin)*xLine), tMin+60, xMin+10); 119 119 120 // Plot X Y121 // ------- 120 // Plot X-coordinates 121 // ------------------ 122 122 if (_pos.size() > 1) { 123 124 123 double posXmin = _pos[0]->xyz[0]; 125 124 double posXmax = _pos[0]->xyz[0]; 126 double posYmin = _pos[0]->xyz[1];127 double posYmax = _pos[0]->xyz[1];128 125 for (int ii = 1; ii < _pos.size(); ++ii) { 129 126 if (_pos[ii]->xyz[0] < posXmin) { … … 133 130 posXmax = _pos[ii]->xyz[0]; 134 131 } 135 if (_pos[ii]->xyz[1] < posYmin) { 136 posYmin = _pos[ii]->xyz[1]; 132 } 133 double rangeX = posXmax - posXmin; // in meters 134 double rangeT = _pos[_pos.size()-1]->time - _pos[0]->time; // in seconds 135 136 if (rangeX > 0.0 && rangeT > 0.0) { 137 double factorX = (xMax - xMin) / rangeX; 138 double factorT = (tMax - tMin) / rangeT; 139 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); 137 147 } 138 if (_pos[ii]->xyz[1] > posYmax) {139 posYmax = _pos[ii]->xyz[1];140 }141 }142 double rangeX = posXmax - posXmin;143 double rangeY = posYmax - posYmin;144 145 for (int ii = 0; ii < _pos.size(); ++ii) {146 const static int width = 10;147 const static int height = 10;148 int xx = int( (_pos[ii]->xyz[0] - posXmin) * (xMax - xMin) / rangeX) ;149 int yy = int( (_pos[ii]->xyz[1] - posYmin) * (yMax - yMin) / rangeY) ;150 painter.drawEllipse(xx, yy, width, height);151 148 } 152 149 }
Note:
See TracChangeset
for help on using the changeset viewer.