////////////////////////////////////////////////////////// // TMapDC // ------ // draw a LineDef void TMapDC::DrawMapLineDefLen (int editmode, SHORT ldnum) { assert_ldnum (ldnum); // Use interm. vars. to accelarate LineDef *pLD = &LineDefs[ldnum]; SHORT start = pLD->start; SHORT end = pLD->end; assert_vnum (start); assert_vnum (end); Vertex *pVStart = &Vertexes[start]; Vertex *pVEnd = &Vertexes[end]; SHORT x0 = pVStart->x; SHORT y0 = pVStart->y; SHORT x1 = pVEnd->x; SHORT y1 = pVEnd->y; #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(x0,y0,x1,y1) ) return; #endif // Get the LineDef color int color = GetLineDefColor(editmode, ldnum); // Draw the Length DrawLineDefLen (x0, y0, x1, y1, color); }
////////////////////////////////////////////////////////// // TMapDC // ------ // draw a Vertex void TMapDC::DrawMapVertex (int editmode, SHORT vnum) { assert_vnum (vnum); if ( editmode != OBJ_VERTEXES ) return; Vertex ve = Vertexes[vnum]; SHORT x0 = ve.x - OBJSIZE; SHORT y0 = ve.y - OBJSIZE; SHORT x1 = ve.x + OBJSIZE; SHORT y1 = ve.y + OBJSIZE; #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(x0, y0, x1, y1) ) return; #endif // Draw a point if cross is small SetPenColor16 (LIGHTGREEN); // if ( ((x1 - x0) * MUL_SCALE) <= 3 ) // Draw point if Scale <= 1/6 if ( (ScaleNum == 1) && (ScaleDen >= 6) ) { #ifdef WINDOWS_SCALING SHORT x = ve.x; SHORT y = ve.y; #else SHORT x = SCREENX(ve.x); SHORT y = SCREENY(ve.y); #endif MoveTo (x, y); LineTo (x + 1, y); // SetPixel (SCREENX(ve.x), SCREENY(ve.y), GetColor16(LIGHTGREEN)); // SetPixel (ve.x, ve.y, GetColor16(LIGHTGREEN)); // ::SetPixel (*this, SCREENX(ve.x), SCREENY(ve.y), Color16Tab[LIGHTGREEN]); } else { #ifndef WINDOWS_SCALING x0 = SCREENX(x0); y0 = SCREENY(y0); x1 = SCREENX(x1); y1 = SCREENY(y1); #endif MoveTo(x0, y0); LineTo(x1, y1); MoveTo(x1, y0); LineTo(x0, y1); } }
////////////////////////////////////////////////////////// // TMapDC // ------ // draw a circle on the screen from map coords void TMapDC::DrawMapCircle(SHORT mapXcenter, SHORT mapYcenter, SHORT mapRadius) { SHORT radius; SHORT x0 = mapXcenter - mapRadius; SHORT y0 = mapYcenter + mapRadius; SHORT x1 = mapXcenter + mapRadius; SHORT y1 = mapYcenter - mapRadius; #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(x0,y0,x1,y1) ) return; #endif radius = mapRadius * ScaleNum / ScaleDen; #ifndef WINDOWS_SCALING x0 = SCREENX(x0); y0 = SCREENY(y0); x1 = SCREENX(x1); y1 = SCREENY(y1); #endif // LogMessage ("DrawMapCircle(%d,%d,%d,%d)\n", x0, y0, x1, y1); // SelectStockObject (NULL_BRUSH); // If radius is small, draw a rectangle instead of an ellipse if ( radius <= 3 ) { TPoint points[5], *pp = points ; #ifdef WINDOWS_SCALING pp->x = mapXcenter; pp->y = y0; pp++; pp->x = x1; pp->y = mapYcenter; pp++; pp->x = mapXcenter; pp->y = y1; pp++; pp->x = x0; pp->y = mapYcenter; pp++; pp->x = mapXcenter; pp->y = y0; #else pp->x = x0+radius; pp->y = y0; pp++; pp->x = x1; pp->y = y0+radius; pp++; pp->x = x0+radius; pp->y = y1; pp++; pp->x = x0; pp->y = y0+radius; pp++; pp->x = x0+radius; pp->y = y0; #endif Polyline (points, 5); } else { Ellipse (x0, y0, x1+1, y1+1); } }
////////////////////////////////////////////////////////// // TMapDC // ------ // draw a rectangle on the screen from map coords void TMapDC::DrawMapRect(SHORT mapXstart, SHORT mapYstart, SHORT mapXend, SHORT mapYend) { // LogMessage ("DrawMapRect(%d,%d,%d,%d)\n", mapXstart, mapYstart, mapXend, mapYend); #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(mapXstart, mapYstart, mapXend, mapYend) ) return; #endif #ifdef WINDOWS_SCALING Rectangle (mapXstart, mapYstart, mapXend, mapYend); #else Rectangle (SCREENX(mapXstart), SCREENY(mapYstart), SCREENX(mapXend), SCREENY(mapYend)); #endif }
////////////////////////////////////////////////////////// // TMapDC // ------ // draw a vector (line with an ending arrow) on the screen // from map coords void TMapDC::DrawMapVector(SHORT mapXstart, SHORT mapYstart, SHORT mapXend, SHORT mapYend) { #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(mapXstart, mapYstart, mapXend, mapYend) ) return; #endif #ifdef WINDOWS_SCALING SHORT x0 = mapXstart; SHORT y0 = mapYstart; SHORT x1 = mapXend; SHORT y1 = mapYend; #else SHORT x0 = SCREENX(mapXstart); SHORT y0 = SCREENY(mapYstart); SHORT x1 = SCREENX(mapXend); SHORT y1 = SCREENY(mapYend); #endif SHORT dx = x0 - x1; SHORT dy = y0 - y1; // Draw the line part of the vector MoveTo (x0, y0); LineTo (x1, y1); // Don't draw arrow if Scale <= 1/6 if ( (ScaleNum == 1) && (ScaleDen >= 6) ) return; // Calc the length of the line SHORT r = (SHORT)hypot(dx, dy); // Don't calc if length == 0 (no orientation !) if ( r == 0 ) return; // Draw the arrow part of the vector SHORT scrXoff = (SHORT) (dx * 8 * MUL_SCALE / r); SHORT scrYoff = (SHORT) (dy * 8 * MUL_SCALE / r); x0 = x1 + 2 * scrXoff; y0 = y1 + 2 * scrYoff; MoveTo (x0 - scrYoff, y0 + scrXoff); LineTo (x1 , y1); LineTo (x0 + scrYoff, y0 - scrXoff); }
////////////////////////////////////////////////////////// // TMapDC // ------ // draw a LineDef void TMapDC::DrawMapLineDef (int editmode, SHORT ldnum, BOOL DrawLen) { assert_ldnum (ldnum); // Use interm. vars. to accelarate LineDef HUGE *pLD = &LineDefs[ldnum]; SHORT start = pLD->start; SHORT end = pLD->end; assert_vnum (start); assert_vnum (end); Vertex HUGE *pVStart = &Vertexes[start]; Vertex HUGE *pVEnd = &Vertexes[end]; SHORT x0 = pVStart->x; SHORT y0 = pVStart->y; SHORT x1 = pVEnd->x; SHORT y1 = pVEnd->y; #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(x0, y0, x1, y1) ) return; #endif // Set the LineDef color int color = GetLineDefColor(editmode, ldnum); SetPenColor16(color); // Draw the LineDef if ( editmode == OBJ_VERTEXES ) DrawMapVector(x0, y0, x1, y1); else DrawMapLine(x0, y0, x1, y1); // Draw the Length if ( DrawLen ) DrawLineDefLen(x0, y0, x1, y1, color); }
////////////////////////////////////////////////////////// // TMapDC // ------ // draw a Thing void TMapDC::DrawMapThing (int editmode, SHORT tnum) { assert_tnum (tnum); Thing *pThing = &Things[tnum]; SHORT xpos = pThing->xpos; SHORT ypos = pThing->ypos; SHORT scrRadius; SHORT mapRadius; // Select the radius if (editmode == OBJ_THINGS) mapRadius = GetKodObjectRadius(Things[tnum].type); else mapRadius = OBJSIZE; // Calc. bouding rectangle SHORT x0 = xpos - mapRadius; SHORT y0 = ypos + mapRadius; SHORT x1 = xpos + mapRadius; SHORT y1 = ypos - mapRadius; #ifndef WINDOWS_CLIPPING if ( ! IS_VISIBLE_MAP_RECT(x0,y0,x1,y1) ) return; #endif // Convert map coords. to screen coords. scrRadius = (SHORT)(mapRadius * MUL_SCALE); #ifndef WINDOWS_SCALING xpos = SCREENX(xpos); ypos = SCREENY(ypos); x0 = SCREENX(x0); y0 = SCREENY(y0); x1 = SCREENX(x1); y1 = SCREENY(y1); #endif // Draw bouding circle of the thing if (editmode == OBJ_THINGS) { SetPenColor16 (GetKodObjectColor (Things[tnum].type)); // If radius is small, draw a rectangle instead of an ellipse if ( scrRadius > 4 ) { Ellipse (x0, y0, x1+1, y1+1); } else if ( scrRadius > 1 ) { TPoint points[5], *pp = points ; pp->x = xpos; pp->y = y0; pp++; pp->x = x1; pp->y = ypos; pp++; pp->x = xpos; pp->y = y1; pp++; pp->x = x0; pp->y = ypos; pp++; pp->x = xpos; pp->y = y0; Polyline (points, 5); } } // Set pen color to default (LIGHTGRAY) else SetPenColor16 (LIGHTGRAY); // Draw the cross MoveTo (xpos, y0) ; LineTo (xpos, y1) ; MoveTo (x0, ypos) ; LineTo (x1, ypos) ; }