diff --git a/include/gal/cairo/cairo_compositor.h b/include/gal/cairo/cairo_compositor.h index 1cf70f925f..1105ade12c 100644 --- a/include/gal/cairo/cairo_compositor.h +++ b/include/gal/cairo/cairo_compositor.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -25,7 +25,7 @@ /** * @file cairo_compositor.h - * @brief Class that handles multitarget rendering (ie. to different textures/surfaces) and + * Class that handles multitarget rendering (ie. to different textures/surfaces) and * later compositing into a single image (Cairo flavour). */ @@ -94,8 +94,7 @@ public: } /** - * Function SetMainContext() - * Sets a context to be treated as the main context (ie. as a target of buffers rendering and + * Set a context to be treated as the main context (ie. as a target of buffers rendering and * as a source of settings for newly created buffers). * * @param aMainContext is the context that should be treated as the main one. @@ -109,6 +108,17 @@ public: } protected: + /** + * Perform freeing of resources. + */ + void clean(); + + /// Return number of currently used buffers. + unsigned int usedBuffers() + { + return m_buffers.size(); + } + typedef uint32_t* BitmapPtr; typedef struct { @@ -136,18 +146,6 @@ protected: unsigned int m_bufferSize; ///< Amount of memory needed to store a buffer cairo_antialias_t m_currentAntialiasingMode; - - /** - * Function clean() - * performs freeing of resources. - */ - void clean(); - - /// Returns number of currently used buffers - unsigned int usedBuffers() - { - return m_buffers.size(); - } }; } // namespace KIGFX diff --git a/include/gal/cairo/cairo_gal.h b/include/gal/cairo/cairo_gal.h index f993257e1f..715ea452ed 100644 --- a/include/gal/cairo/cairo_gal.h +++ b/include/gal/cairo/cairo_gal.h @@ -40,16 +40,15 @@ #include /** - * @brief Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer. + * Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer. * * Quote from Wikipedia: * " Cairo is a software library used to provide a vector graphics-based, device-independent * API for software developers. It is designed to provide primitives for 2-dimensional * drawing across a number of different backends. " - *
+ * * Cairo offers also backends for PostScript and PDF surfaces. So it can be used for printing * of KiCad graphics surfaces as well. - * */ namespace KIGFX { @@ -72,7 +71,8 @@ public: void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) override; /// @copydoc GAL::DrawSegment() - void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ) override; + void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, + double aWidth ) override; /// @copydoc GAL::DrawCircle() void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) override; @@ -90,19 +90,27 @@ public: /// @copydoc GAL::DrawPolyline() void DrawPolyline( const std::deque& aPointList ) override { drawPoly( aPointList ); } - void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) override { drawPoly( aPointList, aListSize ); } + void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) override + { + drawPoly( aPointList, aListSize ); + } + void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) override { drawPoly( aLineChain ); } /// @copydoc GAL::DrawPolygon() void DrawPolygon( const std::deque& aPointList ) override { drawPoly( aPointList ); } - void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) override { drawPoly( aPointList, aListSize ); } + void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) override + { + drawPoly( aPointList, aListSize ); + } + void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) override; void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) override; /// @copydoc GAL::DrawCurve() void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA, - const VECTOR2D& controlPointB, const VECTOR2D& endPoint, - double aFilterValue = 0.0 ) override; + const VECTOR2D& controlPointB, const VECTOR2D& endPoint, + double aFilterValue = 0.0 ) override; /// @copydoc GAL::DrawBitmap() void DrawBitmap( const BITMAP_BASE& aBitmap ) override; @@ -111,7 +119,7 @@ public: // Screen methods // -------------- - /// @brief Resizes the canvas. + /// Resizes the canvas. void ResizeScreen( int aWidth, int aHeight ) override; /// @copydoc GAL::Flush() @@ -215,14 +223,18 @@ protected: const VECTOR2D xform( double x, double y ); // rotation, scale and offset const VECTOR2D xform( const VECTOR2D& aP ); // rotation, scale and offset - /** Transform according to the rotation from currentWorld2Screen transform matrix: - * @param aAngle is the angle in radians to transform - * @return the modified angle + /** + * Transform according to the rotation from currentWorld2Screen transform matrix. + * + * @param aAngle is the angle in radians to transform. + * @return the modified angle. */ const double angle_xform( const double aAngle ); - /** Transform according to the rotation from currentWorld2Screen transform matrix - * for the start angle and the end angle of an arc + /** + * Transform according to the rotation from currentWorld2Screen transform matrix + * for the start angle and the end angle of an arc. + * * @param aStartAngle is the arc starting point in radians to transform * @param aEndAngle is the arc ending point in radians to transform */ @@ -237,7 +249,7 @@ protected: void resetContext(); /** - * @brief Draw a grid line (usually a simplified line function). + * Draw a grid line (usually a simplified line function). * * @param aStartPoint is the start point of the line. * @param aEndPoint is the end point of the line. @@ -247,6 +259,31 @@ protected: void drawGridPoint( const VECTOR2D& aPoint, double aWidth, double aHeight ); void drawAxes( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ); + + void flushPath(); + void storePath(); ///< Store the actual path + + /** + * Blits cursor into the current screen. + */ + void blitCursor( wxMemoryDC& clientDC ); + + /// Drawing polygons & polylines is the same in cairo, so here is the common code + void drawPoly( const std::deque& aPointList ); + void drawPoly( const VECTOR2D aPointList[], int aListSize ); + void drawPoly( const SHAPE_LINE_CHAIN& aLineChain ); + + /** + * Returns a valid key that can be used as a new group number. + * + * @return An unique group number that is not used by any other group. + */ + unsigned int getNewGroupNumber(); + + void syncLineWidth( bool aForceWidth = false, double aWidth = 0.0 ); + void updateWorldScreenMatrix(); + const VECTOR2D roundp( const VECTOR2D& v ); + /// Super class definition typedef GAL super; @@ -307,32 +344,6 @@ protected: std::vector imageSurfaces; std::vector xformStack; - - void flushPath(); - void storePath(); ///< Store the actual path - - /** - * @brief Blits cursor into the current screen. - */ - void blitCursor( wxMemoryDC& clientDC ); - - /// Drawing polygons & polylines is the same in cairo, so here is the common code - void drawPoly( const std::deque& aPointList ); - void drawPoly( const VECTOR2D aPointList[], int aListSize ); - void drawPoly( const SHAPE_LINE_CHAIN& aLineChain ); - - /** - * @brief Returns a valid key that can be used as a new group number. - * - * @return An unique group number that is not used by any other group. - */ - unsigned int getNewGroupNumber(); - - void syncLineWidth( bool aForceWidth = false, double aWidth = 0.0 ); - void updateWorldScreenMatrix(); - const VECTOR2D roundp( const VECTOR2D& v ); - - /// Format used to store pixels static constexpr cairo_format_t GAL_FORMAT = CAIRO_FORMAT_ARGB32; }; @@ -342,23 +353,19 @@ class CAIRO_GAL : public CAIRO_GAL_BASE, public wxWindow { public: /** - * Constructor CAIRO_GAL_BASE - * * @param aParent is the wxWidgets immediate wxWindow parent of this object. + * @param aMouseListener is the wxEvtHandler that should receive the mouse events, this + * can be can be any wxWindow, but is often a wxFrame container. + * @param aPaintListener is the wxEvtHandler that should receive the paint event. This + * can be any wxWindow, but is often a derived instance of this + * class or a containing wxFrame. The "paint event" here is a + * wxCommandEvent holding EVT_GAL_REDRAW, as sent by PostPaint(). * - * @param aMouseListener is the wxEvtHandler that should receive the mouse events, - * this can be can be any wxWindow, but is often a wxFrame container. - * - * @param aPaintListener is the wxEvtHandler that should receive the paint - * event. This can be any wxWindow, but is often a derived instance - * of this class or a containing wxFrame. The "paint event" here is - * a wxCommandEvent holding EVT_GAL_REDRAW, as sent by PostPaint(). - * - * @param aName is the name of this window for use by wxWindow::FindWindowByName() + * @param aName is the name of this window for use by wxWindow::FindWindowByName(). */ - CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, - wxWindow* aParent, wxEvtHandler* aMouseListener = NULL, - wxEvtHandler* aPaintListener = NULL, const wxString& aName = wxT( "CairoCanvas" ) ); + CAIRO_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent, + wxEvtHandler* aMouseListener = nullptr, wxEvtHandler* aPaintListener = nullptr, + const wxString& aName = wxT( "CairoCanvas" ) ); ~CAIRO_GAL(); @@ -383,10 +390,10 @@ public: void ClearTarget( RENDER_TARGET aTarget ) override; /** - * Function PostPaint - * posts an event to m_paint_listener. A post is used so that the actual drawing - * function can use a device context type that is not specific to the wxEVT_PAINT event, - * just by changing the PostPaint code. + * Post an event to m_paint_listener. + * + * A post is used so that the actual drawing function can use a device context type that + * is not specific to the wxEVT_PAINT event, just by changing the PostPaint code. */ void PostPaint( wxPaintEvent& aEvent ); @@ -400,28 +407,6 @@ public: paintListener = aPaintListener; } -protected: - // Compositor related variables - std::shared_ptr compositor; ///< Object for layers compositing - unsigned int mainBuffer; ///< Handle to the main buffer - unsigned int overlayBuffer; ///< Handle to the overlay buffer - RENDER_TARGET currentTarget; ///< Current rendering target - bool validCompositor; ///< Compositor initialization flag - - // Variables related to wxWidgets - wxWindow* parentWindow; ///< Parent window - wxEvtHandler* mouseListener; ///< Mouse listener - wxEvtHandler* paintListener; ///< Paint listener - unsigned int bufferSize; ///< Size of buffers cairoOutput, bitmapBuffers - unsigned char* wxOutput; ///< wxImage comaptible buffer - - // Variables related to Cairo <-> wxWidgets - unsigned char* bitmapBuffer; ///< Storage of the cairo image - int stride; ///< Stride value for Cairo - int wxBufferWidth; - bool isInitialized; ///< Are Cairo image & surface ready to use - COLOR4D backgroundColor; ///< Background color - /// @copydoc GAL::BeginDrawing() void beginDrawing() override; @@ -445,14 +430,14 @@ protected: // Event handlers /** - * @brief Paint event handler. + * Paint event handler. * * @param aEvent is the paint event. */ void onPaint( wxPaintEvent& aEvent ); /** - * @brief Mouse event handler, forwards the event to the child. + * Mouse event handler, forwards the event to the child. * * @param aEvent is the mouse event to be forwarded. */ @@ -460,6 +445,28 @@ protected: ///> Cairo-specific update handlers bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) override; + +protected: + // Compositor related variables + std::shared_ptr compositor; ///< Object for layers compositing + unsigned int mainBuffer; ///< Handle to the main buffer + unsigned int overlayBuffer; ///< Handle to the overlay buffer + RENDER_TARGET currentTarget; ///< Current rendering target + bool validCompositor; ///< Compositor initialization flag + + // Variables related to wxWidgets + wxWindow* parentWindow; ///< Parent window + wxEvtHandler* mouseListener; ///< Mouse listener + wxEvtHandler* paintListener; ///< Paint listener + unsigned int bufferSize; ///< Size of buffers cairoOutput, bitmapBuffers + unsigned char* wxOutput; ///< wxImage compatible buffer + + // Variables related to Cairo <-> wxWidgets + unsigned char* bitmapBuffer; ///< Storage of the cairo image + int stride; ///< Stride value for Cairo + int wxBufferWidth; + bool isInitialized; ///< Are Cairo image & surface ready to use + COLOR4D backgroundColor; ///< Background color }; } // namespace KIGFX diff --git a/include/gal/cairo/cairo_print.h b/include/gal/cairo/cairo_print.h index 9c363a81de..6106b14bf3 100644 --- a/include/gal/cairo/cairo_print.h +++ b/include/gal/cairo/cairo_print.h @@ -1,5 +1,7 @@ /* * Copyright (C) 2018 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * Author: Maciej Suminski * Author: Tomasz Wlostowski * @@ -29,7 +31,8 @@ class wxGCDC; namespace KIGFX { /** - * CAIRO_PRINT_CTX provides a Cairo context created from wxPrintDC. + * Provide a Cairo context created from wxPrintDC. + * * It allows one to prepare printouts using the Cairo library and let wxWidgets handle the rest. */ class CAIRO_PRINT_CTX : public PRINT_CONTEXT @@ -80,7 +83,7 @@ class CAIRO_PRINT_GAL : public CAIRO_GAL_BASE, public GAL_PRINT { public: CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, - std::unique_ptr aContext ); + std::unique_ptr aContext ); void ComputeWorldScreenMatrix() override; @@ -96,8 +99,8 @@ public: /** * @param aSize is the printing sheet size expressed in inches. - * @param aRotateIfLandscape true if the platform requires 90 degrees - * rotation in order to print in landscape format. + * @param aRotateIfLandscape true if the platform requires 90 degrees rotation in order + * to print in landscape format. */ void SetNativePaperSize( const VECTOR2D& aSize, bool aRotateIfLandscape ) override; diff --git a/include/gal/color4d.h b/include/gal/color4d.h index 35033aafa9..47da07adff 100644 --- a/include/gal/color4d.h +++ b/include/gal/color4d.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de - * Copyright (C) 2017-2019 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2020 Kicad Developers, see AUTHORS.txt for contributors. * * Color class * @@ -36,8 +36,7 @@ #endif /** - * Legacy color enumeration. Also contains a flag and the alpha value in - * the upper bits + * Legacy color enumeration. Also contains a flag and the alpha value in the upper bits */ enum EDA_COLOR_T { @@ -94,8 +93,7 @@ const StructColors* colorRefs(); namespace KIGFX { /** - * COLOR4D - * is the color representation with 4 components: red, green, blue, alpha. + * A color representation with 4 components: red, green, blue, alpha. */ class COLOR4D { @@ -107,8 +105,6 @@ public: } /** - * @brief Constructor - * * @param aRed is the red component [0.0 .. 1.0]. * @param aGreen is the green component [0.0 .. 1.0]. * @param aBlue is the blue component [0.0 .. 1.0]. @@ -124,34 +120,31 @@ public: } /** - * @brief Constructor - * * @param aColor is one of KiCad's palette colors. * @see EDA_COLOR_T */ COLOR4D( EDA_COLOR_T aColor ); /** - * Initializes the color from a RGBA value with 0-255 red/green/blue and 0-1 alpha. - * Suitable for taking the values directly from the "CSS syntax" from ToWxString - * @return this color + * Initialize the color from a RGBA value with 0-255 red/green/blue and 0-1 alpha. + * + * Suitable for taking the values directly from the "CSS syntax" from ToWxString. + * + * @return this color. */ COLOR4D& FromCSSRGBA( int aRed, int aGreen, int aBlue, double aAlpha = 1.0 ); #ifdef WX_COMPATIBILITY /** - * @brief Constructor - * * @param aColor is the color type used by wxWidgets. */ COLOR4D( const wxColour& aColor ); /** - * Function SetFromWxString - * Sets color values by parsing a string using wxColour::Set() + * Set color values by parsing a string using wxColour::Set(). * - * @param aColorString is a color string that wxColour can understand - * @return true if color was set successfully + * @param aColorString is a color string that wxColour can understand. + * @return true if color was set successfully. */ bool SetFromWxString( const wxString& aColorString ); @@ -160,12 +153,10 @@ public: wxColour ToColour() const; /** - * Function LegacyMix() - * Mixes this COLOR4D with an input COLOR4D using the OR-mixing of legacy canvas. + * Mix this COLOR4D with an input COLOR4D using the OR-mixing of legacy canvas. * - * Can be removed once legacy canvas is removed. - * Depends on wxColour for simplicity, but could be re-written to avoid - * this dependency if desired. + * Can be removed once legacy canvas is removed. Depends on wxColour for simplicity, + * but could be re-written to avoid this dependency if desired. * * @param aColor The color to mix with this one */ @@ -173,22 +164,22 @@ public: /** * Packs the color into an unsigned int for compatibility with legacy canvas. - * Note that this is a lossy downsampling and also that the alpha channel is lost. + * + * @note This is a lossy downsampling and also that the alpha channel is lost. */ unsigned int ToU32() const; /** - * Unpacks from a unsigned int in the legacy EDA_COLOR_T format. + * Unpack from a unsigned int in the legacy EDA_COLOR_T format. */ void FromU32( unsigned int aPackedColor ); #endif /* WX_COMPATIBLITY */ /** - * Function ToHSL() * Converts current color (stored in RGB) to HSL format. * - * @param aOutHue is the conversion result for hue component, in degrees 0 ... 360.0 + * @param aOutHue is the conversion result for hue component, in degrees 0 ... 360.0. * @param aOutSaturation is the conversion result for saturation component (0 ... 1.0). * @param aOutLightness is conversion result for value component (0 ... 1.0). * @note saturation is set to 0.0 for black color if r = g = b, @@ -196,18 +187,17 @@ public: void ToHSL( double& aOutHue, double& aOutSaturation, double& aOutValue ) const; /** - * Function FromHSL() - * Changes currently used color to the one given by hue, saturation and lightness parameters. + * Change currently used color to the one given by hue, saturation and lightness parameters. * - * @param aInHue is hue component, in degrees (0.0 - 360.0) - * @param aInSaturation is saturation component (0.0 - 1.0) - * @param aInLightness is lightness component (0.0 - 1.0) + * @param aInHue is hue component, in degrees (0.0 - 360.0). + * @param aInSaturation is saturation component (0.0 - 1.0). + * @param aInLightness is lightness component (0.0 - 1.0). */ void FromHSL( double aInHue, double aInSaturation, double aInLightness ); /** - * Function Brighten * Makes the color brighter by a given factor. + * * @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0). * @return COLOR4D& Brightened color. */ @@ -223,8 +213,8 @@ public: } /** - * Function Darken * Makes the color darker by a given factor. + * * @param aFactor Specifies how dark the color should become (valid values: 0.0 .. 1.0). * @return COLOR4D& Darkened color. */ @@ -240,8 +230,8 @@ public: } /** - * Function Invert * Makes the color inverted, alpha remains the same. + * * @return COLOR4D& Inverted color. */ COLOR4D& Invert() @@ -259,8 +249,8 @@ public: COLOR4D& Saturate( double aFactor ); /** - * Function Brightened - * Returns a color that is brighter by a given factor, without modifying object. + * Return a color that is brighter by a given factor, without modifying object. + * * @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0). * @return COLOR4D Highlighted color. */ @@ -268,15 +258,13 @@ public: { assert( aFactor >= 0.0 && aFactor <= 1.0 ); - return COLOR4D( r * ( 1.0 - aFactor ) + aFactor, - g * ( 1.0 - aFactor ) + aFactor, - b * ( 1.0 - aFactor ) + aFactor, - a ); + return COLOR4D( r * ( 1.0 - aFactor ) + aFactor, g * ( 1.0 - aFactor ) + aFactor, + b * ( 1.0 - aFactor ) + aFactor, a ); } /** - * Function Darkened - * Returns a color that is darker by a given factor, without modifying object. + * Return a color that is darker by a given factor, without modifying object. + * * @param aFactor Specifies how dark the color should become (valid values: 0.0 .. 1.0). * @return COLOR4D Darkened color. */ @@ -284,15 +272,12 @@ public: { assert( aFactor >= 0.0 && aFactor <= 1.0 ); - return COLOR4D( r * ( 1.0 - aFactor ), - g * ( 1.0 - aFactor ), - b * ( 1.0 - aFactor ), - a ); + return COLOR4D( r * ( 1.0 - aFactor ), g * ( 1.0 - aFactor ), b * ( 1.0 - aFactor ), a ); } /** - * Function Mix - * Returns a color that is mixed with the input by a factor + * Return a color that is mixed with the input by a factor. + * * @param aFactor Specifies how much of the original color to keep (valid values: 0.0 .. 1.0). * @return COLOR4D Mixed color. */ @@ -307,8 +292,8 @@ public: } /** - * Function WithAlpha - * Returns a colour with the same colour, but the given alpha + * Return a color with the same color, but the given alpha. + * * @param aAlpha specifies the alpha of the new color * @return COLOR4D color with that alpha */ @@ -320,8 +305,8 @@ public: } /** - * Function Inverted * Returns an inverted color, alpha remains the same. + * * @return COLOR4D& Inverted color. */ COLOR4D Inverted() const @@ -330,8 +315,8 @@ public: } /** - * Function GetBrightness * Returns the brightness value of the color ranged from 0.0 to 1.0. + * * @return The brightness value. */ double GetBrightness() const @@ -341,22 +326,21 @@ public: } /** - * Function ToHSV() - * Converts current color (stored in RGB) to HSV format. + * Convert current color (stored in RGB) to HSV format. * - * @param aOutHue is the conversion result for hue component, in degrees 0 ... 360.0 + * @param aOutHue is the conversion result for hue component, in degrees 0 ... 360.0. * @param aOutSaturation is the conversion result for saturation component (0 ... 1.0). * @param aOutValue is conversion result for value component (0 ... 1.0). * @param aAlwaysDefineHue controls the way hue is defined when r = v = b * @note saturation is set to 0.0 for black color (r = v = b = 0), and if r = v = b, * hue is set to 0.0 if aAlwaysDefineHue = true, and set to NAN if aAlwaysDefineHue = false. - * this option is usefull to convert a 4D color to a legacy color, because Red has hue = 0, + * this option is useful to convert a 4D color to a legacy color, because Red has hue = 0, * therefore aAlwaysDefineHue = false makes difference between Red and Gray colors. */ - void ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue, bool aAlwaysDefineHue = false ) const; + void ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue, + bool aAlwaysDefineHue = false ) const; /** - * Function FromHSV() * Changes currently used color to the one given by hue, saturation and value parameters. * * @param aInH is hue component, in degrees. diff --git a/include/gal/compositor.h b/include/gal/compositor.h index 9e68397efc..3e67f74f26 100644 --- a/include/gal/compositor.h +++ b/include/gal/compositor.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2020 Kicad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -33,7 +35,6 @@ namespace KIGFX { - class COLOR4D; class COMPOSITOR @@ -49,14 +50,12 @@ public: } /** - * Function Reset() - * performs primary initialiation, necessary to use the object. + * Perform primary initialization, necessary to use the object. */ virtual void Initialize() = 0; /** - * Function Resize() - * clears the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions. + * Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions. * * @param aWidth is the framebuffer width (in pixels). * @param aHeight is the framebuffer height (in pixels). @@ -64,53 +63,47 @@ public: virtual void Resize( unsigned int aWidth, unsigned int aHeight ) = 0; /** - * Function CreateBuffer() - * prepares a new buffer that may be used as a rendering target. + * Prepare a new buffer that may be used as a rendering target. * * @return is the handle of the buffer. In case of failure 0 (zero) is returned as the handle. */ virtual unsigned int CreateBuffer() = 0; /** - * Function GetBuffer() - * returns currently used buffer handle. + * Return currently used buffer handle. * * @return Currently used buffer handle. */ virtual unsigned int GetBuffer() const = 0; /** - * Function SetBuffer() - * sets the selected buffer as the rendering target. All the following drawing functions are - * going to be rendered in the selected buffer. + * Set the selected buffer as the rendering target. + * + * All the following drawing functions are going to be rendered in the selected buffer. * * @param aBufferHandle is the handle of the buffer or 0 in case of rendering directly to the - * display. + * display. */ virtual void SetBuffer( unsigned int aBufferHandle ) = 0; /** - * Function ClearBuffer() - * clears the selected buffer (set by the SetBuffer() function). + * Clear the selected buffer (set by the SetBuffer() function). */ virtual void ClearBuffer( const COLOR4D& aColor ) = 0; /** - * Function Begin() - * Call this at the beginning of each frame + * Call this at the beginning of each frame. */ virtual void Begin() = 0; /** - * Function DrawBuffer() - * draws the selected buffer to the output buffer. + * Draw the selected buffer to the output buffer. * * @param aBufferHandle is the handle of the buffer to be drawn. */ virtual void DrawBuffer( unsigned int aBufferHandle ) = 0; /** - * Function Present() * Call this to present the output buffer to the screen. */ virtual void Present() = 0; diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 9c2c0ebea6..24645190b1 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de - * Copyright (C) 2016-2017 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. * * Graphics Abstraction Layer (GAL) - base class * @@ -47,13 +47,13 @@ namespace KIGFX { /** - * @brief Class GAL is the abstract interface for drawing on a 2D-surface. + * Class GAL is the abstract interface for drawing on a 2D-surface. * * The functions are optimized for drawing shapes of an EDA-program such as KiCad. Most methods - * are abstract and need to be implemented by a lower layer, for example by a cairo or OpenGL implementation. - *
- * Almost all methods use world coordinates as arguments. The board design is defined in world space units; - * for drawing purposes these are transformed to screen units with this layer. So zooming is handled here as well. + * are abstract and need to be implemented by a lower layer, for example by a cairo or OpenGL + * implementation. Almost all methods use world coordinates as arguments. The board design is + * defined in world space units for drawing purposes these are transformed to screen units with + * this layer. So zooming is handled here as well. * */ class GAL : GAL_DISPLAY_OPTIONS_OBSERVER @@ -69,16 +69,16 @@ public: GAL( GAL_DISPLAY_OPTIONS& aOptions ); virtual ~GAL(); - /// @brief Returns the initalization status for the canvas. + /// Returns the initialization status for the canvas. virtual bool IsInitialized() const { return true; } - /// @brief Returns true if the GAL canvas is visible on the screen. + /// Returns true if the GAL canvas is visible on the screen. virtual bool IsVisible() const { return true; } - /// @brief Returns true if the GAL engine is a cairo based type. + /// Returns true if the GAL engine is a cairo based type. virtual bool IsCairoEngine() { return false; } - /// @brief Returns true if the GAL engine is a opengl based type. + /// Returns true if the GAL engine is a OpenGL based type. virtual bool IsOpenGlEngine() { return false; } // --------------- @@ -86,7 +86,7 @@ public: // --------------- /** - * @brief Draw a line. + * Draw a line. * * Start and end points are defined as 2D-Vectors. * @@ -96,7 +96,7 @@ public: virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {}; /** - * @brief Draw a rounded segment. + * Draw a rounded segment. * * Start and end points are defined as 2D-Vectors. * @@ -104,10 +104,11 @@ public: * @param aEndPoint is the end point of the segment. * @param aWidth is a width of the segment */ - virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ) {}; + virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, + double aWidth ) {}; /** - * @brief Draw a polyline + * Draw a polyline * * @param aPointList is a list of 2D-Vectors containing the polyline points. */ @@ -116,7 +117,7 @@ public: virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {}; /** - * @brief Draw a circle using world coordinates. + * Draw a circle using world coordinates. * * @param aCenterPoint is the center point of the circle. * @param aRadius is the radius of the circle. @@ -124,7 +125,7 @@ public: virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {}; /** - * @brief Draw an arc. + * Draw an arc. * * @param aCenterPoint is the center point of the arc. * @param aRadius is the arc radius. @@ -132,10 +133,11 @@ public: * @param aEndAngle is the end angle of the arc. */ virtual void - DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle ) {}; + DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, + double aEndAngle ) {}; /** - * @brief Draw an arc segment. + * Draw an arc segment. * * This method differs from DrawArc() in what happens when fill/stroke are on or off. * DrawArc() draws a "pie piece" when fill is turned on, and a thick stroke when fill is off. @@ -152,10 +154,10 @@ public: */ virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, - double aEndAngle, double aWidth ) {}; + double aEndAngle, double aWidth ) {}; /** - * @brief Draw a rectangle. + * Draw a rectangle. * * @param aStartPoint is the start point of the rectangle. * @param aEndPoint is the end point of the rectangle. @@ -163,7 +165,7 @@ public: virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {}; /** - * @brief Draw a polygon. + * Draw a polygon. * * @param aPointList is the list of the polygon points. */ @@ -173,7 +175,7 @@ public: virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {}; /** - * @brief Draw a cubic bezier spline. + * Draw a cubic bezier spline. * * @param startPoint is the start point of the spline. * @param controlPointA is the first control point. @@ -188,7 +190,7 @@ public: double aFilterValue = 0.0 ) {}; /** - * @brief Draw a bitmap image. + * Draw a bitmap image. */ virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {}; @@ -196,19 +198,19 @@ public: // Screen methods // -------------- - /// @brief Resizes the canvas. + /// Resizes the canvas. virtual void ResizeScreen( int aWidth, int aHeight ) {}; - /// @brief Shows/hides the GAL canvas + /// Shows/hides the GAL canvas virtual bool Show( bool aShow ) { return true; }; - /// @brief Returns GAL canvas size in pixels + /// Returns GAL canvas size in pixels const VECTOR2I& GetScreenPixelSize() const { return screenSize; } - /// @brief Force all remaining objects to be drawn. + /// Force all remaining objects to be drawn. virtual void Flush() {}; void SetClearColor( const COLOR4D& aColor ) @@ -222,7 +224,8 @@ public: } /** - * @brief Clear the screen. + * Clear the screen. + * * @param aColor is the color used for clearing. */ virtual void ClearScreen() {}; @@ -232,7 +235,7 @@ public: // ----------------- /** - * @brief Enable/disable fill. + * Enable/disable fill. * * @param aIsFillEnabled is true, when the graphics objects should be filled, else false. */ @@ -242,7 +245,7 @@ public: } /** - * @brief Enable/disable stroked outlines. + * Enable/disable stroked outlines. * * @param aIsStrokeEnabled is true, if the outline of an object should be stroked. */ @@ -252,7 +255,7 @@ public: } /** - * @brief Set the fill color. + * Set the fill color. * * @param aColor is the color for filling. */ @@ -262,7 +265,7 @@ public: } /** - * @brief Get the fill color. + * Get the fill color. * * @return the color for filling a outline. */ @@ -272,7 +275,7 @@ public: } /** - * @brief Set the stroke color. + * Set the stroke color. * * @param aColor is the color for stroking the outline. */ @@ -282,7 +285,7 @@ public: } /** - * @brief Get the stroke color. + * Get the stroke color. * * @return the color for stroking the outline. */ @@ -292,7 +295,7 @@ public: } /** - * @brief Set the line width. + * Set the line width. * * @param aLineWidth is the line width. */ @@ -302,7 +305,7 @@ public: } /** - * @brief Get the line width. + * Get the line width. * * @return the actual line width. */ @@ -312,7 +315,7 @@ public: } /** - * @brief Set the depth of the layer (position on the z-axis) + * Set the depth of the layer (position on the z-axis) * * @param aLayerDepth the layer depth for the objects. */ @@ -334,7 +337,7 @@ public: } /** - * @brief Draws a vector type text using preloaded Newstroke font. + * Draws a vector type text using preloaded Newstroke font. * * @param aText is the text to be drawn. * @param aPosition is the text position in world coordinates. @@ -347,7 +350,7 @@ public: } /** - * @brief Draws a text using a bitmap font. It should be faster than StrokeText(), + * Draws a text using a bitmap font. It should be faster than StrokeText(), * but can be used only for non-Gerber elements. * * @param aText is the text to be drawn. @@ -370,7 +373,7 @@ public: } /** - * @brief Compute the X and Y size of a given text. The text is expected to be + * Compute the X and Y size of a given text. The text is expected to be * a only one line text. * * @param aText is the text string (one line). @@ -379,7 +382,7 @@ public: VECTOR2D GetTextLineSize( const UTF8& aText ) const; /** - * @brief Loads attributes of the given text (bold/italic/underline/mirrored and so on). + * Loads attributes of the given text (bold/italic/underline/mirrored and so on). * * @param aText is the text item. */ @@ -394,7 +397,7 @@ public: void ResetTextAttributes(); /** - * @brief Set the font glyph size. + * Set the font glyph size. * * @param aGlyphSize is the new font glyph size. */ @@ -402,7 +405,7 @@ public: const VECTOR2D& GetGlyphSize() const { return textProperties.m_glyphSize; } /** - * @brief Set bold property of current font. + * Set bold property of current font. * * @param aBold tells if the font should be bold or not. */ @@ -410,7 +413,7 @@ public: inline bool IsFontBold() const { return textProperties.m_bold; } /** - * @brief Set italic property of current font. + * Set italic property of current font. * * @param aItalic tells if the font should be italic or not. */ @@ -421,7 +424,7 @@ public: inline bool IsFontUnderlined() const { return textProperties.m_underlined; } /** - * @brief Set a mirrored property of text. + * Set a mirrored property of text. * * @param aMirrored tells if the text should be mirrored or not. */ @@ -429,7 +432,7 @@ public: inline bool IsTextMirrored() const { return textProperties.m_mirrored; } /** - * @brief Set the horizontal justify for text drawing. + * Set the horizontal justify for text drawing. * * @param aHorizontalJustify is the horizontal justify value. */ @@ -439,7 +442,7 @@ public: } /** - * @brief Returns current text horizontal justification setting. + * Returns current text horizontal justification setting. */ inline EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const { @@ -447,7 +450,7 @@ public: } /** - * @brief Set the vertical justify for text drawing. + * Set the vertical justify for text drawing. * * @param aVerticalJustify is the vertical justify value. */ @@ -457,7 +460,7 @@ public: } /** - * @brief Returns current text vertical justification setting. + * Returns current text vertical justification setting. */ inline EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const { @@ -470,37 +473,37 @@ public: // -------------- /** - * @brief Transform the context. + * Transform the context. * * @param aTransformation is the transformation matrix. */ virtual void Transform( const MATRIX3x3D& aTransformation ) {}; /** - * @brief Rotate the context. + * Rotate the context. * * @param aAngle is the rotation angle in radians. */ virtual void Rotate( double aAngle ) {}; /** - * @brief Translate the context. + * Translate the context. * * @param aTranslation is the translation vector. */ virtual void Translate( const VECTOR2D& aTranslation ) {}; /** - * @brief Scale the context. + * Scale the context. * * @param aScale is the scale factor for the x- and y-axis. */ virtual void Scale( const VECTOR2D& aScale ) {}; - /// @brief Save the context. + /// Save the context. virtual void Save() {}; - /// @brief Restore the context. + /// Restore the context. virtual void Restore() {}; // -------------------------------------------- @@ -508,7 +511,7 @@ public: // --------------------------------------------- /** - * @brief Begin a group. + * Begin a group. * * A group is a collection of graphic items. * Hierarchical groups are possible, attributes and transformations can be used. @@ -517,18 +520,18 @@ public: */ virtual int BeginGroup() { return 0; }; - /// @brief End the group. + /// End the group. virtual void EndGroup() {}; /** - * @brief Draw the stored group. + * Draw the stored group. * * @param aGroupNumber is the group number. */ virtual void DrawGroup( int aGroupNumber ) {}; /** - * @brief Changes the color used to draw the group. + * Changes the color used to draw the group. * * @param aGroupNumber is the group number. * @param aNewColor is the new color. @@ -536,7 +539,7 @@ public: virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {}; /** - * @brief Changes the depth (Z-axis position) of the group. + * Changes the depth (Z-axis position) of the group. * * @param aGroupNumber is the group number. * @param aDepth is the new depth. @@ -544,14 +547,14 @@ public: virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {}; /** - * @brief Delete the group from the memory. + * Delete the group from the memory. * * @param aGroupNumber is the group number. */ virtual void DeleteGroup( int aGroupNumber ) {}; /** - * @brief Delete all data created during caching of graphic items. + * Delete all data created during caching of graphic items. */ virtual void ClearCache() {}; @@ -559,11 +562,11 @@ public: // Handling the world <-> screen transformation // -------------------------------------------------------- - /// @brief Compute the world <-> screen transformation matrix + /// Compute the world <-> screen transformation matrix virtual void ComputeWorldScreenMatrix(); /** - * @brief Get the world <-> screen transformation matrix. + * Get the world <-> screen transformation matrix. * * @return the transformation matrix. */ @@ -573,7 +576,7 @@ public: } /** - * @brief Get the screen <-> world transformation matrix. + * Get the screen <-> world transformation matrix. * * @return the transformation matrix. */ @@ -583,7 +586,7 @@ public: } /** - * @brief Set the world <-> screen transformation matrix. + * Set the world <-> screen transformation matrix. * * @param aMatrix is the 3x3 world <-> screen transformation matrix. */ @@ -593,7 +596,7 @@ public: } /** - * @brief Set the unit length. + * Set the unit length. * * This defines the length [inch] per one integer. For instance a value 0.001 means * that the coordinate [1000, 1000] corresponds with a point at (1 inch, 1 inch) or @@ -612,7 +615,7 @@ public: } /** - * @brief Set the dots per inch of the screen. + * Set the dots per inch of the screen. * * This value depends on the user screen, it should be configurable by the application. * For instance a typical notebook with HD+ resolution (1600x900) has 106 DPI. @@ -625,7 +628,7 @@ public: } /** - * @brief Set the Point in world space to look at. + * Set the Point in world space to look at. * * This point corresponds with the center of the actual drawing area. * @@ -637,7 +640,7 @@ public: } /** - * @brief Get the look at point. + * Get the look at point. * * @return the look at point. */ @@ -647,7 +650,7 @@ public: } /** - * @brief Set the zoom factor of the scene. + * Set the zoom factor of the scene. * * @param aZoomFactor is the zoom factor. */ @@ -657,7 +660,7 @@ public: } /** - * @brief Get the zoom factor + * Get the zoom factor * * @return the zoom factor. */ @@ -667,7 +670,7 @@ public: } /** - * @brief Set the rotation angle. + * Set the rotation angle. * * @param aRotation is the new rotation angle (radians). */ @@ -687,12 +690,12 @@ public: } /** - * @brief Set the range of the layer depth. + * Set the range of the layer depth. * * Usually required for the OpenGL implementation, any object outside this range is not drawn. * * @param aDepthRange is the depth range where component x is the near clipping plane and y - * is the far clipping plane. + * is the far clipping plane. */ inline void SetDepthRange( const VECTOR2D& aDepthRange ) { @@ -700,7 +703,7 @@ public: } /** - * @brief Returns the minimum depth in the currently used range (the top). + * Returns the minimum depth in the currently used range (the top). */ inline double GetMinDepth() const { @@ -708,7 +711,7 @@ public: } /** - * @brief Returns the maximum depth in the currently used range (the bottom). + * Returns the maximum depth in the currently used range (the bottom). */ inline double GetMaxDepth() const { @@ -716,7 +719,7 @@ public: } /** - * @brief Get the world scale. + * Get the world scale. * * @return the actual world scale factor. */ @@ -726,7 +729,7 @@ public: } /** - * @brief Sets flipping of the screen. + * Sets flipping of the screen. * * @param xAxis is the flip flag for the X axis. * @param yAxis is the flip flag for the Y axis. @@ -758,28 +761,28 @@ public: // --------------------------- /** - * @brief Sets the target for rendering. + * Sets the target for rendering. * * @param aTarget is the new target for rendering. */ virtual void SetTarget( RENDER_TARGET aTarget ) {}; /** - * @brief Gets the currently used target for rendering. + * Gets the currently used target for rendering. * * @return The current rendering target. */ virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; }; /** - * @brief Clears the target for rendering. + * Clears the target for rendering. * * @param aTarget is the target to be cleared. */ virtual void ClearTarget( RENDER_TARGET aTarget ) {}; /** - * @brief Returns true if the target exists. + * Returns true if the target exists. * * @param aTarget is the target to be checked. */ @@ -789,7 +792,7 @@ public: }; /** - * @brief Sets negative draw mode in the renderer + * Sets negative draw mode in the renderer * * When negative mode is enabled, drawn items will subtract from * previously drawn items. This is mainly needed for Gerber @@ -806,7 +809,7 @@ public: // ------------- /** - * @brief Sets the visibility setting of the grid. + * Sets the visibility setting of the grid. * * @param aVisibility is the new visibility setting of the grid. */ @@ -820,7 +823,7 @@ public: ( gridVisibility && options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID ) ); } /** - * @brief Set the origin point for the grid. + * Set the origin point for the grid. * * @param aGridOrigin is a vector containing the grid origin point, in world coordinates. */ @@ -841,7 +844,7 @@ public: } /** - * @brief Set the grid size. + * Set the grid size. * * @param aGridSize is a vector containing the grid size in x and y direction. */ @@ -858,7 +861,7 @@ public: } /** - * @brief Returns the grid size. + * Returns the grid size. * * @return A vector containing the grid size in x and y direction. */ @@ -868,7 +871,7 @@ public: } /** - * @brief Set the grid color. + * Set the grid color. * * @param aGridColor is the grid color, it should have a low alpha value for the best effect. */ @@ -878,7 +881,7 @@ public: } /** - * @brief Set the axes color. + * Set the axes color. * * @param aAxesColor is the color to draw the axes if enabled. */ @@ -888,7 +891,7 @@ public: } /** - * @brief Enables drawing the axes. + * Enables drawing the axes. */ inline void SetAxesEnabled( bool aAxesEnabled ) { @@ -896,7 +899,7 @@ public: } /** - * @brief Draw every tick line wider. + * Draw every tick line wider. * * @param aInterval increase the width of every aInterval line, if 0 do not use this feature. */ @@ -906,7 +909,7 @@ public: } /** - * @brief Get the grid line width. + * Get the grid line width. * * @return the grid line width */ @@ -915,11 +918,10 @@ public: return gridLineWidth; } - ///> @brief Draw the grid + ///> Draw the grid virtual void DrawGrid() {}; /** - * Function GetGridPoint() * For a given point it returns the nearest point belonging to the grid in world coordinates. * * @param aPoint is the point for which the grid point is searched. @@ -928,7 +930,7 @@ public: VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const; /** - * @brief Compute the point position in world coordinates from given screen coordinates. + * Compute the point position in world coordinates from given screen coordinates. * * @param aPoint the pointposition in screen coordinates. * @return the point position in world coordinates. @@ -939,7 +941,7 @@ public: } /** - * @brief Compute the point position in screen coordinates from given world coordinates. + * Compute the point position in screen coordinates from given world coordinates. * * @param aPoint the pointposition in world coordinates. * @return the point position in screen coordinates. @@ -950,7 +952,7 @@ public: } /** - * @brief Enable/disable cursor. + * Enable/disable cursor. * * @param aCursorEnabled is true if the cursor should be drawn, else false. */ @@ -960,7 +962,8 @@ public: } /** - * @brief Returns information about cursor visibility. + * Returns information about cursor visibility. + * * @return True if cursor is visible. */ bool IsCursorEnabled() const @@ -969,7 +972,7 @@ public: } /** - * @brief Set the cursor color. + * Set the cursor color. * * @param aCursorColor is the color of the cursor. */ @@ -979,14 +982,14 @@ public: } /** - * @brief Draw the cursor. + * Draw the cursor. * * @param aCursorPosition is the cursor position in screen coordinates. */ virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {}; /** - * @brief Changes the current depth to deeper, so it is possible to draw objects right beneath + * Changes the current depth to deeper, so it is possible to draw objects right beneath * other. */ inline void AdvanceDepth() @@ -995,7 +998,7 @@ public: } /** - * @brief Stores current drawing depth on the depth stack. + * Stores current drawing depth on the depth stack. */ inline void PushDepth() { @@ -1003,7 +1006,7 @@ public: } /** - * @brief Restores previously stored drawing depth for the depth stack. + * Restores previously stored drawing depth for the depth stack. */ inline void PopDepth() { @@ -1014,6 +1017,68 @@ public: virtual void EnableDepthTest( bool aEnabled = false ) {}; protected: + /// Private: use GAL_CONTEXT_LOCKER RAII object + virtual void lockContext( int aClientCookie ) {} + + virtual void unlockContext( int aClientCookie ) {} + + /// Enables item update mode. + /// Private: use GAL_UPDATE_CONTEXT RAII object + virtual void beginUpdate() {} + + /// Disables item update mode. + virtual void endUpdate() {} + + /// Begin the drawing, needs to be called for every new frame. + /// Private: use GAL_DRAWING_CONTEXT RAII object + virtual void beginDrawing() {}; + + /// End the drawing, needs to be called for every new frame. + /// Private: use GAL_DRAWING_CONTEXT RAII object + virtual void endDrawing() {}; + + /// Compute the scaling factor for the world->screen matrix + inline void computeWorldScale() + { + worldScale = screenDPI * worldUnitLength * zoomFactor; + } + + /** + * compute minimum grid spacing from the grid settings + * + * @return the minimum spacing to use for drawing the grid + */ + double computeMinGridSpacing() const; + + /// Possible depth range + static const int MIN_DEPTH; + static const int MAX_DEPTH; + + /// Depth level on which the grid is drawn + static const int GRID_DEPTH; + + /** + * Gets the actual cursor color to draw + */ + COLOR4D getCursorColor() const; + + // --------------- + // Settings observer interface + // --------------- + /** + * Handler for observer settings changes + */ + void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override; + + /** + * Handle updating display options. + * + * Derived classes should call up to this to set base-class methods. + * + * @return true if the new settings changed something. Derived classes can use this + * information to refresh themselves + */ + virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ); GAL_DISPLAY_OPTIONS& options; UTIL::LINK observerLink; @@ -1070,70 +1135,6 @@ protected: /// Instance of object that stores information about how to draw texts STROKE_FONT strokeFont; - /// Private: use GAL_CONTEXT_LOCKER RAII object - virtual void lockContext( int aClientCookie ) {} - - virtual void unlockContext( int aClientCookie ) {} - - /// @brief Enables item update mode. - /// Private: use GAL_UPDATE_CONTEXT RAII object - virtual void beginUpdate() {} - - /// @brief Disables item update mode. - virtual void endUpdate() {} - - /// @brief Begin the drawing, needs to be called for every new frame. - /// Private: use GAL_DRAWING_CONTEXT RAII object - virtual void beginDrawing() {}; - - /// @brief End the drawing, needs to be called for every new frame. - /// Private: use GAL_DRAWING_CONTEXT RAII object - virtual void endDrawing() {}; - - /// Compute the scaling factor for the world->screen matrix - inline void computeWorldScale() - { - worldScale = screenDPI * worldUnitLength * zoomFactor; - } - - /** - * @brief compute minimum grid spacing from the grid settings - * - * @return the minimum spacing to use for drawing the grid - */ - double computeMinGridSpacing() const; - - /// Possible depth range - static const int MIN_DEPTH; - static const int MAX_DEPTH; - - /// Depth level on which the grid is drawn - static const int GRID_DEPTH; - - /** - * Gets the actual cursor color to draw - */ - COLOR4D getCursorColor() const; - - // --------------- - // Settings observer interface - // --------------- - /** - * Handler for observer settings changes - */ - void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override; - - /** - * Function updatedGalDisplayOptions - * - * @brief handler for updated display options. Derived classes - * should call up to this to set base-class methods. - * - * @return true if the new settings changed something. Derived classes - * can use this information to refresh themselves - */ - virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ); - private: struct TEXT_PROPERTIES { diff --git a/include/gal/hidpi_gl_canvas.h b/include/gal/hidpi_gl_canvas.h index 58f69a2cb9..cf251073bc 100644 --- a/include/gal/hidpi_gl_canvas.h +++ b/include/gal/hidpi_gl_canvas.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2017 Bernhard Stegmaier - * Copyright (C) 2016-2017 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2016-2020 Kicad Developers, see AUTHORS.txt for contributors. * * Base class for HiDPI aware wxGLCanvas implementations. * @@ -31,7 +31,7 @@ /** - * @brief wxGLCanvas wrapper for HiDPI/Retina support. + * wxGLCanvas wrapper for HiDPI/Retina support. * * This is a small wrapper class to enable HiDPI/Retina support for wxGLCanvas. */ @@ -39,15 +39,10 @@ class HIDPI_GL_CANVAS : public wxGLCanvas { public: // wxGLCanvas constructor - HIDPI_GL_CANVAS( wxWindow *parent, - wxWindowID id = wxID_ANY, - const int *attribList = NULL, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - const wxPalette& palette = wxNullPalette ); - + HIDPI_GL_CANVAS( wxWindow *parent, wxWindowID id = wxID_ANY, const int *attribList = NULL, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = 0, const wxString& name = wxGLCanvasName, + const wxPalette& palette = wxNullPalette ); virtual wxSize GetNativePixelSize() const; diff --git a/include/gal/opengl/cached_container.h b/include/gal/opengl/cached_container.h index 70cd32e28a..41b9611b52 100644 --- a/include/gal/opengl/cached_container.h +++ b/include/gal/opengl/cached_container.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright 2013-2017 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -35,8 +37,9 @@ class VERTEX_ITEM; class SHADER; /** - * @brief Class to store VERTEX instances with caching. It associates VERTEX - * objects and with VERTEX_ITEMs. Caching vertices data in the memory and a + * Class to store VERTEX instances with caching. + * + * It associates VERTEX objects and with VERTEX_ITEMs. Caching vertices data in the memory and a * enables fast reuse of that data. */ @@ -67,12 +70,12 @@ public: virtual void Clear() override; /** - * Returns handle to the vertex buffer. It might be negative if the buffer is not initialized. + * Return handle to the vertex buffer. It might be negative if the buffer is not initialized. */ virtual unsigned int GetBufferHandle() const = 0; /** - * Returns true if vertex buffer is currently mapped. + * Return true if vertex buffer is currently mapped. */ virtual bool IsMapped() const = 0; @@ -90,7 +93,67 @@ protected: /// List of all the stored items typedef std::set ITEMS; - ///> Stores size & offset of free chunks. + /** + * Resize the chunk that stores the current item to the given size. The current item has + * its offset adjusted after the call, and the new chunk parameters are stored + * in m_chunkOffset and m_chunkSize. + * + * @param aSize is the requested chunk size. + * @return true in case of success, false otherwise. + */ + bool reallocate( unsigned int aSize ); + + /** + * Remove empty spaces between chunks and optionally resizes the container. + * + * After the operation there is continuous space for storing vertices at the end of the + * container. + * + * @param aNewSize is the new size of container, expressed in number of vertices. + * @return false in case of failure (e.g. memory shortage). + */ + virtual bool defragmentResize( unsigned int aNewSize ) = 0; + + /** + * Transfer all stored data to a new buffer, removing empty spaces between the data chunks + * in the container. + * + * @param aTarget is the destination for the defragmented data. + */ + void defragment( VERTEX* aTarget ); + + /** + * Look for consecutive free memory chunks and merges them, decreasing fragmentation of + * memory. + */ + void mergeFreeChunks(); + + /** + * Return the size of a chunk. + * + * @param aChunk is the chunk. + */ + inline int getChunkSize( const CHUNK& aChunk ) const + { + return aChunk.first; + } + + /** + * Return the offset of a chunk. + * + * @param aChunk is the chunk. + */ + inline unsigned int getChunkOffset( const CHUNK& aChunk ) const + { + return aChunk.second; + } + + /** + * Add a chunk marked as a free space. + */ + void addFreeChunk( unsigned int aOffset, unsigned int aSize ); + + ///> Store size & offset of free chunks. FREE_CHUNK_MAP m_freeChunks; ///> Stored VERTEX_ITEMs @@ -106,63 +169,6 @@ protected: ///> Maximal vertex index number stored in the container unsigned int m_maxIndex; - /** - * Resizes the chunk that stores the current item to the given size. The current item has - * its offset adjusted after the call, and the new chunk parameters are stored - * in m_chunkOffset and m_chunkSize. - * - * @param aSize is the requested chunk size. - * @return true in case of success, false otherwise - */ - bool reallocate( unsigned int aSize ); - - /** - * Removes empty spaces between chunks and optionally resizes the container. - * After the operation there is continous space for storing vertices at the end of the container. - * - * @param aNewSize is the new size of container, expressed in number of vertices - * @return false in case of failure (e.g. memory shortage) - */ - virtual bool defragmentResize( unsigned int aNewSize ) = 0; - - /** - * Transfers all stored data to a new buffer, removing empty spaces between the data chunks - * in the container. - * @param aTarget is the destination for the defragmented data. - */ - void defragment( VERTEX* aTarget ); - - /** - * Looks for consecutive free memory chunks and merges them, decreasing fragmentation of - * memory. - */ - void mergeFreeChunks(); - - /** - * Returns the size of a chunk. - * - * @param aChunk is the chunk. - */ - inline int getChunkSize( const CHUNK& aChunk ) const - { - return aChunk.first; - } - - /** - * Returns the offset of a chunk. - * - * @param aChunk is the chunk. - */ - inline unsigned int getChunkOffset( const CHUNK& aChunk ) const - { - return aChunk.second; - } - - /** - * Adds a chunk marked as a free space. - */ - void addFreeChunk( unsigned int aOffset, unsigned int aSize ); - private: /// Debug & test functions void showFreeChunks(); diff --git a/include/gal/opengl/cached_container_gpu.h b/include/gal/opengl/cached_container_gpu.h index 7d85d4e23d..e59d08ffb7 100644 --- a/include/gal/opengl/cached_container_gpu.h +++ b/include/gal/opengl/cached_container_gpu.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright 2013-2017 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -31,7 +33,7 @@ namespace KIGFX { /** - * @brief Specialization of CACHED_CONTAINER that stores data in video memory via memory mapping. + * Specialization of CACHED_CONTAINER that stores data in video memory via memory mapping. */ class CACHED_CONTAINER_GPU : public CACHED_CONTAINER @@ -57,6 +59,18 @@ public: void Unmap() override; protected: + /** + * Remove empty spaces between chunks and optionally resizes the container. + * + * After the operation there is continuous space for storing vertices at the end of + * the container. + * + * @param aNewSize is the new size of container, expressed in number of vertices. + * @return false in case of failure (e.g. memory shortage). + */ + bool defragmentResize( unsigned int aNewSize ) override; + bool defragmentResizeMemcpy( unsigned int aNewSize ); + ///> Flag saying if vertex buffer is currently mapped bool m_isMapped; @@ -65,17 +79,6 @@ protected: ///> Flag saying whether it is safe to use glCopyBufferSubData bool m_useCopyBuffer; - - /** - * Function defragmentResize() - * removes empty spaces between chunks and optionally resizes the container. - * After the operation there is continous space for storing vertices at the end of the container. - * - * @param aNewSize is the new size of container, expressed in number of vertices - * @return false in case of failure (e.g. memory shortage) - */ - bool defragmentResize( unsigned int aNewSize ) override; - bool defragmentResizeMemcpy( unsigned int aNewSize ); }; } // namespace KIGFX diff --git a/include/gal/opengl/cached_container_ram.h b/include/gal/opengl/cached_container_ram.h index b4180ca50c..dfd96364c6 100644 --- a/include/gal/opengl/cached_container_ram.h +++ b/include/gal/opengl/cached_container_ram.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright 2013-2017 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -35,8 +37,9 @@ class VERTEX_ITEM; class SHADER; /** - * @brief Specialization of CACHED_CONTAINER that stores data in RAM. This is mainly for - * video cards/drivers that do not cope well with video memory mapping. + * Specialization of CACHED_CONTAINER that stores data in RAM. + * + * This is mainly for video cards/drivers that do not cope well with video memory mapping. */ class CACHED_CONTAINER_RAM : public CACHED_CONTAINER @@ -57,8 +60,9 @@ public: } /** - * Function GetBufferHandle() - * returns handle to the vertex buffer. It might be negative if the buffer is not initialized. + * Return handle to the vertex buffer. + * + * It might be negative if the buffer is not initialized. */ unsigned int GetBufferHandle() const override { @@ -66,15 +70,16 @@ public: } protected: - ///> Handle to vertices buffer - GLuint m_verticesBuffer; - /** - * Defragments the currently stored data and resizes the buffer. + * Defragment the currently stored data and resizes the buffer. + * * @param aNewSize is the new buffer vertex buffer size, expressed as the number of vertices. * @return true on success. */ bool defragmentResize( unsigned int aNewSize ) override; + + ///> Handle to vertices buffer + GLuint m_verticesBuffer; }; } // namespace KIGFX diff --git a/include/gal/opengl/gpu_manager.h b/include/gal/opengl/gpu_manager.h index d43e923400..de1916fcc0 100644 --- a/include/gal/opengl/gpu_manager.h +++ b/include/gal/opengl/gpu_manager.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -36,9 +38,8 @@ class CACHED_CONTAINER; class NONCACHED_CONTAINER; /** - * @brief Class to handle uploading vertices and indices to GPU in drawing purposes. + * Class to handle uploading vertices and indices to GPU in drawing purposes. */ - class GPU_MANAGER { public: @@ -47,41 +48,37 @@ public: virtual ~GPU_MANAGER(); /** - * Function BeginDrawing() - * Prepares the stored data to be drawn. + * Prepare the stored data to be drawn. */ virtual void BeginDrawing() = 0; /** - * Function DrawIndices() - * Makes the GPU draw given range of vertices. + * Make the GPU draw given range of vertices. + * * @param aOffset is the beginning of the range. * @param aSize is the number of vertices to be drawn. */ virtual void DrawIndices( unsigned int aOffset, unsigned int aSize ) = 0; /** - * Function DrawIndices() - * Makes the GPU draw all the vertices stored in the container. + * Make the GPU draw all the vertices stored in the container. */ virtual void DrawAll() = 0; /** - * Function EndDrawing() * Clears the container after drawing routines. */ virtual void EndDrawing() = 0; /** - * Function SetShader() - * Allows using shaders with the stored data. + * Allow using shaders with the stored data. + * * @param aShader is the object that allows using shaders. */ virtual void SetShader( SHADER& aShader ); /** - * Function EnableDepthTest() - * Enables/disables Z buffer depth test. + * Enable/disable Z buffer depth test. */ void EnableDepthTest( bool aEnabled ); diff --git a/include/gal/opengl/opengl_compositor.h b/include/gal/opengl/opengl_compositor.h index 92b553bb98..65685e70bd 100644 --- a/include/gal/opengl/opengl_compositor.h +++ b/include/gal/opengl/opengl_compositor.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -24,8 +26,8 @@ /** * @file opengl_compositor.h - * @brief Class that handles multitarget rendering (ie. to different textures/surfaces) and - * later compositing into a single image (OpenGL flavour). + * Handle multitarget rendering (ie. to different textures/surfaces) and later compositing + * into a single image (OpenGL flavor). */ #ifndef OPENGL_COMPOSITOR_H_ @@ -83,7 +85,6 @@ public: // Constant used by glBindFramebuffer to turn off rendering to framebuffers static const unsigned int DIRECT_RENDERING = 0; -public: VECTOR2U GetScreenSize() const; GLenum GetBufferTexture( unsigned int aBufferHandle ); void DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle ); @@ -95,6 +96,20 @@ public: int GetAntialiasSupersamplingFactor() const; protected: + /// Binds a specific Framebuffer Object. + void bindFb( unsigned int aFb ); + + /** + * Perform freeing of resources. + */ + void clean(); + + /// Returns number of used buffers + inline unsigned int usedBuffers() + { + return m_buffers.size(); + } + // Buffers are simply textures storing a result of certain target rendering. typedef struct { @@ -117,21 +132,6 @@ protected: OPENGL_ANTIALIASING_MODE m_currentAntialiasingMode; std::unique_ptr m_antialiasing; - - /// Binds a specific Framebuffer Object. - void bindFb( unsigned int aFb ); - - /** - * Function clean() - * performs freeing of resources. - */ - void clean(); - - /// Returns number of used buffers - inline unsigned int usedBuffers() - { - return m_buffers.size(); - } }; } // namespace KIGFX diff --git a/include/gal/opengl/shader.h b/include/gal/opengl/shader.h index 3c9f6f4878..3ff2c36719 100644 --- a/include/gal/opengl/shader.h +++ b/include/gal/opengl/shader.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de - * Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2012-2020 KiCad Developers, see AUTHORS.txt for contributors. * * Graphics Abstraction Layer (GAL) for OpenGL * @@ -64,12 +64,12 @@ inline const char* translateStringArg( const char* str ) /** - * @brief Class SHADER provides the access to the OpenGL shaders. + * Provide the access to the OpenGL shaders. * * The purpose of this class is advanced drawing with OpenGL. One example is using the pixel * shader for drawing exact circles or for anti-aliasing. This class supports vertex, geometry * and fragment shaders. - *
+ * * Make sure that the hardware supports these features. This can be identified with the "GLEW" * library. */ @@ -77,21 +77,15 @@ class SHADER { public: - /** - * @brief Constructor - */ SHADER(); - /** - * @brief Destructor - */ virtual ~SHADER(); /** - * @brief Add a shader and compile the shader sources. + * Add a shader and compile the shader sources. * * @param aArgs is the list of strings (std::string or convertible to const char*) which - are concatenated and compiled as a single shader source code. + * are concatenated and compiled as a single shader source code. * @param aShaderType is the type of the shader. * @return True in case of success, false otherwise. */ @@ -103,7 +97,7 @@ public: } /** - * @brief Loads one of the built-in shaders and compiles it. + * Load one of the built-in shaders and compiles it. * * @param aShaderSourceName is the shader source file name. * @param aShaderType is the type of the shader. @@ -112,14 +106,14 @@ public: bool LoadShaderFromFile( SHADER_TYPE aShaderType, const std::string& aShaderSourceName ); /** - * @brief Link the shaders. + * Link the shaders. * * @return true in case of success, false otherwise. */ bool Link(); /** - * @brief Returns true if shaders are linked correctly. + * Return true if shaders are linked correctly. */ bool IsLinked() const { @@ -127,7 +121,7 @@ public: } /** - * @brief Use the shader. + * Use the shader. */ inline void Use() { @@ -136,7 +130,7 @@ public: } /** - * @brief Deactivate the shader and use the default OpenGL program. + * Deactivate the shader and use the default OpenGL program. */ inline void Deactivate() { @@ -145,7 +139,7 @@ public: } /** - * @brief Returns the current state of the shader. + * Return the current state of the shader. * * @return True if any of shaders is enabled. */ @@ -155,7 +149,7 @@ public: } /** - * @brief Configure the geometry shader - has to be done before linking! + * Configure the geometry shader - has to be done before linking! * * @param maxVertices is the maximum of vertices to be generated. * @param geometryInputType is the input type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.] @@ -165,7 +159,7 @@ public: GLuint geometryOutputType ); /** - * @brief Add a parameter to the parameter queue. + * Add a parameter to the parameter queue. * * To communicate with the shader use this function to set up the names for the uniform * variables. These are queued in a list and can be assigned with the SetParameter(..) @@ -177,7 +171,7 @@ public: int AddParameter( const std::string& aParameterName ); /** - * @brief Set a parameter of the shader. + * Set a parameter of the shader. * * @param aParameterNumber is the number of the parameter. * @param aValue is the value of the parameter. @@ -188,7 +182,7 @@ public: void SetParameter( int aParameterNumber, float f0, float f1, float f2, float f3 ) const; /** - * @brief Gets an attribute location. + * Get an attribute location. * * @param aAttributeName is the name of the attribute. * @return the location. @@ -196,7 +190,7 @@ public: int GetAttribute( const std::string& aAttributeName ) const; /** - * @brief Read the shader source file + * Read the shader source file * * @param aShaderSourceName is the shader source file name. * @return the source as string @@ -204,22 +198,20 @@ public: static std::string ReadSource( const std::string& aShaderSourceName ); private: - /** - * @brief Compile vertex of fragment shader source code into the program. + * Compile vertex of fragment shader source code into the program. */ - bool loadShaderFromStringArray( SHADER_TYPE aShaderType, const char** aArray, - size_t aSize ); + bool loadShaderFromStringArray( SHADER_TYPE aShaderType, const char** aArray, size_t aSize ); /** - * @brief Get the shader program information. + * Get the shader program information. * * @param aProgram is the program number. */ void programInfo( GLuint aProgram ); /** - * @brief Get the shader information. + * Get the shader information. * * @param aShader is the shader number. */ @@ -231,8 +223,12 @@ private: bool isShaderLinked; ///< Is the shader linked? bool active; ///< Is any of shaders used? GLuint maximumVertices; ///< The maximum of vertices to be generated - GLuint geomInputType; ///< Input type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.] - GLuint geomOutputType; ///< Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.] + + ///< Input type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.] + GLuint geomInputType; + + ///< Output type [e.g. GL_LINES, GL_TRIANGLES, GL_QUADS etc.] + GLuint geomOutputType; std::deque parameterLocation; ///< Location of the parameter }; } // namespace KIGFX diff --git a/include/gal/opengl/vertex_container.h b/include/gal/opengl/vertex_container.h index ac4b9b6ae9..7cbe276393 100644 --- a/include/gal/opengl/vertex_container.h +++ b/include/gal/opengl/vertex_container.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright 2013-2017 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -24,7 +26,7 @@ /** * @file vertex_container.h - * @brief Class to store vertices and handle transfers between system memory and GPU memory. + * Class to store vertices and handle transfers between system memory and GPU memory. */ #ifndef VERTEX_CONTAINER_H_ @@ -41,30 +43,31 @@ class VERTEX_CONTAINER { public: /** - * Returns a pointer to a new container of an appropriate type. + * Return a pointer to a new container of an appropriate type. */ static VERTEX_CONTAINER* MakeContainer( bool aCached ); virtual ~VERTEX_CONTAINER(); /** - * Returns true if the container caches vertex data in RAM or video memory. + * Return true if the container caches vertex data in RAM or video memory. * Otherwise it is a single batch draw which is later discarded. */ virtual bool IsCached() const = 0; /** - * Prepares the container for vertices updates. + * Prepare the container for vertices updates. */ virtual void Map() {} /** - * Finishes the vertices updates stage. + * Finish the vertices updates stage. */ virtual void Unmap() {} /** - * Sets the item for the further actions. + * Set the item for the further actions. + * * @param aItem is the item or NULL in case of finishing the item. */ virtual void SetItem( VERTEX_ITEM* aItem ) = 0; @@ -75,27 +78,31 @@ public: virtual void FinishItem() {}; /** - * Returns allocated space for the requested number of vertices associated with the - * current item (set with SetItem()). The allocated space is added at the end of the chunk - * used by the current item and may serve to store new vertices. + * Return allocated space for the requested number of vertices associated with the + * current item (set with SetItem()). + * + * The allocated space is added at the end of the chunk used by the current item and + * may serve to store new vertices. + * * @param aSize is the number of vertices to be allocated. * @return Pointer to the allocated space or NULL in case of failure. */ virtual VERTEX* Allocate( unsigned int aSize ) = 0; /** - * Erases the data related to an item. + * Erase the data related to an item. + * * @param aItem is the item to be erased. */ virtual void Delete( VERTEX_ITEM* aItem ) = 0; /** - * Removes all data stored in the container and restores its original state. + * Remove all data stored in the container and restores its original state. */ virtual void Clear() = 0; /** - * Returns pointer to the vertices stored in the container. + * Return pointer to the vertices stored in the container. */ VERTEX* GetAllVertices() const { @@ -103,8 +110,8 @@ public: } /** - * Function GetVertices() - * returns vertices stored at the specific offset. + * Return vertices stored at the specific offset. + * * @param aOffset is the offset. */ virtual VERTEX* GetVertices( unsigned int aOffset ) const @@ -113,8 +120,7 @@ public: } /** - * Function GetSize() - * returns amount of vertices currently stored in the container. + * Return amount of vertices currently stored in the container. */ virtual unsigned int GetSize() const { @@ -122,7 +128,8 @@ public: } /** - * Returns information about the container cache state. + * Return information about the container cache state. + * * @return True in case the vertices have to be reuploaded. */ bool IsDirty() const @@ -131,7 +138,7 @@ public: } /** - * Sets the dirty flag, so vertices in the container are going to be reuploaded to the GPU on + * Set the dirty flag, so vertices in the container are going to be reuploaded to the GPU on * the next frame. */ void SetDirty() @@ -140,7 +147,7 @@ public: } /** - * Clears the dirty flag to prevent reuploading vertices to the GPU memory. + * Clear the dirty flag to prevent reuploading vertices to the GPU memory. */ void ClearDirty() { @@ -150,6 +157,16 @@ public: protected: VERTEX_CONTAINER( unsigned int aSize = DEFAULT_SIZE ); + /** + * Return size of the used memory space. + * + * @return Size of the used memory space (expressed as a number of vertices). + */ + unsigned int usedSpace() const + { + return m_currentSize - m_freeSpace; + } + ///> Free space left in the container, expressed in vertices unsigned int m_freeSpace; @@ -166,16 +183,6 @@ protected: bool m_failed; bool m_dirty; - /** - * Function usedSpace() - * returns size of the used memory space. - * @return Size of the used memory space (expressed as a number of vertices). - */ - unsigned int usedSpace() const - { - return m_currentSize - m_freeSpace; - } - ///< Default initial size of a container (expressed in vertices) static constexpr unsigned int DEFAULT_SIZE = 1048576; }; diff --git a/include/gal/opengl/vertex_item.h b/include/gal/opengl/vertex_item.h index 8c125637af..d206545eff 100644 --- a/include/gal/opengl/vertex_item.h +++ b/include/gal/opengl/vertex_item.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -24,7 +26,7 @@ /** * @file vertex_item.h - * @brief Class to handle an item held in a container. + * Class to handle an item held in a container. */ #ifndef VERTEX_ITEM_H_ @@ -49,8 +51,8 @@ public: virtual ~VERTEX_ITEM(); /** - * Function GetSize() - * Returns information about number of vertices stored. + * Return information about number of vertices stored. + * * @return Number of vertices. */ inline unsigned int GetSize() const @@ -59,8 +61,8 @@ public: } /** - * Function GetOffset() - * Returns data offset in the container. + * Return data offset in the container. + * * @return Data offset expressed as a number of vertices. */ inline unsigned int GetOffset() const @@ -69,19 +71,14 @@ public: } /** - * Function GetVertices() - * Returns pointer to the data used by the VERTEX_ITEM. + * Return pointer to the data used by the VERTEX_ITEM. */ VERTEX* GetVertices() const; private: - const VERTEX_MANAGER& m_manager; - unsigned int m_offset; - unsigned int m_size; - /** - * Function SetOffset() - * Sets data offset in the container. + * Set data offset in the container. + * * @param aOffset is the offset expressed as a number of vertices. */ inline void setOffset( unsigned int aOffset ) @@ -90,14 +87,18 @@ private: } /** - * Function SetSize() - * Sets data size in the container. + * Set data size in the container. + * * @param aSize is the size expressed as a number of vertices. */ inline void setSize( unsigned int aSize ) { m_size = aSize; } + + const VERTEX_MANAGER& m_manager; + unsigned int m_offset; + unsigned int m_size; }; } // namespace KIGFX diff --git a/include/gal/opengl/vertex_manager.h b/include/gal/opengl/vertex_manager.h index 6c8e23f400..bdd92a11f6 100644 --- a/include/gal/opengl/vertex_manager.h +++ b/include/gal/opengl/vertex_manager.h @@ -2,6 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -24,8 +26,6 @@ /** * @file vertex_manager.h - * @brief Class to control vertex container and GPU with possibility of emulating old-style OpenGL - * 1.0 state machine using modern OpenGL methods. */ #ifndef VERTEX_MANAGER_H_ @@ -47,32 +47,31 @@ class VERTEX_ITEM; class VERTEX_CONTAINER; class GPU_MANAGER; +/** + * Class to control vertex container and GPU with possibility of emulating old-style OpenGL + * 1.0 state machine using modern OpenGL methods. + */ class VERTEX_MANAGER { public: /** - * @brief Constructor. - * * @param aCached says if vertices should be cached in GPU or system memory. For data that - * does not change every frame, it is better to store vertices in GPU memory. + * does not change every frame, it is better to store vertices in GPU memory. */ VERTEX_MANAGER( bool aCached ); /** - * Function Map() - * maps vertex buffer. + * Map vertex buffer. */ void Map(); /** - * Function Unmap() - * unmaps vertex buffer. + * Unmap vertex buffer. */ void Unmap(); /** - * Function Reserve() - * allocates space for vertices, so it will be used with subsequent Vertex() calls. + * Allocate space for vertices, so it will be used with subsequent Vertex() calls. * * @param aSize is the number of vertices that should be available in the reserved space. * @return True if successful, false otherwise. @@ -80,11 +79,11 @@ public: bool Reserve( unsigned int aSize ); /** - * Function Vertex() - * adds a vertex with the given coordinates to the currently set item. Color & shader - * parameters stored in aVertex are ignored, instead color & shader set by Color() and - * Shader() functions are used. Vertex coordinates will have the current transformation - * matrix applied. + * Add a vertex with the given coordinates to the currently set item. + * + * Color & shader parameters stored in aVertex are ignored, instead color & shader set + * by Color() and Shader() functions are used. Vertex coordinates will have the current + * transformation matrix applied. * * @param aVertex contains vertex coordinates. * @return True if successful, false otherwise. @@ -95,9 +94,9 @@ public: } /** - * Function Vertex() - * adds a vertex with the given coordinates to the currently set item. Vertex coordinates will - * have the current transformation matrix applied. + * Add a vertex with the given coordinates to the currently set item. + * + * Vertex coordinates will have the current transformation matrix applied. * * @param aX is the X coordinate of the new vertex. * @param aY is the Y coordinate of the new vertex. @@ -107,9 +106,9 @@ public: bool Vertex( GLfloat aX, GLfloat aY, GLfloat aZ ); /** - * Function Vertex() - * adds a vertex with the given coordinates to the currently set item. Vertex coordinates will - * have the current transformation matrix applied. + * Add a vertex with the given coordinates to the currently set item. + * + * Vertex coordinates will have the current transformation matrix applied. * * @param aXY are the XY coordinates of the new vertex. * @param aZ is the Z coordinate of the new vertex. @@ -121,22 +120,21 @@ public: } /** - * Function Vertices() - * adds one or more vertices to the currently set item. It takes advantage of allocating memory - * in advance, so should be faster than adding vertices one by one. Color & shader - * parameters stored in aVertices are ignored, instead color & shader set by Color() and - * Shader() functions are used. All the vertex coordinates will have the current - * transformation matrix applied. + * Add one or more vertices to the currently set item. * - * @param aVertices contains vertices to be added + * It takes advantage of allocating memory in advance, so should be faster than + * adding vertices one by one. Color & shader parameters stored in aVertices are + * ignored, instead color & shader set by Color() and Shader() functions are used. + * All the vertex coordinates will have the current transformation matrix applied. + * + * @param aVertices contains vertices to be added. * @param aSize is the number of vertices to be added. * @return True if successful, false otherwise. */ bool Vertices( const VERTEX aVertices[], unsigned int aSize ); /** - * Function Color() - * changes currently used color that will be applied to newly added vertices. + * Changes currently used color that will be applied to newly added vertices. * * @param aColor is the new color. */ @@ -149,9 +147,10 @@ public: } /** - * Function Color() - * changes currently used color that will be applied to newly added vertices. It is the - * equivalent of glColor4f() function. + * Change currently used color that will be applied to newly added vertices. + * + * It is the equivalent of glColor4f() function. + * * @param aRed is the red component of the new color. * @param aGreen is the green component of the new color. * @param aBlue is the blue component of the new color. @@ -166,10 +165,11 @@ public: } /** - * Function Shader() - * changes currently used shader and its parameters that will be applied to newly added - * vertices. Parameters depend on shader, for more information have a look at shaders source - * code. + * Change currently used shader and its parameters that will be applied to newly added + * vertices. + * + * Parameters depend on shader, for more information have a look at shaders source code. + * * @see SHADER_TYPE * * @param aShaderType is the a shader type to be applied. @@ -177,8 +177,8 @@ public: * @param aParam2 is the optional parameter for a shader. * @param aParam3 is the optional parameter for a shader. */ - inline void Shader( GLfloat aShaderType, GLfloat aParam1 = 0.0f, - GLfloat aParam2 = 0.0f, GLfloat aParam3 = 0.0f ) + inline void Shader( GLfloat aShaderType, GLfloat aParam1 = 0.0f, GLfloat aParam2 = 0.0f, + GLfloat aParam3 = 0.0f ) { m_shader[0] = aShaderType; m_shader[1] = aParam1; @@ -187,9 +187,10 @@ public: } /** - * Function Translate() - * multiplies the current matrix by a translation matrix, so newly vertices will be - * translated by the given vector. It is the equivalent of the glTranslatef() function. + * Multiply the current matrix by a translation matrix, so newly vertices will be + * translated by the given vector. + * + * It is the equivalent of the glTranslatef() function. * * @param aX is the X coordinate of a translation vector. * @param aY is the X coordinate of a translation vector. @@ -201,9 +202,10 @@ public: } /** - * Function Rotate() - * multiplies the current matrix by a rotation matrix, so the newly vertices will be - * rotated by the given angles. It is the equivalent of the glRotatef() function. + * Multiply the current matrix by a rotation matrix, so the newly vertices will be + * rotated by the given angles. + * + * It is the equivalent of the glRotatef() function. * * @param aAngle is the angle of rotation, in radians. * @param aX is a multiplier for the X axis @@ -216,9 +218,10 @@ public: } /** - * Function Scale() - * multiplies the current matrix by a scaling matrix, so the newly vertices will be - * scaled by the given factors. It is the equivalent of the glScalef() function. + * Multiply the current matrix by a scaling matrix, so the newly vertices will be + * scaled by the given factors. + * + * It is the equivalent of the glScalef() function. * * @param aX is the X axis scaling factor. * @param aY is the Y axis scaling factor. @@ -230,9 +233,9 @@ public: } /** - * Function PushMatrix() - * pushes the current transformation matrix stack. It is the equivalent of the glPushMatrix() - * function. + * Push the current transformation matrix stack. + * + * It is the equivalent of the glPushMatrix() function. */ inline void PushMatrix() { @@ -243,9 +246,9 @@ public: } /** - * Function PopMatrix() - * pops the current transformation matrix stack. It is the equivalent of the glPopMatrix() - * function. + * Pop the current transformation matrix stack. + * + * It is the equivalent of the glPopMatrix() function. */ void PopMatrix() { @@ -262,31 +265,28 @@ public: } /** - * Function SetItem() - * sets an item to start its modifications. After calling the function it is possible to add - * vertices using function Add(). + * Set an item to start its modifications. + * + * After calling the function it is possible to add vertices using function Add(). * * @param aItem is the item that is going to store vertices in the container. */ void SetItem( VERTEX_ITEM& aItem ) const; /** - * Function FinishItem() - * does the cleaning after adding an item. + * Clean after adding an item. */ void FinishItem() const; /** - * Function FreeItem() - * frees the memory occupied by the item, so it is no longer stored in the container. + * Free the memory occupied by the item, so it is no longer stored in the container. * * @param aItem is the item to be freed */ void FreeItem( VERTEX_ITEM& aItem ) const; /** - * Function ChangeItemColor() - * changes the color of all vertices owned by an item. + * Change the color of all vertices owned by an item. * * @param aItem is the item to change. * @param aColor is the new color to be applied. @@ -294,8 +294,7 @@ public: void ChangeItemColor( const VERTEX_ITEM& aItem, const COLOR4D& aColor ) const; /** - * Function ChangeItemDepth() - * changes the depth of all vertices owned by an item. + * Change the depth of all vertices owned by an item. * * @param aItem is the item to change. * @param aDepth is the new color to be applied. @@ -303,8 +302,7 @@ public: void ChangeItemDepth( const VERTEX_ITEM& aItem, GLfloat aDepth ) const; /** - * Function GetVertices() - * returns a pointer to the vertices owned by an item. + * Return a pointer to the vertices owned by an item. * * @param aItem is the owner of vertices that are going to be returned. * @return Pointer to the vertices or NULL if the item is not stored at the container. @@ -317,51 +315,45 @@ public: } /** - * Function SetShader() - * sets a shader program that is going to be used during rendering. + * Set a shader program that is going to be used during rendering. + * * @param aShader is the object containing compiled and linked shader program. */ void SetShader( SHADER& aShader ) const; /** - * Function Clear() - * removes all the stored vertices from the container. + * Remove all the stored vertices from the container. */ void Clear() const; /** - * Function BeginDrawing() - * prepares buffers and items to start drawing. + * Prepare buffers and items to start drawing. */ void BeginDrawing() const; /** - * Function DrawItem() - * draws an item to the buffer. + * Draw an item to the buffer. * * @param aItem is the item to be drawn. */ void DrawItem( const VERTEX_ITEM& aItem ) const; /** - * Function EndDrawing() - * finishes drawing operations. + * Finish drawing operations. */ void EndDrawing() const; /** - * Function EnableDepthTest() - * Enables/disables Z buffer depth test. + * Enable/disable Z buffer depth test. */ void EnableDepthTest( bool aEnabled ); protected: /** - * Function putVertex() - * applies all transformation to the given coordinates and store them at the specified target. + * Apply all transformation to the given coordinates and store them at the specified target. * * @param aTarget is the place where the new vertex is going to be stored (it has to be - * allocated first). + * allocated first). * @param aX is the X coordinate of the new vertex. * @param aY is the Y coordinate of the new vertex. * @param aZ is the Z coordinate of the new vertex. diff --git a/include/gal/stroke_font.h b/include/gal/stroke_font.h index 51bebf875e..b266a9b25f 100644 --- a/include/gal/stroke_font.h +++ b/include/gal/stroke_font.h @@ -4,7 +4,7 @@ * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de * Copyright (C) 2013 CERN * @author Maciej Suminski - * Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2016-2020 Kicad Developers, see AUTHORS.txt for contributors. * * Stroke font class * @@ -46,7 +46,7 @@ typedef std::vector*> GLYPH; typedef std::vector GLYPH_LIST; /** - * @brief Class STROKE_FONT implements stroke font drawing. + * Class STROKE_FONT implements stroke font drawing. * * A stroke font is composed of lines. */ @@ -59,7 +59,7 @@ public: STROKE_FONT( GAL* aGal ); /** - * @brief Load the new stroke font. + * Load the new stroke font. * * @param aNewStrokeFont is the pointer to the font data. * @param aNewStrokeFontSize is the size of the font data. @@ -68,7 +68,7 @@ public: bool LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNewStrokeFontSize ); /** - * @brief Draw a string. + * Draw a string. * * @param aText is the text to be drawn. * @param aPosition is the text position in world coordinates. @@ -77,8 +77,8 @@ public: void Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRotationAngle ); /** - * Function SetGAL * Changes Graphics Abstraction Layer used for drawing items for a new one. + * * @param aGal is the new GAL instance. */ void SetGAL( GAL* aGal ) @@ -88,7 +88,9 @@ public: /** * Compute the boundary limits of aText (the bounding box of all shapes). + * * The overbar and alignment are not taken in account, '~' characters are skipped. + * * @return a VECTOR2D giving the width and height of text. */ VECTOR2D ComputeStringBoundaryLimits( const UTF8& aText, const VECTOR2D& aGlyphSize, @@ -96,29 +98,25 @@ public: /** * Compute the vertical position of an overbar, sometimes used in texts. + * * This is the distance between the text base line and the overbar. + * * @param aGlyphHeight is the height (vertical size) of the text. * @return the relative position of the overbar axis. */ double ComputeOverbarVerticalPosition( double aGlyphHeight ) const; /** - * @brief Compute the distance (interline) between 2 lines of text (for multiline texts). + * Compute the distance (interline) between 2 lines of text (for multiline texts). * * @param aGlyphHeight is the height (vertical size) of the text. * @return the interline. */ static double GetInterline( double aGlyphHeight ); - - private: - GAL* m_gal; ///< Pointer to the GAL - const GLYPH_LIST* m_glyphs; ///< Glyph list - const std::vector* m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs - /** - * @brief Compute the X and Y size of a given text. The text is expected to be + * Compute the X and Y size of a given text. The text is expected to be * a only one line text. * * @param aText is the text string (one line). @@ -135,7 +133,7 @@ private: double computeUnderlineVerticalPosition() const; /** - * @brief Compute the bounding box of a given glyph. + * Compute the bounding box of a given glyph. * * @param aGlyph is the glyph. * @param aGlyphWidth is the x-component of the bounding box size. @@ -144,7 +142,7 @@ private: BOX2D computeBoundingBox( const GLYPH* aGlyph, double aGlyphWidth ) const; /** - * @brief Draws a single line of text. Multiline texts should be split before using the + * Draws a single line of text. Multiline texts should be split before using the * function. * * @param aText is the text to be drawn. @@ -152,7 +150,7 @@ private: void drawSingleLineText( const UTF8& aText ); /** - * @brief Returns number of lines for a given text. + * Returns number of lines for a given text. * * @param aText is the text to be checked. * @return unsigned - The number of lines in aText. @@ -166,6 +164,10 @@ private: return std::count( aText.begin(), aText.end() - 1, '\n' ) + 1; } + GAL* m_gal; ///< Pointer to the GAL + const GLYPH_LIST* m_glyphs; ///< Glyph list + const std::vector* m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs + ///> Factor that determines relative vertical position of the overbar. static const double OVERBAR_POSITION_FACTOR; static const double UNDERLINE_POSITION_FACTOR; diff --git a/include/page_layout/ws_data_item.h b/include/page_layout/ws_data_item.h index 26e87b475b..93ad203275 100644 --- a/include/page_layout/ws_data_item.h +++ b/include/page_layout/ws_data_item.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -46,8 +46,8 @@ class VIEW; /** * A coordinate is relative to a page corner. - * Any of the 4 corners can be a reference. - * The default is the right bottom corner + * + * Any of the 4 corners can be a reference. The default is the right bottom corner. */ enum CORNER_ANCHOR { @@ -65,15 +65,14 @@ enum PAGE_OPTION }; /** - * A coordinate point - * The position is always relative to the corner anchor - * Note the coordinate is from the anchor point to the opposite corner. + * A coordinate point. + * + * The position is always relative to the corner anchor. + * + * @note The coordinate is from the anchor point to the opposite corner. */ class POINT_COORD { -public: - DPOINT m_Pos; - int m_Anchor; public: POINT_COORD() { m_Anchor = RB_CORNER; } @@ -82,11 +81,15 @@ public: m_Pos = aPos; m_Anchor = aAnchor; } + + DPOINT m_Pos; + int m_Anchor; }; /** * Work sheet structure type definitions. + * * Basic items are: * * segment and rect (defined by 2 points) * * text (defined by a coordinate), the text and its justifications @@ -105,25 +108,6 @@ public: WS_BITMAP }; -protected: - WS_ITEM_TYPE m_type; - PAGE_OPTION m_pageOption; - - std::vector m_drawItems; - -public: - wxString m_Name; // a item name used in page layout - // editor to identify items - wxString m_Info; // a comment, only useful in page - // layout editor - POINT_COORD m_Pos; - POINT_COORD m_End; - double m_LineWidth; - int m_RepeatCount; // repeat count for duplicate items - DPOINT m_IncrementVector; // For duplicate items: move vector - // for position increment - int m_IncrementLabel; - public: WS_DATA_ITEM( WS_ITEM_TYPE aType ); @@ -147,12 +131,10 @@ public: m_End.m_Anchor = aAnchor; } - // Accessors: WS_ITEM_TYPE GetType() const { return m_type; } /** - * @return true if the item has a end point (segment; rect) - * of false (text, polugon) + * @return true if the item has a end point (segment; rect) of false (text, polygon). */ PAGE_OPTION GetPage1Option() const { return m_pageOption; } void SetPage1Option( PAGE_OPTION aChoice ) { m_pageOption = aChoice; } @@ -166,67 +148,81 @@ public: virtual int GetPenSizeUi(); /** - * move item to a new position - * @param aPosition = the new position of item, in mm + * Move item to a new position. + * + * @param aPosition the new position of item, in mm. */ void MoveTo( DPOINT aPosition ); /** - * move item to a new position - * @param aPosition = the new position of the starting point in graphic units + * Move item to a new position. + * + * @param aPosition the new position of the starting point in graphic units. */ void MoveToUi( wxPoint aPosition ); /** - * move the starting point of the item to a new position - * @param aPosition = the new position of the starting point, in mm + * Move the starting point of the item to a new position. + * + * @param aPosition the new position of the starting point, in mm. */ void MoveStartPointTo( DPOINT aPosition ); /** - * move the starting point of the item to a new position - * @param aPosition = the new position of item in graphic units + * Move the starting point of the item to a new position. + * + * @param aPosition is the new position of item in graphic units. */ void MoveStartPointToUi( wxPoint aPosition ); /** - * move the ending point of the item to a new position - * has meaning only for items defined by 2 points - * (segments and rectangles) - * @param aPosition = the new position of the ending point, in mm + * Move the ending point of the item to a new position. + * + * This has meaning only for items defined by 2 points (segments and rectangles). + * + * @param aPosition is the new position of the ending point, in mm. */ void MoveEndPointTo( DPOINT aPosition ); /** - * move the ending point of the item to a new position - * has meaning only for items defined by 2 points - * (segments and rectangles) - * @param aPosition = the new position of the ending point in graphic units + * Move the ending point of the item to a new position. + * + * This has meaning only for items defined by 2 points (segments and rectangles). + * + * @param aPosition is the new position of the ending point in graphic units */ void MoveEndPointToUi( wxPoint aPosition ); /** - * @return true if the item is inside the rectangle defined by the - * 4 corners, false otherwise. + * @return true if the item is inside the rectangle defined by the 4 corners, false otherwise. */ virtual bool IsInsidePage( int ii ) const; const wxString GetClassName() const; + +protected: + WS_ITEM_TYPE m_type; + PAGE_OPTION m_pageOption; + + std::vector m_drawItems; + +public: + wxString m_Name; // a item name used in page layout + // editor to identify items + wxString m_Info; // a comment, only useful in page layout editor + POINT_COORD m_Pos; + POINT_COORD m_End; + double m_LineWidth; + int m_RepeatCount; // repeat count for duplicate items + DPOINT m_IncrementVector; // For duplicate items: move vector + // for position increment + int m_IncrementLabel; }; class WS_DATA_ITEM_POLYGONS : public WS_DATA_ITEM { -public: - double m_Orient; // Orientation in degrees - std::vector m_Corners; // corner list - -private: - std::vector m_polyIndexEnd; // index of the last point of each polygon - DPOINT m_minCoord; // min coord of corners, relative to m_Pos - DPOINT m_maxCoord; // max coord of corners, relative to m_Pos - public: WS_DATA_ITEM_POLYGONS( ); @@ -235,8 +231,9 @@ public: virtual int GetPenSizeUi() override; /** - * add a corner in corner list - * @param aCorner: the item to append + * Add a corner in corner list. + * + * @param aCorner is the item to append. */ void AppendCorner( const DPOINT& aCorner ) { @@ -244,8 +241,8 @@ public: } /** - * Closes the current contour, by storing the index of the last corner - * of the current polygon in m_polyIndexEnd. + * Closes the current contour, by storing the index of the last corner of the current + * polygon in m_polyIndexEnd. */ void CloseContour() { @@ -253,13 +250,13 @@ public: } /** - * @return the count of contours in the poly polygon + * @return the count of contours in the poly polygon. */ int GetPolyCount() const { return (int) m_polyIndexEnd.size(); } /** - * @return the index of the first corner of the contour aCountour - * @param aContour = the index of the contour + * @param aContour is the index of the contour. + * @return the index of the first corner of the contour \a aCountour. */ unsigned GetPolyIndexStart( unsigned aContour) const { @@ -270,8 +267,8 @@ public: } /** - * @return the index of the last corner of the contour aCountour - * @param aContour = the index of the contour + * @param aContour is the index of the contour. + * @return the index of the last corner of the contour \a aCountour. */ unsigned GetPolyIndexEnd( unsigned aContour) const { @@ -279,46 +276,35 @@ public: } /** - * @return the coordinate (in mm) of the corner aIdx, - * for the repeated item aRepeat + * @return the coordinate (in mm) of the corner \a aIdx and the repeated item \a aRepeat */ const DPOINT GetCornerPosition( unsigned aIdx, int aRepeat = 0 ) const; /** - * @return the coordinate (in draw/plot units) of the corner aIdx, - * for the repeated item aRepeat + * @return the coordinate (in draw/plot units) of the corner \a aIdx and the repeated + * item \a aRepeat */ const wxPoint GetCornerPositionUi( unsigned aIdx, int aRepeat = 0 ) const; /** - * calculate the bounding box of the set polygons + * Calculate the bounding box of the set polygons. */ void SetBoundingBox(); bool IsInsidePage( int ii ) const override; + + double m_Orient; // Orientation in degrees + std::vector m_Corners; // corner list + +private: + std::vector m_polyIndexEnd; // index of the last point of each polygon + DPOINT m_minCoord; // min coord of corners, relative to m_Pos + DPOINT m_maxCoord; // max coord of corners, relative to m_Pos }; class WS_DATA_ITEM_TEXT : public WS_DATA_ITEM { -public: - wxString m_TextBase; // The basic text, with format symbols - wxString m_FullText; // The expanded text, shown on screen - double m_Orient; // Orientation in degrees - EDA_TEXT_HJUSTIFY_T m_Hjustify; - EDA_TEXT_VJUSTIFY_T m_Vjustify; - bool m_Italic; - bool m_Bold; - DSIZE m_TextSize; - DSIZE m_BoundingBoxSize; // When not null, this is the max - // size of the full text. - // the text size will be modified - // to keep the full text insite this - // bound. - DSIZE m_ConstrainedTextSize; // Actual text size, if constrained by - // the m_BoundingBoxSize constraint - - public: WS_DATA_ITEM_TEXT( const wxString& aTextBase ); @@ -330,7 +316,7 @@ public: * Try to build text wihich is an increment of m_TextBase * has meaning only if m_TextBase is a basic text (one char) * If the basic char is a digit, build a number - * If the basic char is a letter, use the letter with ascii code + * If the basic char is a letter, use the letter with ASCII code * aIncr + (basic char ascc code) * @param aIncr = the increment value * return the incremented label in m_FullText @@ -338,7 +324,7 @@ public: void IncrementLabel( int aIncr ); /** - * Calculates m_ConstrainedTextSize from m_TextSize + * Calculate m_ConstrainedTextSize from m_TextSize * to keep the X size and the full Y size of the text * smaller than m_BoundingBoxSize * if m_BoundingBoxSize.x or m_BoundingBoxSize.y > 0 @@ -348,12 +334,27 @@ public: void SetConstrainedTextSize(); - /** Replace the '\''n' sequence by EOL - * and the sequence '\''\' by only one '\' + /** + * Replace the '\''n' sequence by EOL and the sequence '\''\' by only one '\' * inside m_FullText - * @return true if the EOL symbol is found or is inserted (multiline text) + * @return true if the EOL symbol is found or is inserted (multiline text). */ bool ReplaceAntiSlashSequence(); + +public: + wxString m_TextBase; // The basic text, with format symbols + wxString m_FullText; // The expanded text, shown on screen + double m_Orient; // Orientation in degrees + EDA_TEXT_HJUSTIFY_T m_Hjustify; + EDA_TEXT_VJUSTIFY_T m_Vjustify; + bool m_Italic; + bool m_Bold; + DSIZE m_TextSize; + DSIZE m_BoundingBoxSize; // When not null, this is the max size of the + // full text. The text size will be modified + // to keep the full text inside this bound. + DSIZE m_ConstrainedTextSize; // Actual text size, if constrained by + // the m_BoundingBoxSize constraint }; @@ -361,9 +362,6 @@ class BITMAP_BASE; class WS_DATA_ITEM_BITMAP : public WS_DATA_ITEM { -public: - BITMAP_BASE* m_ImageBitmap; - public: WS_DATA_ITEM_BITMAP( BITMAP_BASE* aImage ) : WS_DATA_ITEM( WS_BITMAP ) @@ -375,6 +373,9 @@ public: int GetPPI() const; void SetPPI( int aBitmapPPI ); + +public: + BITMAP_BASE* m_ImageBitmap; }; diff --git a/include/page_layout/ws_data_model.h b/include/page_layout/ws_data_model.h index c6ef7b7208..fbc7f2cc4e 100644 --- a/include/page_layout/ws_data_model.h +++ b/include/page_layout/ws_data_model.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,33 +33,10 @@ class WS_DATA_ITEM; class PAGE_INFO; /** - * WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block + * Handle the graphic items list to draw/plot the frame and title block. */ class WS_DATA_MODEL { - std::vector m_list; - bool m_allowVoidList; // If false, the default page layout will be loaded the - // first time WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList - // is run (useful mainly for page layout editor) - double m_leftMargin; // the left page margin in mm - double m_rightMargin; // the right page margin in mm - double m_topMargin; // the top page margin in mm - double m_bottomMargin; // the bottom page margin in mm - -public: - double m_WSunits2Iu; // conversion factor between - // ws units (mils) and draw/plot units - DPOINT m_RB_Corner; // cordinates of the right bottom corner (in mm) - DPOINT m_LT_Corner; // cordinates of the left top corner (in mm) - double m_DefaultLineWidth; // Used when object line width is 0 - DSIZE m_DefaultTextSize; // Used when object text size is 0 - double m_DefaultTextThickness; // Used when object text stroke width is 0 - bool m_EditMode; // Used in page layout editor to toggle variable substution - // In normal mode (m_EditMode = false) the %format is - // replaced by the corresponding text. - // In edit mode (m_EditMode = true) the %format is - // displayed "as this" - public: WS_DATA_MODEL(); ~WS_DATA_MODEL() @@ -73,13 +50,12 @@ public: static WS_DATA_MODEL& GetTheInstance(); /** - * static function: Set an alternate instance of WS_DATA_MODEL - * mainly used in page setting dialog - * @param aLayout = the alternate page layout; if null restore the basic page layout + * Set an alternate instance of WS_DATA_MODEL. + * + * @param aLayout the alternate page layout; if null restore the basic page layout */ static void SetAltInstance( WS_DATA_MODEL* aLayout = NULL ); - // Accessors: double GetLeftMargin() { return m_leftMargin; } void SetLeftMargin( double aMargin ) { m_leftMargin = aMargin; } @@ -95,7 +71,7 @@ public: void SetupDrawEnvironment( const PAGE_INFO& aPageInfo, double aMilsToIU ); /** - * In Kicad applications, a page layout description is needed + * In KiCad applications, a page layout description is needed * So if the list is empty, a default description is loaded, * the first time a page layout is drawn. * However, in page layout editor, an empty list is acceptable. @@ -105,29 +81,30 @@ public: /** * @return true if an empty list is allowed - * (mainly allowed for page layout editor). */ bool VoidListAllowed() { return m_allowVoidList; } /** - * erase the list of items + * Erase the list of items. */ void ClearList(); /** - * Save the description in a file - * @param aFullFileName the filename of the file to created + * Save the description in a file. + * + * @param aFullFileName the filename of the file to created. */ void Save( const wxString& aFullFileName ); /** - * Save the description in a buffer - * @param aOutputString = a wxString to store the S expr string + * Save the description in a buffer. + * + * @param aOutputString is a wxString to store the S expr string */ void SaveInString( wxString& aOutputString ); /** - * Fill the given string with an S-expr serialization of the WS_DATA_ITEMs + * Fill the given string with an S-expr serialization of the WS_DATA_ITEMs. */ void SaveInString( std::vector aItemsList, wxString& aOutputString ); @@ -135,12 +112,12 @@ public: void Remove( WS_DATA_ITEM* aItem ); /** - * @return the index of aItem, or -1 if does not exist + * @return the index of aItem, or -1 if does not exist. */ int GetItemIndex( WS_DATA_ITEM* aItem ) const; /** - * @return the item from its index aIdx, or NULL if does not exist + * @return is the item from it's index \a aIdx, or NULL if does not exist. */ WS_DATA_ITEM* GetItem( unsigned aIdx ) const; @@ -150,7 +127,7 @@ public: std::vector& GetItems() { return m_list; } /** - * @return the item count + * @return the item count. */ unsigned GetCount() const { return m_list.size(); } @@ -158,50 +135,49 @@ public: void SetEmptyLayout(); /** - * Returns a string containing the empty layout shape + * Return a string containing the empty layout shape. */ static wxString EmptyLayout(); /** - * Returns a string containing the empty layout shape + * Return a string containing the empty layout shape. */ static wxString DefaultLayout(); /** - * Populates the list with a custom layout, or - * the default layout, if no custom layout available - * @param aFullFileName = the custom page layout description file. - * if empty, loads the file defined by KICAD_WKSFILE - * and if its is not defined, uses the default internal description - * @param Append = if true: do not delete old layout, and load only - aFullFileName. + * Populates the list with a custom layout or the default layout if no custom layout + * is available. + * + * @param aFullFileName is the custom page layout description file. If empty, load the + * file defined by KICAD_WKSFILE and if its is not defined use the + * default internal description. + * @param Append if true: do not delete old layout, and load only \a aFullFileName. */ void SetPageLayout( const wxString& aFullFileName = wxEmptyString, bool Append = false ); /** - * Populates the list from a S expr description stored in a string - * @param aPageLayout = the S expr string - * @param aAppend Do not delete old layout if true and append \a aPageLayout - * the existing one. + * Populate the list from a S expr description stored in a string. + * + * @param aPageLayout is the S expr string. + * @param aAppend Do not delete old layout if true and append \a aPageLayout the existing + * one. @param aSource is the layout source description. */ void SetPageLayout( const char* aPageLayout, bool aAppend = false, const wxString& aSource = wxT( "Sexpr_string" ) ); /** - * @return a short filename from a full filename: + * @param aFullFileName is the full filename, which can be a relative. + * @param aProjectPath is the current project absolute path (can be empty). + * @return a short filename from a full filename: * if the path is the current project path, or if the path * is the same as kicad.pro (in template), returns the shortname * else do nothing and returns a full filename - * @param aFullFileName = the full filename, which can be a relative - * @param aProjectPath = the curr project absolute path (can be empty) */ static const wxString MakeShortFileName( const wxString& aFullFileName, const wxString& aProjectPath ); /** - * Static function - * @return a full filename from a short filename. * @param aShortFileName = the short filename, which can be a relative * @param aProjectPath = the curr project absolute path (can be empty) * or absolute path, and can include env variable reference ( ${envvar} expression ) @@ -209,9 +185,35 @@ public: * or (if aProjectPath is empty or if the file does not exist) * relative to kicad.pro (in template) * If aShortFileName is absolute return aShortFileName + * @return a full filename from a short filename. */ static const wxString MakeFullFileName( const wxString& aShortFileName, const wxString& aProjectPath ); + + double m_WSunits2Iu; // conversion factor between + // ws units (mils) and draw/plot units + DPOINT m_RB_Corner; // coordinates of the right bottom corner (in mm) + DPOINT m_LT_Corner; // coordinates of the left top corner (in mm) + double m_DefaultLineWidth; // Used when object line width is 0 + DSIZE m_DefaultTextSize; // Used when object text size is 0 + double m_DefaultTextThickness; // Used when object text stroke width is 0 + bool m_EditMode; // Used in page layout editor to toggle variable substation + // In normal mode (m_EditMode = false) the %format is + // replaced by the corresponding text. + // In edit mode (m_EditMode = true) the %format is + // displayed "as this" + +private: + std::vector m_list; + bool m_allowVoidList; // If false, the default page layout will be loaded the + // first time WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList + // is run (useful mainly for page layout editor) + double m_leftMargin; // the left page margin in mm + double m_rightMargin; // the right page margin in mm + double m_topMargin; // the top page margin in mm + double m_bottomMargin; // the bottom page margin in mm + + }; #endif // WS_DATA_MODEL_H diff --git a/include/page_layout/ws_draw_item.h b/include/page_layout/ws_draw_item.h index 4c6e0ddc32..ba8116653d 100644 --- a/include/page_layout/ws_draw_item.h +++ b/include/page_layout/ws_draw_item.h @@ -44,31 +44,19 @@ class EDA_DRAW_FRAME; class PROJECT; /** - * Helper classes to handle basic graphic items used to draw/plot - * title blocks and frame references - * segments - * rect - * polygons (for logos) - * graphic texts - * bitmaps (also for logos, but they cannot be plot by SVG, GERBER or HPGL plotters - * where we just plot the bounding box) + * Base class to handle basic graphic items. + * + * Used to draw and/or plot: + * - title blocks and frame references + * - segments + * - rect + * - polygons (for logos) + * - graphic texts + * - bitmaps (also for logos, but they cannot be plot by SVG, GERBER or HPGL plotters + * where we just plot the bounding box) */ -class WS_DRAW_ITEM_BASE : public EDA_ITEM // This basic class, not directly usable. +class WS_DRAW_ITEM_BASE : public EDA_ITEM { -protected: - WS_DATA_ITEM* m_peer; // the parent WS_DATA_ITEM item in the WS_DATA_MODEL - int m_index; // the index in the parent's repeat count - int m_penWidth; - - WS_DRAW_ITEM_BASE( WS_DATA_ITEM* aPeer, int aIndex, KICAD_T aType ) : - EDA_ITEM( aType ) - { - m_peer = aPeer; - m_index = aIndex; - m_penWidth = 0; - m_flags = 0; - } - public: virtual ~WS_DRAW_ITEM_BASE() {} @@ -110,15 +98,26 @@ public: bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) override; + +protected: + WS_DRAW_ITEM_BASE( WS_DATA_ITEM* aPeer, int aIndex, KICAD_T aType ) : + EDA_ITEM( aType ) + { + m_peer = aPeer; + m_index = aIndex; + m_penWidth = 0; + m_flags = 0; + } + + WS_DATA_ITEM* m_peer; // the parent WS_DATA_ITEM item in the WS_DATA_MODEL + int m_index; // the index in the parent's repeat count + int m_penWidth; }; // This class draws a thick segment class WS_DRAW_ITEM_LINE : public WS_DRAW_ITEM_BASE { - wxPoint m_start; // start point of line/rect - wxPoint m_end; // end point - public: WS_DRAW_ITEM_LINE( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aStart, wxPoint aEnd, int aPenWidth ) : @@ -131,7 +130,6 @@ public: virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_LINE" ); } - // Accessors: const wxPoint& GetStart() const { return m_start; } void SetStart( wxPoint aPos ) { m_start = aPos; } const wxPoint& GetEnd() const { return m_end; } @@ -150,22 +148,15 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif + +private: + wxPoint m_start; // start point of line/rect + wxPoint m_end; // end point }; -// This class draws a polygon class WS_DRAW_ITEM_POLYPOLYGONS : public WS_DRAW_ITEM_BASE { - wxPoint m_pos; // position of reference point, from the - // WS_DATA_ITEM_POLYGONS parent - // (used only in page layout editor to draw anchors) - -public: - /** The list of polygons. Because these polygons are only for drawing purposes, - * each polygon is expected having no holes, just a main outline - */ - SHAPE_POLY_SET m_Polygons; - public: WS_DRAW_ITEM_POLYPOLYGONS( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aPos, int aPenWidth ) : WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_POLY_T ) @@ -176,7 +167,6 @@ public: virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_POLYPOLYGONS" ); } - // Accessors: SHAPE_POLY_SET& GetPolygons() { return m_Polygons; } wxPoint GetPosition() const override { return m_pos; } void SetPosition( const wxPoint& aPos ) override; @@ -192,15 +182,28 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif + +public: + /** + * The list of polygons. + * + * Because these polygons are only for drawing purposes, each polygon is expected to + * have no holes just a main outline. + */ + SHAPE_POLY_SET m_Polygons; + + +private: + wxPoint m_pos; // position of reference point, from the WS_DATA_ITEM_POLYGONS parent + // (used only in page layout editor to draw anchors) }; -// This class draws a not filled rectangle with thick segment +/** + * Non filled rectangle with thick segment. + */ class WS_DRAW_ITEM_RECT : public WS_DRAW_ITEM_BASE { - wxPoint m_start; // start point of line/rect - wxPoint m_end; // end point - public: WS_DRAW_ITEM_RECT( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aStart, wxPoint aEnd, int aPenWidth ) : @@ -213,7 +216,6 @@ public: virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_RECT" ); } - // Accessors: const wxPoint& GetStart() const { return m_start; } void SetStart( wxPoint aPos ) { m_start = aPos; } const wxPoint& GetEnd() const { return m_end; } @@ -233,18 +235,22 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif + +private: + wxPoint m_start; // start point of line/rect + wxPoint m_end; // end point }; -// This class draws a rectangle with thick segment showing the page limits -// and a marker showing the coord origin. This only a draw item only. -// Therefore m_peer ( the parent WS_DATA_ITEM item in the WS_DATA_MODEL) is always a nullptr. +/** + * A rectangle with thick segment showing the page limits and a marker showing the coordinate + * origin. + * + * This only a draw item only. Therefore m_peer ( the parent WS_DATA_ITEM item in the + * WS_DATA_MODEL) is always a nullptr. + */ class WS_DRAW_ITEM_PAGE : public WS_DRAW_ITEM_BASE { - wxPoint m_markerPos; // position of the marker - wxSize m_pageSize; // full size of the page - double m_markerSize; - public: WS_DRAW_ITEM_PAGE( int aPenWidth, double aMarkerSize ) : WS_DRAW_ITEM_BASE( nullptr, 0, WSG_PAGE_T ) @@ -255,7 +261,6 @@ public: virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_PAGE" ); } - // Accessors: void SetPageSize( wxSize aSize ) { m_pageSize = aSize; } wxSize GetPageSize() const { return m_pageSize; } const wxPoint& GetMarkerPos() const { return m_markerPos; } @@ -275,12 +280,20 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif + +private: + wxPoint m_markerPos; // position of the marker + wxSize m_pageSize; // full size of the page + double m_markerSize; }; -// This class draws a graphic text. -// it is derived from an EDA_TEXT, so it handle all characteristics -// of this graphic text (justification, rotation ... ) +/** + * A graphic text. + * + * It is derived from an #EDA_TEXT, so it handle all characteristics of this graphic text + * (justification, rotation ... ). + */ class WS_DRAW_ITEM_TEXT : public WS_DRAW_ITEM_BASE, public EDA_TEXT { public: @@ -318,11 +331,11 @@ public: }; -// This class draws a bitmap. +/** + * A bitmap. + */ class WS_DRAW_ITEM_BITMAP : public WS_DRAW_ITEM_BASE { - wxPoint m_pos; // position of reference point - public: WS_DRAW_ITEM_BITMAP( WS_DATA_ITEM* aPeer, int aIndex, wxPoint aPos ) : WS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_BITMAP_T ) @@ -348,6 +361,9 @@ public: #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif + +private: + wxPoint m_pos; // position of reference point }; @@ -359,24 +375,6 @@ public: */ class WS_DRAW_ITEM_LIST { -protected: - std::vector m_graphicList; // Items to draw/plot - unsigned m_idx; // for GetFirst, GetNext functions - double m_milsToIu; // the scalar to convert pages units ( mils) - // to draw/plot units. - int m_penSize; // The default line width for drawings. - // used when an item has a pen size = 0 - bool m_isFirstPage; ///< Is this the first page or not. - int m_sheetCount; ///< The number of sheets - // for basic inscriptions, in schematic - const TITLE_BLOCK* m_titleBlock; // for basic inscriptions - const wxString* m_paperFormat; // for basic inscriptions - wxString m_fileName; // for basic inscriptions - wxString m_sheetFullName; // for basic inscriptions - wxString m_pageNumber; ///< The actual page number displayed in the title block. - const wxString* m_sheetLayer; // for basic inscriptions - const PROJECT* m_project; // for project-based variable substitutions - public: WS_DRAW_ITEM_LIST() { @@ -561,6 +559,24 @@ public: * @return the text, after replacing the format symbols by the actual value */ wxString BuildFullText( const wxString& aTextbase ); + +protected: + std::vector m_graphicList; // Items to draw/plot + unsigned m_idx; // for GetFirst, GetNext functions + double m_milsToIu; // the scalar to convert pages units ( mils) + // to draw/plot units. + int m_penSize; // The default line width for drawings. + // used when an item has a pen size = 0 + bool m_isFirstPage; ///< Is this the first page or not. + int m_sheetCount; ///< The number of sheets + // for basic inscriptions, in schematic + const TITLE_BLOCK* m_titleBlock; // for basic inscriptions + const wxString* m_paperFormat; // for basic inscriptions + wxString m_fileName; // for basic inscriptions + wxString m_sheetFullName; // for basic inscriptions + wxString m_pageNumber; ///< The actual page number displayed in the title block. + const wxString* m_sheetLayer; // for basic inscriptions + const PROJECT* m_project; // for project-based variable substitutions }; diff --git a/qa/data/complex_hierarchy.kicad_pro b/qa/data/complex_hierarchy.kicad_pro index 09ff48ad10..4cbc91ebcb 100644 --- a/qa/data/complex_hierarchy.kicad_pro +++ b/qa/data/complex_hierarchy.kicad_pro @@ -74,7 +74,6 @@ "invalid_outline": "error", "item_on_disabled_layer": "error", "items_not_allowed": "error", - "keepout": "error", "length_out_of_range": "error", "malformed_courtyard": "error", "microvia_drill_too_small": "error", @@ -95,7 +94,6 @@ "unconnected_items": "error", "unresolved_variable": "error", "via_dangling": "warning", - "via_hole_larger_than_pad": "error", "zone_has_empty_net": "error", "zones_intersect": "error" }, @@ -105,6 +103,7 @@ "max_error": 0.005, "min_clearance": 0.0, "min_copper_edge_clearance": 0.01, + "min_hole_clearance": 0.0, "min_hole_to_hole": 0.25, "min_microvia_diameter": 0.508, "min_microvia_drill": 0.2032,