33#include <unordered_map>
77 VIEW(
bool aIsDynamic =
true );
88 static void OnDestroy(
VIEW_ITEM* aItem );
98 virtual void Add(
VIEW_ITEM* aItem,
int aDrawPriority = -1 );
116 int Query(
const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult )
const;
123 void Query(
const BOX2I& aRect,
const std::function<
bool(
VIEW_ITEM* )>& aFunc )
const;
131 void SetVisible(
VIEW_ITEM* aItem,
bool aIsVisible =
true );
140 void Hide(
VIEW_ITEM* aItem,
bool aHide =
true,
bool aHideOverlay =
false );
149 bool IsVisible(
const VIEW_ITEM* aItem )
const;
151 bool IsHiddenOnOverlay(
const VIEW_ITEM* aItem )
const;
156 bool HasItem(
const VIEW_ITEM* aItem )
const;
165 virtual void Update(
const VIEW_ITEM* aItem,
int aUpdateFlags )
const;
166 virtual void Update(
const VIEW_ITEM* aItem )
const;
176 void SetRequired(
int aLayerId,
int aRequiredId,
bool aRequired =
true );
183 void CopySettings(
const VIEW* aOtherView );
196 void SetGAL(
GAL* aGal );
213 m_painter = aPainter;
231 void SetViewport(
const BOX2D& aViewport );
238 BOX2D GetViewport()
const;
246 void SetMirror(
bool aMirrorX,
bool aMirrorY );
272 virtual void SetScale(
double aScale,
VECTOR2D aAnchor = { 0, 0 } );
289 m_boundary = aBoundary;
299 m_boundary.SetOrigin( aBoundary.
GetOrigin() );
300 m_boundary.SetEnd( aBoundary.
GetEnd() );
319 wxASSERT_MSG( aMaximum > aMinimum, wxT(
"I guess you passed parameters in wrong order" ) );
321 m_minScale = aMinimum;
322 m_maxScale = aMaximum;
331 void SetCenter(
const VECTOR2D& aCenter );
340 void SetCenter(
const VECTOR2D& aCenter,
const std::vector<BOX2D>& obscuringScreenRects );
366 double ToWorld(
double aSize )
const;
381 double ToScreen(
double aSize )
const;
388 const VECTOR2I& GetScreenPixelSize()
const;
403 wxCHECK( aLayer < (
int) m_layers.size(), );
405 if( m_layers[aLayer].visible != aVisible )
408 MarkTargetDirty( m_layers[aLayer].target );
409 m_layers[aLayer].visible = aVisible;
420 wxCHECK( aLayer >= 0,
false);
421 wxCHECK( aLayer < (
int) m_layers.size(),
false );
423 return m_layers.at( aLayer ).visible;
434 wxCHECK( aLayer < (
int) m_layers.size(), );
436 if( m_layers[aLayer].diffLayer != aDiff )
439 MarkTargetDirty( m_layers[aLayer].target );
440 m_layers[aLayer].diffLayer = aDiff;
452 wxCHECK( aLayer < (
int) m_layers.size(), );
454 if( m_layers[aLayer].hasNegatives != aNegatives )
457 MarkTargetDirty( m_layers[aLayer].target );
458 m_layers[aLayer].hasNegatives = aNegatives;
467 wxCHECK( aLayer < (
int) m_layers.size(), );
468 m_layers[aLayer].displayOnly = aDisplayOnly;
479 wxCHECK( aLayer < (
int) m_layers.size(), );
480 m_layers[aLayer].target = aTarget;
489 void SetLayerOrder(
int aLayer,
int aRenderingOrder );
497 int GetLayerOrder(
int aLayer )
const;
507 void SortLayers(
int aLayers[],
int& aCount )
const;
516 void ReorderLayerData( std::unordered_map<int, int> aReorderMap );
524 void UpdateLayerColor(
int aLayer );
531 void UpdateAllLayersColor();
540 virtual void SetTopLayer(
int aLayer,
bool aEnabled =
true );
551 virtual void EnableTopLayer(
bool aEnable );
553 virtual int GetTopLayer()
const;
559 void ClearTopLayers();
566 void UpdateAllLayersOrder();
576 virtual void Redraw();
581 void RecacheAllItems();
601 if( IsTargetDirty( i ) )
617 return m_dirtyTargets[aTarget];
628 m_dirtyTargets[aTarget] =
true;
634 wxCHECK( aLayer < (
int) m_layers.size(),
false );
640 catch(
const std::out_of_range& )
652 m_dirtyTargets[i] =
true;
661 m_dirtyTargets[i] =
false;
674 void UpdateAllItems(
int aUpdateFlags );
682 void UpdateAllItemsConditionally(
int aUpdateFlags,
683 std::function<
bool(
VIEW_ITEM* )> aCondition );
690 void UpdateAllItemsConditionally( std::function<
int(
VIEW_ITEM* )> aItemFlagsProvider );
697 return m_useDrawPriority;
705 m_useDrawPriority = aFlag;
715 m_reverseDrawOrder = aFlag;
718 std::shared_ptr<VIEW_OVERLAY> MakeOverlay();
723 void AddToPreview(
VIEW_ITEM* aItem,
bool aTakeOwnership =
true );
725 void ShowPreview(
bool aShow =
true );
732 std::unique_ptr<VIEW> DataReference()
const;
735 static constexpr int VIEW_MAX_LAYERS = 512;
738 static constexpr int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
760 void redrawRect(
const BOX2I& aRect );
765 m_dirtyTargets[aTarget] =
false;
779 void draw(
VIEW_ITEM* aItem,
int aLayer,
bool aImmediate =
false );
788 void draw(
VIEW_ITEM* aItem,
bool aImmediate =
false );
797 void draw(
VIEW_GROUP* aGroup,
bool aImmediate =
false );
804 void clearGroupCache();
812 void invalidateItem(
VIEW_ITEM* aItem,
int aUpdateFlags );
815 void updateItemColor(
VIEW_ITEM* aItem,
int aLayer );
818 void updateItemGeometry(
VIEW_ITEM* aItem,
int aLayer );
833 bool areRequiredLayersEnabled(
int aLayerId )
const;
836 struct CLEAR_LAYER_CACHE_VISITOR;
837 struct RECACHE_ITEM_VISITOR;
838 struct DRAW_ITEM_VISITOR;
839 struct UPDATE_COLOR_VISITOR;
840 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...
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.
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).
VIEW(const VIEW &)=delete
std::vector< VIEW_ITEM * > m_ownedItems
Whether to use rendering order modifier or not.
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.
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.
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.
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
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
Interface to #PAINTER that is used to draw items.
std::set< unsigned int > m_topLayers
Center point of the VIEW (the point at which we are looking at).
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.
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
Flag to reverse the draw order when using draw priority.
bool m_useDrawPriority
The next sequential drawing priority.
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
GAL * m_gal
Dynamic VIEW (eg.
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
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
Flat list of all items.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
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.