57 std::unique_ptr<KIGFX::GAL_DISPLAY_OPTIONS> aGalOptions ) :
58 EDA_DRAW_PANEL_GAL( aParent, aId, wxDefaultPosition, wxDefaultSize, *aGalOptions, aBackend ),
68 m_view->SetLayerTarget( i, target );
80 m_view->SetMirror(
false,
false );
96 m_hoverBox = std::make_unique<HIGHLIGHT_BOX_ITEM>();
100 m_gal->SetCursorEnabled(
false );
104 SetMinSize( wxSize( -1, 100 ) );
114 SetEvtHandlerEnabled(
true );
159 if(
m_gal->GetWorldUnitLength() == aWorldUnitLength )
162 m_gal->SetWorldUnitLength( aWorldUnitLength );
163 m_gal->ComputeWorldScreenMatrix();
181 std::shared_ptr<const void> aOwner )
220 const std::optional<KIID> focusKiid =
245 if( !eda ||
getItemId( *eda ) != *focusKiid )
248 const BOX2I bb = item->ViewBBox();
272 const std::size_t idx =
static_cast<std::size_t
>( aCategory );
283 if( cat != aCategory )
286 m_view->SetVisible( item, aVisible );
303 const std::size_t idx =
static_cast<std::size_t
>( cat );
313 const std::size_t idx =
static_cast<std::size_t
>( aCategory );
344 std::set<KIID> hiddenItems;
349 hiddenItems.insert(
path.back() );
358 const bool hidden = eda && hiddenItems.count(
getItemId( *eda ) ) > 0;
381 m_view->SetLayerVisible( aLayer, aVisible );
426 BOX2I ib = item->ViewBBox();
450 const wxSize client = GetClientSize();
452 if( client.x <= 0 || client.y <= 0 )
477 if( !bb || bb->GetWidth() <= 0 || bb->GetHeight() <= 0 )
481 focus.
Inflate( std::max( bb->GetWidth(), bb->GetHeight() ) );
535 if( !aBox || !aBox->shown || aBox->bbox.GetWidth() <= 0 || aBox->bbox.GetHeight() <= 0 )
541 m_overlay->Rectangle( aBox->bbox.GetOrigin(), aBox->bbox.GetEnd() );
573 for(
auto sIt = list.rbegin(); sIt != list.rend(); ++sIt )
590 std::optional<KIID_PATH> picked;
593 picked = shape->changeId;
663 if(
m_leftPanning && aEvent.Dragging() && aEvent.LeftIsDown() )
665 VECTOR2D pos( aEvent.GetX(), aEvent.GetY() );
674 std::optional<KIID_PATH> hovered;
688 if( shape && hovered )
717 switch( aEvent.GetKeyCode() )
720 if(
m_scene.documentBBox.GetWidth() ||
m_scene.documentBBox.GetHeight() )
750 default: aEvent.Skip();
return;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr ecoord_type GetArea() const
Return the area of the rectangle.
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
std::unique_ptr< KIGFX::PAINTER > m_painter
Contains information about how to draw items using GAL.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
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.
static bool IsAccelerated(GAL_TYPE aCanvasType)
True for a canvas drawn on the GPU, which keeps cached layers between frames.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
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.)
void StartDrawing()
Begin drawing if it was stopped previously.
GAL_TYPE m_backend
Currently used GAL.
void ZoomToFit(const BOX2I &aBox, std::optional< double > aMarginScale=std::nullopt)
Scale and centre the view on aBox, and fit it again whenever the canvas changes size until something ...
A base class for most all the KiCad significant classes used in schematics and boards.
A color representation with 4 components: red, green, blue, alpha.
An abstract base class for deriving all objects that can be added to a VIEW.
virtual const BOX2I ViewBBox() const =0
Return the bounding box of the item covering all its layers.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
An implementation of class VIEW_CONTROLS for wxWidgets library.
LSET is a set of PCB_LAYER_IDs.
@ LAYER_GP_OVERLAY
General purpose overlay.
PCB_LAYER_ID
A quick note on layer IDs:
KIGFX::COLOR4D ThemeColorFor(const DIFF_COLOR_THEME &aTheme, CATEGORY aCategory)
Map a CATEGORY to its color in a DIFF_COLOR_THEME.
std::optional< BOX2I > HighlightedBBox(const DIFF_SCENE &aScene, const KIID_PATH &aChangeId, const std::array< bool, CATEGORY_COUNT > &aCategoryVisible)
Union bbox of every visible SCENE_SHAPE whose changeId matches aChangeId.
void RenderSceneToOverlay(KIGFX::VIEW_OVERLAY &aOverlay, const DIFF_SCENE &aScene, const std::array< bool, CATEGORY_COUNT > &aVisible, const std::optional< KIID_PATH > &aHighlight, const std::set< KIID_PATH > &aHidden)
Push a DIFF_SCENE's shapes onto a VIEW_OVERLAY as filled, semi-transparent rectangles,...
CATEGORY
Visual category each ITEM_CHANGE belongs to in the scene.
const std::vector< SCENE_SHAPE > & ShapesFor(const DIFF_SCENE &aScene, CATEGORY aCategory)
Read-only access to a DIFF_SCENE's shape list for a given category.
constexpr std::array< CATEGORY, 4 > PAINT_ORDER
Paint order.
DOCUMENT_GEOMETRY FilterGeometryByVisibleLayers(const DOCUMENT_GEOMETRY &aGeometry, const LSET &aVisibleLayers)
Copy geometry primitives whose layer set intersects aVisibleLayers.
The Cairo implementation of the graphics abstraction layer.
@ REPAINT
Item needs to be redrawn.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
@ TARGET_CACHED
Main rendering target (cached)
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Diff colors with defaults for light backgrounds.
Shared rendering model consumed by both the GAL renderer (interactive widget) and the plotter rendere...
KIID_PATH changeId
Stable identifier of the ITEM_CHANGE that produced this shape.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
WX_VIEW_CONTROLS class definition.
#define ZOOM_MIN_LIMIT_DIFF
#define ZOOM_MAX_LIMIT_DIFF