Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-02 22:57:13 +00:00
|
|
|
* Copyright (C) 2013-2017 CERN
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2016-05-09 15:23:01 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <base_struct.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
|
|
|
|
#include <view/view.h>
|
2013-08-20 13:07:38 +00:00
|
|
|
#include <view/view_group.h>
|
2016-12-02 17:58:12 +00:00
|
|
|
#include <view/view_item.h>
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <view/view_rtree.h>
|
2018-08-23 21:54:42 +00:00
|
|
|
#include <view/view_overlay.h>
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <gal/definitions.h>
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
#include <painter.h>
|
|
|
|
|
2016-05-02 13:56:17 +00:00
|
|
|
#ifdef __WXDEBUG__
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
#include <profile.h>
|
2016-05-02 13:56:17 +00:00
|
|
|
#endif /* __WXDEBUG__ */
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
namespace KIGFX {
|
|
|
|
|
|
|
|
class VIEW;
|
|
|
|
|
|
|
|
class VIEW_ITEM_DATA
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VIEW_ITEM_DATA() :
|
2016-12-30 11:39:41 +00:00
|
|
|
m_view( nullptr ),
|
2016-12-02 17:58:12 +00:00
|
|
|
m_flags( KIGFX::VISIBLE ),
|
|
|
|
m_requiredUpdate( KIGFX::NONE ),
|
2017-04-01 12:48:13 +00:00
|
|
|
m_drawPriority( 0 ),
|
2016-12-02 17:58:12 +00:00
|
|
|
m_groups( nullptr ),
|
|
|
|
m_groupsSize( 0 ) {}
|
|
|
|
|
|
|
|
~VIEW_ITEM_DATA()
|
|
|
|
{
|
2017-01-16 13:23:22 +00:00
|
|
|
deleteGroups();
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int getFlags() const
|
|
|
|
{
|
|
|
|
return m_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class VIEW;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getLayers()
|
|
|
|
* Returns layer numbers used by the item.
|
|
|
|
*
|
|
|
|
* @param aLayers[]: output layer index array
|
|
|
|
* @param aCount: number of layer indices in aLayers[]
|
|
|
|
*/
|
|
|
|
void getLayers( int* aLayers, int& aCount ) const
|
|
|
|
{
|
|
|
|
int* layersPtr = aLayers;
|
|
|
|
|
2018-01-29 17:37:34 +00:00
|
|
|
for( auto layer : m_layers )
|
|
|
|
*layersPtr++ = layer;
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2018-01-29 17:37:34 +00:00
|
|
|
aCount = m_layers.size();
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VIEW* m_view; ///< Current dynamic view the item is assigned to.
|
2016-12-12 10:50:09 +00:00
|
|
|
int m_flags; ///< Visibility flags
|
2016-12-02 17:58:12 +00:00
|
|
|
int m_requiredUpdate; ///< Flag required for updating
|
2017-02-27 23:40:27 +00:00
|
|
|
int m_drawPriority; ///< Order to draw this item in a layer, lowest first
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-12 10:50:09 +00:00
|
|
|
///> Helper for storing cached items group ids
|
2016-12-02 17:58:12 +00:00
|
|
|
typedef std::pair<int, int> GroupPair;
|
|
|
|
|
2016-12-12 10:50:09 +00:00
|
|
|
///> Indexes of cached GAL display lists corresponding to the item (for every layer it occupies).
|
|
|
|
///> (in the std::pair "first" stores layer number, "second" stores group id).
|
2016-12-02 17:58:12 +00:00
|
|
|
GroupPair* m_groups;
|
|
|
|
int m_groupsSize;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getGroup()
|
|
|
|
* Returns number of the group id for the given layer, or -1 in case it was not cached before.
|
|
|
|
*
|
|
|
|
* @param aLayer is the layer number for which group id is queried.
|
|
|
|
* @return group id or -1 in case there is no group id (ie. item is not cached).
|
|
|
|
*/
|
2016-12-09 11:04:32 +00:00
|
|
|
int getGroup( int aLayer ) const
|
|
|
|
{
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
if( m_groups[i].first == aLayer )
|
|
|
|
return m_groups[i].second;
|
|
|
|
}
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function getAllGroups()
|
|
|
|
* Returns all group ids for the item (collected from all layers the item occupies).
|
|
|
|
*
|
|
|
|
* @return vector of group ids.
|
|
|
|
*/
|
|
|
|
std::vector<int> getAllGroups() const
|
|
|
|
{
|
|
|
|
std::vector<int> groups( m_groupsSize );
|
|
|
|
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
groups[i] = m_groups[i].second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function setGroup()
|
|
|
|
* Sets a group id for the item and the layer combination.
|
|
|
|
*
|
|
|
|
* @param aLayer is the layer numbe.
|
|
|
|
* @param aGroup is the group id.
|
|
|
|
*/
|
|
|
|
void setGroup( int aLayer, int aGroup )
|
|
|
|
{
|
|
|
|
// Look if there is already an entry for the layer
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
if( m_groups[i].first == aLayer )
|
|
|
|
{
|
|
|
|
m_groups[i].second = aGroup;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there was no entry for the given layer - create one
|
|
|
|
GroupPair* newGroups = new GroupPair[m_groupsSize + 1];
|
|
|
|
|
|
|
|
if( m_groupsSize > 0 )
|
|
|
|
{
|
|
|
|
std::copy( m_groups, m_groups + m_groupsSize, newGroups );
|
|
|
|
delete[] m_groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_groups = newGroups;
|
|
|
|
newGroups[m_groupsSize++] = GroupPair( aLayer, aGroup );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function deleteGroups()
|
|
|
|
* Removes all of the stored group ids. Forces recaching of the item.
|
|
|
|
*/
|
|
|
|
void deleteGroups()
|
|
|
|
{
|
|
|
|
delete[] m_groups;
|
2017-01-16 13:23:22 +00:00
|
|
|
m_groups = nullptr;
|
2016-12-02 17:58:12 +00:00
|
|
|
m_groupsSize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function storesGroups()
|
|
|
|
* Returns information if the item uses at least one group id (ie. if it is cached at all).
|
|
|
|
*
|
|
|
|
* @returns true in case it is cached at least for one layer.
|
|
|
|
*/
|
|
|
|
inline bool storesGroups() const
|
|
|
|
{
|
|
|
|
return m_groupsSize > 0;
|
|
|
|
}
|
|
|
|
|
2018-02-27 02:15:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reorders the stored groups (to facilitate reordering of layers)
|
|
|
|
* @see VIEW::ReorderLayerData
|
|
|
|
*
|
|
|
|
* @param aReorderMap is the mapping of old to new layer ids
|
|
|
|
*/
|
|
|
|
void reorderGroups( std::unordered_map<int, int> aReorderMap )
|
|
|
|
{
|
|
|
|
for( int i = 0; i < m_groupsSize; ++i )
|
|
|
|
{
|
|
|
|
int orig_layer = m_groups[i].first;
|
|
|
|
int new_layer = orig_layer;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
new_layer = aReorderMap.at( orig_layer );
|
|
|
|
}
|
2018-06-05 07:38:49 +00:00
|
|
|
catch( const std::out_of_range& ) {}
|
2018-02-27 02:15:32 +00:00
|
|
|
|
|
|
|
m_groups[i].first = new_layer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
/// Stores layer numbers used by the item.
|
2018-01-29 17:37:34 +00:00
|
|
|
std::vector<int> m_layers;
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function saveLayers()
|
|
|
|
* Saves layers used by the item.
|
|
|
|
*
|
|
|
|
* @param aLayers is an array containing layer numbers to be saved.
|
|
|
|
* @param aCount is the size of the array.
|
|
|
|
*/
|
|
|
|
void saveLayers( int* aLayers, int aCount )
|
|
|
|
{
|
2018-01-29 17:37:34 +00:00
|
|
|
m_layers.clear();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < aCount; ++i )
|
|
|
|
{
|
|
|
|
// this fires on some eagle board after EAGLE_PLUGIN::Load()
|
|
|
|
wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
|
|
|
|
|
2018-01-29 17:37:34 +00:00
|
|
|
m_layers.push_back( aLayers[i] );
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function viewRequiredUpdate()
|
|
|
|
* Returns current update flag for an item.
|
|
|
|
*/
|
|
|
|
int requiredUpdate() const
|
|
|
|
{
|
|
|
|
return m_requiredUpdate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function clearUpdateFlags()
|
|
|
|
* Marks an item as already updated, so it is not going to be redrawn.
|
|
|
|
*/
|
|
|
|
void clearUpdateFlags()
|
|
|
|
{
|
|
|
|
m_requiredUpdate = NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function isRenderable()
|
|
|
|
* Returns if the item should be drawn or not.
|
|
|
|
*/
|
|
|
|
bool isRenderable() const
|
|
|
|
{
|
|
|
|
return m_flags == VISIBLE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-12-12 10:50:09 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
void VIEW::OnDestroy( VIEW_ITEM* aItem )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
auto data = aItem->viewPrivData();
|
|
|
|
|
2017-01-16 13:23:22 +00:00
|
|
|
if( !data )
|
2016-12-02 17:58:12 +00:00
|
|
|
return;
|
|
|
|
|
2017-03-02 22:57:13 +00:00
|
|
|
if( data->m_view )
|
2017-10-31 15:08:18 +00:00
|
|
|
data->m_view->VIEW::Remove( aItem );
|
2017-03-02 22:57:13 +00:00
|
|
|
|
|
|
|
delete data;
|
2019-01-12 01:27:29 +00:00
|
|
|
aItem->ClearViewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2016-12-12 10:50:09 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
VIEW::VIEW( bool aIsDynamic ) :
|
2013-09-12 16:24:53 +00:00
|
|
|
m_enableOrderModifier( true ),
|
2015-05-18 11:48:13 +00:00
|
|
|
m_scale( 4.0 ),
|
2018-10-21 22:16:15 +00:00
|
|
|
m_minScale( 0.2 ), m_maxScale( 25000.0 ),
|
2016-12-12 10:51:08 +00:00
|
|
|
m_mirrorX( false ), m_mirrorY( false ),
|
2013-08-19 09:02:38 +00:00
|
|
|
m_painter( NULL ),
|
|
|
|
m_gal( NULL ),
|
2017-02-27 23:40:27 +00:00
|
|
|
m_dynamic( aIsDynamic ),
|
|
|
|
m_useDrawPriority( false ),
|
2017-09-17 22:36:18 +00:00
|
|
|
m_nextDrawPriority( 0 ),
|
|
|
|
m_reverseDrawOrder( false )
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
2018-11-18 19:04:17 +00:00
|
|
|
// Set m_boundary to define the max area size. The default area size
|
|
|
|
// is defined here as the max value of a int.
|
|
|
|
// this is a default value acceptable for Pcbnew and Gerbview, but too large for Eeschema.
|
|
|
|
// So in eeschema a call to SetBoundary() with a smaller value will be needed.
|
|
|
|
typedef std::numeric_limits<int> coord_limits;
|
|
|
|
double pos = coord_limits::lowest() / 2 + coord_limits::epsilon();
|
|
|
|
double size = coord_limits::max() - coord_limits::epsilon();
|
|
|
|
m_boundary.SetOrigin( pos, pos );
|
|
|
|
m_boundary.SetSize( size, size );
|
2018-12-22 12:44:49 +00:00
|
|
|
SetPrintMode( 0 );
|
2018-11-18 19:04:17 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems.reset( new std::vector<VIEW_ITEM*> );
|
|
|
|
m_allItems->reserve( 32768 );
|
2013-09-18 15:36:54 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
// Redraw everything at the beginning
|
2014-02-21 15:57:18 +00:00
|
|
|
MarkDirty();
|
2013-09-02 09:49:46 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
m_layers.reserve( VIEW_MAX_LAYERS );
|
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
// View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
|
|
|
|
// pad may be shown on pad, pad hole and solder paste layers). There are usual copper layers
|
|
|
|
// (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
|
|
|
|
// silkscreen, pads, vias, etc.
|
2020-08-10 21:52:22 +00:00
|
|
|
for( int ii = 0; ii < VIEW_MAX_LAYERS; ++ii )
|
|
|
|
{
|
|
|
|
m_layers.emplace_back();
|
|
|
|
m_layers[ii].items = std::make_shared<VIEW_RTREE>();
|
|
|
|
m_layers[ii].id = ii;
|
|
|
|
m_layers[ii].renderingOrder = ii;
|
|
|
|
m_layers[ii].visible = true;
|
|
|
|
m_layers[ii].displayOnly = false;
|
|
|
|
m_layers[ii].target = TARGET_CACHED;
|
|
|
|
}
|
2018-07-05 06:35:50 +00:00
|
|
|
|
|
|
|
sortLayers();
|
2020-08-01 13:20:08 +00:00
|
|
|
|
|
|
|
m_preview.reset( new KIGFX::VIEW_GROUP() );
|
|
|
|
Add( m_preview.get() );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VIEW::~VIEW()
|
|
|
|
{
|
2020-08-01 13:20:08 +00:00
|
|
|
Remove( m_preview.get() );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
void VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
if( aDrawPriority < 0 )
|
|
|
|
aDrawPriority = m_nextDrawPriority++;
|
|
|
|
|
2017-03-02 22:57:13 +00:00
|
|
|
if( !aItem->m_viewPrivData )
|
|
|
|
aItem->m_viewPrivData = new VIEW_ITEM_DATA;
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->m_viewPrivData->m_view = this;
|
2017-02-27 23:40:27 +00:00
|
|
|
aItem->m_viewPrivData->m_drawPriority = aDrawPriority;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
|
|
|
aItem->viewPrivData()->saveLayers( layers, layers_count );
|
2015-06-18 15:51:53 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems->push_back( aItem );
|
2016-12-07 09:20:31 +00:00
|
|
|
|
2014-02-24 11:56:47 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-09-04 14:23:26 +00:00
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Insert( aItem );
|
2013-09-13 09:38:16 +00:00
|
|
|
MarkTargetDirty( l.target );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
SetVisible( aItem, true );
|
2017-09-25 01:22:23 +00:00
|
|
|
Update( aItem, KIGFX::INITIAL_ADD );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::Remove( VIEW_ITEM* aItem )
|
|
|
|
{
|
2016-12-09 11:04:32 +00:00
|
|
|
if( !aItem )
|
2016-12-02 17:58:12 +00:00
|
|
|
return;
|
2016-12-07 09:20:31 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
auto viewData = aItem->viewPrivData();
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
if( !viewData )
|
2016-12-02 17:58:12 +00:00
|
|
|
return;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( viewData->m_view == this, /*void*/ );
|
2018-07-05 06:35:50 +00:00
|
|
|
auto item = std::find( m_allItems->begin(), m_allItems->end(), aItem );
|
2014-03-10 15:01:15 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
if( item != m_allItems->end() )
|
2016-12-07 09:20:31 +00:00
|
|
|
{
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems->erase( item );
|
2016-12-07 09:20:31 +00:00
|
|
|
viewData->clearUpdateFlags();
|
2014-03-10 15:01:15 +00:00
|
|
|
}
|
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->getLayers( layers, layers_count );
|
2013-09-02 09:49:46 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < layers_count; ++i )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-09-02 09:49:46 +00:00
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Remove( aItem );
|
2013-12-09 09:42:38 +00:00
|
|
|
MarkTargetDirty( l.target );
|
|
|
|
|
|
|
|
// Clear the GAL cache
|
2016-12-02 17:58:12 +00:00
|
|
|
int prevGroup = viewData->getGroup( layers[i] );
|
2014-02-24 11:56:47 +00:00
|
|
|
|
2013-12-09 09:42:38 +00:00
|
|
|
if( prevGroup >= 0 )
|
|
|
|
m_gal->DeleteGroup( prevGroup );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
2014-02-24 13:31:55 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->deleteGroups();
|
2017-03-02 22:57:13 +00:00
|
|
|
viewData->m_view = nullptr;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-05 14:28:58 +00:00
|
|
|
void VIEW::SetRequired( int aLayerId, int aRequiredId, bool aRequired )
|
|
|
|
{
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayerId < m_layers.size(), /*void*/ );
|
|
|
|
wxCHECK( (unsigned) aRequiredId < m_layers.size(), /*void*/ );
|
2013-08-05 14:28:58 +00:00
|
|
|
|
|
|
|
if( aRequired )
|
|
|
|
m_layers[aLayerId].requiredLayers.insert( aRequiredId );
|
|
|
|
else
|
|
|
|
m_layers[aLayerId].requiredLayers.erase( aRequired );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-04 08:55:51 +00:00
|
|
|
// stupid C++... python lambda would do this in one line
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
template <class Container>
|
|
|
|
struct queryVisitor
|
|
|
|
{
|
|
|
|
typedef typename Container::value_type item_type;
|
|
|
|
|
|
|
|
queryVisitor( Container& aCont, int aLayer ) :
|
|
|
|
m_cont( aCont ), m_layer( aLayer )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
if( aItem->viewPrivData()->getFlags() & VISIBLE )
|
2013-10-14 18:40:36 +00:00
|
|
|
m_cont.push_back( VIEW::LAYER_ITEM_PAIR( aItem, m_layer ) );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Container& m_cont;
|
|
|
|
int m_layer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
int VIEW::Query( const BOX2I& aRect, std::vector<LAYER_ITEM_PAIR>& aResult ) const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
|
|
|
if( m_orderedLayers.empty() )
|
|
|
|
return 0;
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
std::vector<VIEW_LAYER*>::const_reverse_iterator i;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
// execute queries in reverse direction, so that items that are on the top of
|
|
|
|
// the rendering stack are returned first.
|
|
|
|
for( i = m_orderedLayers.rbegin(); i != m_orderedLayers.rend(); ++i )
|
|
|
|
{
|
|
|
|
// ignore layers that do not contain actual items (i.e. the selection box, menus, floats)
|
2018-10-05 04:22:20 +00:00
|
|
|
if( ( *i )->displayOnly || !( *i )->visible )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
continue;
|
|
|
|
|
2013-10-14 18:40:36 +00:00
|
|
|
queryVisitor<std::vector<LAYER_ITEM_PAIR> > visitor( aResult, ( *i )->id );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
( *i )->items->Query( aRect, visitor );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aResult.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const
|
|
|
|
{
|
2014-02-13 18:31:27 +00:00
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
if( aAbsolute )
|
|
|
|
return VECTOR2D( matrix * aCoord );
|
|
|
|
else
|
|
|
|
return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-27 15:13:27 +00:00
|
|
|
double VIEW::ToWorld( double aSize ) const
|
|
|
|
{
|
|
|
|
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
|
|
|
|
|
2017-11-16 00:05:11 +00:00
|
|
|
return fabs( matrix.GetScale().x * aSize );
|
2014-02-27 15:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
|
|
|
|
{
|
2014-02-13 18:31:27 +00:00
|
|
|
const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
if( aAbsolute )
|
|
|
|
return VECTOR2D( matrix * aCoord );
|
|
|
|
else
|
|
|
|
return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-01 01:22:50 +00:00
|
|
|
double VIEW::ToScreen( double aSize ) const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2015-07-01 01:22:50 +00:00
|
|
|
const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2015-07-01 01:22:50 +00:00
|
|
|
return matrix.GetScale().x * aSize;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::CopySettings( const VIEW* aOtherView )
|
|
|
|
{
|
2013-06-18 15:01:23 +00:00
|
|
|
wxASSERT_MSG( false, wxT( "This is not implemented" ) );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::SetGAL( GAL* aGal )
|
|
|
|
{
|
2018-09-28 08:10:08 +00:00
|
|
|
bool recacheGroups = ( m_gal != nullptr ); // recache groups only if GAL is reassigned
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
m_gal = aGal;
|
|
|
|
|
2013-05-10 14:05:40 +00:00
|
|
|
// clear group numbers, so everything is going to be recached
|
2018-09-28 08:10:08 +00:00
|
|
|
if( recacheGroups )
|
|
|
|
clearGroupCache();
|
2013-04-18 15:10:02 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
// every target has to be refreshed
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
2013-08-19 09:02:38 +00:00
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
// force the new GAL to display the current viewport.
|
|
|
|
SetCenter( m_center );
|
|
|
|
SetScale( m_scale );
|
2016-12-12 10:51:08 +00:00
|
|
|
SetMirror( m_mirrorX, m_mirrorY );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOX2D VIEW::GetViewport() const
|
|
|
|
{
|
|
|
|
BOX2D rect;
|
|
|
|
VECTOR2D screenSize = m_gal->GetScreenPixelSize();
|
|
|
|
|
|
|
|
rect.SetOrigin( ToWorld( VECTOR2D( 0, 0 ) ) );
|
|
|
|
rect.SetEnd( ToWorld( screenSize ) );
|
|
|
|
|
|
|
|
return rect.Normalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
void VIEW::SetViewport( const BOX2D& aViewport )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2015-07-01 01:22:50 +00:00
|
|
|
VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( ssize.x > 0 && ssize.y > 0, /*void*/ );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
VECTOR2D centre = aViewport.Centre();
|
|
|
|
VECTOR2D vsize = aViewport.GetSize();
|
2014-07-09 09:22:42 +00:00
|
|
|
double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
SetCenter( centre );
|
|
|
|
SetScale( GetScale() * zoom );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::SetMirror( bool aMirrorX, bool aMirrorY )
|
|
|
|
{
|
2016-12-12 10:51:08 +00:00
|
|
|
wxASSERT_MSG( !aMirrorY, _( "Mirroring for Y axis is not supported yet" ) );
|
|
|
|
|
|
|
|
m_mirrorX = aMirrorX;
|
|
|
|
m_mirrorY = aMirrorY;
|
2013-08-27 16:08:32 +00:00
|
|
|
m_gal->SetFlip( aMirrorX, aMirrorY );
|
2016-12-12 10:50:46 +00:00
|
|
|
|
|
|
|
// Redraw everything
|
|
|
|
MarkDirty();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-08 09:06:53 +00:00
|
|
|
void VIEW::SetScale( double aScale, VECTOR2D aAnchor )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2019-08-08 09:06:53 +00:00
|
|
|
if( aAnchor == VECTOR2D( 0, 0 ) )
|
|
|
|
aAnchor = m_center;
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
VECTOR2D a = ToScreen( aAnchor );
|
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
if( aScale < m_minScale )
|
|
|
|
m_scale = m_minScale;
|
|
|
|
else if( aScale > m_maxScale )
|
|
|
|
m_scale = m_maxScale;
|
|
|
|
else
|
|
|
|
m_scale = aScale;
|
|
|
|
|
|
|
|
m_gal->SetZoomFactor( m_scale );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
m_gal->ComputeWorldScreenMatrix();
|
|
|
|
|
|
|
|
VECTOR2D delta = ToWorld( a ) - aAnchor;
|
|
|
|
|
|
|
|
SetCenter( m_center - delta );
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
// Redraw everything after the viewport has changed
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::SetCenter( const VECTOR2D& aCenter )
|
|
|
|
{
|
|
|
|
m_center = aCenter;
|
2013-09-18 15:36:54 +00:00
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
if( !m_boundary.Contains( aCenter ) )
|
|
|
|
{
|
|
|
|
if( m_center.x < m_boundary.GetLeft() )
|
|
|
|
m_center.x = m_boundary.GetLeft();
|
|
|
|
else if( aCenter.x > m_boundary.GetRight() )
|
|
|
|
m_center.x = m_boundary.GetRight();
|
|
|
|
|
|
|
|
if( m_center.y < m_boundary.GetTop() )
|
|
|
|
m_center.y = m_boundary.GetTop();
|
|
|
|
else if( m_center.y > m_boundary.GetBottom() )
|
|
|
|
m_center.y = m_boundary.GetBottom();
|
|
|
|
}
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
m_gal->SetLookAtPoint( m_center );
|
|
|
|
m_gal->ComputeWorldScreenMatrix();
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
// Redraw everything after the viewport has changed
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-30 06:45:53 +00:00
|
|
|
void VIEW::SetCenter( VECTOR2D aCenter, const BOX2D& occultingScreenRect )
|
|
|
|
{
|
|
|
|
BOX2D screenRect( VECTOR2D( 0, 0 ), m_gal->GetScreenPixelSize() );
|
|
|
|
|
|
|
|
if( !screenRect.Intersects( occultingScreenRect ) )
|
|
|
|
{
|
|
|
|
SetCenter( aCenter );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-20 00:41:16 +00:00
|
|
|
BOX2D occultedRect = screenRect.Intersect( occultingScreenRect );
|
2018-01-30 06:45:53 +00:00
|
|
|
double topExposed = occultedRect.GetTop() - screenRect.GetTop();
|
|
|
|
double bottomExposed = screenRect.GetBottom() - occultedRect.GetBottom();
|
|
|
|
double leftExposed = occultedRect.GetLeft() - screenRect.GetLeft();
|
|
|
|
double rightExposed = screenRect.GetRight() - occultedRect.GetRight();
|
|
|
|
|
|
|
|
if( std::max( topExposed, bottomExposed ) > std::max( leftExposed, rightExposed ) )
|
|
|
|
{
|
|
|
|
if( topExposed > bottomExposed )
|
2019-07-20 00:41:16 +00:00
|
|
|
aCenter.y += ToWorld( screenRect.GetHeight() / 2 - topExposed / 2 );
|
2018-01-30 06:45:53 +00:00
|
|
|
else
|
2019-07-20 00:41:16 +00:00
|
|
|
aCenter.y -= ToWorld( screenRect.GetHeight() / 2 - bottomExposed / 2 );
|
2018-01-30 06:45:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( leftExposed > rightExposed )
|
2019-07-20 00:41:16 +00:00
|
|
|
aCenter.x += ToWorld( screenRect.GetWidth() / 2 - leftExposed / 2 );
|
2018-01-30 06:45:53 +00:00
|
|
|
else
|
2019-07-20 00:41:16 +00:00
|
|
|
aCenter.x -= ToWorld( screenRect.GetWidth() / 2 - rightExposed / 2 );
|
2018-01-30 06:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetCenter( aCenter );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-20 13:07:38 +00:00
|
|
|
m_layers[aLayer].renderingOrder = aRenderingOrder;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
sortLayers();
|
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
int VIEW::GetLayerOrder( int aLayer ) const
|
|
|
|
{
|
2013-10-14 14:13:35 +00:00
|
|
|
return m_layers.at( aLayer ).renderingOrder;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
void VIEW::SortLayers( int aLayers[], int& aCount ) const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-20 13:07:38 +00:00
|
|
|
int maxLay, maxOrd, maxIdx;
|
2013-06-26 14:31:52 +00:00
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
for( int i = 0; i < aCount; ++i )
|
|
|
|
{
|
|
|
|
maxLay = aLayers[i];
|
|
|
|
maxOrd = GetLayerOrder( maxLay );
|
|
|
|
maxIdx = i;
|
|
|
|
|
|
|
|
// Look for the max element in the range (j..aCount)
|
|
|
|
for( int j = i; j < aCount; ++j )
|
|
|
|
{
|
|
|
|
if( maxOrd < GetLayerOrder( aLayers[j] ) )
|
|
|
|
{
|
|
|
|
maxLay = aLayers[j];
|
|
|
|
maxOrd = GetLayerOrder( maxLay );
|
|
|
|
maxIdx = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Swap elements
|
|
|
|
aLayers[maxIdx] = aLayers[i];
|
|
|
|
aLayers[i] = maxLay;
|
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-27 02:15:32 +00:00
|
|
|
void VIEW::ReorderLayerData( std::unordered_map<int, int> aReorderMap )
|
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
std::vector<VIEW_LAYER> new_map;
|
|
|
|
new_map.reserve( m_layers.size() );
|
2018-02-27 02:15:32 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( int ii = 0; ii < VIEW_MAX_LAYERS; ++ii )
|
|
|
|
new_map.emplace_back();
|
|
|
|
|
|
|
|
for( const VIEW_LAYER& layer : m_layers )
|
2018-02-27 02:15:32 +00:00
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
int orig_idx = layer.id;
|
|
|
|
int new_idx = orig_idx;
|
2018-02-27 02:15:32 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
if( aReorderMap.count( orig_idx ) )
|
2018-02-27 02:15:32 +00:00
|
|
|
new_idx = aReorderMap.at( orig_idx );
|
|
|
|
|
|
|
|
new_map[new_idx] = layer;
|
2020-08-10 21:52:22 +00:00
|
|
|
new_map[new_idx].id = new_idx;
|
2018-02-27 02:15:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_layers = new_map;
|
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-02-27 02:15:32 +00:00
|
|
|
{
|
|
|
|
auto viewData = item->viewPrivData();
|
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
|
|
|
|
item->ViewGetLayers( layers, layers_count );
|
|
|
|
viewData->saveLayers( layers, layers_count );
|
|
|
|
|
|
|
|
viewData->reorderGroups( aReorderMap );
|
|
|
|
|
|
|
|
viewData->m_requiredUpdate |= COLOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-25 15:12:54 +00:00
|
|
|
struct VIEW::updateItemsColor
|
|
|
|
{
|
|
|
|
updateItemsColor( int aLayer, PAINTER* aPainter, GAL* aGal ) :
|
2013-10-14 14:13:35 +00:00
|
|
|
layer( aLayer ), painter( aPainter ), gal( aGal )
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
|
|
|
// Obtain the color that should be used for coloring the item
|
2013-09-11 09:39:46 +00:00
|
|
|
const COLOR4D color = painter->GetSettings()->GetColor( aItem, layer );
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = aItem->viewPrivData()->getGroup( layer );
|
2013-06-25 15:12:54 +00:00
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
if( group >= 0 )
|
2013-07-08 13:24:44 +00:00
|
|
|
gal->ChangeGroupColor( group, color );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int layer;
|
|
|
|
PAINTER* painter;
|
|
|
|
GAL* gal;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::UpdateLayerColor( int aLayer )
|
|
|
|
{
|
2013-07-08 13:24:44 +00:00
|
|
|
// There is no point in updating non-cached layers
|
2013-09-04 14:23:26 +00:00
|
|
|
if( !IsCached( aLayer ) )
|
2013-07-08 13:24:44 +00:00
|
|
|
return;
|
|
|
|
|
2013-06-25 15:12:54 +00:00
|
|
|
BOX2I r;
|
|
|
|
|
|
|
|
r.SetMaximum();
|
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
|
|
|
{
|
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
|
|
|
|
|
|
|
updateItemsColor visitor( aLayer, m_painter, m_gal );
|
|
|
|
m_layers[aLayer].items->Query( r, visitor );
|
|
|
|
MarkTargetDirty( m_layers[aLayer].target );
|
|
|
|
}
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::UpdateAllLayersColor()
|
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
2013-06-25 15:12:54 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
2013-06-25 15:12:54 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-10-26 21:25:09 +00:00
|
|
|
{
|
|
|
|
auto viewData = item->viewPrivData();
|
2013-07-08 13:24:44 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( !viewData )
|
|
|
|
continue;
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
viewData->getLayers( layers, layers_count );
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
|
|
|
|
int group = viewData->getGroup( layers[i] );
|
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->ChangeGroupColor( group, color );
|
|
|
|
}
|
2018-02-25 20:38:05 +00:00
|
|
|
}
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
2013-09-12 16:24:53 +00:00
|
|
|
|
|
|
|
MarkDirty();
|
2013-06-25 15:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-26 14:31:52 +00:00
|
|
|
struct VIEW::changeItemsDepth
|
|
|
|
{
|
|
|
|
changeItemsDepth( int aLayer, int aDepth, GAL* aGal ) :
|
|
|
|
layer( aLayer ), depth( aDepth ), gal( aGal )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
2013-06-26 14:31:52 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = aItem->viewPrivData()->getGroup( layer );
|
2013-06-26 14:31:52 +00:00
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
gal->ChangeGroupDepth( group, depth );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
2013-06-26 14:31:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int layer, depth;
|
|
|
|
GAL* gal;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
int VIEW::GetTopLayer() const
|
2013-09-18 11:14:57 +00:00
|
|
|
{
|
|
|
|
if( m_topLayers.size() == 0 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return *m_topLayers.begin();
|
|
|
|
}
|
|
|
|
|
2013-06-26 14:31:52 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
void VIEW::SetTopLayer( int aLayer, bool aEnabled )
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
if( aEnabled )
|
2013-06-26 14:31:52 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
if( m_topLayers.count( aLayer ) == 1 )
|
|
|
|
return;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
m_topLayers.insert( aLayer );
|
|
|
|
|
|
|
|
// Move the layer closer to front
|
|
|
|
if( m_enableOrderModifier )
|
|
|
|
m_layers[aLayer].renderingOrder += TOP_LAYER_MODIFIER;
|
|
|
|
}
|
|
|
|
else
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
if( m_topLayers.count( aLayer ) == 0 )
|
|
|
|
return;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
m_topLayers.erase( aLayer );
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
// Restore the previous rendering order
|
|
|
|
if( m_enableOrderModifier )
|
|
|
|
m_layers[aLayer].renderingOrder -= TOP_LAYER_MODIFIER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::EnableTopLayer( bool aEnable )
|
|
|
|
{
|
2013-10-14 14:13:35 +00:00
|
|
|
if( aEnable == m_enableOrderModifier )
|
|
|
|
return;
|
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
m_enableOrderModifier = aEnable;
|
|
|
|
|
|
|
|
std::set<unsigned int>::iterator it;
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
if( aEnable )
|
|
|
|
{
|
|
|
|
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
|
|
|
|
m_layers[*it].renderingOrder += TOP_LAYER_MODIFIER;
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
|
|
|
|
m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
2013-07-16 11:40:53 +00:00
|
|
|
|
|
|
|
UpdateAllLayersOrder();
|
|
|
|
UpdateAllLayersColor();
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
void VIEW::ClearTopLayers()
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
std::set<unsigned int>::iterator it;
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2013-07-16 07:26:29 +00:00
|
|
|
if( m_enableOrderModifier )
|
2013-04-08 08:50:47 +00:00
|
|
|
{
|
2013-07-16 07:26:29 +00:00
|
|
|
// Restore the previous rendering order for layers that were marked as top
|
|
|
|
for( it = m_topLayers.begin(); it != m_topLayers.end(); ++it )
|
|
|
|
m_layers[*it].renderingOrder -= TOP_LAYER_MODIFIER;
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
2013-07-16 07:26:29 +00:00
|
|
|
|
|
|
|
m_topLayers.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::UpdateAllLayersOrder()
|
|
|
|
{
|
2013-06-26 14:31:52 +00:00
|
|
|
sortLayers();
|
2013-04-08 08:50:47 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
2013-07-16 07:26:29 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-10-26 21:25:09 +00:00
|
|
|
{
|
|
|
|
auto viewData = item->viewPrivData();
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
if( !viewData )
|
|
|
|
continue;
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
|
|
|
viewData->getLayers( layers, layers_count );
|
2018-02-25 20:38:05 +00:00
|
|
|
|
2018-10-26 21:25:09 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
|
|
|
int group = viewData->getGroup( layers[i] );
|
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
|
|
|
|
}
|
2018-02-25 20:38:05 +00:00
|
|
|
}
|
2013-07-16 07:26:29 +00:00
|
|
|
}
|
2013-09-12 16:24:53 +00:00
|
|
|
|
|
|
|
MarkDirty();
|
2013-04-08 08:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
struct VIEW::drawItem
|
|
|
|
{
|
2017-09-17 22:36:18 +00:00
|
|
|
drawItem( VIEW* aView, int aLayer, bool aUseDrawPriority, bool aReverseDrawOrder ) :
|
|
|
|
view( aView ), layer( aLayer ),
|
|
|
|
useDrawPriority( aUseDrawPriority ),
|
|
|
|
reverseDrawOrder( aReverseDrawOrder )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( aItem->viewPrivData(), false );
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2017-09-25 01:22:23 +00:00
|
|
|
// Conditions that have to be fulfilled for an item to be drawn
|
2016-12-02 17:58:12 +00:00
|
|
|
bool drawCondition = aItem->viewPrivData()->isRenderable() &&
|
|
|
|
aItem->ViewGetLOD( layer, view ) < view->m_scale;
|
2013-07-08 07:28:58 +00:00
|
|
|
if( !drawCondition )
|
2013-11-13 16:03:22 +00:00
|
|
|
return true;
|
2013-07-08 07:28:58 +00:00
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
if( useDrawPriority )
|
|
|
|
drawItems.push_back( aItem );
|
|
|
|
else
|
|
|
|
view->draw( aItem, layer );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
void deferredDraw()
|
|
|
|
{
|
2017-09-17 22:36:18 +00:00
|
|
|
if( reverseDrawOrder )
|
|
|
|
std::sort( drawItems.begin(), drawItems.end(),
|
|
|
|
[]( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool {
|
|
|
|
return b->viewPrivData()->m_drawPriority < a->viewPrivData()->m_drawPriority;
|
|
|
|
});
|
|
|
|
else
|
|
|
|
std::sort( drawItems.begin(), drawItems.end(),
|
|
|
|
[]( VIEW_ITEM* a, VIEW_ITEM* b ) -> bool {
|
|
|
|
return a->viewPrivData()->m_drawPriority < b->viewPrivData()->m_drawPriority;
|
|
|
|
});
|
2017-02-27 23:40:27 +00:00
|
|
|
|
|
|
|
for( auto item : drawItems )
|
|
|
|
view->draw( item, layer );
|
|
|
|
}
|
|
|
|
|
2013-07-04 15:02:20 +00:00
|
|
|
VIEW* view;
|
2014-07-09 09:22:42 +00:00
|
|
|
int layer, layers[VIEW_MAX_LAYERS];
|
2017-09-17 22:36:18 +00:00
|
|
|
bool useDrawPriority, reverseDrawOrder;
|
2017-02-27 23:40:27 +00:00
|
|
|
std::vector<VIEW_ITEM*> drawItems;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
};
|
|
|
|
|
2013-04-04 09:18:47 +00:00
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
void VIEW::redrawRect( const BOX2I& aRect )
|
|
|
|
{
|
2016-06-29 20:07:55 +00:00
|
|
|
for( VIEW_LAYER* l : m_orderedLayers )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2014-02-21 15:57:18 +00:00
|
|
|
if( l->visible && IsTargetDirty( l->target ) && areRequiredLayersEnabled( l->id ) )
|
2013-04-02 09:02:35 +00:00
|
|
|
{
|
2017-09-17 22:36:18 +00:00
|
|
|
drawItem drawFunc( this, l->id, m_useDrawPriority, m_reverseDrawOrder );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2013-07-23 16:39:07 +00:00
|
|
|
m_gal->SetTarget( l->target );
|
2013-07-16 07:26:29 +00:00
|
|
|
m_gal->SetLayerDepth( l->renderingOrder );
|
2013-04-02 09:02:35 +00:00
|
|
|
l->items->Query( aRect, drawFunc );
|
2017-02-27 23:40:27 +00:00
|
|
|
|
|
|
|
if( m_useDrawPriority )
|
|
|
|
drawFunc.deferredDraw();
|
2013-04-02 09:02:35 +00:00
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 08:52:50 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
auto viewData = aItem->viewPrivData();
|
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
if( IsCached( aLayer ) && !aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
|
|
|
// Draw using cached information or create one
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( aLayer );
|
2013-08-20 13:07:38 +00:00
|
|
|
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->DrawGroup( group );
|
|
|
|
else
|
2017-09-28 07:57:46 +00:00
|
|
|
Update( aItem );
|
2013-08-20 13:07:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Immediate mode
|
|
|
|
if( !m_painter->Draw( aItem, aLayer ) )
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
2013-08-20 13:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
2013-09-02 09:49:46 +00:00
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
// Sorting is needed for drawing order dependent GALs (like Cairo)
|
2013-08-20 13:07:38 +00:00
|
|
|
SortLayers( layers, layers_count );
|
|
|
|
|
|
|
|
for( int i = 0; i < layers_count; ++i )
|
|
|
|
{
|
2013-11-06 17:17:42 +00:00
|
|
|
m_gal->SetLayerDepth( m_layers.at( layers[i] ).renderingOrder );
|
2013-08-20 13:07:38 +00:00
|
|
|
draw( aItem, layers[i], aImmediate );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-16 13:23:22 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::draw( VIEW_GROUP* aGroup, bool aImmediate )
|
2013-08-20 13:07:38 +00:00
|
|
|
{
|
2016-12-09 11:04:32 +00:00
|
|
|
for( unsigned int i = 0; i < aGroup->GetSize(); i++)
|
2016-11-04 21:29:47 +00:00
|
|
|
draw( aGroup->GetItem(i), aImmediate );
|
2013-08-02 14:51:38 +00:00
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
|
|
|
|
2013-10-02 11:57:21 +00:00
|
|
|
struct VIEW::recacheItem
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
2016-05-09 15:23:01 +00:00
|
|
|
recacheItem( VIEW* aView, GAL* aGal, int aLayer ) :
|
|
|
|
view( aView ), gal( aGal ), layer( aLayer )
|
2013-04-30 15:55:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
auto viewData = aItem->viewPrivData();
|
2016-12-09 14:48:34 +00:00
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
return false;
|
|
|
|
|
2013-05-10 14:05:40 +00:00
|
|
|
// Remove previously cached group
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( layer );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( group >= 0 )
|
|
|
|
gal->DeleteGroup( group );
|
2013-04-30 15:55:24 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->setGroup( layer, -1 );
|
|
|
|
view->Update( aItem );
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
2013-04-18 15:10:02 +00:00
|
|
|
}
|
2013-04-30 15:55:24 +00:00
|
|
|
|
|
|
|
VIEW* view;
|
|
|
|
GAL* gal;
|
|
|
|
int layer;
|
2013-04-18 15:10:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
void VIEW::Clear()
|
|
|
|
{
|
|
|
|
BOX2I r;
|
|
|
|
r.SetMaximum();
|
2018-07-05 06:35:50 +00:00
|
|
|
m_allItems->clear();
|
2015-06-04 12:54:07 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
layer.items->RemoveAll();
|
2013-06-18 14:20:29 +00:00
|
|
|
|
2017-02-27 23:40:27 +00:00
|
|
|
m_nextDrawPriority = 0;
|
|
|
|
|
2013-07-04 15:02:20 +00:00
|
|
|
m_gal->ClearCache();
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-13 09:28:47 +00:00
|
|
|
void VIEW::ClearTargets()
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-08-26 08:43:22 +00:00
|
|
|
if( IsTargetDirty( TARGET_CACHED ) || IsTargetDirty( TARGET_NONCACHED ) )
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
|
|
|
// TARGET_CACHED and TARGET_NONCACHED have to be redrawn together, as they contain
|
|
|
|
// layers that rely on each other (eg. netnames are noncached, but tracks - are cached)
|
|
|
|
m_gal->ClearTarget( TARGET_NONCACHED );
|
|
|
|
m_gal->ClearTarget( TARGET_CACHED );
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
2013-08-26 08:43:22 +00:00
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
if( IsTargetDirty( TARGET_OVERLAY ) )
|
|
|
|
{
|
|
|
|
m_gal->ClearTarget( TARGET_OVERLAY );
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
2013-08-26 08:43:22 +00:00
|
|
|
}
|
2013-08-20 13:07:38 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
|
|
|
|
void VIEW::Redraw()
|
|
|
|
{
|
2016-05-02 13:56:17 +00:00
|
|
|
#ifdef __WXDEBUG__
|
2016-12-31 12:00:24 +00:00
|
|
|
PROF_COUNTER totalRealTime;
|
2016-05-02 13:56:17 +00:00
|
|
|
#endif /* __WXDEBUG__ */
|
2014-03-11 09:58:58 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
VECTOR2D screenSize = m_gal->GetScreenPixelSize();
|
2019-01-04 00:51:05 +00:00
|
|
|
BOX2D rect( ToWorld( VECTOR2D( 0, 0 ) ),
|
2013-08-26 08:43:22 +00:00
|
|
|
ToWorld( screenSize ) - ToWorld( VECTOR2D( 0, 0 ) ) );
|
2019-01-04 00:51:05 +00:00
|
|
|
|
2013-08-26 08:43:22 +00:00
|
|
|
rect.Normalize();
|
2019-01-04 00:51:05 +00:00
|
|
|
BOX2I recti( rect.GetPosition(), rect.GetSize() );
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2019-01-04 00:51:05 +00:00
|
|
|
// The view rtree uses integer positions. Large screens can overflow
|
|
|
|
// this size so in this case, simply set the rectangle to the full rtree
|
|
|
|
if( rect.GetWidth() > std::numeric_limits<int>::max() ||
|
|
|
|
rect.GetHeight() > std::numeric_limits<int>::max() )
|
|
|
|
recti.SetMaximum();
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2019-01-04 00:51:05 +00:00
|
|
|
redrawRect( recti );
|
2013-08-19 09:02:38 +00:00
|
|
|
// All targets were redrawn, so nothing is dirty
|
2014-02-21 15:57:18 +00:00
|
|
|
markTargetClean( TARGET_CACHED );
|
|
|
|
markTargetClean( TARGET_NONCACHED );
|
|
|
|
markTargetClean( TARGET_OVERLAY );
|
2014-03-11 09:58:58 +00:00
|
|
|
|
2016-05-02 13:56:17 +00:00
|
|
|
#ifdef __WXDEBUG__
|
2016-12-31 12:00:24 +00:00
|
|
|
totalRealTime.Stop();
|
2018-02-26 15:46:35 +00:00
|
|
|
wxLogTrace( "GAL_PROFILE", "VIEW::Redraw(): %.1f ms", totalRealTime.msecs() );
|
2016-05-02 13:56:17 +00:00
|
|
|
#endif /* __WXDEBUG__ */
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-20 07:47:31 +00:00
|
|
|
const VECTOR2I& VIEW::GetScreenPixelSize() const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
|
|
|
return m_gal->GetScreenPixelSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-04 15:02:20 +00:00
|
|
|
struct VIEW::clearLayerCache
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2013-07-04 15:02:20 +00:00
|
|
|
clearLayerCache( VIEW* aView ) :
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
view( aView )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:03:22 +00:00
|
|
|
bool operator()( VIEW_ITEM* aItem )
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->viewPrivData()->deleteGroups();
|
2013-11-13 16:03:22 +00:00
|
|
|
|
|
|
|
return true;
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VIEW* view;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::clearGroupCache()
|
|
|
|
{
|
|
|
|
BOX2I r;
|
|
|
|
|
|
|
|
r.SetMaximum();
|
2013-07-04 15:02:20 +00:00
|
|
|
clearLayerCache visitor( this );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
layer.items->Query( r, visitor );
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
2013-04-18 15:10:02 +00:00
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2017-09-25 01:22:23 +00:00
|
|
|
if( aUpdateFlags & INITIAL_ADD )
|
2017-07-24 14:18:09 +00:00
|
|
|
{
|
2017-09-25 01:22:23 +00:00
|
|
|
// Don't update layers or bbox, since it was done in VIEW::Add()
|
|
|
|
// Now that we have initialized, set flags to ALL for the code below
|
|
|
|
aUpdateFlags = ALL;
|
2017-07-24 14:18:09 +00:00
|
|
|
}
|
2017-09-25 01:22:23 +00:00
|
|
|
else
|
2017-07-24 14:18:09 +00:00
|
|
|
{
|
2017-09-25 01:22:23 +00:00
|
|
|
// updateLayers updates geometry too, so we do not have to update both of them at the same time
|
|
|
|
if( aUpdateFlags & LAYERS )
|
|
|
|
{
|
|
|
|
updateLayers( aItem );
|
|
|
|
}
|
|
|
|
else if( aUpdateFlags & GEOMETRY )
|
|
|
|
{
|
|
|
|
updateBbox( aItem );
|
|
|
|
}
|
2017-07-24 14:18:09 +00:00
|
|
|
}
|
2013-09-04 14:23:26 +00:00
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
// Iterate through layers used by the item and recache it immediately
|
2014-02-21 15:57:18 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2013-09-02 09:49:46 +00:00
|
|
|
int layerId = layers[i];
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( IsCached( layerId ) )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2018-02-25 20:01:17 +00:00
|
|
|
if( aUpdateFlags & ( GEOMETRY | LAYERS | REPAINT ) )
|
2013-09-04 14:23:26 +00:00
|
|
|
updateItemGeometry( aItem, layerId );
|
2016-12-02 17:58:12 +00:00
|
|
|
else if( aUpdateFlags & COLOR )
|
2014-02-21 15:57:18 +00:00
|
|
|
updateItemColor( aItem, layerId );
|
2013-08-07 15:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mark those layers as dirty, so the VIEW will be refreshed
|
2013-09-13 09:38:16 +00:00
|
|
|
MarkTargetDirty( m_layers[layerId].target );
|
2013-08-07 15:20:01 +00:00
|
|
|
}
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->viewPrivData()->clearUpdateFlags();
|
2013-08-07 15:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-20 13:07:38 +00:00
|
|
|
void VIEW::sortLayers()
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
m_orderedLayers.resize( m_layers.size() );
|
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( VIEW_LAYER& layer : m_layers )
|
|
|
|
m_orderedLayers[n++] = &layer;
|
2013-08-20 13:07:38 +00:00
|
|
|
|
|
|
|
sort( m_orderedLayers.begin(), m_orderedLayers.end(), compareRenderingOrder );
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
MarkDirty();
|
2013-08-20 13:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-02 09:49:46 +00:00
|
|
|
void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
|
2013-08-07 15:20:01 +00:00
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
auto viewData = aItem->viewPrivData();
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
|
|
|
|
wxCHECK( IsCached( aLayer ), /*void*/ );
|
2013-08-07 15:20:01 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
// Obtain the color that should be used for coloring the item on the specific layerId
|
2013-09-11 09:39:46 +00:00
|
|
|
const COLOR4D color = m_painter->GetSettings()->GetColor( aItem, aLayer );
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( aLayer );
|
2013-08-07 15:20:01 +00:00
|
|
|
|
|
|
|
// Change the color, only if it has group assigned
|
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->ChangeGroupColor( group, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
auto viewData = aItem->viewPrivData();
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayer < m_layers.size(), /*void*/ );
|
|
|
|
wxCHECK( IsCached( aLayer ), /*void*/ );
|
2014-02-21 15:57:18 +00:00
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
VIEW_LAYER& l = m_layers.at( aLayer );
|
|
|
|
|
|
|
|
m_gal->SetTarget( l.target );
|
|
|
|
m_gal->SetLayerDepth( l.renderingOrder );
|
|
|
|
|
|
|
|
// Redraw the item from scratch
|
2016-12-02 17:58:12 +00:00
|
|
|
int group = viewData->getGroup( aLayer );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( group >= 0 )
|
|
|
|
m_gal->DeleteGroup( group );
|
2013-10-02 11:57:21 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
group = m_gal->BeginGroup();
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->setGroup( aLayer, group );
|
|
|
|
|
2014-06-05 10:40:26 +00:00
|
|
|
if( !m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ) )
|
2016-12-02 17:58:12 +00:00
|
|
|
aItem->ViewDraw( aLayer, this ); // Alternative drawing method
|
2014-02-24 13:31:55 +00:00
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
m_gal->EndGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
void VIEW::updateBbox( VIEW_ITEM* aItem )
|
|
|
|
{
|
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-04 14:23:26 +00:00
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
|
|
|
|
2014-02-24 13:31:55 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2013-09-04 14:23:26 +00:00
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Remove( aItem );
|
|
|
|
l.items->Insert( aItem );
|
2013-09-13 09:38:16 +00:00
|
|
|
MarkTargetDirty( l.target );
|
2013-09-04 14:23:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
void VIEW::updateLayers( VIEW_ITEM* aItem )
|
|
|
|
{
|
2016-12-02 17:58:12 +00:00
|
|
|
auto viewData = aItem->viewPrivData();
|
2013-09-24 13:48:04 +00:00
|
|
|
int layers[VIEW_MAX_LAYERS], layers_count;
|
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
// Remove the item from previous layer set
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->getLayers( layers, layers_count );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2014-02-24 13:31:55 +00:00
|
|
|
for( int i = 0; i < layers_count; ++i )
|
2013-09-24 13:48:04 +00:00
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Remove( aItem );
|
|
|
|
MarkTargetDirty( l.target );
|
2013-12-09 09:42:38 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( IsCached( l.id ) )
|
|
|
|
{
|
|
|
|
// Redraw the item from scratch
|
2016-12-02 17:58:12 +00:00
|
|
|
int prevGroup = viewData->getGroup( layers[i] );
|
2013-12-09 09:42:38 +00:00
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
if( prevGroup >= 0 )
|
|
|
|
{
|
|
|
|
m_gal->DeleteGroup( prevGroup );
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->setGroup( l.id, -1 );
|
2014-02-21 15:57:18 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-24 13:48:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add the item to new layer set
|
|
|
|
aItem->ViewGetLayers( layers, layers_count );
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->saveLayers( layers, layers_count );
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-24 13:48:04 +00:00
|
|
|
for( int i = 0; i < layers_count; i++ )
|
|
|
|
{
|
|
|
|
VIEW_LAYER& l = m_layers[layers[i]];
|
|
|
|
l.items->Insert( aItem );
|
|
|
|
MarkTargetDirty( l.target );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-05 14:28:58 +00:00
|
|
|
bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
|
2013-07-08 07:28:58 +00:00
|
|
|
{
|
2018-07-05 06:36:31 +00:00
|
|
|
wxCHECK( (unsigned) aLayerId < m_layers.size(), false );
|
2013-08-05 14:28:58 +00:00
|
|
|
|
2016-01-17 17:31:00 +00:00
|
|
|
std::set<int>::const_iterator it, it_end;
|
2013-08-05 14:28:58 +00:00
|
|
|
|
2013-08-07 15:20:01 +00:00
|
|
|
for( it = m_layers.at( aLayerId ).requiredLayers.begin(),
|
2013-10-14 14:13:35 +00:00
|
|
|
it_end = m_layers.at( aLayerId ).requiredLayers.end(); it != it_end; ++it )
|
2013-07-08 07:28:58 +00:00
|
|
|
{
|
2013-08-05 14:28:58 +00:00
|
|
|
// That is enough if just one layer is not enabled
|
2014-03-11 09:58:58 +00:00
|
|
|
if( !m_layers.at( *it ).visible || !areRequiredLayersEnabled( *it ) )
|
2013-07-08 07:28:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
void VIEW::RecacheAllItems()
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
|
|
|
BOX2I r;
|
|
|
|
|
|
|
|
r.SetMaximum();
|
|
|
|
|
2020-08-10 21:52:22 +00:00
|
|
|
for( const VIEW_LAYER& l : m_layers )
|
2013-04-18 15:10:02 +00:00
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
if( IsCached( l.id ) )
|
2013-07-04 15:02:20 +00:00
|
|
|
{
|
2020-08-10 21:52:22 +00:00
|
|
|
recacheItem visitor( this, m_gal, l.id );
|
|
|
|
l.items->Query( r, visitor );
|
2013-07-04 15:02:20 +00:00
|
|
|
}
|
2013-05-10 14:05:40 +00:00
|
|
|
}
|
2013-04-18 15:10:02 +00:00
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
|
|
|
|
|
2014-02-21 15:57:18 +00:00
|
|
|
void VIEW::UpdateItems()
|
2013-08-19 09:02:38 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
if( m_gal->IsVisible() )
|
2014-02-21 15:57:18 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
GAL_UPDATE_CONTEXT ctx( m_gal );
|
2013-08-19 09:02:38 +00:00
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2017-01-16 13:23:22 +00:00
|
|
|
{
|
2018-10-26 21:25:09 +00:00
|
|
|
auto viewData = item->viewPrivData();
|
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( viewData->m_requiredUpdate != NONE )
|
|
|
|
{
|
|
|
|
invalidateItem( item, viewData->m_requiredUpdate );
|
|
|
|
viewData->m_requiredUpdate = NONE;
|
|
|
|
}
|
2017-01-16 13:23:22 +00:00
|
|
|
}
|
2014-02-21 15:57:18 +00:00
|
|
|
}
|
2013-08-19 09:02:38 +00:00
|
|
|
}
|
2014-05-14 11:48:29 +00:00
|
|
|
|
|
|
|
|
2018-02-25 17:38:35 +00:00
|
|
|
void VIEW::UpdateAllItems( int aUpdateFlags )
|
|
|
|
{
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-02-25 17:38:35 +00:00
|
|
|
{
|
|
|
|
auto viewData = item->viewPrivData();
|
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
viewData->m_requiredUpdate |= aUpdateFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-25 20:14:28 +00:00
|
|
|
void VIEW::UpdateAllItemsConditionally( int aUpdateFlags,
|
|
|
|
std::function<bool( VIEW_ITEM* )> aCondition )
|
|
|
|
{
|
2018-07-05 06:35:50 +00:00
|
|
|
for( VIEW_ITEM* item : *m_allItems )
|
2018-02-25 20:14:28 +00:00
|
|
|
{
|
|
|
|
if( aCondition( item ) )
|
|
|
|
{
|
|
|
|
auto viewData = item->viewPrivData();
|
|
|
|
|
|
|
|
if( !viewData )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
viewData->m_requiredUpdate |= aUpdateFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-05 06:35:50 +00:00
|
|
|
std::unique_ptr<VIEW> VIEW::DataReference() const
|
|
|
|
{
|
|
|
|
auto ret = std::make_unique<VIEW>();
|
|
|
|
ret->m_allItems = m_allItems;
|
|
|
|
ret->m_layers = m_layers;
|
|
|
|
ret->sortLayers();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
void VIEW::SetVisible( VIEW_ITEM* aItem, bool aIsVisible )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
auto viewData = aItem->viewPrivData();
|
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
2016-12-02 17:58:12 +00:00
|
|
|
|
|
|
|
bool cur_visible = viewData->m_flags & VISIBLE;
|
|
|
|
|
|
|
|
if( cur_visible != aIsVisible )
|
|
|
|
{
|
|
|
|
if( aIsVisible )
|
|
|
|
viewData->m_flags |= VISIBLE;
|
|
|
|
else
|
|
|
|
viewData->m_flags &= ~VISIBLE;
|
|
|
|
|
|
|
|
Update( aItem, APPEARANCE | COLOR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
|
|
|
void VIEW::Hide( VIEW_ITEM* aItem, bool aHide )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
auto viewData = aItem->viewPrivData();
|
|
|
|
|
2016-12-09 14:48:34 +00:00
|
|
|
if( !viewData )
|
|
|
|
return;
|
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
if( !( viewData->m_flags & VISIBLE ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aHide )
|
|
|
|
viewData->m_flags |= HIDDEN;
|
|
|
|
else
|
|
|
|
viewData->m_flags &= ~HIDDEN;
|
|
|
|
|
|
|
|
Update( aItem, APPEARANCE );
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
|
|
|
bool VIEW::IsVisible( const VIEW_ITEM* aItem ) const
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
const auto viewData = aItem->viewPrivData();
|
|
|
|
|
2019-10-15 13:39:54 +00:00
|
|
|
return viewData && ( viewData->m_flags & VISIBLE );
|
2016-12-02 17:58:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2017-01-17 16:24:09 +00:00
|
|
|
void VIEW::Update( VIEW_ITEM* aItem )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
|
|
|
Update( aItem, ALL );
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
|
|
|
void VIEW::Update( VIEW_ITEM* aItem, int aUpdateFlags )
|
2016-12-02 17:58:12 +00:00
|
|
|
{
|
2020-08-01 13:20:08 +00:00
|
|
|
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
if( !viewData )
|
2016-12-02 17:58:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
assert( aUpdateFlags != NONE );
|
2016-12-05 22:54:41 +00:00
|
|
|
|
2016-12-02 17:58:12 +00:00
|
|
|
viewData->m_requiredUpdate |= aUpdateFlags;
|
|
|
|
}
|
|
|
|
|
2018-08-23 21:54:42 +00:00
|
|
|
|
|
|
|
std::shared_ptr<VIEW_OVERLAY> VIEW::MakeOverlay()
|
|
|
|
{
|
|
|
|
std::shared_ptr<VIEW_OVERLAY> overlay( new VIEW_OVERLAY );
|
|
|
|
|
|
|
|
Add( overlay.get() );
|
|
|
|
return overlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-01 13:20:08 +00:00
|
|
|
void VIEW::ClearPreview()
|
|
|
|
{
|
|
|
|
m_preview->Clear();
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : m_ownedItems )
|
|
|
|
delete item;
|
|
|
|
|
|
|
|
m_ownedItems.clear();
|
|
|
|
Update( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-15 20:13:08 +00:00
|
|
|
void VIEW::InitPreview()
|
|
|
|
{
|
|
|
|
m_preview.reset( new KIGFX::VIEW_GROUP() );
|
|
|
|
Add( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-01 13:20:08 +00:00
|
|
|
void VIEW::AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership )
|
|
|
|
{
|
|
|
|
Hide( aItem, false );
|
|
|
|
m_preview->Add( aItem );
|
|
|
|
|
|
|
|
if( aTakeOwnership )
|
|
|
|
m_ownedItems.push_back( aItem );
|
|
|
|
|
|
|
|
SetVisible( m_preview.get(), true );
|
|
|
|
Hide( m_preview.get(), false );
|
|
|
|
Update( m_preview.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIEW::ShowPreview( bool aShow )
|
|
|
|
{
|
|
|
|
SetVisible( m_preview.get(), aShow );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-30 12:09:56 +00:00
|
|
|
const int VIEW::TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
|
2016-12-02 17:58:12 +00:00
|
|
|
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|