Add GAL support to Cvpcb display footprints frame.

This commit is contained in:
jean-pierre charras 2018-08-06 20:26:37 +02:00
parent 80f713f366
commit 15e0771ea8
19 changed files with 1176 additions and 139 deletions

View File

@ -34,6 +34,7 @@ set( CVPCB_SRCS
../pcbnew/board_items_to_polygon_shape_transform.cpp
../pcbnew/pcb_general_settings.cpp
../pcbnew/drc_item.cpp
../pcbnew/tools/grid_helper.cpp
auto_associate.cpp
cfg.cpp
components_listbox.cpp
@ -45,6 +46,9 @@ set( CVPCB_SRCS
menubar.cpp
readwrite_dlgs.cpp
tool_cvpcb.cpp
tools/cvpcb_actions.cpp
tools/cvpcb_control.cpp
tools/cvpcb_selection_tool.cpp
)

View File

@ -55,5 +55,6 @@ enum id_cvpcb_frm
ID_CVPCB_LIBRARY_LIST,
ID_CVPCB_EQUFILES_LIST_EDIT,
ID_CVPCB_LIB_TABLE_EDIT,
ID_CVPCB_FILTER_TEXT_EDIT
ID_CVPCB_FILTER_TEXT_EDIT,
ID_TB_MEASUREMENT_TOOL
};

View File

@ -968,7 +968,7 @@ void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();
DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
//DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
switch( mail.Command() )
{

View File

@ -39,23 +39,21 @@
void DISPLAY_FOOTPRINTS_FRAME::InstallOptionsDisplay( wxCommandEvent& event )
{
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS* OptionWindow =
new DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( this );
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS OptionWindow( this );
OptionWindow->ShowModal();
OptionWindow->Destroy();
OptionWindow.ShowModal();
}
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( PCB_BASE_FRAME* parent )
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( DISPLAY_FOOTPRINTS_FRAME* parent )
: DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE( parent )
{
m_Parent = parent;
initDialog();
m_sdbSizer1OK->SetDefault();
GetSizer()->SetSizeHints( this );
Centre();
m_sdbSizerOK->SetDefault();
FinishDialogSettings();;
}
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::~DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( )
@ -103,35 +101,18 @@ void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings( void )
m_Parent->GetCanvas()->SetEnableMousewheelPan( m_enableMousewheelPan->GetValue() );
m_Parent->GetCanvas()->SetEnableAutoPan( m_enableAutoPan->GetValue() );
m_Parent->applyDisplaySettingsToGAL();
m_Parent->GetCanvas()->Refresh();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::OnOkClick( wxCommandEvent& event )
bool DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::TransferDataFromWindow()
{
UpdateObjectSettings();
EndModal( 1 );
return true;
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY
*/
void DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::OnApplyClick( wxCommandEvent& event )
{
UpdateObjectSettings();

View File

@ -39,19 +39,18 @@ class DIALOG_FOOTPRINTS_DISPLAY_OPTIONS :
public DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE
{
private:
PCB_BASE_FRAME * m_Parent;
DISPLAY_FOOTPRINTS_FRAME * m_Parent;
public:
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( PCB_BASE_FRAME* parent );
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS( DISPLAY_FOOTPRINTS_FRAME* parent );
~DIALOG_FOOTPRINTS_DISPLAY_OPTIONS();
private:
void initDialog( );
void initDialog();
void UpdateObjectSettings( void );
void OnApplyClick( wxCommandEvent& event ) override;
void OnCancelClick( wxCommandEvent& event ) override;
void OnOkClick( wxCommandEvent& event ) override;
bool TransferDataFromWindow() override;
};
#endif // _DIALOG_DISPLAY_OPTIONS_H_

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -64,16 +64,16 @@ DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE(
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY );
m_sdbSizer1->AddButton( m_sdbSizer1Apply );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerApply = new wxButton( this, wxID_APPLY );
m_sdbSizer->AddButton( m_sdbSizerApply );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer1, 0, wxEXPAND|wxALL, 5 );
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
this->SetSizer( bSizerMain );
@ -81,16 +81,12 @@ DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE(
bSizerMain->Fit( this );
// Connect Events
m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnApplyClick ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnOkClick ), NULL, this );
m_sdbSizerApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnApplyClick ), NULL, this );
}
DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::~DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE()
{
// Disconnect Events
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnApplyClick ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnCancelClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnOkClick ), NULL, this );
m_sdbSizerApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE::OnApplyClick ), NULL, this );
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="13" />
<FileVersion major="1" minor="14" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -55,13 +55,20 @@
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneActivated"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -76,17 +83,23 @@
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMaximize"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnMove"></event>
<event name="OnMoveEnd"></event>
<event name="OnMoveStart"></event>
<event name="OnMoving"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnShow"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
@ -178,7 +191,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -266,7 +286,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -354,7 +381,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -442,7 +476,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -545,7 +586,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -633,7 +681,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -721,7 +776,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -807,7 +869,14 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@ -846,14 +915,14 @@
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick">OnApplyClick</event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 19 2018)
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -44,15 +44,13 @@ class DIALOG_FOOTPRINTS_DISPLAY_OPTIONS_BASE : public DIALOG_SHIM
wxCheckBox* m_enableMousewheelPan;
wxCheckBox* m_enableAutoPan;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Apply;
wxButton* m_sdbSizer1Cancel;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerApply;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnApplyClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2007-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
@ -29,8 +29,10 @@
#include <fctsys.h>
#include <common.h>
#include <gal/graphics_abstraction_layer.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <pcb_draw_panel_gal.h>
#include <confirm.h>
#include <macros.h>
#include <bitmaps.h>
@ -42,6 +44,7 @@
#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>
@ -49,6 +52,12 @@
#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>
#include "tools/cvpcb_actions.h"
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY );
@ -56,19 +65,16 @@ COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY );
BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow )
EVT_SIZE( DISPLAY_FOOTPRINTS_FRAME::OnSize )
EVT_TOOL( ID_OPTIONS_SETUP, DISPLAY_FOOTPRINTS_FRAME::InstallOptionsDisplay )
EVT_TOOL( ID_CVPCB_SHOW3D_FRAME, DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame )
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar)
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar)
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnUpdateTextDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnUpdateLineDrawMode )
/*
EVT_TOOL and EVT_UPDATE_UI for:
ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
ID_TB_OPTIONS_SHOW_PADS_SKETCH
are managed in PCB_BASE_FRAME
*/
END_EVENT_TABLE()
@ -107,6 +113,13 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
ReCreateVToolbar();
ReCreateOptToolbar();
// Create GAL canvas
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
//EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
GetGalDisplayOptions(), backend );
SetGalCanvas( gal_drawPanel );
m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiz;
@ -125,8 +138,13 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
m_auimgr.AddPane( m_drawToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right() );
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DisplayFrame" ) ).CentrePane() );
if( m_canvas )
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
if( GetGalCanvas() )
m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
m_auimgr.AddPane( m_messagePanel,
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
@ -136,12 +154,38 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
m_auimgr.Update();
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
gal_drawPanel->GetViewControls(), this );
m_actions = new CVPCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
m_actions->RegisterAllTools( m_toolManager );
m_toolManager->InitTools();
// Run the control tool, it is supposed to be always active
m_toolManager->InvokeTool( "cvpcb.InteractiveSelection" );
auto& galOpts = GetGalDisplayOptions();
galOpts.m_fullscreenCursor = true;
galOpts.m_forceDisplayCursor = true;
galOpts.m_axesEnabled = true;
UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
updateView();
Show( true );
}
DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME()
{
if( IsGalCanvasActive() )
GetGalCanvas()->StopDrawing();
delete GetScreen();
SetScreen( NULL ); // Be sure there is no double deletion
}
@ -248,31 +292,20 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
}
void DISPLAY_FOOTPRINTS_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent )
void DISPLAY_FOOTPRINTS_FRAME::UseGalCanvas( bool aEnable )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
wxString msgTextsFill[2] = { _( "Show texts in filled mode" ),
_( "Show texts in sketch mode" ) };
unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
aEvent.Check( displ_opts->m_DisplayModTextFill == SKETCH );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] );
PCB_BASE_FRAME::UseGalCanvas( aEnable );
}
void DISPLAY_FOOTPRINTS_FRAME::OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent )
void DISPLAY_FOOTPRINTS_FRAME::applyDisplaySettingsToGAL()
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
auto view = GetGalCanvas()->GetView();
auto painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
settings->LoadDisplayOptions( &m_DisplayOptions, false );
wxString msgEdgesFill[2] = { _( "Show outlines in filled mode" ),
_( "Show outlines in sketch mode" ) };
int i = displ_opts->m_DisplayModEdgeFill == SKETCH ? 0 : 1;
aEvent.Check( displ_opts->m_DisplayModEdgeFill == SKETCH );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i] );
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
@ -292,31 +325,6 @@ bool DISPLAY_FOOTPRINTS_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* Po
}
void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
switch( id )
{
case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH:
displ_opts->m_DisplayModTextFill = displ_opts->m_DisplayModTextFill == FILLED ? SKETCH : FILLED;
m_canvas->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH:
displ_opts->m_DisplayModEdgeFill = displ_opts->m_DisplayModEdgeFill == FILLED ? SKETCH : FILLED;
m_canvas->Refresh();
break;
default:
DisplayError( this,
wxT( "DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar error" ) );
break;
}
}
bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
EDA_KEY aHotKey )
{
@ -500,6 +508,8 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
else
SetStatusText( wxEmptyString, 0 );
updateView();
UpdateStatusBar();
Zoom_Automatique( false );
GetCanvas()->Refresh();
@ -507,6 +517,34 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
}
void DISPLAY_FOOTPRINTS_FRAME::updateView()
{
if( IsGalCanvasActive() )
{
PCB_DRAW_PANEL_GAL* dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
dp->UseColorScheme( &Settings().Colors() );
dp->DisplayBoard( GetBoard() );
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
UpdateMsgPanel();
}
}
void DISPLAY_FOOTPRINTS_FRAME::UpdateMsgPanel()
{
MODULE* footprint = GetBoard()->m_Modules;
MSG_PANEL_ITEMS items;
if( footprint )
{
footprint->GetMsgPanelInfo( m_UserUnits, items );
}
SetMsgPanel( items );
}
void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( !GetBoard() )
@ -515,14 +553,7 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas->DrawBackGround( DC );
GetBoard()->Draw( m_canvas, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules;
if ( Module )
{
MSG_PANEL_ITEMS items;
Module->GetMsgPanelInfo( m_UserUnits, items );
SetMsgPanel( items );
}
UpdateMsgPanel();
m_canvas->DrawCrossHair( DC );
}

View File

@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2007-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2007-2018 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
@ -25,7 +25,8 @@
/**
* @file display_footprints_frame.h
*/
#ifndef DISPLAY_FOOTPRINTS_FRAME_H
#define DISPLAY_FOOTPRINTS_FRAME_H
#include <pcb_base_frame.h>
@ -56,11 +57,6 @@ public:
void ReCreateVToolbar() override;
void ReCreateOptToolbar() override;
void OnSelectOptionToolbar( wxCommandEvent& event );
void OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent );
/**
* Function InitDisplay
* Refresh the full display for this frame:
@ -69,6 +65,20 @@ public:
*/
void InitDisplay();
/**
* update the gal canvas (view, colors ...)
*/
void updateView();
/// Updates the GAL with display settings changes
void applyDisplaySettingsToGAL();
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
void UseGalCanvas( bool aEnable ) override;
///> @copydoc EDA_DRAW_FRAME::UpdateMsgPanel()
void UpdateMsgPanel() override;
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
@ -131,3 +141,5 @@ public:
DECLARE_EVENT_TABLE()
};
#endif // DISPLAY_FOOTPRINTS_FRAME_H

View File

@ -0,0 +1,65 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2016 CERN
* Copyright (C) 2018 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 <tool/tool_manager.h>
#include <tool/common_tools.h>
#include <tool/zoom_tool.h>
#include "cvpcb_actions.h"
#include "cvpcb_control.h"
#include "cvpcb_selection_tool.h"
#include <cvpcb_id.h>
void CVPCB_ACTIONS::RegisterAllTools( TOOL_MANAGER* aToolManager )
{
aToolManager->RegisterTool( new COMMON_TOOLS );
aToolManager->RegisterTool( new ZOOM_TOOL );
aToolManager->RegisterTool( new CVPCB_SELECTION_TOOL );
aToolManager->RegisterTool( new CVPCB_CONTROL );
}
OPT<TOOL_EVENT> CVPCB_ACTIONS::TranslateLegacyId( int aId )
{
switch( aId )
{
case ID_ZOOM_IN: // toolbar button "Zoom In"
case ID_VIEWER_ZOOM_IN:
return ACTIONS::zoomInCenter.MakeEvent();
case ID_ZOOM_OUT: // toolbar button "Zoom In"
case ID_VIEWER_ZOOM_OUT:
return ACTIONS::zoomOutCenter.MakeEvent();
case ID_ZOOM_PAGE: // toolbar button "Fit on Screen"
case ID_VIEWER_ZOOM_PAGE:
return ACTIONS::zoomFitScreen.MakeEvent();
case ID_ZOOM_SELECTION:
return ACTIONS::zoomTool.MakeEvent();
}
return OPT<TOOL_EVENT>();
}

View File

@ -0,0 +1,86 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2016 CERN
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* 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
*/
#ifndef CVPCB_ACTIONS_H
#define CVPCB_ACTIONS_H
#include <tool/tool_action.h>
#include <tool/actions.h>
#include <core/optional.h>
class TOOL_EVENT;
class TOOL_MANAGER;
/**
* Class CVPCB_ACTIONS
*
* Gathers all the actions that are shared by tools. The instance of CVPCB_ACTIONS is created
* inside of ACTION_MANAGER object that registers the actions.
*/
class CVPCB_ACTIONS : public ACTIONS
{
public:
// Selection Tool
/// Activation of the selection tool
static TOOL_ACTION selectionActivate;
static TOOL_ACTION measureTool;
/// Cursor control with keyboard
static TOOL_ACTION cursorUp;
static TOOL_ACTION cursorDown;
static TOOL_ACTION cursorLeft;
static TOOL_ACTION cursorRight;
static TOOL_ACTION cursorUpFast;
static TOOL_ACTION cursorDownFast;
static TOOL_ACTION cursorLeftFast;
static TOOL_ACTION cursorRightFast;
static TOOL_ACTION cursorClick;
// Panning with keyboard
static TOOL_ACTION panUp;
static TOOL_ACTION panDown;
static TOOL_ACTION panLeft;
static TOOL_ACTION panRight;
// Miscellaneous
static TOOL_ACTION zoomTool;
static TOOL_ACTION resetCoords;
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;
///> @copydoc COMMON_ACTIONS::RegisterAllTools()
virtual void RegisterAllTools( TOOL_MANAGER* aToolManager ) override;
};
#endif

View File

@ -0,0 +1,288 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
* Copyright (C) 2007-2018 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 <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 <gal/graphics_abstraction_layer.h>
#include <view/view_controls.h>
//#include <pcb_painter.h>
#include <tools/grid_helper.h> // from pcbnew
#include <functional>
using namespace std::placeholders;
// Cursor control
TOOL_ACTION CVPCB_ACTIONS::cursorUp( "cvpcb.Control.cursorUp",
AS_GLOBAL, WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP );
TOOL_ACTION CVPCB_ACTIONS::cursorDown( "cvpcb.Control.cursorDown",
AS_GLOBAL, WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
TOOL_ACTION CVPCB_ACTIONS::cursorLeft( "cvpcb.Control.cursorLeft",
AS_GLOBAL, WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
TOOL_ACTION CVPCB_ACTIONS::cursorRight( "cvpcb.Control.cursorRight",
AS_GLOBAL, WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
TOOL_ACTION CVPCB_ACTIONS::cursorUpFast( "cvpcb.Control.cursorUpFast",
AS_GLOBAL, MD_CTRL + WXK_UP, "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) );
TOOL_ACTION CVPCB_ACTIONS::cursorDownFast( "cvpcb.Control.cursorDownFast",
AS_GLOBAL, MD_CTRL + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) );
TOOL_ACTION CVPCB_ACTIONS::cursorLeftFast( "cvpcb.Control.cursorLeftFast",
AS_GLOBAL, MD_CTRL + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) );
TOOL_ACTION CVPCB_ACTIONS::cursorRightFast( "cvpcb.Control.cursorRightFast",
AS_GLOBAL, MD_CTRL + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) );
TOOL_ACTION CVPCB_ACTIONS::cursorClick( "cvpcb.Control.cursorClick",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ),
"", "", NULL, AF_NONE, (void*) CURSOR_CLICK );
TOOL_ACTION CVPCB_ACTIONS::panUp( "cvpcb.Control.panUp",
AS_GLOBAL, MD_SHIFT + WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP );
TOOL_ACTION CVPCB_ACTIONS::panDown( "cvpcb.Control.panDown",
AS_GLOBAL, MD_SHIFT + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN );
TOOL_ACTION CVPCB_ACTIONS::panLeft( "cvpcb.Control.panLeft",
AS_GLOBAL, MD_SHIFT + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT );
TOOL_ACTION CVPCB_ACTIONS::panRight( "cvpcb.Control.panRight",
AS_GLOBAL, MD_SHIFT + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT );
// Miscellaneous
TOOL_ACTION CVPCB_ACTIONS::resetCoords( "cvpcb.Control.resetCoords",
AS_GLOBAL, ' ',//TOOL_ACTION::LegacyHotKey( HK_RESET_LOCAL_COORD ),
"", "" );
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 ),
"", "" );
CVPCB_CONTROL::CVPCB_CONTROL() :
TOOL_INTERACTIVE( "cvpcb.Control" ), m_frame( NULL )
{
}
CVPCB_CONTROL::~CVPCB_CONTROL()
{
}
void CVPCB_CONTROL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<DISPLAY_FOOTPRINTS_FRAME>();
}
// Cursor control
int CVPCB_CONTROL::CursorControl( const TOOL_EVENT& aEvent )
{
long type = aEvent.Parameter<intptr_t>();
bool fastMove = type & CVPCB_ACTIONS::CURSOR_FAST_MOVE;
type &= ~CVPCB_ACTIONS::CURSOR_FAST_MOVE;
bool mirroredX = getView()->IsMirroredX();
GRID_HELPER gridHelper( m_frame );
VECTOR2D cursor = getViewControls()->GetRawCursorPosition( true );
VECTOR2I gridSize = gridHelper.GetGrid();
if( fastMove )
gridSize = gridSize * 10;
switch( type )
{
case CVPCB_ACTIONS::CURSOR_UP:
cursor -= VECTOR2D( 0, gridSize.y );
break;
case CVPCB_ACTIONS::CURSOR_DOWN:
cursor += VECTOR2D( 0, gridSize.y );
break;
case CVPCB_ACTIONS::CURSOR_LEFT:
cursor -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break;
case CVPCB_ACTIONS::CURSOR_RIGHT:
cursor += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break;
case CVPCB_ACTIONS::CURSOR_CLICK: // fall through
case CVPCB_ACTIONS::CURSOR_DBL_CLICK:
{
TOOL_ACTIONS action = TA_NONE;
int modifiers = 0;
modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
if( type == CVPCB_ACTIONS::CURSOR_CLICK )
action = TA_MOUSE_CLICK;
else if( type == CVPCB_ACTIONS::CURSOR_DBL_CLICK )
action = TA_MOUSE_DBLCLICK;
else
wxFAIL;
TOOL_EVENT evt( TC_MOUSE, action, BUT_LEFT | modifiers );
evt.SetMousePosition( getViewControls()->GetCursorPosition() );
m_toolMgr->ProcessEvent( evt );
return 0;
}
break;
}
getViewControls()->SetCursorPosition( cursor );
return 0;
}
int CVPCB_CONTROL::PanControl( const TOOL_EVENT& aEvent )
{
long type = aEvent.Parameter<intptr_t>();
KIGFX::VIEW* view = getView();
GRID_HELPER gridHelper( m_frame );
VECTOR2D center = view->GetCenter();
VECTOR2I gridSize = gridHelper.GetGrid() * 10;
bool mirroredX = view->IsMirroredX();
switch( type )
{
case CVPCB_ACTIONS::CURSOR_UP:
center -= VECTOR2D( 0, gridSize.y );
break;
case CVPCB_ACTIONS::CURSOR_DOWN:
center += VECTOR2D( 0, gridSize.y );
break;
case CVPCB_ACTIONS::CURSOR_LEFT:
center -= VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break;
case CVPCB_ACTIONS::CURSOR_RIGHT:
center += VECTOR2D( mirroredX ? -gridSize.x : gridSize.x, 0 );
break;
default:
wxFAIL;
break;
}
view->SetCenter( center );
return 0;
}
// Miscellaneous
int CVPCB_CONTROL::ResetCoords( const TOOL_EVENT& aEvent )
{
auto vcSettings = m_toolMgr->GetCurrentToolVC();
// Use either the active tool forced cursor position or the general settings
VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
return 0;
}
int CVPCB_CONTROL::SwitchCursor( 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 )
{
// TODO should not it be refactored to pcb_frame member function?
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
if( m_frame->GetUserUnits() == INCHES )
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_MM );
else
evt.SetId( ID_TB_OPTIONS_SELECT_UNIT_INCH );
m_frame->ProcessEvent( evt );
return 0;
}
void CVPCB_CONTROL::setTransitions()
{
// Cursor control
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorUp.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorDown.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorLeft.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorRight.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorUpFast.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorDownFast.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorLeftFast.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorRightFast.MakeEvent() );
Go( &CVPCB_CONTROL::CursorControl, CVPCB_ACTIONS::cursorClick.MakeEvent() );
// Pan control
Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panUp.MakeEvent() );
Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panDown.MakeEvent() );
Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panLeft.MakeEvent() );
Go( &CVPCB_CONTROL::PanControl, CVPCB_ACTIONS::panRight.MakeEvent() );
// Miscellaneous
Go( &CVPCB_CONTROL::ResetCoords, CVPCB_ACTIONS::resetCoords.MakeEvent() );
Go( &CVPCB_CONTROL::SwitchCursor, CVPCB_ACTIONS::switchCursor.MakeEvent() );
Go( &CVPCB_CONTROL::SwitchUnits, CVPCB_ACTIONS::switchUnits.MakeEvent() );
}
/*
void CVPCB_CONTROL::updateGrid()
{
BASE_SCREEN* screen = m_frame->GetScreen();
//GRID_TYPE grid = screen->GetGrid( idx );
getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
*/

View File

@ -0,0 +1,78 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2016 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
* Copyright (C) 2007-2018 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
*/
#ifndef CVPCB_CONTROL_H
#define CVPCB_CONTROL_H
#include <tool/tool_interactive.h>
#include <display_footprints_frame.h>
namespace KIGFX {
class ORIGIN_VIEWITEM;
}
/**
* Class CVPCB_CONTROL
*
* Handles actions in cvpcb display frame.
*/
class CVPCB_CONTROL : public TOOL_INTERACTIVE
{
public:
CVPCB_CONTROL();
~CVPCB_CONTROL();
/// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override;
int CursorControl( const TOOL_EVENT& aEvent );
int PanControl( const TOOL_EVENT& aEvent );
// Miscellaneous
int ResetCoords( const TOOL_EVENT& aEvent );
int SwitchCursor( const TOOL_EVENT& aEvent );
int SwitchUnits( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;
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;
///> Applies the legacy canvas grid settings for GAL.
void updateGrid();
KIGFX::VIEW* view()
{
return m_frame->GetGalCanvas()->GetView();
}
};
#endif

View File

@ -0,0 +1,290 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <limits>
#include <functional>
using namespace std::placeholders;
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <hotkeys.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <preview_items/ruler_item.h>
#include <cvpcb_id.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
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 );
CVPCB_SELECTION_TOOL::CVPCB_SELECTION_TOOL() :
TOOL_INTERACTIVE( "cvpcb.InteractiveSelection" ),
m_frame( NULL ), 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>() );
return true;
}
void CVPCB_SELECTION_TOOL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<DISPLAY_FOOTPRINTS_FRAME>();
}
int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
// This is kind of hacky: activate RMB drag on any event.
// There doesn't seem to be any other good way to tell when another tool
// is canceled and control returns to the selection tool, except by the
// fact that the selection tool starts to get events again.
if( m_frame->GetToolId() == ID_NO_TOOL_SELECTED)
{
getViewControls()->SetAdditionalPanButtons( false, true );
}
// Disable RMB pan for other tools; they can re-enable if desired
if( evt->IsActivate() )
{
getViewControls()->SetAdditionalPanButtons( false, false );
}
// single click? Select single object
if( evt->IsClick( BUT_LEFT ) )
{
clearSelection();
}
// right click? if there is any object - show the context menu
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selection );
}
else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
{
clearSelection();
}
else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
}
// This tool is supposed to be active forever
wxASSERT( false );
return 0;
}
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();
auto& controls = *getViewControls();
auto previous_settings = controls.GetSettings();
Activate();
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() );
view.Add( &ruler );
view.SetVisible( &ruler, false );
bool originSet = false;
controls.ShowCursor( true );
controls.SetSnapping( true );
controls.SetAdditionalPanButtons( false, true );
while( auto evt = Wait() )
{
const VECTOR2I cursorPos = controls.GetCursorPosition();
if( evt->IsCancel() || evt->IsActivate() )
{
break;
}
// click or drag starts
else if( !originSet &&
( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
{
if( !evt->IsDrag( BUT_LEFT ) )
{
twoPtMgr.SetOrigin( cursorPos );
twoPtMgr.SetEnd( cursorPos );
}
controls.CaptureCursor( true );
controls.SetAutoPan( true );
originSet = true;
}
else if( !originSet && evt->IsMotion() )
{
// make sure the origin is set before a drag starts
// otherwise you can miss a step
twoPtMgr.SetOrigin( cursorPos );
twoPtMgr.SetEnd( cursorPos );
}
// second click or mouse up after drag ends
else if( originSet &&
( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
{
originSet = false;
controls.SetAutoPan( false );
controls.CaptureCursor( false );
view.SetVisible( &ruler, false );
}
// move or drag when origin set updates rules
else if( originSet &&
( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
{
twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
twoPtMgr.SetEnd( cursorPos );
view.SetVisible( &ruler, true );
view.Update( &ruler, KIGFX::GEOMETRY );
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( m_selection );
}
}
view.SetVisible( &ruler, false );
view.Remove( &ruler );
controls.ApplySettings( previous_settings );
m_frame->SetNoToolSelected();
return 0;
}
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() );
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
items.push_back( item );
return items;
}

View File

@ -0,0 +1,99 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef CVPCB_SELECTION_TOOL_H
#define CVPCB_SELECTION_TOOL_H
#include <tool/tool_interactive.h>
#include <tool/context_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
*
* Selection tool for GerbView, based on the one in PcbNew
*/
class CVPCB_SELECTION_TOOL : public TOOL_INTERACTIVE
{
public:
CVPCB_SELECTION_TOOL();
~CVPCB_SELECTION_TOOL();
/// @copydoc TOOL_BASE::Init()
bool Init() override;
/// @copydoc TOOL_BASE::Reset()
void Reset( RESET_REASON aReason ) override;
/**
* Function Main()
*
* The main loop.
*/
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.
*/
void clearSelection() {};
///> Launches a tool to measure between points
int MeasureTool( const TOOL_EVENT& aEvent );
///> 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;
};
#endif

View File

@ -568,7 +568,7 @@ void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
if( gal )
{
// Apply new display options to the GAL canvas
// Apply new display options to the GAL canvas
auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
view->UpdateDisplayOptions( displ_opts );
@ -597,6 +597,16 @@ void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
displ_opts->m_DisplayModEdgeFill = !displ_opts->m_DisplayModEdgeFill;
EDA_DRAW_PANEL_GAL* gal = GetGalCanvas();
if( gal )
{
// Apply new display options to the GAL canvas
auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
view->UpdateDisplayOptions( displ_opts );
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
m_canvas->Refresh();
}
@ -605,6 +615,16 @@ void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
displ_opts->m_DisplayModTextFill = !displ_opts->m_DisplayModTextFill;
EDA_DRAW_PANEL_GAL* gal = GetGalCanvas();
if( gal )
{
// Apply new display options to the GAL canvas
auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
view->UpdateDisplayOptions( displ_opts );
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
m_canvas->Refresh();
}
@ -663,6 +683,12 @@ void PCB_BASE_FRAME::OnUpdateEdgeDrawMode( wxUpdateUIEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
aEvent.Check( !displ_opts->m_DisplayModEdgeFill );
wxString msgEdgesFill[2] = { _( "Show outlines in filled mode" ),
_( "Show outlines in sketch mode" ) };
unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i] );
}
@ -670,6 +696,11 @@ void PCB_BASE_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
aEvent.Check( !displ_opts->m_DisplayModTextFill );
wxString msgTextsFill[2] = { _( "Show texts in filled mode" ),
_( "Show texts in sketch mode" ) };
unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] );
}

View File

@ -55,6 +55,7 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
m_clearance = CL_NONE;
m_sketchBoardGfx = false;
m_sketchFpGfx = false;
m_sketchFpTxtfx = false;
m_selectionCandidateColor = COLOR4D( 0.0, 1.0, 0.0, 0.75 );
// By default everything should be displayed as filled
@ -133,6 +134,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption
m_padNumbers = aOptions->m_DisplayPadNum;
m_sketchBoardGfx = !aOptions->m_DisplayDrawItemsFill;
m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill;
m_sketchFpTxtfx = !aOptions->m_DisplayModTextFill;
// Whether to draw tracks, vias & pads filled or as outlines
m_sketchMode[LAYER_PADS_TH] = !aOptions->m_DisplayPadFill;
@ -1020,10 +1022,14 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
if( shownText.Length() == 0 )
return;
bool sketch = m_pcbSettings.m_sketchFpTxtfx;
const COLOR4D& color = m_pcbSettings.GetColor( aText, aLayer );
VECTOR2D position( aText->GetTextPos().x, aText->GetTextPos().y );
if( m_pcbSettings.m_sketchMode[aLayer] )
// Currently, draw text routines do not know the true outline mode.
// so draw the text in "line" mode (no thickness)
if( sketch )
{
// Outline mode
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
@ -1041,7 +1047,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() );
// Draw the umbilical line
if( aText->IsSelected() && aText->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
if( aText->IsSelected() )
{
m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );

View File

@ -153,6 +153,9 @@ protected:
///> Flag determining if footprint graphic items should be outlined or stroked
bool m_sketchFpGfx;
///> Flag determining if footprint text items should be outlined or stroked
bool m_sketchFpTxtfx;
///> Flag determining if pad numbers should be visible
bool m_padNumbers;