Commit abe5c08e authored by jean-pierre charras's avatar jean-pierre charras

3D-viewer: code cleaning. Added option in menu: show a 3D grid.

All: press ctrl+shift key when moving the mouse allows the graphic cursor to be moved outside the grid.
(useful to place graphic objects, texts in any position, regardless the current grid)
parent 7c3f47ec
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <3d_viewer.h> #include <3d_viewer.h>
#include <info3d_visu.h>
#include <trackball.h> #include <trackball.h>
...@@ -176,47 +177,45 @@ GLuint EDA_3D_CANVAS::DisplayCubeforTest() ...@@ -176,47 +177,45 @@ GLuint EDA_3D_CANVAS::DisplayCubeforTest()
} }
Info_3D_Visu::Info_3D_Visu() INFO3D_VISU::INFO3D_VISU()
{ {
int ii; int ii;
m_Beginx = m_Beginy = 0.0; /* position of mouse */ m_Beginx = m_Beginy = 0.0; // position of mouse
m_Zoom = 1.0; /* field of view in degrees */ m_Zoom = 1.0;
m_3D_Grid = 10.0; // Grid value in mm
trackball( m_Quat, 0.0, 0.0, 0.0, 0.0 ); trackball( m_Quat, 0.0, 0.0, 0.0, 0.0 );
for( ii = 0; ii < 4; ii++ ) for( ii = 0; ii < 4; ii++ )
m_Rot[ii] = 0.0; m_Rot[ii] = 0.0;
m_Layers = 1; m_CopperLayersCount = 2;
m_BoardSettings = NULL; m_BoardSettings = NULL;
// default all special item layers Visible // default all special item layers Visible
for (ii=0; ii< FL_LAST; ii++) for( ii = 0; ii < FL_LAST; ii++)
m_DrawFlags[ii]=true; m_DrawFlags[ii] = true;
m_DrawFlags[FL_GRID] = false;
} }
Info_3D_Visu::~Info_3D_Visu() INFO3D_VISU::~INFO3D_VISU()
{ {
} }
WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* parent, const wxString& title,
wxBoxSizer* BoxSizer, wxBoxSizer* BoxSizer )
EDA_UNITS_T units, int internal_unit )
{ {
wxString text; wxString text;
wxStaticText* msgtitle; wxStaticText* msgtitle;
m_Units = units;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() ) if( title.IsEmpty() )
text = _( "Vertex " ); text = _( "Vertex " );
else else
text = title; text = title;
text += ReturnUnitSymbol( units );
msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 ); msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 );
BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM ); BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM );
...@@ -267,12 +266,12 @@ WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, ...@@ -267,12 +266,12 @@ WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
} }
WinEDA_VertexCtrl::~WinEDA_VertexCtrl() VERTEX_VALUE_CTRL::~VERTEX_VALUE_CTRL()
{ {
} }
S3D_Vertex WinEDA_VertexCtrl::GetValue() S3D_Vertex VERTEX_VALUE_CTRL::GetValue()
{ {
S3D_Vertex value; S3D_Vertex value;
double dtmp; double dtmp;
...@@ -287,7 +286,7 @@ S3D_Vertex WinEDA_VertexCtrl::GetValue() ...@@ -287,7 +286,7 @@ S3D_Vertex WinEDA_VertexCtrl::GetValue()
} }
void WinEDA_VertexCtrl::SetValue( S3D_Vertex vertex ) void VERTEX_VALUE_CTRL::SetValue( S3D_Vertex vertex )
{ {
wxString text; wxString text;
...@@ -305,7 +304,7 @@ void WinEDA_VertexCtrl::SetValue( S3D_Vertex vertex ) ...@@ -305,7 +304,7 @@ void WinEDA_VertexCtrl::SetValue( S3D_Vertex vertex )
} }
void WinEDA_VertexCtrl::Enable( bool onoff ) void VERTEX_VALUE_CTRL::Enable( bool onoff )
{ {
m_XValueCtrl->Enable( onoff ); m_XValueCtrl->Enable( onoff );
m_YValueCtrl->Enable( onoff ); m_YValueCtrl->Enable( onoff );
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
#include <gestfich.h> #include <gestfich.h>
#include <3d_viewer.h> #include <3d_viewer.h>
#include <info3d_visu.h>
#include <trackball.h> #include <trackball.h>
#include <3d_viewer_id.h>
// ----------------- // -----------------
......
...@@ -6,13 +6,6 @@ ...@@ -6,13 +6,6 @@
#include <3d_viewer.h> #include <3d_viewer.h>
S3D_Vertex::S3D_Vertex()
{
x = y = z = 0.0;
}
S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) : S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
EDA_ITEM( father, NOT_USED ) EDA_ITEM( father, NOT_USED )
{ {
......
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////// /**
// Name: 3d_frame.cpp * @file 3d_frame.cpp
///////////////////////////////////////////////////////////////////////////// */
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <3d_viewer.h> #include <3d_viewer.h>
#include <info3d_visu.h>
#include <trackball.h> #include <trackball.h>
#include <wx/colordlg.h> #include <wx/colordlg.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <3d_viewer_id.h>
Info_3D_Visu g_Parm_3D_Visu; INFO3D_VISU g_Parm_3D_Visu;
double DataScale3D; // 3D conversion units. double DataScale3D; // 3D conversion units.
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame ) BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate ) EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, EDA_3D_FRAME::Process_Zoom ) EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, EDA_3D_FRAME::Process_Zoom )
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D, EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
EDA_3D_FRAME::Process_Special_Functions ) EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( wxID_EXIT, EDA_3D_FRAME::Exit3DFrame ) EVT_MENU( wxID_EXIT, EDA_3D_FRAME::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG, EDA_3D_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_SCREENCOPY_PNG, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG, EDA_3D_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_SCREENCOPY_JPEG, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END,
EDA_3D_FRAME::On3DGridSelection )
EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow ) EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -38,7 +65,6 @@ EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long ...@@ -38,7 +65,6 @@ EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long
m_Canvas = NULL; m_Canvas = NULL;
m_HToolBar = NULL; m_HToolBar = NULL;
m_VToolBar = NULL; m_VToolBar = NULL;
m_InternalUnits = 10000; // Internal units = 1/10000 inch
m_reloadRequest = false; m_reloadRequest = false;
// Give it an icon // Give it an icon
...@@ -322,7 +348,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -322,7 +348,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
return; return;
default: default:
wxMessageBox( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) ); wxLogMessage( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
return; return;
} }
...@@ -330,6 +356,52 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -330,6 +356,52 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_Canvas->DisplayStatus(); m_Canvas->DisplayStatus();
} }
void EDA_3D_FRAME::On3DGridSelection( wxCommandEvent& event )
{
int id = event.GetId();
for( int ii = ID_MENU3D_GRID; ii < ID_MENU3D_GRID_END; ii++ )
{
if( event.GetId() == ii )
continue;
GetMenuBar()->Check( ii, false );
}
switch( id )
{
case ID_MENU3D_GRID_NOGRID:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = false;
break;
case ID_MENU3D_GRID_10_MM:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
g_Parm_3D_Visu.m_3D_Grid = 10.0;
break;
case ID_MENU3D_GRID_5_MM:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
g_Parm_3D_Visu.m_3D_Grid = 5.0;
break;
case ID_MENU3D_GRID_2P5_MM:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
g_Parm_3D_Visu.m_3D_Grid = 2.5;
break;
case ID_MENU3D_GRID_1_MM:
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] = true;
g_Parm_3D_Visu.m_3D_Grid = 1.0;
break;
default:
wxLogMessage( wxT( "EDA_3D_FRAME::On3DGridSelection() error: unknown command" ) );
return;
}
NewDisplay();
}
void EDA_3D_FRAME::NewDisplay() void EDA_3D_FRAME::NewDisplay()
{ {
......
...@@ -47,19 +47,31 @@ class S3D_Color /* 3D color (R, G, G) 3 floats range 0 to 1.0*/ ...@@ -47,19 +47,31 @@ class S3D_Color /* 3D color (R, G, G) 3 floats range 0 to 1.0*/
{ {
public: public:
double m_Red, m_Green, m_Blue; double m_Red, m_Green, m_Blue;
public: S3D_Color() public: S3D_Color()
{ {
m_Red = m_Green = m_Blue = 0; m_Red = m_Green = m_Blue = 0;
} }
}; };
class S3D_Vertex /* 3D coordinate (3 float numbers: x,y,z coordinates)*/ /* S3D_Vertex manage a 3D coordinate (3 float numbers: x,y,z coordinates)*/
class S3D_Vertex
{ {
public: public:
double x, y, z; double x, y, z;
public: public:
S3D_Vertex(); S3D_Vertex()
{
x = y = z = 0.0;
}
S3D_Vertex( double px, double py, double pz)
{
x = px;
y = py;
z = pz;
}
}; };
class S3D_MATERIAL : public EDA_ITEM /* openGL "material" data*/ class S3D_MATERIAL : public EDA_ITEM /* openGL "material" data*/
...@@ -166,26 +178,20 @@ public: ...@@ -166,26 +178,20 @@ public:
/** /**
* Class WinEDA_VertexCtrl * Class VERTEX_VALUE_CTRL
* displays a vertex for editing. A vertex is a triplet of values in INCHES, MM, * displays a vertex for editing. A vertex is a triplet of values
* or without units. * Values can be scale, rotation, offset...
*
* Internal_units are the internal units by inch which is 1000 for Eeschema and
* 10000 for Pcbnew
*/ */
class WinEDA_VertexCtrl class VERTEX_VALUE_CTRL
{ {
private: private:
int m_Units;
int m_Internal_Unit;
wxTextCtrl* m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl; wxTextCtrl* m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl;
wxStaticText* m_Text; wxStaticText* m_Text;
public: public:
WinEDA_VertexCtrl( wxWindow* parent, const wxString& title, VERTEX_VALUE_CTRL( wxWindow* parent, const wxString& title, wxBoxSizer* BoxSizer );
wxBoxSizer* BoxSizer, EDA_UNITS_T units, int internal_unit );
~WinEDA_VertexCtrl(); ~VERTEX_VALUE_CTRL();
/** /**
* Function GetValue * Function GetValue
......
...@@ -30,7 +30,9 @@ ...@@ -30,7 +30,9 @@
#include <fctsys.h> #include <fctsys.h>
#include <3d_viewer.h> #include <3d_viewer.h>
#include <info3d_visu.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <3d_viewer_id.h>
void EDA_3D_FRAME::ReCreateHToolbar() void EDA_3D_FRAME::ReCreateHToolbar()
...@@ -167,29 +169,41 @@ void EDA_3D_FRAME::ReCreateMenuBar() ...@@ -167,29 +169,41 @@ void EDA_3D_FRAME::ReCreateMenuBar()
if( full_options ) if( full_options )
{ {
item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
_( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK ); _( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]);
item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF,
_( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK ); _( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]);
item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF, // Creates grid menu
wxMenu * gridlistMenu = new wxMenu;
item = AddMenuItem( prefsMenu, gridlistMenu, ID_MENU3D_GRID,
_( "3D Grid" ), KiBitmap( grid_xpm ) );
gridlistMenu->Append( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), wxEmptyString, true );
gridlistMenu->Check( ID_MENU3D_GRID_NOGRID, true );
gridlistMenu->Append( ID_MENU3D_GRID_10_MM, _( "3D Grid 10 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_5_MM, _( "3D Grid 5 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_2P5_MM, _( "3D Grid 2.5 mm" ), wxEmptyString, true );
gridlistMenu->Append( ID_MENU3D_GRID_1_MM, _( "3D Grid 1 mm" ), wxEmptyString, true );
item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "Show &Comments Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK ); _( "Show &Comments Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]);
item = AddMenuItem( prefsMenu, ID_MENU3D_DRAWINGS_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_DRAWINGS_ONOFF,
_( "Show &Drawings Layer" ), KiBitmap( add_polygon_xpm ), wxITEM_CHECK ); _( "Show &Drawings Layer" ), KiBitmap( add_polygon_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_DRAWINGS]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_DRAWINGS]);
item = AddMenuItem( prefsMenu, ID_MENU3D_ECO1_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_ECO1_ONOFF,
_( "Show Eco&1 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK ); _( "Show Eco&1 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO1]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO1]);
item = AddMenuItem( prefsMenu, ID_MENU3D_ECO2_ONOFF, item = AddMenuItem( prefsMenu, ID_MENU3D_ECO2_ONOFF,
_( "Show Eco&2 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK ); _( "Show Eco&2 Layer" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO2]); item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO2]);
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define __3D_VIEWER_H__ #define __3D_VIEWER_H__
#include <wxBasePcbFrame.h> // m_auimanager member. #include <wxBasePcbFrame.h> // m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#if !wxUSE_GLCANVAS #if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h. #error Please set wxUSE_GLCANVAS to 1 in setup.h.
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#endif #endif
#include <3d_struct.h> #include <3d_struct.h>
#include <id.h>
class BOARD_DESIGN_SETTINGS; class BOARD_DESIGN_SETTINGS;
...@@ -62,109 +61,15 @@ class ZONE_CONTAINER; ...@@ -62,109 +61,15 @@ class ZONE_CONTAINER;
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS #define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
#define LIB3D_PATH wxT( "packages3d" ) #define LIB3D_PATH wxT( "packages3d" )
/**
* Command IDs for the 3D viewer.
*
* Please add IDs that are unique to the 3D viewer here and not in the global
* id.h file. This will prevent the entire project from being rebuilt when
* adding new commands to the 3D viewer.
*/
enum id_3dview_frm
{
ID_START_COMMAND_3D = ID_END_LIST,
ID_ROTATE3D_X_NEG,
ID_ROTATE3D_X_POS,
ID_ROTATE3D_Y_NEG,
ID_ROTATE3D_Y_POS,
ID_ROTATE3D_Z_NEG,
ID_ROTATE3D_Z_POS,
ID_RELOAD3D_BOARD,
ID_TOOL_SCREENCOPY_TOCLIBBOARD,
ID_MOVE3D_LEFT,
ID_MOVE3D_RIGHT,
ID_MOVE3D_UP,
ID_MOVE3D_DOWN,
ID_ORTHO,
ID_MENU3D_BGCOLOR_SELECTION,
ID_MENU3D_AXIS_ONOFF,
ID_MENU3D_MODULE_ONOFF,
ID_MENU3D_UNUSED,
ID_MENU3D_ZONE_ONOFF,
ID_MENU3D_DRAWINGS_ONOFF,
ID_MENU3D_COMMENTS_ONOFF,
ID_MENU3D_ECO1_ONOFF,
ID_MENU3D_ECO2_ONOFF,
ID_END_COMMAND_3D,
ID_MENU_SCREENCOPY_PNG,
ID_MENU_SCREENCOPY_JPEG,
ID_MENU_SCREENCOPY_TOCLIBBOARD,
ID_POPUP_3D_VIEW_START,
ID_POPUP_ZOOMIN,
ID_POPUP_ZOOMOUT,
ID_POPUP_VIEW_XPOS,
ID_POPUP_VIEW_XNEG,
ID_POPUP_VIEW_YPOS,
ID_POPUP_VIEW_YNEG,
ID_POPUP_VIEW_ZPOS,
ID_POPUP_VIEW_ZNEG,
ID_POPUP_MOVE3D_LEFT,
ID_POPUP_MOVE3D_RIGHT,
ID_POPUP_MOVE3D_UP,
ID_POPUP_MOVE3D_DOWN,
ID_POPUP_3D_VIEW_END
};
class EDA_3D_CANVAS; class EDA_3D_CANVAS;
class EDA_3D_FRAME; class EDA_3D_FRAME;
class Info_3D_Visu;
class S3D_Vertex; class S3D_Vertex;
class SEGVIA; class SEGVIA;
#define m_ROTX m_Rot[0]
#define m_ROTY m_Rot[1]
#define m_ROTZ m_Rot[2]
/* information needed to display 3D board */
class Info_3D_Visu
{
public:
enum {
FL_AXIS=0, FL_MODULE, FL_ZONE,
FL_COMMENTS, FL_DRAWINGS, FL_ECO1, FL_ECO2,
FL_LAST
};
double m_Beginx, m_Beginy; /* position of mouse */
double m_Quat[4]; /* orientation of object */
double m_Rot[4]; /* man rotation of object */
double m_Zoom; /* field of view in degrees */
S3D_Color m_BgColor;
bool m_DrawFlags[FL_LAST]; /* show these special items */
wxPoint m_BoardPos;
wxSize m_BoardSize;
int m_Layers;
const BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
double m_Epoxy_Width; // Epoxy thickness (normalized)
double m_BoardScale; /* Normalization scale for coordinates:
* when scaled between -1.0 and +1.0 */
double m_LayerZcoord[32];
double m_ActZpos;
public: Info_3D_Visu();
~Info_3D_Visu();
};
class EDA_3D_CANVAS : public wxGLCanvas class EDA_3D_CANVAS : public wxGLCanvas
{ {
...@@ -218,6 +123,9 @@ public: ...@@ -218,6 +123,9 @@ public:
m_draw3dOffset.x = aPosX; m_draw3dOffset.x = aPosX;
m_draw3dOffset.y = aPosY; m_draw3dOffset.y = aPosY;
} }
void DrawGrid( double aGriSizeMM );
void Draw3D_Track( TRACK* track ); void Draw3D_Track( TRACK* track );
/** /**
...@@ -275,7 +183,6 @@ private: ...@@ -275,7 +183,6 @@ private:
EDA_3D_CANVAS* m_Canvas; EDA_3D_CANVAS* m_Canvas;
wxAuiToolBar* m_HToolBar; wxAuiToolBar* m_HToolBar;
wxAuiToolBar* m_VToolBar; wxAuiToolBar* m_VToolBar;
int m_InternalUnits;
wxPoint m_FramePos; wxPoint m_FramePos;
wxSize m_FrameSize; wxSize m_FrameSize;
wxAuiManager m_auimgr; wxAuiManager m_auimgr;
...@@ -290,14 +197,6 @@ public: ...@@ -290,14 +197,6 @@ public:
}; };
PCB_BASE_FRAME* Parent() { return (PCB_BASE_FRAME*)GetParent(); } PCB_BASE_FRAME* Parent() { return (PCB_BASE_FRAME*)GetParent(); }
void Exit3DFrame( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event );
void ReCreateMenuBar();
void ReCreateHToolbar();
void ReCreateVToolbar();
void SetToolbars();
void GetSettings();
void SaveSettings();
/** /**
* Function ReloadRequest * Function ReloadRequest
...@@ -310,16 +209,33 @@ public: ...@@ -310,16 +209,33 @@ public:
m_reloadRequest = true; m_reloadRequest = true;
} }
/**
* Function NewDisplay
* Rebuild the display list.
* must be called when 3D opengl data is modified
*/
void NewDisplay();
private:
void Exit3DFrame( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event );
void ReCreateMenuBar();
void ReCreateHToolbar();
void ReCreateVToolbar();
void SetToolbars();
void GetSettings();
void SaveSettings();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); void OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
void OnKeyEvent( wxKeyEvent& event ); void OnKeyEvent( wxKeyEvent& event );
double BestZoom(); double BestZoom();
void RedrawActiveWindow( wxDC* DC, bool EraseBg ); void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void On3DGridSelection( wxCommandEvent& event );
void Process_Zoom( wxCommandEvent& event ); void Process_Zoom( wxCommandEvent& event );
void OnActivate( wxActivateEvent& event ); void OnActivate( wxActivateEvent& event );
void NewDisplay();
void Set3DBgColor(); void Set3DBgColor();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
...@@ -328,7 +244,4 @@ public: ...@@ -328,7 +244,4 @@ public:
void SetGLColor( int color ); void SetGLColor( int color );
void Set_Object_Data( std::vector< S3D_Vertex >& aVertices ); void Set_Object_Data( std::vector< S3D_Vertex >& aVertices );
extern Info_3D_Visu g_Parm_3D_Visu;
extern double DataScale3D; // 3D scale units.
#endif /* __3D_VIEWER_H__ */ #endif /* __3D_VIEWER_H__ */
/**
* @file 3d_viewer_id.h
*/
/**
* Command IDs for the 3D viewer.
*
* Please add IDs that are unique to the 3D viewer here and not in the global
* id.h file. This will prevent the entire project from being rebuilt when
* adding new commands to the 3D viewer.
*/
#include <id.h> // Generic Id.
enum id_3dview_frm
{
ID_START_COMMAND_3D = ID_END_LIST,
ID_ROTATE3D_X_NEG,
ID_ROTATE3D_X_POS,
ID_ROTATE3D_Y_NEG,
ID_ROTATE3D_Y_POS,
ID_ROTATE3D_Z_NEG,
ID_ROTATE3D_Z_POS,
ID_RELOAD3D_BOARD,
ID_TOOL_SCREENCOPY_TOCLIBBOARD,
ID_MOVE3D_LEFT,
ID_MOVE3D_RIGHT,
ID_MOVE3D_UP,
ID_MOVE3D_DOWN,
ID_ORTHO,
ID_MENU3D_BGCOLOR_SELECTION,
ID_MENU3D_AXIS_ONOFF,
ID_MENU3D_MODULE_ONOFF,
ID_MENU3D_ZONE_ONOFF,
ID_MENU3D_DRAWINGS_ONOFF,
ID_MENU3D_COMMENTS_ONOFF,
ID_MENU3D_ECO1_ONOFF,
ID_MENU3D_ECO2_ONOFF,
ID_END_COMMAND_3D,
ID_MENU3D_GRID,
ID_MENU3D_GRID_NOGRID,
ID_MENU3D_GRID_10_MM,
ID_MENU3D_GRID_5_MM,
ID_MENU3D_GRID_2P5_MM,
ID_MENU3D_GRID_1_MM,
ID_MENU3D_GRID_END,
ID_MENU_SCREENCOPY_PNG,
ID_MENU_SCREENCOPY_JPEG,
ID_MENU_SCREENCOPY_TOCLIBBOARD,
ID_POPUP_3D_VIEW_START,
ID_POPUP_ZOOMIN,
ID_POPUP_ZOOMOUT,
ID_POPUP_VIEW_XPOS,
ID_POPUP_VIEW_XNEG,
ID_POPUP_VIEW_YPOS,
ID_POPUP_VIEW_YNEG,
ID_POPUP_VIEW_ZPOS,
ID_POPUP_VIEW_ZNEG,
ID_POPUP_MOVE3D_LEFT,
ID_POPUP_MOVE3D_RIGHT,
ID_POPUP_MOVE3D_UP,
ID_POPUP_MOVE3D_DOWN,
ID_POPUP_3D_VIEW_END
};
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file 3d_viewer.h
*/
#ifndef __INFO3D_VISU_H__
#define __INFO3D_VISU_H__
#include <wxBasePcbFrame.h> // m_auimanager member.
#include <layers_id_colors_and_visibility.h> // Layers id definitions
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <wx/glcanvas.h>
#ifdef __WXMAC__
# ifdef __DARWIN__
# include <OpenGL/glu.h>
# else
# include <glu.h>
# endif
#else
# include <GL/glu.h>
#endif
#include <3d_struct.h>
#define m_ROTX m_Rot[0]
#define m_ROTY m_Rot[1]
#define m_ROTZ m_Rot[2]
/* information needed to display 3D board */
class INFO3D_VISU
{
public:
enum DISPLAY3D_FLG
{
FL_AXIS=0, FL_MODULE, FL_ZONE,
FL_COMMENTS, FL_DRAWINGS, FL_ECO1, FL_ECO2,
FL_GRID,
FL_LAST
};
double m_Beginx, m_Beginy; // position of mouse
double m_Quat[4]; // orientation of object
double m_Rot[4]; // man rotation of object
double m_Zoom; // field of view in degrees
double m_3D_Grid; // 3D grid valmue, in mm
S3D_Color m_BgColor;
bool m_DrawFlags[FL_LAST]; // show these special items
wxPoint m_BoardPos;
wxSize m_BoardSize;
int m_CopperLayersCount; // Number of copper layers actually used by the board
const BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
double m_EpoxyThickness; // Epoxy thickness (normalized)
double m_NonCopperLayerThickness; // Non copper layers thickness
double m_BoardScale; /* Normalization scale for coordinates:
* when scaled between -1.0 and +1.0 */
double m_LayerZcoord[LAYER_COUNT]; // Z position of each layer (normalized)
double m_ActZpos;
public: INFO3D_VISU();
~INFO3D_VISU();
};
extern INFO3D_VISU g_Parm_3D_Visu;
extern double DataScale3D; // 3D scale units.
#endif /* __INFO3D_VISU_H__ */
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
width="26" width="26"
version="1.1" version="1.1"
id="svg2" id="svg2"
inkscape:version="0.48.2 r9819" inkscape:version="0.48.1 "
sodipodi:docname="add_hierarchical_label.svg"> sodipodi:docname="add_hierarchical_label.svg">
<metadata <metadata
id="metadata22"> id="metadata22">
...@@ -801,14 +801,14 @@ ...@@ -801,14 +801,14 @@
inkscape:pageopacity="0" inkscape:pageopacity="0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:window-width="1280" inkscape:window-width="1280"
inkscape:window-height="941" inkscape:window-height="968"
id="namedview18" id="namedview18"
showgrid="true" showgrid="true"
inkscape:zoom="27.812867" inkscape:zoom="30.205858"
inkscape:cx="13.075538" inkscape:cx="14.001662"
inkscape:cy="10.42187" inkscape:cy="12.978439"
inkscape:window-x="0" inkscape:window-x="-4"
inkscape:window-y="30" inkscape:window-y="-4"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="svg2" inkscape:current-layer="svg2"
inkscape:snap-grids="false" inkscape:snap-grids="false"
...@@ -929,7 +929,7 @@ ...@@ -929,7 +929,7 @@
id="path42" id="path42"
d="m 12.030832,21.080758 7.978779,0 3.419474,-6.034091 -3.419474,-6.0340911 -7.978779,0 0,12.0681821 z" d="m 12.030832,21.080758 7.978779,0 3.419474,-6.034091 -3.419474,-6.0340911 -7.978779,0 0,12.0681821 z"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
style="fill:none;stroke:#d50000;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> style="fill:none;stroke:#997a00;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path <path
sodipodi:nodetypes="ccccccccccc" sodipodi:nodetypes="ccccccccccc"
id="path40" id="path40"
......
...@@ -57,7 +57,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC ...@@ -57,7 +57,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
SCH_COMPONENT* LibItem = NULL; SCH_COMPONENT* LibItem = NULL;
wxPoint gridPosition = GetScreen()->GetNearestGridPosition( aPosition ); wxPoint gridPosition = GetScreen()->GetNearestGridPosition( aPosition );
// Check the on grid position first. There is more likely to be multple items on // Check the on grid position first. There is more likely to be multiple items on
// grid than off grid. // grid than off grid.
item = LocateItem( gridPosition, aFilterList, aHotKeyCommandId ); item = LocateItem( gridPosition, aFilterList, aHotKeyCommandId );
...@@ -197,7 +197,16 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -197,7 +197,16 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos; wxPoint oldpos;
wxPoint pos = aPosition; wxPoint pos = aPosition;
pos = screen->GetNearestGridPosition( pos ); // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
// for next cursor position
// ( shift or ctrl key down are PAN command with mouse wheel)
bool snapToGrid = true;
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
snapToGrid = false;
if( snapToGrid )
pos = screen->GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition(); oldpos = screen->GetCrossHairPosition();
gridSize = screen->GetGridSize(); gridSize = screen->GetGridSize();
...@@ -235,14 +244,14 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -235,14 +244,14 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
} }
// Update cursor position. // Update cursor position.
screen->SetCrossHairPosition( pos ); screen->SetCrossHairPosition( pos, snapToGrid );
if( oldpos != screen->GetCrossHairPosition() ) if( oldpos != screen->GetCrossHairPosition() )
{ {
pos = screen->GetCrossHairPosition(); pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos ); screen->SetCrossHairPosition( oldpos, false);
m_canvas->CrossHairOff( aDC ); m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos ); screen->SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC ); m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
...@@ -282,7 +291,16 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -282,7 +291,16 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos; wxPoint oldpos;
wxPoint pos = aPosition; wxPoint pos = aPosition;
pos = screen->GetNearestGridPosition( pos ); // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
// for next cursor position
// ( shift or ctrl key down are PAN command with mouse wheel)
bool snapToGrid = true;
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
snapToGrid = false;
if( snapToGrid )
pos = screen->GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition(); oldpos = screen->GetCrossHairPosition();
gridSize = screen->GetGridSize(); gridSize = screen->GetGridSize();
...@@ -320,14 +338,14 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -320,14 +338,14 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
} }
// Update the cursor position. // Update the cursor position.
screen->SetCrossHairPosition( pos ); screen->SetCrossHairPosition( pos, snapToGrid );
if( oldpos != screen->GetCrossHairPosition() ) if( oldpos != screen->GetCrossHairPosition() )
{ {
pos = screen->GetCrossHairPosition(); pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos ); screen->SetCrossHairPosition( oldpos, false );
m_canvas->CrossHairOff( aDC ); m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos ); screen->SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC ); m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
......
...@@ -67,4 +67,11 @@ inline int Mils2iu( int mils ) ...@@ -67,4 +67,11 @@ inline int Mils2iu( int mils )
} }
#endif #endif
/// Convert mm to internal units (iu).
inline int Millimeter2iu( double mm )
{
return (int) ( mm < 0 ? mm * IU_PER_MM - 0.5 : mm * IU_PER_MM + 0.5);
}
#endif // CONVERT_TO_BIU_H_ #endif // CONVERT_TO_BIU_H_
...@@ -262,7 +262,17 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -262,7 +262,17 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
{ {
wxRealPoint gridSize; wxRealPoint gridSize;
wxPoint oldpos; wxPoint oldpos;
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); wxPoint pos = aPosition;
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
// for next cursor position
// ( shift or ctrl key down are PAN command with mouse wheel)
bool snapToGrid = true;
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
snapToGrid = false;
if( snapToGrid )
pos = GetScreen()->GetNearestGridPosition( pos );
oldpos = GetScreen()->GetCrossHairPosition(); oldpos = GetScreen()->GetCrossHairPosition();
...@@ -299,51 +309,42 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -299,51 +309,42 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
} }
// Put cursor in new position, according to the zoom keys (if any). // Put cursor in new position, according to the zoom keys (if any).
GetScreen()->SetCrossHairPosition( pos ); GetScreen()->SetCrossHairPosition( pos, snapToGrid );
/* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the
* cursor is left off grid this is better to reach items to delete off grid, * cursor is left off grid this is better to reach items to delete off grid,
*/ */
bool keep_on_grid = true;
if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT ) if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = false; snapToGrid = false;
/* Cursor is left off grid if no block in progress and no moving object */ // Cursor is left off grid if no block in progress
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
keep_on_grid = true; snapToGrid = true;
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem(); wxPoint curs_pos = pos;
if( DrawStruct && DrawStruct->GetFlags() ) wxSize grid;
keep_on_grid = true; grid.x = KiROUND( GetScreen()->GetGridSize().x );
grid.y = KiROUND( GetScreen()->GetGridSize().y );
if( keep_on_grid ) if( Magnetize( m_Pcb, this, GetToolId(), grid, curs_pos, &pos ) )
{ {
wxPoint on_grid = GetScreen()->GetNearestGridPosition( pos ); GetScreen()->SetCrossHairPosition( pos, false );
}
wxSize grid; else
grid.x = (int) GetScreen()->GetGridSize().x; {
grid.y = (int) GetScreen()->GetGridSize().y; // If there's no intrusion and DRC is active, we pass the cursor
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
if( Magnetize( m_Pcb, this, GetToolId(), grid, on_grid, &pos ) ) if( !Drc_On || !g_CurrentTrackSegment
{ || (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem()
GetScreen()->SetCrossHairPosition( pos, false ); || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment,
} GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) )
else
{ {
// If there's no intrusion and DRC is active, we pass the cursor GetScreen()->SetCrossHairPosition( curs_pos, snapToGrid );
// "as is", and let ShowNewTrackWhenMovingCursor figure out what to do.
if( !Drc_On || !g_CurrentTrackSegment
|| (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem()
|| !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment,
GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) )
{
GetScreen()->SetCrossHairPosition( on_grid );
}
} }
} }
if( oldpos != GetScreen()->GetCrossHairPosition() ) if( oldpos != GetScreen()->GetCrossHairPosition() )
{ {
pos = GetScreen()->GetCrossHairPosition(); pos = GetScreen()->GetCrossHairPosition();
......
...@@ -312,18 +312,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() ...@@ -312,18 +312,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
// Initialize 3D parameters // Initialize 3D parameters
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), m_3D_Scale = new VERTEX_VALUE_CTRL( m_Panel3D, _( "Shape Scale:" ), BoxSizer );
BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL ); BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), m_3D_Offset = new VERTEX_VALUE_CTRL( m_Panel3D, _( "Shape Offset (inch):" ), BoxSizer );
BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL ); BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), m_3D_Rotation = new VERTEX_VALUE_CTRL( m_Panel3D,
BoxSizer, UNSCALED_UNITS, 1 ); _( "Shape Rotation (degrees):" ), BoxSizer );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
// if m_3D_ShapeNameListBox is not empty, preselect first 3D shape // if m_3D_ShapeNameListBox is not empty, preselect first 3D shape
......
...@@ -20,9 +20,9 @@ private: ...@@ -20,9 +20,9 @@ private:
TEXTE_MODULE* m_ValueCopy; TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_MASTER*> m_Shapes3D_list; std::vector <S3D_MASTER*> m_Shapes3D_list;
int m_LastSelected3DShapeIndex; int m_LastSelected3DShapeIndex;
WinEDA_VertexCtrl * m_3D_Scale; VERTEX_VALUE_CTRL * m_3D_Scale;
WinEDA_VertexCtrl * m_3D_Offset; VERTEX_VALUE_CTRL * m_3D_Offset;
WinEDA_VertexCtrl * m_3D_Rotation; VERTEX_VALUE_CTRL * m_3D_Rotation;
public: public:
......
...@@ -131,15 +131,15 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() ...@@ -131,15 +131,15 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
// Initialize 3D parameters // Initialize 3D parameters
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), BoxSizer, UNSCALED_UNITS, 1 ); m_3D_Scale = new VERTEX_VALUE_CTRL( m_Panel3D, _( "Shape Scale:" ), BoxSizer );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL ); BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), BoxSizer, UNSCALED_UNITS, 1 ); m_3D_Offset = new VERTEX_VALUE_CTRL( m_Panel3D, _( "Shape Offset (inch):" ), BoxSizer );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL ); BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, UNSCALED_UNITS, 1 ); m_3D_Rotation = new VERTEX_VALUE_CTRL( m_Panel3D, _( "Shape Rotation (degrees):" ), BoxSizer );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 ); m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
// Initialize dialog relative to masks clearances // Initialize dialog relative to masks clearances
......
...@@ -23,9 +23,9 @@ private: ...@@ -23,9 +23,9 @@ private:
TEXTE_MODULE* m_ValueCopy; TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_MASTER*> m_Shapes3D_list; std::vector <S3D_MASTER*> m_Shapes3D_list;
int m_LastSelected3DShapeIndex; int m_LastSelected3DShapeIndex;
WinEDA_VertexCtrl * m_3D_Scale; VERTEX_VALUE_CTRL * m_3D_Scale;
WinEDA_VertexCtrl * m_3D_Offset; VERTEX_VALUE_CTRL * m_3D_Offset;
WinEDA_VertexCtrl * m_3D_Rotation; VERTEX_VALUE_CTRL * m_3D_Rotation;
public: public:
......
...@@ -343,7 +343,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -343,7 +343,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// 3D Display // 3D Display
AddMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME, AddMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME,
_( "3&D Display" ),_( "Show board in 3D viewer" ), _( "&3D Display" ),_( "Show board in 3D viewer" ),
KiBitmap( three_d_xpm ) ); KiBitmap( three_d_xpm ) );
// List Nets // List Nets
...@@ -372,7 +372,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -372,7 +372,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Keepout areas // Keepout areas
AddMenuItem( placeMenu, ID_PCB_KEEPOUT_AREA_BUTT, AddMenuItem( placeMenu, ID_PCB_KEEPOUT_AREA_BUTT,
_( "&Zone" ), _( "Add keepout areas" ), KiBitmap( add_keepout_area_xpm ) ); _( "&Keepout Area" ), _( "Add keepout areas" ), KiBitmap( add_keepout_area_xpm ) );
// Text // Text
AddMenuItem( placeMenu, ID_PCB_ADD_TEXT_BUTT, AddMenuItem( placeMenu, ID_PCB_ADD_TEXT_BUTT,
......
...@@ -429,7 +429,16 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, ...@@ -429,7 +429,16 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
wxPoint oldpos; wxPoint oldpos;
wxPoint pos = aPosition; wxPoint pos = aPosition;
pos = GetScreen()->GetNearestGridPosition( aPosition ); // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
// for next cursor position
// ( shift or ctrl key down are PAN command with mouse wheel)
bool snapToGrid = true;
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
snapToGrid = false;
if( snapToGrid )
pos = GetScreen()->GetNearestGridPosition( pos );
oldpos = GetScreen()->GetCrossHairPosition(); oldpos = GetScreen()->GetCrossHairPosition();
gridSize = GetScreen()->GetGridSize(); gridSize = GetScreen()->GetGridSize();
...@@ -463,14 +472,14 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, ...@@ -463,14 +472,14 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
break; break;
} }
GetScreen()->SetCrossHairPosition( pos ); GetScreen()->SetCrossHairPosition( pos, snapToGrid );
if( oldpos != GetScreen()->GetCrossHairPosition() ) if( oldpos != GetScreen()->GetCrossHairPosition() )
{ {
pos = GetScreen()->GetCrossHairPosition(); pos = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( oldpos ); GetScreen()->SetCrossHairPosition( oldpos, false );
m_canvas->CrossHairOff( aDC ); m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( pos ); GetScreen()->SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC ); m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment