70001849 I would like to display entities after all the entities in ViewCS

Article 70001849
Type Wish
Product WebJS
Version 8005
Date Added 10/25/2020 12:00:00 AM
Fixed 8.8006.0.4 (10/27/2020 12:00:00 AM)
Submitted by Bogumil Styczen


I would like to draw and display entities after all the entities of the document have breen drawn in View Coordinating System.


In version 8006.0.4 a new AfterDrawInView event has been exported so the user is able to draw and display entities always on the top of the view, on the screen, on the selected print area and also on the selected printer paper. The AfterDrawInView event represents a user define function of type "AfterDrawInViewDelegate" that will be called just after all document entities are drawn.


On the following example we create a new solid colored rectangle with the width and the height of the canvas and on the bottom right corner
of the screen we create and display a text with text string "vdraw screen". Also if we call the printToImageData, we display and print a text on the bottom right
corner of the selected print window with the text string "vdraw printer window". And in the last case again in the print operation we create and and print another
text on the bottom right corner of the printer paper with the text string "vdraw printer paper".
NOTE both of the rectangle and the texts are not be added in the document entities and not be saved if we save the document.

 vdcanvas.AfterDrawInView = AfterDrawInView;// set the event in the initialize page load 
         function AfterDrawInView(e) {
           var oldcolor = e.sender.GetActivePenColor();
           var r = e.sender.AddRect2([e.viewrect.left , e.viewrect.bottom , 0], (e.viewrect.right - e.viewrect.left), (e.viewrect.top - e.viewrect.bottom), 0, false, {});
            r.HatchProperties = vdcanvas.createNewHatchProperties('solid', null, vdConst.colorFromString("255,0,0,90"), 1.0, 0.0);
            e.sender.DrawEntity(r, e.render);
            var textstring = "vdraw ";
            switch (e.display) {
                case 0:
                    textstring += "screen ";
                case 2:
                    textstring += "printer window ";
                case 4:
                    textstring += "printer paper ";
            var t = e.sender.AddText(textstring, e.pixelsize * 20, [e.viewrect.right, e.viewrect.bottom, 0], vdConst.VdConstHorJust_VdTextHorRight, vdConst.VdConstVerJust_VdTextVerBottom, 0, false, {});
            t.BackGroundMask = true;
            t.BackGroundMaskColor = vdConst.colorFromString("0,0,255,100");
            e.sender.DrawEntity(t, e.render);


object sender :The "vdrawObj" that caused the event.
object render :The render context that is used to draw entities.
int display :The dispaly mode tha can be one of the following values:
0 is going to draw on the screen view.
2 is going to draw on printer window view during the call of "vdrawObj.printToImageData".
4 is going to draw on printer paper view during the call of "vdrawObj.printToImageData".
Printer window view is the content of the selected drawing area tha will be print.
Printer paper view is the content of the selected printer paper where the printer window is placed.
object viewrect :Returns an object with left , right, top , bottom properties that defines the bounding of the rendering area in view co-ordinate system. The height of the viewrect is always 1.0 Drawing Unit.
double pixelsize :The size of one(1) pixel in Drawing Units.

Send comments on this topic.