I am geomatic engineer. I try to write a program that i use it for my thesis. In my work i can describe that is a special cases of coordinate transformation in 2d and 3d.
So i wrote program. But i want to go further for my application. İ wanna design a coordinate screen that user can interact with data. In this case points. İ attached a jpg file to describe what i want. There should be a coordinate screen and after loading data to the program(points= Point ID, x,y) i wanna see them in the screen. and some cases i might wanna get information by clicking points (such as point' y coordinate). (in the file that attached white square is mouse pointer)
how can i design such a program that user can interact with graphic objects(points, maybe lines).
Hi yigit-sertac, welcome to the forum. Unfortunately your first post seems to be lacking the information people will need to answer your question property. The attached image is just a big black square with three little numbers on it; that doesn't explain what you mean by a "coordinate screen". I sounds like you want a screen showing X and Y axes, on which the user can click to mark points, and get the coordinates of existing points for example by hovering over them. That shouldn't be to hard if you know the basics of VB.Net. So it's a question how much you already know. You say you have written a program. Was that in VB.Net? What does it do?
In VB.Net all interaction is event driven. For a drawing program, you would write code for various Mouse event handlers and for the Paint event handler of your drawing surface (a Form or a PictureBox). Maybe you would like to look at the code I posted in this thread, which shows you how to mark points to form a curve and drag them to new positions. If you understand how that works it shouldn't be hard to adapt it for individual points and straight lines. If that's not the kind of information you are looking for, please say.
Perhaps it'll give you some ideas. The graphics themselves shouldn't act as the objects you use to determine what to draw next, that's my advice. Keep the logic for coordinates and objects to be drawn with their boundaries and such on it's own, use that for the logic that determines how that data changes, and use that data to decide what to draw.
Please note that although it's in C#, the logic is the same as VB.net, and you can attempt to use an online converter otherwise (Telerik's is good), or ask me if you don't understand something, and respond here. The other thing is that this is self-animated, there is no user interaction. Another thing is because I have called Start() within the constructor for that class, it shows the emulation in design view, which may not be good if you don't want it consuming CPU like that, and anything else computationally expensive will probably freeze your IDE itself, or if you do not want it to start as soon as it's instantiated, and you'd rather call to start it yourself.
Last edited by AceInfinity; Dec 25th, 2013 at 04:18 PM.
Hi yigit-sertac, welcome to the forum. Unfortunately your first post seems to be lacking the information people will need to answer your question property. The attached image is just a big black square with three little numbers on it; that doesn't explain what you mean by a "coordinate screen". I sounds like you want a screen showing X and Y axes, on which the user can click to mark points, and get the coordinates of existing points for example by hovering over them. That shouldn't be to hard if you know the basics of VB.Net. So it's a question how much you already know. You say you have written a program. Was that in VB.Net? What does it do?
In VB.Net all interaction is event driven. For a drawing program, you would write code for various Mouse event handlers and for the Paint event handler of your drawing surface (a Form or a PictureBox). Maybe you would like to look at the code I posted in this thread, which shows you how to mark points to form a curve and drag them to new positions. If you understand how that works it shouldn't be hard to adapt it for individual points and straight lines. If that's not the kind of information you are looking for, please say.
BB
thanks for reply boops boops.
I'll try to explain what i want. I mentioned that i am geomatic engineer. The basic element of my profession is point comes from adjusted gps data or clasical way total station data if you are familiar this terms you should understrand me better.if not they are surveying instruments using our work. basic instruments that we can collect useful data from terrain surface. if still not clear let me know please.
Secondly, yes i wrote a program for my thesis and for my firm using vb.net language. I'll try explain better. Coordinate trasnformation is one the most used processes in geodesy and surveying. Coordinates of points in one coordinate system are obtained in another coordinate system. To do this the transformation parameters between two individual coordinate systems are calculated from the identical points, coordinates of wich are known in both systems. I'll give you an example data that i enter to my program below. Imagine you have two different planar coordinate system and identical points which are known in both coordinates systems. To solve this problem there are different ways. One of them least square estimation. further, total least square estimation.And I use both of them for my program. If you heard of helmert transformation, affine transformation it gives you an idea. That's the subject of my thesis. The program that I wrote uses a single text file that contains points' coordinates in both system. Basiclly these are purpose of my program. I hope it's more clear.
example data:
...........................first system.................................second system
point ID..............y....................x..........................Y...................X
OL42G001 526211.8150 4230490.3010 526227.4200 4230671.3900
0000M205 529660.2150 4247462.7710 529675.8720 4247644.0010
0000M202 535396.3590 4243421.9540 535412.0020 4243603.1350
0C355255 536586.4990 4214544.4000 536601.9300 4214725.5000
Third, I don't know if you are familiar autocad or not but you can find out what this is and its purposes very easily. Well, In autocad we can draw line into the drawing screen(maybe i couldn't explain this at the first time). Then for some point you need to edit that line and you click that line and you do whatever you want. That's my question. How to interact with that graphical object that you draw.( line, point). when you click the line or point a pop up menu appears including some functions. it doesen't matter what they are at this point. Just interactions those graphical objects that i wanna know how it's done.
I hope i explained myself better this time. thank you...
Last edited by yigit_sertac; Dec 26th, 2013 at 12:36 AM.
Perhaps it'll give you some ideas. The graphics themselves shouldn't act as the objects you use to determine what to draw next, that's my advice. Keep the logic for coordinates and objects to be drawn with their boundaries and such on it's own, use that for the logic that determines how that data changes, and use that data to decide what to draw.
Please note that although it's in C#, the logic is the same as VB.net, and you can attempt to use an online converter otherwise (Telerik's is good), or ask me if you don't understand something, and respond here. The other thing is that this is self-animated, there is no user interaction. Another thing is because I have called Start() within the constructor for that class, it shows the emulation in design view, which may not be good if you don't want it consuming CPU like that, and anything else computationally expensive will probably freeze your IDE itself, or if you do not want it to start as soon as it's instantiated, and you'd rather call to start it yourself.
thank you for reply. that's not exactly what i wanna do but it gave me some other ideas to my project. Thank you for your help AceInfinity.
I've used AutoCAD before btw. It's quite an advanced program once you get into functions and all that good stuff. I'd taken a course and was a designer a while back. I haven't used much of it lately though, so I'd probably be a bit rusty. I'm glad my example gave you some ideas though.
"How to interact with that graphical object that you draw.( line, point)." -- the short of it is you don't... even things like AutoCAD don't... what you do is interact with the hotspot(s) that are associated with that graphical object. When the mouse button goes down, you get the position, then check to see if it is in the boundaries of an object and react accordingly. But you never really interact with the graphical object itself.
"How to interact with that graphical object that you draw.( line, point)." -- the short of it is you don't... even things like AutoCAD don't... what you do is interact with the hotspot(s) that are associated with that graphical object. When the mouse button goes down, you get the position, then check to see if it is in the boundaries of an object and react accordingly. But you never really interact with the graphical object itself.
-tg
hi techgnome. so you say every graphical objects that we created also need some property that defines boundaires. so for example, for points we need a square boundary, for lines we need rectangle. do i understand correctly?
thanks...
Yes, that's the way I'd do it. Squares are just rectangles, too. If ALL of your shapes can be reduced to rectangles, that will make your life pretty easy. If your shapes are more complex, it's still possible, but not quite as easy.
I did something like this where I had a series of pictures on a picturebox. Some could be dragged and dropped, others could be clicked, while still others just showed a tooltip. In all cases, what I was actually storing was just a collection of Rectangles. The picturebox would take the MouseDown event, get the mouse coordinates, check whether the coordinates fell inside any of the rectangles, and if it did, it would act accoringly. The image was drawn to the Picturebox, and it looks to the user like they are interacting with the image, but in fact they are interacting with a collection of Rectangles that neither know nor care what is drawn in that location.
Yup... pretty much... that's what Ace alluded to in his post:
The graphics themselves shouldn't act as the objects you use to determine what to draw next, that's my advice. Keep the logic for coordinates and objects to be drawn with their boundaries and such on it's own, use that for the logic that determines how that data changes, and use that data to decide what to draw.
Rather than storing the graphics, you store the directions to make the graphical object. Graphics are just points of light on the screen... they're not something like a variable that sticks around that you can use... but you can use a variable (or an array of them or a list of them) that hold the directions for what needs to be drawn, then when you need to draw it, you follow (or the app does) the directions.
Yes, that's the way I'd do it. Squares are just rectangles, too. If ALL of your shapes can be reduced to rectangles, that will make your life pretty easy. If your shapes are more complex, it's still possible, but not quite as easy.
I did something like this where I had a series of pictures on a picturebox. Some could be dragged and dropped, others could be clicked, while still others just showed a tooltip. In all cases, what I was actually storing was just a collection of Rectangles. The picturebox would take the MouseDown event, get the mouse coordinates, check whether the coordinates fell inside any of the rectangles, and if it did, it would act accoringly. The image was drawn to the Picturebox, and it looks to the user like they are interacting with the image, but in fact they are interacting with a collection of Rectangles that neither know nor care what is drawn in that location.
for more complex shapes using small rectangles is a correct approach?
Rectangles are convenient because they have methods that can tell you whether a point is within the rectangle, and these methods are fast. I believe that there is some method (though I forget what it is) which will work for arbitrarily complex shapes, but that would also be a little slower. It may be that you have time to burn, since humans can only interact with computer in tenths of a second, whereas the difference between slow and fast from the computer perspective is in milliseconds, or less. In general, though, you trade precision for speed. Rectangles are the highest speed, but lowest precision for shapes that are not rectangles, or are not rectangles arranged in a horizontal or vertical orientation.
I don't agree with Shaggy on this. Using rectangles to represent everything is not a good basis for a CAD type program.
The class you will find essential for making a 2D vector drawing tool is the Drawing2D.GraphicsPath. The GraphicsPath has the following features:
1. You can add all kinds of primitive to it: Lines, Polylines, Polygons, Rectangles, Ellipses, Arcs, Spline Curves, Bezier curves and Text. You can combine any number of these primitives into a single path, e.g. to represent a complex shape as a unit. Or you can use as many separate paths in a drawing as you need.
2. You can draw and fill the path on a Form etc. using GDI+ pens and brushes (GraphicsPath.DrawPath and FillPath). Rendering is fast because the necessary algorithms are built into the graphics hardware.
3. You can use paths for hit-testing. That means, you can detect if the mouse pointer is over a path (GraphicsPath.IsOutlineVisible) or is inside an area enclosed by a path (GraphicsPath.IsVisible). The IsOutlineVisible method method allows you to specify a margin of error, which for example makes it easier for the user click on a line or other shape to select it.
4. You can perform 2D transformations (translate, scale and rotate) on individual paths or on all paths. In effect this means that you could develop a 3D rendering starting from 2D beginnings; although if you reach that point it would make sense to look at WPF or other graphic techniques rather than Windows Forms.
5. You can serialize a GraphicsPath (I think, or at least its main data). That means it is easy to store all the data for the the path in a file or in a database. The data consists of two arrays: an array of PointFs, and a matching array of bytes representing Path Types (straight lines, Beziers etc.). Consequently the amount of data to be stored is quite small, particular for curves and text because the graphics hardware renders the necessary curves at run time.
BB
Last edited by boops boops; Dec 26th, 2013 at 04:50 PM.
Reason: got IsVisible/IsOutlineVisible the wrong way round. I'm gettign rusty!
I disagree with your statement that you are disagreeing with me.
On the contrary, I do disagree with you. Never mind, we can agree to disagree about that can't we? What do you mean, we can't!
If you can get away with rectangles, they are faster, but not many solutions can work with JUST rectangles.
This is my point. JUST rectangles aren't much use. Maybe you are thinking of the Drawing2D.Region, which in fact consists of a collection of RectangleFs. These do have some useful methods, such as Intersect and XOR. That is a question of coding efficiiency rather than peformance. You can instantly convert a GraphicsPath into a Region when you need to, for example to take advantage of one of those methods. But you cannot convert a Region directly into a Graphics path (you sometimes can convert it, by the Marching Squares algorithm, but that is not exactly efficient either as coding or processing).
Anyway, suppose you want to do something like clicking on a diagonal line amid dozens or hundreds of other lines, to select and drag it to a new position. That is a typical task in a vector graphics tool. How on earth would you do that using rectangles?
BB
Last edited by boops boops; Dec 26th, 2013 at 05:39 PM.
Actually I agree with boop boops here as well. Rectangles are not the basis of drawing efficiently anymore. Newer gaming engines are reluctant to use rectangles as a base drawing model because it has 4 verticies. Algebraically, they've found that the triangle is actually more efficient, because it only contains 3 verticies, and you can still make a rectangle out of it if needed, but it allows for more complex polygon rendering.
This although, delving into more advanced topics, just goes to show how ineffective a rectangle can become for complex structures. Even though perhaps this talk was more about the structure itself and not the polygon shape... lol.
Rectangles are convenient, but there are cases when they can't be used.
Last edited by AceInfinity; Dec 26th, 2013 at 09:28 PM.