KiCad PCB EDA Suite
KIGFX::VIEW Class Reference

Class VIEW. More...

#include <view.h>

Inheritance diagram for KIGFX::VIEW:
KIGFX::PCB_VIEW KIGFX::SCH_VIEW

Classes

struct  changeItemsDepth
 
struct  clearLayerCache
 
struct  drawItem
 
struct  extentsVisitor
 
struct  recacheItem
 
struct  updateItemsColor
 
struct  VIEW_LAYER
 

Public Types

typedef std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
 

Public Member Functions

 VIEW (bool aIsDynamic=true)
 Constructor. More...
 
virtual ~VIEW ()
 
virtual void Add (VIEW_ITEM *aItem, int aDrawPriority=-1)
 Function Add() Adds a VIEW_ITEM to the view. More...
 
virtual void Remove (VIEW_ITEM *aItem)
 Function Remove() Removes a VIEW_ITEM from the view. More...
 
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. More...
 
void SetVisible (VIEW_ITEM *aItem, bool aIsVisible=true)
 Sets the item visibility. More...
 
void Hide (VIEW_ITEM *aItem, bool aHide=true)
 Temporarily hides the item in the view (e.g. More...
 
bool IsVisible (const VIEW_ITEM *aItem) const
 Returns information if the item is visible (or not). More...
 
virtual void Update (VIEW_ITEM *aItem, int aUpdateFlags)
 For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has changed. More...
 
virtual void Update (VIEW_ITEM *aItem)
 
void SetRequired (int aLayerId, int aRequiredId, bool aRequired=true)
 Function SetRequired() Marks the aRequiredId layer as required for the aLayerId layer. More...
 
void CopySettings (const VIEW *aOtherView)
 Function CopySettings() Copies layers and visibility settings from another view. More...
 
void SetGAL (GAL *aGal)
 Function SetGAL() Assigns a rendering device for the VIEW. More...
 
GALGetGAL () const
 Function GetGAL() Returns the GAL this view is using to draw graphical primitives. More...
 
void SetPainter (PAINTER *aPainter)
 Function SetPainter() Sets the painter object used by the view for drawing VIEW_ITEMS. More...
 
PAINTERGetPainter () const
 Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS. More...
 
void SetViewport (const BOX2D &aViewport)
 Function SetViewport() Sets the visible area of the VIEW. More...
 
BOX2D GetViewport () const
 Function GetViewport() Returns the current viewport visible area rectangle. More...
 
void SetMirror (bool aMirrorX, bool aMirrorY)
 Function SetMirror() Controls the mirroring of the VIEW. More...
 
bool IsMirroredX () const
 Function IsMirroredX() Returns true if view is flipped across the X axis. More...
 
bool IsMirroredY () const
 Function IsMirroredX() Returns true if view is flipped across the Y axis. More...
 
void SetScale (double aScale)
 Function SetScale() Sets the scaling factor. More...
 
void SetScale (double aScale, const VECTOR2D &aAnchor)
 Function SetScale() Sets the scaling factor, zooming around a given anchor point. More...
 
double GetScale () const
 Function GetScale() More...
 
void SetBoundary (const BOX2D &aBoundary)
 Function SetBoundary() Sets limits for view area. More...
 
void SetBoundary (const BOX2I &aBoundary)
 Function SetBoundary() Sets limits for view area. More...
 
const BOX2DGetBoundary () const
 Function GetBoundary() More...
 
void SetScaleLimits (double aMaximum, double aMinimum)
 Function SetScaleLimits() Sets minimum and maximum values for scale. More...
 
void SetCenter (const VECTOR2D &aCenter)
 Function SetCenter() Sets the center point of the VIEW (i.e. More...
 
void SetCenter (VECTOR2D aCenter, const BOX2D &occultingScreenRect)
 Function SetCenter() Sets the center point of the VIEW, attempting to avoid occultingScreenRect (for instance, the screen rect of a modeless dialog in front of the VIEW). More...
 
const VECTOR2DGetCenter () const
 Function GetCenter() Returns the center point of this VIEW (in world space coordinates) More...
 
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. More...
 
double ToWorld (double aSize) const
 Function ToWorld() Converts a screen space one dimensional size to a one dimensional size in world space coordinates. More...
 
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. More...
 
double ToScreen (double aSize) const
 Function ToScreen() Converts a world space one dimensionsal size to a one dimensional size in screen space. More...
 
const VECTOR2IGetScreenPixelSize () const
 Function GetScreenPixelSize() Returns the size of the our rendering area, in pixels. More...
 
void AddLayer (int aLayer, bool aDisplayOnly=false)
 Function AddLayer() Adds a new layer to the view. More...
 
void ClearLayer (int aLayer)
 Function ClearLayer() Removes all items from a given layer. More...
 
void Clear ()
 Function Clear() Removes all items from the view. More...
 
void SetLayerVisible (int aLayer, bool aVisible=true)
 Function SetLayerVisible() Controls the visibility of a particular layer. More...
 
bool IsLayerVisible (int aLayer) const
 Function IsLayerVisible() Returns information about visibility of a particular layer. More...
 
void SetLayerDisplayOnly (int aLayer, bool aDisplayOnly=true)
 
void SetLayerTarget (int aLayer, RENDER_TARGET aTarget)
 Function SetLayerTarget() Changes the rendering target for a particular layer. More...
 
void SetLayerOrder (int aLayer, int aRenderingOrder)
 Function SetLayerOrder() Sets rendering order of a particular layer. More...
 
int GetLayerOrder (int aLayer) const
 Function GetLayerOrder() Returns rendering order of a particular layer. More...
 
void SortLayers (int aLayers[], int &aCount) const
 Function SortLayers() Changes the order of given layer ids, so after sorting the order corresponds to layers rendering order (descending, ie. More...
 
void ReorderLayerData (std::unordered_map< int, int > aReorderMap)
 Remaps the data between layer ids without invalidating that data. More...
 
void UpdateLayerColor (int aLayer)
 Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it has changed. More...
 
void UpdateAllLayersColor ()
 Function UpdateAllLayersColor() Applies the new coloring scheme to all layers. More...
 
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 layers. More...
 
virtual void EnableTopLayer (bool aEnable)
 Function EnableTopLayer() Enables or disables display of the top layer. More...
 
virtual int GetTopLayer () const
 
void ClearTopLayers ()
 Function ClearTopLayers() Removes all layers from the on-the-top set (they are no longer displayed over the rest of layers). More...
 
void UpdateAllLayersOrder ()
 Function UpdateLayerOrder() Does everything that is needed to apply the rendering order of layers. More...
 
void ClearTargets ()
 Function ClearTargets() Clears targets that are marked as dirty. More...
 
virtual void Redraw ()
 Function Redraw() Immediately redraws the whole view. More...
 
void RecacheAllItems ()
 Function RecacheAllItems() Rebuilds GAL display lists. More...
 
bool IsDynamic () const
 Function IsDynamic() Tells if the VIEW is dynamic (ie. More...
 
bool IsDirty () const
 Function IsDirty() Returns true if any of the VIEW layers needs to be refreshened. More...
 
bool IsTargetDirty (int aTarget) const
 Function IsTargetDirty() Returns true if any of layers belonging to the target or the target itself should be redrawn. More...
 
void MarkTargetDirty (int aTarget)
 Function MarkTargetDirty() Sets or clears target 'dirty' flag. More...
 
bool IsCached (int aLayer) const
 Returns true if the layer is cached. More...
 
void MarkDirty ()
 Function MarkDirty() Forces redraw of view on the next rendering. More...
 
void MarkForUpdate (VIEW_ITEM *aItem)
 Function MarkForUpdate() Adds an item to a list of items that are going to be refreshed upon the next frame rendering. More...
 
void UpdateItems ()
 Function UpdateItems() Iterates through the list of items that asked for updating and updates them. More...
 
void UpdateAllItems (int aUpdateFlags)
 Updates all items in the view according to the given flags. More...
 
void UpdateAllItemsConditionally (int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
 Updates items in the view according to the given flags and condition. More...
 
const BOX2I CalculateExtents ()
 
bool IsUsingDrawPriority () const
 Function IsUsingDrawPriority() More...
 
void UseDrawPriority (bool aFlag)
 Function UseDrawPriority() More...
 
bool IsDrawOrderReversed () const
 Function IsDrawOrderReversed() More...
 
void ReverseDrawOrder (bool aFlag)
 Function ReverseDrawOrder() Only takes effect if UseDrawPriority is true. More...
 
std::shared_ptr< VIEW_OVERLAYMakeOverlay ()
 

Static Public Member Functions

static void OnDestroy (VIEW_ITEM *aItem)
 

Static Public Attributes

static const int VIEW_MAX_LAYERS = 512
 maximum number of layers that may be shown More...
 

Protected Types

typedef std::unordered_map< int, VIEW_LAYERLAYER_MAP
 
typedef LAYER_MAP::iterator LAYER_MAP_ITER
 
typedef std::vector< VIEW_LAYER * > LAYER_ORDER
 
typedef std::vector< VIEW_LAYER * >::iterator LAYER_ORDER_ITER
 

Protected Member Functions

void redrawRect (const BOX2I &aRect)
 
void markTargetClean (int aTarget)
 
void draw (VIEW_ITEM *aItem, int aLayer, bool aImmediate=false)
 Function draw() Draws an item, but on a specified layers. More...
 
void draw (VIEW_ITEM *aItem, bool aImmediate=false)
 Function draw() Draws an item on all layers that the item uses. More...
 
void draw (VIEW_GROUP *aGroup, bool aImmediate=false)
 Function draw() Draws a group of items on all layers that those items use. More...
 
void sortLayers ()
 
void clearGroupCache ()
 
void invalidateItem (VIEW_ITEM *aItem, int aUpdateFlags)
 Function invalidateItem() Manages dirty flags & redraw queueing when updating an item. More...
 
void updateItemColor (VIEW_ITEM *aItem, int aLayer)
 Updates colors that are used for an item to be drawn. More...
 
void updateItemGeometry (VIEW_ITEM *aItem, int aLayer)
 Updates all informations needed to draw an item. More...
 
void updateBbox (VIEW_ITEM *aItem)
 Updates bounding box of an item. More...
 
void updateLayers (VIEW_ITEM *aItem)
 Updates set of layers that an item occupies. More...
 
bool areRequiredLayersEnabled (int aLayerId) const
 Checks if every layer required by the aLayerId layer is enabled. More...
 

Static Protected Member Functions

static bool compareRenderingOrder (VIEW_LAYER *aI, VIEW_LAYER *aJ)
 Determines rendering order of layers. Used in display order sorting function. More...
 

Protected Attributes

bool m_enableOrderModifier
 
LAYER_MAP m_layers
 Contains set of possible displayed layers and its properties. More...
 
LAYER_ORDER m_orderedLayers
 Sorted list of pointers to members of m_layers. More...
 
std::set< unsigned int > m_topLayers
 Stores set of layers that are displayed on the top. More...
 
VECTOR2D m_center
 Center point of the VIEW (the point at which we are looking at) More...
 
double m_scale
 Scale of displayed VIEW_ITEMs. More...
 
BOX2D m_boundary
 View boundaries. More...
 
double m_minScale
 Scale lower limit. More...
 
double m_maxScale
 Scale upper limit. More...
 
bool m_mirrorX
 

Horizontal flip flag

More...
 
bool m_mirrorY
 

Vertical flip flag

More...
 
PAINTERm_painter
 PAINTER contains information how do draw items. More...
 
GALm_gal
 Gives interface to PAINTER, that is used to draw items. More...
 
bool m_dynamic
 Dynamic VIEW (eg. More...
 
bool m_dirtyTargets [TARGETS_NUMBER]
 Flags to mark targets as dirty, so they have to be redrawn on the next refresh event. More...
 
std::vector< VIEW_ITEM * > m_allItems
 Flat list of all items. More...
 
bool m_useDrawPriority
 Flag to respect draw priority when drawing items. More...
 
int m_nextDrawPriority
 The next sequential drawing priority. More...
 
bool m_reverseDrawOrder
 Flag to reverse the draw order when using draw priority. More...
 

Static Protected Attributes

static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS
 Rendering order modifier for layers that are marked as top layers. More...
 

Friends

class VIEW_ITEM
 

Detailed Description

Class VIEW.

Holds a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the GAL. VIEWs can exist in two flavors:

  • dynamic - where items can be added, removed or changed anytime, intended for the main editing panel. Each VIEW_ITEM can be added to a single dynamic view.
  • static - where items are added once at the startup and are not linked with the VIEW. Foreseen for preview windows and printing. Items in a view are grouped in layers (not to be confused with Kicad's PCB layers). Each layer is identified by an integer number. Visibility and rendering order can be set individually for each of the layers. Future versions of the VIEW will also allows one to assign different layers to different rendering targets, which will be composited at the final stage by the GAL. The VIEW class also provides fast methods for finding all visible objects that are within a given rectangular area, useful for object selection/hit testing.

Definition at line 61 of file view.h.

Member Typedef Documentation

typedef std::pair<VIEW_ITEM*, int> KIGFX::VIEW::LAYER_ITEM_PAIR

Definition at line 66 of file view.h.

typedef std::unordered_map<int, VIEW_LAYER> KIGFX::VIEW::LAYER_MAP
protected

Definition at line 715 of file view.h.

typedef LAYER_MAP::iterator KIGFX::VIEW::LAYER_MAP_ITER
protected

Definition at line 716 of file view.h.

typedef std::vector<VIEW_LAYER*> KIGFX::VIEW::LAYER_ORDER
protected

Definition at line 717 of file view.h.

typedef std::vector<VIEW_LAYER*>::iterator KIGFX::VIEW::LAYER_ORDER_ITER
protected

Definition at line 718 of file view.h.

Constructor & Destructor Documentation

KIGFX::VIEW::VIEW ( bool  aIsDynamic = true)

Constructor.

Parameters
aIsDynamicdecides whether we are creating a static or a dynamic VIEW.

Definition at line 285 of file view.cpp.

References AddLayer(), i, m_allItems, m_boundary, MarkDirty(), BOX2< Vec >::SetMaximum(), and VIEW_MAX_LAYERS.

285  :
286  m_enableOrderModifier( true ),
287  m_scale( 4.0 ),
288  m_minScale( 4.0 ), m_maxScale( 75000.0 ),
289  m_mirrorX( false ), m_mirrorY( false ),
290  m_painter( NULL ),
291  m_gal( NULL ),
292  m_dynamic( aIsDynamic ),
293  m_useDrawPriority( false ),
294  m_nextDrawPriority( 0 ),
295  m_reverseDrawOrder( false )
296 {
298  m_allItems.reserve( 32768 );
299 
300  // Redraw everything at the beginning
301  MarkDirty();
302 
303  // View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
304  // pad may be shown on pad, pad hole and solder paste layers). There are usual copper layers
305  // (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
306  // silkscreen, pads, vias, etc.
307  for( int i = 0; i < VIEW_MAX_LAYERS; i++ )
308  AddLayer( i );
309 }
void AddLayer(int aLayer, bool aDisplayOnly=false)
Function AddLayer() Adds a new layer to the view.
Definition: view.cpp:319
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition: view.h:861
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
double m_minScale
Scale lower limit.
Definition: view.h:830
void SetMaximum()
Definition: box2.h:71
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
bool m_mirrorX
Horizontal flip flag
Definition: view.h:836
bool m_dynamic
Dynamic VIEW (eg.
Definition: view.h:849
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:867
int m_nextDrawPriority
The next sequential drawing priority.
Definition: view.h:864
double m_maxScale
Scale upper limit.
Definition: view.h:833
bool m_enableOrderModifier
Definition: view.h:809
BOX2D m_boundary
View boundaries.
Definition: view.h:827
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
size_t i
Definition: json11.cpp:597
bool m_mirrorY
Vertical flip flag
Definition: view.h:839
double m_scale
Scale of displayed VIEW_ITEMs.
Definition: view.h:824
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
KIGFX::VIEW::~VIEW ( )
virtual

Definition at line 312 of file view.cpp.

References m_layers.

313 {
314  for( LAYER_MAP::value_type& l : m_layers )
315  delete l.second.items;
316 }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812

Member Function Documentation

void KIGFX::VIEW::Add ( VIEW_ITEM aItem,
int  aDrawPriority = -1 
)
virtual

Function Add() Adds a VIEW_ITEM to the view.

Set aDrawPriority to -1 to assign sequential priorities.

Parameters
aItemitem to be added. No ownership is given
aDrawPrioritypriority to draw this item on its layer, lowest first.

Reimplemented in KIGFX::PCB_VIEW, and KIGFX::SCH_VIEW.

Definition at line 336 of file view.cpp.

References i, KIGFX::INITIAL_ADD, KIGFX::VIEW_RTREE::Insert(), KIGFX::VIEW::VIEW_LAYER::items, m_allItems, KIGFX::VIEW_ITEM_DATA::m_drawPriority, m_layers, m_nextDrawPriority, KIGFX::VIEW_ITEM_DATA::m_view, KIGFX::VIEW_ITEM::m_viewPrivData, MarkTargetDirty(), KIGFX::VIEW_ITEM_DATA::saveLayers(), SetVisible(), KIGFX::VIEW::VIEW_LAYER::target, Update(), VIEW_MAX_LAYERS, KIGFX::VIEW_ITEM::ViewGetLayers(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by KIGFX::SCH_VIEW::Add(), KIGFX::PCB_VIEW::Add(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PCB_DRAW_PANEL_GAL::DisplayBoard(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), GRID_HELPER::GRID_HELPER(), MakeOverlay(), POINT_EDITOR::OnSelectionChange(), DRAWING_TOOL::PlaceDXF(), DIALOG_PAD_PROPERTIES::prepareCanvas(), BOARD_COMMIT::Push(), GERBVIEW_FRAME::Read_EXCELLON_File(), PCB_EDIT_FRAME::ReadPcbNetlist(), DIALOG_PAD_PROPERTIES::redraw(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), BOARD_COMMIT::Revert(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PCB_DRAW_PANEL_GAL::SetWorksheet(), GERBVIEW_DRAW_PANEL_GAL::SetWorksheet(), DIALOG_ERC::TestErc(), POINT_EDITOR::updatePoints(), and ZONE_CREATE_HELPER::ZONE_CREATE_HELPER().

337 {
338  int layers[VIEW_MAX_LAYERS], layers_count;
339 
340  if( aDrawPriority < 0 )
341  aDrawPriority = m_nextDrawPriority++;
342 
343  if( !aItem->m_viewPrivData )
344  aItem->m_viewPrivData = new VIEW_ITEM_DATA;
345 
346  aItem->m_viewPrivData->m_view = this;
347  aItem->m_viewPrivData->m_drawPriority = aDrawPriority;
348 
349  aItem->ViewGetLayers( layers, layers_count );
350  aItem->viewPrivData()->saveLayers( layers, layers_count );
351 
352  m_allItems.push_back( aItem );
353 
354  for( int i = 0; i < layers_count; ++i )
355  {
356  VIEW_LAYER& l = m_layers[layers[i]];
357  l.items->Insert( aItem );
358  MarkTargetDirty( l.target );
359  }
360 
361  SetVisible( aItem, true );
362  Update( aItem, KIGFX::INITIAL_ADD );
363 }
Layers have changed.
Definition: view_item.h:59
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
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:1538
int m_nextDrawPriority
The next sequential drawing priority.
Definition: view.h:864
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
size_t i
Definition: json11.cpp:597
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1484
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::AddLayer ( int  aLayer,
bool  aDisplayOnly = false 
)

Function AddLayer() Adds a new layer to the view.

Parameters
aLayerunique ID of the layer to be added.
aDisplayOnlylayer is display-only (example: selection boxes, floating hints/menus). Objects belonging to this layer are not taken into account by Query() method.

Definition at line 319 of file view.cpp.

References m_layers, sortLayers(), and KIGFX::TARGET_CACHED.

Referenced by GetCenter(), and VIEW().

320 {
321  if( m_layers.find( aLayer ) == m_layers.end() )
322  {
323  m_layers[aLayer] = VIEW_LAYER();
324  m_layers[aLayer].id = aLayer;
325  m_layers[aLayer].items = new VIEW_RTREE();
326  m_layers[aLayer].renderingOrder = aLayer;
327  m_layers[aLayer].visible = true;
328  m_layers[aLayer].displayOnly = aDisplayOnly;
329  m_layers[aLayer].target = TARGET_CACHED;
330  }
331 
332  sortLayers();
333 }
void sortLayers()
Definition: view.cpp:1233
Main rendering target (cached)
Definition: definitions.h:41
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
bool KIGFX::VIEW::areRequiredLayersEnabled ( int  aLayerId) const
protected

Checks if every layer required by the aLayerId layer is enabled.

Definition at line 1356 of file view.cpp.

References m_layers.

Referenced by compareRenderingOrder(), and redrawRect().

1357 {
1358  wxASSERT( (unsigned) aLayerId < m_layers.size() );
1359 
1360  std::set<int>::const_iterator it, it_end;
1361 
1362  for( it = m_layers.at( aLayerId ).requiredLayers.begin(),
1363  it_end = m_layers.at( aLayerId ).requiredLayers.end(); it != it_end; ++it )
1364  {
1365  // That is enough if just one layer is not enabled
1366  if( !m_layers.at( *it ).visible || !areRequiredLayersEnabled( *it ) )
1367  return false;
1368  }
1369 
1370  return true;
1371 }
bool areRequiredLayersEnabled(int aLayerId) const
Checks if every layer required by the aLayerId layer is enabled.
Definition: view.cpp:1356
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
const BOX2I KIGFX::VIEW::CalculateExtents ( )

Definition at line 1469 of file view.cpp.

References KIGFX::VIEW::extentsVisitor::extents, m_orderedLayers, and BOX2< Vec >::SetMaximum().

Referenced by MarkDirty().

1470 {
1471  extentsVisitor v;
1472  BOX2I fullScene;
1473  fullScene.SetMaximum();
1474 
1475  for( VIEW_LAYER* l : m_orderedLayers )
1476  {
1477  l->items->Query( fullScene, v );
1478  }
1479 
1480  return v.extents;
1481 }
void SetMaximum()
Definition: box2.h:71
LAYER_ORDER m_orderedLayers
Sorted list of pointers to members of m_layers.
Definition: view.h:815
void KIGFX::VIEW::Clear ( )

Function Clear() Removes all items from the view.

Definition at line 1090 of file view.cpp.

References KIGFX::GAL::ClearCache(), i, m_allItems, m_gal, m_layers, m_nextDrawPriority, and BOX2< Vec >::SetMaximum().

Referenced by PCB_DRAW_PANEL_GAL::DisplayBoard(), KIGFX::SCH_VIEW::DisplayComponent(), SCH_DRAW_PANEL::DisplayComponent(), SCH_DRAW_PANEL::DisplaySheet(), GetCenter(), GERBVIEW_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::RebuildView(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), PCB_BASE_EDIT_FRAME::SetBoard(), DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME(), FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME(), and GERBVIEW_FRAME::~GERBVIEW_FRAME().

1091 {
1092  BOX2I r;
1093  r.SetMaximum();
1094  m_allItems.clear();
1095 
1096  for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
1097  i->second.items->RemoveAll();
1098 
1099  m_nextDrawPriority = 0;
1100 
1101  m_gal->ClearCache();
1102 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void SetMaximum()
Definition: box2.h:71
int m_nextDrawPriority
The next sequential drawing priority.
Definition: view.h:864
LAYER_MAP::iterator LAYER_MAP_ITER
Definition: view.h:716
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
virtual void ClearCache()
Delete all data created during caching of graphic items.
void KIGFX::VIEW::clearGroupCache ( )
protected

Definition at line 1173 of file view.cpp.

References i, KIGFX::VIEW::VIEW_LAYER::items, m_layers, KIGFX::VIEW_RTREE::Query(), and BOX2< Vec >::SetMaximum().

Referenced by markTargetClean(), and SetGAL().

1174 {
1175  BOX2I r;
1176 
1177  r.SetMaximum();
1178  clearLayerCache visitor( this );
1179 
1180  for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
1181  {
1182  VIEW_LAYER* l = &( ( *i ).second );
1183  l->items->Query( r, visitor );
1184  }
1185 }
void SetMaximum()
Definition: box2.h:71
LAYER_MAP::iterator LAYER_MAP_ITER
Definition: view.h:716
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::ClearLayer ( int  aLayer)

Function ClearLayer() Removes all items from a given layer.

Parameters
aLayerID of the layer to be cleared

Referenced by GetCenter().

void KIGFX::VIEW::ClearTargets ( )

Function ClearTargets() Clears targets that are marked as dirty.

Definition at line 1105 of file view.cpp.

References KIGFX::GAL::ClearTarget(), IsTargetDirty(), m_gal, MarkDirty(), KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, and KIGFX::TARGET_OVERLAY.

Referenced by EDA_DRAW_PANEL_GAL::onPaint(), and SetLayerTarget().

1106 {
1108  {
1109  // TARGET_CACHED and TARGET_NONCACHED have to be redrawn together, as they contain
1110  // layers that rely on each other (eg. netnames are noncached, but tracks - are cached)
1113 
1114  MarkDirty();
1115  }
1116 
1117  if( IsTargetDirty( TARGET_OVERLAY ) )
1118  {
1120  }
1121 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
Auxiliary rendering target (noncached)
Definition: definitions.h:42
virtual void ClearTarget(RENDER_TARGET aTarget)
Clears the target for rendering.
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:590
Items that may change while the view stays the same (noncached)
Definition: definitions.h:43
Main rendering target (cached)
Definition: definitions.h:41
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
void KIGFX::VIEW::ClearTopLayers ( )

Function ClearTopLayers() Removes all layers from the on-the-top set (they are no longer displayed over the rest of layers).

Definition at line 894 of file view.cpp.

References m_enableOrderModifier, m_layers, m_topLayers, and TOP_LAYER_MODIFIER.

Referenced by SetLayerTarget(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and EDA_DRAW_PANEL_GAL::SetTopLayer().

895 {
896  std::set<unsigned int>::iterator it;
897 
899  {
900  // Restore the previous rendering order for layers that were marked as top
901  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
902  m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
903  }
904 
905  m_topLayers.clear();
906 }
static const int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855
std::set< unsigned int > m_topLayers
Stores set of layers that are displayed on the top.
Definition: view.h:818
bool m_enableOrderModifier
Definition: view.h:809
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
static bool KIGFX::VIEW::compareRenderingOrder ( VIEW_LAYER aI,
VIEW_LAYER aJ 
)
inlinestaticprotected

Determines rendering order of layers. Used in display order sorting function.

Definition at line 800 of file view.h.

References areRequiredLayersEnabled(), and KIGFX::VIEW::VIEW_LAYER::renderingOrder.

Referenced by sortLayers().

801  {
802  return aI->renderingOrder > aJ->renderingOrder;
803  }
void KIGFX::VIEW::CopySettings ( const VIEW aOtherView)

Function CopySettings() Copies layers and visibility settings from another view.

Parameters
aOtherViewview from which settings will be copied.

Definition at line 503 of file view.cpp.

504 {
505  wxASSERT_MSG( false, wxT( "This is not implemented" ) );
506 }
void KIGFX::VIEW::draw ( VIEW_ITEM aItem,
int  aLayer,
bool  aImmediate = false 
)
protected

Function draw() Draws an item, but on a specified layers.

It has to be marked that some of drawing settings are based on the layer on which an item is drawn.

Parameters
aItemis the item to be drawn.
aLayeris the layer which should be drawn.
aImmediatedictates the way of drawing - it allows one to force immediate drawing mode for cached items.

Definition at line 1008 of file view.cpp.

References KIGFX::PAINTER::Draw(), KIGFX::GAL::DrawGroup(), KIGFX::VIEW_ITEM_DATA::getGroup(), IsCached(), m_gal, m_painter, Update(), KIGFX::VIEW_ITEM::ViewDraw(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by draw(), and markTargetClean().

1009 {
1010  auto viewData = aItem->viewPrivData();
1011 
1012  if( !viewData )
1013  return;
1014 
1015  if( IsCached( aLayer ) && !aImmediate )
1016  {
1017  // Draw using cached information or create one
1018  int group = viewData->getGroup( aLayer );
1019 
1020  if( group >= 0 )
1021  m_gal->DrawGroup( group );
1022  else
1023  Update( aItem );
1024  }
1025  else
1026  {
1027  // Immediate mode
1028  if( !m_painter->Draw( aItem, aLayer ) )
1029  aItem->ViewDraw( aLayer, this ); // Alternative drawing method
1030  }
1031 }
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
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:1538
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer)=0
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
void KIGFX::VIEW::draw ( VIEW_ITEM aItem,
bool  aImmediate = false 
)
protected

Function draw() Draws an item on all layers that the item uses.

Parameters
aItemis the item to be drawn.
aImmediatedictates the way of drawing - it allows one to force immediate drawing mode for cached items.

Definition at line 1034 of file view.cpp.

References draw(), i, m_gal, m_layers, KIGFX::GAL::SetLayerDepth(), SortLayers(), VIEW_MAX_LAYERS, and KIGFX::VIEW_ITEM::ViewGetLayers().

1035 {
1036  int layers[VIEW_MAX_LAYERS], layers_count;
1037 
1038  aItem->ViewGetLayers( layers, layers_count );
1039 
1040  // Sorting is needed for drawing order dependent GALs (like Cairo)
1041  SortLayers( layers, layers_count );
1042 
1043  for( int i = 0; i < layers_count; ++i )
1044  {
1045  m_gal->SetLayerDepth( m_layers.at( layers[i] ).renderingOrder );
1046  draw( aItem, layers[i], aImmediate );
1047  }
1048 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
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:665
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
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:1008
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::draw ( VIEW_GROUP aGroup,
bool  aImmediate = false 
)
protected

Function draw() Draws a group of items on all layers that those items use.

Parameters
aGroupis the group to be drawn.
aImmediatedictates the way of drawing - it allows one to force immediate drawing mode for cached items.

Definition at line 1051 of file view.cpp.

References draw(), KIGFX::VIEW_GROUP::GetItem(), KIGFX::VIEW_GROUP::GetSize(), and i.

1052 {
1053  for( unsigned int i = 0; i < aGroup->GetSize(); i++)
1054  draw( aGroup->GetItem(i), aImmediate );
1055 }
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:1008
void KIGFX::VIEW::EnableTopLayer ( bool  aEnable)
virtual

Function EnableTopLayer() Enables or disables display of the top layer.

When disabled - layers are rendered as usual with no influence from SetTopLayer function. Otherwise on the top there is displayed the layer set previously with SetTopLayer function.

Parameters
aEnablewhether to enable or disable display of the top layer.

Definition at line 869 of file view.cpp.

References m_enableOrderModifier, m_layers, m_topLayers, TOP_LAYER_MODIFIER, UpdateAllLayersColor(), and UpdateAllLayersOrder().

Referenced by SetLayerTarget().

870 {
871  if( aEnable == m_enableOrderModifier )
872  return;
873 
874  m_enableOrderModifier = aEnable;
875 
876  std::set<unsigned int>::iterator it;
877 
878  if( aEnable )
879  {
880  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
881  m_layers[*it].renderingOrder += TOP_LAYER_MODIFIER;
882  }
883  else
884  {
885  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
886  m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
887  }
888 
891 }
static const int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855
std::set< unsigned int > m_topLayers
Stores set of layers that are displayed on the top.
Definition: view.h:818
void UpdateAllLayersOrder()
Function UpdateLayerOrder() Does everything that is needed to apply the rendering order of layers...
Definition: view.cpp:909
bool m_enableOrderModifier
Definition: view.h:809
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:782
const BOX2D& KIGFX::VIEW::GetBoundary ( ) const
inline

Function GetBoundary()

Returns
Current view area boundary.

Definition at line 300 of file view.h.

References m_boundary.

Referenced by KIGFX::WX_VIEW_CONTROLS::onScroll(), and KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars().

301  {
302  return m_boundary;
303  }
BOX2D m_boundary
View boundaries.
Definition: view.h:827
const VECTOR2D& KIGFX::VIEW::GetCenter ( ) const
inline

Function GetCenter() Returns the center point of this VIEW (in world space coordinates)

Returns
center point of the view

Definition at line 341 of file view.h.

References AddLayer(), Clear(), ClearLayer(), GetScreenPixelSize(), m_center, ToScreen(), and ToWorld().

Referenced by KIGFX::WX_VIEW_CONTROLS::onButton(), EDA_DRAW_PANEL_GAL::onPaint(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), SCH_BASE_FRAME::Zoom_Automatique(), and COMMON_TOOLS::ZoomFitScreen().

342  {
343  return m_center;
344  }
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:821
GAL* KIGFX::VIEW::GetGAL ( ) const
inline

Function GetGAL() Returns the GAL this view is using to draw graphical primitives.

Returns
Pointer to the currently used GAL instance.

Definition at line 182 of file view.h.

References m_gal.

Referenced by KIGFX::WX_VIEW_CONTROLS::CenterOnCursor(), DIALOG_SET_GRID::DIALOG_SET_GRID(), PCBNEW_CONTROL::DoSetGridOrigin(), drawArcWithHilight(), drawLineWithHilight(), KIGFX::PREVIEW::CENTRELINE_RECT_ITEM::drawPreviewShape(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), KIGFX::VIEW_OVERLAY::COMMAND_LINE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_CIRCLE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_ARC::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_STROKE::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_FILL::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_COLOR::Execute(), KIGFX::VIEW_OVERLAY::COMMAND_SET_WIDTH::Execute(), KIGFX::WX_VIEW_CONTROLS::GetRawCursorPosition(), DIALOG_PAD_PROPERTIES::prepareCanvas(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), EDA_DRAW_FRAME::SetPresetGrid(), KIGFX::VIEW_CONTROLS::ShowCursor(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), PCB_BRIGHT_BOX::ViewDraw(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), KIGFX::RATSNEST_VIEWITEM::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), BRIGHT_BOX::ViewDraw(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM::ViewDraw(), KIGFX::PREVIEW::SELECTION_AREA::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), ROUTER_PREVIEW_ITEM::ViewDraw(), KIGFX::WORKSHEET_VIEWITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), and KIGFX::WX_VIEW_CONTROLS::WarpCursor().

183  {
184  return m_gal;
185  }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
int KIGFX::VIEW::GetLayerOrder ( int  aLayer) const

Function GetLayerOrder() Returns rendering order of a particular layer.

Lower values are rendered first.

Parameters
aLayerthe layer
Returns
Rendering order of a particular layer.

Definition at line 659 of file view.cpp.

References m_layers.

Referenced by SetLayerTarget(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and SortLayers().

660 {
661  return m_layers.at( aLayer ).renderingOrder;
662 }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
PAINTER* KIGFX::VIEW::GetPainter ( ) const
inline

Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.

Returns
Pointer to the currently used Painter instance.

Definition at line 201 of file view.h.

References GetViewport(), m_painter, SetMirror(), and SetViewport().

Referenced by FOOTPRINT_VIEWER_FRAME::ApplyDisplaySettingsToGAL(), DISPLAY_FOOTPRINTS_FRAME::ApplyDisplaySettingsToGAL(), PCB_EDITOR_CONTROL::ClearHighlight(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), drawArcWithHilight(), drawLineWithHilight(), KIGFX::PREVIEW::POLYGON_ITEM::drawPreviewShape(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), ROUTER_PREVIEW_ITEM::getLayerColor(), SCH_BASE_FRAME::GetRenderSettings(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), SCH_EDIT_FRAME::LoadSettings(), LIB_EDIT_FRAME::LoadSettings(), DIALOG_PAD_PROPERTIES::onChangePadMode(), ZONE_CREATE_HELPER::OnFirstPoint(), PCB_LAYER_WIDGET::OnLayerColorChange(), GERBER_LAYER_WIDGET::OnLayerColorChange(), PCB_LAYER_WIDGET::OnRenderColorChange(), GERBER_LAYER_WIDGET::OnRenderColorChange(), GERBVIEW_FRAME::OnSelectHighlightChoice(), SCH_EDIT_FRAME::OnSelectOptionToolbar(), GERBVIEW_DRAW_PANEL_GAL::OnShow(), PCB_DRAW_PANEL_GAL::OnShow(), DIALOG_PAD_PROPERTIES::prepareCanvas(), GRID_HELPER::queryVisible(), DIALOG_PAD_PROPERTIES::redraw(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), EDA_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_LAYER_WIDGET::SyncLayerAlphaIndicators(), PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_PCBNEW_SETTINGS::TransferDataFromWindow(), KIGFX::PCB_VIEW::UpdateDisplayOptions(), GERBVIEW_DRAW_PANEL_GAL::UseColorScheme(), PCB_DRAW_PANEL_GAL::UseColorScheme(), PCB_BASE_FRAME::UseGalCanvas(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), KIGFX::RATSNEST_VIEWITEM::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), KIGFX::PREVIEW::SELECTION_AREA::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), and KIGFX::WORKSHEET_VIEWITEM::ViewDraw().

202  {
203  return m_painter;
204  }
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
double KIGFX::VIEW::GetScale ( ) const
inline
const VECTOR2I & KIGFX::VIEW::GetScreenPixelSize ( ) const

Function GetScreenPixelSize() Returns the size of the our rendering area, in pixels.

Returns
viewport screen size

Definition at line 1149 of file view.cpp.

References KIGFX::GAL::GetScreenPixelSize(), and m_gal.

Referenced by GetCenter(), KIGFX::WX_VIEW_CONTROLS::handleAutoPanning(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), and KIGFX::WX_VIEW_CONTROLS::onWheel().

1150 {
1151  return m_gal->GetScreenPixelSize();
1152 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
int KIGFX::VIEW::GetTopLayer ( ) const
virtual

Definition at line 833 of file view.cpp.

References m_topLayers.

Referenced by ROUTER_TOOL::getStartLayer(), SELECTION_TOOL::guessSelectionCandidates(), PNS::TOOL_BASE::pickSingleItem(), SetLayerTarget(), and PNS::TOOL_BASE::updateStartItem().

834 {
835  if( m_topLayers.size() == 0 )
836  return 0;
837 
838  return *m_topLayers.begin();
839 }
std::set< unsigned int > m_topLayers
Stores set of layers that are displayed on the top.
Definition: view.h:818
BOX2D KIGFX::VIEW::GetViewport ( ) const

Function GetViewport() Returns the current viewport visible area rectangle.

Returns
Current viewport rectangle

Definition at line 526 of file view.cpp.

References KIGFX::GAL::GetScreenPixelSize(), m_gal, BOX2< Vec >::Normalize(), BOX2< Vec >::SetEnd(), BOX2< Vec >::SetOrigin(), and ToWorld().

Referenced by GetPainter(), SELECTION_TOOL::guessSelectionCandidates(), and KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars().

527 {
528  BOX2D rect;
529  VECTOR2D screenSize = m_gal->GetScreenPixelSize();
530 
531  rect.SetOrigin( ToWorld( VECTOR2D( 0, 0 ) ) );
532  rect.SetEnd( ToWorld( screenSize ) );
533 
534  return rect.Normalize();
535 }
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:465
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
BOX2< Vec > & Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: box2.h:127
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:223
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
void SetOrigin(const Vec &pos)
Definition: box2.h:208
void KIGFX::VIEW::Hide ( VIEW_ITEM aItem,
bool  aHide = true 
)

Temporarily hides the item in the view (e.g.

for overlaying)

Parameters
aItemthe item to modify.
aHidewhether the item is hidden (on all layers), or not.

Definition at line 1505 of file view.cpp.

References KIGFX::APPEARANCE, KIGFX::HIDDEN, KIGFX::VIEW_ITEM_DATA::m_flags, Update(), KIGFX::VIEW_ITEM::viewPrivData(), and KIGFX::VISIBLE.

Referenced by KIGFX::SCH_VIEW::AddToPreview(), KIGFX::SCH_VIEW::ClearHiddenFlags(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), DrawMovingBlockOutlines(), SELECTION_TOOL::highlight(), GERBVIEW_SELECTION_TOOL::selectVisually(), LIB_EDIT_FRAME::StartMoveDrawSymbol(), SELECTION_TOOL::unhighlight(), and GERBVIEW_SELECTION_TOOL::unselectVisually().

1506 {
1507  auto viewData = aItem->viewPrivData();
1508 
1509  if( !viewData )
1510  return;
1511 
1512  if( !( viewData->m_flags & VISIBLE ) )
1513  return;
1514 
1515  if( aHide )
1516  viewData->m_flags |= HIDDEN;
1517  else
1518  viewData->m_flags &= ~HIDDEN;
1519 
1520  Update( aItem, APPEARANCE );
1521 }
Item is visible (in general)
Definition: view_item.h:70
No updates are required.
Definition: view_item.h:55
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:1538
void KIGFX::VIEW::invalidateItem ( VIEW_ITEM aItem,
int  aUpdateFlags 
)
protected

Function invalidateItem() Manages dirty flags & redraw queueing when updating an item.

Parameters
aItemis the item to be updated.
aUpdateFlagsdetermines the way an item is refreshed.

Definition at line 1188 of file view.cpp.

References KIGFX::ALL, KIGFX::VIEW_ITEM_DATA::clearUpdateFlags(), KIGFX::COLOR, KIGFX::GEOMETRY, i, KIGFX::INITIAL_ADD, IsCached(), KIGFX::LAYERS, m_layers, MarkTargetDirty(), KIGFX::REPAINT, updateBbox(), updateItemColor(), updateItemGeometry(), updateLayers(), VIEW_MAX_LAYERS, KIGFX::VIEW_ITEM::ViewGetLayers(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by markTargetClean(), and UpdateItems().

1189 {
1190  if( aUpdateFlags & INITIAL_ADD )
1191  {
1192  // Don't update layers or bbox, since it was done in VIEW::Add()
1193  // Now that we have initialized, set flags to ALL for the code below
1194  aUpdateFlags = ALL;
1195  }
1196  else
1197  {
1198  // updateLayers updates geometry too, so we do not have to update both of them at the same time
1199  if( aUpdateFlags & LAYERS )
1200  {
1201  updateLayers( aItem );
1202  }
1203  else if( aUpdateFlags & GEOMETRY )
1204  {
1205  updateBbox( aItem );
1206  }
1207  }
1208 
1209  int layers[VIEW_MAX_LAYERS], layers_count;
1210  aItem->ViewGetLayers( layers, layers_count );
1211 
1212  // Iterate through layers used by the item and recache it immediately
1213  for( int i = 0; i < layers_count; ++i )
1214  {
1215  int layerId = layers[i];
1216 
1217  if( IsCached( layerId ) )
1218  {
1219  if( aUpdateFlags & ( GEOMETRY | LAYERS | REPAINT ) )
1220  updateItemGeometry( aItem, layerId );
1221  else if( aUpdateFlags & COLOR )
1222  updateItemColor( aItem, layerId );
1223  }
1224 
1225  // Mark those layers as dirty, so the VIEW will be refreshed
1226  MarkTargetDirty( m_layers[layerId].target );
1227  }
1228 
1229  aItem->viewPrivData()->clearUpdateFlags();
1230 }
Layers have changed.
Definition: view_item.h:59
void updateLayers(VIEW_ITEM *aItem)
Updates set of layers that an item occupies.
Definition: view.cpp:1313
void updateItemColor(VIEW_ITEM *aItem, int aLayer)
Updates colors that are used for an item to be drawn.
Definition: view.cpp:1248
Visibility flag has changed.
Definition: view_item.h:56
Item needs to be redrawn.
Definition: view_item.h:61
Item is being added to the view.
Definition: view_item.h:60
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
void updateBbox(VIEW_ITEM *aItem)
Updates bounding box of an item.
Definition: view.cpp:1297
void updateItemGeometry(VIEW_ITEM *aItem, int aLayer)
Updates all informations needed to draw an item.
Definition: view.cpp:1267
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
Position or shape has changed.
Definition: view_item.h:58
Color has changed.
Definition: view_item.h:57
bool KIGFX::VIEW::IsCached ( int  aLayer) const
inline

Returns true if the layer is cached.

Definition at line 610 of file view.h.

References m_layers, and KIGFX::TARGET_CACHED.

Referenced by draw(), invalidateItem(), RecacheAllItems(), updateItemColor(), updateItemGeometry(), UpdateLayerColor(), and updateLayers().

611  {
612  wxASSERT( aLayer < (int) m_layers.size() );
613 
614  try
615  {
616  return m_layers.at( aLayer ).target == TARGET_CACHED;
617  }
618  catch( const std::out_of_range& )
619  {
620  return false;
621  }
622  }
Main rendering target (cached)
Definition: definitions.h:41
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
bool KIGFX::VIEW::IsDirty ( ) const
inline

Function IsDirty() Returns true if any of the VIEW layers needs to be refreshened.

Returns
True in case if any of layers is marked as dirty.

Definition at line 573 of file view.h.

References i, IsTargetDirty(), and KIGFX::TARGETS_NUMBER.

Referenced by EDA_DRAW_PANEL_GAL::onPaint(), and TOOL_MANAGER::ProcessEvent().

574  {
575  for( int i = 0; i < TARGETS_NUMBER; ++i )
576  {
577  if( IsTargetDirty( i ) )
578  return true;
579  }
580 
581  return false;
582  }
Number of available rendering targets.
Definition: definitions.h:44
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:590
size_t i
Definition: json11.cpp:597
bool KIGFX::VIEW::IsDrawOrderReversed ( ) const
inline

Function IsDrawOrderReversed()

Returns
true if draw order is reversed

Definition at line 685 of file view.h.

References m_reverseDrawOrder.

686  {
687  return m_reverseDrawOrder;
688  }
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:867
bool KIGFX::VIEW::IsDynamic ( ) const
inline

Function IsDynamic() Tells if the VIEW is dynamic (ie.

can be changed, for example displaying PCBs in a window) or static (that cannot be modified, eg. displaying image/PDF).

Definition at line 563 of file view.h.

References m_dynamic.

564  {
565  return m_dynamic;
566  }
bool m_dynamic
Dynamic VIEW (eg.
Definition: view.h:849
bool KIGFX::VIEW::IsLayerVisible ( int  aLayer) const
inline

Function IsLayerVisible() Returns information about visibility of a particular layer.

Parameters
aLayertrue if the layer is visible, false otherwise

Definition at line 429 of file view.h.

References m_layers.

Referenced by KIGFX::VIEW_GROUP::ViewDraw(), EDGE_MODULE::ViewGetLOD(), TEXTE_MODULE::ViewGetLOD(), TRACK::ViewGetLOD(), MODULE::ViewGetLOD(), and D_PAD::ViewGetLOD().

430  {
431  wxASSERT( aLayer < (int) m_layers.size() );
432 
433  return m_layers.at( aLayer ).visible;
434  }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
bool KIGFX::VIEW::IsMirroredX ( ) const
inline

Function IsMirroredX() Returns true if view is flipped across the X axis.

Definition at line 232 of file view.h.

References m_mirrorX.

Referenced by COMMON_TOOLS::CursorControl(), KIGFX::WX_VIEW_CONTROLS::onScroll(), SELECTION_TOOL::selectMultiple(), KIGFX::WX_VIEW_CONTROLS::UpdateScrollbars(), and KIGFX::PREVIEW::SELECTION_AREA::ViewDraw().

233  {
234  return m_mirrorX;
235  }
bool m_mirrorX
Horizontal flip flag
Definition: view.h:836
bool KIGFX::VIEW::IsMirroredY ( ) const
inline

Function IsMirroredX() Returns true if view is flipped across the Y axis.

Definition at line 241 of file view.h.

References m_mirrorY.

242  {
243  return m_mirrorY;
244  }
bool m_mirrorY
Vertical flip flag
Definition: view.h:839
bool KIGFX::VIEW::IsTargetDirty ( int  aTarget) const
inline

Function IsTargetDirty() Returns true if any of layers belonging to the target or the target itself should be redrawn.

Returns
True if the above condition is fulfilled.

Definition at line 590 of file view.h.

References m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

Referenced by ClearTargets(), IsDirty(), EDA_DRAW_PANEL_GAL::onPaint(), and redrawRect().

591  {
592  wxASSERT( aTarget < TARGETS_NUMBER );
593 
594  return m_dirtyTargets[aTarget];
595  }
Number of available rendering targets.
Definition: definitions.h:44
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:852
bool KIGFX::VIEW::IsUsingDrawPriority ( ) const
inline

Function IsUsingDrawPriority()

Returns
true if draw priority is being respected while redrawing.

Definition at line 667 of file view.h.

References m_useDrawPriority.

668  {
669  return m_useDrawPriority;
670  }
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition: view.h:861
bool KIGFX::VIEW::IsVisible ( const VIEW_ITEM aItem) const

Returns information if the item is visible (or not).

Parameters
aItemthe item to test.
Returns
when true, the item is visible (i.e. to be displayed, not visible in the current viewport)

Definition at line 1524 of file view.cpp.

References KIGFX::VIEW_ITEM_DATA::m_flags, KIGFX::VIEW_ITEM::viewPrivData(), and KIGFX::VISIBLE.

Referenced by SELECTION_TOOL::selectable().

1525 {
1526  const auto viewData = aItem->viewPrivData();
1527 
1528  return viewData->m_flags & VISIBLE;
1529 }
std::shared_ptr< VIEW_OVERLAY > KIGFX::VIEW::MakeOverlay ( )

Definition at line 1552 of file view.cpp.

References Add(), TOP_LAYER_MODIFIER, and VIEW_MAX_LAYERS.

Referenced by AUTOPLACE_TOOL::autoplace(), and ReverseDrawOrder().

1553 {
1554  std::shared_ptr<VIEW_OVERLAY> overlay( new VIEW_OVERLAY );
1555 
1556  Add( overlay.get() );
1557  return overlay;
1558 }
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:336
void KIGFX::VIEW::MarkDirty ( )
inline

Function MarkDirty() Forces redraw of view on the next rendering.

Definition at line 628 of file view.h.

References CalculateExtents(), i, m_dirtyTargets, MarkForUpdate(), KIGFX::TARGETS_NUMBER, UpdateAllItems(), UpdateAllItemsConditionally(), and UpdateItems().

Referenced by ClearTargets(), PCB_EDITOR_CONTROL::DoSetDrillOrigin(), PCBNEW_CONTROL::DoSetGridOrigin(), LIB_VIEW_FRAME::OnShowElectricalType(), SetCenter(), SetGAL(), SetMirror(), SetScale(), LIB_VIEW_FRAME::SetUnitAndConvert(), sortLayers(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), UpdateAllLayersColor(), UpdateAllLayersOrder(), and VIEW().

629  {
630  for( int i = 0; i < TARGETS_NUMBER; ++i )
631  m_dirtyTargets[i] = true;
632  }
Number of available rendering targets.
Definition: definitions.h:44
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:852
size_t i
Definition: json11.cpp:597
void KIGFX::VIEW::MarkForUpdate ( VIEW_ITEM aItem)

Function MarkForUpdate() Adds an item to a list of items that are going to be refreshed upon the next frame rendering.

Parameters
aItemis the item to be refreshed.

Referenced by MarkDirty().

void KIGFX::VIEW::markTargetClean ( int  aTarget)
inlineprotected

Definition at line 733 of file view.h.

References clearGroupCache(), draw(), invalidateItem(), m_dirtyTargets, sortLayers(), KIGFX::TARGETS_NUMBER, updateBbox(), updateItemColor(), updateItemGeometry(), and updateLayers().

Referenced by Redraw().

734  {
735  wxASSERT( aTarget < TARGETS_NUMBER );
736 
737  m_dirtyTargets[aTarget] = false;
738  }
Number of available rendering targets.
Definition: definitions.h:44
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:852
void KIGFX::VIEW::OnDestroy ( VIEW_ITEM aItem)
static

Definition at line 271 of file view.cpp.

References KIGFX::VIEW_ITEM_DATA::m_view, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by KIGFX::VIEW_ITEM::~VIEW_ITEM().

272 {
273  auto data = aItem->viewPrivData();
274 
275  if( !data )
276  return;
277 
278  if( data->m_view )
279  data->m_view->VIEW::Remove( aItem );
280 
281  delete data;
282 }
int KIGFX::VIEW::Query ( const BOX2I aRect,
std::vector< LAYER_ITEM_PAIR > &  aResult 
) const
virtual

Function Query() Finds all visible items that touch or are within the rectangle aRect.

Parameters
aRectarea to search for items
aResultresult of the search, containing VIEW_ITEMs associated with their layers. Sorted according to the rendering order (items that are on top of the rendering stack as first).
Returns
Number of found items.

Definition at line 442 of file view.cpp.

References i, and m_orderedLayers.

Referenced by GERBVIEW_SELECTION_TOOL::selectMultiple(), and SELECTION_TOOL::selectMultiple().

443 {
444  if( m_orderedLayers.empty() )
445  return 0;
446 
447  std::vector<VIEW_LAYER*>::const_reverse_iterator i;
448 
449  // execute queries in reverse direction, so that items that are on the top of
450  // the rendering stack are returned first.
451  for( i = m_orderedLayers.rbegin(); i != m_orderedLayers.rend(); ++i )
452  {
453  // ignore layers that do not contain actual items (i.e. the selection box, menus, floats)
454  if( ( *i )->displayOnly || !( *i )->visible )
455  continue;
456 
457  queryVisitor<std::vector<LAYER_ITEM_PAIR> > visitor( aResult, ( *i )->id );
458  ( *i )->items->Query( aRect, visitor );
459  }
460 
461  return aResult.size();
462 }
LAYER_ORDER m_orderedLayers
Sorted list of pointers to members of m_layers.
Definition: view.h:815
size_t i
Definition: json11.cpp:597
void KIGFX::VIEW::RecacheAllItems ( )

Function RecacheAllItems() Rebuilds GAL display lists.

Definition at line 1374 of file view.cpp.

References i, KIGFX::VIEW::VIEW_LAYER::id, IsCached(), KIGFX::VIEW::VIEW_LAYER::items, m_gal, m_layers, KIGFX::VIEW_RTREE::Query(), and BOX2< Vec >::SetMaximum().

Referenced by SCH_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDIT_FRAME::HighlightConnectionAtPosition(), GERBVIEW_DRAW_PANEL_GAL::OnShow(), SetLayerTarget(), PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_LIBEDIT_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow(), PCB_BASE_FRAME::UseGalCanvas(), and GERBVIEW_FRAME::UseGalCanvas().

1375 {
1376  BOX2I r;
1377 
1378  r.SetMaximum();
1379 
1380  for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
1381  {
1382  VIEW_LAYER* l = &( ( *i ).second );
1383 
1384  if( IsCached( l->id ) )
1385  {
1386  recacheItem visitor( this, m_gal, l->id );
1387  l->items->Query( r, visitor );
1388  }
1389  }
1390 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void SetMaximum()
Definition: box2.h:71
LAYER_MAP::iterator LAYER_MAP_ITER
Definition: view.h:716
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::Redraw ( )
virtual

Function Redraw() Immediately redraws the whole view.

Reimplemented in KIGFX::SCH_VIEW.

Definition at line 1124 of file view.cpp.

References KIGFX::GAL::GetScreenPixelSize(), m_gal, markTargetClean(), PROF_COUNTER::msecs(), BOX2< Vec >::Normalize(), redrawRect(), PROF_COUNTER::Stop(), KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, KIGFX::TARGET_OVERLAY, and ToWorld().

Referenced by EDA_DRAW_PANEL_GAL::onPaint(), KIGFX::SCH_VIEW::Redraw(), and SetLayerTarget().

1125 {
1126 #ifdef __WXDEBUG__
1127  PROF_COUNTER totalRealTime;
1128 #endif /* __WXDEBUG__ */
1129 
1130  VECTOR2D screenSize = m_gal->GetScreenPixelSize();
1131  BOX2I rect( ToWorld( VECTOR2D( 0, 0 ) ),
1132  ToWorld( screenSize ) - ToWorld( VECTOR2D( 0, 0 ) ) );
1133  rect.Normalize();
1134 
1135  redrawRect( rect );
1136 
1137  // All targets were redrawn, so nothing is dirty
1141 
1142 #ifdef __WXDEBUG__
1143  totalRealTime.Stop();
1144  wxLogTrace( "GAL_PROFILE", "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
1145 #endif /* __WXDEBUG__ */
1146 }
void Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
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:465
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:45
Auxiliary rendering target (noncached)
Definition: definitions.h:42
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
Items that may change while the view stays the same (noncached)
Definition: definitions.h:43
void markTargetClean(int aTarget)
Definition: view.h:733
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
double msecs() const
Definition: profile.h:124
void redrawRect(const BOX2I &aRect)
Definition: view.cpp:989
Main rendering target (cached)
Definition: definitions.h:41
void KIGFX::VIEW::redrawRect ( const BOX2I aRect)
protected
  • Redraws contents within rect aRect

Definition at line 989 of file view.cpp.

References areRequiredLayersEnabled(), KIGFX::VIEW::drawItem::deferredDraw(), IsTargetDirty(), m_gal, m_orderedLayers, m_reverseDrawOrder, m_useDrawPriority, KIGFX::GAL::SetLayerDepth(), and KIGFX::GAL::SetTarget().

Referenced by Redraw().

990 {
991  for( VIEW_LAYER* l : m_orderedLayers )
992  {
993  if( l->visible && IsTargetDirty( l->target ) && areRequiredLayersEnabled( l->id ) )
994  {
995  drawItem drawFunc( this, l->id, m_useDrawPriority, m_reverseDrawOrder );
996 
997  m_gal->SetTarget( l->target );
998  m_gal->SetLayerDepth( l->renderingOrder );
999  l->items->Query( aRect, drawFunc );
1000 
1001  if( m_useDrawPriority )
1002  drawFunc.deferredDraw();
1003  }
1004  }
1005 }
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition: view.h:861
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
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:590
LAYER_ORDER m_orderedLayers
Sorted list of pointers to members of m_layers.
Definition: view.h:815
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:867
bool areRequiredLayersEnabled(int aLayerId) const
Checks if every layer required by the aLayerId layer is enabled.
Definition: view.cpp:1356
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
void KIGFX::VIEW::Remove ( VIEW_ITEM aItem)
virtual

Function Remove() Removes a VIEW_ITEM from the view.

Parameters
aItemitem to be removed. Caller must dispose the removed item if necessary

Reimplemented in KIGFX::PCB_VIEW, and KIGFX::SCH_VIEW.

Definition at line 366 of file view.cpp.

References KIGFX::GAL::DeleteGroup(), i, KIGFX::VIEW::VIEW_LAYER::items, m_allItems, m_gal, m_layers, MarkTargetDirty(), KIGFX::VIEW_RTREE::Remove(), KIGFX::VIEW::VIEW_LAYER::target, VIEW_MAX_LAYERS, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SYMBOL_PREVIEW_WIDGET::DisplayPart(), SYMBOL_PREVIEW_WIDGET::DisplaySymbol(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), POINT_EDITOR::OnSelectionChange(), DRAWING_TOOL::PlaceDXF(), BOARD_COMMIT::Push(), PCB_EDIT_FRAME::ReadPcbNetlist(), KIGFX::SCH_VIEW::Remove(), KIGFX::PCB_VIEW::Remove(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), BOARD_COMMIT::Revert(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::unselect(), POINT_EDITOR::updatePoints(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), SELECTION_TOOL::~SELECTION_TOOL(), SYMBOL_PREVIEW_WIDGET::~SYMBOL_PREVIEW_WIDGET(), and ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER().

367 {
368  if( !aItem )
369  return;
370 
371  auto viewData = aItem->viewPrivData();
372 
373  if( !viewData )
374  return;
375 
376  wxASSERT( viewData->m_view == this );
377  auto item = std::find( m_allItems.begin(), m_allItems.end(), aItem );
378 
379  if( item != m_allItems.end() )
380  {
381  m_allItems.erase( item );
382  viewData->clearUpdateFlags();
383  }
384 
385  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
386  viewData->getLayers( layers, layers_count );
387 
388  for( int i = 0; i < layers_count; ++i )
389  {
390  VIEW_LAYER& l = m_layers[layers[i]];
391  l.items->Remove( aItem );
392  MarkTargetDirty( l.target );
393 
394  // Clear the GAL cache
395  int prevGroup = viewData->getGroup( layers[i] );
396 
397  if( prevGroup >= 0 )
398  m_gal->DeleteGroup( prevGroup );
399  }
400 
401  viewData->deleteGroups();
402  viewData->m_view = nullptr;
403 }
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::ReorderLayerData ( std::unordered_map< int, int >  aReorderMap)

Remaps the data between layer ids without invalidating that data.

Used by GerbView for the "Sort by X2" functionality

Parameters
aReorderMapis a mapping of old to new layer ids

Definition at line 693 of file view.cpp.

References KIGFX::COLOR, KIGFX::VIEW::VIEW_LAYER::id, m_allItems, m_layers, UpdateItems(), and VIEW_MAX_LAYERS.

Referenced by SetLayerTarget(), and GERBVIEW_FRAME::SortLayersByX2Attributes().

694 {
695  LAYER_MAP new_map;
696 
697  for( auto it : m_layers )
698  {
699  int orig_idx = it.first;
700  VIEW_LAYER layer = it.second;
701  int new_idx;
702 
703  try
704  {
705  new_idx = aReorderMap.at( orig_idx );
706  }
707  catch( const std::out_of_range& )
708  {
709  new_idx = orig_idx;
710  }
711 
712  layer.id = new_idx;
713  new_map[new_idx] = layer;
714  }
715 
716  m_layers = new_map;
717 
718  for( VIEW_ITEM* item : m_allItems )
719  {
720  auto viewData = item->viewPrivData();
721 
722  if( !viewData )
723  continue;
724 
725  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
726 
727  item->ViewGetLayers( layers, layers_count );
728  viewData->saveLayers( layers, layers_count );
729 
730  viewData->reorderGroups( aReorderMap );
731 
732  viewData->m_requiredUpdate |= COLOR;
733  }
734 
735  UpdateItems();
736 }
friend class VIEW_ITEM
Definition: view.h:64
Visibility flag has changed.
Definition: view_item.h:56
std::unordered_map< int, VIEW_LAYER > LAYER_MAP
Definition: view.h:715
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
void UpdateItems()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them...
Definition: view.cpp:1393
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::ReverseDrawOrder ( bool  aFlag)
inline

Function ReverseDrawOrder() Only takes effect if UseDrawPriority is true.

Parameters
aFlagis true if draw order should be reversed

Definition at line 695 of file view.h.

References m_reverseDrawOrder, and MakeOverlay().

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

696  {
697  m_reverseDrawOrder = aFlag;
698  }
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:867
void KIGFX::VIEW::SetBoundary ( const BOX2D aBoundary)
inline

Function SetBoundary() Sets limits for view area.

Parameters
aBoundaryis the box that limits view area.

Definition at line 280 of file view.h.

References m_boundary.

Referenced by DIALOG_PAD_PROPERTIES::redraw().

281  {
282  m_boundary = aBoundary;
283  }
BOX2D m_boundary
View boundaries.
Definition: view.h:827
void KIGFX::VIEW::SetBoundary ( const BOX2I aBoundary)
inline

Function SetBoundary() Sets limits for view area.

Parameters
aBoundaryis the box that limits view area.

Definition at line 290 of file view.h.

References BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), m_boundary, BOX2< Vec >::SetEnd(), and BOX2< Vec >::SetOrigin().

291  {
292  m_boundary.SetOrigin( aBoundary.GetOrigin() );
293  m_boundary.SetEnd( aBoundary.GetEnd() );
294  }
const Vec & GetOrigin() const
Definition: box2.h:191
const Vec GetEnd() const
Definition: box2.h:193
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:223
BOX2D m_boundary
View boundaries.
Definition: view.h:827
void SetOrigin(const Vec &pos)
Definition: box2.h:208
void KIGFX::VIEW::SetCenter ( const VECTOR2D aCenter)

Function SetCenter() Sets the center point of the VIEW (i.e.

the point in world space that will be drawn in the middle of the screen).

Parameters
aCenterthe new center point, in world space coordinates.

Definition at line 589 of file view.cpp.

References KIGFX::GAL::ComputeWorldScreenMatrix(), BOX2< Vec >::Contains(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), m_boundary, m_center, m_gal, MarkDirty(), KIGFX::GAL::SetLookAtPoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by COMMON_TOOLS::CenterContents(), KIGFX::WX_VIEW_CONTROLS::CenterOnCursor(), SCH_BASE_FRAME::CenterScreen(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), SELECTION_TOOL::findCallback(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), PCB_BASE_FRAME::FocusOnLocation(), KIGFX::WX_VIEW_CONTROLS::onMotion(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), SetCenter(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), SetGAL(), SetScale(), SetScaleLimits(), SetViewport(), EDA_DRAW_FRAME::UseGalCanvas(), KIGFX::WX_VIEW_CONTROLS::WarpCursor(), SCH_BASE_FRAME::Window_Zoom(), SCH_BASE_FRAME::Zoom_Automatique(), COMMON_TOOLS::ZoomFitScreen(), and SELECTION_TOOL::zoomFitSelection().

590 {
591  m_center = aCenter;
592 
593  if( !m_boundary.Contains( aCenter ) )
594  {
595  if( m_center.x < m_boundary.GetLeft() )
597  else if( aCenter.x > m_boundary.GetRight() )
599 
600  if( m_center.y < m_boundary.GetTop() )
602  else if( m_center.y > m_boundary.GetBottom() )
604  }
605 
608 
609  // Redraw everything after the viewport has changed
610  MarkDirty();
611 }
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:149
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
coord_type GetRight() const
Definition: box2.h:197
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
coord_type GetTop() const
Definition: box2.h:202
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:821
coord_type GetBottom() const
Definition: box2.h:198
BOX2D m_boundary
View boundaries.
Definition: view.h:827
void SetLookAtPoint(const VECTOR2D &aPoint)
Set the Point in world space to look at.
coord_type GetLeft() const
Definition: box2.h:201
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
void KIGFX::VIEW::SetCenter ( VECTOR2D  aCenter,
const BOX2D occultingScreenRect 
)

Function SetCenter() Sets the center point of the VIEW, attempting to avoid occultingScreenRect (for instance, the screen rect of a modeless dialog in front of the VIEW).

Parameters
aCenterthe new center point, in world space coordinates.
occultingScreenRectthe occulting rect, in screen space coordinates.

Definition at line 614 of file view.cpp.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetTop(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Intersect(), m_gal, max, SetCenter(), ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

615 {
616  BOX2D screenRect( VECTOR2D( 0, 0 ), m_gal->GetScreenPixelSize() );
617 
618  if( !screenRect.Intersects( occultingScreenRect ) )
619  {
620  SetCenter( aCenter );
621  return;
622  }
623 
624  BOX2D occultedRect = screenRect.Intersect( occultingScreenRect );
625  VECTOR2D offset( occultedRect.GetWidth() / 2, occultedRect.GetHeight() / 2 );
626 
627  double topExposed = occultedRect.GetTop() - screenRect.GetTop();
628  double bottomExposed = screenRect.GetBottom() - occultedRect.GetBottom();
629  double leftExposed = occultedRect.GetLeft() - screenRect.GetLeft();
630  double rightExposed = screenRect.GetRight() - occultedRect.GetRight();
631 
632  if( std::max( topExposed, bottomExposed ) > std::max( leftExposed, rightExposed ) )
633  {
634  if( topExposed > bottomExposed )
635  aCenter.y += ToWorld( occultedRect.GetHeight() / 2 );
636  else
637  aCenter.y -= ToWorld( occultedRect.GetHeight() / 2 );
638  }
639  else
640  {
641  if( leftExposed > rightExposed )
642  aCenter.x += ToWorld( occultedRect.GetWidth() / 2 );
643  else
644  aCenter.x -= ToWorld( occultedRect.GetWidth() / 2 );
645  }
646 
647  SetCenter( aCenter );
648 }
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:465
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
coord_type GetRight() const
Definition: box2.h:197
coord_type GetTop() const
Definition: box2.h:202
coord_type GetWidth() const
Definition: box2.h:195
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:589
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
coord_type GetBottom() const
Definition: box2.h:198
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
coord_type GetHeight() const
Definition: box2.h:196
#define max(a, b)
Definition: auxiliary.h:86
coord_type GetLeft() const
Definition: box2.h:201
BOX2< Vec > Intersect(const BOX2< Vec > &aRect)
Function Intersect Returns the intersection of this with another rectangle.
Definition: box2.h:266
void KIGFX::VIEW::SetGAL ( GAL aGal)

Function SetGAL() Assigns a rendering device for the VIEW.

Parameters
aGalpointer to the GAL output device

Definition at line 509 of file view.cpp.

References clearGroupCache(), m_center, m_gal, m_mirrorX, m_mirrorY, m_scale, MarkDirty(), SetCenter(), SetMirror(), and SetScale().

Referenced by GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and EDA_DRAW_PANEL_GAL::SwitchBackend().

510 {
511  m_gal = aGal;
512 
513  // clear group numbers, so everything is going to be recached
514  clearGroupCache();
515 
516  // every target has to be refreshed
517  MarkDirty();
518 
519  // force the new GAL to display the current viewport.
520  SetCenter( m_center );
521  SetScale( m_scale );
523 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void SetMirror(bool aMirrorX, bool aMirrorY)
Function SetMirror() Controls the mirroring of the VIEW.
Definition: view.cpp:553
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:252
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:821
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:589
bool m_mirrorX
Horizontal flip flag
Definition: view.h:836
void clearGroupCache()
Definition: view.cpp:1173
bool m_mirrorY
Vertical flip flag
Definition: view.h:839
double m_scale
Scale of displayed VIEW_ITEMs.
Definition: view.h:824
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
void KIGFX::VIEW::SetLayerDisplayOnly ( int  aLayer,
bool  aDisplayOnly = true 
)
inline

Definition at line 436 of file view.h.

References m_layers.

Referenced by GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps(), SCH_PREVIEW_PANEL::setDefaultLayerDeps(), SCH_DRAW_PANEL::setDefaultLayerDeps(), and PCB_DRAW_PANEL_GAL::setDefaultLayerDeps().

437  {
438  wxASSERT( aLayer < (int) m_layers.size() );
439 
440  m_layers[aLayer].displayOnly = aDisplayOnly;
441  }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::SetLayerOrder ( int  aLayer,
int  aRenderingOrder 
)

Function SetLayerOrder() Sets rendering order of a particular layer.

Lower values are rendered first.

Parameters
aLayerthe layer
aRenderingOrderarbitrary number denoting the rendering order.

Definition at line 651 of file view.cpp.

References m_layers, and sortLayers().

Referenced by PCB_DRAW_PANEL_GAL::setDefaultLayerOrder(), SetLayerTarget(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), and PCB_DRAW_PANEL_GAL::SetTopLayer().

652 {
653  m_layers[aLayer].renderingOrder = aRenderingOrder;
654 
655  sortLayers();
656 }
void sortLayers()
Definition: view.cpp:1233
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::SetLayerTarget ( int  aLayer,
RENDER_TARGET  aTarget 
)
inline

Function SetLayerTarget() Changes the rendering target for a particular layer.

Parameters
aLayeris the layer.
aTargetis the rendering target.

Definition at line 449 of file view.h.

References ClearTargets(), ClearTopLayers(), EnableTopLayer(), GetLayerOrder(), GetTopLayer(), m_layers, RecacheAllItems(), Redraw(), ReorderLayerData(), SetLayerOrder(), SetTopLayer(), SortLayers(), UpdateAllLayersColor(), UpdateAllLayersOrder(), and UpdateLayerColor().

Referenced by GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps(), SCH_PREVIEW_PANEL::setDefaultLayerDeps(), SCH_DRAW_PANEL::setDefaultLayerDeps(), and PCB_DRAW_PANEL_GAL::setDefaultLayerDeps().

450  {
451  wxASSERT( aLayer < (int) m_layers.size() );
452 
453  m_layers[aLayer].target = aTarget;
454  }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::SetLayerVisible ( int  aLayer,
bool  aVisible = true 
)
inline

Function SetLayerVisible() Controls the visibility of a particular layer.

Parameters
aLayerthe layer to show/hide.
aVisiblethe obvious.

Definition at line 412 of file view.h.

References m_layers, and MarkTargetDirty().

Referenced by PCB_LAYER_WIDGET::OnLayerVisible(), PCB_LAYER_WIDGET::OnRenderEnable(), FOOTPRINT_EDIT_FRAME::SetElementVisibility(), and PCB_DRAW_PANEL_GAL::SyncLayersVisibility().

413  {
414  wxASSERT( aLayer < (int) m_layers.size() );
415 
416  if( m_layers[aLayer].visible != aVisible )
417  {
418  // Target has to be redrawn after changing its visibility
419  MarkTargetDirty( m_layers[aLayer].target );
420  m_layers[aLayer].visible = aVisible;
421  }
422  }
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::SetMirror ( bool  aMirrorX,
bool  aMirrorY 
)

Function SetMirror() Controls the mirroring of the VIEW.

Parameters
aMirrorXwhen true, the X axis is mirrored
aMirrorYwhen true, the Y axis is mirrored.

Definition at line 553 of file view.cpp.

References m_gal, m_mirrorX, m_mirrorY, MarkDirty(), and KIGFX::GAL::SetFlip().

Referenced by GetPainter(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and SetGAL().

554 {
555  wxASSERT_MSG( !aMirrorY, _( "Mirroring for Y axis is not supported yet" ) );
556 
557  m_mirrorX = aMirrorX;
558  m_mirrorY = aMirrorY;
559  m_gal->SetFlip( aMirrorX, aMirrorY );
560 
561  // Redraw everything
562  MarkDirty();
563 }
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
bool m_mirrorX
Horizontal flip flag
Definition: view.h:836
bool m_mirrorY
Vertical flip flag
Definition: view.h:839
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
void KIGFX::VIEW::SetPainter ( PAINTER aPainter)
inline

Function SetPainter() Sets the painter object used by the view for drawing VIEW_ITEMS.

Definition at line 191 of file view.h.

References m_painter.

Referenced by GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), and SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL().

192  {
193  m_painter = aPainter;
194  }
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
void KIGFX::VIEW::SetRequired ( int  aLayerId,
int  aRequiredId,
bool  aRequired = true 
)

Function SetRequired() Marks the aRequiredId layer as required for the aLayerId layer.

In order to display the layer, all of its required layers have to be enabled.

Parameters
aLayerIdis the id of the layer for which we enable/disable the required layer.
aRequiredIdis the id of the required layer.
aRequiredtells if the required layer should be added or removed from the list.

Definition at line 406 of file view.cpp.

References m_layers.

Referenced by PCB_DRAW_PANEL_GAL::setDefaultLayerDeps().

407 {
408  wxASSERT( (unsigned) aLayerId < m_layers.size() );
409  wxASSERT( (unsigned) aRequiredId < m_layers.size() );
410 
411  if( aRequired )
412  m_layers[aLayerId].requiredLayers.insert( aRequiredId );
413  else
414  m_layers[aLayerId].requiredLayers.erase( aRequired );
415 }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::SetScale ( double  aScale)
inline

Function SetScale() Sets the scaling factor.

Scale = 1 corresponds to the real world size of the objects (depending on correct GAL unit length & DPI settings).

Parameters
aScalethe scalefactor

Definition at line 252 of file view.h.

References m_center.

Referenced by COMMON_TOOLS::doZoomToPreset(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), KIGFX::WX_VIEW_CONTROLS::onWheel(), EDA_DRAW_FRAME::OnZoom(), DIALOG_PAD_PROPERTIES::redraw(), SCH_BASE_FRAME::RedrawScreen(), SCH_BASE_FRAME::RedrawScreen2(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), SetGAL(), SetViewport(), EDA_DRAW_FRAME::UseGalCanvas(), SCH_BASE_FRAME::Window_Zoom(), SCH_BASE_FRAME::Zoom_Automatique(), COMMON_TOOLS::ZoomFitScreen(), and SELECTION_TOOL::zoomFitSelection().

253  {
254  SetScale( aScale, m_center );
255  }
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:252
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:821
void KIGFX::VIEW::SetScale ( double  aScale,
const VECTOR2D aAnchor 
)

Function SetScale() Sets the scaling factor, zooming around a given anchor point.

(depending on correct GAL unit length & DPI settings).

Parameters
aAnchorthe zooming anchor point
aScalethe scale factor

Definition at line 566 of file view.cpp.

References KIGFX::GAL::ComputeWorldScreenMatrix(), delta, m_center, m_gal, m_maxScale, m_minScale, m_scale, MarkDirty(), SetCenter(), KIGFX::GAL::SetZoomFactor(), ToScreen(), and ToWorld().

567 {
568  VECTOR2D a = ToScreen( aAnchor );
569 
570  if( aScale < m_minScale )
572  else if( aScale > m_maxScale )
574  else
575  m_scale = aScale;
576 
579 
580  VECTOR2D delta = ToWorld( a ) - aAnchor;
581 
582  SetCenter( m_center - delta );
583 
584  // Redraw everything after the viewport has changed
585  MarkDirty();
586 }
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:465
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
static const int delta[8][2]
Definition: solve.cpp:112
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:821
double m_minScale
Scale lower limit.
Definition: view.h:830
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:589
double m_maxScale
Scale upper limit.
Definition: view.h:833
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:484
void SetZoomFactor(double aZoomFactor)
Set the zoom factor of the scene.
double m_scale
Scale of displayed VIEW_ITEMs.
Definition: view.h:824
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
void KIGFX::VIEW::SetScaleLimits ( double  aMaximum,
double  aMinimum 
)
inline

Function SetScaleLimits() Sets minimum and maximum values for scale.

Parameters
aMaximumis the maximum value for scale.
aMinimumis the minimum value for scale.

Definition at line 311 of file view.h.

References m_maxScale, m_minScale, and SetCenter().

Referenced by SCH_DRAW_PANEL::SCH_DRAW_PANEL(), and SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL().

312  {
313  wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
314 
315  m_minScale = aMinimum;
316  m_maxScale = aMaximum;
317  }
double m_minScale
Scale lower limit.
Definition: view.h:830
double m_maxScale
Scale upper limit.
Definition: view.h:833
void KIGFX::VIEW::SetTopLayer ( int  aLayer,
bool  aEnabled = true 
)
virtual

Function SetTopLayer() Sets given layer to be displayed on the top or sets back the default order of layers.

Parameters
aEnabled= true to display aLayer on the top.
aLayerthe layer or -1 in case when no particular layer should be displayed on the top.

Definition at line 842 of file view.cpp.

References m_enableOrderModifier, m_layers, m_topLayers, and TOP_LAYER_MODIFIER.

Referenced by DIALOG_PAD_PROPERTIES::redraw(), SetLayerTarget(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and EDA_DRAW_PANEL_GAL::SetTopLayer().

843 {
844  if( aEnabled )
845  {
846  if( m_topLayers.count( aLayer ) == 1 )
847  return;
848 
849  m_topLayers.insert( aLayer );
850 
851  // Move the layer closer to front
853  m_layers[aLayer].renderingOrder += TOP_LAYER_MODIFIER;
854  }
855  else
856  {
857  if( m_topLayers.count( aLayer ) == 0 )
858  return;
859 
860  m_topLayers.erase( aLayer );
861 
862  // Restore the previous rendering order
864  m_layers[aLayer].renderingOrder -= TOP_LAYER_MODIFIER;
865  }
866 }
static const int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:855
std::set< unsigned int > m_topLayers
Stores set of layers that are displayed on the top.
Definition: view.h:818
bool m_enableOrderModifier
Definition: view.h:809
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::SetViewport ( const BOX2D aViewport)

Function SetViewport() Sets the visible area of the VIEW.

Parameters
aViewportdesired visible area, in world space coordinates.

Definition at line 538 of file view.cpp.

References BOX2< Vec >::Centre(), GetScale(), KIGFX::GAL::GetScreenPixelSize(), BOX2< Vec >::GetSize(), m_gal, max, SetCenter(), SetScale(), ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetPainter(), DIALOG_PAD_PROPERTIES::redraw(), and FOOTPRINT_PREVIEW_PANEL::renderFootprint().

539 {
540  VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
541 
542  wxASSERT( ssize.x > 0 && ssize.y > 0 );
543 
544  VECTOR2D centre = aViewport.Centre();
545  VECTOR2D vsize = aViewport.GetSize();
546  double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
547 
548  SetCenter( centre );
549  SetScale( GetScale() * zoom );
550 }
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:465
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
const Vec & GetSize() const
Definition: box2.h:187
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:252
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:589
Vec Centre() const
Definition: box2.h:77
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
#define max(a, b)
Definition: auxiliary.h:86
double GetScale() const
Function GetScale()
Definition: view.h:270
void KIGFX::VIEW::SetVisible ( VIEW_ITEM aItem,
bool  aIsVisible = true 
)

Sets the item visibility.

Parameters
aItemthe item to modify.
aIsVisiblewhether the item is visible (on all layers), or not.

Definition at line 1484 of file view.cpp.

References KIGFX::APPEARANCE, KIGFX::COLOR, KIGFX::VIEW_ITEM_DATA::m_flags, Update(), KIGFX::VIEW_ITEM::viewPrivData(), and KIGFX::VISIBLE.

Referenced by Add(), KIGFX::SCH_VIEW::AddToPreview(), GRID_HELPER::BestSnapAnchor(), MICROWAVE_TOOL::drawMicrowaveInductor(), DrawMovingBlockOutlines(), GRID_HELPER::GRID_HELPER(), EDIT_TOOL::MeasureTool(), ZONE_CREATE_HELPER::OnComplete(), ZONE_CREATE_HELPER::OnFirstPoint(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GRID_HELPER::SetAuxAxes(), KIGFX::SCH_VIEW::ShowPreview(), KIGFX::SCH_VIEW::ShowSelectionArea(), and ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER().

1485 {
1486  auto viewData = aItem->viewPrivData();
1487 
1488  if( !viewData )
1489  return;
1490 
1491  bool cur_visible = viewData->m_flags & VISIBLE;
1492 
1493  if( cur_visible != aIsVisible )
1494  {
1495  if( aIsVisible )
1496  viewData->m_flags |= VISIBLE;
1497  else
1498  viewData->m_flags &= ~VISIBLE;
1499 
1500  Update( aItem, APPEARANCE | COLOR );
1501  }
1502 }
No updates are required.
Definition: view_item.h:55
Visibility flag has changed.
Definition: view_item.h:56
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:1538
void KIGFX::VIEW::SortLayers ( int  aLayers[],
int &  aCount 
) const

Function SortLayers() Changes the order of given layer ids, so after sorting the order corresponds to layers rendering order (descending, ie.

order in which layers should be drawn - from the bottom to the top).

Parameters
aLayersstores id of layers to be sorted.
aCountstores the number of layers.

Definition at line 665 of file view.cpp.

References GetLayerOrder(), and i.

Referenced by draw(), SetLayerTarget(), and KIGFX::VIEW_GROUP::ViewDraw().

666 {
667  int maxLay, maxOrd, maxIdx;
668 
669  for( int i = 0; i < aCount; ++i )
670  {
671  maxLay = aLayers[i];
672  maxOrd = GetLayerOrder( maxLay );
673  maxIdx = i;
674 
675  // Look for the max element in the range (j..aCount)
676  for( int j = i; j < aCount; ++j )
677  {
678  if( maxOrd < GetLayerOrder( aLayers[j] ) )
679  {
680  maxLay = aLayers[j];
681  maxOrd = GetLayerOrder( maxLay );
682  maxIdx = j;
683  }
684  }
685 
686  // Swap elements
687  aLayers[maxIdx] = aLayers[i];
688  aLayers[i] = maxLay;
689  }
690 }
int GetLayerOrder(int aLayer) const
Function GetLayerOrder() Returns rendering order of a particular layer.
Definition: view.cpp:659
size_t i
Definition: json11.cpp:597
void KIGFX::VIEW::sortLayers ( )
protected
  • Sorts m_orderedLayers when layer rendering order has changed

Definition at line 1233 of file view.cpp.

References compareRenderingOrder(), i, m_layers, m_orderedLayers, and MarkDirty().

Referenced by AddLayer(), markTargetClean(), SetLayerOrder(), and UpdateAllLayersOrder().

1234 {
1235  int n = 0;
1236 
1237  m_orderedLayers.resize( m_layers.size() );
1238 
1239  for( LAYER_MAP_ITER i = m_layers.begin(); i != m_layers.end(); ++i )
1240  m_orderedLayers[n++] = &i->second;
1241 
1242  sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder );
1243 
1244  MarkDirty();
1245 }
LAYER_ORDER m_orderedLayers
Sorted list of pointers to members of m_layers.
Definition: view.h:815
LAYER_MAP::iterator LAYER_MAP_ITER
Definition: view.h:716
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
static bool compareRenderingOrder(VIEW_LAYER *aI, VIEW_LAYER *aJ)
Determines rendering order of layers. Used in display order sorting function.
Definition: view.h:800
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
VECTOR2D KIGFX::VIEW::ToScreen ( const VECTOR2D aCoord,
bool  aAbsolute = true 
) const

Function ToScreen() Converts a world space point/vector to a point/vector in screen space coordinates.

Parameters
aCoordthe point/vector to be converted
aAbsolutewhen true, aCoord is treated as a point, otherwise - as a direction (vector)

Definition at line 484 of file view.cpp.

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetWorldScreenMatrix(), m_gal, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetCenter(), TOOL_DISPATCHER::handleMouseButton(), KIGFX::WX_VIEW_CONTROLS::SetCrossHairCursorPosition(), SetScale(), and KIGFX::WX_VIEW_CONTROLS::WarpCursor().

485 {
486  const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
487 
488  if( aAbsolute )
489  return VECTOR2D( matrix * aCoord );
490  else
491  return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
492 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
double KIGFX::VIEW::ToScreen ( double  aSize) const

Function ToScreen() Converts a world space one dimensionsal size to a one dimensional size in screen space.

Parameters
aSizethe size to be transformed.

Definition at line 495 of file view.cpp.

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetWorldScreenMatrix(), m_gal, and VECTOR2< T >::x.

496 {
497  const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
498 
499  return matrix.GetScale().x * aSize;
500 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
VECTOR2D KIGFX::VIEW::ToWorld ( const VECTOR2D aCoord,
bool  aAbsolute = true 
) const

Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates.

Parameters
aCoordthe point/vector to be converted
aAbsolutewhen true, aCoord is treated as a point, otherwise - as a direction (vector)

Definition at line 465 of file view.cpp.

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), m_gal, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by COMMON_TOOLS::CenterContents(), EDIT_POINTS::FindPoint(), SYMBOL_PREVIEW_WIDGET::fitOnDrawArea(), GetCenter(), KIGFX::WX_VIEW_CONTROLS::GetMousePosition(), GetViewport(), KIGFX::WX_VIEW_CONTROLS::onMotion(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), Redraw(), KIGFX::WX_VIEW_CONTROLS::refreshMouse(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), SetCenter(), SetScale(), SetViewport(), KIGFX::ORIGIN_VIEWITEM::ViewDraw(), EDIT_POINTS::ViewDraw(), SCH_BASE_FRAME::Window_Zoom(), SCH_BASE_FRAME::Zoom_Automatique(), COMMON_TOOLS::ZoomFitScreen(), and SELECTION_TOOL::zoomFitSelection().

466 {
467  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
468 
469  if( aAbsolute )
470  return VECTOR2D( matrix * aCoord );
471  else
472  return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
473 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
double KIGFX::VIEW::ToWorld ( double  aSize) const

Function ToWorld() Converts a screen space one dimensional size to a one dimensional size in world space coordinates.

Parameters
aSize: the size to be converted

Definition at line 476 of file view.cpp.

References MATRIX3x3< T >::GetScale(), KIGFX::GAL::GetScreenWorldMatrix(), m_gal, and VECTOR2< T >::x.

477 {
478  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
479 
480  return fabs( matrix.GetScale().x * aSize );
481 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
void KIGFX::VIEW::Update ( VIEW_ITEM aItem,
int  aUpdateFlags 
)
virtual

For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has changed.

For static views calling has no effect.

Parameters
aItemthe item to update.
aUpdateFlagshow much the object has changed.

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 1538 of file view.cpp.

References KIGFX::NONE, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by Add(), KIGFX::SCH_VIEW::AddToPreview(), KIGFX::SCH_VIEW::ClearPreview(), draw(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DrawMovingBlockOutlines(), DRAWING_TOOL::drawSegment(), PCB_EDIT_FRAME::Edit_Zone_Params(), SCH_EDIT_FRAME::EditSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), SCH_EDIT_FRAME::HandleBlockPlace(), Hide(), SCH_EDIT_FRAME::MirrorSheet(), EDIT_TOOL::MoveExact(), ZONE_CREATE_HELPER::OnGeometryChange(), DIALOG_UPDATE_PCB::PerformUpdate(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), processBoardItem(), BOARD_COMMIT::Push(), PCB_EDIT_FRAME::ReadPcbNetlist(), KIGFX::SCH_VIEW::Redraw(), DIALOG_PAD_PROPERTIES::redraw(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), SCH_BASE_FRAME::RefreshItem(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), SCH_EDIT_FRAME::RotateHierarchicalSheet(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectVisually(), SetVisible(), SCH_EDIT_FRAME::TestDanglingEnds(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow(), GERBVIEW_SELECTION_TOOL::unselectVisually(), KIGFX::PCB_VIEW::Update(), Update(), POINT_EDITOR::updatePoints(), and SELECTION_TOOL::updateSelection().

1539 {
1540  auto viewData = aItem->viewPrivData();
1541 
1542  if( !viewData )
1543  return;
1544 
1545  assert( aUpdateFlags != NONE );
1546 
1547  viewData->m_requiredUpdate |= aUpdateFlags;
1548 
1549 }
void KIGFX::VIEW::Update ( VIEW_ITEM aItem)
virtual

Reimplemented in KIGFX::PCB_VIEW.

Definition at line 1532 of file view.cpp.

References KIGFX::ALL, and Update().

1533 {
1534  Update( aItem, ALL );
1535 }
Item needs to be redrawn.
Definition: view_item.h:61
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:1538
void KIGFX::VIEW::UpdateAllItems ( int  aUpdateFlags)

Updates all items in the view according to the given flags.

Parameters
aUpdateFlagsis is according to KIGFX::VIEW_UPDATE_FLAGS

Definition at line 1415 of file view.cpp.

References m_allItems.

Referenced by FOOTPRINT_VIEWER_FRAME::ApplyDisplaySettingsToGAL(), DISPLAY_FOOTPRINTS_FRAME::ApplyDisplaySettingsToGAL(), GERBVIEW_CONTROL::HighlightControl(), SCH_EDIT_FRAME::KiwayMailIn(), MarkDirty(), GERBVIEW_FRAME::OnSelectHighlightChoice(), SCH_EDIT_FRAME::OnSelectOptionToolbar(), LIB_EDIT_FRAME::OnShowElectricalType(), SCH_EDIT_FRAME::PutDataInPreviousState(), and SCH_BASE_FRAME::SyncView().

1416 {
1417  for( VIEW_ITEM* item : m_allItems )
1418  {
1419  auto viewData = item->viewPrivData();
1420 
1421  if( !viewData )
1422  continue;
1423 
1424  viewData->m_requiredUpdate |= aUpdateFlags;
1425  }
1426 }
friend class VIEW_ITEM
Definition: view.h:64
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
void KIGFX::VIEW::UpdateAllItemsConditionally ( int  aUpdateFlags,
std::function< bool(VIEW_ITEM *)>  aCondition 
)

Updates items in the view according to the given flags and condition.

Parameters
aUpdateFlagsis is according to KIGFX::VIEW_UPDATE_FLAGS
aConditionis a function returning true if the item should be updated

Definition at line 1429 of file view.cpp.

References m_allItems.

Referenced by MarkDirty(), GERBVIEW_FRAME::SetElementVisibility(), and GERBVIEW_FRAME::UpdateDisplayOptions().

1431 {
1432  for( VIEW_ITEM* item : m_allItems )
1433  {
1434  if( aCondition( item ) )
1435  {
1436  auto viewData = item->viewPrivData();
1437 
1438  if( !viewData )
1439  continue;
1440 
1441  viewData->m_requiredUpdate |= aUpdateFlags;
1442  }
1443  }
1444 }
friend class VIEW_ITEM
Definition: view.h:64
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
void KIGFX::VIEW::UpdateAllLayersColor ( )

Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.

The used scheme is held by RENDER_SETTINGS.

See also
RENDER_SETTINGS

Definition at line 782 of file view.cpp.

References KIGFX::GAL::BeginUpdate(), KIGFX::GAL::ChangeGroupColor(), color, KIGFX::GAL::EndUpdate(), KIGFX::RENDER_SETTINGS::GetColor(), KIGFX::PAINTER::GetSettings(), i, m_allItems, m_gal, m_painter, MarkDirty(), and VIEW_MAX_LAYERS.

Referenced by PCB_EDITOR_CONTROL::ClearHighlight(), EnableTopLayer(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), highlightNet(), GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer(), PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), EDA_DRAW_PANEL_GAL::SetHighContrastLayer(), and SetLayerTarget().

783 {
784  m_gal->BeginUpdate();
785 
786  for( VIEW_ITEM* item : m_allItems )
787  {
788  auto viewData = item->viewPrivData();
789 
790  if( !viewData )
791  continue;
792 
793  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
794  viewData->getLayers( layers, layers_count );
795 
796  for( int i = 0; i < layers_count; ++i )
797  {
798  const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
799  int group = viewData->getGroup( layers[i] );
800 
801  if( group >= 0 )
802  m_gal->ChangeGroupColor( group, color );
803  }
804  }
805 
806  m_gal->EndUpdate();
807  MarkDirty();
808 }
friend class VIEW_ITEM
Definition: view.h:64
int color
Definition: DXF_plotter.cpp:62
virtual void EndUpdate()
Disables item update mode.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const =0
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Changes the color used to draw the group.
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
virtual void BeginUpdate()
Enables item update mode.
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
size_t i
Definition: json11.cpp:597
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void KIGFX::VIEW::UpdateAllLayersOrder ( )

Function UpdateLayerOrder() Does everything that is needed to apply the rendering order of layers.

It has to be called after modification of renderingOrder field of LAYER.

Definition at line 909 of file view.cpp.

References KIGFX::GAL::BeginUpdate(), KIGFX::GAL::ChangeGroupDepth(), KIGFX::GAL::EndUpdate(), i, m_allItems, m_gal, m_layers, MarkDirty(), sortLayers(), and VIEW_MAX_LAYERS.

Referenced by EnableTopLayer(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), SetLayerTarget(), GERBVIEW_DRAW_PANEL_GAL::SetTopLayer(), PCB_DRAW_PANEL_GAL::SetTopLayer(), and EDA_DRAW_PANEL_GAL::SetTopLayer().

910 {
911  sortLayers();
912  m_gal->BeginUpdate();
913 
914  for( VIEW_ITEM* item : m_allItems )
915  {
916  auto viewData = item->viewPrivData();
917 
918  if( !viewData )
919  continue;
920 
921  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
922  viewData->getLayers( layers, layers_count );
923 
924  for( int i = 0; i < layers_count; ++i )
925  {
926  int group = viewData->getGroup( layers[i] );
927 
928  if( group >= 0 )
929  m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
930  }
931  }
932 
933  m_gal->EndUpdate();
934  MarkDirty();
935 }
void sortLayers()
Definition: view.cpp:1233
friend class VIEW_ITEM
Definition: view.h:64
virtual void EndUpdate()
Disables item update mode.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
virtual void BeginUpdate()
Enables item update mode.
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
size_t i
Definition: json11.cpp:597
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Changes the depth (Z-axis position) of the group.
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:628
void KIGFX::VIEW::updateBbox ( VIEW_ITEM aItem)
protected

Updates bounding box of an item.

Definition at line 1297 of file view.cpp.

References i, KIGFX::VIEW_RTREE::Insert(), KIGFX::VIEW::VIEW_LAYER::items, m_layers, MarkTargetDirty(), KIGFX::VIEW_RTREE::Remove(), KIGFX::VIEW::VIEW_LAYER::target, VIEW_MAX_LAYERS, and KIGFX::VIEW_ITEM::ViewGetLayers().

Referenced by invalidateItem(), and markTargetClean().

1298 {
1299  int layers[VIEW_MAX_LAYERS], layers_count;
1300 
1301  aItem->ViewGetLayers( layers, layers_count );
1302 
1303  for( int i = 0; i < layers_count; ++i )
1304  {
1305  VIEW_LAYER& l = m_layers[layers[i]];
1306  l.items->Remove( aItem );
1307  l.items->Insert( aItem );
1308  MarkTargetDirty( l.target );
1309  }
1310 }
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::updateItemColor ( VIEW_ITEM aItem,
int  aLayer 
)
protected

Updates colors that are used for an item to be drawn.

Definition at line 1248 of file view.cpp.

References KIGFX::GAL::ChangeGroupColor(), color, KIGFX::RENDER_SETTINGS::GetColor(), KIGFX::PAINTER::GetSettings(), IsCached(), m_gal, m_layers, m_painter, and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by invalidateItem(), and markTargetClean().

1249 {
1250  auto viewData = aItem->viewPrivData();
1251  wxASSERT( (unsigned) aLayer < m_layers.size() );
1252  wxASSERT( IsCached( aLayer ) );
1253 
1254  if( !viewData )
1255  return;
1256 
1257  // Obtain the color that should be used for coloring the item on the specific layerId
1258  const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
1259  int group = viewData->getGroup( aLayer );
1260 
1261  // Change the color, only if it has group assigned
1262  if( group >= 0 )
1263  m_gal->ChangeGroupColor( group, color );
1264 }
int color
Definition: DXF_plotter.cpp:62
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const =0
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Changes the color used to draw the group.
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void KIGFX::VIEW::updateItemGeometry ( VIEW_ITEM aItem,
int  aLayer 
)
protected

Updates all informations needed to draw an item.

Definition at line 1267 of file view.cpp.

References KIGFX::GAL::BeginGroup(), KIGFX::GAL::DeleteGroup(), KIGFX::PAINTER::Draw(), KIGFX::GAL::EndGroup(), IsCached(), m_gal, m_layers, m_painter, KIGFX::VIEW::VIEW_LAYER::renderingOrder, KIGFX::GAL::SetLayerDepth(), KIGFX::GAL::SetTarget(), KIGFX::VIEW::VIEW_LAYER::target, KIGFX::VIEW_ITEM::ViewDraw(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by invalidateItem(), and markTargetClean().

1268 {
1269  auto viewData = aItem->viewPrivData();
1270  wxASSERT( (unsigned) aLayer < m_layers.size() );
1271  wxASSERT( IsCached( aLayer ) );
1272 
1273  if( !viewData )
1274  return;
1275 
1276  VIEW_LAYER& l = m_layers.at( aLayer );
1277 
1278  m_gal->SetTarget( l.target );
1279  m_gal->SetLayerDepth( l.renderingOrder );
1280 
1281  // Redraw the item from scratch
1282  int group = viewData->getGroup( aLayer );
1283 
1284  if( group >= 0 )
1285  m_gal->DeleteGroup( group );
1286 
1287  group = m_gal->BeginGroup();
1288  viewData->setGroup( aLayer, group );
1289 
1290  if( !m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ) )
1291  aItem->ViewDraw( aLayer, this ); // Alternative drawing method
1292 
1293  m_gal->EndGroup();
1294 }
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void EndGroup()
End the group.
virtual int BeginGroup()
Begin a group.
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer)=0
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
void KIGFX::VIEW::UpdateItems ( )

Function UpdateItems() Iterates through the list of items that asked for updating and updates them.

Definition at line 1393 of file view.cpp.

References KIGFX::GAL::BeginUpdate(), KIGFX::GAL::EndUpdate(), invalidateItem(), m_allItems, m_gal, and KIGFX::NONE.

Referenced by MarkDirty(), EDA_DRAW_PANEL_GAL::onPaint(), PCB_DRAW_PANEL_GAL::OnShow(), and ReorderLayerData().

1394 {
1395  m_gal->BeginUpdate();
1396 
1397  for( VIEW_ITEM* item : m_allItems )
1398  {
1399  auto viewData = item->viewPrivData();
1400 
1401  if( !viewData )
1402  continue;
1403 
1404  if( viewData->m_requiredUpdate != NONE )
1405  {
1406  invalidateItem( item, viewData->m_requiredUpdate );
1407  viewData->m_requiredUpdate = NONE;
1408  }
1409  }
1410 
1411  m_gal->EndUpdate();
1412 }
friend class VIEW_ITEM
Definition: view.h:64
virtual void EndUpdate()
Disables item update mode.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void invalidateItem(VIEW_ITEM *aItem, int aUpdateFlags)
Function invalidateItem() Manages dirty flags & redraw queueing when updating an item.
Definition: view.cpp:1188
virtual void BeginUpdate()
Enables item update mode.
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:858
void KIGFX::VIEW::UpdateLayerColor ( int  aLayer)

Function UpdateLayerColor() Applies the new coloring scheme held by RENDER_SETTINGS in case that it has changed.

Parameters
aLayeris a number of the layer to be updated.
See also
RENDER_SETTINGS

Definition at line 764 of file view.cpp.

References KIGFX::GAL::BeginUpdate(), KIGFX::GAL::EndUpdate(), IsCached(), m_gal, m_layers, m_painter, MarkTargetDirty(), and BOX2< Vec >::SetMaximum().

Referenced by PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), PCB_LAYER_WIDGET::OnLayerColorChange(), GERBER_LAYER_WIDGET::OnLayerColorChange(), PCB_LAYER_WIDGET::OnRenderColorChange(), and SetLayerTarget().

765 {
766  // There is no point in updating non-cached layers
767  if( !IsCached( aLayer ) )
768  return;
769 
770  BOX2I r;
771 
772  r.SetMaximum();
773 
774  m_gal->BeginUpdate();
775  updateItemsColor visitor( aLayer, m_painter, m_gal );
776  m_layers[aLayer].items->Query( r, visitor );
777  MarkTargetDirty( m_layers[aLayer].target );
778  m_gal->EndUpdate();
779 }
virtual void EndUpdate()
Disables item update mode.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
void SetMaximum()
Definition: box2.h:71
virtual void BeginUpdate()
Enables item update mode.
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:842
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::updateLayers ( VIEW_ITEM aItem)
protected

Updates set of layers that an item occupies.

Definition at line 1313 of file view.cpp.

References KIGFX::GAL::DeleteGroup(), KIGFX::VIEW_ITEM_DATA::getLayers(), i, KIGFX::VIEW::VIEW_LAYER::id, KIGFX::VIEW_RTREE::Insert(), IsCached(), KIGFX::VIEW::VIEW_LAYER::items, m_gal, m_layers, MarkTargetDirty(), KIGFX::VIEW_RTREE::Remove(), KIGFX::VIEW::VIEW_LAYER::target, VIEW_MAX_LAYERS, KIGFX::VIEW_ITEM::ViewGetLayers(), and KIGFX::VIEW_ITEM::viewPrivData().

Referenced by invalidateItem(), and markTargetClean().

1314 {
1315  auto viewData = aItem->viewPrivData();
1316  int layers[VIEW_MAX_LAYERS], layers_count;
1317 
1318  if( !viewData )
1319  return;
1320 
1321  // Remove the item from previous layer set
1322  viewData->getLayers( layers, layers_count );
1323 
1324  for( int i = 0; i < layers_count; ++i )
1325  {
1326  VIEW_LAYER& l = m_layers[layers[i]];
1327  l.items->Remove( aItem );
1328  MarkTargetDirty( l.target );
1329 
1330  if( IsCached( l.id ) )
1331  {
1332  // Redraw the item from scratch
1333  int prevGroup = viewData->getGroup( layers[i] );
1334 
1335  if( prevGroup >= 0 )
1336  {
1337  m_gal->DeleteGroup( prevGroup );
1338  viewData->setGroup( l.id, -1 );
1339  }
1340  }
1341  }
1342 
1343  // Add the item to new layer set
1344  aItem->ViewGetLayers( layers, layers_count );
1345  viewData->saveLayers( layers, layers_count );
1346 
1347  for( int i = 0; i < layers_count; i++ )
1348  {
1349  VIEW_LAYER& l = m_layers[layers[i]];
1350  l.items->Insert( aItem );
1351  MarkTargetDirty( l.target );
1352  }
1353 }
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:845
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:602
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:68
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:610
size_t i
Definition: json11.cpp:597
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:812
void KIGFX::VIEW::UseDrawPriority ( bool  aFlag)
inline

Function UseDrawPriority()

Parameters
aFlagis true if draw priority should be respected while redrawing.

Definition at line 676 of file view.h.

References m_useDrawPriority.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME().

677  {
678  m_useDrawPriority = aFlag;
679  }
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition: view.h:861

Friends And Related Function Documentation

friend class VIEW_ITEM
friend

Definition at line 64 of file view.h.

Member Data Documentation

std::vector<VIEW_ITEM*> KIGFX::VIEW::m_allItems
protected
BOX2D KIGFX::VIEW::m_boundary
protected

View boundaries.

Definition at line 827 of file view.h.

Referenced by GetBoundary(), SetBoundary(), SetCenter(), and VIEW().

VECTOR2D KIGFX::VIEW::m_center
protected

Center point of the VIEW (the point at which we are looking at)

Definition at line 821 of file view.h.

Referenced by GetCenter(), SetCenter(), SetGAL(), and SetScale().

bool KIGFX::VIEW::m_dirtyTargets[TARGETS_NUMBER]
protected

Flags to mark targets as dirty, so they have to be redrawn on the next refresh event.

Definition at line 852 of file view.h.

Referenced by IsTargetDirty(), MarkDirty(), markTargetClean(), and MarkTargetDirty().

bool KIGFX::VIEW::m_dynamic
protected

Dynamic VIEW (eg.

display PCB in window) allows changes once it is built, static (eg. image/PDF) - does not.

Definition at line 849 of file view.h.

Referenced by IsDynamic().

bool KIGFX::VIEW::m_enableOrderModifier
protected
  • Whether to use rendering order modifier or not

Definition at line 809 of file view.h.

Referenced by ClearTopLayers(), EnableTopLayer(), and SetTopLayer().

double KIGFX::VIEW::m_maxScale
protected

Scale upper limit.

Definition at line 833 of file view.h.

Referenced by SetScale(), and SetScaleLimits().

double KIGFX::VIEW::m_minScale
protected

Scale lower limit.

Definition at line 830 of file view.h.

Referenced by SetScale(), and SetScaleLimits().

bool KIGFX::VIEW::m_mirrorX
protected

Horizontal flip flag

Definition at line 836 of file view.h.

Referenced by IsMirroredX(), SetGAL(), and SetMirror().

bool KIGFX::VIEW::m_mirrorY
protected

Vertical flip flag

Definition at line 839 of file view.h.

Referenced by IsMirroredY(), SetGAL(), and SetMirror().

int KIGFX::VIEW::m_nextDrawPriority
protected

The next sequential drawing priority.

Definition at line 864 of file view.h.

Referenced by Add(), and Clear().

LAYER_ORDER KIGFX::VIEW::m_orderedLayers
protected

Sorted list of pointers to members of m_layers.

Definition at line 815 of file view.h.

Referenced by CalculateExtents(), Query(), KIGFX::SCH_VIEW::Redraw(), redrawRect(), and sortLayers().

PAINTER* KIGFX::VIEW::m_painter
protected

PAINTER contains information how do draw items.

Definition at line 842 of file view.h.

Referenced by draw(), GetPainter(), SetPainter(), UpdateAllLayersColor(), updateItemColor(), updateItemGeometry(), and UpdateLayerColor().

bool KIGFX::VIEW::m_reverseDrawOrder
protected

Flag to reverse the draw order when using draw priority.

Definition at line 867 of file view.h.

Referenced by IsDrawOrderReversed(), redrawRect(), and ReverseDrawOrder().

double KIGFX::VIEW::m_scale
protected

Scale of displayed VIEW_ITEMs.

Definition at line 824 of file view.h.

Referenced by GetScale(), SetGAL(), and SetScale().

std::set<unsigned int> KIGFX::VIEW::m_topLayers
protected

Stores set of layers that are displayed on the top.

Definition at line 818 of file view.h.

Referenced by ClearTopLayers(), EnableTopLayer(), GetTopLayer(), and SetTopLayer().

bool KIGFX::VIEW::m_useDrawPriority
protected

Flag to respect draw priority when drawing items.

Definition at line 861 of file view.h.

Referenced by IsUsingDrawPriority(), redrawRect(), and UseDrawPriority().

const int KIGFX::VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS
staticprotected

Rendering order modifier for layers that are marked as top layers.

Definition at line 855 of file view.h.

Referenced by ClearTopLayers(), EnableTopLayer(), MakeOverlay(), and SetTopLayer().


The documentation for this class was generated from the following files: