| 1114 | // expanse of pixels, so that there's a minimum of overlapping glyphs. |
| 1115 | |
| 1116 | void DrawObjects(ObjDraw *rgod, int cod, int zEdge) |
| 1117 | { |
| 1118 | int zGlyph, zGlyph2, zGlyphS, zGlyphS2, i, j, k, k2, obj; |
| 1119 | KI kSav; |
| 1120 | |
| 1121 | // Define or adjust some initial values. |
| 1122 | zGlyph = 7*gi.nScale; zGlyphS = 9*gi.nScaleTextT; |
| 1123 | zGlyph2 = zGlyph << 1; zGlyphS2 = zGlyphS << 1; |
| 1124 | |
| 1125 | // Assume glyph is positioned below actual point, unless say otherwise. |
| 1126 | for (i = 0; i < cod; i++) if (rgod[i].f) { |
| 1127 | if (zEdge > 0 && !FInRect(rgod[i].x, rgod[i].y, |
| 1128 | zEdge, zEdge, gs.xWin-zEdge, gs.yWin-zEdge)) { |
| 1129 | rgod[i].f = fFalse; |
| 1130 | continue; |
| 1131 | } |
| 1132 | obj = rgod[i].obj; |
| 1133 | rgod[i].yg = rgod[i].y + (obj < moonsLo ? zGlyph : zGlyphS); |
| 1134 | } |
| 1135 | |
| 1136 | // Determine where to draw the glyphs in relation to the actual points, |
| 1137 | // so that the glyphs aren't drawn on top of each other if possible. |
| 1138 | for (i = 0; i < cod; i++) if (rgod[i].f) { |
| 1139 | obj = rgod[i].obj; |
| 1140 | k = k2 = gs.xWin + gs.yWin; |
| 1141 | |
| 1142 | // For each planet, will draw glyph either right over or right under the |
| 1143 | // actual planet location point. Find out the closest distance of any |
| 1144 | // other planet assuming glyph is placed at both possibilities. |
| 1145 | for (j = 0; j < i; j++) if (rgod[j].f) { |
| 1146 | k = Min(k, NAbs(rgod[i].x-rgod[j].x) + NAbs(rgod[i].yg-rgod[j].yg)); |
| 1147 | k2 = Min(k2, NAbs(rgod[i].x-rgod[j].x) + NAbs(rgod[i].yg-rgod[j].yg - |
| 1148 | zGlyph2)); |
| 1149 | } |
| 1150 | |
| 1151 | // Normally, put the glyph right below the actual point. If however |
| 1152 | // another planet is close enough to have their glyphs overlap, and the |
| 1153 | // above location is better, then will draw the glyph above instead. |
| 1154 | if (((k < zGlyph2 || k2 < zGlyph2) && k < k2) || |
| 1155 | rgod[i].yg >= gs.yWin-zEdge) |
| 1156 | rgod[i].yg -= (obj < moonsLo ? zGlyph2 : zGlyphS2); |
| 1157 | } |
| 1158 | |
| 1159 | // Draw planet glyphs. |
| 1160 | for (i = cod-1; i >= 0; i--) if (rgod[i].f) { |
| 1161 | if (zEdge > 0 && !FInRect(rgod[i].x, rgod[i].yg, |
| 1162 | zEdge, zEdge, gs.xWin-zEdge, gs.yWin-zEdge)) |
| 1163 | continue; |
| 1164 | obj = rgod[i].obj; |
| 1165 | if (rgod[i].kv != ~0) { |
| 1166 | kSav = kObjB[obj]; kObjB[obj] = rgod[i].kv; |
| 1167 | } |
| 1168 | DrawObject(rgod[i].obj, rgod[i].x, rgod[i].yg); |
| 1169 | if (rgod[i].kv != ~0) |
| 1170 | kObjB[obj] = kSav; |
| 1171 | } |
| 1172 | |
| 1173 | // Draw dots for actual object location. |
no test coverage detected