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 @@
#include <class_pcb_text.h>
#include <3d_viewer.h>
#include <info3d_visu.h>
#include <trackball.h>
......@@ -176,47 +177,45 @@ GLuint EDA_3D_CANVAS::DisplayCubeforTest()
}
Info_3D_Visu::Info_3D_Visu()
INFO3D_VISU::INFO3D_VISU()
{
int ii;
m_Beginx = m_Beginy = 0.0; /* position of mouse */
m_Zoom = 1.0; /* field of view in degrees */
m_Beginx = m_Beginy = 0.0; // position of mouse
m_Zoom = 1.0;
m_3D_Grid = 10.0; // Grid value in mm
trackball( m_Quat, 0.0, 0.0, 0.0, 0.0 );
for( ii = 0; ii < 4; ii++ )
m_Rot[ii] = 0.0;
m_Layers = 1;
m_CopperLayersCount = 2;
m_BoardSettings = NULL;
// default all special item layers Visible
for (ii=0; ii< FL_LAST; ii++)
m_DrawFlags[ii]=true;
for( ii = 0; ii < FL_LAST; ii++)
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,
wxBoxSizer* BoxSizer,
EDA_UNITS_T units, int internal_unit )
VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* parent, const wxString& title,
wxBoxSizer* BoxSizer )
{
wxString text;
wxStaticText* msgtitle;
m_Units = units;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() )
text = _( "Vertex " );
else
text = title;
text += ReturnUnitSymbol( units );
msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 );
BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM );
......@@ -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;
double dtmp;
......@@ -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;
......@@ -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_YValueCtrl->Enable( onoff );
......
......@@ -17,7 +17,9 @@
#include <gestfich.h>
#include <3d_viewer.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <3d_viewer_id.h>
// -----------------
......
......@@ -6,13 +6,6 @@
#include <3d_viewer.h>
S3D_Vertex::S3D_Vertex()
{
x = y = z = 0.0;
}
S3D_MATERIAL::S3D_MATERIAL( S3D_MASTER* father, const wxString& name ) :
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 <appl_wxstruct.h>
#if !wxUSE_GLCANVAS
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
#endif
#include <3d_viewer.h>
#include <info3d_visu.h>
#include <trackball.h>
#include <wx/colordlg.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.
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
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,
EDA_3D_FRAME::Process_Special_Functions )
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_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 )
END_EVENT_TABLE()
......@@ -38,7 +65,6 @@ EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long
m_Canvas = NULL;
m_HToolBar = NULL;
m_VToolBar = NULL;
m_InternalUnits = 10000; // Internal units = 1/10000 inch
m_reloadRequest = false;
// Give it an icon
......@@ -322,7 +348,7 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
return;
default:
wxMessageBox( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
wxLogMessage( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
return;
}
......@@ -330,6 +356,52 @@ void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
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()
{
......
......@@ -47,19 +47,31 @@ class S3D_Color /* 3D color (R, G, G) 3 floats range 0 to 1.0*/
{
public:
double m_Red, m_Green, m_Blue;
public: S3D_Color()
{
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:
double x, y, z;
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*/
......@@ -166,26 +178,20 @@ public:
/**
* Class WinEDA_VertexCtrl
* displays a vertex for editing. A vertex is a triplet of values in INCHES, MM,
* or without units.
*
* Internal_units are the internal units by inch which is 1000 for Eeschema and
* 10000 for Pcbnew
* Class VERTEX_VALUE_CTRL
* displays a vertex for editing. A vertex is a triplet of values
* Values can be scale, rotation, offset...
*/
class WinEDA_VertexCtrl
class VERTEX_VALUE_CTRL
{
private:
int m_Units;
int m_Internal_Unit;
wxTextCtrl* m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl;
wxStaticText* m_Text;
public:
WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
wxBoxSizer* BoxSizer, EDA_UNITS_T units, int internal_unit );
VERTEX_VALUE_CTRL( wxWindow* parent, const wxString& title, wxBoxSizer* BoxSizer );
~WinEDA_VertexCtrl();
~VERTEX_VALUE_CTRL();
/**
* Function GetValue
......
......@@ -30,7 +30,9 @@
#include <fctsys.h>
#include <3d_viewer.h>
#include <info3d_visu.h>
#include <menus_helpers.h>
#include <3d_viewer_id.h>
void EDA_3D_FRAME::ReCreateHToolbar()
......@@ -175,6 +177,18 @@ void EDA_3D_FRAME::ReCreateMenuBar()
_( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]);
// 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 );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]);
......
......@@ -31,7 +31,7 @@
#define __3D_VIEWER_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.
......@@ -50,7 +50,6 @@
#endif
#include <3d_struct.h>
#include <id.h>
class BOARD_DESIGN_SETTINGS;
......@@ -62,109 +61,15 @@ class ZONE_CONTAINER;
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
#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_FRAME;
class Info_3D_Visu;
class S3D_Vertex;
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
{
......@@ -218,6 +123,9 @@ public:
m_draw3dOffset.x = aPosX;
m_draw3dOffset.y = aPosY;
}
void DrawGrid( double aGriSizeMM );
void Draw3D_Track( TRACK* track );
/**
......@@ -275,7 +183,6 @@ private:
EDA_3D_CANVAS* m_Canvas;
wxAuiToolBar* m_HToolBar;
wxAuiToolBar* m_VToolBar;
int m_InternalUnits;
wxPoint m_FramePos;
wxSize m_FrameSize;
wxAuiManager m_auimgr;
......@@ -290,14 +197,6 @@ public:
};
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
......@@ -310,16 +209,33 @@ public:
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 OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
void OnKeyEvent( wxKeyEvent& event );
double BestZoom();
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void Process_Special_Functions( wxCommandEvent& event );
void On3DGridSelection( wxCommandEvent& event );
void Process_Zoom( wxCommandEvent& event );
void OnActivate( wxActivateEvent& event );
void NewDisplay();
void Set3DBgColor();
DECLARE_EVENT_TABLE()
......@@ -328,7 +244,4 @@ public:
void SetGLColor( int color );
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__ */
/**
* @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 @@
width="26"
version="1.1"
id="svg2"
inkscape:version="0.48.2 r9819"
inkscape:version="0.48.1 "
sodipodi:docname="add_hierarchical_label.svg">
<metadata
id="metadata22">
......@@ -801,14 +801,14 @@
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1280"
inkscape:window-height="941"
inkscape:window-height="968"
id="namedview18"
showgrid="true"
inkscape:zoom="27.812867"
inkscape:cx="13.075538"
inkscape:cy="10.42187"
inkscape:window-x="0"
inkscape:window-y="30"
inkscape:zoom="30.205858"
inkscape:cx="14.001662"
inkscape:cy="12.978439"
inkscape:window-x="-4"
inkscape:window-y="-4"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-grids="false"
......@@ -929,7 +929,7 @@
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"
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
sodipodi:nodetypes="ccccccccccc"
id="path40"
......
......@@ -57,7 +57,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
SCH_COMPONENT* LibItem = NULL;
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.
item = LocateItem( gridPosition, aFilterList, aHotKeyCommandId );
......@@ -197,7 +197,16 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos;
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 = screen->GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition();
gridSize = screen->GetGridSize();
......@@ -235,14 +244,14 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// Update cursor position.
screen->SetCrossHairPosition( pos );
screen->SetCrossHairPosition( pos, snapToGrid );
if( oldpos != screen->GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos );
screen->SetCrossHairPosition( oldpos, false);
m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos );
screen->SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......@@ -282,7 +291,16 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
wxPoint oldpos;
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 = screen->GetNearestGridPosition( pos );
oldpos = screen->GetCrossHairPosition();
gridSize = screen->GetGridSize();
......@@ -320,14 +338,14 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// Update the cursor position.
screen->SetCrossHairPosition( pos );
screen->SetCrossHairPosition( pos, snapToGrid );
if( oldpos != screen->GetCrossHairPosition() )
{
pos = screen->GetCrossHairPosition();
screen->SetCrossHairPosition( oldpos );
screen->SetCrossHairPosition( oldpos, false );
m_canvas->CrossHairOff( aDC );
screen->SetCrossHairPosition( pos );
screen->SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC );
if( m_canvas->IsMouseCaptured() )
......
......@@ -67,4 +67,11 @@ inline int Mils2iu( int mils )
}
#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_
......@@ -262,7 +262,17 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
{
wxRealPoint gridSize;
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();
......@@ -299,34 +309,25 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
// 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
* 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 )
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 )
keep_on_grid = true;
EDA_ITEM* DrawStruct = GetScreen()->GetCurItem();
snapToGrid = true;
if( DrawStruct && DrawStruct->GetFlags() )
keep_on_grid = true;
if( keep_on_grid )
{
wxPoint on_grid = GetScreen()->GetNearestGridPosition( pos );
wxPoint curs_pos = pos;
wxSize grid;
grid.x = (int) GetScreen()->GetGridSize().x;
grid.y = (int) GetScreen()->GetGridSize().y;
grid.x = KiROUND( GetScreen()->GetGridSize().x );
grid.y = KiROUND( GetScreen()->GetGridSize().y );
if( Magnetize( m_Pcb, this, GetToolId(), grid, on_grid, &pos ) )
if( Magnetize( m_Pcb, this, GetToolId(), grid, curs_pos, &pos ) )
{
GetScreen()->SetCrossHairPosition( pos, false );
}
......@@ -339,11 +340,11 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
|| !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment,
GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) )
{
GetScreen()->SetCrossHairPosition( on_grid );
}
GetScreen()->SetCrossHairPosition( curs_pos, snapToGrid );
}
}
if( oldpos != GetScreen()->GetCrossHairPosition() )
{
pos = GetScreen()->GetCrossHairPosition();
......
......@@ -312,18 +312,16 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
// Initialize 3D parameters
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 );
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 );
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 );
// if m_3D_ShapeNameListBox is not empty, preselect first 3D shape
......
......@@ -20,9 +20,9 @@ private:
TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_MASTER*> m_Shapes3D_list;
int m_LastSelected3DShapeIndex;
WinEDA_VertexCtrl * m_3D_Scale;
WinEDA_VertexCtrl * m_3D_Offset;
WinEDA_VertexCtrl * m_3D_Rotation;
VERTEX_VALUE_CTRL * m_3D_Scale;
VERTEX_VALUE_CTRL * m_3D_Offset;
VERTEX_VALUE_CTRL * m_3D_Rotation;
public:
......
......@@ -131,15 +131,15 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
// Initialize 3D parameters
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 );
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 );
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 );
// Initialize dialog relative to masks clearances
......
......@@ -23,9 +23,9 @@ private:
TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_MASTER*> m_Shapes3D_list;
int m_LastSelected3DShapeIndex;
WinEDA_VertexCtrl * m_3D_Scale;
WinEDA_VertexCtrl * m_3D_Offset;
WinEDA_VertexCtrl * m_3D_Rotation;
VERTEX_VALUE_CTRL * m_3D_Scale;
VERTEX_VALUE_CTRL * m_3D_Offset;
VERTEX_VALUE_CTRL * m_3D_Rotation;
public:
......
......@@ -343,7 +343,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// 3D Display
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 ) );
// List Nets
......@@ -372,7 +372,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Keepout areas
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
AddMenuItem( placeMenu, ID_PCB_ADD_TEXT_BUTT,
......
......@@ -429,7 +429,16 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
wxPoint oldpos;
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();
gridSize = GetScreen()->GetGridSize();
......@@ -463,14 +472,14 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
break;
}
GetScreen()->SetCrossHairPosition( pos );
GetScreen()->SetCrossHairPosition( pos, snapToGrid );
if( oldpos != GetScreen()->GetCrossHairPosition() )
{
pos = GetScreen()->GetCrossHairPosition();
GetScreen()->SetCrossHairPosition( oldpos );
GetScreen()->SetCrossHairPosition( oldpos, false );
m_canvas->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( pos );
GetScreen()->SetCrossHairPosition( pos, snapToGrid );
m_canvas->CrossHairOn( aDC );
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