Recent

Author Topic: millimeter paper  (Read 1244 times)

krolikbest

  • Full Member
  • ***
  • Posts: 246
millimeter paper
« on: December 03, 2019, 01:48:39 pm »
Hello,

 need to use as a backgroud on a canvas millimeter paper. Is there to use something ready or have to invent my own? At first glance comes to mind use lines and moveto but it doesn't look good. meantime found:https://wiki.freepascal.org/PlotPanel and thought also about chart components but i'm not sure in which direction to go... Do you have ideas?

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: millimeter paper
« Reply #1 on: December 03, 2019, 01:54:15 pm »
For what do you need the millimeter paper? For plotting? Then use TAChart, otherwise you'll have to reinvent scaling of coordinates, generation of axis labels, positioning titles and legends and a lot more. PlotPanel might work too, it is not actively maintained, and in fact, I don't know whether it even compile.

For using TAChart you should have a look at the introductory tutorial: wiki.lazarus.freepascal.org/TAChart_Tutorial:_Getting_started

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: millimeter paper
« Reply #2 on: December 03, 2019, 02:27:58 pm »
It has to be only as a background on a canvas. It won't be plotted nor printed. Ok, try TChart

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: millimeter paper
« Reply #3 on: December 03, 2019, 03:36:14 pm »
No, for decorative purposes TAChart is overkill. Simply paint the grid on the canvas by using Canvas.Line instructions.

Since this smells like some homework assignment I am showing you here only a partial solution for the vertical lines:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Panel1Paint(Sender: TObject);
  2. const
  3.   COLOR1 = TColor($F0F0F0);
  4.   COLOR2 = TColor($E0E0E0);
  5. var
  6.   dx: Integer;
  7.   x: Integer;
  8.   i: Integer;
  9. begin
  10.   dx := round(ScreenInfo.PixelsPerInchX / 25.4);
  11.   with Panel1 do begin
  12.     Canvas.Brush.Color := clWhite;
  13.     Canvas.FillRect(0, 0, Width, Height);
  14.     Canvas.Pen.Width := 1;
  15.     Canvas.Pen.Style := psSolid;
  16.     // vertical grid lines
  17.     x := 0;
  18.     for i := 0 to MaxInt do
  19.     begin
  20.       if i mod 10 = 0 then
  21.         Canvas.Pen.Color := COLOR2
  22.       else
  23.         Canvas.Pen.Color := COLOR1;
  24.       Canvas.Line(x, 0, x, Height);
  25.       inc(x, dx);
  26.       if x > Width then break;
  27.     end;
  28.     // horizontal grid lines
  29.     // ...
  30.   end;
  31. end;

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: millimeter paper
« Reply #4 on: December 03, 2019, 03:52:21 pm »
oh, how nice already with a code!
Thanks :)

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: millimeter paper
« Reply #5 on: December 04, 2019, 11:46:49 am »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: millimeter paper
« Reply #6 on: December 04, 2019, 05:32:21 pm »
Yes, know Eye-Candy Controls and find them simply awsome!. Some years ago did my own CNC program for milling machine https://www.youtube.com/watch?v=0xt6NM7tVxY in Delphi 7 Personal.
Had to write the same background grid (that is the reason why I asked if is there something ready to use). As you can see i use in this project a ruler but forgot where it came from.

 

TinyPortal © 2005-2018