2019-05-20 10:23:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-10-18 20:30:37 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-05-20 10:23:32 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
// For page and paper size, values are in 1/1000 inch
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
#ifndef DS_PAINTER_H
|
|
|
|
#define DS_PAINTER_H
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
#include <gal/color4d.h>
|
|
|
|
#include <painter.h>
|
|
|
|
#include <page_info.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_draw_item.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
// Forward declarations:
|
|
|
|
class EDA_RECT;
|
|
|
|
class TITLE_BLOCK;
|
|
|
|
|
|
|
|
using KIGFX::COLOR4D;
|
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2020-10-18 20:30:37 +00:00
|
|
|
* Store page-layout-specific render settings.
|
2019-05-20 10:23:32 +00:00
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_RENDER_SETTINGS : public RENDER_SETTINGS
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-02-22 23:47:17 +00:00
|
|
|
friend class DS_PAINTER;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_RENDER_SETTINGS();
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
/// @copydoc RENDER_SETTINGS::GetColor()
|
2020-07-11 17:42:00 +00:00
|
|
|
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
inline bool IsBackgroundDark() const override
|
|
|
|
{
|
|
|
|
auto luma = m_backgroundColor.GetBrightness();
|
|
|
|
return luma < 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
const COLOR4D& GetBackgroundColor() override { return m_backgroundColor; }
|
|
|
|
void SetBackgroundColor( const COLOR4D& aColor ) override { m_backgroundColor = aColor; }
|
|
|
|
|
|
|
|
void SetNormalColor( const COLOR4D& aColor ) { m_normalColor = aColor; }
|
|
|
|
void SetSelectedColor( const COLOR4D& aColor ) { m_selectedColor = aColor; }
|
|
|
|
void SetBrightenedColor( const COLOR4D& aColor ) { m_brightenedColor = aColor; }
|
2020-02-24 03:39:15 +00:00
|
|
|
void SetPageBorderColor( const COLOR4D& aColor ) { m_pageBorderColor = aColor; }
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
const COLOR4D& GetGridColor() override
|
|
|
|
{
|
|
|
|
m_gridColor = IsBackgroundDark() ? DARKGRAY : LIGHTGRAY;
|
|
|
|
return m_gridColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
const COLOR4D& GetCursorColor() override
|
|
|
|
{
|
|
|
|
m_cursorColor = IsBackgroundDark() ? WHITE : BLACK;
|
|
|
|
return m_cursorColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
COLOR4D m_normalColor;
|
|
|
|
COLOR4D m_selectedColor;
|
|
|
|
COLOR4D m_brightenedColor;
|
|
|
|
|
|
|
|
COLOR4D m_gridColor;
|
|
|
|
COLOR4D m_cursorColor;
|
2020-02-24 03:39:15 +00:00
|
|
|
COLOR4D m_pageBorderColor;
|
2019-05-20 10:23:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-10-18 20:30:37 +00:00
|
|
|
* Methods for drawing worksheet items.
|
2019-05-20 10:23:32 +00:00
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
class DS_PAINTER : public PAINTER
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_PAINTER( GAL* aGal ) :
|
2019-05-20 10:23:32 +00:00
|
|
|
PAINTER( aGal )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
/// @copydoc PAINTER::Draw()
|
|
|
|
virtual bool Draw( const VIEW_ITEM*, int ) override;
|
|
|
|
|
|
|
|
void DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const;
|
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
/// @copydoc PAINTER::GetSettings()
|
2019-05-20 10:23:32 +00:00
|
|
|
virtual RENDER_SETTINGS* GetSettings() override { return &m_renderSettings; }
|
|
|
|
|
|
|
|
private:
|
2021-02-22 23:47:17 +00:00
|
|
|
void draw( const DS_DRAW_ITEM_LINE* aItem, int aLayer ) const;
|
|
|
|
void draw( const DS_DRAW_ITEM_RECT* aItem, int aLayer ) const;
|
|
|
|
void draw( const DS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const;
|
|
|
|
void draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const;
|
|
|
|
void draw( const DS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const;
|
|
|
|
void draw( const DS_DRAW_ITEM_PAGE* aItem, int aLayer ) const;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
private:
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_RENDER_SETTINGS m_renderSettings;
|
2019-05-20 10:23:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KIGFX
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-10-18 20:30:37 +00:00
|
|
|
* Print the border and title block.
|
|
|
|
*
|
2019-05-20 10:23:32 +00:00
|
|
|
* @param aDC The device context.
|
|
|
|
* @param aPageInfo for margins and page size (in mils).
|
|
|
|
* @param aFullSheetName The sheetpath (full sheet name), for basic inscriptions.
|
|
|
|
* @param aFileName The file name, for basic inscriptions.
|
|
|
|
* @param aTitleBlock The sheet title block, for basic inscriptions.
|
|
|
|
* @param aSheetCount The number of sheets (for basic inscriptions).
|
2020-10-18 20:30:37 +00:00
|
|
|
* @param aPageNumber The page number.
|
2019-05-20 10:23:32 +00:00
|
|
|
* @param aScalar the scale factor to convert from mils to internal units.
|
2020-10-18 20:30:37 +00:00
|
|
|
* @param aSheetLayer The layer from Pcbnew.
|
|
|
|
* @param aIsFirstPage True when this is the first page. This only has meaning for schematics.
|
2019-05-20 10:23:32 +00:00
|
|
|
*
|
|
|
|
* Parameters used in aPageInfo
|
|
|
|
* - the size of the page layout.
|
|
|
|
* - the LTmargin The left top margin of the page layout.
|
|
|
|
* - the RBmargin The right bottom margin of the page layout.
|
|
|
|
*/
|
2021-02-22 23:47:17 +00:00
|
|
|
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 );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
#endif // DS_PAINTER_H
|