Search in sources :

Example 1 with RemoveComponentsCommand

use of artisynth.core.gui.editorManager.RemoveComponentsCommand in project artisynth_core by artisynth.

the class ControlPanel method removeFromParent.

private void removeFromParent() {
    if (myParent instanceof MutableCompositeComponent) {
        RemoveComponentsCommand rmCmd = new RemoveComponentsCommand("delete controlPanel", this);
        Main.getMain().getUndoManager().saveStateAndExecute(rmCmd);
    }
}
Also used : MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent) RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand)

Example 2 with RemoveComponentsCommand

use of artisynth.core.gui.editorManager.RemoveComponentsCommand in project artisynth_core by artisynth.

the class Track method deleteProbe.

/**
 * delete a probe from the track, need to give the index of the probe
 *
 * @param pinfo probe information object
 * @param confirm confirm the deletion in the GUI
 */
public void deleteProbe(ProbeInfo pinfo, boolean confirm) {
    if (confirmDelete("Delete this probe?", confirm)) {
        RemoveComponentsCommand rmCmd = new RemoveComponentsCommand("delete probe", pinfo.getProbe());
        myController.myMain.getUndoManager().saveStateAndExecute(rmCmd);
        myController.myMain.rerender();
    }
}
Also used : RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand)

Example 3 with RemoveComponentsCommand

use of artisynth.core.gui.editorManager.RemoveComponentsCommand in project artisynth_core by artisynth.

the class SelectionPopup method deleteRefComponentSelection.

private void deleteRefComponentSelection() {
    mySelectionManager.clearSelections();
    @SuppressWarnings("unchecked") RemoveComponentsCommand cmd = new RemoveComponentsCommand("delete", myRefComponentSelection);
    myMain.getUndoManager().saveStateAndExecute(cmd);
    requestViewerUpdate();
}
Also used : RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand)

Example 4 with RemoveComponentsCommand

use of artisynth.core.gui.editorManager.RemoveComponentsCommand in project artisynth_core by artisynth.

the class SelectionPopup method deleteSelection.

private void deleteSelection() {
    LinkedList<ModelComponent> selection = mySelectionManager.getCurrentSelection();
    LinkedList<ModelComponent> update = new LinkedList<ModelComponent>();
    LinkedList<ModelComponent> delete = ComponentUtils.findDependentComponents(update, selection);
    if (delete.size() > selection.size()) {
        // first, see if we can actually delete:
        System.out.println("delete size=" + delete.size());
        if (!componentsAreDeletable(delete)) {
            JOptionPane.showMessageDialog(myParentGUIComponent, "Selection refers to additional components that can't be deleted", "selection not deletable", JOptionPane.INFORMATION_MESSAGE);
        } else {
            boolean needConfirmation = false;
            for (ModelComponent c : delete) {
                if (!c.isSelected()) {
                    needConfirmation = true;
                    mySelectionManager.addSelected(c);
                }
            }
            requestViewerUpdate();
            if (needConfirmation) {
                JOptionPane confirmDialog = new JOptionPane("Dependent components will be deleted also. Proceed?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
                JDialog dialog = confirmDialog.createDialog(myParentGUIComponent, "confirm deletion");
                GuiUtils.locateHorizontally(dialog, myParentGUIComponent, GuiUtils.CENTER);
                GuiUtils.locateVertically(dialog, myParentGUIComponent, GuiUtils.BELOW);
                dialog.setVisible(true);
                if ((confirmDialog.getValue() == null) || (confirmDialog.getValue().equals(JOptionPane.NO_OPTION))) {
                    return;
                }
            }
        }
    }
    // components are deselected before they are removed. This
    // will not affect dependentSelection because it is a (possibly
    // extended) copy of the selection.
    mySelectionManager.clearSelections();
    @SuppressWarnings("unchecked") RemoveComponentsCommand cmd = new RemoveComponentsCommand("delete", delete, update);
    myMain.getUndoManager().saveStateAndExecute(cmd);
    requestViewerUpdate();
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand) JOptionPane(javax.swing.JOptionPane) LinkedList(java.util.LinkedList) JDialog(javax.swing.JDialog)

Example 5 with RemoveComponentsCommand

use of artisynth.core.gui.editorManager.RemoveComponentsCommand in project artisynth_core by artisynth.

the class MenuBarHandler method actionPerformed.

/**
 * action performed to process all the menu and button actions in this class
 */
public void actionPerformed(ActionEvent event) {
    String cmd = event.getActionCommand();
    // Scripts menu
    if (isScriptMenuItem(event.getSource())) {
        String scriptName = myMain.getScriptName(cmd);
        runScript(scriptName);
    } else if (cmd.equals("load script from file")) {
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setCurrentDirectory(ArtisynthPath.getWorkingDir());
        FileFilter jythonFilter = new GenericFileFilter(new String[] { "py", "jy" }, "Jython files");
        fileChooser.addChoosableFileFilter(jythonFilter);
        fileChooser.setFileFilter(jythonFilter);
        int result = fileChooser.showOpenDialog(myFrame);
        if (result == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();
            runScript(selectedFile.getAbsolutePath());
        }
    } else // 
    if (myMain.isDemoClassName(cmd)) {
        ModelInfo mi = new ModelInfo(myMain.getDemoClassName(cmd), cmd, null);
        doLoadModelSafely(mi);
    } else // 
    if (cmd.equals("Clear model")) {
        doClearModel();
    } else if (cmd.equals("New blank MechModel")) {
        doBlankMechmodel();
    } else if (cmd.equals("Save model")) {
        doSaveModel();
    } else if (cmd.equals("Save model as ...")) {
        doSaveModelAs();
    } else if (cmd.equals("Reload model")) {
        doReloadModel();
    } else if (cmd.equals("Load model ...")) {
        doLoadModel();
    } else if (cmd.equals("Load from class ...")) {
        doLoadFromClass();
    } else if (cmd.equals("Switch workspace ...")) {
        doSwitchWorkspace();
    } else if (cmd.equals("Open MATLAB connection")) {
        doOpenMatlab();
    } else if (cmd.equals("Close MATLAB connection")) {
        doCloseMatlab();
    } else if (cmd.equals("Load probes ...")) {
        doLoadProbes();
    } else if (cmd.equals("Save probes")) {
        doSaveProbes();
    } else if (cmd.equals("Save probes as ...")) {
        doSaveProbesAs();
    } else if (cmd.equals("Load probes from ...")) {
        newLoadProbesFrom();
    } else if (cmd.equals("Save probes new")) {
        newSaveProbes();
    } else if (cmd.equals("Save probes in ...")) {
        newSaveProbesIn();
    } else if (cmd.equals("Save viewer image ...")) {
        saveViewerImage();
    } else if (cmd.equals("Quit")) {
        myMain.quit();
    } else // 
    if (cmd.equals("Add input probe")) {
        doAddInputProbe();
    } else if (cmd.equals("Add output probe")) {
        doAddOutputProbe();
    } else if (cmd.equals("Add control panel")) {
        doAddControlPanel();
    } else if (cmd.equals("Load control panel")) {
        doLoadControlPanel();
    } else if (cmd.equals("Print selection")) {
        SelectionManager sm = myMain.getSelectionManager();
        for (ModelComponent c : sm.getCurrentSelection()) {
            System.out.println(ComponentUtils.getPathName(c));
        }
    } else if (cmd.equals("Undo")) {
        doUndoCommand();
    } else // 
    if (cmd.equals("Background color")) {
        setBackgroundColor();
    } else if (cmd.equals("Selection color")) {
        setSelectionColor();
    } else if (cmd.equals("Enable selection highlighting")) {
        setSelectionColorEnabled(true);
    } else if (cmd.equals("Disable selection highlighting")) {
        setSelectionColorEnabled(false);
    } else if (cmd.equals("Visual display rate")) {
        setVisualDisplayRate();
    } else if (cmd.equals("Real-time scaling")) {
        setRealTimeScaling();
    } else if (cmd.equals("Mouse Preferences ...")) {
        openMouseSettingsDialog();
    } else if (cmd.equals("Init draggers in world coords")) {
        myMain.setInitDraggersInWorldCoords(true);
    } else if (cmd.equals("Init draggers in local coords")) {
        myMain.setInitDraggersInWorldCoords(false);
    } else if (cmd.equals("Enable articulated transforms")) {
        myMain.setArticulatedTransformsEnabled(true);
    } else if (cmd.equals("Disable articulated transforms")) {
        myMain.setArticulatedTransformsEnabled(false);
    } else // }
    if (cmd.equals("PullController properties ...")) {
        showPullControllerPropertyDialog();
    } else if (cmd.equals("PullController render props ...")) {
        showPullControllerRenderPropsDialog();
    } else // 
    if (cmd.equals("Center view on selection")) {
        myMain.centerViewOnSelection();
    } else if (cmd.equals("Hide timeline")) {
        myMain.setTimelineVisible(false);
        isTimelineVisible = false;
    } else if (cmd.equals("Show timeline")) {
        myMain.setTimelineVisible(true);
        isTimelineVisible = true;
    } else if (cmd.equals("Reset view")) {
        GLViewer v = myMain.getViewer();
        v.setAxialView(v.getAxialView());
        v.autoFit();
    } else if (cmd.equals("Perspective view")) {
        myMain.getViewer().setOrthographicView(false);
    } else if (cmd.equals("Orthographic view")) {
        myMain.getViewer().setOrthographicView(true);
    } else if (cmd.equals("Hide Jython console")) {
        setJythonConsoleVisible(false);
    } else if (cmd.equals("Show Jython console")) {
        setJythonConsoleVisible(true);
    } else if (cmd.equals("Show Inverse panel")) {
        myMain.getInverseManager().showInversePanel(myMain.getRootModel(), InverseManager.findInverseController());
    } else if (cmd.equals("Hide Inverse panel")) {
        myMain.getInverseManager().hideInversePanel();
    } else if (cmd.equals("Show movie panel")) {
        myFrame.getMain().getViewer().getCanvas().display();
        myMain.getMovieMaker().showDialog(myFrame);
    } else if (cmd.equals("Hide movie panel")) {
        // TODO: this isn't implemented yet because we need to set
        // this up as an action
        myMain.getMovieMaker().closeDialog();
    } else if (cmd.equals("Show empty components in navpanel")) {
        myFrame.getNavPanel().setHideEmptyComponents(false);
    } else if (cmd.equals("Hide empty components in navpanel")) {
        myFrame.getNavPanel().setHideEmptyComponents(true);
    } else if (cmd.equals("New viewer")) {
        myMain.createViewerFrame();
    } else if (cmd.equals("Clear traces")) {
        myMain.getRootModel().clearTraces();
    } else if (cmd.equals("Disable all tracing")) {
        myMain.getRootModel().disableAllTracing();
    } else if (cmd.equals("Remove traces")) {
        RemoveComponentsCommand rmCmd = new RemoveComponentsCommand("remove traces", myMain.getRootModel().getTracingProbes());
        myMain.getUndoManager().saveStateAndExecute(rmCmd);
        myMain.rerender();
    } else if (cmd.equals("Set traces visible")) {
        myMain.getRootModel().setTracingProbesVisible(true);
        myMain.rerender();
    } else if (cmd.equals("Set traces invisible")) {
        myMain.getRootModel().setTracingProbesVisible(false);
        myMain.rerender();
    } else if (cmd.equals("Hide viewer toolbar")) {
        isToolbarVisible = false;
        detachViewerToolbar(toolbarPanel);
    } else if (cmd.equals("Show viewer toolbar")) {
        isToolbarVisible = true;
        attachViewerToolbar(toolbarPanel);
    } else if (cmd.equals("Merge control panels")) {
        myMain.getRootModel().mergeAllControlPanels(true);
    } else if (cmd.equals("Separate control panels")) {
        myMain.getRootModel().mergeAllControlPanels(false);
    } else if (cmd.equals("Show progress")) {
        spawnProgressBar();
    } else // 
    if (cmd.equals("About ArtiSynth")) {
        myFrame.displayAboutArtisynth();
    } else if (cmd.equals("About the current model")) {
        myFrame.displayAboutModel(myMain.getRootModel());
    } else if (cmd.equals("Keybindings")) {
        myFrame.displayKeybindings();
    } else // 
    if (cmd.equals("Hide NavBar")) {
        myFrame.getNavPanel().setStatus(!myFrame.getNavPanel().getStatus());
        myFrame.refreshSplitPane();
        navBarButton.setToolTipText("Show Navbar");
        navBarButton.setActionCommand("Show Navbar");
    } else if (cmd.equals("Show Navbar")) {
        myFrame.getNavPanel().setStatus(!myFrame.getNavPanel().getStatus());
        myFrame.refreshSplitPane();
        navBarButton.setToolTipText("Hide NavBar");
        navBarButton.setActionCommand("Hide NavBar");
    } else if (cmd.equals("Re-render")) {
        myMain.rerender();
    } else if (cmd.equals("Reset")) {
        myMain.getScheduler().reset();
    } else if (cmd.equals("Rewind")) {
        myMain.getScheduler().rewind();
    } else if (cmd.equals("Play")) {
        myMain.getScheduler().play();
    } else if (cmd.equals("Pause")) {
        myMain.getScheduler().pause();
    } else if (cmd.equals("Single step")) {
        myMain.getScheduler().step();
    } else if (cmd.equals("Fast forward")) {
        myMain.getScheduler().fastForward();
    } else if (cmd.equals("cancel")) {
        return;
    } else {
        throw new InternalErrorException("Unimplemented command: " + cmd);
    }
}
Also used : SelectionManager(artisynth.core.gui.selectionManager.SelectionManager) GLViewer(maspack.render.GL.GLViewer) JFileChooser(javax.swing.JFileChooser) ModelComponent(artisynth.core.modelbase.ModelComponent) RemoveComponentsCommand(artisynth.core.gui.editorManager.RemoveComponentsCommand) GenericFileFilter(maspack.util.GenericFileFilter) InternalErrorException(maspack.util.InternalErrorException) ExtensionFileFilter(artisynth.core.util.ExtensionFileFilter) GenericFileFilter(maspack.util.GenericFileFilter) FileFilter(javax.swing.filechooser.FileFilter) File(java.io.File)

Aggregations

RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)5 ModelComponent (artisynth.core.modelbase.ModelComponent)2 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)1 MutableCompositeComponent (artisynth.core.modelbase.MutableCompositeComponent)1 ExtensionFileFilter (artisynth.core.util.ExtensionFileFilter)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1 JDialog (javax.swing.JDialog)1 JFileChooser (javax.swing.JFileChooser)1 JOptionPane (javax.swing.JOptionPane)1 FileFilter (javax.swing.filechooser.FileFilter)1 GLViewer (maspack.render.GL.GLViewer)1 GenericFileFilter (maspack.util.GenericFileFilter)1 InternalErrorException (maspack.util.InternalErrorException)1