MCPcopy Create free account
hub / github.com/OrcaSlicer/OrcaSlicer / DebugNodeDrawList

Method DebugNodeDrawList

deps_src/imgui/imgui.cpp:11347–11438  ·  view source on GitHub ↗

[DEBUG] Display contents of ImDrawList

Source from the content-addressed store, hash-verified

11345
11346// [DEBUG] Display contents of ImDrawList
11347void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label)
11348{
11349 ImGuiContext& g = *GImGui;
11350 ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
11351 int cmd_count = draw_list->CmdBuffer.Size;
11352 if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL)
11353 cmd_count--;
11354 bool node_open = TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, cmd_count);
11355 if (draw_list == GetWindowDrawList())
11356 {
11357 SameLine();
11358 TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
11359 if (node_open)
11360 TreePop();
11361 return;
11362 }
11363
11364 ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list
11365 if (window && IsItemHovered())
11366 fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
11367 if (!node_open)
11368 return;
11369
11370 if (window && !window->WasActive)
11371 TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!");
11372
11373 for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++)
11374 {
11375 if (pcmd->UserCallback)
11376 {
11377 BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
11378 continue;
11379 }
11380
11381 char buf[300];
11382 ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
11383 pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId,
11384 pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
11385 bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
11386 if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list)
11387 DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes);
11388 if (!pcmd_node_open)
11389 continue;
11390
11391 // Calculate approximate coverage area (touched pixel count)
11392 // This will be in pixels squared as long there's no post-scaling happening to the renderer output.
11393 const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
11394 const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset;
11395 float total_area = 0.0f;
11396 for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; )
11397 {
11398 ImVec2 triangle[3];
11399 for (int n = 0; n < 3; n++, idx_n++)
11400 triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos;
11401 total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]);
11402 }
11403
11404 // Display vertex information summary. Hover to get all triangles drawn in wire-frame

Callers

nothing calls this directly

Calls 10

ImVec4Class · 0.85
GetForegroundDrawListFunction · 0.85
ImFormatStringFunction · 0.85
ImTriangleAreaFunction · 0.85
AddRectMethod · 0.80
BeginMethod · 0.80
AddPolylineMethod · 0.80
backMethod · 0.45
beginMethod · 0.45
StepMethod · 0.45

Tested by

no test coverage detected