KiCad PCB EDA Suite
view.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013-2016 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef __VIEW_H
26 #define __VIEW_H
27 
28 #include <vector>
29 #include <set>
30 #include <unordered_map>
31 #include <memory>
32 
33 #include <math/box2.h>
34 #include <gal/definitions.h>
35 
36 #include <view/view_overlay.h>
37 
38 namespace KIGFX
39 {
40 class PAINTER;
41 class GAL;
42 class VIEW_ITEM;
43 class VIEW_GROUP;
44 class VIEW_RTREE;
45 
61 class VIEW
62 {
63 public:
64  friend class VIEW_ITEM;
65 
66  typedef std::pair<VIEW_ITEM*, int> LAYER_ITEM_PAIR;
67 
72  VIEW( bool aIsDynamic = true );
73 
74  virtual ~VIEW();
75 
76  // nasty hack, invoked by the destructor of VIEW_ITEM to auto-remove the item
77  // from the owning VIEW if there is any. Kicad relies too much on this mechanism.
78  // this is the only linking dependency now between EDA_ITEM and VIEW class. In near future
79  // I'll replace it with observers.
80  static void OnDestroy( VIEW_ITEM* aItem );
81 
89  virtual void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 );
90 
96  virtual void Remove( VIEW_ITEM* aItem );
97 
98 
108  virtual int Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const;
109 
116  void SetVisible( VIEW_ITEM* aItem, bool aIsVisible = true );
117 
124  void Hide( VIEW_ITEM* aItem, bool aHide = true );
125 
133  bool IsVisible( const VIEW_ITEM* aItem ) const;
134 
142  virtual void Update( VIEW_ITEM* aItem, int aUpdateFlags );
143  virtual void Update( VIEW_ITEM* aItem );
144 
153  void SetRequired( int aLayerId, int aRequiredId, bool aRequired = true );
154 
160  void CopySettings( const VIEW* aOtherView );
161 
162  /*
163  * Convenience wrappers for adding multiple items
164  * template <class T> void AddItems( const T& aItems );
165  * template <class T> void RemoveItems( const T& aItems );
166  */
167 
173  void SetGAL( GAL* aGal );
174 
180  inline GAL* GetGAL() const
181  {
182  return m_gal;
183  }
184 
189  inline void SetPainter( PAINTER* aPainter )
190  {
191  m_painter = aPainter;
192  }
193 
199  inline PAINTER* GetPainter() const
200  {
201  return m_painter;
202  }
203 
209  void SetViewport( const BOX2D& aViewport );
210 
216  BOX2D GetViewport() const;
217 
224  void SetMirror( bool aMirrorX, bool aMirrorY );
225 
230  bool IsMirroredX() const
231  {
232  return m_mirrorX;
233  }
234 
239  bool IsMirroredY() const
240  {
241  return m_mirrorY;
242  }
243 
250  inline void SetScale( double aScale )
251  {
252  SetScale( aScale, m_center );
253  }
254 
262  void SetScale( double aScale, const VECTOR2D& aAnchor );
263 
268  inline double GetScale() const
269  {
270  return m_scale;
271  }
272 
278  inline void SetBoundary( const BOX2D& aBoundary )
279  {
280  m_boundary = aBoundary;
281  }
282 
288  inline void SetBoundary( const BOX2I& aBoundary )
289  {
290  m_boundary.SetOrigin( aBoundary.GetOrigin() );
291  m_boundary.SetEnd( aBoundary.GetEnd() );
292  }
293 
298  inline const BOX2D& GetBoundary() const
299  {
300  return m_boundary;
301  }
302 
309  void SetScaleLimits( double aMaximum, double aMinimum )
310  {
311  wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
312 
313  m_minScale = aMinimum;
314  m_maxScale = aMaximum;
315  }
316 
323  void SetCenter( const VECTOR2D& aCenter );
324 
332  void SetCenter( VECTOR2D aCenter, const BOX2D& occultingScreenRect );
333 
339  const VECTOR2D& GetCenter() const
340  {
341  return m_center;
342  }
343 
350  VECTOR2D ToWorld( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
351 
358  double ToWorld( double aSize ) const;
359 
366  VECTOR2D ToScreen( const VECTOR2D& aCoord, bool aAbsolute = true ) const;
367 
373  double ToScreen( double aSize ) const;
374 
380  const VECTOR2I& GetScreenPixelSize() const;
381 
389  void AddLayer( int aLayer, bool aDisplayOnly = false );
390 
396  void ClearLayer( int aLayer );
397 
402  void Clear();
403 
410  inline void SetLayerVisible( int aLayer, bool aVisible = true )
411  {
412  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
413 
414  if( m_layers[aLayer].visible != aVisible )
415  {
416  // Target has to be redrawn after changing its visibility
417  MarkTargetDirty( m_layers[aLayer].target );
418  m_layers[aLayer].visible = aVisible;
419  }
420  }
421 
427  inline bool IsLayerVisible( int aLayer ) const
428  {
429  wxCHECK( aLayer < (int) m_layers.size(), false );
430  return m_layers.at( aLayer ).visible;
431  }
432 
433  inline void SetLayerDisplayOnly( int aLayer, bool aDisplayOnly = true )
434  {
435  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
436  m_layers[aLayer].displayOnly = aDisplayOnly;
437  }
438 
445  inline void SetLayerTarget( int aLayer, RENDER_TARGET aTarget )
446  {
447  wxCHECK( aLayer < (int) m_layers.size(), /*void*/ );
448  m_layers[aLayer].target = aTarget;
449  }
450 
457  void SetLayerOrder( int aLayer, int aRenderingOrder );
458 
465  int GetLayerOrder( int aLayer ) const;
466 
475  void SortLayers( int aLayers[], int& aCount ) const;
476 
484  void ReorderLayerData( std::unordered_map<int, int> aReorderMap );
485 
492  void UpdateLayerColor( int aLayer );
493 
499  void UpdateAllLayersColor();
500 
508  virtual void SetTopLayer( int aLayer, bool aEnabled = true );
509 
517  virtual void EnableTopLayer( bool aEnable );
518 
519  virtual int GetTopLayer() const;
520 
526  void ClearTopLayers();
527 
533  void UpdateAllLayersOrder();
534 
539  void ClearTargets();
540 
545  virtual void Redraw();
546 
551  void RecacheAllItems();
552 
558  bool IsDynamic() const
559  {
560  return m_dynamic;
561  }
562 
568  bool IsDirty() const
569  {
570  for( int i = 0; i < TARGETS_NUMBER; ++i )
571  {
572  if( IsTargetDirty( i ) )
573  return true;
574  }
575 
576  return false;
577  }
578 
585  bool IsTargetDirty( int aTarget ) const
586  {
587  wxCHECK( aTarget < TARGETS_NUMBER, false );
588  return m_dirtyTargets[aTarget];
589  }
590 
596  inline void MarkTargetDirty( int aTarget )
597  {
598  wxCHECK( aTarget < TARGETS_NUMBER, /* void */ );
599  m_dirtyTargets[aTarget] = true;
600  }
601 
603  inline bool IsCached( int aLayer ) const
604  {
605  wxCHECK( aLayer < (int) m_layers.size(), false );
606 
607  try
608  {
609  return m_layers.at( aLayer ).target == TARGET_CACHED;
610  }
611  catch( const std::out_of_range& )
612  {
613  return false;
614  }
615  }
616 
621  void MarkDirty()
622  {
623  for( int i = 0; i < TARGETS_NUMBER; ++i )
624  m_dirtyTargets[i] = true;
625  }
626 
632  void MarkForUpdate( VIEW_ITEM* aItem );
633 
638  void UpdateItems();
639 
644  void UpdateAllItems( int aUpdateFlags );
645 
651  void UpdateAllItemsConditionally( int aUpdateFlags,
652  std::function<bool( VIEW_ITEM* )> aCondition );
653 
658  bool IsUsingDrawPriority() const
659  {
660  return m_useDrawPriority;
661  }
662 
667  void UseDrawPriority( bool aFlag )
668  {
669  m_useDrawPriority = aFlag;
670  }
671 
676  bool IsDrawOrderReversed() const
677  {
678  return m_reverseDrawOrder;
679  }
680 
686  void ReverseDrawOrder( bool aFlag )
687  {
688  m_reverseDrawOrder = aFlag;
689  }
690 
691  std::shared_ptr<VIEW_OVERLAY> MakeOverlay();
692 
697  std::unique_ptr<VIEW> DataReference() const;
698 
703  int GetPrintMode() { return m_printMode; }
704 
710  void SetPrintMode( int aPrintMode ) { m_printMode = aPrintMode; }
711 
712  static constexpr int VIEW_MAX_LAYERS = 512;
713 
714 protected:
715  struct VIEW_LAYER
716  {
717  bool visible;
718  bool displayOnly;
719  std::shared_ptr<VIEW_RTREE> items;
721  int id;
723  std::set<int> requiredLayers;
724  };
725 
726  // Convenience typedefs
727  typedef std::unordered_map<int, VIEW_LAYER> LAYER_MAP;
728  typedef LAYER_MAP::iterator LAYER_MAP_ITER;
729  typedef std::vector<VIEW_LAYER*> LAYER_ORDER;
730  typedef std::vector<VIEW_LAYER*>::iterator LAYER_ORDER_ITER;
731 
732  // Function objects that need to access VIEW/VIEW_ITEM private/protected members
733  struct clearLayerCache;
734  struct recacheItem;
735  struct drawItem;
736  struct unlinkItem;
737  struct updateItemsColor;
738  struct changeItemsDepth;
739  struct extentsVisitor;
740 
741 
743  void redrawRect( const BOX2I& aRect );
744 
745  inline void markTargetClean( int aTarget )
746  {
747  wxCHECK( aTarget < TARGETS_NUMBER, /* void */ );
748  m_dirtyTargets[aTarget] = false;
749  }
750 
761  void draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate = false );
762 
771  void draw( VIEW_ITEM* aItem, bool aImmediate = false );
772 
781  void draw( VIEW_GROUP* aGroup, bool aImmediate = false );
782 
784  void sortLayers();
785 
788  void clearGroupCache();
789 
796  void invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags );
797 
799  void updateItemColor( VIEW_ITEM* aItem, int aLayer );
800 
802  void updateItemGeometry( VIEW_ITEM* aItem, int aLayer );
803 
805  void updateBbox( VIEW_ITEM* aItem );
806 
808  void updateLayers( VIEW_ITEM* aItem );
809 
812  {
813  return aI->renderingOrder > aJ->renderingOrder;
814  }
815 
817  bool areRequiredLayersEnabled( int aLayerId ) const;
818 
821 
824 
826  std::shared_ptr<std::vector<VIEW_ITEM*>> m_allItems;
827 
830 
832  std::set<unsigned int> m_topLayers;
833 
836 
838  double m_scale;
839 
842 
844  double m_minScale;
845 
847  double m_maxScale;
848 
850  bool m_mirrorX;
851 
853  bool m_mirrorY;
854 
857 
860 
863  bool m_dynamic;
864 
867 
869  static const int TOP_LAYER_MODIFIER;
870 
874 
877 
880 
884 
885  VIEW( const VIEW& ) = delete;
886 };
887 } // namespace KIGFX
888 
889 #endif
void MarkForUpdate(VIEW_ITEM *aItem)
Function MarkForUpdate() Adds an item to a list of items that are going to be refreshed upon the next...
void SetScaleLimits(double aMaximum, double aMinimum)
Function SetScaleLimits() Sets minimum and maximum values for scale.
Definition: view.h:309
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1506
Number of available rendering targets.
Definition: definitions.h:51
bool IsDrawOrderReversed() const
Function IsDrawOrderReversed()
Definition: view.h:676
BOX2D GetViewport() const
Function GetViewport() Returns the current viewport visible area rectangle.
Definition: view.cpp:538
void SetViewport(const BOX2D &aViewport)
Function SetViewport() Sets the visible area of the VIEW.
Definition: view.cpp:550
void updateLayers(VIEW_ITEM *aItem)
Updates set of layers that an item occupies.
Definition: view.cpp:1340
void AddLayer(int aLayer, bool aDisplayOnly=false)
Function AddLayer() Adds a new layer to the view.
Definition: view.cpp:331
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1457
void ReverseDrawOrder(bool aFlag)
Function ReverseDrawOrder() Only takes effect if UseDrawPriority is true.
Definition: view.h:686
void SetLayerOrder(int aLayer, int aRenderingOrder)
Function SetLayerOrder() Sets rendering order of a particular layer.
Definition: view.cpp:663
void SetRequired(int aLayerId, int aRequiredId, bool aRequired=true)
Function SetRequired() Marks the aRequiredId layer as required for the aLayerId layer.
Definition: view.cpp:416
void updateItemColor(VIEW_ITEM *aItem, int aLayer)
Updates colors that are used for an item to be drawn.
Definition: view.cpp:1275
bool m_useDrawPriority
Flat list of all items Flag to respect draw priority when drawing items.
Definition: view.h:873
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
const BOX2D & GetBoundary() const
Function GetBoundary()
Definition: view.h:298
virtual void SetTopLayer(int aLayer, bool aEnabled=true)
Function SetTopLayer() Sets given layer to be displayed on the top or sets back the default order of ...
Definition: view.cpp:859
static const int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:869
const Vec GetEnd() const
Definition: box2.h:193
void sortLayers()
Definition: view.cpp:1260
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:475
const VECTOR2D & GetCenter() const
Function GetCenter() Returns the center point of this VIEW (in world space coordinates)
Definition: view.h:339
void UseDrawPriority(bool aFlag)
Function UseDrawPriority()
Definition: view.h:667
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1443
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:859
bool areRequiredLayersEnabled(int aLayerId) const
Checks if every layer required by the aLayerId layer is enabled.
Definition: view.cpp:1383
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
std::set< unsigned int > m_topLayers
Stores set of layers that are displayed on the top.
Definition: view.h:832
void UpdateAllLayersOrder()
Function UpdateLayerOrder() Does everything that is needed to apply the rendering order of layers.
Definition: view.cpp:926
void SetMirror(bool aMirrorX, bool aMirrorY)
Function SetMirror() Controls the mirroring of the VIEW.
Definition: view.cpp:565
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:250
std::shared_ptr< VIEW_OVERLAY > MakeOverlay()
Definition: view.cpp:1553
std::vector< VIEW_LAYER * > LAYER_ORDER
Definition: view.h:729
virtual void EnableTopLayer(bool aEnable)
Function EnableTopLayer() Enables or disables display of the top layer.
Definition: view.cpp:886
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:835
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
static constexpr int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:712
bool IsUsingDrawPriority() const
Function IsUsingDrawPriority()
Definition: view.h:658
void SetBoundary(const BOX2I &aBoundary)
Function SetBoundary() Sets limits for view area.
Definition: view.h:288
std::shared_ptr< std::vector< VIEW_ITEM * > > m_allItems
Flat list of all items.
Definition: view.h:826
void SortLayers(int aLayers[], int &aCount) const
Function SortLayers() Changes the order of given layer ids, so after sorting the order corresponds to...
Definition: view.cpp:677
double m_minScale
Scale lower limit.
Definition: view.h:844
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Function SetLayerTarget() Changes the rendering target for a particular layer.
Definition: view.h:445
void SetPrintMode(int aPrintMode)
Set the printing mode.
Definition: view.h:710
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:313
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:601
virtual void Redraw()
Function Redraw() Immediately redraws the whole view.
Definition: view.cpp:1144
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:596
bool IsTargetDirty(int aTarget) const
Function IsTargetDirty() Returns true if any of layers belonging to the target or the target itself s...
Definition: view.h:585
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1110
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1525
bool visible
is the layer to be rendered?
Definition: view.h:717
virtual int GetTopLayer() const
Definition: view.cpp:850
void SetLayerDisplayOnly(int aLayer, bool aDisplayOnly=true)
Definition: view.h:433
std::unordered_map< int, VIEW_LAYER > LAYER_MAP
Definition: view.h:727
bool m_mirrorX
Horizontal flip flag
Definition: view.h:850
void invalidateItem(VIEW_ITEM *aItem, int aUpdateFlags)
Function invalidateItem() Manages dirty flags & redraw queueing when updating an item.
Definition: view.cpp:1215
const VECTOR2I & GetScreenPixelSize() const
Function GetScreenPixelSize() Returns the size of the our rendering area, in pixels.
Definition: view.cpp:1176
bool m_dynamic
Dynamic VIEW (eg.
Definition: view.h:863
int id
layer ID
Definition: view.h:721
LAYER_ORDER m_orderedLayers
Sorted list of pointers to members of m_layers.
Definition: view.h:829
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:410
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:705
void UpdateItems()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them.
Definition: view.cpp:1420
void markTargetClean(int aTarget)
Definition: view.h:745
void updateBbox(VIEW_ITEM *aItem)
Updates bounding box of an item.
Definition: view.cpp:1324
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:856
bool IsDynamic() const
Function IsDynamic() Tells if the VIEW is dynamic (ie.
Definition: view.h:558
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:879
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1539
int m_nextDrawPriority
The next sequential drawing priority.
Definition: view.h:876
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToScreen() Converts a world space point/vector to a point/vector in screen space coordinates...
Definition: view.cpp:494
void ClearTopLayers()
Function ClearTopLayers() Removes all layers from the on-the-top set (they are no longer displayed ov...
Definition: view.cpp:911
bool IsMirroredX() const
Function IsMirroredX() Returns true if view is flipped across the X axis.
Definition: view.h:230
LAYER_MAP::iterator LAYER_MAP_ITER
Definition: view.h:728
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:223
void clearGroupCache()
Definition: view.cpp:1200
double m_maxScale
Scale upper limit.
Definition: view.h:847
void UpdateLayerColor(int aLayer)
Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it h...
Definition: view.cpp:776
std::unique_ptr< VIEW > DataReference() const
Returns a new VIEW object that shares the same set of VIEW_ITEMs and LAYERs.
Definition: view.cpp:1475
int GetPrintMode()
Definition: view.h:703
bool m_dirtyTargets[TARGETS_NUMBER]
Flags to mark targets as dirty, so they have to be redrawn on the next refresh event.
Definition: view.h:866
void redrawRect(const BOX2I &aRect)
Definition: view.cpp:1009
void updateItemGeometry(VIEW_ITEM *aItem, int aLayer)
Updates all informations needed to draw an item.
Definition: view.cpp:1294
Main rendering target (cached)
Definition: definitions.h:48
bool m_enableOrderModifier
Definition: view.h:820
static void OnDestroy(VIEW_ITEM *aItem)
Definition: view.cpp:271
BOX2D m_boundary
View boundaries.
Definition: view.h:841
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:66
int GetLayerOrder(int aLayer) const
Function GetLayerOrder() Returns rendering order of a particular layer.
Definition: view.cpp:671
size_t i
Definition: json11.cpp:597
void draw(VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
Function draw() Draws an item, but on a specified layers.
Definition: view.cpp:1028
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:603
void SetOrigin(const Vec &pos)
Definition: box2.h:208
bool m_mirrorY
Vertical flip flag
Definition: view.h:853
void ClearTargets()
Function ClearTargets() Clears targets that are marked as dirty.
Definition: view.cpp:1125
std::vector< VIEW_LAYER * >::iterator LAYER_ORDER_ITER
Definition: view.h:730
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1485
void CopySettings(const VIEW *aOtherView)
Function CopySettings() Copies layers and visibility settings from another view.
Definition: view.cpp:513
void SetPainter(PAINTER *aPainter)
Function SetPainter() Sets the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:189
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:823
double m_scale
Scale of displayed VIEW_ITEMs.
Definition: view.h:838
int renderingOrder
rendering order of this layer
Definition: view.h:720
bool displayOnly
is the layer display only?
Definition: view.h:718
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Function Query() Finds all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:452
bool IsMirroredY() const
Function IsMirroredX() Returns true if view is flipped across the Y axis.
Definition: view.h:239
virtual ~VIEW()
Definition: view.cpp:326
const Vec & GetOrigin() const
Definition: box2.h:191
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition: definitions.h:46
VIEW(bool aIsDynamic=true)
Constructor.
Definition: view.cpp:286
Class VIEW.
Definition: view.h:61
void SetBoundary(const BOX2D &aBoundary)
Function SetBoundary() Sets limits for view area.
Definition: view.h:278
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:797
double GetScale() const
Function GetScale()
Definition: view.h:268
void SetGAL(GAL *aGal)
Function SetGAL() Assigns a rendering device for the VIEW.
Definition: view.cpp:519
int m_printMode
A control for printing: m_printMode <= 0 means no printing mode (normal draw mode m_printMode > 0 is ...
Definition: view.h:883
void ClearLayer(int aLayer)
Function ClearLayer() Removes all items from a given layer.
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Determines rendering order of layers. Used in display order sorting function.
Definition: view.h:811
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:621
std::set< int > requiredLayers
layers that have to be enabled to show the layer
Definition: view.h:723
bool IsDirty() const
Function IsDirty() Returns true if any of the VIEW layers needs to be refreshened.
Definition: view.h:568
Class GAL is the abstract interface for drawing on a 2D-surface.
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:427
RENDER_TARGET target
where the layer should be rendered
Definition: view.h:722
std::shared_ptr< VIEW_RTREE > items
R-tree indexing all items on this layer.
Definition: view.h:719