KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20// For page and paper size, values are in 1/1000 inch
21
22#ifndef DS_PAINTER_H
23#define DS_PAINTER_H
24
25#include <gal/color4d.h>
26#include <gal/painter.h>
27#include <page_info.h>
29
30// Forward declarations:
31class TITLE_BLOCK;
32
33using KIGFX::COLOR4D;
34
35namespace KIGFX
36{
37
42{
43public:
44 friend class DS_PAINTER;
45
47
48 void LoadColors( const COLOR_SETTINGS* aSettings ) override;
49
51 virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
52
53 inline bool IsBackgroundDark() const override
54 {
55 auto luma = m_backgroundColor.GetBrightness();
56 return luma < 0.5;
57 }
58
59 const COLOR4D& GetBackgroundColor() const override { return m_backgroundColor; }
60 void SetBackgroundColor( const COLOR4D& aColor ) override { m_backgroundColor = aColor; }
61
62 void SetNormalColor( const COLOR4D& aColor ) { m_normalColor = aColor; }
63 void SetSelectedColor( const COLOR4D& aColor ) { m_selectedColor = aColor; }
64 void SetBrightenedColor( const COLOR4D& aColor ) { m_brightenedColor = aColor; }
65 void SetPageBorderColor( const COLOR4D& aColor ) { m_pageBorderColor = aColor; }
66
67 const COLOR4D& GetGridColor() override
68 {
70 return m_gridColor;
71 }
72
73 const COLOR4D& GetCursorColor() override
74 {
76 return m_cursorColor;
77 }
78
79private:
83
87};
88
89
93class DS_PAINTER : public PAINTER
94{
95public:
96 DS_PAINTER( GAL* aGal ) :
97 PAINTER( aGal )
98 { }
99
101 virtual bool Draw( const VIEW_ITEM*, int ) override;
102
103 void DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const;
104
106 virtual RENDER_SETTINGS* GetSettings() override { return &m_renderSettings; }
107
108private:
109 void draw( const DS_DRAW_ITEM_LINE* aItem, int aLayer ) const;
110 void draw( const DS_DRAW_ITEM_RECT* aItem, int aLayer ) const;
111 void draw( const DS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const;
112 void draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const;
113 void draw( const DS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const;
114 void draw( const DS_DRAW_ITEM_PAGE* aItem, int aLayer ) const;
115
116private:
118};
119
120} // namespace KIGFX
121
122
144void PrintDrawingSheet( const RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
145 const wxString& aSheetName, const wxString& aSheetPath,
146 const wxString& aFileName, const TITLE_BLOCK& aTitleBlock,
147 const std::map<wxString, wxString>* aProperties, int aSheetCount,
148 const wxString& aPageNumber, double aScalar, const PROJECT* aProject,
149 const wxString& aSheetLayer = wxEmptyString, bool aIsFirstPage = true );
150
151#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.
Non filled rectangle with thick segment.
A graphic text.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
void DrawBorder(const PAGE_INFO *aPageInfo, int aScaleFactor) const
DS_RENDER_SETTINGS m_renderSettings
Definition ds_painter.h:117
void draw(const DS_DRAW_ITEM_LINE *aItem, int aLayer) const
virtual RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition ds_painter.h:106
DS_PAINTER(GAL *aGal)
Definition ds_painter.h:96
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.
Store page-layout-specific render settings.
Definition ds_painter.h:42
const COLOR4D & GetGridColor() override
Return current grid color settings.
Definition ds_painter.h:67
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
Definition ds_painter.h:60
void LoadColors(const COLOR_SETTINGS *aSettings) override
void SetBrightenedColor(const COLOR4D &aColor)
Definition ds_painter.h:64
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...
void SetSelectedColor(const COLOR4D &aColor)
Definition ds_painter.h:63
void SetPageBorderColor(const COLOR4D &aColor)
Definition ds_painter.h:65
const COLOR4D & GetBackgroundColor() const override
Return current background color settings.
Definition ds_painter.h:59
bool IsBackgroundDark() const override
Definition ds_painter.h:53
const COLOR4D & GetCursorColor() override
Return current cursor color settings.
Definition ds_painter.h:73
void SetNormalColor(const COLOR4D &aColor)
Definition ds_painter.h:62
Abstract interface for drawing on a 2D-surface.
PAINTER(GAL *aGal)
Initialize this object for painting on any of the polymorphic GRAPHICS_ABSTRACTION_LAYER* derivatives...
Definition painter.cpp:29
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:82
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
Container for project specific data.
Definition project.h:62
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition title_block.h:37
@ WHITE
Definition color4d.h:44
@ LIGHTGRAY
Definition color4d.h:43
@ DARKGRAY
Definition color4d.h:42
@ BLACK
Definition color4d.h:40
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aSheetName, const wxString &aSheetPath, 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 eda_group.h:29