KiCad PCB EDA Suite
Loading...
Searching...
No Matches
view.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2013-2016 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#pragma once
24
25#include <gal/gal.h>
26#include <array>
27#include <cstdint>
28#include <functional>
29#include <map>
30#include <vector>
31#include <set>
32#include <unordered_map>
33#include <memory>
34#include <utility>
35
36#include <math/box2.h>
37#include <gal/definitions.h>
38#include <base_set.h>
39#include <view/view_overlay.h>
40
41namespace KIGFX
42{
43class PAINTER;
44class GAL;
46class VIEW_ITEM;
47class VIEW_GROUP;
48class VIEW_RTREE;
49
68{
69public:
70 friend class VIEW_ITEM;
71
72 typedef std::pair<VIEW_ITEM*, int> LAYER_ITEM_PAIR;
73
74 VIEW();
75 virtual ~VIEW();
76
77 // We own at least one list of raw pointers. Don't let the compiler fill in copy c'tors that
78 // will only land us in trouble.
79 VIEW( const VIEW& ) = delete;
80 VIEW& operator=( const VIEW& ) = delete;
81
89 static void OnDestroy( VIEW_ITEM* aItem );
90
99 virtual void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 );
100
107 void AddBatch( const std::vector<VIEW_ITEM*>& aItems );
108
114 virtual void Remove( VIEW_ITEM* aItem );
115
116
126 int Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const;
127
134 void Query( const BOX2I& aRect, const std::function<bool( VIEW_ITEM* )>& aFunc ) const;
135
142 void SetVisible( VIEW_ITEM* aItem, bool aIsVisible = true );
143
151 void Hide( VIEW_ITEM* aItem, bool aHide = true, bool aHideOverlay = false );
152
160 bool IsVisible( const VIEW_ITEM* aItem ) const;
161
162 bool IsHiddenOnOverlay( const VIEW_ITEM* aItem ) const;
163
167 bool HasItem( const VIEW_ITEM* aItem ) const;
168
176 void RepaintLayers( const BOX2I& aRect, const std::function<bool( int )>& aLayerFilter,
177 const std::function<bool( VIEW_ITEM*, int )>& aItemFilter );
178
186 virtual void Update( const VIEW_ITEM* aItem, int aUpdateFlags ) const;
187 virtual void Update( const VIEW_ITEM* aItem ) const;
188
197 void SetRequired( int aLayerId, int aRequiredId, bool aRequired = true );
198
204 void CopySettings( const VIEW* aOtherView );
205
206 /*
207 * Convenience wrappers for adding multiple items
208 * template <class T> void AddItems( const T& aItems );
209 * template <class T> void RemoveItems( const T& aItems );
210 */
211
217 void SetGAL( GAL* aGal );
218
224 inline GAL* GetGAL() const
225 {
226 return m_gal;
227 }
228
232 inline void SetPainter( PAINTER* aPainter )
233 {
234 m_painter = aPainter;
235 }
236
242 inline PAINTER* GetPainter() const
243 {
244 return m_painter;
245 }
246
252 void SetViewport( const BOX2D& aViewport );
253
259 BOX2D GetViewport() const;
260
267 void SetMirror( bool aMirrorX, bool aMirrorY );
268
272 bool IsMirroredX() const
273 {
274 return m_mirrorX;
275 }
276
280 bool IsMirroredY() const
281 {
282 return m_mirrorY;
283 }
284
293 virtual void SetScale( double aScale, VECTOR2D aAnchor = { 0, 0 } );
294
298 inline double GetScale() const
299 {
300 m_scaleRead = true;
301 return m_scale;
302 }
303
310 bool IsShownAtScale( double aLod ) const;
311
317 inline void SetBoundary( const BOX2D& aBoundary )
318 {
319 m_boundary = aBoundary;
320 }
321
327 inline void SetBoundary( const BOX2I& aBoundary )
328 {
329 m_boundary.SetOrigin( aBoundary.GetOrigin() );
330 m_boundary.SetEnd( aBoundary.GetEnd() );
331 }
332
336 inline const BOX2D& GetBoundary() const
337 {
338 return m_boundary;
339 }
340
347 void SetScaleLimits( double aMaximum, double aMinimum )
348 {
349 wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
350
351 m_minScale = aMinimum;
352 m_maxScale = aMaximum;
353 }
354
361 void SetCenter( const VECTOR2D& aCenter );
362
370 void SetCenter( const VECTOR2D& aCenter, const std::vector<BOX2D>& obscuringScreenRects );
371
377 const VECTOR2D& GetCenter() const
378 {
379 return m_center;
380 }
381
388 VECTOR2D ToWorld( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
389
396 double ToWorld( double aSize ) const;
397
404 VECTOR2D ToScreen( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
405
411 double ToScreen( double aSize ) const;
412
418 const VECTOR2I& GetScreenPixelSize() const;
419
423 void Clear();
424
431 inline void SetLayerVisible( int aLayer, bool aVisible = true )
432 {
433 auto it = m_layers.find( aLayer );
434
435 if( it == m_layers.end() )
436 return;
437
438 VIEW_LAYER& layer = it->second;
439
440 if( layer.visible != aVisible )
441 {
442 // Target has to be redrawn after changing its visibility
443 MarkTargetDirty( layer.target );
444
445 layerStateChanged( aLayer );
446
447 layer.visible = aVisible;
448 m_layerCachesStale = true;
449 }
450 }
451
457 bool IsLayerVisible( int aLayer ) const
458 {
459 if( m_lodProbeLayer >= 0 )
460 noteLodRead( aLayer );
461
462 auto it = m_layers.find( aLayer );
463
464 if( it == m_layers.end() )
465 return false;
466
467 return it->second.visible;
468 }
469
470 void SyncLayerVisibilityCache();
471
472 bool IsLayerVisibleCached( int aLayer ) const
473 {
474 if( m_lodProbeLayer >= 0 )
475 noteLodRead( aLayer );
476
477 return m_layerVisibilityCache[ aLayer ];
478 }
479
486 inline void SetLayerDiff( int aLayer, bool aDiff = true )
487 {
488 auto it = m_layers.find( aLayer );
489
490 if( it == m_layers.end() )
491 return;
492
493 VIEW_LAYER& layer = it->second;
494
495 if( layer.diffLayer != aDiff )
496 {
497 // Target has to be redrawn after changing its layers' diff status
498 MarkTargetDirty( layer.target );
499
500 if( IsCached( aLayer ) )
501 {
504 }
505
506 layer.diffLayer = aDiff;
507 }
508 }
509
516 inline void SetLayerHasNegatives( int aLayer, bool aNegatives = true )
517 {
518 auto it = m_layers.find( aLayer );
519
520 if( it == m_layers.end() )
521 return;
522
523 VIEW_LAYER& layer = it->second;
524
525 if( layer.hasNegatives != aNegatives )
526 {
527 // Target has to be redrawn after changing a layers' negatives
528 MarkTargetDirty( layer.target );
529
530 layerStateChanged( aLayer );
531
532 layer.hasNegatives = aNegatives;
533 }
534 }
535
539 inline void SetLayerDisplayOnly( int aLayer, bool aDisplayOnly = true )
540 {
541 auto it = m_layers.find( aLayer );
542
543 if( it == m_layers.end() )
544 return;
545
546 it->second.displayOnly = aDisplayOnly;
547 }
548
555 inline void SetLayerTarget( int aLayer, RENDER_TARGET aTarget )
556 {
557 auto it = m_layers.find( aLayer );
558
559 if( it == m_layers.end() )
560 return;
561
562 VIEW_LAYER& layer = it->second;
563
564 if( layer.target != aTarget )
565 {
566 MarkTargetDirty( layer.target );
567 MarkTargetDirty( aTarget );
570 layer.target = aTarget;
571 m_layerCachesStale = true;
572 }
573 }
574
583 void SetLayerOrder( int aLayer, int aRenderingOrder, bool aAutoSort = true );
584
591 int GetLayerOrder( int aLayer ) const;
592
597 void SortOrderedLayers();
598
606 void SortLayers( std::vector<int>& aLayers ) const;
607
615 void ReorderLayerData( std::unordered_map<int, int> aReorderMap );
616
623 void UpdateLayerColor( int aLayer );
624
630 void UpdateAllLayersColor();
631
637 void UpdateAllLayersColorAndVisibility();
638
644 void UpdateLayersColor( bool aVisibility, const std::function<bool( int )>& aLayers );
645
653 virtual void SetTopLayer( int aLayer, bool aEnabled = true );
654
664 virtual void EnableTopLayer( bool aEnable );
665
666 virtual int GetTopLayer() const;
667
672 void ClearTopLayers();
673
679 void UpdateAllLayersOrder();
680
684 void ClearTargets();
685
689 virtual void Redraw();
690
694 void RecacheAllItems();
695
701 bool IsDirty() const
702 {
703 for( int i = 0; i < TARGETS_NUMBER; ++i )
704 {
705 if( IsTargetDirty( i ) )
706 return true;
707 }
708
709 return false;
710 }
711
718 bool IsTargetDirty( int aTarget ) const
719 {
720 wxCHECK( aTarget < TARGETS_NUMBER, false );
721 return m_dirtyTargets[aTarget];
722 }
723
729 inline void MarkTargetDirty( int aTarget )
730 {
731 wxCHECK( aTarget < TARGETS_NUMBER, /* void */ );
732 m_dirtyTargets[aTarget] = true;
733 m_targetEdited[aTarget] = true;
734 }
735
741 inline void MarkGeometryDirty()
742 {
743 m_cameraDirtyOnly = false;
745 }
746
752 void markSceneEdited();
753
757 void MarkStaticDirty();
758
763 void SyncRetainedScene();
764
766 inline bool IsCached( int aLayer ) const
767 {
768 auto it = m_layers.find( aLayer );
769
770 if( it == m_layers.end() )
771 return false;
772
773 return it->second.target == TARGET_CACHED;
774 }
775
780 {
781 for( int i = 0; i < TARGETS_NUMBER; ++i )
782 {
783 m_dirtyTargets[i] = true;
784 m_targetEdited[i] = true;
785 }
786
787 m_cameraDirtyOnly = false;
788 }
789
794 {
796
797 for( int i = 0; i < TARGETS_NUMBER; ++i )
798 m_dirtyTargets[i] = true;
799 }
800
805 {
806 for( int i = 0; i < TARGETS_NUMBER; ++i )
807 {
808 m_dirtyTargets[i] = false;
809 m_targetEdited[i] = false;
810 }
811
812 m_cameraDirtyOnly = false;
813 }
814
815 bool IsCameraDirtyOnly() const
816 {
817 return IsDirty() && m_cameraDirtyOnly;
818 }
819
823 void UpdateItems();
824
829 {
831 }
832
838 void UpdateAllItems( int aUpdateFlags );
839
846 void UpdateAllItemsConditionally( int aUpdateFlags,
847 std::function<bool( VIEW_ITEM* )> aCondition );
848
854 void UpdateAllItemsConditionally( std::function<int( VIEW_ITEM* )> aItemFlagsProvider );
855
860 {
861 return m_useDrawPriority;
862 }
863
867 void UseDrawPriority( bool aFlag )
868 {
869 m_useDrawPriority = aFlag;
870 }
871
877 void ReverseDrawOrder( bool aFlag )
878 {
879 m_reverseDrawOrder = aFlag;
880 }
881
882 std::shared_ptr<VIEW_OVERLAY> MakeOverlay();
883
884 void InitPreview();
885
886 void ClearPreview();
887 void AddToPreview( VIEW_ITEM* aItem, bool aTakeOwnership = true );
888
889 void ShowPreview( bool aShow = true );
890
896 std::unique_ptr<VIEW> DataReference() const;
897
899 static constexpr int VIEW_MAX_LAYERS = MAX_LAYERS_FOR_VIEW;
900
903
904protected:
906 {
907 bool visible;
909
912
915 std::shared_ptr<VIEW_RTREE> items;
917 int id;
919
921 std::set<int> requiredLayers;
922
923 bool operator< ( const VIEW_LAYER& aOther ) const
924 {
925 return id < aOther.id;
926 }
927 };
928
938 void unlinkItem( VIEW_ITEM* aItem );
939
941 void redrawRect( const BOX2I& aRect );
942
947 void placeCachedGroup( VIEW_ITEM* aItem, int aLayer,
948 const RETAINED_GROUP_ORDER* aOrder = nullptr );
949 double cachedGroupLOD( VIEW_ITEM* aItem, int aLayer );
950
956 void placeRetainedInOrder( const std::vector<LAYER_ITEM_PAIR>& aItems, bool aReplacing );
957
963 void layerStateChanged( int aLayer );
964
968 void noteLodRead( int aLayer ) const;
969
970 inline void markTargetClean( int aTarget )
971 {
972 wxCHECK( aTarget < TARGETS_NUMBER, /* void */ );
973 m_dirtyTargets[aTarget] = false;
974 m_targetEdited[aTarget] = false;
975 }
976
988 void draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate = false );
989
997 void draw( VIEW_ITEM* aItem, bool aImmediate = false );
998
1006 void draw( VIEW_GROUP* aGroup, bool aImmediate = false );
1007
1010 void clearGroupCache();
1011
1018 void invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags );
1019
1024 void recolorAllLayers( bool aReplace, const std::function<bool( int )>& aLayers = {} );
1025
1029 void markDimExemption( const VIEW_ITEM* aItem, int aGroup );
1030
1032 void updateItemColor( VIEW_ITEM* aItem, int aLayer );
1033
1034 void recolorGroup( VIEW_ITEM* aItem, int aLayer, int aGroup );
1035
1039 void releaseReplacedGroup( VIEW_ITEM* aItem, int aLayer );
1040
1044 void releaseReplacedGroups();
1045
1047 void updateItemGeometry( VIEW_ITEM* aItem, int aLayer, bool aPlace = true );
1048
1050 void updateBbox( VIEW_ITEM* aItem );
1051
1053 void updateLayers( VIEW_ITEM* aItem );
1054
1057 {
1058 return aI->renderingOrder > aJ->renderingOrder;
1059 }
1060
1062 bool areRequiredLayersEnabled( int aLayerId ) const;
1063
1064 // Function objects that need to access VIEW/VIEW_ITEM private/protected members
1065 struct CLEAR_LAYER_CACHE_VISITOR;
1066 struct RECACHE_ITEM_VISITOR;
1067 struct DRAW_ITEM_VISITOR;
1068
1069 std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
1070 std::vector<VIEW_ITEM*> m_ownedItems;
1071
1074
1076 std::map<int, VIEW_LAYER> m_layers;
1077
1079 std::vector<VIEW_LAYER*> m_orderedLayers;
1080
1082 std::shared_ptr<std::vector<VIEW_ITEM*>> m_allItems;
1083
1085 std::set<unsigned int> m_topLayers;
1086
1089
1090 double m_scale;
1094
1099
1104
1107
1110
1113
1119
1122
1125
1128
1131
1136 mutable std::vector<VIEW_ITEM*> m_pendingItems;
1138 std::vector<std::pair<VIEW_ITEM*, int>> m_deferredRetainedPlacements;
1139
1144 std::map<std::pair<VIEW_ITEM*, int>, int> m_replacedRetainedGroups;
1145
1149 mutable bool m_pendingListIncomplete = false;
1150
1155
1160 {
1161 bool read = false;
1162 double lodBelow = 0.0;
1163 double lodAbove = std::numeric_limits<double>::max();
1164 };
1165
1167 mutable bool m_scaleRead = false;
1168
1173
1174 void noteKeptLod( double aLod ) const;
1175
1179 void rescaleKeptTargets();
1180
1184 std::vector<int> m_lodRefreshLayers;
1185
1189 mutable int m_lodProbeLayer = -1;
1190
1195 mutable std::unordered_map<int, std::vector<bool>> m_lodReads;
1196
1200 void clearPendingItems();
1201
1206};
1207} // namespace KIGFX
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
BOX2< VECTOR2D > BOX2D
Definition box2.h:915
constexpr const Vec GetEnd() const
Definition box2.h:209
constexpr const Vec & GetOrigin() const
Definition box2.h:207
Abstract interface for drawing on a 2D-surface.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition painter.h:55
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition view_group.h:39
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
Implement a non-owning R-tree for fast spatial indexing of VIEW items.
Definition view_rtree.h:42
double GetScale() const
Definition view.h:298
bool m_layerCachesStale
A layer's visibility or target changed since SyncLayerVisibilityCache() last copied them.
Definition view.h:1103
std::vector< int > m_lodRefreshLayers
Layers shown or hidden since the last sync, whose readers have to be placed again.
Definition view.h:1184
bool m_cameraDirtyOnly
The current dirty state is due only to camera changes.
Definition view.h:1205
double m_maxScale
Definition view.h:1093
void ReverseDrawOrder(bool aFlag)
Only takes effect if UseDrawPriority is true.
Definition view.h:877
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition view.h:377
void CopySettings(const VIEW *aOtherView)
Copy layers and visibility settings from another view.
Definition view.cpp:829
static constexpr int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition view.h:902
VIEW(const VIEW &)=delete
SCALE_USE * m_keptScaleUse
The SCALE_USE of the kept target being drawn, updated by each level of detail drawn.
Definition view.h:1172
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition view.h:1127
std::unordered_map< int, std::vector< bool > > m_lodReads
For each layer whose visibility an item asked about, the cached layers those items were placed on.
Definition view.h:1195
bool m_targetEdited[TARGETS_NUMBER]
The target's content changed, not just the camera.
Definition view.h:1118
int m_lodProbeLayer
Cached layer being placed while an item is asked for its level of detail, else -1.
Definition view.h:1189
void SetRequired(int aLayerId, int aRequiredId, bool aRequired=true)
Mark the aRequiredId layer as required for the aLayerId layer.
Definition view.cpp:573
void SetLayerDisplayOnly(int aLayer, bool aDisplayOnly=true)
Set a layer display-only (ie: to be rendered but not returned by hit test queries).
Definition view.h:539
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Determine rendering order of layers. Used in display order sorting function.
Definition view.h:1056
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition view.cpp:365
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition view.cpp:488
bool m_mirrorX
Definition view.h:1095
void SetPainter(PAINTER *aPainter)
Set the painter object used by the view for drawing VIEW_ITEM objects.
Definition view.h:232
std::vector< std::pair< VIEW_ITEM *, int > > m_deferredRetainedPlacements
Definition view.h:1138
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
Definition view.h:317
void MarkStaticDirty()
Flag the GAL's static geometry pool as dirty so the next full redraw rebuilds it.
Definition view.cpp:713
bool m_deferRetainedPlacement
Definition view.h:1137
bool HasPendingItemUpdates() const
Definition view.h:828
bool m_mirrorY
Definition view.h:1096
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
Flat list of all items.
Definition view.h:1082
void MarkGeometryDirty()
Signal a change to cached geometry so the next paint leaves the camera-reuse path and rebuilds the st...
Definition view.h:741
void rescaleKeptTargets()
Mark the kept targets whose content the new scale changes, so they are emitted again.
Definition view.cpp:952
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
Definition view.h:486
void SetGAL(GAL *aGal)
Assign a rendering device for the VIEW.
Definition view.cpp:835
int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
Definition view.cpp:744
std::vector< VIEW_ITEM * > m_ownedItems
Definition view.h:1070
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
Definition view.h:555
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:2631
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:431
bool IsCameraDirtyOnly() const
Definition view.h:815
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
Definition view.cpp:2617
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition view.h:1106
std::set< unsigned int > m_topLayers
The set of layers that are displayed on the top.
Definition view.h:1085
bool m_enableOrderModifier
Whether to use rendering order modifier or not.
Definition view.h:1073
void SetLayerHasNegatives(int aLayer, bool aNegatives=true)
Set the status of negatives presense in a particular layer.
Definition view.h:516
SCALE_USE m_scaleUse[TARGETS_NUMBER]
Definition view.h:1166
GAL * GetGAL() const
Return the GAL this view is using to draw graphical primitives.
Definition view.h:224
bool IsHiddenOnOverlay(const VIEW_ITEM *aItem) const
Definition view.cpp:2609
bool m_dirtyTargets[TARGETS_NUMBER]
Flag to mark targets as dirty so they have to be redrawn on the next refresh event.
Definition view.h:1112
void MarkClean()
Force redraw of view on the next rendering.
Definition view.h:804
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
Definition view.h:899
double m_minScale
Definition view.h:1092
double m_scale
Definition view.h:1090
void layerStateChanged(int aLayer)
React to a change of a layer's visibility, order, required layers or negatives.
Definition view.cpp:588
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition view.h:272
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:718
bool m_pendingListIncomplete
Items were flagged without being listed, so UpdateItems() has to scan them all.
Definition view.h:1149
void SetBoundary(const BOX2I &aBoundary)
Set limits for view area.
Definition view.h:327
int m_nextDrawPriority
The next sequential drawing priority.
Definition view.h:1124
bool m_scaleRead
GetScale() was called, see SCALE_USE::read.
Definition view.h:1167
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition view.h:1121
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:472
void MarkViewportDirty()
Force a redraw for a camera change alone, which lets the paint reuse the cached scene.
Definition view.h:793
bool IsCached(int aLayer) const
Return true if the layer is cached.
Definition view.h:766
void AddBatch(const std::vector< VIEW_ITEM * > &aItems)
Add a batch of items to the view, using bulk-loaded R-trees for initial population.
Definition view.cpp:414
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition view.h:72
bool IsMirroredY() const
Return true if view is flipped across the Y axis.
Definition view.h:280
BASE_SET m_layerVisibilityCache
Definition view.h:1097
void UseDrawPriority(bool aFlag)
Definition view.h:867
bool m_hasPendingItemUpdates
True when at least one item has deferred update flags that still need processing.
Definition view.h:1130
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Definition view.h:1069
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 th...
Definition view.cpp:289
bool IsUsingDrawPriority() const
Definition view.h:859
void clearPendingItems()
Empty m_pendingItems and forget each listed item's place in it.
Definition view.cpp:2463
VIEW & operator=(const VIEW &)=delete
bool m_sceneLayersStale
A layer's order, visibility, required layers or negatives changed since the last sync.
Definition view.h:1154
std::vector< VIEW_ITEM * > m_pendingItems
Items flagged through Update() since the last UpdateItems(), so a frame that changed a few items need...
Definition view.h:1136
GAL * m_gal
Interface to PAINTER that is used to draw items.
Definition view.h:1109
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
Definition view.h:701
std::map< int, VIEW_LAYER > m_layers
The set of possible displayed layers and its properties.
Definition view.h:1076
void RepaintLayers(const BOX2I &aRect, const std::function< bool(int)> &aLayerFilter, const std::function< bool(VIEW_ITEM *, int)> &aItemFilter)
Re-cache only some layers of the items in aRect.
Definition view.cpp:2656
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
Definition view.cpp:2576
void markTargetClean(int aTarget)
Definition view.h:970
void MarkDirty()
Force redraw of view on the next rendering.
Definition view.h:779
friend class VIEW_ITEM
Definition view.h:70
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition view.h:457
BOX2D m_boundary
Definition view.h:1091
void noteLodRead(int aLayer) const
Record that the item being placed asked whether aLayer is visible.
Definition view.cpp:612
void noteKeptLod(double aLod) const
Definition view.cpp:939
std::map< std::pair< VIEW_ITEM *, int >, int > m_replacedRetainedGroups
Groups replaced by items redrawn during a deferred placement.
Definition view.h:1144
const BOX2D & GetBoundary() const
Definition view.h:336
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
Definition view.h:242
void SetScaleLimits(double aMaximum, double aMinimum)
Set minimum and maximum values for scale.
Definition view.h:347
std::vector< VIEW_LAYER * > m_orderedLayers
Sorted list of pointers to members of m_layers.
Definition view.h:1079
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at).
Definition view.h:1088
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition view.h:729
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
Definition view.cpp:2601
BASE_SET m_layerCachedFlagCache
Definition view.h:1098
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition view.cpp:2552
#define MAX_LAYERS_FOR_VIEW
Definition definitions.h:41
bool operator<(const FOOTPRINT_INFO &lhs, const FOOTPRINT_INFO &rhs)
#define GAL_API
Definition gal.h:27
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition definitions.h:32
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:33
@ TARGETS_NUMBER
Number of available rendering targets.
Definition definitions.h:37
How the content of a kept target depends on the scale it was emitted at.
Definition view.h:1160
bool read
something was sized from the scale
Definition view.h:1161
double lodAbove
nearest threshold above it
Definition view.h:1163
double lodBelow
nearest threshold under that scale
Definition view.h:1162
std::set< int > requiredLayers
Layers that have to be enabled to show the layer.
Definition view.h:921
bool diffLayer
Layer should be drawn differentially over lower layers.
Definition view.h:911
int renderingOrder
Rendering order of this layer.
Definition view.h:916
bool hasNegatives
Layer should be drawn separately to not delete lower layers.
Definition view.h:914
bool visible
Is the layer to be rendered?
Definition view.h:907
bool displayOnly
Is the layer display only?
Definition view.h:908
std::shared_ptr< VIEW_RTREE > items
R-tree indexing all items on this layer.
Definition view.h:915
RENDER_TARGET target
Where the layer should be rendered.
Definition view.h:918
int id
Layer ID.
Definition view.h:917
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707