Exemple #1
0
void Block::draw(Level& level) {
    // récupération de la texture correspondant au type de bloc
    std::string texture_name = "block.tga";

    if (getMass() > 0) {
        texture_name = "movable_" + texture_name;
    }

    if (isSelected()) {
        texture_name = "selected_" + texture_name;
    }

    sprite.setTexture(*ResourceManager::get().getTexture(
        "objects/" + texture_name
    ));

    // coloration du bloc selon sa charge
    if (getCharge() > 0) {
        sprite.setColor(sf::Color(180, 180, 255));
    } else if (getCharge() < 0) {
        sprite.setColor(sf::Color(255, 180, 180));
    } else {
        sprite.setColor(sf::Color::White);
    }

    sprite.setPosition(getPosition());
    level.getManager().getWindow().draw(sprite);
}
Exemple #2
0
void HoldSkill::tick()
{
	if (isEnabled())
	{
		setCharge(getCharge() - getReduction());
	}
	else
	{
		setCharge(getCharge() + getRecharge());
	}
}
Exemple #3
0
/********************
 * write_mc_parts
 *******************/
int write_mc_parts(FILE *fp, mc_evt_t *mc_evt){
  int i;
  
  
  /* 
   * write header info 
   */
  fprintf(fp,"%d  %d\n", mc_evt->runNo, mc_evt->eventNo);
  
  /* 
   * now loop over the particle in the event 
   */
  for(i=0;i<mc_evt->nparts;i++){
    fprintf(fp,"%d %d %lf \n",(i+1), 
	    gampID(mc_evt->part[i].pid), mc_evt->part[i].mass);
    fprintf(fp,"   %d %lf %lf %lf %lf\n",
	    getCharge( mc_evt->part[i].pid),
	    /* mc_evt->part[i].pid/abs(mc_evt->part[i].pid),*/
	    mc_evt->part[i].p.space.x,
	    mc_evt->part[i].p.space.y,
	    mc_evt->part[i].p.space.z,
	    mc_evt->part[i].p.t);
  }
  return 1;
}
Exemple #4
0
CRectangle::CRectangle(CVector b, CVector e)
{

	ptbvir.push_back(b);
	ptevir.push_back(e);
	cancharge=true;
	getCharge();

}
/******************************************************************//**
 * Initializing protein class
 ******************************************************************/
CProtein::CProtein(const char *fname) {
	vector<AA> aas;
	string ss = fname;

	if (ss.find("pdb") != std::string::npos) {
		CPDB::loadFromPDB(fname, aas);
	} else if (ss.find("pqr") != std::string::npos) {
		CPDB::loadFromPQR(fname, aas);
	}

	// Add each atom in each amino acid of protein to matrix of atoms
	for (int i = 0; i < aas.size(); i++)
		for (int j = 0; j < aas[i].getNumAtoms(); j++)
			m_atoms.push_back(aas[i][j]);

	// Add charge on atom in each amino acid to vector of charges
	for (int i = 0; i < m_atoms.size(); i++) {
		if (m_atoms[i].getCharge() != 0.0)
			m_chargedAtoms.push_back(&(m_atoms[i]));
	}

	m_center = computeCenter(); // compute center of geometry if the atom
	// reposition each atom WRT to the center of mass of protein
	for (int i = 0; i < m_atoms.size(); i++)
		m_atoms[i].setPos(m_atoms[i].getPos() - m_center);

	computeRadius();

	m_sumCharge = 0.0; // Total charge of protein
	for (int i = 0; i < getNumCharges(); i++) m_sumCharge += getCharge(i);

	REAL s = 0.0; // Total charge of protein to print as output
	for (int i = 0; i < getNumCharges(); i++) s += (getCharge(i));
	cout << "sum = " << s << " rad = " << m_rad << endl;

	// Creating a multipole expansion class for the protein
	m_mpe = new CMPE(*this);

	m_exps.push_back(m_mpe); // Pushing the MPE to an array
	// Adding the protein center to an array of centers
	m_cens.push_back(&m_center);
	m_mols.push_back(this); // Adding the protein to an array of proteins
}
Exemple #6
0
void SMSClient::charge(bool bCharge, unsigned capacity)
{
    bool bChange = false;
    if (bCharge != getCharging()){
        bChange = true;
        setCharging(bCharge);
    }
    if (capacity != getCharge()){
        bChange = true;
        setCharge(capacity);
    }
    if (bChange){
        Event e(EventClientChanged, this);
        e.process();
    }
}
Exemple #7
0
/********************
 * write_gamp_parts
 *******************/
int write_gamp_parts(FILE *fp, mc_evt_t *mc_evt, int photon_beam){
  int i;
  /*
   * Write the number of particles (including the beam)
   */
  fprintf(fp,"%d \n", mc_evt->nparts+1);
  /*
   * Write particle info (id charge p.x p.y p.z p.t)
   */
  /* kludged beam */
  fprintf(fp,"1 0 0 0 %d %d \n", photon_beam,photon_beam);
  /* now write out nparts */
  for(i=0;i<mc_evt->nparts;i++){ 
    fprintf(fp,"%d %d %lf %lf %lf %lf \n",
	    gampID(mc_evt->part[i].pid),getCharge( mc_evt->part[i].pid),
	    mc_evt->part[i].p.space.x,
	    mc_evt->part[i].p.space.y,
	    mc_evt->part[i].p.space.z,
	    mc_evt->part[i].p.t);
  }
}
int main(void){
	Charge chNull = NULL;
	ChargeArray chANull = NULL;
	Charge chrv;
	ChargeArray chArv; 
	int rv; 
	int len = 5; 
	int val = -999; 
	int spot = 3; //spot in array where testing functions
	double drv; 
	//valid:
	//Charge ch
	//ChargeArray chA

	printf("Testing: newCharge\n");
	Charge ch = newCharge();
	assert(ch !=NULL);  
	
	printf("Testing: newChargeA\n");
	ChargeArray chA = newChargeA(len);
	assert(chA !=NULL);  
	chArv = newChargeA(val);
	assert(chArv ==NULL);  

	printf("Testing: setDwel\n");
	rv= setDwel(chNull, 15.75);
	assert(rv==-1);
	rv= setDwel(ch, val);
	assert(rv==-1);
	rv= setDwel(ch, 15.75);
	assert(rv==0);
	
	printf("Testing: MinusDwel\n");
	rv= MinusDwel(chNull, 1.05);
	assert(rv==-1);
	rv= MinusDwel(ch, val);
	assert(rv==-1);
	rv= MinusDwel(ch, 14.25);
	assert(rv==0);
	
	printf("Testing: getDwel\n");
	drv= getDwel(chNull);
	assert(drv==-1);
	drv= getDwel(ch);
	printf("%f\n", drv);
	assert(drv==1.5);

	printf("Testing: printCharge, Expecting: dwelltime = 1.5 \n");
	rv= printCharge(chNull);
	assert(rv==-1); 
	rv= printCharge(ch);
	assert(rv==0); 

	printf("Testing: sett\n"); 
	rv= sett(chNull, 2.451);
	assert(rv==-1);
	rv= sett(ch, val);
	assert(rv==-1);
	rv= sett(ch, 2.451);
	assert(rv==0);
	printf("Testing: Plust\n"); 
	rv= Plust(chNull, 3.5);
	assert(rv==-1);
	rv= Plust(ch, val);
	assert(rv==-1);
	rv= Plust(ch, 3.5);
	assert(rv==0);
	printf("Testing: gett\n");
	drv= gett(chNull);
	assert(drv==-1);
	drv= gett(ch);
	printf("%f\n", drv);
	assert(drv==(2.451+3.5)); 

	printf("Testing: getCharge\n");
	chrv= getCharge(chANull, 4);
	assert(chrv==NULL); 
	chrv= getCharge(chA, -val); // i > len
	assert(chrv==NULL); 
	chrv= getCharge(chA, val);
	assert(chrv==NULL); 
	chrv= getCharge(chA, 4);
	assert(chrv!=NULL); 	

	printf("Testing: setCx\n"); 
	rv= setCx(chNull, 6);
	assert(rv==-1);
	rv= setCx(getCharge(chA, spot), val);
	assert(rv==0);
	rv= setCx(getCharge(chA, spot), 6);
	assert(rv==0);
	printf("Testing: CxPlus\n"); //x=8
	rv= CxPlus(chNull);
	assert(rv==-1);
	rv= CxPlus(getCharge(chA, spot));
	rv= CxPlus(getCharge(chA, spot)); //done twice
	assert(rv==0);
	printf("Testing: CxMinus\n"); //x=7 //tot_x = 7
	rv= CxMinus(chNull);
	assert(rv==-1);
	rv= CxMinus(getCharge(chA, spot)); //done once
	assert(rv==0);
	printf("Testing: CxPlusPeriodic\n"); //x=0  //tot_x = 8
	rv= CxPlusPeriodic(chNull, 2);
	assert(rv==-1);
	rv= CxPlusPeriodic(getCharge(chA, spot), val);
	assert(rv==-1);
	rv= CxPlusPeriodic(getCharge(chA, spot), 2); //add once
	assert(rv==0);
	printf("Testing: CxMinusPeriodic\n"); //x=4 //tot_x = 7
	rv= CxMinusPeriodic(chNull, 5);
	assert(rv==-1);
	rv= CxMinusPeriodic(getCharge(chA, spot), val);
	assert(rv==-1);
	rv= CxMinusPeriodic(getCharge(chA, spot), 5);
	assert(rv==0);
	printf("Testing: getCx\n");
	rv= getCx(chNull);
	assert(rv==-1);
	rv= getCx(getCharge(chA, spot));
	assert(rv==4);
	printf("Testing: getXdist\n");
	rv= getXdist(chNull);
	assert(rv==-1);
	rv= getXdist(getCharge(chA, spot));
	assert(rv==7);
	printf("Testing: printChargeA, Expecting: ch[3]->x = 4\n");
	rv= printChargeA(chANull);
	assert(rv==-1);
	rv= printChargeA(chA);
	assert(rv==0);

	printf("Testing: setCy\n"); 
	rv= setCy(chNull,8);
	assert(rv==-1);
	rv= setCy(ch, val);
	assert(rv==0);
	rv= setCy(ch, 8);
	assert(rv==0);
	printf("Testing: CyPlus\n"); //y=9 (after function successfully called)
	rv= CyPlus(chNull);
	assert(rv==-1);
	rv= CyPlus(ch);
	assert(rv==0); 
	printf("Testing: CyMinus\n");//y=7
	rv= CyMinus(chNull);
	assert(rv==-1);
	rv= CyMinus(ch);
	rv= CyMinus(ch); //subtract twice
	assert(rv==0); 
	printf("Testing: CyPlusPeriodic\n"); //y=0 
	rv= CyPlusPeriodic(chNull, 2);
	assert(rv==-1);
	rv= CyPlusPeriodic(ch, val);
	assert(rv==-1);
	rv= CyPlusPeriodic(ch, 2); //add once
	assert(rv==0);
	printf("Testing: CyMinusPeriodic\n"); //y=4
	rv= CyMinusPeriodic(chNull, 5);
	assert(rv==-1);
	rv= CyMinusPeriodic(ch, val);
	assert(rv==-1);
	rv= CyMinusPeriodic(ch, 5);
	assert(rv==0);
	printf("Testing: getCy\n");
	rv= getCy(chNull);
	assert(rv==-1);
	rv= getCy(ch);
	assert(rv==4);
	printf("Testing: setCz\n"); 
	rv= setCz(chNull,16);
	assert(rv==-1);
	rv= setCz(ch, val);
	assert(rv==0);
	rv= setCz(ch, 16);
	assert(rv==0);
	printf("Testing: CzPlus\n"); //z=18
	rv= CzPlus(chNull);
	assert(rv==-1);
	rv= CzPlus(ch);	
	rv= CzPlus(ch); //add twice
	assert(rv==0);
	printf("Testing: CzMinus\n"); //z=17
	rv= CzMinus(chNull);
	assert(rv==-1);
	rv= CzMinus(ch);
	assert(rv==0);
	printf("Testing: CzPlusPeriodic\n"); //z=0
	rv= CzPlusPeriodic(chNull, 5);
	assert(rv==-1);
	rv= CzPlusPeriodic(ch, val);
	assert(rv==-1);
	rv= CzPlusPeriodic(ch, 6);
	assert(rv==0);
	printf("Testing: CzMinusPeriodic\n"); // z=12
	rv= CzMinusPeriodic(chNull, 13);
	assert(rv==-1); 
	rv= CzMinusPeriodic(ch, val);
	assert(rv==-1); 
	rv= CzMinusPeriodic(ch, 13);
	assert(rv==0);
	printf("Testing: getCz\n");
	rv= getCz(chNull);
	assert(rv==-1);
	rv= getCz(ch);
	assert(rv==12);
  
   printf("Testing: deleteCharge\n");
	rv= deleteCharge(chNull);
	assert(rv==-1); 
	rv= deleteCharge(ch);
	assert(rv==0); 
	printf("Testing: deleteChargeA\n");
	rv= deleteChargeA(chANull);
	assert(rv==-1); 
	rv= deleteChargeA(chA);
	assert(rv==0);

  
  printf("Testing: initChargePath\n");
  Charge ch2 = newCharge();
  assert(ch2!=NULL);
  fprintf(stderr,"Should print ERROR message: ");
  rv = initChargePath(NULL, 3);
  assert(rv==-1);
  fprintf(stderr,"Should print ERROR message: ");
  rv = initChargePath(&ch2,1);
  assert(rv==-1);
  fprintf(stderr,"initializing same charge again with 2 nodes\n");
  rv = initChargePath(&ch2,2);
  assert(rv==0);
  printCharge(ch2);
  fprintf(stderr,"Should print ERROR message: ");
  rv = initChargePath(&ch2,2);
  assert(rv==-1);
  fprintf(stderr,"Deleting ch2\n");
  rv= deleteCharge(ch2);

  printf("Testing: initChargeArrayPath\n");
  ChargeArray cha2 = newChargeA(3);
  fprintf(stderr,"Should print ERROR message: ");
  rv = initChargeArrayPath(NULL, 2);
  assert(rv==-1);
  fprintf(stderr,"Should print ERROR message: ");
  rv = initChargeArrayPath(cha2,1);
  assert(rv==-1);
  rv = initChargeArrayPath(cha2,2);
  assert(rv==0);
  Charge ch3 = getCharge(cha2,2);
  assert(ch3!=NULL);
  rv= deleteChargeA(cha2);
  assert(rv==0);

	printf("Mission Completed\n");
	return 0;
}
Exemple #9
0
/********************
 * write_mc_parts
 *******************/
int write_mc_parts(FILE *fp, mc_evt_t *mc_evt){
  int i,ret;
  static itape_header_t *buffer=NULL;
  esr_nparticle_t *esr;
  int group=802; /* esrGroup*/
  int nparticles;
  esr_particle_t esrp[MAX_ESR_PARTS];
  
  if(!buffer){
    buffer=(itape_header_t *)malloc(BUFSIZE);
    data_newItape(buffer);
  }
  /* 
   * write header info 
   */
  buffer->runNo=mc_evt->runNo;
  buffer->eventNo= mc_evt->eventNo;
  buffer->spillNo= 0;
  buffer->trigger= 1;
  if(Debug)
      fprintf(fp,"%d  %d\n", mc_evt->runNo, mc_evt->eventNo);
  
  esr=data_addGroup(buffer,BUFSIZE,802,sizeof(esr_nparticle_t)+
		     (mc_evt->nparts)*sizeof(esr_particle_t));
  esr->nparticles = mc_evt->nparts;
  /* 
   * now loop over the particle in the event and fill the esr
   */
  /*
   * Kludged Beam */
  esr->beam.space.x=0;
  esr->beam.space.y=0;
  esr->beam.space.z=KludgedBeam;
  esr->beam.t = KludgedBeam;

  for(i=0;i<mc_evt->nparts;i++){
    esr->p[i].particleType =mc_evt->part[i].pid;
    esr->p[i].charge = getCharge( mc_evt->part[i].pid);
    esr->p[i].p.space.x=mc_evt->part[i].p.space.x;/* float = double */
    esr->p[i].p.space.y=mc_evt->part[i].p.space.y;
    esr->p[i].p.space.z=mc_evt->part[i].p.space.z;
    esr->p[i].p.t=mc_evt->part[i].p.t;

    if(Debug)
      fprintf(fp,"%d %d %lf \n",(i+1), 
	      mc_evt->part[i].pid, mc_evt->part[i].mass);
    if(Debug)
      fprintf(fp,"   %d %lf %lf %lf %lf\n",
	       getCharge( mc_evt->part[i].pid),
	      /*mc_evt->part[i].pid/abs(mc_evt->part[i].pid),*/
	      mc_evt->part[i].p.space.x,
	      mc_evt->part[i].p.space.y,
	      mc_evt->part[i].p.space.z,
	      mc_evt->part[i].p.t);
  }
  data_saveGroups(buffer,1,&group);
  data_clean(buffer);
  data_write(fileno(fp),buffer);

  return 1;
}
Exemple #10
0
void Screen::printCharge() {
    getCharge(charge_);
    lcdPrintCharge(charge_, 8);
    lcdPrintChar(' ');
}