Exemple #1
0
// text has a start point and a string to display
static int tcl_graphics_text(MoleculeGraphics *gmol, int argc, const char *argv[],
			     Tcl_Interp *interp) {
  // have a vector and some text
  AT_LEAST(2, "text");
  float vals[3];
  if (tcl_get_vector(argv[0], vals+0,  interp) != TCL_OK) {
    return TCL_ERROR;
  }

  // get the optional size values
  const char* string = argv[1];
  double size = 1.0;
  double thickness = 1.0;
  argc -= 2;
  argv += 2;

  if (argc %2) {
    Tcl_SetResult(interp, (char *) "graphics: text has wrong number of options", TCL_STATIC);
    return TCL_ERROR;
  }

  while (argc) {
    if (!strcmp(argv[0], "size")) {
      if (Tcl_GetDouble(interp, argv[1], &size) != TCL_OK) {
        return TCL_ERROR;
      }
      if (size <0) size = 0;
      argc -= 2;
      argv += 2;
      continue;
    }

    if (!strcmp(argv[0], "thickness")) {
      if (Tcl_GetDouble(interp, argv[1], &thickness) != TCL_OK) {
        return TCL_ERROR;
      }
      if (thickness <0) thickness = 0;
      argc -= 2;
      argv += 2;
      continue;
    }

    // reaching here is an error
    Tcl_AppendResult(interp, "graphics: unknown option for text: ",
                     argv[0], NULL);
    return TCL_ERROR;
  }

  // add the text
  char tmpstring[64];
  sprintf(tmpstring, "%d", gmol->add_text(vals+0, string, (float) size, (float) thickness));
  Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
  return TCL_OK;
}
Exemple #2
0
// has begin and end points, a "style", and a width
static int tcl_graphics_line(MoleculeGraphics *gmol, 
			     int argc, const char *argv[],
			     Tcl_Interp *interp)
{
  // just need the start and end values
  AT_LEAST(2, "line");
  float vals[6];
  if (tcl_get_vector(argv[0], vals+0, interp) != TCL_OK ||
      tcl_get_vector(argv[1], vals+3, interp) != TCL_OK) {
    return TCL_ERROR;
  }
  // options:
  //  'style' is "solid" or "dashed"
  //  'width' is 0 .. 255;
  int line_style = ::SOLIDLINE;
  int width = 1;
  argc -= 2;
  argv += 2;
  if (argc %2) {
    Tcl_SetResult(interp, (char *) "graphics: line has wrong number of options", TCL_STATIC);
    return TCL_ERROR;
  }
  while (argc) {
    if (!strcmp(argv[0], "style")) {
      if (!strcmp(argv[1], "solid")) {
	line_style = ::SOLIDLINE;
      } else if (!strcmp(argv[1], "dashed")) {
	line_style = ::DASHEDLINE;
      } else {
	Tcl_AppendResult(interp, "graphics: don't understand the line style ",
			 argv[1], NULL);
	return TCL_ERROR;
      }
    } else if (!strcmp(argv[0], "width")) {
      if (Tcl_GetInt(interp, argv[1], &width) != TCL_OK) {
	return TCL_ERROR;
      }
      if (width > 255) width = 255;
      if (width < 0) width = 0;
    } else {
      Tcl_AppendResult(interp, "graphics: don't understand the line option ",
		       argv[0], NULL);
      return TCL_ERROR;
    }
    argc -= 2;
    argv += 2;
  }

  // otherwise, just draw the line
  char tmpstring[64];
  sprintf(tmpstring, "%d", gmol->add_line(vals+0, vals+3, line_style, width));
  Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
  return TCL_OK;
}
Exemple #3
0
// sphere has a center, radius, and resolution
static int tcl_graphics_sphere(MoleculeGraphics *gmol,
			       int argc, const char *argv[],
			       Tcl_Interp *interp)
{
  // only really need the coordinates
  AT_LEAST(1, "sphere");
  float vals[3];
  if (tcl_get_vector(argv[0], vals+0,  interp) != TCL_OK) {
    return TCL_ERROR;
  }

  // get the optional values
  double radius = 1.0;
  int resolution = 6;
  argc -= 1;
  argv += 1;
  if (argc %2) {
    Tcl_SetResult(interp, (char *) "graphics: sphere has wrong number of options", TCL_STATIC);
    return TCL_ERROR;
  }
  while (argc) {
    if (!strcmp(argv[0], "radius")) {
      if (Tcl_GetDouble(interp, argv[1], &radius) != TCL_OK) {
	return TCL_ERROR;
      }
      if (radius <0) radius = 0;
      argc -= 2;
      argv += 2;
      continue;
    }
    if (!strcmp(argv[0], "resolution")) {
      if (Tcl_GetInt(interp, argv[1], &resolution) != TCL_OK) {
	return TCL_ERROR;
      }
      if (resolution < 0) resolution = 0;
      if (resolution > 30) resolution = 30;
      argc -= 2;
      argv += 2;
      continue;
    }
    // reaching here is an error
    Tcl_AppendResult(interp, "graphics: unknown option for sphere: ",
		     argv[0], NULL);
    return TCL_ERROR;
  }

  // I have a sphere, so add it
  char tmpstring[64];
  sprintf(tmpstring, "%d",
	  gmol->add_sphere(vals+0, (float) radius, resolution));
  Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
  return TCL_OK;
}
Exemple #4
0
// cone has base and tip coordinates, width at the base, width at the tip and resolution
static int tcl_graphics_cone(MoleculeGraphics *gmol,
			     int argc, const char *argv[],
			     Tcl_Interp *interp)
{
  // the first two are {x, y, z}
  AT_LEAST(2, "cone");
  float vals[6];
  if (tcl_get_vector(argv[0], vals+0,  interp) != TCL_OK ||
      tcl_get_vector(argv[1], vals+3,  interp) != TCL_OK) {
    return TCL_ERROR;
  }

  // get the optional values
  double radius = 1.0;
  double radius2 = 0.0;
  int resolution = 6;
  argc -= 2;
  argv += 2;
  if (argc %2) {
    Tcl_SetResult(interp, (char *) "graphics: cone has wrong number of options", TCL_STATIC);
    return TCL_ERROR;
  }
  while (argc) {
    if (!strcmp(argv[0], "radius2")) {
      if (Tcl_GetDouble(interp, argv[1], &radius2) != TCL_OK) {
	return TCL_ERROR;
      }
      if (radius2 <0) radius2 = 0;
      argc -= 2;
      argv += 2;
      continue;
    }
    if (!strcmp(argv[0], "radius")) {
      if (Tcl_GetDouble(interp, argv[1], &radius) != TCL_OK) {
	return TCL_ERROR;
      }
      if (radius <0) radius = 0;
      argc -= 2;
      argv += 2;
      continue;
    }
    if (!strcmp(argv[0], "resolution")) {
      if (Tcl_GetInt(interp, argv[1], &resolution) != TCL_OK) {
	return TCL_ERROR;
      }
      if (resolution < 0) resolution = 0;
      if (resolution > 300) resolution = 300;
      argc -= 2;
      argv += 2;
      continue;
    }

    // reaching here is an error
    Tcl_AppendResult(interp, "graphics: unknown option for cone: ",
		     argv[0], NULL);
    return TCL_ERROR;
  }

  // I have a cone, so add it
  char tmpstring[64];
  sprintf(tmpstring, "%d",
	  gmol->add_cone(vals+0, vals+3, (float) radius, (float) radius2, resolution));
  Tcl_SetResult(interp, tmpstring, TCL_VOLATILE);
  return TCL_OK;
}
static void 
peanut_gallery(void)
{
    char    buf[90];

    if (strcmp(me->p_name, "a fungusamongus") == 0) {	/* that's me! */
	pmessage2("  ", 0, MALL, "LDDENYS > ", me->p_no);
	pmessage2("Yikes.  EEK!  Help.  There seems to be a fungus among us!", 0, MALL, "LDDENYS > ", me->p_no);
	pmessage2("  ", 0, MALL, "LDDENYS > ", me->p_no);

    }
    else if (strcmp(me->p_name, "Lynx") == 0) {
	pmessage2("\"GAME OVER MAN, GAME OVER!\"", 0, MALL, "Lynx->ALL ", me->p_no);

    }
    else if (strcmp(me->p_name, "Hammor") == 0) {
	pmessage2("Please don't hurt 'em, Hammor!", 0, MALL, "GOD->ALL", me->p_no);

    }
    else if (strcmp(me->p_name, "Bubbles") == 0) {
	pmessage2("Whoa!", 0, MALL, "KAOLSEN > ", me->p_no);
	pmessage2("Dudes.", 0, MALL, "KAOLSEN > ", me->p_no);
	pmessage2("Cool.", 0, MALL, "KAOLSEN > ", me->p_no);

    }
    else if (strcmp(me->p_name, "KnightRaven") == 0) {
	pmessage2("Insert Heiji quote here", 0, MALL, "KAOLSEN > ", me->p_no);
	AT_LEAST(AMBASSADOR);

    }
    else if (strcmp(me->p_name, "wibble") == 0) {
	pmessage2("No mountain is unclimbable, no river uncrossable, no client RSA"
		 ,0, MALL, "EGO->wibble", me->p_no);
	pmessage2("key unbreakable.  We can just make it bloody difficult!",
		 0, MALL, "EGO->wibble", me->p_no);

    }
    else if (strcmp(me->p_name, "Key") == 0) {
	time_t  curtime;
	struct tm *tmstruct;
	int     hour;

	(void) time(&curtime);
	tmstruct = localtime(&curtime);
	if (!(hour = tmstruct->tm_hour % 12))
	    hour = 12;

	sprintf(buf, "It's %d:%02d%s, time [for me] to die.", hour,
		tmstruct->tm_min, tmstruct->tm_hour >= 12 ? "pm" : "am");
	pmessage2(buf, 0, MALL, "GOD->ALL", me->p_no);

    }
    else if (strcmp(me->p_name, "MikeL") == 0) {
	pmessage2("<This space for rent>", 0, MALL, "GOD->ALL", me->p_no);


    }
    else if (strcmp(me->p_name, "Bolo") == 0) {
	pmessage2("Bolo Mk. MCLXVII On-line.", 0, MALL, MSERVA, me->p_no);
    }
}