32#include <unordered_map>
99 virtual void Add(
VIEW_ITEM* aItem,
int aDrawPriority = -1 );
107 void AddBatch(
const std::vector<VIEW_ITEM*>& aItems );
126 int Query(
const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
const;
151 void Hide(
VIEW_ITEM* aItem,
bool aHide =
true,
bool aHideOverlay =
false );
176 void RepaintLayers(
const BOX2I& aRect,
const std::function<
bool(
int )>& aLayerFilter,
177 const std::function<
bool(
VIEW_ITEM*,
int )>& aItemFilter );
197 void SetRequired(
int aLayerId,
int aRequiredId,
bool aRequired =
true );
252 void SetViewport(
const BOX2D& aViewport );
259 BOX2D GetViewport()
const;
267 void SetMirror(
bool aMirrorX,
bool aMirrorY );
293 virtual void SetScale(
double aScale,
VECTOR2D aAnchor = { 0, 0 } );
310 bool IsShownAtScale(
double aLod )
const;
349 wxASSERT_MSG( aMaximum > aMinimum, wxT(
"I guess you passed parameters in wrong order" ) );
361 void SetCenter(
const VECTOR2D& aCenter );
370 void SetCenter(
const VECTOR2D& aCenter,
const std::vector<BOX2D>& obscuringScreenRects );
396 double ToWorld(
double aSize )
const;
411 double ToScreen(
double aSize )
const;
418 const VECTOR2I& GetScreenPixelSize()
const;
440 if( layer.
visible != aVisible )
467 return it->second.visible;
470 void SyncLayerVisibilityCache();
546 it->second.displayOnly = aDisplayOnly;
564 if( layer.
target != aTarget )
583 void SetLayerOrder(
int aLayer,
int aRenderingOrder,
bool aAutoSort =
true );
591 int GetLayerOrder(
int aLayer )
const;
597 void SortOrderedLayers();
606 void SortLayers( std::vector<int>& aLayers )
const;
615 void ReorderLayerData( std::unordered_map<int, int> aReorderMap );
623 void UpdateLayerColor(
int aLayer );
630 void UpdateAllLayersColor();
637 void UpdateAllLayersColorAndVisibility();
644 void UpdateLayersColor(
bool aVisibility,
const std::function<
bool(
int )>& aLayers );
653 virtual void SetTopLayer(
int aLayer,
bool aEnabled =
true );
664 virtual void EnableTopLayer(
bool aEnable );
666 virtual int GetTopLayer()
const;
672 void ClearTopLayers();
679 void UpdateAllLayersOrder();
689 virtual void Redraw();
694 void RecacheAllItems();
752 void markSceneEdited();
757 void MarkStaticDirty();
763 void SyncRetainedScene();
838 void UpdateAllItems(
int aUpdateFlags );
846 void UpdateAllItemsConditionally(
int aUpdateFlags,
847 std::function<
bool(
VIEW_ITEM* )> aCondition );
854 void UpdateAllItemsConditionally( std::function<
int(
VIEW_ITEM* )> aItemFlagsProvider );
882 std::shared_ptr<VIEW_OVERLAY> MakeOverlay();
887 void AddToPreview(
VIEW_ITEM* aItem,
bool aTakeOwnership =
true );
889 void ShowPreview(
bool aShow =
true );
896 std::unique_ptr<VIEW> DataReference()
const;
925 return id < aOther.
id;
941 void redrawRect(
const BOX2I& aRect );
947 void placeCachedGroup(
VIEW_ITEM* aItem,
int aLayer,
949 double cachedGroupLOD(
VIEW_ITEM* aItem,
int aLayer );
956 void placeRetainedInOrder(
const std::vector<LAYER_ITEM_PAIR>& aItems,
bool aReplacing );
963 void layerStateChanged(
int aLayer );
968 void noteLodRead(
int aLayer )
const;
988 void draw(
VIEW_ITEM* aItem,
int aLayer,
bool aImmediate =
false );
997 void draw(
VIEW_ITEM* aItem,
bool aImmediate =
false );
1006 void draw(
VIEW_GROUP* aGroup,
bool aImmediate =
false );
1010 void clearGroupCache();
1018 void invalidateItem(
VIEW_ITEM* aItem,
int aUpdateFlags );
1024 void recolorAllLayers(
bool aReplace,
const std::function<
bool(
int )>& aLayers = {} );
1029 void markDimExemption(
const VIEW_ITEM* aItem,
int aGroup );
1032 void updateItemColor( VIEW_ITEM* aItem,
int aLayer );
1034 void recolorGroup( VIEW_ITEM* aItem,
int aLayer,
int aGroup );
1039 void releaseReplacedGroup( VIEW_ITEM* aItem,
int aLayer );
1044 void releaseReplacedGroups();
1047 void updateItemGeometry( VIEW_ITEM* aItem,
int aLayer,
bool aPlace =
true );
1050 void updateBbox( VIEW_ITEM* aItem );
1053 void updateLayers( VIEW_ITEM* aItem );
1062 bool areRequiredLayersEnabled(
int aLayerId )
const;
1065 struct CLEAR_LAYER_CACHE_VISITOR;
1066 struct RECACHE_ITEM_VISITOR;
1067 struct DRAW_ITEM_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.
Implement a non-owning R-tree for fast spatial indexing of VIEW items.
bool m_layerCachesStale
A layer's visibility or target changed since SyncLayerVisibilityCache() last copied them.
std::vector< int > m_lodRefreshLayers
Layers shown or hidden since the last sync, whose readers have to be placed again.
bool m_cameraDirtyOnly
The current dirty state is due only to camera changes.
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).
void CopySettings(const VIEW *aOtherView)
Copy layers and visibility settings from another view.
static constexpr int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
VIEW(const VIEW &)=delete
SCALE_USE * m_keptScaleUse
The SCALE_USE of the kept target being drawn, updated by each level of detail drawn.
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
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.
bool m_targetEdited[TARGETS_NUMBER]
The target's content changed, not just the camera.
int m_lodProbeLayer
Cached layer being placed while an item is asked for its level of detail, else -1.
void SetRequired(int aLayerId, int aRequiredId, bool aRequired=true)
Mark the aRequiredId layer as required for the aLayerId layer.
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.
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.
void SetPainter(PAINTER *aPainter)
Set the painter object used by the view for drawing VIEW_ITEM objects.
std::vector< std::pair< VIEW_ITEM *, int > > m_deferredRetainedPlacements
void SetBoundary(const BOX2D &aBoundary)
Set limits for view area.
void MarkStaticDirty()
Flag the GAL's static geometry pool as dirty so the next full redraw rebuilds it.
bool m_deferRetainedPlacement
bool HasPendingItemUpdates() const
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
Flat list of all items.
void MarkGeometryDirty()
Signal a change to cached geometry so the next paint leaves the camera-reuse path and rebuilds the st...
void rescaleKeptTargets()
Mark the kept targets whose content the new scale changes, so they are emitted again.
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.
int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
std::vector< VIEW_ITEM * > m_ownedItems
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 SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
bool IsCameraDirtyOnly() const
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
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.
SCALE_USE m_scaleUse[TARGETS_NUMBER]
GAL * GetGAL() const
Return the GAL this view is using to draw graphical primitives.
bool IsHiddenOnOverlay(const VIEW_ITEM *aItem) const
bool m_dirtyTargets[TARGETS_NUMBER]
Flag to mark targets as dirty so they have to be redrawn on the next refresh event.
void MarkClean()
Force redraw of view on the next rendering.
static constexpr int VIEW_MAX_LAYERS
Maximum number of layers that may be shown.
void layerStateChanged(int aLayer)
React to a change of a layer's visibility, order, required layers or negatives.
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.
bool m_pendingListIncomplete
Items were flagged without being listed, so UpdateItems() has to scan them all.
void SetBoundary(const BOX2I &aBoundary)
Set limits for view area.
int m_nextDrawPriority
The next sequential drawing priority.
bool m_scaleRead
GetScale() was called, see SCALE_USE::read.
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
bool IsLayerVisibleCached(int aLayer) const
void MarkViewportDirty()
Force a redraw for a camera change alone, which lets the paint reuse the cached scene.
bool IsCached(int aLayer) const
Return true if the layer is cached.
void AddBatch(const std::vector< VIEW_ITEM * > &aItems)
Add a batch of items to the view, using bulk-loaded R-trees for initial population.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
bool IsMirroredY() const
Return true if view is flipped across the Y axis.
BASE_SET m_layerVisibilityCache
void UseDrawPriority(bool aFlag)
bool m_hasPendingItemUpdates
True when at least one item has deferred update flags that still need processing.
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
void clearPendingItems()
Empty m_pendingItems and forget each listed item's place in it.
VIEW & operator=(const VIEW &)=delete
bool m_sceneLayersStale
A layer's order, visibility, required layers or negatives changed since the last sync.
std::vector< VIEW_ITEM * > m_pendingItems
Items flagged through Update() since the last UpdateItems(), so a frame that changed a few items need...
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 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.
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
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.
void noteLodRead(int aLayer) const
Record that the item being placed asked whether aLayer is visible.
void noteKeptLod(double aLod) const
std::map< std::pair< VIEW_ITEM *, int >, int > m_replacedRetainedGroups
Groups replaced by items redrawn during a deferred placement.
const BOX2D & GetBoundary() const
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
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.
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
BASE_SET m_layerCachedFlagCache
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
#define MAX_LAYERS_FOR_VIEW
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.
How the content of a kept target depends on the scale it was emitted at.
bool read
something was sized from the scale
double lodAbove
nearest threshold above it
double lodBelow
nearest threshold under that scale
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.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D