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.

663 lines
19 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
13 years ago
13 years ago
13 years ago
11 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
11 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 (C) 2013-2021 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 <confirm.h>
  28. #include <eda_draw_frame.h>
  29. #include <kiface_base.h>
  30. #include <macros.h>
  31. #include <scoped_set_reset.h>
  32. #include <settings/app_settings.h>
  33. #include <trace_helpers.h>
  34. #include <class_draw_panel_gal.h>
  35. #include <view/view.h>
  36. #include <view/wx_view_controls.h>
  37. #include <painter.h>
  38. #include <base_screen.h>
  39. #include <gal/cursors.h>
  40. #include <gal/graphics_abstraction_layer.h>
  41. #include <gal/opengl/opengl_gal.h>
  42. #include <gal/cairo/cairo_gal.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 <profile.h>
  48. #include <pgm_base.h>
  49. EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
  50. const wxPoint& aPosition, const wxSize& aSize,
  51. KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
  52. wxScrolledCanvas( aParentWindow, aWindowId, aPosition, aSize ),
  53. m_MouseCapturedLost( false ),
  54. m_parent( aParentWindow ),
  55. m_edaFrame( nullptr ),
  56. m_lastRefresh( 0 ),
  57. m_pendingRefresh( false ),
  58. m_drawing( false ),
  59. m_drawingEnabled( false ),
  60. m_gal( nullptr ),
  61. m_view( nullptr ),
  62. m_painter( nullptr ),
  63. m_viewControls( nullptr ),
  64. m_backend( GAL_TYPE_NONE ),
  65. m_options( aOptions ),
  66. m_eventDispatcher( nullptr ),
  67. m_lostFocus( false ),
  68. m_stealsFocus( true ),
  69. m_statusPopup( nullptr )
  70. {
  71. m_PaintEventCounter = std::make_unique<PROF_COUNTER>( "Draw panel paint events" );
  72. m_minRefreshPeriod = 13; // 77 FPS (minus render time) by default
  73. SetLayoutDirection( wxLayout_LeftToRight );
  74. m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( m_parent );
  75. // If we're in a dialog, we have to go looking for our parent frame
  76. if( !m_edaFrame )
  77. {
  78. wxWindow* ancestor = aParentWindow->GetParent();
  79. while( ancestor && !dynamic_cast<EDA_DRAW_FRAME*>( ancestor ) )
  80. ancestor = ancestor->GetParent();
  81. if( ancestor )
  82. m_edaFrame = dynamic_cast<EDA_DRAW_FRAME*>( ancestor );
  83. }
  84. SwitchBackend( aGalType );
  85. SetBackgroundStyle( wxBG_STYLE_CUSTOM );
  86. if( Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
  87. {
  88. ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
  89. }
  90. else
  91. {
  92. ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
  93. }
  94. EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
  95. KIPLATFORM::UI::SetOverlayScrolling( this, false ); // Prevent excessive repaint on GTK
  96. Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), nullptr, this );
  97. Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), nullptr,
  98. this );
  99. Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( EDA_DRAW_PANEL_GAL::onLostFocus ), nullptr,
  100. this );
  101. const wxEventType events[] = {
  102. // Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events,
  103. // especially special key like arrow keys, are handled by the GAL event dispatcher,
  104. // and not sent to GUI without filtering, because they have a default action (scroll)
  105. // that must not be called.
  106. wxEVT_LEFT_UP,
  107. wxEVT_LEFT_DOWN,
  108. wxEVT_LEFT_DCLICK,
  109. wxEVT_RIGHT_UP,
  110. wxEVT_RIGHT_DOWN,
  111. wxEVT_RIGHT_DCLICK,
  112. wxEVT_MIDDLE_UP,
  113. wxEVT_MIDDLE_DOWN,
  114. wxEVT_MIDDLE_DCLICK,
  115. wxEVT_AUX1_UP,
  116. wxEVT_AUX1_DOWN,
  117. wxEVT_AUX1_DCLICK,
  118. wxEVT_AUX2_UP,
  119. wxEVT_AUX2_DOWN,
  120. wxEVT_AUX2_DCLICK,
  121. wxEVT_MOTION,
  122. wxEVT_MOUSEWHEEL,
  123. wxEVT_CHAR,
  124. wxEVT_CHAR_HOOK,
  125. #if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
  126. wxEVT_MAGNIFY,
  127. #endif
  128. KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE
  129. };
  130. for( wxEventType eventType : events )
  131. Connect( eventType, wxEventHandler( EDA_DRAW_PANEL_GAL::OnEvent ), nullptr,
  132. m_eventDispatcher );
  133. // Set up timer that prevents too frequent redraw commands
  134. m_refreshTimer.SetOwner( this );
  135. Connect( m_refreshTimer.GetId(), wxEVT_TIMER,
  136. wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onRefreshTimer ), nullptr, this );
  137. // Set up timer to execute OnShow() method when the window appears on the screen
  138. m_onShowTimer.SetOwner( this );
  139. Connect( m_onShowTimer.GetId(), wxEVT_TIMER,
  140. wxTimerEventHandler( EDA_DRAW_PANEL_GAL::onShowTimer ), nullptr, this );
  141. m_onShowTimer.Start( 10 );
  142. }
  143. EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
  144. {
  145. StopDrawing();
  146. wxASSERT( !m_drawing );
  147. delete m_viewControls;
  148. delete m_view;
  149. delete m_gal;
  150. }
  151. void EDA_DRAW_PANEL_GAL::SetFocus()
  152. {
  153. wxScrolledCanvas::SetFocus();
  154. m_lostFocus = false;
  155. }
  156. void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
  157. {
  158. DoRePaint();
  159. }
  160. void EDA_DRAW_PANEL_GAL::DoRePaint()
  161. {
  162. if( !m_refreshMutex.try_lock() )
  163. return;
  164. std::lock_guard<std::mutex> lock( m_refreshMutex, std::adopt_lock );
  165. // Repaint the canvas, and fix scrollbar cursors
  166. // Usually called by a OnPaint event, but because it does not use a wxPaintDC,
  167. // it can be called outside a wxPaintEvent.
  168. // Update current zoom settings if the canvas is managed by a EDA frame
  169. // (i.e. not by a preview panel in a dialog)
  170. if( !IsDialogPreview() && GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() )
  171. GetParentEDAFrame()->GetScreen()->m_ScrollCenter = GetView()->GetCenter();
  172. if( Pgm().GetCommonSettings()->m_Appearance.show_scrollbars )
  173. m_viewControls->UpdateScrollbars();
  174. if( !m_drawingEnabled )
  175. return;
  176. if( !m_gal->IsInitialized() || !m_gal->IsVisible() )
  177. return;
  178. m_pendingRefresh = false;
  179. if( m_drawing )
  180. return;
  181. SCOPED_SET_RESET<bool> drawing( m_drawing, true );
  182. ( *m_PaintEventCounter )++;
  183. wxASSERT( m_painter );
  184. KIGFX::RENDER_SETTINGS* settings =
  185. static_cast<KIGFX::RENDER_SETTINGS*>( m_painter->GetSettings() );
  186. PROF_TIMER cntUpd("view-upd-items");
  187. PROF_TIMER cntTotal("view-total");
  188. PROF_TIMER cntCtx("view-context-create");
  189. PROF_TIMER cntCtxDestroy("view-context-destroy");
  190. PROF_TIMER cntRedraw("view-redraw-rects");
  191. bool isDirty = false;
  192. cntTotal.Start();
  193. try
  194. {
  195. cntUpd.Start();
  196. try
  197. {
  198. m_view->UpdateItems();
  199. }
  200. catch( std::out_of_range& err )
  201. {
  202. // Don't do anything here but don't fail
  203. // This can happen when we don't catch `at()` calls
  204. wxString msg;
  205. msg.Printf( wxT( "Out of Range error: %s" ), err.what() );
  206. wxLogDebug( msg );
  207. }
  208. cntUpd.Stop();
  209. // GAL_DRAWING_CONTEXT can throw in the dtor, so we need to scope
  210. // the full lifetime inside the try block
  211. {
  212. cntCtx.Start();
  213. KIGFX::GAL_DRAWING_CONTEXT ctx( m_gal );
  214. cntCtx.Stop();
  215. if( m_view->IsTargetDirty( KIGFX::TARGET_OVERLAY )
  216. && !m_gal->HasTarget( KIGFX::TARGET_OVERLAY ) )
  217. {
  218. m_view->MarkDirty();
  219. }
  220. m_gal->SetClearColor( settings->GetBackgroundColor() );
  221. m_gal->SetGridColor( settings->GetGridColor() );
  222. m_gal->SetCursorColor( settings->GetCursorColor() );
  223. // TODO: find why ClearScreen() must be called here in opengl mode
  224. // and only if m_view->IsDirty() in Cairo mode to avoid display artifacts
  225. // when moving the mouse cursor
  226. if( m_backend == GAL_TYPE_OPENGL )
  227. m_gal->ClearScreen();
  228. if( m_view->IsDirty() )
  229. {
  230. if( m_backend != GAL_TYPE_OPENGL // Already called in opengl
  231. && m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
  232. {
  233. m_gal->ClearScreen();
  234. }
  235. m_view->ClearTargets();
  236. // Grid has to be redrawn only when the NONCACHED target is redrawn
  237. if( m_view->IsTargetDirty( KIGFX::TARGET_NONCACHED ) )
  238. m_gal->DrawGrid();
  239. cntRedraw.Start();
  240. m_view->Redraw();
  241. cntRedraw.Stop();
  242. isDirty = true;
  243. }
  244. m_gal->DrawCursor( m_viewControls->GetCursorPosition() );
  245. cntCtxDestroy.Start();
  246. }
  247. // ctx goes out of scope here so destructor would be called
  248. cntCtxDestroy.Stop();
  249. }
  250. catch( std::exception& err )
  251. {
  252. if( GAL_FALLBACK != m_backend )
  253. {
  254. SwitchBackend( GAL_FALLBACK );
  255. DisplayInfoMessage( m_parent,
  256. _( "Could not use OpenGL, falling back to software rendering" ),
  257. wxString( err.what() ) );
  258. }
  259. else
  260. {
  261. // We're well and truly banjaxed if we get here without a fallback.
  262. DisplayInfoMessage( m_parent, _( "Could not use OpenGL" ), wxString( err.what() ) );
  263. }
  264. }
  265. if( isDirty )
  266. {
  267. KI_TRACE( traceGalProfile, "View timing: %s %s %s %s %s\n",
  268. cntTotal.to_string(),
  269. cntUpd.to_string(),
  270. cntRedraw.to_string(),
  271. cntCtx.to_string(),
  272. cntCtxDestroy.to_string()
  273. );
  274. }
  275. m_lastRefresh = wxGetLocalTimeMillis();
  276. }
  277. void EDA_DRAW_PANEL_GAL::onSize( wxSizeEvent& aEvent )
  278. {
  279. // If we get a second wx update call before the first finishes, don't crash
  280. if( m_gal->IsContextLocked() )
  281. return;
  282. KIGFX::GAL_CONTEXT_LOCKER locker( m_gal );
  283. wxSize clientSize = GetClientSize();
  284. WX_INFOBAR* infobar = GetParentEDAFrame() ? GetParentEDAFrame()->GetInfoBar() : nullptr;
  285. if( VECTOR2I( clientSize ) == m_gal->GetScreenPixelSize() )
  286. return;
  287. clientSize.x = std::max( 10, clientSize.x );
  288. clientSize.y = std::max( 10, clientSize.y );
  289. VECTOR2D bottom( 0, 0 );
  290. if( m_view )
  291. bottom = m_view->ToWorld( m_gal->GetScreenPixelSize(), true );
  292. m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
  293. if( m_view )
  294. {
  295. if( infobar && infobar->IsLocked() )
  296. m_view->SetCenter( bottom - m_view->ToWorld( clientSize, false ) / 2.0 );
  297. m_view->MarkTargetDirty( KIGFX::TARGET_CACHED );
  298. m_view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
  299. }
  300. }
  301. void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
  302. {
  303. wxLongLong t = wxGetLocalTimeMillis();
  304. wxLongLong delta = t - m_lastRefresh;
  305. // If it has been too long since the last frame (possible depending on platform timer latency),
  306. // just do a refresh. Otherwise, start the refresh timer if it hasn't already been started.
  307. // This ensures that we will render often enough but not too often.
  308. if( delta >= m_minRefreshPeriod )
  309. {
  310. if( !m_pendingRefresh )
  311. ForceRefresh();
  312. m_refreshTimer.Start( m_minRefreshPeriod, true );
  313. }
  314. else if( !m_refreshTimer.IsRunning() )
  315. {
  316. m_refreshTimer.Start( ( m_minRefreshPeriod - delta ).ToLong(), true );
  317. }
  318. }
  319. void EDA_DRAW_PANEL_GAL::ForceRefresh()
  320. {
  321. m_pendingRefresh = true;
  322. DoRePaint();
  323. }
  324. void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher )
  325. {
  326. m_eventDispatcher = aEventDispatcher;
  327. }
  328. void EDA_DRAW_PANEL_GAL::StartDrawing()
  329. {
  330. // Start querying GAL if it is ready
  331. m_refreshTimer.StartOnce( 100 );
  332. }
  333. void EDA_DRAW_PANEL_GAL::StopDrawing()
  334. {
  335. m_refreshTimer.Stop();
  336. m_drawingEnabled = false;
  337. Disconnect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr, this );
  338. m_pendingRefresh = false;
  339. }
  340. void EDA_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer )
  341. {
  342. // Set display settings for high contrast mode
  343. KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
  344. SetTopLayer( aLayer );
  345. rSettings->ClearHighContrastLayers();
  346. rSettings->SetLayerIsHighContrast( aLayer );
  347. m_view->UpdateAllLayersColor();
  348. }
  349. void EDA_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
  350. {
  351. m_view->ClearTopLayers();
  352. m_view->SetTopLayer( aLayer );
  353. m_view->UpdateAllLayersOrder();
  354. }
  355. bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
  356. {
  357. // Do not do anything if the currently used GAL is correct
  358. if( aGalType == m_backend && m_gal != nullptr )
  359. return true;
  360. VECTOR2D grid_size = m_gal ? m_gal->GetGridSize() : VECTOR2D();
  361. bool grid_visibility = m_gal ? m_gal->GetGridVisibility() : true;
  362. bool result = true; // assume everything will be fine
  363. // Prevent refreshing canvas during backend switch
  364. StopDrawing();
  365. KIGFX::GAL* new_gal = nullptr;
  366. try
  367. {
  368. switch( aGalType )
  369. {
  370. case GAL_TYPE_OPENGL:
  371. {
  372. wxString errormsg = KIGFX::OPENGL_GAL::CheckFeatures( m_options );
  373. if( errormsg.empty() )
  374. {
  375. new_gal = new KIGFX::OPENGL_GAL( m_options, this, this, this );
  376. }
  377. else
  378. {
  379. if( GAL_FALLBACK != aGalType )
  380. {
  381. aGalType = GAL_FALLBACK;
  382. DisplayInfoMessage(
  383. m_parent,
  384. _( "Could not use OpenGL, falling back to software rendering" ),
  385. errormsg );
  386. new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this );
  387. }
  388. else
  389. {
  390. // We're well and truly banjaxed if we get here without a fallback.
  391. DisplayInfoMessage( m_parent, _( "Could not use OpenGL" ), errormsg );
  392. }
  393. }
  394. break;
  395. }
  396. case GAL_TYPE_CAIRO: new_gal = new KIGFX::CAIRO_GAL( m_options, this, this, this ); break;
  397. default:
  398. wxASSERT( false );
  399. KI_FALLTHROUGH;
  400. // warn about unhandled GAL canvas type, but continue with the fallback option
  401. case GAL_TYPE_NONE:
  402. // KIGFX::GAL is a stub - it actually does cannot display anything,
  403. // but prevents code relying on GAL canvas existence from crashing
  404. new_gal = new KIGFX::GAL( m_options );
  405. break;
  406. }
  407. }
  408. catch( std::runtime_error& err )
  409. {
  410. // Create a dummy GAL
  411. new_gal = new KIGFX::GAL( m_options );
  412. aGalType = GAL_TYPE_NONE;
  413. DisplayError( m_parent, wxString( err.what() ) );
  414. result = false;
  415. }
  416. // trigger update of the gal options in case they differ from the defaults
  417. m_options.NotifyChanged();
  418. delete m_gal;
  419. m_gal = new_gal;
  420. wxSize clientSize = GetClientSize();
  421. clientSize.x = std::max( 10, clientSize.x );
  422. clientSize.y = std::max( 10, clientSize.y );
  423. m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
  424. if( grid_size.x > 0 && grid_size.y > 0 )
  425. m_gal->SetGridSize( grid_size );
  426. m_gal->SetGridVisibility( grid_visibility );
  427. if( m_gal->GetSwapInterval() != 0 )
  428. {
  429. // In theory this could be 0 but then more CPU cycles will be wasted in SwapBuffers
  430. m_minRefreshPeriod = 5;
  431. }
  432. // Make sure the cursor is set on the new canvas
  433. SetCurrentCursor( KICURSOR::ARROW );
  434. if( m_painter )
  435. m_painter->SetGAL( m_gal );
  436. if( m_view )
  437. {
  438. m_view->SetGAL( m_gal );
  439. // Note: OpenGL requires reverse draw order when draw priority is enabled
  440. m_view->ReverseDrawOrder( aGalType == GAL_TYPE_OPENGL );
  441. }
  442. m_backend = aGalType;
  443. return result;
  444. }
  445. void EDA_DRAW_PANEL_GAL::OnEvent( wxEvent& aEvent )
  446. {
  447. bool shouldSetFocus = m_lostFocus && m_stealsFocus
  448. && !KIUI::IsInputControlFocused() // Don't steal from input controls
  449. && !KIUI::IsModalDialogFocused() // Don't steal from dialogs
  450. && KIPLATFORM::UI::IsWindowActive( m_edaFrame ); // Don't steal from other windows
  451. if( shouldSetFocus )
  452. SetFocus();
  453. if( !m_eventDispatcher )
  454. aEvent.Skip();
  455. else
  456. m_eventDispatcher->DispatchWxEvent( aEvent );
  457. Refresh();
  458. }
  459. void EDA_DRAW_PANEL_GAL::onEnter( wxMouseEvent& aEvent )
  460. {
  461. bool shouldSetFocus = m_stealsFocus
  462. && !KIUI::IsInputControlFocused() // Don't steal from input controls
  463. && !KIUI::IsModalDialogFocused() // Don't steal from dialogs
  464. && KIPLATFORM::UI::IsWindowActive( m_edaFrame ); // Don't steal from other windows
  465. // Getting focus is necessary in order to receive key events properly
  466. if( shouldSetFocus )
  467. SetFocus();
  468. aEvent.Skip();
  469. }
  470. void EDA_DRAW_PANEL_GAL::onLostFocus( wxFocusEvent& aEvent )
  471. {
  472. m_lostFocus = true;
  473. m_viewControls->CancelDrag();
  474. aEvent.Skip();
  475. }
  476. void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
  477. {
  478. if( !m_drawingEnabled )
  479. {
  480. if( m_gal && m_gal->IsInitialized() )
  481. {
  482. m_pendingRefresh = true;
  483. Connect( wxEVT_PAINT, wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), nullptr,
  484. this );
  485. m_drawingEnabled = true;
  486. }
  487. else
  488. {
  489. // Try again soon
  490. m_refreshTimer.StartOnce( 100 );
  491. return;
  492. }
  493. }
  494. DoRePaint();
  495. }
  496. void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
  497. {
  498. if( m_gal && m_gal->IsVisible() )
  499. {
  500. m_onShowTimer.Stop();
  501. OnShow();
  502. }
  503. }
  504. void EDA_DRAW_PANEL_GAL::SetCurrentCursor( KICURSOR aCursor )
  505. {
  506. if( m_gal )
  507. m_gal->SetNativeCursorStyle( aCursor );
  508. }
  509. std::shared_ptr<KIGFX::VIEW_OVERLAY> EDA_DRAW_PANEL_GAL::DebugOverlay()
  510. {
  511. if( !m_debugOverlay )
  512. {
  513. m_debugOverlay.reset( new KIGFX::VIEW_OVERLAY() );
  514. m_view->Add( m_debugOverlay.get() );
  515. }
  516. return m_debugOverlay;
  517. }
  518. void EDA_DRAW_PANEL_GAL::ClearDebugOverlay()
  519. {
  520. if( m_debugOverlay )
  521. {
  522. m_view->Remove( m_debugOverlay.get() );
  523. m_debugOverlay = nullptr;
  524. }
  525. }