Search in sources :

Example 1 with ChangeFacetGroupCommandVector

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

the class FindFacetsIndexMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Ask for the facet index to find:
    String response = Dialogs.input(controller, "Enter the indices of the facets to find:", title());
    if (response == null) {
        return;
    }
    response = response.trim();
    String[] ss = response.split("[ ]+");
    FacetVector facetsFound = new FacetVector();
    int nfacets = controller.numberOfFacets();
    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 > nfacets) {
                throw new NumberFormatException();
            }
            // -1 because Java starts numbering from 0 but poly files from 1
            facetsFound.add(model.getFacet(ind - 1));
        }
    } catch (NumberFormatException e) {
        Dialogs.error(controller, "You must enter integer values on [1," + nfacets + "]. Please try again.", "Error");
        return;
    }
    // Move the facets to the current group:
    ChangeFacetGroupCommandVector com = new ChangeFacetGroupCommandVector(facetsFound, controller.getSelectedCurrentGroup(), title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
}
Also used : ChangeFacetGroupCommandVector(facetmodeller.commands.ChangeFacetGroupCommandVector) FacetVector(facetmodeller.plc.FacetVector) ModelManager(facetmodeller.ModelManager)

Example 2 with ChangeFacetGroupCommandVector

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

the class FindHolesMenuTask method execute.

@Override
public void execute() {
    // Check for the required information:
    if (!check()) {
        return;
    }
    // Find them:
    FacetVector facets = controller.findHoles();
    if (facets == null) {
        Dialogs.inform(controller, "You can't currently search for holes when non-triangular facets exist.", title());
        return;
    }
    // Check facets were found:
    if (facets.size() == 0) {
        Dialogs.inform(controller, "No holes found.", title());
        return;
    }
    // Change the group membership of those facets:
    ChangeFacetGroupCommandVector com = new ChangeFacetGroupCommandVector(facets, controller.getSelectedCurrentGroup(), title());
    com.execute();
    controller.undoVectorAdd(com);
    // Enable or disable menu items:
    controller.checkItemsEnabled();
    // Repaint:
    controller.redraw();
    // Inform user:
    String s = facets.size() + " facets found around holes and moved to current group.";
    Dialogs.inform(controller, s, title());
}
Also used : ChangeFacetGroupCommandVector(facetmodeller.commands.ChangeFacetGroupCommandVector) FacetVector(facetmodeller.plc.FacetVector)

Example 3 with ChangeFacetGroupCommandVector

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

the class FindBadFacetsMenuTask method execute.

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

Aggregations

ChangeFacetGroupCommandVector (facetmodeller.commands.ChangeFacetGroupCommandVector)3 FacetVector (facetmodeller.plc.FacetVector)3 ModelManager (facetmodeller.ModelManager)1