当前位置: 首页>>代码示例>>C++>>正文


C++ Tcl_Eval函数代码示例

本文整理汇总了C++中Tcl_Eval函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_Eval函数的具体用法?C++ Tcl_Eval怎么用?C++ Tcl_Eval使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Tcl_Eval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: app


//.........这里部分代码省略.........
  // Don't check for interactive console input if compiled for Android
  ignorestdin = 1;
#endif

  // set tcl_interactive, lets us run unix commands as from a shell
#if !defined(VMD_NANOHUB)
  Tcl_SetVar(interp, "tcl_interactive", "1", 0);
#else
  Tcl_SetVar(interp, "tcl_interactive", "0", 0);

  Tcl_Channel channel;
#define CLIENT_READ	(3)
#define CLIENT_WRITE	(4)
  channel = Tcl_MakeFileChannel((ClientData)CLIENT_READ, TCL_READABLE);
  if (channel != NULL) {
      const char *result;

      Tcl_RegisterChannel(interp, channel);
      result = Tcl_SetVar2(interp, "vmd_client", "read", 
		Tcl_GetChannelName(channel), 
		TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG);
      if (result == NULL) {
	  fprintf(stderr, "can't create variable for client read channel\n");
      }
  }
  channel = Tcl_MakeFileChannel((ClientData)CLIENT_WRITE, TCL_WRITABLE);
  if (channel != NULL) {
      const char *result;

      Tcl_RegisterChannel(interp, channel);
      result = Tcl_SetVar2(interp, "vmd_client", "write", 
		Tcl_GetChannelName(channel), 
		TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG);
      if (result == NULL) {
	  fprintf(stderr, "can't create variable for client write channel\n");
      }
  }
  write(CLIENT_WRITE, "vmd 1.0\n", 8);
#endif


  // pass our instance of VMDApp to a hash table assoc. with the interpreter 
  Tcl_SetAssocData(interp, "VMDApp", NULL, app);
 
  // Set up argc, argv0, and argv variables
  {
    char argcbuf[20];
    sprintf(argcbuf, "%d", app->argc_m);
    Tcl_SetVar(interp, "argc", argcbuf, TCL_GLOBAL_ONLY);
    // it might be better to use the same thing that was passed to
    // Tcl_FindExecutable, but this is now
    Tcl_SetVar(interp, "argv0", app->argv_m[0], TCL_GLOBAL_ONLY);
    char *args = Tcl_Merge(app->argc_m-1, app->argv_m+1);
    Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY);
    Tcl_Free(args);
  }

#if defined(_MSC_VER) && TCL_MINOR_VERSION >= 4
  // The Windows versions of Tcl 8.5.x have trouble finding
  // the Tcl library subdirectory for unknown reasons.
  // We force the appropriate env variables to be set in Tcl, 
  // despite Windows.
  {
    char vmdinitscript[4096];
    char * tcl_library = getenv("TCL_LIBRARY");
    char * tk_library = getenv("TK_LIBRARY");

    if (tcl_library) {
      sprintf(vmdinitscript, "set env(TCL_LIBRARY) {%s}", tcl_library);
      if (Tcl_Eval(interp, vmdinitscript) != TCL_OK) {
        msgErr << Tcl_GetStringResult(interp) << sendmsg;
      }
    }
    if (tk_library) {
      sprintf(vmdinitscript, "set env(TK_LIBRARY) {%s}", tk_library);
      if (Tcl_Eval(interp, vmdinitscript) != TCL_OK) {
        msgErr << Tcl_GetStringResult(interp) << sendmsg;
      }
    }
  }
#endif

  if (Tcl_Init(interp) == TCL_ERROR) {  // new with 7.6
    msgErr << "Tcl startup error: " << Tcl_GetStringResult(interp) << sendmsg;
  }

#ifdef VMDTK
  // and the Tk commands (but only if a GUI is available!)
  if (guienabled) {
    if (Tk_Init(interp) == TCL_ERROR) {
      msgErr << "Tk startup error: " << Tcl_GetStringResult(interp) << sendmsg;
    } else {
      Tcl_StaticPackage(interp,  "Tk",
                        (Tcl_PackageInitProc *) Tk_Init,
                        (Tcl_PackageInitProc *) NULL);
    }
  } // end of check that GUI is allowed
#endif
  add_commands();
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:101,代码来源:TclTextInterp.C

示例2: common_dm


//.........这里部分代码省略.........
	    MAT4X3PNT(model_pt, view_state->vs_gvp->gv_view2model, view_pt);
	    VSCALE(model_pt, model_pt, base2local);
	    bu_vls_printf(&vls, "p %lf %lf %lf", model_pt[X], model_pt[Y], model_pt[Z]);
	} else if (grid_state->gr_snap && !stolen &&
		   OEDIT_TRAN && mged_variables->mv_transform == 'e') {
	    point_t view_pt;
	    point_t model_pt;

	    snap_to_grid(&fx, &fy);
	    MAT4X3PNT(view_pt, view_state->vs_gvp->gv_model2view, curr_e_axes_pos);
	    view_pt[X] = fx;
	    view_pt[Y] = fy;
	    MAT4X3PNT(model_pt, view_state->vs_gvp->gv_view2model, view_pt);
	    VSCALE(model_pt, model_pt, base2local);
	    bu_vls_printf(&vls, "translate %lf %lf %lf", model_pt[X], model_pt[Y], model_pt[Z]);
	} else if (grid_state->gr_snap && !stolen &&
		   STATE != ST_S_PICK && STATE != ST_O_PICK &&
		   STATE != ST_O_PATH && !SEDIT_PICK && !EDIT_SCALE) {
	    point_t view_pt;
	    point_t model_pt;
	    point_t vcenter;

	    snap_to_grid(&fx, &fy);
	    MAT_DELTAS_GET_NEG(vcenter, view_state->vs_gvp->gv_center);
	    MAT4X3PNT(view_pt, view_state->vs_gvp->gv_model2view, vcenter);
	    view_pt[X] = fx;
	    view_pt[Y] = fy;
	    MAT4X3PNT(model_pt, view_state->vs_gvp->gv_view2model, view_pt);
	    VSCALE(model_pt, model_pt, base2local);
	    bu_vls_printf(&vls, "center %lf %lf %lf", model_pt[X], model_pt[Y], model_pt[Z]);
	} else
	    bu_vls_printf(&vls, "M 1 %d %d\n", x, y);

	status = Tcl_Eval(INTERP, bu_vls_addr(&vls));
	mged_variables->mv_orig_gui = old_orig_gui;
	bu_vls_free(&vls);

	return status;
    }

    if (BU_STR_EQUAL(argv[0], "am")) {
	if (argc < 4) {
	    Tcl_AppendResult(INTERP, "dm am: need more parameters\n",
			     "dm am <r|t|s> xpos ypos\n", (char *)NULL);
	    return TCL_ERROR;
	}

	dml_omx = atoi(argv[2]);
	dml_omy = atoi(argv[3]);

	switch (*argv[1]) {
	    case 'r':
		am_mode = AMM_ROT;
		break;
	    case 't':
		am_mode = AMM_TRAN;

		if (grid_state->gr_snap) {
		    int save_edflag;

		    if ((STATE == ST_S_EDIT || STATE == ST_O_EDIT) &&
			mged_variables->mv_transform == 'e') {
			if (STATE == ST_S_EDIT) {
			    save_edflag = es_edflag;
			    if (!SEDIT_TRAN)
				es_edflag = STRANS;
开发者ID:cogitokat,项目名称:brlcad,代码行数:67,代码来源:dm-generic.c

示例3: OnPostRehash

	virtual void OnPostRehash() {
		if (interp) {
			Tcl_Eval(interp,"rehash");
			Tcl_Eval(interp,"Binds::ProcessEvnt rehash");
		}
	}
开发者ID:jakoch,项目名称:znc,代码行数:6,代码来源:modtcl.cpp

示例4: run_main

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("TkReactor_Test"));

  tcl_interp   = Tcl_CreateInterp ();

  if (init (tcl_interp) != TCL_OK) {
    ACE_OS::exit (1);
  }

  Tk_Window tk = 0;
  tk = Tk_MainWindow(tcl_interp);
  if (tk == 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR, "Tk_Reactor_Test: %s\n", tcl_interp->result),1);
    }

  char tcl_cmd[] = "source TkReactor_Test.tcl";
  if (Tcl_Eval (tcl_interp, tcl_cmd) != TCL_OK) {
    ACE_OS::exit (1);
  }
  // set up callback
  char label_var_name[] = "label_var";
  char pressme[] = "pressme";
  Tcl_CreateCommand (tcl_interp,
                     pressme,
                     inc_count,
                     label_var_name,
                     0);

  // Register callback for X Timer
  (void) Tk_CreateTimerHandler (1000,
                                inc_tmo,
                                label_var_name);

  // It will perform Tk Main Loop
  ACE_TkReactor reactor;
  ACE_Reactor r (&reactor);

  //Event Handler for ACE Timer.
  EV_handler evh;

  ACE_Acceptor <Connection_Handler, ACE_SOCK_ACCEPTOR> acceptor;

  if (acceptor.open (ACE_INET_Addr ((u_short) SERV_TCP_PORT),
                     &r) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       "open"),
                      -1);

  if (reactor.schedule_timer (&evh,
                              (const void *) "label_var",
                              ACE_Time_Value (2),
                              ACE_Time_Value (2))==-1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       " (%P|%t) can't register with reactor\n"),
                      -1);

  ACE_Thread_Manager::instance ()->spawn ((ACE_THR_FUNC) client,
                                          0,
                                          THR_NEW_LWP | THR_DETACHED);

  while (!quit)
    {
      int result = reactor.handle_events ();
      switch (result)
        {
        case 0:
          //          ACE_DEBUG ((LM_DEBUG,"handle_events timed out\n"));
          break;
        case -1:
          ACE_DEBUG ((LM_DEBUG,"handle_events returned -1\n"));
          quit = 1;
          break;
        }
    }

  ACE_END_TEST;
  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:82,代码来源:TkReactor_Test.cpp

示例5: InitTcl

/********************************************************************************************
 * InitTcl
 * purpose : Initialize the TCL part of the test application
 * input   : executable     - Program executable
 *           versionString  - Stack version string
 * output  : reason         - Reason of failure on failure
 * return  : Tcl_Interp interpreter for tcl commands
 *           NULL on failure
 ********************************************************************************************/
Tcl_Interp* InitTcl(const char* executable, char* versionString, char** reason)
{
    static char strBuf[1024];
    int retCode;

    /* Find TCL executable and create an interpreter */
    Tcl_FindExecutable(executable);
    interp = Tcl_CreateInterp();

    if (interp == NULL)
    {
        *reason = (char*)"Failed to create Tcl interpreter";
        return NULL;
    }

    /* Overload file and source commands */
    TclExecute("rename file fileOverloaded");
    CREATE_COMMAND("file", test_File);
    CREATE_COMMAND("source", test_Source);

    /* Reroute tcl libraries - we'll need this one later */
    /*TclSetVariable("tcl_library", TCL_LIBPATH);
    TclSetVariable("env(TCL_LIBRARY)", TCL_LIBPATH);
    TclSetVariable("tk_library", TK_LIBPATH);
    TclSetVariable("env(TK_LIBRARY)", TK_LIBPATH);*/

    /* Initialize TCL */
    retCode = Tcl_Init(interp);
    if (retCode != TCL_OK)
    {
        sprintf(strBuf, "Error in Tcl_Init: %s", Tcl_GetStringResult(interp));
        *reason = strBuf;
        Tcl_DeleteInterp(interp);
        return NULL;
    }

    /* Initialize TK */
    retCode = Tk_Init(interp);
    if (retCode != TCL_OK)
    {
        sprintf(strBuf, "Error in Tk_Init: %s", Tcl_GetStringResult(interp));
        *reason = strBuf;
        Tcl_DeleteInterp(interp);
        return NULL;
    }

    /* Set argc and argv parameters for the script.
       This allows us to work with C in the scripts. */
    retCode = TclExecute("set tmp(version) {Test Application: %s }", versionString);
    if (retCode != TCL_OK)
    {
        *reason = (char*)"Error setting stack's version for test application";
        return interp;
    }

    /* Create new commands that are used in the tcl script */
    CreateTclCommands(interp);

    Tcl_LinkVar(interp, (char *)"scriptLogs", (char *)&LogWrappers, TCL_LINK_BOOLEAN);

    /* Evaluate the Tcl script of the test application */
    retCode = Tcl_Eval(interp, (char*)"source " TCL_FILENAME);
    if (retCode != TCL_OK)
    {
        sprintf(strBuf, "Error reading testapp script (line %d): %s\n", interp->errorLine, Tcl_GetStringResult(interp));
        *reason = strBuf;
        return NULL;
    }

    /* Return the created interpreter */
    *reason = NULL;
    return interp;
}
开发者ID:AkankshaGovil,项目名称:Automation,代码行数:82,代码来源:TAP_init.c

示例6: cs_callback


//.........这里部分代码省略.........
	case TASK_CANVAS_ZOOM:
	    {
		s_zoom *szoom = (s_zoom *)jdata->generic.data;
		canvasZoom(GetInterp(), cs->canvas, cs->window, cs->world,
			   cs->win_list, cs->num_wins, &cs->zoom, szoom->zoom,
			   szoom->scroll);

		break;
	    }
	case TASK_CANVAS_CURSOR_X:
	    {
		char *label;
		int *cx = (int *)jdata->generic.data;
		double local_pos;
		double wx, wy;

		CanvasToWorld(cs->canvas, *cx, 0, &wx, &wy);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR1_X");

		canvasCursorX(GetInterp(), cs->canvas, cs->frame, label,
			      cs->cursor.colour, cs->cursor.width, *cx, wx,
			      cs->win_list, cs->num_wins);

		/* fill in local position of cursor in label box */
		local_pos = CSLocalCursor(io, wx);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR2_X");

		sprintf(cmd, "%s%s configure -text %d\n", cs->frame, label,
			(int)local_pos);
		Tcl_Eval(GetInterp(), cmd);

		break;
	    }
	case TASK_CANVAS_CURSOR_Y:
	    {
		char *label;
		int *cy = (int *)jdata->generic.data;
		double local_pos;
		double wx, wy;
		char cmd[1024];
		double cx1, cy1;

		CanvasToWorld(cs->canvas, 0, *cy, &wx, &wy);
		WorldToCanvas(cs->canvas, wy, 0, &cx1, &cy1);

		label = get_default_string(GetInterp(), gap_defs,
					   "CONTIG_SEL.CURSOR1_Y");

		canvasCursorY(GetInterp(), cs->canvas, cs->frame, label,
			      cs->cursor.colour, cs->cursor.width, *cy, wy,
			      cs->win_list, cs->num_wins);

		sprintf(cmd, "DrawCanvasCursorX1 %s %s %.20f %s %d\n",
			cs->frame, cs->hori, cx1, cs->cursor.colour,
			cs->cursor.width);
		if (TCL_ERROR == Tcl_Eval(GetInterp(), cmd))
		    printf("%s\n", GetInterpResult());

		/* fill in local position of cursor in label box */
		local_pos = CSLocalCursor(io, wy);

		label = get_default_string(GetInterp(), gap_defs,
开发者ID:nathanhaigh,项目名称:staden-trunk,代码行数:67,代码来源:contig_selector.c

示例7: UWerr_f


//.........这里部分代码省略.........
    sprintf(str, "%d", W_max);
    Tcl_AppendResult(interp, "Windowing condition failed up to W = ", str, ".\n", (char *)NULL);
  }
  ret.W = W_opt;

  CFbb_opt = (gFbb[0] + 2*UWerr_sum(gFbb+1, W_opt))/rows;
  for (k = 0; k < i; ++k)
    gFbb[k] += CFbb_opt;
  CFbb_opt = (gFbb[0] + 2*UWerr_sum(gFbb+1, W_opt));

  ret.dvalue = sqrt(CFbb_opt/rows); /* sigmaF */
  
  if (len >= 2) {
    bF = (Fb-Fbb)/(len-1);
    Fbb -= bF;
    if (fabs(bF) > ret.dvalue/4) {
      Tcl_PrintDouble(interp, bF/ret.dvalue, str);
      Tcl_AppendResult(interp, "A ", str, " sigma bias of the mean has been cancelled./n", (char *)NULL);
    }
    for (i = 0; i < len; ++i)
      Fbr[i] -= bF*rows/n_rep[i];
    Fb -= bF*len;
    
    ret.bias = bF/ret.dvalue;
  }

  ret.tau_int = 0;
  for (i = 0; i <= W_opt; ++i)
    ret.tau_int += gFbb[i];
      
  ret.tau_int /= gFbb[0];
  ret.tau_int -= .5;

  ret.value  = Fbb;
  ret.ddvalue = ret.dvalue*sqrt((W_opt + .5)/rows);
  ret.dtau_int = 2 * ret.tau_int * sqrt((W_opt + .5 - ret.tau_int)/rows);

  if (len > 1) {
    for (i = 0; i < len; ++i)
      Fbr[i] = (Fbr[i] - Fb)*(Fbr[i] - Fb)*n_rep[i];
    
    ret.Q_val = UWerr_sum(Fbr, len);
    ret.Q_val /= CFbb_opt;
    ret.Q_val = gammaq((len-1)/2., ret.Q_val/2.);
  }

  if (plot) {
    plotScriptf = fopen("uwerr_plot_script", "w");

    fprintf(plotScriptf, "set ylabel \"Gamma\"; set xlabel \"W\"; set label \"W_opt=%d\" at %d,0 center; plot f(x) = 0, f(x) notitle, 'uwerr_plot_data' using 1:2 title \"normalized autocorrelation\" with lines; show label; pause -1\n", W_opt, W_opt);
    fprintf(plotScriptf, "set ylabel \"tau_int\"; plot f(x) = %.3f, 'uwerr_plot_data' using 1:3 title \"tau_int with statistical errors\" with lines,", ret.tau_int);
    fprintf(plotScriptf, " 'uwerr_plot_data' using 1:3:4 notitle with errorbars, f(x) title \"estimate\"; pause -1\n");

    fclose(plotScriptf);

    plotDataf = fopen("uwerr_plot_data", "w");
    tmp = 0;
    for (i = 0; i < W_max; ++i) {
      tmp += gFbb[i];
      /* print values for x-Axis, Gamma/Gamma[0], tau_int, and its errors */
      fprintf(plotDataf, "%d %.3f %.3f %.3f\n", i, gFbb[i]/gFbb[0],
	      tmp/gFbb[0]-.5, 2*sqrt((i+tmp/gFbb[0])/rows));
    }
    fclose(plotDataf);

    puts("Press Return to continue ...");
    Tcl_Eval(interp, "[exec gnuplot uwerr_plot_script]");
  }

  Tcl_ResetResult(interp);
  Tcl_PrintDouble(interp, ret.value, str);
  Tcl_AppendResult(interp, str, " ", (char *)NULL);
  Tcl_PrintDouble(interp, ret.dvalue, str);
  Tcl_AppendResult(interp, str, " ", (char *)NULL);
  Tcl_PrintDouble(interp, ret.ddvalue, str);
  Tcl_AppendResult(interp, str, " ", (char *)NULL);
  Tcl_PrintDouble(interp, ret.tau_int, str);
  Tcl_AppendResult(interp, str, " ", (char *)NULL);
  Tcl_PrintDouble(interp, ret.dtau_int, str);
  Tcl_AppendResult(interp, str, (char *)NULL);
  if (len > 1) {
    Tcl_PrintDouble(interp, ret.Q_val, str);
    Tcl_AppendResult(interp, " ", str, (char *)NULL);
  }

 err_exit:
  free(abb);
  for (k = 0; k < len; ++k)
    free(abr[k]);
  free(abr);
  free(delpro);
  free(gFbb);
  free(Fbr);
  free(fgrad);
  free(str);
  free(my_argv);
  uwerr_free_tcl_vector(tcl_vector);

  return TCL_OK;
}
开发者ID:andmi,项目名称:espresso,代码行数:101,代码来源:uwerr_tcl.c

示例8: main


//.........这里部分代码省略.........
      draw = 1;
      break;
    case 'i':
      initialize = optarg[0];
      break;
      break;
    case 'n':
      sscanf( optarg, "%d,%d,%d", &(iter[0]), &(iter[1]), &(iter[2]) );
      break;
    case 'o':
      fprintf(stdout,"%d\n",getpid());  fflush(stdout);
      break;
    case 's':
      statistics = 1;
      break;
    case 'v':
      sscanf( optarg, "%d,%d,%d", &(vstep[0]), &(vstep[1]), &(vstep[2]) );
      break;
    case 'w':
      bestangle = atof( optarg ) / 180.0 * M_PI;
      break;
    case 'B':
      frames_begin = atoi( optarg );
      break;
    case 'D':
      maxdist = atof( optarg );
      break;
    case 'E':
      frames_end = atoi( optarg );
      break;
    case 'H':
      height = atof( optarg );
      break;
    case 'N':
      print_frame_count = 1;
      break;
    case 'O':
      count_only = print_frame_count = 1;
      break;
    case 'W':
      sleep_ms = atoi(optarg);
      break;
    case '?':
      fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
      exit(1);
    }
  }

  switch(initialize) {
  case 'r':
    random_positions();
    break;
  case 's':
    initial_positions_planar(1);
    break;
  case 'z':
    zero_out_positions();
    break;
  case 'p':
    initial_positions_planar(0);
    break;
  default:
    break;
  }

  for (i = 1; i <= nvertices; i++) {
    vertices[i].saved_pos.x = vertices[i].pos.x;
    vertices[i].saved_pos.y = vertices[i].pos.y;
    vertices[i].saved_pos.z = vertices[i].pos.z;
  }

  maxstep = iter[0] + iter[1] + iter[2];

#if USE_TCL
  if (draw > 0) {
    init_tk();
    draw_graph(0);
    sprintf(tcl_command_buffer, "stop_go");
    c = Tcl_Eval(interp, tcl_command_buffer);
    if (c != TCL_OK) {
      fprintf(stderr, "in Tcl_Eval: %s\n", interp->result);
      exit(c);
    }
  }
#endif /*USE_TCL*/

  if (position())
    exit(1);

  if (writegraph())
    exit(1);

  if (statistics)
    show_statistics();

#if USE_TCL
  if (draw > 0)
    exit_tk();
#endif /*USE_TCL*/
}
开发者ID:CaGe-graph,项目名称:CaGe,代码行数:101,代码来源:tkspring.c

示例9: Tcl_Eval

int tcl::eval(char *cmd)
{
	return Tcl_Eval(tcl_int, cmd) == TCL_OK;
}
开发者ID:nukleus,项目名称:psotnic-ng,代码行数:4,代码来源:Tcl.cpp

示例10: draw_graph

int
  draw_graph(int step)
{
  int code;
  double display_width, display_height;
  double xscale, yscale;
  double xoff, yoff;

  struct vertex *v, *w;
  struct point t;
  int n, i, j;
  static int angle = 90;
  static int count = 0;
  int steps;
  double s, c;
  double xc, yc, zc;
  double d, dmax, avglen;
  double f1, f2;
  double xmin, xmax, ymin, ymax, zmin, zmax;
  double elevation;

  struct edge *edges;
  int e;

  edges = (struct edge *) malloc( sizeof(struct edge) * nedges );
  if (edges == NULL) {
    fprintf(stderr, "Not enough memory");
    return;
  }

  /* --- determine number of interpolation steps  --- */

  dmax = 0.0;
  avglen = 0.0;

  for (i = 1; i <= nvertices; i++) {
    v = &(vertices[i]);
    d = norm( difference( v->pos, v->saved_pos ) );
    if (d > dmax)
      dmax = d;
    for (j = 0; j < v->valency; j++) {
      if (v->adj[j] > i) {
	w = &(vertices[v->adj[j]]);
	avglen += norm( difference( v->saved_pos, w->saved_pos ) );
      }
    }
  }

  avglen /= nedges;
  steps = (int) ( dmax / maxdist ) + 1;


  /* --- interpolate and display --- */

  if (count_only)
    count += steps;
  else {
    for (n = 1; n <= steps; n++) {
      /* --- initialize Tk stuff --- */

      if (Tk_GetNumMainWindows() <= 0) {
	free(edges);
	return TCL_RETURN;
      }

      sprintf(tcl_command_buffer, "update; set step %d", step);
      code = Tcl_Eval(interp, tcl_command_buffer);
      if (code != TCL_OK) {
	fprintf(stderr, "in Tcl_Eval: %s\n", interp->result);
	free(edges);
	return code;
      }

      if (Tk_GetNumMainWindows() <= 0) {
	free(edges);
	return TCL_RETURN;
      }

      sprintf(tcl_command_buffer, "get_canvas_size");
      code = Tcl_Eval(interp, tcl_command_buffer);
      if (code != TCL_OK) {
	fprintf(stderr, "in Tcl_Eval: %s\n", interp->result);
	free(edges);
	return code;
      }
      sscanf(interp->result, "%lf %lf", &display_width, &display_height);

      xscale = (display_width  / 2.0 - 10.0) / height;
      yscale = (display_height / 2.0 - 10.0) / height;

      if (xscale <= yscale)
	yscale = xscale;
      else
	xscale = yscale;

      yscale *= -1;

      xoff = display_width / 2.0;
      yoff = display_height - 10.0;

//.........这里部分代码省略.........
开发者ID:CaGe-graph,项目名称:CaGe,代码行数:101,代码来源:tkspring.c

示例11: Iaxc_Init

int
Iaxc_Init (Tcl_Interp *interp)
{
	iaxcCmd *cmdPtr;
	Tcl_Obj *codec_val, *codec_name, *evt_val, *evt_name;

	if (Tcl_InitStubs(interp, "8.3", 0) == NULL)
		return TCL_ERROR;

	MUTEXINIT(&head_mutex);
	evt_list = Tcl_NewListObj(0, NULL);

	/* iaxc package commands */
	
	for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) {

		Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, (ClientData) "::",(Tcl_CmdDeleteProc *)NULL);
		Tcl_CreateObjCommand(interp, cmdPtr->name2, cmdPtr->objProc, (ClientData) "::iaxc::",(Tcl_CmdDeleteProc *)NULL);
	}
	
	
	if (Tcl_Eval(interp, "namespace eval ::iaxc namespace export *") == TCL_ERROR)
		return TCL_ERROR;

	/*
	 * set available codecs on ::iaxc namespace
	 */

	codec_val = Tcl_NewIntObj(1 << 1);
	codec_name = Tcl_NewStringObj("::iaxc::IAXC_FORMAT_GSM", -1);
	Tcl_ObjSetVar2(interp, codec_name, NULL, codec_val, 0);
	
	codec_val = Tcl_NewIntObj(1 << 2);
	codec_name = Tcl_NewStringObj("::iaxc::IAXC_FORMAT_ULAW", -1);
	Tcl_ObjSetVar2(interp, codec_name, NULL, codec_val, 0);
	
	codec_val = Tcl_NewIntObj(1 << 3);
	codec_name = Tcl_NewStringObj("::iaxc::IAXC_FORMAT_ALAW", -1);
	Tcl_ObjSetVar2(interp, codec_name, NULL, codec_val, 0);
	
	codec_val = Tcl_NewIntObj(1 << 9);
	codec_name = Tcl_NewStringObj("::iaxc::IAXC_FORMAT_SPEEX", -1);
	Tcl_ObjSetVar2(interp, codec_name, NULL, codec_val, 0);
	
	codec_val = Tcl_NewIntObj(1 << 10);
	codec_name = Tcl_NewStringObj("::iaxc::IAXC_FORMAT_ILBC", -1);
	Tcl_ObjSetVar2(interp, codec_name, NULL, codec_val, 0);

	/*
	 * set available event types
	 */
	
	evt_val = Tcl_NewStringObj("text", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_TEXT", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);
	
	evt_val = Tcl_NewStringObj("levels", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_LEVELS", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);
	
	evt_val = Tcl_NewStringObj("state", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_STATE", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);
	
	evt_val = Tcl_NewStringObj("netstat", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_NETSTAT", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);
	
	evt_val = Tcl_NewStringObj("url", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_URL", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);
	
	evt_val = Tcl_NewStringObj("video", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_VIDEO", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);
	
	evt_val = Tcl_NewStringObj("registration", -1);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_EVENT_REGISTRATION", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);

	/*
	 * available states for a call (contained in an state event)
	 */
	
	evt_val = Tcl_NewIntObj(IAXC_CALL_STATE_FREE);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_CALL_STATE_FREE", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);

	evt_val = Tcl_NewIntObj(IAXC_CALL_STATE_ACTIVE);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_CALL_STATE_ACTIVE", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);

	evt_val = Tcl_NewIntObj(IAXC_CALL_STATE_OUTGOING);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_CALL_STATE_OUTGOING", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);

	evt_val = Tcl_NewIntObj(IAXC_CALL_STATE_RINGING);
	evt_name = Tcl_NewStringObj("::iaxc::IAXC_CALL_STATE_RINGING", -1);
	Tcl_ObjSetVar2(interp, evt_name, NULL, evt_val, 0);

//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:tcliaxc-svn,代码行数:101,代码来源:iaxc.c

示例12: winprint_print_command

/* Implement ide_winprint print_text.  */
static int
winprint_print_command (ClientData cd, Tcl_Interp *interp, int argc,
			     CONST84 char **argv)
{
  struct winprint_data *wd = (struct winprint_data *) cd;
  const char *queryproc;
  const char *textproc;
  struct print_text_options pto;
  PRINTDLG pd;
  int cancelled;
  int top, bottom, left;
  TEXTMETRIC tm;
  POINT pt;
  int lineheight;
  int pageno;
  int error=0, done, needquery;
  struct {
	 short len; /* Defined to be 16 bits.... */
	 char buffer[PRINT_BUFSIZE+1];
  } indata;

  queryproc = argv[2];
  textproc = argv[3];

  if (winprint_print_text_options (wd, interp, argc, argv, &pto) != TCL_OK)
    return TCL_ERROR;

  if (winprint_print_text_dialog (wd, interp, &pto, &pd, &cancelled) != TCL_OK)
    return TCL_ERROR;
  if (cancelled)
    return TCL_OK;

  if (pto.postscript)
  {
	int eps_printing = 33;
	int result;
	short bresult = 1; /* EPS printing download suppressed */
	result = Escape (pd.hDC, eps_printing, sizeof (BOOL), (LPCSTR)&bresult, NULL);
	if ( result < 0 )
	{
		/* The EPSPRINTING escape failed! */
		Tcl_AppendElement(interp,
                   "ide_winprint: EPSPRINTING escape implemented but failed");
		DeleteDC (pd.hDC);
		return TCL_ERROR;
	  }
  }
  else
  {
	winprint_get_margins(wd, &pd, &top, &left, &bottom);
  }

  if (winprint_start (wd, interp, &pd, &pto, &cancelled) != TCL_OK)
    {
      DeleteDC (pd.hDC);
      return TCL_ERROR;
    }
  if (cancelled)
    {
      DeleteDC (pd.hDC);
      return TCL_OK;
    }

  /* init and start init-procedure if available */
  if (pto.initproc != NULL)
  {
    	Tcl_DString initStr;
	char buf[64];
	Tcl_DStringInit (&initStr);
	Tcl_DStringAppend (&initStr, pto.initproc, -1);

	/* Here we must pass the customer selection from the PrintDialog
	 * as parameters for the init command, */
	/* From page */
	Tcl_DStringAppendElement (&initStr, "-frompage");
	sprintf (buf, "%i", pd.nFromPage);
	Tcl_DStringAppendElement (&initStr, buf);
	/* To Page */
	Tcl_DStringAppendElement (&initStr, "-topage");
	sprintf (buf, "%i", pd.nToPage);
	Tcl_DStringAppendElement (&initStr, buf);
	/* # Copies */
	Tcl_DStringAppendElement (&initStr, "-copies");
	sprintf (buf, "%i", pd.nCopies);
	Tcl_DStringAppendElement (&initStr, buf);
	/* Print Selection? */
	Tcl_DStringAppendElement (&initStr, "-selection");
	Tcl_DStringAppendElement (&initStr, (pd.Flags&PD_SELECTION) ? "1" : "0");

	/* Execute tcl/command */
	if (Tcl_Eval (interp, Tcl_DStringValue(&initStr)) != TCL_OK)
	{
	      Tcl_DStringFree (&initStr);
	      return TCL_ERROR;
	}
	Tcl_DStringFree (&initStr);
  }

  if (pto.postscript)
//.........这里部分代码省略.........
开发者ID:monnerat,项目名称:insight,代码行数:101,代码来源:tclwinprint.c

示例13: defined

int TclTextInterp::evalString(const char *s) {
#if defined(VMD_NANOHUB)
  if (Tcl_Eval(interp, s) != TCL_OK) {
#else
  if (Tcl_RecordAndEval(interp, s, 0) != TCL_OK) {
#endif
    // Don't print error message if there's nothing to show.
    if (strlen(Tcl_GetStringResult(interp))) 
      msgErr << Tcl_GetStringResult(interp) << sendmsg;
    return FALSE;
  }
  return TRUE;
}

void TclTextInterp::setString(const char *name, const char *val) {
  if (interp)
    Tcl_SetVar(interp, name, val, 
      TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG);
}

void TclTextInterp::setMap(const char *name, const char *key, 
                           const char *val) { 
  if (interp)
    Tcl_SetVar2(interp, name, key, val, 
      TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG);
    
}

// There's a fair amount of code duplication between doEvent and evalFile,
// maybe these could be combined somehow, say by having TclTextInterp keep 
// track of its Tcl_Channel objects.
// 
// Side note: Reading line-by-line gives different Tcl semantics than 
// just calling Tcl_EvalFile. Shell commands (e.g., stty) are properly
// parsed when read line-by-line and passed to Tcl_RecordAndEval, but are
// unrecognized when contained in a file read by Tcl_EvalFile.  I would 
// consider this a bug.  

int TclTextInterp::evalFile(const char *fname) {
  Tcl_Channel inchannel = Tcl_OpenFileChannel(interp, fname, "r", 0644);
  Tcl_Channel outchannel = Tcl_GetStdChannel(TCL_STDOUT);
  if (inchannel == NULL) {
    msgErr << "Error opening file " << fname << sendmsg;
    msgErr << Tcl_GetStringResult(interp) << sendmsg;
    return 1;
  }

  Tcl_Obj *cmdPtr = Tcl_NewObj();
  Tcl_IncrRefCount(cmdPtr);
  int length = 0;
  while ((length = Tcl_GetsObj(inchannel, cmdPtr)) >= 0) {
    Tcl_AppendToObj(cmdPtr, "\n", 1);
    char *stringrep = Tcl_GetStringFromObj(cmdPtr, NULL);
    if (!Tcl_CommandComplete(stringrep)) {
      continue;
    }

    // check if "exit" was called
    if (app->exitFlag) break;

#if defined(VMD_NANOHUB)
    Tcl_EvalObjEx(interp, cmdPtr, 0);
#else
    Tcl_RecordAndEvalObj(interp, cmdPtr, 0);
#endif

#if TCL_MINOR_VERSION >= 4
    Tcl_DecrRefCount(cmdPtr);
    cmdPtr = Tcl_NewObj();
    Tcl_IncrRefCount(cmdPtr);
#else
    // XXX this crashes Tcl 8.5.[46] with an internal panic
    Tcl_SetObjLength(cmdPtr, 0);
#endif

    // XXX this makes sure the display is updated 
    // after each line read from the file or pipe
    // So, this is also where we'd optimise reading multiple
    // lines at once
    //
    // In VR modes (CAVE, FreeVR, VR Juggler) the draw method will 
    // not be called from app->display_update(), so multiple lines
    // of input could be combined in one frame, if possible
    app->display_update();

    Tcl_Obj *resultPtr = Tcl_GetObjResult(interp);
    char *bytes = Tcl_GetStringFromObj(resultPtr, &length);
#if defined(VMDTKCON)
    if (length > 0) {
      vmdcon_append(VMDCON_ALWAYS, bytes,length);
      vmdcon_append(VMDCON_ALWAYS, "\n", 1);
    }
    vmdcon_purge();
#else
    if (length > 0) {
#if TCL_MINOR_VERSION >= 4
      Tcl_WriteChars(outchannel, bytes, length);
      Tcl_WriteChars(outchannel, "\n", 1);
#else
      Tcl_Write(outchannel, bytes, length);
//.........这里部分代码省略.........
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:101,代码来源:TclTextInterp.C

示例14: update_contig_order

void
update_contig_order(Tcl_Interp *interp,
		    GapIO *io,
		    int cs_id,
		    int *contig_array,
		    int num_contigs,
		    int cx)
{
    GCardinal *order = ArrayBase(GCardinal, io->contig_order);
    obj_cs *cs;
    int i, j;
    double wx, wy;
    int left_position;
    char cmd[1024];
    int orig_pos = 0;
    reg_buffer_start rs;
    reg_buffer_end re;
    reg_order ro;

    cs = result_data(io, cs_id, 0);

    CanvasToWorld(cs->canvas, cx, 0, &wx, &wy);

    /*
     * returns the nth contig to the left of the wx, NOT the contig number.
     * If this is to the left of the first contig, returns 0.
     */
    left_position = find_left_position(io, order, wx);

    for (i = 0; i < NumContigs(io); i++) {
	if (order[i] == contig_array[0]) {
	    orig_pos = i+1;
	    break;
	}
    }

    /* convert index on order to index on contig num */
    for (i = 0; i < num_contigs; i++) {

	for (j = 0; j < NumContigs(io); j++) {
	    if (order[j] == contig_array[i])
		break;
	}
	ReOrder(io, order, j, left_position);

	if (j > left_position) {
	    left_position++;
	    orig_pos++;
	}
    }

    ro.job = REG_ORDER;
    ro.pos = left_position;

#ifdef HACK
    /* HACK is there a better way of representing this - only need to
     * replot once
     */
    contig_notify(io, 1, (reg_data *)&ro);
#endif

    /* Notify of the start of the flurry of updates */
    rs.job = REG_BUFFER_START;
    for (i = 0; i < num_contigs; i++) {
	contig_notify(io, contig_array[i], (reg_data *)&rs);
    }

    ro.job = REG_ORDER;
    ro.pos = left_position;

    for (i = 0; i< num_contigs; i++)
	contig_notify(io, contig_array[i], (reg_data *)&ro);

    /* Notify the end of our updates */
    re.job = REG_BUFFER_END;
    for (i = 0; i < num_contigs; i++) {
	contig_notify(io, contig_array[i], (reg_data *)&re);
    }

    /* draw larger separator tick to show where contig was moved from */
    sprintf(cmd, "HighlightSeparator %s %d", cs->hori, orig_pos);
    Tcl_Eval(interp, cmd);
}
开发者ID:nathanhaigh,项目名称:staden-trunk,代码行数:83,代码来源:contig_selector.c

示例15: vrmldetections_c


//.........这里部分代码省略.........
	fprintf(fp2, "   Coordinate3 { point [\n");
	fprintf(fp2, "    0.000 %5.1f 0.000,\n", ymax);
	fprintf(fp2, "    0.000   0.000 0.000, ] }\n");
	fprintf(fp2, "   IndexedLineSet { coordIndex [ 0, 1, -1 ] } } }\n\n");

	fprintf(fp2, "  DEF group0 Separator { Label { label \"z-axis\" }\n");
	fprintf(fp2, "   Material {\n");
	fprintf(fp2, "    ambientColor 0.25 0.25 0.25\n");
	fprintf(fp2, "    diffuseColor 0.00 0.00 1.00 }\n");
	fprintf(fp2, "   Separator {\n");
	fprintf(fp2, "   Coordinate3 { point  [\n");
	fprintf(fp2, "    0.000 0.000 %5.1f,\n",-Zmin_lay[0]);
	fprintf(fp2, "    0.000 0.000   0.000, ] }\n");
	fprintf(fp2, "   IndexedLineSet { coordIndex [ 0, 1, -1 ] } } }\n\n");
	*/

	fprintf(fp2, "  DEF group0 Separator { Label { label \"object volume\" }\n");
	fprintf(fp2, "   Material {\n");
	fprintf(fp2, "    ambientColor 0.25 0.25 0.25\n");
	fprintf(fp2, "    diffuseColor 0.00 0.00 0.00 }\n");
	fprintf(fp2, "   Separator {\n");
	fprintf(fp2, "   Coordinate3 { point  [\n");
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[0],ymin, Zmin_lay[0]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[0], ymax, Zmin_lay[0]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[1], ymax, Zmin_lay[0]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[1], ymin,Zmin_lay[0]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[0], ymin, Zmax_lay[1]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[0], ymax, Zmax_lay[1]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f,\n", X_lay[1], ymax,Zmax_lay[1]);
	fprintf(fp2, "    %7.3f %7.3f %7.3f, ] }\n", X_lay[1], ymin, Zmax_lay[1]);
	fprintf(fp2, "   IndexedLineSet { coordIndex [ \n");
	fprintf(fp2, "    0, 1, 2, 3, 0, -1,\n");
	fprintf(fp2, "    0, 4, -1,\n");
	fprintf(fp2, "    1, 5, -1,\n");
	fprintf(fp2, "    2, 6, -1,\n");
	fprintf(fp2, "    3, 7, -1,\n");
	fprintf(fp2, "    4, 5, 6, 7, 4, -1 ] } } }\n\n\n");
	fprintf(fp2, "# start trajectories\n\n");

	line1 = NULL;	// added, ad holten 2012

	/* read trackfile from ptv and create vectorfield */
	for (i=seq_first; i<=seq_last ;i++)
	{
		// replaced next lines. ad holten 12-2012
		//	if      (i < 10)  sprintf (val, "res/rt_is.00%1d", i);
		//	else if (i < 100) sprintf (val, "res/rt_is.0%2d",  i);
		//	else              sprintf (val, "res/rt_is.%3d",  i);
		sprintf (val, "res/rt_is.%03d", i);
		printf("Create VRML, read file: %s\n", val);         
		
		fp1 = fopen_rp (val);	// replaced fopen(), ad holten 12-2-2012
		if (!fp1) break;

		color = ((double)(i-seq_first))/((double)(seq_last+1-seq_first));
      
		fscanf (fp1,"%d\n", &anz1);
		line1 = (vector *) calloc (anz1, sizeof (vector));
		for (j=0;j<anz1;j++) {
			fscanf (fp1, "%d %lf %lf %lf %d %d %d %d\n",
				&line1[j].p, &line1[j].x1, &line1[j].y1,
				&line1[j].z1, &dumy, &dumy, &line1[j].type, &dumy);
		}

		fclose (fp1);

	fprintf(fp2, "  DEF group0 Separator { Label { label  \"time step %d\" }\n", i);
	fprintf(fp2, "   Material {\n");
	fprintf(fp2, "    ambientColor 0.25 0.25 0.25\n");
	fprintf(fp2, "    diffuseColor 1 %.4f 0 }\n\n", color);

		for(j=0;j<anz1;j++) {
			fprintf(fp2, "    Separator {\n");
			fprintf(fp2, "     Transform {translation %7.3f %7.3f %7.3f}\n",
				line1[j].x1, line1[j].y1, line1[j].z1);
			fprintf(fp2, "     Cube { width %3.2f height %3.2f depth %3.2f } }\n\n",
				cubes, cubes, cubes );
		}
		fprintf(fp2, "   }\n\n");
		fprintf(fp2, "# end of time step %d\n\n", i);   
		strcpy(val, "");
		free(line1);
		line1 = NULL;
	}  /* end of sequence loop */
	
	if (line1) free(line1);
	fprintf(fp2, "# detections finished\n");

	fclose(fp2); 
	Tcl_Eval(interp, ".text delete 2");
	Tcl_Eval(interp, ".text insert 2 \"Detections written to VRML-File: detections.wrl\"");
	Tcl_Eval(interp, "update idletasks");

	sprintf(val, "...done");
	Tcl_SetVar(interp, "tbuf", val, TCL_GLOBAL_ONLY);
	Tcl_Eval(interp, ".text delete 3");
	Tcl_Eval(interp, ".text insert 3 $tbuf");

	return TCL_OK;
}
开发者ID:OpenPTV,项目名称:C-TclTk,代码行数:101,代码来源:vrml.c


注:本文中的Tcl_Eval函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。