2018-08-03 12:18:26 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-06-19 11:48:00 +00:00
|
|
|
* Copyright (C) 2019-2020 CERN
|
2022-01-25 22:33:37 +00:00
|
|
|
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-02-24 13:48:02 +00:00
|
|
|
*
|
2018-08-03 12:18:26 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* This program 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 this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SCH_PAINTER_H
|
|
|
|
#define __SCH_PAINTER_H
|
|
|
|
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
#include <painter.h>
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
class LIB_PIN;
|
2021-07-18 23:08:54 +00:00
|
|
|
class LIB_SHAPE;
|
2018-08-03 12:18:26 +00:00
|
|
|
class LIB_ITEM;
|
2021-06-10 18:51:46 +00:00
|
|
|
class LIB_SYMBOL;
|
2018-08-03 12:18:26 +00:00
|
|
|
class LIB_FIELD;
|
|
|
|
class LIB_TEXT;
|
2022-01-25 22:33:37 +00:00
|
|
|
class LIB_TEXTBOX;
|
2021-06-10 14:10:55 +00:00
|
|
|
class SCH_SYMBOL;
|
2018-08-03 12:18:26 +00:00
|
|
|
class SCH_FIELD;
|
|
|
|
class SCH_JUNCTION;
|
|
|
|
class SCH_LABEL;
|
|
|
|
class SCH_TEXT;
|
2022-01-25 22:33:37 +00:00
|
|
|
class SCH_TEXTBOX;
|
2018-08-03 12:18:26 +00:00
|
|
|
class SCH_HIERLABEL;
|
2022-01-24 13:40:39 +00:00
|
|
|
class SCH_DIRECTIVE_LABEL;
|
2018-08-03 12:18:26 +00:00
|
|
|
class SCH_GLOBALLABEL;
|
|
|
|
class SCH_SHEET;
|
|
|
|
class SCH_SHEET_PIN;
|
2021-07-17 19:56:18 +00:00
|
|
|
class SCH_SHAPE;
|
2018-08-03 12:18:26 +00:00
|
|
|
class SCH_MARKER;
|
|
|
|
class SCH_NO_CONNECT;
|
|
|
|
class SCH_LINE;
|
|
|
|
class SCH_BUS_ENTRY_BASE;
|
2018-08-27 13:25:48 +00:00
|
|
|
class SCH_BITMAP;
|
2020-05-13 02:00:37 +00:00
|
|
|
class SCHEMATIC;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class GAL;
|
|
|
|
class SCH_PAINTER;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-25 21:13:01 +00:00
|
|
|
* Store schematic specific render settings.
|
2018-08-03 12:18:26 +00:00
|
|
|
*/
|
|
|
|
class SCH_RENDER_SETTINGS : public RENDER_SETTINGS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
friend class SCH_PAINTER;
|
|
|
|
|
|
|
|
SCH_RENDER_SETTINGS();
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
/// @copydoc RENDER_SETTINGS::GetColor()
|
2020-07-11 17:42:00 +00:00
|
|
|
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
bool IsBackgroundDark() const override
|
|
|
|
{
|
|
|
|
auto luma = m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ].GetBrightness();
|
|
|
|
|
|
|
|
return luma < 0.5;
|
|
|
|
}
|
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
const COLOR4D& GetBackgroundColor() const override
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
|
|
|
return m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ];
|
|
|
|
}
|
2018-09-17 23:19:58 +00:00
|
|
|
|
2018-10-03 07:50:05 +00:00
|
|
|
void SetBackgroundColor( const COLOR4D& aColor ) override
|
|
|
|
{
|
|
|
|
m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ] = aColor;
|
|
|
|
}
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
float GetDanglineSymbolThickness() const
|
2020-08-25 12:46:16 +00:00
|
|
|
{
|
|
|
|
return (float) m_defaultPenWidth / 3.0F;
|
|
|
|
}
|
|
|
|
|
2018-09-17 23:19:58 +00:00
|
|
|
const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; }
|
|
|
|
|
|
|
|
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_SCHEMATIC_CURSOR ]; }
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
bool GetShowPageLimits() const override;
|
|
|
|
|
|
|
|
public:
|
2021-09-30 14:44:35 +00:00
|
|
|
bool m_IsSymbolEditor;
|
|
|
|
|
2022-09-06 16:28:44 +00:00
|
|
|
int m_ShowUnit; // Show all units if 0
|
|
|
|
int m_ShowConvert; // Show all conversions if 0
|
2020-04-14 09:08:42 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
bool m_ShowPinsElectricalType;
|
2022-09-06 16:28:44 +00:00
|
|
|
bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific)
|
2020-04-14 12:25:00 +00:00
|
|
|
bool m_ShowDisabled;
|
2021-02-10 22:56:26 +00:00
|
|
|
bool m_ShowGraphicsDisabled;
|
2018-09-02 20:19:22 +00:00
|
|
|
|
2020-04-14 12:25:00 +00:00
|
|
|
bool m_OverrideItemColors;
|
2020-04-04 20:32:14 +00:00
|
|
|
|
2021-07-25 11:42:19 +00:00
|
|
|
double m_LabelSizeRatio; // Proportion of font size to label box
|
2020-04-14 12:25:00 +00:00
|
|
|
double m_TextOffsetRatio; // Proportion of font size to offset text above/below
|
|
|
|
// wires, buses, etc.
|
2020-05-03 23:55:31 +00:00
|
|
|
int m_PinSymbolSize;
|
2018-08-03 12:18:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains methods for drawing schematic-specific items.
|
|
|
|
*/
|
|
|
|
class SCH_PAINTER : public PAINTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SCH_PAINTER( GAL* aGal );
|
|
|
|
|
|
|
|
/// @copydoc PAINTER::Draw()
|
|
|
|
virtual bool Draw( const VIEW_ITEM*, int ) override;
|
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
/// @copydoc PAINTER::GetSettings()
|
2022-08-20 09:27:35 +00:00
|
|
|
virtual SCH_RENDER_SETTINGS* GetSettings() override { return &m_schSettings; }
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
void SetSchematic( SCHEMATIC* aSchematic ) { m_schematic = aSchematic; }
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
private:
|
2022-09-16 16:20:36 +00:00
|
|
|
void draw( const EDA_ITEM*, int, bool aDimmed );
|
|
|
|
void draw( const LIB_PIN* aPin, int aLayer, bool aDimmed );
|
|
|
|
void draw( const LIB_SHAPE* aCircle, int aLayer, bool aDimmed );
|
2021-06-10 18:51:46 +00:00
|
|
|
void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0,
|
2022-09-16 16:20:36 +00:00
|
|
|
int aConvert = 0, bool aDimmed = false );
|
|
|
|
void draw( const LIB_FIELD* aField, int aLayer, bool aDimmed );
|
|
|
|
void draw( const LIB_TEXT* aText, int aLayer, bool aDimmed );
|
|
|
|
void draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed );
|
|
|
|
void draw( const SCH_SYMBOL* aSymbol, int aLayer );
|
2020-12-20 18:44:13 +00:00
|
|
|
void draw( const SCH_JUNCTION* aJct, int aLayer );
|
2022-09-16 16:20:36 +00:00
|
|
|
void draw( const SCH_FIELD* aField, int aLayer, bool aDimmed );
|
2022-01-25 22:33:37 +00:00
|
|
|
void draw( const SCH_SHAPE* aShape, int aLayer );
|
|
|
|
void draw( const SCH_TEXTBOX* aTextBox, int aLayer );
|
2020-12-20 18:44:13 +00:00
|
|
|
void draw( const SCH_TEXT* aText, int aLayer );
|
2021-10-12 20:05:37 +00:00
|
|
|
void draw( const SCH_LABEL* aText, int aLayer );
|
2022-01-24 13:40:39 +00:00
|
|
|
void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer );
|
2021-10-12 20:05:37 +00:00
|
|
|
void draw( const SCH_HIERLABEL* aLabel, int aLayer );
|
|
|
|
void draw( const SCH_GLOBALLABEL* aLabel, int aLayer );
|
2020-12-20 18:44:13 +00:00
|
|
|
void draw( const SCH_SHEET* aSheet, int aLayer );
|
|
|
|
void draw( const SCH_NO_CONNECT* aNC, int aLayer );
|
|
|
|
void draw( const SCH_MARKER* aMarker, int aLayer );
|
|
|
|
void draw( const SCH_BITMAP* aBitmap, int aLayer );
|
|
|
|
void draw( const SCH_LINE* aLine, int aLayer );
|
|
|
|
void draw( const SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-12-06 18:50:00 +00:00
|
|
|
void drawPinDanglingSymbol( const VECTOR2I& aPos, const COLOR4D& aColor,
|
2021-09-15 20:03:07 +00:00
|
|
|
bool aDrawingShadows, bool aBrightened );
|
2021-12-29 21:30:11 +00:00
|
|
|
void drawDanglingSymbol( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
|
2022-12-12 14:03:26 +00:00
|
|
|
bool aDangling, bool aDrawingShadows, bool aBrightened );
|
2019-07-30 01:57:41 +00:00
|
|
|
|
2020-05-03 23:55:31 +00:00
|
|
|
int internalPinDecoSize( const LIB_PIN &aPin );
|
|
|
|
int externalPinDecoSize( const LIB_PIN &aPin );
|
|
|
|
|
2022-02-24 18:15:47 +00:00
|
|
|
// Indicates the item is drawn on a non-cached layer in OpenGL
|
|
|
|
bool nonCached( const EDA_ITEM* aItem );
|
|
|
|
|
2020-12-20 18:44:13 +00:00
|
|
|
bool isUnitAndConversionShown( const LIB_ITEM* aItem ) const;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2021-09-15 20:03:07 +00:00
|
|
|
float getShadowWidth( bool aForHighlight ) const;
|
2022-10-21 21:42:09 +00:00
|
|
|
COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows,
|
|
|
|
bool aDimmed = false ) const;
|
2023-01-28 20:01:58 +00:00
|
|
|
KIFONT::FONT* getFont( const EDA_TEXT* aText ) const;
|
2022-01-25 22:33:37 +00:00
|
|
|
float getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const;
|
2022-05-13 21:36:20 +00:00
|
|
|
float getTextThickness( const EDA_ITEM* aItem ) const;
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
bool setDeviceColors( const LIB_ITEM* aItem, int aLayer, bool aDimmed );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
void triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
|
2021-12-31 14:07:24 +00:00
|
|
|
void strokeText( const wxString& aText, const VECTOR2D& aPosition,
|
|
|
|
const TEXT_ATTRIBUTES& aAttributes );
|
2022-02-23 12:07:33 +00:00
|
|
|
void bitmapText( const wxString& aText, const VECTOR2D& aPosition,
|
|
|
|
const TEXT_ATTRIBUTES& aAttributes );
|
2022-08-20 09:27:35 +00:00
|
|
|
void boxText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2022-05-13 21:36:20 +00:00
|
|
|
public:
|
2022-08-21 19:54:07 +00:00
|
|
|
static std::vector<KICAD_T> g_ScaledSelectionTypes;
|
2022-05-13 21:36:20 +00:00
|
|
|
|
2021-09-15 20:15:55 +00:00
|
|
|
private:
|
2018-08-03 12:18:26 +00:00
|
|
|
SCH_RENDER_SETTINGS m_schSettings;
|
2022-08-20 09:27:35 +00:00
|
|
|
SCHEMATIC* m_schematic;
|
2018-08-03 12:18:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace KIGFX
|
|
|
|
|
|
|
|
|
2020-12-20 18:50:45 +00:00
|
|
|
#endif // __SCH_PAINTER_H
|