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
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
#ifndef WS_PAINTER_H
|
|
|
|
#define WS_PAINTER_H
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
#include <gal/color4d.h>
|
|
|
|
#include <painter.h>
|
|
|
|
#include <page_info.h>
|
2020-10-14 00:23:36 +00:00
|
|
|
#include <page_layout/ws_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
|
|
|
*/
|
2020-10-18 20:30:37 +00:00
|
|
|
class WS_RENDER_SETTINGS : public RENDER_SETTINGS
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-05-25 11:05:39 +00:00
|
|
|
friend class WS_PAINTER;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
WS_RENDER_SETTINGS();
|
|
|
|
|
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
|
|
|
*/
|
2019-05-25 11:05:39 +00:00
|
|
|
class WS_PAINTER : public PAINTER
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_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;
|
|
|
|
|
|
|
|
/// @copydoc PAINTER::ApplySettings()
|
|
|
|
virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
|
|
|
|
{
|
|
|
|
m_renderSettings = *static_cast<const WS_RENDER_SETTINGS*>( aSettings );
|
|
|
|
}
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
/// @copydoc PAINTER::GetAdapter()
|
2019-05-20 10:23:32 +00:00
|
|
|
virtual RENDER_SETTINGS* GetSettings() override { return &m_renderSettings; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const;
|
|
|
|
void draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const;
|
2019-06-13 11:23:39 +00:00
|
|
|
void draw( const WS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const;
|
2019-05-20 10:23:32 +00:00
|
|
|
void draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const;
|
|
|
|
void draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const;
|
2019-06-07 10:42:28 +00:00
|
|
|
void draw( const WS_DRAW_ITEM_PAGE* aItem, int aLayer ) const;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
WS_RENDER_SETTINGS m_renderSettings;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // 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.
|
|
|
|
*/
|
2020-04-14 12:25:00 +00:00
|
|
|
void PrintPageLayout( RENDER_SETTINGS* aSettings, const PAGE_INFO& aPageInfo,
|
|
|
|
const wxString& aFullSheetName, const wxString& aFileName,
|
2020-10-18 20:30:37 +00:00
|
|
|
const TITLE_BLOCK& aTitleBlock, int aSheetCount, const wxString& aPageNumber,
|
2020-04-14 12:25:00 +00:00
|
|
|
double aScalar, const PROJECT* aProject,
|
2020-10-18 20:30:37 +00:00
|
|
|
const wxString& aSheetLayer = wxEmptyString, bool aIsFirstPage = true );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
#endif // WS_PAINTER_H
|