KiCad PCB EDA Suite
viewlib_frame.cpp File Reference
#include <fctsys.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <sch_draw_panel.h>
#include <sch_view.h>
#include <msgpanel.h>
#include <bitmaps.h>
#include <eda_dockart.h>
#include <sch_edit_frame.h>
#include <eeschema_id.h>
#include <general.h>
#include <viewlib_frame.h>
#include <symbol_lib_table.h>
#include <sch_legacy_plugin.h>
#include <hotkeys.h>
#include <dialog_helpers.h>
#include <class_libentry.h>
#include <class_library.h>
#include <view/view_controls.h>
#include <sch_painter.h>

Go to the source code of this file.

Macros

#define LIB_VIEW_NAME   "ViewlibFrame"
 
#define LIB_VIEW_NAME_MODAL   "ViewlibFrameModal"
 
#define LIB_VIEW_STYLE   ( KICAD_DEFAULT_DRAWFRAME_STYLE )
 
#define LIB_VIEW_STYLE_MODAL   ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
 
#define LIBLIST_WIDTH_KEY   "ViewLiblistWidth"
 
#define CMPLIST_WIDTH_KEY   "ViewCmplistWidth"
 
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY   "ViewCmpShowPinElectricalType"
 

Functions

 EVT_TOOL_RANGE (ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onSelectSymbolBodyStyle) LIB_VIEW_FRAME
 

Macro Definition Documentation

#define CMPLIST_WIDTH_KEY   "ViewCmplistWidth"
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY   "ViewCmpShowPinElectricalType"
#define LIB_VIEW_NAME   "ViewlibFrame"

Referenced by EVT_TOOL_RANGE().

#define LIB_VIEW_NAME_MODAL   "ViewlibFrameModal"
#define LIB_VIEW_STYLE   ( KICAD_DEFAULT_DRAWFRAME_STYLE )
#define LIB_VIEW_STYLE_MODAL   ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
#define LIBLIST_WIDTH_KEY   "ViewLiblistWidth"

Function Documentation

Definition at line 71 of file viewlib_frame.cpp.

References EDA_PANE::Canvas(), FRAME_SCH_VIEWER, FRAME_SCH_VIEWER_MODAL, g_Viewlib_Hokeys_Descr, ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_LEVEL_50, KiBitmap(), PCAD2KICAD::Left, LIB_VIEW_NAME, BOX2< Vec >::SetOrigin(), and BOX2< Vec >::SetSize().

105  :
106  SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Library Browser" ),
107  wxDefaultPosition, wxDefaultSize,
110  m_libList( nullptr ),
111  m_cmpList( nullptr ),
112  m_previewItem( nullptr )
113 {
114  wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL );
115 
116  if( aFrameType == FRAME_SCH_VIEWER_MODAL )
117  SetModal( true );
118 
119  // Force the frame name used in config. the lib viewer frame has a name
120  // depending on aFrameType (needed to identify the frame by wxWidgets),
121  // but only one configuration is preferable.
122  m_configFrameName = LIB_VIEW_NAME;
123 
124  // Give an icon
125  wxIcon icon;
126  icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) );
127  SetIcon( icon );
128 
129  m_hotkeysDescrList = g_Viewlib_Hokeys_Descr;
130  m_libListWidth = 200;
131  m_cmpListWidth = 300;
132  m_listPowerCmpOnly = false;
133  SetShowElectricalType( true );
134 
135  // Initialize grid id to the default value (50 mils):
137 
138  SetScreen( new SCH_SCREEN( aKiway ) );
139  GetScreen()->m_Center = true; // Axis origin centered on screen.
140  LoadSettings( config() );
141 
142  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
143 
144  SetPresetGrid( m_LastGridSizeId );
145 
146  // Menu bar is not mandatory: uncomment/comment the next line
147  // to add/remove the menubar
148  ReCreateMenuBar();
149  ReCreateHToolbar();
150  ReCreateVToolbar();
151 
152  m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
153  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
154 
155  m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxDefaultPosition, wxDefaultSize,
156  0, NULL, wxLB_HSCROLL | wxNO_BORDER );
157 
158  if( aLibraryName.empty() )
159  {
160  ReCreateListLib();
161  }
162  else
163  {
164  m_libraryName = aLibraryName;
165  m_entryName.Clear();
166  m_unit = 1;
167  m_convert = 1;
168  }
169 
170  m_selection_changed = false;
171 
172  DisplayLibInfos();
173 
174  m_auimgr.SetManagedWindow( this );
175  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
176 
177  // Manage main toolbar
178  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
179  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
180 
181  m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(3)
182  .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_libListWidth, -1 ) );
183  m_auimgr.AddPane( m_cmpList, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
184  .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_cmpListWidth, -1 ) );
185 
186  m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
187 
188  m_auimgr.GetPane( m_libList ).Show( aLibraryName.empty() );
189 
190  m_auimgr.Update();
191 
192  // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
193 #ifdef USE_WX_GRAPHICS_CONTEXT
194  GetScreen()->SetScalingFactor( BestZoom() );
195 #else
196  Zoom_Automatique( false );
197 #endif
198 
199  if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
200  {
201  Raise();
202  Show( true );
203  }
204 
205  SyncView();
206  GetGalCanvas()->GetViewControls()->SetSnapping( true );
207  GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
208  GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
209 
210  // Set the working/draw area size to display a symbol to a reasonable value:
211  // A 450mm x 450mm with a origin at the area center looks like a large working area
212  double max_size_x = Millimeter2iu( 450 );
213  double max_size_y = Millimeter2iu( 450 );
214  BOX2D bbox;
215  bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
216  bbox.SetSize( max_size_x, max_size_y );
217  GetCanvas()->GetView()->SetBoundary( bbox );
218 }
void SetSize(const Vec &size)
Definition: box2.h:210
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
Specialization of the wxAuiPaneInfo class for KiCad panels.
#define LIB_VIEW_NAME
EDA_PANE & Canvas()
Function Canvas Turn *this into an undecorated pane suitable for a drawing canvas.
#define LIB_VIEW_NAME_MODAL
#define LIB_VIEW_STYLE_MODAL
struct EDA_HOTKEY_CONFIG g_Viewlib_Hokeys_Descr[]
#define LIB_VIEW_STYLE
void SetOrigin(const Vec &pos)
Definition: box2.h:208
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.