mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-07 20:34:14 +02:00
4b501521a5
"Ajouter un congé" on the drawing toolbar, in Édition > Ajouter and in the command search. Click two lines one after the other, or once where they meet, and a small dialog asks for the radius (remembered for the next one); Enter makes the fillet. The tool stays on for the next corner; Escape or a right-click ends it. The two lines are trimmed -- or extended, when they did not reach each other -- to the points where the arc touches them, and an arc is added between them. For each line the part kept is the one on the side of the corner where it was clicked; a click on the corner keeps the longer part of each. Parallel or nearly aligned lines, and a radius too big for the lines, are refused with a status-bar message. The arc is an ordinary Ellipse shape with a start and end angle, as the Arc tool and the ellipse's arc handles save it, so nothing new is written to the file. It is added by its own small undo command rather than AddGraphicsObjectCommand, whose redo() calls setPos(), and QetShapeItem::setPos() snaps the outline's corner to the grid, which would pull the arc off the lines. One undo step undoes the fillet. New icon draw-fillet, light and dark, registered like the Align icons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef DIAGRAMEVENTFILLET_H
|
|
#define DIAGRAMEVENTFILLET_H
|
|
|
|
#include "diagrameventinterface.h"
|
|
|
|
#include <QPointer>
|
|
#include <QPointF>
|
|
|
|
class QetShapeItem;
|
|
|
|
/**
|
|
@brief The DiagramEventFillet class
|
|
The "add a fillet" tool: rounds the corner between two drawn lines,
|
|
the way a sketch fillet does in a CAD program. Click the two lines
|
|
one after the other, or once where they meet; a dialog asks for the
|
|
radius. The lines are trimmed (or extended) to the points where the
|
|
arc touches them, and an arc is added between them -- an ordinary
|
|
Ellipse shape with a start and end angle, so nothing new is saved.
|
|
*/
|
|
class DiagramEventFillet : public DiagramEventInterface
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
DiagramEventFillet(Diagram *diagram);
|
|
~DiagramEventFillet() override;
|
|
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
|
|
|
private:
|
|
struct Pick {
|
|
QetShapeItem *line = nullptr;
|
|
QPointF pos; // where the line was clicked, in scene coordinates
|
|
};
|
|
|
|
QList<QetShapeItem *> linesNear(const QPointF &scenePos) const;
|
|
void filletLines(const Pick &a, const Pick &b);
|
|
void clearFirstPick();
|
|
void showHint(const QString &text) const;
|
|
void showDefaultHint() const;
|
|
|
|
Pick m_first;
|
|
QPointer<QetShapeItem> m_first_line; // m_first.line, guarded: the line can be deleted between the two clicks
|
|
};
|
|
|
|
#endif // DIAGRAMEVENTFILLET_H
|