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;
163 void SetRequired(
int aLayerId,
int aRequiredId,
bool aRequired =
true );
233 void SetMirror(
bool aMirrorX,
bool aMirrorY );
306 wxASSERT_MSG( aMaximum > aMinimum, wxT(
"I guess you passed parameters in wrong order" ) );
327 void SetCenter(
const VECTOR2D& aCenter,
const std::vector<BOX2D>& obscuringScreenRects );
353 double ToWorld(
double aSize )
const;
368 double ToScreen(
double aSize )
const;
390 wxCHECK( aLayer < (
int)
m_layers.size(), );
392 if(
m_layers[aLayer].visible != aVisible )
396 m_layers[aLayer].visible = aVisible;
407 wxCHECK( aLayer >= 0,
false);
408 wxCHECK( aLayer < (
int)
m_layers.size(), false );
410 return m_layers.at( aLayer ).visible;
421 wxCHECK( aLayer < (
int)
m_layers.size(), );
423 if(
m_layers[aLayer].diffLayer != aDiff )
439 wxCHECK( aLayer < (
int)
m_layers.size(), );
441 if(
m_layers[aLayer].hasNegatives != aNegatives )
445 m_layers[aLayer].hasNegatives = aNegatives;
451 wxCHECK( aLayer < (
int)
m_layers.size(), );
452 m_layers[aLayer].displayOnly = aDisplayOnly;
463 wxCHECK( aLayer < (
int)
m_layers.size(), );
491 void SortLayers(
int aLayers[],
int& aCount )
const;
524 virtual void SetTopLayer(
int aLayer,
bool aEnabled =
true );
618 wxCHECK( aLayer < (
int)
m_layers.size(), false );
624 catch(
const std::out_of_range& )
667 std::function<
bool(
VIEW_ITEM* )> aCondition );
752 void draw(
VIEW_ITEM* aItem,
int aLayer,
bool aImmediate =
false );
809 struct CLEAR_LAYER_CACHE_VISITOR;
810 struct RECACHE_ITEM_VISITOR;
811 struct DRAW_ITEM_VISITOR;
812 struct UPDATE_COLOR_VISITOR;
815 std::unique_ptr<KIGFX::VIEW_GROUP>
m_preview;
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.
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
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
bool hasNegatives
Layer should be drawn separately to not delete lower layers.
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.
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
std::shared_ptr< VIEW_OVERLAY > MakeOverlay()
virtual void EnableTopLayer(bool aEnable)
Enable or disable display of the top layer.
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)
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
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)
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.
bool diffLayer
Layer should be drawn differentially over lower layers.
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.
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.
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.
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...
std::vector< VIEW_LAYER * > m_orderedLayers
Flat list of all items.
void MarkClean()
Force redraw of view on the next rendering.
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.
int renderingOrder
Rendering order of this layer.
void SetLayerHasNegatives(int aLayer, bool aNegatives=true)
Set the status of negatives presense in a particular 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...
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.