kicad/3d-viewer/3d_toolbar.cpp

253 lines
9.4 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 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_toolbar.cpp
*/
2007-05-06 16:03:28 +00:00
#include <fctsys.h>
2007-05-06 16:03:28 +00:00
#include <3d_viewer.h>
#include <info3d_visu.h>
#include <menus_helpers.h>
#include <3d_viewer_id.h>
2007-05-06 16:03:28 +00:00
void EDA_3D_FRAME::ReCreateHToolbar()
2007-05-06 16:03:28 +00:00
{
if( m_HToolBar != NULL )
{
// Simple update to the list of old files.
SetToolbars();
return;
}
2007-05-06 16:03:28 +00:00
m_HToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
// Set up toolbar
m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
KiBitmap( import3d_xpm ),
_( "Reload board" ) );
2011-09-17 15:31:21 +00:00
#if (defined(__WINDOWS__) || defined(__APPLE__ ) )
// Does not work properly under linux
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString,
KiBitmap( copy_button_xpm ),
_( "Copy 3D Image to Clipboard" ) );
2007-05-06 16:03:28 +00:00
#endif
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_TOOL_SET_VISIBLE_ITEMS, wxEmptyString,
KiBitmap( read_setup_xpm ),
_( "Set display options, and some layers visibility" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ),
_( "Zoom in" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ),
_( "Zoom out" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
KiBitmap( zoom_redraw_xpm ),
_( "Redraw view" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ),
2011-03-20 17:10:38 +00:00
_( "Fit in page" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_ROTATE3D_X_NEG, wxEmptyString,
KiBitmap( rotate_neg_x_xpm ),
_( "Rotate X <-" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_ROTATE3D_X_POS, wxEmptyString,
KiBitmap( rotate_pos_x_xpm ),
_( "Rotate X ->" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_ROTATE3D_Y_NEG, wxEmptyString,
KiBitmap( rotate_neg_y_xpm ),
_( "Rotate Y <-" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_ROTATE3D_Y_POS, wxEmptyString,
KiBitmap( rotate_pos_y_xpm ),
_( "Rotate Y ->" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_ROTATE3D_Z_NEG, wxEmptyString,
KiBitmap( rotate_neg_z_xpm ),
_( "Rotate Z <-" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_ROTATE3D_Z_POS, wxEmptyString,
KiBitmap( rotate_pos_z_xpm ),
_( "Rotate Z ->" ) );
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_MOVE3D_LEFT, wxEmptyString, KiBitmap( left_xpm ),
_( "Move left" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_MOVE3D_RIGHT, wxEmptyString, KiBitmap( right_xpm ),
_( "Move right" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_MOVE3D_UP, wxEmptyString, KiBitmap( up_xpm ),
_( "Move up" ) );
2007-05-06 16:03:28 +00:00
m_HToolBar->AddTool( ID_MOVE3D_DOWN, wxEmptyString, KiBitmap( down_xpm ),
_( "Move down" ) );
2010-10-04 12:58:07 +00:00
m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_ORTHO, wxEmptyString, KiBitmap( ortho_xpm ),
_( "Enable/Disable orthographic projection" ),
2010-10-04 12:58:07 +00:00
wxITEM_CHECK );
2007-05-06 16:03:28 +00:00
m_HToolBar->Realize();
2007-05-06 16:03:28 +00:00
}
void EDA_3D_FRAME::ReCreateVToolbar()
2007-05-06 16:03:28 +00:00
{
}
void EDA_3D_FRAME::CreateMenuBar()
2007-05-06 16:03:28 +00:00
{
wxMenuBar* menuBar = new wxMenuBar;
wxMenu* fileMenu = new wxMenu;
wxMenu* prefsMenu = new wxMenu;
2007-05-06 16:03:28 +00:00
menuBar->Append( fileMenu, _( "&File" ) );
2007-05-06 16:03:28 +00:00
2011-09-17 15:31:21 +00:00
fileMenu->Append( ID_MENU_SCREENCOPY_PNG, _( "Create Image (png format)" ) );
fileMenu->Append( ID_MENU_SCREENCOPY_JPEG, _( "Create Image (jpeg format)" ) );
2010-10-04 11:50:43 +00:00
#if (defined(__WINDOWS__) || defined(__APPLE__ ) )
// Does not work properly under linux
fileMenu->AppendSeparator();
2011-09-17 15:31:21 +00:00
fileMenu->Append( ID_TOOL_SCREENCOPY_TOCLIBBOARD, _( "Copy 3D Image to Clipboard" ) );
2010-10-04 11:50:43 +00:00
#endif
fileMenu->AppendSeparator();
fileMenu->Append( wxID_EXIT, _( "&Exit" ) );
2007-05-06 16:03:28 +00:00
menuBar->Append( prefsMenu, _( "&Preferences" ) );
2007-05-06 16:03:28 +00:00
AddMenuItem( prefsMenu, ID_MENU3D_BGCOLOR_SELECTION,
_( "Choose background color" ), KiBitmap( palette_xpm ) );
2007-05-06 16:03:28 +00:00
wxMenuItem* item;
item = AddMenuItem( prefsMenu, ID_MENU3D_AXIS_ONOFF,
_( "Show 3D &Axis" ), KiBitmap( axis3d_front_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS]);
// 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_USE_COPPER_THICKNESS,
_( "Show Copper Thickness" ), KiBitmap( use_3D_copper_thickness_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_MODULE_ONOFF,
_( "Show 3D F&ootprints" ), KiBitmap( shape_3d_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_ZONE_ONOFF,
_( "Show Zone &Filling" ), KiBitmap( add_zone_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_ADHESIVE_ONOFF,
_( "Show &Adhesive Layers" ), KiBitmap( tools_xpm ), wxITEM_CHECK );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
item = AddMenuItem( prefsMenu, ID_MENU3D_SILKSCREEN_ONOFF,
_( "Show &Silkscreen Layer" ), KiBitmap( add_text_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_MASK_ONOFF,
_( "Show Solder &Mask Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_SOLDER_PASTE_ONOFF,
_( "Show Solder &Paste Layers" ), KiBitmap( pads_mask_layers_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_COMMENTS_ONOFF,
_( "Show &Comments and Drawings Layer" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
item = AddMenuItem( prefsMenu, ID_MENU3D_ECO_ONOFF,
_( "Show &Eco Layers" ), KiBitmap( edit_sheet_xpm ), wxITEM_CHECK );
SetMenuBarOptionsState();
SetMenuBar( menuBar );
2007-05-06 16:03:28 +00:00
}
void EDA_3D_FRAME::SetMenuBarOptionsState()
{
wxMenuBar* menuBar = GetMenuBar();
if( menuBar == NULL )
return;
wxMenuItem* item;
// Set the state of toggle menus according to the current display options
item = menuBar->FindItem( ID_MENU3D_USE_COPPER_THICKNESS );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_USE_COPPER_THICKNESS]);
item = menuBar->FindItem( ID_MENU3D_MODULE_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE]);
item = menuBar->FindItem( ID_MENU3D_ZONE_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE]);
item = menuBar->FindItem( ID_MENU3D_ADHESIVE_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ADHESIVE]);
item = menuBar->FindItem( ID_MENU3D_SILKSCREEN_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SILKSCREEN]);
item = menuBar->FindItem( ID_MENU3D_SOLDER_MASK_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERMASK]);
item = menuBar->FindItem( ID_MENU3D_SOLDER_PASTE_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_SOLDERPASTE]);
item = menuBar->FindItem( ID_MENU3D_COMMENTS_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_COMMENTS]);
item = menuBar->FindItem( ID_MENU3D_ECO_ONOFF );
item->Check(g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ECO]);
}
void EDA_3D_FRAME::SetToolbars()
2007-05-06 16:03:28 +00:00
{
}