KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ratsnest_view_item.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 (C) 2013 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
26
27#ifndef RATSNEST_VIEW_ITEM_H
28#define RATSNEST_VIEW_ITEM_H
29
30#include <memory>
31#include <eda_item.h>
32#include <layer_ids.h>
33#include <math/box2.h>
34#include <math/vector2d.h>
36
37class GAL;
39
40
42{
43public:
48 enum class PART
49 {
53 };
54
56 static constexpr int LOCAL_LAYER = static_cast<int>( LAYER_UI_START ) + 2;
57
58 RATSNEST_VIEW_ITEM( std::shared_ptr<CONNECTIVITY_DATA> aData, PART aPart = PART::ALL );
59
60 const BOX2I ViewBBox() const override;
61
62 void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override;
63
64 std::vector<int> ViewGetLayers() const override;
65
80 static bool LineInViewport( const VECTOR2I& aSource, const VECTOR2I& aTarget,
81 const BOX2D& aViewport, bool aCurved );
82
86 static VECTOR2D CurveControlPoint( const VECTOR2D& aSource, const VECTOR2D& aTarget );
87
92 bool BoardInputsChanged( KIGFX::VIEW* aView );
93
94 const std::shared_ptr<CONNECTIVITY_DATA>& GetConnectivity() const { return m_data; }
95
96 bool HitTest( const VECTOR2I& aPoint, int aAccuracy = 0 ) const override
97 {
98 return false; // Not selectable
99 }
100
101#if defined(DEBUG)
102 void Show( int x, std::ostream& st ) const override { }
103#endif
104
105 virtual wxString GetClass() const override
106 {
107 return wxT( "RATSNEST_VIEW_ITEM" );
108 }
109
110protected:
111 std::shared_ptr<CONNECTIVITY_DATA> m_data;
113 size_t m_boardInputs = 0;
114 mutable bool m_drawSkipped = false;
115};
116
117
118#endif /* RATSNEST_VIEW_ITEM_H */
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
BOX2< VECTOR2D > BOX2D
Definition box2.h:915
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Abstract interface for drawing on a 2D-surface.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
RATSNEST_VIEW_ITEM(std::shared_ptr< CONNECTIVITY_DATA > aData, PART aPart=PART::ALL)
bool BoardInputsChanged(KIGFX::VIEW *aView)
Return true when an input to the board's lines other than connectivity has changed since the last cal...
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
PART
The lines an item draws.
static bool LineInViewport(const VECTOR2I &aSource, const VECTOR2I &aTarget, const BOX2D &aViewport, bool aCurved)
Return true when a ratsnest line between aSource and aTarget can contribute to aViewport.
static VECTOR2D CurveControlPoint(const VECTOR2D &aSource, const VECTOR2D &aTarget)
Return the doubled Bezier control point used to bow a curved ratsnest line.
const std::shared_ptr< CONNECTIVITY_DATA > & GetConnectivity() const
std::shared_ptr< CONNECTIVITY_DATA > m_data
Object containing ratsnest data.
bool HitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
virtual wxString GetClass() const override
Return the class name.
static constexpr int LOCAL_LAYER
The local part is drawn on a UI layer, which every canvas keeps on its overlay.
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
size_t m_boardInputs
see BoardInputsChanged()
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
@ LAYER_UI_START
Definition layer_ids.h:375
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707