void DrawTest(void){ uint32_t h,v; uint16_t dark = 0; uint32_t c = 0; uint16_t col = 0; uint32_t pixel = 0; DrawBox(0,0,0,HLEN-1,VLEN-1); /* DrawHLine(-1,0,0,20);*/ /* DrawBox(0xAA,270,190,370,290);*/ // DrawHLine(0x55,0,0,HLEN-1); //DrawHLine(0x55,VLEN-1,0,HLEN-1); DrawVLine(0x55,0,0,VLEN-1); DrawVLine(0x55,HLEN-1,0,VLEN-1); WaitMs(100); for (h = 0; h < HLEN; ++h) { pixel++; if (pixel == 10){ pixel = 0; dark++; } if (dark == 16) { c++; dark = 0; } if (c == 4) { c = 0; } col = 0; switch (c) { case 0: col = (dark << 1); break; case 1: col = (dark << 7); break; case 2: col = (dark << 12); break; case 3: col = (dark << 1) | (dark << 7) | (dark << 12); break; } DrawPoint(col,h,0); } for (v = 1; v < VLEN; ++v) { DrawCopyHLine(v-1,v); } }
iwBuildOrder::iwBuildOrder(const GameWorldViewer& gwv) : IngameWindow(CGI_BUILDORDER, IngameWindow::posLastOrCenter, Extent(320, 300), _("Building sequence"), LOADER.GetImageN("io", 5)), gwv(gwv), settings_changed(false) { ctrlList* list = AddList(0, DrawPoint(15, 60), Extent(150, 220), TC_GREY, NormalFont); // Liste füllen BuildOrders buildOrders = GAMECLIENT.visual_settings.build_order; for(auto& buildOrder : buildOrders) list->AddString(_(BUILDING_NAMES[buildOrder])); //-V807 // Nach ganz oben AddImageButton(1, DrawPoint(250, 194), Extent(48, 20), TC_GREY, LOADER.GetImageN("io", 215), _("Top")); // Hoch AddImageButton(2, DrawPoint(250, 216), Extent(48, 20), TC_GREY, LOADER.GetImageN("io", 33), _("Up")); // Runter AddImageButton(3, DrawPoint(250, 238), Extent(48, 20), TC_GREY, LOADER.GetImageN("io", 34), _("Down")); // Nach ganz unten AddImageButton(4, DrawPoint(250, 260), Extent(48, 20), TC_GREY, LOADER.GetImageN("io", 216), _("Bottom")); // Bild der Auswahl AddImage(5, DrawPoint(240, 150), LOADER.GetNationImage(gwv.GetPlayer().nation, 250 + buildOrders[0] * 5)); ctrlComboBox* combo = AddComboBox(6, DrawPoint(15, 30), Extent(290, 20), TC_GREY, NormalFont, 100); combo->AddString(_("Sequence of given order")); // "Reihenfolge der Auftraggebung" combo->AddString(_("After the following order")); // "Nach folgender Reihenfolge" // Eintrag in Combobox auswählen combo->SetSelection(GAMECLIENT.visual_settings.useCustomBuildOrder ? 1 : 0); // Standard AddImageButton(10, DrawPoint(200, 250), Extent(48, 30), TC_GREY, LOADER.GetImageN("io", 191), _("Default")); // Absendetimer, in 2s-Abschnitten wird jeweils das ganze als Netzwerknachricht ggf. abgeschickt AddTimer(11, 2000); list->SetSelection(0); }
void nobHQ::Draw(DrawPoint drawPt) { if(isTent_) LOADER.building_cache[nation][BLD_HEADQUARTERS][1].draw(drawPt); else { DrawBaseBuilding(drawPt); // Draw at most 4 flags const unsigned numSoldiers = std::accumulate(reserve_soldiers_available.begin(), reserve_soldiers_available.end(), GetNumSoldiers()); DrawPoint flagsPos = drawPt + TROOPS_FLAG_HQ_OFFSET[nation]; for(auto i = min<unsigned>(numSoldiers, 4); i; --i) { glArchivItem_Bitmap_Player* bitmap = LOADER.GetMapPlayerImage(3162 + GAMECLIENT.GetGlobalAnimation(8, 80, 40, GetX() * GetY() * i)); if(bitmap) bitmap->DrawFull(flagsPos + DrawPoint(0, (i - 1) * 3), COLOR_WHITE, gwg->GetPlayer(player).color); } } }
iwSuggestPact::iwSuggestPact(const PactType pt, const GamePlayer& player, GameCommandFactory& gcFactory) : IngameWindow(CGI_SUGGESTPACT, IngameWindow::posLastOrCenter, Extent(320, 215), _(PACT_TITLES[pt]), LOADER.GetImageN("resource", 41)), pt(pt), player(player), gcFactory(gcFactory) { glArchivItem_Bitmap* image; switch(pt) { case TREATY_OF_ALLIANCE: image = LOADER.GetImageN("io", 61); break; case NON_AGGRESSION_PACT: image = LOADER.GetImageN("io", 100); break; default: image = nullptr; } // Bild als Orientierung, welchen Vertrag wir gerade bearbeiten if(image) this->AddImage(0, DrawPoint(55, 100), image); AddText(1, DrawPoint(100, 30), _("Contract type:"), COLOR_YELLOW, FontStyle{}, NormalFont); AddText(2, DrawPoint(100, 45), _(PACT_NAMES[pt]), COLOR_GREEN, FontStyle{}, NormalFont); AddText(3, DrawPoint(100, 70), _("To player:"), COLOR_YELLOW, FontStyle{}, NormalFont); AddText(4, DrawPoint(100, 85), player.name, player.color, FontStyle{}, NormalFont); AddText(5, DrawPoint(100, 110), _("Duration:"), COLOR_YELLOW, FontStyle{}, NormalFont); ctrlComboBox* combo = AddComboBox(6, DrawPoint(100, 125), Extent(190, 22), TC_GREEN2, NormalFont, 100); // Zeiten zur Combobox hinzufügen for(unsigned i = 0; i < NUM_DURATIONS; ++i) { combo->AddString(helpers::format("%s (%s)", DURATION_NAMES[i], GAMECLIENT.FormatGFTime(DURATIONS[i]))); } // Erstes Item in der Combobox vorerst auswählen combo->SetSelection(0); // Option "ewig" noch hinzufügen combo->AddString(_("Eternal")); AddTextButton(7, DrawPoint(110, 170), Extent(100, 22), TC_GREEN2, _("Confirm"), NormalFont); }
void GameMapRandomizer::AddSpawnpoint() { Position center((width_ * section_width_) / 2, (height_ * section_height_) / 2); const int spawnpoint[11][11] = { { 1, 1, 1, 1, 1, 15, 1, 1, 1, 1, 1}, { 1, 1, 1, 15, 15, 15, 15, 15, 1, 1, 1}, { 1, 1, 15, 15, 15, 15, 15, 15, 15, 1, 1}, { 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1}, { 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1}, { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, { 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1}, { 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1}, { 1, 1, 15, 15, 15, 15, 15, 15, 15, 1, 1}, { 1, 1, 1, 15, 15, 15, 15, 15, 1, 1, 1}, { 1, 1, 1, 1, 1, 15, 1, 1, 1, 1, 1} }; for (int y = -5; y < 6; y++) { for (int x = -5; x < 6; x++) { DrawPoint(Position(center.x()+x, center.y()+y), spawnpoint[y+5][x+5]); } } }
void MinimumAreaCircle2DWindow::OnDisplay() { unsigned int gray = 0xFF808080; unsigned int blue = 0xFFFF0000; unsigned int red = 0xFF0000FF; // Clear the screen to white. memset(mScreenTexture->GetData(), 0xFF, mScreenTexture->GetNumBytes()); // Draw the minimum area circle. int x = static_cast<int>(mMinimalCircle.center[0] + 0.5f); int y = static_cast<int>(mMinimalCircle.center[1] + 0.5f); int radius = static_cast<int>(mMinimalCircle.radius + 0.5f); DrawCircle(x, y, radius, gray); // Draw the support. int numSupport = mMAC2.GetNumSupport(); std::array<int, 3> support = mMAC2.GetSupport(); for (int i0 = numSupport - 1, i1 = 0; i1 <numSupport; i0 = i1++) { int x0 = static_cast<int>(mVertices[support[i0]][0] + 0.5f); int y0 = static_cast<int>(mVertices[support[i0]][1] + 0.5f); int x1 = static_cast<int>(mVertices[support[i1]][0] + 0.5f); int y1 = static_cast<int>(mVertices[support[i1]][1] + 0.5f); DrawLine(x0, y0, x1, y1, red); } // Draw the input points. for (int i = 0; i < mNumActive; ++i) { x = static_cast<int>(mVertices[i][0] + 0.5f); y = static_cast<int>(mVertices[i][1] + 0.5f); DrawPoint(x, y, blue); } mEngine->Update(mScreenTexture); mEngine->Draw(mOverlay); mEngine->DisplayColorBuffer(0); }
void CGraph::GraphMain(void) { //绘图开启标识 if (m_uChGraphPaintFlag) { //绘制图形 if(m_hGraphWnd == NULL) return; PrepareDraw(); DrawPoint(); ::BitBlt(m_hGraphDC, 0, 0, m_cxStaticWidth, m_cyStaticHeight, m_hMemDC, 0, 0, SRCCOPY); //::StretchBlt(m_hGraphDC, 0, 0, m_cxStaticWidth, m_cyStaticHeight, m_hMemDC, // m_GraphPointMinX, m_GraphPointMinY, m_GraphPointMaxX, m_GraphPointMaxY, SRCCOPY); OverDraw(); } }
void DrawCircle(int fd, int center_x, int center_y, int radius, unsigned short color) { int x = radius, y = 0; int radiusError = 1 - x; while(x >= y) { DrawPoint(fd, x + center_x, y + center_y, color); DrawPoint(fd, y + center_x, x + center_y, color); DrawPoint(fd, -x + center_x, y + center_y, color); DrawPoint(fd, -y + center_x, x + center_y, color); DrawPoint(fd, -x + center_x, -y + center_y, color); DrawPoint(fd, -y + center_x, -x + center_y, color); DrawPoint(fd, x + center_x, -y + center_y, color); DrawPoint(fd, y + center_x, -x + center_y, color); y++; if (radiusError < 0) { radiusError += 2 * y + 1; } else { x--; radiusError += 2 * (y - x + 1); } }; }
ctrlProgress::ctrlProgress(Window* parent, const unsigned int id, const unsigned short x, const unsigned short y, const unsigned short width, const unsigned short height, const TextureColor tc, unsigned short button_minus, unsigned short button_plus, const unsigned short maximum, const unsigned short x_padding, const unsigned short y_padding, const unsigned int force_color, const std::string& tooltip, const std::string& button_minus_tooltip, const std::string& button_plus_tooltip, unsigned short* const /*write_val*/) : Window(DrawPoint(x, y), id, parent, width, height, tooltip), tc(tc), position(0), maximum(maximum), padding(x_padding, y_padding), force_color(force_color) { const char* str1 = "io", * str2 = "io"; if(button_minus >= 1000) { str1 = "io_new"; button_minus -= 1000; } if(button_plus >= 1000) { str2 = "io_new"; button_plus -= 1000; } AddImageButton(0, 0, 0, height, height, tc, LOADER.GetImageN(str1, button_minus), (button_minus_tooltip.length() ? button_minus_tooltip : _("Less")) ); AddImageButton(1, width - height, 0, height, height, tc, LOADER.GetImageN(str2, button_plus), (button_plus_tooltip.length( ) ? button_plus_tooltip : _("More")) ); // Hide left and right 3D border by making the buttons overlap the bar padding.x -= 2; }
void CPainter::DrawRect(const CRect& Rect, bool bFilled, const CRGBColor& BorderColor, const CRGBColor& FillColor) { CRect RealRect(Rect); if (m_pWindow) { RealRect = Rect + m_pWindow->GetClientRect().TopLeft(); RealRect.ClipTo(m_pWindow->GetClientRect()); } if (!bFilled || (BorderColor != FillColor)) { DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), BorderColor); DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), BorderColor); DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), BorderColor); DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), BorderColor); RealRect.Grow(-1); //In case we have to fill the rect, then it's ready to go. } if (bFilled) { if (m_PaintMode == PAINT_REPLACE) { SDL_Rect FillRect = RealRect.SDLRect(); SDL_FillRect(m_pSurface, &FillRect, FillColor.SDLColor(m_pSurface->format)); } else { for (int iY = RealRect.Top(); iY <= RealRect.Bottom(); ++iY) { for (int iX = RealRect.Left(); iX <= RealRect.Right(); ++iX) { DrawPoint(CPoint(iX, iY), FillColor); } } } } }
void Surface::DrawFilledBox( int x1, int y1, int x2, int y2, uint Color ) { if( x1 > x2 ) { int t = x1; x1 = x2; x2 = t; } if( y1 > y2 ) { int t = y1; y1 = y2; y2 = t; } for( int y = y1; y < y2; ++y ) { for( int x = x1; x < x2; ++x ) { DrawPoint( x, y, Color ); } } }
void GameWorldView::DrawObject(const MapPoint& pt, const DrawPoint& curPos) { noBase* obj = GetWorld().GetNode(pt).obj; if(!obj) return; obj->Draw(curPos); return; //TODO: military aid - display icon overlay of attack possibility noBuilding* building = dynamic_cast<noBuilding*>(obj); if(!building || gwv.GetPlayer().IsAlly(building->GetPlayer())) return; BuildingType bt = building->GetBuildingType(); if((bt >= BLD_BARRACKS && bt <= BLD_FORTRESS) || bt == BLD_HEADQUARTERS || bt == BLD_HARBORBUILDING) //is it a military building? { if(gwv.GetNumSoldiersForAttack(building->GetPos())) //soldiers available for attack? LOADER.GetImageN("map_new", 20000)->Draw(curPos + DrawPoint(1, -5)); } }
void Drawer::TestCurve(const Point& aPoint1, const Point& aPoint2, const Point& aPoint3, const Point& aPoint4, const Point& aPoint5, const Point& aPoint6, double& aCoef) { SetColor(1.0,0,0); DrawCurve2(aPoint1, aPoint2, aPoint3, aPoint4, aCoef); SetColor(1.0,0,0); DrawCurve2(aPoint3, aPoint4, aPoint5, aPoint6, aCoef); SetColor(1.0,0,0); MoveTo(aPoint1); DrawLine(aPoint2); MoveTo(aPoint3); DrawLine(aPoint4); MoveTo(aPoint5); DrawLine(aPoint6); SetColor(0.0,0.0,0.0); DrawPoint(aPoint1); DrawPoint(aPoint2); DrawPoint(aPoint3); DrawPoint(aPoint4); DrawPoint(aPoint5); DrawPoint(aPoint6); }
void noShipBuildingSite::Draw(DrawPoint drawPt) { if(progress < PROGRESS_PARTS[0] + PROGRESS_PARTS[1]) { glArchivItem_Bitmap* image = LOADER.GetImageN("boot_z", 24); unsigned height = std::min(image->getHeight() * unsigned(progress) / PROGRESS_PARTS[0], unsigned(image->getHeight())); image->Draw(drawPt + DrawPoint(0, image->getHeight() - height), 0, 0, 0, (image->getHeight() - height), 0, height); image = LOADER.GetImageN("boot_z", 25); height = std::min(image->getHeight() * unsigned(progress) / PROGRESS_PARTS[0], unsigned(image->getHeight())); image->Draw(drawPt + DrawPoint(0, image->getHeight() - height), 0, 0, 0, (image->getHeight() - height), 0, height, COLOR_SHADOW); } if(progress > PROGRESS_PARTS[0]) { unsigned real_progress = progress - PROGRESS_PARTS[0]; glArchivItem_Bitmap* image = LOADER.GetImageN("boot_z", 26); unsigned height = std::min(image->getHeight() * unsigned(real_progress) / PROGRESS_PARTS[1], unsigned(image->getHeight())); image->Draw(drawPt + DrawPoint(0, image->getHeight() - height), 0, 0, 0, (image->getHeight() - height), 0, height); image = LOADER.GetImageN("boot_z", 27); height = std::min(image->getHeight() * unsigned(real_progress) / PROGRESS_PARTS[1], unsigned(image->getHeight())); image->Draw(drawPt + DrawPoint(0, image->getHeight() - height), 0, 0, 0, (image->getHeight() - height), 0, height, COLOR_SHADOW); } if(progress > PROGRESS_PARTS[0] + PROGRESS_PARTS[1]) { unsigned real_progress = progress - PROGRESS_PARTS[0] - PROGRESS_PARTS[1]; glArchivItem_Bitmap* image = LOADER.GetImageN("boot_z", 28); unsigned height = image->getHeight() * unsigned(real_progress) / PROGRESS_PARTS[2]; image->Draw(drawPt + DrawPoint(0, image->getHeight() - height), 0, 0, 0, (image->getHeight() - height), 0, height); image = LOADER.GetImageN("boot_z", 29); height = image->getHeight() * unsigned(real_progress) / PROGRESS_PARTS[2]; image->Draw(drawPt + DrawPoint(0, image->getHeight() - height), 0, 0, 0, (image->getHeight() - height), 0, height, COLOR_SHADOW); } }
bool IngameWindow::Draw_() { if(isModal_) { SetActive(true); Close(false); } // Linkes oberes Teil glArchivItem_Bitmap* leftUpperImg = LOADER.GetImageN("resource", 36); leftUpperImg->Draw(pos_); // Rechtes oberes Teil glArchivItem_Bitmap* rightUpperImg = LOADER.GetImageN("resource", 37); rightUpperImg->Draw(pos_ + DrawPoint(width_ - rightUpperImg->getWidth(), 0)); // Die beiden Buttons oben static const unsigned short ids[2][3] = { {47, 55, 50}, {48, 56, 52} }; // Titelleiste if(closeOnRightClick_ || !IsModal()) LOADER.GetImageN("resource", ids[0][button_state[0]])->Draw(pos_); if(!IsModal()) LOADER.GetImageN("resource", ids[1][button_state[1]])->Draw(pos_ + DrawPoint(width_ - 16, 0)); // Breite berechnen unsigned title_width = width_ - leftUpperImg->getWidth() - rightUpperImg->getWidth(); unsigned short title_index; if(active_) title_index = isMoving ? 44 : 43; else title_index = 42; glArchivItem_Bitmap& titleImg = *LOADER.GetImageN("resource", title_index); DrawPoint titleImgPos = pos_ + DrawPoint(leftUpperImg->getWidth(), 0); // Wieviel mal nebeneinanderzeichnen? unsigned short title_count = title_width / titleImg.getWidth(); for(unsigned short i = 0; i < title_count; ++i) { titleImg.Draw(titleImgPos); titleImgPos.x += titleImg.getWidth(); } // Rest zeichnen unsigned short rest = title_width % titleImg.getWidth(); if(rest) titleImg.Draw(titleImgPos, rest, 0, 0, 0, rest, 0); // Text auf die Leiste NormalFont->Draw(pos_ + DrawPoint(width_, titleImg.getHeight()) / 2, title_, glArchivItem_Font::DF_CENTER | glArchivItem_Font::DF_VCENTER, COLOR_YELLOW); if(!isMinimized_) { // Seitenleisten // Höhe glArchivItem_Bitmap* bottomBorderSideImg = LOADER.GetImageN("resource", 45); unsigned side_height = height_ - leftUpperImg->getHeight() - bottomBorderSideImg->getHeight(); // Wieviel mal nebeneinanderzeichnen? glArchivItem_Bitmap* leftSideImg = LOADER.GetImageN("resource", 38); glArchivItem_Bitmap* rightSideImg = LOADER.GetImageN("resource", 39); title_count = side_height / leftSideImg->getHeight(); DrawPoint leftImgPos = pos_ + DrawPoint(0, leftUpperImg->getHeight()); DrawPoint rightImgPos = leftImgPos + DrawPoint(width_ - leftSideImg->getWidth(), 0); for(unsigned short i = 0; i < title_count; ++i) { leftSideImg->Draw(leftImgPos); rightSideImg->Draw(rightImgPos); rightImgPos.y = leftImgPos.y += leftSideImg->getHeight(); } // Rest zeichnen rest = side_height % leftSideImg->getHeight(); if(rest) { leftSideImg->Draw(leftImgPos, 0, rest, 0, 0, 0, rest); rightSideImg->Draw(rightImgPos, 0, rest, 0, 0, 0, rest); } // Untere Leiste unsigned side_width = width_ - bottomBorderSideImg->getWidth() * 2; // Wieviel mal nebeneinanderzeichnen? glArchivItem_Bitmap* bottomBarImg = LOADER.GetImageN("resource", 40); title_count = side_width / bottomBarImg->getWidth(); DrawPoint bottomImgPos = pos_ + DrawPoint(bottomBorderSideImg->getWidth(), GetIwBottomBoundary()); for(unsigned short i = 0; i < title_count; ++i) { bottomBarImg->Draw(bottomImgPos); bottomImgPos.x += bottomBarImg->getWidth(); } rest = side_width % bottomBarImg->getWidth(); if(rest) bottomBarImg->Draw(bottomImgPos, rest, 0, 0, 0, rest, 0); // Clientbereich // überhaupt ne Clienttexture gewnscht? if(background) background->Draw(pos_ + contentOffset, GetIwWidth(), iwHeight, 0, 0, GetIwWidth(), iwHeight); // Msg_PaintBefore aufrufen vor den Controls Msg_PaintBefore(); DrawControls(); // Links und rechts unten die 2 kleinen Knäufe bottomBorderSideImg->Draw(pos_ + DrawPoint(0, height_ - bottomBorderSideImg->getHeight())); bottomBorderSideImg->Draw(pos_ + DrawPoint(width_ - bottomBorderSideImg->getWidth(), height_ - bottomBorderSideImg->getHeight())); } else { glArchivItem_Bitmap* bottomBorderSideImg = LOADER.GetImageN("resource", 45); glArchivItem_Bitmap* bottomBarImg = LOADER.GetImageN("resource", 40); unsigned side_width = width_ - bottomBorderSideImg->getWidth() * 2; title_count = side_width / bottomBarImg->getWidth(); DrawPoint bottomImgPos = pos_ + DrawPoint(bottomBorderSideImg->getWidth(), 20); for(unsigned short i = 0; i < title_count; ++i) { bottomBarImg->Draw(bottomImgPos); bottomImgPos.x += bottomBarImg->getWidth(); } rest = side_width % bottomBarImg->getWidth(); if(rest) bottomBarImg->Draw(bottomImgPos, rest, 0, 0, 0, rest, 0); bottomBorderSideImg->Draw(pos_ + DrawPoint(0, bottomBorderSideImg->getHeight())); bottomBorderSideImg->Draw(pos_ + DrawPoint(width_ - bottomBorderSideImg->getWidth(), bottomBorderSideImg->getHeight())); } return true; }
static void DrawPoints(void *data, long nb, struct plot_points *p) { long i; for (i=0; i<nb; ++i) DrawPoint(data,p[i].x,p[i].y); }
/**\brief Draw a point using Coordinate and Color. */ void Video::DrawPoint( Coordinate c, Color col ) { DrawPoint( (int)c.GetX(), (int)c.GetY(), col.r, col.g, col.b ); }
void SpatialGraphKDNode::Render() { if( HasChildren() ) { LHC->Render(); RHC->Render(); return; } if( theSpatialGraph.GetDrawBlocked() ) { if( bBlocked ) { glColor4f(1,0,0,0.25f); BBox.RenderBox(); } } if( theSpatialGraph.GetDrawBounds() ) { glColor4f(0,0,0,1.f); BBox.RenderOutline(); } Vector2 centroid = BBox.Centroid(); if( theSpatialGraph.GetDrawNodeIndex() ) { Vector2 screenCenter = MathUtil::WorldToScreen( centroid.X, centroid.Y ); //Print some vals glColor3f(0,1.f,1.f); DrawGameText( IntToString(Index), "ConsoleSmall", (unsigned int)screenCenter.X, (unsigned int)screenCenter.Y ); } if( theSpatialGraph.GetDrawGraph() && !bBlocked ) { glColor3f(1.f,0.f,0.f); float linePoints[4]; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, linePoints); for( unsigned int i = 0; i < Neighbors.size(); i++ ) { if( Neighbors[i]->bBlocked || !NeighborLOS[i] ) continue; //draw centroid to centroid half way point Vector2 neighbor = Neighbors[i]->BBox.Centroid(); neighbor = centroid + ((neighbor - centroid) * 0.6f); linePoints[0] = centroid.X; linePoints[1] = centroid.Y; linePoints[2] = neighbor.X; linePoints[3] = neighbor.Y; glDrawArrays(GL_LINES, 0, 2); } } if( theSpatialGraph.GetDrawGridPoints() ) { glColor3f(1.f,0.f,0.f); Vector2List gridPoints; int xPoints, yPoints; GetGridPoints(gridPoints, xPoints, yPoints ); for( unsigned int i = 0; i < gridPoints.size(); i++ ) { DrawPoint( gridPoints[i], Tree->GetSmallestDimensions().X * 0.15f ); } } }
Drawing drawPoint( const QPen & pen, const QPointF & p ) { return DrawPoint( pen, p ); }
void CMapEditor10View::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 switch(GCurOperState) { case OPERSTATE_INPUT_PNT: //造点 AppendPnt(point,pntColor); //把新加的点写入临时文件 DrawPoint(point,pntColor); //画出当前的点 break; case OPERSTATE_DEL_PNT: //删除点 DeletePntLBU(point); break; case OPERSTATE_MOV_PNT: //移动点 MovePntLBU(point); //文件中移动点 (移动到的点,要移动的点) Invalidate(); //刷新图像 break; case OPERSTATE_RECOVER_PNT: //恢复点 RecoverPnt(point); ErasePoint(point); break; case OPERSTATE_ZOOM_IN: //设置操作状态为放大 ZoomInLBU(point); break; case OPERSTATE_ZOOM_OUT: //设置操作状态为缩小 ZoomOutLBU(point); break; case OPERSTATE_CREAT_REG: //设置操作状态为造区 CreatRegLBU(point); break; case OPERSTATE_DELETE_REG: //设置操作状态为删除区 DeleteRegLBU(point); break; case OPERSTATE_MOVE_REG: //设置操作状态为移动区 MoveRegLBU(point); break; case OPERSTATE_WINDOW_MOVE: //设置操作状态为窗口移动 WindowMoveLBU(point); break; case OPERSTATE_RECOVER_REG: //设置操作状态为恢复区 RecoverDeletedRegLBU(point); break; case OPERSTATE_AMMENDPAR_REG: //设置操作状态为修改区参数 AmendRegPARLBU(point); break; case OPERSTATE_INPUT_LIN: //造线 CreateLinLBU(point); break; case OPERSTATE_DEL_LIN: //删除线 DeleteLinLBU(point); break; case OPERSTATE_MOVE_LIN: //移动线 MoveLinLBU(point); Invalidate(); //刷新图像 break; case OPERSTATE_CONNECT_LIN: //连接线 ConLinLBU(point); break; case OPERSTATE_RECOVER_LIN: //恢复线 RecoverLinLBU(point); break; default: break; } GLinChanged=1; CView::OnLButtonUp(nFlags, point); }
static bool HHVM_METHOD(ImagickDraw, point, double x, double y) { auto wand = getDrawingWandResource(Object{this_}); DrawPoint(wand->getWand(), x, y); return true; }
void Test::Step(Settings* settings) { float32 timeStep = settings->hz > 0.0f ? 1.0f / settings->hz : float32(0.0f); if (settings->pause) { if (settings->singleStep) { settings->singleStep = 0; } else { timeStep = 0.0f; } DrawString(5, m_textLine, "****PAUSED****"); m_textLine += 15; } uint32 flags = 0; flags += settings->drawShapes * b2DebugDraw::e_shapeBit; flags += settings->drawJoints * b2DebugDraw::e_jointBit; flags += settings->drawCoreShapes * b2DebugDraw::e_coreShapeBit; flags += settings->drawAABBs * b2DebugDraw::e_aabbBit; flags += settings->drawOBBs * b2DebugDraw::e_obbBit; flags += settings->drawPairs * b2DebugDraw::e_pairBit; flags += settings->drawCOMs * b2DebugDraw::e_centerOfMassBit; m_debugDraw.SetFlags(flags); m_world->SetWarmStarting(settings->enableWarmStarting > 0); m_world->SetPositionCorrection(settings->enablePositionCorrection > 0); m_world->SetContinuousPhysics(settings->enableTOI > 0); m_pointCount = 0; m_world->Step(timeStep, settings->iterationCount); m_world->Validate(); if (m_bomb != NULL && m_bomb->IsFrozen()) { m_world->DestroyBody(m_bomb); m_bomb = NULL; } if (settings->drawStats) { DrawString(5, m_textLine, "proxies(max) = %d(%d), pairs(max) = %d(%d)", m_world->GetProxyCount(), b2_maxProxies, m_world->GetPairCount(), b2_maxPairs); m_textLine += 15; DrawString(5, m_textLine, "bodies/contacts/joints = %d/%d/%d", m_world->GetBodyCount(), m_world->GetContactCount(), m_world->GetJointCount()); m_textLine += 15; DrawString(5, m_textLine, "heap bytes = %d", b2_byteCount); m_textLine += 15; } if (m_mouseJoint) { b2Body* body = m_mouseJoint->GetBody2(); b2Vec2 p1 = body->GetWorldPoint(m_mouseJoint->m_localAnchor); b2Vec2 p2 = m_mouseJoint->m_target; glPointSize(4.0f); glColor3f(0.0f, 1.0f, 0.0f); glBegin(GL_POINTS); glVertex2f(p1.x, p1.y); glVertex2f(p2.x, p2.y); glEnd(); glPointSize(1.0f); glColor3f(0.8f, 0.8f, 0.8f); glBegin(GL_LINES); glVertex2f(p1.x, p1.y); glVertex2f(p2.x, p2.y); glEnd(); } if (settings->drawContactPoints) { //const float32 k_impulseScale = 0.1f; const float32 k_axisScale = 0.3f; for (int32 i = 0; i < m_pointCount; ++i) { ContactPoint* point = m_points + i; if (point->state == 0) { // Add DrawPoint(point->position, 10.0f, b2Color(0.3f, 0.95f, 0.3f)); } else if (point->state == 1) { // Persist DrawPoint(point->position, 5.0f, b2Color(0.3f, 0.3f, 0.95f)); } else { // Remove DrawPoint(point->position, 10.0f, b2Color(0.95f, 0.3f, 0.3f)); } if (settings->drawContactNormals == 1) { b2Vec2 p1 = point->position; b2Vec2 p2 = p1 + k_axisScale * point->normal; DrawSegment(p1, p2, b2Color(0.4f, 0.9f, 0.4f)); } else if (settings->drawContactForces == 1) { //b2Vec2 p1 = point->position; //b2Vec2 p2 = p1 + k_forceScale * point->normalForce * point->normal; //DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); } if (settings->drawFrictionForces == 1) { //b2Vec2 tangent = b2Cross(point->normal, 1.0f); //b2Vec2 p1 = point->position; //b2Vec2 p2 = p1 + k_forceScale * point->tangentForce * tangent; //DrawSegment(p1, p2, b2Color(0.9f, 0.9f, 0.3f)); } } } }
void CMapEditor10View::OnDraw(CDC* pDC) { CMapEditor10Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: 在此处为本机数据添加绘制代码 //画点 int i=0; int len=0; long tempX=0; long tempY=0; CPoint temp; if(1==GPntTmpFOpened&&isShowPnt==1) { len=GPntTmpFile.GetLength(); GPntTmpFile.Seek(0,CFile::begin); for(i=0;i<len/sizeof(PNT_STRU);i++) //遍历所有的点 { GPntTmpFile.Read(&PNT_STRU, sizeof( PNT_STRU )); if(PNT_STRU.isDel==GisShowDeleted) { DotDPtoVP(PNT_STRU); temp.x=PNT_STRU.x; temp.y=PNT_STRU.y; COLORREF Color=PNT_STRU.color; DrawPoint(temp,Color); } } } //画线 int ii=0; int j=0; int datalen=0; int ndxlen=0; int dotnum=0; int datff=0; CPoint ptemp; int linlen=sizeof(LIN_NDX_STRU); int plen=sizeof(D_DOT); if(1==GLinFCreated) { datalen=GLinTmpFile2.GetLength(); ndxlen=GLinTmpFile1.GetLength(); GLinTmpFile2.Seek(0,CFile::begin); GLinTmpFile1.Seek(0,CFile::begin); for(ii=0;ii< ndxlen / linlen;ii++) //遍历所有的线索引 { GLinTmpFile1.Read(&LIN_NDX_STRU, linlen); if(LIN_NDX_STRU.isDel==0&&GCurLINState==0) //画出没被删掉的线 { dotnum=LIN_NDX_STRU.dotNum; datff=LIN_NDX_STRU.datOff; GLinTmpFile2.Seek(datff,CFile::begin); POINT *p=new POINT[dotnum]; for(j=0; j < dotnum ; j++) { GLinTmpFile2.Read(&D_DOT, plen ); DotDPtoVP(D_DOT); //新加的 ptemp.x=D_DOT.x; ptemp.y=D_DOT.y; p[j]=ptemp; } for(j=0; j < dotnum ; j++) { if(j==0) pDC->MoveTo(p[j]); else pDC->LineTo(p[j]); } } else if(LIN_NDX_STRU.isDel==1&&GCurLINState==1) //画被删掉的线 { dotnum=LIN_NDX_STRU.dotNum; datff=LIN_NDX_STRU.datOff; GLinTmpFile2.Seek(datff,CFile::begin); POINT *p=new POINT[dotnum]; for(j=0; j < dotnum ; j++) { GLinTmpFile2.Read(&D_DOT, plen ); ptemp.x=D_DOT.x; ptemp.y=D_DOT.y; p[j]=ptemp; } for(j=0; j < dotnum ; j++) { if(j==0) pDC->MoveTo(p[j]); else pDC->LineTo(p[j]); } } } ReleaseDC(pDC); } //画区 CClientDC dc(this); if(GRegTmpFOpened==1&&isShowReg==1) { for(i=1;i<=GRegNum;i++) { if(GetAReg(i,regNdx,regPntdat,500)==1) { if(regNdx.isDel==GisShowDeleted) { CPen pen(PS_SOLID,1,regNdx.color); dc.SelectObject(&pen); CBrush brush(regNdx.color); dc.SelectObject (&brush); dc.SetROP2(R2_NOTXORPEN); SomeDotDPtoVP(regPntdat,regNdx.dotNum); for(j=0;j<regNdx.dotNum;j++) { regPnt[j].x=regPntdat[j].x; regPnt[j].y=regPntdat[j].y; } DrawAReg(regPnt,regNdx.dotNum,&dc); } } } } ReleaseDC(pDC); //清空移动线数据 firstlinnum=0; seclinnum=0; isfirst=0; issecond=0; MakingLine=0; //状态栏 CString sMousePos; CString Pntnum="点:"; CString Linnum="线:"; CString Regnum="区:"; sMousePos.Format(_T(" %s %d %s %d %s %d"),Pntnum,GPntNum,Linnum,GLinNum,Regnum,GRegNum); AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR)->SetWindowText(sMousePos); }
/// TODO: This should probably move to track artist. void Envelope::DrawPoints(wxDC & dc, const wxRect & r, double h, double pps, bool dB, float zoomMin, float zoomMax) { h -= mOffset; wxASSERT( pps > 0 ); double tright = h + (r.width / pps); // TODO: Cache the gPrefs value. Reading it every time is inefficient. double dBRange = gPrefs->Read(wxT("/GUI/EnvdBRange"), ENV_DB_RANGE); dc.SetPen(AColor::envelopePen); dc.SetBrush(*wxWHITE_BRUSH); for (int i = 0; i < (int)mEnv.Count(); i++) { if (mEnv[i]->GetT() >= h && mEnv[i]->GetT() <= tright) { // Change colour if this is the draggable point... if (i == mDragPoint) { dc.SetPen(AColor::envelopePen); dc.SetBrush(AColor::envelopeBrush); } double v = mEnv[i]->GetVal(); int x = int ((mEnv[i]->GetT() - h) * pps); int y, y2; y = GetWaveYPos(v, zoomMin, zoomMax, r.height, dB, true, dBRange, false); if (!mMirror) { DrawPoint(dc, r, x, y, true); } else { y2 = GetWaveYPos(-v-.000000001, zoomMin, zoomMax, r.height, dB, true, dBRange, false); // This follows the same logic as the envelop drawing in // TrackArtist::DrawEnvelope(). // TODO: make this calculation into a reusable function. if (y2 - y < 9) { int value = (int)((zoomMax / (zoomMax - zoomMin)) * r.height); y = value - 4; y2 = value + 4; } DrawPoint(dc, r, x, y, true); DrawPoint(dc, r, x, y2, false); // Contour y = GetWaveYPos(v, zoomMin, zoomMax, r.height, dB, false, dBRange, false); y2 = GetWaveYPos(-v-.000000001, zoomMin, zoomMax, r.height, dB, false, dBRange, false); if (y <= y2) { DrawPoint(dc, r, x, y, true); DrawPoint(dc, r, x, y2, false); } } // Change colour back again if was the draggable point. if (i == mDragPoint) { dc.SetPen(AColor::envelopePen); dc.SetBrush(*wxWHITE_BRUSH); } } } }
//----------------------------------------------------------------------------------- void Renderer::DrawPoint(const Vector2& point, const RGBA& color /*= RGBA::WHITE*/, float pointSize /*= 1.0f*/) { DrawPoint(point.x, point.y, color, pointSize); }
/** * zeichnet das Fenster. */ void ctrlColorDeepening::DrawContent() const { DrawRectangle(GetDrawPos() + DrawPoint(3, 3), width_ - 6, height_ - 6, fillColor); }
void MjbSphere(float radius, int slices, int stacks) { struct point top, bot; // top, bottom points struct point *p; // set the globals: NumLngs = slices; NumLats = stacks; if (NumLngs < 3) NumLngs = 3; if (NumLats < 3) NumLats = 3; // allocate the point data structure: Pts = new struct point[NumLngs * NumLats]; // fill the Pts structure: for (int ilat = 0; ilat < NumLats; ilat++) { float lat = -M_PI / 2. + M_PI * (float)ilat / (float)(NumLats - 1); float xz = cos(lat); float y = sin(lat); for (int ilng = 0; ilng < NumLngs; ilng++) { float lng = -M_PI + 2. * M_PI * (float)ilng / (float)(NumLngs - 1); float x = xz * cos(lng); float z = -xz * sin(lng); p = PtsPointer(ilat, ilng); p->x = radius * x; p->y = radius * y; p->z = radius * z; p->nx = x; p->ny = y; p->nz = z; if (Distort) { if (ilat >= NumLats / 2) { p->s = (lng + M_PI) / (2.*M_PI) ; //p->s = (lng + M_PI) / (2.*M_PI) * sin(count/2./M_PI); p->t = (lat + M_PI / 2.) / M_PI + sin((M_PI / 4 + lat + count)) * cos((M_PI / 4 + lat + count)) * .2; } else { p->s = (lng + M_PI) / (2.*M_PI); p->t = (lat + M_PI / 2.) / M_PI + sin((M_PI / 4 + lat + count)) * cos((M_PI / 4 + lat + count)) * .2; } } else { p->s = (lng + M_PI) / (2.*M_PI); p->t = (lat + M_PI / 2.) / M_PI; } } } top.x = 0.; top.y = radius; top.z = 0.; top.nx = 0.; top.ny = 1.; top.nz = 0.; top.s = 0.; top.t = 1.; bot.x = 0.; bot.y = -radius; bot.z = 0.; bot.nx = 0.; bot.ny = -1.; bot.nz = 0.; bot.s = 0.; bot.t = 0.; // connect the north pole to the latitude NumLats-2: glBegin(GL_QUADS); for (int ilng = 0; ilng < NumLngs - 1; ilng++) { p = PtsPointer(NumLats - 1, ilng); DrawPoint(p); p = PtsPointer(NumLats - 2, ilng); DrawPoint(p); p = PtsPointer(NumLats - 2, ilng + 1); DrawPoint(p); p = PtsPointer(NumLats - 1, ilng + 1); DrawPoint(p); } glEnd(); // connect the south pole to the latitude 1: glBegin(GL_QUADS); for (int ilng = 0; ilng < NumLngs - 1; ilng++) { p = PtsPointer(0, ilng); DrawPoint(p); p = PtsPointer(0, ilng + 1); DrawPoint(p); p = PtsPointer(1, ilng + 1); DrawPoint(p); p = PtsPointer(1, ilng); DrawPoint(p); } glEnd(); // connect the other 4-sided polygons: glBegin(GL_QUADS); for (int ilat = 2; ilat < NumLats - 1; ilat++) { for (int ilng = 0; ilng < NumLngs - 1; ilng++) { p = PtsPointer(ilat - 1, ilng); DrawPoint(p); p = PtsPointer(ilat - 1, ilng + 1); DrawPoint(p); p = PtsPointer(ilat, ilng + 1); DrawPoint(p); p = PtsPointer(ilat, ilng); DrawPoint(p); } } glEnd(); delete[] Pts; Pts = NULL; }
void MemoryImage::DrawLine(double x1, double y1, double x2, double y2, double color, Mode mode) { x1 *= m_oversample; x2 *= m_oversample; y1 *= m_oversample; y2 *= m_oversample; double dx = (double)x2 - (double)x1; double dy = (double)y2 - (double)y1; if (abs(dx) > abs(dy)) { if (x2 < x1) { swap(x1, x2); swap(y1, y2); } double gradient = dy / dx; double xend = round_(x1); double yend = y1 + gradient*(xend - x1); double xgap = rfpart_(x1 + 0.5); int xpxl1 = xend; int ypxl1 = ipart_(yend); DrawPoint(xpxl1, ypxl1, color* rfpart_(yend)*xgap,mode); DrawPoint(xpxl1, ypxl1 + 1, color* fpart_(yend)*xgap,mode); double intery = yend + gradient; xend = round_(x2); yend = y2 + gradient*(xend - x2); xgap = fpart_(x2 + 0.5); int xpxl2 = xend; int ypxl2 = ipart_(yend); DrawPoint(xpxl2, ypxl2, color* rfpart_(yend) * xgap,mode); DrawPoint(xpxl2, ypxl2 + 1, color* fpart_(yend) * xgap,mode); int x; for (x = xpxl1 + 1; x <= (xpxl2 - 1); x++) { DrawPoint(x, ipart_(intery), color* rfpart_(intery),mode); DrawPoint(x, ipart_(intery) + 1, color* fpart_(intery),mode); intery += gradient; } } else { if (y2 < y1) { swap(x1, x2); swap(y1, y2); } double gradient = dx / dy; double yend = round_(y1); double xend = x1 + gradient*(yend - y1); double ygap = rfpart_(y1 + 0.5); int ypxl1 = yend; int xpxl1 = ipart_(xend); DrawPoint(xpxl1, ypxl1, color* rfpart_(xend)*ygap, mode); DrawPoint(xpxl1, ypxl1 + 1, color* fpart_(xend)*ygap, mode); double interx = xend + gradient; yend = round_(y2); xend = x2 + gradient*(yend - y2); ygap = fpart_(y2 + 0.5); int ypxl2 = yend; int xpxl2 = ipart_(xend); DrawPoint(xpxl2, ypxl2, color* rfpart_(xend) * ygap, mode); DrawPoint(xpxl2, ypxl2 + 1, color* fpart_(xend) * ygap,mode); int y; for (y = ypxl1 + 1; y <= (ypxl2 - 1); y++) { DrawPoint(ipart_(interx), y, color* rfpart_(interx),mode); DrawPoint(ipart_(interx) + 1, y, color* fpart_(interx),mode); interx += gradient; } } }
void MyApp::DrawGlobalMode() { FvRobotMainApp::SpaceList& kSpaceList = FvRobotMainApp::pInstance()->GetSpaceList(); FvRobotMainApp::SpaceEntityList& kSpaceEntityList = FvRobotMainApp::pInstance()->GetSpaceEntityList(); int lineStart(LINE_START); int lineStep(LINE_STEP); //! 显示地图信息 DrawString(0, lineStart, CLR_WHITE, "-------Global Mode-------"); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "ShowHelpInfo: H"); lineStart += lineStep; if(1) { int iCtrlers(0), iOthers(0); if(kSpaceEntityList.size()) { FvRobotMainApp::SpaceEntity* pkSpaceEntity(NULL); if(m_iSpaceIdx >= (int)kSpaceEntityList.size()) { m_bResetWindow4Space = true; m_iSpaceIdx = m_iSpaceIdx % kSpaceEntityList.size(); } DrawString(0, lineStart, CLR_WHITE, "Spaces:%d,Idx:%d", kSpaceEntityList.size(), m_iSpaceIdx); lineStart += lineStep; int idx(0); FvRobotMainApp::SpaceEntityList::iterator itrB = kSpaceEntityList.begin(); FvRobotMainApp::SpaceEntityList::iterator itrE = kSpaceEntityList.end(); while(itrB != itrE) { if(idx == m_iSpaceIdx) { pkSpaceEntity = &(*itrB); break; } ++itrB; ++idx; } DrawString(0, lineStart, CLR_WHITE, "id:%d, type:%d", pkSpaceEntity->m_iSpaceID, pkSpaceEntity->m_uiSpaceType); lineStart += lineStep; //! 显示Space { const FvRobotMainApp::SpaceInfo* pkSpaceInfo = FvRobotMainApp::Instance().FindSpaceInfo(pkSpaceEntity->m_uiSpaceType); FV_ASSERT(pkSpaceInfo); if(m_bResetWindow4Space) { m_bResetWindow4Space = false; SetWindowFit2Rect(pkSpaceInfo->kSpaceRect); } for(int i=0; i<(int)pkSpaceInfo->kCells.size(); ++i) { DrawRect(pkSpaceInfo->kCells[i], CLR_YELLOW); } DrawRect(pkSpaceInfo->kSpaceRect, CLR_YELLOW); } //! 显示实体 if(1) { FvRobotMainApp::Entities& kEntityMap = pkSpaceEntity->m_kEntities; //! 显示实体数量 DrawString(0, lineStart, CLR_WHITE, "Entities:%d", kEntityMap.size()); lineStart += lineStep; FvRobotMainApp::Entities::iterator itrB = kEntityMap.begin(); FvRobotMainApp::Entities::iterator itrE = kEntityMap.end(); while(itrB != itrE) { FvEntity* pkEntity = itrB->second; p2Clr clr; const FvVector3& p3 = pkEntity->GetPos(); FvVector2 p2(p3.x, p3.y); int x,y; char charID[32] = {0}; char robotID[32] = {0}; char charPos[64] = {0}; bool bConvertPos(false); if(m_bShowEntityID) { bConvertPos = true; sprintf(charID, "%d", pkEntity->GetEntityID()); } if(m_bShowRobotID) { bConvertPos = true; sprintf(robotID, "%d", pkEntity->GetRobotID()); } if(m_bShowEntityPos) { bConvertPos = true; sprintf(charPos, "%.2f,%.2f,%.2f", p3.x, p3.y, p3.z); } if(bConvertPos) { ConvertWorldToScreen(p2, x, y); } if(pkEntity->IsCtrler())//! ctrler { ++iCtrlers; clr = CLR_RED; DrawPoint(p3, clr); if(m_bShowEntityID) { DrawString(x, y, clr, charID); } if(m_bShowRobotID) { DrawString(x, y-lineStep, clr, robotID); } if(m_bShowEntityPos) { DrawString(x, y+lineStep, clr, charPos); } } else//! others { ++iOthers; clr = CLR_BLUE; DrawPoint(p3, clr); if(m_bShowEntityID) { DrawString(x, y, clr, charID); } if(m_bShowEntityPos) { DrawString(x, y+lineStep, clr, charPos); } } //! 显示非Ctrler实体的属性,测试Lod if(m_bShowEntityProp) { /** FvEntity* pkOther = pkEntity; DrawString(0, lineStart, CLR_WHITE, "-------------"); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "Entity:%d", pkOther->GetEntityID()); lineStart += lineStep; const FvEntityDescription* pkEntityDes = pkOther->GetEntityDes(); FvUInt32 cnt = pkEntityDes->PropertyCount(); for(FvUInt32 i=0; i<cnt; ++i) { FvDataDescription* pkDataDes = pkEntityDes->Property(i); FvObjPtr spObj = pkOther->FindProperty(i); if(!spObj) continue; switch(spObj->RTTI()) { case FVOBJ_RTTI_INT8: { FvInt8 v = FVOBJ_GETVAL(spObj, FvObjInt8); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT8: { FvUInt8 v = FVOBJ_GETVAL(spObj, FvObjUInt8); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_INT16: { FvInt16 v = FVOBJ_GETVAL(spObj, FvObjInt16); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT16: { FvUInt16 v = FVOBJ_GETVAL(spObj, FvObjUInt16); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_INT32: { FvInt32 v = FVOBJ_GETVAL(spObj, FvObjInt32); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT32: { FvUInt32 v = FVOBJ_GETVAL(spObj, FvObjUInt32); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_INT64: { FvInt64 v = FVOBJ_GETVAL(spObj, FvObjInt64); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT64: { FvUInt64 v = FVOBJ_GETVAL(spObj, FvObjUInt64); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64u", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_FLOAT: { float v = FVOBJ_GETVAL(spObj, FvObjFloat); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_DOUBLE: { double v = FVOBJ_GETVAL(spObj, FvObjDouble); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_STRING: { FvString v = FVOBJ_GETVAL(spObj, FvObjString); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), v.c_str()); } break; case FVOBJ_RTTI_MAILBOX: { FVOBJ_CONVERT_P(spObj, FvObjMailBox, pMB); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), pMB->c_str()); } break; default: { DrawString(0, lineStart, CLR_WHITE, "PropName:%s", pkDataDes->Name().c_str()); } break; } lineStart += lineStep; } **/ } ++itrB; } } DrawString(0, lineStart, CLR_WHITE, "Ctrler:%d, Others:%d", iCtrlers, iOthers); lineStart += lineStep; } else { DrawString(0, lineStart, CLR_WHITE, "Spaces:%d,Idx:%d", 0, 0); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "Entities:%d", 0); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "Ctrler:%d, Others:%d", 0, 0); lineStart += lineStep; } } }
void MyApp::DrawSingleMode() { FvRobotClientAppPtr spApp = FvRobotMainApp::Instance().GetRobotInSingleMode(); int lineStart(LINE_START); int lineStep(LINE_STEP); //! 显示地图信息 DrawString(0, lineStart, CLR_WHITE, "-------Single Mode-------"); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "ShowHelpInfo: H"); lineStart += lineStep; if(!spApp) { DrawString(0, lineStart, CLR_WHITE, "Err: No Selected Robot"); lineStart += lineStep; return; } if(1) { DrawString(0, lineStart, CLR_WHITE, "ServerTime:%.1f", spApp->GetServerConnection()->ServerTime()); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "ServerToDScaling:%.2f,ServerToD:%.2f", spApp->GetToDScaling(), spApp->GetToD()); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "SpaceID:%d, Type:%d, RobotID:%d", spApp->SpaceID(), spApp->SpaceType(), spApp->RobotID()); lineStart += lineStep; //! 显示Space const FvRobotMainApp::SpaceInfo* pkSpaceInfo = FvRobotMainApp::Instance().FindSpaceInfo(spApp->SpaceType()); if(!pkSpaceInfo) { DrawString(0, lineStart, CLR_WHITE, "Err:No Space Info"); lineStart += lineStep; return; } else { if(m_bResetWindow4Space) { m_bResetWindow4Space = false; SetWindowFit2Rect(pkSpaceInfo->kSpaceRect); } for(int i=0; i<(int)pkSpaceInfo->kCells.size(); ++i) { DrawRect(pkSpaceInfo->kCells[i], CLR_YELLOW); } DrawRect(pkSpaceInfo->kSpaceRect, CLR_YELLOW); } //! 显示实体 if(1) { const FvRobotClientApp::EntityMap& kEntityMap = spApp->GetEntityMap(); //! 显示实体数量 DrawString(0, lineStart, CLR_WHITE, "Entities:%d", kEntityMap.size()); lineStart += lineStep; FvRobotClientApp::EntityMap::const_iterator itrB = kEntityMap.begin(); FvRobotClientApp::EntityMap::const_iterator itrE = kEntityMap.end(); while(itrB != itrE) { FvEntity* pkEntity = itrB->second; p2Clr clr; const FvVector3& p3 = pkEntity->GetPos(); FvVector2 p2(p3.x, p3.y); int x,y; char charID[32] = {0}; char robotID[32] = {0}; char charPos[64] = {0}; bool bConvertPos(false); if(m_bShowEntityID) { bConvertPos = true; sprintf(charID, "%d", pkEntity->GetEntityID()); } if(m_bShowRobotID) { bConvertPos = true; sprintf(robotID, "%d", pkEntity->GetRobotID()); } if(m_bShowEntityPos) { bConvertPos = true; sprintf(charPos, "%.2f,%.2f,%.2f", p3.x, p3.y, p3.z); } if(bConvertPos) { ConvertWorldToScreen(p2, x, y); } if(pkEntity->IsCtrler())//! ctrler { clr = CLR_RED; DrawPoint(p3, clr); if(m_bShowEntityID) { DrawString(x, y, clr, charID); } if(m_bShowRobotID) { DrawString(x, y-lineStep, clr, robotID); } if(m_bShowEntityPos) { DrawString(x, y+lineStep, clr, charPos); } } else//! others { clr = CLR_BLUE; DrawPoint(p3, clr); if(m_bShowEntityID) { DrawString(x, y, clr, charID); } if(m_bShowEntityPos) { DrawString(x, y+lineStep, clr, charPos); } } //! 显示非Ctrler实体的属性,测试Lod if(m_bShowEntityProp) { /** FvEntity* pkOther = pkEntity; DrawString(0, lineStart, CLR_WHITE, "-------------"); lineStart += lineStep; DrawString(0, lineStart, CLR_WHITE, "Entity:%d", pkOther->GetEntityID()); lineStart += lineStep; const FvEntityDescription* pkEntityDes = pkOther->GetEntityDes(); FvUInt32 cnt = pkEntityDes->PropertyCount(); for(FvUInt32 i=0; i<cnt; ++i) { FvDataDescription* pkDataDes = pkEntityDes->Property(i); FvObjPtr spObj = pkOther->FindProperty(i); if(!spObj) continue; switch(spObj->RTTI()) { case FVOBJ_RTTI_INT8: { FvInt8 v = FVOBJ_GETVAL(spObj, FvObjInt8); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT8: { FvUInt8 v = FVOBJ_GETVAL(spObj, FvObjUInt8); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_INT16: { FvInt16 v = FVOBJ_GETVAL(spObj, FvObjInt16); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT16: { FvUInt16 v = FVOBJ_GETVAL(spObj, FvObjUInt16); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_INT32: { FvInt32 v = FVOBJ_GETVAL(spObj, FvObjInt32); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT32: { FvUInt32 v = FVOBJ_GETVAL(spObj, FvObjUInt32); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_INT64: { FvInt64 v = FVOBJ_GETVAL(spObj, FvObjInt64); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64d", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_UINT64: { FvUInt64 v = FVOBJ_GETVAL(spObj, FvObjUInt64); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%I64u", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_FLOAT: { float v = FVOBJ_GETVAL(spObj, FvObjFloat); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_DOUBLE: { double v = FVOBJ_GETVAL(spObj, FvObjDouble); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%f", pkDataDes->Name().c_str(), v); } break; case FVOBJ_RTTI_STRING: { FvString v = FVOBJ_GETVAL(spObj, FvObjString); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), v.c_str()); } break; case FVOBJ_RTTI_MAILBOX: { FVOBJ_CONVERT_P(spObj, FvObjMailBox, pMB); DrawString(0, lineStart, CLR_WHITE, "PropName:%s,Val:%s", pkDataDes->Name().c_str(), pMB->c_str()); } break; default: { DrawString(0, lineStart, CLR_WHITE, "PropName:%s", pkDataDes->Name().c_str()); } break; } lineStart += lineStep; } **/ } ++itrB; } } } }