Skip to content

Commit f34f403

Browse files
committed
add removeEverything() function
1 parent 3fa1cb7 commit f34f403

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

include/polyscope/polyscope.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ void frameTick();
6363
// Do shutdown work and de-initialize Polyscope
6464
void shutdown(bool allowMidFrameShutdown = false);
6565

66+
// Remove all structures / quantities / groups / slice planes / callbacks / etc, as if Polyscope was just initialized.
67+
// (But does _not_ reset option & config settings, nor de-initialize the render engine)
68+
void removeEverything();
69+
6670
// Returns true if the user has tried to exit the window at the OS level, e.g clicking the close button. Useful for
6771
// deciding when to exit your control loop when using frameTick()
6872
bool windowRequestsClose();

src/polyscope.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,18 @@ bool isHeadless() {
12081208
return false;
12091209
}
12101210

1211+
void removeEverything() {
1212+
removeAllStructures();
1213+
removeAllGroups();
1214+
removeAllSlicePlanes();
1215+
removeAllTransformationGizmos();
1216+
clearMessages();
1217+
state::userCallback = nullptr;
1218+
state::filesDroppedCallback = nullptr;
1219+
options::configureImGuiStyleCallback = configureImGuiStyle; // restore defaults
1220+
options::prepareImGuiFontsCallback = loadBaseFonts;
1221+
}
1222+
12111223
void shutdown(bool allowMidFrameShutdown) {
12121224
checkInitialized();
12131225

@@ -1220,16 +1232,7 @@ void shutdown(bool allowMidFrameShutdown) {
12201232
writePrefsFile();
12211233
}
12221234

1223-
// Clear out all structures and other scene objects
1224-
removeAllStructures();
1225-
removeAllGroups();
1226-
removeAllSlicePlanes();
1227-
removeAllTransformationGizmos();
1228-
clearMessages();
1229-
state::userCallback = nullptr;
1230-
state::filesDroppedCallback = nullptr;
1231-
options::configureImGuiStyleCallback = configureImGuiStyle; // restore defaults
1232-
options::prepareImGuiFontsCallback = loadBaseFonts;
1235+
removeEverything();
12331236

12341237
// Shut down the render engine
12351238
render::engine->shutdown();

src/view.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ float computeRelativeMotionScale() {
424424
return state::lengthScale;
425425
}
426426
}
427+
return -1.; // should be unreachable
427428
}
428429

429430
void projectCenterToBeValidForView() {

0 commit comments

Comments
 (0)