Move Show3DViewer to common action.

This commit is contained in:
Jeff Young 2019-06-02 15:34:19 +01:00
parent 374a3feb3e
commit 6ac273264d
37 changed files with 137 additions and 548 deletions

View File

@ -1,45 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2016 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
* @brief Declaration of the eda_3d_viewer class
*/
#ifndef _3D_VIEWER_H_
#define _3D_VIEWER_H_
/// A variable name whose value holds the path of 3D shape files.
/// Currently an environment variable, eventually a project variable.
#define KISYS3DMOD wxT( "KISYS3DMOD" )
/// All 3D files are expected to be stored in LIB3D_FOLDER, or one of
/// its subdirectory.
#define LIB3D_FOLDER wxT( "packages3d" )
#endif // _3D_VIEWER_H_

View File

@ -39,6 +39,11 @@
#include <../common/dialogs/dialog_color_picker.h> // for CUSTOM_COLORS_LIST definition
/// A variable name whose value holds the path of 3D shape files.
/// Currently an environment variable, eventually a project variable.
#define KISYS3DMOD wxT( "KISYS3DMOD" )
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE (wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS)
#define VIEWER3D_FRAMENAME wxT( "Viewer3DFrameName" )

View File

@ -336,6 +336,12 @@ TOOL_ACTION ACTIONS::standardGraphics( "common.Control.standardGraphics",
_( "Standard Graphics" ), _( "Use software graphics (fall-back)" ),
tools_xpm );
TOOL_ACTION ACTIONS::show3DViewer( "pcbnew.Control.show3DViewer",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_3D_VIEWER ),
_( "3D Viewer" ), _( "Show 3D viewer window" ),
three_d_xpm );
// System-wide selection Events

View File

@ -45,7 +45,6 @@ set( CVPCB_SRCS
menubar.cpp
readwrite_dlgs.cpp
toolbars_cvpcb.cpp
tools/cvpcb_actions.cpp
tools/cvpcb_control.cpp
tools/cvpcb_selection_tool.cpp
)

View File

@ -46,7 +46,6 @@ enum id_cvpcb_frm
ID_CVPCB_AUTO_ASSOCIE,
ID_CVPCB_COMPONENT_LIST,
ID_CVPCB_FOOTPRINT_LIST,
ID_CVPCB_SHOW3D_FRAME,
ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,

View File

@ -36,20 +36,16 @@
#include <lib_id.h>
#include <fp_lib_table.h>
#include <eda_dockart.h>
#include <io_mgr.h>
#include <class_module.h>
#include <class_board.h>
#include <pcb_painter.h>
#include <cvpcb_mainframe.h>
#include <display_footprints_frame.h>
#include <cvpcb_id.h>
#include <listboxes.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/common_tools.h>
@ -65,14 +61,9 @@ COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY );
BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow )
EVT_TOOL( ID_OPTIONS_SETUP, DISPLAY_FOOTPRINTS_FRAME::InstallOptionsDisplay )
EVT_TOOL( ID_CVPCB_SHOW3D_FRAME, DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame )
EVT_CHOICE( ID_ON_ZOOM_SELECT, DISPLAY_FOOTPRINTS_FRAME::OnSelectZoom )
EVT_CHOICE( ID_ON_GRID_SELECT, DISPLAY_FOOTPRINTS_FRAME::OnSelectGrid )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, DISPLAY_FOOTPRINTS_FRAME::OnUIToolSelection )
EVT_UPDATE_UI( ID_TB_MEASUREMENT_TOOL, DISPLAY_FOOTPRINTS_FRAME::OnUIToolSelection )
EVT_UPDATE_UI( ID_ZOOM_SELECTION, DISPLAY_FOOTPRINTS_FRAME::OnUIToolSelection )
/*
EVT_TOOL and EVT_UPDATE_UI for:
ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
@ -220,21 +211,15 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar()
// TODO: these can be moved to the 'proper' right vertical toolbar if and when there are
// actual tools to put there. That, or I'll get around to implementing configurable
// toolbars.
m_optionsToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString,
KiScaledBitmap( cursor_xpm, this ),
wxEmptyString, wxITEM_CHECK );
m_optionsToolBar->AddTool( ID_TB_MEASUREMENT_TOOL, wxEmptyString,
KiScaledBitmap( measurement_xpm, this ),
_( "Measure distance between two points" ),
wxITEM_CHECK );
m_optionsToolBar->Add( CVPCB_ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( CVPCB_ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddSeparator();
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddSeparator();
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
@ -272,8 +257,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_SHOW3D_FRAME, wxEmptyString, KiScaledBitmap( three_d_xpm, this ),
_( "3D Display (Alt+3)" ) );
m_mainToolBar->Add( ACTIONS::show3DViewer );
KiScaledSeparator( m_mainToolBar, this );
@ -328,13 +312,6 @@ void DISPLAY_FOOTPRINTS_FRAME::ApplyDisplaySettingsToGAL()
}
void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
{
bool forceRecreateIfNotOwner = true;
CreateAndShow3D_Frame( forceRecreateIfNotOwner );
}
/**
* Virtual function needed by the PCB_SCREEN class derived from BASE_SCREEN
* this is a virtual pure function in BASE_SCREEN
@ -450,7 +427,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
UpdateStatusBar();
GetGalCanvas()->Refresh();
Update3DView();
Update3DView( true );
}
@ -483,32 +460,16 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
}
void DISPLAY_FOOTPRINTS_FRAME::OnUIToolSelection( wxUpdateUIEvent& aEvent )
{
switch( aEvent.GetId() )
{
case ID_TB_MEASUREMENT_TOOL:
aEvent.Check( GetToolId() == ID_TB_MEASUREMENT_TOOL );
break;
case ID_NO_TOOL_SELECTED:
aEvent.Check( GetToolId() == ID_NO_TOOL_SELECTED );
break;
case ID_ZOOM_SELECTION:
aEvent.Check( GetToolId() == ID_ZOOM_SELECTION );
break;
default:
break;
}
}
void DISPLAY_FOOTPRINTS_FRAME::SyncMenusAndToolbars()
{
m_mainToolBar->Toggle( CVPCB_ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );
m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( CVPCB_ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );
m_optionsToolBar->Toggle( CVPCB_ACTIONS::measureTool, GetToolId() == ID_TB_MEASUREMENT_TOOL );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Refresh();
}
@ -518,8 +479,6 @@ void DISPLAY_FOOTPRINTS_FRAME::SyncMenusAndToolbars()
void BOARD::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
{
if( !m_modules.empty() )
{
GetFirstModule()->Print( aFrame, aDC );
}
}

View File

@ -51,10 +51,6 @@ public:
void OnCloseWindow( wxCloseEvent& Event ) override;
/** UI events:
*/
void OnUIToolSelection( wxUpdateUIEvent& aEvent );
void ReCreateHToolbar() override;
void ReCreateVToolbar() override;
void ReCreateOptToolbar() override;
@ -109,11 +105,6 @@ public:
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override { return NULL; }
/**
* Display 3D frame of current footprint selection.
*/
void Show3D_Frame( wxCommandEvent& event ) override;
/* SaveCopyInUndoList() virtual
* currently: do nothing in CvPcb.
* but but be defined because it is a pure virtual in PCB_BASE_FRAME

View File

@ -1,41 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2016 CERN
* Copyright (C) 2018-2019 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 "cvpcb_actions.h"
#include <cvpcb_id.h>
OPT<TOOL_EVENT> CVPCB_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
case ID_TB_MEASUREMENT_TOOL:
return CVPCB_ACTIONS::measureTool.MakeEvent();
case ID_NO_TOOL_SELECTED:
return CVPCB_ACTIONS::no_selectionTool.MakeEvent();
}
return OPT<TOOL_EVENT>();
}

View File

@ -47,19 +47,12 @@ public:
static TOOL_ACTION selectionActivate;
/// Tool selection
static TOOL_ACTION no_selectionTool;
static TOOL_ACTION selectionTool;
static TOOL_ACTION measureTool;
// Miscellaneous
static TOOL_ACTION zoomTool;
static TOOL_ACTION switchCursor;
static TOOL_ACTION switchUnits;
static TOOL_ACTION showHelp;
static TOOL_ACTION toBeDone;
///> @copydoc COMMON_ACTIONS::TranslateLegacyId()
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override;
virtual OPT<TOOL_EVENT> TranslateLegacyId( int aId ) override { return OPT<TOOL_EVENT>(); }
};
#endif

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2014-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
* Copyright (C) 2007-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2007-2019 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
@ -24,47 +24,15 @@
*/
#include <cstdint>
#include <view/view.h>
#include "cvpcb_actions.h"
#include "cvpcb_control.h"
#include <class_board.h>
#include <hotkeys.h>
#include <properties.h>
#include <cvpcb_id.h>
#include <tool/tool_manager.h>
#include <view/view_controls.h>
#include <tools/grid_helper.h> // from pcbnew
#include <functional>
using namespace std::placeholders;
// Miscellaneous
TOOL_ACTION CVPCB_ACTIONS::switchCursor( "cvpcb.Control.switchCursor",
AS_GLOBAL, 0,
"", "" );
TOOL_ACTION CVPCB_ACTIONS::switchUnits( "cvpcb.Control.switchUnits",
AS_GLOBAL, 'U',//TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ),
"", "" );
TOOL_ACTION CVPCB_ACTIONS::no_selectionTool( "cvpcb.Control.no_selectionTool",
AS_GLOBAL, ESC,
"", "", NULL, AF_ACTIVATE );
///////////////
CVPCB_CONTROL::CVPCB_CONTROL() :
TOOL_INTERACTIVE( "cvpcb.Control" ), m_frame( NULL )
{
}
CVPCB_CONTROL::~CVPCB_CONTROL()
TOOL_INTERACTIVE( "cvpcb.Control" ),
m_frame( nullptr )
{
}
@ -75,21 +43,9 @@ void CVPCB_CONTROL::Reset( RESET_REASON aReason )
}
// Miscellaneous
int CVPCB_CONTROL::SwitchCursor( const TOOL_EVENT& aEvent )
int CVPCB_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent )
{
auto& galOpts = m_frame->GetGalDisplayOptions();
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
galOpts.NotifyChanged();
return 0;
}
int CVPCB_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
{
m_frame->ChangeUserUnits( m_frame->GetUserUnits() == INCHES ? MILLIMETRES : INCHES );
m_frame->CreateAndShow3D_Frame();
return 0;
}
@ -97,6 +53,5 @@ int CVPCB_CONTROL::SwitchUnits( const TOOL_EVENT& aEvent )
void CVPCB_CONTROL::setTransitions()
{
// Miscellaneous
Go( &CVPCB_CONTROL::SwitchCursor, CVPCB_ACTIONS::switchCursor.MakeEvent() );
Go( &CVPCB_CONTROL::SwitchUnits, CVPCB_ACTIONS::switchUnits.MakeEvent() );
Go( &CVPCB_CONTROL::Show3DViewer, ACTIONS::show3DViewer.MakeEvent() );
}

View File

@ -29,9 +29,6 @@
#include <tool/tool_interactive.h>
#include <display_footprints_frame.h>
namespace KIGFX {
class ORIGIN_VIEWITEM;
}
/**
* Class CVPCB_CONTROL
@ -43,14 +40,12 @@ class CVPCB_CONTROL : public TOOL_INTERACTIVE
{
public:
CVPCB_CONTROL();
~CVPCB_CONTROL();
~CVPCB_CONTROL() { }
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override;
// Miscellaneous
int SwitchCursor( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent );
int Show3DViewer( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;
@ -58,14 +53,6 @@ public:
private:
///> Pointer to the currently used edit/draw frame.
DISPLAY_FOOTPRINTS_FRAME* m_frame;
///> Grid origin marker.
std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_gridOrigin;
KIGFX::VIEW* view()
{
return m_frame->GetGalCanvas()->GetView();
}
};
#endif

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2019 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
@ -25,41 +25,40 @@ using namespace std::placeholders;
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <hotkeys.h>
#include <bitmaps.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <tools/cvpcb_actions.h>
#include <preview_items/ruler_item.h>
#include <cvpcb_id.h>
#include <tools/cvpcb_selection_tool.h>
#include "cvpcb_selection_tool.h"
#include "cvpcb_actions.h"
// Selection tool actions
TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection",
AS_GLOBAL, 0,
"", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere
// Selection tool actions
TOOL_ACTION CVPCB_ACTIONS::selectionTool( "cvpcb.InteractiveSelection.selectionTool",
AS_GLOBAL, 0,
_( "Select item(s)" ), "",
cursor_xpm, AF_ACTIVATE );
TOOL_ACTION CVPCB_ACTIONS::measureTool( "cvpcb.InteractiveSelection.measureTool",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MEASURE_TOOL ),
_( "Measure Tool" ), _( "Interactively measure distance between points" ),
nullptr, AF_ACTIVATE );
measurement_xpm, AF_ACTIVATE );
CVPCB_SELECTION_TOOL::CVPCB_SELECTION_TOOL() :
TOOL_INTERACTIVE( "cvpcb.InteractiveSelection" ),
m_frame( NULL ), m_menu( *this )
m_frame( nullptr ),
m_menu( *this )
{
}
CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL()
{
getView()->Remove( &m_selection );
}
bool CVPCB_SELECTION_TOOL::Init()
{
m_menu.AddStandardSubMenus( getEditFrame<DISPLAY_FOOTPRINTS_FRAME>() );
@ -127,42 +126,6 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
SELECTION& CVPCB_SELECTION_TOOL::GetSelection()
{
return m_selection;
}
void CVPCB_SELECTION_TOOL::setTransitions()
{
Go( &CVPCB_SELECTION_TOOL::Main, CVPCB_ACTIONS::selectionActivate.MakeEvent() );
Go( &CVPCB_SELECTION_TOOL::MeasureTool, CVPCB_ACTIONS::measureTool.MakeEvent() );
}
/*
void CVPCB_SELECTION_TOOL::zoomFitSelection( void )
{
//Should recalculate the view to zoom in on the selection
auto selectionBox = m_selection.ViewBBox();
auto canvas = m_frame->GetGalCanvas();
auto view = getView();
VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
if( !( selectionBox.GetWidth() == 0 ) || !( selectionBox.GetHeight() == 0 ) )
{
VECTOR2D vsize = selectionBox.GetSize();
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
fabs( vsize.y / screenSize.y ) );
view->SetScale( scale );
view->SetCenter( selectionBox.Centre() );
view->Add( &m_selection );
}
m_frame->GetGalCanvas()->ForceRefresh();
}
*/
int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
{
auto& view = *getView();
@ -170,8 +133,7 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
auto previous_settings = controls.GetSettings();
Activate();
m_frame->SetToolID( ID_TB_MEASUREMENT_TOOL, wxCURSOR_PENCIL,
_( "Measure distance" ) );
m_frame->SetToolID( ID_TB_MEASUREMENT_TOOL, wxCURSOR_PENCIL, _( "Measure distance" ) );
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
@ -259,34 +221,19 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
const BOX2I SELECTION::ViewBBox() const
{
EDA_RECT eda_bbox;
if( Size() == 1 )
{
eda_bbox = Front()->GetBoundingBox();
}
else if( Size() > 1 )
{
eda_bbox = Front()->GetBoundingBox();
auto i = m_items.begin();
++i;
for( ; i != m_items.end(); ++i )
{
eda_bbox.Merge( (*i)->GetBoundingBox() );
}
}
return BOX2I( eda_bbox.GetOrigin(), eda_bbox.GetSize() );
return BOX2I();
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
items.push_back( item );
return items;
return std::vector<VIEW_ITEM*>();
}
void CVPCB_SELECTION_TOOL::setTransitions()
{
Go( &CVPCB_SELECTION_TOOL::Main, CVPCB_ACTIONS::selectionActivate.MakeEvent() );
Go( &CVPCB_SELECTION_TOOL::MeasureTool, CVPCB_ACTIONS::measureTool.MakeEvent() );
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2019 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
@ -24,19 +24,9 @@
#include <tool/tool_interactive.h>
#include <tool/action_menu.h>
#include <tool/selection.h>
#include <tool/selection_conditions.h>
#include <tool/tool_menu.h>
#include <display_footprints_frame.h>
class SELECTION_AREA;
class GERBER_COLLECTOR;
namespace KIGFX
{
class GAL;
}
/**
* Class CVPCB_SELECTION_TOOL
@ -47,7 +37,7 @@ class CVPCB_SELECTION_TOOL : public TOOL_INTERACTIVE
{
public:
CVPCB_SELECTION_TOOL();
~CVPCB_SELECTION_TOOL();
~CVPCB_SELECTION_TOOL() { }
/// @copydoc TOOL_BASE::Init()
bool Init() override;
@ -55,6 +45,8 @@ public:
/// @copydoc TOOL_BASE::Reset()
void Reset( RESET_REASON aReason ) override;
inline TOOL_MENU& GetToolMenu() { return m_menu; }
/**
* Function Main()
*
@ -62,17 +54,10 @@ public:
*/
int Main( const TOOL_EVENT& aEvent );
/** Returns the set of currently selected items.
*/
SELECTION& GetSelection();
inline TOOL_MENU& GetToolMenu()
{
return m_menu;
}
/** Clears the current selection.
/**
* Selections aren't currently supported in the footprint viewer.
*/
SELECTION& GetSelection() { return m_selection; }
void clearSelection() {};
///> Launches a tool to measure between points
@ -81,18 +66,13 @@ public:
///> Sets up handlers for various events.
void setTransitions() override;
///> Zooms the screen to center and fit the current selection.
void zoomFitSelection( void );
private:
/// Pointer to the parent frame.
DISPLAY_FOOTPRINTS_FRAME* m_frame;
/// Current state of selection (not really used: no selection in display footprints frame).
SELECTION m_selection;
/// Menu model displayed by the tool.
TOOL_MENU m_menu;
};

View File

@ -112,7 +112,7 @@ public:
* @return false if the 3D view cannot be updated (because the
* owner of the viewer is not this frame)
*/
bool Update3DView( const wxString* aTitle = nullptr );
virtual void Update3DView( bool aForceReload, const wxString* aTitle = nullptr );
/**
* Function LoadFootprint
@ -221,22 +221,12 @@ public:
*/
const wxString GetZoomLevelIndicator() const override;
/**
* Shows the 3D view frame.
* If it does not exist, it is created.
* If it exists, and if I am the owner, it is bring to the foreground
*/
virtual void Show3D_Frame( wxCommandEvent& event );
/**
* Shows the 3D view frame.
* If it does not exist, it is created.
* If it exists, it is bring to the foreground
* @param aForceRecreateIfNotOwner = true to recreate the 3D frame viewer,
* when the owner is not me
* @return true if it is shown with me as owner
*/
virtual bool CreateAndShow3D_Frame( bool aForceRecreateIfNotOwner );
EDA_3D_VIEWER* CreateAndShow3D_Frame();
/**
* Function GetCollectorsGuide

View File

@ -134,6 +134,7 @@ public:
// Misc
static TOOL_ACTION acceleratedGraphics;
static TOOL_ACTION standardGraphics;
static TOOL_ACTION show3DViewer;
/**
* Function TranslateLegacyId()

View File

@ -43,7 +43,7 @@
#include "3d_cache/dialogs/panel_prev_model.h"
#include "3d_cache/dialogs/3d_cache_dialogs.h"
#include <bitmaps.h>
#include <3d_viewer.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <dialog_edit_footprint_for_BoardEditor.h>

View File

@ -31,7 +31,7 @@
#include <dialog_text_entry.h>
#include <pcbnew.h>
#include <kiface_i.h>
#include <3d_viewer.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <pcb_edit_frame.h>
#include <validators.h>
#include <board_design_settings.h>

View File

@ -37,7 +37,7 @@
#include <fctsys.h>
#include <project.h>
#include <3d_viewer.h> // for KISYS3DMOD
#include <3d_viewer/eda_3d_viewer.h> // for KISYS3DMOD
#include <panel_fp_lib_table.h>
#include <lib_id.h>
#include <fp_lib_table.h>

View File

@ -42,7 +42,7 @@
#include <project.h>
#include <wizard_3DShape_Libs_downloader.h>
#include <confirm.h>
#include <3d_viewer.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <bitmaps.h>
#include <../github/github_getliblist.h>

View File

@ -132,9 +132,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_GRID_SETTINGS, FOOTPRINT_EDIT_FRAME::OnGridSettings )
// Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame )
// UI update events.
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted )
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
@ -635,17 +632,10 @@ void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage()
}
void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
{
bool forceRecreateIfNotOwner = true;
CreateAndShow3D_Frame( forceRecreateIfNotOwner );
}
void FOOTPRINT_EDIT_FRAME::OnModify()
{
PCB_BASE_FRAME::OnModify();
Update3DView();
Update3DView( false );
m_treePane->GetLibTree()->Refresh();
}

View File

@ -146,13 +146,6 @@ public:
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
BOARD_ITEM* PrepareItemForHotkey( bool failIfCurrentlyEdited );
/**
* Display 3D view of the footprint (module) being edited.
*/
void Show3D_Frame( wxCommandEvent& event ) override;
/**
* Handle most of tools og the vertical right toolbar ("Tools" toolbar)
*/
@ -160,8 +153,6 @@ public:
void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
void OnUpdateModuleTargeted( wxUpdateUIEvent& aEvent );
void OnUpdateSave( wxUpdateUIEvent& aEvent );
void OnUpdateSaveAs( wxUpdateUIEvent& aEvent );
void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );

View File

@ -116,7 +116,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
Zoom_Automatique( false );
Update3DView();
Update3DView( true );
GetScreen()->ClrModify();
@ -230,7 +230,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
updateView();
GetGalCanvas()->Refresh();
Update3DView();
Update3DView( true );
SyncLibraryTree( false );
}
@ -292,7 +292,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
updateView();
GetGalCanvas()->Refresh();
Update3DView();
Update3DView( true );
SyncLibraryTree( false );
}
@ -415,7 +415,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->SetModify();
Zoom_Automatique( false );
GetGalCanvas()->Refresh();
Update3DView();
Update3DView( true );
break;

View File

@ -1006,7 +1006,7 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint()
Zoom_Automatique( false );
Update3DView();
Update3DView( true );
GetScreen()->ClearUndoRedoList();
GetScreen()->ClrModify();

View File

@ -83,7 +83,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_MODVIEW_NEXT, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
EVT_TOOL( ID_MODVIEW_PREVIOUS, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB )
EVT_TOOL( ID_MODVIEW_SHOW_3D_VIEW, FOOTPRINT_VIEWER_FRAME::Show3D_Frame )
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectZoom )
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectGrid )
@ -433,7 +432,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
updateView();
GetGalCanvas()->Refresh();
Update3D_Frame();
Update3DView( true );
}
}
@ -632,35 +631,11 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent
}
void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event )
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
// We can probably remove this for 6.0, but just to be safe we'll stick to
// one 3DFrame at a time for 5.0
if( draw3DFrame )
draw3DFrame->Close( true );
draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
Update3D_Frame( false );
#ifdef __WXMAC__
// A stronger version of Raise() which promotes the window to its parent's level.
draw3DFrame->ReparentQuasiModal();
#else
draw3DFrame->Raise(); // Needed with some Window Managers
#endif
draw3DFrame->Show( true );
}
void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
void FOOTPRINT_VIEWER_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
{
wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
getCurFootprintName() );
Update3DView( &title );
PCB_BASE_FRAME::Update3DView( aForceReload, &title );
}
@ -774,7 +749,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
if( footprint )
GetBoard()->Add( footprint, ADD_APPEND );
Update3D_Frame();
Update3DView( true );
updateView();
}

View File

@ -156,19 +156,12 @@ private:
void SelectAndViewFootprint( int aMode );
/**
* Function Show3D_Frame (virtual)
* displays 3D view of the footprint (module) being edited.
*/
void Show3D_Frame( wxCommandEvent& event ) override;
/**
* Function Update3D_Frame
* Function Update3DView
* must be called after a footprint selection
* Updates the 3D view and 3D frame title.
* @param aForceReloadFootprint = true to reload data (default)
* = false to update title only -(after creating the 3D viewer)
* @param aForceReload = true to reload data immediately
*/
void Update3D_Frame( bool aForceReloadFootprint = true );
void Update3DView( bool aForceReload, const wxString* aTitle = nullptr ) override;
/*
* Virtual functions, not used here, but needed by PCB_BASE_FRAME

View File

@ -74,7 +74,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE, FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
// listbox events
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
@ -571,50 +570,16 @@ void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
}
void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event )
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
// We can probably remove this for 6.0, but just to be safe we'll stick to
// one 3DFrame at a time for 5.0
if( draw3DFrame )
draw3DFrame->Close( true );
draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
Update3D_Frame( false );
#ifdef __WXMAC__
// A stronger version of Raise() which promotes the window to its parent's level.
draw3DFrame->ReparentQuasiModal();
#else
draw3DFrame->Raise(); // Needed with some Window Managers
#endif
draw3DFrame->Show( true );
}
/**
* Function Update3D_Frame
* Function Update3DView
* must be called after a footprint selection
* Updates the 3D view and 3D frame title.
*/
void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame == NULL )
return;
wxString frm3Dtitle;
frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) );
draw3DFrame->SetTitle( frm3Dtitle );
if( aForceReloadFootprint )
{
// Force 3D screen refresh immediately
draw3DFrame->NewDisplay( true );
}
PCB_BASE_FRAME::Update3DView( aForceReload, &frm3Dtitle );
}
@ -646,9 +611,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
_( "Select next parameters page" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,
KiBitmap( three_d_xpm ),
_( "Show footprint in 3D viewer" ) );
m_mainToolBar->Add( ACTIONS::show3DViewer );
m_mainToolBar->AddSeparator();
m_mainToolBar->Add( ACTIONS::zoomRedraw );

View File

@ -204,20 +204,14 @@ private:
*/
void ParametersUpdated( wxGridEvent& event );
/**
* Function Show3D_Frame (virtual)
* displays 3D view of the footprint (module) being edited.
*/
void Show3D_Frame( wxCommandEvent& event ) override;
/**
* Function Update3D_Frame
* must be called after a footprint selection
* Updates the 3D view and 3D frame title.
* @param aForceReloadFootprint = true to reload data (default)
* = false to update title only -(aftre creating the 3D viewer)
* @param aForceReload = true to reload data immediately
* @param aTitle (optional) the window title to set for the viewer
*/
void Update3D_Frame( bool aForceReloadFootprint = true );
void Update3DView( bool aForceReload, const wxString* aTitle ) override;
/*
* Virtual functions, not used here, but needed by PCB_BASE_FRAME

View File

@ -150,7 +150,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
if( !is_last_fp_from_brd )
ReCreateHToolbar();
Update3DView();
Update3DView( true );
updateView();
GetGalCanvas()->Refresh();
m_treePane->GetLibTree()->Refresh(); // update any previously-highlighted items

View File

@ -212,10 +212,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
_( "Browse footprint libraries" ),
modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ID_MENU_PCB_SHOW_3D_FRAME,
AddHotkeyName( _( "&3D Viewer" ), m_hotkeysDescrList, HK_3D_VIEWER ),
_( "Show footprint in 3D viewer" ),
three_d_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );

View File

@ -351,10 +351,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Footprint &Library Browser" ), _( "Browse footprint libraries" ),
modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ID_MENU_PCB_SHOW_3D_FRAME,
AddHotkeyName( _( "&3D Viewer" ), g_Board_Editor_Hotkeys_Descr, HK_3D_VIEWER ),
_( "Show board in 3D viewer" ),
three_d_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );

View File

@ -120,34 +120,20 @@ EDA_3D_VIEWER* PCB_BASE_FRAME::Get3DViewerFrame()
}
bool PCB_BASE_FRAME::Update3DView( const wxString* aTitle )
void PCB_BASE_FRAME::Update3DView( bool aForceReload, const wxString* aTitle )
{
// Update the 3D view only if the viewer is opened by this frame
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame == NULL )
return false;
// Ensure the viewer was created by me, and not by another editor:
PCB_BASE_FRAME* owner = draw3DFrame->Parent();
// if I am not the owner, do not use the current viewer instance
if( this != owner )
return false;
// JEY TODO: need to keep looking for one that is ours....
if( !draw3DFrame || draw3DFrame->Parent() != this )
return;
if( aTitle )
draw3DFrame->SetTitle( *aTitle );
// The 3D view update can be time consumming to rebuild a board 3D view.
// So do not use a immediate update in the board editor
bool immediate_update = true;
if( IsType( FRAME_PCB ) )
immediate_update = false;
draw3DFrame->NewDisplay( immediate_update );
return true;
draw3DFrame->NewDisplay( aForceReload );
}
@ -405,38 +391,16 @@ void PCB_BASE_FRAME::ShowChangedLanguage()
}
// Virtual functions: Do nothing for PCB_BASE_FRAME window
void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
{
}
bool PCB_BASE_FRAME::CreateAndShow3D_Frame( bool aForceRecreateIfNotOwner )
EDA_3D_VIEWER* PCB_BASE_FRAME::CreateAndShow3D_Frame()
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
// Ensure the viewer was created by me, and not by another editor:
PCB_BASE_FRAME* owner = draw3DFrame ? draw3DFrame->Parent() : nullptr;
// if I am not the owner, do not use the current viewer instance
if( draw3DFrame && this != owner )
{
if( aForceRecreateIfNotOwner )
{
draw3DFrame->Destroy();
draw3DFrame = nullptr;
}
else
return false;
}
if( draw3DFrame && draw3DFrame->Parent() != this )
draw3DFrame = nullptr;
if( !draw3DFrame )
{
draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
draw3DFrame->Raise(); // Needed with some Window Managers
draw3DFrame->Show( true );
return true;
}
// Raising the window does not show the window on Windows if iconized. This should work
// on any platform.
@ -444,12 +408,13 @@ bool PCB_BASE_FRAME::CreateAndShow3D_Frame( bool aForceRecreateIfNotOwner )
draw3DFrame->Iconize( false );
draw3DFrame->Raise();
draw3DFrame->Show( true );
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != draw3DFrame )
draw3DFrame->SetFocus();
return true;
return draw3DFrame;
}

View File

@ -177,9 +177,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS, PCB_EDIT_FRAME::OnEditTextAndGraphics )
// Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
// Menu Get Design Rules Editor
EVT_MENU( ID_BOARD_SETUP_DIALOG, PCB_EDIT_FRAME::ShowBoardSetupDialog )
@ -599,13 +596,6 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
{
bool forceRecreateIfNotOwner = true;
CreateAndShow3D_Frame( forceRecreateIfNotOwner );
}
void PCB_EDIT_FRAME::ActivateGalCanvas()
{
PCB_BASE_EDIT_FRAME::ActivateGalCanvas();
@ -892,7 +882,7 @@ void PCB_EDIT_FRAME::OnModify( )
{
PCB_BASE_FRAME::OnModify();
Update3DView();
Update3DView( false );
m_ZoneFillsDirty = true;
}

View File

@ -563,12 +563,6 @@ public:
*/
void ReFillLayerWidget();
/**
* Function Show3D_Frame
* displays the 3D view of current printed circuit board.
*/
void Show3D_Frame( wxCommandEvent& event ) override;
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void ActivateGalCanvas() override;

View File

@ -149,7 +149,6 @@ enum pcbnew_ids
ID_PCB_GEN_D356_FILE,
ID_PCB_GEN_CMP_FILE,
ID_MENU_PCB_SHOW_3D_FRAME,
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
ID_PCB_3DSHAPELIB_WIZARD,
ID_PCB_LIB_TABLE_EDIT,
@ -211,12 +210,10 @@ enum pcbnew_ids
ID_MODVIEW_OPTIONS,
ID_MODVIEW_PREVIOUS,
ID_MODVIEW_NEXT,
ID_MODVIEW_SHOW_3D_VIEW,
ID_FOOTPRINT_WIZARD_NEXT,
ID_FOOTPRINT_WIZARD_PREVIOUS,
ID_FOOTPRINT_WIZARD_DONE,
ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
ID_FOOTPRINT_WIZARD_PAGE_LIST,
ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
ID_FOOTPRINT_WIZARD_SELECT_WIZARD,

View File

@ -27,6 +27,7 @@
#include <tool/conditional_menu.h>
#include <tool/tool_manager.h>
#include <tools/selection_tool.h>
#include <tools/pcb_actions.h>
#include "help_common_strings.h"
#include "hotkeys.h"
#include "footprint_viewer_frame.h"
@ -76,9 +77,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_MODVIEW_SHOW_3D_VIEW, wxEmptyString,
KiScaledBitmap( three_d_xpm, this ),
_( "Show footprint in 3D viewer" ) );
m_mainToolBar->Add( ACTIONS::show3DViewer );
m_mainToolBar->AddTool( ID_ADD_FOOTPRINT_TO_BOARD, wxEmptyString,
KiScaledBitmap( export_xpm, this ),
_( "Insert footprint in board" ) );
@ -138,16 +137,13 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar()
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddItem( ID_MODVIEW_SHOW_3D_VIEW,
AddHotkeyName( _( "3D Viewer" ), g_Module_Viewer_Hotkeys_Descr, HK_3D_VIEWER ),
_( "Show footprint in 3D viewer" ),
three_d_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::show3DViewer, SELECTION_CONDITIONS::ShowAlways );
viewMenu->Resolve();

View File

@ -44,7 +44,7 @@
#include <io_mgr.h>
#include <kicad_plugin.h>
#include <kicad_clipboard.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <pcbnew_id.h>
#include <pcb_edit_frame.h>
#include <pcb_draw_panel_gal.h>
@ -993,10 +993,29 @@ int PCBNEW_CONTROL::ShowHelp( const TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent )
{
EDA_3D_VIEWER* draw3DFrame = m_frame->CreateAndShow3D_Frame();
if( m_frame->IsType( FRAME_PCB_MODULE_VIEWER )
|| m_frame->IsType( FRAME_PCB_MODULE_VIEWER_MODAL )
|| m_frame->IsType( FRAME_PCB_FOOTPRINT_WIZARD ) )
{
m_frame->Update3DView( true );
#ifdef __WXMAC__
// A stronger version of Raise() which promotes the window to its parent's level.
draw3DFrame->ReparentQuasiModal();
#endif
}
return 0;
}
int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
{
DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
return 0;
}
@ -1079,6 +1098,7 @@ void PCBNEW_CONTROL::setTransitions()
// Miscellaneous
Go( &PCBNEW_CONTROL::DeleteItemCursor, PCB_ACTIONS::deleteTool.MakeEvent() );
Go( &PCBNEW_CONTROL::ShowHelp, PCB_ACTIONS::showHelp.MakeEvent() );
Go( &PCBNEW_CONTROL::Show3DViewer, ACTIONS::show3DViewer.MakeEvent() );
Go( &PCBNEW_CONTROL::ToBeDone, PCB_ACTIONS::toBeDone.MakeEvent() );
// Append control

View File

@ -96,6 +96,7 @@ public:
int AppendBoardFromFile( const TOOL_EVENT& aEvent );
int AppendBoard( PLUGIN& pi, wxString& fileName );
int ShowHelp( const TOOL_EVENT& aEvent );
int Show3DViewer( const TOOL_EVENT& aEvent );
int ToBeDone( const TOOL_EVENT& aEvent );
int UpdateMessagePanel( const TOOL_EVENT& aEvent );