use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class MenuBarHandler method createViewMenu.
private void createViewMenu(JMenu menu) {
JMenuItem item;
RootModel root = myMain.getRootModel();
boolean hasTraceables = root.getNumTraceables() > 0;
boolean hasTraces = false;
boolean hasVisibleTrace = false;
boolean hasInvisibleTrace = false;
for (Probe p : root.getOutputProbes()) {
if (p instanceof TracingProbe) {
hasTraces = true;
if (RenderableUtils.isVisible((TracingProbe) p)) {
hasVisibleTrace = true;
} else {
hasInvisibleTrace = true;
}
}
}
if (isTimelineVisible) {
addMenuItem(menu, "Hide timeline");
} else {
addMenuItem(menu, "Show timeline");
}
if (JythonInit.jythonIsAvailable()) {
if (myMain.myJythonFrame != null && myMain.myJythonFrame.isVisible()) {
addMenuItem(menu, "Hide Jython console");
} else {
addMenuItem(menu, "Show Jython console");
}
}
if (InverseManager.inverseControllerExists()) {
if (InverseManager.isInversePanelVisible()) {
addMenuItem(menu, "Hide Inverse panel");
} else {
addMenuItem(menu, "Show Inverse panel");
}
}
if (isToolbarVisible) {
addMenuItem(menu, "Hide viewer toolbar");
} else {
addMenuItem(menu, "Show viewer toolbar");
}
addMenuItem(menu, "Show movie panel");
menu.add(new JSeparator());
addMenuItem(menu, "New viewer");
SelectionManager sm = myMain.getSelectionManager();
if (sm.getNumSelected() > 0) {
addMenuItem(menu, "Center view on selection");
}
if (getMainViewer().isOrthogonal()) {
addMenuItem(menu, "Perspective view");
} else {
addMenuItem(menu, "Orthographic view");
}
menu.add(new JSeparator());
addMenuItem(menu, "Merge control panels");
addMenuItem(menu, "Separate control panels");
addMenuItem(menu, "Show progress");
if (myFrame.getNavPanel().getHideEmptyComponents()) {
addMenuItem(menu, "Show empty components in navpanel");
} else {
addMenuItem(menu, "Hide empty components in navpanel");
}
menu.add(new JSeparator());
item = addMenuItem(menu, "Clear traces");
item.setEnabled(hasTraceables);
item = addMenuItem(menu, "Disable all tracing");
item.setEnabled(hasTraceables);
item = addMenuItem(menu, "Remove traces");
item.setEnabled(hasTraces);
item = addMenuItem(menu, "Set traces visible");
item.setEnabled(hasInvisibleTrace);
item = addMenuItem(menu, "Set traces invisible");
item.setEnabled(hasVisibleTrace);
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class MenuBarHandler method doLoadControlPanel.
/**
* Load a control panel into the model
*/
private void doLoadControlPanel() {
RootModel root = myMain.getRootModel();
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(myMain.getModelDirectory());
int retVal = chooser.showOpenDialog(myFrame);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
ControlPanel panel = null;
try {
panel = (ControlPanel) ComponentUtils.loadComponent(file, root, ControlPanel.class);
} catch (Exception e) {
showError("Error reading file: " + e.getMessage());
}
if (panel != null) {
// panel.pack();
// panel.setVisible (true);
root.addControlPanel(panel);
myMain.setModelDirectory(chooser.getCurrentDirectory());
}
}
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class Scheduler method updateInitialStateIfNecessary.
private void updateInitialStateIfNecessary() {
if (!myInitialStateValidP) {
RootModel root = getRootModel();
WayPoint way0 = getWayPoint(0);
if (root != null && way0 != null) {
CompositeState state = (CompositeState) root.createState(null);
root.getInitialState(state, way0.getState());
way0.setState(state);
}
myInitialStateValidP = true;
}
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class TimelineController method loadWayPointsFrom.
public void loadWayPointsFrom() {
RootModel root = myMain.getRootModel();
WayPointProbe wayPoints = root.getWayPoints();
setAttachedFileFromUser(wayPoints, "Load From");
wayPoints.load();
refreshWayPoints(root);
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class TimelineController method resetAll.
// /**
// * Called internally when the step time is set by the GUI
// */
// void setStepTime (double newStep) {
// myScheduler.setStepTime (newStep);
// }
/**
* Resets the timeline. Called when it is first created and when new
* models are loaded.
*/
public void resetAll() {
// Assume that caller has ensured the scheduler is not running
// myScheduler.stopRequest();
// myScheduler.waitForPlayingToStop();
RootModel rootModel = myMain.getRootModel();
int count = myInTracks.size();
for (int i = 0; i < count; i++) {
deleteTrack(Track.TYPE_INPUT, 0, false);
}
count = myOutTracks.size();
for (int j = 0; j < count; j++) {
deleteTrack(Track.TYPE_OUTPUT, 0, false);
}
myProbeMap.clear();
// Add the root model on timeline
Track suitableTrack;
// Process all the input probes into proper places
for (Probe p : rootModel.getInputProbes()) {
addProbe(p);
}
// Process all the output probes into proper places
for (Probe p : rootModel.getOutputProbes()) {
if (!(p instanceof WayPointProbe)) {
addProbe(p);
}
}
// Process the waypoints
refreshWayPoints(rootModel);
// for (WayPoint wayPoint : getWayPoints().getPoints ()) {
// addWayPointFromRoot (wayPoint);
// }
// setAppropriateVirtualWaypoint (false);
// timescale.updateTimeCursor (0);
myToolBar.updateToolbarState(rootModel);
closeProbeEditors();
myProbeEditors = new ArrayList<NumericProbeEditor>();
selectedProbes = new ArrayList<ProbeInfo>();
expandToggle.setSelected(false);
muteToggle.setSelected(false);
updateWidgets(rootModel, /*refreshCursor=*/
true);
updateDisplay();
// requestUpdate (UPDATE_WIDGETS | REFRESH_CURSOR);
}
Aggregations