32 #include <unordered_map> 77 VIEW(
bool aIsDynamic =
true );
98 virtual void Add(
VIEW_ITEM* aItem,
int aDrawPriority = -1 );
117 virtual int Query(
const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
const;
162 void SetRequired(
int aLayerId,
int aRequiredId,
bool aRequired =
true );
232 void SetMirror(
bool aMirrorX,
bool aMirrorY );
305 wxASSERT_MSG( aMaximum > aMinimum, wxT(
"I guess you passed parameters in wrong order" ) );
352 double ToWorld(
double aSize )
const;
367 double ToScreen(
double aSize )
const;
389 wxCHECK( aLayer < (
int)
m_layers.size(), );
391 if(
m_layers[aLayer].visible != aVisible )
395 m_layers[aLayer].visible = aVisible;
406 wxCHECK( aLayer < (
int)
m_layers.size(), false );
407 return m_layers.at( aLayer ).visible;
412 wxCHECK( aLayer < (
int)
m_layers.size(), );
413 m_layers[aLayer].displayOnly = aDisplayOnly;
424 wxCHECK( aLayer < (
int)
m_layers.size(), );
452 void SortLayers(
int aLayers[],
int& aCount )
const;
485 virtual void SetTopLayer(
int aLayer,
bool aEnabled =
true );
579 wxCHECK( aLayer < (
int)
m_layers.size(), false );
585 catch(
const std::out_of_range& )
626 std::function<
bool(
VIEW_ITEM* )> aCondition );
735 void draw(
VIEW_ITEM* aItem,
int aLayer,
bool aImmediate =
false );
792 struct clearLayerCache;
796 struct updateItemsColor;
797 struct changeItemsDepth;
798 struct extentsVisitor;
800 std::unique_ptr<KIGFX::VIEW_GROUP>
m_preview;
void MarkForUpdate(VIEW_ITEM *aItem)
Add an item to a list of items that are going to be refreshed upon the next frame rendering.
void SetScaleLimits(double aMaximum, double aMinimum)
Set minimum and maximum values for scale.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Number of available rendering targets.
bool IsDrawOrderReversed() const
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
void SetViewport(const BOX2D &aViewport)
Set the visible area of the VIEW.
void updateLayers(VIEW_ITEM *aItem)
Determine rendering order of layers. Used in display order sorting function.
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
void ReverseDrawOrder(bool aFlag)
Only takes effect if UseDrawPriority is true.
void SetLayerOrder(int aLayer, int aRenderingOrder)
Set rendering order of a particular layer.
void SetRequired(int aLayerId, int aRequiredId, bool aRequired=true)
Mark the aRequiredId layer as required for the aLayerId layer.
void updateItemColor(VIEW_ITEM *aItem, int aLayer)
Update all information needed to draw an item.
bool m_useDrawPriority
The next sequential drawing priority.
std::unique_ptr< KIGFX::VIEW_GROUP > m_preview
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
const BOX2D & GetBoundary() const
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.
static const int TOP_LAYER_MODIFIER
Flag to respect draw priority when drawing items.
void sortLayers()
Clear cached GAL group numbers (ONLY numbers stored in VIEW_ITEMs, not group objects used by GAL)
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
void UseDrawPriority(bool aFlag)
void RecacheAllItems()
Rebuild GAL display lists.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
GAL * m_gal
Dynamic VIEW (eg.
bool areRequiredLayersEnabled(int aLayerId) const
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
void UpdateAllLayersOrder()
Do everything that is needed to apply the rendering order of layers.
void SetMirror(bool aMirrorX, bool aMirrorY)
Control the mirroring of the VIEW.
An abstract base class for deriving all objects that can be added to a VIEW.
std::shared_ptr< VIEW_OVERLAY > MakeOverlay()
virtual void EnableTopLayer(bool aEnable)
Enable or disable display of the top layer.
VECTOR2D m_center
Scale of displayed VIEW_ITEMs.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
bool IsUsingDrawPriority() const
void SetBoundary(const BOX2I &aBoundary)
Set limits for view area.
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
The set of layers that are displayed on the top.
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)
double m_minScale
Scale upper limit.
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
void SetPrintMode(int aPrintMode)
Set the printing mode.
Contains all the knowledge about how to draw graphical object onto any particular output device.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
virtual void Redraw()
Immediately redraws the whole view.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
bool IsTargetDirty(int aTarget) const
Return true if any of layers belonging to the target or the target itself should be redrawn.
void Clear()
Remove all items from the view.
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
bool visible
Is the layer to be rendered?
virtual int GetTopLayer() const
void SetLayerDisplayOnly(int aLayer, bool aDisplayOnly=true)
bool m_mirrorX
Vertical flip flag.
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.
bool m_dynamic
Flag to mark targets as dirty so they have to be redrawn on the next refresh event.
Extend VIEW_ITEM by possibility of grouping items into a single object.
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
void markTargetClean(int aTarget)
void updateBbox(VIEW_ITEM *aItem)
Update set of layers that an item occupies.
PAINTER * m_painter
Interface to #PAINTER that is used to draw items.
bool IsDynamic() const
Tell if the VIEW is dynamic (ie.
bool m_reverseDrawOrder
A control for printing: m_printMode <= 0 means no printing mode (normal draw mode m_printMode > 0 is ...
int m_nextDrawPriority
Flag to reverse the draw order when using draw priority.
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
std::vector< VIEW_LAYER > m_layers
Sorted list of pointers to members of m_layers.
void ClearTopLayers()
Remove all layers from the on-the-top set (they are no longer displayed over the rest of layers).
bool IsMirroredX() const
Return true if view is flipped across the X axis.
void SetEnd(coord_type x, coord_type y)
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
double m_maxScale
Horizontal flip flag.
void UpdateLayerColor(int aLayer)
Apply the new coloring scheme held by RENDER_SETTINGS in case that it has changed.
std::unique_ptr< VIEW > DataReference() const
Return a new VIEW object that shares the same set of VIEW_ITEMs and LAYERs.
int GetPrintMode()
Get the current print mode.
bool m_dirtyTargets[TARGETS_NUMBER]
Rendering order modifier for layers that are marked as top layers.
void redrawRect(const BOX2I &aRect)
std::vector< EDA_ITEM * > m_ownedItems
Whether to use rendering order modifier or not.
void updateItemGeometry(VIEW_ITEM *aItem, int aLayer)
Update bounding box of an item.
Main rendering target (cached)
bool m_enableOrderModifier
The set of possible displayed layers and its properties.
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...
BOX2D m_boundary
Scale lower limit.
std::vector< VIEW_LAYER * > m_orderedLayers
Flat list of all items.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
int GetLayerOrder(int aLayer) const
Return rendering order of a particular layer.
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Draw an item, but on a specified layers.
bool IsCached(int aLayer) const
Return true if the layer is cached.
void SetOrigin(const Vec &pos)
A base class for most all the KiCad significant classes used in schematics and boards.
bool m_mirrorY
PAINTER contains information how do draw items.
void ClearTargets()
Clear targets that are marked as dirty.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
void CopySettings(const VIEW *aOtherView)
Copy layers and visibility settings from another view.
void SetPainter(PAINTER *aPainter)
Set the painter object used by the view for drawing #VIEW_ITEMS.
double m_scale
View boundaries.
int renderingOrder
Rendering order of this layer.
bool displayOnly
Is the layer display only?
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to 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.
bool IsMirroredY() const
Return true if view is flipped across the Y axis.
const Vec & GetOrigin() const
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
VIEW(bool aIsDynamic=true)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
void SetGAL(GAL *aGal)
Assign a rendering device for the VIEW.
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Check if every layer required by the aLayerId layer is enabled.
void MarkDirty()
Force redraw of view on the next rendering.
std::set< int > requiredLayers
Layers that have to be enabled to show the layer.
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
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...
Class GAL is the abstract interface for drawing on a 2D-surface.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
RENDER_TARGET target
Where the layer should be rendered.
std::shared_ptr< VIEW_RTREE > items
R-tree indexing all items on this layer.