KiCad PCB EDA Suite
ds_painter.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 // For page and paper size, values are in 1/1000 inch
25 
26 #ifndef DS_PAINTER_H
27 #define DS_PAINTER_H
28 
29 #include <gal/color4d.h>
30 #include <painter.h>
31 #include <page_info.h>
33 
34 // Forward declarations:
35 class EDA_RECT;
36 class TITLE_BLOCK;
37 
38 using KIGFX::COLOR4D;
39 
40 namespace KIGFX
41 {
42 
47 {
48 public:
49  friend class DS_PAINTER;
50 
52 
53  void LoadColors( const COLOR_SETTINGS* aSettings ) override;
54 
56  virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
57 
58  inline bool IsBackgroundDark() const override
59  {
60  auto luma = m_backgroundColor.GetBrightness();
61  return luma < 0.5;
62  }
63 
64  const COLOR4D& GetBackgroundColor() override { return m_backgroundColor; }
65  void SetBackgroundColor( const COLOR4D& aColor ) override { m_backgroundColor = aColor; }
66 
67  void SetNormalColor( const COLOR4D& aColor ) { m_normalColor = aColor; }
68  void SetSelectedColor( const COLOR4D& aColor ) { m_selectedColor = aColor; }
69  void SetBrightenedColor( const COLOR4D& aColor ) { m_brightenedColor = aColor; }
70  void SetPageBorderColor( const COLOR4D& aColor ) { m_pageBorderColor = aColor; }
71 
72  const COLOR4D& GetGridColor() override
73  {
75  return m_gridColor;
76  }
77 
78  const COLOR4D& GetCursorColor() override
79  {
81  return m_cursorColor;
82  }
83 
84 private:
88 
92 };
93 
94 
98 class DS_PAINTER : public PAINTER
99 {
100 public:
101  DS_PAINTER( GAL* aGal ) :
102  PAINTER( aGal )
103  { }
104 
106  virtual bool Draw( const VIEW_ITEM*, int ) override;
107 
108  void DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const;
109 
111  virtual RENDER_SETTINGS* GetSettings() override { return &m_renderSettings; }
112 
113 private:
114  void draw( const DS_DRAW_ITEM_LINE* aItem, int aLayer ) const;
115  void draw( const DS_DRAW_ITEM_RECT* aItem, int aLayer ) const;
116  void draw( const DS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const;
117  void draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const;
118  void draw( const DS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const;
119  void draw( const DS_DRAW_ITEM_PAGE* aItem, int aLayer ) const;
120 
121 private:
123 };
124 
125 } // namespace KIGFX
126 
127 
147 void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
148  const wxString& aFullSheetName, const wxString& aFileName,
149  const TITLE_BLOCK& aTitleBlock, int aSheetCount,
150  const wxString& aPageNumber, double aScalar, const PROJECT* aProject,
151  const wxString& aSheetLayer = wxEmptyString, bool aIsFirstPage = true );
152 
153 #endif // DS_PAINTER_H
const COLOR4D & GetBackgroundColor() override
Return current background color settings.
Definition: ds_painter.h:64
const COLOR4D & GetCursorColor() override
Return current cursor color settings.
Definition: ds_painter.h:78
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, int aSheetCount, const wxString &aPageNumber, double aScalar, const PROJECT *aProject, const wxString &aSheetLayer=wxEmptyString, bool aIsFirstPage=true)
Print the border and title block.
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
Definition: color4d.h:327
Container for project specific data.
Definition: project.h:62
void SetSelectedColor(const COLOR4D &aColor)
Definition: ds_painter.h:68
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:191
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
DS_RENDER_SETTINGS m_renderSettings
Definition: ds_painter.h:122
void DrawBorder(const PAGE_INFO *aPageInfo, int aScaleFactor) const
Definition: ds_painter.cpp:315
const COLOR4D & GetGridColor() override
Return current grid color settings.
Definition: ds_painter.h:72
Definition: color4d.h:44
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
Store page-layout-specific render settings.
Definition: ds_painter.h:46
A graphic text.
Definition: ds_draw_item.h:297
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:57
DS_PAINTER(GAL *aGal)
Definition: ds_painter.h:101
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
void SetBrightenedColor(const COLOR4D &aColor)
Definition: ds_painter.h:69
A rectangle with thick segment showing the page limits and a marker showing the coordinate origin.
Definition: ds_draw_item.h:252
void SetNormalColor(const COLOR4D &aColor)
Definition: ds_painter.h:67
bool IsBackgroundDark() const override
Definition: ds_painter.h:58
void SetPageBorderColor(const COLOR4D &aColor)
Definition: ds_painter.h:70
Definition: color4d.h:48
Non filled rectangle with thick segment.
Definition: ds_draw_item.h:205
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
Definition: ds_painter.cpp:71
Handle the component boundary box.
Definition: eda_rect.h:42
Color settings are a bit different than most of the settings objects in that there can be more than o...
virtual RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: ds_painter.h:111
virtual bool Draw(const VIEW_ITEM *, int) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
Definition: ds_painter.cpp:173
Methods for painting drawing sheet items.
Definition: ds_painter.h:98
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
Definition: ds_painter.h:65
void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: ds_painter.cpp:57
void draw(const DS_DRAW_ITEM_LINE *aItem, int aLayer) const
Definition: ds_painter.cpp:195
Abstract interface for drawing on a 2D-surface.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103