KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_drag_net_collision.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 * Copyright (C) 2025 VUT Brno, Faculty of Electrical Engineering and Communication
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef KICAD_SCH_DRAG_NET_COLLISION_H
26#define KICAD_SCH_DRAG_NET_COLLISION_H
27
28#include <cstddef>
29#include <optional>
30#include <unordered_map>
31#include <unordered_set>
32#include <vector>
33#include <memory>
34#include <span>
35
36#include <gal/cursors.h>
37#include <math/vector2d.h>
38#include <sch_sheet_path.h>
39
40class SCH_EDIT_FRAME;
41class SCH_ITEM;
42class SCH_JUNCTION;
43class SCH_SELECTION;
44
45namespace KIGFX
46{
47class VIEW;
48class VIEW_OVERLAY;
49}
50
56{
57public:
60
61 void Initialize( const SCH_SELECTION& aSelection );
62
64 {
65 const SCH_ITEM* item;
66 std::optional<int> netCode;
67 };
68
69 bool Update( const std::vector<SCH_JUNCTION*>& aJunctions, const SCH_SELECTION& aSelection,
70 std::span<const PREVIEW_NET_ASSIGNMENT> aPreviewAssignments = {} );
71
72 void Reset();
73
74 KICURSOR AdjustCursor( KICURSOR aBaseCursor ) const;
75
76 std::optional<int> GetNetCode( const SCH_ITEM* aItem ) const;
77
78private:
80 {
82 double radius;
83 };
84
91
99
100 std::optional<COLLISION_MARKER> analyzeJunction( SCH_JUNCTION* aJunction,
101 const SCH_SELECTION& aSelection,
102 const std::unordered_map<const SCH_ITEM*, std::optional<int>>&
103 aPreviewNetCodes ) const;
104
105 void recordItemNet( SCH_ITEM* aItem );
106 void recordOriginalConnections( const SCH_SELECTION& aSelection );
107 std::vector<DISCONNECTION_MARKER> collectDisconnectedMarkers( const SCH_SELECTION& aSelection ) const;
108
109 void ensureOverlay();
110 void clearOverlay() const;
111
112private:
115 std::shared_ptr<KIGFX::VIEW_OVERLAY> m_overlay;
116 std::unordered_map<const SCH_ITEM*, std::optional<int>> m_itemNetCodes;
118 std::vector<ORIGINAL_CONNECTION> m_originalConnections;
120};
121
122#endif // KICAD_SCH_DRAG_NET_COLLISION_H
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
std::optional< COLLISION_MARKER > analyzeJunction(SCH_JUNCTION *aJunction, const SCH_SELECTION &aSelection, const std::unordered_map< const SCH_ITEM *, std::optional< int > > &aPreviewNetCodes) const
std::vector< ORIGINAL_CONNECTION > m_originalConnections
std::vector< DISCONNECTION_MARKER > collectDisconnectedMarkers(const SCH_SELECTION &aSelection) const
std::unordered_map< const SCH_ITEM *, std::optional< int > > m_itemNetCodes
void recordOriginalConnections(const SCH_SELECTION &aSelection)
KICURSOR AdjustCursor(KICURSOR aBaseCursor) const
std::shared_ptr< KIGFX::VIEW_OVERLAY > m_overlay
SCH_DRAG_NET_COLLISION_MONITOR(SCH_EDIT_FRAME *aFrame, KIGFX::VIEW *aView)
std::optional< int > GetNetCode(const SCH_ITEM *aItem) const
bool Update(const std::vector< SCH_JUNCTION * > &aJunctions, const SCH_SELECTION &aSelection, std::span< const PREVIEW_NET_ASSIGNMENT > aPreviewAssignments={})
void Initialize(const SCH_SELECTION &aSelection)
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KICURSOR
Definition cursors.h:44
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695