ftp.nice.ch/pub/next/graphics/3d/geomview.1.4.1.s.tar.gz#/Geomview/src/bin/tackdown/origin.common.c

This is origin.common.c in view mode; [Download] [Up]

#include <stdio.h>
#include "geom.h"
#include "streampool.h"
#include "origin.common.h"

static char targetname[255];

static int neutral;

static Pool *infile;

/* Return ui to state where there are no axes visible */
static void NeutralState() {
  neutral = 1;
  uiDisableDoneCancel();
  uiEnableShow();
  uiSetInstructions("Click on the \"Show Origin\"",
		    "button to display the",
		    "coordinate axes of the",
		    "named object.");
		    
}

/* Set ui to state where there are axes visible */
static void NonNeutralState() {
  neutral = 0;
  uiEnableDoneCancel();
  uiDisableShow();
  uiSetInstructions("Now move the axis around in",
		    "Geomview to move the origin of",
		    "the named object.  Then",
		    "click the \"Done\" button.");
		   
}

void internalsInit() {
  uiSetTargetname("targetgeom");

  infile = PoolStreamTemp(NULL, stdin, 0, NULL); 

  NeutralState();
}

void internalsShow() 
{
  Transform T;

  uiGetTargetname(targetname);

  printf("(echo \"{ \")");
  printf("(write transform - %s world)", targetname);
  printf("(echo } )");
  fflush(stdout);
  if (!TransStreamIn(infile, NULL, T)) {
    uiError("Unable to find transform of", "named item.  Perhaps",
	    "the object does not exist.");
    return;
  }

  printf("(progn ");
  printf("(geometry axes.%s < axes.list) ", targetname);
  printf("(normalization axes.%s none) ", targetname);
  printf("(xform-set axes.%s", targetname);
  fputtransform(stdout, 1, &T[0][0], 0);
  printf(") ");
  printf(")");
  fflush(stdout);
  NonNeutralState();
}

static void DeleteAxes() {
  printf("(delete axes.%s)", targetname);
  fflush(stdout);
}

void internalsDone() {
  Geom *g;
  Transform w2axes, w2target, axes2w, axes2target;
 
  printf("(echo \"{ \")");
  printf("(write transform - axes.%s world)", targetname);
  printf("(echo } )");
  fflush(stdout);
  if (!TransStreamIn(infile, NULL, w2axes)) {
    uiError("Unable to find axes.  Perhaps", "they were deleted in",
	    "Geomview.");
    NeutralState();
    return;
  }

  printf("(echo \"{ \")");
  printf("(write geometry - %s bare)", targetname);
  printf("(echo } )");
  fflush(stdout);
  g = GeomFLoad(stdin, NULL);
  if (g == NULL) 
    uiError("Unable to find", "target object.  Perhaps", 
	    "it has been deleted.");
  else {
    printf("(echo \"{ \")");
    printf("(write transform - %s world)", targetname);
    printf("(echo } )");
    fflush(stdout);
    if (!TransStreamIn(infile, NULL, w2target)) {
      uiError("Unable to find transform of", "named item.  Perhaps",
	      "the object does not exist.");
      return;
    }
    TmInvert(w2axes, axes2w);
    TmConcat(axes2w, w2target, axes2target);
    GeomTransform(g, axes2target);

    printf("(progn ");
    printf("(geometry %s ", targetname);
    GeomFSave(g, stdout, NULL);
    printf(")");
    printf("(xform-set %s ", targetname);
    fputtransform(stdout, 1, &w2axes[0][0], 0);
    printf(")");
    printf(")");
    fflush(stdout);
  }

  DeleteAxes();
  NeutralState();
}

void internalsCancel() {
  DeleteAxes();
  NeutralState();
}

void internalsQuit() {
  PoolDelete(infile);
  exit(0);
}
  

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.