示例#1
0
void CMeth2DLin::Draw(CDC *pDC, double scx, double offx, double scy, double offy)
{
	TRACE("Entering CMeth2DLinWerner::Draw\n");
	CSize ls(2, 0);
	pDC->DPtoLP( &ls );
	int l = ls.cx;

	if( m_bVisible ) {
		double	x, y;
		double dClusNum, dTrash;
		int		i;
		CResult *pRes;

		// first draw hiden solutions
		for( i=0; i<m_results.GetSize(); i++) {
			pRes = m_results[i];
			if( pRes->m_bGrey && pRes->m_bShow) {
				x = offx + scx*pRes->m_dX;
				y = offy + scy*pRes->m_dZ;
				DrawSymbol(pDC, (int)x, (int)y, l, 1, RGB(230, 230, 230), CROSS, false, 0);
			}
		}
		// visible solutions
		for( i=0; i<m_results.GetSize(); i++ ) {
			// draw solution that are checked
			pRes = m_results[i];
			if( !pRes->m_bGrey && pRes->m_bShow)  {
				switch( m_nClstType ) {
					case CLST_NORMAL:
						dClusNum = pRes->m_dClsN;
						dTrash = m_dTrashN;
						break;
					case CLST_POWER:
						dClusNum = pRes->m_dClsP;
						dTrash = m_dTrashP;
						break;
					case CLST_NONE:
						dClusNum = 0;
						break;
				}
				x = pRes->m_dX;
				y = pRes->m_dZ;
				// draw only solutions that are within graph
				if( (x > m_prof.min) && (x < m_prof.max) && (y > m_depth.min) && (y < m_depth.max) ) {
					x = offx + scx*x;	// (offset + scale * value)
					y = offy + scy*y;
					//if(m_bSymbol) {
						//UINT symbL = (UINT) (50 + nPtInClus*symbSc);
						UINT symbL = (UINT) (3*l*(dClusNum-dTrash)/(1-dTrash));
						DrawSymbol(pDC, (int) x, (int) y, symbL, 1, m_color, CROSS, false, 0);
						/*if(m_bDip) {
							int dip = int (pWR->GetAt(pos)->m_dDip*10);
							DrawSymbol(pDC, (int) x, (int) y, symbL, 1, m_logPen.lopnColor, ARROW, FALSE, dip);
						}*/
					//}
				}
			}
		}
	}
}
示例#2
0
void ViewText(char *arg_list, ...)
{
	Label label;
	va_list arg_buffer;
	uint16_t x,y;
	char tobuf[100],i;
	
	label.TextColor = &cAll;
	label.BGColor = (void*)0;
	label.StartPoint.X = TEXT_START_POSITION_X;
	label.StartPoint.Y = TEXT_START_POSITION_Y + 10 * currentTextPosition;
	label.StartPoint.Z = 0;
	
	
	x = label.StartPoint.X;
	y = label.StartPoint.Y;
	
  va_start(arg_buffer,arg_list);
  vsprintf(tobuf, arg_list, arg_buffer);
  for(i=0;i<100;i++)
  {
    if(tobuf[i]!=0) DrawSymbol(i*6+x,y,tobuf[i], label.TextColor, label.BGColor);
    else break;
  }
	
	currentTextPosition++;
}
示例#3
0
	RESULTCODE TriangleMarkerImpl::Draw(WKBPoint* pWKBPoint, Renderer* pRenderer, Transformation* pTransform)
	{
		if(m_size==0)
		{
			return AG_FAILURE;
		}

		RendererCairo* pRendererCairo = static_cast<RendererCairo*>(pRenderer);
		cairo_t			*canvas_cairo = pRendererCairo->GetCairo();
		cairo_surface_t	*canvas_surface=pRendererCairo->GetCairoSurface();

		int sx=0, sy=0;		
		pTransform->ToScreenPoint(pWKBPoint->point.x, pWKBPoint->point.y, sx, sy);

		//cairo_surface_t *image = cairo_image_surface_create_from_png(resource);
		if(m_cairo==NULL)
		{
			DrawSymbol();
		}

		if(m_cairo!=NULL)
		{
			cairo_save(canvas_cairo);
			cairo_translate(canvas_cairo, sx-m_size, sy-m_size);
			cairo_set_source_surface(canvas_cairo, m_icon, 0,0);
			cairo_paint(canvas_cairo);
			cairo_surface_flush(canvas_surface);
			cairo_restore(canvas_cairo);
		}

		return AG_SUCCESS;
	}
void
SymbolButtonRenderer::DrawButton(Canvas &canvas, const PixelRect &rc,
                                 bool enabled,
                                 bool focused, bool pressed) const
{
  frame_renderer.DrawButton(canvas, rc, focused, pressed);

  if (!caption.empty())
    DrawSymbol(canvas, frame_renderer.GetDrawingRect(rc, pressed),
               enabled, focused, pressed);
}
示例#5
0
void CCardRegion::DrawCardStack(SDL_Surface *s)
{
	if(!(Attributes&CRD_VISIBLE))
		return;

	DrawSymbol(xCoord, yCoord, Symbol);
	for(VI vi = InternalStack.begin(); vi != InternalStack.end(); ++vi)
	{
		if(vi->FaceUp())
			DrawCard(vi->x, vi->y, vi->Idx, s);
		else
			DrawCardBack(vi->x, vi->y, s);
	}
}
示例#6
0
__monitor void DrawText(char x,char y,char* text,char interval)
{
  asm("sim");
  unsigned int i,pos;
  pos=x;
  i=0;
  while (1) 
  {
    if (text[i]=='/') {if (text[i+1]=='@'){goto EndDrawText;}};
    DrawSymbol(pos,y,text[i]);
    pos=pos+5+interval;
    i++;
  }  
  EndDrawText:
  asm("rim");
}
示例#7
0
	virtual void Draw(BRect updateRect)
	{
		BRect bounds(Bounds());
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		SetHighColor(tint_color(base, B_DARKEN_2_TINT));
		StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
		bounds.bottom--;
		uint32 flags = be_control_look->Flags(this);
		uint32 borders = BControlLook::B_TOP_BORDER
			| BControlLook::B_BOTTOM_BORDER;
		be_control_look->DrawInactiveTab(this, bounds, updateRect, base,
			0, borders);
		if (IsEnabled()) {
			rgb_color button = tint_color(base, 1.07);
			be_control_look->DrawButtonBackground(this, bounds, updateRect,
				button, flags, 0);
		}

		bounds.left = (bounds.left + bounds.right) / 2 - 6;
		bounds.top = (bounds.top + bounds.bottom) / 2 - 6;
		bounds.right = bounds.left + 12;
		bounds.bottom = bounds.top + 12;
		DrawSymbol(bounds, updateRect, base);
	}
示例#8
0
void CSymbolTypeComboBox::DrawItem(LPDRAWITEMSTRUCT pDIStruct)
{
    CRect rItemRect = pDIStruct->rcItem;

    COLORREF clrNormal   = ::GetSysColor(COLOR_WINDOW);
    COLORREF clrSelected = ::GetSysColor(COLOR_HIGHLIGHT);
    COLORREF drawColor   = symColor;

    CDC dcContext;
    if (!dcContext.Attach(pDIStruct->hDC)) {
        return;
    }

    int iState = pDIStruct->itemState;
    if (iState & ODS_SELECTED)
    {
        drawColor = 0x00FFFFFF & ~(drawColor);
        dcContext.SetBkColor(clrSelected);
        dcContext.FillSolidRect(&rItemRect, clrSelected);
    }
    else
    {
        dcContext.SetBkColor(clrNormal);
        dcContext.FillSolidRect(&rItemRect, clrNormal);
    }

    if (iState & ODS_FOCUS) {
        dcContext.DrawFocusRect(&rItemRect);
    }

    int iItem = pDIStruct->itemID;
    if (iItem != -1)
    {
        dcContext.SetBkMode(TRANSPARENT);

        if (iState & ODS_DISABLED)
        {
            drawColor = ::GetSysColor(COLOR_INACTIVECAPTIONTEXT);
        }

        PlotSymbol currSym = PlotSymbol(iItem);
        bool filledSym = PlotSymbolOps::SymbolIsFilled(currSym);

        rItemRect.DeflateRect(4, 0);
        int lThick = IMin(rItemRect.bottom - rItemRect.top - 2, symLThick);

        if (filledSym)
            lThick = 1;
        CPen drawPen(PS_SOLID, lThick, drawColor);
        CPen* pOldPen = dcContext.SelectObject(&drawPen);

        CBrush brush(drawColor);
        CBrush* pOldBrush = dcContext.SelectObject(&brush);

        int drawSymSize  = IMin((rItemRect.bottom - rItemRect.top), symSize);

        int rectMidY = (rItemRect.top + rItemRect.bottom) / 2;
        int rectMidX = (rItemRect.left + rItemRect.right) / 2;

        switch (currSym) {
            case ps_X : {
                drawSymSize /= 2;
                dcContext.MoveTo(rectMidX - drawSymSize, rectMidY - drawSymSize);
                dcContext.LineTo(rectMidX + drawSymSize, rectMidY + drawSymSize);
                dcContext.MoveTo(rectMidX + drawSymSize, rectMidY - drawSymSize);
                dcContext.LineTo(rectMidX - drawSymSize, rectMidY + drawSymSize);
                break;
            }
            case ps_Plus : {
                drawSymSize /= 2;
                dcContext.MoveTo(rectMidX - drawSymSize, rectMidY);
                dcContext.LineTo(rectMidX + drawSymSize, rectMidY);
                dcContext.MoveTo(rectMidX, rectMidY - drawSymSize);
                dcContext.LineTo(rectMidX, rectMidY + drawSymSize);
                break;
            }
            case ps_Square : case ps_FSquare :{

                drawSymSize /= 2;
                CPoint pts[4];
                pts[0].x = rectMidX - drawSymSize;
                pts[0].y = rectMidY - drawSymSize;
                pts[1].x = rectMidX + drawSymSize;
                pts[1].y = rectMidY - drawSymSize;
                pts[2].x = rectMidX + drawSymSize;
                pts[2].y = rectMidY + drawSymSize;
                pts[3].x = rectMidX - drawSymSize;
                pts[3].y = rectMidY + drawSymSize;
                DrawSymbol(dcContext, pts, 4, filledSym);

                break;
            }
            case ps_Circle : case ps_FCircle: {
                static const Point2D cicoords[] = {Point2D(0.00000 ,0.50000),
                                               Point2D(0.25000 ,0.43301),
                                               Point2D(0.43301 ,0.25000),
                                               Point2D(0.50000 ,0.00000),
                                               Point2D(0.43301 ,-0.25000),
                                               Point2D(0.25000 ,-0.43301),
                                               Point2D(0.00000 ,-0.50000),
                                               Point2D(-0.25000,-0.43301),
                                               Point2D(-0.43301,-0.25000),
                                               Point2D(-0.50000,0.00000),
                                               Point2D(-0.43301,0.25000),
                                               Point2D(-0.25000,0.43301)};

                CPoint pts[12];

                for (int i = 0; i < 12; i++)
                {
                    int offX = int(double(drawSymSize) * cicoords[i].pX);
                    int offY = int(double(drawSymSize) * cicoords[i].pY);
                    pts[i].x = rectMidX + offX;
                    pts[i].y = rectMidY + offY;
                }

                DrawSymbol(dcContext, pts, 12, filledSym);
                break;
            }
            case ps_Triangle : case ps_FTriangle : {

                int offX = int(double(drawSymSize) * 0.4330);
                int offY = int(double(drawSymSize) * 0.25);

                CPoint pts[3];
                pts[0].x = rectMidX - offX;
                pts[0].y = rectMidY + offY;
                pts[1].x = rectMidX + offX;
                pts[1].y = rectMidY + offY;
                pts[2].x = rectMidX;
                pts[2].y = rectMidY - drawSymSize / 2;
                DrawSymbol(dcContext, pts, 3, filledSym);
                break;
            }
            case ps_Diamond : case ps_FDiamond : {
                drawSymSize /= 2;

                CPoint pts[4];
                pts[0].x = rectMidX;
                pts[0].y = rectMidY - drawSymSize;
                pts[1].x = rectMidX + drawSymSize;
                pts[1].y = rectMidY;
                pts[2].x = rectMidX;
                pts[2].y = rectMidY + drawSymSize;
                pts[3].x = rectMidX - drawSymSize;
                pts[3].y = rectMidY;
                DrawSymbol(dcContext, pts, 4, filledSym);
                break;
            }

        }
    }


    dcContext.Detach();
}
示例#9
0
void RwrClass::DrawEmitterSymbol( int symbolID, int boxed )
{
    DrawSymbol (display, symbolID, boxed);
}
示例#10
0
文件: test.c 项目: skal65535/fsc
int main(int argc, const char* argv[]) {
  int N = 100000000;
  int pdf_type = 2;
  int pdf_param = 5;
  int max_symbol = MAX_SYMBOLS;
  int print_pdf = 0;
  int log_tab_size = LOG_TAB_SIZE;
  FSCCodingMethod method = CODING_METHOD_DEFAULT;
  const char* in_file = NULL;
  const char* pdf_file = NULL;
  int c;

  for (c = 1; c < argc; ++c) {
    if (!strcmp(argv[c], "-t") && c + 1 < argc) {
      pdf_type = atoi(argv[++c]);
      if (pdf_type < 0) pdf_type = 0;
      else if (pdf_type > 5) pdf_type = 5;
    } else if (!strcmp(argv[c], "-p") && c + 1 < argc) {
      pdf_param = atoi(argv[++c]);
      if (pdf_type < 0) pdf_param = 0;
    } else if (!strcmp(argv[c], "-s") && c + 1 < argc) {
      max_symbol = atoi(argv[++c]);
      if (max_symbol < 2) max_symbol = 2;
      else if (max_symbol > 256) max_symbol = 256;
    } else if (!strcmp(argv[c], "-l") && c + 1 < argc) {
      log_tab_size = atoi(argv[++c]);
      if (log_tab_size > LOG_TAB_SIZE) log_tab_size = LOG_TAB_SIZE;
    } else if (!strcmp(argv[c], "-f") && c + 1 < argc) {
      in_file = argv[++c];
    } else if (FSCParseCodingMethodOpt(argv[c], &method)) {
      continue;
    } else if (!strcmp(argv[c], "-m") && c + 1 < argc) {
      method = (FSCCodingMethod)atoi(argv[++c]);
    } else if (!strcmp(argv[c], "-save") && c + 1 < argc) {
      pdf_file = argv[++c];
    } else if (!strcmp(argv[c], "-d")) {
      print_pdf = 1;
    } else if (!strcmp(argv[c], "-h")) {
      Help();
    } else {
      N = atoi(argv[c]);
      if (N <= 2) N = 2;
    }
  }
  uint8_t* base;
  FILE* file = NULL;
  if (in_file != NULL) {
    file = fopen(in_file, "rb");
    if (file == NULL) {
      fprintf(stderr, "Error opening file %s!\n", in_file);
      exit(-1);
    }
    fseek(file, 0L, SEEK_END);
    N = ftell(file);
    fseek(file, 0L, SEEK_SET);
    printf("Read File [%s] (%d bytes)\n", in_file, N);
  }

  base = (uint8_t*)malloc(N * sizeof(*base));
  if (base == NULL) {
    fprintf(stderr, "Malloc(%d) failed!\n", N);
    exit(-1);
  }

  if (file != NULL) {
    N = fread(base, 1, N, file);
    fclose(file);
  }  else {
    uint32_t pdf[256] = { 0 };
    int i;
    FSCRandom r;
    FSCInitRandom(&r);
    const int total = GeneratePdf(pdf_type, pdf_param, pdf, &r, max_symbol);
    const int nb_bits = 1 + log2(total - 1);
    uint64_t cumul[256 + 1];
    cumul[0] = 0;
    for (i = 1; i <= max_symbol; ++i) {
      cumul[i] = cumul[i - 1] + pdf[i - 1];
    }
    for (i = 0; i < N; ++i) {
      base[i] = DrawSymbol(cumul, max_symbol, total, nb_bits, &r);
    }
  }
  printf("PDF generated OK (max symbol:%d).\n", max_symbol);
  if (print_pdf) {
    PrintPdf(base, N);
    printf("[Params: type=%d param=%d max_symbol=%d size=%d]\n",
           pdf_type, pdf_param, max_symbol, N);
  }
  if (pdf_file != NULL) {
    SavePdfToFile(base, N, pdf_file);
  }
  const double entropy = GetEntropy(base, N);

  int nb_errors = 0;
  uint8_t* out = NULL;
  size_t out_size = 0;
  // Encode
  uint8_t* bits = NULL;
  size_t bits_size = 0;
  MyClock start, tmp;
  GetElapsed(&start, NULL);
  int ok = FSCEncode(base, N, &bits, &bits_size, log_tab_size, method);
  double elapsed = GetElapsed(&tmp, &start);
  const double MS = 1.e-6 * N; // 8.e-6 * bits_size;
  const double reduction = 1. * bits_size / N;

  printf("Enc time: %.3f sec [%.2lf MS/s] (%ld bytes out, %d in).\n",
         elapsed, MS / elapsed, bits_size, N);
  printf("Entropy: %.4lf vs expected %.4lf "
         "(off by %.5lf bit/symbol [%.3lf%%])\n",
         reduction, entropy, reduction - entropy,
         100. * (reduction - entropy) / entropy);

  if (!ok) {
    fprintf(stderr, "ERROR while encoding!\n");
    nb_errors = 1;
  } else {   // Decode
    GetElapsed(&start, NULL);
    ok = FSCDecode(bits, bits_size, &out, &out_size);
    elapsed = GetElapsed(&tmp, &start);
    printf("Dec time: %.3f sec [%.2lf MS/s].\n", elapsed, MS / elapsed);
    ok &= (out_size == N);

    if (!ok) {
      fprintf(stderr, "Decoding error!\n");
      nb_errors = 1;
    } else {
      int i;
      for (i = 0; i < N; ++i) {
        nb_errors += (out[i] != base[i]);
      }
      printf("#%d errors\n", nb_errors);
      if (nb_errors) fprintf(stderr, "*** PROBLEM!! ***\n");
    }
  }

 End:
  free(base);
  free(out);
  free(bits);
  return (nb_errors != 0);
}
示例#11
0
//====================================================================
void CLEDScreen::RedrawBkCanvas()
{
	ASSERT(backDC);
//	ASSERT(symbDC);

	if (!backDC)  return;

	backDC->m_crBackground     = m_crBackground;
	backDC->m_bDrawTransparent = m_bDrawTransparent;

	CRect clip;
	backDC->GetClipBox(&clip);

	backDC->FillSolidRect(&m_recClient, m_crBackground);

	int nIndex;
	int nColPos = 0;
	int nSpaceCount = 0;
	int nLength = m_contents.GetLength();
	m_Capacity = 0;
	
	if(m_SymbolRect.right > 0)  // if matrix is created
	{
		m_Capacity = (m_recClient.right - m_recClient.left - 2 * m_FieldsWidth + m_Offset) / (m_SymbolRect.right + m_Offset);
		nSpaceCount = m_Capacity - nLength;
	}

	for (int nCount = 0; nCount < m_Capacity && symbDC != NULL; nCount++)
	{
		nColPos = m_FieldsWidth + nCount * (m_SymbolRect.right + m_Offset);

		nIndex = (m_RightAligned ? nCount - m_Capacity + nLength - m_ScrollPos : nCount + m_ScrollPos);  
		// draw symbols (or draw back faded symbol) to buffer
		if ( (!m_RightAligned && nCount < nLength)
			|| (m_RightAligned && nIndex > -1 && nIndex < nLength) )
		{
			if		( m_contents[nIndex] == '0' )    DrawSymbol( backDC, ss_0, nColPos );
			else if ( m_contents[nIndex] == '1' )	DrawSymbol( backDC, ss_1, nColPos );
			else if ( m_contents[nIndex] == '2' )	DrawSymbol( backDC, ss_2, nColPos );
			else if ( m_contents[nIndex] == '3' )	DrawSymbol( backDC, ss_3, nColPos );
			else if ( m_contents[nIndex] == '4' )	DrawSymbol( backDC, ss_4, nColPos );
			else if ( m_contents[nIndex] == '5' )	DrawSymbol( backDC, ss_5, nColPos );
			else if ( m_contents[nIndex] == '6' )	DrawSymbol( backDC, ss_6, nColPos );
			else if ( m_contents[nIndex] == '7' )	DrawSymbol( backDC, ss_7, nColPos );
			else if ( m_contents[nIndex] == '8' )	DrawSymbol( backDC, ss_8, nColPos );
			else if ( m_contents[nIndex] == '9' )	DrawSymbol( backDC, ss_9, nColPos );
			else if ( m_contents[nIndex] == '#' )	DrawSymbol( backDC, ss_Sharp, nColPos );
			else if ( m_contents[nIndex] == '*' )	DrawSymbol( backDC, ss_Star, nColPos );
		}
		else DrawSymbol( backDC, ss_Space, nColPos );
	}
}