2019-05-20 10:23:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-05-25 11:05:39 +00:00
|
|
|
* Copyright (C) 1992-2019 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-04-13 19:55:27 +00:00
|
|
|
#include <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-01-10 14:31:00 +00:00
|
|
|
* WS_RENDER_SETTINGS
|
2019-05-20 10:23:32 +00:00
|
|
|
* Stores page-layout-specific render settings.
|
|
|
|
*/
|
|
|
|
class WS_RENDER_SETTINGS : public RENDER_SETTINGS
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
|
|
|
|
|
|
|
|
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-01-10 14:31:00 +00:00
|
|
|
* WS_PAINTER
|
2019-05-20 10:23:32 +00:00
|
|
|
* Contains methods for drawing worksheet items.
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-05-31 12:15:25 +00:00
|
|
|
* Function PrintPageLayout is a core function to print the page layout with the frame and the
|
|
|
|
* basic inscriptions.
|
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).
|
|
|
|
* @param aSheetNumber The sheet number (for basic inscriptions).
|
|
|
|
* @param aScalar the scale factor to convert from mils to internal units.
|
|
|
|
* @param aSheetLayer The layer from pcbnew.
|
|
|
|
*
|
|
|
|
* 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,
|
|
|
|
const TITLE_BLOCK& aTitleBlock, int aSheetCount, int aSheetNumber,
|
|
|
|
double aScalar, const PROJECT* aProject,
|
|
|
|
const wxString& aSheetLayer = wxEmptyString );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
#endif // WS_PAINTER_H
|