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.

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