KiCad PCB EDA Suite
Loading...
Searching...
No Matches
arc_mode_session.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 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <functional>
23#include <optional>
24
25#include <math/vector2d.h>
26#include <tool/arc_draw_mode.h>
28
31class TOOL_EVENT;
32
33
40 SHAPE_DRAW_BEHAVIOR& aBehavior );
41
42
50{
51public:
53 using SEED_FINDER = std::function<std::optional<ARC_TANGENT_SEED>( const VECTOR2I& aMouse,
54 const VECTOR2I& aPos )>;
55
60 ARC_MODE_SESSION( SHAPE_DRAW_BEHAVIOR& aBehavior, APP_SETTINGS_BASE* aSettings, bool aDrawingArc,
61 const std::optional<ARC_TANGENT_SEED>& aChainSeed, SEED_FINDER aFindSeed,
62 std::function<void( ARC_DRAW_MODE )> aOnModeChanged );
63
64 ARC_DRAW_MODE Mode() const;
65
67 void SetMode( ARC_DRAW_MODE aMode );
68
70 bool HandleModeEvent( const TOOL_EVENT& aEvent );
71
73 void PlacePoint( const VECTOR2I& aMouse, const VECTOR2I& aPos );
74
76 void RemoveLastPoint();
77
78private:
83 bool m_clickSeeded = false;
85 std::function<void( ARC_DRAW_MODE )> m_onModeChanged;
86};
ARC_DRAW_MODE
Construction sequence used when interactively drawing a circular arc.
ARC_DRAW_MODE StartArcDrawMode(const TOOL_EVENT &aEvent, APP_SETTINGS_BASE *aSettings, SHAPE_DRAW_BEHAVIOR &aBehavior)
Pick the mode a Draw Arc action starts in and apply it to aBehavior.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
APP_SETTINGS_BASE * m_settings
void PlacePoint(const VECTOR2I &aMouse, const VECTOR2I &aPos)
Lock in a point, or seed a tangent arc from the graphic under it when it would be the arc's first poi...
void RemoveLastPoint()
Undo the last point. A seed taken from a click is undone too, one from a chain is kept.
SHAPE_DRAW_BEHAVIOR & m_behavior
ARC_DRAW_MODE Mode() const
bool HandleModeEvent(const TOOL_EVENT &aEvent)
Handle a mode or cycle action; return true if aEvent was one.
std::function< std::optional< ARC_TANGENT_SEED >(const VECTOR2I &aMouse, const VECTOR2I &aPos)> SEED_FINDER
Tangent seed from a graphic under the cursor, given the raw and the snapped cursor positions.
SEED_FINDER m_findSeed
void SetMode(ARC_DRAW_MODE aMode)
Switch mode mid-draw, which drops any seed. Does nothing unless an arc is being drawn.
ARC_MODE_SESSION(SHAPE_DRAW_BEHAVIOR &aBehavior, APP_SETTINGS_BASE *aSettings, bool aDrawingArc, const std::optional< ARC_TANGENT_SEED > &aChainSeed, SEED_FINDER aFindSeed, std::function< void(ARC_DRAW_MODE)> aOnModeChanged)
std::function< void(ARC_DRAW_MODE)> m_onModeChanged
Abstract interface for interactive shape-drawing behaviours.
Generic, UI-independent tool event.
Definition tool_event.h:167
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708