Magnetic Cursor behaviour

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Magnetic Cursor behaviour

Post by roman » 16 Jul 2013, 16:59

Hi,

has anyone the following issue:
when I'm creating elements from my stored entities I sometimes get a strange behaviour of the "magnetic cursor" (the X like cursor when snap to element in the toolbar is enabled) - sometimes it fits to the mouse (arrow) position, but following a line it may change direction and moves to another direction than the mouse arrow!

The mouse cursor is still working an it is also selecting the coorect elements, but the X cursor seems to be lost.

does anyone have an idea how to fix this?
is there a possibility to hide the magnetic "X" cursor?

Here's some DEBUG output:

Code: Select all

...
cadEditorControl1.PictureBox.MouseMove += new MouseEventHandler(PictureBox_MouseMove);
...
void PictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            Debug.WriteLine("RP: {0}/{1}\t\t SP: {2}/{3} MP: {4}/{5}", Image.SnapRealPoint.X, Image.SnapRealPoint.Y, Image.SnapScreenPoint.X, Image.SnapScreenPoint.Y, e.X, e.Y);
        }
RP: Image.SnapRealPoint X/Y values
SP: Image.SnapScreenPoint X/Y values
MP: MouseEventArgs e X/Y values

RP: 2071.92711830139/2701.71456336975 SP: 842/337 MP: 842/337
RP: 2071.92711830139/2701.71456336975 SP: 842/337 MP: 842/337
RP: 2068.16272735596/2701.71456336975 SP: 841/337 MP: 841/337
RP: 2068.16272735596/2701.71456336975 SP: 841/337 MP: 841/337
==> what happens here... SP and MP are different? What's the reason? <==
RP: 989.904163697254/1411.01989863903 SP: 547/691 MP: 840/337
RP: 989.904163697254/1411.01989863903 SP: 547/691 MP: 840/337

thank you
Roman

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

Re: Magnetic Cursor behaviour

Post by support » 16 Jul 2013, 18:24

Hello Roman.
Please specify the assembly build version that referenced in your project. Have you updated to 8.1.0.20817 that we have provided last time or some previous version used? The issue occurs when an entity created visually, if we understand correctly. Have you developed own method for the creation or use control default buttons? For which types of created entities the issue can appear?

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Magnetic Cursor behaviour

Post by roman » 17 Jul 2013, 11:45

Hello,
I'm using the CADImport.dll V 8.1.0.20817.

The Issue occurs when I added an entity from my storage. (out customer wanted to be able to store the drwaing project, the internal (de)serialization doesn't work so I had to implement my own). The Elements are loaded as descirbed below:

if the project contains an image element:
cadEditorControl1.LoadFile(fileName);

Code: Select all

                XDocument xDoc = XDocument.Load(Path.Combine(TempPath, "cadData.xml"));
                XElement root = xDoc.Root;
                foreach (XElement element in root.Elements())
                {
                    //deserialize cad data
                    CADEntity item = DeserializeFromXElement(element, converter);

                    converter.GetSection(ConvSection.Entities).AddEntity(item);
                    item.Visibility = true;

                    // add to layer
                    if (item is CADImageEnt)
                        item.Layer = converter.GetLayerByNameAsIndex(1);  //(CADLayer)converter.Layers[1];
                    else
                        item.Layer = converter.GetLayerByNameAsIndex(2); //(CADLayer)converter.Layers[2];

                    converter.OnCreate(item);
                    converter.Loads(item);
                    item.Loaded(converter);
                }
The issue appears to some polylines, there seem to be areas where the mouse and the screen points don't fit. The strange thing is sometimes it's working (as seen on my first post) but moving the mous causes this strange behaviour.

thank you
Roman

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Magnetic Cursor behaviour

Post by roman » 17 Jul 2013, 15:16

After some research I found out that it seems to depend on:

Code: Select all

 
public void LoadImage(string fileName)
        {
            cadEditorControl1.LoadFile(fileName);
        }
when the data is loaded it seems to be correct, but if an image is loaded and the drawing is on the image it seems to show the described behaviour.

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

Re: Magnetic Cursor behaviour

Post by support » 23 Jul 2013, 16:50

Hello Roman.
We have tried to recreate described issue with EditorControl demo - without success. Independently from an imported file (vector or raster format) and entity placement (programmatically or visually) described issue doesn't appear.
We have added entities programmatically to cadEditorControl1.Image object that represents the drawing structure within the control. So we thought your snippet worked in the same way. However CADConverter class have no a member GetLayerByNameAsIndex that used in your code.
// add to layer
if (item is CADImageEnt)
item.Layer = converter.GetLayerByNameAsIndex(1); //(CADLayer)converter.Layers[1];
else
item.Layer = converter.GetLayerByNameAsIndex(2); //(CADLayer)converter.Layers[2];
So which class instantiated as converter in your code?
Have you tried to recreate same issue with default EditorControl demo? Just add a polyline with parameters correspond to deserialized polyline that reveals the problem.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Magnetic Cursor behaviour

Post by roman » 24 Jul 2013, 16:08

Hello,

I added the method GetLayerByNameAsIndex because there where issues calleng GetLayerByName...

Code: Select all

 
public static CADLayer GetLayerByName(this CADConverter converter, string name)
        {
            List<CADLayer> layers = (from lay in converter.Layers
                                     select (CADLayer)lay).ToList();

            return layers.Find(layer => layer.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
        }
Recreating the issue with EditorControl Demo doesn' work because the issue only appears when an image is loaded by the method I described before. Can I send you my code by email?

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

Re: Magnetic Cursor behaviour

Post by support » 24 Jul 2013, 16:23

Hello Roman,
Please send the code sample or example project to support@cadsofttools.com. We will check it and try to find the issue cause.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply