Ejemplo n.º 1
0
void Design::paint(Graphics::ManagedSurface *surface, Patterns &patterns, int x, int y) {
	bool needRender = false;

	if (_surface == NULL) {
		_boundsCalculationMode = true;
		_bounds->debugPrint(4, "Internal bounds:");
		render(patterns);
		_boundsCalculationMode = false;
		if (_bounds->right == -10000) {
			_bounds->left = _bounds->top = _bounds->right = _bounds->bottom = 0;
		}
		_bounds->debugPrint(4, "Calculated bounds:");

		_surface = new Graphics::ManagedSurface;
		_surface->create(_bounds->width(), _bounds->height(), Graphics::PixelFormat::createFormatCLUT8());

		_surface->clear(kColorGreen);

		needRender = true;
	}

	_bounds->debugPrint(4, "Using bounds:");
#if 0
	PlotData pd(_surface, &patterns, 8, 1, this);
	int x1 = 50, y1 = 50, x2 = 200, y2 = 200, borderThickness = 30;
	Common::Rect inn(x1-5, y1-5, x2+5, y2+5);
	drawRoundRect(inn, 6, kColorGray, false, drawPixelPlain, &pd);

	drawThickLine(x1, y1, x2-borderThickness, y1, borderThickness, kColorBlack, drawPixel, &pd);
	drawThickLine(x2-borderThickness, y1, x2-borderThickness, y2, borderThickness, kColorBlack, drawPixel, &pd);
	drawThickLine(x2-borderThickness, y2-borderThickness, x1, y2-borderThickness, borderThickness, kColorBlack, drawPixel, &pd);
	drawThickLine(x1, y2-borderThickness, x1, y1, borderThickness, kColorBlack, drawPixel, &pd);
	drawThickLine(x2+10, y2+10, x2+100, y2+100, borderThickness, kColorBlack, drawPixel, &pd);

	g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, _surface->w, _surface->h);

	while (true) {
		((WageEngine *)g_engine)->processEvents();
		g_system->updateScreen();
		g_system->delayMillis(50);
	}
	return;
#endif

	if (needRender)
		render(patterns);

	if (_bounds->width() && _bounds->height()) {
		const int padding = 3;
		Common::Rect from(padding, padding, _bounds->width() - 2 * padding, _bounds->height() - 2 * padding);
		Common::Rect to(from);
		to.moveTo(x, y);
		surface->transBlitFrom(*_surface, from, to, kColorGreen);
	}
}
Ejemplo n.º 2
0
void user_line()
{
	switch(cur_style)
	{
		case 1:drawLine(1);
				break;
		case 2:drawThickLine(1);
				break;
		case 3:drawLine(2);
				break;
		case 4:drawThickLine(2);
				break;
	}
}
Ejemplo n.º 3
0
void polar(int ang,int n)
{
    RGB tmp;

    tmp.r=randInt(150,255);
    tmp.b=randInt(150,255);
    tmp.g=randInt(150,255);
    int a=250;
    for(int x=0;x<360;x++)
    {
        double r=sin((ang+x)/DEG_TO_RAD*n)*a;
        double x1=cos((x)/DEG_TO_RAD)*r+430;
        double y1=sin((x)/DEG_TO_RAD)*r+250;
        r=sin((x+1)/DEG_TO_RAD*n)*a;
        double x2=cos((x+1+ang)/DEG_TO_RAD)*r+430;
        double y2=sin((x+1+ang)/DEG_TO_RAD)*r+250;

        drawThickLine(x1,y1,x2,y2,1,tmp);
    }
}
Ejemplo n.º 4
0
void ovenGraphScreen::update (float temp, uint16_t time) {
    uint16_t intTemp = (uint16_t)temp;
    myBui.textBox.printTextBox (TEMPERATURE_T_BOX, temp, 2);
    myBui.textBox.printTextBox (RUNTIME_T_BOX, (int32_t)time);
    
    if (oven.ovenOn) {
        float percent = (float)time / (float)fullScaleTime;
        uint16_t x = (uint16_t)((float)_WIDTH * percent) + _LEFT;
        
        percent = (temp - oven.reflowVars.startTemp) / fullScaleTemp;
        uint16_t y = (_HEIGHT - (uint16_t)((float)_HEIGHT * percent)) + _TOP;
        
        if ((x > _LEFT) && (x < (_LEFT + _WIDTH))) {
            if ((y > _TOP) && (y < (_TOP + _HEIGHT))) {
                myBui.myLCD.setColor (VGA_FUCHSIA);
                drawThickLine (x2, y2, x, y);
            }
        }
        
        x2 = x;
        y2 = y;
    }
}
Ejemplo n.º 5
0
void ovenGraphScreen::drawGraph (void) {
    oven.calculateReflowVars ();
    
    uint16_t width = _WIDTH;
    uint16_t height = _HEIGHT;
    uint16_t x = _LEFT;
    uint16_t left = x;
    x2 = left + width;
    uint16_t y = _TOP;
    uint16_t top = y;
    uint16_t bottom = top + height;
    
    char st[10] = { 0 };
    
    float currentTemp = oven.reflowVars.startTemp;
    
    fullScaleTemp = oven.reflowVars.peakTemp + 15.0f - currentTemp;
    
    //draw graph background
    myBui.myLCD.setColor (VGA_SILVER);
    myBui.myLCD.fillRect (left, top, x2, bottom);
    
    //print 0 time
    myBui.myLCD.setColor (VGA_WHITE);
    myBui.myLCD.setBackColor (VGA_BLACK);
    myBui.myLCD.print ("0", left + 1, bottom + 2);
    
    //print full time
    fullScaleTime = oven.reflowVars.totalTime;
    uint8_t stLen = stringUtils.itos(fullScaleTime, st);
    myBui.printRight (st, x2 - 1, bottom + 2, stLen);
    
    //print current temp
    myBui.myLCD.setColor (VGA_RED);
    clearString (st, 10);
    stLen = stringUtils.ftos(oven.temp, st, 2);
    myBui.myLCD.print (st, left - 2, bottom - (stLen * myBui.myLCD.getFontXsize ()), 90);
    
/******************************************************************************/ 
    //determine x (time) coordinate for preheat 
    uint16_t time = oven.reflowVars.preheatTime;
    float percent = (float)time / (float)fullScaleTime;
    x = (uint16_t)((float)width * percent) + left;
    
    //print x (time) coordinate for preheat
    myBui.myLCD.setColor (VGA_WHITE);
    clearString (st, 10);
    stLen = stringUtils.itos(time, st);
    myBui.printCenter (st, x, bottom + 2, stLen);
    
    //determine y (temp) coordinate for preheat
    float temp = oven.reflowVars.soakTemp;
    percent = (temp - currentTemp) / fullScaleTemp;
    y = (height - (uint16_t)((float)height * percent)) + top;
    
    //print y (temp) coordinate for preheat 
    myBui.myLCD.setColor (VGA_RED);
    clearString (st, 10);
    stLen = stringUtils.itos(temp, st);
    myBui.myLCD.print (st, left - 2, y, 90);
    
    //draw lines for preheat
    myBui.myLCD.setColor (VGA_GRAY);
    myBui.myLCD.drawLine (left, y, x, y); // temp line
    myBui.myLCD.drawLine (x, y, x, bottom); // time line
    myBui.myLCD.setColor (VGA_LIME);
    drawThickLine (left + 1, bottom - 1, x, y); // setpoint slop
    
    x2 = x;
    y2 = y;

/******************************************************************************/     
    //determine x (time) coordinate for soak 
    time = oven.reflowVars.preheatTime + oven.reflowVars.soakTime;
    percent = (float)time / (float)fullScaleTime;
    x = (uint16_t)((float)width * percent) + left;
    
    //print x (time) coordinate for soak 
    myBui.myLCD.setColor (VGA_WHITE);
    clearString (st, 10);
    stLen = stringUtils.itos(time, st);
    myBui.printCenter (st, x, bottom + 2, stLen);
    
    //print y (temp) coordinate for preheat 
    temp = oven.reflowVars.soakTemp + oven.reflowVars.soakTempIncrease;
    percent = (temp - currentTemp) / fullScaleTemp;
    y = (height - (uint16_t)((float)height * percent)) + top;
    
    //print y (temp) coordinate for preheat 
    myBui.myLCD.setColor (VGA_RED);
    clearString (st, 10);
    stLen = stringUtils.itos(temp, st);
    myBui.myLCD.print (st, left - 2, y - (stLen * myBui.myLCD.getFontXsize ()), 90);
    
    //draw lines for soak
    myBui.myLCD.setColor (VGA_GRAY);
    myBui.myLCD.drawLine (left, y, x, y); // temp line
    myBui.myLCD.drawLine (x, y, x, bottom); // time line
    myBui.myLCD.setColor (VGA_LIME);
    drawThickLine (x2, y2, x, y); // setpoint slop
    
    x2 = x;
    y2 = y;

/******************************************************************************/    
    //determine x (time) coordinate for ramp 
    time = oven.reflowVars.preheatTime + oven.reflowVars.soakTime + oven.reflowVars.rampTime;
    percent = (float)time / (float)fullScaleTime;
    x = (uint16_t)((float)width * percent) + left;
    
    //print x (time) coordinate for ramp 
    myBui.myLCD.setColor (VGA_WHITE);
    clearString (st, 10);
    stLen = stringUtils.itos(time, st);
    myBui.printCenter (st, x, bottom + 2, stLen);
    
    //determine y (temp) coordinate for ramp
    temp = oven.reflowVars.peakTemp;
    percent = (temp - currentTemp) / fullScaleTemp;
    y = (height - (uint16_t)((float)height * percent)) + top;
    
    //print y (temp) coordinate for ramp 
    myBui.myLCD.setColor (VGA_RED);
    clearString (st, 10);
    stLen = stringUtils.itos(temp, st);
    myBui.myLCD.print (st, left - 2, y - 5, 90);
    
    //draw lines for ramp
    myBui.myLCD.setColor (VGA_GRAY);
    myBui.myLCD.drawLine (left, y, x, y); // temp line
    myBui.myLCD.drawLine (x, y, x, bottom); // time line
    myBui.myLCD.setColor (VGA_LIME);
    drawThickLine (x2, y2, x, y); // setpoint slop
    
    x2 = x;
    y2 = y;
    
/******************************************************************************/
    //determine x (time) coordinate for peak 
    time = oven.reflowVars.preheatTime + oven.reflowVars.soakTime + oven.reflowVars.rampTime + oven.reflowVars.peakTime;
    percent = (float)time / (float)fullScaleTime;
    x = (uint16_t)((float)width * percent) + left;
    
    //print x (time) coordinate for ramp 
    myBui.myLCD.setColor (VGA_WHITE);
    clearString (st, 10);
    stLen = stringUtils.itos(time, st);
    myBui.printCenter (st, x, bottom + 2, stLen);
    
    //draw lines for peak
    myBui.myLCD.setColor (VGA_GRAY);
    myBui.myLCD.drawLine (x, y, x, bottom); // time line
    myBui.myLCD.setColor (VGA_LIME);
    drawThickLine (x2, y2, x, y); // setpoint slop
    
    x2 = x;
    
/******************************************************************************/
    //determine x (time) coordinate for peak 
    x = left + width - 1;
    y = top + height - 1;
    
    drawThickLine (x2, y2, x, y); // setpoint slop
}
Ejemplo n.º 6
0
void PostScriptDrv::StartPage(int n, GXSTD::ostream &stream)
// Start a new page
{
  stream << "%%Page: ? " << n << "\n"; 

  if(use_header) // Set the header font
    stream << header_font_size << " /" << header_font << " ";
  else
    stream << font_size << " /" << text_font << " ";
  
  if(landscape) {
    stream << STARTPAGE << " " << page_width << " 0 translate " << "\n";
    stream << "90 rotate" << "\n";
  }
  else
    stream << STARTPAGE << "\n";

  if(use_header) { // Print the header info and reset the font
    int hpoints = int(HEADER_OFFSET * PIXELS_PER_INCH);
    int header_char_width = int(header_font_size * .6);
    int line_width, width, len, line_points, ypos, xpos = start_x; 
    int hoffset = hpoints / 2; // Offsets the header from text
    
    if(landscape) {
      // Leave some room for three hole punch margin at top of page
      ypos = page_width - (hpoints - 20);

      if(use_lr_margin == 0)
	line_points = int(page_height - (PRINTABLE_OFFSET_X * 2));
      else
	line_points = page_height - (hpoints * 2);

      width = page_height;
    }
    else {
      ypos = page_height - hoffset;
      line_points = page_width - (hpoints * 2);
      width = page_width;
    }

    if(draw_header_line) { // Draw the top and bottom lines
      drawThickLine(stream, line_points, xpos, ypos);
      drawThickLine(stream, line_points, xpos, hoffset);
      line_width = THICK_LINE_WIDTH * 2; // Offset the line from header text
    }
    else
      line_width = 0;
    
    ypos += line_width;
    if(date_string != 0 && document_name != 0) {
      // Left justify the document_name
      stream << xpos << " " << ypos << " " << MOVETO << "\n";
      stream << "(" << document_name << ")" << " " << SHOW << "\n";

      // Right justify the date string
      len = strlen(date_string) * header_char_width;
      if(use_lr_margin == 0)
	xpos = int((width - PRINTABLE_OFFSET_X) - len);
      else
	xpos = (line_points + hpoints) - len;
      stream << xpos << " " << ypos << " " << MOVETO << "\n";
      stream << "(" << date_string << ")" << " " << SHOW << "\n";
    }
    else { // Center the doucuments name
      if(document_name == 0) document_name = "PostScript Document";
      len = strlen(document_name) * header_char_width;
      xpos = (width / 2) - (len / 2);
      stream << xpos << " " << ypos << " " << MOVETO << "\n";
      stream << "(" << document_name << ")" << " " << SHOW << "\n";
      xpos = start_x;
    }

    // Draw the page numbers
    char page_number_string[255];
    sprintf(page_number_string, "PAGE %d", n);
    len = strlen(page_number_string) * header_char_width;
    xpos = (width / 2) - (len / 2);
    ypos = int(hoffset - (header_font_size + line_width));
    stream << xpos << " " << ypos << " " << MOVETO << "\n";
    stream << "(" << page_number_string << ")" << " " << SHOW << "\n";
    
    // Reset the text font
    stream << font_size << " /" << text_font << " " << STARTPAGE << "\n";
  }
}