Q&A - Question

Drawing in the PaintShapeEvent [DK.Delphi.VCL]

Question
DamH asked on November 30, 2016, keyword: Developer Kernel
Under DK10 using the TGIS_LayerSHP object's OnPaintShape event I could draw an arrow on a line, as I had access to the TGIS_ViewerWnd object's Canvas property.

How every under DK11 the TGIS_ViewerWnd object's Canvas property is protected, even if I crack the TGIS_ViewerWnd object to get access to the Canvas property to draw the arrow it only draws for a second before disappearing.

How do I draw the arrow in DK11 after the Shape is drawn?
Answers
Tomasz Kosinski (TatukGIS) replied November 28, 2016
  1. You can just use a build in line style renderer to draw arrow! See: http://docs.tatukgis.com/DK11/doku.php?id=readme:v11.0:linesymbologyeditor
  2. We provided an abstract canvas which will work same way independent of actual renderer technology used (GDI, GDI+, DirectX etc.) and also will work exactly same way an all platforms

Sample custom drawing looks like

procedure TMyForm.doPaintShape( _sender : TObject; _shape : TGIS_Shape ) ;
var
  pt : TPoint ;
begin
  pt := GIS.MapToScreen( _shape.Centroid ) ;
  GIS.Renderer.CanvasDrawLine( pt.X,pt.Y, pt.X+10, pt.Y+10 );
  _shape.Draw();
end;


Or even a more secure way to attach always to a proper context

procedure TMyForm.doPaintShape( _sender : TObject; _shape : TGIS_Shape ) ;
var
  pt : TPoint ;
  rnd : TGIS_RendererAbstract ;
begin
  rnd := TGIS_RendererAbstract( _shape.Layer.Viewer.Ref.GetRenderContext ) ;
  pt := GIS.MapToScreen( _shape.Centroid ) ;
  rnd.CanvasDrawLine( pt.X,pt.Y, pt.X+10, pt.Y+100 );
  _shape.Draw();
end;

 

DamH replied November 28, 2016
Thanks that is a step in the right direction.

Can I get access to the Canvas' Handle to create a TGPGraphics object so that I can work with Graphics Paths and Matrix transformations.
Tomasz Kosinski (TatukGIS) replied November 30, 2016
We will consider to provide a way to get something like this. However it is not an easy task because canvas can be upon open pending operation, which is specially true for all DirectX based canvases..

Currenlty you can use CanvasSetTransformation / CanvasClearTransformationright. We have no plans to add paths etc, because drawing upon this event should be reduced only to very simple operations. We will definilty add to a future release CanvasDrawBitmap
If you would like to answer the question please Sign In.
*
*
Please review our recent Privacy Policy.
If you have any questions or requests, please contact us.
Rules
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
 
  1. Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
  2. Keep the content positive and professional.
  3. Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
  4. The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.