KiCad PCB EDA Suite
KIGFX::VIEW Class Reference

Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the GAL. More...

#include <view.h>

Inheritance diagram for KIGFX::VIEW:
KIGFX::PCB_VIEW KIGFX::SCH_VIEW

Classes

struct  CLEAR_LAYER_CACHE_VISITOR
 
struct  DRAW_ITEM_VISITOR
 
struct  RECACHE_ITEM_VISITOR
 
struct  UPDATE_COLOR_VISITOR
 
struct  UPDATE_DEPTH_VISITOR
 
struct  VIEW_LAYER
 

Public Types

typedef std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
 

Public Member Functions

 VIEW (bool aIsDynamic=true)
 
virtual ~VIEW ()
 
virtual void Add (VIEW_ITEM *aItem, int aDrawPriority=-1)
 Add a VIEW_ITEM to the view. More...
 
virtual void Remove (VIEW_ITEM *aItem)
 Remove a VIEW_ITEM from the view. More...
 
virtual int Query (const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
 Find all visible items that touch or are within the rectangle aRect. More...
 
void SetVisible (VIEW_ITEM *aItem, bool aIsVisible=true)
 Set the item visibility. More...
 
void Hide (VIEW_ITEM *aItem, bool aHide=true)
 Temporarily hide the item in the view (e.g. More...
 
bool IsVisible (const VIEW_ITEM *aItem) const
 Return information if the item is visible (or not). More...
 
bool HasItem (const VIEW_ITEM *aItem) const
 Indicates whether or not the given item has been added to the view. More...
 
virtual void Update (const VIEW_ITEM *aItem, int aUpdateFlags) const
 For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has changed. More...
 
virtual void Update (const VIEW_ITEM *aItem) const
 
void SetRequired (int aLayerId, int aRequiredId, bool aRequired=true)
 Mark the aRequiredId layer as required for the aLayerId layer. More...
 
void CopySettings (const VIEW *aOtherView)
 Copy layers and visibility settings from another view. More...
 
void SetGAL (GAL *aGal)
 Assign a rendering device for the VIEW. More...
 
GALGetGAL () const
 Return the #GAL this view is using to draw graphical primitives. More...
 
void SetPainter (PAINTER *aPainter)
 Set the painter object used by the view for drawing #VIEW_ITEMS. More...
 
PAINTERGetPainter () const
 Return the painter object used by the view for drawing #VIEW_ITEMS. More...
 
void SetViewport (const BOX2D &aViewport)
 Set the visible area of the VIEW. More...
 
BOX2D GetViewport () const
 Return the current viewport visible area rectangle. More...
 
void SetMirror (bool aMirrorX, bool aMirrorY)
 Control the mirroring of the VIEW. More...
 
bool IsMirroredX () const
 Return true if view is flipped across the X axis. More...
 
bool IsMirroredY () const
 Return true if view is flipped across the Y axis. More...
 
virtual void SetScale (double aScale, VECTOR2D aAnchor={ 0, 0 })
 Set the scaling factor, zooming around a given anchor point. More...
 
double GetScale () const
 
void SetBoundary (const BOX2D &aBoundary)
 Set limits for view area. More...
 
void SetBoundary (const BOX2I &aBoundary)
 Set limits for view area. More...
 
const BOX2DGetBoundary () const
 
void SetScaleLimits (double aMaximum, double aMinimum)
 Set minimum and maximum values for scale. More...
 
void SetCenter (const VECTOR2D &aCenter)
 Set the center point of the VIEW (i.e. More...
 
void SetCenter (const VECTOR2D &aCenter, const std::vector< BOX2D > &obscuringScreenRects)
 Set the center point of the VIEW, attempting to avoid obscuringScreenRects (for instance, the screen rect of a modeless dialog in front of the VIEW). More...
 
const VECTOR2DGetCenter () const
 Return the center point of this VIEW (in world space coordinates). More...
 
VECTOR2D ToWorld (const VECTOR2D &aCoord, bool aAbsolute=true) const
 Converts a screen space point/vector to a point/vector in world space coordinates. More...
 
double ToWorld (double aSize) const
 Converts a screen space one dimensional size to a one dimensional size in world space coordinates. More...
 
VECTOR2D ToScreen (const VECTOR2D &aCoord, bool aAbsolute=true) const
 Convert a world space point/vector to a point/vector in screen space coordinates. More...
 
double ToScreen (double aSize) const
 Convert a world space one dimensional size to a one dimensional size in screen space. More...
 
const VECTOR2IGetScreenPixelSize () const
 Return the size of the our rendering area in pixels. More...
 
void Clear ()
 Remove all items from the view. More...
 
void SetLayerVisible (int aLayer, bool aVisible=true)
 Control the visibility of a particular layer. More...
 
bool IsLayerVisible (int aLayer) const
 Return information about visibility of a particular layer. More...
 
void SetLayerDiff (int aLayer, bool aDiff=true)
 Set the whether the layer should drawn differentially. More...
 
void SetLayerHasNegatives (int aLayer, bool aNegatives=true)
 Set the status of negatives presense in a particular layer. More...
 
void SetLayerDisplayOnly (int aLayer, bool aDisplayOnly=true)
 Set a layer display-only (ie: to be rendered but not returned by hit test queries). More...
 
void SetLayerTarget (int aLayer, RENDER_TARGET aTarget)
 Change the rendering target for a particular layer. More...
 
void SetLayerOrder (int aLayer, int aRenderingOrder)
 Set rendering order of a particular layer. More...
 
int GetLayerOrder (int aLayer) const
 Return rendering order of a particular layer. More...
 
void SortLayers (int aLayers[], int &aCount) const
 Change the order of given layer ids, so after sorting the order corresponds to layers rendering order (descending, ie. More...
 
void ReorderLayerData (std::unordered_map< int, int > aReorderMap)
 Remap the data between layer ids without invalidating that data. More...
 
void UpdateLayerColor (int aLayer)
 Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed. More...
 
void UpdateAllLayersColor ()
 Apply the new coloring scheme to all layers. More...
 
virtual void SetTopLayer (int aLayer, bool aEnabled=true)
 Set given layer to be displayed on the top or sets back the default order of layers. More...
 
virtual void EnableTopLayer (bool aEnable)
 Enable or disable display of the top layer. More...
 
virtual int GetTopLayer () const
 
void ClearTopLayers ()
 Remove all layers from the on-the-top set (they are no longer displayed over the rest of layers). More...
 
void UpdateAllLayersOrder ()
 Do everything that is needed to apply the rendering order of layers. More...
 
void ClearTargets ()
 Clear targets that are marked as dirty. More...
 
virtual void Redraw ()
 Immediately redraws the whole view. More...
 
void RecacheAllItems ()
 Rebuild GAL display lists. More...
 
bool IsDynamic () const
 Tell if the VIEW is dynamic (ie. More...
 
bool IsDirty () const
 Return true if any of the VIEW layers needs to be refreshened. More...
 
bool IsTargetDirty (int aTarget) const
 Return true if any of layers belonging to the target or the target itself should be redrawn. More...
 
void MarkTargetDirty (int aTarget)
 Set or clear target 'dirty' flag. More...
 
bool IsCached (int aLayer) const
 Return true if the layer is cached. More...
 
void MarkDirty ()
 Force redraw of view on the next rendering. More...
 
void MarkClean ()
 Force redraw of view on the next rendering. More...
 
void UpdateItems ()
 Iterate through the list of items that asked for updating and updates them. More...
 
void UpdateAllItems (int aUpdateFlags)
 Update all items in the view according to the given flags. More...
 
void UpdateAllItemsConditionally (int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
 Update items in the view according to the given flags and condition. More...
 
void UpdateAllItemsConditionally (std::function< int(VIEW_ITEM *)> aItemFlagsProvider)
 Update items in the view according to the flags returned by the callback. More...
 
bool IsUsingDrawPriority () const
 
void UseDrawPriority (bool aFlag)
 
void ReverseDrawOrder (bool aFlag)
 Only takes effect if UseDrawPriority is true. More...
 
std::shared_ptr< VIEW_OVERLAYMakeOverlay ()
 
void InitPreview ()
 
void ClearPreview ()
 
void AddToPreview (EDA_ITEM *aItem, bool aTakeOwnership=true)
 
void ShowPreview (bool aShow=true)
 
std::unique_ptr< VIEWDataReference () const
 Return a new VIEW object that shares the same set of VIEW_ITEMs and LAYERs. More...
 

Static Public Member Functions

static void OnDestroy (VIEW_ITEM *aItem)
 Nasty hack, invoked by the destructor of VIEW_ITEM to auto-remove the item from the owning VIEW if there is any. More...
 

Static Public Attributes

static constexpr int VIEW_MAX_LAYERS = 512
 Rendering order modifier for layers that are marked as top layers. More...
 
static constexpr int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS
 

Protected Member Functions

 VIEW (const VIEW &)=delete
 
void redrawRect (const BOX2I &aRect)
 
void markTargetClean (int aTarget)
 
void draw (VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
 Draw an item, but on a specified layers. More...
 
void draw (VIEW_ITEM *aItem, bool aImmediate=false)
 Draw an item on all layers that the item uses. More...
 
void draw (VIEW_GROUP *aGroup, bool aImmediate=false)
 Draw a group of items on all layers that those items use. More...
 
void sortLayers ()
 Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL) More...
 
void clearGroupCache ()
 
void invalidateItem (VIEW_ITEM *aItem, int aUpdateFlags)
 Manage dirty flags & redraw queuing when updating an item. More...
 
void updateItemColor (VIEW_ITEM *aItem, int aLayer)
 Update all information needed to draw an item. More...
 
void updateItemGeometry (VIEW_ITEM *aItem, int aLayer)
 Update bounding box of an item. More...
 
void updateBbox (VIEW_ITEM *aItem)
 Update set of layers that an item occupies. More...
 
void updateLayers (VIEW_ITEM *aItem)
 Determine rendering order of layers. Used in display order sorting function. More...
 
bool areRequiredLayersEnabled (int aLayerId) const
 

Static Protected Member Functions

static bool compareRenderingOrder (VIEW_LAYER *aI, VIEW_LAYER *aJ)
 Check if every layer required by the aLayerId layer is enabled. More...
 

Protected Attributes

std::unique_ptr< KIGFX::VIEW_GROUPm_preview
 
std::vector< EDA_ITEM * > m_ownedItems
 Whether to use rendering order modifier or not. More...
 
bool m_enableOrderModifier
 The set of possible displayed layers and its properties. More...
 
std::vector< VIEW_LAYERm_layers
 Sorted list of pointers to members of m_layers. More...
 
std::vector< VIEW_LAYER * > m_orderedLayers
 Flat list of all items. More...
 
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
 The set of layers that are displayed on the top. More...
 
std::set< unsigned int > m_topLayers
 Center point of the VIEW (the point at which we are looking at). More...
 
VECTOR2D m_center
 
double m_scale
 
BOX2D m_boundary
 
double m_minScale
 
double m_maxScale
 
bool m_mirrorX
 
bool m_mirrorY
 PAINTER contains information how do draw items. More...
 
PAINTERm_painter
 Interface to #PAINTER that is used to draw items. More...
 
GALm_gal
 Dynamic VIEW (eg. More...
 
bool m_dynamic
 Flag to mark targets as dirty so they have to be redrawn on the next refresh event. More...
 
bool m_dirtyTargets [TARGETS_NUMBER]
 Flag to respect draw priority when drawing items. More...
 
bool m_useDrawPriority
 The next sequential drawing priority. More...
 
int m_nextDrawPriority
 Flag to reverse the draw order when using draw priority. More...
 
bool m_reverseDrawOrder
 

Friends

class VIEW_ITEM
 

Detailed Description

Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the GAL.

VIEWs can exist in two flavors:

  • dynamic - where items can be added, removed or changed anytime, intended for the main editing panel. Each VIEW_ITEM can be added to a single dynamic view.
  • static - where items are added once at the startup and are not linked with the VIEW. Foreseen for preview windows and printing.

Items in a view are grouped in layers (not to be confused with Kicad's PCB layers). Each layer is identified by an integer number. Visibility and rendering order can be set individually for each of the layers. Future versions of the VIEW will also allows one to assign different layers to different rendering targets, which will be composited at the final stage by the GAL. The VIEW class also provides fast methods for finding all visible objects that are within a given rectangular area, useful for object selection/hit testing.

Definition at line 68 of file view.h.

Member Typedef Documentation

◆ LAYER_ITEM_PAIR

typedef std::pair<VIEW_ITEM*, int> KIGFX::VIEW::LAYER_ITEM_PAIR

Definition at line 73 of file view.h.

Constructor & Destructor Documentation

◆ VIEW() [1/2]

KIGFX::VIEW::VIEW ( bool  aIsDynamic = true)
Parameters
aIsDynamicdecides whether we are creating a static or a dynamic VIEW.

Definition at line 256 of file view.cpp.

256 :
257 m_enableOrderModifier( true ),
258 m_scale( 4.0 ),
259 m_minScale( 0.2 ), m_maxScale( 50000.0 ),
260 m_mirrorX( false ), m_mirrorY( false ),
261 m_painter( nullptr ),
262 m_gal( nullptr ),
263 m_dynamic( aIsDynamic ),
264 m_useDrawPriority( false ),
266 m_reverseDrawOrder( false )
267{
268 // Set m_boundary to define the max area size. The default area size
269 // is defined here as the max value of a int.
270 // this is a default value acceptable for Pcbnew and Gerbview, but too large for Eeschema.
271 // So in eeschema a call to SetBoundary() with a smaller value will be needed.
272 typedef std::numeric_limits<int> coord_limits;
273 double pos = coord_limits::lowest() / 2 + coord_limits::epsilon();
274 double size = coord_limits::max() - coord_limits::epsilon();
275 m_boundary.SetOrigin( pos, pos );
276 m_boundary.SetSize( size, size );
277
278 m_allItems.reset( new std::vector<VIEW_ITEM*> );
279 m_allItems->reserve( 32768 );
280
281 // Redraw everything at the beginning
282 MarkDirty();
283
284 m_layers.reserve( VIEW_MAX_LAYERS );
285
286 // View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
287 // pad may be shown on pad, pad hole and solder paste layers). There are usual copper layers
288 // (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
289 // silkscreen, pads, vias, etc.
290 for( int ii = 0; ii < VIEW_MAX_LAYERS; ++ii )
291 {
292 m_layers.emplace_back();
293 m_layers[ii].items = std::make_shared<VIEW_RTREE>();
294 m_layers[ii].id = ii;
295 m_layers[ii].renderingOrder = ii;
296 m_layers[ii].visible = true;
297 m_layers[ii].displayOnly = false;
298 m_layers[ii].diffLayer = false;
299 m_layers[ii].hasNegatives = false;
300 m_layers[ii].target = TARGET_CACHED;
301 }
302
303 sortLayers();
304
305 m_preview.reset( new KIGFX::VIEW_GROUP() );
306 Add( m_preview.get() );
307}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetSize(const Vec &size)
Definition: box2.h:213
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:47
void sortLayers()
Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL)
Definition: view.cpp:1244
bool m_dynamic
Flag to mark targets as dirty so they have to be redrawn on the next refresh event.
Definition: view.h:871
double m_maxScale
Definition: view.h:858
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:841
bool m_reverseDrawOrder
Definition: view.h:883
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
bool m_mirrorX
Definition: view.h:860
bool m_mirrorY
PAINTER contains information how do draw items.
Definition: view.h:861
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:847
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:864
bool m_enableOrderModifier
The set of possible displayed layers and its properties.
Definition: view.h:838
static constexpr int VIEW_MAX_LAYERS
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:727
double m_minScale
Definition: view.h:857
double m_scale
Definition: view.h:855
int m_nextDrawPriority
Flag to reverse the draw order when using draw priority.
Definition: view.h:880
bool m_useDrawPriority
The next sequential drawing priority.
Definition: view.h:877
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: view.h:834
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:867
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
BOX2D m_boundary
Definition: view.h:856
@ TARGET_CACHED
Main rendering target (cached)
Definition: definitions.h:48

References Add(), m_allItems, m_boundary, m_layers, m_preview, MarkDirty(), BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetSize(), sortLayers(), KIGFX::TARGET_CACHED, and VIEW_MAX_LAYERS.

◆ ~VIEW()

KIGFX::VIEW::~VIEW ( )
virtual

Definition at line 310 of file view.cpp.

311{
312 Remove( m_preview.get() );
313}
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349

References m_preview, and Remove().

◆ VIEW() [2/2]

KIGFX::VIEW::VIEW ( const VIEW )
protecteddelete

Member Function Documentation

◆ Add()

void KIGFX::VIEW::Add ( VIEW_ITEM aItem,
int  aDrawPriority = -1 
)
virtual

Add a VIEW_ITEM to the view.

Set aDrawPriority to -1 to assign sequential priorities.

Parameters
aItemitem to be added. No ownership is given
aDrawPrioritypriority to draw this item on its layer, lowest first.

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 316 of file view.cpp.

317{
318 int layers[VIEW_MAX_LAYERS], layers_count;
319
320 if( aDrawPriority < 0 )
321 aDrawPriority = m_nextDrawPriority++;
322
323 if( !aItem->m_viewPrivData )
324 aItem->m_viewPrivData = new VIEW_ITEM_DATA;
325
326 aItem->m_viewPrivData->m_view = this;
327 aItem->m_viewPrivData->m_drawPriority = aDrawPriority;
328
329 aItem->ViewGetLayers( layers, layers_count );
330 aItem->viewPrivData()->saveLayers( layers, layers_count );
331
332 m_allItems->push_back( aItem );
333
334 for( int i = 0; i < layers_count; ++i )
335 {
336 wxCHECK2_MSG( layers[i] >= 0 && static_cast<unsigned>( layers[i] ) < m_layers.size(),
337 continue, wxS( "Invalid layer" ) );
338
339 VIEW_LAYER& l = m_layers[layers[i]];
340 l.items->Insert( aItem );
341 MarkTargetDirty( l.target );
342 }
343
344 SetVisible( aItem, true );
345 Update( aItem, KIGFX::INITIAL_ADD );
346}
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1591
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:617
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1529
@ INITIAL_ADD
Item is being added to the view.
Definition: view_item.h:51

References KIGFX::INITIAL_ADD, KIGFX::VIEW::VIEW_LAYER::items, m_allItems, KIGFX::VIEW_ITEM_DATA::m_drawPriority, m_layers, m_nextDrawPriority, KIGFX::VIEW_ITEM_DATA::m_view, KIGFX::VIEW_ITEM::m_viewPrivData, MarkTargetDirty(), KIGFX::VIEW_ITEM_DATA::saveLayers(), SetVisible(), KIGFX::VIEW::VIEW_LAYER::target, Update(), VIEW_MAX_LAYERS, KIGFX::VIEW_ITEM::ViewGetLayers(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by KIGFX::PCB_VIEW::Add(), SCH_BASE_FRAME::AddToScreen(), PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), EDA_DRAW_PANEL_GAL::DebugOverlay(), PCB_DRAW_PANEL_GAL::DisplayBoard(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), KIGFX::SCH_VIEW::DisplaySheet(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), KIGFX::SCH_VIEW::DisplaySymbol(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawShape(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EE_GRID_HELPER::EE_GRID_HELPER(), InitPreview(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), MakeOverlay(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PCB_GRID_HELPER::PCB_GRID_HELPER(), DRAWING_TOOL::PlaceImportedGraphics(), DIALOG_PAD_PROPERTIES::prepareCanvas(), BOARD_COMMIT::Push(), GERBVIEW_FRAME::Read_EXCELLON_File(), GERBVIEW_FRAME::Read_GERBER_File(), DIALOG_PAD_PROPERTIES::redraw(), EE_SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), BOARD_EDITOR_CONTROL::Reset(), PCB_CONTROL::Reset(), BOARD_COMMIT::Revert(), GERBVIEW_SELECTION_TOOL::select(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_DRAW_PANEL_GAL::SetDrawingSheet(), PCB_DRAW_PANEL_GAL::SetDrawingSheet(), PNS_PCBNEW_DEBUG_DECORATOR::SetView(), PNS_KICAD_IFACE::SetView(), GERBVIEW_DRAW_PANEL_GAL::SwitchBackend(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_POLYGONS::SyncDrawItems(), DS_DATA_ITEM_TEXT::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_ERC::testErc(), EE_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), SYMBOL_VIEWER_FRAME::updatePreviewSymbol(), VIEW(), and ZONE_CREATE_HELPER::ZONE_CREATE_HELPER().

◆ AddToPreview()

void KIGFX::VIEW::AddToPreview ( EDA_ITEM aItem,
bool  aTakeOwnership = true 
)

Definition at line 1635 of file view.cpp.

1636{
1637 Hide( aItem, false );
1638 m_preview->Add( aItem );
1639
1640 if( aTakeOwnership )
1641 m_ownedItems.push_back( aItem );
1642
1643 SetVisible( m_preview.get(), true );
1644 Hide( m_preview.get(), false );
1645 Update( m_preview.get() );
1646}
std::vector< EDA_ITEM * > m_ownedItems
Whether to use rendering order modifier or not.
Definition: view.h:835
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1550

References Hide(), m_ownedItems, m_preview, SetVisible(), and Update().

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ areRequiredLayersEnabled()

bool KIGFX::VIEW::areRequiredLayersEnabled ( int  aLayerId) const
protected

Definition at line 1367 of file view.cpp.

1368{
1369 wxCHECK( (unsigned) aLayerId < m_layers.size(), false );
1370
1371 std::set<int>::const_iterator it, it_end;
1372
1373 for( int layer : m_layers.at( aLayerId ).requiredLayers )
1374 {
1375 // That is enough if just one layer is not enabled
1376 if( !m_layers.at( layer ).visible || !areRequiredLayersEnabled( layer ) )
1377 return false;
1378 }
1379
1380 return true;
1381}
bool areRequiredLayersEnabled(int aLayerId) const
Definition: view.cpp:1367

References areRequiredLayersEnabled(), and m_layers.

Referenced by areRequiredLayersEnabled(), and redrawRect().

◆ Clear()

◆ clearGroupCache()

void KIGFX::VIEW::clearGroupCache ( )
protected

Definition at line 1190 of file view.cpp.

1191{
1192 BOX2I r;
1193
1194 r.SetMaximum();
1195 CLEAR_LAYER_CACHE_VISITOR visitor( this );
1196
1197 for( VIEW_LAYER& layer : m_layers )
1198 layer.items->Query( r, visitor );
1199}

References m_layers, and BOX2< Vec >::SetMaximum().

Referenced by SetGAL().

◆ ClearPreview()

◆ ClearTargets()

void KIGFX::VIEW::ClearTargets ( )

Clear targets that are marked as dirty.

Definition at line 1114 of file view.cpp.

1115{
1117 {
1118 // TARGET_CACHED and TARGET_NONCACHED have to be redrawn together, as they contain
1119 // layers that rely on each other (eg. netnames are noncached, but tracks - are cached)
1122
1123 MarkDirty();
1124 }
1125
1127 {
1129 }
1130}
virtual void ClearTarget(RENDER_TARGET aTarget)
Clear the target for rendering.
bool IsTargetDirty(int aTarget) const
Return true if any of layers belonging to the target or the target itself should be redrawn.
Definition: view.h:606
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50

References KIGFX::GAL::ClearTarget(), IsTargetDirty(), m_gal, MarkDirty(), KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, and KIGFX::TARGET_OVERLAY.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ ClearTopLayers()

void KIGFX::VIEW::ClearTopLayers ( )

Remove all layers from the on-the-top set (they are no longer displayed over the rest of layers).

Definition at line 877 of file view.cpp.

878{
879 std::set<unsigned int>::iterator it;
880
882 {
883 // Restore the previous rendering order for layers that were marked as top
884 for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
885 m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
886 }
887
888 m_topLayers.clear();
889}
static constexpr int TOP_LAYER_MODIFIER
Definition: view.h:730
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
Definition: view.h:850

References m_enableOrderModifier, m_layers, m_topLayers, and TOP_LAYER_MODIFIER.

Referenced by EDA_DRAW_PANEL_GAL::SetTopLayer(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PL_DRAW_PANEL_GAL::SetTopLayer(), and PCB_DRAW_PANEL_GAL::SetTopLayer().

◆ compareRenderingOrder()

static bool KIGFX::VIEW::compareRenderingOrder ( VIEW_LAYER aI,
VIEW_LAYER aJ 
)
inlinestaticprotected

Check if every layer required by the aLayerId layer is enabled.

Definition at line 819 of file view.h.

References KIGFX::VIEW::VIEW_LAYER::renderingOrder.

Referenced by sortLayers().

◆ CopySettings()

void KIGFX::VIEW::CopySettings ( const VIEW aOtherView)

Copy layers and visibility settings from another view.

Parameters
aOtherViewview from which settings will be copied.

Definition at line 486 of file view.cpp.

487{
488 wxASSERT_MSG( false, wxT( "This is not implemented" ) );
489}

◆ DataReference()

std::unique_ptr< VIEW > KIGFX::VIEW::DataReference ( ) const

Return a new VIEW object that shares the same set of VIEW_ITEMs and LAYERs.

GAL, PAINTER and other properties are left uninitialized. Maximum number of layers that may be shown

Definition at line 1519 of file view.cpp.

1520{
1521 std::unique_ptr<VIEW> ret = std::make_unique<VIEW>();
1522 ret->m_allItems = m_allItems;
1523 ret->m_layers = m_layers;
1524 ret->sortLayers();
1525 return ret;
1526}

References m_allItems, and m_layers.

Referenced by BOARD_PRINTOUT::DrawPage().

◆ draw() [1/3]

void KIGFX::VIEW::draw ( VIEW_GROUP aGroup,
bool  aImmediate = false 
)
protected

Draw a group of items on all layers that those items use.

Parameters
aGroupis the group to be drawn.
aImmediatedictates the way of drawing - it allows one to force immediate drawing mode for cached items. Sort m_orderedLayers when layer rendering order has changed

Definition at line 1058 of file view.cpp.

1059{
1060 for( unsigned int i = 0; i < aGroup->GetSize(); i++)
1061 draw( aGroup->GetItem(i), aImmediate );
1062}
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Draw an item, but on a specified layers.
Definition: view.cpp:1015

References draw(), KIGFX::VIEW_GROUP::GetItem(), and KIGFX::VIEW_GROUP::GetSize().

◆ draw() [2/3]

void KIGFX::VIEW::draw ( VIEW_ITEM aItem,
bool  aImmediate = false 
)
protected

Draw an item on all layers that the item uses.

Parameters
aItemis the item to be drawn.
aImmediatedictates the way of drawing - it allows one to force immediate drawing mode for cached items.

Definition at line 1041 of file view.cpp.

1042{
1043 int layers[VIEW_MAX_LAYERS], layers_count;
1044
1045 aItem->ViewGetLayers( layers, layers_count );
1046
1047 // Sorting is needed for drawing order dependent GALs (like Cairo)
1048 SortLayers( layers, layers_count );
1049
1050 for( int i = 0; i < layers_count; ++i )
1051 {
1052 m_gal->SetLayerDepth( m_layers.at( layers[i] ).renderingOrder );
1053 draw( aItem, layers[i], aImmediate );
1054 }
1055}
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
void SortLayers(int aLayers[], int &aCount) const
Change the order of given layer ids, so after sorting the order corresponds to layers rendering order...
Definition: view.cpp:648

References draw(), m_gal, m_layers, KIGFX::GAL::SetLayerDepth(), SortLayers(), VIEW_MAX_LAYERS, and KIGFX::VIEW_ITEM::ViewGetLayers().

◆ draw() [3/3]

void KIGFX::VIEW::draw ( VIEW_ITEM aItem,
int  aLayer,
bool  aImmediate = false 
)
protected

Draw an item, but on a specified layers.

It has to be marked that some of drawing settings are based on the layer on which an item is drawn.

Parameters
aItemis the item to be drawn.
aLayeris the layer which should be drawn.
aImmediatedictates the way of drawing - it allows one to force immediate drawing mode for cached items.

Definition at line 1015 of file view.cpp.

1016{
1017 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1018
1019 if( !viewData )
1020 return;
1021
1022 if( IsCached( aLayer ) && !aImmediate )
1023 {
1024 // Draw using cached information or create one
1025 int group = viewData->getGroup( aLayer );
1026
1027 if( group >= 0 )
1028 m_gal->DrawGroup( group );
1029 else
1030 Update( aItem );
1031 }
1032 else
1033 {
1034 // Immediate mode
1035 if( !m_painter->Draw( aItem, aLayer ) )
1036 aItem->ViewDraw( aLayer, this ); // Alternative drawing method
1037 }
1038}
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer)=0
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
bool IsCached(int aLayer) const
Return true if the layer is cached.
Definition: view.h:624

References KIGFX::PAINTER::Draw(), KIGFX::GAL::DrawGroup(), KIGFX::VIEW_ITEM_DATA::getGroup(), group, IsCached(), m_gal, m_painter, Update(), KIGFX::VIEW_ITEM::ViewDraw(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by KIGFX::VIEW::DRAW_ITEM_VISITOR::deferredDraw(), draw(), and KIGFX::VIEW::DRAW_ITEM_VISITOR::operator()().

◆ EnableTopLayer()

void KIGFX::VIEW::EnableTopLayer ( bool  aEnable)
virtual

Enable or disable display of the top layer.

When disabled, layers are rendered as usual with no influence from SetTopLayer function. Otherwise on the top there is displayed the layer set previously with SetTopLayer function.

Parameters
aEnablewhether to enable or disable display of the top layer.

Definition at line 852 of file view.cpp.

853{
854 if( aEnable == m_enableOrderModifier )
855 return;
856
857 m_enableOrderModifier = aEnable;
858
859 std::set<unsigned int>::iterator it;
860
861 if( aEnable )
862 {
863 for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
864 m_layers[*it].renderingOrder += TOP_LAYER_MODIFIER;
865 }
866 else
867 {
868 for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
869 m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
870 }
871
874}
void UpdateAllLayersOrder()
Do everything that is needed to apply the rendering order of layers.
Definition: view.cpp:892
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:761

References m_enableOrderModifier, m_layers, m_topLayers, TOP_LAYER_MODIFIER, UpdateAllLayersColor(), and UpdateAllLayersOrder().

Referenced by PCB_DRAW_PANEL_GAL::SetTopLayer().

◆ GetBoundary()

const BOX2D & KIGFX::VIEW::GetBoundary ( ) const
inline
Returns
Current view area boundary.

Definition at line 298 of file view.h.

299 {
300 return m_boundary;
301 }

References m_boundary.

Referenced by NL_PCBNEW_PLUGIN_IMPL::NL_PCBNEW_PLUGIN_IMPL(), KIGFX::WX_VIEW_CONTROLS::onScroll(), NL_SCHEMATIC_PLUGIN_IMPL::SetCanvas(), and KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars().

◆ GetCenter()

◆ GetGAL()

GAL * KIGFX::VIEW::GetGAL ( ) const
inline

Return the #GAL this view is using to draw graphical primitives.

Returns
Pointer to the currently used GAL instance.

Definition at line 195 of file view.h.

196 {
197 return m_gal;
198 }

References m_gal.

Referenced by EE_GRID_HELPER::BestDragOrigin(), PCB_GRID_HELPER::BestDragOrigin(), PCB_GRID_HELPER::BestSnapAnchor(), GRID_HELPER::canUseGrid(), KIGFX::WX_VIEW_CONTROLS::CenterOnCursor(), PNS_PCBNEW_DEBUG_DECORATOR::Clear(), COMMON_TOOLS::CursorControl(), PCB_CONTROL::DoSetGridOrigin(), COMMON_TOOLS::doZoomInOut(), drawBacksideTicks(), KIGFX::PREVIEW::CENTRELINE_RECT_ITEM::drawPreviewShape(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), KIGFX::VIEW_OVERLAY::COMMAND_LINE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_RECTANGLE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_CIRCLE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_ARC::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_POLYGON::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_POLY_POLYGON::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_POINT_POLYGON::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_STROKE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_FILL::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_COLOR::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_WIDTH::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_GLYPH_SIZE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_BITMAP_TEXT::Execute(), GRID_HELPER::GetGrid(), GRID_HELPER::GetOrigin(), KIGFX::WX_VIEW_CONTROLS::GetRawCursorPosition(), GRID_HELPER::GetVisibleGrid(), ROUTER_TOOL::handleCommonEvents(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_VIEWER_TOOLS::MeasureTool(), PNS_PCBNEW_DEBUG_DECORATOR::nextDepth(), COMMON_TOOLS::OnGridChanged(), COMMON_TOOLS::PanControl(), DIALOG_PAD_PROPERTIES::prepareCanvas(), SCH_BASE_FRAME::RefreshZoomDependentItems(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), PNS_PCBNEW_DEBUG_DECORATOR::SetView(), KIGFX::VIEW_CONTROLS::ShowCursor(), DIALOG_ERC::testErc(), PNS::TOOL_BASE::updateEndItem(), PNS::TOOL_BASE::updateStartItem(), DS_PROXY_VIEW_ITEM::ViewDraw(), KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), RATSNEST_VIEW_ITEM::ViewDraw(), ROUTER_PREVIEW_ITEM::ViewDraw(), MY_DRAWING::ViewDraw(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), KIGFX::PREVIEW::SELECTION_AREA::ViewDraw(), KIGFX::PREVIEW::TWO_POINT_ASSISTANT::ViewDraw(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), KIGFX::VIEW_OVERLAY::ViewDraw(), and KIGFX::WX_VIEW_CONTROLS::WarpMouseCursor().

◆ GetLayerOrder()

int KIGFX::VIEW::GetLayerOrder ( int  aLayer) const

Return rendering order of a particular layer.

Lower values are rendered first.

Parameters
aLayeris the layer.
Returns
Rendering order of a particular layer.

Definition at line 642 of file view.cpp.

643{
644 return m_layers.at( aLayer ).renderingOrder;
645}

References m_layers.

Referenced by PCB_DRAW_PANEL_GAL::SetTopLayer(), and SortLayers().

◆ GetPainter()

PAINTER * KIGFX::VIEW::GetPainter ( ) const
inline

Return the painter object used by the view for drawing #VIEW_ITEMS.

Returns
Pointer to the currently used Painter instance.

Definition at line 213 of file view.h.

214 {
215 return m_painter;
216 }

References m_painter.

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::ApplyDisplaySettingsToGAL(), EDITOR_CONDITIONS::bboxesFunc(), DS_PROXY_VIEW_ITEM::buildDrawList(), DIALOG_NET_INSPECTOR::buildNetsList(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_BASE_FRAME::CommonSettingsChanged(), PCB_BASE_FRAME::CommonSettingsChanged(), PL_EDITOR_FRAME::CommonSettingsChanged(), PCB_EDIT_FRAME::CommonSettingsChanged(), PCB_GRID_HELPER::computeAnchors(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), PNS_KICAD_IFACE::DisplayRatline(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), KIGFX::PREVIEW::DrawTextNextToCursor(), PAD_TOOL::EditPad(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), FOOTPRINT_PREVIEW_PANEL::GetBackgroundColor(), FOOTPRINT_PREVIEW_PANEL::GetForegroundColor(), ROUTER_PREVIEW_ITEM::getLayerColor(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), ROUTER_TOOL::Init(), DRAWING_TOOL::Init(), PCB_SELECTION_TOOL::Init(), PNS_KICAD_IFACE::IsItemVisible(), PCB_EDIT_FRAME::LoadProjectSettings(), PCB_BASE_FRAME::LoadSettings(), DIALOG_PAD_PROPERTIES::onChangePadMode(), ZONE_CREATE_HELPER::OnFirstPoint(), GERBER_LAYER_WIDGET::OnLayerColorChange(), GERBER_LAYER_WIDGET::OnLayerSelect(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), DIALOG_NET_INSPECTOR::onSelChanged(), GERBVIEW_FRAME::OnSelectActiveDCode(), GERBVIEW_FRAME::OnSelectActiveLayer(), PCB_DRAW_PANEL_GAL::OnShow(), DIALOG_NET_INSPECTOR::onSortingChanged(), PCB_GRID_HELPER::PCB_GRID_HELPER(), DIALOG_PAD_PROPERTIES::prepareCanvas(), PCB_GRID_HELPER::queryVisible(), NET_GRID_TABLE::Rebuild(), APPEARANCE_CONTROLS::rebuildNets(), DIALOG_PAD_PROPERTIES::redraw(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), EE_SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), PCB_EDIT_FRAME::SaveProjectSettings(), SCH_EDIT_FRAME::SCH_EDIT_FRAME(), PCB_SELECTION_TOOL::Selectable(), NETS_SEARCH_HANDLER::SelectItems(), PCB_BASE_FRAME::SetBoard(), EDA_DRAW_PANEL_GAL::SetHighContrastLayer(), GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_EDIT_FRAME::setupUIConditions(), PCBNEW_PRINTOUT::setupViewLayers(), SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET(), COMMON_TOOLS::ToggleBoundingBoxes(), PCB_DRAW_PANEL_GAL::UpdateColors(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), NET_GRID_TABLE::updateNetColor(), PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview(), PANEL_PCBNEW_COLOR_SETTINGS::updatePreview(), DS_PROXY_VIEW_ITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), RATSNEST_VIEW_ITEM::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), KIGFX::PREVIEW::SELECTION_AREA::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), FP_TEXTBOX::ViewGetLOD(), PAD::ViewGetLOD(), PCB_SHAPE::ViewGetLOD(), PCB_TEXT::ViewGetLOD(), PCB_TEXTBOX::ViewGetLOD(), PCB_TRACK::ViewGetLOD(), and PCB_VIA::ViewGetLOD().

◆ GetScale()

◆ GetScreenPixelSize()

const VECTOR2I & KIGFX::VIEW::GetScreenPixelSize ( ) const

Return the size of the our rendering area in pixels.

Returns
viewport screen size.

Definition at line 1166 of file view.cpp.

1167{
1168 return m_gal->GetScreenPixelSize();
1169}
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.

References KIGFX::GAL::GetScreenPixelSize(), and m_gal.

Referenced by KIGFX::WX_VIEW_CONTROLS::handleAutoPanning(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), and KIGFX::WX_VIEW_CONTROLS::PinCursorInsideNonAutoscrollArea().

◆ GetTopLayer()

int KIGFX::VIEW::GetTopLayer ( ) const
virtual

Definition at line 816 of file view.cpp.

817{
818 if( m_topLayers.size() == 0 )
819 return 0;
820
821 return *m_topLayers.begin();
822}

References m_topLayers.

Referenced by ROUTER_TOOL::getStartLayer(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::pickSingleItem(), and PNS::TOOL_BASE::updateStartItem().

◆ GetViewport()

BOX2D KIGFX::VIEW::GetViewport ( ) const

Return the current viewport visible area rectangle.

Returns
Current viewport rectangle.

Definition at line 511 of file view.cpp.

512{
513 BOX2D rect;
514 VECTOR2D screenSize = m_gal->GetScreenPixelSize();
515
516 rect.SetOrigin( ToWorld( VECTOR2D( 0, 0 ) ) );
517 rect.SetEnd( ToWorld( screenSize ) );
518
519 return rect.Normalize();
520}
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:448
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617

References KIGFX::GAL::GetScreenPixelSize(), m_gal, BOX2< Vec >::Normalize(), BOX2< Vec >::SetEnd(), BOX2< Vec >::SetOrigin(), and ToWorld().

Referenced by drawBacksideTicks(), drawTicksAlongLine(), PCB_SELECTION_TOOL::FindItem(), PCB_BASE_FRAME::FocusOnItems(), EDA_DRAW_FRAME::FocusOnLocation(), NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::GetViewExtents(), PCB_SELECTION_TOOL::hitTestDistance(), APPEARANCE_CONTROLS::onViewportChanged(), NL_SCHEMATIC_PLUGIN_IMPL::SetViewExtents(), NL_PCBNEW_PLUGIN_IMPL::SetViewExtents(), KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars(), PCB_TRACK::ViewGetLOD(), and EE_SELECTION_TOOL::ZoomFitCrossProbeBBox().

◆ HasItem()

bool KIGFX::VIEW::HasItem ( const VIEW_ITEM aItem) const

Indicates whether or not the given item has been added to the view.

Definition at line 1577 of file view.cpp.

1578{
1579 const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1580
1581 return viewData && viewData->m_view == this;
1582}

References KIGFX::VIEW_ITEM_DATA::m_view, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by PCB_BASE_FRAME::HideSolderMask(), and PCB_BASE_FRAME::ShowSolderMask().

◆ Hide()

void KIGFX::VIEW::Hide ( VIEW_ITEM aItem,
bool  aHide = true 
)

Temporarily hide the item in the view (e.g.

for overlaying).

Parameters
aItemthe item to modify.
aHidewhether the item is hidden (on all layers), or not.

Definition at line 1550 of file view.cpp.

1551{
1552 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1553
1554 if( !viewData )
1555 return;
1556
1557 if( !( viewData->m_flags & VISIBLE ) )
1558 return;
1559
1560 if( aHide )
1561 viewData->m_flags |= HIDDEN;
1562 else
1563 viewData->m_flags &= ~HIDDEN;
1564
1565 Update( aItem, APPEARANCE );
1566}
@ APPEARANCE
Visibility flag has changed.
Definition: view_item.h:47
@ HIDDEN
Item is temporarily hidden (e.g.
Definition: view_item.h:61
@ VISIBLE
Item is visible (in general)
Definition: view_item.h:60

References KIGFX::APPEARANCE, KIGFX::HIDDEN, KIGFX::VIEW_ITEM_DATA::m_flags, Update(), KIGFX::VIEW_ITEM::viewPrivData(), and KIGFX::VISIBLE.

Referenced by AddToPreview(), KIGFX::SCH_VIEW::ClearHiddenFlags(), PCB_SELECTION_TOOL::EnterGroup(), PCB_SELECTION_TOOL::ExitGroup(), PCB_SELECTION_TOOL::highlightInternal(), ROUTER_TOOL::InlineDrag(), SCH_MOVE_TOOL::moveItem(), SCH_EDITOR_CONTROL::Paste(), GERBVIEW_SELECTION_TOOL::selectVisually(), PCB_SELECTION_TOOL::unhighlightInternal(), and GERBVIEW_SELECTION_TOOL::unselectVisually().

◆ InitPreview()

◆ invalidateItem()

void KIGFX::VIEW::invalidateItem ( VIEW_ITEM aItem,
int  aUpdateFlags 
)
protected

Manage dirty flags & redraw queuing when updating an item.

Parameters
aItemis the item to be updated.
aUpdateFlagsdetermines the way an item is refreshed. Update colors that are used for an item to be drawn

Definition at line 1202 of file view.cpp.

1203{
1204 if( aUpdateFlags & INITIAL_ADD )
1205 {
1206 // Don't update layers or bbox, since it was done in VIEW::Add()
1207 // Now that we have initialized, set flags to ALL for the code below
1208 aUpdateFlags = ALL;
1209 }
1210 else
1211 {
1212 // updateLayers updates geometry too, so we do not have to update both of them at the
1213 // same time
1214 if( aUpdateFlags & LAYERS )
1215 updateLayers( aItem );
1216 else if( aUpdateFlags & GEOMETRY )
1217 updateBbox( aItem );
1218 }
1219
1220 int layers[VIEW_MAX_LAYERS], layers_count;
1221 aItem->ViewGetLayers( layers, layers_count );
1222
1223 // Iterate through layers used by the item and recache it immediately
1224 for( int i = 0; i < layers_count; ++i )
1225 {
1226 int layerId = layers[i];
1227
1228 if( IsCached( layerId ) )
1229 {
1230 if( aUpdateFlags & ( GEOMETRY | LAYERS | REPAINT ) )
1231 updateItemGeometry( aItem, layerId );
1232 else if( aUpdateFlags & COLOR )
1233 updateItemColor( aItem, layerId );
1234 }
1235
1236 // Mark those layers as dirty, so the VIEW will be refreshed
1237 MarkTargetDirty( m_layers[layerId].target );
1238 }
1239
1240 aItem->viewPrivData()->clearUpdateFlags();
1241}
void updateItemColor(VIEW_ITEM *aItem, int aLayer)
Update all information needed to draw an item.
Definition: view.cpp:1259
void updateItemGeometry(VIEW_ITEM *aItem, int aLayer)
Update bounding box of an item.
Definition: view.cpp:1278
void updateLayers(VIEW_ITEM *aItem)
Determine rendering order of layers. Used in display order sorting function.
Definition: view.cpp:1324
void updateBbox(VIEW_ITEM *aItem)
Update set of layers that an item occupies.
Definition: view.cpp:1308
@ COLOR
Color has changed.
Definition: view_item.h:48
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:49
@ LAYERS
Layers have changed.
Definition: view_item.h:50
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:53

References KIGFX::ALL, KIGFX::VIEW_ITEM_DATA::clearUpdateFlags(), KIGFX::COLOR, KIGFX::GEOMETRY, KIGFX::INITIAL_ADD, IsCached(), KIGFX::LAYERS, m_layers, MarkTargetDirty(), KIGFX::REPAINT, updateBbox(), updateItemColor(), updateItemGeometry(), updateLayers(), VIEW_MAX_LAYERS, KIGFX::VIEW_ITEM::ViewGetLayers(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by UpdateItems().

◆ IsCached()

bool KIGFX::VIEW::IsCached ( int  aLayer) const
inline

Return true if the layer is cached.

Definition at line 624 of file view.h.

625 {
626 wxCHECK( aLayer < (int) m_layers.size(), false );
627
628 try
629 {
630 return m_layers.at( aLayer ).target == TARGET_CACHED;
631 }
632 catch( const std::out_of_range& )
633 {
634 return false;
635 }
636 }

References m_layers, and KIGFX::TARGET_CACHED.

Referenced by draw(), invalidateItem(), RecacheAllItems(), updateItemColor(), updateItemGeometry(), UpdateLayerColor(), and updateLayers().

◆ IsDirty()

bool KIGFX::VIEW::IsDirty ( ) const
inline

Return true if any of the VIEW layers needs to be refreshened.

Returns
True in case if any of layers is marked as dirty.

Definition at line 589 of file view.h.

590 {
591 for( int i = 0; i < TARGETS_NUMBER; ++i )
592 {
593 if( IsTargetDirty( i ) )
594 return true;
595 }
596
597 return false;
598 }
@ TARGETS_NUMBER
Number of available rendering targets.
Definition: definitions.h:52

References IsTargetDirty(), and KIGFX::TARGETS_NUMBER.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint(), and TOOL_MANAGER::ProcessEvent().

◆ IsDynamic()

bool KIGFX::VIEW::IsDynamic ( ) const
inline

Tell if the VIEW is dynamic (ie.

can be changed, for example displaying PCBs in a window) or static (that cannot be modified, eg. displaying image/PDF).

Definition at line 579 of file view.h.

580 {
581 return m_dynamic;
582 }

References m_dynamic.

◆ IsLayerVisible()

◆ IsMirroredX()

◆ IsMirroredY()

bool KIGFX::VIEW::IsMirroredY ( ) const
inline

Return true if view is flipped across the Y axis.

Definition at line 251 of file view.h.

252 {
253 return m_mirrorY;
254 }

References m_mirrorY.

Referenced by NL_SCHEMATIC_PLUGIN_IMPL::GetCameraMatrix(), and NL_PCBNEW_PLUGIN_IMPL::GetCameraMatrix().

◆ IsTargetDirty()

bool KIGFX::VIEW::IsTargetDirty ( int  aTarget) const
inline

Return true if any of layers belonging to the target or the target itself should be redrawn.

Returns
True if the above condition is fulfilled.

Definition at line 606 of file view.h.

607 {
608 wxCHECK( aTarget < TARGETS_NUMBER, false );
609 return m_dirtyTargets[aTarget];
610 }
bool m_dirtyTargets[TARGETS_NUMBER]
Flag to respect draw priority when drawing items.
Definition: view.h:874

References m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

Referenced by ClearTargets(), EDA_DRAW_PANEL_GAL::DoRePaint(), IsDirty(), and redrawRect().

◆ IsUsingDrawPriority()

bool KIGFX::VIEW::IsUsingDrawPriority ( ) const
inline
Returns
true if draw priority is being respected while redrawing.

Definition at line 687 of file view.h.

688 {
689 return m_useDrawPriority;
690 }

References m_useDrawPriority.

◆ IsVisible()

bool KIGFX::VIEW::IsVisible ( const VIEW_ITEM aItem) const

Return information if the item is visible (or not).

Parameters
aItemthe item to test.
Returns
when true, the item is visible (i.e. to be displayed, not visible in the current viewport)

Definition at line 1569 of file view.cpp.

1570{
1571 const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1572
1573 return viewData && ( viewData->m_flags & VISIBLE );
1574}

References KIGFX::VIEW_ITEM_DATA::m_flags, KIGFX::VIEW_ITEM::viewPrivData(), and KIGFX::VISIBLE.

Referenced by PCB_GRID_HELPER::BestSnapAnchor(), EE_GRID_HELPER::BestSnapAnchor(), PCB_GRID_HELPER::computeAnchors(), PNS_KICAD_IFACE::HideItem(), PNS_KICAD_IFACE::IsItemVisible(), EE_GRID_HELPER::queryVisible(), PCB_GRID_HELPER::queryVisible(), and PCB_SELECTION_TOOL::Selectable().

◆ MakeOverlay()

std::shared_ptr< VIEW_OVERLAY > KIGFX::VIEW::MakeOverlay ( )

Definition at line 1604 of file view.cpp.

1605{
1606 std::shared_ptr<VIEW_OVERLAY> overlay = std::make_shared<VIEW_OVERLAY>();
1607
1608 Add( overlay.get() );
1609 return overlay;
1610}
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay
Definition: playground.cpp:36

References Add(), and overlay.

Referenced by AUTOPLACE_TOOL::autoplace().

◆ MarkClean()

void KIGFX::VIEW::MarkClean ( )
inline

Force redraw of view on the next rendering.

Definition at line 650 of file view.h.

651 {
652 for( int i = 0; i < TARGETS_NUMBER; ++i )
653 m_dirtyTargets[i] = false;
654 }

References m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

Referenced by Redraw().

◆ MarkDirty()

◆ markTargetClean()

void KIGFX::VIEW::markTargetClean ( int  aTarget)
inlineprotected

Definition at line 754 of file view.h.

755 {
756 wxCHECK( aTarget < TARGETS_NUMBER, /* void */ );
757 m_dirtyTargets[aTarget] = false;
758 }

References m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

◆ MarkTargetDirty()

◆ OnDestroy()

void KIGFX::VIEW::OnDestroy ( VIEW_ITEM aItem)
static

Nasty hack, invoked by the destructor of VIEW_ITEM to auto-remove the item from the owning VIEW if there is any.

KiCad relies too much on this mechanism. This is the only linking dependency now between EDA_ITEM and VIEW class. In near future I'll replace it with observers.

Definition at line 241 of file view.cpp.

242{
243 VIEW_ITEM_DATA* data = aItem->viewPrivData();
244
245 if( !data )
246 return;
247
248 if( data->m_view )
249 data->m_view->VIEW::Remove( aItem );
250
251 delete data;
252 aItem->ClearViewPrivData();
253}

References KIGFX::VIEW_ITEM::ClearViewPrivData(), KIGFX::VIEW_ITEM_DATA::m_view, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by KIGFX::VIEW_ITEM::~VIEW_ITEM().

◆ Query()

int KIGFX::VIEW::Query ( const BOX2I aRect,
std::vector< LAYER_ITEM_PAIR > &  aResult 
) const
virtual

Find all visible items that touch or are within the rectangle aRect.

Parameters
aRectarea to search for items
aResultresult of the search, containing VIEW_ITEMs associated with their layers. Sorted according to the rendering order (items that are on top of the rendering stack as first).
Returns
Number of found items.

Definition at line 425 of file view.cpp.

426{
427 if( m_orderedLayers.empty() )
428 return 0;
429
430 std::vector<VIEW_LAYER*>::const_reverse_iterator i;
431
432 // execute queries in reverse direction, so that items that are on the top of
433 // the rendering stack are returned first.
434 for( i = m_orderedLayers.rbegin(); i != m_orderedLayers.rend(); ++i )
435 {
436 // ignore layers that do not contain actual items (i.e. the selection box, menus, floats)
437 if( ( *i )->displayOnly || !( *i )->visible )
438 continue;
439
440 QUERY_VISITOR<std::vector<LAYER_ITEM_PAIR> > visitor( aResult, ( *i )->id );
441 ( *i )->items->Query( aRect, visitor );
442 }
443
444 return aResult.size();
445}
std::vector< VIEW_LAYER * > m_orderedLayers
Flat list of all items.
Definition: view.h:844

References m_orderedLayers.

Referenced by DRAWING_TOOL::DrawVia(), EE_GRID_HELPER::queryVisible(), PCB_GRID_HELPER::queryVisible(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectMultiple(), and PCB_SELECTION_TOOL::selectMultiple().

◆ RecacheAllItems()

◆ Redraw()

void KIGFX::VIEW::Redraw ( )
virtual

Immediately redraws the whole view.

Definition at line 1133 of file view.cpp.

1134{
1135#ifdef KICAD_GAL_PROFILE
1136 PROF_TIMER totalRealTime;
1137#endif /* KICAD_GAL_PROFILE */
1138
1139 VECTOR2D screenSize = m_gal->GetScreenPixelSize();
1140 BOX2D rect( ToWorld( VECTOR2D( 0, 0 ) ),
1141 ToWorld( screenSize ) - ToWorld( VECTOR2D( 0, 0 ) ) );
1142
1143 rect.Normalize();
1144 BOX2I recti( rect.GetPosition(), rect.GetSize() );
1145
1146 // The view rtree uses integer positions. Large screens can overflow this size so in
1147 // this case, simply set the rectangle to the full rtree.
1148 if( rect.GetWidth() > std::numeric_limits<int>::max()
1149 || rect.GetHeight() > std::numeric_limits<int>::max() )
1150 {
1151 recti.SetMaximum();
1152 }
1153
1154 redrawRect( recti );
1155
1156 // All targets were redrawn, so nothing is dirty
1157 MarkClean();
1158
1159#ifdef KICAD_GAL_PROFILE
1160 totalRealTime.Stop();
1161 wxLogTrace( traceGalProfile, wxS( "VIEW::Redraw(): %.1f ms" ), totalRealTime.msecs() );
1162#endif /* KICAD_GAL_PROFILE */
1163}
void MarkClean()
Force redraw of view on the next rendering.
Definition: view.h:650
void redrawRect(const BOX2I &aRect)
Definition: view.cpp:982
A small class to help profiling.
Definition: profile.h:47
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition: profile.h:86
double msecs(bool aSinceLast=false)
Definition: profile.h:147
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.

References BOX2< Vec >::GetHeight(), BOX2< Vec >::GetPosition(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetSize(), BOX2< Vec >::GetWidth(), m_gal, MarkClean(), PROF_TIMER::msecs(), BOX2< Vec >::Normalize(), redrawRect(), BOX2< Vec >::SetMaximum(), PROF_TIMER::Stop(), ToWorld(), and traceGalProfile.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ redrawRect()

void KIGFX::VIEW::redrawRect ( const BOX2I aRect)
protected
  • Redraws contents within rect aRect

Definition at line 982 of file view.cpp.

983{
984 for( VIEW_LAYER* l : m_orderedLayers )
985 {
986 if( l->visible && IsTargetDirty( l->target ) && areRequiredLayersEnabled( l->id ) )
987 {
988 DRAW_ITEM_VISITOR drawFunc( this, l->id, m_useDrawPriority, m_reverseDrawOrder );
989
990 m_gal->SetTarget( l->target );
991 m_gal->SetLayerDepth( l->renderingOrder );
992
993 // Differential layer also work for the negatives, since both special layer types
994 // will composite on separate layers (at least in Cairo)
995 if( l->diffLayer )
997 else if( l->hasNegatives )
999
1000
1001 l->items->Query( aRect, drawFunc );
1002
1003 if( m_useDrawPriority )
1004 drawFunc.deferredDraw();
1005
1006 if( l->diffLayer )
1008 else if( l->hasNegatives )
1010 }
1011 }
1012}
virtual void StartDiffLayer()
Begins rendering of a differential layer.
virtual void EndDiffLayer()
Ends rendering of a differential layer.
virtual void EndNegativesLayer()
Ends rendering of a negatives layer and draws it to the main layer.
virtual void StartNegativesLayer()
Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.

References areRequiredLayersEnabled(), KIGFX::VIEW::DRAW_ITEM_VISITOR::deferredDraw(), KIGFX::GAL::EndDiffLayer(), KIGFX::GAL::EndNegativesLayer(), IsTargetDirty(), m_gal, m_orderedLayers, m_reverseDrawOrder, m_useDrawPriority, KIGFX::GAL::SetLayerDepth(), KIGFX::GAL::SetTarget(), KIGFX::GAL::StartDiffLayer(), and KIGFX::GAL::StartNegativesLayer().

Referenced by Redraw().

◆ Remove()

void KIGFX::VIEW::Remove ( VIEW_ITEM aItem)
virtual

Remove a VIEW_ITEM from the view.

Parameters
aItemitem to be removed. Caller must dispose the removed item if necessary

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 349 of file view.cpp.

350{
351 if( !aItem )
352 return;
353
354 auto viewData = aItem->viewPrivData();
355
356 if( !viewData )
357 return;
358
359 wxCHECK( viewData->m_view == this, /*void*/ );
360 auto item = std::find( m_allItems->begin(), m_allItems->end(), aItem );
361
362 if( item != m_allItems->end() )
363 {
364 m_allItems->erase( item );
365 viewData->clearUpdateFlags();
366 }
367
368 int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
369 viewData->getLayers( layers, layers_count );
370
371 for( int i = 0; i < layers_count; ++i )
372 {
373 VIEW_LAYER& l = m_layers[layers[i]];
374 l.items->Remove( aItem );
375 MarkTargetDirty( l.target );
376
377 // Clear the GAL cache
378 int prevGroup = viewData->getGroup( layers[i] );
379
380 if( prevGroup >= 0 )
381 m_gal->DeleteGroup( prevGroup );
382 }
383
384 viewData->deleteGroups();
385 viewData->m_view = nullptr;
386}
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.

References KIGFX::GAL::DeleteGroup(), KIGFX::VIEW::VIEW_LAYER::items, m_allItems, m_gal, m_layers, MarkTargetDirty(), KIGFX::VIEW::VIEW_LAYER::target, VIEW_MAX_LAYERS, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by EDA_DRAW_PANEL_GAL::ClearDebugOverlay(), EDIT_TOOL::DeleteItems(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), PL_EDIT_TOOL::DoDelete(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawShape(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), DRAWING_TOOL::PlaceImportedGraphics(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), SCH_BASE_FRAME::RemoveFromScreen(), EE_SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), BOARD_EDITOR_CONTROL::Reset(), PCB_CONTROL::Reset(), BOARD_COMMIT::Revert(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_POLYGONS::SyncDrawItems(), DS_DATA_ITEM_TEXT::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_ERC::testErc(), GERBVIEW_SELECTION_TOOL::unselect(), EE_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), SYMBOL_VIEWER_FRAME::updatePreviewSymbol(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL(), SYMBOL_PREVIEW_WIDGET::~SYMBOL_PREVIEW_WIDGET(), SYMBOL_VIEWER_FRAME::~SYMBOL_VIEWER_FRAME(), ~VIEW(), and ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER().

◆ ReorderLayerData()

void KIGFX::VIEW::ReorderLayerData ( std::unordered_map< int, int >  aReorderMap)

Remap the data between layer ids without invalidating that data.

Used by GerbView for the "Sort by X2" functionality.

Parameters
aReorderMapis a mapping of old to new layer ids.

Definition at line 676 of file view.cpp.

677{
678 std::vector<VIEW_LAYER> new_map;
679 new_map.reserve( m_layers.size() );
680
681 for( const VIEW_LAYER& layer : m_layers )
682 new_map.push_back( layer );
683
684 for( auto& pair : aReorderMap )
685 {
686 new_map[pair.second] = m_layers[pair.first];
687 new_map[pair.second].id = pair.second;
688 }
689
690 m_layers = new_map;
691
692 for( VIEW_ITEM* item : *m_allItems )
693 {
694 VIEW_ITEM_DATA* viewData = item->viewPrivData();
695
696 if( !viewData )
697 continue;
698
699 int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
700
701 item->ViewGetLayers( layers, layers_count );
702 viewData->saveLayers( layers, layers_count );
703
704 viewData->reorderGroups( aReorderMap );
705
706 viewData->m_requiredUpdate |= COLOR;
707 }
708
709 UpdateItems();
710}
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1401
friend class VIEW_ITEM
Definition: view.h:71

References KIGFX::COLOR, m_allItems, m_layers, KIGFX::VIEW_ITEM_DATA::m_requiredUpdate, KIGFX::VIEW_ITEM_DATA::reorderGroups(), KIGFX::VIEW_ITEM_DATA::saveLayers(), UpdateItems(), and VIEW_MAX_LAYERS.

Referenced by GERBVIEW_FRAME::RemapLayers().

◆ ReverseDrawOrder()

void KIGFX::VIEW::ReverseDrawOrder ( bool  aFlag)
inline

Only takes effect if UseDrawPriority is true.

Parameters
aFlagis true if draw order should be reversed

Definition at line 705 of file view.h.

706 {
707 m_reverseDrawOrder = aFlag;
708 }

References m_reverseDrawOrder.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ SetBoundary() [1/2]

void KIGFX::VIEW::SetBoundary ( const BOX2D aBoundary)
inline

Set limits for view area.

Parameters
aBoundaryis the box that limits view area.

Definition at line 279 of file view.h.

280 {
281 m_boundary = aBoundary;
282 }

References m_boundary.

Referenced by PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), DIALOG_PAD_PROPERTIES::redraw(), and SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME().

◆ SetBoundary() [2/2]

void KIGFX::VIEW::SetBoundary ( const BOX2I aBoundary)
inline

Set limits for view area.

Parameters
aBoundaryis the box that limits view area.

Definition at line 289 of file view.h.

290 {
291 m_boundary.SetOrigin( aBoundary.GetOrigin() );
292 m_boundary.SetEnd( aBoundary.GetEnd() );
293 }
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185

References BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), m_boundary, BOX2< Vec >::SetEnd(), and BOX2< Vec >::SetOrigin().

◆ SetCenter() [1/2]

void KIGFX::VIEW::SetCenter ( const VECTOR2D aCenter)

Set the center point of the VIEW (i.e.

the point in world space that will be drawn in the middle of the screen).

Parameters
aCenterthe new center point, in world space coordinates.

Definition at line 577 of file view.cpp.

578{
579 m_center = aCenter;
580
581 if( !m_boundary.Contains( aCenter ) )
582 {
583 if( m_center.x < m_boundary.GetLeft() )
585 else if( aCenter.x > m_boundary.GetRight() )
587
588 if( m_center.y < m_boundary.GetTop() )
590 else if( m_center.y > m_boundary.GetBottom() )
592 }
593
596
597 // Redraw everything after the viewport has changed
598 MarkDirty();
599}
coord_type GetTop() const
Definition: box2.h:194
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
coord_type GetRight() const
Definition: box2.h:189
coord_type GetLeft() const
Definition: box2.h:193
coord_type GetBottom() const
Definition: box2.h:190
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.

References KIGFX::GAL::ComputeWorldScreenMatrix(), BOX2< Vec >::Contains(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), m_boundary, m_center, m_gal, MarkDirty(), KIGFX::GAL::SetLookAtPoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by COMMON_TOOLS::CenterContents(), KIGFX::WX_VIEW_CONTROLS::CenterOnCursor(), COMMON_TOOLS::doZoomFit(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), EDA_DRAW_FRAME::FocusOnLocation(), KIGFX::WX_VIEW_CONTROLS::onMotion(), KIGFX::WX_VIEW_CONTROLS::onScroll(), EDA_DRAW_PANEL_GAL::onSize(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), SCH_BASE_FRAME::RedrawScreen(), ZOOM_TOOL::selectRegion(), NL_SCHEMATIC_PLUGIN_IMPL::SetCameraMatrix(), NL_PCBNEW_PLUGIN_IMPL::SetCameraMatrix(), SetCenter(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), SetGAL(), SetScale(), SetViewport(), KIGFX::WX_VIEW_CONTROLS::WarpMouseCursor(), PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), and PCB_SELECTION_TOOL::zoomFitSelection().

◆ SetCenter() [2/2]

void KIGFX::VIEW::SetCenter ( const VECTOR2D aCenter,
const std::vector< BOX2D > &  obscuringScreenRects 
)

Set the center point of the VIEW, attempting to avoid obscuringScreenRects (for instance, the screen rect of a modeless dialog in front of the VIEW).

Parameters
aCenterthe new center point, in world space coordinates.
obscuringScreenRectsthe obscuring rects, in screen space coordinates.

Definition at line 602 of file view.cpp.

603{
604 if( obscuringScreenRects.empty() )
605 return SetCenter( aCenter );
606
607 BOX2D screenRect( { 0, 0 }, m_gal->GetScreenPixelSize() );
608 SHAPE_POLY_SET unobscuredPoly( screenRect );
609 VECTOR2D unobscuredCenter = screenRect.Centre();
610
611 for( const BOX2D& obscuringScreenRect : obscuringScreenRects )
612 {
613 SHAPE_POLY_SET obscuringPoly( obscuringScreenRect );
614 unobscuredPoly.BooleanSubtract( obscuringPoly, SHAPE_POLY_SET::PM_FAST );
615 }
616
617 /*
618 * Perform a step-wise deflate to find the center of the largest unobscured area
619 */
620
621 BOX2I bbox = unobscuredPoly.BBox();
622 int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
623
624 while( !unobscuredPoly.IsEmpty() )
625 {
626 unobscuredCenter = unobscuredPoly.BBox().Centre();
627 unobscuredPoly.Deflate( step, 4 );
628 }
629
630 SetCenter( aCenter - ToWorld( unobscuredCenter - screenRect.Centre(), false ) );
631}
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:577
Represent a set of closed polygons.

References SHAPE_POLY_SET::BBox(), SHAPE_POLY_SET::BooleanSubtract(), BOX2< Vec >::Centre(), SHAPE_POLY_SET::Deflate(), BOX2< Vec >::GetHeight(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetWidth(), SHAPE_POLY_SET::IsEmpty(), m_gal, SHAPE_POLY_SET::PM_FAST, SetCenter(), and ToWorld().

◆ SetGAL()

void KIGFX::VIEW::SetGAL ( GAL aGal)

Assign a rendering device for the VIEW.

Parameters
aGalpointer to the GAL output device.

Definition at line 492 of file view.cpp.

493{
494 bool recacheGroups = ( m_gal != nullptr ); // recache groups only if GAL is reassigned
495 m_gal = aGal;
496
497 // clear group numbers, so everything is going to be recached
498 if( recacheGroups )
500
501 // every target has to be refreshed
502 MarkDirty();
503
504 // force the new GAL to display the current viewport.
506 SetScale( m_scale );
508}
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:538
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:551
void clearGroupCache()
Definition: view.cpp:1190

References clearGroupCache(), m_center, m_gal, m_mirrorX, m_mirrorY, m_scale, MarkDirty(), SetCenter(), SetMirror(), and SetScale().

Referenced by GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ SetLayerDiff()

void KIGFX::VIEW::SetLayerDiff ( int  aLayer,
bool  aDiff = true 
)
inline

Set the whether the layer should drawn differentially.

Parameters
aLayeris the layer to set to be draw differentially
aDiffis the layer diff'ing state.

Definition at line 424 of file view.h.

425 {
426 wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
427
428 if( m_layers[aLayer].diffLayer != aDiff )
429 {
430 // Target has to be redrawn after changing its layers' diff status
431 MarkTargetDirty( m_layers[aLayer].target );
432 m_layers[aLayer].diffLayer = aDiff;
433 }
434 }

References m_layers, and MarkTargetDirty().

Referenced by GERBVIEW_FRAME::UpdateXORLayers().

◆ SetLayerDisplayOnly()

void KIGFX::VIEW::SetLayerDisplayOnly ( int  aLayer,
bool  aDisplayOnly = true 
)
inline

Set a layer display-only (ie: to be rendered but not returned by hit test queries).

Definition at line 457 of file view.h.

458 {
459 wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
460 m_layers[aLayer].displayOnly = aDisplayOnly;
461 }

References m_layers.

Referenced by SCH_DRAW_PANEL::setDefaultLayerDeps(), SCH_PREVIEW_PANEL::setDefaultLayerDeps(), GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps(), PL_DRAW_PANEL_GAL::setDefaultLayerDeps(), and PCB_DRAW_PANEL_GAL::setDefaultLayerDeps().

◆ SetLayerHasNegatives()

void KIGFX::VIEW::SetLayerHasNegatives ( int  aLayer,
bool  aNegatives = true 
)
inline

Set the status of negatives presense in a particular layer.

Parameters
aLayeris the layer to set as containing negatives (or not).
aNegativesis the layer negatives state.

Definition at line 442 of file view.h.

443 {
444 wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
445
446 if( m_layers[aLayer].hasNegatives != aNegatives )
447 {
448 // Target has to be redrawn after changing a layers' negatives
449 MarkTargetDirty( m_layers[aLayer].target );
450 m_layers[aLayer].hasNegatives = aNegatives;
451 }
452 }

References m_layers, and MarkTargetDirty().

Referenced by GERBVIEW_FRAME::unarchiveFiles().

◆ SetLayerOrder()

void KIGFX::VIEW::SetLayerOrder ( int  aLayer,
int  aRenderingOrder 
)

Set rendering order of a particular layer.

Lower values are rendered first.

Parameters
aLayeris the layer.
aRenderingOrderis an arbitrary number denoting the rendering order.

Definition at line 634 of file view.cpp.

635{
636 m_layers[aLayer].renderingOrder = aRenderingOrder;
637
638 sortLayers();
639}

References m_layers, and sortLayers().

Referenced by SCH_DRAW_PANEL::setDefaultLayerOrder(), SCH_PREVIEW_PANEL::setDefaultLayerOrder(), PCB_DRAW_PANEL_GAL::setDefaultLayerOrder(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), and PCB_DRAW_PANEL_GAL::SetTopLayer().

◆ SetLayerTarget()

void KIGFX::VIEW::SetLayerTarget ( int  aLayer,
RENDER_TARGET  aTarget 
)
inline

Change the rendering target for a particular layer.

Parameters
aLayeris the layer.
aTargetis the rendering target.

Definition at line 469 of file view.h.

470 {
471 wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
472 m_layers[aLayer].target = aTarget;
473 }

References m_layers.

Referenced by SCH_DRAW_PANEL::setDefaultLayerDeps(), SCH_PREVIEW_PANEL::setDefaultLayerDeps(), GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps(), PL_DRAW_PANEL_GAL::setDefaultLayerDeps(), PCB_DRAW_PANEL_GAL::setDefaultLayerDeps(), BOARD_PRINTOUT::setupViewLayers(), and GERBVIEW_FRAME::UpdateXORLayers().

◆ SetLayerVisible()

◆ SetMirror()

void KIGFX::VIEW::SetMirror ( bool  aMirrorX,
bool  aMirrorY 
)

Control the mirroring of the VIEW.

Parameters
aMirrorXwhen true, the X axis is mirrored.
aMirrorYwhen true, the Y axis is mirrored.

Definition at line 538 of file view.cpp.

539{
540 wxASSERT_MSG( !aMirrorY, _( "Mirroring for Y axis is not supported yet" ) );
541
542 m_mirrorX = aMirrorX;
543 m_mirrorY = aMirrorY;
544 m_gal->SetFlip( aMirrorX, aMirrorY );
545
546 // Redraw everything
547 MarkDirty();
548}
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
#define _(s)

References _, m_gal, m_mirrorX, m_mirrorY, MarkDirty(), and KIGFX::GAL::SetFlip().

Referenced by GERBVIEW_CONTROL::DisplayControl(), PCB_CONTROL::FlipPcbView(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and SetGAL().

◆ SetPainter()

void KIGFX::VIEW::SetPainter ( PAINTER aPainter)
inline

Set the painter object used by the view for drawing #VIEW_ITEMS.

Definition at line 203 of file view.h.

204 {
205 m_painter = aPainter;
206 }

References m_painter.

Referenced by GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), and SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL().

◆ SetRequired()

void KIGFX::VIEW::SetRequired ( int  aLayerId,
int  aRequiredId,
bool  aRequired = true 
)

Mark the aRequiredId layer as required for the aLayerId layer.

In order to display the layer, all of its required layers have to be enabled.

Parameters
aLayerIdis the id of the layer for which we enable/disable the required layer.
aRequiredIdis the id of the required layer.
aRequiredtells if the required layer should be added or removed from the list.

Definition at line 389 of file view.cpp.

390{
391 wxCHECK( (unsigned) aLayerId < m_layers.size(), /*void*/ );
392 wxCHECK( (unsigned) aRequiredId < m_layers.size(), /*void*/ );
393
394 if( aRequired )
395 m_layers[aLayerId].requiredLayers.insert( aRequiredId );
396 else
397 m_layers[aLayerId].requiredLayers.erase( aRequired );
398}

References m_layers.

Referenced by PCB_DRAW_PANEL_GAL::setDefaultLayerDeps().

◆ SetScale()

void KIGFX::VIEW::SetScale ( double  aScale,
VECTOR2D  aAnchor = { 0, 0 } 
)
virtual

Set the scaling factor, zooming around a given anchor point.

(depending on correct GAL unit length & DPI settings).

Parameters
aAnchoris the zooming anchor point.
aScaleis the scale factor.

Reimplemented in KIGFX::SCH_VIEW.

Definition at line 551 of file view.cpp.

552{
553 if( aAnchor == VECTOR2D( 0, 0 ) )
554 aAnchor = m_center;
555
556 VECTOR2D a = ToScreen( aAnchor );
557
558 if( aScale < m_minScale )
560 else if( aScale > m_maxScale )
562 else
563 m_scale = aScale;
564
567
568 VECTOR2D delta = ToWorld( a ) - aAnchor;
569
571
572 // Redraw everything after the viewport has changed
573 MarkDirty();
574}
void SetZoomFactor(double aZoomFactor)
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:467
constexpr int delta

References KIGFX::GAL::ComputeWorldScreenMatrix(), delta, m_center, m_gal, m_maxScale, m_minScale, m_scale, MarkDirty(), SetCenter(), KIGFX::GAL::SetZoomFactor(), ToScreen(), and ToWorld().

Referenced by COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomToPreset(), PCB_SELECTION_TOOL::FindItem(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), KIGFX::WX_VIEW_CONTROLS::onMotion(), KIGFX::WX_VIEW_CONTROLS::onWheel(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), ZOOM_TOOL::selectRegion(), SetGAL(), KIGFX::SCH_VIEW::SetScale(), NL_PCBNEW_PLUGIN_IMPL::SetViewExtents(), SetViewport(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), and PCB_SELECTION_TOOL::zoomFitSelection().

◆ SetScaleLimits()

void KIGFX::VIEW::SetScaleLimits ( double  aMaximum,
double  aMinimum 
)
inline

Set minimum and maximum values for scale.

Parameters
aMaximumis the maximum value for scale.
aMinimumis the minimum value for scale.

Definition at line 309 of file view.h.

310 {
311 wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
312
313 m_minScale = aMinimum;
314 m_maxScale = aMaximum;
315 }

References m_maxScale, and m_minScale.

Referenced by GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), and SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL().

◆ SetTopLayer()

void KIGFX::VIEW::SetTopLayer ( int  aLayer,
bool  aEnabled = true 
)
virtual

Set given layer to be displayed on the top or sets back the default order of layers.

Parameters
aEnabled= true to display aLayer on the top.
aLayeris the layer or -1 in case when no particular layer should be displayed on the top.

Definition at line 825 of file view.cpp.

826{
827 if( aEnabled )
828 {
829 if( m_topLayers.count( aLayer ) == 1 )
830 return;
831
832 m_topLayers.insert( aLayer );
833
834 // Move the layer closer to front
836 m_layers[aLayer].renderingOrder += TOP_LAYER_MODIFIER;
837 }
838 else
839 {
840 if( m_topLayers.count( aLayer ) == 0 )
841 return;
842
843 m_topLayers.erase( aLayer );
844
845 // Restore the previous rendering order
847 m_layers[aLayer].renderingOrder -= TOP_LAYER_MODIFIER;
848 }
849}

References m_enableOrderModifier, m_layers, m_topLayers, and TOP_LAYER_MODIFIER.

Referenced by DIALOG_PAD_PROPERTIES::redraw(), EDA_DRAW_PANEL_GAL::SetTopLayer(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PL_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), BOARD_PRINTOUT::setupViewLayers(), and PCBNEW_PRINTOUT::setupViewLayers().

◆ SetViewport()

void KIGFX::VIEW::SetViewport ( const BOX2D aViewport)

Set the visible area of the VIEW.

Parameters
aViewportdesired visible area, in world space coordinates.

Definition at line 523 of file view.cpp.

524{
525 VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
526
527 wxCHECK( ssize.x > 0 && ssize.y > 0, /*void*/ );
528
529 VECTOR2D centre = aViewport.Centre();
530 VECTOR2D vsize = aViewport.GetSize();
531 double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
532
533 SetCenter( centre );
534 SetScale( GetScale() * zoom );
535}
Vec Centre() const
Definition: box2.h:70
const Vec & GetSize() const
Definition: box2.h:179
double GetScale() const
Definition: view.h:269

References BOX2< Vec >::Centre(), GetScale(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetSize(), m_gal, SetCenter(), SetScale(), ToWorld(), VECTOR2< T >::x, VECTOR2< T >::y, and zoom.

Referenced by APPEARANCE_CONTROLS::doApplyViewport(), DIALOG_PAD_PROPERTIES::redraw(), and FOOTPRINT_PREVIEW_PANEL::renderFootprint().

◆ SetVisible()

void KIGFX::VIEW::SetVisible ( VIEW_ITEM aItem,
bool  aIsVisible = true 
)

Set the item visibility.

Parameters
aItemthe item to modify.
aIsVisiblewhether the item is visible (on all layers), or not.

Definition at line 1529 of file view.cpp.

1530{
1531 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1532
1533 if( !viewData )
1534 return;
1535
1536 bool cur_visible = viewData->m_flags & VISIBLE;
1537
1538 if( cur_visible != aIsVisible )
1539 {
1540 if( aIsVisible )
1541 viewData->m_flags |= VISIBLE;
1542 else
1543 viewData->m_flags &= ~VISIBLE;
1544
1545 Update( aItem, APPEARANCE | COLOR );
1546 }
1547}

References KIGFX::APPEARANCE, KIGFX::COLOR, KIGFX::VIEW_ITEM_DATA::m_flags, Update(), KIGFX::VIEW_ITEM::viewPrivData(), and KIGFX::VISIBLE.

Referenced by Add(), AddToPreview(), PCB_GRID_HELPER::BestSnapAnchor(), EE_GRID_HELPER::BestSnapAnchor(), MICROWAVE_TOOL::drawMicrowaveInductor(), EE_GRID_HELPER::EE_GRID_HELPER(), PNS_KICAD_IFACE::EraseView(), PNS_KICAD_IFACE::HideItem(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ZONE_CREATE_HELPER::OnComplete(), ZONE_CREATE_HELPER::OnFirstPoint(), PCB_GRID_HELPER::PCB_GRID_HELPER(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GRID_HELPER::SetAuxAxes(), ShowPreview(), and ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER().

◆ ShowPreview()

◆ sortLayers()

void KIGFX::VIEW::sortLayers ( )
protected

Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL)

Definition at line 1244 of file view.cpp.

1245{
1246 int n = 0;
1247
1248 m_orderedLayers.resize( m_layers.size() );
1249
1250 for( VIEW_LAYER& layer : m_layers )
1251 m_orderedLayers[n++] = &layer;
1252
1254
1255 MarkDirty();
1256}
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Check if every layer required by the aLayerId layer is enabled.
Definition: view.h:819

References compareRenderingOrder(), m_layers, m_orderedLayers, and MarkDirty().

Referenced by SetLayerOrder(), UpdateAllLayersOrder(), and VIEW().

◆ SortLayers()

void KIGFX::VIEW::SortLayers ( int  aLayers[],
int &  aCount 
) const

Change the order of given layer ids, so after sorting the order corresponds to layers rendering order (descending, ie.

order in which layers should be drawn - from the bottom to the top).

Parameters
aLayersstores id of layers to be sorted.
aCountstores the number of layers.

Definition at line 648 of file view.cpp.

649{
650 int maxLay, maxOrd, maxIdx;
651
652 for( int i = 0; i < aCount; ++i )
653 {
654 maxLay = aLayers[i];
655 maxOrd = GetLayerOrder( maxLay );
656 maxIdx = i;
657
658 // Look for the max element in the range (j..aCount)
659 for( int j = i; j < aCount; ++j )
660 {
661 if( maxOrd < GetLayerOrder( aLayers[j] ) )
662 {
663 maxLay = aLayers[j];
664 maxOrd = GetLayerOrder( maxLay );
665 maxIdx = j;
666 }
667 }
668
669 // Swap elements
670 aLayers[maxIdx] = aLayers[i];
671 aLayers[i] = maxLay;
672 }
673}
int GetLayerOrder(int aLayer) const
Return rendering order of a particular layer.
Definition: view.cpp:642

References GetLayerOrder().

Referenced by draw(), and KIGFX::VIEW_GROUP::ViewDraw().

◆ ToScreen() [1/2]

VECTOR2D KIGFX::VIEW::ToScreen ( const VECTOR2D aCoord,
bool  aAbsolute = true 
) const

Convert a world space point/vector to a point/vector in screen space coordinates.

Parameters
aCoordis the point/vector to be converted.
aAbsolutewhen true aCoord is treated as a point, otherwise as a direction (vector).

Definition at line 467 of file view.cpp.

468{
469 const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
470
471 if( aAbsolute )
472 return VECTOR2D( matrix * aCoord );
473 else
474 return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
475}
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:295

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetWorldScreenMatrix(), m_gal, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::WX_VIEW_CONTROLS::handleAutoPanning(), ROUTER_TOOL::handleLayerSwitch(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), SetScale(), and KIGFX::WX_VIEW_CONTROLS::WarpMouseCursor().

◆ ToScreen() [2/2]

double KIGFX::VIEW::ToScreen ( double  aSize) const

Convert a world space one dimensional size to a one dimensional size in screen space.

Parameters
aSizethe size to be transformed.

Definition at line 478 of file view.cpp.

479{
480 const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
481
482 return matrix.GetScale().x * aSize;
483}

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetWorldScreenMatrix(), m_gal, and VECTOR2< T >::x.

◆ ToWorld() [1/2]

VECTOR2D KIGFX::VIEW::ToWorld ( const VECTOR2D aCoord,
bool  aAbsolute = true 
) const

Converts a screen space point/vector to a point/vector in world space coordinates.

Parameters
aCoordis the point/vector to be converted.
aAbsolutewhen true aCoord is treated as a point, otherwise as a direction (vector).

Definition at line 448 of file view.cpp.

449{
450 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
451
452 if( aAbsolute )
453 return VECTOR2D( matrix * aCoord );
454 else
455 return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
456}
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), m_gal, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EE_POINT_EDITOR::addCornerCondition(), COMMON_TOOLS::CenterContents(), COMMON_TOOLS::doZoomFit(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), EDIT_POINTS::FindPoint(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), PCB_BASE_FRAME::FocusOnItems(), GENERAL_COLLECTORS_GUIDE::GENERAL_COLLECTORS_GUIDE(), KIGFX::WX_VIEW_CONTROLS::GetMousePosition(), GetViewport(), DS_PROXY_VIEW_ITEM::HitTestDrawingSheetItems(), KIGFX::WX_VIEW_CONTROLS::onMotion(), KIGFX::WX_VIEW_CONTROLS::onScroll(), EDA_DRAW_PANEL_GAL::onSize(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), KIGFX::WX_VIEW_CONTROLS::PinCursorInsideNonAutoscrollArea(), Redraw(), KIGFX::WX_VIEW_CONTROLS::refreshMouse(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), ZOOM_TOOL::selectRegion(), SetCenter(), SetScale(), SetViewport(), EDIT_POINTS::ViewDraw(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), and PCB_SELECTION_TOOL::zoomFitSelection().

◆ ToWorld() [2/2]

double KIGFX::VIEW::ToWorld ( double  aSize) const

Converts a screen space one dimensional size to a one dimensional size in world space coordinates.

Parameters
aSizeis the size to be converted.

Definition at line 459 of file view.cpp.

460{
461 const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
462
463 return fabs( matrix.GetScale().x * aSize );
464}

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), m_gal, and VECTOR2< T >::x.

◆ Update() [1/2]

void KIGFX::VIEW::Update ( const VIEW_ITEM aItem) const
virtual

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 1585 of file view.cpp.

1586{
1587 Update( aItem, ALL );
1588}

References KIGFX::ALL, and Update().

◆ Update() [2/2]

void KIGFX::VIEW::Update ( const VIEW_ITEM aItem,
int  aUpdateFlags 
) const
virtual

For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has changed.

For static views calling has no effect.

Parameters
aItemthe item to update.
aUpdateFlagshow much the object has changed.

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 1591 of file view.cpp.

1592{
1593 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1594
1595 if( !viewData )
1596 return;
1597
1598 assert( aUpdateFlags != NONE );
1599
1600 viewData->m_requiredUpdate |= aUpdateFlags;
1601}
@ NONE
No updates are required.
Definition: view_item.h:46

References KIGFX::VIEW_ITEM_DATA::m_requiredUpdate, KIGFX::NONE, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by Add(), PNS_PCBNEW_DEBUG_DECORATOR::AddItem(), PNS_PCBNEW_DEBUG_DECORATOR::AddShape(), AddToPreview(), PCB_GRID_HELPER::BestSnapAnchor(), EE_GRID_HELPER::BestSnapAnchor(), SCH_EDIT_TOOL::ChangeTextType(), PNS_PCBNEW_DEBUG_DECORATOR::Clear(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::ClearConflicts(), ClearPreview(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EDIT_TOOL::DeleteItems(), PNS_KICAD_IFACE::DisplayItem(), PNS_KICAD_IFACE::DisplayRatline(), EDIT_TOOL::DragArcTrack(), draw(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), PAD_TOOL::EnumeratePads(), PNS_KICAD_IFACE::EraseView(), EE_INSPECTION_TOOL::ExcludeMarker(), DIALOG_ERC::ExcludeMarker(), Hide(), PNS_KICAD_IFACE::HideItem(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), PROPERTIES_FRAME::OnAcceptPrms(), DIALOG_ERC::OnERCItemRClick(), ZONE_CREATE_HELPER::OnGeometryChange(), PCB_POINT_EDITOR::OnSelectionChange(), KIGFX::VIEW::RECACHE_ITEM_VISITOR::operator()(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), DIALOG_CHANGE_SYMBOLS::processSymbol(), BOARD_COMMIT::Push(), SCH_EDIT_FRAME::RecalculateConnections(), DIALOG_PAD_PROPERTIES::redraw(), PCB_EDIT_FRAME::redrawNetnames(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), SCH_BASE_FRAME::RefreshZoomDependentItems(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SetVisible(), SCH_EDIT_FRAME::TestDanglingEnds(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), SCH_MOVE_TOOL::trimDanglingLines(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselectVisually(), Update(), KIGFX::PCB_VIEW::Update(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::UpdateConflicts(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::updateItem(), SCH_BASE_FRAME::UpdateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), and PCB_BASE_FRAME::UpdateUserUnits().

◆ UpdateAllItems()

◆ UpdateAllItemsConditionally() [1/2]

void KIGFX::VIEW::UpdateAllItemsConditionally ( int  aUpdateFlags,
std::function< bool(VIEW_ITEM *)>  aCondition 
)

Update items in the view according to the given flags and condition.

Parameters
aUpdateFlagsis is according to KIGFX::VIEW_UPDATE_FLAGS.
aConditionis a function returning true if the item should be updated.

Definition at line 1494 of file view.cpp.

1496{
1497 for( VIEW_ITEM* item : *m_allItems )
1498 {
1499 if( aCondition( item ) )
1500 {
1501 if( item->viewPrivData() )
1502 item->viewPrivData()->m_requiredUpdate |= aUpdateFlags;
1503 }
1504 }
1505}

References m_allItems.

Referenced by PCB_BASE_FRAME::CommonSettingsChanged(), GERBVIEW_CONTROL::DisplayControl(), PAD_TOOL::EditPad(), DIALOG_NET_INSPECTOR::onDeleteNet(), PCB_EDIT_FRAME::OnNetlistChanged(), BOARD_EDITOR_CONTROL::PageSettings(), SCH_EDIT_FRAME::RecalculateConnections(), ZONE_FILLER_TOOL::refresh(), PCB_EDIT_FRAME::SetActiveLayer(), PCB_BASE_FRAME::SetDisplayOptions(), GERBVIEW_FRAME::SetElementVisibility(), APPEARANCE_CONTROLS::setVisibleLayers(), and PCB_EDIT_FRAME::ShowBoardSetupDialog().

◆ UpdateAllItemsConditionally() [2/2]

void KIGFX::VIEW::UpdateAllItemsConditionally ( std::function< int(VIEW_ITEM *)>  aItemFlagsProvider)

Update items in the view according to the flags returned by the callback.

Parameters
aItemFlagsProvideris a function returning any KIGFX::VIEW_UPDATE_FLAGS that should be set on the VIEW_ITEM.

Definition at line 1508 of file view.cpp.

1509{
1510 for( VIEW_ITEM* item : *m_allItems )
1511 {
1512 if( item->viewPrivData() )
1513 item->viewPrivData()->m_requiredUpdate |= aItemFlagsProvider( item );
1514 }
1515}

References m_allItems.

◆ UpdateAllLayersColor()

void KIGFX::VIEW::UpdateAllLayersColor ( )

Apply the new coloring scheme to all layers.

The used scheme is held by #RENDER_SETTINGS.

See also
RENDER_SETTINGS

Definition at line 761 of file view.cpp.

762{
763 if( m_gal->IsVisible() )
764 {
765 GAL_UPDATE_CONTEXT ctx( m_gal );
766
767 for( VIEW_ITEM* item : *m_allItems )
768 {
769 VIEW_ITEM_DATA* viewData = item->viewPrivData();
770
771 if( !viewData )
772 continue;
773
774 int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
775 viewData->getLayers( layers, layers_count );
776
777 for( int i = 0; i < layers_count; ++i )
778 {
779 const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
780 int group = viewData->getGroup( layers[i] );
781
782 if( group >= 0 )
783 m_gal->ChangeGroupColor( group, color );
784 }
785 }
786 }
787
788 MarkDirty();
789}
int color
Definition: DXF_plotter.cpp:57
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Change the color used to draw the group.
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const =0
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...

References KIGFX::GAL::ChangeGroupColor(), color, KIGFX::RENDER_SETTINGS::GetColor(), KIGFX::VIEW_ITEM_DATA::getGroup(), KIGFX::VIEW_ITEM_DATA::getLayers(), KIGFX::PAINTER::GetSettings(), group, KIGFX::GAL::IsVisible(), m_allItems, m_gal, m_painter, MarkDirty(), and VIEW_MAX_LAYERS.

Referenced by DIALOG_NET_INSPECTOR::buildNetsList(), BOARD_INSPECTION_TOOL::ClearHighlight(), FOOTPRINT_EDIT_FRAME::CommonSettingsChanged(), PCB_SELECTION_TOOL::doSyncSelection(), EnableTopLayer(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), APPEARANCE_CONTROLS::onNetColorMode(), DIALOG_NET_INSPECTOR::onSelChanged(), DIALOG_NET_INSPECTOR::onSortingChanged(), NETS_SEARCH_HANDLER::SelectItems(), EDA_DRAW_PANEL_GAL::SetHighContrastLayer(), GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), and NET_GRID_TABLE::updateNetColor().

◆ UpdateAllLayersOrder()

void KIGFX::VIEW::UpdateAllLayersOrder ( )

Do everything that is needed to apply the rendering order of layers.

It has to be called after modification of renderingOrder field of LAYER.

Definition at line 892 of file view.cpp.

893{
894 sortLayers();
895
896 if( m_gal->IsVisible() )
897 {
898 GAL_UPDATE_CONTEXT ctx( m_gal );
899
900 for( VIEW_ITEM* item : *m_allItems )
901 {
902 VIEW_ITEM_DATA* viewData = item->viewPrivData();
903
904 if( !viewData )
905 continue;
906
907 int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
908 viewData->getLayers( layers, layers_count );
909
910 for( int i = 0; i < layers_count; ++i )
911 {
912 int group = viewData->getGroup( layers[i] );
913
914 if( group >= 0 )
915 m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
916 }
917 }
918 }
919
920 MarkDirty();
921}
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Change the depth (Z-axis position) of the group.

References KIGFX::GAL::ChangeGroupDepth(), KIGFX::VIEW_ITEM_DATA::getGroup(), KIGFX::VIEW_ITEM_DATA::getLayers(), group, KIGFX::GAL::IsVisible(), m_allItems, m_gal, m_layers, MarkDirty(), sortLayers(), and VIEW_MAX_LAYERS.

Referenced by EnableTopLayer(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), EDA_DRAW_PANEL_GAL::SetTopLayer(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PL_DRAW_PANEL_GAL::SetTopLayer(), and PCB_DRAW_PANEL_GAL::SetTopLayer().

◆ updateBbox()

void KIGFX::VIEW::updateBbox ( VIEW_ITEM aItem)
protected

Update set of layers that an item occupies.

Definition at line 1308 of file view.cpp.

1309{
1310 int layers[VIEW_MAX_LAYERS], layers_count;
1311
1312 aItem->ViewGetLayers( layers, layers_count );
1313
1314 for( int i = 0; i < layers_count; ++i )
1315 {
1316 VIEW_LAYER& l = m_layers[layers[i]];
1317 l.items->Remove( aItem );
1318 l.items->Insert( aItem );
1319 MarkTargetDirty( l.target );
1320 }
1321}

References KIGFX::VIEW::VIEW_LAYER::items, m_layers, MarkTargetDirty(), KIGFX::VIEW::VIEW_LAYER::target, VIEW_MAX_LAYERS, and KIGFX::VIEW_ITEM::ViewGetLayers().

Referenced by invalidateItem().

◆ updateItemColor()

void KIGFX::VIEW::updateItemColor ( VIEW_ITEM aItem,
int  aLayer 
)
protected

Update all information needed to draw an item.

Definition at line 1259 of file view.cpp.

1260{
1261 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1262 wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
1263 wxCHECK( IsCached( aLayer ), /*void*/ );
1264
1265 if( !viewData )
1266 return;
1267
1268 // Obtain the color that should be used for coloring the item on the specific layerId
1269 const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
1270 int group = viewData->getGroup( aLayer );
1271
1272 // Change the color, only if it has group assigned
1273 if( group >= 0 )
1274 m_gal->ChangeGroupColor( group, color );
1275}

References KIGFX::GAL::ChangeGroupColor(), color, KIGFX::RENDER_SETTINGS::GetColor(), KIGFX::VIEW_ITEM_DATA::getGroup(), KIGFX::PAINTER::GetSettings(), group, IsCached(), m_gal, m_layers, m_painter, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by invalidateItem().

◆ updateItemGeometry()

void KIGFX::VIEW::updateItemGeometry ( VIEW_ITEM aItem,
int  aLayer 
)
protected

Update bounding box of an item.

Definition at line 1278 of file view.cpp.

1279{
1280 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1281 wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
1282 wxCHECK( IsCached( aLayer ), /*void*/ );
1283
1284 if( !viewData )
1285 return;
1286
1287 VIEW_LAYER& l = m_layers.at( aLayer );
1288
1289 m_gal->SetTarget( l.target );
1290 m_gal->SetLayerDepth( l.renderingOrder );
1291
1292 // Redraw the item from scratch
1293 int group = viewData->getGroup( aLayer );
1294
1295 if( group >= 0 )
1296 m_gal->DeleteGroup( group );
1297
1298 group = m_gal->BeginGroup();
1299 viewData->setGroup( aLayer, group );
1300
1301 if( !m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ) )
1302 aItem->ViewDraw( aLayer, this ); // Alternative drawing method
1303
1304 m_gal->EndGroup();
1305}
virtual int BeginGroup()
Begin a group.
virtual void EndGroup()
End the group.

References KIGFX::GAL::BeginGroup(), KIGFX::GAL::DeleteGroup(), KIGFX::PAINTER::Draw(), KIGFX::GAL::EndGroup(), KIGFX::VIEW_ITEM_DATA::getGroup(), group, IsCached(), m_gal, m_layers, m_painter, KIGFX::VIEW::VIEW_LAYER::renderingOrder, KIGFX::VIEW_ITEM_DATA::setGroup(), KIGFX::GAL::SetLayerDepth(), KIGFX::GAL::SetTarget(), KIGFX::VIEW::VIEW_LAYER::target, KIGFX::VIEW_ITEM::ViewDraw(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by invalidateItem().

◆ UpdateItems()

void KIGFX::VIEW::UpdateItems ( )

Iterate through the list of items that asked for updating and updates them.

Definition at line 1401 of file view.cpp.

1402{
1403 if( !m_gal->IsVisible() )
1404 return;
1405
1406 unsigned int cntGeomUpdate = 0;
1407 bool anyUpdated = false;
1408
1409 for( VIEW_ITEM* item : *m_allItems )
1410 {
1411 auto vpd = item->viewPrivData();
1412
1413 if( !vpd )
1414 continue;
1415
1416 if( vpd->m_requiredUpdate != NONE )
1417 {
1418 anyUpdated = true;
1419
1420 if( vpd->m_requiredUpdate & ( GEOMETRY | LAYERS ) )
1421 {
1422 cntGeomUpdate++;
1423 }
1424 }
1425 }
1426
1427 unsigned int cntTotal = m_allItems->size();
1428
1429 double ratio = (double) cntGeomUpdate / (double) cntTotal;
1430
1431 // Optimization to improve view update time. If a lot of items (say, 30%) have their
1432 // bboxes/geometry changed it's way faster (around 10 times) to rebuild the R-Trees
1433 // from scratch rather than update the bbox of each changed item. Pcbnew does multiple
1434 // full geometry updates during file load, this can save a solid 30 seconds on load time
1435 // for larger designs...
1436
1437 if( ratio > 0.3 )
1438 {
1439 auto allItems = *m_allItems;
1440 int layers[VIEW_MAX_LAYERS], layers_count;
1441
1442 // kill all Rtrees
1443 for( VIEW_LAYER& layer : m_layers )
1444 layer.items->RemoveAll();
1445
1446 // and re-insert items from scratch
1447 for( VIEW_ITEM* item : allItems )
1448 {
1449 item->ViewGetLayers( layers, layers_count );
1450 item->viewPrivData()->saveLayers( layers, layers_count );
1451
1452 for( int i = 0; i < layers_count; ++i )
1453 {
1454 wxCHECK2_MSG( layers[i] >= 0 && static_cast<unsigned>( layers[i] ) < m_layers.size(),
1455 continue, wxS( "Invalid layer" ) );
1456 VIEW_LAYER& l = m_layers[layers[i]];
1457 l.items->Insert( item );
1458 MarkTargetDirty( l.target );
1459 }
1460
1461 item->viewPrivData()->m_requiredUpdate &= ~( LAYERS | GEOMETRY );
1462 }
1463 }
1464
1465 if( anyUpdated )
1466 {
1467 GAL_UPDATE_CONTEXT ctx( m_gal );
1468
1469 for( VIEW_ITEM* item : *m_allItems.get() )
1470 {
1471 if( item->viewPrivData() && item->viewPrivData()->m_requiredUpdate != NONE )
1472 {
1473 invalidateItem( item, item->viewPrivData()->m_requiredUpdate );
1474 item->viewPrivData()->m_requiredUpdate = NONE;
1475 }
1476 }
1477 }
1478
1479 KI_TRACE( traceGalProfile, wxS( "View update: total items %u, geom %u anyUpdated %u\n" ), cntTotal,
1480 cntGeomUpdate, (unsigned) anyUpdated );
1481}
void invalidateItem(VIEW_ITEM *aItem, int aUpdateFlags)
Manage dirty flags & redraw queuing when updating an item.
Definition: view.cpp:1202
#define KI_TRACE(aWhat,...)

References KIGFX::GEOMETRY, invalidateItem(), KIGFX::GAL::IsVisible(), KIGFX::VIEW::VIEW_LAYER::items, KI_TRACE, KIGFX::LAYERS, m_allItems, m_gal, m_layers, MarkTargetDirty(), KIGFX::NONE, KIGFX::VIEW::VIEW_LAYER::target, traceGalProfile, and VIEW_MAX_LAYERS.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint(), SELECTION_TOOL::doSelectionMenu(), SCH_DRAW_PANEL::OnShow(), PCB_DRAW_PANEL_GAL::OnShow(), ReorderLayerData(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ UpdateLayerColor()

void KIGFX::VIEW::UpdateLayerColor ( int  aLayer)

Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.

Parameters
aLayeris a number of the layer to be updated.
See also
RENDER_SETTINGS

Definition at line 740 of file view.cpp.

741{
742 // There is no point in updating non-cached layers
743 if( !IsCached( aLayer ) )
744 return;
745
746 BOX2I r;
747
748 r.SetMaximum();
749
750 if( m_gal->IsVisible() )
751 {
752 GAL_UPDATE_CONTEXT ctx( m_gal );
753
754 UPDATE_COLOR_VISITOR visitor( aLayer, m_painter, m_gal );
755 m_layers[aLayer].items->Query( r, visitor );
756 MarkTargetDirty( m_layers[aLayer].target );
757 }
758}

References IsCached(), KIGFX::GAL::IsVisible(), m_gal, m_layers, m_painter, MarkTargetDirty(), and BOX2< Vec >::SetMaximum().

Referenced by PCB_CONTROL::LayerAlphaDec(), PCB_CONTROL::LayerAlphaInc(), APPEARANCE_CONTROLS::OnColorSwatchChanged(), and GERBER_LAYER_WIDGET::OnLayerColorChange().

◆ updateLayers()

void KIGFX::VIEW::updateLayers ( VIEW_ITEM aItem)
protected

Determine rendering order of layers. Used in display order sorting function.

Definition at line 1324 of file view.cpp.

1325{
1326 VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1327 int layers[VIEW_MAX_LAYERS], layers_count;
1328
1329 if( !viewData )
1330 return;
1331
1332 // Remove the item from previous layer set
1333 viewData->getLayers( layers, layers_count );
1334
1335 for( int i = 0; i < layers_count; ++i )
1336 {
1337 VIEW_LAYER& l = m_layers[layers[i]];
1338 l.items->Remove( aItem );
1339 MarkTargetDirty( l.target );
1340
1341 if( IsCached( l.id ) )
1342 {
1343 // Redraw the item from scratch
1344 int prevGroup = viewData->getGroup( layers[i] );
1345
1346 if( prevGroup >= 0 )
1347 {
1348 m_gal->DeleteGroup( prevGroup );
1349 viewData->setGroup( l.id, -1 );
1350 }
1351 }
1352 }
1353
1354 // Add the item to new layer set
1355 aItem->ViewGetLayers( layers, layers_count );
1356 viewData->saveLayers( layers, layers_count );
1357
1358 for( int i = 0; i < layers_count; i++ )
1359 {
1360 VIEW_LAYER& l = m_layers[layers[i]];
1361 l.items->Insert( aItem );
1362 MarkTargetDirty( l.target );
1363 }
1364}

References KIGFX::GAL::DeleteGroup(), KIGFX::VIEW_ITEM_DATA::getGroup(), KIGFX::VIEW_ITEM_DATA::getLayers(), KIGFX::VIEW::VIEW_LAYER::id, IsCached(), KIGFX::VIEW::VIEW_LAYER::items, m_gal, m_layers, MarkTargetDirty(), KIGFX::VIEW_ITEM_DATA::saveLayers(), KIGFX::VIEW_ITEM_DATA::setGroup(), KIGFX::VIEW::VIEW_LAYER::target, VIEW_MAX_LAYERS, KIGFX::VIEW_ITEM::ViewGetLayers(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by invalidateItem().

◆ UseDrawPriority()

void KIGFX::VIEW::UseDrawPriority ( bool  aFlag)
inline
Parameters
aFlagis true if draw priority should be respected while redrawing.

Definition at line 695 of file view.h.

696 {
697 m_useDrawPriority = aFlag;
698 }

References m_useDrawPriority.

Friends And Related Function Documentation

◆ VIEW_ITEM

friend class VIEW_ITEM
friend

Definition at line 71 of file view.h.

Member Data Documentation

◆ m_allItems

std::shared_ptr<std::vector<VIEW_ITEM*> > KIGFX::VIEW::m_allItems
protected

◆ m_boundary

◆ m_center

VECTOR2D KIGFX::VIEW::m_center
protected

Definition at line 853 of file view.h.

Referenced by GetCenter(), SetCenter(), SetGAL(), and SetScale().

◆ m_dirtyTargets

bool KIGFX::VIEW::m_dirtyTargets[TARGETS_NUMBER]
protected

Flag to respect draw priority when drawing items.

Definition at line 874 of file view.h.

Referenced by IsTargetDirty(), MarkClean(), MarkDirty(), markTargetClean(), and MarkTargetDirty().

◆ m_dynamic

bool KIGFX::VIEW::m_dynamic
protected

Flag to mark targets as dirty so they have to be redrawn on the next refresh event.

Definition at line 871 of file view.h.

Referenced by IsDynamic().

◆ m_enableOrderModifier

bool KIGFX::VIEW::m_enableOrderModifier
protected

The set of possible displayed layers and its properties.

Definition at line 838 of file view.h.

Referenced by ClearTopLayers(), EnableTopLayer(), and SetTopLayer().

◆ m_gal

GAL* KIGFX::VIEW::m_gal
protected

◆ m_layers

◆ m_maxScale

double KIGFX::VIEW::m_maxScale
protected

Definition at line 858 of file view.h.

Referenced by SetScale(), and SetScaleLimits().

◆ m_minScale

double KIGFX::VIEW::m_minScale
protected

Definition at line 857 of file view.h.

Referenced by SetScale(), and SetScaleLimits().

◆ m_mirrorX

bool KIGFX::VIEW::m_mirrorX
protected

Definition at line 860 of file view.h.

Referenced by IsMirroredX(), SetGAL(), and SetMirror().

◆ m_mirrorY

bool KIGFX::VIEW::m_mirrorY
protected

PAINTER contains information how do draw items.

Definition at line 861 of file view.h.

Referenced by IsMirroredY(), SetGAL(), and SetMirror().

◆ m_nextDrawPriority

int KIGFX::VIEW::m_nextDrawPriority
protected

Flag to reverse the draw order when using draw priority.

Definition at line 880 of file view.h.

Referenced by Add(), and Clear().

◆ m_orderedLayers

std::vector<VIEW_LAYER*> KIGFX::VIEW::m_orderedLayers
protected

Flat list of all items.

Definition at line 844 of file view.h.

Referenced by Query(), redrawRect(), and sortLayers().

◆ m_ownedItems

std::vector<EDA_ITEM *> KIGFX::VIEW::m_ownedItems
protected

Whether to use rendering order modifier or not.

Definition at line 835 of file view.h.

Referenced by AddToPreview(), and ClearPreview().

◆ m_painter

PAINTER* KIGFX::VIEW::m_painter
protected

Interface to #PAINTER that is used to draw items.

Definition at line 864 of file view.h.

Referenced by draw(), GetPainter(), SetPainter(), UpdateAllLayersColor(), updateItemColor(), updateItemGeometry(), and UpdateLayerColor().

◆ m_preview

std::unique_ptr<KIGFX::VIEW_GROUP> KIGFX::VIEW::m_preview
protected

◆ m_reverseDrawOrder

bool KIGFX::VIEW::m_reverseDrawOrder
protected

Definition at line 883 of file view.h.

Referenced by redrawRect(), and ReverseDrawOrder().

◆ m_scale

double KIGFX::VIEW::m_scale
protected

Definition at line 855 of file view.h.

Referenced by GetScale(), KIGFX::VIEW::DRAW_ITEM_VISITOR::operator()(), SetGAL(), and SetScale().

◆ m_topLayers

std::set<unsigned int> KIGFX::VIEW::m_topLayers
protected

Center point of the VIEW (the point at which we are looking at).

Definition at line 850 of file view.h.

Referenced by ClearTopLayers(), EnableTopLayer(), GetTopLayer(), and SetTopLayer().

◆ m_useDrawPriority

bool KIGFX::VIEW::m_useDrawPriority
protected

The next sequential drawing priority.

Definition at line 877 of file view.h.

Referenced by IsUsingDrawPriority(), redrawRect(), and UseDrawPriority().

◆ TOP_LAYER_MODIFIER

constexpr int KIGFX::VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS
staticconstexpr

◆ VIEW_MAX_LAYERS


The documentation for this class was generated from the following files: