XYZ position mouse click within 3D chart
XYZ position mouse click within 3D chart
I need to determine XYZ coordinates of a clicked point when someone clickes bottom plane (plane between X and Z axes). How could I do it (maybe I need to draw a surface on this plane and use some functions?)?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi bairog,
GDI+ doesn't have 3D coordinates. However you can obtain them doing something like this:
GDI+ doesn't have 3D coordinates. However you can obtain them doing something like this:
Code: Select all
private void tChart1_MouseClick(object sender, MouseEventArgs e)
{
int ZstartP = tChart1.Axes.Depth.IStartPos;
int ZendP = tChart1.Axes.Depth.IEndPos;
int XPos = tChart1.Axes.Bottom.Position;
if ((e.Y <= XPos) && (e.Y >= XPos - ZendP))
{
double ZPos = XPos - e.Y;
double ZVal = (tChart1.Axes.Depth.Maximum * ZPos) / ZendP;
double XVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);
double YVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);
tChart1.Header.Text = XVal.ToString() + ", " + YVal.ToString() + ", " + ZVal.ToString();
}
else
{
tChart1.Header.Text = "";
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Thank you, but you code does not work correctly in my chart.
As you can see values that are shown in header are not right (more than that in you code X and Y coordinates are always the same).Moreover while rotating and elevating the chart I have the same XYZ coordinates if I click at the same XY screen position. That's why I have some questions:
1)Are you sure that the code you gave is correct?
2)What shoul I add to code to make XYZ coordinates rotation-,elevation- and zoom-dependent?
3)From what border do Position, IEndPos and IStartPos values are calculate (screen XY xoordinates as far as I know are calculated from form border) and how could I obtain this border coordinates?
Thank you.
As you can see values that are shown in header are not right (more than that in you code X and Y coordinates are always the same).Moreover while rotating and elevating the chart I have the same XYZ coordinates if I click at the same XY screen position. That's why I have some questions:
1)Are you sure that the code you gave is correct?
2)What shoul I add to code to make XYZ coordinates rotation-,elevation- and zoom-dependent?
3)From what border do Position, IEndPos and IStartPos values are calculate (screen XY xoordinates as far as I know are calculated from form border) and how could I obtain this border coordinates?
Thank you.