You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
5.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2019-2020 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef SCH_PAINTER_H
  27. #define SCH_PAINTER_H
  28. #include <sch_render_settings.h>
  29. #include <sch_symbol.h>
  30. #include <gal/painter.h>
  31. class SCH_PIN;
  32. class LIB_SYMBOL;
  33. class SCH_SYMBOL;
  34. class SCH_FIELD;
  35. class SCH_GROUP;
  36. class SCH_JUNCTION;
  37. class SCH_LABEL;
  38. class SCH_TEXT;
  39. class SCH_TEXTBOX;
  40. class SCH_TABLE;
  41. class SCH_HIERLABEL;
  42. class SCH_DIRECTIVE_LABEL;
  43. class SCH_GLOBALLABEL;
  44. class SCH_SHEET;
  45. class SCH_SHEET_PIN;
  46. class SCH_SHAPE;
  47. class SCH_MARKER;
  48. class SCH_NO_CONNECT;
  49. class SCH_LINE;
  50. class SCH_BUS_ENTRY_BASE;
  51. class SCH_BITMAP;
  52. class SCHEMATIC;
  53. namespace KIGFX
  54. {
  55. class GAL;
  56. class SCH_PAINTER;
  57. /**
  58. * Contains methods for drawing schematic-specific items.
  59. */
  60. class SCH_PAINTER : public PAINTER
  61. {
  62. public:
  63. SCH_PAINTER( GAL* aGal );
  64. /// @copydoc PAINTER::Draw()
  65. virtual bool Draw( const VIEW_ITEM*, int ) override;
  66. /// @copydoc PAINTER::GetSettings()
  67. virtual SCH_RENDER_SETTINGS* GetSettings() override { return &m_schSettings; }
  68. void SetSchematic( SCHEMATIC* aSchematic ) { m_schematic = aSchematic; }
  69. private:
  70. void drawItemBoundingBox( const EDA_ITEM* aItem );
  71. void draw( const EDA_ITEM*, int, bool aDimmed );
  72. void draw( const SCH_PIN* aPin, int aLayer, bool aDimmed );
  73. void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0,
  74. int aBodyStyle = 0, bool aDimmed = false );
  75. void draw( const SCH_SYMBOL* aSymbol, int aLayer );
  76. void draw( const SCH_SHAPE* aShape, int aLayer, bool aDimmed );
  77. void draw( const SCH_JUNCTION* aJct, int aLayer );
  78. void draw( const SCH_FIELD* aField, int aLayer, bool aDimmed );
  79. void draw( const SCH_TEXTBOX* aTextBox, int aLayer, bool aDimmed );
  80. void draw( const SCH_TEXT* aText, int aLayer, bool aDimmed );
  81. void draw( const SCH_TABLE* aTable, int aLayer, bool aDimmed );
  82. void draw( const SCH_LABEL* aLabel, int aLayer, bool aDimmed );
  83. void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer, bool aDimmed );
  84. void draw( const SCH_HIERLABEL* aLabel, int aLayer, bool aDimmed );
  85. void draw( const SCH_GLOBALLABEL* aLabel, int aLayer, bool aDimmed );
  86. void draw( const SCH_SHEET* aSheet, int aLayer );
  87. void draw( const SCH_NO_CONNECT* aNC, int aLayer );
  88. void draw( const SCH_MARKER* aMarker, int aLayer );
  89. void draw( const SCH_BITMAP* aBitmap, int aLayer );
  90. void draw( const SCH_LINE* aLine, int aLayer );
  91. void draw( const SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
  92. void draw( const SCH_GROUP* aGroup, int aLayer );
  93. void drawPinDanglingIndicator( const SCH_PIN& aPin, const COLOR4D& aColor, bool aDrawingShadows,
  94. bool aBrightened );
  95. void drawLocalPowerIcon( const VECTOR2D& aPos, double aSize, bool aRotate,
  96. const COLOR4D& aColor, bool aDrawingShadows, bool aBrightened );
  97. /**
  98. * Draw the target (an open square) for a wire or label which has no connection or is
  99. * being moved.
  100. */
  101. void drawDanglingIndicator( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
  102. bool aDangling, bool aDrawingShadows, bool aBrightened );
  103. /// Draw anchor indicating the anchor position of text objects, local labels, or fields.
  104. void drawAnchor( const VECTOR2I& aPos, bool aDrawingShadows );
  105. int internalPinDecoSize( const SCH_PIN &aPin );
  106. int externalPinDecoSize( const SCH_PIN &aPin );
  107. /// Indicates the item is drawn on a non-cached layer in OpenGL.
  108. bool nonCached( const EDA_ITEM* aItem );
  109. bool isUnitAndConversionShown( const SCH_ITEM* aItem ) const;
  110. float getShadowWidth( bool aForHighlight ) const;
  111. COLOR4D getRenderColor( const SCH_ITEM* aItem, int aLayer, bool aDrawingShadows,
  112. bool aDimmed = false, bool aIgnoreNets = false ) const;
  113. KIFONT::FONT* getFont( const EDA_TEXT* aText ) const;
  114. float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows,
  115. bool aDrawingWireColorHighlights = false ) const;
  116. float getTextThickness( const SCH_ITEM* aItem ) const;
  117. int getOperatingPointTextSize() const;
  118. void triLine( const VECTOR2D& a, const VECTOR2D& b, const VECTOR2D& c );
  119. wxString expandLibItemTextVars( const wxString& aSourceText, const SCH_SYMBOL* aSymbolContext );
  120. void drawLine( const VECTOR2I& aStartPoint, const VECTOR2I& aEndPoint, LINE_STYLE aLineStyle,
  121. bool aDrawDirectLine = false, int aWidth = 0 );
  122. public:
  123. static std::vector<KICAD_T> g_ScaledSelectionTypes;
  124. private:
  125. SCH_RENDER_SETTINGS m_schSettings;
  126. SCHEMATIC* m_schematic;
  127. };
  128. }; // namespace KIGFX
  129. #endif // SCH_PAINTER_H