LineType of DxfXLine doesn't work
Clay
11/22/2007 10:40 AM
|
---|
Hi Wout
I think the LineType of DxfXLine doesn't work. Below my code with DxfXLine and DxfLine. For the DxfLine the LineType works, for the DxfXLine not.
C# Code:         int gridCount = 200; |
Wout
11/22/2007 12:38 PM
|
---|
Hi Clay,
Yes, I had to compromise in that area, and also I think it's probably not a good idea using DxfXLine + line type for the grid. Currently CadLib does drawing in 2 stages for performance reasons, first it creates drawables, and it also applies e.g. line types in that stage. The second drawing stage is fairly unintelligent and just draws the bunch of line segments collected in the first stage. So for lines (of infinite length), this obviously doesn't work, because CadLib would have to create an infinite number of line segments. In the current design it's a bit less bad, because it just draws very long lines, but still a large number of line segments would result. Alternatively the application of line type could be deferred to the 2nd drawing stage, which helps a bit because there information about the viewport clipping would reduce the amount of line segments, however this also doesn't always hold, e.g. when doing perspective transforms, where you basically still possibly have an infinite number of line segments. You see this is getting fairly hairy!
Can I ask what the purpose of the grid is? If it's just for presentation purposes, I'd suggest not using DXF to draw, but some custom drawing code that draws on top, or below the DXF rendering.
Wout
|
Clay
11/22/2007 12:46 PM
|
---|
Hi Wout
The grid should work like a grid in drawing apps like Gimp or Photoshop. Only as a help for the user ,with a snap function. before I save the model to a dxf file, I remove the grid.
So I think I'll use 'normal' DxfLines for the grid. I need the LineType to set it to 'dotted', because of my other problem with the sort order of the layers, where my grid hides other entities :-)
best regards
Clay
|
Wout
11/22/2007 1:18 PM
|
---|
Hi Clay,
My personal preference for this would do some specific drawing code drawing the grid before drawing the DXF. Reasons for this are:
- Probably you want the grid dotting scale/spacing to be based on pixels, rather than drawing units. If you have a large drawing, your dots would be close together.
- It's more efficient too: drawing lines using GDI is very simple, and you have perfect knowledge of how much to draw, since you know the size of the viewport/Control. Applying a line style to it is not that much more work (roughly 20-30 lines of code perhaps).
I've implemented similar things in the DXF Sharp Viewer with e.g. the selection rectangle or the rotation disk, which are disconnected from the DXF.
Just my 2 cents :-).
Wout
|
Clay
11/22/2007 1:28 PM
|
---|
my problem is, I have no experience with cad things and also no experience with GDI :-)
i've already implemented a selection rectangle with dxf-stuff. So you think thats a bad idea?
|
Wout
11/22/2007 1:36 PM
|
---|
Aha! Probably you'll need a few pointers here and there then (I'd suggest some consultancy!)
But yes, it's a bad idea, though not terrible or catastrophic. GDI is not difficult, just spend some time getting to know it. Transforming coordinates probably takes a bit of learning curve. A selection rectangle I typically implement using
C# Code:       ControlPaint. |
Clay
11/22/2007 1:44 PM
|
---|
yeah that whas my point when I started with the selection rectangle and the grid: moving, zooming, and so on is easy done by your CadLib :-)
But thank you for your hints. I'll check if we have enough time left in this project and if it is so, I'll do the grid and selection thing with GDI.
best regards
Clay
|