Search in sources :

Example 26 with RootModel

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);
}
Also used : SelectionManager(artisynth.core.gui.selectionManager.SelectionManager) RootModel(artisynth.core.workspace.RootModel) TracingProbe(artisynth.core.probes.TracingProbe) JMenuItem(javax.swing.JMenuItem) Probe(artisynth.core.probes.Probe) TracingProbe(artisynth.core.probes.TracingProbe) JSeparator(javax.swing.JSeparator)

Example 27 with RootModel

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());
        }
    }
}
Also used : RootModel(artisynth.core.workspace.RootModel) JFileChooser(javax.swing.JFileChooser) ControlPanel(artisynth.core.gui.ControlPanel) File(java.io.File) InternalErrorException(maspack.util.InternalErrorException) IOException(java.io.IOException)

Example 28 with RootModel

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;
    }
}
Also used : RootModel(artisynth.core.workspace.RootModel)

Example 29 with RootModel

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);
}
Also used : RootModel(artisynth.core.workspace.RootModel) WayPointProbe(artisynth.core.probes.WayPointProbe)

Example 30 with RootModel

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);
}
Also used : RootModel(artisynth.core.workspace.RootModel) NumericProbeEditor(artisynth.core.gui.probeEditor.NumericProbeEditor) WayPointProbe(artisynth.core.probes.WayPointProbe) Probe(artisynth.core.probes.Probe) WayPointProbe(artisynth.core.probes.WayPointProbe) WayPoint(artisynth.core.probes.WayPoint)

Aggregations

RootModel (artisynth.core.workspace.RootModel)44 ModelComponent (artisynth.core.modelbase.ModelComponent)10 InternalErrorException (maspack.util.InternalErrorException)7 IOException (java.io.IOException)6 WayPoint (artisynth.core.probes.WayPoint)4 FileNotFoundException (java.io.FileNotFoundException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Probe (artisynth.core.probes.Probe)3 WayPointProbe (artisynth.core.probes.WayPointProbe)3 File (java.io.File)3 Property (maspack.properties.Property)3 ControlPanel (artisynth.core.gui.ControlPanel)2 CompositeComponent (artisynth.core.modelbase.CompositeComponent)2 TracingProbe (artisynth.core.probes.TracingProbe)2 Point (java.awt.Point)2 JFileChooser (javax.swing.JFileChooser)2 JMenuItem (javax.swing.JMenuItem)2 JSeparator (javax.swing.JSeparator)2 CompositeProperty (maspack.properties.CompositeProperty)2 ArgParser (argparser.ArgParser)1