Problems in CAD Editor demo

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Problems in CAD Editor demo

Post by AlexUS » 05 Dec 2006, 14:49

I downloaded the Editor demo example application and have a few questions
I make dwg-file in AutoCad 2005 which consists of 3 lines (not polylines and it doesn’t matter how many lines) and then I open thi file in Editor. I’ve added two lines in your unit sgSManager that is placed between “//****”:

Code: Select all

…
          <b>if</b> FSelectedObject <> <b>nil then
          begin</b>
            Pos := InList(FSelectedObject);
            <b>if</b> Pos < 0 <b>then
              begin</b>
                FEntities.Add(FSelectedObject);
                //****
                  TsgDXFEntity(FSelectedObject).SetLWeight(200);
                  TsgDXFEntity(FSelectedObject).Draw;
                //****
              <b>end</b>
…
As I understand program must set line weight equal 200 to selected entity, but in fact it makes line weight to last created in Auto CAD line (and it’s doesn’t matter which line I choose). But DrawMarker correctly makes small rectangles in chosen line points!
Then if I make zoom of image selected line becomes thick and other lines become the same thickness that they had in Auto CAD.
There is no such a problem if dwg-file comprises any other entities except lines.
Can you help me to solve this problem?

And it’s not only problem that I found in this program that I need your help to solve it.

If I call SetLWeight of any Entity after that Marker becomes the same thickness as I’ve just set to Entity (it’s not important but I hope useful for you to know)

How can I get weight of entity line (there is no GetLWeight)?

When I work in mmSelect mode I can select rectangle only if I hit top or right side of this rectangle. And what about bottom and left sides?

I want to turn on the Snap Made (like in your CADImporterVCL Viewer demo). Is it possible to make in Editor? It looks like there is not enough methods in Editor for it.

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 05 Dec 2006, 16:08

Hi!
And one more thing:
Editor has limitations in zooming in, and after far zoom out (into point) it's not possible to zoom in the TsgImage.
Are there any program limitations in zooming and how can I fix it in program?

Thank you for your answers (I hope it very much)

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 06 Dec 2006, 15:55

Dear AlexUS!
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">As I understand program must set line weight equal 200 to selected entity, but in fact it makes line weight to last created in Auto CAD line (and it’s doesn’t matter which line I choose). But DrawMarker correctly makes small rectangles in chosen line points!
Then if I make zoom of image selected line becomes thick and other lines become the same thickness that they had in Auto CAD.
There is no such a problem if dwg-file comprises any other entities except lines.
Can you help me to solve this problem?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We made some tests with the following library: http://www.cadsofttools.com/download/cadimportvcl.zip We failed to repeat this bug. If possible, please describe in detail your actions.
BTW: CADImportVCL beta contains updated Editor demo. The package is available at: http://www.cadsofttools.com/download/CA ... 010906.zip
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">If I call SetLWeight of any Entity after that Marker becomes the same thickness as I’ve just set to Entity (it’s not important but I hope useful for you to know)<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It is necessary to make some changes to procedure <b>DrawMarker</b>:

Code: Select all

  <b>procedure</b> DrawMarker(APoint: TPoint);
  <b>var</b>
    vPrevWidth: Integer;
  <b>begin</b>
    vPrevWidth := FsgImage.Canvas.Pen.Width;
    FsgImage.Canvas.Pen.Width := 1;
    vRect.Top := APoint.Y + BoxSize;
    vRect.Left := APoint.X - BoxSize;
    vRect.Bottom := APoint.Y - BoxSize;
    vRect.Right := APoint.X + BoxSize;
    FsgImage.Canvas.Rectangle(vRect.Left, vRect.Top, vRect.Right, vRect.Bottom);
    FsgImage.Canvas.Pen.Width := vPrevWidth;
  <b>end</b>;
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">How can I get weight of entity line (there is no GetLWeight)?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It is necessary to use function <b>GetThickness</b>.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I want to turn on the Snap Made (like in your CADImporterVCL Viewer demo). Is it possible to make in Editor? It looks like there is not enough methods in Editor for it.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Snap Mode was created according to Viewer demo. That is why it is necessary to bring "Snap Mode" functionality to Editor demo "manually" from the one demo to another.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Editor has limitations in zooming in, and after far zoom out (into point) it's not possible to zoom in the TsgImage.
Are there any program limitations in zooming and how can I fix it in program?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
As a demo <b>Editor</b> has restricted functionality. Very soon we plan to release <b>CADImportVCL 6</b>. And we prepare a separate product <b>Editor for CADImportVCL</b>. It is based on <b>ABViewer</b> sources (<b>ABViewer</b> is available at: http://www.cadsofttools.com/download/abviewer.zip) and it is delivered on a request to info@cadsofttools.com.

Sergey.

please post questions to the forum or write to support@cadsofttools.com

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 06 Dec 2006, 18:16

Dear Sergey!


quote:
We made some tests with the following library: http://www.cadsofttools.com/download/cadimportvcl.zip We failed to repeat this bug. If possible, please describe in detail your actions.

1. I make DWG-file which consists for example of 3 lines (but I use only lines).
2. As I told I add 2 lines in unit sgSManager

Code: Select all

  <b>if</b> FSelectedObject <> <b>nil then
  begin</b>
    Pos := InList(FSelectedObject);
    <b>if</b> Pos < 0 <b>then
    begin</b>
      FEntities.Add(FSelectedObject);
      //****
      TsgDXFEntity(FSelectedObject).SetLWeight(200);
      TsgDXFEntity(FSelectedObject).Draw;
      //****
    <b>end</b>
It means that if I choose line it has to become LineWeight=200
3. I open dwg-file in Editor (by the way I downloaded it's new version thank you very much)
4. In mmSelect mode I click on first or second line. Last created in AutoCAD line become thick but on the chosen line points there are smal rectangles drawn by DrawMarker
5. I make zoom of Image (zoom in or zoom out doesn't matter). And chosen line becomes thick and last created line become it's real LineWeight (=1)

If I make the same but dwg-file consists of other entities with lines there is no such problem

When I work in mmSelect mode I can select rectangle only if I hit top or right side of this rectangle. And what about bottom and left sides?

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 06 Dec 2006, 18:21

I'm sorry for those empty quotes.

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 06 Dec 2006, 19:09

I try to change direction of lines in Editor. Compiler doesn't find mistakes in tis code:

Code: Select all

  procedure ChangeLineDir (LineEnt:Pointer);
   var TmpPoint:TFPoint;
   begin
     TmpPoint := TsgDXFLine(LineEnt).Point;
     TsgDXFLine(LineEnt).Point := TsgDXFLine(LineEnt).Point1;
     TsgDXFLine(LineEnt).Point1:=TmpPoint;
   end;
But when I try to make the same with PolyLine it compiler says that Points is read-only property:

Code: Select all

procedure ChangePolyLineDir (PolyLineEnt:Pointer);
   var TmpPoint:TFPoint;
       I:integer;

   begin
     for I:=0 to ((TsgDXFPolyLine(PolyLineEnt).PolyPoints.Count-1) div 2) do
      begin
        TmpPoint := TsgDXFPolyLine(PolyLineEnt).Points[I];
        TsgDXFPolyLine(PolyLineEnt).Points[I] := TsgDXFPolyLine(PolyLineEnt).Points[round(I*2)];
        TsgDXFPolyLine(PolyLineEnt).Points[round(I*2)] := TmpPoint;
      end;
   end;// ChangePolyLineDir
How can I change coordinates of points in PolyLine?
If I try to change directly points[].X compiler says the same that points is read-only property.

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 07 Dec 2006, 16:00

Dear AlexUS,

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">2. As I told I add 2 lines in unit sgSManager

Code: Select all

<b>if</b> FSelectedObject <> <b>nil then
begin</b>
Pos := InList(FSelectedObject);
<b>if</b> Pos < 0 <b>then
  begin</b>
    FEntities.Add(FSelectedObject);
    //****
    TsgDXFEntity(FSelectedObject).SetLWeight(200);
    TsgDXFEntity(FSelectedObject).Draw;
    //****
  <b>end</b>
It means that if I choose line it has to become LineWeight=200<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

According to AutoCAD documentation LineWeight is represented by 100th of millimeteres.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">4. In mmSelect mode I click on first or second line. Last created in AutoCAD line become thick but on the chosen line points there are smal rectangles drawn by DrawMarker
5. I make zoom of Image (zoom in or zoom out doesn't matter). And chosen line becomes thick and last created line become it's real LineWeight (=1)<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
We do not recommend to use the following method:

Code: Select all

  TsgDXFEntity(FSelectedObject).Draw;
Please use the following way for redrawing some separate entities (it is necessary to get access to the protected methods):
<b>Unit sgSManager.pas</b>

Code: Select all

<b>implementation

uses</b> fEntityInspector, fMain;

<b>type</b>
  TsgDXFImageAccess = <b>class</b>(TsgDXFImage);
  TsgDXFEntityAccess = <b>class</b>(TsgDXFEntity);

...
          <b>if</b> FSelectedObject <> <b>nil then
          begin</b>
            Pos := InList(FSelectedObject);
            <b>if</b> Pos < 0 <b>then
            begin</b>
              FEntities.Add(FSelectedObject);
              TsgDXFEntity(FSelectedObject).SetLWeight(200);
              TsgDXFEntityAccess(FSelectedObject).Invoke(TsgDXFImageAccess(FsgImage.Picture.Graphic).Converter,
                TsgDXFImageAccess(FsgImage.Picture.Graphic).DrawEntity);
            <b>end</b>
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">When I work in mmSelect mode I can select rectangle only if I hit top or right side of this rectangle. And what about bottom and left sides?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Editor is a demo application. It just gives a main idea of the editing functionality.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I try to change direction of lines in Editor. Compiler doesn't find mistakes in tis code:

Code: Select all

  <b>procedure</b> ChangeLineDir (LineEnt:Pointer);
   <b>var</b> TmpPoint:TFPoint;
   <b>begin</b>
     TmpPoint := TsgDXFLine(LineEnt).Point;
     TsgDXFLine(LineEnt).Point := TsgDXFLine(LineEnt).Point1;
     TsgDXFLine(LineEnt).Point1:=TmpPoint;
   <b>end</b>;
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It is necessary to call <b>Converters.Loads(A_Your_Entity)</b> after changing entities' proprties:

Code: Select all

<b>     FConverter.Loads(TsgDXFLine(LineEnt))</b>

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">But when I try to make the same with PolyLine it compiler says that Points is read-only property:

Code: Select all

<b>procedure</b> ChangePolyLineDir (PolyLineEnt:Pointer);
   <b>var</b> TmpPoint:TFPoint;
       I:integer;
   <b>begin
     for</b> I:=0 <b>to</b> ((TsgDXFPolyLine(PolyLineEnt).PolyPoints.Count-1) <b>div</b> 2) <b>do
      begin</b>
        TmpPoint := TsgDXFPolyLine(PolyLineEnt).Points[I];
        TsgDXFPolyLine(PolyLineEnt).Points[I] := TsgDXFPolyLine(PolyLineEnt).Points[round(I*2)];
        TsgDXFPolyLine(PolyLineEnt).Points[round(I*2)] := TmpPoint;
      <b>end</b>;
   <b>end</b>;// ChangePolyLineDir
How can I change coordinates of points in PolyLine?
If I try to change directly points[].X compiler says the same that points is read-only property.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
It is forbidden to change Points and Polypoints of the TsgDXFPolyline entity (and its descendants). But if you need to change polyline's vertexes it is necessary to change Vertexes (i.e. TsgDXFPolyline.Entities) and then to call Converters.Loads(A_Polyline).

Sergey.


please post questions to the forum or write to support@cadsofttools.com

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 08 Dec 2006, 13:29

Hi, Segey!
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">

Code: Select all

TsgDXFEntityAccess(FSelectedObject).Invoke(TsgDXFImageAccess(FsgImage.Picture.Graphic).Converter,
                TsgDXFImageAccess(FsgImage.Picture.Graphic).DrawEntity);          
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Thank you! It works!

DarwMarker i had corrected by myself earlier and I just wanted you to know this bug.


<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">It is necessary to call Converters.Loads(A_Your_Entity) after changing entities' proprties:


FConverter.Loads(TsgDXFLine(LineEnt))<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

About that i still don't understand. You said that it's forbidden to change Points in Line and PolyLine but it's possible. I can't even run my programm because compiler says that these properties are read-only.
What do you mean when you say:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
it is necessary to change Vertexes (i.e. TsgDXFPolyline.Entities) and then to call Converters.Loads(A_Polyline).
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
How to make it?


Thank you, Sergey, for your answers, you greatly help me in using your component.

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 08 Dec 2006, 15:13

Hi Alex,
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">It is necessary to call Converters.Loads(A_Your_Entity) after changing entities' proprties:

FConverter.Loads(TsgDXFLine(LineEnt))<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

About that i still don't understand. You said that it's forbidden to change Points in Line and PolyLine but it's possible. I can't even run my programm because compiler says that these properties are read-only.
What do you mean when you say:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
it is necessary to change Vertexes (i.e. TsgDXFPolyline.Entities) and then to call Converters.Loads(A_Polyline).
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
How to make it?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Please find respective examples of changing entities in the <b>unit sgSManager</b>:

Code: Select all

<b>procedure</b> TsgSelectionManager.sgImageMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
<b>var</b>
...
<b>begin</b>
...
          <b>if</b> FSelectedObject <b>is</b> TsgDXFPolyline <b>then
          begin</b>
            vPoly := TsgDXFPolyline(FSelectedObject);
            <b>for</b> I := 0 <b>to</b> vPoly.Count - 1 <b>do</b>
              TsgDXFVertex(vPoly.Entities[I]).Point := MovePoint(TsgDXFVertex(vPoly.Entities[I]).Point);
...
Sergey.

please post questions to the forum or write to support@cadsofttools.com

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 11 Dec 2006, 12:37

Yes, now I see. Thank you, Sergey.

I've found one more bug in your component: if i draw line in AutoCAD in direction from right to left i can't select it in mmSelect mode in Editor. If I draw line in direction from left to right - I can select line without any problems

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 11 Dec 2006, 15:02

Hello Alex,

Thank you for the remark. As we have mentioned in previous posts, <b>Editor</b> gives just general principles of the editing functionality. It is required to redevelop selecting methods to make <b>Editor</b> able to select lines drawn in both directions. We will take it into account in the future version of the library.

Sergey.

please post questions to the forum or write to support@cadsofttools.com

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 13 Dec 2006, 14:08

Dear Sergey!

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">I've found one more bug in your component: if i draw line in AutoCAD in direction from right to left i can't select it in mmSelect mode in Editor. If I draw line in direction from left to right - I can select line without any problems<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
I fixed this bug. In unit sgSManager find function TsgSelectionManager.IsPtOnTheLine(APoint, AStart, AnEnd: TPoint): Boolean;

there i've added following lines:

Code: Select all

      if AStart.Y = AnEnd.Y then
      begin
        if AStart.X <= AnEnd.X then
          if (CurPoint.Y = AStart.Y) and (CurPoint.X >= AStart.X) and (CurPoint.X <= AnEnd.X) then
            Result := true;

        if AStart.X > AnEnd.X then
          if (CurPoint.Y = AStart.Y) and (CurPoint.X >= AnEnd.X) and (CurPoint.X <= AStart.X) then
            Result := true;

        if AStart.Y <= AnEnd.Y then
          if (CurPoint.Y = AStart.Y) and (CurPoint.X > AStart.X) and (CurPoint.X < AnEnd.X) then
            Result := true;

      end
It seems that it works.

support
Posts: 3254
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 13 Dec 2006, 14:37

Dear Alex,

Thank you for the help! We will check your code certainly!

Sergey.

please post questions to the forum or write to support@cadsofttools.com

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 13 Dec 2006, 16:52

Hi, Sergey

I've already asked you about zooming in Editor.
I can't solve this problem.
In Editor there is the limitation of zooming in, but in Viewer this problem is apsent. I compare procudures OnMouseWheelUp in Editor and in Viewer and they are absolutly similar. I think that problem is in some differences of properties of sgPaintBox (in Viewer) and sgImage (in Editor).
Can you help me in solving of this problem?

AlexUS
Posts: 53
Joined: 05 Dec 2006, 14:44

Post by AlexUS » 13 Dec 2006, 17:11

Hi again.
I found.
It is necessarily to set the property IsBigScale=True;

Post Reply