2013-05-24 08:59:40 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
|
2019-05-25 13:56:52 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-05-24 08:59:40 +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
|
|
|
|
*/
|
|
|
|
|
2013-06-07 09:49:36 +00:00
|
|
|
|
|
|
|
/*
|
2019-05-25 11:05:39 +00:00
|
|
|
* the class WS_DATA_ITEM (and derived) defines
|
2013-06-07 09:49:36 +00:00
|
|
|
* a basic shape of a page layout ( frame references and title block )
|
|
|
|
* Basic shapes are line, rect and texts
|
2019-05-25 11:05:39 +00:00
|
|
|
* the WS_DATA_ITEM coordinates units is the mm, and are relative to
|
2013-06-07 09:49:36 +00:00
|
|
|
* one of 4 page corners.
|
|
|
|
*
|
|
|
|
* These items cannot be drawn or plot "as this". they should be converted
|
|
|
|
* to a "draw list" (WS_DRAW_ITEM_BASE and derived items)
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
* The list of these items is stored in a WS_DATA_MODEL instance.
|
2013-06-07 09:49:36 +00:00
|
|
|
*
|
|
|
|
* When building the draw list:
|
2019-05-25 11:05:39 +00:00
|
|
|
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
|
2013-06-07 09:49:36 +00:00
|
|
|
* coordinates are converted to draw/plot coordinates.
|
|
|
|
* texts are expanded if they contain format symbols.
|
|
|
|
* Items with m_RepeatCount > 1 are created m_RepeatCount times
|
|
|
|
*
|
2019-05-25 11:05:39 +00:00
|
|
|
* the WS_DATA_MODEL is created only once.
|
2013-06-07 09:49:36 +00:00
|
|
|
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
|
|
|
|
*
|
2019-05-25 11:05:39 +00:00
|
|
|
* the WS_DATA_MODEL instance is created from a S expression which
|
2013-06-07 09:49:36 +00:00
|
|
|
* describes the page layout (can be the default page layout or a custom file).
|
|
|
|
*/
|
|
|
|
|
2013-05-24 08:59:40 +00:00
|
|
|
#include <fctsys.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <eda_rect.h>
|
2019-05-25 13:56:52 +00:00
|
|
|
#include <view/view.h>
|
2019-05-25 11:05:39 +00:00
|
|
|
#include <ws_painter.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <title_block.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include <ws_draw_item.h>
|
2019-05-25 13:56:52 +00:00
|
|
|
#include <ws_data_model.h>
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
using KIGFX::COLOR4D;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// The constructor:
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM::WS_DATA_ITEM( WS_ITEM_TYPE aType )
|
2013-06-08 18:19:09 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
m_pageOption = ALL_PAGES;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_type = aType;
|
|
|
|
m_RepeatCount = 1;
|
|
|
|
m_IncrementLabel = 1;
|
|
|
|
m_LineWidth = 0;
|
2013-06-08 18:19:09 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
|
|
|
int pensize = GetPenSizeUi();
|
|
|
|
|
|
|
|
if( pensize == 0 )
|
|
|
|
pensize = aCollector ? aCollector->GetDefaultPenSize() : 0;
|
|
|
|
|
2019-05-24 10:11:18 +00:00
|
|
|
std::map<int, STATUS_FLAGS> itemFlags;
|
|
|
|
WS_DRAW_ITEM_BASE* item = nullptr;
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
item = m_drawItems[ i ];
|
|
|
|
itemFlags[ i ] = item->GetFlags();
|
2019-05-24 10:11:18 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
if( aCollector )
|
|
|
|
aCollector->Remove( item );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Remove( item );
|
|
|
|
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_drawItems.clear();
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( int j = 0; j < m_RepeatCount; j++ )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
if( j && ! IsInsidePage( j ) )
|
2019-05-20 10:23:32 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( m_type == WS_SEGMENT )
|
2019-05-26 18:35:20 +00:00
|
|
|
item = new WS_DRAW_ITEM_LINE( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
|
2019-05-20 10:23:32 +00:00
|
|
|
else if( m_type == WS_RECT )
|
2019-05-26 18:35:20 +00:00
|
|
|
item = new WS_DRAW_ITEM_RECT( this, j, GetStartPosUi( j ), GetEndPosUi( j ), pensize );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
item->SetFlags( itemFlags[ j ] );
|
2019-05-24 10:11:18 +00:00
|
|
|
m_drawItems.push_back( item );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-24 10:11:18 +00:00
|
|
|
if( aCollector )
|
|
|
|
aCollector->Append( item );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Add( item );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
int WS_DATA_ITEM::GetPenSizeUi()
|
|
|
|
{
|
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
|
|
|
|
if( m_LineWidth != 0 )
|
|
|
|
return KiROUND( m_LineWidth * model.m_WSunits2Iu );
|
|
|
|
else
|
|
|
|
return KiROUND( model.m_DefaultLineWidth * model.m_WSunits2Iu );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// move item to aPosition
|
|
|
|
// starting point is moved to aPosition
|
|
|
|
// the Ending point is moved to a position which keeps the item size
|
|
|
|
// (if both coordinates have the same corner reference)
|
|
|
|
// MoveToUi and MoveTo takes the graphic position (i.e relative to the left top
|
|
|
|
// paper corner
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::MoveToUi( wxPoint aPosition )
|
2013-06-08 18:19:09 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
DPOINT pos_mm;
|
2019-05-25 13:56:52 +00:00
|
|
|
pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
|
|
|
pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
2013-06-08 18:19:09 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
MoveTo( pos_mm );
|
2013-06-08 18:19:09 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::MoveTo( DPOINT aPosition )
|
2013-06-08 18:19:09 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
DPOINT vector = aPosition - GetStartPos();
|
|
|
|
DPOINT endpos = vector + GetEndPos();
|
2013-06-08 18:19:09 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
MoveStartPointTo( aPosition );
|
|
|
|
MoveEndPointTo( endpos );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( WS_DRAW_ITEM_BASE* drawItem : m_drawItems )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
drawItem->SetPosition( GetStartPosUi( drawItem->GetIndexInPeer() ) );
|
|
|
|
drawItem->SetEnd( GetEndPosUi( drawItem->GetIndexInPeer() ) );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
2013-06-08 18:19:09 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/* move the starting point of the item to a new position
|
|
|
|
* aPosition = the new position of the starting point, in mm
|
|
|
|
*/
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::MoveStartPointTo( DPOINT aPosition )
|
2013-06-08 18:19:09 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
DPOINT position;
|
2013-06-08 18:19:09 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Calculate the position of the starting point
|
|
|
|
// relative to the reference corner
|
|
|
|
// aPosition is the position relative to the right top paper corner
|
|
|
|
switch( m_Pos.m_Anchor )
|
|
|
|
{
|
2016-07-11 19:48:46 +00:00
|
|
|
case RB_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position = model.m_RB_Corner - aPosition;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RT_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position.x = model.m_RB_Corner.x - aPosition.x;
|
|
|
|
position.y = aPosition.y - model.m_LT_Corner.y;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position.x = aPosition.x - model.m_LT_Corner.x;
|
|
|
|
position.y = model.m_RB_Corner.y - aPosition.y;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LT_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position = aPosition - model.m_LT_Corner;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_Pos.m_Pos = position;
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/* move the starting point of the item to a new position
|
|
|
|
* aPosition = the new position of the starting point in graphic units
|
|
|
|
*/
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::MoveStartPointToUi( wxPoint aPosition )
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
DPOINT pos_mm( aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu,
|
|
|
|
aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
MoveStartPointTo( pos_mm );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/**
|
|
|
|
* move the ending point of the item to a new position
|
|
|
|
* has meaning only for items defined by 2 points
|
|
|
|
* (segments and rectangles)
|
|
|
|
* aPosition = the new position of the ending point, in mm
|
|
|
|
*/
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::MoveEndPointTo( DPOINT aPosition )
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
DPOINT position;
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Calculate the position of the starting point
|
|
|
|
// relative to the reference corner
|
|
|
|
// aPosition is the position relative to the right top paper corner
|
|
|
|
switch( m_End.m_Anchor )
|
2013-06-05 12:03:16 +00:00
|
|
|
{
|
2016-07-11 19:48:46 +00:00
|
|
|
case RB_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position = model.m_RB_Corner - aPosition;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RT_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position.x = model.m_RB_Corner.x - aPosition.x;
|
|
|
|
position.y = aPosition.y - model.m_LT_Corner.y;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position.x = aPosition.x - model.m_LT_Corner.x;
|
|
|
|
position.y = model.m_RB_Corner.y - aPosition.y;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LT_CORNER:
|
2019-05-25 13:56:52 +00:00
|
|
|
position = aPosition - model.m_LT_Corner;
|
2016-07-11 19:48:46 +00:00
|
|
|
break;
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Modify m_End only for items having 2 coordinates
|
|
|
|
switch( GetType() )
|
2013-06-05 12:03:16 +00:00
|
|
|
{
|
2016-07-11 19:48:46 +00:00
|
|
|
case WS_SEGMENT:
|
|
|
|
case WS_RECT:
|
|
|
|
m_End.m_Pos = position;
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
/* move the ending point of the item to a new position
|
|
|
|
* has meaning only for items defined by 2 points
|
|
|
|
* (segments and rectangles)
|
|
|
|
* aPosition = the new position of the ending point in graphic units
|
|
|
|
*/
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM::MoveEndPointToUi( wxPoint aPosition )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
DPOINT pos_mm;
|
2019-05-25 13:56:52 +00:00
|
|
|
pos_mm.x = aPosition.x / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
|
|
|
pos_mm.y = aPosition.y / WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
MoveEndPointTo( pos_mm );
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const DPOINT WS_DATA_ITEM::GetStartPos( int ii ) const
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
DPOINT pos( m_Pos.m_Pos.x + ( m_IncrementVector.x * ii ),
|
|
|
|
m_Pos.m_Pos.y + ( m_IncrementVector.y * ii ) );
|
2013-06-05 12:03:16 +00:00
|
|
|
|
|
|
|
switch( m_Pos.m_Anchor )
|
|
|
|
{
|
|
|
|
case RB_CORNER: // right bottom corner
|
2019-05-25 13:56:52 +00:00
|
|
|
pos = model.m_RB_Corner - pos;
|
2013-06-05 12:03:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RT_CORNER: // right top corner
|
2019-05-25 13:56:52 +00:00
|
|
|
pos.x = model.m_RB_Corner.x - pos.x;
|
|
|
|
pos.y = model.m_LT_Corner.y + pos.y;
|
2013-06-05 12:03:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LB_CORNER: // left bottom corner
|
2019-05-25 13:56:52 +00:00
|
|
|
pos.x = model.m_LT_Corner.x + pos.x;
|
|
|
|
pos.y = model.m_RB_Corner.y - pos.y;
|
2013-06-05 12:03:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LT_CORNER: // left top corner
|
2019-05-25 13:56:52 +00:00
|
|
|
pos = model.m_LT_Corner + pos;
|
2013-06-05 12:03:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const wxPoint WS_DATA_ITEM::GetStartPosUi( int ii ) const
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
DPOINT pos = GetStartPos( ii ) * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
|
|
|
return (wxPoint) pos;
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const DPOINT WS_DATA_ITEM::GetEndPos( int ii ) const
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
DPOINT pos( m_End.m_Pos.x + ( m_IncrementVector.x * ii ),
|
|
|
|
m_End.m_Pos.y + ( m_IncrementVector.y * ii ) );
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
switch( m_End.m_Anchor )
|
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
case RB_CORNER: // right bottom corner
|
|
|
|
pos = WS_DATA_MODEL::GetTheInstance().m_RB_Corner - pos;
|
|
|
|
break;
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
case RT_CORNER: // right top corner
|
|
|
|
pos.x = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.x - pos.x;
|
|
|
|
pos.y = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.y + pos.y;
|
|
|
|
break;
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
case LB_CORNER: // left bottom corner
|
|
|
|
pos.x = WS_DATA_MODEL::GetTheInstance().m_LT_Corner.x + pos.x;
|
|
|
|
pos.y = WS_DATA_MODEL::GetTheInstance().m_RB_Corner.y - pos.y;
|
|
|
|
break;
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
case LT_CORNER: // left top corner
|
|
|
|
pos = WS_DATA_MODEL::GetTheInstance().m_LT_Corner + pos;
|
|
|
|
break;
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const wxPoint WS_DATA_ITEM::GetEndPosUi( int ii ) const
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2013-06-05 12:03:16 +00:00
|
|
|
DPOINT pos = GetEndPos( ii );
|
2019-05-25 13:56:52 +00:00
|
|
|
pos = pos * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
2016-07-11 19:48:46 +00:00
|
|
|
return wxPoint( KiROUND( pos.x ), KiROUND( pos.y ) );
|
2013-06-05 12:03:16 +00:00
|
|
|
}
|
2013-05-24 08:59:40 +00:00
|
|
|
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
bool WS_DATA_ITEM::IsInsidePage( int ii ) const
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
|
2013-06-05 12:03:16 +00:00
|
|
|
DPOINT pos = GetStartPos( ii );
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2013-07-24 15:11:35 +00:00
|
|
|
for( int kk = 0; kk < 1; kk++ )
|
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
if( model.m_RB_Corner.x < pos.x || model.m_LT_Corner.x > pos.x )
|
2013-07-24 15:11:35 +00:00
|
|
|
return false;
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
if( model.m_RB_Corner.y < pos.y || model.m_LT_Corner.y > pos.y )
|
2013-07-24 15:11:35 +00:00
|
|
|
return false;
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2013-07-24 15:11:35 +00:00
|
|
|
pos = GetEndPos( ii );
|
|
|
|
}
|
2013-06-05 12:03:16 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const wxString WS_DATA_ITEM::GetClassName() const
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
wxString name;
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( GetType() )
|
|
|
|
{
|
2019-05-25 11:05:39 +00:00
|
|
|
case WS_TEXT: name = wxT( "Text" ); break;
|
|
|
|
case WS_SEGMENT: name = wxT( "Line" ); break;
|
|
|
|
case WS_RECT: name = wxT( "Rectangle" ); break;
|
2019-05-20 10:23:32 +00:00
|
|
|
case WS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
|
2019-05-25 11:05:39 +00:00
|
|
|
case WS_BITMAP: name = wxT( "Image" ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
return name;
|
|
|
|
}
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_POLYGONS::WS_DATA_ITEM_POLYGONS() :
|
|
|
|
WS_DATA_ITEM( WS_POLYPOLYGON )
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
m_Orient = 0.0;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
void WS_DATA_ITEM_POLYGONS::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-24 10:11:18 +00:00
|
|
|
std::map<int, STATUS_FLAGS> itemFlags;
|
|
|
|
WS_DRAW_ITEM_BASE* item = nullptr;
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
2019-05-24 10:11:18 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
item = m_drawItems[ i ];
|
|
|
|
itemFlags[ i ] = item->GetFlags();
|
2019-05-24 10:11:18 +00:00
|
|
|
|
|
|
|
if( aCollector )
|
|
|
|
aCollector->Remove( item );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Remove( item );
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
delete item;
|
2019-05-24 10:11:18 +00:00
|
|
|
}
|
2013-05-25 09:01:44 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
m_drawItems.clear();
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( int j = 0; j < m_RepeatCount; j++ )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
if( j && !IsInsidePage( j ) )
|
2019-05-20 10:23:32 +00:00
|
|
|
continue;
|
2013-05-25 09:01:44 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
for( int kk = 0; kk < GetPolyCount(); kk++ )
|
|
|
|
{
|
|
|
|
const bool fill = true;
|
|
|
|
int pensize = GetPenSizeUi();
|
2019-05-26 18:35:20 +00:00
|
|
|
auto poly = new WS_DRAW_ITEM_POLYGON( this, j, GetStartPosUi( j ), fill, pensize );
|
|
|
|
poly->SetFlags( itemFlags[ j ] );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_drawItems.push_back( poly );
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
if( aCollector )
|
|
|
|
aCollector->Append( poly );
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
if( aView )
|
|
|
|
aView->Add( poly );
|
|
|
|
|
|
|
|
// Create polygon outline
|
|
|
|
unsigned ist = GetPolyIndexStart( kk );
|
|
|
|
unsigned iend = GetPolyIndexEnd( kk );
|
|
|
|
|
|
|
|
while( ist <= iend )
|
2019-05-26 18:35:20 +00:00
|
|
|
poly->m_Corners.push_back( GetCornerPositionUi( ist++, j ) );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
int WS_DATA_ITEM_POLYGONS::GetPenSizeUi()
|
|
|
|
{
|
|
|
|
return KiROUND( m_LineWidth * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const DPOINT WS_DATA_ITEM_POLYGONS::GetCornerPosition( unsigned aIdx, int aRepeat ) const
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
DPOINT pos = m_Corners[aIdx];
|
|
|
|
|
|
|
|
// Rotation:
|
|
|
|
RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
|
|
|
|
pos += GetStartPos( aRepeat );
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM_POLYGONS::SetBoundingBox()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
if( m_Corners.size() == 0 )
|
2013-05-24 08:59:40 +00:00
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
m_minCoord.x = m_maxCoord.x = 0.0;
|
|
|
|
m_minCoord.y = m_maxCoord.y = 0.0;
|
|
|
|
return;
|
|
|
|
}
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
DPOINT pos;
|
|
|
|
pos = m_Corners[0];
|
|
|
|
RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
|
|
|
|
m_minCoord = m_maxCoord = pos;
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
|
|
|
|
{
|
|
|
|
pos = m_Corners[ii];
|
|
|
|
RotatePoint( &pos.x, &pos.y, m_Orient * 10 );
|
2013-05-24 08:59:40 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( m_minCoord.x > pos.x )
|
|
|
|
m_minCoord.x = pos.x;
|
|
|
|
|
|
|
|
if( m_minCoord.y > pos.y )
|
|
|
|
m_minCoord.y = pos.y;
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( m_maxCoord.x < pos.x )
|
|
|
|
m_maxCoord.x = pos.x;
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( m_maxCoord.y < pos.y )
|
|
|
|
m_maxCoord.y = pos.y;
|
|
|
|
}
|
|
|
|
}
|
2013-06-05 12:03:16 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
bool WS_DATA_ITEM_POLYGONS::IsInsidePage( int ii ) const
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-25 13:56:52 +00:00
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
DPOINT pos = GetStartPos( ii );
|
|
|
|
pos += m_minCoord; // left top pos of bounding box
|
2013-06-08 18:19:09 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
if( model.m_LT_Corner.x > pos.x || model.m_LT_Corner.y > pos.y )
|
2013-07-19 18:27:22 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
pos = GetStartPos( ii );
|
|
|
|
pos += m_maxCoord; // rignt bottom pos of bounding box
|
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
if( model.m_RB_Corner.x < pos.x || model.m_RB_Corner.y < pos.y )
|
2013-07-19 18:27:22 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
const wxPoint WS_DATA_ITEM_POLYGONS::GetCornerPositionUi( unsigned aIdx, int aRepeat ) const
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
DPOINT pos = GetCornerPosition( aIdx, aRepeat );
|
2019-05-25 13:56:52 +00:00
|
|
|
pos = pos * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu;
|
2013-07-19 18:27:22 +00:00
|
|
|
return wxPoint( int(pos.x), int(pos.y) );
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_ITEM_TEXT::WS_DATA_ITEM_TEXT( const wxString& aTextBase ) :
|
|
|
|
WS_DATA_ITEM( WS_TEXT )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
m_TextBase = aTextBase;
|
|
|
|
m_IncrementLabel = 1;
|
|
|
|
m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
|
|
|
|
m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
|
2019-05-20 10:23:32 +00:00
|
|
|
m_Italic = false;
|
|
|
|
m_Bold = false;
|
2013-07-19 18:27:22 +00:00
|
|
|
m_Orient = 0.0;
|
2019-05-20 10:23:32 +00:00
|
|
|
m_LineWidth = 0.0; // 0 means use default value
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
int pensize = GetPenSizeUi();
|
|
|
|
bool multilines = false;
|
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
if( WS_DATA_MODEL::GetTheInstance().m_EditMode )
|
2019-05-20 10:23:32 +00:00
|
|
|
m_FullText = m_TextBase;
|
|
|
|
else
|
|
|
|
{
|
2019-05-24 19:12:10 +00:00
|
|
|
m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxString();
|
2019-05-20 10:23:32 +00:00
|
|
|
multilines = ReplaceAntiSlashSequence();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pensize == 0 )
|
|
|
|
pensize = aCollector ? aCollector->GetDefaultPenSize() : 1;
|
|
|
|
|
|
|
|
SetConstrainedTextSize();
|
|
|
|
wxSize textsize;
|
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
textsize.x = KiROUND( m_ConstrainedTextSize.x * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
|
|
|
textsize.y = KiROUND( m_ConstrainedTextSize.y * WS_DATA_MODEL::GetTheInstance().m_WSunits2Iu );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
if( m_Bold )
|
|
|
|
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
|
|
|
|
|
2019-05-24 10:11:18 +00:00
|
|
|
std::map<int, STATUS_FLAGS> itemFlags;
|
|
|
|
WS_DRAW_ITEM_TEXT* text = nullptr;
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
2019-05-24 10:11:18 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
text = (WS_DRAW_ITEM_TEXT*) m_drawItems[ i ];
|
|
|
|
itemFlags[ i ] = text->GetFlags();
|
2019-05-24 10:11:18 +00:00
|
|
|
|
|
|
|
if( aCollector )
|
|
|
|
aCollector->Remove( text );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Remove( text );
|
|
|
|
|
|
|
|
delete text;
|
|
|
|
}
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
m_drawItems.clear();
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( int j = 0; j < m_RepeatCount; ++j )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
if( j > 0 && !IsInsidePage( j ) )
|
2019-05-20 10:23:32 +00:00
|
|
|
continue;
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
text = new WS_DRAW_ITEM_TEXT( this, j, m_FullText, GetStartPosUi( j ), textsize, pensize,
|
2019-05-24 10:11:18 +00:00
|
|
|
m_Italic, m_Bold );
|
2019-05-26 18:35:20 +00:00
|
|
|
text->SetFlags( itemFlags[ j ] );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_drawItems.push_back( text );
|
|
|
|
|
|
|
|
if( aCollector )
|
|
|
|
aCollector->Append( text );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Add( text );
|
|
|
|
|
|
|
|
text->SetHorizJustify( m_Hjustify ) ;
|
|
|
|
text->SetVertJustify( m_Vjustify );
|
|
|
|
text->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
|
|
|
|
text->SetMultilineAllowed( multilines );
|
|
|
|
|
|
|
|
// Increment label for the next text (has no meaning for multiline texts)
|
|
|
|
if( m_RepeatCount > 1 && !multilines )
|
2019-05-26 18:35:20 +00:00
|
|
|
IncrementLabel(( j + 1 ) * m_IncrementLabel );
|
2019-05-20 10:23:32 +00:00
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
int WS_DATA_ITEM_TEXT::GetPenSizeUi()
|
|
|
|
{
|
|
|
|
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
|
|
|
|
if( m_LineWidth != 0 )
|
|
|
|
return KiROUND( m_LineWidth * model.m_WSunits2Iu );
|
|
|
|
else
|
|
|
|
return KiROUND( model.m_DefaultTextThickness * model.m_WSunits2Iu );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM_TEXT::IncrementLabel( int aIncr )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
int last = m_TextBase.Len() -1;
|
|
|
|
|
|
|
|
wxChar lbchar = m_TextBase[last];
|
|
|
|
m_FullText = m_TextBase;
|
|
|
|
m_FullText.RemoveLast();
|
|
|
|
|
|
|
|
if( lbchar >= '0' && lbchar <= '9' )
|
|
|
|
// A number is expected:
|
|
|
|
m_FullText << (int)( aIncr + lbchar - '0' );
|
|
|
|
else
|
|
|
|
m_FullText << (wxChar) ( aIncr + lbchar );
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2013-08-18 15:49:04 +00:00
|
|
|
// Replace the '\''n' sequence by EOL
|
|
|
|
// and the sequence '\''\' by only one '\' in m_FullText
|
2015-03-25 13:07:05 +00:00
|
|
|
// if m_FullText is a multiline text (i.e.contains '\n') return true
|
2019-05-25 11:05:39 +00:00
|
|
|
bool WS_DATA_ITEM_TEXT::ReplaceAntiSlashSequence()
|
2013-08-18 15:49:04 +00:00
|
|
|
{
|
|
|
|
bool multiline = false;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < m_FullText.Len(); ii++ )
|
|
|
|
{
|
|
|
|
if( m_FullText[ii] == '\n' )
|
|
|
|
multiline = true;
|
|
|
|
|
|
|
|
else if( m_FullText[ii] == '\\' )
|
|
|
|
{
|
|
|
|
if( ++ii >= m_FullText.Len() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( m_FullText[ii] == '\\' )
|
|
|
|
{
|
|
|
|
// a double \\ sequence is replaced by a single \ char
|
|
|
|
m_FullText.Remove(ii, 1);
|
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
else if( m_FullText[ii] == 'n' )
|
|
|
|
{
|
|
|
|
// Replace the "\n" sequence by a EOL char
|
|
|
|
multiline = true;
|
|
|
|
m_FullText[ii] = '\n';
|
|
|
|
m_FullText.Remove(ii-1, 1);
|
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return multiline;
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM_TEXT::SetConstrainedTextSize()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
|
|
|
m_ConstrainedTextSize = m_TextSize;
|
|
|
|
|
|
|
|
if( m_ConstrainedTextSize.x == 0 )
|
2019-05-25 13:56:52 +00:00
|
|
|
m_ConstrainedTextSize.x = WS_DATA_MODEL::GetTheInstance().m_DefaultTextSize.x;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
if( m_ConstrainedTextSize.y == 0 )
|
2019-05-25 13:56:52 +00:00
|
|
|
m_ConstrainedTextSize.y = WS_DATA_MODEL::GetTheInstance().m_DefaultTextSize.y;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-07-31 16:41:32 +00:00
|
|
|
if( m_BoundingBoxSize.x || m_BoundingBoxSize.y )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2013-07-31 16:41:32 +00:00
|
|
|
// to know the X and Y size of the line, we should use
|
|
|
|
// EDA_TEXT::GetTextBox()
|
2013-07-19 18:27:22 +00:00
|
|
|
// but this function uses integers
|
|
|
|
// So, to avoid truncations with our unit in mm, use microns.
|
2013-07-31 16:41:32 +00:00
|
|
|
wxSize size_micron;
|
2016-10-06 15:19:55 +00:00
|
|
|
#define FSCALE 1000.0
|
|
|
|
int linewidth = 0;
|
|
|
|
size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
|
|
|
|
size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
|
2019-05-26 18:35:20 +00:00
|
|
|
WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, 0, this->m_FullText, wxPoint( 0, 0 ),
|
2019-05-20 10:23:32 +00:00
|
|
|
size_micron, linewidth, m_Italic, m_Bold ) );
|
2013-07-31 16:41:32 +00:00
|
|
|
dummy.SetMultilineAllowed( true );
|
2019-05-20 10:23:32 +00:00
|
|
|
dummy.SetHorizJustify( m_Hjustify ) ;
|
|
|
|
dummy.SetVertJustify( m_Vjustify );
|
|
|
|
dummy.SetTextAngle( m_Orient * 10 );
|
2016-10-06 15:19:55 +00:00
|
|
|
|
2013-07-31 16:41:32 +00:00
|
|
|
EDA_RECT rect = dummy.GetTextBox();
|
|
|
|
DSIZE size;
|
2016-10-06 15:19:55 +00:00
|
|
|
size.x = rect.GetWidth() / FSCALE;
|
|
|
|
size.y = rect.GetHeight() / FSCALE;
|
2013-07-31 16:41:32 +00:00
|
|
|
|
|
|
|
if( m_BoundingBoxSize.x && size.x > m_BoundingBoxSize.x )
|
|
|
|
m_ConstrainedTextSize.x *= m_BoundingBoxSize.x / size.x;
|
|
|
|
|
|
|
|
if( m_BoundingBoxSize.y && size.y > m_BoundingBoxSize.y )
|
|
|
|
m_ConstrainedTextSize.y *= m_BoundingBoxSize.y / size.y;
|
2013-05-24 08:59:40 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-18 15:49:04 +00:00
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-24 10:11:18 +00:00
|
|
|
std::map<int, STATUS_FLAGS> itemFlags;
|
|
|
|
WS_DRAW_ITEM_BASE* item = nullptr;
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( size_t i = 0; i < m_drawItems.size(); ++i )
|
2019-05-24 10:11:18 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
item = m_drawItems[ i ];
|
|
|
|
itemFlags[ i ] = item->GetFlags();
|
2019-05-24 10:11:18 +00:00
|
|
|
|
|
|
|
if( aCollector )
|
|
|
|
aCollector->Remove( item );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Remove( item );
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
delete item;
|
2019-05-24 10:11:18 +00:00
|
|
|
}
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
m_drawItems.clear();
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
for( int j = 0; j < m_RepeatCount; j++ )
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2019-05-26 18:35:20 +00:00
|
|
|
if( j && !IsInsidePage( j ) )
|
2019-05-20 10:23:32 +00:00
|
|
|
continue;
|
|
|
|
|
2019-05-26 18:35:20 +00:00
|
|
|
auto bitmap = new WS_DRAW_ITEM_BITMAP( this, j, GetStartPosUi( j ) );
|
|
|
|
bitmap->SetFlags( itemFlags[ j ] );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_drawItems.push_back( bitmap );
|
|
|
|
|
|
|
|
if( aCollector )
|
|
|
|
aCollector->Append( bitmap );
|
|
|
|
|
|
|
|
if( aView )
|
|
|
|
aView->Add( bitmap );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
int WS_DATA_ITEM_BITMAP::GetPPI() const
|
2013-10-19 10:29:54 +00:00
|
|
|
{
|
|
|
|
if( m_ImageBitmap )
|
2016-07-11 19:48:46 +00:00
|
|
|
return m_ImageBitmap->GetPPI() / m_ImageBitmap->GetScale();
|
2013-10-19 10:29:54 +00:00
|
|
|
|
|
|
|
return 300;
|
|
|
|
}
|
|
|
|
|
2016-07-11 19:48:46 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
void WS_DATA_ITEM_BITMAP::SetPPI( int aBitmapPPI )
|
2013-10-19 10:29:54 +00:00
|
|
|
{
|
|
|
|
if( m_ImageBitmap )
|
2016-07-11 19:48:46 +00:00
|
|
|
m_ImageBitmap->SetScale( (double) m_ImageBitmap->GetPPI() / aBitmapPPI );
|
2013-10-19 10:29:54 +00:00
|
|
|
}
|