コード例 #1
0
static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
                          GR_DRAWMODE aDraw_mode, LSET aMask,
                          PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt )
{
    // Print pads
    for( D_PAD* pad = aModule->Pads();  pad;  pad = pad->Next() )
    {
        if( !( pad->GetLayerSet() & aMask ).any() )
            continue;

        // Manage hole according to the print drill option
        wxSize drill_tmp = pad->GetDrillSize();

        switch( aDrillShapeOpt )
        {
        case PRINT_PARAMETERS::NO_DRILL_SHAPE:
            pad->SetDrillSize( wxSize(0,0) );
            break;

        case PRINT_PARAMETERS::SMALL_DRILL_SHAPE:
            {
                wxSize sz(  std::min( SMALL_DRILL, pad->GetDrillSize().x ),
                            std::min( SMALL_DRILL, pad->GetDrillSize().y ) );

                pad->SetDrillSize( sz );
            }
            break;

        case PRINT_PARAMETERS::FULL_DRILL_SHAPE:
            // Do nothing
            break;
        }

        pad->Draw( aPanel, aDC, aDraw_mode );
        pad->SetDrillSize( drill_tmp );
    }

    // Print footprint graphic shapes
    LSET mlayer( aModule->GetLayer() );

    if( aModule->GetLayer() == B_Cu )
        mlayer = LSET( B_SilkS );
    else if( aModule->GetLayer() == F_Cu )
        mlayer = LSET( F_SilkS );

    if( ( mlayer & aMask ).any() )
    {
        if( aModule->Reference().IsVisible() )
            aModule->Reference().Draw( aPanel, aDC, aDraw_mode );

        if( aModule->Value().IsVisible() )
            aModule->Value().Draw( aPanel, aDC, aDraw_mode );
    }

    for( EDA_ITEM* item = aModule->GraphicalItems();  item;  item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
            {
                if( !( mlayer & aMask ).any() )
                    break;

                TEXTE_MODULE* textMod = static_cast<TEXTE_MODULE*>( item );
                textMod->Draw( aPanel, aDC, aDraw_mode );
                break;
            }

        case PCB_MODULE_EDGE_T:
            {
                EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );

                if( !aMask[edge->GetLayer()] )
                    break;

                edge->Draw( aPanel, aDC, aDraw_mode );
            }
            break;

        default:
            break;
        }
    }
}
コード例 #2
0
ファイル: mlayertcl.c プロジェクト: reflectometry/reflpak
/* define the gmlayer command */
static int
gmlayer_TclCmd(ClientData data, Tcl_Interp *interp,
	   int argc, CONST char *argv[])
{
  static int fitting;

  CONST char *what;

#if DEBUG
  int i;
  for (i=0; i < argc; i++) { debug_message(argv[i]); debug_message(" ");}
  debug_message("\n");
#endif

  if (argc < 2) {
    Tcl_AppendResult(interp,"gmlayer cmd ?args?",NULL);
    return TCL_ERROR;
  }
  if (argc < 3) what = "";
  else what = argv[2];

  if (strcmp(argv[1], "halt") == 0) {
    abortFit = 1;

  } else if (strcmp(argv[1], "fit") == 0) {
    /* XXX FIXME XXX shouldn't need 'fitting' */
    Constrain = tclconstraints;
    fitting = 1;
    fit_callback = what;
    fitReflec("FRG ");
    fitting = 0;

    sendfit(interp);

  } else if (strcmp(argv[1], "constraints") == 0) {
    if (fit_constraints != NULL) Tcl_Free(fit_constraints);
    if (*what != '\0') {
	fit_constraints = Tcl_Alloc(strlen(what)+1);
	strcpy(fit_constraints, what);
    } else {
	fit_constraints = NULL;
    }

  } else if (strcmp(argv[1], "set") == 0) {
    double *pd; int *pi;
    char result[20];
    if (!parsevar(what,&pi,&pd)) {
      Tcl_AppendResult(interp,"gmlayer variable ",what," is not defined",NULL);
      return TCL_ERROR;
    }
    if (argc > 3) {
      if (pi != NULL && Tcl_GetInt(interp,argv[3],pi) != TCL_OK)
	return TCL_ERROR;
      if (pd != NULL && Tcl_GetDouble(interp,argv[3],pd) != TCL_OK)
	return TCL_ERROR;
    }
    if (pi != NULL) { sprintf(result,"%d",*pi); }
    if (pd != NULL) { sprintf(result,"%.15g",*pd); }
    Tcl_SetResult(interp,result,TCL_VOLATILE);

  } else if (strcmp(argv[1], "send") == 0) {
    if (strcmp(what, "datafile") == 0) {
      Tcl_SetResult(interp,infile,TCL_STATIC);
    } else if (strcmp(what, "parfile") == 0) {
      Tcl_SetResult(interp,parfile,TCL_STATIC);
    } else if (strcmp(what, "constraints") == 0) {
      if (argc > 3) {
         cleanFree((double **)&ConstraintScript);
         if (strlen(argv[3])) {
            ConstraintScript = Tcl_Alloc(strlen(argv[3])+1);
            if (ConstraintScript)
                strcpy(ConstraintScript, argv[3]);
         }
      } else if (ConstraintScript != NULL)
         Tcl_SetResult(interp,ConstraintScript,TCL_VOLATILE);
    } else if (strcmp(what, "mkconstrain") == 0) {
#if 0
      char version[15];
      sprintf(version, "0x%08lx", MAJOR|MINOR);
      Tcl_AppendResult(interp,makeconstrain," \"",constrainScript,
		       "\" \"", constrainModule,"\" ",version,
		       " \"", prototype, "\"", NULL);
#endif
    } else if (strcmp(what, "varying") == 0) {
      genva(listA, mfit, fitlist);
      Tcl_SetResult(interp,fitlist,TCL_STATIC);
    } else if (strcmp(what, "pars") == 0) {
      sendpars(interp);
    } else if (strcmp(what, "data") == 0) {
      senddata(interp);
    } else if (strcmp(what, "refl") == 0) {
      if (fitting)
	sendreflect(interp,xdat,ymod,npnts);
      else if (0) {
	/* Ideally, we would work on a subset of the
	   points until so that the user gets partial
	   feedback while dragging.  These points would
	   lie in the current zoom window.  When the
	   user stops dragging, the complete dataset would
	   be calculated.  This has to happen without
	   making the rest of the interface clunky, either
	   with some sort of abort call or by calculating
	   one section at a time. For now this is too
	   complicated.
	*/
	int refinement;
	if (argc>3) {
	  if (strcmp(argv[3], "max") == 0)
	    refinement = -1;
	  else if (Tcl_GetInt(interp, argv[3], &refinement) != TCL_OK)
	    return TCL_ERROR;
	} else {
	  refinement = -1;
	}
	sendreflect(interp,xtemp,ytemp,npnts);
      } else if (loaded) {
	extend(xdat, npnts, lambda, lamdel, thedel);
	genderiv(xdat, yfit, npnts, 0);
	sendreflect(interp,xdat,yfit,npnts);
      } else {
	/* Send calculated reflectivity to GUI */
	double qstep;
	int j;

	allocCdata(npnts); /* XXX FIXME XXX - not checking alloc failure */
	qstep = (qmax - qmin) / (double) (npnts - 1);
	for (j = 0; j < npnts; j++)
	  xtemp[j] = (double) j * qstep + qmin;

	/* XXX FIXME XXX - not checking for memory allocation failure */
	extend(xtemp, npnts, lambda, lamdel, thedel);
	genderiv(xtemp, yfit, npnts, 0);

	sendreflect(interp,xtemp,yfit,npnts);
      }
    } else if (strcmp(what, "chisq") == 0) {
      char value[40];
      double ret;
      if (fitting) ret = chisq/(double)(npnts-mfit);
      else if (loaded) ret=calcChiSq(npnts,yfit,ydat,srvar)/(double)(npnts-1);
      else ret = -1.0;
      sprintf(value,"%.15g",ret);
      Tcl_AppendResult(interp,value,NULL);
    } else if (strcmp(what, "prof") == 0) {
      if (!fitting)
	genmulti(tqcsq, mqcsq, bqcsq, tqcmsq, mqcmsq, bqcmsq,
		 td, md, bd, trough, mrough, brough, tmu, mmu, bmu,
		 nrough, ntlayer, nmlayer, nblayer, nrepeat, proftyp);
      sendprofile(interp,argc>3);
    } else {
      Tcl_AppendResult(interp,"gmlayer send ?: expected pars, work, ...",NULL);
      return TCL_ERROR;
    }

  } else if (strcmp(argv[1],"msg") == 0) {
    printf("%s\n",what);
  } else if (strcmp(argv[1],"gd") == 0) {
    if (*infile) {
      loadData(infile);
      loaded = !failure;
    }
  } else {
    queue = argv+1;
    queued = argc-1;
    failure = 0;
    abortFit = 0;
    mlayer();
    if (failure) {
      Tcl_AppendResult(interp,error_message,TCL_STATIC);
      return TCL_ERROR;
    }
  }
  return TCL_OK;
}