Ejemplo n.º 1
0
  private void createToSettings() {

    Composite parent = this;
    Group group = new Group(parent, SWT.NONE);

    group.setText("Camera To");

    GridLayout gridLayout = new GridLayout(2, true);

    group.setLayout(gridLayout);

    Label textX = new Label(group, SWT.NONE);
    textX.setText("X");
    toX = new Text(group, SWT.NONE);
    toX.addListener(SWT.Verify, UIUtils.createVerifyIntegerListener());

    Label textY = new Label(group, SWT.NONE);
    textY.setText("Y");
    toY = new Text(group, SWT.NONE);
    toY.addListener(SWT.Verify, UIUtils.createVerifyIntegerListener());

    Label textZ = new Label(group, SWT.NONE);
    textZ.setText("Z");
    toZ = new Text(group, SWT.NONE);
    toZ.addListener(SWT.Verify, UIUtils.createVerifyIntegerListener());

    Button buttonOk = new Button(group, SWT.NONE);
    buttonOk.setText("OK");
    buttonOk.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {

            try {

              int x = UIUtils.retrieveInteger(toX);
              int y = UIUtils.retrieveInteger(toY);
              int z = UIUtils.retrieveInteger(toZ);

              Point3D point3D = new Point3D(x, y, z);

              controller.setCameraToCoordinates(point3D);

            } catch (IllegalArgumentException e) {
              String message = e.getMessage();
              UIUtils.showMessage(message);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });
  }
Ejemplo n.º 2
0
  private void createProjectionSettings() {

    Composite parent = this;
    Group group = new Group(parent, SWT.NONE);

    group.setText("Projection");

    GridLayout gridLayout = new GridLayout(2, true);

    group.setLayout(gridLayout);

    perspectiveButton = new Button(group, SWT.RADIO);
    perspectiveButton.setText("Perspective");

    parallelButton = new Button(group, SWT.RADIO);
    parallelButton.setText("Parallel");

    parallelButton.setSelection(true);

    SelectionListener listener =
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {
            if (parallelButton.getSelection()) {
              controller.setProjectionType(ProjectionType.PARALLEL);
            } else {

              controller.setProjectionType(ProjectionType.CENTRAL);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        };
    parallelButton.addSelectionListener(listener);
    perspectiveButton.addSelectionListener(listener);
  }
Ejemplo n.º 3
0
  private void createViewSettings() {

    Composite parent = this;
    Group group = new Group(parent, SWT.NONE);

    group.setText("View");

    GridLayout gridLayout = new GridLayout(2, true);

    group.setLayout(gridLayout);

    fillButton = new Button(group, SWT.RADIO);
    fillButton.setText("Fill");

    edgeButton = new Button(group, SWT.RADIO);
    edgeButton.setText("Edges");

    edgeButton.setSelection(true);

    SelectionListener listener =
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {
            if (edgeButton.getSelection()) {
              controller.setViewType(ViewType.EDGES);
            } else {

              controller.setViewType(ViewType.POLYGONS);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        };
    edgeButton.addSelectionListener(listener);
    fillButton.addSelectionListener(listener);
  }
Ejemplo n.º 4
0
  private void createRotateSettings() {

    Composite parent = this;
    Group group = new Group(parent, SWT.NONE);

    group.setText("Rotate camera");

    GridLayout gridLayout = new GridLayout(2, false);

    group.setLayout(gridLayout);

    fromRotate = new Button(group, SWT.RADIO);
    fromRotate.setText("Axes");

    toRotate = new Button(group, SWT.RADIO);
    toRotate.setText("Orbit");

    toRotate.setSelection(true);

    parent = group;
    group = new Group(parent, SWT.NONE);

    gridLayout = new GridLayout(3, false);

    group.setLayout(gridLayout);

    final Label textXZ = new Label(group, SWT.NONE);
    textXZ.setText("X");
    rotateX = new Text(group, SWT.NONE);
    rotateX.addListener(SWT.Verify, UIUtils.createVerifyPositiveIntegerListener());

    rotateXSlider = new Slider(group, SWT.NONE);
    initRotateSlider(rotateXSlider);

    final Label textYZ = new Label(group, SWT.NONE);
    textYZ.setText("Y");
    rotateY = new Text(group, SWT.NONE);
    rotateY.addListener(SWT.Verify, UIUtils.createVerifyPositiveIntegerListener());

    rotateYSlider = new Slider(group, SWT.NONE);
    initRotateSlider(rotateYSlider);

    final Label textXY = new Label(group, SWT.NONE);
    textXY.setText("Z");
    rotateZ = new Text(group, SWT.NONE);
    rotateZ.addListener(SWT.Verify, UIUtils.createVerifyPositiveIntegerListener());

    rotateZSlider = new Slider(group, SWT.NONE);
    initRotateSlider(rotateZSlider);

    SelectionListener sliderListener =
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {
            int x = rotateXSlider.getSelection();
            int y = rotateYSlider.getSelection();
            int z = rotateZSlider.getSelection();
            applyCameraRotation(x, y, z);
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            int x = rotateXSlider.getSelection();
            int y = rotateYSlider.getSelection();
            int z = rotateZSlider.getSelection();
            applyCameraRotation(x, y, z);
          }
        };
    rotateXSlider.addSelectionListener(sliderListener);
    rotateYSlider.addSelectionListener(sliderListener);
    rotateZSlider.addSelectionListener(sliderListener);

    Button buttonOk = new Button(group, SWT.NONE);
    buttonOk.setText("OK");
    buttonOk.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {

            try {

              int x = UIUtils.retrieveInteger(rotateX);
              int y = UIUtils.retrieveInteger(rotateY);
              int z = UIUtils.retrieveInteger(rotateZ);

              UIUtils.checkDegrees(x);
              UIUtils.checkDegrees(y);
              UIUtils.checkDegrees(z);

              applyCameraRotation(x, y, z);

            } catch (IllegalArgumentException e) {
              String message = e.getMessage();
              UIUtils.showMessage(message);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });
  }
Ejemplo n.º 5
0
  private void createFocalLengthSettings() {

    Composite parent = this;
    Group group = new Group(parent, SWT.NONE);

    group.setText("FocalLength");

    GridLayout gridLayout = new GridLayout(3, true);

    group.setLayout(gridLayout);

    Label textFocalLength = new Label(group, SWT.NONE);
    textFocalLength.setText("Focal");
    focalLength = new Text(group, SWT.NONE);
    focalLength.addListener(SWT.Verify, UIUtils.createVerifyPositiveIntegerListener());

    focalLengthSlider = new Slider(group, SWT.NONE);
    focalLengthSlider.setMinimum(1);
    focalLengthSlider.setMaximum(1000);
    focalLengthSlider.setSelection(500);

    focalLengthSlider.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {
            int focalLengthValue = focalLengthSlider.getSelection();

            applyFocalLength(focalLengthValue);
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    Label textHorizontLength = new Label(group, SWT.NONE);
    textHorizontLength.setText("Horizont");
    horizontLength = new Text(group, SWT.NONE);
    horizontLength.addListener(SWT.Verify, UIUtils.createVerifyPositiveIntegerListener());

    horizontLengthSlider = new Slider(group, SWT.NONE);
    horizontLengthSlider.setMinimum(1000);
    horizontLengthSlider.setMaximum(8000);
    horizontLengthSlider.setSelection(2000);

    horizontLengthSlider.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {
            int horizontLengthValue = horizontLengthSlider.getSelection();

            applyHorizontalLength(horizontLengthValue);
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });

    Button buttonOk = new Button(group, SWT.NONE);
    buttonOk.setText("OK");
    buttonOk.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent selectionEvent) {

            try {
              int focalLength = UIUtils.retrieveInteger(CameraFragment.this.focalLength);

              int horizontLengthValue = UIUtils.retrieveInteger(CameraFragment.this.horizontLength);

              applyHorizontalLength(horizontLengthValue);

              applyFocalLength(focalLength);

            } catch (IllegalArgumentException e) {
              String message = e.getMessage();
              UIUtils.showMessage(message);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            // To change body of implemented methods use File | Settings | File Templates.
          }
        });
  }