نمایش نتایج 1 تا 14 از 14

نام تاپیک: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

  1. #1

    خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    سلام
    تاپیک قبل تری هم داشتم الان دوباره این را برقرار کردم. برای شروع منظور این است که از متن مانند ضمیمه مقادیر عددی مثلا x و y و غیره جدا شده و در لیست باکس یا مموی مناسب قرار داده شود.البته بعلت متغییر بودن محل x - y , ........ برنامه هایم درست کار نکردند.نمونه ای هم هست که درست کار می کند در ضمیمه می توانید ببینید.
    فایل نمونه درست کار کننده dxf90-11-14 می باشد فایل کاری من هم به همراه فایل متنی اضافه شده است.
    مرسی
    فایل های ضمیمه فایل های ضمیمه

  2. #2

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    این کدی است که از سایت پیدا کردم فقط اعداد جداشده معلوم نیست که مربوط به کدام مقدار هستند مثلا x - y و غیره..............
    کد HTML:
    procedure TForm1.Button2Click(Sender: TObject);
    var
      StartPos,ToEnd,a:integer;
    begin
    RichEdit1.SelAttributes.Color := clBlack;
     While a<>-1 do
     begin
       if RichEdit1.SelLength <> 0 then
         StartPos := RichEdit1.SelStart + RichEdit1.SelLength
       else
         StartPos :=0;
        ToEnd    := Length(RichEdit1.Text) - StartPos;
        a:=RichEdit1.FindText(Edit1.text,StartPos,ToEnd,[]);
        if a <> -1 then
        begin
          RichEdit1.SelStart := a;
          RichEdit1.SelLength := Length(Edit1.text);
          RichEdit1.SelAttributes.Color := clred;
        end;
      end;
    end;

  3. #3

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    کد هایی که نوشتم ولی اگه جای مقادیر حرفی مانند x - y و سایر عوض بشه دچار مشکل میشه:
    کد HTML:
    procedure TForm1.Button12Click(Sender: TObject);
    var
    temp,tempx,tempy,tempy1,tempy2,tempy3,tempy4:string;
    a1,a2,a3,a4,a5,a6,a7:int64;
    f1,f2,f3,f4:real;
    StrList: TStringList;
    I:INTEGER;
    begin
       ListBox1.Clear;
       ListBox2.Clear;
       if OpenDialog1.Execute then
       begin
       StrList:= TStringList.Create;
       try
       StrList.LoadFromFile(OpenDialog1.FileName);
       ListBox1.Clear;
       for I := 0 to StrList.Count - 1 do
       begin
       Temp:=StrList.Strings[i];
      // showmessage(Temp);
       a1:=Pos('X',Temp);
       //showmessage('a1= '+inttostr(a1));
       if a1<>0 then
       a2:=Pos('Y',Temp);
       //showmessage('a2= '+inttostr(a2));
       TempX:= Copy(Temp, Pos('X', Temp)+1, Pos('Y', Temp)-(a1+1));
       //TempX:= Copy(Temp, Pos('X', Temp)+1, Pos('Y', Temp)-2);
       //showmessage(('X= ')+(TempX));
       //form1.ListBox1.Clear;
       form1.ListBox1.Items.Add(TempX);
      if a2<>0 then
       a3:=Pos('R',Temp);
       //showmessage(inttostr(a3));
        Tempy:= Copy(Temp, Pos('Y', Temp)+1,  Length(Temp));
       //showmessage(tempy);
       //form1.ListBox1.Clear;
    
        Tempy1:='Y'+Tempy;
         a4:=Pos('Y',Tempy1);
         a5:=Pos('F',Tempy1);
         a6:=Pos('R',Tempy1);
        // showmessage(inttostr(a4));
        // showmessage(inttostr(a5));
        TempY:= Copy(Tempy1, Pos('Y', Tempy1)+(1), Pos('F', Tempy1)-(a4+1));
        //showmessage(('Y= ')+(TempY));
       form1.ListBox2.Items.Add(TempY);
       Tempy2:= Copy(Temp, Pos('F', Temp)+(1),Length(Temp));
       if a3<>0 then
       Tempy:= Copy(Tempy2, Pos('F', Tempy2)+1, Pos('R', Tempy2)-(a5+1));   /////,  Length(Tempy));
       //showmessage(('F= ')+(tempy));
       form1.ListBox3.Items.Add(Tempy);
       if a6<>0 then
       Tempy:= Copy(Tempy2, Pos('R', Tempy2)+1, Length(Tempy2));
       //showmessage(('R= ')+(tempy));
       form1.ListBox4.Items.Add(Tempy);
    
    
      END;
      finally
      StrList.Free;
      END;
      END;
    آخرین ویرایش به وسیله hassan p.b : چهارشنبه 18 تیر 1393 در 20:21 عصر

  4. #4

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    نمونه دیگه:
    کد HTML:
    var
      StrList: TStringList;
      Temp, TempX, TempY: String;
      I: Integer;
    begin
      if OpenDialog1.Execute then
      begin
        StrList:= TStringList.Create;
        try
          StrList.LoadFromFile(OpenDialog1.FileName);
          for I := 0 to StrList.Count - 1 do
          begin
            Temp:= StrList.Strings[i];
            TempX:= Copy(Temp, Pos('x', Temp)+2, Pos('y', Temp)-3);
            TempY:= Copy(Temp, Pos('y', Temp)+2, Length(Temp));
            ListBox1.Items.Add(TempX);
            ListBox2.Items.Add(TempY);
          end;
        finally
          StrList.Free;
        end;
      end;
    end;

  5. #5

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    امروز سعی کردم چنین کدی را بنویسم ولی برنامه کیج می زنه و قسمت رسم کار خواهد برد.
    کد HTML:
    var
    i,s,posx,posy,posz,posr:integer;
      x, y, a, b :real;
    locX,locy,locz,locr:string;
    Linetemp:string;
    F:textfile;
    a1,a2,a3,a4:real;
    begin
       form12.Memo1.Clear;
    if self.OpenDialog1.Execute then
      assignfile(F,opendialog1.FileName)
      else
      exit;
    reset(F);
       locx:='0';
       locy:='0';
       locz:='0';
       locr:='0';
    while not eof(F) do
     begin
      Linetemp:=uppercase(Linetemp);
      readln(f,Linetemp);
      Linetemp:=uppercase(Linetemp);
      posx:=pos('X',Linetemp);
      posy:=pos('Y',Linetemp);
      posz:=pos('Z',Linetemp);
      posr:=pos('R',Linetemp);
      s:=length(Linetemp);
     //»ñÈ¡XÖá×ø±ê
     //showmessage(inttostr(posx));
    // tempY := Copy(temp2, Pos('Y',temp2),Pos('F', temp2) - 1);
     //showmessage(inttostr(s));
     //showmessage(Linetemp);
      if posx<>0 then
       begin
        locx:='';
        for i:=(posx+1) to (s-1) do
          begin
            if ( Linetemp[i]in['A'..'Z']) or (Linetemp[i] in ['a'..'z']) then
    
             break ;
             locx:=locx+Linetemp[i];
             //showmessage('LocX= '+locX);
    
          end;
       end
       else
        locX:=locx;
        self.ListBox1.Items.Add(locX);
      //»ñÈ¡YÖá×ø±ê
      if posy<>0 then
       begin
        locy:='';
        for i:=posy+1 to (s-1) do
          begin
            if ( Linetemp[i]in['A'..'Z']) or (Linetemp[i] in ['a'..'z']) then
             break ;
             locy:=locy+Linetemp[i];
             //showmessage('LocY= '+locy);
          end;
       end
       else
        locY:=locy;
        self.ListBox2.Items.Add(locY);
      //»ñÈ¡ZÖá×ø±ê
        if posz<>0 then
       begin
        locz:='';
        for i:=posz+1 to (s-1) do
          begin
            if ( Linetemp[i]in['A'..'Z']) or (Linetemp[i] in ['a'..'z']) then
             break ;
             locz:=locz+Linetemp[i];
             //showmessage('LocZ= '+locz);
          end;
       end
       else
         locZ:=locz;
       //Ôö¼Ó¼Ç¼
       if posr<>0 then
       begin
        locr:='';
        for i:=posr+1 to (s-1) do
          begin
            if ( Linetemp[i]in['A'..'Z']) or (Linetemp[i] in ['a'..'z']) then
             break ;
             locr:=locr+Linetemp[i];
             //showmessage('LocZ= '+locz);
          end;
       end
       else
         locR:=locr;
         self.ListBox3.Items.Add(locR);
       {  if (locx<>'0')or(locx<>'') then
       //begin
       self.Memo1.Lines.Add('X='+locx+' ');
       //end
       //else
         if (locy<>'0')or(locy<>'') then
       //begin
       self.Memo1.Lines.Add('Y='+locy+' ');
       //end
       //else
         if (locz<>'0')or(locz<>'') then
       //begin
       self.Memo1.Lines.Add('Z='+locz+' ');
       //end
       //else
         if (locr<>'0')or(locr<>'') then
       //begin
       self.Memo1.Lines.Add('R='+locz+' ');
       //end
       //else }
       self.Memo1.Lines.Add('X='+locx+' '+'Y'+locy+' '+'Z'+locz+' '+'R'+locr);
      // showmessage(locx);
       a1:=Round(strtofloat(locx));
       a2:=Round(strtofloat(locy));
       //form12.Image1.Canvas.LineTo(Trunc(a1),Trunc(a2));
    
    
     Image1.Canvas.Pen.Color := RGB(255, 0, 0);
     Image1.Canvas.MoveTo(200, 200);
     //a := 0.02;   // اعداد متغییر
     //b := 0.05;
      // a1:=strtofloat(locx);
      // a2:=strtofloat(locy);
     //for i:=0 to 100000 do
     //begin
      //x := i/1000; // مقیاس ترسیم
      //y :=a+b*x;
     // image1.Canvas.LineTo(200+Trunc(a1), 200+Trunc(a2));
      Form12.PaintBox1.Canvas.LineTo(200+Trunc(a1), 200+Trunc(a2));
       locx:='';
       locy:='';
       locz:='';
       locr:='';
       //end;
    
     end;

  6. #6

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    در قسمت رسم کار وقتی اعداد جداشده به line نسبت داده میشه کامپایلر با دیدن اعداد اعشار و منفی خطا میده بنابراین مجبور به استفاده از دستور Trunc شدم.
    مثلا دو ضمیمه زیر را می خواهیم خوانده و بعد جداسازی رسم نماییم.
    شاید با دستور poly line بهتر بشه نمی دانم.
    فایل های ضمیمه فایل های ضمیمه

  7. #7

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    با این کدها مقادیر عددی کامل جدامیشه ولی مشخص نیست که کدام مقدار مربوط به چیه و در هم همه جداسازی می شونند و سرعت کار هم بسیار مناسب است، فقط بعضی مواقع در فاصله و ممیز اشتباه می کنه:
    کد HTML:
    const
      CS_0123456789 = '-.0123456789';
    var
      I,J: INTEGER;
      s,temp,temp1,temp2, tempx, tempy: string;
      // nums : array of Int64;
      StrList: TStringList;
      a1,a2,a3,a4,a5,a6,a7,a8,a9,a10:Integer;
    begin
       ListBox1.Clear;
       ListBox2.Clear;
    
      if OpenDialog1.Execute then
      begin
        StrList := TStringList.Create;
        try
          StrList.LoadFromFile(OpenDialog1.FileName);
          form8.Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
          for I := 0 to StrList.Count - 1 do
          begin
            Temp := StrList.Strings[I];
            edit1.Text:=uppercase(temp);
            J := 0;
           /// Edit1.Text := 'x-9.00007 y7.7 r4.00009';
      while J < Length(Temp) do
      begin
        Inc(J);
        if (Pos(Temp[J], CS_0123456789) > 0) then
        begin
          s := '';
          while (J < Length(temp)) and (Pos(temp[J], CS_0123456789) > 0) do
          begin
            s := s + temp[J];
            Inc(J);
          end;
          //showmessage(s);
          //
          // SetLength(nums, Length(nums) + 1);
          // nums[High(nums)] := StrToInt64Def(s, 0);
          //
          // form7.RichEdit1.Lines.Text:=s;
          Form8.ListBox1.Items.Add(s);
    
        end;
      end;
    
    
    
            //////////////////////////////
    
          END;
        finally
          StrList.Free;
        END;
      END;
    آخرین ویرایش به وسیله hassan p.b : جمعه 20 تیر 1393 در 18:33 عصر

  8. #8

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    لطفا یاردم کنید منظور کمک هست
    مرسی

  9. #9

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    سلام
    اگه می خواهید فایلهای cnc را بنویسید و بخونید ، lazarus یک کتابخانه داره به نام fpvectorial

  10. #10

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    مرسی آیا میشه از آن در دلفی استفاده کرد فایل ها هم جی کد هستند من لازاروس بلد نیستم میشه توضیح بدید
    البته جداسازی مقادیر هم برام مهمه می خواهم یکبار این مساله را حل کنم و هرجا لازمم شد بتوانم درست اینکار را انجام بدهم.
    ممنون

  11. #11

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    لطفا مثال را ببینید این کار من نیست و سورس ندارم
    فایل های ضمیمه فایل های ضمیمه

  12. #12

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    نقل قول نوشته شده توسط hassan p.b مشاهده تاپیک
    مرسی آیا میشه از آن در دلفی استفاده کرد فایل ها هم جی کد هستند من لازاروس بلد نیستم میشه توضیح بدید
    البته جداسازی مقادیر هم برام مهمه می خواهم یکبار این مساله را حل کنم و هرجا لازمم شد بتوانم درست اینکار را انجام بدهم.
    ممنون
    خودم میدونم جی کد cnc هستند. حالا اگه نشه مستقیما در دلفی استفاده کرد میشه نمونه کدها را با تغییر کمی به دلفی تبدیل کرد
    این هم سایتش:
    http://wiki.lazarus.freepascal.org/fpvectorial

  13. #13

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    Introduction

    FPVectorial offers support to read, modify and write vectorial images.
    Its counterpart library is fcl-image, which works with raster images. FPVectorial comes with a unit which allows to draw a vectorial image to a TFPCustomCanvas, but no routines are provided to convert raster images to vectorial images.
    Download

    fpvectorial comes in the Lazarus SVN, in the directory components/fpvectorial:
    svn co http://svn.freepascal.org/svn/lazarus/trunk/components/fpvectorial fpvectorial
    Downloading the fpvviewer project:
    svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/applications/fpvviewer fpvviewer
    Current file list

    FPVectorial is located in Free Pascal 2.3.1+ in the directory fpc/packages/fpvectorial/src
    The central unit is fpvectorial.
    Readers for various image formats
    pdfvectorialreader - Read support for PDF files, supports compression, only reads the first page
    avisocncgcodereader - Read support for the G-Code from the Aviso CNC machine
    cdrvectorialreader - Initial work of a reader support for Corel Draw CDR files
    dxfvectorialreader - Read support for DXF, the Drawing eXchange Format utilized by the AutoCAD
    svgvectorialreader - Read support for SVG
    epsvectorialreader - Read support for Encapsulated PostScript
    Writers for various image formats
    avisocncgcodewriter - Write support for the G-Code from the Aviso CNC machine
    svgvectorialwriter - Write support for SVG. The most advanced writer at the moment. Supports lines, curves and text. Supports pen color and width.
    Other units
    fpvtocanvas - Converts a vectorial document to a TFPCustomCanvas descendent (like TCanvas). Essentially converts the vectorial image to a raster image
    fpvutils - Utility functions which don't belong to fpvectorial.pas or that would bring unwanted dependencies to it. Color conversion functions.
    pdfvrlexico, pdfvrsemantico, pdfvrsintatico, avisozlib - Other units from the PDF reader, don't use directly
    Formats

    PDF
    The PDF format is developed by Adobe (tm) and it is fully documented. Inside, PDF is simply text, so it is rather easy to parse, but parts of this text are usually can be compressed.
    Link to the PDF Reference: http://www.adobe.com/devnet/pdf/pdf_reference.html
    CorelDraw
    Corel does not release public documentation for its CorelDraw file format. Any information about this format depends on reverse engineering and guessing. The format is binary and consists of a tree of chunks.
    See also fpvectorial#fpcorelexplorer
    SVG
    Scalable Vectorial Graphics (SVG) is a standard from W3C for vectorial graphics. It is the native format of Inkscape and stores its data as a single, uncompressed XML file with the extension ".svg".
    Link to the specification: http://www.w3.org/TR/SVG/
    A very serious shortcoming in SVG is that it does not allow real world units to be specified in the drawing routines, only pixel values accepted, which makes it impossible to have a document with real world units. This can be worked around by simply hardcoding to a fixed DPI resolution, which is 90 DPI for Inkscape. Read more here:
    http://stackoverflow.com/questions/1346922/svg-and-dpi-absolute-units-and-user-units-inkscape-vs-firefox-vs-imagemagick
    http://www.inkscapeforum.com/viewtopic.php?f=16&t=5904
    http://www.inkscapeforum.com/viewtopic.php?f=16&t=3700&p=17179&hilit=units+path #p17179
    Following Inkscape and the Opera Browser, FPVectorial also hardcodes to 90 DPI.
    As of February 2014 support for SVG is partial.
    DXF
    The Drawing eXchange Format from Autodesk AutoCAD. This format is documented, but the quality of the documentation is rather low, lacking adequate explanations.
    The format itself is rather simple, composed by text. Each unit is composed of two lines, the first one being a number describing the type of data and then another line with the value itself, which might be text or a number.
    The most common problem in other DXF reading libraries is that they don't support the actual DXF writen by newer versions of AutoCAD. This is not the case with fpvectorial, which was tested with AutoCAD 2000 and also the previous simpler formats.
    Link to the documentation:
    http://www.autodesk.com/techpubs/autocad/acad2000/dxf/
    The software fpvviewer can be utilized to show the internal structure of a DXF file. This software can be found in the lazarus-ccr svn in applications/fpvviewer. More info here: fpvectorial#fpvviewer
    PostScript
    PostScript is a graphics drawing programming language and fpvectorial has an interpreter which can execute PostScript and convert its commands into its internal format. This is done by reader modules, for example epsvectorialreader. The interpreter is separated into a Tokenizer and an Executer. The tokens are classified into 3 types: Procedures, ExpressionTokens and Comments. Procedures are inside a {..} block in PostScript and in FPVectorial they are not tokenezed in the first pass, but instead on the first usage. The entire document is tokenized in one run, before executing the tokens, except for the procedures. The PostScript interpreter contains a Stack and a lookup Dictionary, as specified in PostScript.
    PostScript can be embedded into various formats, and the interpreter currently supports the EPS format.
    References:
    http://en.wikipedia.org/wiki/Encapsulated_PostScript
    http://partners.adobe.com/public/developer/en/ps/PLRM.pdf
    LAS
    LAS is geospatial data encoded in the ASPRS LASer (LAS) file format, which exists in versions 1.0, 1.1, 1.2, 1.3 and 1.4. Version 2.0 does not yet exist as of December 2011.
    References:
    http://en.wikipedia.org/wiki/LibLAS
    http://www.asprs.org/a/society/committees/lidar/lidar_format.html
    http://trac.liblas.org/wiki/Software
    http://www.cs.unc.edu/~isenburg/lastools/
    http://www.fugroviewer.com/
    Example las file: www.appliedimagery.com/downloads/sampledata/Serpent%20Mound%20Model%20LAS%20Data.las
    Specification docs up to 1.3: http://www.asprs.org/a/society/committees/standards/lidar_exchange_format.html
    Specification for 1.4: http://www.asprs.org/Press-Releases/LAS-1-4-Draft-Specification-Released-by-ASPRS.html
    Types of data in FPVectorial

    FPVectorial holds lists of three types of objects: paths, text and entities.
    Essentially paths are sequences of points, through which run lines and bezier curves. A path can be a line, a bezier, a polyline, a polybezier or any combination of these elements. The main characteristic of paths is that they can be utilized to guide a milling machine, also known as CNC machine, into physically executing the drawing. Before being able to execute a drawing which contains either text or entities in a CNC machine, these items need to be converted to paths.
    Text, just like the name says are strings drawn with fonts.
    Entities are things like circles, arcs, ellipses, rotated ellipses, etc.
    Usage examples

    Format conversion
    This example loads a PDF, converts it to G-Code and writes the G-Code to a TStrings descendent
    uses
    fpvectorial, pdfvectorialreader, avisocncgcodewriter;

    var
    Vec: TvVectorialDocument;
    begin
    if dialogoAbrir.Execute() then
    begin
    Vec := TvVectorialDocument.Create;
    try
    Vec.ReadFromFile(dialogoAbrir.FileName, vfPDF);
    Vec.WriteToStrings(synCodigo.Lines, vfGCodeAvisoCNCPrototipoV5);
    finally
    Vec.Free;
    end;
    end;
    end;
    Adding paths, bezier lines and text
    This example shows how to add various elements.
    {
    Author: Felipe Monteiro de Carvalho

    License: Public Domain
    }
    program fpvwritetest;

    {$mode objfpc}{$H+}

    uses
    fpvectorial, svgvectorialwriter;

    const
    cFormat = vfSVG;
    cExtension = '.svg';
    var
    VecDoc: TvVectorialDocument;
    Vec: TvVectorialPage;
    begin
    VecDoc := TvVectorialDocument.Create;
    try
    Vec := VecDoc.AddPage();
    // All documents are 10cm x 10cm
    Vec.Width := 100;
    Vec.Height := 100;

    // ...

    // multi_test_1 Combines various elements
    Vec.Clear;
    Vec.StartPath(0, 20);
    Vec.AddLineToPath(30, 30);
    Vec.EndPath();
    Vec.StartPath(0, 0);
    Vec.AddLineToPath(100, 0);
    Vec.AddLineToPath(100, 100);
    Vec.AddLineToPath(0, 100);
    Vec.AddLineToPath(0, 0);
    Vec.EndPath();
    Vec.StartPath(0, 0);
    Vec.AddLineToPath(10, 10);
    Vec.AddBezierToPath(10, 20, 20, 20, 20, 10);
    Vec.AddLineToPath(30, 0);
    Vec.EndPath();
    Vec.AddText(10, 10, 0, '10,10 Some text in english.');
    Vec.AddText(20, 20, 0, '20, 20 Mówić, cześć, Włosku, Parabéns.');
    Vec.AddText(30, 30, 0, '30, 30 森林,是一个高密');
    VecDoc.WriteToFile('multi_test_1' + cExtension, cFormat);
    finally
    VecDoc.Free;
    end;
    end.
    And here is the output of this example when rendered by the Opera Browser:

    Adding Aligned Coordinates
    One can either add horizontal coordinates:
    Vec.AddAlignedDimension(Make2DPoint(100, 50), Make2DPoint(200, 100), Make2DPoint(100, 150), Make2DPoint(200, 150));

    Or add vertical coordinates:
    Vec.AddAlignedDimension(Make2DPoint(50, 250), Make2DPoint(100, 200), Make2DPoint(150, 250), Make2DPoint(150, 200));

    Rendering the image into a TCanvas
    To render a vectorial image into a TCanvas or TFPCustomCanvas use the unit fpvtocanvas and its routines:
    unit fpvtocanvas;
    //..
    {@@
    This function draws a FPVectorial vectorial image to a TFPCustomCanvas
    descendent, such as TCanvas from the LCL.

    Be careful that by default this routine does not execute coordinate transformations,
    and that FPVectorial works with a start point in the bottom-left corner, with
    the X growing to the right and the Y growing to the top. This will result in
    an image in TFPCustomCanvas mirrored in the Y axis in relation with the document
    as seen in a PDF viewer, for example. This can be easily changed with the
    provided parameters. To have the standard view of an image viewer one could
    use this function like this:

    DrawFPVectorialToCanvas(ASource, ADest, 0, ASource.Height, 1.0, -1.0);
    }
    procedure DrawFPVectorialToCanvas(ASource: TvVectorialPage;
    ADest: TFPCustomCanvas;
    ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
    And below an example taken from lazarus-ccr/application/fpvviewer
    uses fpvtocanvas;

    procedure TfrmFPVViewer.btnVisualizeClick(Sender: TObject);
    const
    FPVVIEWER_MAX_IMAGE_SIZE = 1000;
    FPVVIEWER_MIN_IMAGE_SIZE = 100;
    FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS = 100;
    var
    Vec: TvVectorialDocument;
    CanvasSize: TPoint;
    begin
    // First check the in input
    //if not CheckInput() then Exit;

    notebook.PageIndex := 0;

    Drawer.Clear;

    Vec := TvVectorialDocument.Create;
    try
    Vec.ReadFromFile(editFileName.FileName);

    // We need to be robust, because sometimes the document size won't be given
    // also give up drawing everything if we need more then 4MB of RAM for the image
    // and also give some space in the image to allow for negative coordinates
    if Vec.Width * spinScale.Value > FPVVIEWER_MAX_IMAGE_SIZE then CanvasSize.X := FPVVIEWER_MAX_IMAGE_SIZE
    else if Vec.Width < FPVVIEWER_MIN_IMAGE_SIZE then CanvasSize.X := Drawer.Width
    else CanvasSize.X := Round(Vec.Width * spinScale.Value);
    if CanvasSize.X < Drawer.Width then CanvasSize.X := Drawer.Width;

    if Vec.Height * spinScale.Value > FPVVIEWER_MAX_IMAGE_SIZE then CanvasSize.Y := FPVVIEWER_MAX_IMAGE_SIZE
    else if Vec.Height < FPVVIEWER_MIN_IMAGE_SIZE then CanvasSize.Y := Drawer.Height
    else CanvasSize.Y := Round(Vec.Height * spinScale.Value);
    if CanvasSize.Y < Drawer.Height then CanvasSize.Y := Drawer.Height;

    Drawer.Drawing.Width := CanvasSize.X;
    Drawer.Drawing.Height := CanvasSize.Y;
    Drawer.Drawing.Canvas.Brush.Color := clWhite;
    Drawer.Drawing.Canvas.Brush.Style := bsSolid;
    Drawer.Drawing.Canvas.FillRect(0, 0, Drawer.Drawing.Width, Drawer.Drawing.Height);
    DrawFPVectorialToCanvas(
    Vec.GetPage(0),
    Drawer.Drawing.Canvas,
    FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS,
    Drawer.Drawing.Height - FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS,
    spinScale.Value,
    -1 * spinScale.Value);
    Drawer.Invalidate;
    finally
    Vec.Free;
    end;
    end;
    Coordinates in FPVectorial
    It is important to note that the coordinates in FPVectorial are different from the ones in TCanvas. TCanvas uses the coordinates from the Windows API, with the origin in the top-left corner and with the X axis growing to the right and the Y axis growing to the bottom. FPVectorial, on the other hand, uses the coordinates which are commonly used in drawing programs, such as CAD software, Inkscape, the Mac OS X APIs (Carbon and Cocoa), etc. In FPVectorial the origin is in bottom-left part of the document. The X axis grows to the right and the Y axis to the top.

    Because of these differences, one should be careful when converting coordinates between TCanvas and FPVectorial. To convert coordinates between TCanvas and FPVectorial, one needs the height of the Canvas. The following routine from the unit fpvutils can be used to execute this conversion:
    {@@ Converts the coordinate system from a TCanvas to FPVectorial
    The basic difference is that the Y axis is positioned differently and
    points upwards in FPVectorial and downwards in TCanvas.
    The X axis doesn't change. The fix is trivial and requires only the Height of
    the Canvas as extra info.
    }
    function CanvasCoordsToFPVectorial(AY: Integer; AHeight: Integer):
    Integer; inline;
    begin
    Result := AHeight - AY;
    end;
    And there is also a difference regarding the text positioning. In TCanvas.TextOut the text is positioned based on the top-left coordinates of the text area. In fpvectorial it is based on the bottom-left. Again, there is a convenient routine in the unit fpvutils to convert between the coordinate systems:
    {@@
    LCL Text is positioned based on the top-left corner of the text.
    Besides that, one also needs to take the general coordinate change into account too.

    @param ACanvasHeight Should receive TCanvas.Height
    @param ATextHeight Should receive TFont.Size
    }
    function CanvasTextPosToFPVectorial(AY: Integer; ACanvasHeight, ATextHeight: Integer): Integer;
    begin
    Result := CanvasCoordsToFPVectorial(AY, ACanvasHeight) - ATextHeight;
    end;
    More examples
    Please see in the FPC repository: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fpvectorial/examples/
    fpvviewer

    The Free Pascal Vectorial Viewer is a sample application which implements a simple CAD viewer using fpvectorial.
    Besides being able to visualize vectorial drawings, this software can also help in exploring the internal structure of DXF file:

    It's source code can be found in the Lazarus-CCR in the directory application/fpvviewer
    Link to download the Lazarus-CCR from subversion:
    svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr lazarus-ccr
    Contour line generation
    fpvviewer can generate contour lines from .raw files. These files can be generated with fpv3dviewer


    FPVectorial Debug Tokens
    FPVViewer can be utilized to see the internal debug tokens from fpvectorial, see:

    fpcorelexplorer

    An application was developed for helping studying the CDR file format. At the moment this application can identify the version of CorelDraw files. It is located in fpctrunk/packages/fpvectorial/examples/fpcorelexplorer.lpi

    fpv3dviewer

    One of the examples of fpvectorial located in lazarus/components/fpvectorial/examples/fpv3dviewer.lpi is a 3D viewer.

    Articles about fpvectorial

  14. #14

    نقل قول: خواندن فایل متنی و جداسازی مقادیر عددی از آن (وقرار دادن در جدول و یا لیست باکس)

    حالا چطور این و تو دلفی معنی کنیم!
    چون مانند یک کلاس است که تو دلفی نیست!
    فایل های ضمیمه فایل های ضمیمه
    آخرین ویرایش به وسیله hassan p.b : جمعه 07 شهریور 1393 در 16:19 عصر

تاپیک های مشابه

  1. مشکل با خواندن فایل متنی
    نوشته شده توسط saeedvir در بخش برنامه نویسی در 6 VB
    پاسخ: 1
    آخرین پست: جمعه 23 بهمن 1388, 18:31 عصر
  2. سوال: خواندن فایل متنی و ذخیره آن
    نوشته شده توسط niko2008 در بخش برنامه نویسی در 6 VB
    پاسخ: 31
    آخرین پست: سه شنبه 15 دی 1388, 23:56 عصر
  3. خواندن فایل متنی
    نوشته شده توسط tefos666 در بخش C#‎‎
    پاسخ: 2
    آخرین پست: سه شنبه 10 آذر 1388, 10:14 صبح
  4. خواندن فایل متنی (فوری)
    نوشته شده توسط هانی هاشمی در بخش VB.NET
    پاسخ: 4
    آخرین پست: پنج شنبه 25 اسفند 1384, 11:20 صبح
  5. مشکل در خواندن فایل متنی
    نوشته شده توسط علی ارجمندی در بخش VB.NET
    پاسخ: 2
    آخرین پست: سه شنبه 09 اسفند 1384, 08:22 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •