Page 1 of 1

Drawing and moving the image

Posted: 25 Nov 2016, 16:48
by roman
Hello,

I'd need to implement the following task:
A User draws on an large image (red). The Image is zoomed (black) and the user wants to draw a polyline(blue) which is started inside the clip rectangle with the given zoom, but the end is outside the visible area.
The user needs to move the clip rectangle but the line should still exist in "edit mode". At the moment the line is removed when the zoom changes.

thank you for your help.
Roman

Image

Re: Drawing and moving the image

Posted: 29 Nov 2016, 21:14
by support
Hello Roman,

The drawing tools are implemented through the EntitiesCreator class which is defined under CADImport.Professional namespace. You should pay attention to the EntitiesCreator.Disable method, it terminates the usage of a drawing tool and removes the drawn object. It seems that you call this method in your zooming in/out routines.


Mikhail

Re: Drawing and moving the image

Posted: 30 Nov 2016, 09:41
by roman
Hello Mikhail,

I didn't find the EntitiesCreator.Disable method where you mentioned, but after some research inside the CADEditor I found the code I postet at the bottom of this post (taken form CadEditorDemo)

Inside the method below i found this part.

Code: Select all

if ((!this.clipRectangle.Enabled) && (!this.CreateNewEntity))
                {
                    LeftImagePosition -= (cX - e.X);
                    TopImagePosition -= (cY - e.Y);
                    cadPictBox.Invalidate();
                }
It prevents moving the drawing when CreateNewEntity is true. Simply removing the (!this.CreateNewEntity) didn't work because the traces were drawn not where the traces should be...
Thank you for your help,
Roman

Code: Select all

private void cadPictBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (cadImage == null)
                return;
            if (!this.cadPictBox.Focused)
            {
                this.cadPictBox.Focus();
                this.cadPictBox.Invalidate();
            }
            if ((!stopSnap) && (this.cadPictBox.ClientRectangle.Contains(e.X, e.Y)))
            {
                RectangleF tmpRect = ImageRectangleF;
                cadImage.DrawSnapTrace(e.X, e.Y, this.cadPictBox, tmpRect);
            }
            else
            {
                this.cadImage.RefreshSnapTrace(this.cadPictBox);
                this.stopSnap = false;
            }
            
            if (detMouseDown)
            {

                if (e.Button != MouseButtons.Right)
                {
                    if (ChangeEntityOnMouseMove(new Point(e.X, e.Y)))
                        return;

                }

                if ((!this.clipRectangle.Enabled) && (!this.CreateNewEntity))
                {
                    LeftImagePosition -= (cX - e.X);
                    TopImagePosition -= (cY - e.Y);
                    cadPictBox.Invalidate();
                }
                cX = e.X;
                cY = e.Y;
            }
            
            PreviousPosition = new PointF(e.X, e.Y);
            DPoint vPt = GetRealPoint(e.X, e.Y, true);
            stBar.Panels[2].Text = string.Format("{0} : {1} : 0", vPt.X, vPt.Y);
        }

Re: Drawing and moving the image

Posted: 31 Jan 2017, 09:08
by roman
Hello,

still no answer?