Esempio n. 1
0
  public void setMeasurementMode(boolean enabled) {
    measuring = enabled;

    if (enabled) {
      if (choosingPivotPoint) { // disable choose-pivot-point mode
        setChoosePivotPointMode(false);
      }
      // initialize PickCanvas for mouse picking
      if (pickCanvas == null) {
        pickCanvas = new PickCanvas(this, kainBG);
        pickCanvas.setMode(PickCanvas.GEOMETRY);
      }
      if (snapList == null) {
        snapList = new LinkedList<Point3d>();
      }
    } else // clear remaining first point and remove the marker
    if (measurer != null) {
      try {
        Mark currentMark = measurer.getMarks().getLast();
        if (currentMark.isFristPointPlaced()) {
          measurer.removeChild(currentMark);
          currentMark.setFirstPointPlaced(false);
        }
      } catch (NoSuchElementException ex) {
      }
      measurer.getMarker().removeMarkerLine();
    }
  }
Esempio n. 2
0
  void setMeasurementVisible(boolean visible) {
    measurementVisible = visible;

    if (measurer != null) {
      measurer.getMarker().setVisible(visible);
      for (Mark mark : measurer.getMarks()) {
        mark.setVisible(visible);
      }
    }
  }
Esempio n. 3
0
  @Override
  public void mouseClicked(MouseEvent e) {
    if (measurer != null && measurementVisible) {
      Marker marker = measurer.getMarker();
      Point3d markerPos = marker.getMarkerPos();

      // if there's any selected node, unselect it
      if (selectedNode != null) {
        ((Mark) selectedNode.getParent().getParent().getParent()).unSelect();
        selectedNode = null;
      }

      if (hoveredNode != null && hoveredNode.getParent().getParent().getParent() instanceof Mark) {

        // select the clicked one
        selectedNode = hoveredNode;
        ((Mark) selectedNode.getParent().getParent().getParent()).select();
      } // click to add a mark dot
      else if (measuring) {
        Mark currentMark; // could be the last mark, or a new one
        try {
          currentMark = measurer.getMarks().getLast();
          if (!currentMark.isFristPointPlaced()) { // last mark completed
            Mark newMark = measurer.createMark(); // create new one
            newMark.createFirstPoint(markerPos);
            marker.initMarkerLine(markerPos);
          } else { // use last mark
            currentMark.createSecondPoint(markerPos);
            currentMark.createText();
            currentMark.createMarkLine();
            marker.removeMarkerLine();
          }
        } catch (NoSuchElementException ex) { // no mark found
          currentMark = measurer.createMark();
          currentMark.createFirstPoint(markerPos);
          marker.initMarkerLine(markerPos);
        }
      }
    }

    if (choosingPivotPoint) {
      pivotPointAdjustor.putPivotPoint(pivotPointAdjustor.getPlacer().getPos());
    }
  }