51 return std::numeric_limits<double>::infinity();
71 double nearest = std::numeric_limits<double>::infinity();
73 for(
size_t i = 0; i < corners.size(); i++ )
75 SEG side( corners[i], corners[( i + 1 ) % corners.size()] );
76 nearest = std::min( nearest, (
double) side.
Distance( aPointer ) );
83 return std::numeric_limits<double>::infinity();
128 return _(
"More than one shape meets this one here." );
130 return _(
"That shape is too small or too near a full circle to work with." );
132 return _(
"That shape is locked." );
158 { .m_NoResult =
_(
"There is nothing to reach in that direction." ),
159 .m_CommitDescription =
_(
"Extend Line or Arc" ),
170 { .m_NoResult =
_(
"Nothing crosses the shape here." ),
171 .m_CommitDescription =
_(
"Trim Shape" ),
176 .m_QueryBounds =
nullptr,
204 return shape && aOperation.
m_Accepts( *shape );
210 auto collectBoundaries =
213 std::set<const BOARD_ITEM*> seen;
214 std::vector<const BOARD_ITEM*> boundaries;
231 &&
view()->IsVisible( item )
233 && seen.insert( item ).second )
235 boundaries.push_back( item );
248 preview.ClearDrawables();
258 preview.ClearDrawables();
272 BOX2I rayBounds = worldBounds;
274 rayBounds.
Merge( queryBounds );
286 std::vector<const BOARD_ITEM*>
candidates = collectBoundaries( queryBounds, *
source );
291 std::vector<BOARD_ITEM*> lit{
source };
295 const std::vector<GRAPHIC_EDIT_GEOMETRY>& shown = aResult.m_Preview.empty() ? aResult.m_Geometry
299 preview.AddDrawable(
drawable( geometry ),
false, 4 );
301 for(
const BOARD_ITEM* boundary : aResult.m_Boundaries )
302 lit.push_back(
const_cast<BOARD_ITEM*
>( boundary ) );
314 if(
view()->GetGAL()->GetClearColor().Distance( previewColor ) < 0.5 )
317 preview.SetColor( previewColor );
323 frame()->PushTool( aEvent );
341 updatePreview( aPointer,
result );
360 preview.ClearDrawables();
365 if(
result.m_Geometry.empty() )
371 std::vector<PCB_SHAPE*> pieces;
374 for(
size_t i = 1; i <
result.m_Geometry.size(); i++ )
379 pieces.push_back( piece );
385 for(
size_t i = 0; i < pieces.size(); i++ )
388 commit.
Add( pieces[i] );
394 updatePreview( aPointer,
result );
415 event->SetPassEvent();
421 frame()->PopTool( aEvent );
static TOOL_ACTION pickerSubTool
static TOOL_ACTION selectionClear
Clear the current selection.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr bool IsValid() const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
std::vector< VECTOR2I > GetRectCorners() const
void SetFillMode(FILL_T aFill)
The board item under the pointer, and the highlight that follows it.
void BrightenOnly(const std::vector< BOARD_ITEM * > &aItems)
Light exactly these, leaving what is already lit alone.
void ClearBrightening()
Items go back by id, so a commit that replaced one still puts the original back.
BOARD_ITEM * Pick(const VECTOR2I &aPointer, const ACCEPTS &aAccepts, const PROXIMITY &aProximity=nullptr) const
The item a click would take, or null.
A color representation with 4 components: red, green, blue, alpha.
COLOR4D & Invert()
Makes the color inverted, alpha remains the same.
Shows construction geometry for things like line extensions, arc centers, etc.
std::variant< SEG, LINE, HALF_LINE, CIRCLE, SHAPE_ARC, VECTOR2I > DRAWABLE
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
An abstract base class for deriving all objects that can be added to a VIEW.
bool IsBOARD_ITEM() const
int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
static TOOL_ACTION extendGraphic
Extend one graphical line or arc to the nearest boundary.
static TOOL_ACTION trimGraphic
Trim a section from one graphical line or arc.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetShape(SHAPE_T aShape) override
void SetEnd(const VECTOR2I &aEnd) override
void SetStart(const VECTOR2I &aStart) override
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) override
Set the three controlling points for an arc.
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
VECTOR2I NearestPoint(const VECTOR2I &aP) const
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
SHAPE_ARC GraphicEditArc(const PCB_SHAPE &aShape)
bool IsGraphicTrimSource(const PCB_SHAPE &aShape)
Trim also takes the closed shapes, which it opens up.
bool IsGraphicExtendSource(const PCB_SHAPE &aShape)
Extend needs two ends to work with.
const PCB_SHAPE * GraphicEditShape(const EDA_ITEM *aItem)
Any graphical shape a planner or a boundary search might use. Anything else gives null.
GRAPHIC_EDIT_REFUSAL
Why a planner refused. Each one gets its own message.
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc).
@ LAYER_DRC_ERROR
Layer for DRC markers with RPT_SEVERITY_ERROR.
PCB_LAYER_ID
A quick note on layer IDs:
BOX2I QueryBounds(const BOARD_ITEM &aSource, GRAPHIC_ENDPOINT aEndpoint, const BOX2I &aWorldBounds)
GRAPHIC_EDIT_RESULT Plan(const BOARD_ITEM &aSource, GRAPHIC_ENDPOINT aEndpoint, const std::vector< const BOARD_ITEM * > &aBoundaries)
GRAPHIC_EDIT_RESULT Plan(const BOARD_ITEM &aSource, const VECTOR2I &aPointer, const std::vector< const BOARD_ITEM * > &aBoundaries)
Plan removal of the part of aSource under aPointer.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
SHAPE_T m_Shape
A result need not be the same kind as the source.
VECTOR2I m_Mid
Arcs only. Everything else leaves it default.
static std::vector< int > candidates(const SEGMENT_INDEX &aIndex, const SEG &aQuery, int aPadding)
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D