KiCad PCB EDA Suite
KIGFX::PCB_VIEW Class Reference

#include <pcb_view.h>

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

Public Types

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

Public Member Functions

 PCB_VIEW (bool aIsDynamic=true)
 
virtual ~PCB_VIEW ()
 
virtual void Add (VIEW_ITEM *aItem, int aDrawPriority=-1) override
 Function Add() Adds a VIEW_ITEM to the view. More...
 
virtual void Remove (VIEW_ITEM *aItem) override
 Function Remove() Removes a VIEW_ITEM from the view. More...
 
virtual void Update (VIEW_ITEM *aItem, int aUpdateFlags) override
 For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has changed. More...
 
virtual void Update (VIEW_ITEM *aItem) override
 For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has changed. More...
 
void UpdateDisplayOptions (PCB_DISPLAY_OPTIONS *aOptions)
 
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...
 
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 BOX2I &aBoundary)
 Function SetBoundary() Sets limits for view area. More...
 
const BOX2IGetBoundary () 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...
 

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...
 

Detailed Description

Definition at line 36 of file pcb_view.h.

Member Typedef Documentation

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

Definition at line 63 of file view.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file pcb_view.cpp.

37  :
38  VIEW( aIsDynamic )
39 {
40 }
VIEW(bool aIsDynamic=true)
Constructor.
Definition: view.cpp:283
KIGFX::PCB_VIEW::~PCB_VIEW ( )
virtual

Definition at line 43 of file pcb_view.cpp.

44 {
45 }

Member Function Documentation

void KIGFX::PCB_VIEW::Add ( KIGFX::VIEW_ITEM aItem,
int  aDrawPriority = -1 
)
overridevirtual

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 from KIGFX::VIEW.

Definition at line 48 of file pcb_view.cpp.

References KIGFX::VIEW::Add(), mod, and PCB_MODULE_T.

Referenced by PCB_TOOL::doInteractiveItemPlacement(), EDIT_TOOL::MeasureTool(), SELECTION_TOOL::Reset(), and SELECTION_TOOL::zoomFitSelection().

49 {
50  auto item = static_cast<BOARD_ITEM*>( aItem );
51 
52  if( item->Type() == PCB_MODULE_T )
53  {
54  auto mod = static_cast<MODULE*>( item );
55  mod->RunOnChildren([this] ( BOARD_ITEM* aModItem ) {
56  VIEW::Add( aModItem );
57  } );
58  }
59 
60  VIEW::Add( item, aDrawPriority );
61 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:334
#define mod(a, n)
Definition: greymap.cpp:24
void KIGFX::VIEW::AddLayer ( int  aLayer,
bool  aDisplayOnly = false 
)
inherited

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 317 of file view.cpp.

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

Referenced by KIGFX::VIEW::GetCenter(), and KIGFX::VIEW::VIEW().

318 {
319  if( m_layers.find( aLayer ) == m_layers.end() )
320  {
321  m_layers[aLayer] = VIEW_LAYER();
322  m_layers[aLayer].id = aLayer;
323  m_layers[aLayer].items = new VIEW_RTREE();
324  m_layers[aLayer].renderingOrder = aLayer;
325  m_layers[aLayer].visible = true;
326  m_layers[aLayer].displayOnly = aDisplayOnly;
327  m_layers[aLayer].target = TARGET_CACHED;
328  }
329 
330  sortLayers();
331 }
void sortLayers()
Definition: view.cpp:1231
Main rendering target (cached)
Definition: definitions.h:41
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
const BOX2I KIGFX::VIEW::CalculateExtents ( )
inherited

Definition at line 1467 of file view.cpp.

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

Referenced by KIGFX::VIEW::MarkDirty().

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

Function Clear() Removes all items from the view.

Definition at line 1088 of file view.cpp.

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

Referenced by PCB_DRAW_PANEL_GAL::DisplayBoard(), KIGFX::VIEW::GetCenter(), GERBVIEW_FRAME::OnCloseWindow(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), PCB_BASE_EDIT_FRAME::SetBoard(), DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME(), and GERBVIEW_FRAME::~GERBVIEW_FRAME().

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

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

Parameters
aLayerID of the layer to be cleared

Referenced by KIGFX::VIEW::GetCenter().

void KIGFX::VIEW::ClearTargets ( )
inherited

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

Definition at line 1103 of file view.cpp.

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

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

1104 {
1106  {
1107  // TARGET_CACHED and TARGET_NONCACHED have to be redrawn together, as they contain
1108  // layers that rely on each other (eg. netnames are noncached, but tracks - are cached)
1111 
1112  MarkDirty();
1113  }
1114 
1115  if( IsTargetDirty( TARGET_OVERLAY ) )
1116  {
1118  }
1119 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
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:574
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:612
void KIGFX::VIEW::ClearTopLayers ( )
inherited

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

Definition at line 892 of file view.cpp.

References KIGFX::VIEW::m_enableOrderModifier, KIGFX::VIEW::m_layers, KIGFX::VIEW::m_topLayers, and KIGFX::VIEW::TOP_LAYER_MODIFIER.

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

893 {
894  std::set<unsigned int>::iterator it;
895 
897  {
898  // Restore the previous rendering order for layers that were marked as top
899  for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
900  m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
901  }
902 
903  m_topLayers.clear();
904 }
static const int TOP_LAYER_MODIFIER
Rendering order modifier for layers that are marked as top layers.
Definition: view.h:840
std::set< unsigned int > m_topLayers
Stores set of layers that are displayed on the top.
Definition: view.h:803
bool m_enableOrderModifier
Definition: view.h:794
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
void KIGFX::VIEW::CopySettings ( const VIEW aOtherView)
inherited

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

Parameters
aOtherViewview from which settings will be copied.

Definition at line 501 of file view.cpp.

502 {
503  wxASSERT_MSG( false, wxT( "This is not implemented" ) );
504 }
void KIGFX::VIEW::EnableTopLayer ( bool  aEnable)
virtualinherited

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 867 of file view.cpp.

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

Referenced by KIGFX::VIEW::SetLayerTarget().

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

Function GetBoundary()

Returns
Current view area boundary.

Definition at line 284 of file view.h.

References KIGFX::VIEW::m_boundary.

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

285  {
286  return m_boundary;
287  }
BOX2I m_boundary
View boundaries.
Definition: view.h:812
const VECTOR2D& KIGFX::VIEW::GetCenter ( ) const
inlineinherited

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

Returns
center point of the view

Definition at line 325 of file view.h.

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

Referenced by KIGFX::WX_VIEW_CONTROLS::onButton(), KIGFX::WX_VIEW_CONTROLS::onScroll(), KIGFX::WX_VIEW_CONTROLS::onTimer(), KIGFX::WX_VIEW_CONTROLS::onWheel(), EDA_DRAW_FRAME::UseGalCanvas(), and COMMON_TOOLS::ZoomFitScreen().

326  {
327  return m_center;
328  }
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:806
int KIGFX::VIEW::GetLayerOrder ( int  aLayer) const
inherited

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 657 of file view.cpp.

References KIGFX::VIEW::m_layers.

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

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

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 196 of file view.h.

References KIGFX::VIEW::GetViewport(), KIGFX::VIEW::m_painter, KIGFX::VIEW::SetMirror(), and KIGFX::VIEW::SetViewport().

Referenced by 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(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), 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(), GERBVIEW_DRAW_PANEL_GAL::OnShow(), PCB_DRAW_PANEL_GAL::OnShow(), DIALOG_PAD_PROPERTIES::prepareCanvas(), 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(), 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().

197  {
198  return m_painter;
199  }
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:827
double KIGFX::VIEW::GetScale ( ) const
inlineinherited
const VECTOR2I & KIGFX::VIEW::GetScreenPixelSize ( ) const
inherited

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

Returns
viewport screen size

Definition at line 1147 of file view.cpp.

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

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

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

Definition at line 831 of file view.cpp.

References KIGFX::VIEW::m_topLayers.

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

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

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

Returns
Current viewport rectangle

Definition at line 524 of file view.cpp.

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

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

525 {
526  BOX2D rect;
527  VECTOR2D screenSize = m_gal->GetScreenPixelSize();
528 
529  rect.SetOrigin( ToWorld( VECTOR2D( 0, 0 ) ) );
530  rect.SetEnd( ToWorld( screenSize ) );
531 
532  return rect.Normalize();
533 }
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:463
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
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 
)
inherited

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 1503 of file view.cpp.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::highlight(), GERBVIEW_SELECTION_TOOL::selectVisually(), SELECTION_TOOL::unhighlight(), and GERBVIEW_SELECTION_TOOL::unselectVisually().

1504 {
1505  auto viewData = aItem->viewPrivData();
1506 
1507  if( !viewData )
1508  return;
1509 
1510  if( !( viewData->m_flags & VISIBLE ) )
1511  return;
1512 
1513  if( aHide )
1514  viewData->m_flags |= HIDDEN;
1515  else
1516  viewData->m_flags &= ~HIDDEN;
1517 
1518  Update( aItem, APPEARANCE );
1519 }
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:1536
bool KIGFX::VIEW::IsCached ( int  aLayer) const
inlineinherited

Returns true if the layer is cached.

Definition at line 594 of file view.h.

References KIGFX::VIEW::m_layers, and KIGFX::TARGET_CACHED.

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

595  {
596  wxASSERT( aLayer < (int) m_layers.size() );
597 
598  try
599  {
600  return m_layers.at( aLayer ).target == TARGET_CACHED;
601  }
602  catch( const std::out_of_range& )
603  {
604  return false;
605  }
606  }
Main rendering target (cached)
Definition: definitions.h:41
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
bool KIGFX::VIEW::IsDirty ( ) const
inlineinherited

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 557 of file view.h.

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

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

558  {
559  for( int i = 0; i < TARGETS_NUMBER; ++i )
560  {
561  if( IsTargetDirty( i ) )
562  return true;
563  }
564 
565  return false;
566  }
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:574
size_t i
Definition: json11.cpp:597
bool KIGFX::VIEW::IsDrawOrderReversed ( ) const
inlineinherited

Function IsDrawOrderReversed()

Returns
true if draw order is reversed

Definition at line 669 of file view.h.

References KIGFX::VIEW::m_reverseDrawOrder.

670  {
671  return m_reverseDrawOrder;
672  }
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:852
bool KIGFX::VIEW::IsDynamic ( ) const
inlineinherited

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 547 of file view.h.

References KIGFX::VIEW::m_dynamic.

548  {
549  return m_dynamic;
550  }
bool m_dynamic
Dynamic VIEW (eg.
Definition: view.h:834
bool KIGFX::VIEW::IsLayerVisible ( int  aLayer) const
inlineinherited

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

Parameters
aLayertrue if the layer is visible, false otherwise

Definition at line 413 of file view.h.

References KIGFX::VIEW::m_layers.

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

414  {
415  wxASSERT( aLayer < (int) m_layers.size() );
416 
417  return m_layers.at( aLayer ).visible;
418  }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
bool KIGFX::VIEW::IsMirroredX ( ) const
inlineinherited

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

Definition at line 227 of file view.h.

References KIGFX::VIEW::m_mirrorX.

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

228  {
229  return m_mirrorX;
230  }
bool m_mirrorX
Horizontal flip flag
Definition: view.h:821
bool KIGFX::VIEW::IsMirroredY ( ) const
inlineinherited

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

Definition at line 236 of file view.h.

References KIGFX::VIEW::m_mirrorY.

237  {
238  return m_mirrorY;
239  }
bool m_mirrorY
Vertical flip flag
Definition: view.h:824
bool KIGFX::VIEW::IsTargetDirty ( int  aTarget) const
inlineinherited

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 574 of file view.h.

References KIGFX::VIEW::m_dirtyTargets, and KIGFX::TARGETS_NUMBER.

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

575  {
576  wxASSERT( aTarget < TARGETS_NUMBER );
577 
578  return m_dirtyTargets[aTarget];
579  }
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:837
bool KIGFX::VIEW::IsUsingDrawPriority ( ) const
inlineinherited

Function IsUsingDrawPriority()

Returns
true if draw priority is being respected while redrawing.

Definition at line 651 of file view.h.

References KIGFX::VIEW::m_useDrawPriority.

652  {
653  return m_useDrawPriority;
654  }
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition: view.h:846
bool KIGFX::VIEW::IsVisible ( const VIEW_ITEM aItem) const
inherited

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 1522 of file view.cpp.

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

Referenced by SELECTION_TOOL::selectable().

1523 {
1524  const auto viewData = aItem->viewPrivData();
1525 
1526  return viewData->m_flags & VISIBLE;
1527 }
void KIGFX::VIEW::MarkDirty ( )
inlineinherited
void KIGFX::VIEW::MarkForUpdate ( VIEW_ITEM aItem)
inherited

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 KIGFX::VIEW::MarkDirty().

void KIGFX::VIEW::OnDestroy ( VIEW_ITEM aItem)
staticinherited

Definition at line 269 of file view.cpp.

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

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

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

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 440 of file view.cpp.

References i, and KIGFX::VIEW::m_orderedLayers.

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

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

Function RecacheAllItems() Rebuilds GAL display lists.

Definition at line 1372 of file view.cpp.

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

Referenced by GERBVIEW_DRAW_PANEL_GAL::OnShow(), KIGFX::VIEW::SetLayerTarget(), PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow(), GERBVIEW_FRAME::UseGalCanvas(), and PCB_BASE_FRAME::UseGalCanvas().

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

Function Redraw() Immediately redraws the whole view.

Definition at line 1122 of file view.cpp.

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

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

1123 {
1124 #ifdef __WXDEBUG__
1125  PROF_COUNTER totalRealTime;
1126 #endif /* __WXDEBUG__ */
1127 
1128  VECTOR2D screenSize = m_gal->GetScreenPixelSize();
1129  BOX2I rect( ToWorld( VECTOR2D( 0, 0 ) ),
1130  ToWorld( screenSize ) - ToWorld( VECTOR2D( 0, 0 ) ) );
1131  rect.Normalize();
1132 
1133  redrawRect( rect );
1134 
1135  // All targets were redrawn, so nothing is dirty
1139 
1140 #ifdef __WXDEBUG__
1141  totalRealTime.Stop();
1142  wxLogTrace( "GAL_PROFILE", "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
1143 #endif /* __WXDEBUG__ */
1144 }
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:463
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
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:718
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:987
Main rendering target (cached)
Definition: definitions.h:41
void KIGFX::PCB_VIEW::Remove ( KIGFX::VIEW_ITEM aItem)
overridevirtual

Function Remove() Removes a VIEW_ITEM from the view.

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

Reimplemented from KIGFX::VIEW.

Definition at line 64 of file pcb_view.cpp.

References mod, PCB_MODULE_T, and KIGFX::VIEW::Remove().

Referenced by PCB_TOOL::doInteractiveItemPlacement(), EDIT_TOOL::MeasureTool(), and SELECTION_TOOL::Reset().

65 {
66  auto item = static_cast<BOARD_ITEM*>( aItem );
67 
68 
69  if( item->Type() == PCB_MODULE_T )
70  {
71  auto mod = static_cast<MODULE*>( item );
72  mod->RunOnChildren([this] ( BOARD_ITEM* aModItem ) {
73  VIEW::Remove( aModItem );
74  } );
75  }
76 
77  VIEW::Remove( item );
78 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:364
class MODULE, a footprint
Definition: typeinfo.h:89
#define mod(a, n)
Definition: greymap.cpp:24
void KIGFX::VIEW::ReorderLayerData ( std::unordered_map< int, int >  aReorderMap)
inherited

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 691 of file view.cpp.

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

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

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

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

Parameters
aFlagis true if draw order should be reversed

Definition at line 679 of file view.h.

References KIGFX::VIEW::m_reverseDrawOrder.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

680  {
681  m_reverseDrawOrder = aFlag;
682  }
bool m_reverseDrawOrder
Flag to reverse the draw order when using draw priority.
Definition: view.h:852
void KIGFX::VIEW::SetBoundary ( const BOX2I aBoundary)
inlineinherited

Function SetBoundary() Sets limits for view area.

Parameters
aBoundaryis the box that limits view area.

Definition at line 275 of file view.h.

References KIGFX::VIEW::m_boundary.

Referenced by DIALOG_PAD_PROPERTIES::redraw().

276  {
277  m_boundary = aBoundary;
278  }
BOX2I m_boundary
View boundaries.
Definition: view.h:812
void KIGFX::VIEW::SetCenter ( const VECTOR2D aCenter)
inherited

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 587 of file view.cpp.

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

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

588 {
589  m_center = aCenter;
590 
591  if( !m_boundary.Contains( aCenter ) )
592  {
593  if( m_center.x < m_boundary.GetLeft() )
595  else if( aCenter.x > m_boundary.GetRight() )
597 
598  if( m_center.y < m_boundary.GetTop() )
600  else if( m_center.y > m_boundary.GetBottom() )
602  }
603 
606 
607  // Redraw everything after the viewport has changed
608  MarkDirty();
609 }
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:830
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:806
BOX2I m_boundary
View boundaries.
Definition: view.h:812
coord_type GetBottom() const
Definition: box2.h:198
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:612
void KIGFX::VIEW::SetCenter ( VECTOR2D  aCenter,
const BOX2D occultingScreenRect 
)
inherited

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 612 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(), KIGFX::VIEW::m_gal, max, KIGFX::VIEW::SetCenter(), KIGFX::VIEW::ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

613 {
614  BOX2D screenRect( VECTOR2D( 0, 0 ), m_gal->GetScreenPixelSize() );
615 
616  if( !screenRect.Intersects( occultingScreenRect ) )
617  {
618  SetCenter( aCenter );
619  return;
620  }
621 
622  BOX2D occultedRect = screenRect.Intersect( occultingScreenRect );
623  VECTOR2D offset( occultedRect.GetWidth() / 2, occultedRect.GetHeight() / 2 );
624 
625  double topExposed = occultedRect.GetTop() - screenRect.GetTop();
626  double bottomExposed = screenRect.GetBottom() - occultedRect.GetBottom();
627  double leftExposed = occultedRect.GetLeft() - screenRect.GetLeft();
628  double rightExposed = screenRect.GetRight() - occultedRect.GetRight();
629 
630  if( std::max( topExposed, bottomExposed ) > std::max( leftExposed, rightExposed ) )
631  {
632  if( topExposed > bottomExposed )
633  aCenter.y += ToWorld( occultedRect.GetHeight() / 2 );
634  else
635  aCenter.y -= ToWorld( occultedRect.GetHeight() / 2 );
636  }
637  else
638  {
639  if( leftExposed > rightExposed )
640  aCenter.x += ToWorld( occultedRect.GetWidth() / 2 );
641  else
642  aCenter.x -= ToWorld( occultedRect.GetWidth() / 2 );
643  }
644 
645  SetCenter( aCenter );
646 }
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:463
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
coord_type GetRight() const
Definition: box2.h:197
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
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:587
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)
inherited

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

Parameters
aGalpointer to the GAL output device

Definition at line 507 of file view.cpp.

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

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

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

Definition at line 420 of file view.h.

References KIGFX::VIEW::m_layers.

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

421  {
422  wxASSERT( aLayer < (int) m_layers.size() );
423 
424  m_layers[aLayer].displayOnly = aDisplayOnly;
425  }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
void KIGFX::VIEW::SetLayerOrder ( int  aLayer,
int  aRenderingOrder 
)
inherited

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 649 of file view.cpp.

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

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

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

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

Parameters
aLayeris the layer.
aTargetis the rendering target.

Definition at line 433 of file view.h.

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

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

434  {
435  wxASSERT( aLayer < (int) m_layers.size() );
436 
437  m_layers[aLayer].target = aTarget;
438  }
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
void KIGFX::VIEW::SetLayerVisible ( int  aLayer,
bool  aVisible = true 
)
inlineinherited

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

Parameters
aLayerthe layer to show/hide.
aVisiblethe obvious.

Definition at line 396 of file view.h.

References KIGFX::VIEW::m_layers, and KIGFX::VIEW::MarkTargetDirty().

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

397  {
398  wxASSERT( aLayer < (int) m_layers.size() );
399 
400  if( m_layers[aLayer].visible != aVisible )
401  {
402  // Target has to be redrawn after changing its visibility
403  MarkTargetDirty( m_layers[aLayer].target );
404  m_layers[aLayer].visible = aVisible;
405  }
406  }
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:586
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
void KIGFX::VIEW::SetMirror ( bool  aMirrorX,
bool  aMirrorY 
)
inherited

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 551 of file view.cpp.

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

Referenced by KIGFX::VIEW::GetPainter(), and KIGFX::VIEW::SetGAL().

552 {
553  wxASSERT_MSG( !aMirrorY, _( "Mirroring for Y axis is not supported yet" ) );
554 
555  m_mirrorX = aMirrorX;
556  m_mirrorY = aMirrorY;
557  m_gal->SetFlip( aMirrorX, aMirrorY );
558 
559  // Redraw everything
560  MarkDirty();
561 }
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:830
bool m_mirrorX
Horizontal flip flag
Definition: view.h:821
bool m_mirrorY
Vertical flip flag
Definition: view.h:824
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:612
void KIGFX::VIEW::SetPainter ( PAINTER aPainter)
inlineinherited

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

Definition at line 186 of file view.h.

References KIGFX::VIEW::m_painter.

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

187  {
188  m_painter = aPainter;
189  }
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:827
void KIGFX::VIEW::SetRequired ( int  aLayerId,
int  aRequiredId,
bool  aRequired = true 
)
inherited

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 404 of file view.cpp.

References KIGFX::VIEW::m_layers.

Referenced by PCB_DRAW_PANEL_GAL::setDefaultLayerDeps().

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

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 247 of file view.h.

References KIGFX::VIEW::m_center.

Referenced by COMMON_TOOLS::doZoomToPreset(), KIGFX::WX_VIEW_CONTROLS::onWheel(), DIALOG_PAD_PROPERTIES::redraw(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), KIGFX::VIEW::SetGAL(), KIGFX::VIEW::SetViewport(), EDA_DRAW_FRAME::UseGalCanvas(), COMMON_TOOLS::ZoomFitScreen(), and SELECTION_TOOL::zoomFitSelection().

248  {
249  SetScale( aScale, m_center );
250  }
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:247
VECTOR2D m_center
Center point of the VIEW (the point at which we are looking at)
Definition: view.h:806
void KIGFX::VIEW::SetScale ( double  aScale,
const VECTOR2D aAnchor 
)
inherited

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 564 of file view.cpp.

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

565 {
566  VECTOR2D a = ToScreen( aAnchor );
567 
568  if( aScale < m_minScale )
570  else if( aScale > m_maxScale )
572  else
573  m_scale = aScale;
574 
577 
578  VECTOR2D delta = ToWorld( a ) - aAnchor;
579 
580  SetCenter( m_center - delta );
581 
582  // Redraw everything after the viewport has changed
583  MarkDirty();
584 }
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:463
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
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:806
double m_minScale
Scale lower limit.
Definition: view.h:815
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:587
double m_maxScale
Scale upper limit.
Definition: view.h:818
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:482
void SetZoomFactor(double aZoomFactor)
Set the zoom factor of the scene.
double m_scale
Scale of displayed VIEW_ITEMs.
Definition: view.h:809
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:612
void KIGFX::VIEW::SetScaleLimits ( double  aMaximum,
double  aMinimum 
)
inlineinherited

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 295 of file view.h.

References KIGFX::VIEW::m_maxScale, KIGFX::VIEW::m_minScale, and KIGFX::VIEW::SetCenter().

296  {
297  wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
298 
299  m_minScale = aMinimum;
300  m_maxScale = aMaximum;
301  }
double m_minScale
Scale lower limit.
Definition: view.h:815
double m_maxScale
Scale upper limit.
Definition: view.h:818
void KIGFX::VIEW::SetTopLayer ( int  aLayer,
bool  aEnabled = true 
)
virtualinherited

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 840 of file view.cpp.

References KIGFX::VIEW::m_enableOrderModifier, KIGFX::VIEW::m_layers, KIGFX::VIEW::m_topLayers, and KIGFX::VIEW::TOP_LAYER_MODIFIER.

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

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

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

Parameters
aViewportdesired visible area, in world space coordinates.

Definition at line 536 of file view.cpp.

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

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

537 {
538  VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
539 
540  wxASSERT( ssize.x > 0 && ssize.y > 0 );
541 
542  VECTOR2D centre = aViewport.Centre();
543  VECTOR2D vsize = aViewport.GetSize();
544  double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
545 
546  SetCenter( centre );
547  SetScale( GetScale() * zoom );
548 }
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:463
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
const Vec & GetSize() const
Definition: box2.h:187
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:247
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:587
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:265
void KIGFX::VIEW::SetVisible ( VIEW_ITEM aItem,
bool  aIsVisible = true 
)
inherited

Sets the item visibility.

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

Definition at line 1482 of file view.cpp.

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

Referenced by KIGFX::VIEW::Add(), GRID_HELPER::BestSnapAnchor(), MICROWAVE_TOOL::drawMicrowaveInductor(), 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(), and ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER().

1483 {
1484  auto viewData = aItem->viewPrivData();
1485 
1486  if( !viewData )
1487  return;
1488 
1489  bool cur_visible = viewData->m_flags & VISIBLE;
1490 
1491  if( cur_visible != aIsVisible )
1492  {
1493  if( aIsVisible )
1494  viewData->m_flags |= VISIBLE;
1495  else
1496  viewData->m_flags &= ~VISIBLE;
1497 
1498  Update( aItem, APPEARANCE | COLOR );
1499  }
1500 }
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:1536
void KIGFX::VIEW::SortLayers ( int  aLayers[],
int &  aCount 
) const
inherited

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 663 of file view.cpp.

References KIGFX::VIEW::GetLayerOrder(), and i.

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

664 {
665  int maxLay, maxOrd, maxIdx;
666 
667  for( int i = 0; i < aCount; ++i )
668  {
669  maxLay = aLayers[i];
670  maxOrd = GetLayerOrder( maxLay );
671  maxIdx = i;
672 
673  // Look for the max element in the range (j..aCount)
674  for( int j = i; j < aCount; ++j )
675  {
676  if( maxOrd < GetLayerOrder( aLayers[j] ) )
677  {
678  maxLay = aLayers[j];
679  maxOrd = GetLayerOrder( maxLay );
680  maxIdx = j;
681  }
682  }
683 
684  // Swap elements
685  aLayers[maxIdx] = aLayers[i];
686  aLayers[i] = maxLay;
687  }
688 }
int GetLayerOrder(int aLayer) const
Function GetLayerOrder() Returns rendering order of a particular layer.
Definition: view.cpp:657
size_t i
Definition: json11.cpp:597
VECTOR2D KIGFX::VIEW::ToScreen ( const VECTOR2D aCoord,
bool  aAbsolute = true 
) const
inherited

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 482 of file view.cpp.

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

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

483 {
484  const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
485 
486  if( aAbsolute )
487  return VECTOR2D( matrix * aCoord );
488  else
489  return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
490 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
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
inherited

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 493 of file view.cpp.

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

494 {
495  const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
496 
497  return matrix.GetScale().x * aSize;
498 }
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
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
inherited

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 463 of file view.cpp.

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

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

464 {
465  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
466 
467  if( aAbsolute )
468  return VECTOR2D( matrix * aCoord );
469  else
470  return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
471 }
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:830
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
inherited

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 474 of file view.cpp.

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

475 {
476  const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
477 
478  return fabs( matrix.GetScale().x * aSize );
479 }
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:830
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:269
void KIGFX::PCB_VIEW::Update ( KIGFX::VIEW_ITEM aItem,
int  aUpdateFlags 
)
overridevirtual

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 from KIGFX::VIEW.

Definition at line 81 of file pcb_view.cpp.

References mod, PCB_MODULE_T, and KIGFX::VIEW::Update().

Referenced by SELECTION_TOOL::clearSelection(), PCB_TOOL::doInteractiveItemPlacement(), PCBNEW_CONTROL::GraphicDisplayMode(), EDIT_TOOL::MeasureTool(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCBNEW_CONTROL::PadDisplayMode(), SELECTION_TOOL::select(), PCBNEW_CONTROL::TrackDisplayMode(), SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unselect(), Update(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

82 {
83  auto item = static_cast<BOARD_ITEM*>( aItem );
84 
85  if( item->Type() == PCB_MODULE_T )
86  {
87  auto mod = static_cast<MODULE*>( item );
88  mod->RunOnChildren([this, aUpdateFlags] ( BOARD_ITEM* aModItem ) {
89  VIEW::Update( aModItem, aUpdateFlags );
90  } );
91  }
92 
93  VIEW::Update( item, aUpdateFlags );
94 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
class MODULE, a footprint
Definition: typeinfo.h:89
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:1536
#define mod(a, n)
Definition: greymap.cpp:24
void KIGFX::PCB_VIEW::Update ( KIGFX::VIEW_ITEM aItem)
overridevirtual

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 from KIGFX::VIEW.

Definition at line 97 of file pcb_view.cpp.

References KIGFX::ALL, and Update().

98 {
99  PCB_VIEW::Update( aItem, KIGFX::ALL );
100 }
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:81
Item needs to be redrawn.
Definition: view_item.h:61
void KIGFX::VIEW::UpdateAllItems ( int  aUpdateFlags)
inherited

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

Parameters
aUpdateFlagsis is according to KIGFX::VIEW_UPDATE_FLAGS

Definition at line 1413 of file view.cpp.

References KIGFX::VIEW::m_allItems.

Referenced by GERBVIEW_CONTROL::HighlightControl(), KIGFX::VIEW::MarkDirty(), and GERBVIEW_FRAME::OnSelectHighlightChoice().

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

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 1427 of file view.cpp.

References KIGFX::VIEW::m_allItems.

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

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

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 780 of file view.cpp.

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

Referenced by KIGFX::VIEW::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 KIGFX::VIEW::SetLayerTarget().

781 {
782  m_gal->BeginUpdate();
783 
784  for( VIEW_ITEM* item : m_allItems )
785  {
786  auto viewData = item->viewPrivData();
787 
788  if( !viewData )
789  continue;
790 
791  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
792  viewData->getLayers( layers, layers_count );
793 
794  for( int i = 0; i < layers_count; ++i )
795  {
796  const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
797  int group = viewData->getGroup( layers[i] );
798 
799  if( group >= 0 )
800  m_gal->ChangeGroupColor( group, color );
801  }
802  }
803 
804  m_gal->EndUpdate();
805  MarkDirty();
806 }
friend class VIEW_ITEM
Definition: view.h:61
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:830
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:684
virtual void BeginUpdate()
Enables item update mode.
PAINTER * m_painter
PAINTER contains information how do draw items.
Definition: view.h:827
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:843
size_t i
Definition: json11.cpp:597
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:612
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void KIGFX::VIEW::UpdateAllLayersOrder ( )
inherited

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 907 of file view.cpp.

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

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

908 {
909  sortLayers();
910  m_gal->BeginUpdate();
911 
912  for( VIEW_ITEM* item : m_allItems )
913  {
914  auto viewData = item->viewPrivData();
915 
916  if( !viewData )
917  continue;
918 
919  int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
920  viewData->getLayers( layers, layers_count );
921 
922  for( int i = 0; i < layers_count; ++i )
923  {
924  int group = viewData->getGroup( layers[i] );
925 
926  if( group >= 0 )
927  m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
928  }
929  }
930 
931  m_gal->EndUpdate();
932  MarkDirty();
933 }
void sortLayers()
Definition: view.cpp:1231
friend class VIEW_ITEM
Definition: view.h:61
virtual void EndUpdate()
Disables item update mode.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:684
virtual void BeginUpdate()
Enables item update mode.
std::vector< VIEW_ITEM * > m_allItems
Flat list of all items.
Definition: view.h:843
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:797
void MarkDirty()
Function MarkDirty() Forces redraw of view on the next rendering.
Definition: view.h:612
void KIGFX::PCB_VIEW::UpdateDisplayOptions ( PCB_DISPLAY_OPTIONS aOptions)

Definition at line 103 of file pcb_view.cpp.

References KIGFX::VIEW::GetPainter(), and KIGFX::PCB_RENDER_SETTINGS::LoadDisplayOptions().

Referenced by PCBNEW_CONTROL::GraphicDisplayMode(), PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCB_BASE_FRAME::OnToggleEdgeDrawMode(), PCB_BASE_FRAME::OnTogglePadDrawMode(), PCB_BASE_FRAME::OnToggleTextDrawMode(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

104 {
105  auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetPainter() );
106  auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
107 
108  settings->LoadDisplayOptions( aOptions, settings->GetShowPageLimits() );
109 }
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:189
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
void LoadDisplayOptions(const PCB_DISPLAY_OPTIONS *aOptions, bool aShowPageLimits)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode...
void KIGFX::VIEW::UpdateItems ( )
inherited

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

Definition at line 1391 of file view.cpp.

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

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

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

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 762 of file view.cpp.

References KIGFX::GAL::BeginUpdate(), KIGFX::GAL::EndUpdate(), KIGFX::VIEW::IsCached(), KIGFX::VIEW::m_gal, KIGFX::VIEW::m_layers, KIGFX::VIEW::m_painter, KIGFX::VIEW::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 KIGFX::VIEW::SetLayerTarget().

763 {
764  // There is no point in updating non-cached layers
765  if( !IsCached( aLayer ) )
766  return;
767 
768  BOX2I r;
769 
770  r.SetMaximum();
771 
772  m_gal->BeginUpdate();
773  updateItemsColor visitor( aLayer, m_painter, m_gal );
774  m_layers[aLayer].items->Query( r, visitor );
775  MarkTargetDirty( m_layers[aLayer].target );
776  m_gal->EndUpdate();
777 }
virtual void EndUpdate()
Disables item update mode.
GAL * m_gal
Gives interface to PAINTER, that is used to draw items.
Definition: view.h:830
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:586
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:827
bool IsCached(int aLayer) const
Returns true if the layer is cached.
Definition: view.h:594
LAYER_MAP m_layers
Contains set of possible displayed layers and its properties.
Definition: view.h:797
void KIGFX::VIEW::UseDrawPriority ( bool  aFlag)
inlineinherited

Function UseDrawPriority()

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

Definition at line 660 of file view.h.

References KIGFX::VIEW::m_useDrawPriority.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME().

661  {
662  m_useDrawPriority = aFlag;
663  }
bool m_useDrawPriority
Flag to respect draw priority when drawing items.
Definition: view.h:846

Member Data Documentation


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