You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

728 lines
21 KiB

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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
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
13 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013-2017 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  8. * @author Maciej Suminski <maciej.suminski@cern.ch>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, you may find one here:
  22. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  23. * or you may search the http://www.gnu.org website for the version 2 license,
  24. * or you may write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  26. */
  27. #include <eda_draw_frame.h>
  28. #include <kiface_base.h>
  29. #include <macros.h>
  30. #include <scoped_set_reset.h>
  31. #include <settings/app_settings.h>
  32. #include <trace_helpers.h>
  33. #include <class_draw_panel_gal.h>
  34. #include <view/view.h>
  35. #include <view/wx_view_controls.h>
  36. #include <gal/painter.h>
  37. #include <base_screen.h>
  38. #include <gal/cursors.h>
  39. #include <gal/graphics_abstraction_layer.h>
  40. #include <gal/opengl/opengl_gal.h>
  41. #include <gal/cairo/cairo_gal.h>
  42. #include <math/vector2wx.h>
  43. #include <tool/tool_dispatcher.h>
  44. #include <tool/tool_manager.h>
  45. #include <widgets/wx_infobar.h>
  46. #include <kiplatform/ui.h>
  47. #include <core/profile.h>
  48. #include <pgm_base.h>
  49. #include <confirm.h>
  50. /**
  51. * Flag to enable drawing panel debugging output.
  52. *
  53. * @ingroup trace_env_vars
  54. */
  55. static const wxChar traceDrawPanel[] = wxT( "KICAD_DRAW_PANEL" );
  56. EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
  57. const wxPoint& aPosition, const wxSize& aSize,
  58. KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
  59. wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ),
  60. m_MouseCapturedLost( false ),
  61. m_parent( aParentWindow ),
  62. m_edaFrame( nullptr ),
  63. m_lastRepaintStart( 0 ),
  64. m_lastRepaintEnd( 0 ),
  65. m_drawing( false ),
  66. m_drawingEnabled( false ),
  67. m_needIdleRefresh( false ),
  68. m_gal( nullptr ),
  69. m_view( nullptr ),
  70. m_painter( nullptr ),
  71. m_viewControls( nullptr ),
  72. m_backend( GAL_TYPE_NONE ),
  73. m_options( aOptions ),
  74. m_eventDispatcher( nullptr ),
  75. m_lostFocus( false ),
  76. m_stealsFocus( true ),
  77. m_statusPopup( nullptr )
  78. {
  79. m_PaintEventCounter = std::make_unique<PROF_COUNTER>( "Draw panel paint events" );
  80. if( Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
  81. ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
  82. else
  83. ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
  84. SetLayoutDirection( wxLayout_LeftToRight );
  85. m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_parent );
  86. // If we're in a dialog, we have to go looking for our parent frame
  87. if( !m_edaFrame )
  88. {
  89. wxWindow* ancestor = aParentWindow->GetParent();
  90. while( ancestor && !dynamic_cast<EDA_DRAW_FRAME*>( ancestor ) )
  91. ancestor = ancestor->GetParent();
  92. if( ancestor )
  93. m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( ancestor );
  94. }
  95. SwitchBackend( aGalType );
  96. SetBackgroundStyle( wxBG_STYLE_CUSTOM );
  97. EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
  98. KIPLATFORM::UI::SetOverlayScrolling( this, false ); // Prevent excessive repaint on GTK
  99. KIPLATFORM::UI::ImmControl( this, false ); // Ensure our panel can't suck in IME events
  100. Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), nullptr, this );
  101. Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), nullptr,
  102. this );
  103. Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), nullptr,
  104. this );
  105. const wxEventType events[] = {
  106. // Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
  107. // especially special key like arrow keys, are handled by the GAL event dispatcher,
  108. // and not sent to GUI without filtering, because they have a default action (scroll)
  109. // that must not be called.
  110. wxEVT_LEFT_UP,
  111. wxEVT_LEFT_DOWN,
  112. wxEVT_LEFT_DCLICK,
  113. wxEVT_RIGHT_UP,
  114. wxEVT_RIGHT_DOWN,
  115. wxEVT_RIGHT_DCLICK,
  116. wxEVT_MIDDLE_UP,
  117. wxEVT_MIDDLE_DOWN,
  118. wxEVT_MIDDLE_DCLICK,
  119. wxEVT_AUX1_UP,
  120. wxEVT_AUX1_DOWN,
  121. wxEVT_AUX1_DCLICK,
  122. wxEVT_AUX2_UP,
  123. wxEVT_AUX2_DOWN,
  124. wxEVT_AUX2_DCLICK,
  125. wxEVT_MOTION,
  126. wxEVT_MOUSEWHEEL,
  127. wxEVT_CHAR,
  128. wxEVT_CHAR_HOOK,
  129. wxEVT_MAGNIFY,
  130. KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
  131. };
  132. for( wxEventType eventType : events )
  133. Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::OnEvent ), nullptr,
  134. m_eventDispatcher );
  135. // Set up timer to detect when drawing starts
  136. m_refreshTimer.SetOwner( this );
  137. Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
  138. wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), nullptr, this );
  139. // Set up timer to execute OnShow() method when the window appears on the screen
  140. m_onShowTimer.SetOwner( this );
  141. Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
  142. wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), nullptr, this );
  143. m_onShowTimer.Start( 10 );
  144. }
  145. EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
  146. {
  147. StopDrawing();
  148. wxASSERT( !m_drawing );
  149. delete m_viewControls;
  150. delete m_view;
  151. delete m_gal;
  152. }
  153. void EDA_DRAW_PANEL_GAL::SetFocus()
  154. {
  155. KIPLATFORM::UI::ImeNotifyCancelComposition( this );
  156. wxScrolledCanvas::SetFocus();
  157. m_lostFocus = false;
  158. }
  159. void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
  160. {
  161. DoRePaint();
  162. }
  163. bool EDA_DRAW_PANEL_GAL::DoRePaint()
  164. {
  165. if( !m_refreshMutex.try_lock() )
  166. return false;
  167. std::lock_guard<std::mutex> lock( m_refreshMutex, std::adopt_lock );
  168. if( !m_drawingEnabled )
  169. return false;
  170. if( !m_gal->IsInitialized() || !m_gal->IsVisible() || m_gal->IsContextLocked() )
  171. return false;
  172. if( m_drawing )
  173. return false;
  174. m_lastRepaintStart = wxGetLocalTimeMillis();
  175. // Repaint the canvas, and fix scrollbar cursors
  176. // Usually called by a OnPaint event, but because it does not use a wxPaintDC,
  177. // it can be called outside a wxPaintEvent.
  178. // Update current zoom settings if the canvas is managed by a EDA frame
  179. // (i.e. not by a preview panel in a dialog)
  180. if( !IsDialogPreview() && GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() )
  181. GetParentEDAFrame()->GetScreen()->m_ScrollCenter = GetView()->GetCenter();
  182. if( Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
  183. m_viewControls->UpdateScrollbars();
  184. SCOPED_SET_RESET<bool> drawing( m_drawing, true );
  185. ( *m_PaintEventCounter )++;
  186. wxASSERT( m_painter );
  187. KIGFX::RENDER_SETTINGS* settings =
  188. static_cast<KIGFX::RENDER_SETTINGS*>( m_painter->GetSettings() );
  189. PROF_TIMER cntUpd("view-upd-items");
  190. PROF_TIMER cntTotal("view-total");
  191. PROF_TIMER cntCtx("view-context-create");
  192. PROF_TIMER cntCtxDestroy("view-context-destroy");
  193. PROF_TIMER cntRedraw("view-redraw-rects");
  194. bool isDirty = false;
  195. cntTotal.Start();
  196. try
  197. {
  198. cntUpd.Start();
  199. try
  200. {
  201. m_view->UpdateItems();
  202. }
  203. catch( std::out_of_range& err )
  204. {
  205. // Don't do anything here but don't fail
  206. // This can happen when we don't catch `at()` calls
  207. wxLogTrace( traceDrawPanel, wxS( "Out of Range error: %s" ), err.what() );
  208. }
  209. cntUpd.Stop();
  210. // GAL_DRAWING_CONTEXT can throw in the dtor, so we need to scope
  211. // the full lifetime inside the try block
  212. {
  213. cntCtx.Start();
  214. KIGFX::GAL_DRAWING_CONTEXT ctx( m_gal );
  215. cntCtx.Stop();
  216. if( m_view->IsTargetDirty( KIGFX::TARGET_OVERLAY )
  217. && !m_gal->HasTarget( KIGFX::TARGET_OVERLAY ) )
  218. {
  219. m_view->MarkDirty();
  220. }
  221. m_gal->SetClearColor( settings->GetBackgroundColor() );
  222. m_gal->SetGridColor( settings->GetGridColor() );
  223. m_gal->SetCursorColor( settings->GetCursorColor() );
  224. // TODO: find why ClearScreen() must be called here in opengl mode
  225. // and only if m_view->IsDirty() in Cairo mode to avoid display artifacts
  226. // when moving the mouse cursor
  227. if( m_backend == GAL_TYPE_OPENGL )
  228. m_gal->ClearScreen();
  229. if( m_view->IsDirty() )
  230. {
  231. if( m_backend != GAL_TYPE_OPENGL // Already called in opengl
  232. && m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
  233. {
  234. m_gal->ClearScreen();
  235. }
  236. m_view->ClearTargets();
  237. // Grid has to be redrawn only when the NONCACHED target is redrawn
  238. if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
  239. m_gal->DrawGrid();
  240. cntRedraw.Start();
  241. m_view->Redraw();
  242. cntRedraw.Stop();
  243. isDirty = true;
  244. }
  245. m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
  246. cntCtxDestroy.Start();
  247. }
  248. // ctx goes out of scope here so destructor would be called
  249. cntCtxDestroy.Stop();
  250. }
  251. catch( std::exception& err )
  252. {
  253. if( GAL_FALLBACK != m_backend )
  254. {
  255. SwitchBackend( GAL_FALLBACK );
  256. DisplayInfoMessage( m_parent,
  257. _( "Could not use OpenGL, falling back to software rendering" ),
  258. wxString( err.what() ) );
  259. StartDrawing();
  260. }
  261. else
  262. {
  263. // We're well and truly banjaxed if we get here without a fallback.
  264. DisplayErrorMessage( m_parent, _( "Graphics error" ), wxString( err.what() ) );
  265. StopDrawing();
  266. }
  267. }
  268. if( isDirty )
  269. {
  270. KI_TRACE( traceGalProfile, "View timing: %s %s %s %s %s\n",
  271. cntTotal.to_string(),
  272. cntUpd.to_string(),
  273. cntRedraw.to_string(),
  274. cntCtx.to_string(),
  275. cntCtxDestroy.to_string()
  276. );
  277. }
  278. m_lastRepaintEnd = wxGetLocalTimeMillis();
  279. return true;
  280. }
  281. void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
  282. {
  283. // If we get a second wx update call before the first finishes, don't crash
  284. if( m_gal->IsContextLocked() )
  285. return;
  286. KIGFX::GAL_CONTEXT_LOCKER locker( m_gal );
  287. wxSize clientSize = GetClientSize();
  288. WX_INFOBAR* infobar = GetParentEDAFrame() ? GetParentEDAFrame()->GetInfoBar() : nullptr;
  289. if( ToVECTOR2I( clientSize ) == m_gal->GetScreenPixelSize() )
  290. return;
  291. // Note: ( +1, +1 ) prevents an ugly black line on right and bottom on Mac
  292. clientSize.x = std::max( 10, clientSize.x + 1 );
  293. clientSize.y = std::max( 10, clientSize.y + 1 );
  294. VECTOR2D bottom( 0, 0 );
  295. if( m_view )
  296. bottom = m_view->ToWorld( m_gal->GetScreenPixelSize(), true );
  297. m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
  298. if( m_view )
  299. {
  300. if( infobar && infobar->IsLocked() )
  301. {
  302. VECTOR2D halfScreen( std::ceil( 0.5 * clientSize.x ), std::ceil( 0.5 * clientSize.y ) );
  303. m_view->SetCenter( bottom - m_view->ToWorld( halfScreen, false ) );
  304. }
  305. m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
  306. m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
  307. }
  308. }
  309. void EDA_DRAW_PANEL_GAL::RequestRefresh()
  310. {
  311. m_needIdleRefresh = true;
  312. }
  313. void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
  314. {
  315. if( !DoRePaint() )
  316. RequestRefresh();
  317. }
  318. void EDA_DRAW_PANEL_GAL::ForceRefresh()
  319. {
  320. if( !m_drawingEnabled )
  321. {
  322. if( m_gal && m_gal->IsInitialized() )
  323. {
  324. Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr,
  325. this );
  326. Connect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_PANEL_GAL::onIdle ), nullptr, this );
  327. m_drawingEnabled = true;
  328. }
  329. else
  330. {
  331. // Try again soon
  332. m_refreshTimer.StartOnce( 100 );
  333. return;
  334. }
  335. }
  336. DoRePaint();
  337. }
  338. void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
  339. {
  340. m_eventDispatcher = aEventDispatcher;
  341. }
  342. void EDA_DRAW_PANEL_GAL::StartDrawing()
  343. {
  344. // Start querying GAL if it is ready
  345. m_refreshTimer.StartOnce( 100 );
  346. }
  347. void EDA_DRAW_PANEL_GAL::StopDrawing()
  348. {
  349. m_refreshTimer.Stop();
  350. m_drawingEnabled = false;
  351. Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr, this );
  352. Disconnect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_PANEL_GAL::onIdle ), nullptr, this );
  353. }
  354. void EDA_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer )
  355. {
  356. // Set display settings for high contrast mode
  357. KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
  358. SetTopLayer( aLayer );
  359. rSettings->ClearHighContrastLayers();
  360. rSettings->SetLayerIsHighContrast( aLayer );
  361. m_view->UpdateAllLayersColor();
  362. }
  363. void EDA_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
  364. {
  365. m_view->ClearTopLayers();
  366. m_view->SetTopLayer( aLayer );
  367. m_view->UpdateAllLayersOrder();
  368. }
  369. bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
  370. {
  371. // Do not do anything if the currently used GAL is correct
  372. if( aGalType == m_backend && m_gal != nullptr )
  373. return true;
  374. VECTOR2D grid_size = m_gal ? m_gal->GetGridSize() : VECTOR2D();
  375. bool grid_visibility = m_gal ? m_gal->GetGridVisibility() : true;
  376. bool result = true; // assume everything will be fine
  377. // Prevent refreshing canvas during backend switch
  378. StopDrawing();
  379. KIGFX::GAL* new_gal = nullptr;
  380. try
  381. {
  382. switch( aGalType )
  383. {
  384. case GAL_TYPE_OPENGL:
  385. {
  386. wxString errormsg = KIGFX::OPENGL_GAL::CheckFeatures( m_options );
  387. if( errormsg.empty() )
  388. {
  389. new_gal = new KIGFX::OPENGL_GAL( GetVcSettings(), m_options, this, this, this );
  390. }
  391. else
  392. {
  393. if( GAL_FALLBACK != aGalType )
  394. {
  395. aGalType = GAL_FALLBACK;
  396. DisplayInfoMessage(
  397. m_parent,
  398. _( "Could not use OpenGL, falling back to software rendering" ),
  399. errormsg );
  400. new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this );
  401. }
  402. else
  403. {
  404. // We're well and truly banjaxed if we get here without a fallback.
  405. DisplayInfoMessage( m_parent, _( "Could not use OpenGL" ), errormsg );
  406. }
  407. }
  408. break;
  409. }
  410. case GAL_TYPE_CAIRO:
  411. new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this );
  412. break;
  413. default:
  414. wxASSERT( false );
  415. KI_FALLTHROUGH;
  416. // warn about unhandled GAL canvas type, but continue with the fallback option
  417. case GAL_TYPE_NONE:
  418. // KIGFX::GAL is a stub - it actually does cannot display anything,
  419. // but prevents code relying on GAL canvas existence from crashing
  420. new_gal = new KIGFX::GAL( m_options );
  421. break;
  422. }
  423. }
  424. catch( std::runtime_error& err )
  425. {
  426. // Create a dummy GAL
  427. new_gal = new KIGFX::GAL( m_options );
  428. aGalType = GAL_TYPE_NONE;
  429. DisplayErrorMessage( m_parent, _( "Error switching GAL backend" ), wxString( err.what() ) );
  430. result = false;
  431. }
  432. // trigger update of the gal options in case they differ from the defaults
  433. m_options.NotifyChanged();
  434. delete m_gal;
  435. m_gal = new_gal;
  436. wxSize clientSize = GetClientSize();
  437. clientSize.x = std::max( 10, clientSize.x );
  438. clientSize.y = std::max( 10, clientSize.y );
  439. m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
  440. if( grid_size.x > 0 && grid_size.y > 0 )
  441. m_gal->SetGridSize( grid_size );
  442. m_gal->SetGridVisibility( grid_visibility );
  443. // Make sure the cursor is set on the new canvas
  444. SetCurrentCursor( KICURSOR::ARROW );
  445. if( m_painter )
  446. m_painter->SetGAL( m_gal );
  447. if( m_view )
  448. {
  449. m_view->SetGAL( m_gal );
  450. // Note: OpenGL requires reverse draw order when draw priority is enabled
  451. m_view->ReverseDrawOrder( aGalType == GAL_TYPE_OPENGL );
  452. }
  453. m_backend = aGalType;
  454. return result;
  455. }
  456. void EDA_DRAW_PANEL_GAL::OnEvent( wxEvent& aEvent )
  457. {
  458. bool shouldSetFocus = m_lostFocus && m_stealsFocus
  459. && !KIUI::IsInputControlFocused() // Don't steal from input controls
  460. && !KIUI::IsModalDialogFocused() // Don't steal from dialogs
  461. && KIPLATFORM::UI::IsWindowActive( m_edaFrame ); // Don't steal from other windows
  462. if( shouldSetFocus )
  463. SetFocus();
  464. if( !m_eventDispatcher )
  465. aEvent.Skip();
  466. else
  467. m_eventDispatcher->DispatchWxEvent( aEvent );
  468. // Give events time to process, based on last render duration
  469. wxLongLong endDelta = wxGetLocalTimeMillis() - m_lastRepaintEnd;
  470. long long timeLimit = ( m_lastRepaintEnd - m_lastRepaintStart ).GetValue() / 5;
  471. timeLimit = std::clamp( timeLimit, 3LL, 150LL );
  472. if( endDelta > timeLimit )
  473. Refresh();
  474. else
  475. RequestRefresh();
  476. }
  477. void EDA_DRAW_PANEL_GAL::onEnter( wxMouseEvent& aEvent )
  478. {
  479. bool shouldSetFocus = m_stealsFocus
  480. && !KIUI::IsInputControlFocused() // Don't steal from input controls
  481. && !KIUI::IsModalDialogFocused() // Don't steal from dialogs
  482. && KIPLATFORM::UI::IsWindowActive( m_edaFrame ); // Don't steal from other windows
  483. // Getting focus is necessary in order to receive key events properly
  484. if( shouldSetFocus )
  485. SetFocus();
  486. aEvent.Skip();
  487. }
  488. void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent )
  489. {
  490. m_lostFocus = true;
  491. m_viewControls->CancelDrag();
  492. aEvent.Skip();
  493. }
  494. void EDA_DRAW_PANEL_GAL::onIdle( wxIdleEvent& aEvent )
  495. {
  496. if( m_needIdleRefresh )
  497. {
  498. m_needIdleRefresh = false;
  499. Refresh();
  500. }
  501. aEvent.Skip();
  502. }
  503. void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
  504. {
  505. ForceRefresh();
  506. }
  507. void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
  508. {
  509. if( m_gal && m_gal->IsInitialized() && m_gal->IsVisible() )
  510. {
  511. m_onShowTimer.Stop();
  512. OnShow();
  513. }
  514. }
  515. void EDA_DRAW_PANEL_GAL::SetCurrentCursor( KICURSOR aCursor )
  516. {
  517. if( !m_gal )
  518. return;
  519. DPI_SCALING_COMMON dpi( nullptr, m_parent );
  520. bool hidpi = false;
  521. // Cursor scaling factor cannot be set for a wxCursor on GTK and OSX (at least before wx 3.3),
  522. // resulting in 4x rendered size on 2x window scale.
  523. // MSW renders the bitmap as-is, without scaling, so this works here.
  524. #ifdef __WXMSW__
  525. hidpi = dpi.GetContentScaleFactor() >= 2.0;
  526. #endif
  527. m_gal->SetNativeCursorStyle( aCursor, hidpi );
  528. }
  529. std::shared_ptr<KIGFX::VIEW_OVERLAY> EDA_DRAW_PANEL_GAL::DebugOverlay()
  530. {
  531. if( !m_debugOverlay )
  532. {
  533. m_debugOverlay.reset( new KIGFX::VIEW_OVERLAY() );
  534. m_view->Add( m_debugOverlay.get() );
  535. }
  536. return m_debugOverlay;
  537. }
  538. void EDA_DRAW_PANEL_GAL::ClearDebugOverlay()
  539. {
  540. if( m_debugOverlay )
  541. {
  542. m_view->Remove( m_debugOverlay.get() );
  543. m_debugOverlay = nullptr;
  544. }
  545. }
  546. KIGFX::VC_SETTINGS EDA_DRAW_PANEL_GAL::GetVcSettings()
  547. {
  548. COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
  549. KIGFX::VC_SETTINGS vcSettings;
  550. vcSettings.m_warpCursor = cfg->m_Input.center_on_zoom;
  551. vcSettings.m_focusFollowSchPcb = cfg->m_Input.focus_follow_sch_pcb;
  552. vcSettings.m_autoPanSettingEnabled = cfg->m_Input.auto_pan;
  553. vcSettings.m_autoPanAcceleration = cfg->m_Input.auto_pan_acceleration;
  554. vcSettings.m_horizontalPan = cfg->m_Input.horizontal_pan;
  555. vcSettings.m_zoomAcceleration = cfg->m_Input.zoom_acceleration;
  556. vcSettings.m_zoomSpeed = cfg->m_Input.zoom_speed;
  557. vcSettings.m_zoomSpeedAuto = cfg->m_Input.zoom_speed_auto;
  558. vcSettings.m_scrollModifierZoom = cfg->m_Input.scroll_modifier_zoom;
  559. vcSettings.m_scrollModifierPanH = cfg->m_Input.scroll_modifier_pan_h;
  560. vcSettings.m_scrollModifierPanV = cfg->m_Input.scroll_modifier_pan_v;
  561. vcSettings.m_dragLeft = cfg->m_Input.drag_left;
  562. vcSettings.m_dragMiddle = cfg->m_Input.drag_middle;
  563. vcSettings.m_dragRight = cfg->m_Input.drag_right;
  564. vcSettings.m_scrollReverseZoom = cfg->m_Input.reverse_scroll_zoom;
  565. vcSettings.m_scrollReversePanH = cfg->m_Input.reverse_scroll_pan_h;
  566. return vcSettings;
  567. }