Search in sources :

Example 1 with GLGridPlane

use of maspack.render.GL.GLGridPlane in project artisynth_core by artisynth.

the class ViewerToolBar method updateWidgets.

/**
 * Called after the viewer state has been changed by some other agent, to
 * update the appearance of the widgets and icons.
 */
public void updateWidgets() {
    updateIcons();
    if (myGridDisplayEnabled) {
        boolean gridOn = myViewer.getGridVisible();
        GLGridPlane grid = myViewer.getGrid();
        if ((myGridDisplay != null) != gridOn) {
            if (gridOn) {
                myGridDisplay = GridDisplay.createAndAdd(grid, this, myGridDisplayIndex);
            } else {
                GridDisplay.removeAndDispose(myGridDisplay, this, myGridDisplayIndex);
                myGridDisplay = null;
            }
        }
    }
    if (myGridDisplay != null) {
        myGridDisplay.updateWidgets();
    }
    for (ClipPlaneControl cpc : myClipPlaneControls) {
        cpc.updateWidgets();
    }
}
Also used : GLGridPlane(maspack.render.GL.GLGridPlane)

Example 2 with GLGridPlane

use of maspack.render.GL.GLGridPlane in project artisynth_core by artisynth.

the class MenuBarHandler method updateWidgets.

public void updateWidgets() {
    // frame is being set visible can cause some problems
    if (!myFrame.isVisible()) {
        return;
    }
    GLViewer v = getMainViewer();
    boolean gridOn = v.getGridVisible();
    GLGridPlane grid = v.getGrid();
    if ((myGridDisplay != null) != gridOn) {
        if (gridOn) {
            myGridDisplay = GridDisplay.createAndAdd(grid, myToolBar, myGridDisplayIndex);
        } else {
            GridDisplay.removeAndDispose(myGridDisplay, myToolBar, myGridDisplayIndex);
            myGridDisplay = null;
        }
    }
    if (myGridDisplay != null) {
        myGridDisplay.updateWidgets();
    }
}
Also used : GLViewer(maspack.render.GL.GLViewer) GLGridPlane(maspack.render.GL.GLGridPlane)

Example 3 with GLGridPlane

use of maspack.render.GL.GLGridPlane in project artisynth_core by artisynth.

the class ViewerFrame method updateWidgets.

protected void updateWidgets() {
    // frame is being set visible can cause some problems
    if (!isVisible()) {
        return;
    }
    if (myTopPanel != null) {
        // if we have a top panel, then we have a grid display there
        boolean gridOn = viewer.getGridVisible();
        GLGridPlane grid = viewer.getGrid();
        if ((myGridDisplay != null) != gridOn) {
            if (gridOn) {
                myGridDisplay = GridDisplay.createAndAdd(grid, myTopPanel, myGridDisplayIndex);
            } else {
                GridDisplay.removeAndDispose(myGridDisplay, myTopPanel, myGridDisplayIndex);
                myGridDisplay = null;
            }
        }
        if (myGridDisplay != null) {
            myGridDisplay.updateWidgets();
        }
    }
}
Also used : GLGridPlane(maspack.render.GL.GLGridPlane)

Example 4 with GLGridPlane

use of maspack.render.GL.GLGridPlane in project artisynth_core by artisynth.

the class Translator3d method updatePosition.

private void updatePosition(Point3d p0, Point3d p1, MouseRayEvent e) {
    Vector3d del = new Vector3d();
    del.sub(p1, p0);
    // if (dragIsConstrained(e)) {
    if (dragIsConstrained()) {
        Renderer renderer = e.getViewer();
        boolean constrainedToGrid = false;
        if (renderer instanceof GLViewer) {
            GLViewer viewer = (GLViewer) renderer;
            if (viewer.getGridVisible()) {
                GLGridPlane grid = viewer.getGrid();
                RigidTransform3d XDraggerToGrid = new RigidTransform3d();
                XDraggerToGrid.mulInverseLeft(grid.getGridToWorld(), myXDraggerToWorld);
                if (XDraggerToGrid.R.isAxisAligned(EPS)) {
                    // if the dragger orientation is axis-aligned with grid
                    // coordinates, then adjust constrained motions so that the
                    // dragger center always lies on a grid point. (Otherwise, this
                    // can't necessarily be done without causing the dragger to move
                    // off the specified line or plane of translation).
                    Point3d pa = new Point3d(del);
                    pa.transform(XDraggerToGrid);
                    grid.alignPoint(pa, pa);
                    pa.inverseTransform(XDraggerToGrid);
                    del.set(pa);
                    constrainToFixture(del);
                    constrainedToGrid = true;
                }
            }
        }
        if (!constrainedToGrid) {
            // if not possible to constrain to grid, just constrain the step
            // size
            double s = getConstrainedStepSize();
            del.x = s * Math.round(del.x / s);
            del.y = s * Math.round(del.y / s);
            del.z = s * Math.round(del.z / s);
        }
    }
    myXDraggerToWorld.mulXyz(del.x, del.y, del.z);
    myIncrementalTransform.p.set(del.x, del.y, del.z);
    myTransform.mul(myIncrementalTransform);
}
Also used : GLViewer(maspack.render.GL.GLViewer) RigidTransform3d(maspack.matrix.RigidTransform3d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) GLGridPlane(maspack.render.GL.GLGridPlane)

Example 5 with GLGridPlane

use of maspack.render.GL.GLGridPlane in project artisynth_core by artisynth.

the class MeshViewer method updateWidgets.

public void updateWidgets() {
    // frame is being set visible can cause some problems
    if (!isVisible()) {
        return;
    }
    boolean gridOn = viewer.getGridVisible();
    GLGridPlane grid = viewer.getGrid();
    if ((myGridDisplay != null) != gridOn) {
        if (gridOn) {
            myGridDisplay = GridDisplay.createAndAdd(grid, myToolBar, myGridDisplayIndex);
        } else {
            GridDisplay.removeAndDispose(myGridDisplay, myToolBar, myGridDisplayIndex);
            myGridDisplay = null;
        }
    }
    if (myGridDisplay != null) {
        myGridDisplay.updateWidgets();
    }
}
Also used : GLGridPlane(maspack.render.GL.GLGridPlane)

Aggregations

GLGridPlane (maspack.render.GL.GLGridPlane)5 GLViewer (maspack.render.GL.GLViewer)2 Point3d (maspack.matrix.Point3d)1 RigidTransform3d (maspack.matrix.RigidTransform3d)1 Vector3d (maspack.matrix.Vector3d)1