← Back to team overview

kicad-developers team mailing list archive

My patches to 3d-viewer (request 1892773 + patch 1905661)

 

Hi,

first of all, Hi everyone, I am new to the devel-list (I was the one 
complaining about the unclear versioning on kicad-users, which Igor posted to 
this list).

I have implemented request 1892773
http://sourceforge.net/tracker/index.php?func=detail&aid=1892773&group_id=145591&atid=762479

During that, I noticed that panning in general did not work well when the view 
was rotated with the mouse. This was caused because the rotation was applied 
after the panning in Pcb3D_GLCanvas::Redraw(). I fixed that, see issue 
1905661:
http://sourceforge.net/tracker/index.php?func=detail&aid=1905661&group_id=145591&atid=762478

For completeness, I have attached both patches, hoping that someone will merge 
them into the SVN trunk.

The panning patch also contains some formatting changes. I noticed, that some 
formatting was inconsistent (mainly due to mixing tabs and spaces in 
indenting). Also, french characters in comments were causing problems on my 
platform (they were rendered incorrectly in patches)...

Best regards.
 --Boundary-00=_yksyHgjFM9ZyzQB Content-Type: text/x-diff;
charset="us-ascii";
name="middle_mouse_pan.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="middle_mouse_pan.patch"

Index: 3d-viewer/3d_canvas.cpp
===================================================================
--- 3d-viewer/3d_canvas.cpp	(Revision 821)
+++ 3d-viewer/3d_canvas.cpp	(Arbeitskopie)
@@ -283,14 +283,22 @@

if( event.Dragging() )
{
- /* drag in progress, simulate trackball */
- trackball( spin_quat,
+ if (event.LeftIsDown()){
+ /* drag in progress, simulate trackball */
+ trackball( spin_quat,
(2.0 * g_Parm_3D_Visu.m_Beginx - size.x) / size.x,
(size.y - 2.0 * g_Parm_3D_Visu.m_Beginy) / size.y,
( 2.0 * event.GetX() - size.x) / size.x,
( size.y - 2.0 * event.GetY() ) / size.y );

- add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat );
+ add_quats( spin_quat, g_Parm_3D_Visu.m_Quat, g_Parm_3D_Visu.m_Quat );
+ } else if (event.MiddleIsDown()){
+ /* middle button drag -> pan */
+ /* Current zoom and an additional factor are taken into account for the amount of panning. */
+ const float PAN_FACTOR = 8.0 * g_Parm_3D_Visu.m_Zoom;
+ g_Draw3d_dx -= PAN_FACTOR * (g_Parm_3D_Visu.m_Beginx - event.GetX()) / size.x;
+ g_Draw3d_dy -= PAN_FACTOR * (event.GetY() - g_Parm_3D_Visu.m_Beginy) / size.y;
+ }

/* orientation has changed, redraw mesh */
DisplayStatus();
 --Boundary-00=_yksyHgjFM9ZyzQB Content-Type: text/x-diff;
charset="us-ascii";
name="fix_drawing.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="fix_drawing.patch"

Index: 3d-viewer/3d_draw.cpp
===================================================================
--- 3d-viewer/3d_draw.cpp	(Revision 821)
+++ 3d-viewer/3d_draw.cpp	(Arbeitskopie)
@@ -44,33 +44,34 @@
{
SetCurrent();

-	InitGL();
+ InitGL();

glMatrixMode(GL_MODELVIEW); /* position viewer */
/* transformations */
GLfloat mat[4][4];

+ // Translatory motion first, so rotations don't mess up the orientation...
+ glTranslatef(g_Draw3d_dx, g_Draw3d_dy, 0.0F);
+
build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat );
glMultMatrixf( &mat[0][0] );

-	glTranslatef(g_Draw3d_dx, g_Draw3d_dy, 0.0F);
-
glRotatef(g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0);
-	glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0);
+ glRotatef(g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0);
glRotatef(g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0);

-	if( m_gllist )
-	glCallList( m_gllist );
-	else
-	{
-	m_gllist = CreateDrawGL_List();
+ if( m_gllist )
+ glCallList( m_gllist );
+ else
+ {
+ m_gllist = CreateDrawGL_List();
//	m_gllist = DisplayCubeforTest();	// Only for test
-	}
+ }

-	glFlush();
-	if( finish )
-	glFinish();
-	SwapBuffers();
+ glFlush();
+ if( finish )
+ glFinish();
+ SwapBuffers();
}
 --Boundary-00=_yksyHgjFM9ZyzQB-- 




Follow ups