@@ -45,6 +45,7 @@ TEST_F(PolyscopeTest, FrameTickWithImgui) {
4545 polyscope::state::userCallback = nullptr ;
4646}
4747
48+
4849// We should be able to nest calls to show() via the callback. ImGUI causes headaches here
4950TEST_F (PolyscopeTest, NestedShow) {
5051
@@ -148,6 +149,55 @@ TEST_F(PolyscopeTest, ScreenshotBuffer) {
148149 EXPECT_EQ (buff2.size (), polyscope::view::bufferWidth * polyscope::view::bufferHeight * 4 );
149150}
150151
152+ TEST_F (PolyscopeTest, ImPlotBasic) {
153+
154+ std::vector<float > xvals = {0 ., 2 ., 4 ., 8 .};
155+
156+ auto showCallback = [&]() {
157+ ImGui::Button (" do something" );
158+ if (ImPlot::BeginPlot (" test plot" )) {
159+ ImPlot::PlotLine (" test line" , &xvals.front (), xvals.size ());
160+ ImPlot::EndPlot ();
161+ }
162+ };
163+ polyscope::state::userCallback = showCallback;
164+
165+ polyscope::show (3 );
166+
167+ for (int i = 0 ; i < 3 ; i++) {
168+ polyscope::frameTick ();
169+ }
170+
171+ polyscope::state::userCallback = nullptr ;
172+ }
173+
174+
175+ TEST_F (PolyscopeTest, ImPlotScreenshot) {
176+ // test this because there is some context logic duplicated there
177+
178+ std::vector<float > xvals = {0 ., 2 ., 4 ., 8 .};
179+
180+ auto showCallback = [&]() {
181+ ImGui::Button (" do something" );
182+ if (ImPlot::BeginPlot (" test plot" )) {
183+ ImPlot::PlotLine (" test line" , &xvals.front (), xvals.size ());
184+ ImPlot::EndPlot ();
185+ }
186+ };
187+ polyscope::state::userCallback = showCallback;
188+
189+ polyscope::show (3 );
190+
191+ polyscope::ScreenshotOptions opts;
192+ opts.includeUI = true ;
193+ opts.transparentBackground = false ;
194+ polyscope::screenshot (opts);
195+
196+ polyscope::show (3 );
197+
198+ polyscope::state::userCallback = nullptr ;
199+ }
200+
151201// ============================================================
152202// =============== View and navigation
153203// ============================================================
0 commit comments