mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-25 07:24:21 +01:00
6e83012109
The strip seen from above drew no cable at all: it had no zone for one and no code to draw it, so a strip drawn realistically told nothing about where its cables go while the same strip drawn schematically did. The drawing itself was already shared between nothing -- it lived in one style only, so it is now Helpers::drawCables() with its cells, and both styles hand it the terminals they show. The realistic style collects one wire exit per level spread over the width of the terminal body, all of them leaving the strip at its bottom edge, and reserves the zone under the strip for them as soon as one terminal carries a cable, exactly like the schematic style does. tst_cabletarget checks the realistic style paints under the body of the strip when a terminal carries a cable, and drops that zone when it does not.
65 lines
2.7 KiB
C++
65 lines
2.7 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 TERMINALSTRIPDRAWERHELPERS_H
|
|
#define TERMINALSTRIPDRAWERHELPERS_H
|
|
|
|
#include "terminalstripdrawer.h"
|
|
|
|
class QPainter;
|
|
|
|
/**
|
|
* Functions shared by the drawing styles of a terminal strip
|
|
* (schematic style in terminalstripdrawer.cpp, realistic style in realisticterminalstripdrawer.cpp).
|
|
*/
|
|
namespace TerminalStripDrawer
|
|
{
|
|
namespace Helpers
|
|
{
|
|
//Width (mm) of the reference terminal (2.5 mm2), used when the width of a terminal is unknown
|
|
qreal referenceTerminalWidthMm();
|
|
//Fill color and stripe color (can be invalid) of a terminal
|
|
void terminalColors(const QSharedPointer<AbstractRealTerminalInterface> &real_t,
|
|
QColor &fill, QColor &stripe);
|
|
//Black or white, the more readable on background
|
|
QColor contrastColor(const QColor &background);
|
|
//Number of a terminal : "1" for "XAUZ1:1"
|
|
QString terminalNumber(const QString &label);
|
|
//Symbol of the type of the terminal (fuse, diode, led...) scaled to fit in box
|
|
void drawTypeSymbol(QPainter *painter, const QRectF &box,
|
|
ElementData::TerminalType type, bool led);
|
|
//What is needed to draw the cable under a terminal
|
|
struct CableCell
|
|
{
|
|
qreal x{0}; ///< x of the middle of the terminal, in the strip coordinates
|
|
qreal bottom{0}; ///< y of the bottom of the terminal
|
|
QString cable; ///< name of the cable (hose)
|
|
QString wire; ///< color / number of the wire
|
|
bool shield{false}; ///< true if the terminal is the shield of the cable
|
|
QSharedPointer<AbstractRealTerminalInterface> terminal; ///< to ask where the cable goes
|
|
};
|
|
//Draw the cables under the terminals, whichever style draws them :
|
|
//consecutive terminals with the same cable share one cable, which ends
|
|
//together in a short stub and a box naming where it goes (see drawCables()
|
|
//in terminalstripdrawer.cpp for the whole drawing)
|
|
void drawCables(QPainter *painter, const QVector<CableCell> &cells,
|
|
const TerminalStripLayoutPattern &pattern);
|
|
}
|
|
}
|
|
|
|
#endif // TERMINALSTRIPDRAWERHELPERS_H
|