Beispiel #1
0
void scatter_PlotUnif (unif01_Gen *gen, char *Nin)
{
   unif01_Gen *genL;
   genL = scatter_ReadData (gen, Nin);
   chro = chrono_Create ();
   Plot (genL, Nin, precision);
   chrono_Delete (chro);
}
Beispiel #2
0
void scatter_PlotUnifInterac (unif01_Gen *gen)
{
   unif01_Gen *genL;
   genL = scatter_ReadDataInterac (gen);
   chro = chrono_Create ();
   Plot (genL, Nin, precision);
   chrono_Delete (chro);
}
Beispiel #3
0
void FreqWindow::OnGridOnOff(wxCommandEvent & WXUNUSED(event))
{
   if( mGridOnOff->IsChecked() )
      mDrawGrid = true;
   else
      mDrawGrid = false;
   Plot();
}
Beispiel #4
0
void FreqWindow::OnReplot(wxCommandEvent & WXUNUSED(event))
{
   gPrefs->Read(wxT("/GUI/EnvdBRange"), &dBRange, ENV_DB_RANGE);
   if(dBRange < 90.)
      dBRange = 90.;
   GetAudio();
   Plot();
}
Beispiel #5
0
void plot(unsigned char *vals, int numvals, char *title) {
	int *hist = (int *) calloc(256, sizeof(int));
	int i;
	
	for(i = 0; i < numvals; i++)
		hist[vals[i]]++;
		
	Plot(hist, 256, title);
}
void ribi::QtToolTestApproximatorXyMainDialog::on_button_clicked() noexcept
{
  const int x = ui->box_int_x->value();
  const double y = ui->box_double_y->value();
  assert(m_approximator.CanAdd(x,y)
    && "Can only click the button when the pair can be added");

  m_approximator.Add(x,y);
  Plot();
}
Beispiel #7
0
void TGStatVec::PlotAllVsX(const TGStatVal& XVal, const TStr& OutFNm, TStr Desc, const TGpScaleTy& Scale, const bool& PowerFit) const {
  const TFSet SkipStat = TFSet() | gsvFullDiamDev | gsvEffDiamDev | gsvEffWccDiamDev | gsvFullWccDiamDev;
  for (int stat = gsvNone; stat < gsvMx; stat++) {
    const TGStatVal Stat = TGStatVal(stat);
    if (SkipStat.In(Stat)) { continue; }
    if (Last()->HasVal(Stat) && Last()->HasVal(XVal) && Stat!=XVal) {
      Plot(XVal, Stat, OutFNm, Desc, Scale, PowerFit);
    }
  }
}
Beispiel #8
0
void Robot::tourner(char dir) {
	try{
		etat = etat->tourner();
		direction = dir;
		plot = Plot(0);
		notify();
	}
	catch(RobotExceptions::Tourner_Exception& e){
		cerr << "Impossible de tourner" << endl;
	}
}
Beispiel #9
0
FenetreCourbe::FenetreCourbe( wxWindow* parent, wxWindowID id, const wxPoint& pos,  const wxSize& size, long style, int pl_style ) : 
          wxPLplotwindow<wxFrame>( true )
 {
    Create( parent, wxID_ANY, wxT( "wxPLplotDemo" ) );
//    frame->SetIcon( wxIcon( graph ) );
    Show();
    x.resize(6);
    y.resize(6);
    fenMere=(FenetrePrincipale*)parent;
    Plot(  );

    
 }
void ribi::QtToolTestApproximatorXyzMainDialog::on_button_clicked() noexcept
{
  #ifdef TODO_723468346509350397
  const double x = static_cast<double>(ui->box_int_x->value());
  const double y = ui->box_double_y->value();
  const double z = static_cast<double>(ui->box_int_z->value());
  assert(m_approximator.CanAdd(y, {x,z})
    && "Can only click the button when the pair can be added");

  m_approximator.Add(x,y);
  Plot();
  #endif
}
void Graphics::Render(HDC hdc) {
	zBuffer->Reset();

	MemDC memDC(hdc, &stage);

	const char* info = "°´F1»ñÈ¡°ïÖú";
	TextOut(memDC, 0, 0, info, strlen(info));

	RenderList renderList;
	camera->RunPipeline(renderList, container);

	Plot(memDC, renderList);
}
Beispiel #12
0
void MesaDriver::WriteRGBAPixelsFront(const GLcontext *ctx,
                                   GLuint n, const GLint x[], const GLint y[],
                                   CONST GLubyte rgba[][4],
                                   const GLubyte mask[] )
{
   MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
   BGLView *bglview = md->m_bglview;
   assert(bglview);
   if (mask) {
      for (GLuint i = 0; i < n; i++) {
         if (mask[i]) {
            bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
            Plot(bglview, x[i], md->m_bottom - y[i]);
         }
      }
   }
   else {
      for (GLuint i = 0; i < n; i++) {
         bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
         Plot(bglview, x[i], md->m_bottom - y[i]);
      }
   }
}
Beispiel #13
0
void MesaDriver::WriteMonoRGBAPixelsFront(const GLcontext *ctx, GLuint n,
                                       const GLint x[], const GLint y[],
                                       const GLchan color[4],
                                       const GLubyte mask[])
{
   MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
   BGLView *bglview = md->m_bglview;
   assert(bglview);
   // plot points using current color
   bglview->SetHighColor(color[RCOMP], color[GCOMP], color[BCOMP]);
   if (mask) {
      for (GLuint i = 0; i < n; i++) {
         if (mask[i]) {
            Plot(bglview, x[i], md->m_bottom - y[i]);
         }
      }
   }
   else {
      for (GLuint i = 0; i < n; i++) {
         Plot(bglview, x[i], md->m_bottom - y[i]);
      }
   }
}
Beispiel #14
0
void MesaDriver::WriteMonoRGBASpanFront(const GLcontext *ctx, GLuint n,
                                     GLint x, GLint y,
                                     const GLchan color[4],
                                     const GLubyte mask[])
{
   MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
   BGLView *bglview = md->m_bglview;
   assert(bglview);
   int flippedY = md->m_bottom - y;
   bglview->SetHighColor(color[RCOMP], color[GCOMP], color[BCOMP]);
   if (mask) {
      for (GLuint i = 0; i < n; i++) {
         if (mask[i]) {
            Plot(bglview, x++, flippedY);
         }
      }
   }
   else {
      for (GLuint i = 0; i < n; i++) {
         Plot(bglview, x++, flippedY);
      }
   }
}
Beispiel #15
0
void Oscilloscope::ProcessRawEvent(){
	ChannelEvent *current_event = NULL;

	// Fill the processor event deques with events
	while(!rawEvent.empty()){
		current_event = rawEvent.front();
	
		// Pass this event to the correct processor
		if(current_event->modNum == mod && current_event->chanNum == chan){ Plot(current_event); } // This is a signal we wish to plot.
		
		// Remove this event from the raw event deque
		delete current_event;
		rawEvent.pop_front();
	}
}
Beispiel #16
0
void MesaDriver::WriteRGBSpanFront(const GLcontext *ctx, GLuint n,
                                GLint x, GLint y,
                                CONST GLubyte rgba[][3],
                                const GLubyte mask[])
{
   MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
   BGLView *bglview = md->m_bglview;
   assert(bglview);
   int flippedY = md->m_bottom - y;
   if (mask) {
      for (GLuint i = 0; i < n; i++) {
         if (mask[i]) {
            bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
            Plot(bglview, x++, flippedY);
         }
      }
   }
   else {
      for (GLuint i = 0; i < n; i++) {
         bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
         Plot(bglview, x++, flippedY);
      }
   }
}
void QmitkTbssRoiAnalysisWidget::PlotFiber4D(mitk::TbssImage::Pointer tbssImage,
                                             mitk::FiberBundle *fib,
                                             mitk::DataNode* startRoi,
                                             mitk::DataNode* endRoi,
                                             int number)
{
  m_PlottingFiberBundle = false;
  m_Fib = fib;
  m_CurrentStartRoi = startRoi;
  m_CurrentEndRoi = endRoi;
  m_CurrentTbssImage = tbssImage;
  std::vector <std::vector<mitk::ScalarType> > groupProfiles = CalculateGroupProfilesFibers(tbssImage, fib, startRoi, endRoi, number);
  Plot(groupProfiles);

}
Beispiel #18
0
void winplot_point(int i, int j, int val)
{
  int ii;

  if(plot_mag == 1)
    Plot(ax * i + bx, ay * (winplot_height - j) + by,
         al * val, al * val, al * val);
  else {
    for(ii = 0; ii < plot_mag; ii++)
      Line(ax * (i * plot_mag + ii) + bx,
           ay * ((winplot_height - j) * plot_mag) + by,
           ax * (i * plot_mag + ii) + bx,
           ay * ((winplot_height - j + 1) * plot_mag - 1) + by,
           al * val, al * val, al * val);
  }
}
Beispiel #19
0
//Draw radar dots on HUD
void DrawRadarDots(bool clear) {
	int i;
	int x, y;
	Point3d transformed;
	SetLineWidth(3); //only the tank is largest
	for(i=1; i<=world.numObjects; i++) {
		transformed=TransformPoint(world.objects[i].centre, cameraPos, cameraAngle);
		if (i==2) //rest of objects a little smaller
			SetLineWidth(2);
		//draw transformed point on radar
		x = (int)(transformed.x / 200.0 * 20.0);
		y = (int)(transformed.z / 200.0 * 20.0);
		if (qsqrt(x * x + y * y) < 20) { //if within circle
			Plot(x + radarX, radarY - y, (clear ? BLACK : world.objects[i].colour));
		}
	}
	SetLineWidth(1);
}
Beispiel #20
0
void Winplot_point(int i, int j, int val)
{
  int ii;

  if(plot_mag == 1)
    Plot(ax * i + bx, ay * (winplot_height - j) + by,
         colors[(int)(al * val)][0],
         colors[(int)(al * val)][1],
         colors[(int)(al * val)][2]);
  else {
    for(ii = 0; ii < plot_mag; ii++)
      Line(ax * (i * plot_mag + ii) + bx,
           ay * ((winplot_height - j) * plot_mag) + by,
           ax * (i * plot_mag + ii) + bx,
           ay * ((winplot_height - j + 1) * plot_mag - 1) + by,
           colors[(int)(al * val)][0],
           colors[(int)(al * val)][1],
           colors[(int)(al * val)][2]);
  }
}
Beispiel #21
0
//**********************************************************************
void QRap::PerformSpectral()
{
	cout << "voor new Confirmspectral in QRap::PerformSpectral()" << endl;
	cConfirmSpectral ConfirmSpectral(mQGisIface->mainWindow(), QgisGui::ModalDialogFlags);
	cout << "voor ConfirmSpectral->SetPoints(mPoints) in QRap::PerformSpectral()" << endl;
	if (ConfirmSpectral.SetPoints(mPoints))
	{
		cout << "voor ConfirmSpectral->exec() in QRap::PerformSpectral()" << endl;
		if(ConfirmSpectral.exec()==1)
		{
			cSpectralAnalysis Plot(mQGisIface->mainWindow(), QgisGui::ModalDialogFlags);
			Plot.DoAndSetUpDisplay(ConfirmSpectral.mRx,ConfirmSpectral.mRadInst,
						ConfirmSpectral.mFrequencySpacing, ConfirmSpectral.mkFactor);
			if (Plot.exec())
			{
				mQGisIface->mapCanvas()->refresh();
			}
		}
	}
}
//! This method is called right at the beginning and opens a frame for us.
//
bool MyApp::OnInit()
{
#ifdef __WXMAC__
    // this hack enables to have a GUI on Mac OSX even if the
    // program was called from the command line (and isn't a bundle)
    ProcessSerialNumber psn;

    GetCurrentProcess( &psn );
    CPSEnableForegroundOperation( &psn );
    SetFrontProcess( &psn );
#endif

    wxPLplotwindow<wxFrame> *frame = new wxPLplotwindow<wxFrame>();
    frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
    frame->SetIcon( wxIcon( graph ) );
    frame->Show();
    Plot( frame );

    return true;
}
void Solenoid_MagneticField_Naive_Primary()
{
  //define the historgrams
  Define_Histograms();

  //get the root files add them to the TChain
  HMOLPOL_CHAIN.resize(NUM_FILES);
  for (int i_files = 0; i_files < NUM_FILES; i_files++)
  //for (int i_files = 1; i_files < 2; i_files++)
  {

    HMOLPOL_CHAIN[i_files] = new TChain("HMolPol_Tree");
    //add the file


    HMOLPOL_CHAIN[i_files]->Add(
        Form(
            "~/workspace/HMolPol/SolenoidMagField_Study/HMolPol_Dummy_2GeV_MagField%dT_PhiCom0.root",
            MAG_FIELD_STRENGTH[i_files]));

    /*
    HMOLPOL_CHAIN[i_files]->Add(
    Form(
    "~/workspace/HMolPol/SolenoidMagField_Study/HMolPol_Dummy_2GeV_MagField%dT.root",
    MAG_FIELD_STRENGTH[i_files]));
    */

    /*
     HMOLPOL_CHAIN[i_files]->Add(
     Form(
     "~/workspace/HMolPol/SolenoidMagField_Study/HMolPol_Dummy_2GeV_MagField%dT_Theta1to179.root",
     MAG_FIELD_STRENGTH[i_files]));
     */

    Loop_Through_Tree(HMOLPOL_CHAIN[i_files], i_files);
    Plot(i_files);
  }

  return;
}
Beispiel #24
0
void Base::DrawCircleMidpoint(const Real& x_c, const Real& y_c, const Real& r) {
  // Determine the initial coordinates and plot the first point
  int  x = 0;
  int  y = static_cast<int>(r);
  Real p = 1.25 - r; // The decision parameter

  // Now advance until x and y are equal
  while (x < y) {
    // Plot a single point in each octant of the circle, and shift each
    // point around the true center of the circle at (x_c, y_c).
    Plot(x + x_c, y + y_c);
    Plot(y + x_c, x + y_c);
    Plot(-y + x_c, x + y_c);
    Plot(-x + x_c, y + y_c);
    Plot(-x + x_c, -y + y_c);
    Plot(-y + x_c, -x + y_c);
    Plot(y + x_c, -x + y_c);
    Plot(x + x_c, -y + y_c);

    // Now determine the decision paramter at the next step based on its
    // previous value. If the decision parameter was less than zero then
    // the previously plotted point was inside the circle and the y coordinate
    // need not change. If, however, the decision parameter is greater than
    // zero our previously plotted point was outside the circle and thus we
    // should reduce y to compensate. If the previous decision parameter was
    // equal to zero then we were exactly on the circle and any choice we make
    // to modify y is equally accurate for plotting the next point.
    if (p <= 0) {
      p = p + (2 * x + 2) + 1;
      x++;
    } else {
      p = p + (2 * x + 2) + 1 - (2 * y - 2);
      x++;
      y--;
    }
  }
}
Beispiel #25
0
void Base::DrawLineDDA(Real x1, Real y1, Real x2, Real y2) {
  // First we compute the change in the x and y directions as the difference
  // between the given x and y coordinates.
  Real dx = x2 - x1;
  Real dy = y2 - y1;
  Real x  = x1;
  Real y  = y1;

  // If the coordinates change more rapidly in the x direction than in the y
  // direction.
  unsigned int steps = 0;

  if (fabs(dx) > fabs(dy)) {
    // Then change at unit intervals in the x direction
    steps = static_cast<int>(fabs(dx));
  } else {
    // Otherwise, change at unit intervals in the y direction
    steps = static_cast<int>(fabs(dy));
  }

  // Now we determine the increments in the x and y directions by dividing
  // the change in the corresponding direction by the number of steps the
  // line will be divided into. Notice that whichever direction is changing
  // at unit intervals will have an increment of 1. For example if steps = dx
  // then xIncrement = dx / steps = dx / dx = 1.
  Real xIncrement = dx / steps;
  Real yIncrement = dy / steps;

  // Plot successive pixels onto the screen until the line is completely
  // drawn.
  for (unsigned int k = 0; k < steps; k++) {
    Plot(round(x), round(y));
    x += xIncrement;
    y += yIncrement;
  }
}
Beispiel #26
0
void CChart::OnPaint() 
{
	CPaintDC	dc(this); // device context for painting

	CDC			memPlotDC ;
	CBitmap		*oldBitmap ;
	CBitmap		m_plotBitmap ;
	/* 
	 DrawBackGround-> memPlotDC.CreateCompatibleDC -> m_plotBitmap.CreateCompatibleBitmap
     memPlotDC.SelectObject(&m_plotBitmap)

	*/
	// Check if background need to be redrawn
	if (bBkNeedToUpdate){
		DrawBackGround(&dc);
		bBkNeedToUpdate = FALSE ;
	}
	memPlotDC.CreateCompatibleDC(&dc) ;						
	m_plotBitmap.CreateCompatibleBitmap(&dc,
				  									m_clientRect.Width(), 
													m_clientRect.Height());

	oldBitmap = (CBitmap*)memPlotDC.SelectObject(&m_plotBitmap);
	
	// BitBlt background .
	memPlotDC.BitBlt(0,0, m_clientRect.Width(), m_clientRect.Height(),
					&memBkDC,0,0,SRCCOPY);
	Plot(&memPlotDC);



	dc.BitBlt(0,0, m_clientRect.Width(), m_clientRect.Height(),
				&memPlotDC,0,0,SRCCOPY);
	memPlotDC.SelectObject(oldBitmap);

}
Beispiel #27
0
void scatter_PlotUnif1 (unif01_Gen * gen, long N, int Dim, lebool Over,
   int Proj[2], double Lower[], double Upper[], scatter_OutputType Output,
   int Prec, lebool Lac, long LacI[], char *Name)
{
   int j;
   unif01_Gen *genL;
   chro = chrono_Create ();
   scatter_N = N;
   scatter_t = Dim;
   scatter_Over = Over;
   scatter_x = Proj[0];
   scatter_y = Proj[1];
   for (j = 1; j <= scatter_t; j++) {
      scatter_L[j] = Lower[j - 1];
      scatter_H[j] = Upper[j - 1];
      util_Assert (scatter_L[j] >= 0.0, "scatter_PlotUnif1:   Lower[r] < 0");
      util_Assert (scatter_H[j] <= 1.0, "scatter_PlotUnif1:   Upper[r] > 1");
      util_Assert (scatter_L[j] < scatter_H[j],
                   "scatter_PlotUnif1:   Upper[r] <= Lower[r]");
   }
   if (scatter_Width <= 0.0)
      scatter_Width = 13.0;       /* cm */
   if (scatter_Height <= 0.0)
      scatter_Height = 13.0;      /* cm */
   scatter_Output = Output;
   scatter_Lacunary = Lac;
   if (scatter_Lacunary) {
      for (j = 0; j < scatter_t; j++)
         scatter_LacI[j] = LacI[j];
      genL = unif01_CreateLacGen (gen, scatter_t, scatter_LacI);
   } else
      genL = gen;
   strncpy (Nin, Name, (size_t) NUM_CHAR - 5);
   Plot (genL, Nin, Prec);
   chrono_Delete (chro);
}
Beispiel #28
0
int main(void)
{

//	GPIO_InitTypeDef GPIO_InitStructure;


//	RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOE , ENABLE);

//	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_2 | GPIO_Pin_4 | GPIO_Pin_6;
//	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//	GPIO_Init(GPIOE, &GPIO_InitStructure);
//	GPIO_SetBits(GPIOE,GPIO_Pin_0 | GPIO_Pin_2 | GPIO_Pin_4 | GPIO_Pin_6);

//	RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC , ENABLE);

//	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_3;
//	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//	GPIO_Init(GPIOC, &GPIO_InitStructure);
//	GPIO_SetBits(GPIOC,GPIO_Pin_1 | GPIO_Pin_3);

//	RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA , ENABLE);

//	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
//	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//	GPIO_Init(GPIOA, &GPIO_InitStructure);
//	GPIO_SetBits(GPIOA,GPIO_Pin_1);

//	while(1)
//	;

	CoThread::InitCoOS();
	//sensClock clock(SENSOR_ID_CLOCK);
	DEBUG.print("Welcome to RootControl!\r\n");
//	SDFile testFile("0:/MIRKO.TXT");
//	DEBUG.print("File size = %d, content:\r\n",testFile.Size());
//	char buff[5];
//	buff[4] = 0;
//	testFile.Read(buff,4);
//	DEBUG.print(buff);
//	testFile.Read(buff,4);
//	DEBUG.print(buff);
//	testFile.Read(buff,4);
//	DEBUG.print(buff);

//	testFile.Write("Leba ti jebem!\r\n12345\r\n",sizeof("Leba ti jebem!\r\n12345\r\n")-1);
//	testFile.Close();
//	DEBUG.print("Finished writing the file!\r\n");
	Display display;
	BrainRoot brain;
	Screen mainScreen;
	Screen settingsScreen;


	DEBUG.print("Adding screens!\r\n");
	display.addScreen(&mainScreen);
	display.addScreen(&settingsScreen);
	DEBUG.print("Making widgets!\r\n");
	wgVerGauge gauge1(10, 10, 60, 180, 400, 100);
	wgVerGauge gauge2(250, 10, 60, 180, 1000, 0);
	gauge1.setScaleFactor(10,1);
	gauge2.setScaleFactor(10,1);
	gauge1.setUnit('C');
	gauge2.setUnit('%');

	wg2DPlot Plot(80,10,180,160,&SENSCLOCK,8);
	wgNavScreens wgNext(WGNAVSCREENS_TYPE_MOVE_PREV,20,200,30,30);
	wgNavScreens wgPrev(WGNAVSCREENS_TYPE_MOVE_NEXT,270,200,30,30);
	wgLabel wgClockLabel(80,200,30,160);
	wgIndicator wgCoolHeat(80,200,30,30);
	wgIndicator wgHumi(120,200,30,30);
	wgIndicator wgLed(160,200,30,30);

	DEBUG.print("Calibrating touch sensor!\r\n");
	TouchSensor touchsensor(SENSOR_ID_DISPLAY, &display);
	//touchsensor.calibrate();
	touchsensor.addListener(&brain);

	DEBUG.print("Adding clock listeners!\r\n");
	SENSCLOCK.addListener(&wgClockLabel);
	SENSCLOCK.addListener(&brain);

	DEBUG.print("Initializing humidity sensor!\r\n");
	sensHumidityTemperature humidityTempSensor;
	humidityTempSensor.sensHumi.addListener(&brain);
	humidityTempSensor.sensTemp.addListener(&brain);
	humidityTempSensor.sensHumi.addListener(&gauge2);
	humidityTempSensor.sensTemp.addListener(&gauge1);

	Plot.addTrace(&humidityTempSensor.sensHumi,0,1000,COLOR_BLUE);
	Plot.addTrace(&humidityTempSensor.sensTemp,100,400,COLOR_RED);
	Plot.addTrace(&brain.refTemp,100,400,COLOR_GREEN);
	Plot.addTrace(&brain.refHumi,0,1000,COLOR_BLUE|COLOR_GREEN);
	brain.humidityActuator.status.addListener(&wgHumi);
	brain.temperatureActuator.status.addListener(&wgCoolHeat);
	brain.ledActuator.status.addListener(&wgLed);
	DEBUG.print("Adding widgets to screens!\r\n");
	mainScreen.addWidget(&gauge1);
	mainScreen.addWidget(&gauge2);
	mainScreen.addWidget(&Plot);
	mainScreen.addWidget(&wgNext);
	mainScreen.addWidget(&wgPrev);
	mainScreen.addWidget(&wgCoolHeat);
	mainScreen.addWidget(&wgHumi);
	mainScreen.addWidget(&wgLed);
	settingsScreen.addWidget(&wgClockLabel);
	settingsScreen.addWidget(&wgNext);
	settingsScreen.addWidget(&wgPrev);
	DEBUG.print("Starting threads!\r\n");
	humidityTempSensor.start();
	touchsensor.start();
	brain.start();
	display.start();
	SENSCLOCK.start();

	CoThread::StartCoOS();
	DEBUG.print("Major error! CoOS died!\r\n");
	while(1)
	{
	}
}
Beispiel #29
0
//code credit of http://tech-algorithm.com/articles/drawing-line-using-bresenham-algorithm/
void DrawLine(int x, int y, int x2, int y2, int color, int* buffer, int bufferWidth, int bufferHeight)
{
	//width
	int w = x2 - x;
	//height
	int h = y2 - y;
	//initialize "deltax/y", delta means change
	//so dx1 is "change in x1"
	int dx1 = 0;
	int dy1 = 0;
	int dx2 = 0;
	int dy2 = 0;
	//is our width negative or postive?
	//set deltax1 accordingly
	if (w < 0) dx1 = -1; else if (w > 0) dx1 = 1;
	//ditto
	if (h < 0) dy1 = -1; else if (h > 0) dy1 = 1;
	//same as before...
	if (w < 0) dx2 = -1; else if (w > 0) dx2 = 1;
	//get |width|
	int longest = MC_Abs(w);
	//get |shortest|
	int shortest = MC_Abs(h);
	//another octant check, is our width less than (or equal to) our height?
	if (!(longest > shortest))
	{
		//swap width/height
		longest = MC_Abs(h);
		shortest = MC_Abs(w);
		//another octant check! Is our height negative? Set deltay accordingly
		if (h < 0) dy2 = -1; else if (h > 0) dy2 = 1;
		//no change in x2
		dx2 = 0;
	}
	int numerator = longest >> 1; //faster way to divide by two
								  //go along the length of the triangle and...
	for (int i = 0; i <= longest; i++)
	{
		//plot the point at x/y
		Plot(x, y, color, buffer, bufferWidth, bufferHeight);
		//increase the size of the numerator by our "shortest" (h/w, whichever is smaller)
		numerator += shortest;

		//if the numerator is greater than or equal to our "longest" (h/w, whichever is bigger)
		if (!(numerator < longest))
		{
			//decrease the size of the numerator by our "longest"
			numerator -= longest;
			//increase x by our CHANGE IN X
			x += dx1;
			//ditto but with y
			y += dy1;
		}
		else
		{
			//increase our x by our CHANGE IN X2
			x += dx2;
			//ditto but with y
			y += dy2;
		}
	}
}
int main(int i_iArg_Count,const char * i_lpszArg_Values[])
{
//	char lpszLine_Buffer[1024];
	char	lpszFilename[256];
	char	lpszBuffer[1024];
	XDATASET cData;
	char	chSeparator;
	bool	bNo_Title = xParse_Command_Line_Exists(i_iArg_Count,i_lpszArg_Values,"--no-plot-title");
	bool	bLinear_Plot = xParse_Command_Line_Exists(i_iArg_Count,i_lpszArg_Values,"--linear-scale");

	for (unsigned int uiI = 1; uiI < i_iArg_Count; uiI++)
	{
		if ((strcmp(i_lpszArg_Values[uiI],"--no-plot-title") != 0) &&
			(strcmp(i_lpszArg_Values[uiI],"--linear-scale") != 0))
		{
			FILE * fileIn = fopen(i_lpszArg_Values[uiI],"rt");
			if (fileIn)
			{
				if (fgets(lpszBuffer,1024,fileIn))
				{
					if (strchr(lpszBuffer,','))
						chSeparator = ',';
					else if (strchr(lpszBuffer,'\t'))
						chSeparator = '\t';
					else
						chSeparator = 0;
				}
				fclose(fileIn);
				cData.ReadDataFile(i_lpszArg_Values[uiI],chSeparator == 0, false,chSeparator,0);
				if (cData.GetNumColumns() == 3)
				{
					cData.Add_Columns(2);
					double	dMin_Flux = DBL_MAX;
					double	dMin_Flux_Error = DBL_MAX;
					double	dMax_Flux = 0.0;
					double	dMax_Flux_Error = 0.0;
					bool bBad_Error = true;
					for (unsigned int uiJ = 0; uiJ < cData.GetNumElements(); uiJ++)
					{
						double	dFlux = cData.GetElement(1,uiJ);
						double	dFlux_Error = cData.GetElement(2,uiJ);
						double	dFlux_Lower = dFlux - dFlux_Error;
						double	dFlux_Upper = dFlux + dFlux_Error;
						if (dFlux > 0.0 && dFlux < dMin_Flux)
							dMin_Flux = dFlux;
						if (dFlux_Lower > 0.0 && dFlux_Lower < dMin_Flux_Error)
							dMin_Flux_Error = dFlux_Lower;
						if (dFlux > dMax_Flux)
							dMax_Flux = dFlux;
						if (dFlux_Upper > dMax_Flux_Error)
							dMax_Flux_Error = dFlux_Upper;
						bBad_Error &= (dFlux_Error == 1.0 || dFlux_Error == 0.0);
						if (isnan(dFlux) || isnan(dFlux_Error) || isinf(dFlux) || isinf(dFlux_Error))
							printf("%s: Bad flux point at %.2f A\n",i_lpszArg_Values[uiI],cData.GetElement(0,uiJ));
					}
					if (!bBad_Error && dMin_Flux_Error < dMin_Flux)
						dMin_Flux = dMin_Flux_Error;
					if (!bBad_Error && dMax_Flux_Error < dMax_Flux)
						dMax_Flux = dMax_Flux_Error;
					printf("%s: Min Flux %.2e\tMax Flux %.2e\t%s\n",i_lpszArg_Values[uiI],dMin_Flux,dMax_Flux,bBad_Error?"Error not valid":"Error valid");
					for (unsigned int uiJ = 0; uiJ < cData.GetNumElements(); uiJ++)
					{
						double	dFlux = cData.GetElement(1,uiJ);
						double	dFlux_Error = cData.GetElement(2,uiJ);
						if (bBad_Error)
							dFlux_Error = 0.0;
							
						double	dUpper = dFlux + dFlux_Error;
						double	dLower = dFlux - dFlux_Error;
						if (dLower <= 0.0)
							dLower = dMin_Flux;
						if (dFlux <= 0.0)
							dFlux = dMin_Flux;
						if (dUpper <= 0.0)
							dUpper = dMin_Flux;
						if (bLinear_Plot)
						{
							cData.SetElement(3,uiJ,dUpper); // upper bound
							cData.SetElement(4,uiJ,dLower); // lower bound
						}
						else
						{
							cData.SetElement(3,uiJ,log10(dUpper)); // upper bound
							cData.SetElement(4,uiJ,log10(dLower)); // lower bound

							cData.SetElement(1,uiJ,log10(dFlux));
						}
					}
				}
				else
				{
					for (unsigned int uiJ = 0; uiJ < cData.GetNumElements(); uiJ++)
					{
						double	dFlux = cData.GetElement(1,uiJ);
						cData.SetElement(1,uiJ,log10(dFlux));
					}
				}
				sprintf(lpszFilename,"%s.eps",i_lpszArg_Values[uiI]);
				Plot(cData,i_lpszArg_Values[uiI],lpszFilename,2500.0,10000.0, bNo_Title ? NULL : i_lpszArg_Values[uiI], bLinear_Plot, true);
				sprintf(lpszFilename,"%s.NIR.eps",i_lpszArg_Values[uiI]);
				Plot(cData,i_lpszArg_Values[uiI],lpszFilename,7000.0,9000.0, bNo_Title ? NULL : i_lpszArg_Values[uiI], bLinear_Plot, true);
				sprintf(lpszFilename,"%s.HK.eps",i_lpszArg_Values[uiI]);
				Plot(cData,i_lpszArg_Values[uiI],lpszFilename,3000.0,5000.0, bNo_Title ? NULL : i_lpszArg_Values[uiI], bLinear_Plot, true);
				sprintf(lpszFilename,"%s.Si6355.eps",i_lpszArg_Values[uiI]);
				Plot(cData,i_lpszArg_Values[uiI],lpszFilename,5000.0,7000.0, bNo_Title ? NULL : i_lpszArg_Values[uiI], bLinear_Plot, true);
			}
		}
	}
	return 0;
}