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...
 
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)
 
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...
 
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
 maximum number of layers that may be shown More...
 

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]
 Rendering order modifier for layers that are marked as top layers. 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
 

Static Protected Attributes

static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS
 Flag to respect draw priority when drawing items. More...
 

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 260 of file view.cpp.

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

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 314 of file view.cpp.

315 {
316  Remove( m_preview.get() );
317 }
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: view.h:813
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350

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 320 of file view.cpp.

321 {
322  int layers[VIEW_MAX_LAYERS], layers_count;
323 
324  if( aDrawPriority < 0 )
325  aDrawPriority = m_nextDrawPriority++;
326 
327  if( !aItem->m_viewPrivData )
328  aItem->m_viewPrivData = new VIEW_ITEM_DATA;
329 
330  aItem->m_viewPrivData->m_view = this;
331  aItem->m_viewPrivData->m_drawPriority = aDrawPriority;
332 
333  aItem->ViewGetLayers( layers, layers_count );
334  aItem->viewPrivData()->saveLayers( layers, layers_count );
335 
336  m_allItems->push_back( aItem );
337 
338  for( int i = 0; i < layers_count; ++i )
339  {
340  VIEW_LAYER& l = m_layers[layers[i]];
341  l.items->Insert( aItem );
342  MarkTargetDirty( l.target );
343  }
344 
345  SetVisible( aItem, true );
346  Update( aItem, KIGFX::INITIAL_ADD );
347 }
Item is being added to the view.
Definition: view_item.h:51
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
int m_nextDrawPriority
Flag to reverse the draw order when using draw priority.
Definition: view.h:864
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1516
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:1570

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(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), 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(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), 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(), BOARD_EDITOR_CONTROL::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), BOARD_COMMIT::Revert(), GERBVIEW_SELECTION_TOOL::select(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PCB_DRAW_PANEL_GAL::SetDrawingSheet(), GERBVIEW_DRAW_PANEL_GAL::SetDrawingSheet(), PNS_KICAD_IFACE::SetView(), PNS_PCBNEW_DEBUG_DECORATOR::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 1614 of file view.cpp.

1615 {
1616  Hide( aItem, false );
1617  m_preview->Add( aItem );
1618 
1619  if( aTakeOwnership )
1620  m_ownedItems.push_back( aItem );
1621 
1622  SetVisible( m_preview.get(), true );
1623  Hide( m_preview.get(), false );
1624  Update( m_preview.get() );
1625 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1537
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: view.h:813
std::vector< EDA_ITEM * > m_ownedItems
Whether to use rendering order modifier or not.
Definition: view.h:816
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1516
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:1570

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

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

◆ areRequiredLayersEnabled()

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

Definition at line 1368 of file view.cpp.

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

References m_layers.

Referenced by redrawRect().

◆ Clear()

void KIGFX::VIEW::Clear ( )

Remove all items from the view.

Definition at line 1100 of file view.cpp.

1101 {
1102  BOX2I r;
1103  r.SetMaximum();
1104  m_allItems->clear();
1105 
1106  for( VIEW_LAYER& layer : m_layers )
1107  layer.items->RemoveAll();
1108 
1109  m_nextDrawPriority = 0;
1110 
1111  m_gal->ClearCache();
1112 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
E_SERIE r
Definition: eserie.cpp:41
int m_nextDrawPriority
Flag to reverse the draw order when using draw priority.
Definition: view.h:864
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
virtual void ClearCache()
Delete all data created during caching of graphic items.

References KIGFX::GAL::ClearCache(), m_allItems, m_gal, m_layers, m_nextDrawPriority, and r.

Referenced by KIGFX::SCH_VIEW::Cleanup(), GERBVIEW_FRAME::Clear_DrawLayers(), PCB_DRAW_PANEL_GAL::DisplayBoard(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), SCH_DRAW_PANEL::DisplaySheet(), SCH_DRAW_PANEL::DisplaySymbol(), KIGFX::SCH_VIEW::DisplaySymbol(), GERBVIEW_FRAME::doCloseWindow(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), Refresh(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), DS_PROXY_UNDO_ITEM::Restore(), PCB_BASE_EDIT_FRAME::SetBoard(), SYMBOL_EDIT_FRAME::SetCurSymbol(), GERBVIEW_DRAW_PANEL_GAL::SwitchBackend(), DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME(), FOOTPRINT_PREVIEW_PANEL::~FOOTPRINT_PREVIEW_PANEL(), FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::~GERBVIEW_FRAME(), and PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME().

◆ clearGroupCache()

void KIGFX::VIEW::clearGroupCache ( )
protected

Definition at line 1191 of file view.cpp.

1192 {
1193  BOX2I r;
1194 
1195  r.SetMaximum();
1196  CLEAR_LAYER_CACHE_VISITOR visitor( this );
1197 
1198  for( VIEW_LAYER& layer : m_layers )
1199  layer.items->Query( r, visitor );
1200 }
E_SERIE r
Definition: eserie.cpp:41
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_layers, and r.

Referenced by SetGAL().

◆ ClearPreview()

void KIGFX::VIEW::ClearPreview ( )

Definition at line 1592 of file view.cpp.

1593 {
1594  if( !m_preview )
1595  return;
1596 
1597  m_preview->Clear();
1598 
1599  for( EDA_ITEM *item : m_ownedItems )
1600  delete item;
1601 
1602  m_ownedItems.clear();
1603  Update( m_preview.get() );
1604 }
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: view.h:813
std::vector< EDA_ITEM * > m_ownedItems
Whether to use rendering order modifier or not.
Definition: view.h:816
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
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:1570

References m_ownedItems, m_preview, and Update().

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

◆ ClearTargets()

void KIGFX::VIEW::ClearTargets ( )

Clear targets that are marked as dirty.

Definition at line 1115 of file view.cpp.

1116 {
1118  {
1119  // TARGET_CACHED and TARGET_NONCACHED have to be redrawn together, as they contain
1120  // layers that rely on each other (eg. netnames are noncached, but tracks - are cached)
1123 
1124  MarkDirty();
1125  }
1126 
1127  if( IsTargetDirty( TARGET_OVERLAY ) )
1128  {
1130  }
1131 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
Auxiliary rendering target (noncached)
Definition: definitions.h:49
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:598
virtual void ClearTarget(RENDER_TARGET aTarget)
Clear the target for rendering.
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
Main rendering target (cached)
Definition: definitions.h:48
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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 878 of file view.cpp.

879 {
880  std::set<unsigned int>::iterator it;
881 
883  {
884  // Restore the previous rendering order for layers that were marked as top
885  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
886  m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
887  }
888 
889  m_topLayers.clear();
890 }
static const int TOP_LAYER_MODIFIER
Flag to respect draw priority when drawing items.
Definition: view.h:858
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
Definition: view.h:831
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
bool m_enableOrderModifier
The set of possible displayed layers and its properties.
Definition: view.h:819

References m_enableOrderModifier, m_layers, m_topLayers, and TOP_LAYER_MODIFIER.

Referenced by GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PL_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and EDA_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 800 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 487 of file view.cpp.

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

◆ 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.

Definition at line 1506 of file view.cpp.

1507 {
1508  std::unique_ptr<VIEW> ret = std::make_unique<VIEW>();
1509  ret->m_allItems = m_allItems;
1510  ret->m_layers = m_layers;
1511  ret->sortLayers();
1512  return ret;
1513 }
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_allItems, and m_layers.

Referenced by BOARD_PRINTOUT::DrawPage().

◆ draw() [1/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 1016 of file view.cpp.

1017 {
1018  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1019 
1020  if( !viewData )
1021  return;
1022 
1023  if( IsCached( aLayer ) && !aImmediate )
1024  {
1025  // Draw using cached information or create one
1026  int group = viewData->getGroup( aLayer );
1027 
1028  if( group >= 0 )
1029  m_gal->DrawGroup( group );
1030  else
1031  Update( aItem );
1032  }
1033  else
1034  {
1035  // Immediate mode
1036  if( !m_painter->Draw( aItem, aLayer ) )
1037  aItem->ViewDraw( aLayer, this ); // Alternative drawing method
1038  }
1039 }
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845
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:616
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:1570

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()().

◆ 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 1042 of file view.cpp.

1043 {
1044  int layers[VIEW_MAX_LAYERS], layers_count;
1045 
1046  aItem->ViewGetLayers( layers, layers_count );
1047 
1048  // Sorting is needed for drawing order dependent GALs (like Cairo)
1049  SortLayers( layers, layers_count );
1050 
1051  for( int i = 0; i < layers_count; ++i )
1052  {
1053  m_gal->SetLayerDepth( m_layers.at( layers[i] ).renderingOrder );
1054  draw( aItem, layers[i], aImmediate );
1055  }
1056 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
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:649
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Draw an item, but on a specified layers.
Definition: view.cpp:1016

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_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 1059 of file view.cpp.

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

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

◆ 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 853 of file view.cpp.

854 {
855  if( aEnable == m_enableOrderModifier )
856  return;
857 
858  m_enableOrderModifier = aEnable;
859 
860  std::set<unsigned int>::iterator it;
861 
862  if( aEnable )
863  {
864  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
865  m_layers[*it].renderingOrder += TOP_LAYER_MODIFIER;
866  }
867  else
868  {
869  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
870  m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
871  }
872 
875 }
static const int TOP_LAYER_MODIFIER
Flag to respect draw priority when drawing items.
Definition: view.h:858
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
Definition: view.h:831
void UpdateAllLayersOrder()
Do everything that is needed to apply the rendering order of layers.
Definition: view.cpp:893
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
bool m_enableOrderModifier
The set of possible displayed layers and its properties.
Definition: view.h:819
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:762

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 293 of file view.h.

294  {
295  return m_boundary;
296  }
BOX2D m_boundary
Definition: view.h:837

References m_boundary.

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

◆ GetCenter()

const VECTOR2D& KIGFX::VIEW::GetCenter ( ) const
inline

Return the center point of this VIEW (in world space coordinates).

Returns
center point of the view

Definition at line 334 of file view.h.

335  {
336  return m_center;
337  }
VECTOR2D m_center
Definition: view.h:834

References m_center.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint(), KIGFX::WX_VIEW_CONTROLS::onButton(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), and SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor().

◆ 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 190 of file view.h.

191  {
192  return m_gal;
193  }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848

References m_gal.

Referenced by PCB_GRID_HELPER::BestDragOrigin(), EE_GRID_HELPER::BestDragOrigin(), PCB_GRID_HELPER::BestSnapAnchor(), GRID_HELPER::canUseGrid(), KIGFX::WX_VIEW_CONTROLS::CenterOnCursor(), 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(), ROUTER_TOOL::handleCommonEvents(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), COMMON_TOOLS::PanControl(), DIALOG_PAD_PROPERTIES::prepareCanvas(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::TOOL_BASE::updateEndItem(), PNS::TOOL_BASE::updateStartItem(), RATSNEST_VIEW_ITEM::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), KIGFX::PREVIEW::TWO_POINT_ASSISTANT::ViewDraw(), KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM::ViewDraw(), MY_DRAWING::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), KIGFX::PREVIEW::SELECTION_AREA::ViewDraw(), ROUTER_PREVIEW_ITEM::ViewDraw(), DS_PROXY_VIEW_ITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), and KIGFX::WX_VIEW_CONTROLS::WarpCursor().

◆ 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 643 of file view.cpp.

644 {
645  return m_layers.at( aLayer ).renderingOrder;
646 }
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

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 208 of file view.h.

209  {
210  return m_painter;
211  }
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845

References m_painter.

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), DS_PROXY_VIEW_ITEM::buildDrawList(), DIALOG_NET_INSPECTOR::buildNetsList(), BOARD_INSPECTION_TOOL::ClearHighlight(), PL_EDITOR_FRAME::CommonSettingsChanged(), PCB_BASE_FRAME::CommonSettingsChanged(), PCB_GRID_HELPER::computeAnchors(), PL_DRAW_PANEL_GAL::DisplayDrawingSheet(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), BOARD_INSPECTION_TOOL::doHideNet(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), KIGFX::PREVIEW::DrawTextNextToCursor(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), FOOTPRINT_PREVIEW_PANEL::GetBackgroundColor(), FOOTPRINT_PREVIEW_PANEL::GetForegroundColor(), ROUTER_PREVIEW_ITEM::getLayerColor(), BOARD_INSPECTION_TOOL::HighlightNet(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PNS_KICAD_IFACE::IsItemVisible(), PCB_BASE_FRAME::LoadSettings(), DIALOG_PAD_PROPERTIES::onChangePadMode(), ZONE_CREATE_HELPER::OnFirstPoint(), APPEARANCE_CONTROLS::OnLayerAlphaChanged(), GERBER_LAYER_WIDGET::OnLayerColorChange(), GERBER_LAYER_WIDGET::OnLayerSelect(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), DIALOG_NET_INSPECTOR::onSelChanged(), GERBVIEW_DRAW_PANEL_GAL::OnShow(), 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(), GERBVIEW_SELECTION_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Selectable(), GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), EDA_DRAW_PANEL_GAL::SetHighContrastLayer(), PCBNEW_PRINTOUT::setupViewLayers(), SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET(), PANEL_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_EDIT_OPTIONS::TransferDataFromWindow(), PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow(), PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow(), PCB_DRAW_PANEL_GAL::UpdateColors(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), NET_GRID_TABLE::updateNetColor(), PANEL_PCBNEW_COLOR_SETTINGS::updatePreview(), PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview(), RATSNEST_VIEW_ITEM::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), KIGFX::PREVIEW::SELECTION_AREA::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), DS_PROXY_VIEW_ITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), PCB_TRACK::ViewGetLOD(), FP_TEXT::ViewGetLOD(), PCB_VIA::ViewGetLOD(), and PAD::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 1167 of file view.cpp.

1168 {
1169  return m_gal->GetScreenPixelSize();
1170 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
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(), and KIGFX::WX_VIEW_CONTROLS::onWheel().

◆ GetTopLayer()

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

Definition at line 817 of file view.cpp.

818 {
819  if( m_topLayers.size() == 0 )
820  return 0;
821 
822  return *m_topLayers.begin();
823 }
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
Definition: view.h:831

References m_topLayers.

Referenced by ROUTER_TOOL::getStartLayer(), 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 512 of file view.cpp.

513 {
514  BOX2D rect;
515  VECTOR2D screenSize = m_gal->GetScreenPixelSize();
516 
517  rect.SetOrigin( ToWorld( VECTOR2D( 0, 0 ) ) );
518  rect.SetEnd( ToWorld( screenSize ) );
519 
520  return rect.Normalize();
521 }
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:449
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
BOX2< Vec > & Normalize()
Ensure that the height ant width are positive.
Definition: box2.h:112
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:207
void SetOrigin(const Vec &pos)
Definition: box2.h:193

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

Referenced by drawBacksideTicks(), drawTicksAlongLine(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), PCB_BASE_FRAME::FocusOnItem(), EDA_DRAW_FRAME::FocusOnLocation(), PCB_SELECTION_TOOL::hitTestDistance(), and KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars().

◆ 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 1537 of file view.cpp.

1538 {
1539  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1540 
1541  if( !viewData )
1542  return;
1543 
1544  if( !( viewData->m_flags & VISIBLE ) )
1545  return;
1546 
1547  if( aHide )
1548  viewData->m_flags |= HIDDEN;
1549  else
1550  viewData->m_flags &= ~HIDDEN;
1551 
1552  Update( aItem, APPEARANCE );
1553 }
Item is temporarily hidden (e.g.
Definition: view_item.h:61
Visibility flag has changed.
Definition: view_item.h:47
Item is visible (in general)
Definition: view_item.h:60
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:1570

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(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), 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()

void KIGFX::VIEW::InitPreview ( )

Definition at line 1607 of file view.cpp.

1608 {
1609  m_preview.reset( new KIGFX::VIEW_GROUP() );
1610  Add( m_preview.get() );
1611 }
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: view.h:813
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:46
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:320

References Add(), and m_preview.

Referenced by KIGFX::SCH_VIEW::DisplaySheet(), KIGFX::SCH_VIEW::DisplaySymbol(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), Refresh(), and PCB_BASE_EDIT_FRAME::SetBoard().

◆ 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 1203 of file view.cpp.

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

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 616 of file view.h.

617  {
618  wxCHECK( aLayer < (int) m_layers.size(), false );
619 
620  try
621  {
622  return m_layers.at( aLayer ).target == TARGET_CACHED;
623  }
624  catch( const std::out_of_range& )
625  {
626  return false;
627  }
628  }
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
Main rendering target (cached)
Definition: definitions.h:48

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 581 of file view.h.

582  {
583  for( int i = 0; i < TARGETS_NUMBER; ++i )
584  {
585  if( IsTargetDirty( i ) )
586  return true;
587  }
588 
589  return false;
590  }
Number of available rendering targets.
Definition: definitions.h:52
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:598

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 571 of file view.h.

572  {
573  return m_dynamic;
574  }
bool m_dynamic
Flag to mark targets as dirty so they have to be redrawn on the next refresh event.
Definition: view.h:852

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 246 of file view.h.

247  {
248  return m_mirrorY;
249  }
bool m_mirrorY
PAINTER contains information how do draw items.
Definition: view.h:842

References m_mirrorY.

◆ 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 598 of file view.h.

599  {
600  wxCHECK( aTarget < TARGETS_NUMBER, false );
601  return m_dirtyTargets[aTarget];
602  }
Number of available rendering targets.
Definition: definitions.h:52
bool m_dirtyTargets[TARGETS_NUMBER]
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855

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 672 of file view.h.

673  {
674  return m_useDrawPriority;
675  }
bool m_useDrawPriority
The next sequential drawing priority.
Definition: view.h:861

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 1556 of file view.cpp.

1557 {
1558  const VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1559 
1560  return viewData && ( viewData->m_flags & VISIBLE );
1561 }
Item is visible (in general)
Definition: view_item.h:60

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

Referenced by EE_GRID_HELPER::BestSnapAnchor(), PCB_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 1583 of file view.cpp.

1584 {
1585  std::shared_ptr<VIEW_OVERLAY> overlay( new VIEW_OVERLAY );
1586 
1587  Add( overlay.get() );
1588  return overlay;
1589 }
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay
Definition: playground.cpp:36
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:320

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 642 of file view.h.

643  {
644  for( int i = 0; i < TARGETS_NUMBER; ++i )
645  m_dirtyTargets[i] = false;
646  }
Number of available rendering targets.
Definition: definitions.h:52
bool m_dirtyTargets[TARGETS_NUMBER]
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855

References m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

Referenced by Redraw().

◆ MarkDirty()

void KIGFX::VIEW::MarkDirty ( )
inline

Force redraw of view on the next rendering.

Definition at line 633 of file view.h.

634  {
635  for( int i = 0; i < TARGETS_NUMBER; ++i )
636  m_dirtyTargets[i] = true;
637  }
Number of available rendering targets.
Definition: definitions.h:52
bool m_dirtyTargets[TARGETS_NUMBER]
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855

References m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

Referenced by ClearTargets(), EDA_DRAW_PANEL_GAL::DoRePaint(), BOARD_EDITOR_CONTROL::DoSetDrillOrigin(), PCB_CONTROL::DoSetGridOrigin(), EDA_DRAW_FRAME::OnMove(), refreshCallback(), SetCenter(), SetGAL(), SetMirror(), SetScale(), SCH_EDIT_FRAME::ShowSchematicSetupDialog(), sortLayers(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), UpdateAllLayersColor(), UpdateAllLayersOrder(), and VIEW().

◆ markTargetClean()

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

Definition at line 735 of file view.h.

736  {
737  wxCHECK( aTarget < TARGETS_NUMBER, /* void */ );
738  m_dirtyTargets[aTarget] = false;
739  }
Number of available rendering targets.
Definition: definitions.h:52
bool m_dirtyTargets[TARGETS_NUMBER]
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855

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 245 of file view.cpp.

246 {
247  VIEW_ITEM_DATA* data = aItem->viewPrivData();
248 
249  if( !data )
250  return;
251 
252  if( data->m_view )
253  data->m_view->VIEW::Remove( aItem );
254 
255  delete data;
256  aItem->ClearViewPrivData();
257 }

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 426 of file view.cpp.

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

References m_orderedLayers.

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

◆ RecacheAllItems()

void KIGFX::VIEW::RecacheAllItems ( )

Rebuild GAL display lists.

Definition at line 1385 of file view.cpp.

1386 {
1387  BOX2I r;
1388 
1389  r.SetMaximum();
1390 
1391  for( const VIEW_LAYER& l : m_layers )
1392  {
1393  if( IsCached( l.id ) )
1394  {
1395  RECACHE_ITEM_VISITOR visitor( this, m_gal, l.id );
1396  l.items->Query( r, visitor );
1397  }
1398  }
1399 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
E_SERIE r
Definition: eserie.cpp:41
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
bool IsCached(int aLayer) const
Return true if the layer is cached.
Definition: view.h:616

References IsCached(), m_gal, m_layers, and r.

Referenced by GERBVIEW_FRAME::ActivateGalCanvas(), PCB_BASE_FRAME::ActivateGalCanvas(), PCB_CONTROL::FlipPcbView(), SCH_EDIT_TOOL::Mirror(), GERBVIEW_DRAW_PANEL_GAL::OnShow(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), SCH_EDIT_TOOL::Properties(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::Rotate(), and PANEL_GAL_DISPLAY_OPTIONS::TransferDataFromWindow().

◆ Redraw()

void KIGFX::VIEW::Redraw ( )
virtual

Immediately redraws the whole view.

Definition at line 1134 of file view.cpp.

1135 {
1136 #ifdef KICAD_GAL_PROFILE
1137  PROF_COUNTER totalRealTime;
1138 #endif /* KICAD_GAL_PROFILE */
1139 
1140  VECTOR2D screenSize = m_gal->GetScreenPixelSize();
1141  BOX2D rect( ToWorld( VECTOR2D( 0, 0 ) ),
1142  ToWorld( screenSize ) - ToWorld( VECTOR2D( 0, 0 ) ) );
1143 
1144  rect.Normalize();
1145  BOX2I recti( rect.GetPosition(), rect.GetSize() );
1146 
1147  // The view rtree uses integer positions. Large screens can overflow this size so in
1148  // this case, simply set the rectangle to the full rtree.
1149  if( rect.GetWidth() > std::numeric_limits<int>::max()
1150  || rect.GetHeight() > std::numeric_limits<int>::max() )
1151  {
1152  recti.SetMaximum();
1153  }
1154 
1155  redrawRect( recti );
1156 
1157  // All targets were redrawn, so nothing is dirty
1158  MarkClean();
1159 
1160 #ifdef KICAD_GAL_PROFILE
1161  totalRealTime.Stop();
1162  wxLogTrace( traceGalProfile, "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
1163 #endif /* KICAD_GAL_PROFILE */
1164 }
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:449
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
A thread-safe event counter.
Definition: profile.h:225
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
void SetMaximum()
Definition: box2.h:57
void redrawRect(const BOX2I &aRect)
Definition: view.cpp:983
void MarkClean()
Force redraw of view on the next rendering.
Definition: view.h:642

References BOX2< Vec >::GetHeight(), BOX2< Vec >::GetPosition(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetSize(), BOX2< Vec >::GetWidth(), m_gal, MarkClean(), BOX2< Vec >::Normalize(), redrawRect(), BOX2< Vec >::SetMaximum(), 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 983 of file view.cpp.

984 {
985  for( VIEW_LAYER* l : m_orderedLayers )
986  {
987  if( l->visible && IsTargetDirty( l->target ) && areRequiredLayersEnabled( l->id ) )
988  {
989  DRAW_ITEM_VISITOR drawFunc( this, l->id, m_useDrawPriority, m_reverseDrawOrder );
990 
991  m_gal->SetTarget( l->target );
992  m_gal->SetLayerDepth( l->renderingOrder );
993 
994  // Differential layer also work for the negatives, since both special layer types
995  // will composite on separate layers (at least in Cairo)
996  if( l->diffLayer )
998  else if( l->hasNegatives )
1000 
1001 
1002  l->items->Query( aRect, drawFunc );
1003 
1004  if( m_useDrawPriority )
1005  drawFunc.deferredDraw();
1006 
1007  if( l->diffLayer )
1008  m_gal->EndDiffLayer();
1009  else if( l->hasNegatives )
1011  }
1012  }
1013 }
bool m_useDrawPriority
The next sequential drawing priority.
Definition: view.h:861
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
bool areRequiredLayersEnabled(int aLayerId) const
Definition: view.cpp:1368
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void EndDiffLayer()
Ends rendering of a differential layer.
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:598
virtual void StartNegativesLayer()
Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().
bool m_reverseDrawOrder
Definition: view.h:867
virtual void StartDiffLayer()
Begins rendering of a differential layer.
std::vector< VIEW_LAYER * > m_orderedLayers
Flat list of all items.
Definition: view.h:825
virtual void EndNegativesLayer()
Ends rendering of a negatives layer and draws it to the main layer.
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 350 of file view.cpp.

351 {
352  if( !aItem )
353  return;
354 
355  auto viewData = aItem->viewPrivData();
356 
357  if( !viewData )
358  return;
359 
360  wxCHECK( viewData->m_view == this, /*void*/ );
361  auto item = std::find( m_allItems->begin(), m_allItems->end(), aItem );
362 
363  if( item != m_allItems->end() )
364  {
365  m_allItems->erase( item );
366  viewData->clearUpdateFlags();
367  }
368 
369  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
370  viewData->getLayers( layers, layers_count );
371 
372  for( int i = 0; i < layers_count; ++i )
373  {
374  VIEW_LAYER& l = m_layers[layers[i]];
375  l.items->Remove( aItem );
376  MarkTargetDirty( l.target );
377 
378  // Clear the GAL cache
379  int prevGroup = viewData->getGroup( layers[i] );
380 
381  if( prevGroup >= 0 )
382  m_gal->DeleteGroup( prevGroup );
383  }
384 
385  viewData->deleteGroups();
386  viewData->m_view = nullptr;
387 }
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

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(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), PL_EDIT_TOOL::DoDelete(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), 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(), EDIT_TOOL::Remove(), SCH_BASE_FRAME::RemoveFromScreen(), BOARD_EDITOR_CONTROL::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), BOARD_COMMIT::Revert(), PL_SELECTION_TOOL::selectMultiple(), EE_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 677 of file view.cpp.

678 {
679  std::vector<VIEW_LAYER> new_map;
680  new_map.reserve( m_layers.size() );
681 
682  for( const VIEW_LAYER& layer : m_layers )
683  new_map.push_back( layer );
684 
685  for( auto& pair : aReorderMap )
686  {
687  new_map[pair.second] = m_layers[pair.first];
688  new_map[pair.second].id = pair.second;
689  }
690 
691  m_layers = new_map;
692 
693  for( VIEW_ITEM* item : *m_allItems )
694  {
695  VIEW_ITEM_DATA* viewData = item->viewPrivData();
696 
697  if( !viewData )
698  continue;
699 
700  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
701 
702  item->ViewGetLayers( layers, layers_count );
703  viewData->saveLayers( layers, layers_count );
704 
705  viewData->reorderGroups( aReorderMap );
706 
707  viewData->m_requiredUpdate |= COLOR;
708  }
709 
710  UpdateItems();
711 }
friend class VIEW_ITEM
Definition: view.h:71
Color has changed.
Definition: view_item.h:48
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1402
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

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::SortLayersByX2Attributes().

◆ 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 690 of file view.h.

691  {
692  m_reverseDrawOrder = aFlag;
693  }
bool m_reverseDrawOrder
Definition: view.h:867

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 274 of file view.h.

275  {
276  m_boundary = aBoundary;
277  }
BOX2D m_boundary
Definition: view.h:837

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 284 of file view.h.

285  {
286  m_boundary.SetOrigin( aBoundary.GetOrigin() );
287  m_boundary.SetEnd( aBoundary.GetEnd() );
288  }
const Vec GetEnd() const
Definition: box2.h:178
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:207
BOX2D m_boundary
Definition: view.h:837
void SetOrigin(const Vec &pos)
Definition: box2.h:193
const Vec & GetOrigin() const
Definition: box2.h:176

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 578 of file view.cpp.

579 {
580  m_center = aCenter;
581 
582  if( !m_boundary.Contains( aCenter ) )
583  {
584  if( m_center.x < m_boundary.GetLeft() )
586  else if( aCenter.x > m_boundary.GetRight() )
588 
589  if( m_center.y < m_boundary.GetTop() )
591  else if( m_center.y > m_boundary.GetBottom() )
593  }
594 
597 
598  // Redraw everything after the viewport has changed
599  MarkDirty();
600 }
coord_type GetTop() const
Definition: box2.h:187
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
coord_type GetRight() const
Definition: box2.h:182
coord_type GetBottom() const
Definition: box2.h:183
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
VECTOR2D m_center
Definition: view.h:834
bool Contains(const Vec &aPoint) const
Definition: box2.h:134
BOX2D m_boundary
Definition: view.h:837
void SetLookAtPoint(const VECTOR2D &aPoint)
Set the Point in world space to look at.
coord_type GetLeft() const
Definition: box2.h:186
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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(), SCH_BASE_FRAME::CenterScreen(), 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(), SetCenter(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), SetGAL(), SetScale(), SetViewport(), KIGFX::WX_VIEW_CONTROLS::WarpCursor(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), PANEL_EESCHEMA_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 603 of file view.cpp.

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

References BOX2< Vec >::GetHeight(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetWidth(), 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 493 of file view.cpp.

494 {
495  bool recacheGroups = ( m_gal != nullptr ); // recache groups only if GAL is reassigned
496  m_gal = aGal;
497 
498  // clear group numbers, so everything is going to be recached
499  if( recacheGroups )
500  clearGroupCache();
501 
502  // every target has to be refreshed
503  MarkDirty();
504 
505  // force the new GAL to display the current viewport.
506  SetCenter( m_center );
507  SetScale( m_scale );
509 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
Definition: view.cpp:539
VECTOR2D m_center
Definition: view.h:834
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
bool m_mirrorX
Definition: view.h:841
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:552
void clearGroupCache()
Definition: view.cpp:1191
bool m_mirrorY
PAINTER contains information how do draw items.
Definition: view.h:842
double m_scale
Definition: view.h:836
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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 419 of file view.h.

420  {
421  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
422 
423  if( m_layers[aLayer].diffLayer != aDiff )
424  {
425  // Target has to be redrawn after changing its layers' diff status
426  MarkTargetDirty( m_layers[aLayer].target );
427  m_layers[aLayer].diffLayer = aDiff;
428  }
429  }
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_layers, and MarkTargetDirty().

Referenced by GERBVIEW_FRAME::UpdateDiffLayers().

◆ SetLayerDisplayOnly()

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

Definition at line 449 of file view.h.

450  {
451  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
452  m_layers[aLayer].displayOnly = aDisplayOnly;
453  }
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_layers.

Referenced by PL_DRAW_PANEL_GAL::setDefaultLayerDeps(), SCH_DRAW_PANEL::setDefaultLayerDeps(), SCH_PREVIEW_PANEL::setDefaultLayerDeps(), GERBVIEW_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 437 of file view.h.

438  {
439  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
440 
441  if( m_layers[aLayer].hasNegatives != aNegatives )
442  {
443  // Target has to be redrawn after changing a layers' negatives
444  MarkTargetDirty( m_layers[aLayer].target );
445  m_layers[aLayer].hasNegatives = aNegatives;
446  }
447  }
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_layers, and MarkTargetDirty().

Referenced by GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles(), and 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 635 of file view.cpp.

636 {
637  m_layers[aLayer].renderingOrder = aRenderingOrder;
638 
639  sortLayers();
640 }
void sortLayers()
Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL)
Definition: view.cpp:1245
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

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 461 of file view.h.

462  {
463  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
464  m_layers[aLayer].target = aTarget;
465  }
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_layers.

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

◆ SetLayerVisible()

void KIGFX::VIEW::SetLayerVisible ( int  aLayer,
bool  aVisible = true 
)
inline

Control the visibility of a particular layer.

Parameters
aLayeris the layer to show/hide.
aVisibleis the layer visibility state.

Definition at line 388 of file view.h.

389  {
390  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
391 
392  if( m_layers[aLayer].visible != aVisible )
393  {
394  // Target has to be redrawn after changing its visibility
395  MarkTargetDirty( m_layers[aLayer].target );
396  m_layers[aLayer].visible = aVisible;
397  }
398  }
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

References m_layers, and MarkTargetDirty().

Referenced by APPEARANCE_CONTROLS::onLayerVisibilityChanged(), APPEARANCE_CONTROLS::onObjectVisibilityChanged(), GERBER_LAYER_WIDGET::OnRenderEnable(), PL_EDITOR_FRAME::OnSelectPage(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), GERBVIEW_FRAME::SetElementVisibility(), APPEARANCE_CONTROLS::SetLayerVisible(), APPEARANCE_CONTROLS::SetObjectVisible(), GERBVIEW_PRINTOUT::setupViewLayers(), PCBNEW_PRINTOUT::setupViewLayers(), BOARD_PRINTOUT::setupViewLayers(), GERBVIEW_FRAME::SetVisibleLayers(), APPEARANCE_CONTROLS::setVisibleLayers(), APPEARANCE_CONTROLS::setVisibleObjects(), PCB_DRAW_PANEL_GAL::SyncLayersVisibility(), and PCB_EDIT_FRAME::UpdateUserInterface().

◆ 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 539 of file view.cpp.

540 {
541  wxASSERT_MSG( !aMirrorY, _( "Mirroring for Y axis is not supported yet" ) );
542 
543  m_mirrorX = aMirrorX;
544  m_mirrorY = aMirrorY;
545  m_gal->SetFlip( aMirrorX, aMirrorY );
546 
547  // Redraw everything
548  MarkDirty();
549 }
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
bool m_mirrorX
Definition: view.h:841
#define _(s)
bool m_mirrorY
PAINTER contains information how do draw items.
Definition: view.h:842
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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 198 of file view.h.

199  {
200  m_painter = aPainter;
201  }
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845

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 390 of file view.cpp.

391 {
392  wxCHECK( (unsigned) aLayerId < m_layers.size(), /*void*/ );
393  wxCHECK( (unsigned) aRequiredId < m_layers.size(), /*void*/ );
394 
395  if( aRequired )
396  m_layers[aLayerId].requiredLayers.insert( aRequiredId );
397  else
398  m_layers[aLayerId].requiredLayers.erase( aRequired );
399 }
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

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 552 of file view.cpp.

553 {
554  if( aAnchor == VECTOR2D( 0, 0 ) )
555  aAnchor = m_center;
556 
557  VECTOR2D a = ToScreen( aAnchor );
558 
559  if( aScale < m_minScale )
561  else if( aScale > m_maxScale )
563  else
564  m_scale = aScale;
565 
568 
569  VECTOR2D delta = ToWorld( a ) - aAnchor;
570 
571  SetCenter( m_center - delta );
572 
573  // Redraw everything after the viewport has changed
574  MarkDirty();
575 }
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:449
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
VECTOR2D m_center
Definition: view.h:834
double m_minScale
Definition: view.h:838
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
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:468
double m_maxScale
Definition: view.h:839
void SetZoomFactor(double aZoomFactor)
Set the zoom factor of the scene.
double m_scale
Definition: view.h:836
constexpr int delta
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), KIGFX::WX_VIEW_CONTROLS::onMotion(), KIGFX::WX_VIEW_CONTROLS::onWheel(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), ZOOM_TOOL::selectRegion(), SetGAL(), KIGFX::SCH_VIEW::SetScale(), SetViewport(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), PANEL_EESCHEMA_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 304 of file view.h.

305  {
306  wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
307 
308  m_minScale = aMinimum;
309  m_maxScale = aMaximum;
310  }
double m_minScale
Definition: view.h:838
double m_maxScale
Definition: view.h:839

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 826 of file view.cpp.

827 {
828  if( aEnabled )
829  {
830  if( m_topLayers.count( aLayer ) == 1 )
831  return;
832 
833  m_topLayers.insert( aLayer );
834 
835  // Move the layer closer to front
837  m_layers[aLayer].renderingOrder += TOP_LAYER_MODIFIER;
838  }
839  else
840  {
841  if( m_topLayers.count( aLayer ) == 0 )
842  return;
843 
844  m_topLayers.erase( aLayer );
845 
846  // Restore the previous rendering order
848  m_layers[aLayer].renderingOrder -= TOP_LAYER_MODIFIER;
849  }
850 }
static const int TOP_LAYER_MODIFIER
Flag to respect draw priority when drawing items.
Definition: view.h:858
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
Definition: view.h:831
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
bool m_enableOrderModifier
The set of possible displayed layers and its properties.
Definition: view.h:819

References m_enableOrderModifier, m_layers, m_topLayers, and TOP_LAYER_MODIFIER.

Referenced by DIALOG_PAD_PROPERTIES::redraw(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PL_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), EDA_DRAW_PANEL_GAL::SetTopLayer(), PCBNEW_PRINTOUT::setupViewLayers(), and BOARD_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 524 of file view.cpp.

525 {
526  VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
527 
528  wxCHECK( ssize.x > 0 && ssize.y > 0, /*void*/ );
529 
530  VECTOR2D centre = aViewport.Centre();
531  VECTOR2D vsize = aViewport.GetSize();
532  double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
533 
534  SetCenter( centre );
535  SetScale( GetScale() * zoom );
536 }
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:449
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:552
Vec Centre() const
Definition: box2.h:63
const Vec & GetSize() const
Definition: box2.h:172
double GetScale() const
Definition: view.h:264

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 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 1516 of file view.cpp.

1517 {
1518  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1519 
1520  if( !viewData )
1521  return;
1522 
1523  bool cur_visible = viewData->m_flags & VISIBLE;
1524 
1525  if( cur_visible != aIsVisible )
1526  {
1527  if( aIsVisible )
1528  viewData->m_flags |= VISIBLE;
1529  else
1530  viewData->m_flags &= ~VISIBLE;
1531 
1532  Update( aItem, APPEARANCE | COLOR );
1533  }
1534 }
Visibility flag has changed.
Definition: view_item.h:47
Color has changed.
Definition: view_item.h:48
Item is visible (in general)
Definition: view_item.h:60
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:1570

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

Referenced by Add(), AddToPreview(), EE_GRID_HELPER::BestSnapAnchor(), PCB_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(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GRID_HELPER::SetAuxAxes(), ShowPreview(), and ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER().

◆ ShowPreview()

void KIGFX::VIEW::ShowPreview ( bool  aShow = true)

Definition at line 1628 of file view.cpp.

1629 {
1630  SetVisible( m_preview.get(), aShow );
1631 }
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition: view.h:813
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1516

References m_preview, and SetVisible().

Referenced by SCH_EDIT_FRAME::AddJunction(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), ROUTER_TOOL::InlineDrag(), and DRAWING_TOOL::InteractivePlaceWithPreview().

◆ 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 649 of file view.cpp.

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

References GetLayerOrder().

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

◆ 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 1245 of file view.cpp.

1246 {
1247  int n = 0;
1248 
1249  m_orderedLayers.resize( m_layers.size() );
1250 
1251  for( VIEW_LAYER& layer : m_layers )
1252  m_orderedLayers[n++] = &layer;
1253 
1254  sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder );
1255 
1256  MarkDirty();
1257 }
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
std::vector< VIEW_LAYER * > m_orderedLayers
Flat list of all items.
Definition: view.h:825
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Check if every layer required by the aLayerId layer is enabled.
Definition: view.h:800
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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

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

◆ 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 468 of file view.cpp.

469 {
470  const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
471 
472  if( aAbsolute )
473  return VECTOR2D( matrix * aCoord );
474  else
475  return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
476 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.

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::WarpCursor().

◆ 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 479 of file view.cpp.

480 {
481  const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
482 
483  return matrix.GetScale().x * aSize;
484 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.

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 449 of file view.cpp.

450 {
451  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
452 
453  if( aAbsolute )
454  return VECTOR2D( matrix * aCoord );
455  else
456  return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
457 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621

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(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), EDIT_POINTS::FindPoint(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), PCB_BASE_FRAME::FocusOnItem(), 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(), Redraw(), KIGFX::WX_VIEW_CONTROLS::refreshMouse(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), ZOOM_TOOL::selectRegion(), SetCenter(), SetScale(), SetViewport(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview(), PANEL_EESCHEMA_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 460 of file view.cpp.

461 {
462  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
463 
464  return fabs( matrix.GetScale().x * aSize );
465 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265

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

◆ Update() [1/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 1570 of file view.cpp.

1571 {
1572  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1573 
1574  if( !viewData )
1575  return;
1576 
1577  assert( aUpdateFlags != NONE );
1578 
1579  viewData->m_requiredUpdate |= aUpdateFlags;
1580 }
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::AddLine(), AddToPreview(), EE_GRID_HELPER::BestSnapAnchor(), PCB_GRID_HELPER::BestSnapAnchor(), SCH_EDIT_TOOL::ChangeTextType(), PNS_PCBNEW_DEBUG_DECORATOR::Clear(), ClearPreview(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), PNS_KICAD_IFACE::DisplayItem(), PNS_KICAD_IFACE::DisplayRatline(), EDIT_TOOL::DragArcTrack(), draw(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PL_DRAWING_TOOLS::DrawShape(), PAD_TOOL::EnumeratePads(), PNS_KICAD_IFACE::EraseView(), EE_INSPECTION_TOOL::ExcludeMarker(), DIALOG_ERC::ExcludeMarker(), Hide(), PNS_KICAD_IFACE::HideItem(), PL_SELECTION_TOOL::highlight(), EE_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(), BOARD_COMMIT::Push(), SCH_EDIT_FRAME::RecalculateConnections(), SCH_EDIT_FRAME::RecomputeIntersheetRefs(), DIALOG_PAD_PROPERTIES::redraw(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), SCH_BASE_FRAME::RefreshSelection(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SetVisible(), SCH_EDIT_FRAME::TestDanglingEnds(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), GERBVIEW_SELECTION_TOOL::unselectVisually(), KIGFX::PCB_VIEW::Update(), Update(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_BASE_FRAME::UpdateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), and PCB_SELECTION_TOOL::updateSelection().

◆ Update() [2/2]

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

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 1564 of file view.cpp.

1565 {
1566  Update( aItem, ALL );
1567 }
All except INITIAL_ADD.
Definition: view_item.h:53
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:1570

References KIGFX::ALL, and Update().

◆ UpdateAllItems()

void KIGFX::VIEW::UpdateAllItems ( int  aUpdateFlags)

◆ UpdateAllItemsConditionally()

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 1492 of file view.cpp.

1494 {
1495  for( VIEW_ITEM* item : *m_allItems )
1496  {
1497  if( aCondition( item ) )
1498  {
1499  if( item->viewPrivData() )
1500  item->viewPrivData()->m_requiredUpdate |= aUpdateFlags;
1501  }
1502  }
1503 }
friend class VIEW_ITEM
Definition: view.h:71
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828

References m_allItems.

Referenced by DIALOG_NET_INSPECTOR::onDeleteNet(), SCH_EDIT_FRAME::RecalculateConnections(), PCB_BASE_FRAME::SetDisplayOptions(), GERBVIEW_FRAME::SetElementVisibility(), PANEL_DISPLAY_OPTIONS::TransferDataFromWindow(), and PANEL_EDIT_OPTIONS::TransferDataFromWindow().

◆ 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 762 of file view.cpp.

763 {
764  if( m_gal->IsVisible() )
765  {
766  GAL_UPDATE_CONTEXT ctx( m_gal );
767 
768  for( VIEW_ITEM* item : *m_allItems )
769  {
770  VIEW_ITEM_DATA* viewData = item->viewPrivData();
771 
772  if( !viewData )
773  continue;
774 
775  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
776  viewData->getLayers( layers, layers_count );
777 
778  for( int i = 0; i < layers_count; ++i )
779  {
780  const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
781  int group = viewData->getGroup( layers[i] );
782 
783  if( group >= 0 )
784  m_gal->ChangeGroupColor( group, color );
785  }
786  }
787  }
788 
789  MarkDirty();
790 }
friend class VIEW_ITEM
Definition: view.h:71
int color
Definition: DXF_plotter.cpp:57
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Change the color used to draw the group.
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845
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...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

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(), EnableTopLayer(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), APPEARANCE_CONTROLS::onNetColorMode(), DIALOG_NET_INSPECTOR::onSelChanged(), DIALOG_NET_INSPECTOR::onSortingChanged(), GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), EDA_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 893 of file view.cpp.

894 {
895  sortLayers();
896 
897  if( m_gal->IsVisible() )
898  {
899  GAL_UPDATE_CONTEXT ctx( m_gal );
900 
901  for( VIEW_ITEM* item : *m_allItems )
902  {
903  VIEW_ITEM_DATA* viewData = item->viewPrivData();
904 
905  if( !viewData )
906  continue;
907 
908  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
909  viewData->getLayers( layers, layers_count );
910 
911  for( int i = 0; i < layers_count; ++i )
912  {
913  int group = viewData->getGroup( layers[i] );
914 
915  if( group >= 0 )
916  m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
917  }
918  }
919  }
920 
921  MarkDirty();
922 }
void sortLayers()
Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL)
Definition: view.cpp:1245
friend class VIEW_ITEM
Definition: view.h:71
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Change the depth (Z-axis position) of the group.
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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(), PL_DRAW_PANEL_GAL::SetTopLayer(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and EDA_DRAW_PANEL_GAL::SetTopLayer().

◆ updateBbox()

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

Update set of layers that an item occupies.

Definition at line 1309 of file view.cpp.

1310 {
1311  int layers[VIEW_MAX_LAYERS], layers_count;
1312 
1313  aItem->ViewGetLayers( layers, layers_count );
1314 
1315  for( int i = 0; i < layers_count; ++i )
1316  {
1317  VIEW_LAYER& l = m_layers[layers[i]];
1318  l.items->Remove( aItem );
1319  l.items->Insert( aItem );
1320  MarkTargetDirty( l.target );
1321  }
1322 }
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822

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 1260 of file view.cpp.

1261 {
1262  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1263  wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
1264  wxCHECK( IsCached( aLayer ), /*void*/ );
1265 
1266  if( !viewData )
1267  return;
1268 
1269  // Obtain the color that should be used for coloring the item on the specific layerId
1270  const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
1271  int group = viewData->getGroup( aLayer );
1272 
1273  // Change the color, only if it has group assigned
1274  if( group >= 0 )
1275  m_gal->ChangeGroupColor( group, color );
1276 }
int color
Definition: DXF_plotter.cpp:57
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Change the color used to draw the group.
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
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...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
bool IsCached(int aLayer) const
Return true if the layer is cached.
Definition: view.h:616
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

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 1279 of file view.cpp.

1280 {
1281  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1282  wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
1283  wxCHECK( IsCached( aLayer ), /*void*/ );
1284 
1285  if( !viewData )
1286  return;
1287 
1288  VIEW_LAYER& l = m_layers.at( aLayer );
1289 
1290  m_gal->SetTarget( l.target );
1291  m_gal->SetLayerDepth( l.renderingOrder );
1292 
1293  // Redraw the item from scratch
1294  int group = viewData->getGroup( aLayer );
1295 
1296  if( group >= 0 )
1297  m_gal->DeleteGroup( group );
1298 
1299  group = m_gal->BeginGroup();
1300  viewData->setGroup( aLayer, group );
1301 
1302  if( !m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ) )
1303  aItem->ViewDraw( aLayer, this ); // Alternative drawing method
1304 
1305  m_gal->EndGroup();
1306 }
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void EndGroup()
End the group.
virtual int BeginGroup()
Begin a group.
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
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:616
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.

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 1402 of file view.cpp.

1403 {
1404  if( !m_gal->IsVisible() )
1405  return;
1406 
1407  unsigned int cntGeomUpdate = 0;
1408  unsigned int cntAnyUpdate = 0;
1409 
1410  for( VIEW_ITEM* item : *m_allItems )
1411  {
1412  auto vpd = item->viewPrivData();
1413 
1414  if( !vpd )
1415  continue;
1416 
1417  if( vpd->m_requiredUpdate & ( GEOMETRY | LAYERS ) )
1418  {
1419  cntGeomUpdate++;
1420  }
1421  if( vpd->m_requiredUpdate != NONE )
1422  {
1423  cntAnyUpdate++;
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  VIEW_LAYER& l = m_layers[layers[i]];
1455  l.items->Insert( item );
1456  MarkTargetDirty( l.target );
1457  }
1458 
1459  item->viewPrivData()->m_requiredUpdate &= ~( LAYERS | GEOMETRY );
1460  }
1461  }
1462 
1463  if( cntAnyUpdate )
1464  {
1465  GAL_UPDATE_CONTEXT ctx( m_gal );
1466 
1467  for( VIEW_ITEM* item : *m_allItems.get() )
1468  {
1469  if( item->viewPrivData() && item->viewPrivData()->m_requiredUpdate != NONE )
1470  {
1471  invalidateItem( item, item->viewPrivData()->m_requiredUpdate );
1472  item->viewPrivData()->m_requiredUpdate = NONE;
1473  }
1474  }
1475  }
1476 
1477  KI_TRACE( traceGalProfile, "View update: total items %u, geom %u updates %u\n", cntTotal,
1478  cntGeomUpdate, cntAnyUpdate );
1479 }
friend class VIEW_ITEM
Definition: view.h:71
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
Definition: view.h:828
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
void invalidateItem(VIEW_ITEM *aItem, int aUpdateFlags)
Manage dirty flags & redraw queuing when updating an item.
Definition: view.cpp:1203
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
No updates are required.
Definition: view_item.h:46
#define KI_TRACE(...)
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.
Layers have changed.
Definition: view_item.h:50
Position or shape has changed.
Definition: view_item.h:49

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(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SCH_DRAW_PANEL::OnShow(), PCB_DRAW_PANEL_GAL::OnShow(), ReorderLayerData(), and SCH_EDITOR_CONTROL::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 741 of file view.cpp.

742 {
743  // There is no point in updating non-cached layers
744  if( !IsCached( aLayer ) )
745  return;
746 
747  BOX2I r;
748 
749  r.SetMaximum();
750 
751  if( m_gal->IsVisible() )
752  {
753  GAL_UPDATE_CONTEXT ctx( m_gal );
754 
755  UPDATE_COLOR_VISITOR visitor( aLayer, m_painter, m_gal );
756  m_layers[aLayer].items->Query( r, visitor );
757  MarkTargetDirty( m_layers[aLayer].target );
758  }
759 }
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
Definition: view.h:845
E_SERIE r
Definition: eserie.cpp:41
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
bool IsCached(int aLayer) const
Return true if the layer is cached.
Definition: view.h:616
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.

References IsCached(), KIGFX::GAL::IsVisible(), m_gal, m_layers, m_painter, MarkTargetDirty(), and r.

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 1325 of file view.cpp.

1326 {
1327  VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
1328  int layers[VIEW_MAX_LAYERS], layers_count;
1329 
1330  if( !viewData )
1331  return;
1332 
1333  // Remove the item from previous layer set
1334  viewData->getLayers( layers, layers_count );
1335 
1336  for( int i = 0; i < layers_count; ++i )
1337  {
1338  VIEW_LAYER& l = m_layers[layers[i]];
1339  l.items->Remove( aItem );
1340  MarkTargetDirty( l.target );
1341 
1342  if( IsCached( l.id ) )
1343  {
1344  // Redraw the item from scratch
1345  int prevGroup = viewData->getGroup( layers[i] );
1346 
1347  if( prevGroup >= 0 )
1348  {
1349  m_gal->DeleteGroup( prevGroup );
1350  viewData->setGroup( l.id, -1 );
1351  }
1352  }
1353  }
1354 
1355  // Add the item to new layer set
1356  aItem->ViewGetLayers( layers, layers_count );
1357  viewData->saveLayers( layers, layers_count );
1358 
1359  for( int i = 0; i < layers_count; i++ )
1360  {
1361  VIEW_LAYER& l = m_layers[layers[i]];
1362  l.items->Insert( aItem );
1363  MarkTargetDirty( l.target );
1364  }
1365 }
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GAL * m_gal
Dynamic VIEW (eg.
Definition: view.h:848
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:711
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
Definition: view.h:822
bool IsCached(int aLayer) const
Return true if the layer is cached.
Definition: view.h:616

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 680 of file view.h.

681  {
682  m_useDrawPriority = aFlag;
683  }
bool m_useDrawPriority
The next sequential drawing priority.
Definition: view.h:861

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 834 of file view.h.

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

◆ m_dirtyTargets

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

Rendering order modifier for layers that are marked as top layers.

Definition at line 855 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 852 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 819 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 839 of file view.h.

Referenced by SetScale(), and SetScaleLimits().

◆ m_minScale

double KIGFX::VIEW::m_minScale
protected

Definition at line 838 of file view.h.

Referenced by SetScale(), and SetScaleLimits().

◆ m_mirrorX

bool KIGFX::VIEW::m_mirrorX
protected

Definition at line 841 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 842 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 864 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 825 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 816 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 845 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 867 of file view.h.

Referenced by redrawRect(), and ReverseDrawOrder().

◆ m_scale

double KIGFX::VIEW::m_scale
protected

Definition at line 836 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 831 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 861 of file view.h.

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

◆ TOP_LAYER_MODIFIER

const int KIGFX::VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS
staticprotected

Flag to respect draw priority when drawing items.

Definition at line 858 of file view.h.

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

◆ VIEW_MAX_LAYERS


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