2013-05-19 19:35:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2024-02-29 01:24:12 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-05-19 19:35:49 +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
|
|
|
|
*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <common.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <base_screen.h>
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <title_block.h>
|
2013-05-25 09:01:44 +00:00
|
|
|
#include <build_version.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_draw_item.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_painter.h>
|
|
|
|
#include <drawing_sheet/ds_data_item.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-10-18 18:24:20 +00:00
|
|
|
#include <wx/app.h>
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
using namespace KIGFX;
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2024-01-28 20:46:06 +00:00
|
|
|
static const wxString productName = wxT( "KiCad E.D.A." );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_RENDER_SETTINGS::DS_RENDER_SETTINGS()
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
m_backgroundColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
m_normalColor = RED;
|
|
|
|
m_selectedColor = m_normalColor.Brightened( 0.5 );
|
|
|
|
m_brightenedColor = COLOR4D( 0.0, 1.0, 0.0, 0.9 );
|
2020-02-24 03:39:15 +00:00
|
|
|
m_pageBorderColor = COLOR4D( 0.4, 0.4, 0.4, 1.0 );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void DS_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
|
|
|
for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
|
|
|
|
m_layerColors[ layer ] = aSettings->GetColor( layer );
|
|
|
|
|
|
|
|
for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
|
|
|
|
m_layerColors[ layer ] = aSettings->GetColor( layer );
|
|
|
|
|
|
|
|
m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
|
2020-02-24 03:39:15 +00:00
|
|
|
m_pageBorderColor = aSettings->GetColor( LAYER_SCHEMATIC_GRID );
|
2021-02-22 16:37:43 +00:00
|
|
|
m_normalColor = aSettings->GetColor( LAYER_SCHEMATIC_DRAWINGSHEET );
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
COLOR4D DS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
// Selection disambiguation
|
|
|
|
if( item->IsBrightened() )
|
|
|
|
return m_brightenedColor;
|
|
|
|
|
|
|
|
if( item->IsSelected() )
|
|
|
|
return m_selectedColor;
|
2022-03-31 18:43:08 +00:00
|
|
|
|
|
|
|
if( item->Type() == WSG_TEXT_T )
|
|
|
|
{
|
|
|
|
COLOR4D color = static_cast<const DS_DRAW_ITEM_TEXT*>( item )->GetTextColor();
|
|
|
|
|
|
|
|
if( color != COLOR4D::UNSPECIFIED )
|
|
|
|
return color;
|
|
|
|
}
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m_normalColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void DS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
|
2020-05-30 09:22:19 +00:00
|
|
|
{
|
|
|
|
aVars->push_back( wxT( "KICAD_VERSION" ) );
|
|
|
|
aVars->push_back( wxT( "#" ) );
|
|
|
|
aVars->push_back( wxT( "##" ) );
|
|
|
|
aVars->push_back( wxT( "SHEETNAME" ) );
|
2022-04-09 14:38:47 +00:00
|
|
|
aVars->push_back( wxT( "SHEETPATH" ) );
|
2020-05-30 09:22:19 +00:00
|
|
|
aVars->push_back( wxT( "FILENAME" ) );
|
2023-11-29 14:55:17 +00:00
|
|
|
aVars->push_back( wxT( "FILEPATH" ) );
|
|
|
|
aVars->push_back( wxT( "PROJECTNAME" ) );
|
2020-05-30 09:22:19 +00:00
|
|
|
aVars->push_back( wxT( "PAPER" ) );
|
|
|
|
aVars->push_back( wxT( "LAYER" ) );
|
2021-02-12 16:23:24 +00:00
|
|
|
TITLE_BLOCK::GetContextualTextVars( aVars );
|
2020-05-30 09:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-20 14:25:03 +00:00
|
|
|
// Returns the full text corresponding to the aTextbase, after replacing any text variable
|
|
|
|
// references.
|
2021-02-22 23:47:17 +00:00
|
|
|
wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
2013-05-25 09:01:44 +00:00
|
|
|
{
|
2020-04-05 19:51:48 +00:00
|
|
|
std::function<bool( wxString* )> wsResolver =
|
2024-02-09 12:37:01 +00:00
|
|
|
[&]( wxString* token ) -> bool
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2020-05-28 16:35:41 +00:00
|
|
|
bool tokenUpdated = false;
|
|
|
|
|
2020-10-06 12:20:29 +00:00
|
|
|
if( token->IsSameAs( wxT( "KICAD_VERSION" ) ) && PgmOrNull() )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2024-02-29 01:24:12 +00:00
|
|
|
*token = wxString::Format( wxT( "%s %s" ), productName, GetBaseVersion() );
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2020-04-06 11:41:52 +00:00
|
|
|
else if( token->IsSameAs( wxT( "#" ) ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2020-10-18 20:30:37 +00:00
|
|
|
*token = wxString::Format( wxT( "%s" ), m_pageNumber );
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2020-04-06 11:41:52 +00:00
|
|
|
else if( token->IsSameAs( wxT( "##" ) ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
|
|
|
*token = wxString::Format( wxT( "%d" ), m_sheetCount );
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2020-04-06 11:41:52 +00:00
|
|
|
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2022-04-09 14:38:47 +00:00
|
|
|
*token = m_sheetName;
|
|
|
|
tokenUpdated = true;
|
|
|
|
}
|
|
|
|
else if( token->IsSameAs( wxT( "SHEETPATH" ) ) )
|
|
|
|
{
|
|
|
|
*token = m_sheetPath;
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2020-04-06 11:41:52 +00:00
|
|
|
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
|
|
|
wxFileName fn( m_fileName );
|
|
|
|
*token = fn.GetFullName();
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2023-11-29 14:55:17 +00:00
|
|
|
else if( token->IsSameAs( wxT( "FILEPATH" ) ) )
|
|
|
|
{
|
|
|
|
wxFileName fn( m_fileName );
|
|
|
|
*token = fn.GetFullPath();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if( token->IsSameAs( wxT( "PROJECTNAME" ) ) && m_project )
|
|
|
|
{
|
|
|
|
*token = m_project->GetProjectName();
|
|
|
|
return true;
|
|
|
|
}
|
2020-04-06 11:41:52 +00:00
|
|
|
else if( token->IsSameAs( wxT( "PAPER" ) ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2023-01-18 01:16:57 +00:00
|
|
|
*token = m_paperFormat;
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2020-04-06 11:41:52 +00:00
|
|
|
else if( token->IsSameAs( wxT( "LAYER" ) ) )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2023-01-18 01:16:57 +00:00
|
|
|
*token = m_sheetLayer;
|
2020-05-28 16:35:41 +00:00
|
|
|
tokenUpdated = true;
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2021-01-15 15:40:35 +00:00
|
|
|
else if( m_titleBlock )
|
2020-04-05 19:51:48 +00:00
|
|
|
{
|
2023-01-20 19:19:44 +00:00
|
|
|
if( m_titleBlock->TextVarResolver( token, m_project ) )
|
2024-02-09 12:37:01 +00:00
|
|
|
{
|
|
|
|
// No need for tokenUpdated; TITLE_BLOCK::TextVarResolver() already goes
|
|
|
|
// up to the project.
|
|
|
|
//
|
|
|
|
// However, the title block may have variables in it itself, so we need
|
|
|
|
// to run the worksheet resolver again.
|
|
|
|
//
|
|
|
|
const TITLE_BLOCK* savedTitleBlock = m_titleBlock;
|
|
|
|
|
|
|
|
m_titleBlock = nullptr;
|
|
|
|
{
|
|
|
|
*token = ExpandTextVars( *token, &wsResolver );
|
|
|
|
}
|
|
|
|
m_titleBlock = savedTitleBlock;
|
|
|
|
|
2023-01-20 19:19:44 +00:00
|
|
|
return true;
|
2024-02-09 12:37:01 +00:00
|
|
|
}
|
2020-04-05 19:51:48 +00:00
|
|
|
}
|
2022-09-20 14:25:03 +00:00
|
|
|
else if( m_properties && m_properties->count( *token ) )
|
|
|
|
{
|
|
|
|
*token = m_properties->at( *token );
|
|
|
|
tokenUpdated = true;
|
|
|
|
}
|
2020-04-05 19:51:48 +00:00
|
|
|
|
2020-05-28 16:35:41 +00:00
|
|
|
if( tokenUpdated )
|
|
|
|
{
|
2021-01-17 15:47:04 +00:00
|
|
|
*token = ExpandTextVars( *token, m_project );
|
2020-05-28 16:35:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-01-17 16:54:08 +00:00
|
|
|
if( m_project && m_project->TextVarResolver( token ) )
|
|
|
|
return true;
|
|
|
|
|
2020-04-05 19:51:48 +00:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2023-01-17 16:54:08 +00:00
|
|
|
return ExpandTextVars( aTextbase, &wsResolver );
|
2013-05-25 09:01:44 +00:00
|
|
|
}
|
|
|
|
|
2012-04-01 20:51:56 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
bool KIGFX::DS_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2020-08-15 21:06:10 +00:00
|
|
|
auto item = dynamic_cast<const EDA_ITEM*>( aItem );
|
|
|
|
|
|
|
|
if( !item )
|
|
|
|
return false;
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
case WSG_LINE_T: draw( (DS_DRAW_ITEM_LINE*) item, aLayer ); break;
|
|
|
|
case WSG_POLY_T: draw( (DS_DRAW_ITEM_POLYPOLYGONS*) item, aLayer ); break;
|
|
|
|
case WSG_RECT_T: draw( (DS_DRAW_ITEM_RECT*) item, aLayer ); break;
|
|
|
|
case WSG_TEXT_T: draw( (DS_DRAW_ITEM_TEXT*) item, aLayer ); break;
|
|
|
|
case WSG_BITMAP_T: draw( (DS_DRAW_ITEM_BITMAP*) item, aLayer ); break;
|
|
|
|
case WSG_PAGE_T: draw( (DS_DRAW_ITEM_PAGE*) item, aLayer ); break;
|
2019-05-20 10:23:32 +00:00
|
|
|
default: return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_LINE* aItem, int aLayer ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
2020-04-14 12:25:00 +00:00
|
|
|
m_gal->SetLineWidth( std::max( aItem->GetPenWidth(), m_renderSettings.GetDefaultPenWidth() ) );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_gal->DrawLine( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_RECT* aItem, int aLayer ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetIsFill( false );
|
|
|
|
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
2020-04-14 12:25:00 +00:00
|
|
|
m_gal->SetLineWidth( std::max( aItem->GetPenWidth(), m_renderSettings.GetDefaultPenWidth() ) );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_gal->DrawRectangle( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_POLYPOLYGONS* aItem, int aLayer ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-06-13 11:23:39 +00:00
|
|
|
m_gal->SetFillColor( m_renderSettings.GetColor( aItem, aLayer ) );
|
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( false );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DRAW_ITEM_POLYPOLYGONS* item = (DS_DRAW_ITEM_POLYPOLYGONS*)aItem;
|
2019-06-13 11:23:39 +00:00
|
|
|
|
|
|
|
for( int idx = 0; idx < item->GetPolygons().OutlineCount(); ++idx )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-06-13 11:23:39 +00:00
|
|
|
SHAPE_LINE_CHAIN& outline = item->GetPolygons().Outline( idx );
|
|
|
|
m_gal->DrawPolygon( outline );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2023-05-27 15:30:12 +00:00
|
|
|
KIFONT::FONT* font = aItem->GetFont();
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2021-12-31 14:07:24 +00:00
|
|
|
if( !font )
|
2022-10-22 20:32:10 +00:00
|
|
|
{
|
|
|
|
font = KIFONT::FONT::GetFont( m_renderSettings.GetDefaultFont(), aItem->IsBold(),
|
|
|
|
aItem->IsItalic() );
|
|
|
|
}
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
const COLOR4D& color = m_renderSettings.GetColor( aItem, aLayer );
|
|
|
|
|
|
|
|
m_gal->SetStrokeColor( color );
|
|
|
|
m_gal->SetFillColor( color );
|
|
|
|
|
2023-05-27 15:30:12 +00:00
|
|
|
TEXT_ATTRIBUTES attrs = aItem->GetAttributes();
|
2021-12-31 14:07:24 +00:00
|
|
|
attrs.m_StrokeWidth = std::max( aItem->GetEffectiveTextPenWidth(),
|
|
|
|
m_renderSettings.GetDefaultPenWidth() );
|
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
font->Draw( m_gal, aItem->GetShownText( true ), aItem->GetTextPos(), attrs,
|
|
|
|
aItem->GetFontMetrics() );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
m_gal->Save();
|
2021-02-22 23:47:17 +00:00
|
|
|
auto* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( aItem->GetPeer() );
|
2020-01-24 10:52:41 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
VECTOR2D position = aItem->GetPosition();
|
|
|
|
m_gal->Translate( position );
|
|
|
|
|
2023-02-07 11:07:42 +00:00
|
|
|
// If we've failed to read the bitmap data, don't try to draw it
|
|
|
|
if( !( bitmap && bitmap->m_ImageBitmap
|
|
|
|
&& bitmap->m_ImageBitmap->GetImageData() ) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
// When the image scale factor is not 1.0, we need to modify the actual scale
|
|
|
|
// as the image scale factor is similar to a local zoom
|
|
|
|
double img_scale = bitmap->m_ImageBitmap->GetScale();
|
|
|
|
|
|
|
|
if( img_scale != 1.0 )
|
|
|
|
m_gal->Scale( VECTOR2D( img_scale, img_scale ) );
|
|
|
|
|
|
|
|
m_gal->DrawBitmap( *bitmap->m_ImageBitmap );
|
2020-01-24 10:52:41 +00:00
|
|
|
|
|
|
|
#if 0 // For bounding box debug purpose only
|
2022-08-31 22:57:24 +00:00
|
|
|
BOX2I bbox = aItem->GetBoundingBox();
|
2020-01-24 10:52:41 +00:00
|
|
|
m_gal->SetIsFill( true );
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
m_gal->SetFillColor( COLOR4D( 1, 1, 1, 0.4 ) );
|
|
|
|
m_gal->SetStrokeColor( COLOR4D( 0, 0, 0, 1 ) );
|
|
|
|
|
|
|
|
if( img_scale != 1.0 )
|
|
|
|
m_gal->Scale( VECTOR2D( 1.0, 1.0 ) );
|
|
|
|
|
|
|
|
m_gal->DrawRectangle( VECTOR2D( bbox.GetOrigin() ) - position,
|
|
|
|
VECTOR2D( bbox.GetEnd() ) - position );
|
|
|
|
#endif
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
m_gal->Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_PAGE* aItem, int aLayer ) const
|
2019-06-07 10:42:28 +00:00
|
|
|
{
|
|
|
|
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
|
|
|
|
VECTOR2D end = VECTOR2D( aItem->GetPageSize().x,
|
|
|
|
aItem->GetPageSize().y );
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
|
|
|
|
// Use a gray color for the border color
|
2020-02-24 03:39:15 +00:00
|
|
|
m_gal->SetStrokeColor( m_renderSettings.m_pageBorderColor );
|
2019-06-07 10:42:28 +00:00
|
|
|
m_gal->SetIsFill( false );
|
2021-03-07 12:20:03 +00:00
|
|
|
m_gal->SetLineWidth( m_renderSettings.GetDefaultPenWidth() );
|
|
|
|
|
2019-06-07 10:42:28 +00:00
|
|
|
m_gal->DrawRectangle( origin, end );
|
|
|
|
|
|
|
|
// Draw the corner marker
|
|
|
|
double marker_size = aItem->GetMarkerSize();
|
|
|
|
|
2020-02-24 03:39:15 +00:00
|
|
|
m_gal->SetStrokeColor( m_renderSettings.m_pageBorderColor );
|
2019-06-07 10:42:28 +00:00
|
|
|
VECTOR2D pos = VECTOR2D( aItem->GetMarkerPos().x, aItem->GetMarkerPos().y );
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
// Draw a circle and a X
|
2019-06-07 10:42:28 +00:00
|
|
|
m_gal->DrawCircle( pos, marker_size );
|
|
|
|
m_gal->DrawLine( VECTOR2D( pos.x - marker_size, pos.y - marker_size),
|
|
|
|
VECTOR2D( pos.x + marker_size, pos.y + marker_size ) );
|
|
|
|
m_gal->DrawLine( VECTOR2D( pos.x + marker_size, pos.y - marker_size),
|
|
|
|
VECTOR2D( pos.x - marker_size, pos.y + marker_size ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void KIGFX::DS_PAINTER::DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
|
|
|
|
VECTOR2D end = VECTOR2D( aPageInfo->GetWidthMils() * aScaleFactor,
|
|
|
|
aPageInfo->GetHeightMils() * aScaleFactor );
|
|
|
|
|
|
|
|
m_gal->SetIsStroke( true );
|
|
|
|
// Use a gray color for the border color
|
2020-02-24 03:39:15 +00:00
|
|
|
m_gal->SetStrokeColor( m_renderSettings.m_pageBorderColor );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_gal->SetIsFill( false );
|
2023-12-05 16:30:44 +00:00
|
|
|
m_gal->SetLineWidth( m_renderSettings.GetDefaultPenWidth() );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_gal->DrawRectangle( origin, end );
|
|
|
|
}
|