32#include <unordered_map>
78 VIEW(
bool aIsDynamic =
true );
99 virtual void Add(
VIEW_ITEM* aItem,
int aDrawPriority = -1 );
118 virtual int Query(
const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
const;
168 void SetRequired(
int aLayerId,
int aRequiredId,
bool aRequired =
true );
238 void SetMirror(
bool aMirrorX,
bool aMirrorY );
311 wxASSERT_MSG( aMaximum > aMinimum, wxT(
"I guess you passed parameters in wrong order" ) );
332 void SetCenter(
const VECTOR2D& aCenter,
const std::vector<BOX2D>& obscuringScreenRects );
358 double ToWorld(
double aSize )
const;
373 double ToScreen(
double aSize )
const;
395 wxCHECK( aLayer < (
int)
m_layers.size(), );
397 if(
m_layers[aLayer].visible != aVisible )
401 m_layers[aLayer].visible = aVisible;
412 wxCHECK( aLayer >= 0,
false);
413 wxCHECK( aLayer < (
int)
m_layers.size(),
false );
415 return m_layers.at( aLayer ).visible;
426 wxCHECK( aLayer < (
int)
m_layers.size(), );
428 if(
m_layers[aLayer].diffLayer != aDiff )
444 wxCHECK( aLayer < (
int)
m_layers.size(), );
446 if(
m_layers[aLayer].hasNegatives != aNegatives )
450 m_layers[aLayer].hasNegatives = aNegatives;
459 wxCHECK( aLayer < (
int)
m_layers.size(), );
460 m_layers[aLayer].displayOnly = aDisplayOnly;
471 wxCHECK( aLayer < (
int)
m_layers.size(), );
499 void SortLayers(
int aLayers[],
int& aCount )
const;
532 virtual void SetTopLayer(
int aLayer,
bool aEnabled =
true );
626 wxCHECK( aLayer < (
int)
m_layers.size(),
false );
632 catch(
const std::out_of_range& )
675 std::function<
bool(
VIEW_ITEM* )> aCondition );
771 void draw(
VIEW_ITEM* aItem,
int aLayer,
bool aImmediate =
false );
828 struct CLEAR_LAYER_CACHE_VISITOR;
829 struct RECACHE_ITEM_VISITOR;
830 struct DRAW_ITEM_VISITOR;
831 struct UPDATE_COLOR_VISITOR;
832 struct UPDATE_DEPTH_VISITOR;
void SetOrigin(const Vec &pos)
const Vec & GetOrigin() const
void SetEnd(coord_type x, coord_type y)
A base class for most all the KiCad significant classes used in schematics and boards.
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 SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
void SortLayers(int aLayers[], int &aCount) const
Change the order of given layer ids, so after sorting the order corresponds to layers rendering order...
void ShowPreview(bool aShow=true)
void sortLayers()
Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL)
bool m_dynamic
Flag to mark targets as dirty so they have to be redrawn on the next refresh event.
bool IsDynamic() const
Tell if the VIEW is dynamic (ie.
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
void ReverseDrawOrder(bool aFlag)
Only takes effect if UseDrawPriority is true.
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
void CopySettings(const VIEW *aOtherView)
Copy layers and visibility settings from another view.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
static constexpr int TOP_LAYER_MODIFIER
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Draw an item, but on a specified layers.
VIEW(const VIEW &)=delete
void UpdateAllLayersOrder()
Do everything that is needed to apply the rendering order of layers.
void updateItemColor(VIEW_ITEM *aItem, int aLayer)
Update all information needed to draw an item.
void SetViewport(const BOX2D &aViewport)
Set the visible area of the VIEW.
void SetRequired(int aLayerId, int aRequiredId, bool aRequired=true)
Mark the aRequiredId layer as required for the aLayerId layer.
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
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)
Check if every layer required by the aLayerId layer is enabled.
int GetLayerOrder(int aLayer) const
Return rendering order of a particular layer.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
std::vector< EDA_ITEM * > m_ownedItems
Whether to use rendering order modifier or not.
void ClearTargets()
Clear targets that are marked as dirty.
virtual void EnableTopLayer(bool aEnable)
Enable or disable display of the top layer.
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.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
bool m_mirrorY
PAINTER contains information how do draw items.
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
std::shared_ptr< VIEW_OVERLAY > MakeOverlay()
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
void SetGAL(GAL *aGal)
Assign a rendering device for the VIEW.
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.
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
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...
void invalidateItem(VIEW_ITEM *aItem, int aUpdateFlags)
Manage dirty flags & redraw queuing when updating an item.
const VECTOR2I & GetScreenPixelSize() const
Return the size of the our rendering area in pixels.
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
virtual int GetTopLayer() const
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
virtual void Redraw()
Immediately redraws the whole view.
void Clear()
Remove all items from the view.
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
bool m_enableOrderModifier
The set of possible displayed layers and its properties.
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.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
void ClearTopLayers()
Remove all layers from the on-the-top set (they are no longer displayed over the rest of layers).
bool m_dirtyTargets[TARGETS_NUMBER]
Flag to respect draw priority when drawing items.
void MarkClean()
Force redraw of view on the next rendering.
void updateItemGeometry(VIEW_ITEM *aItem, int aLayer)
Update bounding box of an item.
static constexpr int VIEW_MAX_LAYERS
Rendering order modifier for layers that are marked as top layers.
void updateLayers(VIEW_ITEM *aItem)
Determine rendering order of layers. Used in display order sorting function.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
void RecacheAllItems()
Rebuild GAL display lists.
bool areRequiredLayersEnabled(int aLayerId) const
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
Flag to reverse the draw order when using draw priority.
bool m_useDrawPriority
The next sequential drawing priority.
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
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 UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
void UseDrawPriority(bool aFlag)
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
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...
bool IsUsingDrawPriority() const
GAL * m_gal
Dynamic VIEW (eg.
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
std::unique_ptr< VIEW > DataReference() const
Return a new VIEW object that shares the same set of VIEW_ITEMs and LAYERs.
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.
void markTargetClean(int aTarget)
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
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.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
std::vector< VIEW_LAYER * > m_orderedLayers
Flat list of all items.
void SetLayerOrder(int aLayer, int aRenderingOrder)
Set rendering order of a particular layer.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
void updateBbox(VIEW_ITEM *aItem)
Update set of layers that an item occupies.
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
void redrawRect(const BOX2I &aRect)
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
Layers that have to be enabled to show the layer.
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.