KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_draw_panel_gal.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014-2017 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "pcb_draw_panel_gal.h"
27
29#include <pcb_view.h>
31#include <pcb_painter.h>
34
35#include <board.h>
36#include <footprint.h>
37#include <pad.h>
38#include <pcb_track.h>
39#include <macros.h>
40#include <pcb_generator.h>
41#include <pcb_marker.h>
42#include <pcb_point.h>
43#include <pcb_base_frame.h>
44#include <pcbnew_settings.h>
47#include <pcb_board_outline.h>
48
49#include <pgm_base.h>
51#include <confirm.h>
52#include <progress_reporter.h>
53#include <string_utils.h>
54
56#include <zoom_defines.h>
57
58#include <functional>
59#include <memory>
60#include <thread>
61#include <fmt/format.h>
62
63using namespace std::placeholders;
64
65
66const int GAL_LAYER_ORDER[] = {
69
71
78
109
111
113
117
120 // POINT_LAYER_FOR( F_Cu ),
124
185
190
193
206
209
218
221
223
225};
226
227
228PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
229 const wxPoint& aPosition, const wxSize& aSize,
230 KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
231 EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType )
232{
233 m_view = new KIGFX::PCB_VIEW();
234 m_view->SetGAL( m_gal );
235
237
238 if( EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( aParentWindow ) )
239 frameType = frame->GetFrameType();
240
241 m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal, frameType );
242 m_view->SetPainter( m_painter.get() );
243
244 // This fixes the zoom in and zoom out limits:
246
249
250 // View controls is the first in the event handler chain, so the Tool Framework operates
251 // on updated viewport data.
253
254 // Load display options (such as filled/outline display of items).
255 // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
256 // which is not always the case (namely when it is used from a wxDialog like the pad editor)
257 if( !IsDialogPreview() )
258 {
259 KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( m_view );
260 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
261
262 if( frame )
263 view->UpdateDisplayOptions( frame->GetDisplayOptions() );
264 }
265}
266
267
271
272
274{
275 m_view->Clear();
276
277 aBoard->CacheTriangulation( aReporter );
278
279 if( m_drawingSheet )
280 m_drawingSheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
281
282 // Collect all board items, expanding footprints into their children (pads, fields,
283 // graphics, zones) which are individually registered in the VIEW for rendering and
284 // selection. Then bulk-load all items in a single pass for efficient R-tree construction.
285 std::vector<KIGFX::VIEW_ITEM*> viewItems;
286
287 for( BOARD_ITEM* item : aBoard->GetItemSet() )
288 {
289 viewItems.push_back( item );
290
291 if( item->Type() == PCB_FOOTPRINT_T )
292 {
293 static_cast<FOOTPRINT*>( item )->RunOnChildren(
294 [&viewItems]( BOARD_ITEM* child )
295 {
296 viewItems.push_back( child );
297 },
299 }
300 }
301
302 m_view->AddBatch( viewItems );
303
304 aBoard->UpdateBoardOutline();
305 m_view->Add( aBoard->BoardOutline() );
306
307 // Ratsnest
308 if( !aBoard->IsFootprintHolder() )
309 {
310 m_ratsnest = std::make_unique<RATSNEST_VIEW_ITEM>( aBoard->GetConnectivity() );
311 m_view->Add( m_ratsnest.get() );
312 }
313}
314
315
317{
318 m_drawingSheet.reset( aDrawingSheet );
319 m_view->Add( m_drawingSheet.get() );
320}
321
322
324{
326 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
327
328 if( frame )
329 cs = frame->GetColorSettings();
330 else if( PCBNEW_SETTINGS* cfg = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
331 cs = ::GetColorSettings( cfg->m_ColorTheme );
332
333 wxCHECK_RET( cs, wxT( "null COLOR_SETTINGS" ) );
334
335 auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
336 rs->LoadColors( cs );
337
338 m_gal->SetGridColor( cs->GetColor( LAYER_GRID ) );
339 m_gal->SetAxesColor( cs->GetColor( LAYER_GRID_AXES ) );
340 m_gal->SetCursorColor( cs->GetColor( LAYER_CURSOR ) );
341}
342
343
345{
346 // Set display settings for high contrast mode
347 KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
348
349 SetTopLayer( aLayer );
350 rSettings->SetActiveLayer( aLayer );
351
352 rSettings->ClearHighContrastLayers();
353 rSettings->SetLayerIsHighContrast( aLayer );
354
355 if( IsCopperLayer( aLayer ) )
356 {
357 // Bring some other layers to the front in case of copper layers and make them colored
358 // fixme do not like the idea of storing the list of layers here,
359 // should be done in some other way I guess..
360 int layers[] = {
362 GetNetnameLayer( aLayer ),
365 PAD_COPPER_LAYER_FOR( aLayer ),
366 VIA_COPPER_LAYER_FOR( aLayer ),
367 ZONE_LAYER_FOR( aLayer ),
368 BITMAP_LAYER_FOR( aLayer ),
369 POINT_LAYER_FOR( aLayer ),
379 };
380
381 for( int i : layers )
382 rSettings->SetLayerIsHighContrast( i );
383
384 for( int i = LAYER_UI_START; i < LAYER_UI_END; ++i )
385 rSettings->SetLayerIsHighContrast( i );
386
387 // Pads should be shown too
388 if( aLayer == B_Cu )
389 {
391 }
392 else if( aLayer == F_Cu )
393 {
395 }
396 }
397
398 m_view->UpdateAllLayersColor();
399}
400
401
403{
404 m_view->ClearTopLayers();
406 m_view->SetTopLayer( aLayer );
407
408 // Layers that should always have on-top attribute enabled
409 const std::vector<int> layers = {
415 };
416
417 for( auto layer : layers )
418 m_view->SetTopLayer( layer );
419
420 for( int i = LAYER_UI_START; i < LAYER_UI_END; i++ )
421 m_view->SetTopLayer( i );
422
423 // Extra layers that are brought to the top if a F.* or B.* is selected
424 const std::vector<int> frontLayers = {
427 };
428
429 const std::vector<int> backLayers = {
432 };
433
434 const std::vector<int>* extraLayers = nullptr;
435
436 // Bring a few more extra layers to the top depending on the selected board side
437 if( IsFrontLayer( aLayer ) )
438 extraLayers = &frontLayers;
439 else if( IsBackLayer( aLayer ) )
440 extraLayers = &backLayers;
441
442 if( extraLayers )
443 {
444 for( auto layer : *extraLayers )
445 {
446 m_view->SetTopLayer( layer );
447
448 if( layer < PCB_LAYER_ID_COUNT )
449 {
450 m_view->SetTopLayer( ZONE_LAYER_FOR( layer ) );
451 m_view->SetTopLayer( PAD_COPPER_LAYER_FOR( layer ) );
452 m_view->SetTopLayer( VIA_COPPER_LAYER_FOR( layer ) );
453 m_view->SetTopLayer( CLEARANCE_LAYER_FOR( layer ) );
454 m_view->SetTopLayer( POINT_LAYER_FOR( layer ) );
455 }
456 }
457
458 // Move the active layer to the top of the stack but below all the overlay layers
459 if( !IsCopperLayer( aLayer ) )
460 {
461 m_view->SetLayerOrder( aLayer, m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 1 );
462 m_view->SetLayerOrder( ZONE_LAYER_FOR( aLayer ),
463 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 2 );
464 m_view->SetLayerOrder( POINT_LAYER_FOR( aLayer ),
465 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 3 );
466
467 // Fix up pad and via netnames to be below. This is hacky, we need a rethink
468 // of layer ordering...
469 m_view->SetLayerOrder( LAYER_PAD_NETNAMES,
470 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 4 );
471 m_view->SetLayerOrder( LAYER_VIA_NETNAMES,
472 m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 5 );
473 }
474 }
475
476 if( IsCopperLayer( aLayer ) )
477 {
478 m_view->SetTopLayer( ZONE_LAYER_FOR( aLayer ) );
479 m_view->SetTopLayer( PAD_COPPER_LAYER_FOR( aLayer ) );
480 m_view->SetTopLayer( VIA_COPPER_LAYER_FOR( aLayer ) );
481 m_view->SetTopLayer( CLEARANCE_LAYER_FOR( aLayer ) );
482
483 // Display labels for copper layers on the top
484 m_view->SetTopLayer( GetNetnameLayer( aLayer ) );
485 }
486
487 m_view->SetTopLayer( POINT_LAYER_FOR( aLayer ) );
488 m_view->SetTopLayer( BITMAP_LAYER_FOR( aLayer ) );
489 m_view->EnableTopLayer( true );
490 m_view->UpdateAllLayersOrder();
491}
492
493
495{
496 // Load layer & elements visibility settings
497 for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
498 m_view->SetLayerVisible( i, aBoard->IsLayerVisible( PCB_LAYER_ID( i ) ) );
499
501 m_view->SetLayerVisible( i, aBoard->IsElementVisible( i ) );
502
503 // Via layers controlled by dependencies
504 m_view->SetLayerVisible( LAYER_VIA_MICROVIA, true );
505 m_view->SetLayerVisible( LAYER_VIA_BLIND, true );
506 m_view->SetLayerVisible( LAYER_VIA_BURIED, true );
507 m_view->SetLayerVisible( LAYER_VIA_THROUGH, true );
508
509 // Always enable netname layers, as their visibility is controlled by layer dependencies
510 for( int i = NETNAMES_LAYER_ID_START; i < NETNAMES_LAYER_ID_END; ++i )
511 m_view->SetLayerVisible( i, true );
512
513 for( int i = LAYER_ZONE_START; i < LAYER_ZONE_END; i++ )
514 m_view->SetLayerVisible( i, true );
515
516 for( int i = LAYER_PAD_COPPER_START; i < LAYER_PAD_COPPER_END; i++ )
517 m_view->SetLayerVisible( i, true );
518
519 for( int i = LAYER_VIA_COPPER_START; i < LAYER_VIA_COPPER_END; i++ )
520 m_view->SetLayerVisible( i, true );
521
522 for( int i = LAYER_CLEARANCE_START; i < LAYER_CLEARANCE_END; i++ )
523 m_view->SetLayerVisible( i, false );
524
525 for( int i = LAYER_POINT_START; i < LAYER_POINT_END; i++ )
526 m_view->SetLayerVisible( i, true );
527
528 for( int i = LAYER_BITMAP_START; i < LAYER_BITMAP_END; i++ )
529 m_view->SetLayerVisible( i, true );
530
531 for( int i = LAYER_UI_START; i < LAYER_UI_END; i++ )
532 m_view->SetLayerVisible( i, true );
533
534 // Enable some layers that are GAL specific
535 m_view->SetLayerVisible( LAYER_PAD_PLATEDHOLES, true );
536 m_view->SetLayerVisible( LAYER_NON_PLATEDHOLES, true );
537 m_view->SetLayerVisible( LAYER_PAD_HOLEWALLS, true );
538 m_view->SetLayerVisible( LAYER_VIA_HOLES, true );
539 m_view->SetLayerVisible( LAYER_VIA_HOLEWALLS, true );
540 m_view->SetLayerVisible( LAYER_GP_OVERLAY, true );
541 m_view->SetLayerVisible( LAYER_SELECT_OVERLAY, true );
542 m_view->SetLayerVisible( LAYER_RATSNEST, true );
543 m_view->SetLayerVisible( LAYER_MARKER_SHADOWS, true );
544 m_view->SetLayerVisible( LAYER_DRC_SHAPES, true );
545 m_view->SetLayerVisible( LAYER_DRC_HIGHLIGHTED, true );
546}
547
548
550 std::vector<MSG_PANEL_ITEM>& aList )
551{
552 BOARD* board = static_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() )->GetBoard();
553 int padCount = 0;
554 int viaCount = 0;
555 int trackSegmentCount = 0;
556 std::set<int> netCodes;
557 int unconnected = (int) board->GetConnectivity()->GetUnconnectedCount( true );
558
559 for( PCB_TRACK* item : board->Tracks() )
560 {
561 if( item->Type() == PCB_VIA_T )
562 viaCount++;
563 else
564 trackSegmentCount++;
565
566 if( item->GetNetCode() > 0 )
567 netCodes.insert( item->GetNetCode() );
568 }
569
570 for( FOOTPRINT* footprint : board->Footprints() )
571 {
572 for( PAD* pad : footprint->Pads() )
573 {
574 padCount++;
575
576 if( pad->GetNetCode() > 0 )
577 netCodes.insert( pad->GetNetCode() );
578 }
579 }
580
581 aList.emplace_back( _( "Pads" ), fmt::format( "{}", padCount ) );
582 aList.emplace_back( _( "Vias" ), fmt::format( "{}", viaCount ) );
583 aList.emplace_back( _( "Track Segments" ), fmt::format( "{}", trackSegmentCount ) );
584 aList.emplace_back( _( "Nets" ), fmt::format( "{}", (int) netCodes.size() ) );
585 aList.emplace_back( _( "Unrouted" ), fmt::format( "{}", unconnected ) );
586}
587
588
590{
591 PCB_BASE_FRAME* frame = nullptr;
592
593 if( !IsDialogPreview() )
594 frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
595
596 try
597 {
598 // Check if the current rendering back end can be properly initialized
599 m_view->UpdateItems();
600 }
601 catch( const std::runtime_error& e )
602 {
603 DisplayError( GetParent(), e.what() );
604
605 // Use the fallback if we have one
606 if( GAL_FALLBACK != m_backend )
607 {
609
610 if( frame )
611 frame->ActivateGalCanvas();
612 }
613 }
614
615 if( frame )
616 {
617 SetTopLayer( frame->GetActiveLayer() );
618
619 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( m_view->GetPainter() );
620 KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
621
622 settings->LoadDisplayOptions( frame->GetDisplayOptions() );
624 }
625}
626
627
629{
630 for( int i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( int ); ++i )
631 {
632 int layer = GAL_LAYER_ORDER[i];
633 wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
634
635 // MW: Gross hack to make SetTopLayer bring the correct bitmap layer to
636 // the top of the other bitmaps, but still below all the other layers
637 if( layer >= LAYER_BITMAP_START && layer < LAYER_BITMAP_END )
638 m_view->SetLayerOrder( layer, i - KIGFX::VIEW::TOP_LAYER_MODIFIER, false );
639 else
640 m_view->SetLayerOrder( layer, i, false );
641 }
642
643 m_view->SortOrderedLayers();
644}
645
646
648{
649 bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
651 m_gal->SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
652 return rv;
653}
654
655
657{
658 if( m_ratsnest )
659 m_view->Update( m_ratsnest.get() );
660}
661
662
664{
665 if( m_drawingSheet && m_view->IsLayerVisible( LAYER_DRAWINGSHEET ) )
666 return m_drawingSheet->ViewBBox();
667
668 return BOX2I();
669}
670
671
673{
674 // caching makes no sense for Cairo and other software renderers
676
677 for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
678 m_view->SetLayerTarget( i, target );
679
680 for( int i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( int ); ++i )
681 {
682 int layer = GAL_LAYER_ORDER[i];
683 wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
684
685 // Set layer display dependencies & targets
686 if( IsCopperLayer( layer ) )
687 {
688 m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
689 m_view->SetRequired( PAD_COPPER_LAYER_FOR( layer ), layer );
690 m_view->SetRequired( VIA_COPPER_LAYER_FOR( layer ), layer );
691 m_view->SetRequired( CLEARANCE_LAYER_FOR( layer ), layer );
692 m_view->SetRequired( POINT_LAYER_FOR( layer ), layer );
693
694 m_view->SetRequired( BITMAP_LAYER_FOR( layer ), layer );
695 m_view->SetLayerTarget( BITMAP_LAYER_FOR( layer ), KIGFX::TARGET_NONCACHED );
696 m_view->SetRequired( GetNetnameLayer( layer ), layer );
697 }
698 else if( IsNonCopperLayer( layer ) )
699 {
700 m_view->SetRequired( POINT_LAYER_FOR( layer ), layer );
701 m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
702 m_view->SetLayerTarget( BITMAP_LAYER_FOR( layer ), KIGFX::TARGET_NONCACHED );
703 m_view->SetRequired( BITMAP_LAYER_FOR( layer ), layer );
704 }
705 else if( IsNetnameLayer( layer ) )
706 {
707 m_view->SetLayerDisplayOnly( layer );
708 }
709 }
710
711 m_view->SetLayerTarget( LAYER_ANCHOR, KIGFX::TARGET_NONCACHED );
712 m_view->SetLayerDisplayOnly( LAYER_ANCHOR );
713
714 // Use TARGET_OVERLAY for LAYER_CONFLICTS_SHADOW, it is for items
715 // that may change while the view stays the same.
717
718 m_view->SetLayerDisplayOnly( LAYER_LOCKED_ITEM_SHADOW );
719 m_view->SetLayerDisplayOnly( LAYER_CONFLICTS_SHADOW );
720 m_view->SetLayerDisplayOnly( LAYER_BOARD_OUTLINE_AREA );
721
722 // Some more required layers settings
723 m_view->SetRequired( LAYER_PAD_NETNAMES, LAYER_PADS );
724
725 // Holes can be independent of their host objects (cf: printing drill marks)
726 m_view->SetRequired( LAYER_VIA_HOLES, LAYER_VIAS );
727 m_view->SetRequired( LAYER_VIA_HOLEWALLS, LAYER_VIAS );
728 m_view->SetRequired( LAYER_PAD_PLATEDHOLES, LAYER_PADS );
729 m_view->SetRequired( LAYER_PAD_HOLEWALLS, LAYER_PADS );
730 m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS );
731
732 // Via visibility
733 m_view->SetRequired( LAYER_VIA_MICROVIA, LAYER_VIAS );
734 m_view->SetRequired( LAYER_VIA_BLIND, LAYER_VIAS );
735 m_view->SetRequired( LAYER_VIA_BURIED, LAYER_VIAS );
736 m_view->SetRequired( LAYER_VIA_THROUGH, LAYER_VIAS );
737 m_view->SetRequired( LAYER_VIA_NETNAMES, LAYER_VIAS );
738
740 m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ;
742 m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
743 m_view->SetLayerTarget( LAYER_RATSNEST, KIGFX::TARGET_OVERLAY );
744 m_view->SetLayerDisplayOnly( LAYER_RATSNEST );
745
746 m_view->SetLayerTarget( LAYER_DRC_ERROR, KIGFX::TARGET_OVERLAY );
750 m_view->SetLayerDisplayOnly( LAYER_MARKER_SHADOWS );
752 m_view->SetLayerDisplayOnly( LAYER_DRC_SHAPES ); // markers can't be selected through shapes
753
755 m_view->SetLayerDisplayOnly( LAYER_DRAWINGSHEET ) ; // drawing sheet can't be selected
756 m_view->SetLayerDisplayOnly( LAYER_GRID ); // grid can't be selected
757
758 for( int i = LAYER_UI_START; i < LAYER_UI_END; ++i )
759 {
760 m_view->SetLayerTarget( i, KIGFX::TARGET_OVERLAY );
761 m_view->SetLayerDisplayOnly( i );
762 }
763}
764
765
767{
768 return static_cast<KIGFX::PCB_VIEW*>( m_view );
769}
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:323
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition board.h:353
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition board.cpp:1052
PCB_BOARD_OUTLINE * BoardOutline()
Definition board.h:372
void UpdateBoardOutline()
Definition board.cpp:3920
const FOOTPRINTS & Footprints() const
Definition board.h:364
const BOARD_ITEM_SET GetItemSet()
Definition board.cpp:3835
const TRACKS & Tracks() const
Definition board.h:362
const wxString & GetFileName() const
Definition board.h:360
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition board.cpp:992
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition board.h:571
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
Definition board.cpp:1159
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
unsigned int GetUnconnectedCount(bool aVisibileOnly) const
The base frame for deriving all KiCad main window classes.
The base class for create windows for drawing purpose.
static constexpr GAL_TYPE GAL_FALLBACK
std::unique_ptr< KIGFX::PAINTER > m_painter
Contains information about how to draw items using GAL.
KIGFX::GAL * m_gal
Interface for drawing objects on a 2D-surface.
EDA_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_OPENGL)
Create a drawing panel that is contained inside aParentWindow.
@ GAL_TYPE_OPENGL
OpenGL implementation.
KIGFX::VIEW * m_view
Stores view settings (scale, center, etc.) and items to be drawn.
KIGFX::WX_VIEW_CONTROLS * m_viewControls
Control for VIEW (moving, zooming, etc.)
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
GAL_TYPE m_backend
Currently used GAL.
EDA_DRAW_FRAME * GetParentEDAFrame() const
Returns parent EDA_DRAW_FRAME, if available or NULL otherwise.
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
Definition pcb_painter.h:82
void LoadColors(const COLOR_SETTINGS *aSettings) override
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Load settings related to display options (high-contrast mode, full or outline modes for vias/pads/tra...
void UpdateDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
Definition pcb_view.cpp:149
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void ClearHighContrastLayers()
Clear the list of active layers.
void SetActiveLayer(PCB_LAYER_ID aLayer)
void SetLayerIsHighContrast(int aLayerId, bool aEnabled=true)
Set the specified layer as high-contrast.
static constexpr int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition view.h:778
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
Definition view.h:775
An implementation of class VIEW_CONTROLS for wxWidgets library.
Definition pad.h:55
DISPLAY_OPTIONS m_Display
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
virtual PCB_LAYER_ID GetActiveLayer() const
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
void UpdateColors()
Update the color settings in the painter and GAL.
PCB_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_OPENGL)
BOX2I GetDefaultViewBBox() const override
Return the bounding box of the view that should be used if model is not valid.
virtual void SetTopLayer(int aLayer) override
SetTopLayer(), with some extra smarts for PCB.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Called when the window is shown for the first time.
std::unique_ptr< RATSNEST_VIEW_ITEM > m_ratsnest
Ratsnest view item.
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Sets (or updates) drawing-sheet used by the draw panel.
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void OnShow() override
Called when the window is shown for the first time.
void DisplayBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Add all items from the current board to the VIEW, so they can be displayed by GAL.
void SyncLayersVisibility(const BOARD *aBoard)
Update "visibility" property of each layer of a given BOARD.
void setDefaultLayerOrder()
< Reassign layer order to the initial settings.
virtual void SetHighContrastLayer(int aLayer) override
SetHighContrastLayer(), with some extra smarts for PCB.
std::unique_ptr< DS_PROXY_VIEW_ITEM > m_drawingSheet
Currently used drawing-sheet.
bool SwitchBackend(GAL_TYPE aGalType) override
Force refresh of the ratsnest visual representation.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
A progress reporter interface for use in multi-threaded environments.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:196
This file is part of the common library.
#define _(s)
@ NO_RECURSE
Definition eda_item.h:54
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition frame_type.h:33
@ FRAME_FOOTPRINT_PREVIEW
Definition frame_type.h:48
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer).
Definition layer_ids.h:200
@ LAYER_PAD_BK_NETNAMES
Definition layer_ids.h:201
@ LAYER_PAD_NETNAMES
Definition layer_ids.h:202
@ NETNAMES_LAYER_ID_START
Definition layer_ids.h:194
@ NETNAMES_LAYER_ID_END
Definition layer_ids.h:205
@ LAYER_VIA_NETNAMES
Definition layer_ids.h:203
#define BITMAP_LAYER_FOR(boardLayer)
Macros for getting the extra layers for a given board layer.
Definition layer_ids.h:369
#define NETNAMES_LAYER_INDEX(layer)
Macro for obtaining netname layer for a given PCB layer.
Definition layer_ids.h:209
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:782
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition layer_ids.h:805
#define POINT_LAYER_FOR(boardLayer)
Definition layer_ids.h:374
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
Definition layer_ids.h:712
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition layer_ids.h:856
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:679
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
@ LAYER_GRID
Definition layer_ids.h:254
@ LAYER_POINTS
PCB reference/manual snap points visibility.
Definition layer_ids.h:321
@ GAL_LAYER_ID_START
Definition layer_ids.h:229
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:307
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
Definition layer_ids.h:339
@ LAYER_VIA_HOLEWALLS
Definition layer_ids.h:298
@ LAYER_CLEARANCE_END
Definition layer_ids.h:348
@ LAYER_GRID_AXES
Definition layer_ids.h:255
@ LAYER_CONFLICTS_SHADOW
Shadow layer for items flagged conflicting.
Definition layer_ids.h:310
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition layer_ids.h:259
@ LAYER_ZONE_END
Definition layer_ids.h:336
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition layer_ids.h:239
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:278
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
Definition layer_ids.h:266
@ LAYER_BOARD_OUTLINE_AREA
PCB board outline.
Definition layer_ids.h:318
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
Definition layer_ids.h:304
@ LAYER_POINT_END
Definition layer_ids.h:356
@ LAYER_DRC_HIGHLIGHTED
Color for highlighted DRC markers.
Definition layer_ids.h:332
@ LAYER_DRC_SHAPES
Custom shapes for DRC markers.
Definition layer_ids.h:315
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition layer_ids.h:292
@ LAYER_DRC_WARNING
Layer for DRC markers with #SEVERITY_WARNING.
Definition layer_ids.h:301
@ LAYER_UI_START
Definition layer_ids.h:359
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition layer_ids.h:271
@ GAL_LAYER_ID_END
Definition layer_ids.h:362
@ LAYER_GP_OVERLAY
General purpose overlay.
Definition layer_ids.h:279
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
Definition layer_ids.h:343
@ LAYER_CURSOR
PCB cursor.
Definition layer_ids.h:282
@ LAYER_RATSNEST
Definition layer_ids.h:253
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
Definition layer_ids.h:347
@ LAYER_PAD_COPPER_END
Definition layer_ids.h:340
@ LAYER_ZONE_START
Virtual layers for stacking zones and tracks on a given copper layer.
Definition layer_ids.h:335
@ LAYER_FP_TEXT
Definition layer_ids.h:240
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition layer_ids.h:260
@ LAYER_UI_END
Definition layer_ids.h:360
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
Definition layer_ids.h:248
@ LAYER_VIA_BURIED
Draw blind vias.
Definition layer_ids.h:235
@ LAYER_VIA_COPPER_END
Definition layer_ids.h:344
@ LAYER_MARKER_SHADOWS
Shadows for DRC markers.
Definition layer_ids.h:305
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
Definition layer_ids.h:274
@ LAYER_VIA_BLIND
Draw micro vias.
Definition layer_ids.h:234
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
Definition layer_ids.h:263
@ LAYER_POINT_START
Virtual layers for points per board layer.
Definition layer_ids.h:355
@ LAYER_VIA_MICROVIA
Definition layer_ids.h:233
@ LAYER_SELECT_OVERLAY
Selected items overlay.
Definition layer_ids.h:280
@ LAYER_VIA_THROUGH
Draw buried vias.
Definition layer_ids.h:236
@ LAYER_BITMAP_END
Definition layer_ids.h:352
@ LAYER_BITMAP_START
Virtual layers for background images per board layer.
Definition layer_ids.h:351
@ LAYER_DRC_ERROR
Layer for DRC markers with #SEVERITY_ERROR.
Definition layer_ids.h:277
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition layer_ids.h:232
@ LAYER_PAD_HOLEWALLS
Definition layer_ids.h:297
#define CLEARANCE_LAYER_FOR(boardLayer)
Definition layer_ids.h:373
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition layer_ids.h:871
#define VIA_COPPER_LAYER_FOR(boardLayer)
Definition layer_ids.h:372
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ User_16
Definition layer_ids.h:139
@ In22_Cu
Definition layer_ids.h:87
@ In11_Cu
Definition layer_ids.h:76
@ User_29
Definition layer_ids.h:152
@ In29_Cu
Definition layer_ids.h:94
@ In30_Cu
Definition layer_ids.h:95
@ User_40
Definition layer_ids.h:163
@ User_15
Definition layer_ids.h:138
@ User_8
Definition layer_ids.h:131
@ F_CrtYd
Definition layer_ids.h:116
@ User_11
Definition layer_ids.h:134
@ User_25
Definition layer_ids.h:148
@ In17_Cu
Definition layer_ids.h:82
@ User_34
Definition layer_ids.h:157
@ User_45
Definition layer_ids.h:168
@ B_Adhes
Definition layer_ids.h:103
@ User_36
Definition layer_ids.h:159
@ Edge_Cuts
Definition layer_ids.h:112
@ Dwgs_User
Definition layer_ids.h:107
@ F_Paste
Definition layer_ids.h:104
@ In9_Cu
Definition layer_ids.h:74
@ Cmts_User
Definition layer_ids.h:108
@ User_6
Definition layer_ids.h:129
@ User_7
Definition layer_ids.h:130
@ In19_Cu
Definition layer_ids.h:84
@ User_19
Definition layer_ids.h:142
@ User_23
Definition layer_ids.h:146
@ In7_Cu
Definition layer_ids.h:72
@ In28_Cu
Definition layer_ids.h:93
@ In26_Cu
Definition layer_ids.h:91
@ F_Adhes
Definition layer_ids.h:102
@ User_41
Definition layer_ids.h:164
@ B_Mask
Definition layer_ids.h:98
@ B_Cu
Definition layer_ids.h:65
@ User_14
Definition layer_ids.h:137
@ User_39
Definition layer_ids.h:162
@ User_5
Definition layer_ids.h:128
@ User_20
Definition layer_ids.h:143
@ Eco1_User
Definition layer_ids.h:109
@ F_Mask
Definition layer_ids.h:97
@ In21_Cu
Definition layer_ids.h:86
@ User_42
Definition layer_ids.h:165
@ User_43
Definition layer_ids.h:166
@ In23_Cu
Definition layer_ids.h:88
@ B_Paste
Definition layer_ids.h:105
@ In15_Cu
Definition layer_ids.h:80
@ In2_Cu
Definition layer_ids.h:67
@ User_10
Definition layer_ids.h:133
@ User_9
Definition layer_ids.h:132
@ User_27
Definition layer_ids.h:150
@ User_28
Definition layer_ids.h:151
@ F_Fab
Definition layer_ids.h:119
@ In10_Cu
Definition layer_ids.h:75
@ Margin
Definition layer_ids.h:113
@ F_SilkS
Definition layer_ids.h:100
@ In4_Cu
Definition layer_ids.h:69
@ B_CrtYd
Definition layer_ids.h:115
@ Eco2_User
Definition layer_ids.h:110
@ In16_Cu
Definition layer_ids.h:81
@ In24_Cu
Definition layer_ids.h:89
@ In1_Cu
Definition layer_ids.h:66
@ User_35
Definition layer_ids.h:158
@ User_31
Definition layer_ids.h:154
@ User_3
Definition layer_ids.h:126
@ User_1
Definition layer_ids.h:124
@ User_12
Definition layer_ids.h:135
@ B_SilkS
Definition layer_ids.h:101
@ User_30
Definition layer_ids.h:153
@ User_37
Definition layer_ids.h:160
@ User_22
Definition layer_ids.h:145
@ User_38
Definition layer_ids.h:161
@ In13_Cu
Definition layer_ids.h:78
@ User_4
Definition layer_ids.h:127
@ In8_Cu
Definition layer_ids.h:73
@ User_21
Definition layer_ids.h:144
@ In14_Cu
Definition layer_ids.h:79
@ User_24
Definition layer_ids.h:147
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ User_13
Definition layer_ids.h:136
@ User_2
Definition layer_ids.h:125
@ In12_Cu
Definition layer_ids.h:77
@ User_17
Definition layer_ids.h:140
@ In27_Cu
Definition layer_ids.h:92
@ In6_Cu
Definition layer_ids.h:71
@ In5_Cu
Definition layer_ids.h:70
@ User_33
Definition layer_ids.h:156
@ User_26
Definition layer_ids.h:149
@ In3_Cu
Definition layer_ids.h:68
@ User_32
Definition layer_ids.h:155
@ In20_Cu
Definition layer_ids.h:85
@ User_18
Definition layer_ids.h:141
@ User_44
Definition layer_ids.h:167
@ F_Cu
Definition layer_ids.h:64
@ In18_Cu
Definition layer_ids.h:83
@ In25_Cu
Definition layer_ids.h:90
@ B_Fab
Definition layer_ids.h:118
#define ZONE_LAYER_FOR(boardLayer)
Definition layer_ids.h:370
#define PAD_COPPER_LAYER_FOR(boardLayer)
Definition layer_ids.h:371
This file contains miscellaneous commonly used macros and functions.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:38
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:37
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Definition definitions.h:39
const int GAL_LAYER_ORDER[]
see class PGM_BASE
Class that computes missing connections on a PCB.
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:94
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:83
WX_VIEW_CONTROLS class definition.
#define ZOOM_MAX_LIMIT_PCBNEW
#define ZOOM_MIN_LIMIT_PCBNEW