Moving PageLayout editor to GAL canvas and modern toolset.

This commit is contained in:
Jeff Young 2019-05-20 11:23:32 +01:00
parent 43a5bb72ca
commit 323bb0f8e1
141 changed files with 6099 additions and 6967 deletions

View File

@ -36,7 +36,7 @@ set( GAL_SRCS
newstroke_font.cpp
painter.cpp
text_utils.cpp
worksheet_viewitem.cpp
page_layout/worksheet_viewitem.cpp
gal/color4d.cpp
gal/gal_display_options.cpp
gal/graphics_abstraction_layer.cpp
@ -236,11 +236,10 @@ set( COMMON_WIDGET_SRCS
)
set( COMMON_PAGE_LAYOUT_SRCS
page_layout/title_block_shapes.cpp
page_layout/worksheet_dataitem.cpp
page_layout/worksheet_layout.cpp
page_layout/page_layout_default_description.cpp
page_layout/page_layout_graphic_items.cpp
page_layout/ws_draw_item.cpp
page_layout/page_layout_reader_keywords.cpp
page_layout/page_layout_reader.cpp
)
@ -359,7 +358,7 @@ set( COMMON_SRCS
utf8.cpp
validators.cpp
wildcards_and_files_ext.cpp
worksheet.cpp
page_layout/worksheet_painter.cpp
wxdataviewctrl_helpers.cpp
xnode.cpp
)

View File

@ -35,7 +35,7 @@
#include <class_drawpanel.h>
#include <title_block.h>
#include <draw_frame.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <base_screen.h>
#include <wildcards_and_files_ext.h>
@ -47,7 +47,7 @@
#include <general.h>
#endif
#include <worksheet.h>
#include <worksheet_painter.h>
#include <dialog_page_settings.h>
#define MAX_PAGE_EXAMPLE_SIZE 200
@ -665,7 +665,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
DrawPageLayout( &memDC, NULL, pageDUMMY,
emptyString, emptyString,
m_tb, m_screen->m_NumberOfScreens,
m_screen->m_ScreenNumber, 1, 1, DARKGRAY, RED );
m_screen->m_ScreenNumber, 1, 1, DARKGRAY );
memDC.SelectObject( wxNullBitmap );
m_PageLayoutExampleBitmap->SetBitmap( *m_page_bitmap );

View File

@ -45,7 +45,7 @@
#include <tool/action_menu.h>
#include <tool/actions.h>
#include <wx/clipbrd.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <page_info.h>
#include <title_block.h>
#include <advanced_config.h>
@ -728,6 +728,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
}
galCanvas->SetEvtHandlerEnabled( aEnable );
galCanvas->StartDrawing();
// Reset current tool on switch();
SetNoToolSelected();
@ -1030,12 +1031,6 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
}
void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect )
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
@ -1196,19 +1191,22 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
static const wxString productName = wxT( "KiCad E.D.A. " );
void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
void DrawPageLayout( wxDC* aDC,
EDA_RECT* aClipBox,
const PAGE_INFO& aPageInfo,
const wxString &aFullSheetName,
const wxString& aFileName,
TITLE_BLOCK& aTitleBlock,
int aSheetCount, int aSheetNumber,
int aPenWidth, double aScalar,
COLOR4D aColor, COLOR4D aAltColor,
const wxString& aSheetLayer )
const wxString& aFullSheetName,
const wxString& aFileName,
TITLE_BLOCK& aTitleBlock,
int aSheetCount,
int aSheetNumber,
int aPenWidth,
double aScalar,
COLOR4D aColor,
const wxString& aSheetLayer )
{
WS_DRAW_ITEM_LIST drawList;
drawList.SetPenSize( aPenWidth );
drawList.SetDefaultPenSize( aPenWidth );
drawList.SetMilsToIUfactor( aScalar );
drawList.SetSheetNumber( aSheetNumber );
drawList.SetSheetCount( aSheetCount );
@ -1216,10 +1214,10 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
drawList.SetSheetName( aFullSheetName );
drawList.SetSheetLayer( aSheetLayer );
drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock, aColor, aAltColor );
drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
// Draw item list
drawList.Draw( aClipBox, aDC );
drawList.Draw( aClipBox, aDC, aColor );
}
@ -1254,7 +1252,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo, GetScreenDesc(), aFilename, t_block,
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber, aLineWidth, aScalar,
color, color, aSheetLayer );
color, aSheetLayer );
if( aScreen->m_IsPrinting && origin.y > 0 )
{

View File

@ -67,7 +67,7 @@
#include <menus_helpers.h>
#include <page_info.h>
#include <title_block.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
/**
* Definition for enabling and disabling scroll bar setting trace output. See the
@ -519,24 +519,9 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
return;
if( IsGalCanvasActive() )
{
m_toolManager->RunAction( "common.Control.zoomPreset", true, id );
UpdateStatusBar();
m_galCanvas->Refresh();
}
else if( id == 0 ) // Auto zoom (Fit in Page)
{
Zoom_Automatique( true );
m_canvas->Refresh();
}
else
{
double selectedZoom = GetScreen()->m_ZoomList[id-1];
if( GetScreen()->SetZoom( selectedZoom ) )
RedrawScreen( GetScrollCenterPosition(), false );
}
m_toolManager->RunAction( "common.Control.zoomPreset", true, id );
UpdateStatusBar();
m_galCanvas->Refresh();
}
@ -847,8 +832,8 @@ void EDA_DRAW_FRAME::SetMsgPanel( const MSG_PANEL_ITEMS& aList )
ClearMsgPanel();
for( unsigned i = 0; i < aList.size(); i++ )
m_messagePanel->AppendMessage( aList[i] );
for( MSG_PANEL_ITEM item : aList )
m_messagePanel->AppendMessage( item );
}
@ -1216,6 +1201,11 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
m_canvas->SetEvtHandlerEnabled( !aEnable );
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
if( aEnable )
GetGalCanvas()->StartDrawing();
else
GetGalCanvas()->StopDrawing();
// Switch panes
m_auimgr.GetPane( "DrawFrame" ).Show( !aEnable );
m_auimgr.GetPane( "DrawFrameGal" ).Show( aEnable );
@ -1624,6 +1614,7 @@ double EDA_DRAW_FRAME::bestZoom( double sizeX, double sizeY, double scaleFactor,
}
// JEY TODO: Obsolete; replace with ACTIONS::zoomFitScreen
void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
{
BASE_SCREEN* screen = GetScreen();
@ -1646,24 +1637,6 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
}
void EDA_DRAW_FRAME::Window_Zoom( EDA_RECT& Rect )
{
// Compute the best zoom
Rect.Normalize();
wxSize size = m_canvas->GetClientSize();
// Use ceil to at least show the full rect
double scalex = (double) Rect.GetSize().x / size.x;
double bestscale = (double) Rect.GetSize().y / size.y;
bestscale = std::max( bestscale, scalex );
GetScreen()->SetScalingFactor( bestscale );
RedrawScreen( Rect.Centre(), true );
}
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
{
if( m_canvas == NULL )
@ -2040,19 +2013,22 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
}
void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
void DrawPageLayout( wxDC* aDC,
EDA_RECT* aClipBox,
const PAGE_INFO& aPageInfo,
const wxString &aFullSheetName,
const wxString& aFileName,
TITLE_BLOCK& aTitleBlock,
int aSheetCount, int aSheetNumber,
int aPenWidth, double aScalar,
COLOR4D aColor, COLOR4D aAltColor,
const wxString& aSheetLayer )
const wxString& aFullSheetName,
const wxString& aFileName,
TITLE_BLOCK& aTitleBlock,
int aSheetCount,
int aSheetNumber,
int aPenWidth,
double aScalar,
COLOR4D aColor,
const wxString& aSheetLayer )
{
WS_DRAW_ITEM_LIST drawList;
drawList.SetPenSize( aPenWidth );
drawList.SetDefaultPenSize( aPenWidth );
drawList.SetMilsToIUfactor( aScalar );
drawList.SetSheetNumber( aSheetNumber );
drawList.SetSheetCount( aSheetCount );
@ -2060,11 +2036,10 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
drawList.SetSheetName( aFullSheetName );
drawList.SetSheetLayer( aSheetLayer );
drawList.BuildWorkSheetGraphicList( aPageInfo,
aTitleBlock, aColor, aAltColor );
drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
// Draw item list
drawList.Draw( aClipBox, aDC );
drawList.Draw( aClipBox, aDC, aColor );
}
@ -2101,7 +2076,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo,
GetScreenDesc(), aFilename, t_block,
aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
aLineWidth, aScalar, color, color, aSheetLayer );
aLineWidth, aScalar, color, aSheetLayer );
if( aScreen->m_IsPrinting && origin.y > 0 )
{

View File

@ -115,7 +115,7 @@
*
*/
#include <worksheet.h>
#include <worksheet_painter.h>
// height of the band reference grid 2.0 mm
// worksheet frame reference text size 1.3 mm

View File

@ -1,540 +0,0 @@
/*
* 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>.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
*
* 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
*/
/**
* @file page_layout_graphic_items.cpp
* @brief description of graphic items and texts to build a title block
*/
/*
* the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines
* a basic shape of a page layout ( frame references and title block )
* Basic shapes are line, rect and texts
* the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
* 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)
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
*
* When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* 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
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plotted/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
#include <fctsys.h>
#include <eda_rect.h>
#include <draw_graphic_text.h>
#include <worksheet.h>
#include <title_block.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
#include <polygon_test_point_inside.h>
/* a helper function to calculate a marker size scaling factor from zoom level
* when one need a "constant" size to draw an item whatever the zoom level
* the scaling factor is clamped between 1.0 to 10.0 to avoid ugly drawings
* when the factor is ti high (1.0 is the "actual" item size)
* Note:
* Only the page layout editor uses the marker size.
* Other editors do not use or draw markers
*/
static double getScaleFromZoom( wxDC* aDC )
{
double x, y;
aDC->GetUserScale( &x, &y );
double scale = (x + y ) / 2; // should be equal, but if not best we can do is average
double fscale = WORKSHEET_DATAITEM::m_WSunits2Iu * scale;
double zscale = 20.0/ fscale; // The 20.0 factor is chosen for best results
// (fix the zoom level to have a zscale > 1)
// clamp scaling factor:
zscale = std::max( 1.0, zscale ); // never smaller than actual size
zscale = std::min( 10.0, zscale ); // should be enough to make item visible
return zscale;
}
/* a helper function to draw graphic symbols at start point or end point of
* an item.
* The start point symbol is a filled rectangle
* The start point symbol is a filled circle
*/
inline void drawMarker( EDA_RECT* aClipBox, wxDC* aDC,
const wxPoint& aPos, int aSize, bool aEndPointShape = false )
{
int markerHalfSize = aSize/2;
if( aEndPointShape )
GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, markerHalfSize,
0, GREEN, GREEN );
else
GRFilledRect( aClipBox, aDC,
aPos.x - markerHalfSize, aPos.y - markerHalfSize,
aPos.x + markerHalfSize, aPos.y + markerHalfSize,
0, GREEN, GREEN );
}
/* Draws the item list created by BuildWorkSheetGraphicList
* aClipBox = the clipping rect, or NULL if no clipping
* aDC = the current Device Context
* The not selected items are drawn first (most of items)
* The selected items are drawn after (usually 0 or 1)
* to be sure they are seen, even for overlapping items
*/
void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
{
// The not selected items are drawn first (most of items)
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
{
if( item->GetParent() && item->GetParent()->IsSelected() )
continue;
item->DrawWsItem( aClipBox, aDC );
}
// The selected items are drawn after (usually 0 or 1)
int markerSize = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
{
if( !item->GetParent() || !item->GetParent()->IsSelected() )
continue;
item->DrawWsItem( aClipBox, aDC );
if( !markerSize )
continue;
switch( item->GetType() )
{
case WS_DRAW_ITEM_BASE::wsg_line:
{
WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
drawMarker( aClipBox, aDC, line->GetStart(), markerSize );
drawMarker( aClipBox, aDC, line->GetEnd(), markerSize, true );
}
break;
case WS_DRAW_ITEM_BASE::wsg_rect:
{
WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
drawMarker( aClipBox, aDC, rect->GetStart(), markerSize );
drawMarker( aClipBox, aDC, rect->GetEnd(), markerSize, true );
}
break;
case WS_DRAW_ITEM_BASE::wsg_text:
{
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
drawMarker( aClipBox, aDC, text->GetTextPos(), markerSize );
}
break;
case WS_DRAW_ITEM_BASE::wsg_poly:
{
WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item;
drawMarker( aClipBox, aDC, poly->GetPosition(), markerSize );
}
break;
case WS_DRAW_ITEM_BASE::wsg_bitmap:
{
WS_DRAW_ITEM_BITMAP* bitmap = (WS_DRAW_ITEM_BITMAP*) item;
drawMarker( aClipBox, aDC, bitmap->GetPosition(), markerSize );
}
break;
}
}
}
WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
wxString& aText, wxPoint aPos, wxSize aSize,
int aPenWidth, COLOR4D aColor,
bool aItalic, bool aBold ) :
WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
{
SetTextPos( aPos );
SetTextSize( aSize );
SetThickness( aPenWidth );
SetItalic( aItalic );
SetBold( aBold );
}
void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
Draw( aClipBox, aDC, aOffset,
aColor == COLOR4D::UNSPECIFIED ? GetColor() : aColor,
aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode,
FILLED, COLOR4D::UNSPECIFIED );
}
bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition) const
{
return EDA_TEXT::TextHitTest( aPosition, 0 );
}
bool WS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect ) const
{
return EDA_TEXT::TextHitTest( aRect, 0, 0 );
}
bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint pos = GetTextPos();
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
if( std::abs( pos.x - aPosition.x) <= marker_size / 2 &&
std::abs( pos.y - aPosition.y) <= marker_size / 2 )
return true;
return false;
}
void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
std::vector<wxPoint> points_moved;
wxPoint *points;
if( aOffset.x || aOffset.y )
{
for( auto point: m_Corners )
points_moved.push_back( point + aOffset );
points = &points_moved[0];
}
else
{
points = &m_Corners[0];
}
auto color = ( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor;
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
GRPoly( aClipBox, aDC,
m_Corners.size(), points,
IsFilled() ? FILLED_SHAPE : NO_FILL,
GetPenWidth(),
color, color );
GRSetDrawMode( aDC, GR_COPY );
}
bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition) const
{
return TestPointInsidePolygon( &m_Corners[0],
m_Corners.size(), aPosition );
}
bool WS_DRAW_ITEM_POLYGON::HitTest( const EDA_RECT& aRect ) const
{
// Intersection of two polygons is nontrivial. Test if the rectangle intersects
// each line, instead.
if( m_Corners.size() < 2 )
return false;
for( size_t i = 1; i < m_Corners.size(); ++i )
{
if( aRect.Intersects( m_Corners[i - 1], m_Corners[i] ) )
return true;
}
return false;
}
bool WS_DRAW_ITEM_POLYGON::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint pos = GetPosition();
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
if( std::abs( pos.x - aPosition.x) <= marker_size / 2 &&
std::abs( pos.y - aPosition.y) <= marker_size / 2 )
return true;
return false;
}
void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
GRRect( aClipBox, aDC,
GetStart().x + aOffset.x, GetStart().y + aOffset.y,
GetEnd().x + aOffset.x, GetEnd().y + aOffset.y,
GetPenWidth(),
( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
GRSetDrawMode( aDC, GR_COPY );
}
bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition ) const
{
int dist = GetPenWidth()/2;
wxPoint start = GetStart();
wxPoint end;
end.x = GetEnd().x;
end.y = start.y;
// Upper line
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
// Right line
start = end;
end.y = GetEnd().y;
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
// lower line
start = end;
end.x = GetStart().x;
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
// left line
start = end;
end = GetStart();
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
return false;
}
bool WS_DRAW_ITEM_RECT::HitTest( const EDA_RECT& aRect ) const
{
wxPoint start = GetStart();
wxPoint end;
end.x = GetEnd().x;
end.y = start.y;
// Upper line
if( aRect.Intersects( start, end ) )
return true;
// Right line
start = end;
end.y = GetEnd().y;
if( aRect.Intersects( start, end ) )
return true;
// lower line
start = end;
end.x = GetStart().x;
if( aRect.Intersects( start, end ) )
return true;
// left line
start = end;
end = GetStart();
if( aRect.Intersects( start, end ) )
return true;
return false;
}
bool WS_DRAW_ITEM_RECT::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint dist = GetStart() - aPosition;
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
if( std::abs( dist.x) <= marker_size / 2 &&
std::abs( dist.y) <= marker_size / 2 )
return true;
return false;
}
bool WS_DRAW_ITEM_RECT::HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint pos = GetEnd();
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
int dist = (int) hypot( pos.x - aPosition.x, pos.y - aPosition.y );
if( dist <= marker_size / 2 )
return true;
return false;
}
void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset,
GetPenWidth(),
( aColor == COLOR4D::UNSPECIFIED ) ? GetColor() : aColor );
GRSetDrawMode( aDC, GR_COPY );
}
bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition) const
{
return TestSegmentHit( aPosition, GetStart(), GetEnd(), GetPenWidth()/2 );
}
bool WS_DRAW_ITEM_LINE::HitTest( const EDA_RECT& aRect ) const
{
return aRect.Intersects( GetStart(), GetEnd() );
}
bool WS_DRAW_ITEM_LINE::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint dist = GetStart() - aPosition;
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
if( std::abs( dist.x) <= marker_size / 2 &&
std::abs( dist.y) <= marker_size / 2 )
return true;
return false;
}
bool WS_DRAW_ITEM_LINE::HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint dist = GetEnd() - aPosition;
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
if( std::abs( dist.x) <= marker_size / 2 &&
std::abs( dist.y) <= marker_size / 2 )
return true;
return false;
}
void WS_DRAW_ITEM_LIST::Locate( wxDC* aDC, std::vector <WS_DRAW_ITEM_BASE*>& aList,
const wxPoint& aPosition )
{
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
{
item->m_Flags &= ~(LOCATE_STARTPOINT|LOCATE_ENDPOINT);
bool found = false;
if( item->HitTestStartPoint ( aDC, aPosition ) )
{
item->m_Flags |= LOCATE_STARTPOINT;
found = true;
}
if( item->HitTestEndPoint ( aDC, aPosition ) )
{
item->m_Flags |= LOCATE_ENDPOINT;
found = true;
}
if( found || item->HitTest( aPosition ) )
{
aList.push_back( item );
}
}
}
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();
if( parent->m_ImageBitmap )
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
parent->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
GRSetDrawMode( aDC, GR_COPY );
}
}
bool WS_DRAW_ITEM_BITMAP::HitTest( const wxPoint& aPosition) const
{
const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
if( parent->m_ImageBitmap == NULL )
return false;
EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
rect.Move( m_pos );
return rect.Contains( aPosition );
}
bool WS_DRAW_ITEM_BITMAP::HitTest( const EDA_RECT& aRect ) const
{
const WORKSHEET_DATAITEM_BITMAP* parent = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( GetParent() );
if( parent->m_ImageBitmap == NULL )
return false;
EDA_RECT rect = parent->m_ImageBitmap->GetBoundingBox();
rect.Move( m_pos );
return rect.Intersects( aRect );
}
/**
* return true if the point aPosition is on the reference point of this item.
*/
bool WS_DRAW_ITEM_BITMAP::HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition )
{
wxPoint dist = m_pos - aPosition;
int marker_size = WORKSHEET_DATAITEM::GetMarkerSizeUi( getScaleFromZoom( aDC ) );
if( std::abs( dist.x) <= marker_size / 2 &&
std::abs( dist.y) <= marker_size / 2 )
return true;
return false;
}

View File

@ -31,8 +31,8 @@
#include <fctsys.h>
#include <base_struct.h>
#include <worksheet.h>
#include <worksheet_shape_builder.h>
#include <worksheet_painter.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <page_layout_reader_lexer.h>
@ -115,16 +115,11 @@ PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const w
void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
{
T token;
WORKSHEET_DATAITEM * item;
WORKSHEET_DATAITEM* item;
LOCALE_IO toggle;
LOCALE_IO toggle;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
@ -177,12 +172,8 @@ void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout )
void PAGE_LAYOUT_READER_PARSER::parseSetup( WORKSHEET_LAYOUT* aLayout )
{
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
switch( token )
{
case T_LEFT:
@ -233,13 +224,8 @@ void PAGE_LAYOUT_READER_PARSER::parseSetup( WORKSHEET_LAYOUT* aLayout )
void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
{
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
@ -307,13 +293,9 @@ void PAGE_LAYOUT_READER_PARSER::parsePolygon( WORKSHEET_DATAITEM_POLYPOLYGON * a
void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON * aItem )
{
DPOINT corner;
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
@ -336,15 +318,11 @@ void PAGE_LAYOUT_READER_PARSER::parsePolyOutline( WORKSHEET_DATAITEM_POLYPOLYGON
void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
{
T token;
BITMAP_BASE* image = new BITMAP_BASE;
aItem->m_ImageBitmap = image;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
@ -403,28 +381,24 @@ void PAGE_LAYOUT_READER_PARSER::parseBitmap( WORKSHEET_DATAITEM_BITMAP * aItem )
void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
{
std::string tmp;
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
switch( token )
{
case T_data:
NeedSYMBOLorNUMBER();
tmp += CurStr();
tmp += "\n";
NeedRIGHT();
break;
case T_data:
NeedSYMBOLorNUMBER();
tmp += CurStr();
tmp += "\n";
NeedRIGHT();
break;
default:
Unexpected( CurText() );
break;
default:
Unexpected( CurText() );
break;
}
}
@ -434,34 +408,19 @@ void PAGE_LAYOUT_READER_PARSER::readPngdata( WORKSHEET_DATAITEM_BITMAP * aItem )
STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
{
wxLogMessage(msg);
}
}
void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
{
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
switch( token )
{
case T_page1only:
aItem->SetPage1Option( 1 );
break;
case T_notonpage1:
aItem->SetPage1Option( -1 );
break;
default:
Unexpected( CurText() );
break;
case T_page1only: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
case T_notonpage1: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
default: Unexpected( CurText() ); break;
}
}
}
@ -469,13 +428,8 @@ void PAGE_LAYOUT_READER_PARSER::readOption( WORKSHEET_DATAITEM * aItem )
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem )
{
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
else
@ -544,13 +498,8 @@ void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem )
void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
{
T token;
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
if( token == T_LEFT )
token = NextTok();
@ -607,22 +556,19 @@ void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
break;
case T_font:
while( ( token = NextTok() ) != T_RIGHT )
for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
switch( token )
{
case T_LEFT:
break;
case T_bold:
aItem->SetBold( true );
aItem->m_Bold = true;
break;
case T_italic:
aItem->SetItalic( true );
aItem->m_Italic = true;
break;
case T_size:
@ -644,11 +590,8 @@ void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
break;
case T_justify:
while( ( token = NextTok() ) != T_RIGHT )
for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
if( token == T_EOF)
break;
switch( token )
{
case T_center:
@ -694,34 +637,18 @@ void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem )
// parse an expression like " 25 1 ltcorner)"
void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord)
{
T token;
aCoord.m_Pos.x = parseDouble();
aCoord.m_Pos.y = parseDouble();
while( ( token = NextTok() ) != T_RIGHT )
for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
{
switch( token )
{
case T_ltcorner:
aCoord.m_Anchor = LT_CORNER; // left top corner
break;
case T_lbcorner:
aCoord.m_Anchor = LB_CORNER; // left bottom corner
break;
case T_rbcorner:
aCoord.m_Anchor = RB_CORNER; // right bottom corner
break;
case T_rtcorner:
aCoord.m_Anchor = RT_CORNER; // right top corner
break;
default:
Unexpected( CurText() );
break;
case T_ltcorner: aCoord.m_Anchor = LT_CORNER; break;
case T_lbcorner: aCoord.m_Anchor = LB_CORNER; break;
case T_rbcorner: aCoord.m_Anchor = RB_CORNER; break;
case T_rtcorner: aCoord.m_Anchor = RT_CORNER; break;
default: Unexpected( CurText() ); break;
}
}
}

View File

@ -1,258 +0,0 @@
/**
* @file title_block_shapes.cpp
* @brief description of graphic items and texts to build a title block
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2018 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
*
* 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
*/
/*
* the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines
* a basic shape of a page layout ( frame references and title block )
* Basic shapes are line, rect and texts
* the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
* 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)
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
*
* When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* 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
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
#include <fctsys.h>
#include <draw_graphic_text.h>
#include <page_info.h>
#include <worksheet.h>
#include <title_block.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
const PAGE_INFO& aPageInfo,
const TITLE_BLOCK& aTitleBlock,
COLOR4D aColor, COLOR4D aAltColor )
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
#define milsTomm (25.4/1000)
m_titleBlock = &aTitleBlock;
m_paperFormat = &aPageInfo.GetType();
wxPoint LTmargin( Mm2mils( pglayout.GetLeftMargin() ),
Mm2mils( pglayout.GetTopMargin() ) );
wxPoint RBmargin( Mm2mils( pglayout.GetRightMargin() ),
Mm2mils( pglayout.GetBottomMargin() ) );
SetMargins( LTmargin, RBmargin );
SetPageSize( aPageInfo.GetSizeMils() );
// Build the basic layout shape, if the layout list is empty
if( pglayout.GetCount() == 0 && !pglayout.VoidListAllowed() )
pglayout.SetPageLayout();
WORKSHEET_DATAITEM::m_WSunits2Iu = m_milsToIu / milsTomm;
WORKSHEET_DATAITEM::m_Color = aColor; // the default color to draw items
WORKSHEET_DATAITEM::m_AltColor = aAltColor; // an alternate color to draw items
// Left top corner position
DPOINT lt_corner;
lt_corner.x = pglayout.GetLeftMargin();
lt_corner.y = pglayout.GetTopMargin();
WORKSHEET_DATAITEM::m_LT_Corner = lt_corner;
// Right bottom corner position
DPOINT rb_corner;
rb_corner.x = (m_pageSize.x*milsTomm) - pglayout.GetRightMargin();
rb_corner.y = (m_pageSize.y*milsTomm) - pglayout.GetBottomMargin();
WORKSHEET_DATAITEM::m_RB_Corner = rb_corner;
WS_DRAW_ITEM_TEXT* gtext;
int pensize;
for( unsigned ii = 0; ; ii++ )
{
WORKSHEET_DATAITEM* wsItem = pglayout.GetItem( ii );
if( wsItem == NULL )
break;
// Generate it only if the page option allows this
if( wsItem->GetPage1Option() < 0 // Not on page 1
&& m_sheetNumber <= 1 )
continue;
if( wsItem->GetPage1Option() > 0 // Only on page 1
&& m_sheetNumber > 1 )
continue;
COLOR4D color = wsItem->GetItemColor();
pensize = wsItem->GetPenSizeUi();
switch( wsItem->GetType() )
{
case WORKSHEET_DATAITEM::WS_TEXT:
{
WORKSHEET_DATAITEM_TEXT * wsText = (WORKSHEET_DATAITEM_TEXT*)wsItem;
bool multilines = false;
if( wsText->m_SpecialMode )
wsText->m_FullText = wsText->m_TextBase;
else
{
wsText->m_FullText = BuildFullText( wsText->m_TextBase );
multilines = wsText->ReplaceAntiSlashSequence();
}
if( wsText->m_FullText.IsEmpty() )
break;
if( pensize == 0 )
pensize = m_penSize;
wsText->SetConstrainedTextSize();
wxSize textsize;
textsize.x = KiROUND( wsText->m_ConstrainedTextSize.x
* WORKSHEET_DATAITEM::m_WSunits2Iu );
textsize.y = KiROUND( wsText->m_ConstrainedTextSize.y
* WORKSHEET_DATAITEM::m_WSunits2Iu );
if( wsText->IsBold())
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
for( int jj = 0; jj < wsText->m_RepeatCount; jj++)
{
if( jj && ! wsText->IsInsidePage( jj ) )
continue;
gtext = new WS_DRAW_ITEM_TEXT( wsText, wsText->m_FullText,
wsText->GetStartPosUi( jj ),
textsize, pensize, color,
wsText->IsItalic(),
wsText->IsBold() );
Append( gtext );
gtext->SetMultilineAllowed( multilines );
wsText->TransfertSetupToGraphicText( gtext );
// Increment label for the next text
// (has no meaning for multiline texts)
if( wsText->m_RepeatCount > 1 && !multilines )
wsText->IncrementLabel( (jj+1)*wsText->m_IncrementLabel);
}
}
break;
case WORKSHEET_DATAITEM::WS_SEGMENT:
if( pensize == 0 )
pensize = m_penSize;
for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ )
{
if( jj && ! wsItem->IsInsidePage( jj ) )
continue;
Append( new WS_DRAW_ITEM_LINE( wsItem, wsItem->GetStartPosUi( jj ),
wsItem->GetEndPosUi( jj ),
pensize, color ) );
}
break;
case WORKSHEET_DATAITEM::WS_RECT:
if( pensize == 0 )
pensize = m_penSize;
for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ )
{
if( jj && ! wsItem->IsInsidePage( jj ) )
break;
Append( new WS_DRAW_ITEM_RECT( wsItem, wsItem->GetStartPosUi( jj ),
wsItem->GetEndPosUi( jj ),
pensize, color ) );
}
break;
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
{
WORKSHEET_DATAITEM_POLYPOLYGON * wspoly =
(WORKSHEET_DATAITEM_POLYPOLYGON*) wsItem;
for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ )
{
if( jj && ! wsItem->IsInsidePage( jj ) )
continue;
for( int kk = 0; kk < wspoly->GetPolyCount(); kk++ )
{
const bool fill = true;
WS_DRAW_ITEM_POLYGON* poly = new WS_DRAW_ITEM_POLYGON( wspoly,
wspoly->GetStartPosUi( jj ),
fill, pensize, color );
Append( poly );
// Create polygon outline
unsigned ist = wspoly->GetPolyIndexStart( kk );
unsigned iend = wspoly->GetPolyIndexEnd( kk );
while( ist <= iend )
poly->m_Corners.push_back(
wspoly->GetCornerPositionUi( ist++, jj ) );
}
}
}
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
((WORKSHEET_DATAITEM_BITMAP*)wsItem)->SetPixelScaleFactor();
for( int jj = 0; jj < wsItem->m_RepeatCount; jj++ )
{
if( jj && ! wsItem->IsInsidePage( jj ) )
continue;
Append( new WS_DRAW_ITEM_BITMAP( wsItem,
wsItem->GetStartPosUi( jj ) ) );
}
break;
}
}
}

View File

@ -1,8 +1,3 @@
/**
* @file worksheet_dataitem.cpp
* @brief description of graphic items and texts to build a title block
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -57,38 +52,89 @@
#include <fctsys.h>
#include <draw_graphic_text.h>
#include <eda_rect.h>
#include <worksheet.h>
#include <worksheet_painter.h>
#include <title_block.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <view/view.h>
using KIGFX::COLOR4D;
// Static members of class WORKSHEET_DATAITEM:
double WORKSHEET_DATAITEM::m_WSunits2Iu = 1.0;
double WORKSHEET_DATAITEM::m_WSunits2Iu = 1000.0;
DPOINT WORKSHEET_DATAITEM::m_RB_Corner;
DPOINT WORKSHEET_DATAITEM::m_LT_Corner;
double WORKSHEET_DATAITEM::m_DefaultLineWidth = 0.0;
DSIZE WORKSHEET_DATAITEM::m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
double WORKSHEET_DATAITEM::m_DefaultTextThickness = 0.0;
bool WORKSHEET_DATAITEM::m_SpecialMode = false;
COLOR4D WORKSHEET_DATAITEM::m_Color = COLOR4D( RED ); // the default color to draw items
COLOR4D WORKSHEET_DATAITEM::m_AltColor = COLOR4D( RED ); // an alternate color to draw items
COLOR4D WORKSHEET_DATAITEM::m_SelectedColor = COLOR4D( BROWN ); // the color to draw selected items
// The constructor:
WORKSHEET_DATAITEM::WORKSHEET_DATAITEM( WS_ItemType aType )
WORKSHEET_DATAITEM::WORKSHEET_DATAITEM( WS_ITEM_TYPE aType )
{
m_pageOption = ALL_PAGES;
m_type = aType;
m_flags = 0;
m_RepeatCount = 1;
m_IncrementLabel = 1;
m_LineWidth = 0;
}
void WORKSHEET_DATAITEM::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
int pensize = GetPenSizeUi();
if( pensize == 0 )
pensize = aCollector ? aCollector->GetDefaultPenSize() : 0;
for( WS_DRAW_ITEM_BASE* item : m_drawItems )
{
if( aCollector )
aCollector->Remove( item );
if( aView )
aView->Remove( item );
delete item;
}
m_drawItems.clear();
for( int jj = 0; jj < m_RepeatCount; jj++ )
{
if( jj && ! IsInsidePage( jj ) )
continue;
if( m_type == WS_SEGMENT )
{
auto line = new WS_DRAW_ITEM_LINE( this, GetStartPosUi( jj ), GetEndPosUi( jj ),
pensize );
m_drawItems.push_back( line );
if( aCollector )
aCollector->Append( line );
if( aView )
aView->Add( line );
}
else if( m_type == WS_RECT )
{
auto rect = new WS_DRAW_ITEM_RECT( this, GetStartPosUi( jj ), GetEndPosUi( jj ),
pensize );
m_drawItems.push_back( rect );
if( aCollector )
aCollector->Append( rect );
if( aView )
aView->Add( rect );
}
}
}
// move item to aPosition
// starting point is moved to aPosition
// the Ending point is moved to a position which keeps the item size
@ -112,6 +158,16 @@ void WORKSHEET_DATAITEM::MoveTo( DPOINT aPosition )
MoveStartPointTo( aPosition );
MoveEndPointTo( endpos );
for( int jj = 0; jj < m_RepeatCount; jj++ )
{
if( jj && !IsInsidePage( jj ) )
continue;
WS_DRAW_ITEM_BASE* drawItem = m_drawItems[ jj ];
drawItem->SetPosition( GetStartPosUi( jj ) );
drawItem->SetEnd( GetEndPosUi( jj ) );
}
}
@ -331,49 +387,15 @@ const wxString WORKSHEET_DATAITEM::GetClassName() const
{
case WS_TEXT: name = wxT( "Text" ); break;
case WS_SEGMENT: name = wxT( "Line" ); break;
case WS_RECT: name = wxT( "Rect" ); break;
case WS_POLYPOLYGON: name = wxT( "Poly" ); break;
case WS_BITMAP: name = wxT( "Bitmap" ); break;
case WS_RECT: name = wxT( "Rectangle" ); break;
case WS_POLYPOLYGON: name = wxT( "Imported Shape" ); break;
case WS_BITMAP: name = wxT( "Image" ); break;
}
return name;
}
/* return 0 if the item has no specific option for page 1
* 1 if the item is only on page 1
* -1 if the item is not on page 1
*/
int WORKSHEET_DATAITEM::GetPage1Option()
{
if(( m_flags & PAGE1OPTION) == PAGE1OPTION_NOTONPAGE1 )
return -1;
if(( m_flags & PAGE1OPTION) == PAGE1OPTION_PAGE1ONLY )
return 1;
return 0;
}
/* Set the option for page 1
* aChoice = 0 if the item has no specific option for page 1
* > 0 if the item is only on page 1
* < 0 if the item is not on page 1
*/
void WORKSHEET_DATAITEM::SetPage1Option( int aChoice )
{
ClearFlags( PAGE1OPTION );
if( aChoice > 0 )
SetFlags( PAGE1OPTION_PAGE1ONLY );
else if( aChoice < 0 )
SetFlags( PAGE1OPTION_NOTONPAGE1 );
}
WORKSHEET_DATAITEM_POLYPOLYGON::WORKSHEET_DATAITEM_POLYPOLYGON() :
WORKSHEET_DATAITEM( WS_POLYPOLYGON )
{
@ -381,8 +403,45 @@ WORKSHEET_DATAITEM_POLYPOLYGON::WORKSHEET_DATAITEM_POLYPOLYGON() :
}
const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx,
int aRepeat ) const
void WORKSHEET_DATAITEM_POLYPOLYGON::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector,
KIGFX::VIEW* aView )
{
for( WS_DRAW_ITEM_BASE* item : m_drawItems )
delete item;
m_drawItems.clear();
for( int jj = 0; jj < m_RepeatCount; jj++ )
{
if( jj && !IsInsidePage( jj ) )
continue;
for( int kk = 0; kk < GetPolyCount(); kk++ )
{
const bool fill = true;
int pensize = GetPenSizeUi();
auto poly = new WS_DRAW_ITEM_POLYGON( this, GetStartPosUi( jj ), fill, pensize );
m_drawItems.push_back( poly );
if( aCollector )
aCollector->Append( poly );
if( aView )
aView->Add( poly );
// Create polygon outline
unsigned ist = GetPolyIndexStart( kk );
unsigned iend = GetPolyIndexEnd( kk );
while( ist <= iend )
poly->m_Corners.push_back( GetCornerPositionUi( ist++, jj ) );
}
}
}
const DPOINT WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition( unsigned aIdx, int aRepeat ) const
{
DPOINT pos = m_Corners[aIdx];
@ -461,16 +520,67 @@ WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase ) :
m_IncrementLabel = 1;
m_Hjustify = GR_TEXT_HJUSTIFY_LEFT;
m_Vjustify = GR_TEXT_VJUSTIFY_CENTER;
m_Italic = false;
m_Bold = false;
m_Orient = 0.0;
m_LineWidth = 0.0; // 0.0 means use default value
m_LineWidth = 0.0; // 0 means use default value
}
void WORKSHEET_DATAITEM_TEXT::TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aGText )
void WORKSHEET_DATAITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
aGText->SetHorizJustify( m_Hjustify ) ;
aGText->SetVertJustify( m_Vjustify );
aGText->SetTextAngle( m_Orient * 10 ); // graphic text orient unit = 0.1 degree
int pensize = GetPenSizeUi();
bool multilines = false;
if( m_SpecialMode )
m_FullText = m_TextBase;
else
{
m_FullText = aCollector ? aCollector->BuildFullText( m_TextBase ) : wxEmptyString;
multilines = ReplaceAntiSlashSequence();
}
if( pensize == 0 )
pensize = aCollector ? aCollector->GetDefaultPenSize() : 1;
SetConstrainedTextSize();
wxSize textsize;
textsize.x = KiROUND( m_ConstrainedTextSize.x * WORKSHEET_DATAITEM::m_WSunits2Iu );
textsize.y = KiROUND( m_ConstrainedTextSize.y * WORKSHEET_DATAITEM::m_WSunits2Iu );
if( m_Bold )
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
for( WS_DRAW_ITEM_BASE* item : m_drawItems )
delete item;
m_drawItems.clear();
for( int jj = 0; jj < m_RepeatCount; ++jj )
{
if( jj > 0 && !IsInsidePage( jj ) )
continue;
auto text = new WS_DRAW_ITEM_TEXT( this, m_FullText, GetStartPosUi( jj ), textsize,
pensize, m_Italic, m_Bold );
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 )
IncrementLabel( ( jj + 1 ) * m_IncrementLabel );
}
}
@ -549,13 +659,12 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
int linewidth = 0;
size_micron.x = KiROUND( m_ConstrainedTextSize.x * FSCALE );
size_micron.y = KiROUND( m_ConstrainedTextSize.y * FSCALE );
WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText,
wxPoint(0,0),
size_micron,
linewidth, BLACK,
IsItalic(), IsBold() ) );
WS_DRAW_ITEM_TEXT dummy( WS_DRAW_ITEM_TEXT( this, this->m_FullText, wxPoint( 0, 0 ),
size_micron, linewidth, m_Italic, m_Bold ) );
dummy.SetMultilineAllowed( true );
TransfertSetupToGraphicText( &dummy );
dummy.SetHorizJustify( m_Hjustify ) ;
dummy.SetVertJustify( m_Vjustify );
dummy.SetTextAngle( m_Orient * 10 );
EDA_RECT rect = dummy.GetTextBox();
DSIZE size;
@ -571,6 +680,30 @@ void WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize()
}
void WORKSHEET_DATAITEM_BITMAP::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
for( WS_DRAW_ITEM_BASE* item : m_drawItems )
delete item;
m_drawItems.clear();
for( int jj = 0; jj < m_RepeatCount; jj++ )
{
if( jj && !IsInsidePage( jj ) )
continue;
auto bitmap = new WS_DRAW_ITEM_BITMAP( this, GetStartPosUi( jj ) );
m_drawItems.push_back( bitmap );
if( aCollector )
aCollector->Append( bitmap );
if( aView )
aView->Add( bitmap );
}
}
/* set the pixel scale factor of the bitmap
* this factor depend on the application internal unit
* and the PPI bitmap factor

View File

@ -52,9 +52,9 @@
#include <fctsys.h>
#include <kiface_i.h>
#include <draw_graphic_text.h>
#include <worksheet.h>
#include <worksheet_painter.h>
#include <title_block.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
@ -121,43 +121,23 @@ void WORKSHEET_LAYOUT::SetBottomMargin( double aMargin )
void WORKSHEET_LAYOUT::ClearList()
{
for( unsigned ii = 0; ii < m_list.size(); ii++ )
delete m_list[ii];
for( WORKSHEET_DATAITEM* item : m_list )
delete item;
m_list.clear();
}
void WORKSHEET_LAYOUT::Insert( WORKSHEET_DATAITEM* aItem, unsigned aIdx )
void WORKSHEET_LAYOUT::Append( WORKSHEET_DATAITEM* aItem )
{
if ( aIdx >= GetCount() )
Append( aItem );
else
m_list.insert( m_list.begin() + aIdx, aItem );
m_list.push_back( aItem );
}
bool WORKSHEET_LAYOUT::Remove( unsigned aIdx )
void WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
{
if ( aIdx >= GetCount() )
return false;
m_list.erase( m_list.begin() + aIdx );
return true;
}
bool WORKSHEET_LAYOUT::Remove( WORKSHEET_DATAITEM* aItem )
{
unsigned idx = 0;
while( idx < m_list.size() )
{
if( m_list[idx] == aItem )
break;
idx++;
}
return Remove( idx );
auto newEnd = std::remove( m_list.begin(), m_list.end(), aItem );
m_list.erase( newEnd, m_list.end() );
}

View File

@ -1,14 +1,7 @@
/**
* @file worksheet.cpp
* @brief Common code to draw the title block and frame references
* @note it should include title_block_shape_gost.h or title_block_shape.h
* which defines most of draw shapes, and contains a part of the draw code
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
@ -36,15 +29,47 @@
#include <common.h>
#include <base_screen.h>
#include <draw_frame.h>
#include <worksheet.h>
#include <title_block.h>
#include <build_version.h>
#include <ws_draw_item.h>
#include <gal/graphics_abstraction_layer.h>
#include <worksheet_shape_builder.h>
#include <worksheet_painter.h>
#include <worksheet_dataitem.h>
using namespace KIGFX;
static const wxString productName = wxT( "KiCad E.D.A. " );
WS_RENDER_SETTINGS::WS_RENDER_SETTINGS()
{
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 );
update();
}
const COLOR4D& WS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
{
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;
}
return m_normalColor;
}
// returns the full text corresponding to the aTextbase,
// after replacing format symbols by the corresponding value
wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
@ -209,3 +234,115 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
aFormatter->Print( aNestLevel, ")\n\n" );
}
}
bool KIGFX::WORKSHEET_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
{
auto item = static_cast<const EDA_ITEM*>( aItem );
switch( item->Type() )
{
case WSG_LINE_T: draw( (WS_DRAW_ITEM_LINE*) item, aLayer ); break;
case WSG_POLY_T: draw( (WS_DRAW_ITEM_POLYGON*) item, aLayer ); break;
case WSG_RECT_T: draw( (WS_DRAW_ITEM_RECT*) item, aLayer ); break;
case WSG_TEXT_T: draw( (WS_DRAW_ITEM_TEXT*) item, aLayer ); break;
case WSG_BITMAP_T: draw( (WS_DRAW_ITEM_BITMAP*) item, aLayer ); break;
default: return false;
}
return true;
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_LINE* aItem, int aLayer ) const
{
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetLineWidth( aItem->GetPenWidth() );
m_gal->DrawLine( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_RECT* aItem, int aLayer ) const
{
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetLineWidth( aItem->GetPenWidth() );
m_gal->DrawRectangle( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_POLYGON* aItem, int aLayer ) const
{
std::deque<VECTOR2D> corners;
for( wxPoint point : aItem->m_Corners )
{
corners.push_back( VECTOR2D( point ) );
}
if( aItem->IsFilled() )
{
m_gal->SetFillColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetIsFill( true );
m_gal->SetIsStroke( false );
m_gal->DrawPolygon( corners );
}
else
{
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( aItem->GetPenWidth() );
m_gal->DrawPolyline( corners );
}
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
{
VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
m_gal->Save();
m_gal->Translate( position );
m_gal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 );
m_gal->SetStrokeColor( m_renderSettings.GetColor( aItem, aLayer ) );
m_gal->SetLineWidth( aItem->GetThickness() );
m_gal->SetTextAttributes( aItem );
m_gal->StrokeText( aItem->GetShownText(), VECTOR2D( 0, 0 ), 0.0 );
m_gal->Restore();
}
void KIGFX::WORKSHEET_PAINTER::draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const
{
m_gal->Save();
VECTOR2D position = aItem->GetPosition();
m_gal->Translate( position );
auto* bitmap = static_cast<WORKSHEET_DATAITEM_BITMAP*>( aItem->GetPeer() );
// 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 );
m_gal->Restore();
}
void KIGFX::WORKSHEET_PAINTER::DrawBorder( const PAGE_INFO* aPageInfo, int aScaleFactor ) const
{
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
m_gal->SetStrokeColor( COLOR4D( 0.4, 0.4, 0.4, 1.0 ) );
m_gal->SetIsFill( false );
m_gal->DrawRectangle( origin, end );
}

View File

@ -0,0 +1,136 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013-2018 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* 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
*/
/**
* @file worksheet_viewitem.cpp
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <worksheet_viewitem.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#include <layers_id_colors_and_visibility.h>
#include <page_info.h>
#include <view/view.h>
#include <worksheet_painter.h>
using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( int aMils2IUscalefactor,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_mils2IUscalefactor( aMils2IUscalefactor ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}
void WORKSHEET_VIEWITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
{
m_pageInfo = aPageInfo;
}
void WORKSHEET_VIEWITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
{
m_titleBlock = aTitleBlock;
}
const BOX2I WORKSHEET_VIEWITEM::ViewBBox() const
{
BOX2I bbox;
if( m_pageInfo != NULL )
{
bbox.SetOrigin( VECTOR2I( 0, 0 ) );
bbox.SetEnd( VECTOR2I( m_pageInfo->GetWidthMils() * m_mils2IUscalefactor,
m_pageInfo->GetHeightMils() * m_mils2IUscalefactor ) );
}
else
{
bbox.SetMaximum();
}
return bbox;
}
void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
{
auto gal = aView->GetGAL();
auto settings = aView->GetPainter()->GetSettings();
wxString fileName( m_fileName.c_str(), wxConvUTF8 );
wxString sheetName( m_sheetName.c_str(), wxConvUTF8 );
WS_DRAW_ITEM_LIST drawList;
drawList.SetDefaultPenSize( (int) settings->GetWorksheetLineWidth() );
// Adjust the scaling factor for worksheet items:
// worksheet items coordinates and sizes are stored in mils,
// and must be scaled to the same units as the caller
drawList.SetMilsToIUfactor( m_mils2IUscalefactor );
drawList.SetSheetNumber( m_sheetNumber );
drawList.SetSheetCount( m_sheetCount );
drawList.SetFileName( fileName );
drawList.SetSheetName( sheetName );
drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock );
// Draw the title block normally even if the view is flipped
bool flipped = gal->IsFlippedX();
if( flipped )
{
gal->Save();
gal->Translate( VECTOR2D( m_pageInfo->GetWidthMils() * m_mils2IUscalefactor, 0 ) );
gal->Scale( VECTOR2D( -1.0, 1.0 ) );
}
WORKSHEET_PAINTER ws_painter( gal );
WS_RENDER_SETTINGS* ws_settings =static_cast<WS_RENDER_SETTINGS*>( ws_painter.GetSettings() );
ws_settings->SetNormalColor( settings->GetLayerColor( LAYER_WORKSHEET ) );
ws_settings->SetSelectedColor( settings->GetLayerColor( LAYER_SELECT_OVERLAY ) );
ws_settings->SetBrightenedColor( settings->GetLayerColor( LAYER_BRIGHTENED ) );
// Draw all the components that make the page layout
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
ws_painter.Draw( item, LAYER_WORKSHEET );
// Draw gray line that outlines the sheet size
if( settings->GetShowPageLimits() )
ws_painter.DrawBorder( m_pageInfo, m_mils2IUscalefactor );
if( flipped )
gal->Restore();
}
void WORKSHEET_VIEWITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = LAYER_WORKSHEET;
}

View File

@ -0,0 +1,420 @@
/*
* 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>.
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
*
*
* 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
*/
/*
* the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines
* a basic shape of a page layout ( frame references and title block )
* Basic shapes are line, rect and texts
* the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
* 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)
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
*
* When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* 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
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plotted/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
#include <fctsys.h>
#include <eda_rect.h>
#include <draw_graphic_text.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <base_units.h>
#include <page_info.h>
// ============================ BASE CLASS ==============================
// A generic HitTest that can be used by some, but not all, sub-classes.
bool WS_DRAW_ITEM_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT sel = aRect;
if ( aAccuracy )
sel.Inflate( aAccuracy );
if( aContained )
return sel.Contains( GetBoundingBox() );
return sel.Intersects( GetBoundingBox() );
}
void WS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
{
wxString msg;
WORKSHEET_DATAITEM* dataItem = GetPeer();
switch( dataItem->GetType() )
{
case WORKSHEET_DATAITEM::WS_SEGMENT:
aList.push_back( MSG_PANEL_ITEM( _( "Line" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_RECT:
aList.push_back( MSG_PANEL_ITEM( _( "Rectangle" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_TEXT:
msg = static_cast<WS_DRAW_ITEM_TEXT*>( this )->GetShownText();
aList.push_back( MSG_PANEL_ITEM( _( "Text" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
aList.push_back( MSG_PANEL_ITEM( _( "Imported Shape" ), msg, DARKCYAN ) );
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
aList.push_back( MSG_PANEL_ITEM( _( "Image" ), msg, DARKCYAN ) );
break;
}
switch( dataItem->GetPage1Option() )
{
case FIRST_PAGE_ONLY: msg = _( "First Page Only" ); break;
case SUBSEQUENT_PAGES: msg = _( "Subsequent Pages" ); break;
default: msg = _( "All Pages" ); break;
}
aList.push_back( MSG_PANEL_ITEM( _( "First Page Option" ), msg, BROWN ) );
msg = MessageTextFromValue( UNSCALED_UNITS, dataItem->m_RepeatCount );
aList.push_back( MSG_PANEL_ITEM( _( "Repeat Count" ), msg, BLUE ) );
msg = MessageTextFromValue( UNSCALED_UNITS, dataItem->m_IncrementLabel );
aList.push_back( MSG_PANEL_ITEM( _( "Repeat Label Increment" ), msg, DARKGRAY ) );
msg.Printf( wxT( "(%s, %s)" ),
MessageTextFromValue( aUnits, dataItem->m_IncrementVector.x ),
MessageTextFromValue( aUnits, dataItem->m_IncrementVector.y ) );
aList.push_back( MSG_PANEL_ITEM( _( "Repeat Position Increment" ), msg, RED ) );
aList.push_back( MSG_PANEL_ITEM( _( "Comment" ), dataItem->m_Info, MAGENTA ) );
}
// ============================ TEXT ==============================
void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
Draw( aClipBox, aDC, aOffset, aColor, GR_COPY, FILLED, COLOR4D::UNSPECIFIED );
}
bool WS_DRAW_ITEM_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
return EDA_TEXT::TextHitTest( aPosition, aAccuracy );
}
bool WS_DRAW_ITEM_TEXT::HitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
{
return EDA_TEXT::TextHitTest( aRect, aContains, aAccuracy );
}
wxString WS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS_T aUnits ) const
{
return wxString::Format( _( "Text %s at (%s, %s)" ),
GetShownText(),
MessageTextFromValue( aUnits, GetTextPos().x ),
MessageTextFromValue( aUnits, GetTextPos().y ) );
}
// ============================ POLYGON ==============================
void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
std::vector<wxPoint> points_moved;
wxPoint *points;
if( aOffset.x || aOffset.y )
{
for( auto point: m_Corners )
points_moved.push_back( point + aOffset );
points = &points_moved[0];
}
else
{
points = &m_Corners[0];
}
GRPoly( aClipBox, aDC, m_Corners.size(), points, IsFilled() ? FILLED_SHAPE : NO_FILL,
GetPenWidth(), aColor, aColor );
}
bool WS_DRAW_ITEM_POLYGON::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
for( unsigned ii = 1; ii < m_Corners.size(); ii++ )
{
if( TestSegmentHit( aPosition, m_Corners[ii - 1], m_Corners[ii], aAccuracy ) )
return true;
}
return false;
}
bool WS_DRAW_ITEM_POLYGON::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT sel = aRect;
if ( aAccuracy )
sel.Inflate( aAccuracy );
if( aContained )
return sel.Contains( GetBoundingBox() );
// Fast test: if rect is outside the polygon bounding box, then they cannot intersect
if( !sel.Intersects( GetBoundingBox() ) )
return false;
int count = m_Corners.size();
for( int ii = 0; ii < count; ii++ )
{
// Test if the point is within aRect
if( sel.Contains( m_Corners[ ii ] ) )
return true;
// Test if this edge intersects aRect
if( sel.Intersects( m_Corners[ ii ], m_Corners[ (ii+1) % count ] ) )
return true;
}
return false;
}
wxString WS_DRAW_ITEM_POLYGON::GetSelectMenuText( EDA_UNITS_T aUnits ) const
{
return wxString::Format( _( "Imported shape at (%s, %s)" ),
MessageTextFromValue( aUnits, GetPosition().x ),
MessageTextFromValue( aUnits, GetPosition().y ) );
}
// ============================ RECT ==============================
void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
GRRect( aClipBox, aDC,
GetStart().x + aOffset.x, GetStart().y + aOffset.y,
GetEnd().x + aOffset.x, GetEnd().y + aOffset.y,
GetPenWidth(), aColor );
}
bool WS_DRAW_ITEM_RECT::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
int dist = aAccuracy + ( GetPenWidth() / 2 );
wxPoint start = GetStart();
wxPoint end;
end.x = GetEnd().x;
end.y = start.y;
// Upper line
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
// Right line
start = end;
end.y = GetEnd().y;
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
// lower line
start = end;
end.x = GetStart().x;
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
// left line
start = end;
end = GetStart();
if( TestSegmentHit( aPosition, start, end, dist ) )
return true;
return false;
}
wxString WS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS_T aUnits ) const
{
return wxString::Format( _( "Rectangle from (%s, %s) to (%s, %s)" ),
MessageTextFromValue( aUnits, GetStart().x ),
MessageTextFromValue( aUnits, GetStart().y ),
MessageTextFromValue( aUnits, GetEnd().x ),
MessageTextFromValue( aUnits, GetEnd().y ) );
}
// ============================ LINE ==============================
void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset, GetPenWidth(), aColor );
}
bool WS_DRAW_ITEM_LINE::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{
int mindist = aAccuracy + ( GetPenWidth() / 2 );
return TestSegmentHit( aPosition, GetStart(), GetEnd(), mindist );
}
wxString WS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const
{
return wxString::Format( _( "Line from (%s, %s) to (%s, %s)" ),
MessageTextFromValue( aUnits, GetStart().x ),
MessageTextFromValue( aUnits, GetStart().y ),
MessageTextFromValue( aUnits, GetEnd().x ),
MessageTextFromValue( aUnits, GetEnd().y ) );
}
// ============== BITMAP ================
void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
WORKSHEET_DATAITEM_BITMAP* bitmap = (WORKSHEET_DATAITEM_BITMAP*) GetPeer();
if( bitmap->m_ImageBitmap )
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
bitmap->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
GRSetDrawMode( aDC, GR_COPY );
}
}
const EDA_RECT WS_DRAW_ITEM_BITMAP::GetBoundingBox() const
{
auto* bitmap = static_cast<const WORKSHEET_DATAITEM_BITMAP*>( m_peer );
EDA_RECT rect = bitmap->m_ImageBitmap->GetBoundingBox();
rect.Move( m_pos );
return rect;
}
wxString WS_DRAW_ITEM_BITMAP::GetSelectMenuText( EDA_UNITS_T aUnits ) const
{
return wxString::Format( _( "Image at (%s, %s)" ),
MessageTextFromValue( aUnits, GetPosition().x ),
MessageTextFromValue( aUnits, GetPosition().y ) );
}
// ============================ LIST ==============================
#define MILS_TO_MM (25.4/1000)
void WS_DRAW_ITEM_LIST::SetupDrawEnvironment( const PAGE_INFO& aPageInfo )
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
// Left top corner position
DPOINT lt_corner;
lt_corner.x = pglayout.GetLeftMargin();
lt_corner.y = pglayout.GetTopMargin();
WORKSHEET_DATAITEM::m_LT_Corner = lt_corner;
// Right bottom corner position
DPOINT rb_corner;
rb_corner.x = ( aPageInfo.GetSizeMils().x * MILS_TO_MM ) - pglayout.GetRightMargin();
rb_corner.y = ( aPageInfo.GetSizeMils().y * MILS_TO_MM ) - pglayout.GetBottomMargin();
WORKSHEET_DATAITEM::m_RB_Corner = rb_corner;
}
void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo,
const TITLE_BLOCK& aTitleBlock )
{
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
m_titleBlock = &aTitleBlock;
m_paperFormat = &aPageInfo.GetType();
wxPoint LTmargin( Mm2mils( pglayout.GetLeftMargin() ), Mm2mils( pglayout.GetTopMargin() ) );
wxPoint RBmargin( Mm2mils( pglayout.GetRightMargin() ), Mm2mils( pglayout.GetBottomMargin() ) );
// Build the basic layout shape, if the layout list is empty
if( pglayout.GetCount() == 0 && !pglayout.VoidListAllowed() )
pglayout.SetPageLayout();
WORKSHEET_DATAITEM::m_WSunits2Iu = m_milsToIu / MILS_TO_MM;
SetupDrawEnvironment( aPageInfo );
for( WORKSHEET_DATAITEM* wsItem : pglayout.GetItems() )
{
// Generate it only if the page option allows this
if( wsItem->GetPage1Option() == FIRST_PAGE_ONLY && m_sheetNumber != 1 )
continue;
else if( wsItem->GetPage1Option() == SUBSEQUENT_PAGES && m_sheetNumber == 1 )
continue;
wsItem->SyncDrawItems( this, nullptr );
}
}
/* Draws the item list created by BuildWorkSheetGraphicList
* aClipBox = the clipping rect, or NULL if no clipping
* aDC = the current Device Context
* The not selected items are drawn first (most of items)
* The selected items are drawn after (usually 0 or 1)
* to be sure they are seen, even for overlapping items
*/
void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor )
{
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
item->DrawWsItem( aClipBox, aDC, aColor );
}

View File

@ -66,7 +66,8 @@ void RENDER_SETTINGS::update()
PAINTER::PAINTER( GAL* aGal ) :
m_gal( aGal ), m_brightenedColor( 0.0, 1.0, 0.0, 0.9 )
m_gal( aGal ),
m_brightenedColor( 0.0, 1.0, 0.0, 0.9 )
{
}

View File

@ -1,8 +1,3 @@
/**
* @file common_plot_functions.cpp
* @brief Kicad: Common plotting functions
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -30,11 +25,11 @@
#include <fctsys.h>
#include <base_struct.h>
#include <plotter.h>
#include <worksheet.h>
#include <worksheet_painter.h>
#include <base_screen.h>
#include <draw_graphic_text.h>
#include <title_block.h>
#include "worksheet_shape_builder.h"
#include "ws_draw_item.h"
#include "worksheet_dataitem.h"
#include <wx/filename.h>
@ -44,35 +39,20 @@ wxString GetDefaultPlotExtension( PlotFormat aFormat )
{
switch( aFormat )
{
case PLOT_FORMAT_DXF:
return DXF_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_POST:
return PS_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_PDF:
return PDF_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_HPGL:
return HPGL_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_GERBER:
return GERBER_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_SVG:
return SVG_PLOTTER::GetDefaultFileExtension();
default:
wxASSERT( false );
return wxEmptyString;
case PLOT_FORMAT_DXF: return DXF_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_POST: return PS_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_PDF: return PDF_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_HPGL: return HPGL_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_GERBER: return GERBER_PLOTTER::GetDefaultFileExtension();
case PLOT_FORMAT_SVG: return SVG_PLOTTER::GetDefaultFileExtension();
default: wxASSERT( false ); return wxEmptyString;
}
}
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
const PAGE_INFO& aPageInfo,
int aSheetNumber, int aNumberOfSheets,
const PAGE_INFO& aPageInfo, int aSheetNumber, int aNumberOfSheets,
const wxString &aSheetDesc, const wxString &aFilename )
{
/* Note: Page sizes values are given in mils
@ -87,7 +67,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
wxFileName fn( aFilename );
// Prepare plot parameters
drawList.SetPenSize(PLOTTER::USE_DEFAULT_LINE_WIDTH );
drawList.SetDefaultPenSize( PLOTTER::USE_DEFAULT_LINE_WIDTH );
drawList.SetMilsToIUfactor( iusPerMil );
drawList.SetSheetNumber( aSheetNumber );
drawList.SetSheetCount( aNumberOfSheets );
@ -95,18 +75,16 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
drawList.SetSheetName( aSheetDesc );
drawList.BuildWorkSheetGraphicList( aPageInfo,
aTitleBlock, plotColor, plotColor );
drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );
// Draw item list
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item;
item = drawList.GetNext() )
for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item; item = drawList.GetNext() )
{
plotter->SetCurrentLineWidth( PLOTTER::USE_DEFAULT_LINE_WIDTH );
switch( item->GetType() )
switch( item->Type() )
{
case WS_DRAW_ITEM_BASE::wsg_line:
case WSG_LINE_T:
{
WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
plotter->SetCurrentLineWidth( line->GetPenWidth() );
@ -115,51 +93,48 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
}
break;
case WS_DRAW_ITEM_BASE::wsg_rect:
case WSG_RECT_T:
{
WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
plotter->Rect( rect->GetStart(),
rect->GetEnd(),
NO_FILL,
rect->GetPenWidth() );
plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL, rect->GetPenWidth() );
}
break;
case WS_DRAW_ITEM_BASE::wsg_text:
case WSG_TEXT_T:
{
WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
plotter->Text( text->GetTextPos(), text->GetColor(),
text->GetShownText(), text->GetTextAngle(),
text->GetTextSize(),
plotter->Text( text->GetTextPos(), plotColor, text->GetShownText(),
text->GetTextAngle(), text->GetTextSize(),
text->GetHorizJustify(), text->GetVertJustify(),
text->GetPenWidth(),
text->IsItalic(), text->IsBold(),
text->GetPenWidth(), text->IsItalic(), text->IsBold(),
text->IsMultilineAllowed() );
}
break;
case WS_DRAW_ITEM_BASE::wsg_poly:
case WSG_POLY_T:
{
WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item;
plotter->PlotPoly( poly->m_Corners,
poly->IsFilled() ? FILLED_SHAPE : NO_FILL,
plotter->PlotPoly( poly->m_Corners, poly->IsFilled() ? FILLED_SHAPE : NO_FILL,
poly->GetPenWidth() );
}
break;
case WS_DRAW_ITEM_BASE::wsg_bitmap:
case WSG_BITMAP_T:
{
WS_DRAW_ITEM_BITMAP* bm = (WS_DRAW_ITEM_BITMAP*) item;
WS_DRAW_ITEM_BITMAP* drawItem = (WS_DRAW_ITEM_BITMAP*) item;
auto* bitmap = (WORKSHEET_DATAITEM_BITMAP*) drawItem->GetPeer();
WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)bm->GetParent();
if( parent->m_ImageBitmap == NULL )
if( bitmap->m_ImageBitmap == NULL )
break;
parent->m_ImageBitmap->PlotImage( plotter, bm->GetPosition(),
plotColor, PLOTTER::USE_DEFAULT_LINE_WIDTH );
bitmap->m_ImageBitmap->PlotImage( plotter, drawItem->GetPosition(), plotColor,
PLOTTER::USE_DEFAULT_LINE_WIDTH );
}
break;
default:
wxFAIL_MSG( "PlotWorkSheet(): Unknown worksheet item." );
break;
}
}
}

View File

@ -22,7 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "edit_constraints.h"
#include "tool/edit_constraints.h"
#include "tool/edit_points.h"
#include <geometry/seg.h>

View File

@ -1,247 +0,0 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013-2018 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* 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
*/
/**
* @file worksheet_viewitem.cpp
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <worksheet_viewitem.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#include <layers_id_colors_and_visibility.h>
#include <page_info.h>
#include <view/view.h>
using namespace KIGFX;
WORKSHEET_VIEWITEM::WORKSHEET_VIEWITEM( int aMils2IUscalefactor,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_mils2IUscalefactor( aMils2IUscalefactor ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {}
void WORKSHEET_VIEWITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
{
m_pageInfo = aPageInfo;
}
void WORKSHEET_VIEWITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
{
m_titleBlock = aTitleBlock;
}
const BOX2I WORKSHEET_VIEWITEM::ViewBBox() const
{
BOX2I bbox;
if( m_pageInfo != NULL )
{
bbox.SetOrigin( VECTOR2I( 0, 0 ) );
bbox.SetEnd( VECTOR2I( m_pageInfo->GetWidthMils() * m_mils2IUscalefactor,
m_pageInfo->GetHeightMils() * m_mils2IUscalefactor ) );
}
else
{
bbox.SetMaximum();
}
return bbox;
}
void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
{
auto gal = aView->GetGAL();
auto settings = aView->GetPainter()->GetSettings();
wxString fileName( m_fileName.c_str(), wxConvUTF8 );
wxString sheetName( m_sheetName.c_str(), wxConvUTF8 );
WS_DRAW_ITEM_LIST drawList;
drawList.SetPenSize( settings->GetWorksheetLineWidth() );
// Adjust the scaling factor for worksheet items:
// worksheet items coordinates and sizes are stored in mils,
// and must be scaled to the same units as the caller
drawList.SetMilsToIUfactor( m_mils2IUscalefactor );
drawList.SetSheetNumber( m_sheetNumber );
drawList.SetSheetCount( m_sheetCount );
drawList.SetFileName( fileName );
drawList.SetSheetName( sheetName );
COLOR4D color = settings->GetColor( this, aLayer );
drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock, color, color );
// Draw the title block normally even if the view is flipped
bool flipped = gal->IsFlippedX();
if( flipped )
{
gal->Save();
gal->Translate( VECTOR2D( m_pageInfo->GetWidthMils() * m_mils2IUscalefactor, 0 ) );
gal->Scale( VECTOR2D( -1.0, 1.0 ) );
}
// Draw all the components that make the page layout
WS_DRAW_ITEM_BASE* item = drawList.GetFirst();
while( item )
{
switch( item->GetType() )
{
case WS_DRAW_ITEM_BASE::wsg_line:
draw( static_cast<const WS_DRAW_ITEM_LINE*>( item ), gal );
break;
case WS_DRAW_ITEM_BASE::wsg_rect:
draw( static_cast<const WS_DRAW_ITEM_RECT*>( item ), gal );
break;
case WS_DRAW_ITEM_BASE::wsg_poly:
draw( static_cast<const WS_DRAW_ITEM_POLYGON*>( item ), gal );
break;
case WS_DRAW_ITEM_BASE::wsg_text:
draw( static_cast<const WS_DRAW_ITEM_TEXT*>( item ), gal );
break;
case WS_DRAW_ITEM_BASE::wsg_bitmap:
draw( static_cast<const WS_DRAW_ITEM_BITMAP*>( item ), gal );
break;
}
item = drawList.GetNext();
}
// Draw gray line that outlines the sheet size
if( settings->GetShowPageLimits() )
drawBorder( gal );
if( flipped )
gal->Restore();
}
void WORKSHEET_VIEWITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;
aLayers[0] = LAYER_WORKSHEET;
}
void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_LINE* aItem, GAL* aGal ) const
{
aGal->SetIsStroke( true );
aGal->SetIsFill( false );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetPenWidth() );
aGal->DrawLine( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
}
void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_RECT* aItem, GAL* aGal ) const
{
aGal->SetIsStroke( true );
aGal->SetIsFill( false );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetPenWidth() );
aGal->DrawRectangle( VECTOR2D( aItem->GetStart() ), VECTOR2D( aItem->GetEnd() ) );
}
void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) const
{
std::deque<VECTOR2D> corners;
for( wxPoint point : aItem->m_Corners )
{
corners.push_back( VECTOR2D( point ) );
}
if( aItem->IsFilled() )
{
aGal->SetFillColor( COLOR4D( aItem->GetColor() ) );
aGal->SetIsFill( true );
aGal->SetIsStroke( false );
aGal->DrawPolygon( corners );
}
else
{
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetIsFill( false );
aGal->SetIsStroke( true );
aGal->SetLineWidth( aItem->GetPenWidth() );
aGal->DrawPolyline( corners );
}
}
void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
{
VECTOR2D position( aItem->GetTextPos().x, aItem->GetTextPos().y );
aGal->Save();
aGal->Translate( position );
aGal->Rotate( -aItem->GetTextAngle() * M_PI / 1800.0 );
aGal->SetStrokeColor( COLOR4D( aItem->GetColor() ) );
aGal->SetLineWidth( aItem->GetThickness() );
aGal->SetTextAttributes( aItem );
aGal->StrokeText( aItem->GetShownText(), VECTOR2D( 0, 0 ), 0.0 );
aGal->Restore();
}
void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_BITMAP* aItem, GAL* aGal ) const
{
aGal->Save();
VECTOR2D position = aItem->GetPosition();
aGal->Translate( position );
WORKSHEET_DATAITEM_BITMAP* parent = static_cast<WORKSHEET_DATAITEM_BITMAP*>( aItem->GetParent() );
// 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 = parent->m_ImageBitmap->GetScale();
if( img_scale != 1.0 )
aGal->Scale( VECTOR2D( img_scale, img_scale ) );
aGal->DrawBitmap( *parent->m_ImageBitmap );
aGal->Restore();
}
void WORKSHEET_VIEWITEM::drawBorder( GAL* aGal ) const
{
VECTOR2D origin = VECTOR2D( 0.0, 0.0 );
VECTOR2D end = VECTOR2D( m_pageInfo->GetWidthMils() * m_mils2IUscalefactor,
m_pageInfo->GetHeightMils() * m_mils2IUscalefactor );
aGal->SetIsStroke( true );
// Use a gray color for the border color
aGal->SetStrokeColor( COLOR4D( 0.4, 0.4, 0.4, 1.0 ) );
aGal->SetIsFill( false );
aGal->DrawRectangle( origin, end );
}

View File

@ -327,22 +327,6 @@ void DISPLAY_FOOTPRINTS_FRAME::ApplyDisplaySettingsToGAL()
}
void DISPLAY_FOOTPRINTS_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
}
void DISPLAY_FOOTPRINTS_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{
}
bool DISPLAY_FOOTPRINTS_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
return true;
}
bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
EDA_KEY aHotKey )
{

View File

@ -108,9 +108,6 @@ public:
*/
COLOR4D GetGridColor() override;
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
bool GeneralControl( wxDC* DC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
void InstallOptionsDisplay( wxCommandEvent& event );
MODULE* Get_Module( const wxString& CmpName );

View File

@ -31,7 +31,7 @@
#include <pgm_base.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <worksheet.h>
#include <worksheet_painter.h>
#include <sch_sheet.h>
#include <dialog_plot_schematic.h>

View File

@ -46,9 +46,7 @@ public:
EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) :
m_Unit( 0 ),
m_Convert( 0 ),
m_Threshold( 0 ),
m_MenuCancelled( false )
m_Convert( 0 )
{
SetScanTypes( aScanTypes );
}
@ -108,11 +106,6 @@ public:
public:
int m_Unit; // Fixed symbol unit filter (for symbol editor)
int m_Convert; // Fixed DeMorgan filter (for symbol editor)
int m_Threshold; // Hit-test threshold in internal units.
wxString m_MenuTitle; // The title of selection disambiguation menu (if needed)
bool m_MenuCancelled; // Indicates selection disambiguation menu was cancelled
};

View File

@ -400,7 +400,7 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( aHotKey == 0 )
return false;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
/* Convert lower to upper case (the usual toupper function has problem
* with non ascii codes like function keys */

View File

@ -37,7 +37,7 @@
#include <lib_edit_frame.h>
#include <eeschema_config.h>
#include <ee_hotkeys.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <class_library.h>
#include <symbol_lib_table.h>
#include <dialog_erc.h>

View File

@ -52,7 +52,7 @@
#include <symbol_lib_table.h>
#include <dialog_symbol_remap.h>
#include <dialog_migrate_buses.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <connection_graph.h>

View File

@ -22,10 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_arc.cpp
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <macros.h>
@ -434,73 +430,28 @@ BITMAP_DEF LIB_ARC::GetMenuImage() const
}
void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
void LIB_ARC::BeginEdit( const wxPoint aPosition )
{
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
m_ArcStart = m_ArcEnd = aPosition;
m_editState = m_lastEditState = 1;
}
else if( aEditMode == IS_MOVED )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
}
else
{
// The arc center point has to be rotated with while adjusting the
// start or end point, determine the side of this point and the distance
// from the start / end point
wxPoint middlePoint = wxPoint( (m_ArcStart.x + m_ArcEnd.x) / 2,
(m_ArcStart.y + m_ArcEnd.y) / 2 );
wxPoint centerVector = m_Pos - middlePoint;
wxPoint startEndVector = twoPointVector( m_ArcStart, m_ArcEnd );
m_editCenterDistance = EuclideanNorm( centerVector );
// Determine on which side is the center point
m_editDirection = CrossProduct( startEndVector, centerVector ) ? 1 : -1;
// Drag either the start, end point or the outline
if( HitTestPoints( m_ArcStart, aPosition, MINIMUM_SELECTION_DISTANCE ) )
{
m_editSelectPoint = ARC_STATUS_START;
}
else if( HitTestPoints( m_ArcEnd, aPosition, MINIMUM_SELECTION_DISTANCE ) )
{
m_editSelectPoint = ARC_STATUS_END;
}
else
{
m_editSelectPoint = ARC_STATUS_OUTLINE;
}
m_editState = 0;
}
m_ArcStart = m_ArcEnd = aPosition;
m_editState = m_lastEditState = 1;
}
bool LIB_ARC::ContinueEdit( const wxPoint aPosition )
{
if( IsNew() )
if( m_editState == 1 ) // Second position yields the arc segment length.
{
if( m_editState == 1 ) // Second position yields the arc segment length.
{
m_ArcEnd = aPosition;
m_editState = 2;
return true; // Need third position to calculate center point.
}
m_ArcEnd = aPosition;
m_editState = 2;
return true; // Need third position to calculate center point.
}
return false;
}
void LIB_ARC::EndEdit( const wxPoint& aPosition )
void LIB_ARC::EndEdit()
{
LIB_ITEM::EndEdit( aPosition );
m_lastEditState = 0;
m_editState = 0;
}
@ -508,47 +459,39 @@ void LIB_ARC::EndEdit( const wxPoint& aPosition )
void LIB_ARC::CalcEdit( const wxPoint& aPosition )
{
if( IsNew() )
if( m_editState == 1 )
{
if( m_editState == 1 )
{
m_ArcEnd = aPosition;
}
if( m_editState != m_lastEditState )
m_lastEditState = m_editState;
// Keep the arc center point up to date. Otherwise, there will be edit graphic
// artifacts left behind from the initial draw.
int dx, dy;
int cX, cY;
double angle;
cX = aPosition.x;
cY = aPosition.y;
dx = m_ArcEnd.x - m_ArcStart.x;
dy = m_ArcEnd.y - m_ArcStart.y;
cX -= m_ArcStart.x;
cY -= m_ArcStart.y;
angle = ArcTangente( dy, dx );
RotatePoint( &dx, &dy, angle ); /* The segment dx, dy is horizontal
* -> Length = dx, dy = 0 */
RotatePoint( &cX, &cY, angle );
cX = dx / 2; /* cX, cY is on the median segment 0.0 a dx, 0 */
RotatePoint( &cX, &cY, -angle );
cX += m_ArcStart.x;
cY += m_ArcStart.y;
m_Pos.x = cX;
m_Pos.y = cY;
CalcRadiusAngles();
}
else if( IsMoving() )
{
MoveTo( m_initialPos + aPosition - m_initialCursorPos );
m_ArcEnd = aPosition;
}
if( m_editState != m_lastEditState )
m_lastEditState = m_editState;
// Keep the arc center point up to date. Otherwise, there will be edit graphic
// artifacts left behind from the initial draw.
int dx, dy;
int cX, cY;
double angle;
cX = aPosition.x;
cY = aPosition.y;
dx = m_ArcEnd.x - m_ArcStart.x;
dy = m_ArcEnd.y - m_ArcStart.y;
cX -= m_ArcStart.x;
cY -= m_ArcStart.y;
angle = ArcTangente( dy, dx );
RotatePoint( &dx, &dy, angle ); /* The segment dx, dy is horizontal
* -> Length = dx, dy = 0 */
RotatePoint( &cX, &cY, angle );
cX = dx / 2; /* cX, cY is on the median segment 0.0 a dx, 0 */
RotatePoint( &cX, &cY, -angle );
cX += m_ArcStart.x;
cY += m_ArcStart.y;
m_Pos.x = cX;
m_Pos.y = cY;
CalcRadiusAngles();
}

View File

@ -22,12 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_arc.h
*/
#ifndef _LIB_ARC_H_
#define _LIB_ARC_H_
#ifndef LIB_ARC_H
#define LIB_ARC_H
#include <lib_draw_item.h>
@ -89,10 +85,10 @@ public:
int GetPenSize() const override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void BeginEdit( const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition ) override;
void EndEdit() override;
void Offset( const wxPoint& aOffset ) override;
@ -104,7 +100,6 @@ public:
void MirrorHorizontal( const wxPoint& aCenter ) override;
void MirrorVertical( const wxPoint& aCenter ) override;
void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
@ -155,4 +150,4 @@ private:
};
#endif // _LIB_ARC_H_
#endif // LIB_ARC_H

View File

@ -21,10 +21,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_bezier.cpp
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <macros.h>
@ -104,9 +100,7 @@ bool LIB_BEZIER::Inside( EDA_RECT& aRect ) const
void LIB_BEZIER::MoveTo( const wxPoint& aPosition )
{
if ( !m_PolyPoints.size() )
{
m_PolyPoints.push_back( wxPoint(0, 0) );
}
Offset( aPosition - m_PolyPoints[ 0 ] );
}
@ -114,9 +108,7 @@ void LIB_BEZIER::MoveTo( const wxPoint& aPosition )
const wxPoint LIB_BEZIER::GetOffset() const
{
if ( !m_PolyPoints.size() )
{
return wxPoint(0, 0);
}
return m_PolyPoints[0];
}
@ -167,19 +159,11 @@ void LIB_BEZIER::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
size_t i, imax = m_PolyPoints.size();
for( wxPoint& point : m_PolyPoints )
RotatePoint( &point, aCenter, rot_angle );
for( i = 0; i < imax; i++ )
{
RotatePoint( &m_PolyPoints[i], aCenter, rot_angle );
}
imax = m_BezierPoints.size();
for( i = 0; i < imax; i++ )
{
RotatePoint( &m_BezierPoints[i], aCenter, rot_angle );
}
for( wxPoint& bezierPoint : m_BezierPoints )
RotatePoint( &bezierPoint, aCenter, rot_angle );
}
@ -191,9 +175,8 @@ void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
static std::vector< wxPoint > cornerList;
cornerList.clear();
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
for( wxPoint pos : m_PolyPoints )
{
wxPoint pos = m_PolyPoints[ii];
pos = aTransform.TransformCoordinate( pos ) + aOffset;
cornerList.push_back( pos );
}
@ -211,7 +194,7 @@ void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
{
pen_size = std::max( 0, pen_size );
aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, GetPenSize() );
aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, pen_size );
}
}
@ -240,9 +223,8 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
PolyPointsTraslated.clear();
for( unsigned int i = 0; i < m_PolyPoints.size() ; i++ )
PolyPointsTraslated.push_back( aTransform.TransformCoordinate( m_PolyPoints[i] ) +
aOffset );
for( wxPoint& point : m_PolyPoints )
PolyPointsTraslated.push_back( aTransform.TransformCoordinate( point ) + aOffset );
FILL_T fill = aData ? NO_FILL : m_Fill;
@ -250,17 +232,17 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
if( fill == FILLED_WITH_BG_BODYCOLOR )
{
GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], 1, GetPenSize(),
GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], true, GetPenSize(),
bgColor, bgColor );
}
else if( fill == FILLED_SHAPE )
{
GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], 1, GetPenSize(),
GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], true, GetPenSize(),
color, color );
}
else
{
GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], 0, GetPenSize(),
GRPoly( clipbox, aDC, m_PolyPoints.size(), &PolyPointsTraslated[0], false, GetPenSize(),
color, color );
}
}
@ -363,8 +345,11 @@ void LIB_BEZIER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITE
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
msg.Printf( wxT( "(%d, %d, %d, %d)" ),
bBox.GetOrigin().x,
bBox.GetOrigin().y,
bBox.GetEnd().x,
bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}

View File

@ -22,12 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_bezier.h
*/
#ifndef _LIB_BEZIER_H_
#define _LIB_BEZIER_H_
#ifndef LIB_BEZIER_H
#define LIB_BEZIER_H
#include <lib_draw_item.h>
@ -73,10 +69,7 @@ public:
*/
unsigned GetCornerCount() const { return m_PolyPoints.size(); }
const std::vector< wxPoint >& GetPoints() const
{
return m_BezierPoints;
}
const std::vector< wxPoint >& GetPoints() const { return m_BezierPoints; }
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
@ -91,7 +84,6 @@ public:
void MirrorHorizontal( const wxPoint& aCenter ) override;
void MirrorVertical( const wxPoint& aCenter ) override;
void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
@ -119,4 +111,4 @@ private:
};
#endif // _LIB_BEZIER_H_
#endif // LIB_BEZIER_H

View File

@ -22,11 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_circle.cpp
* @brief LIB_CIRCLE class implementation.
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <macros.h>
@ -249,8 +244,11 @@ void LIB_CIRCLE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
msg = MessageTextFromValue( aUnits, GetRadius(), true );
aList.push_back( MSG_PANEL_ITEM( _( "Radius" ), msg, RED ) );
msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x,
bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y );
msg.Printf( wxT( "(%d, %d, %d, %d)" ),
bBox.GetOrigin().x,
bBox.GetOrigin().y,
bBox.GetEnd().x,
bBox.GetEnd().y );
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
}
@ -271,30 +269,13 @@ BITMAP_DEF LIB_CIRCLE::GetMenuImage() const
}
void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
void LIB_CIRCLE::BeginEdit( const wxPoint aPosition )
{
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
m_Pos = m_initialPos = aPosition;
}
else if( aEditMode == IS_MOVED )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
}
m_Pos = m_initialPos = aPosition;
}
void LIB_CIRCLE::CalcEdit( const wxPoint& aPosition )
{
if( IsNew() )
{
SetEnd( aPosition );
}
else if( IsMoving() )
{
MoveTo( m_initialPos + aPosition - m_initialCursorPos );
}
SetEnd( aPosition );
}

View File

@ -22,12 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_circle.h
*/
#ifndef _LIB_CIRCLE_H_
#define _LIB_CIRCLE_H_
#ifndef LIB_CIRCLE_H
#define LIB_CIRCLE_H
#include <lib_draw_item.h>
@ -67,7 +63,7 @@ public:
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void BeginEdit( const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
void Offset( const wxPoint& aOffset ) override;
@ -83,7 +79,6 @@ public:
void MirrorHorizontal( const wxPoint& aCenter ) override;
void MirrorVertical( const wxPoint& aCenter ) override;
void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
@ -115,4 +110,4 @@ private:
};
#endif // _LIB_CIRCLE_H_
#endif // LIB_CIRCLE_H

View File

@ -130,51 +130,34 @@ public:
virtual wxString GetTypeName() = 0;
/**
* Begin an editing a component library draw item in \a aEditMode at \a aPosition.
* Begin drawing a component library draw item at \a aPosition.
*
* This is used to start an editing action such as resize or move a draw object.
* It typically would be called on a left click when a draw tool is selected in
* the component library editor and one of the graphics tools is selected. It
* allows the draw item to maintain it's own internal state while it is being
* edited. Call AbortEdit() to quit the editing mode.
* the component library editor and one of the graphics tools is selected.
*
* @param aEditMode The editing mode being performed. See base_struct.h for a list
* of mode flags.
* @param aPosition The position in drawing coordinates where the editing mode was
* started. This may or may not be required depending on the item
* being edited and the edit mode.
* @param aPosition The position in drawing coordinates where the drawing was started.
* May or may not be required depending on the item being drawn.
*/
virtual void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
SetFlags( aEditMode );
}
virtual void BeginEdit( const wxPoint aPosition ) {}
/**
* Continue an edit in progress at \a aPosition.
*
* This is used to perform the next action while editing a draw item. This would be
* This is used to perform the next action while drawing an item. This would be
* called for each additional left click when the mouse is captured while the item
* is being edited.
* is being drawn.
*
* @param aPosition The position of the mouse left click in drawing coordinates.
* @return True if additional mouse clicks are required to complete the edit in progress.
*/
virtual bool ContinueEdit( const wxPoint aPosition )
{
return false;
}
virtual bool ContinueEdit( const wxPoint aPosition ) { return false; }
/**
* End an object editing action.
*
* This is used to end or abort an edit action in progress initiated by BeginEdit().
*
* @param aPosition The position of the last edit event in drawing coordinates.
*/
virtual void EndEdit( const wxPoint& aPosition )
{
ClearEditFlags();
}
virtual void EndEdit() {}
/**
* Calculates the attributes of an item at \a aPosition when it is being edited.

View File

@ -22,10 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_field.cpp
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
@ -74,7 +70,7 @@ LIB_FIELD::~LIB_FIELD()
}
void LIB_FIELD::operator=( const LIB_FIELD& field )
LIB_FIELD& LIB_FIELD::operator=( const LIB_FIELD& field )
{
m_id = field.m_id;
m_Text = field.m_Text;
@ -82,6 +78,8 @@ void LIB_FIELD::operator=( const LIB_FIELD& field )
m_Parent = field.m_Parent;
SetEffects( field );
return *this;
}
@ -94,9 +92,6 @@ void LIB_FIELD::Init( int id )
SetTextAngle( TEXT_ANGLE_HORIZ ); // constructor already did this.
m_rotate = false;
m_updateText = false;
// fields in RAM must always have names, because we are trying to get
// less dependent on field ids and more dependent on names.
// Plus assumptions are made in the field editors.
@ -303,7 +298,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
/* Calculate the text orientation, according to the component
* orientation/mirror */
int orient = GetTextAngle();
int orient = (int) GetTextAngle();
if( aTransform.y1 ) // Rotate component 90 deg.
{
@ -394,14 +389,7 @@ COLOR4D LIB_FIELD::GetDefaultColor()
void LIB_FIELD::Rotate()
{
if( InEditMode() )
{
m_rotate = true;
}
else
{
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
}
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
}
@ -452,22 +440,7 @@ void LIB_FIELD::SetName( const wxString& aName )
void LIB_FIELD::SetText( const wxString& aText )
{
if( aText == GetText() )
return;
wxString oldValue( m_Text );
wxString newValue( aText );
if( InEditMode() )
{
m_Text = oldValue;
m_savedText = newValue;
m_updateText = true;
}
else
{
m_Text = newValue;
}
m_Text = aText;
}
@ -477,53 +450,15 @@ wxString LIB_FIELD::GetSelectMenuText( EDA_UNITS_T aUnits ) const
}
void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
void LIB_FIELD::BeginEdit( const wxPoint aPosition )
{
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_MOVED )
{
m_initialPos = GetTextPos();
m_initialCursorPos = aPosition;
}
else
{
SetTextPos( aPosition );
}
}
void LIB_FIELD::EndEdit( const wxPoint& aPosition )
{
LIB_ITEM::EndEdit( aPosition );
m_rotate = false;
m_updateText = false;
SetTextPos( aPosition );
}
void LIB_FIELD::CalcEdit( const wxPoint& aPosition )
{
if( m_rotate )
{
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
m_rotate = false;
}
if( m_updateText )
{
std::swap( m_Text, m_savedText );
m_updateText = false;
}
if( IsNew() )
{
SetTextPos( aPosition );
}
else if( IsMoving() )
{
MoveTo( m_initialPos + aPosition - m_initialCursorPos );
}
SetTextPos( aPosition );
}

View File

@ -61,10 +61,6 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
int m_id; ///< @see enum NumFieldType
wxString m_name; ///< Name (not the field text value itself, that is .m_Text)
wxString m_savedText; ///< Temporary storage for the string when editing.
bool m_rotate; ///< Flag to indicate a rotation occurred while editing.
bool m_updateText; ///< Flag to indicate text change occurred while editing.
/**
* Draw the field.
* <p>
@ -137,7 +133,6 @@ public:
void SetName( const wxString& aName );
int GetId() const { return m_id; }
void SetId( int aId ) { m_id = aId; }
int GetPenSize( ) const override;
@ -159,18 +154,13 @@ public:
void ViewGetLayers( int aLayers[], int& aCount ) const override;
/**
* @return true is this field is visible, false if flagged invisible
*/
bool IsVisible() const { return EDA_TEXT::IsVisible(); } // why needed?
const EDA_RECT GetBoundingBox() const override;
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
void operator=( const LIB_FIELD& field );
LIB_FIELD& operator=( const LIB_FIELD& field );
/**
* Return the text of a field.
@ -188,8 +178,7 @@ public:
COLOR4D GetDefaultColor() override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void EndEdit( const wxPoint& aPosition ) override;
void BeginEdit( const wxPoint aStartPoint ) override;
void Rotate() override;

View File

@ -22,10 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_polyline.cpp
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <macros.h>
@ -41,13 +37,12 @@
#include <transform.h>
LIB_POLYLINE::LIB_POLYLINE( LIB_PART* aParent ) :
LIB_POLYLINE::LIB_POLYLINE( LIB_PART* aParent ) :
LIB_ITEM( LIB_POLYLINE_T, aParent )
{
m_Fill = NO_FILL;
m_Width = 0;
m_isFillable = true;
m_ModifyIndex = 0;
}
@ -81,16 +76,16 @@ int LIB_POLYLINE::compare( const LIB_ITEM& aOther ) const
void LIB_POLYLINE::Offset( const wxPoint& aOffset )
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
m_PolyPoints[i] += aOffset;
for( wxPoint& point : m_PolyPoints )
point += aOffset;
}
bool LIB_POLYLINE::Inside( EDA_RECT& aRect ) const
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
for( const wxPoint& point : m_PolyPoints )
{
if( aRect.Contains( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
if( aRect.Contains( point.x, -point.y ) )
return true;
}
@ -106,35 +101,28 @@ void LIB_POLYLINE::MoveTo( const wxPoint& aPosition )
void LIB_POLYLINE::MirrorHorizontal( const wxPoint& aCenter )
{
size_t i, imax = m_PolyPoints.size();
for( i = 0; i < imax; i++ )
for( wxPoint& point : m_PolyPoints )
{
m_PolyPoints[i].x -= aCenter.x;
m_PolyPoints[i].x *= -1;
m_PolyPoints[i].x += aCenter.x;
point.x -= aCenter.x;
point.x *= -1;
point.x += aCenter.x;
}
}
void LIB_POLYLINE::MirrorVertical( const wxPoint& aCenter )
{
size_t i, imax = m_PolyPoints.size();
for( i = 0; i < imax; i++ )
for( wxPoint& point : m_PolyPoints )
{
m_PolyPoints[i].y -= aCenter.y;
m_PolyPoints[i].y *= -1;
m_PolyPoints[i].y += aCenter.y;
point.y -= aCenter.y;
point.y *= -1;
point.y += aCenter.y;
}
}
void LIB_POLYLINE::Rotate( const wxPoint& aCenter, bool aRotateCCW )
{
int rot_angle = aRotateCCW ? -900 : 900;
size_t i, imax = m_PolyPoints.size();
for( i = 0; i < imax; i++ )
RotatePoint( &m_PolyPoints[i], aCenter, rot_angle );
for( wxPoint& point : m_PolyPoints )
RotatePoint( &point, aCenter, aRotateCCW ? -900 : 900 );
}
@ -146,9 +134,8 @@ void LIB_POLYLINE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
static std::vector< wxPoint > cornerList;
cornerList.clear();
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
for( wxPoint pos : m_PolyPoints )
{
wxPoint pos = m_PolyPoints[ii];
pos = aTransform.TransformCoordinate( pos ) + aOffset;
cornerList.push_back( pos );
}
@ -372,127 +359,35 @@ BITMAP_DEF LIB_POLYLINE::GetMenuImage() const
}
void LIB_POLYLINE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
void LIB_POLYLINE::BeginEdit( const wxPoint aPosition )
{
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
m_PolyPoints.push_back( aPosition ); // Start point of first segment.
m_PolyPoints.push_back( aPosition ); // End point of first segment.
}
else if( aEditMode == IS_RESIZED )
{
// Drag one edge point of the polyline
// Find the nearest edge point to be dragged
wxPoint startPoint = m_PolyPoints[0];
// Begin with the first list point as nearest point
int index = 0;
m_ModifyIndex = 0;
m_initialPos = startPoint;
// First distance is the current minimum distance
int distanceMin = (aPosition - startPoint).x * (aPosition - startPoint).x
+ (aPosition - startPoint).y * (aPosition - startPoint).y;
wxPoint prevPoint = startPoint;
// Find the right index of the point to be dragged
for( wxPoint point : m_PolyPoints )
{
int distancePoint = (aPosition - point).x * (aPosition - point).x +
(aPosition - point).y * (aPosition - point).y;
if( distancePoint < distanceMin )
{
// Save point.
m_initialPos = point;
m_ModifyIndex = index;
distanceMin = distancePoint;
}
// check middle of an edge
wxPoint offset = ( aPosition + aPosition - point - prevPoint );
distancePoint = ( offset.x * offset.x + offset.y * offset.y ) / 4 + 1;
if( distancePoint < distanceMin )
{
// Save point.
m_initialPos = point;
m_ModifyIndex = -index; // negative indicates new vertex is to be inserted
distanceMin = distancePoint;
}
prevPoint = point;
index++;
}
}
else if( aEditMode == IS_MOVED )
{
m_initialCursorPos = aPosition;
m_initialPos = m_PolyPoints[0];
}
m_PolyPoints.push_back( aPosition ); // Start point of first segment.
m_PolyPoints.push_back( aPosition ); // End point of first segment.
}
bool LIB_POLYLINE::ContinueEdit( const wxPoint aPosition )
{
if( IsNew() )
{
// do not add zero length segments
if( m_PolyPoints[m_PolyPoints.size() - 2] != m_PolyPoints.back() )
m_PolyPoints.push_back( aPosition );
// do not add zero length segments
if( m_PolyPoints[m_PolyPoints.size() - 2] != m_PolyPoints.back() )
m_PolyPoints.push_back( aPosition );
return true;
}
return false;
return true;
}
void LIB_POLYLINE::EndEdit( const wxPoint& aPosition )
void LIB_POLYLINE::EndEdit()
{
LIB_ITEM::EndEdit( aPosition );
// do not include last point twice
if( m_Flags == IS_NEW && 2 < m_PolyPoints.size() )
if( m_PolyPoints.size() > 2 )
{
if( m_PolyPoints[ m_PolyPoints.size() - 2 ] == m_PolyPoints.back() )
m_PolyPoints.pop_back();
}
if( (m_Flags == IS_RESIZED) && (m_PolyPoints.size() > 2) ) // do not delete last two points... keep it alive
{
if( ( m_ModifyIndex > 0 && m_PolyPoints[ m_ModifyIndex ] ==
m_PolyPoints[ m_ModifyIndex - 1 ] )
|| ( m_ModifyIndex < (int) m_PolyPoints.size() - 1
&& m_PolyPoints[ m_ModifyIndex ] == m_PolyPoints[ m_ModifyIndex + 1 ] ) )
{
m_PolyPoints.erase( m_PolyPoints.begin() + m_ModifyIndex ); // delete a point on this
}
}
}
void LIB_POLYLINE::CalcEdit( const wxPoint& aPosition )
{
if( IsNew() )
{
m_PolyPoints[ GetCornerCount() - 1 ] = aPosition;
}
else if( IsResized() )
{
if( m_ModifyIndex < 0 ) // negative indicates new vertex is to be inserted
{
m_ModifyIndex = -m_ModifyIndex;
m_PolyPoints.insert( m_PolyPoints.begin() + m_ModifyIndex, aPosition );
}
m_PolyPoints[ m_ModifyIndex ] = aPosition;
}
else if( IsMoving() )
{
MoveTo( m_initialPos + aPosition - m_initialCursorPos );
}
m_PolyPoints[ GetCornerCount() - 1 ] = aPosition;
}

View File

@ -22,10 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_polyline.h
*/
#ifndef _LIB_POLYLINE_H_
#define _LIB_POLYLINE_H_
@ -37,8 +33,6 @@ class LIB_POLYLINE : public LIB_ITEM
int m_Width; // Line width
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
int m_ModifyIndex; // Index of the polyline point to modify
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
@ -87,10 +81,10 @@ public:
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void BeginEdit( const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
bool ContinueEdit( const wxPoint aNextPoint ) override;
void EndEdit( const wxPoint& aPosition ) override;
void EndEdit() override;
void Offset( const wxPoint& aOffset ) override;

View File

@ -22,10 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_rectangle.cpp
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <macros.h>
@ -47,9 +43,6 @@ LIB_RECTANGLE::LIB_RECTANGLE( LIB_PART* aParent ) :
m_Width = 0;
m_Fill = NO_FILL;
m_isFillable = true;
m_isHeightLocked = false;
m_isWidthLocked = false;
m_isStartPointSelected = false;
}
@ -173,13 +166,10 @@ int LIB_RECTANGLE::GetPenSize() const
void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
void* aData, const TRANSFORM& aTransform )
{
wxPoint pt1, pt2;
COLOR4D color = GetLayerColor( LAYER_DEVICE );
COLOR4D bgColor = GetLayerColor( LAYER_DEVICE_BACKGROUND );
pt1 = aTransform.TransformCoordinate( m_Pos ) + aOffset;
pt2 = aTransform.TransformCoordinate( m_End ) + aOffset;
wxPoint pt1 = aTransform.TransformCoordinate( m_Pos ) + aOffset;
wxPoint pt2 = aTransform.TransformCoordinate( m_End ) + aOffset;
FILL_T fill = aData ? NO_FILL : m_Fill;
@ -195,11 +185,9 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoin
void LIB_RECTANGLE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
{
wxString msg;
LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
msg = MessageTextFromValue( aUnits, m_Width, true );
wxString msg = MessageTextFromValue( aUnits, m_Width, true );
aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
}
@ -277,39 +265,13 @@ BITMAP_DEF LIB_RECTANGLE::GetMenuImage() const
}
void LIB_RECTANGLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
void LIB_RECTANGLE::BeginEdit( const wxPoint aPosition )
{
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_NEW )
{
m_Pos = m_End = aPosition;
}
else if( aEditMode == IS_MOVED )
{
m_initialPos = m_Pos;
m_initialCursorPos = aPosition;
}
}
void LIB_RECTANGLE::EndEdit( const wxPoint& aPosition )
{
LIB_ITEM::EndEdit( aPosition );
m_isHeightLocked = false;
m_isWidthLocked = false;
m_Pos = m_End = aPosition;
}
void LIB_RECTANGLE::CalcEdit( const wxPoint& aPosition )
{
if( IsNew() )
{
m_End = aPosition;
}
else if( IsMoving() )
{
MoveTo( m_initialPos + aPosition - m_initialCursorPos );
}
m_End = aPosition;
}

View File

@ -22,12 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_rectangle.h
*/
#ifndef _LIB_RECTANGLE_H_
#define _LIB_RECTANGLE_H_
#ifndef LIB_RECTANGLE_H
#define LIB_RECTANGLE_H
#include <lib_draw_item.h>
@ -37,9 +33,6 @@ class LIB_RECTANGLE : public LIB_ITEM
wxPoint m_End; // Rectangle end point.
wxPoint m_Pos; // Rectangle start point.
int m_Width; // Line width
bool m_isWidthLocked; // Flag: Keep width locked
bool m_isHeightLocked; // Flag: Keep height locked
bool m_isStartPointSelected; // Flag: is the upper left edge selected?
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
@ -71,9 +64,8 @@ public:
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void BeginEdit( const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
void EndEdit( const wxPoint& aPosition ) override;
void Offset( const wxPoint& aOffset ) override;
@ -117,4 +109,4 @@ private:
};
#endif // _LIB_RECTANGLE_H_
#endif // LIB_RECTANGLE_H

View File

@ -47,8 +47,6 @@ LIB_TEXT::LIB_TEXT( LIB_PART * aParent ) :
EDA_TEXT()
{
SetTextSize( wxSize( 50, 50 ) );
m_rotate = false;
m_updateText = false;
}
@ -303,27 +301,13 @@ const EDA_RECT LIB_TEXT::GetBoundingBox() const
void LIB_TEXT::Rotate()
{
if( InEditMode() )
m_rotate = true;
else
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
}
void LIB_TEXT::SetText( const wxString& aText )
{
if( aText == m_Text )
return;
if( InEditMode() )
{
m_savedText = aText;
m_updateText = true;
}
else
{
m_Text = aText;
}
m_Text = aText;
}
@ -339,56 +323,13 @@ BITMAP_DEF LIB_TEXT::GetMenuImage() const
}
void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
void LIB_TEXT::BeginEdit( const wxPoint aPosition )
{
LIB_ITEM::BeginEdit( aEditMode, aPosition );
if( aEditMode == IS_MOVED )
{
m_initialPos = GetTextPos();
m_initialCursorPos = aPosition;
}
else
{
SetTextPos( aPosition );
}
}
void LIB_TEXT::EndEdit( const wxPoint& aPosition )
{
LIB_ITEM::EndEdit( aPosition );
m_rotate = false;
m_updateText = false;
SetTextPos( aPosition );
}
void LIB_TEXT::CalcEdit( const wxPoint& aPosition )
{
DBG(printf("textCalcEdit %d %d\n", aPosition.x, aPosition.y );)
if( m_rotate )
{
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
m_rotate = false;
}
if( m_updateText )
{
std::swap( m_Text, m_savedText );
m_updateText = false;
}
if( IsNew() )
{
SetTextPos( aPosition );
}
else if( IsMoving() )
{
MoveTo( m_initialPos + aPosition - m_initialCursorPos );
DBG(printf("%p: move %d %d\n", this, GetPosition().x, GetPosition().y );)
}
DBG(printf("%p: move2 %d %d\n", this, GetPosition().x, GetPosition().y );)
SetTextPos( aPosition );
}

View File

@ -22,12 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file lib_text.h
*/
#ifndef _LIB_TEXT_H_
#define _LIB_TEXT_H_
#ifndef LIB_TEXT_H
#define LIB_TEXT_H
#include <eda_text.h>
#include <lib_draw_item.h>
@ -43,10 +39,6 @@
*/
class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
{
wxString m_savedText; ///< Temporary storage for the string when editing.
bool m_rotate; ///< Flag to indicate a rotation occurred while editing.
bool m_updateText; ///< Flag to indicate text change occurred while editing.
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
const TRANSFORM& aTransform ) override;
@ -97,9 +89,8 @@ public:
void Rotate() override;
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint ) override;
void BeginEdit( const wxPoint aStartPoint ) override;
void CalcEdit( const wxPoint& aPosition ) override;
void EndEdit( const wxPoint& aPosition ) override;
void Offset( const wxPoint& aOffset ) override;
@ -144,4 +135,4 @@ private:
};
#endif // _LIB_TEXT_H_
#endif // LIB_TEXT_H

View File

@ -196,9 +196,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( m_canvas )
m_canvas->SetEnableBlockCommands( true );
m_libMgr = new LIB_MANAGER( *this );
SyncLibraries( true );
m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr );
@ -1072,17 +1069,9 @@ bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
if( aHotKey )
keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_canvas->CrossHairOff( aDC );
else
m_canvas->CrossHairOn( aDC );
GetGalCanvas()->GetViewControls()->SetSnapping( false );
SetCrossHairPosition( pos, false );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( aDC, aPosition, true );
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition, NULL ) )
keyHandled = true;

View File

@ -313,18 +313,12 @@ public:
*/
void RedrawComponent( wxDC* aDC, wxPoint aOffset );
/**
* Redraw the current component loaded in library editor, an axes
* Display reference like in schematic (a reference U is shown U? or U?A)
* update status bar and info shown in the bottom of the window
*/
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override { /* OBSOLETE */ }
void OnCloseWindow( wxCloseEvent& Event );
void ReCreateHToolbar() override;
void ReCreateVToolbar() override;
void ReCreateOptToolbar();
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override { return true; }
double BestZoom() override; // Returns the best zoom
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()

View File

@ -289,34 +289,6 @@ void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset )
}
void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( GetScreen() == NULL )
return;
m_canvas->DrawBackGround( DC );
RedrawComponent( DC, wxPoint( 0, 0 ) );
#ifdef USE_WX_OVERLAY
if( IsShown() )
{
m_overlay.Reset();
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
overlaydc.Clear();
}
#endif
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->DrawCrossHair( DC );
updateTitle();
UpdateStatusBar();
}
void LIB_EDIT_FRAME::OnSaveAll( wxCommandEvent& event )
{
saveAllLibraries( false );

View File

@ -368,74 +368,6 @@ bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
}
// Set the zoom level to show the contents of the view.
void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
{
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
KIGFX::VIEW* view = GetGalCanvas()->GetView();
BOX2I bBox = GetDocumentExtents();
VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
bBox = galCanvas->GetDefaultViewBBox();
VECTOR2D vsize = bBox.GetSize();
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
fabs( vsize.y / screenSize.y ) );
// Reserve a 10% margin around component bounding box.
double margin_scale_factor = 1.1;
// Leave 20% for library editors & viewers
if( IsType( FRAME_PCB_MODULE_VIEWER ) || IsType( FRAME_PCB_MODULE_VIEWER_MODAL )
|| IsType( FRAME_SCH_VIEWER ) || IsType( FRAME_SCH_VIEWER_MODAL )
|| IsType( FRAME_SCH_LIB_EDITOR ) || IsType( FRAME_PCB_MODULE_EDITOR ) )
{
margin_scale_factor = 1.2;
}
scale /= margin_scale_factor;
GetScreen()->SetScalingFactor( 1 / scale );
view->SetScale( scale );
view->SetCenter( bBox.Centre() );
// Take scrollbars into account
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
galCanvas->Refresh();
}
// Set the zoom level to show the area of aRect
void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& aRect )
{
KIGFX::VIEW* view = GetGalCanvas()->GetView();
BOX2I selectionBox ( aRect.GetPosition(), aRect.GetSize() );
VECTOR2D screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
if( selectionBox.GetWidth() == 0 || selectionBox.GetHeight() == 0 )
return;
VECTOR2D vsize = selectionBox.GetSize();
double scale;
double ratio = std::max( fabs( vsize.x / screenSize.x ), fabs( vsize.y / screenSize.y ) );
scale = view->GetScale() / ratio;
GetScreen()->SetScalingFactor( 1 / scale );
view->SetScale( scale );
view->SetCenter( selectionBox.Centre() );
GetGalCanvas()->Refresh();
}
void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
KIGFX::GAL* gal = GetCanvas()->GetGAL();

View File

@ -310,12 +310,6 @@ public:
const LIB_ID& aPreselectedLibid,
int aUnit, int aConvert );
virtual void Zoom_Automatique( bool aWarpPointer ) override;
/* Set the zoom level to show the area Rect */
virtual void Window_Zoom( EDA_RECT& aRect ) override;
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) override;
virtual void RedrawScreen2( const wxPoint& posBefore ) override;

View File

@ -98,12 +98,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
// launching a editor from a double click made in another frame)
m_ignoreNextLeftButtonRelease = true;
m_mouseCaptureCallback = NULL;
m_endMouseCaptureCallback = NULL;
m_enableBlockCommands = false;
m_minDragEventCount = 0;
m_cursorLevel = 0;
m_PrintIsMirrored = false;
@ -246,18 +240,6 @@ EDA_DRAW_FRAME* SCH_DRAW_PANEL::GetParent() const
}
void SCH_DRAW_PANEL::CrossHairOff( wxDC* DC )
{
m_viewControls->ShowCursor( false );
}
void SCH_DRAW_PANEL::CrossHairOn( wxDC* DC )
{
m_viewControls->ShowCursor( true );
}
void SCH_DRAW_PANEL::MoveCursorToCrossHair()
{
GetViewControls()->WarpCursor( GetParent()->GetCrossHairPosition(), true );

View File

@ -52,11 +52,6 @@ public:
BASE_SCREEN* GetScreen() override;
virtual EDA_DRAW_FRAME* GetParent() const override;
virtual void CrossHairOff( wxDC* DC=nullptr ) override;
// Show the cross hair.
virtual void CrossHairOn( wxDC* DC=nullptr ) override;
virtual void MoveCursorToCrossHair() override;
KIGFX::SCH_VIEW* GetView() const { return view(); }

View File

@ -30,7 +30,7 @@
#include <sch_junction.h>
#include <sch_sheet.h>
#include <sch_edit_frame.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <template_fieldnames.h>
#include <wildcards_and_files_ext.h>
#include <sch_screen.h>

View File

@ -324,9 +324,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( m_canvas )
m_canvas->SetEnableBlockCommands( true );
setupTools();
ReCreateMenuBar();
ReCreateHToolbar();
@ -423,23 +420,11 @@ void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem )
// that item may be deleted, such as part of a line concatonation or other.
// So simply always keep a copy of the object which is to be repeated.
SCH_ITEM* old = m_item_to_repeat;
SCH_ITEM* cur = aItem;
delete m_item_to_repeat;
if( cur != old )
{
if( cur )
{
aItem = (SCH_ITEM*) cur->Clone();
// Clone() preserves the flags, we want 'em cleared.
aItem->ClearFlags();
}
m_item_to_repeat = aItem;
delete old;
}
m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
// Clone() preserves the flags, we want 'em cleared.
m_item_to_repeat->ClearFlags();
}
@ -461,20 +446,16 @@ void SCH_EDIT_FRAME::SetSheetNumberAndCount()
{
wxString sheetpath = sheetList[i].Path();
if( sheetpath == current_sheetpath ) // Current sheet path found
if( sheetpath == current_sheetpath ) // Current sheet path found
break;
SheetNumber++; /* Not found, increment sheet
* number before this current
* path */
SheetNumber++; // Not found, increment before this current path
}
g_CurrentSheet->SetPageNumber( SheetNumber );
for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
{
screen->m_NumberOfScreens = sheet_count;
}
GetScreen()->m_ScreenNumber = SheetNumber;
}
@ -503,9 +484,7 @@ wxString SCH_EDIT_FRAME::GetScreenDesc() const
void SCH_EDIT_FRAME::CreateScreens()
{
if( g_RootSheet == NULL )
{
g_RootSheet = new SCH_SHEET();
}
if( g_RootSheet->GetScreen() == NULL )
{
@ -558,30 +537,11 @@ void SCH_EDIT_FRAME::HardRedraw()
}
/*
* Redraws only the active window which is assumed to be whole visible.
*/
void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( GetScreen() == NULL )
return;
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
// Display the sheet filename, and the sheet path, for non root sheets
UpdateTitle();
}
void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem, bool aAppend )
{
wxCHECK_RET( aItem != NULL,
wxT( "Cannot swap undo item structures. Bad programmer!." ) );
wxCHECK_RET( m_undoItem != NULL,
wxT( "Cannot swap undo item structures. Bad programmer!." ) );
wxCHECK_RET( aItem->Type() == m_undoItem->Type(),
wxT( "Cannot swap undo item structures. Bad programmer!." ) );
wxCHECK_RET( aItem != NULL, wxT( "Cannot swap undo item structures." ) );
wxCHECK_RET( m_undoItem != NULL, wxT( "Cannot swap undo item structures." ) );
wxCHECK_RET( aItem->Type() == m_undoItem->Type(), wxT( "Cannot swap undo item structures." ) );
aItem->SwapData( m_undoItem );
SaveCopyInUndoList( aItem, UR_CHANGED, aAppend );
@ -940,8 +900,7 @@ void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
{
wxString pro_dir = m_mruPath;
wxFileDialog dlg( this, _( "New Schematic" ), pro_dir,
wxEmptyString, SchematicFileWildcard(),
wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard(),
wxFD_SAVE );
if( dlg.ShowModal() != wxID_CANCEL )
@ -971,8 +930,7 @@ void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
{
wxString pro_dir = m_mruPath;
wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir,
wxEmptyString, SchematicFileWildcard(),
wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard(),
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() != wxID_CANCEL )
@ -992,8 +950,10 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
kicad_board.SetExt( PcbFileExtension );
wxFileName legacy_board( kicad_board );
legacy_board.SetExt( LegacyPcbFileExtension );
wxFileName& boardfn = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
kicad_board : legacy_board;
wxFileName& boardfn = legacy_board;
if( !legacy_board.FileExists() || kicad_board.FileExists() )
boardfn = kicad_board;
if( Kiface().IsSingle() )
{

View File

@ -300,7 +300,7 @@ public:
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override { /* OBSOLETE */ }
void CreateScreens();
void ReCreateHToolbar() override;
@ -331,7 +331,6 @@ public:
void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override;
bool OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) override { return true; }
double BestZoom() override;
/**

View File

@ -308,8 +308,6 @@ bool SCH_FIELD::IsVoid() const
void SCH_FIELD::Place( SCH_EDIT_FRAME* frame, wxDC* DC )
{
frame->GetCanvas()->SetMouseCapture( NULL, NULL );
SCH_COMPONENT* component = (SCH_COMPONENT*) GetParent();
// save old cmp in undo list

View File

@ -110,11 +110,11 @@ SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) :
SetZoom( 32 );
for( unsigned i = 0; i < arrayDim( SchematicZoomList ); i++ )
m_ZoomList.push_back( SchematicZoomList[i] );
for( unsigned zoom : SchematicZoomList )
m_ZoomList.push_back( zoom );
for( unsigned i = 0; i < arrayDim( SchematicGridList ); i++ )
AddGrid( SchematicGridList[i] );
for( GRID_TYPE grid : SchematicGridList )
AddGrid( grid );
// Set the default grid size, now that the grid list is populated
SetGrid( wxRealPoint( 50, 50 ) );

View File

@ -21,8 +21,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef SCH_POINT_EDITOR_H
#define SCH_POINT_EDITOR_H
#ifndef EE_POINT_EDITOR_H
#define EE_POINT_EDITOR_H
#include <tools/ee_tool_base.h>
#include <tool/edit_points.h>
@ -32,7 +32,7 @@ class EE_SELECTION_TOOL;
class SCH_BASE_FRAME;
/**
* Class SCH_POINT_EDITOR
* Class EE_POINT_EDITOR
*
* Tool that displays edit points allowing to modify items by dragging the points.
*/
@ -101,4 +101,4 @@ private:
std::shared_ptr<EDIT_POINTS> m_editPoints;
};
#endif // SCH_POINT_EDITOR_H
#endif // EE_POINT_EDITOR_H

View File

@ -285,6 +285,8 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_frame->SetToolID( ID_LIBEDIT_BODY_LINE_BUTT, wxCURSOR_PENCIL, _( "Draw Lines" ) );
else if( aEvent.IsAction( &EE_ACTIONS::drawSymbolRectangle ) )
m_frame->SetToolID( ID_LIBEDIT_BODY_RECT_BUTT, wxCURSOR_PENCIL, _( "Draw Rectangle" ) );
else
wxCHECK_MSG( false, 0, "Unknown action in LIB_DRAWING_TOOLS::DrawShape()" );
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true );
@ -329,12 +331,12 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
case ID_LIBEDIT_BODY_CIRCLE_BUTT: item = new LIB_CIRCLE( part ); break;
case ID_LIBEDIT_BODY_LINE_BUTT: item = new LIB_POLYLINE( part ); break;
case ID_LIBEDIT_BODY_RECT_BUTT: item = new LIB_RECTANGLE( part ); break;
default: wxFAIL_MSG( "LIB_DRAWING_TOOLS:DrawShape(): unknown tool" );
}
item->SetWidth( LIB_EDIT_FRAME::g_LastLineWidth );
item->SetFillMode( LIB_EDIT_FRAME::g_LastFillStyle );
item->BeginEdit( IS_NEW, wxPoint( cursorPos.x, -cursorPos.y ) );
item->SetFlags( IS_NEW );
item->BeginEdit( wxPoint( cursorPos.x, -cursorPos.y ) );
if( m_frame->m_DrawSpecificUnit )
item->SetUnit( m_frame->GetUnit() );
@ -353,7 +355,8 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|| evt->IsAction( &EE_ACTIONS::finishDrawing )
|| !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) )
{
item->EndEdit( wxPoint( cursorPos.x, -cursorPos.y ) );
item->EndEdit();
item->ClearEditFlags();
m_view->ClearPreview();
m_frame->SaveCopyInUndoList( part );

View File

@ -154,7 +154,7 @@ TOOL_ACTION EE_ACTIONS::pinTable( "eeschema.InteractiveEdit.pinTable",
_( "Pin Table..." ), _( "Displays pin table for bulk editing of pins" ),
pin_table_xpm );
TOOL_ACTION EE_ACTIONS::doDelete( "eeschema.InteractiveEdit.doDelete",
TOOL_ACTION EE_ACTIONS::doDelete( "eeschema.InteractiveEdit.delete",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ),
_( "Delete" ), _( "Deletes selected item(s)" ),
delete_xpm );

View File

@ -855,7 +855,6 @@ bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
GeneralControlKeyMovement( aHotKey, &pos, true );
// Update cursor position.
m_canvas->CrossHairOn( aDC );
SetCrossHairPosition( pos, true );
if( aHotKey )

View File

@ -84,14 +84,13 @@ public:
bool ReCreateListCmp();
void DisplayLibInfos();
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override { /* OBSOLETE */ }
void OnCloseWindow( wxCloseEvent& Event );
void CloseLibraryViewer( wxCommandEvent& event );
void ReCreateHToolbar() override;
void ReCreateVToolbar() override;
void ReCreateMenuBar() override;
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
double BestZoom() override;
void ClickOnLibList( wxCommandEvent& event );
void ClickOnCmpList( wxCommandEvent& event );
@ -162,7 +161,6 @@ private:
*/
virtual void OnActivate( wxActivateEvent& event ) override;
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
void DClickOnCmpList( wxCommandEvent& event );
void onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent );

View File

@ -156,17 +156,6 @@ void LIB_VIEW_FRAME::onSelectSymbolUnit( wxCommandEvent& aEvent )
}
void LIB_VIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
}
bool LIB_VIEW_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
return true;
}
void LIB_VIEW_FRAME::DisplayLibInfos()
{
if( m_libList && !m_libList->IsEmpty() && !m_libraryName.IsEmpty() )
@ -179,9 +168,3 @@ void LIB_VIEW_FRAME::DisplayLibInfos()
}
}
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
DisplayLibInfos();
UpdateStatusBar();
}

View File

@ -134,9 +134,6 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
false );
}
if( zoom_command )
Window_Zoom( GetScreen()->m_BlockLocate );
return nextcmd ;
}

View File

@ -33,10 +33,8 @@
#include <gerbview_id.h>
#define MIL_GRID( x ) wxRealPoint( x * IU_PER_MILS,\
x * IU_PER_MILS)
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
x * IU_PER_MM )
#define MIL_GRID( x ) wxRealPoint( x * IU_PER_MILS, x * IU_PER_MILS)
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM, x * IU_PER_MM )
/**

View File

@ -232,7 +232,6 @@ public:
void ReCreateMenuBar() override;
void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos ) override;
void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override;
bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override { return true; }
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
double BestZoom() override;
void UpdateStatusBar() override;

View File

@ -55,36 +55,35 @@ class EDA_ITEM;
class COLLECTOR
{
protected:
/// a class common bridge into the polymorphic Inspect()
INSPECTOR_FUNC m_inspector;
/// Which object types to scan
const KICAD_T* m_ScanTypes;
/// A place to hold collected objects without taking ownership of their memory.
std::vector<EDA_ITEM*> m_List;
/// A point to test against, and that was used to make the collection.
wxPoint m_RefPos;
const KICAD_T* m_ScanTypes;
INSPECTOR_FUNC m_inspector;
wxPoint m_RefPos; // Reference position used to generate the collection.
EDA_RECT m_RefBox; // Selection rectangle used to generate the collection.
/// A bounding box to test against, and that was used to make the collection.
EDA_RECT m_RefBox;
timestamp_t m_TimeAtCollection; // The time at which the collection was made.
/// The time at which the collection was made.
timestamp_t m_TimeAtCollection;
public:
int m_Threshold; // Hit-test threshold in internal units.
wxString m_MenuTitle; // The title of selection disambiguation menu (if needed)
bool m_MenuCancelled; // Indicates selection disambiguation menu was cancelled
public:
COLLECTOR() :
m_ScanTypes( 0 ),
// Inspect() is virtual so calling it from a class common inspector preserves polymorphism.
m_inspector( [=] ( EDA_ITEM* aItem, void* aTestData ) { return this->Inspect( aItem, aTestData ); } )
m_inspector( [=] ( EDA_ITEM* aItem, void* aTestData ) { return this->Inspect( aItem, aTestData ); } ),
m_TimeAtCollection( 0 ),
m_Threshold( 0 ),
m_MenuCancelled( false )
{
m_ScanTypes = 0;
m_TimeAtCollection = 0;
}
virtual ~COLLECTOR() {}
virtual SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) = 0;
virtual SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) { return SEARCH_QUIT; };
using ITER = std::vector<EDA_ITEM*>::iterator;
using CITER = std::vector<EDA_ITEM*>::const_iterator;

View File

@ -165,7 +165,7 @@ enum KICAD_T
LIB_FIELD_T,
/*
* For GerbView: items type:
* For GerbView: item types:
*/
GERBER_LAYOUT_T,
GERBER_DRAW_ITEM_T,
@ -173,8 +173,15 @@ enum KICAD_T
GERBER_IMAGE_T,
/*
* for Pl_Editor, in undo/redo commands
* For Pl_Editor: item types:
*/
WSG_LINE_T,
WSG_RECT_T,
WSG_POLY_T,
WSG_TEXT_T,
WSG_BITMAP_T,
// serialized layout used in undo/redo commands
TYPE_PL_EDITOR_LAYOUT,
/*

View File

@ -715,9 +715,6 @@ public:
*/
virtual void Zoom_Automatique( bool aWarpPointer );
/* Set the zoom level to show the area Rect */
virtual void Window_Zoom( EDA_RECT& Rect );
/** Return the zoom level which displays the full page on screen */
virtual double BestZoom() = 0;
@ -755,7 +752,7 @@ public:
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0;
virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) {}
virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) {}
virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0;
virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) { return true; }
virtual void ToolOnRightClick( wxCommandEvent& event );
void AdjustScrollBars( const wxPoint& aCenterPosition );

View File

@ -6,22 +6,8 @@
#include <gr_basic.h>
#include <eda_rect.h>
/**
* Mouse capture callback function prototype.
*/
class BASE_SCREEN;
class EDA_DRAW_PANEL;
typedef void ( *MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
/**
* End mouse capture callback function prototype.
*/
typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
class EDA_DRAW_PANEL
{
@ -55,31 +41,10 @@ protected:
*/
bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true.
bool m_enableBlockCommands; ///< True enables block commands.
/**
* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if
* MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid
* spurious block commands.
*/
int m_minDragEventCount;
/// True when drawing in mirror mode. Used by the draw arc function, because arcs
/// are oriented, and in mirror mode, orientations are reversed.
bool m_PrintIsMirrored;
/// Mouse capture move callback function.
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback;
/// Abort mouse capture callback function.
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback;
/// useful to avoid false start block in certain cases
/// (like switch from a sheet to another sheet
/// >= 0 (or >= n) if a block can start
int m_canStartBlock;
int m_doubleClickInterval;
public:
@ -95,12 +60,7 @@ public:
m_enableAutoPan( false ),
m_ignoreMouseEvents( false ),
m_ignoreNextLeftButtonRelease( false ),
m_enableBlockCommands( true ),
m_minDragEventCount( 5 ),
m_PrintIsMirrored( false ),
m_mouseCaptureCallback( nullptr ),
m_endMouseCaptureCallback( nullptr ),
m_canStartBlock( true ),
m_doubleClickInterval( 0 )
{};
@ -145,13 +105,9 @@ public:
void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; }
void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; }
bool GetPrintMirrored() const { return m_PrintIsMirrored; }
void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; }
/**
* Function DrawBackGround
* @param DC = current Device Context
@ -191,18 +147,6 @@ public:
*/
virtual void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { printf("EDA_DRAW_PANEL:Unimplemented4\n"); };
/**
* Function DeviceToLogical
* converts \a aRect from device to drawing (logical) coordinates.
* <p>
* \a aRect must be in scrolled device units.
* </p>
* @param aRect The rectangle to convert.
* @param aDC The device context used for the conversion.
* @return A rectangle converted to drawing units.
*/
virtual wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC ) { printf("EDA_DRAW_PANEL:Unimplemented5\n");wxASSERT(false); return wxRect(); };
/* Mouse and keys events */
/**
@ -295,84 +239,6 @@ public:
*/
virtual void MoveCursor( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented17\n"); };;
/* Cursor functions */
/**
* Function DrawCrossHair
* draws the user cross hair.
* <p>
* The user cross hair is not the mouse cursor although they may be at the same screen
* position. The mouse cursor is still render by the OS. This is a drawn cross hair
* that is used to snap to grid when grid snapping is enabled. This is as an indicator
* to where the next user action will take place.
* </p>
* @param aDC - the device context to draw the cursor
* @param aColor - the color to draw the cursor
*/
virtual void DrawCrossHair( wxDC* aDC=nullptr, COLOR4D aColor = COLOR4D::WHITE ) { printf("EDA_DRAW_PANEL:Unimplemented18\n"); };;
// Hide the cross hair.
virtual void CrossHairOff( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented19\n"); };;
// Show the cross hair.
virtual void CrossHairOn( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented20\n"); };;
/**
* Function SetMouseCapture
* sets the mouse capture and end mouse capture callbacks to \a aMouseCaptureCallback
* and \a aEndMouseCaptureCallback respectively.
*/
virtual void SetMouseCapture( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback,
END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback )
{
m_mouseCaptureCallback = aMouseCaptureCallback;
m_endMouseCaptureCallback = aEndMouseCaptureCallback;
}
virtual void SetMouseCaptureCallback( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback )
{
m_mouseCaptureCallback = aMouseCaptureCallback;
}
/**
* Function EndMouseCapture
* ends mouse a capture.
*
* Check to see if the cursor is being managed for block or editing commands and release it.
* @param aId The command ID to restore or -1 to keep the current command ID.
* @param aCursorId The wxWidgets stock cursor ID to set the cursor to or -1 to keep the
* current cursor.
* @param aTitle The tool message to display in the status bar or wxEmptyString to clear
* the message.
* @param aCallEndFunc Call the abort mouse capture callback if true.
*/
virtual void EndMouseCapture( int aId = -1, int aCursorId = -1,
const wxString& aTitle = wxEmptyString,
bool aCallEndFunc = true ) { printf("EDA_DRAW_PANEL:Unimplemented21\n"); wxASSERT(false); };;
inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; }
/**
* Function CallMouseCapture
* calls the mouse capture callback.
*
* @param aDC A point to a wxDC object to perform any drawing upon.
* @param aPosition A referecnce to a wxPoint object containing the current cursor
* position.
* @param aErase True indicates the item being drawn should be erase before drawing
* it a \a aPosition.
*/
virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) { printf("EDA_DRAW_PANEL:Unimplemented22\n"); wxASSERT(false); };;
/**
* Function CallEndMouseCapture
* calls the end mouse capture callback.
*
* @param aDC A point to a wxDC object to perform any drawing upon.
*/
virtual void CallEndMouseCapture( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented23\n"); wxASSERT(false); };;
virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {}
virtual wxWindow* GetWindow() = 0;

View File

@ -31,7 +31,7 @@
#include <set>
#include <gal/color4d.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <layers_id_colors_and_visibility.h>
#include <memory>
@ -64,7 +64,7 @@ public:
* Loads a list of color settings for layers.
* @param aSettings is a list of color settings.
*/
virtual void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) = 0;
virtual void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) { }
/**
* Function SetActiveLayer

View File

@ -200,9 +200,6 @@ public:
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override { }
virtual void ReCreateOptToolbar() { }
virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override = 0;
virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override = 0;
virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override = 0;
virtual void ShowChangedLanguage() override;
virtual void ReCreateMenuBar() override;
virtual void SetToolID( int aId, int aCursor, const wxString& aToolMsg ) override;

View File

@ -142,7 +142,6 @@ public:
EDA_RECT GetBoundingBox() const;
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const;
EDA_ITEM* GetTopLeftModule() const;
EDA_ITEM* operator[]( const size_t aIdx ) const
{

View File

@ -1,72 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
#ifndef WORKSHEET_H_
#define WORKSHEET_H_
#include <gal/color4d.h>
#include <page_info.h>
// Forward declarations:
class EDA_DRAW_PANEL;
class EDA_RECT;
class TITLE_BLOCK;
using KIGFX::COLOR4D;
/**
* Function DrawPageLayout is a core function to draw the page layout with
* the frame and the basic inscriptions.
* @param aDC The device context.
* @param aClipBox = the clipping rect, or NULL if no clipping.
* @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 aPenWidth the pen size The line width for drawing.
* @param aScalar the scale factor to convert from mils to internal units.
* @param aColor The color for drawing.
* @param aAltColor The color for items which need to be "hightlighted".
* @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.
*/
void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
const PAGE_INFO& aPageInfo,
const wxString &aFullSheetName,
const wxString& aFileName,
TITLE_BLOCK& aTitleBlock,
int aSheetCount, int aSheetNumber,
int aPenWidth, double aScalar,
COLOR4D aColor, COLOR4D aAltColor,
const wxString& aSheetLayer = wxEmptyString );
#endif // WORKSHEET_H_

View File

@ -33,33 +33,17 @@
#include <math/vector2d.h>
#include <eda_text.h>
#include <bitmap_base.h>
#include <view/view.h>
#include "ws_draw_item.h"
class WS_DRAW_ITEM_TEXT; // Forward declaration
#define TB_DEFAULT_TEXTSIZE 1.5 // default worksheet text size in mm
// Text attributes set in m_flags (ORed bits)
#define USE_BOLD 1 // has meaning for texts
#define USE_THICK_LINE 1 // equivalent to bold for lines
#define USE_ITALIC (1<<1) // has meaning for texts
#define USE_ALT_COLOR (1<<2)
#define SELECTED_STATE (1<<3) // When set, use the hight light color to draw item
#define NEW_ITEM (1<<4) // Set for new items which can be deleted
// by an abort command
#define LOCATE_STARTPOINT (1<<5) // Used in locate function:set by locate function
// if the start point is located
#define LOCATE_ENDPOINT (1<<6) // Used in locate function:set by locate function
// if the end point is located
#define PAGE1OPTION (3<<7) // flag to manage items drawn or not drawn only
// on page 1: NONE = item on all pages
#define PAGE1OPTION_NONE (0<<7) // NONE = item on all pages
#define PAGE1OPTION_PAGE1ONLY (1<<7) // = item only on page 1
#define PAGE1OPTION_NOTONPAGE1 (2<<7) // = item on all pages but page 1
// A coordinate is relative to a page corner.
// Any of the 4 corners can be a reference.
// The default is the right bottom corner
enum corner_anchor
enum CORNER_ANCHOR
{
RB_CORNER, // right bottom corner
RT_CORNER, // right top corner
@ -67,6 +51,13 @@ enum corner_anchor
LT_CORNER, // left top corner
};
enum PAGE_OPTION
{
ALL_PAGES,
FIRST_PAGE_ONLY,
SUBSEQUENT_PAGES
};
// a coordinate point
// The position is always relative to the corner anchor
// Note the coordinate is from the anchor point
@ -78,7 +69,8 @@ public:
int m_Anchor;
public:
POINT_COORD() { m_Anchor = RB_CORNER; }
POINT_COORD( DPOINT aPos, enum corner_anchor aAnchor = RB_CORNER )
POINT_COORD( DPOINT aPos, enum CORNER_ANCHOR aAnchor = RB_CORNER )
{
m_Pos = aPos;
m_Anchor = aAnchor;
@ -96,7 +88,7 @@ public:
class WORKSHEET_DATAITEM
{
public:
enum WS_ItemType {
enum WS_ITEM_TYPE {
WS_TEXT,
WS_SEGMENT,
WS_RECT,
@ -105,8 +97,10 @@ public:
};
protected:
WS_ItemType m_type;
int m_flags;
WS_ITEM_TYPE m_type;
PAGE_OPTION m_pageOption;
std::vector<WS_DRAW_ITEM_BASE*> m_drawItems;
public:
wxString m_Name; // a item name used in page layout
@ -140,25 +134,23 @@ public:
static bool m_SpecialMode; // Used in page layout editor
// When set to true, base texts
// instead of full texts are displayed
static COLOR4D m_Color; // the default color to draw items
static COLOR4D m_AltColor; // an alternate color to draw items
static COLOR4D m_SelectedColor; // the color to draw selected items
// (used in page layout editor
public:
WORKSHEET_DATAITEM( WS_ItemType aType );
WORKSHEET_DATAITEM( WS_ITEM_TYPE aType );
virtual ~WORKSHEET_DATAITEM() {}
void SetStart( double aPosx, double aPosy, enum corner_anchor aAnchor = RB_CORNER )
const std::vector<WS_DRAW_ITEM_BASE*>& GetDrawItems() const { return m_drawItems; }
virtual void SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView );
void SetStart( double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor = RB_CORNER )
{
m_Pos.m_Pos.x = aPosx;
m_Pos.m_Pos.y = aPosy;
m_Pos.m_Anchor = aAnchor;
}
void SetEnd( double aPosx, double aPosy, enum corner_anchor aAnchor = RB_CORNER )
void SetEnd( double aPosx, double aPosy, enum CORNER_ANCHOR aAnchor = RB_CORNER )
{
m_End.m_Pos.x = aPosx;
m_End.m_Pos.y = aPosy;
@ -166,10 +158,7 @@ public:
}
// Accessors:
WS_ItemType GetType() const { return m_type; }
int GetFlags() const { return m_flags; }
void SetFlags( int aMask ) { m_flags |= aMask; }
void ClearFlags( int aMask ) { m_flags &= ~aMask; }
WS_ITEM_TYPE GetType() const { return m_type; }
/**
* @return true if the item has a end point (segment; rect)
@ -177,20 +166,8 @@ public:
*/
virtual bool HasEndPoint() { return true; }
/**
* @return 0 if the item has no specific option for page 1
* 1 if the item is only on page 1
* -1 if the item is not on page 1
*/
int GetPage1Option();
/**
* Set the option for page 1
* @param aChoice = 0 if the item has no specific option for page 1
* > 0 if the item is only on page 1
* < 0 if the item is not on page 1
*/
void SetPage1Option( int aChoice );
PAGE_OPTION GetPage1Option() const { return m_pageOption; }
void SetPage1Option( PAGE_OPTION aChoice ) { m_pageOption = aChoice; }
// Coordinate handling
const wxPoint GetStartPosUi( int ii = 0 ) const;
@ -205,17 +182,6 @@ public:
return KiROUND( m_DefaultLineWidth * m_WSunits2Iu );
}
/** @return the size of markers used in page layout editor to draw
* the anchor points of selected items.
* @param aZoomScale is a scaling factor that can be used to adjust
* the final marker size depending on zoom level
*/
static int GetMarkerSizeUi( double aZoomScale = 1.0 )
{
#define MARKER_DRAW_SIZE 0.5 // Is a value choosen for a suitable size on screen
return KiROUND( MARKER_DRAW_SIZE * m_WSunits2Iu * aZoomScale );
}
/**
* move item to a new position
* @param aPosition = the new position of item, in mm
@ -264,54 +230,25 @@ public:
virtual bool IsInsidePage( int ii ) const;
const wxString GetClassName() const;
/**
* @return true if the selected state on ON
*/
bool IsSelected() { return (m_flags & SELECTED_STATE) != 0; }
/**
* Function SetSelected
* Toggles on/off the selected flag (used in editing functions)
* @param aState = the flag value
*/
void SetSelected( bool aState )
{
if( aState )
m_flags |= SELECTED_STATE;
else
m_flags &= ~SELECTED_STATE;
}
bool UseAltColor() {return m_flags & USE_ALT_COLOR; }
COLOR4D GetItemColor()
{
if( IsSelected() )
return m_SelectedColor;
if( UseAltColor() )
return m_AltColor;
return m_Color;
}
};
class WORKSHEET_DATAITEM_POLYPOLYGON : public WORKSHEET_DATAITEM
{
public:
double m_Orient; // Orientation in degrees
std::vector<DPOINT> m_Corners; // corner list
double m_Orient; // Orientation in degrees
std::vector<DPOINT> m_Corners; // corner list
private:
std::vector<unsigned> m_polyIndexEnd; // index of the last point of each polygon
DPOINT m_minCoord; // min coord of corners, relative to m_Pos
DPOINT m_maxCoord; // max coord of corners, relative to m_Pos
DPOINT m_minCoord; // min coord of corners, relative to m_Pos
DPOINT m_maxCoord; // max coord of corners, relative to m_Pos
public:
WORKSHEET_DATAITEM_POLYPOLYGON( );
void SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
virtual int GetPenSizeUi() override
{
return KiROUND( m_LineWidth * m_WSunits2Iu );
@ -395,6 +332,8 @@ public:
double m_Orient; // Orientation in degrees
EDA_TEXT_HJUSTIFY_T m_Hjustify;
EDA_TEXT_VJUSTIFY_T m_Vjustify;
bool m_Italic;
bool m_Bold;
DSIZE m_TextSize;
DSIZE m_BoundingBoxSize; // When not null, this is the max
// size of the full text.
@ -408,6 +347,8 @@ public:
public:
WORKSHEET_DATAITEM_TEXT( const wxString& aTextBase );
void SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
/**
* @return false (no end point)
*/
@ -427,12 +368,6 @@ public:
*/
void MoveTo( DPOINT aPosition );
/**
* transfert the text justification and orientation
* to aGText
*/
void TransfertSetupToGraphicText( WS_DRAW_ITEM_TEXT* aGText );
/**
* Try to build text wihich is an increment of m_TextBase
* has meaning only if m_TextBase is a basic text (one char)
@ -461,42 +396,6 @@ public:
* @return true if the EOL symbol is found or is inserted (multiline text)
*/
bool ReplaceAntiSlashSequence();
/**
* @return true is a bold font should be selected
*/
bool IsBold() { return (m_flags & USE_BOLD) != 0; }
/**
* Function SetBold
* Toggles on/off the bold option flag
* @param aState = the bold option value
*/
void SetBold( bool aState )
{
if( aState )
m_flags |= USE_BOLD;
else
m_flags &= ~USE_BOLD;
}
/**
* @return true is an italic font should be selected
*/
bool IsItalic() const { return (m_flags & USE_ITALIC) != 0; }
/**
* Function SetItalic
* Toggles on/off the italic option flag
* @param aState = the italic option value
*/
void SetItalic( bool aState )
{
if( aState )
m_flags |= USE_ITALIC;
else
m_flags &= ~USE_ITALIC;
}
};
@ -513,6 +412,8 @@ public:
m_ImageBitmap = aImage;
}
void SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView ) override;
/**
* @return false (no end point)
*/

167
include/worksheet_painter.h Normal file
View File

@ -0,0 +1,167 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
#ifndef WORKSHEET_PAINTER_H
#define WORKSHEET_PAINTER_H
#include <gal/color4d.h>
#include <painter.h>
#include <page_info.h>
// Forward declarations:
class EDA_DRAW_PANEL;
class EDA_RECT;
class TITLE_BLOCK;
using KIGFX::COLOR4D;
namespace KIGFX
{
/**
* Class WS_RENDER_SETTINGS
* Stores page-layout-specific render settings.
*/
class WS_RENDER_SETTINGS : public RENDER_SETTINGS
{
public:
friend class WORKSHEET_PAINTER;
WS_RENDER_SETTINGS();
/// @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; }
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;
};
/**
* Class WORKSHEET_PAINTER
* Contains methods for drawing worksheet items.
*/
class WORKSHEET_PAINTER : public PAINTER
{
public:
WORKSHEET_PAINTER( GAL* aGal ) :
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 );
}
/// @copydoc PAINTER::GetSettings()
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;
void draw( const WS_DRAW_ITEM_POLYGON* aItem, int aLayer ) const;
void draw( const WS_DRAW_ITEM_TEXT* aItem, int aLayer ) const;
void draw( const WS_DRAW_ITEM_BITMAP* aItem, int aLayer ) const;
private:
WS_RENDER_SETTINGS m_renderSettings;
};
} // namespace KIGFX
/**
* Function DrawPageLayout is a core function to draw the page layout with
* the frame and the basic inscriptions.
* @param aDC The device context.
* @param aClipBox = the clipping rect, or NULL if no clipping.
* @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 aPenWidth the pen size The line width for drawing.
* @param aScalar the scale factor to convert from mils to internal units.
* @param aColor The color for drawing.
* @param aAltColor The color for items which need to be "hightlighted".
* @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.
*/
void DrawPageLayout( wxDC* aDC,
EDA_RECT* aClipBox,
const PAGE_INFO& aPageInfo,
const wxString& aFullSheetName,
const wxString& aFileName,
TITLE_BLOCK& aTitleBlock,
int aSheetCount,
int aSheetNumber,
int aPenWidth,
double aScalar,
COLOR4D aColor,
const wxString& aSheetLayer = wxEmptyString );
#endif // WORKSHEET_PAINTER_H

View File

@ -158,16 +158,6 @@ protected:
/// Sheets count number displayed in the title block.
int m_sheetCount;
// Functions for drawing items that makes a worksheet
void draw( const WS_DRAW_ITEM_LINE* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_RECT* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const;
void draw( const WS_DRAW_ITEM_BITMAP* aItem, GAL* aGal ) const;
/// Draws a border that determines the page size.
void drawBorder( GAL* aGal ) const;
};
}

View File

@ -22,117 +22,84 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file worksheet_shape_builder.h
* @brief classes and function to generate graphics to plt or draw titles blocks
* and frame references
*/
#ifndef WORKSHEET_SHAPE_BUILDER_H
#define WORKSHEET_SHAPE_BUILDER_H
#ifndef WS_DRAW_ITEM_H
#define WS_DRAW_ITEM_H
#include <math/vector2d.h>
#include <eda_text.h>
#include <eda_text.h>
#include <bitmap_base.h>
#include "msgpanel.h"
class WORKSHEET_DATAITEM; // Forward declaration
class WORKSHEET_DATAITEM;
class TITLE_BLOCK;
class PAGE_INFO;
#define TB_DEFAULT_TEXTSIZE 1.5 // default worksheet text size in mm
/*
* Helper classes to handle basic graphic items used to raw/plot
* Helper classes to handle basic graphic items used to draw/plot
* title blocks and frame references
* segments
* rect
* polygons (for logos)
* graphic texts
* bitmaps, also for logos, but they cannot be plot by SVG, GERBER
* and HPGL plotters (In this case, only the bounding box is plotted)
* bitmaps, also for logos, but they cannot be plot by SVG, GERBER or HPGL plotters (in
* which case only the bounding box is plotted)
*/
class WS_DRAW_ITEM_BASE // This basic class, not directly usable.
class WS_DRAW_ITEM_BASE : public EDA_ITEM // This basic class, not directly usable.
{
public:
enum WS_DRAW_TYPE {
wsg_line, wsg_rect, wsg_poly, wsg_text, wsg_bitmap
};
int m_Flags; // temporary flgs used in page layout editor
// to locate the item;
protected:
WS_DRAW_TYPE m_type; // wsg_line, wsg_rect, wsg_poly, wsg_text
COLOR4D m_color;
WORKSHEET_DATAITEM* m_parent; // an unique identifier, used as link
WORKSHEET_DATAITEM* m_peer; // an unique identifier, used as link
// to the parent WORKSHEET_DATAITEM item,
// in page layout editor
WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM* aParent,
WS_DRAW_TYPE aType, COLOR4D aColor )
WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM* aPeer, KICAD_T aType ) :
EDA_ITEM( aType )
{
m_type = aType;
m_color = aColor;
m_parent = aParent;
m_peer = aPeer;
m_Flags = 0;
}
public:
virtual ~WS_DRAW_ITEM_BASE() {}
// Accessors:
COLOR4D GetColor() const { return m_color; }
WS_DRAW_TYPE GetType() const { return m_type; };
WORKSHEET_DATAITEM* GetPeer() const { return m_peer; }
WORKSHEET_DATAITEM* GetParent() const { return m_parent; }
virtual const wxPoint GetPosition() const = 0;
virtual void SetPosition( wxPoint aPos ) = 0;
virtual void SetEnd( wxPoint aPos ) { /* not all types will need this */ }
/** The function to draw a WS_DRAW_ITEM
*/
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC)
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor )
{
wxPoint offset( 0, 0 );
DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, COLOR4D::UNSPECIFIED );
DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, aColor );
}
/// More advanced version of DrawWsItem. This is what must be
/// defined in the derived type.
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) = 0;
GR_DRAWMODE aDrawMode, COLOR4D aColor ) = 0;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
{
// This is just here to prevent annoying compiler warnings about hidden overloaded
// virtual functions
return EDA_ITEM::HitTest( aPosition, aAccuracy );
}
/**
* Abstract function: should exist for derived items
* return true if the point aPosition is on the item
*/
virtual bool HitTest( const wxPoint& aPosition) const = 0;
/**
* Abstract function: should exist for derived items
* Virtual function
* return true if the rect aRect intersects on the item
*/
virtual bool HitTest( const EDA_RECT& aRect ) const = 0;
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
/**
* Abstract function: should exist for derived items
* return true if the point aPosition is near the starting point of this item,
* for items defined by 2 points (segments, rect)
* or the position of the item, for items having only one point
* (texts or polygons)
* the maxi dist is WORKSHEET_DATAITEM::GetMarkerSizeUi()/2
*/
virtual bool HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition ) = 0;
/**
* return true if the point aPosition is near the ending point of this item
* This is avirtual function which should be overriden for items defien by
* 2 points
* the maxi dist is WORKSHEET_DATAITEM::GetMarkerSizeUi()/2
*/
virtual bool HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition)
{
return false;
}
void GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) override;
};
// This class draws a thick segment
class WS_DRAW_ITEM_LINE : public WS_DRAW_ITEM_BASE
{
@ -141,49 +108,42 @@ class WS_DRAW_ITEM_LINE : public WS_DRAW_ITEM_BASE
int m_penWidth;
public:
WS_DRAW_ITEM_LINE( WORKSHEET_DATAITEM* aParent,
wxPoint aStart, wxPoint aEnd,
int aPenWidth, COLOR4D aColor ) :
WS_DRAW_ITEM_BASE( aParent, wsg_line, aColor )
WS_DRAW_ITEM_LINE( WORKSHEET_DATAITEM* aPeer, wxPoint aStart, wxPoint aEnd, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_LINE_T )
{
m_start = aStart;
m_end = aEnd;
m_penWidth = aPenWidth;
}
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_LINE" ); }
// Accessors:
int GetPenWidth() const { return m_penWidth; }
const wxPoint& GetStart() const { return m_start; }
void SetStart( wxPoint aPos ) { m_start = aPos; }
const wxPoint& GetEnd() const { return m_end; }
void SetEnd( wxPoint aPos ) override { m_end = aPos; }
const wxPoint GetPosition() const override { return GetStart(); }
void SetPosition( wxPoint aPos ) override { SetStart( aPos ); }
/** The function to draw a WS_DRAW_ITEM_LINE
*/
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
/**
* Virtual function
* return true if the point aPosition is on the line
*/
virtual bool HitTest( const wxPoint& aPosition) const override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
virtual bool HitTest( const EDA_RECT& aRect ) const override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
/**
* return true if the point aPosition is on the starting point of this item.
*/
virtual bool HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition ) override;
/**
* return true if the point aPosition is on the ending point of this item
* This is avirtual function which should be overriden for items defien by
* 2 points
*/
virtual bool HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
// This class draws a polygon
@ -199,83 +159,90 @@ public:
std::vector <wxPoint> m_Corners;
public:
WS_DRAW_ITEM_POLYGON( WORKSHEET_DATAITEM* aParent, wxPoint aPos,
bool aFill, int aPenWidth, COLOR4D aColor ) :
WS_DRAW_ITEM_BASE( aParent, wsg_poly, aColor )
WS_DRAW_ITEM_POLYGON( WORKSHEET_DATAITEM* aPeer, wxPoint aPos, bool aFill, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_POLY_T )
{
m_penWidth = aPenWidth;
m_fill = aFill;
m_pos = aPos;
}
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_POLYGON" ); }
// Accessors:
int GetPenWidth() const { return m_penWidth; }
bool IsFilled() const { return m_fill; }
const wxPoint GetPosition() const { return m_pos; }
const wxPoint GetPosition() const override { return m_pos; }
void SetPosition( wxPoint aPos ) override { m_pos = aPos; }
/** The function to draw a WS_DRAW_ITEM_POLYGON
*/
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
/**
* Virtual function
* return true if the point aPosition is inside one polygon
*/
virtual bool HitTest( const wxPoint& aPosition) const override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
virtual bool HitTest( const EDA_RECT& aRect ) const override;
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
/**
* return true if the point aPosition is on the starting point of this item.
*/
virtual bool HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition ) override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
// This class draws a not filled rectangle with thick segment
class WS_DRAW_ITEM_RECT : public WS_DRAW_ITEM_LINE
class WS_DRAW_ITEM_RECT : public WS_DRAW_ITEM_BASE
{
wxPoint m_start; // start point of line/rect
wxPoint m_end; // end point
int m_penWidth;
public:
WS_DRAW_ITEM_RECT( WORKSHEET_DATAITEM* aParent,
wxPoint aStart, wxPoint aEnd,
int aPenWidth, COLOR4D aColor ) :
WS_DRAW_ITEM_LINE( aParent, aStart, aEnd, aPenWidth, aColor )
WS_DRAW_ITEM_RECT( WORKSHEET_DATAITEM* aPeer, wxPoint aStart, wxPoint aEnd, int aPenWidth ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_RECT_T )
{
m_type = wsg_rect;
m_start = aStart;
m_end = aEnd;
m_penWidth = aPenWidth;
}
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_RECT" ); }
// Accessors:
int GetPenWidth() const { return m_penWidth; }
const wxPoint& GetStart() const { return m_start; }
void SetStart( wxPoint aPos ) { m_start = aPos; }
const wxPoint& GetEnd() const { return m_end; }
void SetEnd( wxPoint aPos ) override { m_end = aPos; }
const wxPoint GetPosition() const override { return GetStart(); }
void SetPosition( wxPoint aPos ) override { SetStart( aPos ); }
/** The function to draw a WS_DRAW_ITEM_RECT
*/
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
/**
* Virtual function
* return true if the point aPosition is on one edge of the rectangle
*/
virtual bool HitTest( const wxPoint& aPosition) const override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
virtual bool HitTest( const EDA_RECT& aRect ) const override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
/**
* return true if the point aPosition is on the starting point of this item.
*/
virtual bool HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition ) override;
/**
* return true if the point aPosition is on the ending point of this item
* This is avirtual function which should be overriden for items defien by
* 2 points
*/
virtual bool HitTestEndPoint( wxDC *aDC, const wxPoint& aPosition ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
// This class draws a graphic text.
@ -284,15 +251,24 @@ public:
class WS_DRAW_ITEM_TEXT : public WS_DRAW_ITEM_BASE, public EDA_TEXT
{
public:
WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
wxString& aText, wxPoint aPos, wxSize aSize,
int aPenWidth, COLOR4D aColor,
bool aItalic = false, bool aBold = false );
WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aPeer, wxString& aText, wxPoint aPos, wxSize aSize,
int aPenWidth, bool aItalic = false, bool aBold = false ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_TEXT_T),
EDA_TEXT( aText )
{
SetTextPos( aPos );
SetTextSize( aSize );
SetThickness( aPenWidth );
SetItalic( aItalic );
SetBold( aBold );
}
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_TEXT" ); }
/** The function to draw a WS_DRAW_ITEM_TEXT
*/
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
// Accessors:
int GetPenWidth() { return GetThickness(); }
@ -302,22 +278,26 @@ public:
EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
}
const wxPoint GetPosition() const override { return GetTextPos(); }
void SetPosition( wxPoint aPos ) override { SetTextPos( aPos ); }
/**
* Virtual function
* return true if the point aPosition is on the text
* return true if the point aPosition is inside one polygon
*/
virtual bool HitTest( const wxPoint& aPosition) const override;
bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
virtual bool HitTest( const EDA_RECT& aRect ) const override;
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
/**
* return true if the point aPosition is on the starting point of this item.
*/
virtual bool HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition ) override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
// This class draws a bitmap.
@ -326,42 +306,36 @@ class WS_DRAW_ITEM_BITMAP : public WS_DRAW_ITEM_BASE
wxPoint m_pos; // position of reference point
public:
WS_DRAW_ITEM_BITMAP( WORKSHEET_DATAITEM* aParent, wxPoint aPos )
:WS_DRAW_ITEM_BASE( aParent, wsg_bitmap, COLOR4D::UNSPECIFIED )
WS_DRAW_ITEM_BITMAP( WORKSHEET_DATAITEM* aPeer, wxPoint aPos ) :
WS_DRAW_ITEM_BASE( aPeer, WSG_BITMAP_T )
{
m_pos = aPos;
}
WS_DRAW_ITEM_BITMAP()
:WS_DRAW_ITEM_BASE( NULL, wsg_bitmap, COLOR4D::UNSPECIFIED )
WS_DRAW_ITEM_BITMAP() :
WS_DRAW_ITEM_BASE( nullptr, WSG_BITMAP_T )
{
}
~WS_DRAW_ITEM_BITMAP() {}
virtual wxString GetClass() const override { return wxT( "WS_DRAW_ITEM_BITMAP" ); }
const wxPoint GetPosition() const override { return m_pos; }
void SetPosition( wxPoint aPos ) override { m_pos = aPos; }
/** The function to draw a WS_DRAW_ITEM_BITMAP
*/
virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor = COLOR4D::UNSPECIFIED ) override;
void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset, GR_DRAWMODE aDrawMode,
COLOR4D aColor ) override;
/**
* Virtual function
* return true if the point aPosition is on bitmap
*/
virtual bool HitTest( const wxPoint& aPosition) const override;
const EDA_RECT GetBoundingBox() const override;
/**
* Virtual function
* return true if the rect aRect intersects on the item
*/
virtual bool HitTest( const EDA_RECT& aRect ) const override;
wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
/**
* return true if the point aPosition is on the reference point of this item.
*/
virtual bool HitTestStartPoint( wxDC *aDC, const wxPoint& aPosition ) override;
const wxPoint GetPosition() const { return m_pos; }
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
/*
@ -375,9 +349,6 @@ class WS_DRAW_ITEM_LIST
protected:
std::vector <WS_DRAW_ITEM_BASE*> m_graphicList; // Items to draw/plot
unsigned m_idx; // for GetFirst, GetNext functions
wxPoint m_LTmargin; // The left top margin in mils of the page layout.
wxPoint m_RBmargin; // The right bottom margin in mils of the page layout.
wxSize m_pageSize; // the page size in mils
double m_milsToIu; // the scalar to convert pages units ( mils)
// to draw/plot units.
int m_penSize; // The default line width for drawings.
@ -407,13 +378,13 @@ public:
~WS_DRAW_ITEM_LIST()
{
for( unsigned ii = 0; ii < m_graphicList.size(); ii++ )
delete m_graphicList[ii];
// Items in the m_graphicList are owned by their respective WORKSHEET_DATAITEMs.
// for( WS_DRAW_ITEM_BASE* item : m_graphicList )
// delete item;
}
/**
* Set the filename to draw/plot
* @param aFileName = the text to display by the "filename" format
*/
void SetFileName( const wxString& aFileName )
{
@ -422,7 +393,6 @@ public:
/**
* Set the sheet name to draw/plot
* @param aSheetName = the text to draw/plot by the "sheetname" format
*/
void SetSheetName( const wxString& aSheetName )
{
@ -431,44 +401,27 @@ public:
/**
* Set the sheet layer to draw/plot
* @param aSheetLayer = the text to draw/plot by the "sheetlayer" format
*/
void SetSheetLayer( const wxString& aSheetLayer )
{
m_sheetLayer = &aSheetLayer;
}
/** Function SetPenSize
* Set the default pen size to draw/plot lines and texts
* @param aPenSize the thickness of lines
*/
void SetPenSize( int aPenSize )
{
m_penSize = aPenSize;
}
void SetDefaultPenSize( int aPenSize ) { m_penSize = aPenSize; }
int GetDefaultPenSize() const { return m_penSize; }
/** Function SetMilsToIUfactor
* Set the scalar to convert pages units ( mils) to draw/plot units
* @param aScale the conversion factor
/**
* Function SetMilsToIUfactor
* Set the scalar to convert pages units (mils) to draw/plot units
*/
void SetMilsToIUfactor( double aScale )
{
m_milsToIu = aScale;
}
/** Function SetPageSize
* Set the size of the page layout
* @param aPageSize size (in mils) of the page layout.
*/
void SetPageSize( const wxSize& aPageSize )
{
m_pageSize = aPageSize;
}
/**
* Function SetSheetNumber
* Set the value of the sheet number, for basic inscriptions
* @param aSheetNumber the number to display.
*/
void SetSheetNumber( int aSheetNumber )
{
@ -478,30 +431,23 @@ public:
/**
* Function SetSheetCount
* Set the value of the count of sheets, for basic inscriptions
* @param aSheetCount the number of esheets to display.
*/
void SetSheetCount( int aSheetCount )
{
m_sheetCount = aSheetCount;
}
/** Function SetMargins
* Set the left top margin and the right bottom margin
* of the page layout
* @param aLTmargin The left top margin of the page layout.
* @param aRBmargin The right bottom margin of the page layout.
*/
void SetMargins( const wxPoint& aLTmargin, const wxPoint& aRBmargin )
{
m_LTmargin = aLTmargin;
m_RBmargin = aRBmargin;
}
void Append( WS_DRAW_ITEM_BASE* aItem )
{
m_graphicList.push_back( aItem );
}
void Remove( WS_DRAW_ITEM_BASE* aItem )
{
auto newEnd = std::remove( m_graphicList.begin(), m_graphicList.end(), aItem );
m_graphicList.erase( newEnd, m_graphicList.end() );
}
WS_DRAW_ITEM_BASE* GetFirst()
{
m_idx = 0;
@ -527,21 +473,23 @@ public:
*aList = m_graphicList;
}
/**
* Sets up the WORKSHEET_DATAITEM globals for generating drawItems.
*/
static void SetupDrawEnvironment( const PAGE_INFO& aPageInfo );
/**
* Draws the item list created by BuildWorkSheetGraphicList
* @param aClipBox = the clipping rect, or NULL if no clipping
* @param aDC = the current Device Context
*/
void Draw( EDA_RECT* aClipBox, wxDC* aDC );
void Draw( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor );
/**
* Function BuildWorkSheetGraphicList is a core function for
* drawing or plotting the page layout with
* the frame and the basic inscriptions.
* It populates the list of basic graphic items to draw or plot.
* currently lines, rect, polygons and texts
* before calling this function, some parameters should be initialized:
* by calling:
* Function BuildWorkSheetGraphicList is a core function for drawing or plotting the
* page layout with the frame and the basic inscriptions.
*
* Before calling this function, some parameters should be initialized by calling:
* SetPenSize( aPenWidth );
* SetMilsToIUfactor( aScalar );
* SetSheetNumber( aSheetNumber );
@ -552,11 +500,10 @@ public:
* @param aPageInfo The PAGE_INFO, for page size, margins...
* @param aTitleBlock The sheet title block, for basic inscriptions.
* @param aColor The color for drawing.
* @param aAltColor The color for items which need to be "hightlighted".
* @param aAltColor The color for items which need to be "highlighted".
*/
void BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo,
const TITLE_BLOCK& aTitleBlock,
COLOR4D aColor, COLOR4D aAltColor );
void BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo, const TITLE_BLOCK& aTitleBlock );
/**
* Function BuildFullText
* returns the full text corresponding to the aTextbase,
@ -586,13 +533,6 @@ public:
* @return the text, after replacing the format symbols by the actual value
*/
wxString BuildFullText( const wxString& aTextbase );
/**
* Locate graphic items in m_graphicList at location aPosition
* @param aList = the list of items found
* @param aPosition the position (in user units) to locate items
*/
void Locate(wxDC* aDC, std::vector <WS_DRAW_ITEM_BASE*>& aList, const wxPoint& aPosition);
};
@ -617,16 +557,14 @@ public:
~WORKSHEET_LAYOUT() {ClearList(); }
/**
* static function: returns the instance of WORKSHEET_LAYOUT
* used in the application
* static function: returns the instance of WORKSHEET_LAYOUT used in the application
*/
static WORKSHEET_LAYOUT& GetTheInstance();
/**
* static function: Set an alternate instance of WORKSHEET_LAYOUT
* mainly used in page setting dialog
* @param aLayout = the alternate page layout.
* if null, restore the basic page layout
* @param aLayout = the alternate page layout; if null restore the basic page layout
*/
static void SetAltInstance( WORKSHEET_LAYOUT* aLayout = NULL );
@ -673,28 +611,8 @@ public:
*/
void SaveInString( wxString& aOutputString );
/**
* Add an item to the list of items
*/
void Append( WORKSHEET_DATAITEM* aItem )
{
m_list.push_back( aItem );
}
/**
*Insert an item to the list of items at position aIdx
*/
void Insert( WORKSHEET_DATAITEM* aItem, unsigned aIdx );
/**
*Remove the item to the list of items at position aIdx
*/
bool Remove( unsigned aIdx );
/**
*Remove the item to the list of items at position aIdx
*/
bool Remove( WORKSHEET_DATAITEM* aItem );
void Append( WORKSHEET_DATAITEM* aItem );
void Remove( WORKSHEET_DATAITEM* aItem );
/**
* @return the index of aItem, or -1 if does not exist
@ -706,19 +624,17 @@ public:
*/
WORKSHEET_DATAITEM* GetItem( unsigned aIdx ) const;
/**
* @return a reference to the items.
*/
std::vector<WORKSHEET_DATAITEM*>& GetItems() { return m_list; }
/**
* @return the item count
*/
unsigned GetCount() const { return m_list.size(); }
/**
* Fills the list with the default layout shape
*/
void SetDefaultLayout();
/**
* Fills the list with an empty layout shape
*/
void SetEmptyLayout();
/**
@ -740,8 +656,7 @@ public:
* @param Append = if true: do not delete old layout, and load only
aFullFileName.
*/
void SetPageLayout( const wxString& aFullFileName = wxEmptyString,
bool Append = false );
void SetPageLayout( const wxString& aFullFileName = wxEmptyString, bool Append = false );
/**
* Populates the list from a S expr description stored in a string
@ -751,7 +666,7 @@ public:
@param aSource is the layout source description.
*/
void SetPageLayout( const char* aPageLayout, bool aAppend = false,
const wxString& aSource = wxT( "Sexpr_string" ) );
const wxString& aSource = wxT( "Sexpr_string" ) );
/**
* @return a short filename from a full filename:
@ -779,4 +694,4 @@ public:
const wxString& aProjectPath );
};
#endif // WORKSHEET_SHAPE_BUILDER_H
#endif // WS_DRAW_ITEM_H

View File

@ -20,12 +20,9 @@ set( PL_EDITOR_SRCS
dialogs/dialog_new_dataitem.cpp
pl_editor_screen.cpp
pl_editor_layout.cpp
design_tree_frame.cpp
events_functions.cpp
controle.cpp
files.cpp
onleftclick.cpp
onrightclick.cpp
page_layout_writer.cpp
pl_editor_config.cpp
pl_editor_frame.cpp
@ -34,7 +31,14 @@ set( PL_EDITOR_SRCS
hotkeys.cpp
menubar.cpp
toolbars_pl_editor.cpp
block.cpp
tools/pl_actions.cpp
tools/pl_selection_tool.cpp
tools/pl_drawing_tools.cpp
tools/pl_edit_tool.cpp
tools/pl_picker_tool.cpp
tools/pl_point_editor.cpp
tools/selection.cpp
)
set( PL_EDITOR_EXTRA_SRCS

View File

@ -1,253 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
/**
* @file pagelayout_editor/block.cpp
* @brief Block operations
*/
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <pl_editor_frame.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool erase );
static void DrawMovingItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
static void ConfigureDrawList( WS_DRAW_ITEM_LIST* aDrawList,
PL_EDITOR_SCREEN* aScreen, PL_EDITOR_FRAME* aFrame );
static void ConfigureDrawList( WS_DRAW_ITEM_LIST* aDrawList,
PL_EDITOR_SCREEN* aScreen, PL_EDITOR_FRAME* aFrame )
{
aDrawList->SetPenSize( 0 );
aDrawList->SetMilsToIUfactor( IU_PER_MILS );
aDrawList->SetSheetNumber( aScreen->m_ScreenNumber );
aDrawList->SetSheetCount( aScreen->m_NumberOfScreens );
aDrawList->SetFileName( aFrame->GetCurrFileName() );
aDrawList->SetSheetName( aFrame->GetScreenDesc() );
aDrawList->BuildWorkSheetGraphicList( aFrame->GetPageSettings(),
aFrame->GetTitleBlock(), RED, RED );
}
int PL_EDITOR_FRAME::BlockCommand( EDA_KEY key )
{
int cmd = 0;
switch( key )
{
default:
cmd = key & 0x255;
break;
case 0:
cmd = BLOCK_MOVE;
break;
case GR_KB_SHIFT:
case GR_KB_CTRL:
case GR_KB_SHIFTCTRL:
case GR_KB_ALT:
break;
case MOUSE_MIDDLE:
cmd = BLOCK_ZOOM;
break;
}
return cmd;
}
void PL_EDITOR_FRAME::HandleBlockPlace( wxDC* DC )
{
wxASSERT( m_canvas->IsMouseCaptured() );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
switch( GetScreen()->m_BlockLocate.GetCommand() )
{
case BLOCK_MOVE: /* Move */
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
Block_Move( DC );
GetScreen()->m_BlockLocate.ClearItemsList();
break;
default:
wxFAIL_MSG( wxT("HandleBlockPlace: Unexpected block command") );
break;
}
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
GetScreen()->SetModify();
GetScreen()->ClearBlockCommand();
wxASSERT( GetScreen()->m_BlockLocate.GetCount() == 0 );
DisplayToolMsg( wxEmptyString );
}
bool PL_EDITOR_FRAME::HandleBlockEnd( wxDC* DC )
{
bool nextcmd = false;
bool zoom_command = false;
if( m_canvas->IsMouseCaptured() )
switch( GetScreen()->m_BlockLocate.GetCommand() )
{
case BLOCK_MOVE: /* Move */
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
nextcmd = true;
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true;
break;
default:
break;
}
if( ! nextcmd )
{
GetScreen()->ClearBlockCommand();
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
false );
}
if( zoom_command )
Window_Zoom( GetScreen()->m_BlockLocate );
return nextcmd ;
}
static void DrawMovingItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
auto screen = static_cast<PL_EDITOR_SCREEN*>( aPanel->GetScreen() );
auto frame = static_cast<PL_EDITOR_FRAME*>( aPanel->GetParent() );
// Get items
std::vector<WS_DRAW_ITEM_BASE*> items;
WS_DRAW_ITEM_LIST drawList;
ConfigureDrawList( &drawList, screen, frame );
drawList.GetAllItems( &items );
// Draw items
for( auto item: items )
{
if( item->HitTest( screen->m_BlockLocate ) )
{
item->DrawWsItem( NULL, aDC, screen->m_BlockLocate.GetMoveVector(),
g_XorMode, g_GhostColor );
}
}
}
/* Traces the outline of the block structures of a repositioning move
*/
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon,
bool aErase )
{
auto screen = aPanel->GetScreen();
auto block = &screen->m_BlockLocate;
if( aErase )
{
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
DrawMovingItems( aPanel, aDC );
}
block->SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
DrawMovingItems( aPanel, aDC );
}
void PL_EDITOR_FRAME::Block_Move( wxDC* DC )
{
auto screen = static_cast<PL_EDITOR_SCREEN*>( GetScreen() );
wxPoint delta;
wxPoint oldpos;
oldpos = GetCrossHairPosition();
m_canvas->SetMouseCaptureCallback( NULL );
SetCrossHairPosition( oldpos );
m_canvas->MoveCursorToCrossHair();
GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize();
// Calculate displacement vectors.
delta = GetScreen()->m_BlockLocate.GetMoveVector();
// Get the items
std::vector<WS_DRAW_ITEM_BASE*> items;
WS_DRAW_ITEM_LIST drawList;
ConfigureDrawList( &drawList, screen, this );
drawList.GetAllItems( &items );
// Move items in block
SaveCopyInUndoList();
for( auto item: items )
{
auto parent = item->GetParent();
if( parent )
parent->ClearFlags( FLAG1 );
}
for( auto item: items )
{
if( item->HitTest( screen->m_BlockLocate ) )
{
auto data_item = item->GetParent();
if( data_item && !( data_item->GetFlags() & FLAG1 ) )
{
data_item->SetFlags( FLAG1 );
data_item->MoveToUi( data_item->GetStartPosUi() + delta );
}
}
}
m_canvas->Refresh( true );
}

View File

@ -1,291 +0,0 @@
/**
* @file design_tree_frame.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* 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
*/
#include <wx/imaglist.h>
#include <wx/wupdlock.h>
#include <fctsys.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
#include <pl_editor_id.h>
#include <design_tree_frame.h>
/* XPM
* This bitmap is used to show item types
*/
static const char* root_xpm[] =
{
"12 12 2 1",
" c None",
"x c #008080",
" xxxx ",
" xxx ",
" xxx ",
" xxx ",
"xxxxxxxxxxx ",
"xxxxxxxxxxxx",
"xxxxxxxxxxx ",
" xxx ",
" xxx ",
" xxx ",
" xxxx ",
" "
};
static const char* line_xpm[] =
{
"12 12 2 1",
" c None",
"x c #008080",
"xx ",
"xx ",
"xx ",
"xx ",
"xx ",
"xx ",
"xx ",
"xx ",
"xx ",
"xx ",
"xxxxxxxxxxxx",
"xxxxxxxxxxxx"
};
static const char* rect_xpm[] =
{
"12 12 2 1",
" c None",
"x c #000080",
"xxxxxxxxxxxx",
"xxxxxxxxxxxx",
"xx xx",
"xx xx",
"xx xx",
"xx xx",
"xx xx",
"xx xx",
"xx xx",
"xx xx",
"xxxxxxxxxxxx",
"xxxxxxxxxxxx"
};
static const char* text_xpm[] =
{
"12 12 2 1",
" c None",
"x c #800000",
" xxxxxxxxxx ",
"xxxxxxxxxxxx",
"xx xx xx",
" xx ",
" xx ",
" xx ",
" xx ",
" xx ",
" xx ",
" xx ",
" xxxx ",
" xxxxxx "
};
static const char* poly_xpm[] =
{
"12 12 2 1",
" c None",
"x c #008000",
" xx ",
" xxxx ",
" xxxxxx ",
" xxxxxxxx ",
" xxxxxxxxxx ",
"xxxxxxxxxxxx",
"xxxxxxxxxxxx",
" xxxxxxxxxx ",
" xxxxxxxx ",
" xxxxxx ",
" xxxx ",
" xx "
};
static const char* img_xpm[] =
{
"12 12 2 1",
" c None",
"x c #800000",
" xx ",
" xxxxxx ",
" xx xx ",
"xx xx",
"xx xx",
" xx xx ",
" xxxxxx ",
" xx ",
" xx ",
" xx ",
" xx ",
" xx "
};
// Event table:
DESIGN_TREE_FRAME::DESIGN_TREE_FRAME( PL_EDITOR_FRAME* aParent ) :
wxTreeCtrl( aParent, ID_DESIGN_TREE_FRAME )
{
// icons size is not know (depending on they are built)
// so get it:
wxSize iconsize;
wxBitmap root_bm( root_xpm );
iconsize.x = root_bm.GetWidth();
iconsize.y = root_bm.GetHeight();
// Make an image list containing small icons
m_imageList = new wxImageList( iconsize.x, iconsize.y, true, 6 );
m_imageList->Add( root_bm ); // root symbol
m_imageList->Add( wxBitmap( line_xpm ) ); // line item
m_imageList->Add( wxBitmap( rect_xpm ) ); // rect item
m_imageList->Add( wxBitmap( text_xpm ) ); // text item
m_imageList->Add( wxBitmap( poly_xpm ) ); // poly item
m_imageList->Add( wxBitmap( img_xpm ) ); // bitmap item
SetImageList( m_imageList );
}
DESIGN_TREE_FRAME::~DESIGN_TREE_FRAME()
{
delete m_imageList;
}
wxSize DESIGN_TREE_FRAME::GetMinSize() const
{
return wxSize( 100, -1 );
}
void DESIGN_TREE_FRAME::ReCreateDesignTree()
{
wxWindowUpdateLocker dummy(this); // Avoid flicker when rebuilding the tree
DeleteAllItems();
const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
// root tree:
wxFileName fn( ((PL_EDITOR_FRAME*) GetParent())->GetCurrFileName() );
wxTreeItemId rootitem;
if( fn.GetName().IsEmpty() )
rootitem = AddRoot( wxT( "<default>" ), 0, 0 );
else
rootitem = AddRoot( fn.GetName(), 0, 0 );
SetItemBold( rootitem, true );
// Now adding all current items
for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
{
WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
int img = 0;
switch( item->GetType() )
{
case WORKSHEET_DATAITEM::WS_SEGMENT: img = 1; break;
case WORKSHEET_DATAITEM::WS_RECT: img = 2; break;
case WORKSHEET_DATAITEM::WS_TEXT: img = 3; break;
case WORKSHEET_DATAITEM::WS_POLYPOLYGON: img = 4; break;
case WORKSHEET_DATAITEM::WS_BITMAP: img = 5; break;
}
wxTreeItemId cell= AppendItem( rootitem, item->m_Name, img, img );
DESIGN_TREE_ITEM_DATA* data = new DESIGN_TREE_ITEM_DATA( item );
SetItemData( cell, data );
}
Expand( rootitem );
}
// Select the tree item corresponding to the WORKSHEET_DATAITEM aItem
void DESIGN_TREE_FRAME::SelectCell( WORKSHEET_DATAITEM* aItem )
{
wxTreeItemId rootcell = GetRootItem();
wxTreeItemIdValue cookie;
wxTreeItemId cell = GetFirstChild( rootcell, cookie );
while( cell.IsOk() )
{
DESIGN_TREE_ITEM_DATA* data = (DESIGN_TREE_ITEM_DATA*) GetItemData( cell );
if( data->GetItem() == aItem )
{
SelectItem( cell );
return;
}
cell = GetNextChild( rootcell, cookie );
}
}
//return the page layout item managed by the cell
WORKSHEET_DATAITEM* DESIGN_TREE_FRAME::GetPageLayoutItem( wxTreeItemId aCell ) const
{
DESIGN_TREE_ITEM_DATA* data = (DESIGN_TREE_ITEM_DATA*) GetItemData( aCell );
if( data )
return data->GetItem();
else
return NULL;
}
/* return the page layout item managed by the selected cell (or NULL)
*/
WORKSHEET_DATAITEM* DESIGN_TREE_FRAME::GetPageLayoutSelectedItem() const
{
wxTreeItemId cell;
cell = GetSelection();
if( cell.IsOk() )
return GetPageLayoutItem( cell );
return NULL;
}
/* return the page layout item index managed by the selected cell (or -1)
*/
int DESIGN_TREE_FRAME::GetSelectedItemIndex()
{
WORKSHEET_DATAITEM*item = GetPageLayoutSelectedItem();
if( item == NULL )
return -1;
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
return pglayout.GetItemIndex( item );
}

View File

@ -1,108 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* 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
*/
/**
* @file design_tree_frame.h
*/
#ifndef _DESIGN_TREE_FRAME_H
#define _DESIGN_TREE_FRAME_H
#include <wx/treectrl.h>
#include <pl_editor_frame.h>
class WORKSHEET_DATAITEM;
/** class DESIGN_TREE_ITEM
* Handle one item for the page layoiut design
*/
class DESIGN_TREE_ITEM_DATA : public wxTreeItemData
{
private:
WORKSHEET_DATAITEM* m_wsItem; // the page layout item owned by me
public:
DESIGN_TREE_ITEM_DATA( WORKSHEET_DATAITEM* aItem = NULL )
{
m_wsItem = aItem;
}
/** @return the item managed by the cell
*/
WORKSHEET_DATAITEM* GetItem() const
{
return m_wsItem;
}
/** Set the link to the item managed by the cell
*/
void SetItem( WORKSHEET_DATAITEM* aItem )
{
m_wsItem = aItem;
}
};
/**
* Class DESIGN_TREE_FRAME is the left window showing the list of items
*/
class DESIGN_TREE_FRAME : protected wxTreeCtrl
{
friend class PL_EDITOR_FRAME;
private:
wxImageList* m_imageList;
public:
DESIGN_TREE_FRAME( PL_EDITOR_FRAME* aParent );
~DESIGN_TREE_FRAME();
void ReCreateDesignTree();
wxSize GetMinSize() const override;
/** @return the page layout item managed by the cell
*/
WORKSHEET_DATAITEM* GetPageLayoutItem(wxTreeItemId aCell) const;
/** @return the page layout item managed by the selected cell (or NULL)
*/
WORKSHEET_DATAITEM* GetPageLayoutSelectedItem() const;
/** @return the page layout item index managed by the selected cell (or -1)
*/
int GetSelectedItemIndex();
// Select the tree item corresponding to the WORKSHEET_DATAITEM aItem
void SelectCell( WORKSHEET_DATAITEM* aItem );
void SelectCell( const wxTreeItemId &aTreeItem, bool aSelect=true )
{
SelectItem( aTreeItem, aSelect );
}
};
#endif /* _DESIGN_TREE_FRAME_H */

View File

@ -1,8 +1,3 @@
/**
* @file dialog_new_dataitem.cpp
* @brief a dialog called on creating a new plage layout data item.
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -35,6 +30,7 @@
#include <worksheet_dataitem.h>
#include <dialog_new_dataitem_base.h>
class DIALOG_NEW_DATAITEM : public DIALOG_NEW_DATAITEM_BASE
{
WORKSHEET_DATAITEM* m_item;
@ -55,8 +51,8 @@ int InvokeDialogNewItem( PL_EDITOR_FRAME* aCaller, WORKSHEET_DATAITEM* aItem )
return dlg.ShowModal();
}
DIALOG_NEW_DATAITEM::DIALOG_NEW_DATAITEM( PL_EDITOR_FRAME* aCaller,
WORKSHEET_DATAITEM* aItem )
DIALOG_NEW_DATAITEM::DIALOG_NEW_DATAITEM( PL_EDITOR_FRAME* aCaller, WORKSHEET_DATAITEM* aItem )
: DIALOG_NEW_DATAITEM_BASE( aCaller )
{
m_item = aItem;
@ -92,10 +88,10 @@ void DIALOG_NEW_DATAITEM::OnOKClick( wxCommandEvent& event )
switch( m_choiceCornerPos->GetSelection() )
{
case 2: m_item->m_Pos.m_Anchor = RB_CORNER; break;
case 0: m_item->m_Pos.m_Anchor = RT_CORNER; break;
case 3: m_item->m_Pos.m_Anchor = LB_CORNER; break;
case 1: m_item->m_Pos.m_Anchor = LT_CORNER; break;
case 2: m_item->m_Pos.m_Anchor = RB_CORNER; break;
case 0: m_item->m_Pos.m_Anchor = RT_CORNER; break;
case 3: m_item->m_Pos.m_Anchor = LB_CORNER; break;
case 1: m_item->m_Pos.m_Anchor = LT_CORNER; break;
}
// Import End point
@ -109,10 +105,10 @@ void DIALOG_NEW_DATAITEM::OnOKClick( wxCommandEvent& event )
switch( m_choiceCornerEnd->GetSelection() )
{
case 2: m_item->m_End.m_Anchor = RB_CORNER; break;
case 0: m_item->m_End.m_Anchor = RT_CORNER; break;
case 3: m_item->m_End.m_Anchor = LB_CORNER; break;
case 1: m_item->m_End.m_Anchor = LT_CORNER; break;
case 2: m_item->m_End.m_Anchor = RB_CORNER; break;
case 0: m_item->m_End.m_Anchor = RT_CORNER; break;
case 3: m_item->m_End.m_Anchor = LB_CORNER; break;
case 1: m_item->m_End.m_Anchor = LT_CORNER; break;
}
EndModal( wxID_OK);
@ -123,20 +119,20 @@ void DIALOG_NEW_DATAITEM::initDlg()
// Disable useless widgets, depending on WORKSHEET_DATAITEM type
switch( m_item->GetType() )
{
case WORKSHEET_DATAITEM::WS_SEGMENT:
case WORKSHEET_DATAITEM::WS_RECT:
m_textCtrlText->Enable( false );
break;
case WORKSHEET_DATAITEM::WS_SEGMENT:
case WORKSHEET_DATAITEM::WS_RECT:
m_textCtrlText->Enable( false );
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
m_textCtrlText->Enable( false );
// fall through
case WORKSHEET_DATAITEM::WS_TEXT:
m_textCtrlEndX->Enable( false );
m_textCtrlEndY->Enable( false );
m_choiceCornerEnd->Enable( false );
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
m_textCtrlText->Enable( false );
// fall through
case WORKSHEET_DATAITEM::WS_TEXT:
m_textCtrlEndX->Enable( false );
m_textCtrlEndY->Enable( false );
m_choiceCornerEnd->Enable( false );
break;
}
wxString msg;
@ -146,16 +142,13 @@ void DIALOG_NEW_DATAITEM::initDlg()
m_textCtrlPosX->SetValue( msg );
msg.Printf( wxT("%.3f"), m_item->m_Pos.m_Pos.y );
m_textCtrlPosY->SetValue( msg );
switch( m_item->m_Pos.m_Anchor )
{
case RB_CORNER: // right bottom corner
m_choiceCornerPos->SetSelection( 2 ); break;
case RT_CORNER: // right top corner
m_choiceCornerPos->SetSelection( 0 ); break;
case LB_CORNER: // left bottom corner
m_choiceCornerPos->SetSelection( 3 ); break;
case LT_CORNER: // left top corner
m_choiceCornerPos->SetSelection( 1 ); break;
case RB_CORNER: m_choiceCornerPos->SetSelection( 2 ); break;
case RT_CORNER: m_choiceCornerPos->SetSelection( 0 ); break;
case LB_CORNER: m_choiceCornerPos->SetSelection( 3 ); break;
case LT_CORNER: m_choiceCornerPos->SetSelection( 1 ); break;
}
// End point
@ -163,16 +156,13 @@ void DIALOG_NEW_DATAITEM::initDlg()
m_textCtrlEndX->SetValue( msg );
msg.Printf( wxT("%.3f"), m_item->m_End.m_Pos.y );
m_textCtrlEndY->SetValue( msg );
switch( m_item->m_End.m_Anchor )
{
case RB_CORNER: // right bottom corner
m_choiceCornerEnd->SetSelection( 2 ); break;
case RT_CORNER: // right top corner
m_choiceCornerEnd->SetSelection( 0 ); break;
case LB_CORNER: // left bottom corner
m_choiceCornerEnd->SetSelection( 3 ); break;
case LT_CORNER: // left top corner
m_choiceCornerEnd->SetSelection( 1 ); break;
case RB_CORNER: m_choiceCornerEnd->SetSelection( 2 ); break;
case RT_CORNER: m_choiceCornerEnd->SetSelection( 0 ); break;
case LB_CORNER: m_choiceCornerEnd->SetSelection( 3 ); break;
case LT_CORNER: m_choiceCornerEnd->SetSelection( 1 ); break;
}
if( m_item->GetType() == WORKSHEET_DATAITEM::WS_TEXT )

View File

@ -34,7 +34,7 @@
#include <pl_editor_frame.h>
#include <pl_editor_id.h>
#include <dialog_helpers.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <dialog_page_settings.h>
#include <invoke_pl_editor_dialog.h>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -23,44 +23,23 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
wxBoxSizer* bSizerButt;
bSizerButt = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerType;
bSizerType = new wxBoxSizer( wxVERTICAL );
m_staticTextType = new wxStaticText( m_swItemProperties, wxID_ANY, _("Type:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextType = new wxStaticText( m_swItemProperties, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextType->Wrap( -1 );
m_staticTextType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
m_staticTextType->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizerType->Add( m_staticTextType, 0, wxLEFT|wxRIGHT, 5 );
bSizerButt->Add( m_staticTextType, 1, wxLEFT|wxRIGHT, 5 );
m_textCtrlType = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
bSizerType->Add( m_textCtrlType, 0, wxRIGHT|wxLEFT, 5 );
bSizerButt->Add( bSizerType, 0, 0, 5 );
wxBoxSizer* bSizerPageOpt;
bSizerPageOpt = new wxBoxSizer( wxVERTICAL );
m_staticTextPageOpt = new wxStaticText( m_swItemProperties, wxID_ANY, _("Page 1 option:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPageOpt->Wrap( -1 );
m_staticTextPageOpt->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
bSizerPageOpt->Add( m_staticTextPageOpt, 0, wxLEFT|wxRIGHT, 5 );
wxString m_choicePageOptChoices[] = { _("None"), _("Page 1 only"), _("Not on page 1") };
wxString m_choicePageOptChoices[] = { _("Show on all pages"), _("First page only"), _("Subsequent pages only") };
int m_choicePageOptNChoices = sizeof( m_choicePageOptChoices ) / sizeof( wxString );
m_choicePageOpt = new wxChoice( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choicePageOptNChoices, m_choicePageOptChoices, 0 );
m_choicePageOpt->SetSelection( 2 );
bSizerPageOpt->Add( m_choicePageOpt, 0, wxRIGHT|wxLEFT, 5 );
bSizerButt->Add( m_choicePageOpt, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bSizerButt->Add( bSizerPageOpt, 0, 0, 5 );
bSizerMain->Add( bSizerButt, 0, 0, 5 );
bSizerMain->Add( bSizerButt, 0, wxEXPAND, 5 );
m_staticline5 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline5, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_staticline5, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_SizerTextOptions = new wxBoxSizer( wxVERTICAL );
@ -69,59 +48,58 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_SizerTextOptions->Add( m_staticTextText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlText = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_SizerTextOptions->Add( m_textCtrlText, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_SizerTextOptions->Add( m_textCtrlText, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerFontOpt;
bSizerFontOpt = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizer1 = new wxFlexGridSizer( 0, 4, 0, 0 );
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextHjust = new wxStaticText( m_swItemProperties, wxID_ANY, _("Horizontal align:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextHjust = new wxStaticText( m_swItemProperties, wxID_ANY, _("H align:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextHjust->Wrap( -1 );
fgSizer1->Add( m_staticTextHjust, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer1->Add( m_staticTextHjust, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxString m_choiceHjustifyChoices[] = { _("Left"), _("Center"), _("Right") };
int m_choiceHjustifyNChoices = sizeof( m_choiceHjustifyChoices ) / sizeof( wxString );
m_choiceHjustify = new wxChoice( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceHjustifyNChoices, m_choiceHjustifyChoices, 0 );
m_choiceHjustify->SetSelection( 0 );
fgSizer1->Add( m_choiceHjustify, 0, wxEXPAND|wxALL, 5 );
fgSizer1->Add( m_choiceHjustify, 0, wxEXPAND|wxALL|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 );
m_checkBoxBold = new wxCheckBox( m_swItemProperties, wxID_ANY, _("Bold"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxBold, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_checkBoxBold, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticTextVjust = new wxStaticText( m_swItemProperties, wxID_ANY, _("Vertical align:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextVjust = new wxStaticText( m_swItemProperties, wxID_ANY, _("V align:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextVjust->Wrap( -1 );
fgSizer1->Add( m_staticTextVjust, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer1->Add( m_staticTextVjust, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
wxString m_choiceVjustifyChoices[] = { _("Top"), _("Center"), _("Bottom") };
int m_choiceVjustifyNChoices = sizeof( m_choiceVjustifyChoices ) / sizeof( wxString );
m_choiceVjustify = new wxChoice( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceVjustifyNChoices, m_choiceVjustifyChoices, 0 );
m_choiceVjustify->SetSelection( 1 );
fgSizer1->Add( m_choiceVjustify, 0, wxEXPAND|wxALL, 5 );
fgSizer1->Add( m_choiceVjustify, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_checkBoxItalic = new wxCheckBox( m_swItemProperties, wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_checkBoxItalic, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_checkBoxItalic, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerFontOpt->Add( fgSizer1, 1, wxEXPAND, 5 );
bSizerFontOpt->Add( fgSizer1, 0, wxEXPAND, 5 );
m_SizerTextOptions->Add( bSizerFontOpt, 0, wxEXPAND, 5 );
m_staticline81 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_SizerTextOptions->Add( m_staticline81, 0, wxEXPAND | wxALL, 5 );
m_staticTextSizeInfo = new wxStaticText( m_swItemProperties, wxID_ANY, _("Set to 0 to use default values"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeInfo->Wrap( -1 );
m_SizerTextOptions->Add( m_staticTextSizeInfo, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SizerTextOptions->Add( bSizerFontOpt, 0, wxEXPAND|wxBOTTOM, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 4, 0, 0 );
fgSizer2 = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizer2->AddGrowableCol( 0 );
fgSizer2->AddGrowableCol( 2 );
fgSizer2->AddGrowableCol( 3 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -130,6 +108,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer2->Add( m_staticTexTsizeX, 0, wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( 0, 0, 0, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextTsizeY = new wxStaticText( m_swItemProperties, wxID_ANY, _("Text height:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -137,7 +118,7 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer2->Add( m_staticTextTsizeY, 0, wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 0, wxEXPAND, 5 );
m_textCtrlTextSizeX = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_textCtrlTextSizeX, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -146,6 +127,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_units1->Wrap( -1 );
fgSizer2->Add( m_units1, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_textCtrlTextSizeY = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_textCtrlTextSizeY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -153,36 +137,26 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_units11->Wrap( -1 );
fgSizer2->Add( m_units11, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
m_staticTextConstraints = new wxStaticText( m_swItemProperties, wxID_ANY, _("Constraints:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextConstraints->Wrap( -1 );
fgSizer2->Add( m_staticTextConstraints, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextConstraintX = new wxStaticText( m_swItemProperties, wxID_ANY, _("Maximum width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextConstraintX->Wrap( -1 );
m_staticTextConstraintX->SetToolTip( _("Set to 0 to disable this constraint") );
fgSizer2->Add( m_staticTextConstraintX, 0, wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( m_staticTextConstraintX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 0, wxEXPAND, 5 );
m_staticTextConstraintY = new wxStaticText( m_swItemProperties, wxID_ANY, _("Maximum height:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextConstraintY->Wrap( -1 );
m_staticTextConstraintY->SetToolTip( _("Set to 0 to disable this constraint") );
fgSizer2->Add( m_staticTextConstraintY, 0, wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( m_staticTextConstraintY, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer2->Add( 0, 0, 0, wxEXPAND, 5 );
m_textCtrlConstraintX = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_textCtrlConstraintX, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -191,6 +165,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_units111->Wrap( -1 );
fgSizer2->Add( m_units111, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 );
fgSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
m_textCtrlConstraintY = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_textCtrlConstraintY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -199,86 +176,85 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer2->Add( m_units1111, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
m_SizerTextOptions->Add( fgSizer2, 1, wxEXPAND, 5 );
m_SizerTextOptions->Add( fgSizer2, 0, wxEXPAND, 5 );
m_staticTextSizeInfo = new wxStaticText( m_swItemProperties, wxID_ANY, _("Set to 0 to use default values"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextSizeInfo->Wrap( -1 );
m_SizerTextOptions->Add( m_staticTextSizeInfo, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticline6 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
m_SizerTextOptions->Add( m_staticline6, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_SizerTextOptions, 0, wxEXPAND, 5 );
m_buttonOK = new wxButton( m_swItemProperties, wxID_ANY, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonOK->SetDefault();
bSizerMain->Add( m_SizerTextOptions, 1, wxEXPAND, 5 );
m_buttonOK = new wxButton( m_swItemProperties, wxID_ANY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonOK->SetDefault();
bSizerMain->Add( m_buttonOK, 0, wxALL|wxEXPAND, 5 );
m_staticline8 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline8, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_staticline8, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextComment = new wxStaticText( m_swItemProperties, wxID_ANY, _("Comment:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextComment->Wrap( -1 );
bSizerMain->Add( m_staticTextComment, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_staticTextComment, 0, wxRIGHT|wxLEFT, 5 );
m_textCtrlComment = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_textCtrlComment, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticline2 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline2, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_staticline2, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 );
wxBoxSizer* bSizerPos;
bSizerPos = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer* fgSizer3;
fgSizer3 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer3->AddGrowableCol( 0 );
fgSizer3->SetFlexibleDirection( wxBOTH );
fgSizer3 = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizer3->AddGrowableCol( 1 );
fgSizer3->SetFlexibleDirection( wxHORIZONTAL );
fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextPosX = new wxStaticText( m_swItemProperties, wxID_ANY, _("Start X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosX = new wxStaticText( m_swItemProperties, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosX->Wrap( -1 );
fgSizer3->Add( m_staticTextPosX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer3->Add( m_staticTextPosX, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_textCtrlPosX = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer3->Add( m_textCtrlPosX, 1, wxEXPAND|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizer3->Add( m_textCtrlPosX, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_units12 = new wxStaticText( m_swItemProperties, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_units12->Wrap( -1 );
fgSizer3->Add( m_units12, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 );
m_staticTextPosY = new wxStaticText( m_swItemProperties, wxID_ANY, _("Start Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosY = new wxStaticText( m_swItemProperties, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextPosY->Wrap( -1 );
fgSizer3->Add( m_staticTextPosY, 0, wxRIGHT|wxLEFT, 5 );
fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer3->Add( m_staticTextPosY, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_textCtrlPosY = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer3->Add( m_textCtrlPosY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
fgSizer3->Add( m_textCtrlPosY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_units121 = new wxStaticText( m_swItemProperties, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_units121->Wrap( -1 );
fgSizer3->Add( m_units121, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 );
fgSizer3->Add( m_units121, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 );
bSizerPos->Add( fgSizer3, 1, wxEXPAND|wxRIGHT, 5 );
bSizerPos->Add( fgSizer3, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
m_staticTextOrgPos = new wxStaticText( m_swItemProperties, wxID_ANY, _("Origin:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOrgPos = new wxStaticText( m_swItemProperties, wxID_ANY, _("From:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOrgPos->Wrap( -1 );
bSizer6->Add( m_staticTextOrgPos, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_comboBoxCornerPos = new wxComboBox( m_swItemProperties, wxID_ANY, _("Lower Right"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_comboBoxCornerPos = new wxComboBox( m_swItemProperties, wxID_ANY, _("Lower Right"), wxDefaultPosition, wxSize( -1,-1 ), 0, NULL, 0 );
m_comboBoxCornerPos->Append( _("Upper Right") );
m_comboBoxCornerPos->Append( _("Upper Left") );
m_comboBoxCornerPos->Append( _("Lower Right") );
m_comboBoxCornerPos->Append( _("Lower Left") );
m_comboBoxCornerPos->SetSelection( 2 );
bSizer6->Add( m_comboBoxCornerPos, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_comboBoxCornerPos->SetMinSize( wxSize( 132,-1 ) );
bSizer6->Add( m_comboBoxCornerPos, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerPos->Add( bSizer6, 0, wxALIGN_CENTER_VERTICAL, 5 );
@ -289,84 +265,74 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_SizerEndPosition = new wxBoxSizer( wxHORIZONTAL );
wxFlexGridSizer* fgSizer4;
fgSizer4 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer4->AddGrowableCol( 0 );
fgSizer4->SetFlexibleDirection( wxBOTH );
fgSizer4 = new wxFlexGridSizer( 0, 3, 0, 0 );
fgSizer4->AddGrowableCol( 1 );
fgSizer4->SetFlexibleDirection( wxHORIZONTAL );
fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_staticTextEndX = new wxStaticText( m_swItemProperties, wxID_ANY, _("End X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextEndX = new wxStaticText( m_swItemProperties, wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextEndX->Wrap( -1 );
fgSizer4->Add( m_staticTextEndX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer4->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer4->Add( m_staticTextEndX, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_textCtrlEndX = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer4->Add( m_textCtrlEndX, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
fgSizer4->Add( m_textCtrlEndX, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_units1211 = new wxStaticText( m_swItemProperties, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_units1211->Wrap( -1 );
fgSizer4->Add( m_units1211, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 );
m_staticTextEndY = new wxStaticText( m_swItemProperties, wxID_ANY, _("End Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextEndY = new wxStaticText( m_swItemProperties, wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextEndY->Wrap( -1 );
fgSizer4->Add( m_staticTextEndY, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer4->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer4->Add( m_staticTextEndY, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_textCtrlEndY = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer4->Add( m_textCtrlEndY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
fgSizer4->Add( m_textCtrlEndY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
m_units12111 = new wxStaticText( m_swItemProperties, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_units12111->Wrap( -1 );
fgSizer4->Add( m_units12111, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM, 5 );
m_SizerEndPosition->Add( fgSizer4, 1, wxEXPAND|wxRIGHT, 5 );
m_SizerEndPosition->Add( fgSizer4, 0, wxEXPAND|wxRIGHT, 5 );
wxBoxSizer* bSizer61;
bSizer61 = new wxBoxSizer( wxVERTICAL );
m_staticTextOrgEnd = new wxStaticText( m_swItemProperties, wxID_ANY, _("Origin:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOrgEnd = new wxStaticText( m_swItemProperties, wxID_ANY, _("From:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextOrgEnd->Wrap( -1 );
bSizer61->Add( m_staticTextOrgEnd, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_comboBoxCornerEnd = new wxComboBox( m_swItemProperties, wxID_ANY, _("Lower Left"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_comboBoxCornerEnd = new wxComboBox( m_swItemProperties, wxID_ANY, _("Lower Left"), wxDefaultPosition, wxSize( -1,-1 ), 0, NULL, 0 );
m_comboBoxCornerEnd->Append( _("Upper Right") );
m_comboBoxCornerEnd->Append( _("Upper Left") );
m_comboBoxCornerEnd->Append( _("Lower Right") );
m_comboBoxCornerEnd->Append( _("Lower Left") );
m_comboBoxCornerEnd->SetSelection( 3 );
bSizer61->Add( m_comboBoxCornerEnd, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_comboBoxCornerEnd->SetMinSize( wxSize( 132,-1 ) );
bSizer61->Add( m_comboBoxCornerEnd, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_SizerEndPosition->Add( bSizer61, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain->Add( m_SizerEndPosition, 0, wxEXPAND, 5 );
bSizerMain->Add( m_SizerEndPosition, 0, wxTOP|wxBOTTOM|wxEXPAND, 5 );
m_SizerLineThickness = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerThickness;
bSizerThickness = new wxBoxSizer( wxVERTICAL );
m_staticTextThickness = new wxStaticText( m_swItemProperties, wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextThickness = new wxStaticText( m_swItemProperties, wxID_ANY, _("Line width:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextThickness->Wrap( -1 );
bSizerThickness->Add( m_staticTextThickness, 0, wxLEFT|wxRIGHT, 5 );
m_SizerLineThickness->Add( m_staticTextThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
m_textCtrlThickness = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerThickness->Add( m_textCtrlThickness, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_SizerLineThickness->Add( m_textCtrlThickness, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_SizerLineThickness->Add( bSizerThickness, 0, wxEXPAND, 5 );
m_staticTextInfoThickness = new wxStaticText( m_swItemProperties, wxID_ANY, _("Set to 0 to use default"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInfoThickness = new wxStaticText( m_swItemProperties, wxID_ANY, _("Set to 0 for default"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInfoThickness->Wrap( -1 );
m_SizerLineThickness->Add( m_staticTextInfoThickness, 0, wxALIGN_CENTER|wxALL, 5 );
m_SizerLineThickness->Add( m_staticTextInfoThickness, 0, wxALIGN_CENTER|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_SizerLineThickness, 0, 0, 5 );
bSizerMain->Add( m_SizerLineThickness, 0, wxTOP|wxBOTTOM, 5 );
m_SizerRotAndPPI = new wxBoxSizer( wxVERTICAL );
@ -380,35 +346,31 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_staticTextRot = new wxStaticText( m_swItemProperties, wxID_ANY, _("Rotation:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRot->Wrap( -1 );
fgSizerRotAndPPI->Add( m_staticTextRot, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRotAndPPI->Add( m_staticTextRot, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_textCtrlRotation = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRotAndPPI->Add( m_textCtrlRotation, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxLEFT|wxRIGHT, 5 );
fgSizerRotAndPPI->Add( m_textCtrlRotation, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_staticTextBitmapPPI = new wxStaticText( m_swItemProperties, wxID_ANY, _("Bitmap PPI:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextBitmapPPI->Wrap( -1 );
fgSizerRotAndPPI->Add( m_staticTextBitmapPPI, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
fgSizerRotAndPPI->Add( m_staticTextBitmapPPI, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_textCtrlBitmapPPI = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizerRotAndPPI->Add( m_textCtrlBitmapPPI, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxLEFT|wxRIGHT, 5 );
fgSizerRotAndPPI->Add( m_textCtrlBitmapPPI, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 );
m_SizerRotAndPPI->Add( fgSizerRotAndPPI, 1, wxEXPAND, 5 );
m_SizerRotAndPPI->Add( fgSizerRotAndPPI, 0, wxEXPAND, 5 );
bSizerMain->Add( m_SizerRotAndPPI, 0, wxEXPAND, 5 );
m_staticline4 = new wxStaticLine( m_swItemProperties, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline4, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_staticTextRepeatPrms = new wxStaticText( m_swItemProperties, wxID_ANY, _("Repeat parameters:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRepeatPrms->Wrap( -1 );
bSizerMain->Add( m_staticTextRepeatPrms, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( m_staticline4, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 );
wxFlexGridSizer* fgSizer8;
fgSizer8 = new wxFlexGridSizer( 0, 4, 0, 0 );
fgSizer8 = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizer8->AddGrowableCol( 0 );
fgSizer8->AddGrowableCol( 2 );
fgSizer8->AddGrowableCol( 3 );
fgSizer8->SetFlexibleDirection( wxBOTH );
fgSizer8->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -417,32 +379,41 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer8->Add( m_staticTextRepeatCnt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer8->Add( 0, 0, 0, wxEXPAND, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextInclabel = new wxStaticText( m_swItemProperties, wxID_ANY, _("Text Increment:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInclabel = new wxStaticText( m_swItemProperties, wxID_ANY, _("Step text:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextInclabel->Wrap( -1 );
fgSizer8->Add( m_staticTextInclabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer8->Add( 0, 0, 0, wxEXPAND, 5 );
m_textCtrlRepeatCount = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer8->Add( m_textCtrlRepeatCount, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 );
fgSizer8->Add( m_textCtrlRepeatCount, 0, wxEXPAND|wxLEFT, 5 );
fgSizer8->Add( 0, 0, 0, wxEXPAND, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
m_textCtrlTextIncrement = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer8->Add( m_textCtrlTextIncrement, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 );
fgSizer8->Add( m_textCtrlTextIncrement, 0, wxEXPAND|wxLEFT, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer8->Add( 0, 0, 0, wxEXPAND, 5 );
m_staticTextStepX = new wxStaticText( m_swItemProperties, wxID_ANY, _("Step X:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextStepX->Wrap( -1 );
fgSizer8->Add( m_staticTextStepX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer8->Add( 0, 0, 0, wxEXPAND, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextStepY = new wxStaticText( m_swItemProperties, wxID_ANY, _("Step Y:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -450,15 +421,18 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer8->Add( m_staticTextStepY, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer8->Add( 0, 0, 0, wxEXPAND, 5 );
m_textCtrlStepX = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlStepX = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 );
fgSizer8->Add( m_textCtrlStepX, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
m_units121111 = new wxStaticText( m_swItemProperties, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 );
m_units121111->Wrap( -1 );
fgSizer8->Add( m_units121111, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
fgSizer8->Add( 0, 0, 1, wxEXPAND|wxLEFT, 5 );
m_textCtrlStepY = new wxTextCtrl( m_swItemProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer8->Add( m_textCtrlStepY, 0, wxEXPAND|wxBOTTOM|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 );
@ -467,7 +441,7 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer8->Add( m_units1211111, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
bSizerMain->Add( fgSizer8, 1, wxEXPAND, 5 );
bSizerMain->Add( fgSizer8, 0, wxEXPAND, 5 );
m_swItemProperties->SetSizer( bSizerMain );
@ -487,9 +461,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
bSizerGeneralOpts1->Add( m_staticTextDefVal, 0, wxALL, 5 );
wxFlexGridSizer* fgSizer5;
fgSizer5 = new wxFlexGridSizer( 0, 4, 0, 0 );
fgSizer5 = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizer5->AddGrowableCol( 0 );
fgSizer5->AddGrowableCol( 2 );
fgSizer5->AddGrowableCol( 3 );
fgSizer5->SetFlexibleDirection( wxBOTH );
fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -498,6 +472,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer5->Add( m_staticTextDefTsX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextDefTsY = new wxStaticText( m_swGeneralOpts, wxID_ANY, _("Text height:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -514,6 +491,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_units14->Wrap( -1 );
fgSizer5->Add( m_units14, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
m_textCtrlDefaultTextSizeY = new wxTextCtrl( m_swGeneralOpts, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer5->Add( m_textCtrlDefaultTextSizeY, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -526,6 +506,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer5->Add( m_staticTextDefLineW, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer5->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText22 = new wxStaticText( m_swGeneralOpts, wxID_ANY, _("Text thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -542,6 +525,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_staticText221->Wrap( -1 );
fgSizer5->Add( m_staticText221, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
fgSizer5->Add( 0, 0, 1, wxEXPAND|wxRIGHT, 5 );
m_textCtrlDefaultTextThickness = new wxTextCtrl( m_swGeneralOpts, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer5->Add( m_textCtrlDefaultTextThickness, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -562,7 +548,7 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
bSizerGeneralOpts->Add( m_buttonDefault, 0, wxALL|wxEXPAND, 5 );
m_staticline9 = new wxStaticLine( m_swGeneralOpts, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerGeneralOpts->Add( m_staticline9, 0, wxEXPAND | wxALL, 5 );
bSizerGeneralOpts->Add( m_staticline9, 0, wxALL, 5 );
wxBoxSizer* bSizerGeneraMargins;
bSizerGeneraMargins = new wxBoxSizer( wxVERTICAL );
@ -572,9 +558,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
bSizerGeneraMargins->Add( m_staticTextMargins, 0, wxALL, 5 );
wxFlexGridSizer* fgSizer6;
fgSizer6 = new wxFlexGridSizer( 0, 4, 0, 0 );
fgSizer6 = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizer6->AddGrowableCol( 0 );
fgSizer6->AddGrowableCol( 2 );
fgSizer6->AddGrowableCol( 3 );
fgSizer6->SetFlexibleDirection( wxBOTH );
fgSizer6->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
@ -583,6 +569,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer6->Add( m_staticTextLeftMargin, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer6->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer6->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextDefRightMargin = new wxStaticText( m_swGeneralOpts, wxID_ANY, _("Right:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -599,6 +588,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_units142->Wrap( -1 );
fgSizer6->Add( m_units142, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxRIGHT, 5 );
fgSizer6->Add( 0, 0, 1, wxEXPAND|wxRIGHT, 5 );
m_textCtrlRightMargin = new wxTextCtrl( m_swGeneralOpts, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer6->Add( m_textCtrlRightMargin, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
@ -611,6 +603,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
fgSizer6->Add( m_staticTextTopMargin, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
fgSizer6->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer6->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticTextBottomMargin = new wxStaticText( m_swGeneralOpts, wxID_ANY, _("Bottom:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -627,6 +622,9 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
m_units1431->Wrap( -1 );
fgSizer6->Add( m_units1431, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxBOTTOM|wxRIGHT, 5 );
fgSizer6->Add( 0, 0, 1, wxEXPAND, 5 );
m_textCtrlDefaultBottomMargin = new wxTextCtrl( m_swGeneralOpts, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer6->Add( m_textCtrlDefaultBottomMargin, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT, 5 );
@ -638,11 +636,10 @@ PANEL_PROPERTIES_BASE::PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, c
bSizerGeneraMargins->Add( fgSizer6, 1, wxEXPAND, 5 );
bSizerGeneralOpts->Add( bSizerGeneraMargins, 0, wxEXPAND, 5 );
m_buttonGeneralOptsOK = new wxButton( m_swGeneralOpts, wxID_ANY, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonGeneralOptsOK->SetDefault();
bSizerGeneralOpts->Add( bSizerGeneraMargins, 0, wxEXPAND|wxBOTTOM, 15 );
m_buttonGeneralOptsOK = new wxButton( m_swGeneralOpts, wxID_ANY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonGeneralOptsOK->SetDefault();
bSizerGeneralOpts->Add( m_buttonGeneralOptsOK, 0, wxALL|wxEXPAND, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jul 11 2018)
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -17,17 +17,17 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/choice.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/combobox.h>
#include <wx/scrolwin.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/notebook.h>
#include <wx/panel.h>
@ -44,8 +44,6 @@ class PANEL_PROPERTIES_BASE : public wxPanel
wxNotebook* m_notebook;
wxScrolledWindow* m_swItemProperties;
wxStaticText* m_staticTextType;
wxTextCtrl* m_textCtrlType;
wxStaticText* m_staticTextPageOpt;
wxChoice* m_choicePageOpt;
wxStaticLine* m_staticline5;
wxBoxSizer* m_SizerTextOptions;
@ -57,21 +55,19 @@ class PANEL_PROPERTIES_BASE : public wxPanel
wxStaticText* m_staticTextVjust;
wxChoice* m_choiceVjustify;
wxCheckBox* m_checkBoxItalic;
wxStaticLine* m_staticline81;
wxStaticText* m_staticTextSizeInfo;
wxStaticText* m_staticTexTsizeX;
wxStaticText* m_staticTextTsizeY;
wxTextCtrl* m_textCtrlTextSizeX;
wxStaticText* m_units1;
wxTextCtrl* m_textCtrlTextSizeY;
wxStaticText* m_units11;
wxStaticText* m_staticTextConstraints;
wxStaticText* m_staticTextConstraintX;
wxStaticText* m_staticTextConstraintY;
wxTextCtrl* m_textCtrlConstraintX;
wxStaticText* m_units111;
wxTextCtrl* m_textCtrlConstraintY;
wxStaticText* m_units1111;
wxStaticText* m_staticTextSizeInfo;
wxStaticLine* m_staticline6;
wxButton* m_buttonOK;
wxStaticLine* m_staticline8;
@ -106,7 +102,6 @@ class PANEL_PROPERTIES_BASE : public wxPanel
wxStaticText* m_staticTextBitmapPPI;
wxTextCtrl* m_textCtrlBitmapPPI;
wxStaticLine* m_staticline4;
wxStaticText* m_staticTextRepeatPrms;
wxStaticText* m_staticTextRepeatCnt;
wxStaticText* m_staticTextInclabel;
wxTextCtrl* m_textCtrlRepeatCount;
@ -155,7 +150,7 @@ class PANEL_PROPERTIES_BASE : public wxPanel
public:
PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 371,864 ), long style = wxTAB_TRAVERSAL );
PANEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 340,775 ), long style = wxTAB_TRAVERSAL );
~PANEL_PROPERTIES_BASE();
};

View File

@ -40,22 +40,15 @@
#include <pl_editor_id.h>
#include <dialog_helpers.h>
#include <menus_helpers.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <design_tree_frame.h>
#include <properties_frame.h>
#include <dialog_page_settings.h>
#include <invoke_pl_editor_dialog.h>
#include <properties_frame.h>
BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow )
// Desing tree event:
EVT_TREE_SEL_CHANGED( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeSelection )
EVT_TREE_ITEM_MIDDLE_CLICK( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeMiddleClick )
EVT_TREE_ITEM_RIGHT_CLICK( ID_DESIGN_TREE_FRAME, PL_EDITOR_FRAME::OnTreeRightClick )
// Menu Files:
EVT_MENU( wxID_NEW, PL_EDITOR_FRAME::Files_io )
EVT_MENU( wxID_OPEN, PL_EDITOR_FRAME::Files_io )
@ -73,36 +66,21 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
// menu Preferences
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Config )
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Config )
EVT_MENU( ID_MENU_SWITCH_BGCOLOR, PL_EDITOR_FRAME::Process_Config )
EVT_MENU( ID_MENU_GRID_ONOFF, PL_EDITOR_FRAME::Process_Config )
EVT_TOOL( wxID_DELETE, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, PL_EDITOR_FRAME::GetLayoutFromUndoList )
EVT_TOOL( wxID_REDO, PL_EDITOR_FRAME::GetLayoutFromRedoList )
EVT_TOOL( wxID_PRINT, PL_EDITOR_FRAME::ToPrinter )
EVT_TOOL( wxID_PREVIEW, PL_EDITOR_FRAME::ToPrinter )
EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions)
// the ID_NO_TOOL_SELECTED id TOOL does not existing currently, but the right click
// popup menu can generate this event.
EVT_TOOL( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( ID_POPUP_CANCEL_CURRENT_COMMAND, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
PL_EDITOR_FRAME::Process_Special_Functions )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PL_EDITOR_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_ZOOM_SELECTION, PL_EDITOR_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode )
EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode )
END_EVENT_TABLE()
@ -110,28 +88,11 @@ END_EVENT_TABLE()
*/
void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
int idx;
wxString msg;
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
WORKSHEET_DATAITEM* item = NULL;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
switch( id )
switch( event.GetId() )
{
case ID_NO_TOOL_SELECTED:
SetNoToolSelected();
break;
case ID_ZOOM_SELECTION:
// This tool is located on the main toolbar: switch it on or off on click
if( GetToolId() != ID_ZOOM_SELECTION )
SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
else
SetNoToolSelected();
break;
case ID_SELECT_PAGE_NUMBER:
m_canvas->Refresh();
break;
@ -149,192 +110,15 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
break;
case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( m_canvas->IsMouseCaptured() )
{
m_canvas->EndMouseCapture();
SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
}
else
{
SetNoToolSelected();
}
break;
case ID_POPUP_DESIGN_TREE_ITEM_DELETE:
case ID_POPUP_ITEM_DELETE:
case wxID_DELETE:
// Delete item, and select the previous item
item = m_treePagelayout->GetPageLayoutSelectedItem();
if( item == NULL )
break;
SaveCopyInUndoList();
idx = pglayout.GetItemIndex( item );
pglayout.Remove( item );
RebuildDesignTree();
if( id == ID_POPUP_DESIGN_TREE_ITEM_DELETE )
{
item = pglayout.GetItem( (unsigned) (idx-1) );
if( item )
m_treePagelayout->SelectCell( item );
}
item = NULL;
OnModify();
m_canvas->Refresh();
break;
case ID_POPUP_ITEM_ADD_LINE:
SaveCopyInUndoList();
idx = m_treePagelayout->GetSelectedItemIndex();
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_SEGMENT, idx );
if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
{
RemoveLastCommandInUndoList();
pglayout.Remove( item );
RebuildDesignTree();
item = NULL;
}
else
{
// Put the new item in move mode, after putting the cursor
// on the start point:
wxPoint position = item->GetStartPosUi();
SetCrossHairPosition( position, false );
position = GetCrossHairPosition();
if( m_canvas->IsPointOnDisplay( position ) )
m_canvas->MoveCursorToCrossHair();
else
RedrawScreen( position, true );
item->SetFlags( NEW_ITEM );
MoveItem( item );
}
break;
case ID_POPUP_ITEM_ADD_RECT:
SaveCopyInUndoList();
idx = m_treePagelayout->GetSelectedItemIndex();
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_RECT, idx );
if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
{
RemoveLastCommandInUndoList();
pglayout.Remove( item );
RebuildDesignTree();
item = NULL;
}
else
{
// Put the new item in move mode, after putting the cursor
// on the start point:
wxPoint position = item->GetStartPosUi();
SetCrossHairPosition( position, false );
position = GetCrossHairPosition();
if( m_canvas->IsPointOnDisplay( position ) )
m_canvas->MoveCursorToCrossHair();
else
RedrawScreen( position, true );
item->SetFlags( NEW_ITEM );
MoveItem( item );
}
break;
case ID_POPUP_ITEM_ADD_TEXT:
SaveCopyInUndoList();
idx = m_treePagelayout->GetSelectedItemIndex();
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_TEXT, idx );
if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
{
RemoveLastCommandInUndoList();
pglayout.Remove( item );
RebuildDesignTree();
item = NULL;
}
else
{
// Put the new text in move mode:
item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
MoveItem( item );
}
break;
case ID_POPUP_ITEM_ADD_BITMAP:
SaveCopyInUndoList();
idx = m_treePagelayout->GetSelectedItemIndex();
item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx );
if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL )
{
RemoveLastCommandInUndoList();
pglayout.Remove( item );
RebuildDesignTree();
item = NULL;
}
if( item )
{
// Put the new text in move mode:
item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
MoveItem( item );
}
break;
case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT:
cmd.SetId( ID_APPEND_DESCR_FILE );
wxPostEvent( this, cmd );
break;
case ID_POPUP_ITEM_PLACE:
item = GetScreen()->GetCurItem();
PlaceItem( item );
break;
case ID_POPUP_ITEM_PLACE_CANCEL:
if( m_canvas->IsMouseCaptured() )
m_canvas->EndMouseCapture();
break;
case ID_POPUP_ITEM_MOVE_START_POINT:
item = m_treePagelayout->GetPageLayoutSelectedItem();
// Ensure flags are properly set
item->ClearFlags( LOCATE_ENDPOINT );
item->SetFlags( LOCATE_STARTPOINT );
MoveItem( item );
break;
case ID_POPUP_ITEM_MOVE_END_POINT:
item = m_treePagelayout->GetPageLayoutSelectedItem();
// Ensure flags are properly set
item->ClearFlags( LOCATE_STARTPOINT );
item->SetFlags( LOCATE_ENDPOINT );
MoveItem( item );
break;
case ID_POPUP_ITEM_MOVE:
item = m_treePagelayout->GetPageLayoutSelectedItem();
item->ClearFlags( LOCATE_ENDPOINT|LOCATE_STARTPOINT );
MoveItem( item );
break;
default:
wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
break;
}
if( item )
{
OnModify();
m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
m_treePagelayout->SelectCell( item );
}
}
@ -342,7 +126,6 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
* Function moveItem: called when the mouse cursor is moving
* moves the item currently selected (or the start point or the end point)
* to the cursor position
*/
DPOINT initialPosition; // The initial position of the item to move, in mm
wxPoint initialPositionUi; // The initial position of the item to move, in Ui
wxPoint initialCursorPosition; // The initial position of the cursor
@ -382,11 +165,9 @@ static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositio
}
/*
* Function abortMoveItem: called when an item is currently moving,
* and when the user aborts the move command.
* Restores the initial position of the item
*/
static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) aPanel->GetScreen();
@ -398,7 +179,6 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
plframe->RemoveLastCommandInUndoList();
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
pglayout.Remove( item );
plframe->RebuildDesignTree();
}
else
{
@ -454,10 +234,8 @@ void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem )
}
/**
* Save in Undo list the layout, and place an item being moved.
* @param aItem is the item moved
*/
void PL_EDITOR_FRAME::PlaceItem( WORKSHEET_DATAITEM* aItem )
{
DPOINT currStartPos = aItem->GetStartPos();
@ -486,6 +264,7 @@ void PL_EDITOR_FRAME::PlaceItem( WORKSHEET_DATAITEM* aItem )
m_canvas->SetMouseCapture( NULL, NULL );
GetScreen()->SetCurItem( NULL );
}
*/
/* called when the user select one of the 4 page corner as corner
@ -563,40 +342,6 @@ void PL_EDITOR_FRAME::ToPrinter(wxCommandEvent& event)
}
void PL_EDITOR_FRAME::OnTreeSelection( wxTreeEvent& event )
{
WORKSHEET_DATAITEM* item = GetSelectedItem();
if( item )
m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
m_canvas->Refresh();
}
void PL_EDITOR_FRAME::OnTreeMiddleClick( wxTreeEvent& event )
{
}
extern void AddNewItemsCommand( wxMenu* aMainMenu );
void PL_EDITOR_FRAME::OnTreeRightClick( wxTreeEvent& event )
{
m_treePagelayout->SelectCell( event.GetItem() );
wxMenu popMenu;
AddNewItemsCommand( &popMenu );
popMenu.AppendSeparator();
AddMenuItem( &popMenu, ID_POPUP_DESIGN_TREE_ITEM_DELETE, _( "Delete" ),
KiBitmap( delete_xpm ) );
PopupMenu( &popMenu );
}
void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event )
{
event.Check( WORKSHEET_DATAITEM::m_SpecialMode == false );
@ -609,7 +354,3 @@ void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& eve
}
void PL_EDITOR_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetToolId() == aEvent.GetId() );
}

View File

@ -34,7 +34,7 @@
#include <confirm.h>
#include <gestfich.h>
#include <macros.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <pl_editor_frame.h>
#include <properties_frame.h>
@ -70,7 +70,7 @@ void PL_EDITOR_FRAME::OnFileHistory( wxCommandEvent& event )
}
}
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT );
::wxSetWorkingDirectory( ::wxPathOnly( filename ) );
if( LoadPageLayoutDescrFile( filename ) )
@ -133,7 +133,6 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
else
{
GetScreen()->SetModify();
RebuildDesignTree();
m_canvas->Refresh();
msg.Printf( _( "File \"%s\" inserted" ), GetChars( filename ) );
SetStatusText( msg );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* This program is free software; you can redistribute it and/or
@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pagelayout_editor/hotkeys.cpp
*/
#include <fctsys.h>
#include <common.h>
#include <kicad_device_context.h>
@ -34,7 +30,6 @@
#include <class_drawpanel.h>
#include <pl_editor_frame.h>
#include <design_tree_frame.h>
#include <worksheet_dataitem.h>
#include <hotkeys.h>
#include <pl_editor_id.h>
@ -70,24 +65,17 @@ static EDA_HOTKEY HkMouseLeftClick( _HKI( "Mouse Left Click" ), HK_LEFT_CLICK, W
static EDA_HOTKEY HkMouseLeftDClick( _HKI( "Mouse Left Double Click" ), HK_LEFT_DCLICK,
WXK_END, 0 );
static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ),
HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME, ID_ZOOM_PAGE );
static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4,
ID_POPUP_ZOOM_CENTER );
static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3, ID_ZOOM_REDRAW );
static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_KEY_ZOOM_OUT );
static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_KEY_ZOOM_IN );
static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION,
GR_KB_CTRL + WXK_F5, ID_ZOOM_SELECTION );
static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
static EDA_HOTKEY HkMoveItem( _HKI( "Move Item" ), HK_MOVE_ITEM, 'M', ID_POPUP_ITEM_MOVE );
static EDA_HOTKEY HkPlaceItem( _HKI( "Place Item" ), HK_PLACE_ITEM, 'P', ID_POPUP_ITEM_PLACE );
static EDA_HOTKEY HkMoveStartPoint( _HKI( "Move Start Point" ), HK_MOVE_START_POINT, 'S',
ID_POPUP_ITEM_MOVE_START_POINT );
static EDA_HOTKEY HkMoveEndPoint( _HKI( "Move End Point" ), HK_MOVE_END_POINT, 'E',
ID_POPUP_ITEM_MOVE_END_POINT );
static EDA_HOTKEY HkDeleteItem( _HKI( "Delete Item" ), HK_DELETE_ITEM, WXK_DELETE, (int) wxID_DELETE );
static EDA_HOTKEY HkResetLocalCoord( _HKI( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' );
static EDA_HOTKEY HkZoomAuto( _HKI( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME );
static EDA_HOTKEY HkZoomCenter( _HKI( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 );
static EDA_HOTKEY HkZoomRedraw( _HKI( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 );
static EDA_HOTKEY HkZoomOut( _HKI( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 );
static EDA_HOTKEY HkZoomIn( _HKI( "Zoom In" ), HK_ZOOM_IN, WXK_F1 );
static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTION,
GR_KB_CTRL + WXK_F5 );
static EDA_HOTKEY HkHelp( _HKI( "List Hotkeys" ), HK_HELP, GR_KB_CTRL + WXK_F1 );
static EDA_HOTKEY HkMoveItem( _HKI( "Move Item" ), HK_MOVE, 'M' );
static EDA_HOTKEY HkDeleteItem( _HKI( "Delete Item" ), HK_DELETE_ITEM, WXK_DELETE );
// Common: hotkeys_basic.h
static EDA_HOTKEY HkUndo( _HKI( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_UNDO );
@ -115,9 +103,7 @@ EDA_HOTKEY* s_Common_Hotkey_List[] =
EDA_HOTKEY* s_PlEditor_Hotkey_List[] =
{
&HkMoveItem, &HkMoveStartPoint,
&HkMoveEndPoint,
&HkPlaceItem,
&HkMoveItem,
&HkDeleteItem,
NULL
};
@ -149,10 +135,9 @@ EDA_HOTKEY* PL_EDITOR_FRAME::GetHotKeyDescription( int aCommand ) const
}
bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
const wxPoint& aPosition, EDA_ITEM* aItem )
bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
EDA_ITEM* aItem )
{
bool busy = GetScreen()->GetCurItem() != NULL;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
@ -169,8 +154,6 @@ bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
if( HK_Descr == NULL )
return false;
WORKSHEET_DATAITEM* item;
switch( HK_Descr->m_Idcommand )
{
case HK_NOT_FOUND:
@ -210,44 +193,6 @@ bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_UNDO:
case HK_REDO:
if( busy )
break;
cmd.SetId( HK_Descr->m_IdMenuEvent );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_IN:
cmd.SetId( ID_POPUP_ZOOM_IN );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_OUT:
cmd.SetId( ID_POPUP_ZOOM_OUT );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_REDRAW:
cmd.SetId( ID_ZOOM_REDRAW );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_CENTER:
cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_AUTO:
cmd.SetId( ID_ZOOM_PAGE );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_ZOOM_SELECTION:
cmd.SetId( ID_ZOOM_SELECTION );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_RESET_LOCAL_COORD: // Reset the relative coord
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
@ -265,35 +210,6 @@ bool PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode,
SetGridOrigin( GetCrossHairPosition() );
break;
case HK_MOVE_ITEM:
case HK_MOVE_START_POINT:
case HK_MOVE_END_POINT:
case HK_DELETE_ITEM:
if( busy )
break;
if( (item = Locate( aDC, aPosition ) ) == NULL )
break;
// Only rect and lines have a end point.
if( HK_Descr->m_Idcommand == HK_MOVE_END_POINT && !item->HasEndPoint() )
break;
if( m_treePagelayout->GetPageLayoutSelectedItem() != item )
m_treePagelayout->SelectCell( item );
cmd.SetId( HK_Descr->m_IdMenuEvent );
GetEventHandler()->ProcessEvent( cmd );
break;
case HK_PLACE_ITEM:
if( busy )
{
cmd.SetId( HK_Descr->m_IdMenuEvent );
GetEventHandler()->ProcessEvent( cmd );
}
break;
default:
wxMessageBox( wxT( "Unknown hotkey" ) );
return false;

View File

@ -35,10 +35,7 @@
// see also enum common_hotkey_id_command in hotkeys_basic.h
// for shared hotkeys id
enum hotkey_id_command {
HK_MOVE_ITEM = HK_COMMON_END,
HK_MOVE_START_POINT,
HK_MOVE_END_POINT,
HK_PLACE_ITEM,
HK_MOVE = HK_COMMON_END,
HK_DELETE_ITEM
};

View File

@ -1,7 +1,3 @@
/**
* @file invoke_pl_editor_dialog.h
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013 CERN
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
@ -23,16 +23,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pagelayout_editor/menubar.cpp
* @brief (Re)Create the main menubar for Pl_Editor
*/
#include <kiface_i.h>
#include <menus_helpers.h>
#include <pgm_base.h>
#include <tool/conditional_menu.h>
#include <tool/tool_manager.h>
#include <tool/selection.h>
#include <tools/pl_actions.h>
#include <tools/pl_selection_tool.h>
#include "hotkeys.h"
#include "pl_editor_frame.h"
#include "pl_editor_id.h"
@ -40,6 +38,7 @@
void PL_EDITOR_FRAME::ReCreateMenuBar()
{
PL_SELECTION_TOOL* selTool = m_toolManager->GetTool<PL_SELECTION_TOOL>();
// wxWidgets handles the Mac Application menu behind the scenes, but that means
// we always have to start from scratch with a new wxMenuBar.
wxMenuBar* oldMenuBar = GetMenuBar();
@ -103,72 +102,57 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
// Edit Menu:
wxMenu* editMenu = new wxMenu;
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
msg = AddHotkeyName( _( "Undo" ), PlEditorHotkeysDescr, HK_UNDO );
AddMenuItem( editMenu, wxID_UNDO, msg, wxEmptyString, KiBitmap( undo_xpm ) );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen() && GetScreen()->GetUndoCommandCount() != 0;
};
auto enableRedoCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen() && GetScreen()->GetRedoCommandCount() != 0;
};
msg = AddHotkeyName( _( "Redo" ), PlEditorHotkeysDescr, HK_REDO );
AddMenuItem( editMenu, wxID_REDO, msg, wxEmptyString, KiBitmap( redo_xpm ) );
editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
editMenu->AppendSeparator();
msg = AddHotkeyName( _( "Delete" ), PlEditorHotkeysDescr, HK_DELETE_ITEM );
AddMenuItem( editMenu, wxID_DELETE, msg, wxEmptyString, KiBitmap( delete_xpm ) );
editMenu->AddSeparator();
editMenu->AddItem( PL_ACTIONS::doDelete, SELECTION_CONDITIONS::MoreThan( 0 ) );
// View Menu:
wxMenu* viewMenu = new wxMenu;
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
msg = AddHotkeyName( _( "Zoom In" ), PlEditorHotkeysDescr, HK_ZOOM_IN, IS_ACCELERATOR );
AddMenuItem( viewMenu, ID_ZOOM_IN, msg, wxEmptyString, KiBitmap( zoom_in_xpm ) );
auto whiteBackgroundCondition = [ this ] ( const SELECTION& aSel ) {
return GetDrawBgColor() == WHITE;
};
auto gridShownCondition = [ this ] ( const SELECTION& aSel ) {
return IsGridVisible();
};
auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) {
return GetGalDisplayOptions().m_fullscreenCursor;
};
msg = AddHotkeyName( _( "Zoom Out" ), PlEditorHotkeysDescr, HK_ZOOM_OUT, IS_ACCELERATOR );
AddMenuItem( viewMenu, ID_ZOOM_OUT, msg, wxEmptyString, KiBitmap( zoom_out_xpm ) );
msg = AddHotkeyName( _( "Zoom to Fit" ), PlEditorHotkeysDescr, HK_ZOOM_AUTO );
AddMenuItem( viewMenu, ID_ZOOM_PAGE, msg, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ) );
msg = AddHotkeyName( _( "Zoom to Selection" ), PlEditorHotkeysDescr, HK_ZOOM_SELECTION );
AddMenuItem( viewMenu, ID_ZOOM_SELECTION, msg, wxEmptyString, KiBitmap( zoom_area_xpm ), wxITEM_CHECK );
viewMenu->AppendSeparator();
AddMenuItem( viewMenu, ID_MENU_SWITCH_BGCOLOR,
GetDrawBgColor() == WHITE ? _( "&Background Black" ) : _( "&Background White" ),
wxEmptyString, KiBitmap( palette_xpm ) );
AddMenuItem( viewMenu, ID_MENU_GRID_ONOFF,
IsGridVisible() ? _( "Hide &Grid" ) : _( "Show &Grid" ),
wxEmptyString, KiBitmap( grid_xpm ) );
viewMenu->AppendSeparator();
msg = AddHotkeyName( _( "Redraw View" ), PlEditorHotkeysDescr, HK_ZOOM_REDRAW );
AddMenuItem( viewMenu, ID_ZOOM_REDRAW, msg, wxEmptyString, KiBitmap( zoom_redraw_xpm ) );
viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomOutCenter, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomFitScreen, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomTool, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddItem( ACTIONS::zoomRedraw, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( PL_ACTIONS::toggleBackground, whiteBackgroundCondition );
viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition );
viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition );
// Place Menu:
wxMenu* placeMenu = new wxMenu;
CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_LINE, _( "&Line..." ),
wxEmptyString, KiBitmap( add_dashed_line_xpm ) );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_RECT, _( "&Rectangle..." ),
wxEmptyString, KiBitmap( add_rectangle_xpm ) );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_TEXT, _( "&Text..." ),
wxEmptyString, KiBitmap( text_xpm ) );
AddMenuItem( placeMenu, ID_POPUP_ITEM_ADD_BITMAP, _( "&Bitmap..." ),
wxEmptyString, KiBitmap( image_xpm ) );
placeMenu->AppendSeparator();
AddMenuItem( placeMenu, ID_APPEND_DESCR_FILE, _( "&Append Existing Page Layout Design File..." ),
_( "Append an existing page layout design file to current file" ),
KiBitmap( pagelayout_load_xpm ) );
placeMenu->AddItem( PL_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PL_ACTIONS::drawRectangle, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PL_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PL_ACTIONS::placeImage, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddSeparator();
placeMenu->AddItem( PL_ACTIONS::appendImportedWorksheet, SELECTION_CONDITIONS::ShowAlways );
// Menu for preferences
wxMenu* preferencesMenu = new wxMenu;

View File

@ -1,77 +0,0 @@
/**
* @file pagelayout_editor/onleftclick.cpp
* @brief functions called on left or double left click mouse event
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 CERN
*
* 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
*/
#include <fctsys.h>
#include <class_drawpanel.h>
#include <common.h>
#include <pl_editor_frame.h>
#include <pl_editor_id.h>
#include <design_tree_frame.h>
#include <properties_frame.h>
#include <dialog_helpers.h>
#include <worksheet_dataitem.h>
/* Process the command triggered by the left button of the mouse when a tool
* is already selected.
*/
void PL_EDITOR_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
{
WORKSHEET_DATAITEM* item = GetScreen()->GetCurItem();
if( item ) // An item is currently in edit: place it
{
PlaceItem( item );
m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
m_canvas->Refresh();
return;
}
item = m_treePagelayout->GetPageLayoutSelectedItem();
WORKSHEET_DATAITEM* newitem = Locate( aDC, aPosition );
if( newitem == NULL )
return;
if( newitem != item )
{
item = newitem;
m_treePagelayout->SelectCell( item );
m_canvas->Refresh();
}
}
/* Called on a double click of left mouse button.
*/
void PL_EDITOR_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
{
// Currently: no nothing
}

View File

@ -1,140 +0,0 @@
/**
* @file pagelayout_editor/onrightclick.cpp
* @brief functions called on rigth click mouse event
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 CERN
*
* 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
*/
#include <fctsys.h>
#include <class_drawpanel.h>
#include <pl_editor_id.h>
#include <pl_editor_frame.h>
#include <design_tree_frame.h>
#include <properties_frame.h>
#include <menus_helpers.h>
#include <worksheet_shape_builder.h>
#include <worksheet_dataitem.h>
#include <hotkeys.h>
#include <kicad_device_context.h>
// Helper function to add menuitems relative to items creation
void AddNewItemsCommand( wxMenu* aMainMenu )
{
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_LINE, _( "Add Line..." ),
KiBitmap( add_dashed_line_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_RECT, _( "Add Rectangle..." ),
KiBitmap( add_rectangle_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_TEXT, _( "Add Text..." ),
KiBitmap( text_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_ADD_BITMAP, _( "Add Bitmap..." ),
KiBitmap( image_xpm ) );
AddMenuItem( aMainMenu, ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
_( "Append Existing Page Layout Design File..." ),
KiBitmap( pagelayout_load_xpm ) );
}
/* Prepare the right-click pullup menu.
* The menu already has a list of zoom commands.
*/
bool PL_EDITOR_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* aPopMenu )
{
bool busy = GetScreen()->GetCurItem() != NULL;
bool blockActive = GetScreen()->IsBlockActive();
wxString msg;
if( blockActive )
{
AddMenuItem( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ),
KiBitmap( cancel_xpm ) );
aPopMenu->AppendSeparator();
return true;
}
// If the tool ID_ZOOM_SELECTION is currently in use, add a close command menu
if( GetToolId() == ID_ZOOM_SELECTION && !busy )
{
AddMenuItem( aPopMenu, ID_POPUP_CLOSE_CURRENT_TOOL, _( "End Tool" ),
KiBitmap( cursor_xpm ) );
aPopMenu->AppendSeparator();
}
if( ! busy ) // No item currently edited
{
INSTALL_UNBUFFERED_DC( dc, m_canvas );
WORKSHEET_DATAITEM* old_item = m_treePagelayout->GetPageLayoutSelectedItem();
WORKSHEET_DATAITEM* item = Locate( &dc, aPosition );
if( item && old_item != item )
{
m_treePagelayout->SelectCell( item );
m_canvas->Refresh();
}
// Add menus to edit and delete the item
if( item )
{
if( (item->GetFlags() & LOCATE_STARTPOINT) )
{
msg = AddHotkeyName( _( "Move Start Point" ), PlEditorHotkeysDescr,
HK_MOVE_START_POINT );
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE_START_POINT, msg,
KiBitmap( move_xpm ) );
}
if( (item->GetFlags() & LOCATE_ENDPOINT ) )
{
msg = AddHotkeyName( _( "Move End Point" ), PlEditorHotkeysDescr,
HK_MOVE_END_POINT );
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE_END_POINT, msg,
KiBitmap( move_xpm ) );
}
msg = AddHotkeyName( _( "Move Item" ), PlEditorHotkeysDescr, HK_MOVE_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_ITEM_MOVE, msg, KiBitmap( move_xpm ) );
aPopMenu->AppendSeparator();
msg = AddHotkeyName( _( "Delete" ), PlEditorHotkeysDescr, HK_DELETE_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_ITEM_DELETE, msg, KiBitmap( delete_xpm ) );
aPopMenu->AppendSeparator();
}
}
else // An item is currently in edit
{
msg = AddHotkeyName( _( "Place Item" ), PlEditorHotkeysDescr, HK_PLACE_ITEM );
AddMenuItem( aPopMenu, ID_POPUP_ITEM_PLACE, msg, KiBitmap( move_xpm ) );
AddMenuItem( aPopMenu, ID_POPUP_ITEM_PLACE_CANCEL, _( "Cancel" ), KiBitmap( cancel_xpm ) );
aPopMenu->AppendSeparator();
}
if( ! busy )
{
AddNewItemsCommand( aPopMenu );
aPopMenu->AppendSeparator();
}
return true;
}

View File

@ -31,8 +31,8 @@
#include <fctsys.h>
#include <base_struct.h>
#include <worksheet.h>
#include <worksheet_shape_builder.h>
#include <worksheet_painter.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <math/vector2d.h>
#include <page_layout_reader_lexer.h>
@ -240,7 +240,7 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_TEXT* aItem, int aNestLevel
bool write_size = aItem->m_TextSize.x != 0.0 || aItem->m_TextSize.y != 0.0;
bool write_thickness = aItem->m_LineWidth != 0.0;
if( write_thickness || write_size || aItem->IsBold() || aItem->IsItalic() )
if( write_thickness || write_size || aItem->m_Bold || aItem->m_Italic )
{
m_out->Print( 0, " (%s", getTokenName( T_font ) );
@ -256,10 +256,10 @@ void WORKSHEET_LAYOUT_IO::format( WORKSHEET_DATAITEM_TEXT* aItem, int aNestLevel
double2Str(aItem->m_TextSize.x ).c_str(),
double2Str(aItem->m_TextSize.y ).c_str() );
}
if( aItem->IsBold() )
if( aItem->m_Bold )
m_out->Print( 0, " %s", getTokenName( T_bold ) );
if( aItem->IsItalic() )
if( aItem->m_Italic )
m_out->Print( 0, " %s", getTokenName( T_italic ) );
m_out->Print( 0, ")" );
@ -453,19 +453,8 @@ void WORKSHEET_LAYOUT_IO::formatRepeatParameters( WORKSHEET_DATAITEM* aItem ) co
void WORKSHEET_LAYOUT_IO::formatOptions( WORKSHEET_DATAITEM* aItem ) const
{
switch( aItem->GetPage1Option() )
{
default:
case 0:
break;
case 1:
m_out->Print( 0, " (%s %s)", getTokenName( T_option ),
getTokenName(T_page1only ) );
break;
case -1:
m_out->Print( 0, " (%s %s)", getTokenName( T_option ), getTokenName( T_notonpage1 ) );
break;
}
if( aItem->GetPage1Option() == FIRST_PAGE_ONLY )
m_out->Print( 0, " (%s %s)", getTokenName( T_option ), getTokenName(T_page1only ) );
else if( aItem->GetPage1Option() == SUBSEQUENT_PAGES )
m_out->Print( 0, " (%s %s)", getTokenName( T_option ), getTokenName( T_notonpage1 ) );
}

View File

@ -0,0 +1,120 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "pl_draw_panel_gal.h"
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tools/pl_actions.h>
#include <view/wx_view_controls.h>
#include <worksheet_viewitem.h>
#include <worksheet_dataitem.h>
#include <worksheet_painter.h>
#include <colors_design_settings.h>
#include <pl_editor_frame.h>
#include <gal/graphics_abstraction_layer.h>
#include <functional>
using namespace std::placeholders;
PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize,
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType )
{
m_view = new KIGFX::VIEW( true );
m_view->SetGAL( m_gal );
GetGAL()->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ );
m_painter.reset( new KIGFX::WORKSHEET_PAINTER( m_gal ) );
m_view->SetPainter( m_painter.get() );
setDefaultLayerDeps();
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
}
PL_DRAW_PANEL_GAL::~PL_DRAW_PANEL_GAL()
{
}
void PL_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector<MSG_PANEL_ITEM>& aList )
{
}
void PL_DRAW_PANEL_GAL::DisplayWorksheet()
{
m_edaFrame->GetToolManager()->RunAction( PL_ACTIONS::clearSelection, true );
m_view->Clear();
WS_DRAW_ITEM_LIST::SetupDrawEnvironment( m_edaFrame->GetPageSettings() );
for( WORKSHEET_DATAITEM* dataItem : WORKSHEET_LAYOUT::GetTheInstance().GetItems() )
dataItem->SyncDrawItems( nullptr, m_view );
}
bool PL_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
{
bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
// The next onPaint event will call m_view->UpdateItems() that is very time consumming
// after switching to opengl. Clearing m_view and rebuild it is much faster
if( aGalType == GAL_TYPE_OPENGL )
m_view->Clear();
setDefaultLayerDeps();
GetGAL()->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ );
return rv;
}
void PL_DRAW_PANEL_GAL::setDefaultLayerDeps()
{
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
m_view->SetLayerTarget( i, KIGFX::TARGET_NONCACHED );
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET );
m_view->SetLayerTarget( LAYER_SELECT_OVERLAY, KIGFX::TARGET_OVERLAY );
m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY );
m_view->SetLayerTarget( LAYER_GP_OVERLAY, KIGFX::TARGET_OVERLAY );
m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY );
}
void PL_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
{
m_view->ClearTopLayers();
m_view->SetTopLayer( aLayer );
m_view->SetTopLayer( LAYER_SELECT_OVERLAY );
m_view->SetTopLayer( LAYER_GP_OVERLAY );
m_view->UpdateAllLayersOrder();
}

View File

@ -0,0 +1,56 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PL_DRAW_PANEL_GAL_H
#define PL_DRAW_PANEL_GAL_H
#include <class_draw_panel_gal.h>
#include <worksheet_viewitem.h>
#include <worksheet_painter.h>
class PL_DRAW_PANEL_GAL : public EDA_DRAW_PANEL_GAL
{
public:
PL_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
const wxSize& aSize, KIGFX::GAL_DISPLAY_OPTIONS& aOptions,
GAL_TYPE aGalType = GAL_TYPE_OPENGL );
virtual ~PL_DRAW_PANEL_GAL();
///> @copydoc EDA_DRAW_PANEL_GAL::GetMsgPanelInfo()
void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
void DisplayWorksheet();
bool SwitchBackend( GAL_TYPE aGalType ) override;
///> @copydoc EDA_DRAW_PANEL_GAL::SetTopLayer
virtual void SetTopLayer( int aLayer ) override;
protected:
///> Sets rendering targets & dependencies for layers.
void setDefaultLayerDeps();
///> Currently used worksheet
std::unique_ptr<KIGFX::WORKSHEET_VIEWITEM> m_worksheet;
};
#endif /* PL_DRAW_PANEL_GAL_H */

View File

@ -31,7 +31,7 @@
#include <kiface_i.h>
#include <confirm.h>
#include <gestfich.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <pl_editor_frame.h>
#include <hotkeys.h>
@ -132,71 +132,3 @@ void IFACE::OnKifaceEnd()
{
end_common();
}
#if 0
bool MYFACE::OnKifaceStart( PGM_BASE* aProgram )
{
wxFileName fn;
InitEDA_Appl( wxT( "pl_editor" ), APP_PL_EDITOR_T );
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if( !IsOK( NULL, _( "pl_editor is already running. Continue?" ) ) )
return false;
}
// read current setup and reopen last directory if no filename to open in
// command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings( reopenLastUsedDirectory );
// Must be called before creating the main frame in order to
// display the real hotkeys in menus or tool tips
ReadHotkeyConfig( PL_EDITOR_FRAME_NAME, s_PlEditor_Hotkeys_Descr );
PL_EDITOR_FRAME * frame = new PL_EDITOR_FRAME( NULL, wxT( "PlEditorFrame" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
// frame title:
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
SetTopWindow( frame );
frame->Show( true );
frame->Zoom_Automatique( true ); // Zoom fit in frame
frame->GetScreen()->m_FirstRedraw = false;
bool descrLoaded = false;
if( argc > 1 )
{
fn = argv[1];
if( fn.IsOk() )
{
bool success = frame->LoadPageLayoutDescrFile( fn.GetFullPath() );
if( !success )
{
wxString msg;
msg.Printf( _("Error when loading file \"%s\""),
fn.GetFullPath().GetData() );
wxMessageBox( msg );
}
else
{
descrLoaded = true;
frame->OnNewPageLayout();
}
}
}
if( !descrLoaded )
{
WORKSHEET_LAYOUT::GetTheInstance().SetPageLayout();
frame->OnNewPageLayout();
}
return true;
}
#endif

View File

@ -47,24 +47,6 @@ void PL_EDITOR_FRAME::Process_Config( wxCommandEvent& event )
switch( id )
{
case ID_MENU_SWITCH_BGCOLOR:
if( GetDrawBgColor() == WHITE )
SetDrawBgColor( BLACK );
else
SetDrawBgColor( WHITE );
GetMenuBar()->SetLabel( ID_MENU_SWITCH_BGCOLOR,
GetDrawBgColor() == WHITE ? _( "&Background Black" ) : _( "&Background White" ) );
m_canvas->Refresh();
break;
case ID_MENU_GRID_ONOFF:
SetGridVisibility( ! IsGridVisible() );
GetMenuBar()->SetLabel( ID_MENU_GRID_ONOFF,
IsGridVisible() ? _( "Hide &Grid" ) : _( "Show &Grid" ) );
m_canvas->Refresh();
break;
case wxID_PREFERENCES:
ShowPreferences( PlEditorHotkeysDescr, PlEditorHotkeysDescr, wxT( "pl_editor" ) );
break;

View File

@ -23,36 +23,40 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pl_editor_frame.cpp
*/
#include <fctsys.h>
#include <kiface_i.h>
#include <class_drawpanel.h>
#include <build_version.h>
#include <macros.h>
#include <base_units.h>
#include <msgpanel.h>
#include <bitmaps.h>
#include <eda_dockart.h>
#include <pl_editor_frame.h>
#include <pl_editor_id.h>
#include <pl_draw_panel_gal.cpp>
#include <hotkeys.h>
#include <pl_editor_screen.h>
#include <worksheet_shape_builder.h>
#include <ws_draw_item.h>
#include <worksheet_dataitem.h>
#include <design_tree_frame.h>
#include <properties_frame.h>
#include <view/view.h>
#include <wildcards_and_files_ext.h>
#include <confirm.h>
#include <tool/selection.h>
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <tool/common_tools.h>
#include <tool/zoom_tool.h>
#include <tools/pl_actions.h>
#include <tools/pl_selection_tool.h>
#include <tools/pl_drawing_tools.h>
#include <tools/pl_edit_tool.h>
#include <tools/pl_point_editor.h>
#include <tools/pl_picker_tool.h>
PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
{
m_UserUnits = MILLIMETRES;
m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
@ -63,35 +67,47 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_showAxis = false; // true to show X and Y axis on screen
m_showGridAxis = true;
m_showBorderAndTitleBlock = true; // true for reference drawings.
m_hotkeysDescrList = PlEditorHotkeysDescr;
m_hotkeysDescrList = PlEditorHotkeysDescr;
m_originSelectChoice = 0;
SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
WORKSHEET_DATAITEM::m_SpecialMode = true;
SetShowPageLimits( true );
m_AboutTitle = "PlEditor";
m_designTreeWidth = 150;
m_propertiesFrameWidth = 200;
if( m_canvas )
m_canvas->SetEnableBlockCommands( true );
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
SetIcon( icon );
wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
// Create GAL canvas
#ifdef __WXMAC__
// Cairo renderer doesn't handle Retina displays
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
#else
m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
#endif
auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
GetGalDisplayOptions(), m_canvasType );
SetGalCanvas( drawPanel );
LoadSettings( config() );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( ! GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1MM - ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
setupTools();
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
wxWindow* stsbar = GetStatusBar();
int dims[] = {
@ -124,19 +140,22 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
m_propertiesPagelayout = new PROPERTIES_FRAME( this );
m_treePagelayout = new DESIGN_TREE_FRAME( this );
// Horizontal items; layers 4 - 6
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
m_auimgr.AddPane( m_treePagelayout, EDA_PANE().Palette().Name( "Design" ).Left().Layer(1)
.Caption( _( "Design" ) ).MinSize( m_treePagelayout->GetMinSize() )
.BestSize( m_designTreeWidth, -1 ) );
m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" ).Right().Layer(1)
// Vertical items; layers 1 - 3
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" ).Right().Layer(2)
.Caption( _( "Properties" ) ).MinSize( m_propertiesPagelayout->GetMinSize() )
.BestSize( m_propertiesFrameWidth, -1 ) );
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
UseGalCanvas( true );
m_auimgr.Update();
@ -152,8 +171,29 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
}
PL_EDITOR_FRAME::~PL_EDITOR_FRAME()
void PL_EDITOR_FRAME::setupTools()
{
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( nullptr, GetGalCanvas()->GetView(),
GetGalCanvas()->GetViewControls(), this );
m_actions = new PL_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
// Register tools
m_toolManager->RegisterTool( new COMMON_TOOLS );
m_toolManager->RegisterTool( new ZOOM_TOOL );
m_toolManager->RegisterTool( new PL_SELECTION_TOOL );
m_toolManager->RegisterTool( new PL_DRAWING_TOOLS );
m_toolManager->RegisterTool( new PL_EDIT_TOOL );
m_toolManager->RegisterTool( new PL_POINT_EDITOR );
m_toolManager->RegisterTool( new PL_PICKER_TOOL );
m_toolManager->InitTools();
// Run the selection tool, it is supposed to be always active
m_toolManager->InvokeTool( "plEditor.InteractiveSelection" );
}
@ -163,12 +203,7 @@ bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, i
if( !LoadPageLayoutDescrFile( fn ) )
{
wxString msg = wxString::Format(
_( "Error when loading file \"%s\"" ),
GetChars( fn )
);
wxMessageBox( msg );
wxMessageBox( wxString::Format( _( "Error when loading file \"%s\"" ), fn ) );
return false;
}
else
@ -205,11 +240,18 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
const BOX2I PL_EDITOR_FRAME::GetDocumentExtents() const
{
BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU() );
return rv;
}
double PL_EDITOR_FRAME::BestZoom()
{
double sizeX = (double) GetPageLayout().GetPageSettings().GetWidthIU();
double sizeY = (double) GetPageLayout().GetPageSettings().GetHeightIU();
wxPoint centre( sizeX / 2, sizeY / 2 );
wxPoint centre( KiROUND( sizeX / 2 ), KiROUND( sizeY / 2 ) );
// The sheet boundary already affords us some margin, so add only an
// additional 5%.
@ -219,7 +261,6 @@ double PL_EDITOR_FRAME::BestZoom()
}
static const wxChar designTreeWidthKey[] = wxT( "DesignTreeWidth" );
static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" );
static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" );
static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
@ -229,7 +270,6 @@ void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
aCfg->Read( propertiesFrameWidthKey, &m_propertiesFrameWidth, 150);
aCfg->Read( cornerOriginChoiceKey, &m_originSelectChoice );
bool tmp;
@ -242,10 +282,8 @@ void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
{
EDA_DRAW_FRAME::SaveSettings( aCfg );
m_designTreeWidth = m_treePagelayout->GetSize().x;
m_propertiesFrameWidth = m_propertiesPagelayout->GetSize().x;
aCfg->Write( designTreeWidthKey, m_designTreeWidth);
aCfg->Write( propertiesFrameWidthKey, m_propertiesFrameWidth);
aCfg->Write( cornerOriginChoiceKey, m_originSelectChoice );
aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
@ -377,29 +415,18 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
switch( GetUserUnits() )
{
case INCHES: // Should not be used in page layout editor
SetStatusText( _("inches"), 5 );
break;
case MILLIMETRES:
SetStatusText( _("mm"), 5 );
break;
case UNSCALED_UNITS:
SetStatusText( wxEmptyString, 5 );
break;
case DEGREES:
wxASSERT( false );
break;
case INCHES: SetStatusText( _("inches"), 5 ); break;
case MILLIMETRES: SetStatusText( _("mm"), 5 ); break;
case UNSCALED_UNITS: SetStatusText( wxEmptyString, 5 ); break;
case DEGREES: wxASSERT( false ); break;
}
wxString line;
// Display page size
#define milsTomm (25.4/1000)
#define MILS_TO_MM (25.4/1000)
DSIZE size = GetPageSettings().GetSizeMils();
size = size * milsTomm;
size = size * MILS_TO_MM;
line.Printf( pagesizeformatter, size.x, size.y );
SetStatusText( line, 0 );
@ -424,8 +451,7 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
}
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void * aData )
void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET , bool , void * )
{
GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
@ -434,7 +460,7 @@ void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
{
// JEY TODO: probably obsolete unless called for print....
GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
if( aEraseBg )
@ -442,26 +468,18 @@ void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
m_canvas->DrawBackGround( aDC );
const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
WS_DRAW_ITEM_LIST& drawList = GetPageLayout().GetDrawItems();
// the color to draw selected items
if( GetDrawBgColor() == WHITE )
WORKSHEET_DATAITEM::m_SelectedColor = DARKCYAN;
else
WORKSHEET_DATAITEM::m_SelectedColor = YELLOW;
drawList.SetDefaultPenSize( 0 );
drawList.SetMilsToIUfactor( IU_PER_MILS );
drawList.SetSheetNumber( GetScreen()->m_ScreenNumber );
drawList.SetSheetCount( GetScreen()->m_NumberOfScreens );
drawList.SetFileName( GetCurrFileName() );
drawList.SetSheetName( GetScreenDesc() );
drawList.SetSheetLayer( wxEmptyString );
for( unsigned ii = 0; ; ii++ )
{
WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
if( item == NULL )
break;
item->SetSelected( item == selecteditem );
}
DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, GetCurrFileName() );
// Draw item list
drawList.Draw( m_canvas->GetClipBox(), aDC, DARKMAGENTA );
#ifdef USE_WX_OVERLAY
if( IsShown() )
@ -482,52 +500,15 @@ void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
}
void PL_EDITOR_FRAME::RebuildDesignTree()
void PL_EDITOR_FRAME::HardRedraw()
{
const WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
int rectId = 0;
int lineId = 0;
int textId = 0;
int polyId = 0;
int bitmapId = 0;
for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
{
WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
switch( item->GetType() )
{
case WORKSHEET_DATAITEM::WS_TEXT:
item->m_Name = wxString::Format( wxT( "text%d:%s" ), ++textId,
GetChars(item->GetClassName()) );
break;
case WORKSHEET_DATAITEM:: WS_SEGMENT:
item->m_Name = wxString::Format( wxT( "segm%d:%s" ), ++lineId,
GetChars(item->GetClassName()) );
break;
case WORKSHEET_DATAITEM::WS_RECT:
item->m_Name = wxString::Format( wxT( "rect%d:%s" ), ++rectId,
GetChars(item->GetClassName()) );
break;
case WORKSHEET_DATAITEM::WS_POLYPOLYGON:
item->m_Name = wxString::Format( wxT( "poly%d:%s" ), ++polyId,
GetChars(item->GetClassName()) );
break;
case WORKSHEET_DATAITEM::WS_BITMAP:
item->m_Name = wxString::Format( wxT( "bm%d:%s" ), ++bitmapId,
GetChars(item->GetClassName()) );
break;
}
}
m_treePagelayout->ReCreateDesignTree();
static_cast<PL_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayWorksheet();
m_propertiesPagelayout->CopyPrmsFromGeneralToPanel();
m_canvas->Refresh();
}
WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
WORKSHEET_DATAITEM* PL_EDITOR_FRAME::AddPageLayoutItem( int aType )
{
WORKSHEET_DATAITEM * item = NULL;
@ -552,8 +533,7 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
case WORKSHEET_DATAITEM::WS_BITMAP:
{
wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
_( "Image Files " ) + wxImage::GetImageExtWildcard(),
wxFD_OPEN );
_( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN );
if( fileDlg.ShowModal() != wxID_OK )
return NULL;
@ -562,7 +542,7 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
if( !wxFileExists( fullFilename ) )
{
wxMessageBox( _( "Couldn't load image from \"%s\"" ), GetChars( fullFilename ) );
wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
break;
}
@ -570,8 +550,7 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
if( !image->ReadImageFile( fullFilename ) )
{
wxMessageBox( _( "Couldn't load image from \"%s\"" ),
GetChars( fullFilename ) );
wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
delete image;
break;
}
@ -584,102 +563,8 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::AddPageLayoutItem( int aType, int aIdx )
if( item == NULL )
return NULL;
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
pglayout.Insert( item, aIdx );
RebuildDesignTree();
return item;
}
WORKSHEET_DATAITEM * PL_EDITOR_FRAME::GetSelectedItem()
{
WORKSHEET_DATAITEM* item = m_treePagelayout->GetPageLayoutSelectedItem();
return item;
}
WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( wxDC* aDC, const wxPoint& aPosition )
{
const PAGE_INFO& pageInfo = GetPageSettings();
TITLE_BLOCK t_block = GetTitleBlock();
COLOR4D color = COLOR4D( RED ); // Needed, not used
PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
WS_DRAW_ITEM_LIST drawList;
drawList.SetPenSize( 0 );
drawList.SetMilsToIUfactor( IU_PER_MILS );
drawList.SetSheetNumber( screen->m_ScreenNumber );
drawList.SetSheetCount( screen->m_NumberOfScreens );
drawList.SetFileName( GetCurrFileName() );
// GetScreenDesc() returns a temporary string. Store it to avoid issues.
wxString descr = GetScreenDesc();
drawList.SetSheetName( descr );
drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
// locate items.
// We do not use here the COLLECTOR classes in use in pcbnew and eeschema
// because the locate requirements are very basic.
std::vector <WS_DRAW_ITEM_BASE*> list;
drawList.Locate( aDC, list, aPosition );
if( list.size() == 0 )
return NULL;
WS_DRAW_ITEM_BASE* drawitem = list[0];
// Choose item in list if more than 1 item
if( list.size() > 1 )
{
wxArrayString choices;
wxString text;
wxPoint cursPos = GetCrossHairPosition();
for( unsigned ii = 0; ii < list.size(); ++ii )
{
drawitem = list[ii];
text = drawitem->GetParent()->m_Name;
if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
== (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
text << wxT( " " ) << _( "(start or end point)" );
else
{
if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
text << wxT( " " ) << _( "(start point)" );
if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
text << wxT( " " ) << _( "(end point)" );
}
if( ! drawitem->GetParent()->m_Info.IsEmpty() )
text << wxT( " \"" ) << drawitem->GetParent()->m_Info << wxT( "\"" );
choices.Add( text );
}
int selection = wxGetSingleChoiceIndex ( wxEmptyString,
_( "Selection Clarification" ),
choices, this );
if( selection < 0 )
return NULL;
SetCrossHairPosition( cursPos );
m_canvas->MoveCursorToCrossHair();
drawitem = list[selection];
}
WORKSHEET_DATAITEM* item = drawitem->GetParent();
item->ClearFlags( LOCATE_STARTPOINT|LOCATE_ENDPOINT );
if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
item->SetFlags( LOCATE_STARTPOINT );
if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
item->SetFlags( LOCATE_ENDPOINT );
WORKSHEET_LAYOUT::GetTheInstance().Append( item );
item->SyncDrawItems( nullptr, GetGalCanvas()->GetView() );
return item;
}
@ -689,9 +574,11 @@ void PL_EDITOR_FRAME::OnNewPageLayout()
{
GetScreen()->ClearUndoRedoList();
GetScreen()->ClrModify();
static_cast<PL_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayWorksheet();
m_propertiesPagelayout->CopyPrmsFromGeneralToPanel();
RebuildDesignTree();
Zoom_Automatique( false );
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
m_canvas->Refresh();
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2019 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
*
* This program is free software; you can redistribute it and/or
@ -23,10 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pl_editor_frame.h
*/
#ifndef _PL_EDITOR_FRAME_H
#define _PL_EDITOR_FRAME_H
@ -38,7 +34,6 @@
#include <pl_editor_layout.h>
class PROPERTIES_FRAME;
class DESIGN_TREE_FRAME;
class WORKSHEET_DATAITEM;
@ -51,7 +46,6 @@ class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
{
PL_EDITOR_LAYOUT m_pageLayout;
int m_designTreeWidth; // the last width (in pixels) of m_treePagelayout
int m_propertiesFrameWidth; // the last width (in pixels) of m_propertiesPagelayout
wxChoice* m_originSelectBox; // Corner origin choice for coordinates
@ -65,7 +59,6 @@ class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
protected:
/// The last filename chosen to be proposed to the user
wxString m_lastFileName;
DESIGN_TREE_FRAME* m_treePagelayout;
PROPERTIES_FRAME* m_propertiesPagelayout;
private:
@ -74,7 +67,9 @@ private:
public:
PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
~PL_EDITOR_FRAME();
~PL_EDITOR_FRAME() {}
PROPERTIES_FRAME* GetPropertiesFrame() { return m_propertiesPagelayout; }
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) override;
@ -102,6 +97,9 @@ public:
void OnCloseWindow( wxCloseEvent& Event );
// The Tool Framework initalization
void setupTools();
// Virtual basic functions:
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
void ReCreateHToolbar() override;
@ -163,17 +161,14 @@ public:
void ReCreateOptToolbar();
void ReCreateMenuBar() override;
void OnLeftClick( wxDC* aDC, const wxPoint& aMousePos ) override;
void OnLeftDClick( wxDC* aDC, const wxPoint& aMousePos ) override;
bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) override;
double BestZoom() override;
// Events created by clicking on the design tree list:
void OnTreeSelection( wxTreeEvent& event );
void OnTreeMiddleClick( wxTreeEvent& event );
void OnTreeRightClick( wxTreeEvent& event );
void SyncMenusAndToolbars() override;
const PL_EDITOR_LAYOUT& GetPageLayout() const { return m_pageLayout; }
PL_EDITOR_LAYOUT& GetPageLayout() { return m_pageLayout; }
const BOX2I GetDocumentExtents() const override;
/**
* Page layout editor can show the title block using a page number
@ -192,7 +187,7 @@ public:
* Displays the short filename (if exists) loaded file
* on the caption of the main window
*/
void UpdateTitleAndInfo();
void UpdateTitleAndInfo();
/**
* Populates the applicatios settings list.
@ -202,20 +197,19 @@ public:
* source code (mainly in dialogs). If you need to define a configuration
* setting that need to be loaded at run time, this is the place to define it.
*/
PARAM_CFG_ARRAY& GetConfigurationSettings( void );
PARAM_CFG_ARRAY& GetConfigurationSettings();
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;
void Process_Special_Functions( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
/**
* called when the user select one of the 4 page corner as corner
* reference (or the left top paper corner)
*/
void OnSelectCoordOriginCorner( wxCommandEvent& event );
void OnSelectCoordOriginCorner( wxCommandEvent& event );
/**
* Toggle the display mode between the normal mode and the editor mode:
@ -225,53 +219,16 @@ public:
* In editor mode, the format symbols in texts are not replaced
* by the actual text, and therefore format symbols are displayed.
*/
void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event );
void OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
/**
* Function BlockCommand
* returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the \a aKey (ALT, SHIFT ALT ..)
*/
virtual int BlockCommand( EDA_KEY key ) override;
/**
* Function HandleBlockPlace
* handles the block place command.
*/
virtual void HandleBlockPlace( wxDC* DC ) override;
/**
* Function HandleBlockEnd( )
* handles the end of a block command,
* It is called at the end of the definition of the area of a block.
* Depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
*
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later.
*/
virtual bool HandleBlockEnd( wxDC* DC ) override;
/**
* Function Block_Move
* moves all items within the selected block.
* New location is determined by the current offset from the selected
* block's original location.
*
* @param DC A device context to draw on.
*/
void Block_Move( wxDC* DC );
/**
* Function OnQuit
* called on request of application quit
*/
void OnQuit( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
@ -285,26 +242,26 @@ public:
* @param aPosition The cursor position in logical (drawing) units.
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor
*/
bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ) override;
bool OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL ) override;
void Process_Settings( wxCommandEvent& event );
void Process_Config( wxCommandEvent& event );
void Process_Config( wxCommandEvent& event );
/**
* Function ToPlotter
* Open a dialog frame to create plot and drill files
* relative to the current board
*/
void ToPlotter( wxCommandEvent& event );
void ToPlotter( wxCommandEvent& event );
/**
* Function ToPrinter
* Open a dialog frame to print layers
*/
void ToPrinter( wxCommandEvent& event );
void ToPrinter( wxCommandEvent& event );
void Files_io( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
void Files_io( wxCommandEvent& event );
bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey = 0 ) override;
/** Virtual function PrintPage
* used to print a page
@ -313,8 +270,8 @@ public:
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer,
bool aPrintMirrorMode, void * aData ) override;
virtual void PrintPage( wxDC* aDC, LSET aPrintMasklayer, bool aPrintMirrorMode,
void * aData ) override;
void OnFileHistory( wxCommandEvent& event );
@ -331,11 +288,9 @@ public:
void SetCurrFileName( const wxString& aName );
/**
* Function RebuildDesignTree
* Re creates the design graphic tree list items,
* and ensures each item has an unique name
* Refresh the library tree and redraw the window
*/
void RebuildDesignTree();
void HardRedraw() override;
/**
* Function AddPageLayoutItem
@ -345,32 +300,7 @@ public:
* @param aIdx = the position in list to insert the new item.
* @return a reference to the new item
*/
WORKSHEET_DATAITEM * AddPageLayoutItem( int aType, int aIdx = -1 );
/**
* Function GetSelectedItem
* @return the current selected item, or NULL
*/
WORKSHEET_DATAITEM * GetSelectedItem();
/**
* Function Locate
* @return the page layout item found at position aPosition
* @param aPosition = the position (in user units) of the reference point
*/
WORKSHEET_DATAITEM *Locate( wxDC* aDC, const wxPoint& aPosition );
/**
* Initialize a move item command
* @param aItem is the item to move
*/
void MoveItem( WORKSHEET_DATAITEM* aItem );
/**
* Save in Undo list the layout, and place an item being moved.
* @param aItem is the item moved
*/
void PlaceItem( WORKSHEET_DATAITEM* aItem );
WORKSHEET_DATAITEM* AddPageLayoutItem( int aType );
/**
* Must be called after a change
@ -391,19 +321,19 @@ public:
* - Place the current edited layout in undo list
* - Get the previous version of the current edited layput
*/
void GetLayoutFromRedoList( wxCommandEvent& event );
void GetLayoutFromRedoList();
/** Undo the last edit:
* - Place the current layout in Redo list
* - Get the previous version of the current edited layout
*/
void GetLayoutFromUndoList( wxCommandEvent& event );
void GetLayoutFromUndoList();
/**
* Remove the last command in Undo List.
* Used to clean the Undo stack after a cancel command
*/
void RemoveLastCommandInUndoList();
void RollbackFromUndo();
protected:
bool saveCurrentPageLayout();

View File

@ -45,8 +45,6 @@ enum pl_editor_ids
ID_PL_EDITOR_SHOW_SOURCE,
ID_MENU_PL_EDITOR_SELECT_PREFERED_EDITOR,
ID_MENU_SWITCH_BGCOLOR,
ID_MENU_GRID_ONOFF,
ID_DESIGN_TREE_FRAME,
ID_SHOW_REAL_MODE,
@ -56,13 +54,16 @@ enum pl_editor_ids
ID_APPEND_DESCR_FILE,
ID_PL_MOVE_TOOL,
ID_PL_LINE_TOOL,
ID_PL_RECTANGLE_TOOL,
ID_PL_TEXT_TOOL,
ID_PL_IMAGE_TOOL,
ID_PL_DELETE_TOOL,
ID_POPUP_START_RANGE,
ID_POPUP_ITEM_DELETE,
ID_POPUP_DESIGN_TREE_ITEM_DELETE,
ID_POPUP_ITEM_ADD_LINE,
ID_POPUP_ITEM_ADD_RECT,
ID_POPUP_ITEM_ADD_TEXT,
ID_POPUP_ITEM_ADD_BITMAP,
ID_POPUP_ITEM_APPEND_PAGE_LAYOUT,
ID_POPUP_ITEM_MOVE,
ID_POPUP_ITEM_PLACE,

View File

@ -31,13 +31,13 @@
#include <base_struct.h>
#include <page_info.h>
#include <title_block.h>
#include <ws_draw_item.h>
class EDA_DRAW_PANEL;
/**
* Class PL_EDITOR_LAYOUT
* holds list of GERBER_DRAW_ITEM currently loaded.
*/
class PL_EDITOR_LAYOUT
{
@ -46,6 +46,8 @@ private:
PAGE_INFO m_paper;
TITLE_BLOCK m_titles;
WS_DRAW_ITEM_LIST m_drawItemList;
public:
PL_EDITOR_LAYOUT();
~PL_EDITOR_LAYOUT();
@ -56,7 +58,7 @@ public:
m_paper = aPageSettings;
}
const wxPoint& GetAuxOrigin() const
const wxPoint& GetAuxOrigin() const
{
static wxPoint zero( 0, 0 );
return zero;
@ -67,6 +69,11 @@ public:
return m_titles;
}
WS_DRAW_ITEM_LIST& GetDrawItems()
{
return m_drawItemList;
}
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
{
m_titles = aTitleBlock;
@ -90,7 +97,6 @@ public:
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const;
#endif
};

Some files were not shown because too many files have changed in this diff Show More