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
|
2015-05-18 11:48:10 +00:00
|
|
|
* Copyright (C) 2013-2015 CERN
|
2016-02-24 19:53:02 +00:00
|
|
|
* Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.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
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2015-05-18 11:48:10 +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 <view/view.h>
|
|
|
|
#include <view/wx_view_controls.h>
|
2013-08-28 14:25:42 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2013-09-13 08:26:08 +00:00
|
|
|
#include <tool/tool_dispatcher.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
|
|
|
|
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
|
|
|
|
2013-09-24 14:12:02 +00:00
|
|
|
const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType();
|
|
|
|
|
2015-05-18 11:48:10 +00:00
|
|
|
WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel ) :
|
|
|
|
VIEW_CONTROLS( aView ), m_state( IDLE ), m_parentPanel( aParentPanel ), m_scrollScale( 1.0, 1.0 )
|
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-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MOTION,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), NULL, this );
|
2016-01-25 00:18:29 +00:00
|
|
|
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
2015-05-21 20:54:29 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MAGNIFY,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onMagnify ), NULL, this );
|
|
|
|
#endif
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_MOUSEWHEEL,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onWheel ), NULL, this );
|
|
|
|
m_parentPanel->Connect( wxEVT_MIDDLE_UP,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
|
|
|
m_parentPanel->Connect( wxEVT_MIDDLE_DOWN,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
|
|
|
m_parentPanel->Connect( wxEVT_LEFT_UP,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
|
|
|
m_parentPanel->Connect( wxEVT_LEFT_DOWN,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), NULL, this );
|
2013-04-22 09:08:02 +00:00
|
|
|
#if defined _WIN32 || defined _WIN64
|
2013-10-14 18:40:36 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), NULL, this );
|
2013-04-22 09:08:02 +00:00
|
|
|
#endif
|
2015-03-10 12:20:38 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_LEAVE_WINDOW,
|
|
|
|
wxMouseEventHandler( WX_VIEW_CONTROLS::onLeave ), NULL, this );
|
2015-05-18 11:48:10 +00:00
|
|
|
m_parentPanel->Connect( wxEVT_SCROLLWIN_THUMBTRACK,
|
|
|
|
wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), NULL, this );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
m_panTimer.SetOwner( this );
|
2013-10-14 18:40:36 +00:00
|
|
|
this->Connect( wxEVT_TIMER,
|
|
|
|
wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), NULL, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
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 14:26:42 +00:00
|
|
|
bool isAutoPanning = false;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2017-02-11 19:54:44 +00:00
|
|
|
if( m_settings.m_autoPanEnabled )
|
2013-09-02 14:26:42 +00:00
|
|
|
isAutoPanning = handleAutoPanning( aEvent );
|
|
|
|
|
|
|
|
if( !isAutoPanning && aEvent.Dragging() )
|
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-22 16:42:53 +00:00
|
|
|
if( m_state == DRAG_PANNING )
|
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
VECTOR2D d = m_dragStartPoint - VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
|
|
|
VECTOR2D delta = m_view->ToWorld( d, false );
|
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-05-18 11:48:13 +00:00
|
|
|
m_view->SetCenter( m_lookStartPoint + delta );
|
2013-08-22 16:42:53 +00:00
|
|
|
aEvent.StopPropagation();
|
|
|
|
}
|
|
|
|
}
|
2015-07-03 18:58:12 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
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-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
|
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
|
|
|
{
|
|
|
|
const double wheelPanSpeed = 0.001;
|
|
|
|
|
2017-01-17 15:36:31 +00:00
|
|
|
// mousewheelpan disabled:
|
|
|
|
// wheel + ctrl -> horizontal scrolling;
|
|
|
|
// wheel + shift -> vertical scrolling;
|
|
|
|
// wheel -> zooming;
|
|
|
|
// mousewheelpan enabled:
|
|
|
|
// wheel -> pan;
|
|
|
|
// wheel + ctrl -> zooming;
|
|
|
|
// wheel + shift -> horizontal scrolling.
|
|
|
|
|
2017-02-11 19:54:44 +00:00
|
|
|
if( ( !m_settings.m_enableMousewheelPan && ( aEvent.ControlDown() || aEvent.ShiftDown() ) ) ||
|
|
|
|
( m_settings.m_enableMousewheelPan && !aEvent.ControlDown() ) )
|
2013-04-23 10:07:14 +00:00
|
|
|
{
|
|
|
|
// Scrolling
|
2014-05-31 09:48:27 +00:00
|
|
|
VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
|
|
|
|
( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
|
2016-02-24 19:53:02 +00:00
|
|
|
int axis = aEvent.GetWheelAxis();
|
|
|
|
double scrollX = 0.0;
|
|
|
|
double scrollY = 0.0;
|
2013-04-23 10:07:14 +00:00
|
|
|
|
2017-02-11 19:54:44 +00:00
|
|
|
if( m_settings.m_enableMousewheelPan )
|
2016-02-24 19:53:02 +00:00
|
|
|
{
|
2017-01-17 15:36:31 +00:00
|
|
|
if ( axis == wxMOUSE_WHEEL_HORIZONTAL || aEvent.ShiftDown() )
|
2016-02-24 19:53:02 +00:00
|
|
|
scrollX = scrollVec.x;
|
|
|
|
else
|
|
|
|
scrollY = -scrollVec.y;
|
|
|
|
}
|
2013-04-23 10:07:14 +00:00
|
|
|
else
|
2016-02-24 19:53:02 +00:00
|
|
|
{
|
2017-02-06 23:05:07 +00:00
|
|
|
if( aEvent.ControlDown() )
|
2016-02-24 19:53:02 +00:00
|
|
|
scrollX = -scrollVec.x;
|
|
|
|
else
|
|
|
|
scrollY = -scrollVec.y;
|
|
|
|
}
|
2013-04-23 10:07:14 +00:00
|
|
|
|
2016-02-24 19:53:02 +00:00
|
|
|
VECTOR2D delta( scrollX, scrollY );
|
2013-04-23 10:07:14 +00:00
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
m_view->SetCenter( m_view->GetCenter() + delta );
|
2013-04-23 10:07:14 +00:00
|
|
|
}
|
|
|
|
else
|
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-23 10:07:14 +00:00
|
|
|
// Zooming
|
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
|
|
|
wxLongLong timeStamp = wxGetLocalTimeMillis();
|
|
|
|
double timeDiff = timeStamp.ToDouble() - m_timeStamp.ToDouble();
|
2015-05-18 11:48:12 +00:00
|
|
|
int rotation = aEvent.GetWheelRotation();
|
|
|
|
double zoomScale;
|
|
|
|
|
2016-02-24 19:53:02 +00:00
|
|
|
#ifdef __WXMAC__
|
2015-05-18 11:48:12 +00:00
|
|
|
// The following is to support Apple pointer devices (MagicMouse &
|
|
|
|
// Macbook touchpad), which send events more frequently, but with smaller
|
|
|
|
// wheel rotation.
|
|
|
|
//
|
|
|
|
// It should not break other platforms, but I prefer to be safe than
|
|
|
|
// sorry. If you find a device that behaves in the same way on another
|
|
|
|
// platform, feel free to remove #ifdef directives.
|
|
|
|
if( timeDiff > 0 && timeDiff < 100 && std::abs( rotation ) < 20 )
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
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_timeStamp = timeStamp;
|
|
|
|
|
|
|
|
// Set scaling speed depending on scroll wheel event interval
|
|
|
|
if( timeDiff < 500 && timeDiff > 0 )
|
|
|
|
{
|
2015-05-18 11:48:12 +00:00
|
|
|
zoomScale = 2.05 - timeDiff / 500;
|
|
|
|
|
|
|
|
if( rotation < 0 )
|
|
|
|
zoomScale = 1.0 / zoomScale;
|
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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-01 12:00:42 +00:00
|
|
|
zoomScale = ( rotation > 0 ) ? 1.05 : 1/1.05;
|
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-15 15:32:30 +00:00
|
|
|
if( IsCursorWarpingEnabled() )
|
2015-07-09 08:18:27 +00:00
|
|
|
{
|
2015-07-24 07:42:45 +00:00
|
|
|
CenterOnCursor();
|
2015-07-09 08:18:27 +00:00
|
|
|
m_view->SetScale( m_view->GetScale() * zoomScale );
|
|
|
|
}
|
2015-07-15 15:32:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
|
|
|
|
m_view->SetScale( m_view->GetScale() * zoomScale, anchor );
|
|
|
|
}
|
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-22 09:08:02 +00:00
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
aEvent.Skip();
|
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-01-25 00:18:29 +00:00
|
|
|
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
2015-05-21 20:54:29 +00:00
|
|
|
void WX_VIEW_CONTROLS::onMagnify( wxMouseEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Scale based on the magnification from our underlying magnification event.
|
|
|
|
VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
|
2015-05-22 07:37:57 +00:00
|
|
|
m_view->SetScale( m_view->GetScale() * ( aEvent.GetMagnification() + 1.0f ), anchor );
|
2015-05-21 20:54:29 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent )
|
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-22 16:42:53 +00:00
|
|
|
switch( m_state )
|
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-22 16:42:53 +00:00
|
|
|
case IDLE:
|
|
|
|
case AUTO_PANNING:
|
|
|
|
if( aEvent.MiddleDown() )
|
|
|
|
{
|
|
|
|
m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
|
|
|
|
m_lookStartPoint = m_view->GetCenter();
|
|
|
|
m_state = DRAG_PANNING;
|
|
|
|
}
|
2013-09-09 11:57:56 +00:00
|
|
|
|
|
|
|
if( aEvent.LeftUp() )
|
|
|
|
m_state = IDLE; // Stop autopanning when user release left mouse button
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAG_PANNING:
|
|
|
|
if( aEvent.MiddleUp() )
|
|
|
|
m_state = IDLE;
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
break;
|
2013-09-02 14:26:42 +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-21 15:37:27 +00:00
|
|
|
aEvent.Skip();
|
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-22 09:08:02 +00:00
|
|
|
|
|
|
|
|
2013-08-21 15:37:27 +00:00
|
|
|
void WX_VIEW_CONTROLS::onEnter( wxMouseEvent& aEvent )
|
2013-04-22 09:08:02 +00:00
|
|
|
{
|
|
|
|
m_parentPanel->SetFocus();
|
|
|
|
}
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
|
2015-03-10 12:20:38 +00:00
|
|
|
void WX_VIEW_CONTROLS::onLeave( wxMouseEvent& aEvent )
|
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
if( m_settings.m_cursorCaptured )
|
2015-03-10 12:20:38 +00:00
|
|
|
{
|
|
|
|
bool warp = false;
|
|
|
|
int x = aEvent.GetX();
|
|
|
|
int y = aEvent.GetY();
|
|
|
|
wxSize parentSize = m_parentPanel->GetClientSize();
|
|
|
|
|
|
|
|
if( x < 0 )
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
else if( x >= parentSize.x )
|
|
|
|
{
|
|
|
|
x = parentSize.x - 1;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( y < 0 )
|
|
|
|
{
|
|
|
|
y = 0;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
else if( y >= parentSize.y )
|
|
|
|
{
|
|
|
|
y = parentSize.y - 1;
|
|
|
|
warp = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( warp )
|
|
|
|
m_parentPanel->WarpPointer( x, y );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
|
|
|
switch( m_state )
|
|
|
|
{
|
|
|
|
case AUTO_PANNING:
|
|
|
|
{
|
2017-03-20 10:45:34 +00:00
|
|
|
if ( !m_settings.m_autoPanEnabled )
|
|
|
|
{
|
|
|
|
m_state = IDLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-14 07:42:16 +00:00
|
|
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
|
|
|
if( !m_parentPanel->HasFocus() )
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2017-02-11 19:54:44 +00:00
|
|
|
double borderSize = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
|
|
|
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
VECTOR2D dir( m_panDirection );
|
|
|
|
|
|
|
|
if( dir.EuclideanNorm() > borderSize )
|
|
|
|
dir = dir.Resize( borderSize );
|
|
|
|
|
|
|
|
dir = m_view->ToWorld( dir, false );
|
2017-02-11 19:54:44 +00:00
|
|
|
m_view->SetCenter( m_view->GetCenter() + dir * m_settings.m_autoPanSpeed );
|
2013-08-22 16:42:53 +00:00
|
|
|
|
2013-09-13 08:26:08 +00:00
|
|
|
// Notify tools that the cursor position has changed in the world coordinates
|
2014-02-04 12:38:18 +00:00
|
|
|
wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
|
|
|
|
|
|
|
|
// Set the modifiers state
|
|
|
|
#if wxCHECK_VERSION( 3, 0, 0 )
|
|
|
|
moveEvent.SetControlDown( wxGetKeyState( WXK_CONTROL ) );
|
|
|
|
moveEvent.SetShiftDown( wxGetKeyState( WXK_SHIFT ) );
|
2014-08-01 09:28:08 +00:00
|
|
|
moveEvent.SetAltDown( wxGetKeyState( WXK_ALT ) );
|
2014-02-04 12:38:18 +00:00
|
|
|
#else
|
|
|
|
// wx <3.0 do not have accessors, but the fields are exposed
|
|
|
|
moveEvent.m_controlDown = wxGetKeyState( WXK_CONTROL );
|
|
|
|
moveEvent.m_shiftDown = wxGetKeyState( WXK_SHIFT );
|
|
|
|
moveEvent.m_altDown = wxGetKeyState( WXK_ALT );
|
|
|
|
#endif
|
|
|
|
|
2013-09-13 08:26:08 +00:00
|
|
|
wxPostEvent( m_parentPanel, moveEvent );
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-02 14:26:42 +00:00
|
|
|
|
2013-10-14 14:13:35 +00:00
|
|
|
case IDLE: // Just remove unnecessary warnings
|
2013-09-02 14:26:42 +00:00
|
|
|
case DRAG_PANNING:
|
|
|
|
break;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-18 11:48:10 +00:00
|
|
|
void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent )
|
|
|
|
{
|
|
|
|
VECTOR2D center = m_view->GetCenter();
|
2015-05-18 11:48:13 +00:00
|
|
|
const BOX2I& boundary = m_view->GetBoundary();
|
2015-05-18 11:48:10 +00:00
|
|
|
|
|
|
|
if( aEvent.GetOrientation() == wxHORIZONTAL )
|
2017-02-06 23:05:07 +00:00
|
|
|
center.x = boundary.GetLeft() + aEvent.GetPosition() / m_scrollScale.x;
|
2015-05-18 11:48:10 +00:00
|
|
|
else if( aEvent.GetOrientation() == wxVERTICAL )
|
2017-02-06 23:05:07 +00:00
|
|
|
center.y = boundary.GetTop() + aEvent.GetPosition() / m_scrollScale.y;
|
2015-05-18 11:48:10 +00:00
|
|
|
|
2015-05-18 11:48:13 +00:00
|
|
|
m_view->SetCenter( center );
|
2015-05-18 11:48:10 +00:00
|
|
|
m_parentPanel->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-22 16:42:53 +00:00
|
|
|
void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
if( aEnabled && !m_settings.m_grabMouse )
|
2013-08-22 16:42:53 +00:00
|
|
|
m_parentPanel->CaptureMouse();
|
2017-02-11 19:54:44 +00:00
|
|
|
else if( !aEnabled && m_settings.m_grabMouse )
|
2013-08-22 16:42:53 +00:00
|
|
|
m_parentPanel->ReleaseMouse();
|
2015-07-24 08:58:47 +00:00
|
|
|
|
|
|
|
VIEW_CONTROLS::SetGrabMouse( aEnabled );
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-12 13:27:10 +00:00
|
|
|
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
2013-09-16 14:46:02 +00:00
|
|
|
{
|
|
|
|
wxPoint msp = wxGetMousePosition();
|
|
|
|
wxPoint winp = m_parentPanel->GetScreenPosition();
|
2017-06-12 13:27:10 +00:00
|
|
|
VECTOR2D screenPos( msp.x - winp.x, msp.y - winp.y );
|
2013-09-16 14:46:02 +00:00
|
|
|
|
2017-06-12 13:27:10 +00:00
|
|
|
return aWorldCoordinates ? m_view->ToWorld( screenPos ) : screenPos;
|
2013-09-16 14:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-13 19:23:28 +00:00
|
|
|
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
|
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
if( m_settings.m_forceCursorPosition )
|
2015-07-15 15:32:30 +00:00
|
|
|
{
|
2017-02-11 19:54:44 +00:00
|
|
|
return m_settings.m_forcedPosition;
|
2015-07-15 15:32:30 +00:00
|
|
|
}
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
VECTOR2D mousePosition = GetMousePosition();
|
|
|
|
|
2017-02-11 19:54:44 +00:00
|
|
|
if( m_settings.m_snappingEnabled )
|
2017-06-12 13:27:10 +00:00
|
|
|
return m_view->GetGAL()->GetGridPoint( mousePosition );
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
2017-06-12 13:27:10 +00:00
|
|
|
return mousePosition;
|
2014-02-13 19:23:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-15 15:32:30 +00:00
|
|
|
void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates,
|
|
|
|
bool aWarpView ) const
|
|
|
|
{
|
|
|
|
if( aWorldCoordinates )
|
|
|
|
{
|
|
|
|
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
|
|
|
|
BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
|
|
|
|
VECTOR2D screenPos = m_view->ToScreen( aPosition );
|
|
|
|
|
|
|
|
if( !screen.Contains( screenPos ) )
|
|
|
|
{
|
|
|
|
if( aWarpView )
|
|
|
|
{
|
|
|
|
m_view->SetCenter( aPosition );
|
|
|
|
m_parentPanel->WarpPointer( screenSize.x / 2, screenSize.y / 2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_parentPanel->WarpPointer( screenPos.x, screenPos.y );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_parentPanel->WarpPointer( aPosition.x, aPosition.y );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-24 07:42:45 +00:00
|
|
|
void WX_VIEW_CONTROLS::CenterOnCursor() const
|
|
|
|
{
|
|
|
|
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
|
|
|
|
VECTOR2I screenCenter( screenSize / 2 );
|
|
|
|
|
2017-06-12 13:27:10 +00:00
|
|
|
if( GetMousePosition( false ) != screenCenter )
|
2015-07-24 07:42:45 +00:00
|
|
|
{
|
|
|
|
m_view->SetCenter( GetCursorPosition() );
|
|
|
|
m_parentPanel->WarpPointer( KiROUND( screenSize.x / 2 ), KiROUND( screenSize.y / 2 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-02 14:26:42 +00:00
|
|
|
bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
|
2013-08-22 16:42:53 +00:00
|
|
|
{
|
|
|
|
VECTOR2D p( aEvent.GetX(), aEvent.GetY() );
|
|
|
|
|
|
|
|
// Compute areas where autopanning is active
|
2017-02-11 19:54:44 +00:00
|
|
|
double borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
|
|
|
|
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
|
2013-08-22 16:42:53 +00:00
|
|
|
double borderEndX = m_view->GetScreenPixelSize().x - borderStart;
|
|
|
|
double borderEndY = m_view->GetScreenPixelSize().y - borderStart;
|
|
|
|
|
|
|
|
if( p.x < borderStart )
|
|
|
|
m_panDirection.x = -( borderStart - p.x );
|
|
|
|
else if( p.x > borderEndX )
|
|
|
|
m_panDirection.x = ( p.x - borderEndX );
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
|
|
|
m_panDirection.x = 0;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
if( p.y < borderStart )
|
|
|
|
m_panDirection.y = -( borderStart - p.y );
|
|
|
|
else if( p.y > borderEndY )
|
|
|
|
m_panDirection.y = ( p.y - borderEndY );
|
2014-02-13 19:23:28 +00:00
|
|
|
else
|
|
|
|
m_panDirection.y = 0;
|
2013-08-22 16:42:53 +00:00
|
|
|
|
|
|
|
bool borderHit = ( m_panDirection.x != 0 || m_panDirection.y != 0 );
|
|
|
|
|
|
|
|
switch( m_state )
|
|
|
|
{
|
|
|
|
case AUTO_PANNING:
|
|
|
|
if( !borderHit )
|
|
|
|
{
|
|
|
|
m_panTimer.Stop();
|
|
|
|
m_state = IDLE;
|
2013-09-02 14:26:42 +00:00
|
|
|
|
|
|
|
return false;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-02 14:26:42 +00:00
|
|
|
return true;
|
2013-08-22 16:42:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDLE:
|
|
|
|
if( borderHit )
|
|
|
|
{
|
|
|
|
m_state = AUTO_PANNING;
|
2016-05-02 13:56:11 +00:00
|
|
|
m_panTimer.Start( (int) ( 250.0 / 60.0 ) );
|
2013-09-02 14:26:42 +00:00
|
|
|
|
|
|
|
return true;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2013-10-14 14:13:35 +00:00
|
|
|
|
2013-09-02 14:26:42 +00:00
|
|
|
return false;
|
2013-08-22 16:42:53 +00:00
|
|
|
break;
|
2013-09-02 14:26:42 +00:00
|
|
|
|
|
|
|
case DRAG_PANNING:
|
|
|
|
return false;
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2013-09-02 14:26:42 +00:00
|
|
|
|
|
|
|
wxASSERT_MSG( false, wxT( "This line should never be reached" ) );
|
2013-10-14 14:13:35 +00:00
|
|
|
return false; // Should not be reached, just avoid the compiler warnings..
|
2013-08-22 16:42:53 +00:00
|
|
|
}
|
2015-05-18 11:48:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
void WX_VIEW_CONTROLS::UpdateScrollbars()
|
|
|
|
{
|
|
|
|
const BOX2D viewport = m_view->GetViewport();
|
2015-05-18 11:48:13 +00:00
|
|
|
const BOX2I& boundary = m_view->GetBoundary();
|
2015-05-18 11:48:10 +00:00
|
|
|
|
2017-02-06 23:05:07 +00:00
|
|
|
m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often
|
|
|
|
m_scrollScale.y = 2e3 / viewport.GetHeight();
|
|
|
|
VECTOR2I newScroll( ( viewport.Centre().x - boundary.GetLeft() ) * m_scrollScale.x,
|
|
|
|
( viewport.Centre().y - boundary.GetTop() ) * m_scrollScale.y );
|
2015-05-18 11:48:10 +00:00
|
|
|
|
2017-02-06 23:05:07 +00:00
|
|
|
// Adjust scrollbars only if it is needed. Otherwise there are cases when canvas is continuosly
|
|
|
|
// refreshed (Windows)
|
|
|
|
if( m_scrollPos != newScroll )
|
|
|
|
{
|
|
|
|
// Another example of wxWidgets being broken by design: scroll position is determined by the
|
|
|
|
// left (or top, if vertical) edge of the slider. Fortunately, slider size seems to be constant
|
|
|
|
// (at least for wxGTK and wxMSW), so we have to add its size to allow user to scroll the workspace
|
|
|
|
// till the end.
|
|
|
|
|
|
|
|
m_parentPanel->SetScrollbars( 1, 1,
|
|
|
|
#if defined(__LINUX__)
|
|
|
|
m_scrollScale.x * boundary.GetWidth() + 1623, m_scrollScale.y * boundary.GetHeight() + 1623,
|
|
|
|
#elif defined(__WIN32__) || defined(__WIN64__)
|
|
|
|
m_scrollScale.x * boundary.GetWidth() + 1377, m_scrollScale.y * boundary.GetHeight() + 741,
|
2015-05-18 11:48:10 +00:00
|
|
|
#else
|
2017-02-06 23:05:07 +00:00
|
|
|
m_scrollScale.x * boundary.GetWidth(), m_scrollScale.y * boundary.GetHeight(),
|
2015-05-18 11:48:10 +00:00
|
|
|
#endif
|
2017-02-06 23:05:07 +00:00
|
|
|
newScroll.x, newScroll.y, false );
|
|
|
|
|
|
|
|
m_scrollPos = newScroll;
|
|
|
|
}
|
2015-05-18 11:48:10 +00:00
|
|
|
}
|