Links with dotted line displayed solid when zoomed

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

Links with dotted line displayed solid when zoomed

Postby kokkoras » December 23rd, 2005, 11:16 pm

Problem:
Ok, the subject tells the story. Can anyone reproduce this? I can see dotted links only at 100%.


Suggestion:
I suggest that the default fill color for links should be dynamicaly set to the background color of the canvas.
The reason:
I am using a colored canvas. My links are with black line and white fill color. As a result the dotted line is paint in black and white; not in black + background of canvas. So the white is visible on by colored canvas.

I understand that this is due to the way links are created (closed polylines).

Question:
Is it possible to have links with no arrow head at all?

fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby elias » December 27th, 2005, 9:33 pm

Kokkoras:
1)Windows itself can't draw dotted lines if the width is bigger than 1. (At least if we are talking about windows 98, I think I heard that using XP this issue is solved. But... you could write a code that make that (or maybe find it at the Web)...

2)You may use these values for the links:
Code: Select all
  Brush.Color:=owner.color;   //the background color of simplegraph.
  Pen.Color:=666; //A kind of red
  Pen.Style:=psdot;   //lines dotted

or
Code: Select all
  Brush.Style:=bsClear; //So there will be not background color at all; maybe the best solution.
  Pen.Color:=666;
  Pen.Style:=psdot;


3)In procedure TGraphLink.DrawBody(Canvas: TCanvas); (It is inside SimpleGraph.pas)
if you delete this sentece
Code: Select all
if Kind <> lkUndirected then
  begin
    DrawArrow(EndPt, ArrowSize);
    if Kind = lkBidirected then
      DrawArrow(StartPt, -ArrowSize);
  end;

You won't see the arrow anymore; (just the line of the link).

Elías.
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby elias » December 27th, 2005, 9:41 pm

Kokkoras:
1)Windows itself can't draw dotted lines if the width is bigger than 1. (At least if we are talking about windows 98, I think I heard that using XP this issue is solved. But... you could write a code that make that (or maybe find it at the Web)...

2)You may use these values for the links:
Code: Select all
  Brush.Color:=owner.color;   //the background color of simplegraph.
  Pen.Color:=666; //A kind of red
  Pen.Style:=psdot;   //lines dotted

or
Code: Select all
  Brush.Style:=bsClear; //So there will be not background color at all; maybe the best solution.
  Pen.Color:=666;
  Pen.Style:=psdot;


3)In procedure TGraphLink.DrawBody(Canvas: TCanvas); (It is inside SimpleGraph.pas)
if you delete this sentece
Code: Select all
if Kind <> lkUndirected then
  begin
    DrawArrow(EndPt, ArrowSize);
    if Kind = lkBidirected then
      DrawArrow(StartPt, -ArrowSize);
  end;

You won't see the arrow anymore; (just the line of the link).

Elías.
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby kokkoras » December 27th, 2005, 11:23 pm

elias wrote:Kokkoras:
1)Windows itself can't draw dotted lines if the width is bigger than 1. (At least if we are talking about windows 98, I think I heard that using XP this issue is solved.


I am on XP. The width is always 1. I see no reason on zoom affecting the line width. It must be something else....

elias wrote:2)You may use these values for the links:
Code: Select all
  Brush.Color:=owner.color;   //the background color of simplegraph.
  Pen.Color:=666; //A kind of red
  Pen.Style:=psdot;   //lines dotted

or
Code: Select all
  Brush.Style:=bsClear; //So there will be not background color at all; maybe the best solution.
  Pen.Color:=666;
  Pen.Style:=psdot;



That's the temporary solution I gave (see my 1st post).


elias wrote:3)In procedure TGraphLink.DrawBody(Canvas: TCanvas); (It is inside SimpleGraph.pas)
if you delete this sentece
Code: Select all
if Kind <> lkUndirected then
  begin
    DrawArrow(EndPt, ArrowSize);
    if Kind = lkBidirected then
      DrawArrow(StartPt, -ArrowSize);
  end;

You won't see the arrow anymore; (just the line of the link).



Well, this one is a non-issue. TSimpleGraph already provides a setting for ...arrowless links. Silly me that didn't checked.

fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby elias » December 28th, 2005, 9:02 pm

1)Please put a Tshape in a empty form and play with the pen property. With my Delphi7 & W98 I cannot have a rectangle with dotted pen-style with a width bigger than 1. Dont'you?
POSIBLE SOLUTIONS:
I think Windows 98 haven't, but maybe Windows XP have a function for dotted-lines-widthed>1 but delphi yet calls the old one: Call it for yourself
Find an alternative Method in the Web and include it to your code
Make it yourself: Draw a little line 4 pixels long, let a space 4 pixels long... and again

2)I've written this(comments):
Code: Select all
procedure TGraphLink.DrawBody(Canvas: TCanvas);
var oldcolor:Tcolor;                                                //Declaring
  procedure DrawArrow(const Pt: TPoint; ArrowScale: Integer);
  var
    ArrowHeight: Integer;
    ArrowPts: array[1..4] of TPoint;
  begin
    if Owner.MarkerSize > Pen.Width then
      ArrowHeight := ArrowScale * Owner.MarkerSize
    else
      ArrowHeight := ArrowScale * Pen.Width;
    ArrowPts[1] := Pt;
    ArrowPts[2] := NextPointOfLine(Angle+Pi/6, Pt, ArrowHeight);
    ArrowPts[3] := NextPointOfLine(Angle, Pt, MulDiv(ArrowHeight, 2, 3));
    ArrowPts[4] := NextPointOfLine(Angle-Pi/6, Pt, ArrowHeight);
    Canvas.Polygon(ArrowPts);
  end;

begin
  oldcolor:=canvas.Brush.Color;  //'cause setting style clear, color resets(clWhite); so we put it inside oldcolor.
  canvas.brush.Style:=bsclear;                               //Brush style is bsClear now
  with StartPt do Canvas.MoveTo(X, Y);
  with EndPt do Canvas.LineTo(X,Y);
  canvas.Brush.Color:=oldcolor;  //...and setting brush, style resets (bsSolid again), in order to draw the arrow
  if Kind <> lkUndirected then
  begin
    DrawArrow(EndPt, ArrowSize);
    if Kind = lkBidirected then
      DrawArrow(StartPt, -ArrowSize);
  end;
end;//of the problem.


3)You are right... :)

PD If you find solution to 1) I'd like to know how you did; Thanks.
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby elias » December 28th, 2005, 9:08 pm

Ah; one thing; when you use the zoom at 200%, maybe in the properties the width is 1, but when painting the control is telling "width is 2"
elias
Senior Member
Senior Member
 
Posts: 90
Joined: November 8th, 2005, 12:09 pm
Location: Galicia, Spain

Postby kokkoras » December 28th, 2005, 11:12 pm

elias wrote:Ah; one thing; when you use the zoom at 200%, maybe in the properties the width is 1, but when painting the control is telling "width is 2"


ok, it seems logical to have this behaviour. Drawing the dotted line piece by piece in computationaly expensive. I can live without it. But I think that when zooming say at 200% then I should expect the dotten line to be like **00**00**00**00**00**00**00**00**00**00, while in 100% it should be like *0*0*0*0*0*0*0*0*0*0*0* The behaviour I described is followed in ACAD.

I mean both lines (***) and spaces (000) should be affected by the zoom functor. It seems that windows does not draw the lines this way, which I accept as I said above for computational efficiency.

Regarding TShape, I can reproduce what you said in D7Ent + WinXPPro.

It's easy to create a different lineDraw function but, IMHO, this should be left outside TSimpleGraph.


fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby Kambiz » December 29th, 2005, 8:36 am

Just for your information: the control doesn't increase the width of pen while zooming. It's the Windows mapping mode fault that causes dotted/dashed lines appear solid.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby kokkoras » December 29th, 2005, 11:17 am

Kambiz wrote:Just for your information: the control doesn't increase the width of pen while zooming. It's the Windows mapping mode fault that causes dotted/dashed lines appear solid.


Kambiz, thanks for the crarifcation. BTW, happy new year (I guess we are on the same calendar).

Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby Kambiz » December 31st, 2005, 2:25 pm

Thanks kokkoras. Happy New Year to you too.

Iranians use Persian Calendar.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 4 guests

cron