Beispiel #1
0
 protected boolean restore() {
   ModelSet modelSet = vwr.ms;
   if (modelSet == null) return false;
   modelSet.deleteAllBonds();
   for (int i = bondCount; --i >= 0; ) {
     Connection c = connections[i];
     int ac = modelSet.ac;
     if (c.atomIndex1 >= ac || c.atomIndex2 >= ac) continue;
     Bond b =
         modelSet.bondAtoms(
             modelSet.at[c.atomIndex1],
             modelSet.at[c.atomIndex2],
             c.order,
             c.mad,
             null,
             c.energy,
             false,
             true);
     b.colix = c.colix;
     b.shapeVisibilityFlags = c.shapeVisibilityFlags;
   }
   for (int i = bondCount; --i >= 0; ) modelSet.bo[i].index = i;
   vwr.setShapeProperty(JC.SHAPE_STICKS, "reportAll", null);
   return true;
 }
  String generateOutput(String type, Graphics3D g3d, ModelSet modelSet, String fileName) {

    viewer.finalizeTransformParameters();

    JmolRendererInterface g3dExport = null;
    Object output = null;
    boolean isOK = false;
    try {
      if (fileName == null) {
        output = new StringBuffer();
      } else {
        if (fileName.charAt(0) == '?') fileName = viewer.dialogAsk("save", fileName.substring(1));
        if (fileName == null) return null;
        output = fileName;
      }
      Class export3Dclass = Class.forName("org.jmol.export.Export3D");
      g3dExport = (JmolRendererInterface) export3Dclass.newInstance();
      isOK = g3dExport.initializeExporter(type, viewer, g3d, output);
    } catch (Exception e) {
    }
    if (!isOK) {
      Logger.error("Cannot export " + type);
      return null;
    }
    g3dExport.renderBackground();
    for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) {
      Shape shape = modelSet.getShape(i);
      if (shape == null) continue;
      ShapeRenderer generator = getGenerator(i, g3d);
      generator.setGenerator(true);
      generator.render(g3dExport, modelSet, shape);
      generator.setGenerator(false);
    }
    return g3dExport.finalizeOutput();
  }
  private void render1(Graphics3D g3d, ModelSet modelSet) { // , Rectangle rectClip

    if (modelSet == null || !viewer.mustRenderFlag()) return;

    logTime = viewer.getTestFlag1();

    viewer.finalizeTransformParameters();

    if (logTime) Logger.startTimer();

    try {
      g3d.renderBackground();
      if (renderers == null) renderers = new ShapeRenderer[JmolConstants.SHAPE_MAX];
      for (int i = 0; i < JmolConstants.SHAPE_MAX && g3d.currentlyRendering(); ++i) {
        Shape shape = modelSet.getShape(i);
        if (shape == null) continue;
        getRenderer(i, g3d).render(g3d, modelSet, shape);
      }

    } catch (Exception e) {
      Logger.error("rendering error -- perhaps use \"set refreshing FALSE/TRUE\" ? ");
    }
    if (logTime) Logger.checkTimer("render time");
  }