Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,11 @@ public class RDXSCS2Session
private final StatelessNotification sessionStoppedNotification = new StatelessNotification();

public RDXSCS2Session(RDXBaseUI baseUI)
{
this(baseUI, null);
}

public RDXSCS2Session(RDXBaseUI baseUI, RDXPanel plotManagerParentPanel)
{
baseUI.getImGuiPanelManager().addPanel(controlPanel);

baseUI.getPrimaryScene().addRenderableAdapter(renderables);
plotManager.create(baseUI.getLayoutManager(), plotManagerParentPanel == null ? controlPanel : plotManagerParentPanel);
plotManager.create(baseUI.getLayoutManager(), controlPanel);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void startSession(SimulationSession simulationSession)
bulletPhysicsDebugger.drawBulletDebugDrawings();

// This technically belongs in RDXSCS2Session, but there's no after tick callback for a regular session
if (pauseAtEndOfBuffer.get() && yoManager.getCurrentIndex() == yoManager.getBufferSize() - 2)
if (pauseAtEndOfBuffer.get() && session.getBufferProperties().getCurrentIndex() == session.getBufferProperties().getSize() - 1)
{
session.setSessionMode(SessionMode.PAUSE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,13 @@ public void addVariableWidget(String variableName)
{
variableWidgets.add(new RDXLinkedYoBooleanWidget(yoManager, variableName));
}

public ImPlotModifiableYoPlotPanel getPlotPanel(String name)
{
for (ImPlotModifiableYoPlotPanel plotPanel : plotPanels)
if (plotPanel.getPanelName().equals(name))
return plotPanel;

return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package us.ihmc.rdx.ui.yo;

import imgui.internal.ImGui;
import imgui.type.ImInt;
import us.ihmc.rdx.imgui.RDXPanel;
import us.ihmc.rdx.imgui.ImGuiUniqueLabelMap;
import us.ihmc.rdx.simulation.scs2.RDXYoManager;
import us.ihmc.rdx.imgui.ImPlotPlotPanelLayout;

import java.util.ArrayList;
import java.util.function.Consumer;

public class ImPlotModifiableYoPlotPanel extends RDXPanel
{
private final ArrayList<ImPlotModifiableYoPlot> yoPlots = new ArrayList<>();
private final ImPlotPlotPanelLayout layout = new ImPlotPlotPanelLayout();
private final ImGuiUniqueLabelMap labels = new ImGuiUniqueLabelMap(getClass());
private final ArrayList<ImPlotModifiableYoPlot> yoPlots = new ArrayList<>();
private final ImInt numberOfRows = new ImInt(1);
private final ImInt numberOfColumns = new ImInt(1);
private final ImInt plotHeight = new ImInt(60);
private float plotWidth;
private final ImGuiYoVariableSearchPanel yoVariableSearchPanel;
private final RDXYoManager yoManager;
private final Consumer<ImPlotModifiableYoPlotPanel> removeSelf;
Expand All @@ -28,21 +31,35 @@ public ImPlotModifiableYoPlotPanel(String panelName,
this.yoManager = yoManager;
this.removeSelf = removeSelf;
setRenderMethod(this::render);
layout.setPlotRenderer(this::renderPlot, yoPlots::size);
}

private void renderPlot(int i)
{
yoPlots.get(i).render(layout.getPlotWidth(), layout.getPlotHeight());
}

public void render()
{
ImGui.beginMenuBar();
layout.renderLayoutMenu();
if (ImGui.beginMenu(labels.get("Layout")))
{
ImGui.pushItemWidth(100);
if (ImGui.inputInt(labels.get("Number of rows"), numberOfRows))
{
if (numberOfRows.get() < 1)
numberOfRows.set(1);
}
if (ImGui.inputInt(labels.get("Number of columns"), numberOfColumns))
{
if (numberOfColumns.get() < 1)
numberOfColumns.set(1);
}
if (ImGui.inputInt(labels.get("Plot height"), plotHeight))
{
if (plotHeight.get() < 10)
plotHeight.set(10);
}
ImGui.popItemWidth();
ImGui.endMenu();
}
if (ImGui.beginMenu(labels.get("Plots")))
{
if (ImGui.menuItem("Add Plot"))
if (ImGui.button(labels.get("Add Plot")))
{
addPlot();
}
Expand All @@ -55,7 +72,23 @@ public void render()

ImGui.endMenuBar();

layout.renderPlots();
plotWidth = ImGui.getColumnWidth() / numberOfColumns.get();

for (int i = 0; i < yoPlots.size(); i++)
{
yoPlots.get(i).render(plotWidth, plotHeight.get());

if (i % numberOfColumns.get() != numberOfColumns.get() - 1)
ImGui.sameLine();
}
}

public ImPlotModifiableYoPlot addPlot(String... variables)
{
ImPlotModifiableYoPlot plot = addPlot();
for (String variable : variables)
plot.addVariable(yoManager.getRootRegistry().findVariable(variable), false);
return plot;
}

public ImPlotModifiableYoPlot addPlot()
Expand All @@ -74,4 +107,14 @@ public ArrayList<ImPlotModifiableYoPlot> getYoPlots()
{
return yoPlots;
}

public void setNumberOfRows(int numberOfRows)
{
this.numberOfRows.set(numberOfRows);
}

public void setNumberOfColumns(int numberOfColumns)
{
this.numberOfColumns.set(numberOfColumns);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package us.ihmc.rdx.ui.plotting;

import us.ihmc.rdx.Lwjgl3ApplicationAdapter;
import us.ihmc.rdx.sceneManager.RDXSceneLevel;
import us.ihmc.rdx.simulation.scs2.RDXSCS2SimulationSession;
import us.ihmc.rdx.ui.RDXBaseUI;
import us.ihmc.rdx.ui.yo.ImPlotModifiableYoPlotPanel;
import us.ihmc.scs2.examples.simulations.bullet.StackOfBoxesExperimentalBulletSimulation;
import us.ihmc.scs2.session.SessionMode;

public class RDXSCS2StyleChartDemo
{
private final RDXBaseUI baseUI;
private RDXSCS2SimulationSession session;

public RDXSCS2StyleChartDemo()
{
Expand All @@ -16,21 +22,36 @@ public RDXSCS2StyleChartDemo()
@Override
public void create()
{
baseUI.create();
baseUI.create(RDXSceneLevel.values());

baseUI.getImGuiPanelManager().addPanel("Plot", this::renderImGuiWidgets);
}

private void renderImGuiWidgets()
{
session = new RDXSCS2SimulationSession(baseUI);
session.startSession(StackOfBoxesExperimentalBulletSimulation.createSession());
session.changeBufferDuration(1.0);
session.getSession().setSessionMode(SessionMode.RUNNING);

ImPlotModifiableYoPlotPanel plotPanel = session.getPlotManager().getPlotPanel("Poses");
plotPanel.setNumberOfRows(7);
plotPanel.setNumberOfColumns(5);
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_x".formatted(i, i));
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_y".formatted(i, i));
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_z".formatted(i, i));
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_qx".formatted(i, i));
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_qy".formatted(i, i));
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_qz".formatted(i, i));
for (int i = 0; i < 5; i++)
plotPanel.addPlot("root.Block%d.q_Block%d_qs".formatted(i, i));
}

@Override
public void render()
{


session.update();

baseUI.renderBeforeOnScreenUI();
baseUI.renderEnd();
Expand All @@ -39,6 +60,7 @@ public void render()
@Override
public void dispose()
{
session.destroy(baseUI);
baseUI.dispose();
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"dockspacePanels" : { },
"windows" : {
"3D View" : true,
"SCS 2 Session" : true,
"Poses" : true,
"YoVariable Search" : false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[Window][DockSpaceViewport_11111111]
Pos=0,22
Size=1735,1021
Collapsed=0

[Window][SCS 2 Session]
Pos=0,22
Size=343,1021
Collapsed=0
DockId=0x00000001,0

[Window][3D View]
Pos=345,22
Size=1390,462
Collapsed=0
DockId=0x00000003,0

[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0

[Window][Poses]
Pos=345,486
Size=1390,557
Collapsed=0
DockId=0x00000004,0

[Docking][Data]
DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=445,193 Size=1735,1021 Split=X Selected=0x2E64DC63
DockNode ID=0x00000001 Parent=0x8B93E3BD SizeRef=343,1031 Selected=0x29EC79FC
DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=1390,1031 Split=Y Selected=0x2E64DC63
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=1390,462 CentralNode=1 Selected=0x2E64DC63
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=1390,557 Selected=0x1A45B6EE

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"panels" : [ {
"name" : "Poses",
"plots" : [ ]
} ]
}
Loading