Example #1
0
void Clock::displayColor(bool onOff)
{
     Digit hour1(x, y), hour2(x, y+10), min1(x, y+25), min2(x, y+35), sec1(x, y+50), sec2(x, y+60);
     hour1.changeColor(true); 
     hour2.changeColor(true); 
     min1.changeColor(true); 
     min2.changeColor(true); 
     sec1.changeColor(true); 
     sec2.changeColor(true); 
     if(onOff)
     {
          clearDisplay();
          hour1.display(hr/10, true); 
          hour2.display(hr%10, true);
          min1.display(min/10, true);
          min2.display(min%10, true); 
          sec1.display(sec/10, isSec);
          sec2.display(sec%10, isSec);

          if(isPM)
          {
             attron(COLOR_PAIR(BLACKONYELLOW));
             mvprintw(x+6, y-5, "PM");
             attroff(COLOR_PAIR(BLACKONYELLOW));
          }
          else
          {
             attron(COLOR_PAIR(WHITEONBLACK));
             mvprintw(x+6, y-5, "  ");
          }
          refresh();
     }
     else
         clearDisplay();   
}
Example #2
0
static float distance_to_system(const SystemPath *dest)
{
	SystemPath here = Pi::currentSystem->GetPath();
	
	Sector sec1(here.sectorX, here.sectorY, here.sectorZ);
	Sector sec2(dest->sectorX, dest->sectorY, dest->sectorZ);

	return Sector::DistanceBetween(&sec1, here.systemIndex, &sec2, dest->systemIndex);
}
Example #3
0
static float distance_to_system(const SystemPath &dest)
{
	SystemPath here = Pi::game->GetSpace()->GetStarSystem()->GetPath();
	assert(here.HasValidSystem());
	assert(dest.HasValidSystem());

	Sector sec1(here.sectorX, here.sectorY, here.sectorZ);
	Sector sec2(dest.sectorX, dest.sectorY, dest.sectorZ);

	return Sector::DistanceBetween(&sec1, here.systemIndex, &sec2, dest.systemIndex);
}
Example #4
0
void Clock::clearDisplay()
{
     Digit hour1(x, y), hour2(x, y+10), min1(x, y+25), min2(x, y+35), sec1(x, y+50), sec2(x, y+60);
     hour1.display(8, false); 
     hour2.display(8, false);
     min1.display(8, false);
     min2.display(8, false); 
     sec1.display(8, false);
     sec2.display(8, false);
     attron(COLOR_PAIR(WHITEONBLACK));
     mvprintw(x+6, y-5, "  ");            //erase PM indicator   
     refresh();
}
Example #5
0
/*
 * Method: DistanceTo
 *
 * Calculate the distance between this and another system
 *
 * > dist = path:DistanceTo(system)
 *
 * Parameters:
 *
 *   system - a <SystemPath> or <StarSystem> to calculate the distance to
 *
 * Return:
 *
 *   dist - the distance, in light years
 *
 * Availability:
 *
 *   alpha 10
 *
 * Status:
 *
 *   stable
 */
static int l_sbodypath_distance_to(lua_State *l)
{
	LUA_DEBUG_START(l);

	const SystemPath *loc1 = LuaObject<SystemPath>::CheckFromLua(1);

	const SystemPath *loc2 = LuaObject<SystemPath>::GetFromLua(2);
	if (!loc2) {
		StarSystem *s2 = LuaObject<StarSystem>::CheckFromLua(2);
		loc2 = &(s2->GetPath());
	}

	Sector sec1(loc1->sectorX, loc1->sectorY, loc1->sectorZ);
	Sector sec2(loc2->sectorX, loc2->sectorY, loc2->sectorZ);

	double dist = Sector::DistanceBetween(&sec1, loc1->systemIndex, &sec2, loc2->systemIndex);

	lua_pushnumber(l, dist);

	LUA_DEBUG_END(l, 1);
	return 1;
}
void plot_pad_size_in_layer(TString digiPar="trd.v13/trd_v13g.digi.par", Int_t nlines=1, Int_t nrows_in_sec=0, Int_t alllayers=1) 
{

  gStyle->SetPalette(1,0);
  gROOT->SetStyle("Plain");
  gStyle->SetPadTickX(1);                        
  gStyle->SetPadTickY(1); 
  gStyle->SetOptStat(kFALSE);
  gStyle->SetOptTitle(kFALSE);

  Bool_t read = false;
  TH2I *fLayerDummy = new TH2I("LayerDummy","",1200,-600,600,1000,-500,500);
  fLayerDummy->SetXTitle("x-coordinate [cm]");
  fLayerDummy->SetYTitle("y-coordinate [cm]");
  fLayerDummy->GetXaxis()->SetLabelSize(0.02);
  fLayerDummy->GetYaxis()->SetLabelSize(0.02);
  fLayerDummy->GetZaxis()->SetLabelSize(0.02);
  fLayerDummy->GetXaxis()->SetTitleSize(0.02);
  fLayerDummy->GetXaxis()->SetTitleOffset(1.5);
  fLayerDummy->GetYaxis()->SetTitleSize(0.02);
  fLayerDummy->GetYaxis()->SetTitleOffset(2);
  fLayerDummy->GetZaxis()->SetTitleSize(0.02);
  fLayerDummy->GetZaxis()->SetTitleOffset(-2);

  TString title;
  TString title1, title2, title3;
  TString buffer;
  TString firstModule = "";
  Int_t blockCounter(0), startCounter(0); // , stopCounter(0);
  Double_t msX(0), msY(0), mpX(0), mpY(0), mpZ(0), psX(0), psY(0);
  Double_t ps1X(0), ps1Y(0), ps2X(0), ps2Y(0), ps3X(0), ps3Y(0);
  Int_t modId(0), layerId(0);
  Double_t sec1(0), sec2(0), sec3(0);
  Double_t row1(0), row2(0), row3(0);
  std::map<float, TCanvas*> layerView;// map key is z-position of modules
  std::map<float, TCanvas*>::iterator it;
  ifstream digipar;

  digipar.open(digiPar.Data(), ifstream::in);
  while (digipar.good()) {
    digipar >> buffer;
    //cout << "(" << blockCounter << ")    " << buffer << endl;
    if (blockCounter == 19)
      firstModule = buffer;
    if (buffer == (firstModule + ":")){
      //cout << buffer << " <===========================================" << endl;
      read = true;
    }
    if (read) {
      startCounter++;
      if (startCounter == 1)   // position of module position in x
      {
	modId = buffer.Atoi();
        layerId = (modId & (15 << 4)) >> 4;  // from CbmTrdAddress.h
      }

      if (startCounter == 5)   // position of module position in x
	mpX = buffer.Atof();
      if (startCounter == 6)   // position of module position in y
	mpY = buffer.Atof();
      if (startCounter == 7)   // position of module position in z
	mpZ = buffer.Atof();
      if (startCounter == 8)   // position of module size in x
	msX = buffer.Atof();
      if (startCounter == 9)   // position of module size in y
	msY = buffer.Atof();

      if (startCounter == 12)   // sector 1 size in y
	sec1 = buffer.Atof();
      if (startCounter == 13)   // position of pad size in x - do not take the backslash (@14)
	ps1X = buffer.Atof();
      if (startCounter == 15)   // position of pad size in y
	ps1Y = buffer.Atof();

      if (startCounter == 17)   // sector 2 size in y
	sec2 = buffer.Atof();
      if (startCounter == 18)   // position of pad size in x
      {
	ps2X = buffer.Atof();
        psX = ps2X;   // for backwards compatibility - sector 2 is default sector
      }
      if (startCounter == 19)   // position of pad size in y
      {
	ps2Y = buffer.Atof();
        psY = ps2Y;   // for backwards compatibility - sector 2 is default sector
      }

      if (startCounter == 21)   // sector 3 size in y
	sec3 = buffer.Atof();
      if (startCounter == 22)   // position of pad size in x
	ps3X = buffer.Atof();
      if (startCounter == 23)   // position of pad size in y
	ps3Y = buffer.Atof();

//      if (startCounter == 23)   // last element
//      {
//        printf("moduleId         : %d, %d\n", modId, layerId);
//        printf("pad size sector 1: (%.2f cm, %.2f cm) pad area: %.2f cm2\n", ps1X, ps1Y, ps1X*ps1Y);
//        printf("pad size sector 2: (%.2f cm, %.2f cm) pad area: %.2f cm2\n", ps2X, ps2Y, ps2X*ps2Y);
//        printf("pad size sector 3: (%.2f cm, %.2f cm) pad area: %.2f cm2\n", ps3X, ps3Y, ps3X*ps3Y);
//        printf("rows per sector  : %.1f %.1f %.1f\n", sec1/ps1Y, sec2/ps2Y, sec3/ps3Y);
//        printf("\n");
//      }

      //printf("module position: (%.1f, %.1f, %.1f) module size: (%.1f, %.1f) pad size: (%.2f, %.2f) pad area: %.2f\n",mpX,mpY,mpZ,2*msX,2*msY,psX,psY,psX*psY);

      if (startCounter == 23) { // if last element is reached
	startCounter = 0; // reset

        if ( alllayers == 0 )   
          if ( !((layerId == 0) || (layerId == 4) || (layerId == 8)) )   // plot only 1 layer per station
            continue;

        row1 = sec1 / ps1Y;
        row2 = sec2 / ps2Y;
        row3 = sec3 / ps3Y;

	it = layerView.find(mpZ);
	if (it == layerView.end()){	
	  //	  title.Form("pad_size_layer_at_z_%.2fm",mpZ);  
	  title.Form("%02d_pad_size_layer%02d", layerId, layerId);  
	  layerView[mpZ] = new TCanvas(title,title,1200,1000);
	  fLayerDummy->DrawCopy("");

        // now print cm2 in the center
	layerView[mpZ]->cd();
	title.Form("cm^{2}");  // print cm2
	TPaveText *text = new TPaveText(0 - 28.5,
					0 - 28.5,
					0 + 28.5,
					0 + 28.5
					);
	text->SetFillStyle(1001);
	text->SetLineColor(1);
        text->SetFillColor(kWhite);
	text->AddText(title);
	text->Draw("same");
	}

        // print pad size in each module
	layerView[mpZ]->cd();
	//	title.Form("%2.0fcm^{2}",psX*psY);  // print pad size
	//	title.Form("%.0f",psX*psY);  // print pad size - 1 digit
	TPaveText *text = new TPaveText(mpX - msX,
					mpY - msY,
					mpX + msX,
					mpY + msY
					);
	text->SetFillStyle(1001);
	text->SetLineColor(1);
	//        text->SetFillColor(kViolet);

	// vary background color
//        if ((int)(psX*psY+.5) == 2)
//        {
//          text->SetFillColor(kOrange + 9);
//        } 
//        else 
        if (psX*psY <= 1.1)
        {
          text->SetFillColor(kOrange + 10);
        }
        else if (psX*psY <= 2.1)
        {
          text->SetFillColor(kOrange -  3);
        }
        else if (psX*psY <= 3.1)
        {
          text->SetFillColor(kOrange -  4);
        }
        else if (psX*psY <= 5)
        {
          text->SetFillColor(kOrange + 10 - ((int)(psX*psY+.5)-1) * 2);
//        printf("%2.1f: %d\n", psX*psY, 10 - ((int)(psX*psY+.5)-1) * 2);
        } 
        else if (psX*psY <= 10)
	{
          text->SetFillColor(kSpring + 10 - ((int)(psX*psY+.5)-4) * 2);
//        printf("%2.1f: %d\n", psX*psY, 10 - ((int)(psX*psY+.5)-4) * 2);
        } 
        else if (psX*psY > 10)
	{
          text->SetFillColor(kGreen);
//        printf("%2.1f: %s\n", psX*psY, "green");
        } 

        if (nrows_in_sec == 1)   // print number of rows in sector
	{
   	  title1.Form("%3.1f - %2.0f", ps1X*ps1Y, row1);  // print pad size and nrows - 2 digits - sector 1
	  title2.Form("%3.1f - %2.0f", ps2X*ps2Y, row2);  // print pad size and nrows - 2 digits - sector 2
	  title3.Form("%3.1f - %2.0f", ps3X*ps3Y, row3);  // print pad size and nrows - 2 digits - sector 3
	}
        else
	{
   	  title1.Form("%3.1f",ps1X*ps1Y);  // print pad size - 2 digits - sector 1
	  title2.Form("%3.1f",ps2X*ps2Y);  // print pad size - 2 digits - sector 2
	  title3.Form("%3.1f",ps3X*ps3Y);  // print pad size - 2 digits - sector 3
	}

        if (nlines==1)   // plot pad size for central sector only
	{
	  text->AddText(title2);
        }
        else   // plot pad size for all 3 sectors
	{
	  text->AddText(title1);
	  text->AddText(title2);
	  text->AddText(title3);
        }
	text->Draw("same");
	//layerView[mpZ]->Update();
      }
    }  
    blockCounter++;
  }