32#include <unordered_map>
87 static void OnDestroy(
VIEW_ITEM* aItem );
97 virtual void Add(
VIEW_ITEM* aItem,
int aDrawPriority = -1 );
115 int Query(
const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
const;
122 void Query(
const BOX2I& aRect,
const std::function<
bool(
VIEW_ITEM* )>& aFunc )
const;
130 void SetVisible(
VIEW_ITEM* aItem,
bool aIsVisible =
true );
139 void Hide(
VIEW_ITEM* aItem,
bool aHide =
true,
bool aHideOverlay =
false );
148 bool IsVisible(
const VIEW_ITEM* aItem )
const;
150 bool IsHiddenOnOverlay(
const VIEW_ITEM* aItem )
const;
155 bool HasItem(
const VIEW_ITEM* aItem )
const;
164 virtual void Update(
const VIEW_ITEM* aItem,
int aUpdateFlags )
const;
165 virtual void Update(
const VIEW_ITEM* aItem )
const;
175 void SetRequired(
int aLayerId,
int aRequiredId,
bool aRequired =
true );
182 void CopySettings(
const VIEW* aOtherView );
195 void SetGAL(
GAL* aGal );
212 m_painter = aPainter;
230 void SetViewport(
const BOX2D& aViewport );
237 BOX2D GetViewport()
const;
245 void SetMirror(
bool aMirrorX,
bool aMirrorY );
271 virtual void SetScale(
double aScale,
VECTOR2D aAnchor = { 0, 0 } );
288 m_boundary = aBoundary;
298 m_boundary.SetOrigin( aBoundary.
GetOrigin() );
299 m_boundary.SetEnd( aBoundary.
GetEnd() );
318 wxASSERT_MSG( aMaximum > aMinimum, wxT(
"I guess you passed parameters in wrong order" ) );
320 m_minScale = aMinimum;
321 m_maxScale = aMaximum;
330 void SetCenter(
const VECTOR2D& aCenter );
339 void SetCenter(
const VECTOR2D& aCenter,
const std::vector<BOX2D>& obscuringScreenRects );
365 double ToWorld(
double aSize )
const;
380 double ToScreen(
double aSize )
const;
387 const VECTOR2I& GetScreenPixelSize()
const;
402 auto it = m_layers.find( aLayer );
404 if( it == m_layers.end() )
409 if( layer.
visible != aVisible )
412 MarkTargetDirty( layer.
target );
424 auto it = m_layers.find( aLayer );
426 if( it == m_layers.end() )
429 return it->second.visible;
440 auto it = m_layers.find( aLayer );
442 if( it == m_layers.end() )
450 MarkTargetDirty( layer.
target );
463 auto it = m_layers.find( aLayer );
465 if( it == m_layers.end() )
473 MarkTargetDirty( layer.
target );
483 auto it = m_layers.find( aLayer );
485 if( it == m_layers.end() )
488 it->second.displayOnly = aDisplayOnly;
499 auto it = m_layers.find( aLayer );
501 if( it == m_layers.end() )
504 it->second.target = aTarget;
513 void SetLayerOrder(
int aLayer,
int aRenderingOrder );
521 int GetLayerOrder(
int aLayer )
const;
530 void SortLayers( std::vector<int>& aLayers )
const;
539 void ReorderLayerData( std::unordered_map<int, int> aReorderMap );
547 void UpdateLayerColor(
int aLayer );
554 void UpdateAllLayersColor();
563 virtual void SetTopLayer(
int aLayer,
bool aEnabled =
true );
574 virtual void EnableTopLayer(
bool aEnable );
576 virtual int GetTopLayer()
const;
582 void ClearTopLayers();
589 void UpdateAllLayersOrder();
599 virtual void Redraw();
604 void RecacheAllItems();
615 if( IsTargetDirty( i ) )
631 return m_dirtyTargets[aTarget];
642 m_dirtyTargets[aTarget] =
true;
648 auto it = m_layers.find( aLayer );
650 if( it == m_layers.end() )
662 m_dirtyTargets[i] =
true;
671 m_dirtyTargets[i] =
false;
684 void UpdateAllItems(
int aUpdateFlags );
692 void UpdateAllItemsConditionally(
int aUpdateFlags,
693 std::function<
bool(
VIEW_ITEM* )> aCondition );
700 void UpdateAllItemsConditionally( std::function<
int(
VIEW_ITEM* )> aItemFlagsProvider );
707 return m_useDrawPriority;
715 m_useDrawPriority = aFlag;
725 m_reverseDrawOrder = aFlag;
728 std::shared_ptr<VIEW_OVERLAY> MakeOverlay();
733 void AddToPreview(
VIEW_ITEM* aItem,
bool aTakeOwnership =
true );
735 void ShowPreview(
bool aShow =
true );
742 std::unique_ptr<VIEW> DataReference()
const;
771 return id < aOther.
id;
776 void redrawRect(
const BOX2I& aRect );
781 m_dirtyTargets[aTarget] =
false;
795 void draw(
VIEW_ITEM* aItem,
int aLayer,
bool aImmediate =
false );
804 void draw(
VIEW_ITEM* aItem,
bool aImmediate =
false );
813 void draw(
VIEW_GROUP* aGroup,
bool aImmediate =
false );
816 void sortOrderedLayers();
820 void clearGroupCache();
828 void invalidateItem(
VIEW_ITEM* aItem,
int aUpdateFlags );
831 void updateItemColor(
VIEW_ITEM* aItem,
int aLayer );
834 void updateItemGeometry(
VIEW_ITEM* aItem,
int aLayer );
849 bool areRequiredLayersEnabled(
int aLayerId )
const;
852 struct CLEAR_LAYER_CACHE_VISITOR;
853 struct RECACHE_ITEM_VISITOR;
854 struct DRAW_ITEM_VISITOR;
855 struct UPDATE_COLOR_VISITOR;
856 struct UPDATE_DEPTH_VISITOR;
constexpr const Vec GetEnd() const
constexpr const Vec & GetOrigin() const
Abstract interface for drawing on a 2D-surface.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Extend VIEW_ITEM by possibility of grouping items into a single object.
An abstract base class for deriving all objects that can be added to a VIEW.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void ReverseDrawOrder(bool aFlag)
Only takes effect if UseDrawPriority is true.
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
VIEW(const VIEW &)=delete
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
void SetLayerDisplayOnly(int aLayer, bool aDisplayOnly=true)
Set a layer display-only (ie: to be rendered but not returned by hit test queries).
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Determine rendering order of layers. Used in display order sorting function.
void SetPainter(PAINTER *aPainter)
Set the painter object used by the view for drawing #VIEW_ITEMS.
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
Flat list of all items.
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
std::vector< VIEW_ITEM * > m_ownedItems
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
PAINTER * m_painter
PAINTER contains information how do draw items.
std::set< unsigned int > m_topLayers
The set of layers that are displayed on the top.
bool m_enableOrderModifier
Whether to use rendering order modifier or not.
void SetLayerHasNegatives(int aLayer, bool aNegatives=true)
Set the status of negatives presense in a particular layer.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
void MarkClean()
Force redraw of view on the next rendering.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
bool IsTargetDirty(int aTarget) const
Return true if any of layers belonging to the target or the target itself should be redrawn.
void SetBoundary(const BOX2I &aBoundary)
Set limits for view area.
int m_nextDrawPriority
The next sequential drawing priority.
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
bool IsCached(int aLayer) const
Return true if the layer is cached.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
bool IsMirroredY() const
Return true if view is flipped across the Y axis.
void UseDrawPriority(bool aFlag)
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
bool IsUsingDrawPriority() const
VIEW & operator=(const VIEW &)=delete
GAL * m_gal
Interface to #PAINTER that is used to draw items.
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
std::map< int, VIEW_LAYER > m_layers
The set of possible displayed layers and its properties.
void markTargetClean(int aTarget)
void MarkDirty()
Force redraw of view on the next rendering.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
const BOX2D & GetBoundary() const
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
void SetScaleLimits(double aMaximum, double aMinimum)
Set minimum and maximum values for scale.
std::vector< VIEW_LAYER * > m_orderedLayers
Sorted list of pointers to members of m_layers.
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at).
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
#define MAX_LAYERS_FOR_VIEW
bool operator<(const DESIGN_BLOCK_INFO &lhs, const DESIGN_BLOCK_INFO &rhs)
The Cairo implementation of the graphics abstraction layer.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
@ TARGET_CACHED
Main rendering target (cached)
@ TARGETS_NUMBER
Number of available rendering targets.
std::set< int > requiredLayers
bool diffLayer
Layer should be drawn differentially over lower layers.
int renderingOrder
Rendering order of this layer.
bool hasNegatives
Layer should be drawn separately to not delete lower layers.
bool visible
Is the layer to be rendered?
bool displayOnly
Is the layer display only?
std::shared_ptr< VIEW_RTREE > items
R-tree indexing all items on this layer.
RENDER_TARGET target
Where the layer should be rendered.