Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Create Node at Mouse Click Loc. in DiagramView3D (Read 4390 times)
chrism
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Mar 11th, 2010
Create Node at Mouse Click Loc. in DiagramView3D
Mar 11th, 2010 at 5:23pm
Print Post  
I am attempting to create nodes in my DiagramView3D by converting the mouse click location on the 2D control area to a point in three-dimensional space. I can currently achieve this if no changes to the three-dimensional orientation have been made from the load state. However, once this orientation is changed (such as using mouse drag to move the camera across the plane perpendicular to direction of the camera) I can no longer create the nodes in the location of the mouse click. Here is a sample of my working code:

[code]Private Sub view3D_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles view3D.MouseDown

Dim b As New System.Drawing.RectangleF

b.Width = 20
b.Height = 20

Dim z As Double = view3D.CameraPosition.Z
Dim ClickPt3D As MindFusion.Layout.Point3D
Dim ClickPt2Dclient As Point
Dim ClickPt2Ddoc As PointF
Dim ViewCenterPt2Dclient As Point
Dim ViewCenterPt2Ddoc As PointF
Dim CameraPos2D As Point

CameraPos2D.X = view3D.CameraPosition.X
CameraPos2D.Y = view3D.CameraPosition.Y

CameraPos2D = view3D.DocToClient(CameraPos2D)

ViewCenterPt2Dclient.X = view3D.Bounds.Width / 2
ViewCenterPt2Dclient.Y = view3D.Bounds.Height / 2

ViewCenterPt2Ddoc = view3D.ClientToDoc(ViewCenterPt2Dclient)

ClickPt2Dclient.X = e.X
ClickPt2Dclient.Y = e.Y

ClickPt2Ddoc = view3D.ClientToDoc(ClickPt2Dclient)

ClickPt3D.X = ClickPt2Ddoc.X - ViewCenterPt2Ddoc.X
ClickPt3D.Y = ViewCenterPt2Ddoc.Y - ClickPt2Ddoc.Y
ClickPt3D.Z = z

Dim node As ShapeNode = diagram.Factory.CreateShapeNode(b)

node.LayoutTraits(MindFusion.Diagramming.View3D.Position) = New MindFusion.Layout.Point3D(ClickPt3D.X, ClickPt3D.Y, ClickPt3D.Z)

view3D.ResetProjection()
[/code]

By using break points and watches I've determined that the (X,Y,Z) values for the camera's position are not changing when mouse and keyboard actions are used to move the camera around the 3D scene. As such, it doesn't seem there is a means for tracking how the orientation of the 3D space is changing and to properly locate created nodes by mouse click. I would greatly appreciate any assistance or insight that anyone might be able to provide.

Thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #1 - Mar 11th, 2010 at 6:00pm
Print Post  
You can set DiagramView3D.Behavior = DrawShapes and just draw nodes with the mouse. Have you tried that?

Stoyan
  
Back to top
 
IP Logged
 
chrism
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Mar 11th, 2010
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #2 - Mar 11th, 2010 at 7:00pm
Print Post  
Stoyo,

Thank you very much for your quick response.

Unfortunately, the suggested method does not satisfy my requirements.  The code I provided in my initial post was more of a prototype for investigating feasibility.  My ultimate goal is to have unique predefined nodes (that are bound to business code objects) that a user can create in a diagram, and draw links, so as to produce a flow model.  It is desired that the size, shape, appearance, and anchor pattern of these predefined nodes be specified programatically so a user can simply "point and click" to add their desired flow model structures.  As such, the DrawShapes behavior will not provide the desired functionality.

Are there any current methods that would satisfy my requirements?

Thanks again.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #3 - Mar 11th, 2010 at 7:35pm
Print Post  
This will raise the InitializeNode and NodeCreated events, and you could handle one of them to customize the new node so it looks like the selected predefined node. If you prefer point and click creation, I suppose we have a method that finds 3D positions for the nodes being drawn, and could make it public for the next release.

Stoyan
  
Back to top
 
IP Logged
 
Aziz ur Rahman
YaBB Newbies
*
Offline



Posts: 43
Joined: Feb 23rd, 2009
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #4 - Jun 9th, 2011 at 5:37pm
Print Post  
[quote author=Stoyo link=1268328189/0#3 date=1268336151]This will raise the InitializeNode and NodeCreated events, and you could handle one of them to customize the new node so it looks like the selected predefined node. If you prefer point and click creation, I suppose we have a method that finds 3D positions for the nodes being drawn, and could make it public for the next release.

Stoyan[/quote]

Dear Stoyo,
Any update on this feature?
  

Syed Aziz ur Rahman
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #5 - Jun 10th, 2011 at 7:10am
Print Post  
What update do you expect? The poster above did not confirm they need anything new, so I suppose there's no update.
  
Back to top
 
IP Logged
 
chrism
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Mar 11th, 2010
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #6 - Jun 10th, 2011 at 12:52pm
Print Post  
I never requested additional functionality as I was able to make use of the drag-drop feature to add copies of pre-defined nodes from a library to a 2D working diagram window.  Hope that helps.
  
Back to top
 
IP Logged
 
Aziz ur Rahman
YaBB Newbies
*
Offline



Posts: 43
Joined: Feb 23rd, 2009
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #7 - Jun 10th, 2011 at 4:45pm
Print Post  
I was talking about the exposure of method that can return the 3D position of the node being drawn.

I want same kind of functionality. i.e. Ability to drag and drop some predefined nodes on the diagramview3D. But i need the 3d Position where the node is dropped.

Any work around?

Thanks
  

Syed Aziz ur Rahman
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Create Node at Mouse Click Loc. in DiagramView
Reply #8 - Jun 13th, 2011 at 8:08am
Print Post  
This version adds a GetProjectionOrigin method that returns a 3D point projected on the specified client point:
https://mindfusion.eu/_beta/fcnet_reverseprojection.zip

Code
Select All
ShapeNode node = diagram.Factory.CreateShapeNode(0, 0, 30, 30);
node.LayoutTraits[View3D.Position] =
	view3D.GetProjectionOrigin(PointToClient(MousePosition));
view3D.ResetProjection(); 



By default it returns a point at CreationPlaneDistance behind the projection plane. There's also a GetProjectionOrigin(point, depth) overload that lets you specify a different distance.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint