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:
35class TITLE_BLOCK;
36
37using KIGFX::COLOR4D;
38
39namespace KIGFX
40{
41
46{
47public:
48 friend class DS_PAINTER;
49
51
52 void LoadColors( const COLOR_SETTINGS* aSettings ) override;
53
55 virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
56
57 inline bool IsBackgroundDark() const override
58 {
59 auto luma = m_backgroundColor.GetBrightness();
60 return luma < 0.5;
61 }
62
63 const COLOR4D& GetBackgroundColor() const override { return m_backgroundColor; }
64 void SetBackgroundColor( const COLOR4D& aColor ) override { m_backgroundColor = aColor; }
65
66 void SetNormalColor( const COLOR4D& aColor ) { m_normalColor = aColor; }
67 void SetSelectedColor( const COLOR4D& aColor ) { m_selectedColor = aColor; }
68 void SetBrightenedColor( const COLOR4D& aColor ) { m_brightenedColor = aColor; }
69 void SetPageBorderColor( const COLOR4D& aColor ) { m_pageBorderColor = aColor; }
70
71 const COLOR4D& GetGridColor() override
72 {
74 return m_gridColor;
75 }
76
77 const COLOR4D& GetCursorColor() override
78 {
80 return m_cursorColor;
81 }
82
83private:
87
91};
92
93
97class DS_PAINTER : public PAINTER
98{
99public:
100 DS_PAINTER( GAL* aGal ) :
101 PAINTER( aGal )
102 { }
103
105 virtual bool Draw( const VIEW_ITEM*, int ) override;
106
107 void DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const;
108
110 virtual RENDER_SETTINGS* GetSettings() override { return &m_renderSettings; }
111
112private:
113 void draw( const DS_DRAW_ITEM_LINE* aItem, int aLayer ) const;
114 void draw( const DS_DRAW_ITEM_RECT* aItem, int aLayer ) const;
115 void draw( const DS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const;
116 void draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const;
117 void draw( const DS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const;
118 void draw( const DS_DRAW_ITEM_PAGE* aItem, int aLayer ) const;
119
120private:
122};
123
124} // namespace KIGFX
125
126
147void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
148 const wxString& aFullSheetName, const wxString& aFileName,
149 const TITLE_BLOCK& aTitleBlock,
150 const std::map<wxString, wxString>* aProperties, int aSheetCount,
151 const wxString& aPageNumber, double aScalar, const PROJECT* aProject,
152 const wxString& aSheetLayer = wxEmptyString, bool aIsFirstPage = true );
153
154#endif // DS_PAINTER_H
Color settings are a bit different than most of the settings objects in that there can be more than o...
A rectangle with thick segment showing the page limits and a marker showing the coordinate origin.
Definition: ds_draw_item.h:256
Non filled rectangle with thick segment.
Definition: ds_draw_item.h:208
A graphic text.
Definition: ds_draw_item.h:303
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
Definition: color4d.h:343
Methods for painting drawing sheet items.
Definition: ds_painter.h:98
void DrawBorder(const PAGE_INFO *aPageInfo, int aScaleFactor) const
Definition: ds_painter.cpp:338
DS_RENDER_SETTINGS m_renderSettings
Definition: ds_painter.h:121
void draw(const DS_DRAW_ITEM_LINE *aItem, int aLayer) const
Definition: ds_painter.cpp:214
virtual RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: ds_painter.h:110
DS_PAINTER(GAL *aGal)
Definition: ds_painter.h:100
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:192
Store page-layout-specific render settings.
Definition: ds_painter.h:46
const COLOR4D & GetGridColor() override
Return current grid color settings.
Definition: ds_painter.h:71
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
Definition: ds_painter.h:64
void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: ds_painter.cpp:57
void SetBrightenedColor(const COLOR4D &aColor)
Definition: ds_painter.h:68
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
void SetSelectedColor(const COLOR4D &aColor)
Definition: ds_painter.h:67
void SetPageBorderColor(const COLOR4D &aColor)
Definition: ds_painter.h:69
const COLOR4D & GetBackgroundColor() const override
Return current background color settings.
Definition: ds_painter.h:63
bool IsBackgroundDark() const override
Definition: ds_painter.h:57
const COLOR4D & GetCursorColor() override
Return current cursor color settings.
Definition: ds_painter.h:77
void SetNormalColor(const COLOR4D &aColor)
Definition: ds_painter.h:66
Abstract interface for drawing on a 2D-surface.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:58
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
Container for project specific data.
Definition: project.h:64
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
@ WHITE
Definition: color4d.h:48
@ LIGHTGRAY
Definition: color4d.h:47
@ DARKGRAY
Definition: color4d.h:46
@ BLACK
Definition: color4d.h:44
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, const std::map< wxString, wxString > *aProperties, int aSheetCount, const wxString &aPageNumber, double aScalar, const PROJECT *aProject, const wxString &aSheetLayer=wxEmptyString, bool aIsFirstPage=true)
Print the border and title block.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266