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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef KICAD_SCH_DRAG_NET_COLLISION_H
22#define KICAD_SCH_DRAG_NET_COLLISION_H
23
24#include <cstddef>
25#include <optional>
26#include <unordered_map>
27#include <unordered_set>
28#include <vector>
29#include <memory>
30#include <span>
31
32#include <gal/cursors.h>
33#include <math/vector2d.h>
34#include <sch_sheet_path.h>
35
36class SCH_EDIT_FRAME;
37class SCH_ITEM;
38class SCH_JUNCTION;
39class SCH_SELECTION;
40
41namespace KIGFX
42{
43class VIEW;
44class VIEW_OVERLAY;
45}
46
52{
53public:
56
57 void Initialize( const SCH_SELECTION& aSelection );
58
60 {
61 const SCH_ITEM* item;
62 std::optional<int> netCode;
63 };
64
65 bool Update( const std::vector<SCH_JUNCTION*>& aJunctions, const SCH_SELECTION& aSelection,
66 std::span<const PREVIEW_NET_ASSIGNMENT> aPreviewAssignments = {} );
67
68 void Reset();
69
70 KICURSOR AdjustCursor( KICURSOR aBaseCursor ) const;
71
72 std::optional<int> GetNetCode( const SCH_ITEM* aItem ) const;
73
74private:
76 {
78 double radius;
79 };
80
87
95
96 std::optional<COLLISION_MARKER> analyzeJunction( SCH_JUNCTION* aJunction,
97 const SCH_SELECTION& aSelection,
98 const std::unordered_map<const SCH_ITEM*, std::optional<int>>&
99 aPreviewNetCodes ) const;
100
101 void recordItemNet( SCH_ITEM* aItem );
102 void recordOriginalConnections( const SCH_SELECTION& aSelection );
103 std::vector<DISCONNECTION_MARKER> collectDisconnectedMarkers( const SCH_SELECTION& aSelection ) const;
104
105 void ensureOverlay();
106 void clearOverlay() const;
107
108private:
111 std::shared_ptr<KIGFX::VIEW_OVERLAY> m_overlay;
112 std::unordered_map<const SCH_ITEM*, std::optional<int>> m_itemNetCodes;
114 std::vector<ORIGINAL_CONNECTION> m_originalConnections;
116};
117
118#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:63
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:162
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KICURSOR
Definition cursors.h:40
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683