Search in sources :

Example 1 with ChangeNodeGroupCommandVector

use of facetmodeller.commands.ChangeNodeGroupCommandVector in project facetmodeller by pglelievre.

the class FindNodesIndexMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Ask for the node index to find:
    String response = Dialogs.input(controller, "Enter the indices of the nodes to find:", title());
    if (response == null) {
        return;
    }
    response = response.trim();
    String[] ss = response.split("[ ]+");
    NodeVector nodesFound = new NodeVector();
    int nnodes = controller.numberOfNodes();
    try {
        ModelManager model = controller.getModelManager();
        // int ind = Integer.parseInt(ss[i].trim());
        for (String s : ss) {
            int ind = Integer.parseInt(s.trim());
            if (ind < 1 || ind > nnodes) {
                throw new NumberFormatException();
            }
            // -1 because Java starts numbering from 0 but poly files from 1
            nodesFound.add(model.getNode(ind - 1));
        }
    } catch (NumberFormatException e) {
        Dialogs.error(controller, "You must enter integer values on [1," + nnodes + "]. Please try again.", "Error");
        return;
    }
    // Move the nodes to the current group:
    ChangeNodeGroupCommandVector com = new ChangeNodeGroupCommandVector(nodesFound, controller.getSelectedCurrentGroup(), title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
}
Also used : NodeVector(facetmodeller.plc.NodeVector) ModelManager(facetmodeller.ModelManager) ChangeNodeGroupCommandVector(facetmodeller.commands.ChangeNodeGroupCommandVector)

Example 2 with ChangeNodeGroupCommandVector

use of facetmodeller.commands.ChangeNodeGroupCommandVector in project facetmodeller by pglelievre.

the class FindNodesOutsideCalibrationMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Find the nodes:
    NodeVector nodes = controller.removeNodesCalibrationRange();
    // Check nodes were found:
    if (nodes.size() == 0) {
        Dialogs.inform(controller, "No nodes found.", title());
        return;
    }
    // Change the group membership of those nodes:
    ChangeNodeGroupCommandVector com = new ChangeNodeGroupCommandVector(nodes, controller.getSelectedCurrentGroup(), title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
    // Inform user:
    String s = nodes.size() + " nodes found and moved to current group.";
    Dialogs.inform(controller, s, title());
}
Also used : NodeVector(facetmodeller.plc.NodeVector) ChangeNodeGroupCommandVector(facetmodeller.commands.ChangeNodeGroupCommandVector)

Example 3 with ChangeNodeGroupCommandVector

use of facetmodeller.commands.ChangeNodeGroupCommandVector in project facetmodeller by pglelievre.

the class FindNodesOutsideVOIMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Find any nodes outside of the VOI:
    NodeVector nodes = new NodeVector();
    for (int i = 0; i < controller.numberOfNodes(); i++) {
        Node node = controller.getNode(i);
        MyPoint3D p = node.getPoint3D();
        if (p != null) {
            // calibrated
            if (!controller.inOrOn(p)) {
                nodes.add(node);
            }
        }
    }
    // Check nodes were found:
    if (nodes.size() == 0) {
        Dialogs.inform(controller, "No nodes found.", title());
        return;
    }
    // Change the group membership of those nodes:
    ChangeNodeGroupCommandVector com = new ChangeNodeGroupCommandVector(nodes, controller.getSelectedCurrentGroup(), title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
    // Inform user:
    String s = nodes.size() + " nodes found and moved to current group.";
    Dialogs.inform(controller, s, title());
}
Also used : NodeVector(facetmodeller.plc.NodeVector) Node(facetmodeller.plc.Node) MyPoint3D(geometry.MyPoint3D) ChangeNodeGroupCommandVector(facetmodeller.commands.ChangeNodeGroupCommandVector)

Example 4 with ChangeNodeGroupCommandVector

use of facetmodeller.commands.ChangeNodeGroupCommandVector in project facetmodeller by pglelievre.

the class FindUnusedNodesMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Find unused nodes:
    NodeVector nodes = controller.findUnusedNodes();
    if (nodes == null) {
        return;
    }
    // Check nodes were found:
    if (nodes.size() == 0) {
        Dialogs.inform(controller, "No nodes found.", title());
        return;
    }
    // Change the group membership of those nodes:
    ChangeNodeGroupCommandVector com = new ChangeNodeGroupCommandVector(nodes, controller.getSelectedCurrentGroup(), title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
    // Inform user:
    String s = nodes.size() + " nodes found and moved to current group.";
    Dialogs.inform(controller, s, title());
}
Also used : NodeVector(facetmodeller.plc.NodeVector) ChangeNodeGroupCommandVector(facetmodeller.commands.ChangeNodeGroupCommandVector)

Aggregations

ChangeNodeGroupCommandVector (facetmodeller.commands.ChangeNodeGroupCommandVector)4 NodeVector (facetmodeller.plc.NodeVector)4 ModelManager (facetmodeller.ModelManager)1 Node (facetmodeller.plc.Node)1 MyPoint3D (geometry.MyPoint3D)1