Beispiel #1
0
 private void setVis(Map<?, Ellipsoid> ellipsoids, BS bs, Atom[] atoms) {
   for (Ellipsoid e : ellipsoids.values()) {
     Tensor t = e.tensor;
     boolean isOK = (t != null && e.isValid && e.isOn);
     if (isOK && t.atomIndex1 >= 0) {
       if (t.iType == Tensor.TYPE_ADP) {
         boolean isModTensor = t.isModulated;
         boolean isUnmodTensor = t.isUnmodulated;
         boolean isModAtom = ms.isModulated(t.atomIndex1);
         isOK = (!isModTensor && !isUnmodTensor || isModTensor == isModAtom);
       }
       atoms[t.atomIndex1].setShapeVisibility(vf, true);
     }
     e.visible = isOK && (e.modelIndex < 0 || bs.get(e.modelIndex));
   }
 }
Beispiel #2
0
 /**
  * needed for XmlPersistable
  *
  * @param encoder encoder for encoding
  * @return this as an encoded Element
  */
 public Element createElement(XmlEncoder encoder) {
   List arguments =
       Misc.newList(
           ellipsoid, new Integer(onezone), new Boolean(onehemiflag), getDefaultMapArea());
   List types =
       Misc.newList(ellipsoid.getClass(), Integer.TYPE, Boolean.TYPE, Rectangle2D.Double.class);
   Element result = encoder.createObjectElement(getClass());
   Element ctorElement = encoder.createConstructorElement(arguments, types);
   result.appendChild(ctorElement);
   return result;
 }
Beispiel #3
0
 @Override
 protected void setSize(int size, BS bsSelected) {
   if (ms.at == null || size == 0 && ms.atomTensors == null) return;
   boolean isAll = (bsSelected == null);
   if (!isAll && selectedAtoms != null) bsSelected = selectedAtoms;
   Lst<Object> tensors = vwr.ms.getAllAtomTensors(typeSelected);
   if (tensors == null) return;
   Atom[] atoms = ms.at;
   for (int i = tensors.size(); --i >= 0; ) {
     Tensor t = (Tensor) tensors.get(i);
     if (isAll || t.isSelected(bsSelected, -1)) {
       Ellipsoid e = atomEllipsoids.get(t);
       boolean isNew = (size != 0 && e == null);
       if (isNew)
         atomEllipsoids.put(t, e = Ellipsoid.getEllipsoidForAtomTensor(t, atoms[t.atomIndex1]));
       if (e != null && (isNew || size != Integer.MAX_VALUE)) { // MAX_VALUE --> "create only"
         e.setScale(size, true);
       }
     }
   }
 }
Beispiel #4
0
 private void setProp(Ellipsoid e, int mode, Object value) {
   // "ax ce co de eq mo on op sc tr"
   //  0  1  2  3  4  5  6  7  8  9
   switch (mode) {
     case 0: // axes
       e.setTensor(
           ((Tensor) Interface.getUtil("Tensor", vwr, "script")).setFromAxes((V3[]) value));
       return;
     case 1: // center
       e.setCenter((P3) value);
       return;
     case 2: // color
       e.colix = C.getColixO(value);
       return;
     case 3: // delete
       simpleEllipsoids.remove(e.id);
       return;
     case 4: // equation
       e.setTensor(
           ((Tensor) Interface.getUtil("Tensor", vwr, "script"))
               .setFromThermalEquation((double[]) value, null));
       return;
     case 5: // modelindex
       e.tensor.modelIndex = ((Integer) value).intValue();
       return;
     case 6: // on
       e.isOn = ((Boolean) value).booleanValue();
       return;
     case 7: // options
       e.options = ((String) value).toLowerCase();
       return;
     case 8: // scale
       e.setScale(((Float) value).floatValue(), false);
       return;
     case 9: // translucency
       e.colix = C.getColixTranslucent3(e.colix, value.equals("translucent"), translucentLevel);
       return;
   }
   return;
 }
Beispiel #5
0
  @Override
  public void setProperty(String propertyName, Object value, BS bs) {
    // System.out.println(propertyName + " " + value + " " + bs);
    if (propertyName == "thisID") {
      if (initEllipsoids(value) && ellipsoidSet.size() == 0) {
        String id = (String) value;
        Ellipsoid e = Ellipsoid.getEmptyEllipsoid(id, vwr.am.cmi);
        ellipsoidSet.addLast(e);
        simpleEllipsoids.put(id, e);
      }
      return;
    }

    if ("atoms" == propertyName) {
      selectedAtoms = (BS) value;
      return;
    }

    if (propertyName == "deleteModelAtoms") {
      int modelIndex = ((int[]) ((Object[]) value)[2])[0];
      Iterator<Ellipsoid> e = simpleEllipsoids.values().iterator();
      while (e.hasNext()) if (e.next().tensor.modelIndex == modelIndex) e.remove();
      e = atomEllipsoids.values().iterator();
      while (e.hasNext()) if (e.next().modelIndex == modelIndex) e.remove();
      ellipsoidSet.clear();
      return;
    }
    int mode = PROPERTY_MODES.indexOf((propertyName + "  ").substring(0, 2));
    if (ellipsoidSet.size() > 0) {
      if ("translucentLevel" == propertyName) {
        setPropS(propertyName, value, bs);
        return;
      }
      if (mode >= 0)
        for (int i = ellipsoidSet.size(); --i >= 0; ) setProp(ellipsoidSet.get(i), mode / 3, value);
      return;
    }

    if ("color" == propertyName) {
      short colix = C.getColixO(value);
      byte pid = PAL.pidOf(value);
      if (selectedAtoms != null) bs = selectedAtoms;
      for (Ellipsoid e : atomEllipsoids.values())
        if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) {
          e.colix = getColixI(colix, pid, e.tensor.atomIndex1);
          e.pid = pid;
        }
      return;
    }

    if ("on" == propertyName) {
      boolean isOn = ((Boolean) value).booleanValue();
      if (selectedAtoms != null) bs = selectedAtoms;
      if (isOn) setSize(Integer.MAX_VALUE, bs);
      for (Ellipsoid e : atomEllipsoids.values()) {
        Tensor t = e.tensor;
        if ((t.type.equals(typeSelected) || typeSelected.equals(t.altType))
            && t.isSelected(bs, -1)) {
          e.isOn = isOn;
        }
      }
      return;
    }

    if ("options" == propertyName) {
      String options = ((String) value).toLowerCase().trim();
      if (options.length() == 0) options = null;
      if (selectedAtoms != null) bs = selectedAtoms;
      if (options != null) setSize(Integer.MAX_VALUE, bs);
      for (Ellipsoid e : atomEllipsoids.values())
        if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) e.options = options;
      return;
    }

    if ("params" == propertyName) {
      Object[] data = (Object[]) value;
      data[2] = null; // Jmol does not allow setting sizes this way from PyMOL yet
      typeSelected = "0";
      setSize(50, bs);
      // onward...
    }

    if ("points" == propertyName) {
      // Object[] o = (Object[]) value;
      // setPoints((P3[]) o[1], (BS) o[2]);
      return;
    }

    if ("scale" == propertyName) {
      setSize((int) (((Float) value).floatValue() * 100), bs);
      return;
    }

    if ("select" == propertyName) {
      typeSelected = ((String) value).toLowerCase();
      return;
    }

    if ("translucency" == propertyName) {
      boolean isTranslucent = (value.equals("translucent"));
      for (Ellipsoid e : atomEllipsoids.values())
        if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1))
          e.colix = C.getColixTranslucent3(e.colix, isTranslucent, translucentLevel);
      return;
    }
    setPropS(propertyName, value, bs);
  }
    protected void makeShapes() {
      RenderableLayer layer = new RenderableLayer();
      layer.setName("Rigid Shapes");

      // Create and set an attribute bundle.
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setInteriorMaterial(Material.YELLOW);
      attrs.setInteriorOpacity(0.7);
      attrs.setEnableLighting(true);
      attrs.setOutlineMaterial(Material.RED);
      attrs.setOutlineWidth(2d);
      attrs.setDrawInterior(true);
      attrs.setDrawOutline(false);

      // Create and set a second attribute bundle.
      ShapeAttributes attrs2 = new BasicShapeAttributes();
      attrs2.setInteriorMaterial(Material.PINK);
      attrs2.setInteriorOpacity(1);
      attrs2.setEnableLighting(true);
      attrs2.setOutlineMaterial(Material.WHITE);
      attrs2.setOutlineWidth(2d);
      attrs2.setDrawOutline(false);

      // Pyramid with equal axes, ABSOLUTE altitude mode.
      Pyramid pyramid = new Pyramid(Position.fromDegrees(40, -120, 220000), 200000, 200000, 200000);
      pyramid.setAltitudeMode(WorldWind.ABSOLUTE);
      pyramid.setAttributes(attrs);
      pyramid.setValue(AVKey.DISPLAY_NAME, "Pyramid with equal axes, ABSOLUTE altitude mode");
      layer.addRenderable(pyramid);

      // Cone with equal axes, RELATIVE_TO_GROUND.
      Cone cone = new Cone(Position.fromDegrees(37.5, -115, 200000), 200000, 200000, 200000);
      cone.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      cone.setAttributes(attrs);
      cone.setValue(AVKey.DISPLAY_NAME, "Cone with equal axes, RELATIVE_TO_GROUND altitude mode");
      layer.addRenderable(cone);

      // Wedge with equal axes, CLAMP_TO_GROUND.
      Wedge wedge =
          new Wedge(
              Position.fromDegrees(35, -110, 200000),
              Angle.fromDegrees(225),
              200000,
              200000,
              200000);
      wedge.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
      wedge.setAttributes(attrs);
      wedge.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, CLAMP_TO_GROUND altitude mode");
      layer.addRenderable(wedge);

      // Box with a texture.
      Box box = new Box(Position.fromDegrees(0, -90, 600000), 600000, 600000, 600000);
      box.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      ArrayList<Object> imageSources = new ArrayList<Object>();
      imageSources.add("images/32x32-icon-nasa.png");
      imageSources.add(null);
      imageSources.add("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      imageSources.add(null);
      imageSources.add("images/64x64-crosshair.png");
      imageSources.add(null);
      box.setImageSources(imageSources);
      box.setAttributes(attrs);
      box.setValue(AVKey.DISPLAY_NAME, "Box with a texture");
      layer.addRenderable(box);

      // Sphere with a texture.
      Ellipsoid sphere =
          new Ellipsoid(Position.fromDegrees(0, -110, 600000), 600000, 600000, 600000);
      sphere.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      sphere.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      sphere.setAttributes(attrs);
      sphere.setValue(AVKey.DISPLAY_NAME, "Sphere with a texture");
      layer.addRenderable(sphere);

      // Cylinder with a texture.
      Cylinder cylinder =
          new Cylinder(Position.fromDegrees(0, -130, 600000), 600000, 600000, 600000);
      cylinder.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      cylinder.setImageSources(
          "gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      cylinder.setAttributes(attrs);
      cylinder.setValue(AVKey.DISPLAY_NAME, "Cylinder with a texture");
      layer.addRenderable(cylinder);

      // Cylinder with default orientation.
      cylinder = new Cylinder(Position.ZERO, 600000, 500000, 300000);
      cylinder.setAltitudeMode(WorldWind.ABSOLUTE);
      cylinder.setAttributes(attrs);
      cylinder.setValue(AVKey.DISPLAY_NAME, "Cylinder with default orientation");
      layer.addRenderable(cylinder);

      // Ellipsoid with a pre-set orientation.
      Ellipsoid ellipsoid =
          new Ellipsoid(
              Position.fromDegrees(0, 30, 750000),
              1000000,
              500000,
              100000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      ellipsoid.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      ellipsoid.setAttributes(attrs2);
      ellipsoid.setValue(AVKey.DISPLAY_NAME, "Ellipsoid with a pre-set orientation");
      layer.addRenderable(ellipsoid);

      // Ellipsoid with a pre-set orientation.
      ellipsoid =
          new Ellipsoid(
              Position.fromDegrees(30, 30, 750000),
              1000000,
              500000,
              100000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      ellipsoid.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      ellipsoid.setImageSources(
          "gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      ellipsoid.setAttributes(attrs2);
      ellipsoid.setValue(AVKey.DISPLAY_NAME, "Ellipsoid with a pre-set orientation");
      layer.addRenderable(ellipsoid);

      // Ellipsoid with a pre-set orientation.
      ellipsoid =
          new Ellipsoid(
              Position.fromDegrees(60, 30, 750000),
              1000000,
              500000,
              100000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      ellipsoid.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      ellipsoid.setAttributes(attrs2);
      ellipsoid.setValue(AVKey.DISPLAY_NAME, "Ellipsoid with a pre-set orientation");
      layer.addRenderable(ellipsoid);

      // Ellipsoid oriented in 3rd "quadrant" (-X, -Y, -Z).
      ellipsoid =
          new Ellipsoid(
              Position.fromDegrees(-45, -180, 750000),
              1000000,
              500000,
              100000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      ellipsoid.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      ellipsoid.setAttributes(attrs2);
      ellipsoid.setValue(AVKey.DISPLAY_NAME, "Ellipsoid oriented in 3rd \"quadrant\" (-X, -Y, -Z)");
      layer.addRenderable(ellipsoid);

      // Add the layer to the model and update the layer panel.
      insertBeforePlacenames(getWwd(), layer);
    }