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.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
|
2017-02-13 11:53:58 +00:00
|
|
|
* Copyright (C) 2012-2017 Kicad Developers, see change_log.txt for contributors.
|
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
|
|
|
*
|
|
|
|
* Graphics Abstraction Layer (GAL) - base class
|
|
|
|
*
|
|
|
|
* 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 <wx/log.h>
|
|
|
|
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
#include <gal/definitions.h>
|
|
|
|
|
2016-05-28 16:46:29 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
using namespace KIGFX;
|
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-06-05 10:40:26 +00:00
|
|
|
|
2017-02-13 11:43:28 +00:00
|
|
|
GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) :
|
|
|
|
options( aDisplayOptions ),
|
2013-10-14 14:13:35 +00:00
|
|
|
strokeFont( 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
|
|
|
{
|
|
|
|
// Set the default values for the internal variables
|
|
|
|
SetIsFill( false );
|
|
|
|
SetIsStroke( true );
|
|
|
|
SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
|
|
|
|
SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
2014-02-13 19:23:28 +00:00
|
|
|
SetLookAtPoint( VECTOR2D( 0, 0 ) );
|
2013-07-30 15:09:06 +00:00
|
|
|
SetZoomFactor( 1.0 );
|
2018-08-03 08:22:34 +00:00
|
|
|
SetRotation( 0.0 );
|
2018-10-21 22:16:15 +00:00
|
|
|
SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
|
|
|
|
// wxDC::GetPPI() reports 96 DPI, but somehow this value
|
|
|
|
// is the closest match to the legacy renderer
|
|
|
|
SetScreenDPI( 91 );
|
2013-09-11 09:34:10 +00:00
|
|
|
SetDepthRange( VECTOR2D( GAL::MIN_DEPTH, GAL::MAX_DEPTH ) );
|
2015-03-21 09:06:04 +00:00
|
|
|
SetLayerDepth( 0.0 );
|
2013-08-27 16:08:32 +00:00
|
|
|
SetFlip( false, false );
|
2018-09-28 10:46:20 +00:00
|
|
|
SetLineWidth( 1.0f );
|
2016-05-02 13:56:12 +00:00
|
|
|
computeWorldScale();
|
2017-03-30 07:52:40 +00:00
|
|
|
SetAxesEnabled( false );
|
2013-07-30 15:09:06 +00:00
|
|
|
|
|
|
|
// Set grid defaults
|
|
|
|
SetGridVisibility( true );
|
|
|
|
SetCoarseGrid( 10 );
|
2018-09-28 10:46:20 +00:00
|
|
|
gridLineWidth = 0.5f;
|
2017-02-16 02:50:34 +00:00
|
|
|
gridStyle = GRID_STYLE::LINES;
|
2017-02-13 03:47:50 +00:00
|
|
|
gridMinSpacing = 10;
|
2013-07-30 15:09:06 +00:00
|
|
|
|
|
|
|
// Initialize the cursor shape
|
|
|
|
SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
|
2017-03-19 20:51:59 +00:00
|
|
|
fullscreenCursor = false;
|
2017-03-18 20:03:24 +00:00
|
|
|
forceDisplayCursor = false;
|
2017-03-19 20:51:59 +00:00
|
|
|
SetCursorEnabled( false );
|
2013-07-04 09:37:43 +00:00
|
|
|
|
2017-03-30 07:44:38 +00:00
|
|
|
// Initialize text properties
|
|
|
|
ResetTextAttributes();
|
|
|
|
|
2013-07-04 09:37:43 +00:00
|
|
|
strokeFont.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize );
|
2017-02-13 11:43:28 +00:00
|
|
|
|
|
|
|
// subscribe for settings updates
|
|
|
|
observerLink = options.Subscribe( 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GAL::~GAL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
|
2017-02-13 11:43:28 +00:00
|
|
|
void GAL::OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions )
|
|
|
|
{
|
|
|
|
// defer to the child class first
|
|
|
|
updatedGalDisplayOptions( aOptions );
|
|
|
|
|
|
|
|
// there is no refresh to do at this level
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
|
|
|
|
{
|
|
|
|
bool refresh = false;
|
|
|
|
|
2017-02-13 11:53:58 +00:00
|
|
|
if( options.m_gridStyle != gridStyle )
|
|
|
|
{
|
|
|
|
gridStyle = options.m_gridStyle ;
|
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-02-14 15:31:21 +00:00
|
|
|
if( options.m_gridLineWidth != gridLineWidth )
|
|
|
|
{
|
|
|
|
gridLineWidth = options.m_gridLineWidth ;
|
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-02-13 03:47:50 +00:00
|
|
|
if( options.m_gridMinSpacing != gridMinSpacing )
|
|
|
|
{
|
|
|
|
gridMinSpacing = options.m_gridMinSpacing;
|
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-03-08 08:37:12 +00:00
|
|
|
if( options.m_axesEnabled != axesEnabled )
|
|
|
|
{
|
|
|
|
axesEnabled = options.m_axesEnabled;
|
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-03-18 20:03:24 +00:00
|
|
|
if( options.m_forceDisplayCursor != forceDisplayCursor )
|
|
|
|
{
|
|
|
|
forceDisplayCursor = options.m_forceDisplayCursor;
|
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-03-19 20:51:59 +00:00
|
|
|
if( options.m_fullscreenCursor != fullscreenCursor )
|
|
|
|
{
|
|
|
|
fullscreenCursor = options.m_fullscreenCursor;
|
|
|
|
refresh = true;
|
|
|
|
}
|
|
|
|
|
2017-02-13 11:43:28 +00:00
|
|
|
// tell the derived class if the base class needs an update or not
|
|
|
|
return refresh;
|
|
|
|
}
|
|
|
|
|
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-27 16:08:32 +00:00
|
|
|
void GAL::SetTextAttributes( const EDA_TEXT* aText )
|
|
|
|
{
|
2017-01-23 20:30:11 +00:00
|
|
|
SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
|
2016-05-02 13:56:12 +00:00
|
|
|
SetHorizontalJustify( aText->GetHorizJustify() );
|
|
|
|
SetVerticalJustify( aText->GetVertJustify() );
|
|
|
|
SetFontBold( aText->IsBold() );
|
|
|
|
SetFontItalic( aText->IsItalic() );
|
|
|
|
SetTextMirrored( aText->IsMirrored() );
|
2013-08-27 16:08:32 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 20:30:11 +00:00
|
|
|
|
2017-03-30 07:44:38 +00:00
|
|
|
void GAL::ResetTextAttributes()
|
|
|
|
{
|
|
|
|
// Tiny but non-zero - this will always need setting
|
|
|
|
// there is no built-in default
|
|
|
|
SetGlyphSize( { 1.0, 1.0 } );
|
|
|
|
|
|
|
|
SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
|
|
|
|
SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
|
|
|
|
|
|
|
|
SetFontBold( false );
|
|
|
|
SetFontItalic( false );
|
|
|
|
SetTextMirrored( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 07:41:47 +00:00
|
|
|
VECTOR2D GAL::GetTextLineSize( const UTF8& aText ) const
|
|
|
|
{
|
|
|
|
// Compute the X and Y size of a given text.
|
|
|
|
// Because computeTextLineSize expects a one line text,
|
|
|
|
// aText is expected to be only one line text.
|
|
|
|
return strokeFont.computeTextLineSize( aText );
|
|
|
|
}
|
|
|
|
|
2013-08-27 16:08:32 +00:00
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
void GAL::ComputeWorldScreenMatrix()
|
|
|
|
{
|
2016-05-02 13:56:12 +00:00
|
|
|
computeWorldScale();
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
MATRIX3x3D translation;
|
|
|
|
translation.SetIdentity();
|
2014-03-20 07:47:31 +00:00
|
|
|
translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
2018-08-03 08:22:34 +00:00
|
|
|
MATRIX3x3D rotate;
|
|
|
|
rotate.SetIdentity();
|
|
|
|
rotate.SetRotation( rotation );
|
|
|
|
|
2013-07-30 16:29:54 +00:00
|
|
|
MATRIX3x3D scale;
|
|
|
|
scale.SetIdentity();
|
|
|
|
scale.SetScale( VECTOR2D( worldScale, worldScale ) );
|
|
|
|
|
|
|
|
MATRIX3x3D flip;
|
|
|
|
flip.SetIdentity();
|
2016-12-02 17:59:48 +00:00
|
|
|
flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
|
2013-07-30 16:29:54 +00:00
|
|
|
|
|
|
|
MATRIX3x3D lookat;
|
|
|
|
lookat.SetIdentity();
|
|
|
|
lookat.SetTranslation( -lookAtPoint );
|
|
|
|
|
2018-08-03 08:22:34 +00:00
|
|
|
worldScreenMatrix = translation * rotate * flip * scale * lookat;
|
2013-08-27 16:08:32 +00:00
|
|
|
screenWorldMatrix = worldScreenMatrix.Inverse();
|
2013-07-30 16:29:54 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2017-02-13 03:47:50 +00:00
|
|
|
double GAL::computeMinGridSpacing() const
|
|
|
|
{
|
|
|
|
// just return the current value. This could be cleverer and take
|
|
|
|
// into account other settings in future
|
|
|
|
return gridMinSpacing;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 GAL::DrawGrid()
|
|
|
|
{
|
2013-07-23 16:39:07 +00:00
|
|
|
SetTarget( TARGET_NONCACHED );
|
|
|
|
|
2013-07-31 08:28:23 +00:00
|
|
|
// Draw the grid
|
2013-07-30 15:09:06 +00:00
|
|
|
// For the drawing the start points, end points and increments have
|
|
|
|
// to be calculated in world coordinates
|
2014-06-04 15:56:44 +00:00
|
|
|
VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
|
|
|
|
VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
|
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-13 03:47:50 +00:00
|
|
|
const double gridThreshold = computeMinGridSpacing();
|
|
|
|
|
2015-07-17 08:26:48 +00:00
|
|
|
int gridScreenSizeDense = KiROUND( gridSize.x * worldScale );
|
|
|
|
int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) * worldScale );
|
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-31 08:28:23 +00:00
|
|
|
// Compute the line marker or point radius of the grid
|
2017-02-14 15:31:21 +00:00
|
|
|
// Note: generic grids can't handle sub-pixel lines without
|
|
|
|
// either losing fine/course distinction or having some dots
|
|
|
|
// fail to render
|
2018-09-28 10:46:20 +00:00
|
|
|
float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale;
|
|
|
|
float doubleMarker = 2.0f * marker;
|
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-03-08 09:35:51 +00:00
|
|
|
// Draw axes if desired
|
|
|
|
if( axesEnabled )
|
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-03-08 09:35:51 +00:00
|
|
|
SetIsFill( false );
|
|
|
|
SetIsStroke( true );
|
|
|
|
SetStrokeColor( axesColor );
|
|
|
|
SetLineWidth( marker );
|
2013-07-30 15:09:06 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
drawGridLine( VECTOR2D( worldStartPoint.x, 0 ),
|
|
|
|
VECTOR2D( worldEndPoint.x, 0 ) );
|
2016-12-08 21:55:06 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
drawGridLine( VECTOR2D( 0, worldStartPoint.y ),
|
|
|
|
VECTOR2D( 0, worldEndPoint.y ) );
|
|
|
|
}
|
2013-07-30 15:09:06 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( !gridVisibility )
|
|
|
|
return;
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Check if the grid would not be too dense
|
|
|
|
if( std::max( gridScreenSizeDense, gridScreenSizeCoarse ) <= gridThreshold )
|
|
|
|
return;
|
|
|
|
|
2017-07-14 18:18:37 +00:00
|
|
|
// Compute grid staring and ending indexes to draw grid points on the
|
|
|
|
// visible screen area
|
|
|
|
// Note: later any point coordinate will be offsetted by gridOrigin
|
2017-12-20 08:27:40 +00:00
|
|
|
int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridSize.x );
|
|
|
|
int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridSize.x );
|
|
|
|
int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridSize.y );
|
|
|
|
int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridSize.y );
|
2017-03-08 09:35:51 +00:00
|
|
|
|
2017-07-14 18:18:37 +00:00
|
|
|
// Ensure start coordinate > end coordinate
|
|
|
|
if( gridStartX > gridEndX )
|
|
|
|
std::swap( gridStartX, gridEndX );
|
2017-03-08 09:35:51 +00:00
|
|
|
|
2017-07-14 18:18:37 +00:00
|
|
|
if( gridStartY > gridEndY )
|
|
|
|
std::swap( gridStartY, gridEndY );
|
2017-03-08 09:35:51 +00:00
|
|
|
|
2017-12-20 08:27:40 +00:00
|
|
|
// Ensure the grid fills the screen
|
|
|
|
--gridStartX; ++gridEndX;
|
|
|
|
--gridStartY; ++gridEndY;
|
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Draw the grid behind all other layers
|
|
|
|
SetLayerDepth( depthRange.y * 0.75 );
|
2016-12-07 09:20:31 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( gridStyle == GRID_STYLE::LINES )
|
|
|
|
{
|
|
|
|
SetIsFill( false );
|
|
|
|
SetIsStroke( true );
|
|
|
|
SetStrokeColor( gridColor );
|
2013-07-30 15:09:06 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Now draw the grid, every coarse grid line gets the double width
|
|
|
|
|
|
|
|
// Vertical lines
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
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-03-08 09:35:51 +00:00
|
|
|
const double y = j * gridSize.y + gridOrigin.y;
|
2013-07-31 08:28:23 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( axesEnabled && y == 0 )
|
|
|
|
continue;
|
2014-06-04 15:56:44 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
|
|
|
SetLineWidth( doubleMarker );
|
|
|
|
else
|
|
|
|
SetLineWidth( marker );
|
2013-07-31 08:28:23 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
|
|
|
|| gridScreenSizeDense > gridThreshold )
|
|
|
|
{
|
2017-03-21 12:09:24 +00:00
|
|
|
drawGridLine( VECTOR2D( gridStartX * gridSize.x + gridOrigin.x, y ),
|
|
|
|
VECTOR2D( gridEndX * gridSize.x + gridOrigin.x, y ) );
|
2013-07-30 15:09:06 +00:00
|
|
|
}
|
2017-03-08 09:35:51 +00:00
|
|
|
}
|
2013-07-30 15:09:06 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Horizontal lines
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
2017-03-08 09:35:51 +00:00
|
|
|
{
|
|
|
|
const double x = i * gridSize.x + gridOrigin.x;
|
2013-07-31 08:28:23 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( axesEnabled && x == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
|
|
|
SetLineWidth( doubleMarker );
|
|
|
|
else
|
|
|
|
SetLineWidth( marker );
|
|
|
|
|
|
|
|
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
|
|
|
|| gridScreenSizeDense > gridThreshold )
|
|
|
|
{
|
2017-03-21 12:09:24 +00:00
|
|
|
drawGridLine( VECTOR2D( x, gridStartY * gridSize.y + gridOrigin.y ),
|
|
|
|
VECTOR2D( x, gridEndY * gridSize.y + gridOrigin.y ) );
|
2013-07-30 15:09:06 +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
|
|
|
}
|
2017-03-08 09:35:51 +00:00
|
|
|
}
|
|
|
|
else if( gridStyle == GRID_STYLE::SMALL_CROSS )
|
|
|
|
{
|
|
|
|
SetIsFill( false );
|
|
|
|
SetIsStroke( true );
|
|
|
|
SetStrokeColor( gridColor );
|
2017-03-01 09:29:19 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
SetLineWidth( marker );
|
|
|
|
double lineLen = GetLineWidth() * 2;
|
2017-03-01 09:29:19 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Vertical positions:
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
2017-03-08 09:35:51 +00:00
|
|
|
{
|
|
|
|
if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
|
|
|
|| gridScreenSizeDense > gridThreshold )
|
2017-03-01 09:29:19 +00:00
|
|
|
{
|
2017-03-08 09:35:51 +00:00
|
|
|
int posY = j * gridSize.y + gridOrigin.y;
|
2017-03-01 09:29:19 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
// Horizontal positions:
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
2017-03-08 09:35:51 +00:00
|
|
|
{
|
|
|
|
if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
|
|
|
|
|| gridScreenSizeDense > gridThreshold )
|
2017-03-01 09:29:19 +00:00
|
|
|
{
|
2017-03-08 09:35:51 +00:00
|
|
|
int posX = i * gridSize.x + gridOrigin.x;
|
2017-03-01 09:29:19 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
drawGridLine( VECTOR2D( posX - lineLen, posY ),
|
|
|
|
VECTOR2D( posX + lineLen, posY ) );
|
2017-03-01 09:29:19 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
drawGridLine( VECTOR2D( posX, posY - lineLen ),
|
|
|
|
VECTOR2D( posX, posY + lineLen ) );
|
2017-03-01 09:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-08 09:35:51 +00:00
|
|
|
}
|
|
|
|
else // Dotted grid
|
|
|
|
{
|
|
|
|
bool tickX, tickY;
|
|
|
|
SetIsFill( true );
|
|
|
|
SetIsStroke( false );
|
|
|
|
SetFillColor( gridColor );
|
|
|
|
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int j = gridStartY; j <= gridEndY; j++ )
|
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-03-08 09:35:51 +00:00
|
|
|
if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
|
|
|
tickY = true;
|
|
|
|
else
|
|
|
|
tickY = false;
|
2013-07-30 15:09:06 +00:00
|
|
|
|
2017-12-20 08:27:40 +00:00
|
|
|
for( int i = gridStartX; i <= gridEndX; i++ )
|
2013-07-30 15:09:06 +00:00
|
|
|
{
|
2017-03-08 09:35:51 +00:00
|
|
|
if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
|
|
|
|
tickX = true;
|
2013-07-31 08:28:23 +00:00
|
|
|
else
|
2017-03-08 09:35:51 +00:00
|
|
|
tickX = false;
|
2013-07-31 08:28:23 +00:00
|
|
|
|
2017-03-08 09:35:51 +00:00
|
|
|
if( tickX || tickY || gridScreenSizeDense > gridThreshold )
|
2013-07-31 08:28:23 +00:00
|
|
|
{
|
2017-03-08 09:35:51 +00:00
|
|
|
double radius = ( ( tickX && tickY ) ? doubleMarker : marker ) / 2.0;
|
|
|
|
DrawRectangle( VECTOR2D( i * gridSize.x - radius + gridOrigin.x,
|
|
|
|
j * gridSize.y - radius + gridOrigin.y ),
|
|
|
|
VECTOR2D( i * gridSize.x + radius + gridOrigin.x,
|
|
|
|
j * gridSize.y + radius + gridOrigin.y ) );
|
2013-07-31 08:28:23 +00:00
|
|
|
}
|
2013-07-30 15:09:06 +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-28 14:25:42 +00:00
|
|
|
|
|
|
|
|
2014-02-06 11:38:06 +00:00
|
|
|
VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const
|
2013-08-28 14:25:42 +00:00
|
|
|
{
|
2017-11-07 08:45:03 +00:00
|
|
|
#if 0
|
|
|
|
// This old code expects a non zero grid size, which can be wrong here.
|
2015-07-17 08:26:48 +00:00
|
|
|
return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
|
|
|
|
KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
|
2017-11-07 08:45:03 +00:00
|
|
|
#else
|
|
|
|
// if grid size == 0.0 there is no grid, so use aPoint as grid reference position
|
|
|
|
double cx = gridSize.x > 0.0 ? KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x
|
|
|
|
: aPoint.x;
|
|
|
|
double cy = gridSize.y > 0.0 ? KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y
|
|
|
|
: aPoint.y;
|
|
|
|
|
|
|
|
return VECTOR2D( cx, cy );
|
|
|
|
#endif
|
2013-08-28 14:25:42 +00:00
|
|
|
}
|
2015-03-30 12:09:56 +00:00
|
|
|
|
2015-03-30 20:14:37 +00:00
|
|
|
const int GAL::MIN_DEPTH = -1024;
|
|
|
|
const int GAL::MAX_DEPTH = 1023;
|
2015-03-30 12:09:56 +00:00
|
|
|
const int GAL::GRID_DEPTH = MAX_DEPTH - 1;
|
2017-03-18 22:00:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
COLOR4D GAL::getCursorColor() const
|
|
|
|
{
|
|
|
|
auto color = cursorColor;
|
|
|
|
|
|
|
|
// dim the cursor if it's only on because it was forced
|
|
|
|
// (this helps to provide a hint for active tools)
|
|
|
|
if( !isCursorEnabled )
|
|
|
|
{
|
|
|
|
color.a = color.a * 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|