From 2cd28009efc7a966003a35227613090bcf4cd3fd Mon Sep 17 00:00:00 2001 From: jean-pierre charras <jp.charras@wanadoo.fr> Date: Mon, 30 Dec 2024 16:41:44 +0100 Subject: [PATCH] Define MAX_LAYERS_FOR_VIEW to init GAL::Mxx_DEPTH and VIEW_MAX_LAYERS These values MIN_DEPTH, MAX_DEPTH and VIEW_MAX_LAYERS are coupled, so to avoid mismatch, it is better to derive these values from an unique value --- common/gal/graphics_abstraction_layer.cpp | 11 ++++++++--- include/gal/definitions.h | 5 ++++- include/view/view.h | 7 +++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 89783fe4a7..c8af5ed5f9 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de - * Copyright (C) 2012-2017 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2012-2024 Kicad Developers, see AUTHORS.txt for contributors. * * Graphics Abstraction Layer (GAL) - base class * @@ -236,8 +236,13 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const #endif } -const int GAL::MIN_DEPTH = -2048; -const int GAL::MAX_DEPTH = 2047; +// MIN_DEPTH must be set to be - (VIEW::VIEW_MAX_LAYERS + abs(VIEW::TOP_LAYER_MODIFIER)) +// MAX_DEPTH must be set to be VIEW::VIEW_MAX_LAYERS + abs(VIEW::TOP_LAYER_MODIFIER) -1 +// VIEW_MAX_LAYERS and TOP_LAYER_MODIFIER are defined in view.h. +// TOP_LAYER_MODIFIER is set as -VIEW_MAX_LAYERS +// Currently KIGFX::VIEW::VIEW_MAX_LAYERS = MAX_LAYERS_FOR_VIEW +const int GAL::MIN_DEPTH = -2*MAX_LAYERS_FOR_VIEW; +const int GAL::MAX_DEPTH = 2*MAX_LAYERS_FOR_VIEW - 1; const int GAL::GRID_DEPTH = MAX_DEPTH - 1; diff --git a/include/gal/definitions.h b/include/gal/definitions.h index e15a58a628..96fdff7d52 100644 --- a/include/gal/definitions.h +++ b/include/gal/definitions.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 <at> gmx.de - * Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2024 Kicad Developers, see AUTHORS.txt for contributors. * * Macro definitions * @@ -40,6 +40,9 @@ enum RENDER_TARGET TARGET_TEMP, ///< Temporary target for drawing in separate layer TARGETS_NUMBER ///< Number of available rendering targets }; + +// Used in view.h to initialize VIEW_MAX_LAYERS and graphic_abstraction_layer.cpp +#define MAX_LAYERS_FOR_VIEW 1024 } // namespace KIGFX #endif /* DEFINITIONS_H_ */ diff --git a/include/view/view.h b/include/view/view.h index af4f91e01c..5201ac0783 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -2,7 +2,7 @@ * 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. + * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @@ -37,7 +37,6 @@ #include <gal/definitions.h> #include <view/view_overlay.h> -#include <view/view.h> namespace KIGFX { @@ -739,10 +738,10 @@ public: std::unique_ptr<VIEW> DataReference() const; ///< Maximum number of layers that may be shown - static constexpr int VIEW_MAX_LAYERS = 1024;//512; + static constexpr int VIEW_MAX_LAYERS = MAX_LAYERS_FOR_VIEW; ///< Rendering order modifier for layers that are marked as top layers. - static constexpr int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS; + static constexpr int TOP_LAYER_MODIFIER = -MAX_LAYERS_FOR_VIEW; protected: struct VIEW_LAYER