Search in sources :

Example 1 with RenderPropsDialog

use of maspack.widgets.RenderPropsDialog in project artisynth_core by artisynth.

the class MenuBarHandler method showPullControllerRenderPropsDialog.

private void showPullControllerRenderPropsDialog() {
    if (myPullControllerRenderPropsDialog == null) {
        PullController pc = myMain.getPullController();
        LinkedList<HasProperties> list = new LinkedList<HasProperties>();
        list.add(pc);
        RenderPropsDialog dialog = new RenderPropsDialog("Edit render properties", list);
        dialog.locateRight(myMain.getFrame());
        // dialog.setSynchronizeObject(myMain.getRootModel());
        dialog.setTitle("RenderProps for PullController");
        dialog.addWindowListener(new WindowAdapter() {

            public void windowClosed(WindowEvent e) {
                myPullControllerRenderPropsDialog = null;
            }
        });
        myMain.registerWindow(dialog);
        myPullControllerRenderPropsDialog = dialog;
        dialog.pack();
        dialog.setVisible(true);
    }
}
Also used : RenderPropsDialog(maspack.widgets.RenderPropsDialog) WindowEvent(java.awt.event.WindowEvent) HasProperties(maspack.properties.HasProperties) WindowAdapter(java.awt.event.WindowAdapter) LinkedList(java.util.LinkedList) PullController(artisynth.core.workspace.PullController)

Example 2 with RenderPropsDialog

use of maspack.widgets.RenderPropsDialog in project artisynth_core by artisynth.

the class SelectionPopup method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    LinkedList<ModelComponent> selectedItems = mySelectionManager.getCurrentSelection();
    if (command.equals("Edit reference list properties ...")) {
        createPropertyDialog(selectedItems);
    } else if (command.equals("Edit reference properties ...")) {
        createPropertyDialog(myRefComponentSelection);
    }
    if (command.equals("Edit properties ...")) {
        LinkedList<ModelComponent> selection = myPropertyEditSelection;
        if (myRefComponentSelection.size() > 0 && myRefComponentSelection.size() < selection.size()) {
            selection = new LinkedList<ModelComponent>();
            for (ModelComponent c : myPropertyEditSelection) {
                if (!(c instanceof ReferenceComponent)) {
                    selection.add(c);
                }
            }
        }
        createPropertyDialog(selection);
    } else if (command.equals("Edit render props ...") || command.equals("Set render props ...")) {
        LinkedList<ModelComponent> renderables = new LinkedList<ModelComponent>();
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof Renderable) {
                renderables.add(c);
            }
        }
        RenderPropsDialog dialog = new RenderPropsDialog("Edit render properties", renderables);
        if (dialog.numProperties() == 0) {
            JOptionPane.showMessageDialog(myParentGUIComponent, "No common render properties for selected components", "no common render properties", JOptionPane.INFORMATION_MESSAGE);
        } else {
            if (myLocateRenderPropEditClose) {
                GuiUtils.locateRelative(dialog, myLastBounds, 0.5, 0.5, 0, 0.5);
            } else {
                dialog.locateRight(myMain.getFrame());
            }
            myMain.registerWindow(dialog);
            dialog.setTitle("RenderProps for " + getNameForSelection(myPropertyEditSelection));
            dialog.setVisible(true);
        }
    } else if (command.equals("Clear render props")) {
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof Renderable) {
                ((Renderable) c).setRenderProps(null);
            }
        }
        requestViewerUpdate();
    } else if (command.equals("Set visible")) {
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof RenderableComponent) {
                setVisible((RenderableComponent) c, true);
            }
        }
        requestViewerUpdate();
    } else if (command.equals("Set invisible")) {
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof RenderableComponent) {
                setVisible((RenderableComponent) c, false);
            }
        }
        requestViewerUpdate();
    } else if (command.equals("Enable tracing")) {
        RootModel rootModel = myMain.getRootModel();
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof Traceable) {
                Traceable tr = (Traceable) c;
                if (!rootModel.isTracing(tr)) {
                    rootModel.enableTracing(tr);
                }
            }
        }
    } else if (command.equals("Disable tracing")) {
        RootModel rootModel = myMain.getRootModel();
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof Traceable) {
                Traceable tr = (Traceable) c;
                if (rootModel.isTracing(tr)) {
                    rootModel.disableTracing(tr);
                }
            }
        }
    } else if (command.equals("Clear trace")) {
        RootModel rootModel = myMain.getRootModel();
        for (ModelComponent c : myPropertyEditSelection) {
            if (c instanceof Traceable) {
                Traceable tr = (Traceable) c;
                if (rootModel.isTracing(tr)) {
                    rootModel.clearTracing(tr);
                }
            }
        }
        myMain.rerender();
    } else if (command.equals("Add tracing probe")) {
        addTracing(myPropertyEditSelection);
    } else if (command.equals("Save as ...")) {
        EditorUtils.saveComponent(selectedItems.get(0));
    } else if (command == "Delete") {
        deleteSelection();
    } else if (command.equals("Delete reference(s)")) {
        deleteRefComponentSelection();
    } else if (command == "Duplicate") {
        duplicateSelection();
    } else {
        // EditorBase editor = myEditActionMap.get (command);
        // if (editor != null) {
        // editor.applyAction (command, selectedItems, myLastBounds);
        // }
        EditorBase editor = myEditActionMap.getEditor(command);
        if (editor != null) {
            editor.applyAction(command, selectedItems, myLastBounds);
        }
    }
}
Also used : Renderable(maspack.render.Renderable) RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent) ReferenceComponent(artisynth.core.modelbase.ReferenceComponent) RenderPropsDialog(maspack.widgets.RenderPropsDialog) RenderableComponent(artisynth.core.modelbase.RenderableComponent) EditorBase(artisynth.core.gui.editorManager.EditorBase) Traceable(artisynth.core.modelbase.Traceable) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)2 RenderPropsDialog (maspack.widgets.RenderPropsDialog)2 EditorBase (artisynth.core.gui.editorManager.EditorBase)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 ReferenceComponent (artisynth.core.modelbase.ReferenceComponent)1 RenderableComponent (artisynth.core.modelbase.RenderableComponent)1 Traceable (artisynth.core.modelbase.Traceable)1 PullController (artisynth.core.workspace.PullController)1 RootModel (artisynth.core.workspace.RootModel)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 HasProperties (maspack.properties.HasProperties)1 Renderable (maspack.render.Renderable)1