2018-08-03 12:18:26 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-03-17 19:50:18 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
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
|
|
|
|
|
2019-04-03 09:14:36 +00:00
|
|
|
#include <sch_component.h>
|
|
|
|
|
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_RECTANGLE;
|
|
|
|
class LIB_PIN;
|
|
|
|
class LIB_CIRCLE;
|
|
|
|
class LIB_ITEM;
|
|
|
|
class LIB_PART;
|
|
|
|
class LIB_POLYLINE;
|
|
|
|
class LIB_ARC;
|
|
|
|
class LIB_FIELD;
|
|
|
|
class LIB_TEXT;
|
2019-02-19 09:41:21 +00:00
|
|
|
class LIB_BEZIER;
|
2018-08-03 12:18:26 +00:00
|
|
|
class SCH_COMPONENT;
|
|
|
|
class SCH_FIELD;
|
|
|
|
class SCH_JUNCTION;
|
|
|
|
class SCH_LABEL;
|
|
|
|
class SCH_TEXT;
|
|
|
|
class SCH_HIERLABEL;
|
|
|
|
class SCH_GLOBALLABEL;
|
|
|
|
class SCH_SHEET;
|
|
|
|
class SCH_SHEET_PIN;
|
|
|
|
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;
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class GAL;
|
|
|
|
class SCH_PAINTER;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* SCH_RENDER_SETTINGS
|
2018-08-03 12:18:26 +00:00
|
|
|
* Stores schematic-specific render settings.
|
|
|
|
*/
|
|
|
|
|
|
|
|
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()
|
|
|
|
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
|
|
|
|
|
|
|
|
bool IsBackgroundDark() const override
|
|
|
|
{
|
|
|
|
auto luma = m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ].GetBrightness();
|
|
|
|
|
|
|
|
return luma < 0.5;
|
|
|
|
}
|
|
|
|
|
2019-11-06 19:15:42 +00:00
|
|
|
const COLOR4D& GetBackgroundColor() override
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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 ]; }
|
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
int m_ShowUnit; // Show all units if 0
|
|
|
|
int m_ShowConvert; // Show all conversions if 0
|
|
|
|
|
|
|
|
bool m_ShowHiddenText;
|
|
|
|
bool m_ShowHiddenPins;
|
|
|
|
bool m_ShowPinsElectricalType;
|
2019-11-06 19:15:42 +00:00
|
|
|
bool m_ShowDisabled;
|
2018-11-14 21:54:53 +00:00
|
|
|
bool m_ShowUmbilicals;
|
2018-08-03 12:18:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* SCH_PAINTER
|
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;
|
|
|
|
|
|
|
|
/// @copydoc PAINTER::ApplySettings()
|
|
|
|
virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
|
|
|
|
{
|
|
|
|
m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @copydoc PAINTER::GetSettings()
|
|
|
|
virtual SCH_RENDER_SETTINGS* GetSettings() override
|
|
|
|
{
|
|
|
|
return &m_schSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-03-17 19:50:18 +00:00
|
|
|
void draw( LIB_RECTANGLE* aRect, int aLayer );
|
2019-04-19 15:54:29 +00:00
|
|
|
void draw( LIB_PIN* aPin, int aLayer );
|
2019-03-17 19:50:18 +00:00
|
|
|
void draw( LIB_CIRCLE* aCircle, int aLayer );
|
2019-04-19 15:54:29 +00:00
|
|
|
void draw( LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 );
|
2019-03-17 19:50:18 +00:00
|
|
|
void draw( LIB_ARC* aArc, int aLayer );
|
|
|
|
void draw( LIB_POLYLINE* aLine, int aLayer );
|
|
|
|
void draw( LIB_FIELD* aField, int aLayer );
|
|
|
|
void draw( LIB_TEXT* aText, int aLayer );
|
|
|
|
void draw( LIB_BEZIER* aCurve, int aLayer );
|
|
|
|
void draw( SCH_COMPONENT* aComp, int aLayer );
|
|
|
|
void draw( SCH_JUNCTION* aJct, int aLayer );
|
|
|
|
void draw( SCH_FIELD* aField, int aLayer );
|
|
|
|
void draw( SCH_TEXT* aText, int aLayer );
|
|
|
|
void draw( SCH_HIERLABEL* aLabel, int aLayer );
|
|
|
|
void draw( SCH_GLOBALLABEL* aLabel, int aLayer );
|
|
|
|
void draw( SCH_SHEET* aSheet, int aLayer );
|
|
|
|
void draw( SCH_NO_CONNECT* aNC, int aLayer );
|
|
|
|
void draw( SCH_MARKER* aMarker, int aLayer );
|
|
|
|
void draw( SCH_BITMAP* aBitmap, int aLayer );
|
|
|
|
void draw( SCH_LINE* aLine, int aLayer );
|
|
|
|
void draw( SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
void drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows );
|
|
|
|
void drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows );
|
|
|
|
|
2018-09-02 20:19:22 +00:00
|
|
|
bool isUnitAndConversionShown( const LIB_ITEM* aItem );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
float getShadowWidth();
|
|
|
|
COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows );
|
|
|
|
float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows );
|
|
|
|
float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows );
|
|
|
|
float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows );
|
2019-04-19 15:54:29 +00:00
|
|
|
|
2019-07-30 01:57:41 +00:00
|
|
|
bool setDeviceColors( const LIB_ITEM* aItem, int aLayer );
|
2019-11-21 15:48:44 +00:00
|
|
|
void fillIfSelection( int aLayer );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
|
2019-10-21 18:03:54 +00:00
|
|
|
void strokeText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle );
|
2018-08-03 12:18:26 +00:00
|
|
|
|
|
|
|
SCH_RENDER_SETTINGS m_schSettings;
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace KIGFX
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|