2012-08-11 12:52:13 +00:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <3d_viewer.h>
|
2012-12-15 08:52:02 +00:00
|
|
|
#include <3d_canvas.h>
|
2012-08-11 12:52:13 +00:00
|
|
|
#include <info3d_visu.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trackball.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include <wx/colordlg.h>
|
2009-11-02 22:24:55 +00:00
|
|
|
#include <wxstruct.h>
|
2012-08-11 12:52:13 +00:00
|
|
|
#include <3d_viewer_id.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
INFO3D_VISU g_Parm_3D_Visu;
|
|
|
|
|
|
|
|
// Key to store 3D Viewer config:
|
|
|
|
static const wxString keyPosx( wxT( "Pos_x" ) );
|
|
|
|
static const wxString keyPosy( wxT( "Pos_y" ) );
|
|
|
|
static const wxString keySizex( wxT( "Size_x" ) );
|
|
|
|
static const wxString keySizey( wxT( "Size_y" ) );
|
|
|
|
static const wxString keyBgColor_Red( wxT( "BgColor_Red" ) );
|
|
|
|
static const wxString keyBgColor_Green( wxT( "BgColor_Green" ) );
|
|
|
|
static const wxString keyBgColor_Blue( wxT( "BgColor_Blue" ) );
|
|
|
|
static const wxString keyShowAxis( wxT( "ShowAxis" ) );
|
|
|
|
static const wxString keyShowZones( wxT( "ShowZones" ) );
|
|
|
|
static const wxString keyShowFootprints( wxT( "ShowFootprints" ) );
|
|
|
|
static const wxString keyShowCopperThickness( wxT( "ShowCopperThickness" ) );
|
2013-05-16 19:04:21 +00:00
|
|
|
static const wxString keyShowAdhesiveLayers( wxT( "ShowAdhesiveLayers" ) );
|
|
|
|
static const wxString keyShowSilkScreenLayers( wxT( "ShowSilkScreenLayers" ) );
|
|
|
|
static const wxString keyShowSolderMaskLayers( wxT( "ShowSolderMasLayers" ) );
|
|
|
|
static const wxString keyShowSolderPasteLayers( wxT( "ShowSolderPasteLayers" ) );
|
|
|
|
static const wxString keyShowCommentsLayer( wxT( "ShowCommentsLayers" ) );
|
|
|
|
static const wxString keyShowEcoLayers( wxT( "ShowEcoLayers" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
|
2012-12-15 08:52:02 +00:00
|
|
|
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
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 )
|
2013-05-16 19:04:21 +00:00
|
|
|
EVT_TOOL( ID_TOOL_SET_VISIBLE_ITEMS, EDA_3D_FRAME::Process_Special_Functions )
|
2012-12-15 08:52:02 +00:00
|
|
|
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 )
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END,
|
|
|
|
EDA_3D_FRAME::On3DGridSelection )
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
|
2012-08-11 12:52:13 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent,
|
|
|
|
const wxString& title,
|
|
|
|
long style ) :
|
|
|
|
wxFrame( parent, DISPLAY3D_FRAME_TYPE, title, wxDefaultPosition, wxDefaultSize, style )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-12-15 08:52:02 +00:00
|
|
|
m_frameName = wxT( "Frame3D" );
|
|
|
|
m_canvas = NULL;
|
2008-03-21 19:25:41 +00:00
|
|
|
m_HToolBar = NULL;
|
|
|
|
m_VToolBar = NULL;
|
2010-05-01 12:46:33 +00:00
|
|
|
m_reloadRequest = false;
|
2012-12-15 08:52:02 +00:00
|
|
|
m_ortho = false;
|
2008-03-21 19:25:41 +00:00
|
|
|
|
|
|
|
// Give it an icon
|
2012-12-15 08:52:02 +00:00
|
|
|
wxIcon icon;
|
2011-09-11 11:38:01 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
|
|
|
|
SetIcon( icon );
|
2008-03-21 19:25:41 +00:00
|
|
|
|
|
|
|
GetSettings();
|
2012-12-15 08:52:02 +00:00
|
|
|
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
2008-03-21 19:25:41 +00:00
|
|
|
|
|
|
|
// Create the status line
|
2009-08-07 04:44:42 +00:00
|
|
|
static const int dims[5] = { -1, 100, 100, 100, 140 };
|
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
CreateStatusBar( 5 );
|
|
|
|
SetStatusWidths( 5, dims );
|
2009-08-07 04:44:42 +00:00
|
|
|
|
2013-05-25 09:01:44 +00:00
|
|
|
CreateMenuBar();
|
2008-03-21 19:25:41 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
// ReCreateAuxiliaryToolbar();
|
2008-03-21 19:25:41 +00:00
|
|
|
ReCreateVToolbar();
|
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
// Make a EDA_3D_CANVAS
|
2011-08-03 15:09:39 +00:00
|
|
|
int attrs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 };
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas = new EDA_3D_CANVAS( this, attrs );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2011-09-15 18:25:44 +00:00
|
|
|
|
|
|
|
EDA_PANEINFO horiz;
|
|
|
|
horiz.HorizontalToolbarPane();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
|
|
|
m_auimgr.AddPane( m_HToolBar,
|
|
|
|
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top() );
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
m_auimgr.AddPane( m_canvas,
|
2009-11-04 20:46:53 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
|
|
|
m_auimgr.Update();
|
2011-08-03 15:09:39 +00:00
|
|
|
|
|
|
|
// Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
|
|
|
|
// in order to receive mouse events. Otherwise, the user has to click somewhere on
|
|
|
|
// the canvas before it will respond to mouse wheel events.
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->SetFocus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::Exit3DFrame( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-08-03 15:09:39 +00:00
|
|
|
Close( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-21 19:25:41 +00:00
|
|
|
SaveSettings();
|
2011-08-03 15:09:39 +00:00
|
|
|
|
2012-02-25 19:55:40 +00:00
|
|
|
if( Parent() )
|
|
|
|
Parent()->m_Draw3DFrame = NULL;
|
2011-08-03 15:09:39 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::GetSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-12-15 08:52:02 +00:00
|
|
|
wxString text;
|
|
|
|
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
|
2008-03-21 19:25:41 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( config )
|
2008-03-21 19:25:41 +00:00
|
|
|
{
|
2012-12-15 08:52:02 +00:00
|
|
|
text = m_frameName + keyPosx;
|
|
|
|
config->Read( text, &m_framePos.x );
|
|
|
|
text = m_frameName + keyPosy;
|
|
|
|
config->Read( text, &m_framePos.y );
|
|
|
|
text = m_frameName + keySizex;
|
|
|
|
config->Read( text, &m_frameSize.x, 600 );
|
|
|
|
text = m_frameName + keySizey;
|
|
|
|
config->Read( text, &m_frameSize.y, 400 );
|
2012-08-26 13:59:55 +00:00
|
|
|
config->Read( keyBgColor_Red, &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
|
|
|
|
config->Read( keyBgColor_Green, &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
|
|
|
|
config->Read( keyBgColor_Blue, &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
|
2012-12-15 08:52:02 +00:00
|
|
|
class INFO3D_VISU& prms = g_Parm_3D_Visu;
|
|
|
|
config->Read( keyShowAxis, &prms.m_DrawFlags[prms.FL_AXIS], true );
|
|
|
|
config->Read( keyShowFootprints, &prms.m_DrawFlags[prms.FL_MODULE], true );
|
|
|
|
config->Read( keyShowCopperThickness,
|
|
|
|
&prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS],
|
|
|
|
false );
|
|
|
|
config->Read( keyShowZones, &prms.m_DrawFlags[prms.FL_ZONE], true );
|
2013-05-16 19:04:21 +00:00
|
|
|
config->Read( keyShowAdhesiveLayers, &prms.m_DrawFlags[prms.FL_ADHESIVE], true );
|
|
|
|
config->Read( keyShowSilkScreenLayers, &prms.m_DrawFlags[prms.FL_SILKSCREEN], true );
|
|
|
|
config->Read( keyShowSolderMaskLayers, &prms.m_DrawFlags[prms.FL_SOLDERMASK], true );
|
|
|
|
config->Read( keyShowSolderPasteLayers, &prms.m_DrawFlags[prms.FL_SOLDERPASTE], true );
|
|
|
|
config->Read( keyShowCommentsLayer, &prms.m_DrawFlags[prms.FL_COMMENTS], true );
|
|
|
|
config->Read( keyShowEcoLayers, &prms.m_DrawFlags[prms.FL_ECO], true );
|
2008-03-21 19:25:41 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::SaveSettings()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-12-15 08:52:02 +00:00
|
|
|
wxString text;
|
|
|
|
wxConfig* config = wxGetApp().GetSettings(); // Current config used by application
|
2008-03-21 19:25:41 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
if( !config )
|
2008-03-21 19:25:41 +00:00
|
|
|
return;
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
config->Write( keyBgColor_Red, g_Parm_3D_Visu.m_BgColor.m_Red );
|
|
|
|
config->Write( keyBgColor_Green, g_Parm_3D_Visu.m_BgColor.m_Green );
|
|
|
|
config->Write( keyBgColor_Blue, g_Parm_3D_Visu.m_BgColor.m_Blue );
|
|
|
|
class INFO3D_VISU& prms = g_Parm_3D_Visu;
|
|
|
|
config->Write( keyShowAxis, prms.m_DrawFlags[prms.FL_AXIS] );
|
|
|
|
config->Write( keyShowFootprints, prms.m_DrawFlags[prms.FL_MODULE] );
|
|
|
|
config->Write( keyShowCopperThickness, prms.m_DrawFlags[prms.FL_USE_COPPER_THICKNESS] );
|
|
|
|
config->Write( keyShowZones, prms.m_DrawFlags[prms.FL_ZONE] );
|
2013-05-16 19:04:21 +00:00
|
|
|
config->Write( keyShowAdhesiveLayers, prms.m_DrawFlags[prms.FL_ADHESIVE] );
|
|
|
|
config->Write( keyShowSilkScreenLayers, prms.m_DrawFlags[prms.FL_SILKSCREEN] );
|
|
|
|
config->Write( keyShowSolderMaskLayers, prms.m_DrawFlags[prms.FL_SOLDERMASK] );
|
|
|
|
config->Write( keyShowSolderPasteLayers, prms.m_DrawFlags[prms.FL_SOLDERPASTE] );
|
|
|
|
config->Write( keyShowCommentsLayer, prms.m_DrawFlags[prms.FL_COMMENTS] );
|
|
|
|
config->Write( keyShowEcoLayers, prms.m_DrawFlags[prms.FL_ECO] );
|
2008-03-21 19:25:41 +00:00
|
|
|
|
|
|
|
if( IsIconized() )
|
|
|
|
return;
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
m_frameSize = GetSize();
|
|
|
|
m_framePos = GetPosition();
|
|
|
|
|
|
|
|
text = m_frameName + keyPosx;
|
|
|
|
config->Write( text, (long) m_framePos.x );
|
|
|
|
text = m_frameName + keyPosy;
|
|
|
|
config->Write( text, (long) m_framePos.y );
|
|
|
|
text = m_frameName + keySizex;
|
|
|
|
config->Write( text, (long) m_frameSize.x );
|
|
|
|
text = m_frameName + keySizey;
|
|
|
|
config->Write( text, (long) m_frameSize.y );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::Process_Zoom( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-21 19:25:41 +00:00
|
|
|
int ii;
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
2009-01-07 15:59:49 +00:00
|
|
|
case ID_ZOOM_PAGE:
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
for( ii = 0; ii < 4; ii++ )
|
|
|
|
g_Parm_3D_Visu.m_Rot[ii] = 0.0;
|
|
|
|
|
|
|
|
g_Parm_3D_Visu.m_Zoom = 1.0;
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->SetOffset( 0.0, 0.0 );
|
2008-03-21 19:25:41 +00:00
|
|
|
trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
|
|
|
|
break;
|
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
case ID_ZOOM_IN:
|
2008-03-21 19:25:41 +00:00
|
|
|
g_Parm_3D_Visu.m_Zoom /= 1.2;
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
|
|
|
|
g_Parm_3D_Visu.m_Zoom = 0.01;
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
break;
|
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
case ID_ZOOM_OUT:
|
2008-03-21 19:25:41 +00:00
|
|
|
g_Parm_3D_Visu.m_Zoom *= 1.2;
|
|
|
|
break;
|
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
case ID_ZOOM_REDRAW:
|
2008-03-21 19:25:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->Refresh( false );
|
|
|
|
m_canvas->DisplayStatus();
|
2008-03-21 19:25:41 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
double EDA_3D_FRAME::BestZoom()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-07-05 12:46:14 +00:00
|
|
|
return 1.0;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
#define ROT_ANGLE 10.0
|
2012-12-15 08:52:02 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
bool isChecked = event.IsChecked();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-04-09 09:16:47 +00:00
|
|
|
switch( id )
|
2008-03-21 19:25:41 +00:00
|
|
|
{
|
2013-05-16 19:04:21 +00:00
|
|
|
case ID_TOOL_SET_VISIBLE_ITEMS:
|
|
|
|
Install_3D_ViewOptionDialog( event );
|
|
|
|
break;
|
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
case ID_RELOAD3D_BOARD:
|
|
|
|
NewDisplay();
|
2008-07-15 10:11:44 +00:00
|
|
|
return;
|
2008-03-21 19:25:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ROTATE3D_X_POS:
|
|
|
|
g_Parm_3D_Visu.m_ROTX += ROT_ANGLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ROTATE3D_X_NEG:
|
|
|
|
g_Parm_3D_Visu.m_ROTX -= ROT_ANGLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ROTATE3D_Y_POS:
|
|
|
|
g_Parm_3D_Visu.m_ROTY += ROT_ANGLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ROTATE3D_Y_NEG:
|
|
|
|
g_Parm_3D_Visu.m_ROTY -= ROT_ANGLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ROTATE3D_Z_POS:
|
|
|
|
g_Parm_3D_Visu.m_ROTZ += ROT_ANGLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_ROTATE3D_Z_NEG:
|
|
|
|
g_Parm_3D_Visu.m_ROTZ -= ROT_ANGLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MOVE3D_LEFT:
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->SetView3D( WXK_LEFT );
|
2008-03-21 19:25:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_MOVE3D_RIGHT:
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->SetView3D( WXK_RIGHT );
|
2008-03-21 19:25:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_MOVE3D_UP:
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->SetView3D( WXK_UP );
|
2008-03-21 19:25:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_MOVE3D_DOWN:
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->SetView3D( WXK_DOWN );
|
2008-03-21 19:25:41 +00:00
|
|
|
return;
|
2011-05-22 19:08:34 +00:00
|
|
|
|
2010-10-04 12:58:07 +00:00
|
|
|
case ID_ORTHO:
|
2012-12-15 08:52:02 +00:00
|
|
|
ToggleOrtho();
|
2010-10-04 12:58:07 +00:00
|
|
|
return;
|
2008-03-21 19:25:41 +00:00
|
|
|
|
|
|
|
case ID_TOOL_SCREENCOPY_TOCLIBBOARD:
|
|
|
|
case ID_MENU_SCREENCOPY_PNG:
|
|
|
|
case ID_MENU_SCREENCOPY_JPEG:
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->TakeScreenshot( event );
|
2008-03-21 19:25:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MENU3D_BGCOLOR_SELECTION:
|
|
|
|
Set3DBgColor();
|
|
|
|
return;
|
|
|
|
|
2008-08-16 17:42:40 +00:00
|
|
|
case ID_MENU3D_AXIS_ONOFF:
|
2012-04-09 09:16:47 +00:00
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS] = isChecked;
|
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_MENU3D_MODULE_ONOFF:
|
2012-04-09 09:16:47 +00:00
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] = isChecked;
|
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
case ID_MENU3D_USE_COPPER_THICKNESS:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS] = isChecked;
|
|
|
|
NewDisplay();
|
|
|
|
return;
|
|
|
|
|
2008-08-16 17:42:40 +00:00
|
|
|
case ID_MENU3D_ZONE_ONOFF:
|
2012-04-09 09:16:47 +00:00
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE] = isChecked;
|
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-16 19:04:21 +00:00
|
|
|
case ID_MENU3D_ADHESIVE_ONOFF:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE] = isChecked;
|
2012-04-09 09:16:47 +00:00
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-16 19:04:21 +00:00
|
|
|
case ID_MENU3D_SILKSCREEN_ONOFF:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN] = isChecked;
|
2012-04-09 09:16:47 +00:00
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-16 19:04:21 +00:00
|
|
|
case ID_MENU3D_SOLDER_MASK_ONOFF:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK] = isChecked;
|
|
|
|
NewDisplay();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_MENU3D_SOLDER_PASTE_ONOFF:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE] = isChecked;
|
|
|
|
NewDisplay();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case ID_MENU3D_COMMENTS_ONOFF:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS] = isChecked;
|
2012-04-09 09:16:47 +00:00
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
2013-05-16 19:04:21 +00:00
|
|
|
case ID_MENU3D_ECO_ONOFF:
|
|
|
|
g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO] = isChecked;
|
2012-04-09 09:16:47 +00:00
|
|
|
NewDisplay();
|
2008-08-16 17:42:40 +00:00
|
|
|
return;
|
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
default:
|
2012-08-11 12:52:13 +00:00
|
|
|
wxLogMessage( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
|
2008-03-21 19:25:41 +00:00
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-03-21 19:25:41 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->Refresh( true );
|
|
|
|
m_canvas->DisplayStatus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
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;
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::NewDisplay()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-05-01 12:46:33 +00:00
|
|
|
m_reloadRequest = false;
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
m_canvas->ClearLists();
|
|
|
|
m_canvas->CreateDrawGL_List();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
// m_canvas->InitGL();
|
|
|
|
m_canvas->Refresh( true );
|
|
|
|
m_canvas->DisplayStatus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-10-26 19:09:20 +00:00
|
|
|
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
|
2010-04-29 09:06:01 +00:00
|
|
|
{
|
|
|
|
// Reload data if 3D frame shows a footprint,
|
|
|
|
// because it can be changed since last frame activation
|
2010-05-01 12:46:33 +00:00
|
|
|
if( m_reloadRequest )
|
|
|
|
NewDisplay();
|
|
|
|
|
2012-12-15 08:52:02 +00:00
|
|
|
event.Skip(); // required under wxMAC
|
2010-04-29 09:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* called to set the background color of the 3D scene
|
2008-03-21 19:25:41 +00:00
|
|
|
*/
|
2011-08-03 15:09:39 +00:00
|
|
|
void EDA_3D_FRAME::Set3DBgColor()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-12-15 08:52:02 +00:00
|
|
|
S3D_COLOR color;
|
|
|
|
wxColour newcolor, oldcolor;
|
2008-03-21 19:25:41 +00:00
|
|
|
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
oldcolor.Set( KiROUND( g_Parm_3D_Visu.m_BgColor.m_Red * 255 ),
|
|
|
|
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Green * 255 ),
|
|
|
|
KiROUND( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
|
2008-03-21 19:25:41 +00:00
|
|
|
|
|
|
|
newcolor = wxGetColourFromUser( this, oldcolor );
|
2011-08-03 15:09:39 +00:00
|
|
|
|
2008-03-21 19:25:41 +00:00
|
|
|
if( newcolor != oldcolor )
|
|
|
|
{
|
2012-12-15 08:52:02 +00:00
|
|
|
g_Parm_3D_Visu.m_BgColor.m_Red = (double) newcolor.Red() / 255.0;
|
|
|
|
g_Parm_3D_Visu.m_BgColor.m_Green = (double) newcolor.Green() / 255.0;
|
|
|
|
g_Parm_3D_Visu.m_BgColor.m_Blue = (double) newcolor.Blue() / 255.0;
|
2008-03-21 19:25:41 +00:00
|
|
|
NewDisplay();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|