use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class Main method clearRootModel.
public void clearRootModel() {
myWorkspace.cancelRenderRequests();
myModelName = null;
myModelFile = null;
RootModel rootModel = getRootModel();
if (rootModel != null) {
rootModel.detach(this);
rootModel.removeComponentChangeListener(this);
// just for completeness
rootModel.setMainViewer(null);
//
rootModel.removeController(myPullController);
rootModel.dispose();
}
mySelectionManager.clearSelections();
myUndoManager.clearCommands();
myWorkspace.removeDisposables();
ArtisynthPath.setWorkingDir(null);
// myWorkspace.clearOutputProbes();
if (myViewerManager != null) {
myViewerManager.clearRenderables();
}
getWorkspace().setRootModel(null);
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class MenuBarHandler method createHelpMenu.
private void createHelpMenu(JMenu menu) {
RootModel rootModel = myMain.getRootModel();
addMenuItem(menu, "About ArtiSynth");
addMenuItem(menu, "Keybindings");
if (rootModel.getAbout() != null && rootModel.getAbout().length() > 0) {
addMenuItem(menu, "About the current model");
}
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class MenuBarHandler method doAddControlPanel.
/**
* add a control panel to the model
*/
private void doAddControlPanel() {
RootModel root = myMain.getRootModel();
int number = root.getControlPanels().nextComponentNumber();
ControlPanel panel = new ControlPanel("panel " + number, "LiveUpdate Close");
GuiUtils.locateVertically(panel.getFrame(), myMain.getFrame(), GuiUtils.CENTER);
GuiUtils.locateHorizontally(panel.getFrame(), myMain.getFrame(), GuiUtils.RIGHT);
root.addControlPanel(panel);
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class TestCommands method testSaveAndLoad.
public String testSaveAndLoad(String baseFileName, String fmtStr, double tsim, double hsim) {
RootModel rootModel = myMain.getRootModel();
if (rootModel == null) {
return ("No root model loaded");
}
try {
System.out.println("TESTING saveAndLoad for " + rootModel.getName() + " ...");
String saveFileName = baseFileName + ".art";
String checkFileName = baseFileName + ".chk";
String stateFile0Name = rootModel.getName() + "_testdata0.txt";
String stateFile1Name = rootModel.getName() + "_testdata1.txt";
File saveFile = new File(saveFileName);
File checkFile = new File(checkFileName);
System.out.println("saving model to " + saveFileName + " ...");
myMain.saveModelFile(saveFile, fmtStr);
if (tsim > 0) {
MechModel mech = findMechModel(rootModel);
if (mech != null) {
System.out.println("running model for " + tsim + " seconds ...");
mech.setPrintState("%g", hsim);
mech.openPrintStateFile(stateFile0Name);
myMain.play(tsim);
myMain.waitForStop();
}
}
System.out.println("loading model from " + saveFileName + " ...");
myMain.loadModelFile(saveFile);
rootModel = myMain.getRootModel();
System.out.println("saving model from " + checkFileName + " ...");
myMain.saveModelFile(checkFile, fmtStr);
System.out.println("comparing files " + saveFileName + " and " + checkFileName + " ...");
String compareError = compareFiles(saveFileName, checkFileName, true);
if (compareError != null) {
System.out.println("FAILED");
return compareError;
} else {
saveFile.delete();
checkFile.delete();
}
if (tsim > 0) {
MechModel mech = findMechModel(rootModel);
if (mech != null) {
System.out.println("running restored model for " + tsim + " seconds ...");
mech.setPrintState("%g", hsim);
mech.openPrintStateFile(stateFile1Name);
myMain.play(tsim);
myMain.waitForStop();
CompareStateFiles comparator = new CompareStateFiles();
System.out.println("comparing run state files " + stateFile0Name + " and " + stateFile1Name + " ...");
if (!comparator.compareFiles(stateFile0Name, stateFile1Name, -1)) {
StringWriter sw = new StringWriter();
comparator.printMaxErrors(new PrintWriter(sw));
System.out.println("FAILED");
return sw.toString();
} else {
File stateFile0 = new File(stateFile0Name);
File stateFile1 = new File(stateFile1Name);
stateFile0.delete();
stateFile1.delete();
}
}
}
System.out.println("OK");
} catch (Exception e) {
e.printStackTrace();
return "IO Exception";
}
return null;
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class ViewerManager method buildRenderList.
RenderList buildRenderList() {
RenderList list = new RenderList();
list.addIfVisibleAll(myRenderables);
RootModel root = Main.getMain().getRootModel();
if (root != null) {
// modified by Ian: add RootModel to the render list,
// note that prerender is called by addIfVisible()
// root.prerender (list);
list.addIfVisible(root);
}
return list;
}
Aggregations