LibrePCB Developers Documentation
BoardEditorState_DrawTrace Class Referencefinal

The "draw trace" state/tool of the board editor. More...

#include <boardeditorstate_drawtrace.h>

+ Inheritance diagram for BoardEditorState_DrawTrace:
+ Collaboration diagram for BoardEditorState_DrawTrace:

Public Member Functions

 BoardEditorState_DrawTrace ()=delete
 
 BoardEditorState_DrawTrace (const BoardEditorState_DrawTrace &other)=delete
 
 BoardEditorState_DrawTrace (const Context &context) noexcept
 
virtual ~BoardEditorState_DrawTrace () noexcept
 
virtual bool entry () noexcept override
 
virtual bool exit () noexcept override
 
virtual bool processAbortCommand () noexcept override
 
virtual bool processKeyPressed (const QKeyEvent &e) noexcept override
 
virtual bool processKeyReleased (const QKeyEvent &e) noexcept override
 
virtual bool processGraphicsSceneMouseMoved (QGraphicsSceneMouseEvent &e) noexcept override
 
virtual bool processGraphicsSceneLeftMouseButtonPressed (QGraphicsSceneMouseEvent &e) noexcept override
 
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked (QGraphicsSceneMouseEvent &e) noexcept override
 
virtual bool processGraphicsSceneRightMouseButtonReleased (QGraphicsSceneMouseEvent &e) noexcept override
 
virtual bool processSwitchToBoard (int index) noexcept override
 
BoardEditorState_DrawTraceoperator= (const BoardEditorState_DrawTrace &rhs)=delete
 
- Public Member Functions inherited from BoardEditorState
 BoardEditorState ()=delete
 
 BoardEditorState (const BoardEditorState &other)=delete
 
 BoardEditorState (const Context &context, QObject *parent=nullptr) noexcept
 
virtual ~BoardEditorState () noexcept
 
virtual bool entry () noexcept
 
virtual bool exit () noexcept
 
virtual bool processAddDevice (ComponentInstance &component, const Uuid &device, const Uuid &footprint) noexcept
 
virtual bool processImportDxf () noexcept
 
virtual bool processSelectAll () noexcept
 
virtual bool processCut () noexcept
 
virtual bool processCopy () noexcept
 
virtual bool processPaste () noexcept
 
virtual bool processMove (const Point &delta) noexcept
 
virtual bool processRotate (const Angle &rotation) noexcept
 
virtual bool processFlip (Qt::Orientation orientation) noexcept
 
virtual bool processSnapToGrid () noexcept
 
virtual bool processSetLocked (bool locked) noexcept
 
virtual bool processChangeLineWidth (int step) noexcept
 
virtual bool processResetAllTexts () noexcept
 
virtual bool processRemove () noexcept
 
virtual bool processEditProperties () noexcept
 
virtual bool processAbortCommand () noexcept
 
virtual bool processKeyPressed (const QKeyEvent &e) noexcept
 
virtual bool processKeyReleased (const QKeyEvent &e) noexcept
 
virtual bool processGraphicsSceneMouseMoved (QGraphicsSceneMouseEvent &e) noexcept
 
virtual bool processGraphicsSceneLeftMouseButtonPressed (QGraphicsSceneMouseEvent &e) noexcept
 
virtual bool processGraphicsSceneLeftMouseButtonReleased (QGraphicsSceneMouseEvent &e) noexcept
 
virtual bool processGraphicsSceneLeftMouseButtonDoubleClicked (QGraphicsSceneMouseEvent &e) noexcept
 
virtual bool processGraphicsSceneRightMouseButtonReleased (QGraphicsSceneMouseEvent &e) noexcept
 
virtual bool processSwitchToBoard (int index) noexcept
 
BoardEditorStateoperator= (const BoardEditorState &rhs)=delete
 

Private Types

enum  SubState
 Internal FSM States (substates) More...
 
enum class  WireMode
 All available wire modes. More...
 

Private Member Functions

bool startPositioning (Board &board, const Point &pos, BI_NetPoint *fixedPoint=nullptr, BI_Via *fixedVia=nullptr, BI_FootprintPad *fixedPad=nullptr) noexcept
 Begin drawing the next BI_NetLine. More...
 
bool addNextNetPoint (BoardGraphicsScene &scene) noexcept
 Finalize the BI_NetLines and connect them to other existing traces if necessary. More...
 
bool abortPositioning (bool showErrMsgBox) noexcept
 Abort or cancel the current drawing of the trace. More...
 
void updateNetpointPositions () noexcept
 Update the currently active traces according to the set parameters. More...
 
void showVia (bool isVisible) noexcept
 Sets the BI_Via of the currently active trace. More...
 
BI_NetLineAnchorcombineAnchors (BI_NetLineAnchor &a, BI_NetLineAnchor &b)
 
void wireModeChanged (WireMode mode) noexcept
 
void layerChanged (const Layer &layer) noexcept
 
void sizeEditValueChanged (const PositiveLength &value) noexcept
 
void drillDiameterEditValueChanged (const PositiveLength &value) noexcept
 
void wireWidthEditValueChanged (const PositiveLength &value) noexcept
 
void wireAutoWidthEditToggled (const bool checked) noexcept
 
Point calcMiddlePointPos (const Point &p1, const Point p2, WireMode mode) const noexcept
 Calculate the 'middle point' of two point, according to the chosen WireMode. More...
 

Private Attributes

SubState mSubState
 the current substate More...
 
WireMode mCurrentWireMode
 the current wire mode More...
 
const LayermCurrentLayer
 the current board layer name More...
 
bool mAddVia
 whether a via add is requested More...
 
BI_ViamTempVia
 
Via mCurrentViaProperties
 
tl::optional< const Layer & > mViaLayer
 Layer where the via was started. More...
 
Point mTargetPos
 
Point mCursorPos
 the current cursor position More...
 
PositiveLength mCurrentWidth
 the current wire width More...
 
bool mCurrentAutoWidth
 automatically adjust wire width More...
 
bool mCurrentSnapActive
 the current active snap to target More...
 
BI_NetLineAnchormFixedStartAnchor
 
BI_NetSegmentmCurrentNetSegment
 
BI_NetLinemPositioningNetLine1
 line between fixed point and p1 More...
 
BI_NetPointmPositioningNetPoint1
 the first netpoint to place More...
 
BI_NetLinemPositioningNetLine2
 line between p1 and p2 More...
 
BI_NetPointmPositioningNetPoint2
 the second netpoint to place More...
 
QPointer< LayerComboBoxmLayerComboBox
 
QPointer< PositiveLengthEditmSizeEdit
 
QPointer< PositiveLengthEditmDrillEdit
 
QPointer< PositiveLengthEditmWidthEdit
 
QPointer< QActionGroup > mWireModeActionGroup
 

Additional Inherited Members

- Public Types inherited from BoardEditorState
enum class  FindFlag
 
using Context = BoardEditorFsm::Context
 
- Signals inherited from BoardEditorState
void requestLeavingState ()
 Signal to indicate that the current tool should be exited. More...
 
void statusBarMessageChanged (const QString &message, int timeoutMs=-1)
 
- Protected Member Functions inherited from BoardEditorState
BoardgetActiveBoard () noexcept
 
BoardGraphicsScenegetActiveBoardScene () noexcept
 
bool getIgnoreLocks () const noexcept
 
PositiveLength getGridInterval () const noexcept
 
const LengthUnitgetLengthUnit () const noexcept
 
QSet< const Layer * > getAllowedGeometryLayers () noexcept
 
void makeLayerVisible (const QString &layer) noexcept
 
void abortBlockingToolsInOtherEditors () noexcept
 
bool execCmd (UndoCommand *cmd)
 
QWidget * parentWidget () noexcept
 
QList< std::shared_ptr< QGraphicsItem > > findItemsAtPos (const Point &pos, FindFlags flags, const tl::optional< const Layer & > cuLayer=tl::nullopt, const QSet< const NetSignal * > &netsignals={}, const QVector< std::shared_ptr< QGraphicsItem > > &except={}) noexcept
 
template<typename T = QGraphicsItem>
std::shared_ptr< T > findItemAtPos (const Point &pos, FindFlags flags, const tl::optional< const Layer & > cuLayer=tl::nullopt, const QSet< const NetSignal * > &netsignals={}, const QVector< std::shared_ptr< QGraphicsItem > > &except={}) noexcept
 
- Protected Attributes inherited from BoardEditorState
Context mContext
 

Detailed Description

The "draw trace" state/tool of the board editor.

Member Enumeration Documentation

◆ SubState

enum SubState
private

Internal FSM States (substates)

Enumerator
SubState_Idle 

idle state [initial state]

SubState_Initializing 

beginning to start

SubState_PositioningNetPoint 

in this state, an undo command is active!

◆ WireMode

enum class WireMode
strongprivate

All available wire modes.

Enumerator
HV 

horizontal - vertical [default]

VH 

vertical - horizontal

Deg9045 

90° - 45°

Deg4590 

45° - 90°

Straight 

straight

Constructor & Destructor Documentation

◆ BoardEditorState_DrawTrace() [1/3]

◆ BoardEditorState_DrawTrace() [2/3]

◆ BoardEditorState_DrawTrace() [3/3]

BoardEditorState_DrawTrace ( const Context context)
explicitnoexcept

◆ ~BoardEditorState_DrawTrace()

~BoardEditorState_DrawTrace ( )
virtualnoexcept

Member Function Documentation

◆ entry()

bool entry ( )
overridevirtualnoexcept

Reimplemented from BoardEditorState.

+ Here is the call graph for this function:

◆ exit()

bool exit ( )
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processAbortCommand()

bool processAbortCommand ( )
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processKeyPressed()

bool processKeyPressed ( const QKeyEvent &  e)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processKeyReleased()

bool processKeyReleased ( const QKeyEvent &  e)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processGraphicsSceneMouseMoved()

bool processGraphicsSceneMouseMoved ( QGraphicsSceneMouseEvent &  e)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processGraphicsSceneLeftMouseButtonPressed()

bool processGraphicsSceneLeftMouseButtonPressed ( QGraphicsSceneMouseEvent &  e)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

+ Here is the call graph for this function:

◆ processGraphicsSceneLeftMouseButtonDoubleClicked()

bool processGraphicsSceneLeftMouseButtonDoubleClicked ( QGraphicsSceneMouseEvent &  e)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processGraphicsSceneRightMouseButtonReleased()

bool processGraphicsSceneRightMouseButtonReleased ( QGraphicsSceneMouseEvent &  e)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ processSwitchToBoard()

bool processSwitchToBoard ( int  index)
overridevirtualnoexcept

Reimplemented from BoardEditorState.

◆ operator=()

BoardEditorState_DrawTrace & operator= ( const BoardEditorState_DrawTrace rhs)
delete

◆ startPositioning()

bool startPositioning ( Board board,
const Point pos,
BI_NetPoint fixedPoint = nullptr,
BI_Via fixedVia = nullptr,
BI_FootprintPad fixedPad = nullptr 
)
privatenoexcept

Begin drawing the next BI_NetLine.

Parameters
boardOn which board the new traces are drawn.
posThe position, where the tracing should begin. If necessary, a new BI_NetPoint is created.
fixedPointThe BI_NetPoint used as the start anchor, when beginning a new trace.
fixedViaThe BI_Via used as the start anchor, when beginning a new trace.
fixedPadThe BI_FootprintPad used as the start anchor, when beginning a new trace.
Returns
True, when the tracing is successfully started.
+ Here is the call graph for this function:

◆ addNextNetPoint()

bool addNextNetPoint ( BoardGraphicsScene scene)
privatenoexcept

Finalize the BI_NetLines and connect them to other existing traces if necessary.

Parameters
sceneOn which board scene the drawing is finalized.
Returns
True, when the trace is successfully drawn. When the trace is continued, return the result of startPositioning(). False when canceled or an error occurred
+ Here is the call graph for this function:

◆ abortPositioning()

bool abortPositioning ( bool  showErrMsgBox)
privatenoexcept

Abort or cancel the current drawing of the trace.

Parameters
showErrMsgBoxWhen true, show an error message in a pop-up box.
+ Here is the call graph for this function:

◆ updateNetpointPositions()

void updateNetpointPositions ( )
privatenoexcept

Update the currently active traces according to the set parameters.

Uses the current mCursorPos to where the currently active trace is snapped to and how its BI_NetLine are palced. Also determines whether a BI_Via should be added or if the target anchor can provide the desired layer change.

+ Here is the call graph for this function:

◆ showVia()

void showVia ( bool  isVisible)
privatenoexcept

Sets the BI_Via of the currently active trace.

When true, adds a BI_Via instead of the current last BI_NetPoint to the currently active trace. Otherwise removes it if necessary and replaces it again with a BI_NetPoint. It also updates the BI_Via according to the currently selected parameters.

Warning
mPositioningNetPoint2 and mTempVia are exclusive. If one is set, the other is nullptr and vice versa.
Parameters
isVisibleWhether the BI_Via is shown or not
+ Here is the call graph for this function:

◆ combineAnchors()

BI_NetLineAnchor * combineAnchors ( BI_NetLineAnchor a,
BI_NetLineAnchor b 
)
private
+ Here is the call graph for this function:

◆ wireModeChanged()

void wireModeChanged ( WireMode  mode)
privatenoexcept
+ Here is the caller graph for this function:

◆ layerChanged()

void layerChanged ( const Layer layer)
privatenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeEditValueChanged()

void sizeEditValueChanged ( const PositiveLength value)
privatenoexcept
+ Here is the caller graph for this function:

◆ drillDiameterEditValueChanged()

void drillDiameterEditValueChanged ( const PositiveLength value)
privatenoexcept
+ Here is the caller graph for this function:

◆ wireWidthEditValueChanged()

void wireWidthEditValueChanged ( const PositiveLength value)
privatenoexcept
+ Here is the caller graph for this function:

◆ wireAutoWidthEditToggled()

void wireAutoWidthEditToggled ( const bool  checked)
privatenoexcept
+ Here is the caller graph for this function:

◆ calcMiddlePointPos()

Point calcMiddlePointPos ( const Point p1,
const Point  p2,
WireMode  mode 
) const
privatenoexcept

Calculate the 'middle point' of two point, according to the chosen WireMode.

Parameters
p1Start point.
p2End point.
modeThe selected WireMode.
Returns
Middle Point.
+ Here is the call graph for this function:

Member Data Documentation

◆ mSubState

SubState mSubState
private

the current substate

◆ mCurrentWireMode

WireMode mCurrentWireMode
private

the current wire mode

◆ mCurrentLayer

const Layer* mCurrentLayer
private

the current board layer name

◆ mAddVia

bool mAddVia
private

whether a via add is requested

◆ mTempVia

BI_Via* mTempVia
private

◆ mCurrentViaProperties

Via mCurrentViaProperties
private

The current Via properties diameter

◆ mViaLayer

tl::optional<const Layer&> mViaLayer
private

Layer where the via was started.

◆ mTargetPos

Point mTargetPos
private

the current target position of the active trace

◆ mCursorPos

Point mCursorPos
private

the current cursor position

◆ mCurrentWidth

PositiveLength mCurrentWidth
private

the current wire width

◆ mCurrentAutoWidth

bool mCurrentAutoWidth
private

automatically adjust wire width

◆ mCurrentSnapActive

bool mCurrentSnapActive
private

the current active snap to target

◆ mFixedStartAnchor

BI_NetLineAnchor* mFixedStartAnchor
private

the fixed netline anchor (start point of the line)

◆ mCurrentNetSegment

BI_NetSegment* mCurrentNetSegment
private

the net segment that is currently edited

◆ mPositioningNetLine1

BI_NetLine* mPositioningNetLine1
private

line between fixed point and p1

◆ mPositioningNetPoint1

BI_NetPoint* mPositioningNetPoint1
private

the first netpoint to place

◆ mPositioningNetLine2

BI_NetLine* mPositioningNetLine2
private

line between p1 and p2

◆ mPositioningNetPoint2

BI_NetPoint* mPositioningNetPoint2
private

the second netpoint to place

◆ mLayerComboBox

QPointer<LayerComboBox> mLayerComboBox
private

◆ mSizeEdit

QPointer<PositiveLengthEdit> mSizeEdit
private

◆ mDrillEdit

QPointer<PositiveLengthEdit> mDrillEdit
private

◆ mWidthEdit

QPointer<PositiveLengthEdit> mWidthEdit
private

◆ mWireModeActionGroup

QPointer<QActionGroup> mWireModeActionGroup
private

The documentation for this class was generated from the following files: