eeschema-gal: initial GALified version. Lots of stuff still to do!
This commit is contained in:
parent
14fed877c8
commit
90c7c60471
|
@ -11,9 +11,12 @@ endif()
|
|||
|
||||
include_directories( BEFORE ${INC_BEFORE} )
|
||||
include_directories(
|
||||
../include/legacy_gal
|
||||
./dialogs
|
||||
./netlist_exporters
|
||||
./widgets
|
||||
./libedit
|
||||
./libview
|
||||
../common
|
||||
../common/dialogs
|
||||
${INC_AFTER}
|
||||
|
@ -92,14 +95,35 @@ set( EESCHEMA_WIDGETS
|
|||
)
|
||||
|
||||
|
||||
set ( EESCHEMA_LIBEDIT_SRCS
|
||||
libedit/block_libedit.cpp
|
||||
libedit/controller.cpp
|
||||
libedit/libedit.cpp
|
||||
libedit/libedit_onleftclick.cpp
|
||||
libedit/libedit_onrightclick.cpp
|
||||
libedit/libedit_plot_component.cpp
|
||||
libedit/libedit_undo_redo.cpp
|
||||
libedit/lib_edit_frame.cpp
|
||||
libedit/libfield.cpp
|
||||
libedit/menubar_libedit.cpp
|
||||
libedit/pinedit.cpp
|
||||
libedit/symbdraw.cpp
|
||||
libedit/symbedit.cpp
|
||||
libedit/tool_lib.cpp
|
||||
libedit/lib_export.cpp
|
||||
libedit/lib_manager.cpp
|
||||
|
||||
)
|
||||
set( EESCHEMA_SRCS
|
||||
${EESCHEMA_DLGS}
|
||||
${EESCHEMA_WIDGETS}
|
||||
${EESCHEMA_LIBEDIT_SRCS}
|
||||
sch_view.cpp
|
||||
sch_painter.cpp
|
||||
annotate.cpp
|
||||
autoplace_fields.cpp
|
||||
backanno.cpp
|
||||
block.cpp
|
||||
block_libedit.cpp
|
||||
bus-wire-junction.cpp
|
||||
busentry.cpp
|
||||
class_libentry.cpp
|
||||
|
@ -131,23 +155,13 @@ set( EESCHEMA_SRCS
|
|||
lib_circle.cpp
|
||||
lib_collectors.cpp
|
||||
lib_draw_item.cpp
|
||||
lib_export.cpp
|
||||
lib_field.cpp
|
||||
lib_manager.cpp
|
||||
lib_pin.cpp
|
||||
lib_polyline.cpp
|
||||
lib_rectangle.cpp
|
||||
lib_text.cpp
|
||||
libarch.cpp
|
||||
libedit.cpp
|
||||
libedit_onleftclick.cpp
|
||||
libedit_onrightclick.cpp
|
||||
libedit_plot_component.cpp
|
||||
libedit_undo_redo.cpp
|
||||
lib_edit_frame.cpp
|
||||
libfield.cpp
|
||||
menubar.cpp
|
||||
menubar_libedit.cpp
|
||||
netlist_generator.cpp
|
||||
netlist_object_list.cpp
|
||||
netlist_object.cpp
|
||||
|
@ -157,12 +171,12 @@ set( EESCHEMA_SRCS
|
|||
pin_number.cpp
|
||||
pin_shape.cpp
|
||||
pin_type.cpp
|
||||
pinedit.cpp
|
||||
plot_schematic_DXF.cpp
|
||||
plot_schematic_HPGL.cpp
|
||||
plot_schematic_PDF.cpp
|
||||
plot_schematic_PS.cpp
|
||||
plot_schematic_SVG.cpp
|
||||
sch_draw_panel.cpp
|
||||
project_rescue.cpp
|
||||
sch_base_frame.cpp
|
||||
sch_bitmap.cpp
|
||||
|
@ -191,14 +205,11 @@ set( EESCHEMA_SRCS
|
|||
selpart.cpp
|
||||
sheet.cpp
|
||||
sheetlab.cpp
|
||||
symbdraw.cpp
|
||||
symbedit.cpp
|
||||
symbol_lib_table.cpp
|
||||
symbol_tree_model_adapter.cpp
|
||||
symbol_tree_synchronizing_adapter.cpp
|
||||
template_fieldnames.cpp
|
||||
template_fieldnames_keywords.cpp
|
||||
tool_lib.cpp
|
||||
tool_sch.cpp
|
||||
tool_viewlib.cpp
|
||||
transform.cpp
|
||||
|
@ -299,6 +310,19 @@ target_link_libraries( eeschema
|
|||
common
|
||||
bitmaps
|
||||
gal
|
||||
legacy_gal
|
||||
common
|
||||
bitmaps
|
||||
gal
|
||||
legacy_gal
|
||||
common
|
||||
bitmaps
|
||||
gal
|
||||
legacy_gal
|
||||
common
|
||||
bitmaps
|
||||
gal
|
||||
legacy_gal
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
|
||||
|
@ -312,6 +336,22 @@ target_link_libraries( eeschema_kiface
|
|||
bitmaps
|
||||
polygon
|
||||
gal
|
||||
legacy_gal
|
||||
common
|
||||
bitmaps
|
||||
polygon
|
||||
gal
|
||||
legacy_gal
|
||||
common
|
||||
bitmaps
|
||||
polygon
|
||||
gal
|
||||
legacy_gal
|
||||
common
|
||||
bitmaps
|
||||
polygon
|
||||
gal
|
||||
legacy_gal
|
||||
${wxWidgets_LIBRARIES}
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <reporter.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -236,7 +236,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
|
|||
m_CurrentSheet->UpdateAllScreenReferences();
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
m_canvas->Refresh( true );
|
||||
SyncView();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include <sch_component.h>
|
||||
#include <sch_line.h>
|
||||
#include <lib_pin.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <class_libentry.h>
|
||||
#include <eeschema_config.h>
|
||||
#include <kiface_i.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
|
@ -49,6 +49,10 @@
|
|||
#include <sch_sheet_path.h>
|
||||
#include <list_operations.h>
|
||||
|
||||
#include <preview_items/selection_area.h>
|
||||
#include <sch_view.h>
|
||||
#include <view/view_group.h>
|
||||
|
||||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
||||
const wxPoint& aPosition, bool aErase );
|
||||
|
||||
|
@ -176,7 +180,9 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
}
|
||||
|
||||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
|
||||
m_canvas->Refresh();
|
||||
|
||||
GetCanvas()->GetView()->ClearPreview();
|
||||
GetCanvas()->GetView()->ClearHiddenFlags();
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,6 +193,14 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
bool append = false;
|
||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||
|
||||
|
||||
auto panel =static_cast<SCH_DRAW_PANEL*>(m_canvas);
|
||||
auto view = panel->GetView();
|
||||
auto area = view->GetSelectionArea();
|
||||
|
||||
view->ShowSelectionArea( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
if( block->GetCount() )
|
||||
{
|
||||
BLOCK_STATE_T state = block->GetState();
|
||||
|
@ -374,7 +388,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
if( block->GetCommand() == BLOCK_ABORT )
|
||||
{
|
||||
GetScreen()->ClearDrawingState();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
if( ! nextcmd )
|
||||
|
@ -389,6 +402,11 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
if( zoom_command )
|
||||
Window_Zoom( GetScreen()->m_BlockLocate );
|
||||
|
||||
view->ShowPreview( false );
|
||||
view->ShowSelectionArea( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
|
||||
return nextcmd;
|
||||
}
|
||||
|
||||
|
@ -399,41 +417,30 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
||||
bool aErase )
|
||||
{
|
||||
auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel);
|
||||
auto view = panel->GetView();
|
||||
|
||||
auto preview = view->GetPreview();
|
||||
|
||||
BASE_SCREEN* screen = aPanel->GetScreen();
|
||||
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
|
||||
SCH_ITEM* schitem;
|
||||
|
||||
/* Erase old block contents. */
|
||||
if( aErase )
|
||||
{
|
||||
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
|
||||
block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
|
||||
|
||||
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
|
||||
{
|
||||
schitem = (SCH_ITEM*) block->GetItem( ii );
|
||||
|
||||
if( schitem->Type() == SCH_COMPONENT_T )
|
||||
((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
|
||||
g_XorMode, g_GhostColor, false );
|
||||
else
|
||||
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
|
||||
}
|
||||
}
|
||||
|
||||
/* Repaint new view. */
|
||||
block->SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
|
||||
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
|
||||
preview->Clear();
|
||||
view->SetVisible( preview, true );
|
||||
|
||||
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
|
||||
{
|
||||
schitem = (SCH_ITEM*) block->GetItem( ii );
|
||||
|
||||
if( schitem->Type() == SCH_COMPONENT_T )
|
||||
((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
|
||||
g_XorMode, g_GhostColor, false );
|
||||
else
|
||||
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
|
||||
SCH_ITEM *copy = static_cast<SCH_ITEM*>( schitem->Clone() );
|
||||
copy->Move( block->GetMoveVector() );
|
||||
preview->Add( copy );
|
||||
view->Hide( schitem );
|
||||
}
|
||||
|
||||
view->Update( preview );
|
||||
}
|
||||
|
||||
|
||||
|
@ -545,8 +552,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
|
|||
}
|
||||
|
||||
SetSchItemParent( item, GetScreen() );
|
||||
item->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
GetScreen()->Append( item );
|
||||
AddToScreen( item );
|
||||
}
|
||||
|
||||
SaveCopyInUndoList( picklist, UR_NEW );
|
||||
|
@ -568,3 +574,36 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
||||
bool aErase )
|
||||
{
|
||||
auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel);
|
||||
auto area = panel->GetView()->GetSelectionArea();
|
||||
auto frame = static_cast<EDA_BASE_FRAME*>(aPanel->GetParent());
|
||||
|
||||
BLOCK_SELECTOR* block;
|
||||
bool isLibEdit = frame->IsType( FRAME_SCH_LIB_EDITOR );
|
||||
|
||||
block = &aPanel->GetScreen()->m_BlockLocate;
|
||||
block->SetMoveVector( wxPoint( 0, 0 ) );
|
||||
block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition( isLibEdit ) );
|
||||
block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
|
||||
|
||||
panel->GetView()->ClearPreview();
|
||||
panel->GetView()->ClearHiddenFlags();
|
||||
|
||||
area->SetOrigin( block->GetOrigin() );;
|
||||
area->SetEnd( block->GetEnd() );
|
||||
|
||||
panel->GetView()->SetVisible( area );
|
||||
panel->GetView()->Hide( area, false );
|
||||
panel->GetView()->Update( area );
|
||||
|
||||
if( block->GetState() == STATE_BLOCK_INIT )
|
||||
{
|
||||
if( block->GetWidth() || block->GetHeight() )
|
||||
// 2nd point exists: the rectangle is not surface anywhere
|
||||
block->SetState( STATE_BLOCK_END );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <lib_draw_item.h>
|
||||
|
@ -42,6 +42,9 @@
|
|||
#include <sch_text.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_view.h>
|
||||
#include <view/view_group.h>
|
||||
|
||||
|
||||
|
||||
static void AbortCreateNewLine( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
|
||||
|
@ -129,17 +132,6 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
segment = (SCH_LINE*) s_wires.begin();
|
||||
COLOR4D color = GetLayerColor( segment->GetLayer() );
|
||||
|
||||
if( aErase )
|
||||
{
|
||||
while( segment )
|
||||
{
|
||||
if( !segment->IsNull() ) // Redraw if segment length != 0
|
||||
segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color );
|
||||
|
||||
segment = segment->Next();
|
||||
}
|
||||
}
|
||||
|
||||
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent();
|
||||
|
||||
wxPoint endpos = frame->GetCrossHairPosition();
|
||||
|
@ -151,13 +143,18 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
|
||||
segment = (SCH_LINE*) s_wires.begin();
|
||||
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>( aPanel )->GetView();
|
||||
|
||||
view->ClearPreview();
|
||||
|
||||
while( segment )
|
||||
{
|
||||
if( !segment->IsNull() ) // Redraw if segment length != 0
|
||||
segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color );
|
||||
view->AddToPreview( segment->Clone() );
|
||||
|
||||
segment = segment->Next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,7 +324,13 @@ void SCH_EDIT_FRAME::EndSegment()
|
|||
SetRepeatItem( segment = (SCH_LINE*) s_wires.GetLast() );
|
||||
|
||||
// Add the new wires
|
||||
screen->Append( s_wires );
|
||||
AddToScreen( s_wires );
|
||||
|
||||
auto view = GetCanvas()->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
SaveCopyInUndoList(itemList, UR_NEW);
|
||||
|
||||
// Correct and remove segments that need to be merged.
|
||||
|
@ -464,7 +467,7 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
|
|||
|
||||
DrawSegment( m_canvas, DC, wxDefaultPosition, false );
|
||||
|
||||
screen->Remove( screen->GetCurItem() );
|
||||
RemoveFromScreen( screen->GetCurItem() );
|
||||
m_canvas->SetMouseCaptureCallback( NULL );
|
||||
screen->SetCurItem( NULL );
|
||||
}
|
||||
|
@ -534,7 +537,7 @@ bool SCH_EDIT_FRAME::TrimWire( const wxPoint& aStart, const wxPoint& aEnd, bool
|
|||
line = return_line;
|
||||
|
||||
SaveCopyInUndoList( (SCH_ITEM*)line, UR_DELETED, aAppend );
|
||||
GetScreen()->Remove( (SCH_ITEM*)line );
|
||||
RemoveFromScreen( (SCH_ITEM*)line );
|
||||
aAppend = true;
|
||||
retval = true;
|
||||
}
|
||||
|
@ -619,7 +622,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend )
|
|||
remove_item( item );
|
||||
remove_item( secondItem );
|
||||
itemList.PushItem( ITEM_PICKER( line, UR_NEW ) );
|
||||
screen->Append( (SCH_ITEM*) line );
|
||||
AddToScreen( (SCH_ITEM*) line );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +637,7 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( bool aAppend )
|
|||
secondItem = item->Next();
|
||||
|
||||
if( item->GetFlags() & STRUCT_DELETED )
|
||||
screen->Remove( item );
|
||||
RemoveFromScreen( item );
|
||||
}
|
||||
|
||||
SaveCopyInUndoList( itemList, UR_CHANGED, aAppend );
|
||||
|
@ -656,7 +659,7 @@ bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const wxPoint& aPoint, bo
|
|||
|
||||
newSegment->SetStartPoint( aPoint );
|
||||
aSegment->SetEndPoint( aPoint );
|
||||
GetScreen()->Append( newSegment );
|
||||
AddToScreen( newSegment );
|
||||
|
||||
if( aNewSegment )
|
||||
*aNewSegment = newSegment;
|
||||
|
@ -719,7 +722,7 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
|
|||
{
|
||||
aItem->SetFlags( STRUCT_DELETED );
|
||||
itemList.PushItem( ITEM_PICKER( aItem, UR_DELETED ) );
|
||||
screen->Remove( aItem );
|
||||
RemoveFromScreen( aItem );
|
||||
};
|
||||
|
||||
remove_item( aJunction );
|
||||
|
@ -756,7 +759,7 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
|
|||
remove_item( item );
|
||||
remove_item( secondItem );
|
||||
itemList.PushItem( ITEM_PICKER( line, UR_NEW ) );
|
||||
screen->Append( (SCH_ITEM*) line );
|
||||
AddToScreen( line );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -770,7 +773,7 @@ void SCH_EDIT_FRAME::DeleteJunction( SCH_ITEM* aJunction, bool aAppend )
|
|||
nextitem = item->Next();
|
||||
|
||||
if( item->GetFlags() & STRUCT_DELETED )
|
||||
screen->Remove( item );
|
||||
RemoveFromScreen( item );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -781,11 +784,17 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( const wxPoint& aPosition, bool aAppen
|
|||
SCH_SCREEN* screen = GetScreen();
|
||||
bool broken_segments = false;
|
||||
|
||||
screen->Append( junction );
|
||||
AddToScreen( junction );
|
||||
broken_segments = BreakSegments( aPosition, aAppend );
|
||||
screen->TestDanglingEnds();
|
||||
OnModify();
|
||||
SaveCopyInUndoList( junction, UR_NEW, broken_segments || aAppend );
|
||||
|
||||
auto view = GetCanvas()->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
return junction;
|
||||
}
|
||||
|
||||
|
@ -795,11 +804,16 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( const wxPoint& aPosition )
|
|||
SCH_NO_CONNECT* no_connect = new SCH_NO_CONNECT( aPosition );
|
||||
|
||||
SetRepeatItem( no_connect );
|
||||
GetScreen()->Append( no_connect );
|
||||
AddToScreen( no_connect );
|
||||
SchematicCleanUp();
|
||||
GetScreen()->TestDanglingEnds();
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
|
||||
auto view = GetCanvas()->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
SaveCopyInUndoList( no_connect, UR_NEW );
|
||||
return no_connect;
|
||||
}
|
||||
|
@ -810,19 +824,23 @@ SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( const wxPoint& aPosition )
|
|||
static void AbortCreateNewLine( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
||||
{
|
||||
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
||||
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent();
|
||||
|
||||
if( screen->GetCurItem() )
|
||||
{
|
||||
s_wires.DeleteAll(); // Free the list, for a future usage
|
||||
screen->SetCurItem( NULL );
|
||||
aPanel->Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent();
|
||||
parent->SetRepeatItem( NULL );
|
||||
}
|
||||
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(aPanel)->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
// Clear flags used in edit functions.
|
||||
screen->ClearDrawingState();
|
||||
}
|
||||
|
@ -851,7 +869,6 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
|
|||
my_clone->SetFlags( IS_NEW );
|
||||
( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() );
|
||||
my_clone->Move( pos );
|
||||
my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
||||
PrepareMoveItem( my_clone, DC );
|
||||
}
|
||||
else
|
||||
|
@ -861,16 +878,11 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
|
|||
if( my_clone->CanIncrementLabel() )
|
||||
( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() );
|
||||
|
||||
GetScreen()->Append( my_clone );
|
||||
AddToScreen( my_clone );
|
||||
|
||||
if( my_clone->IsConnectable() )
|
||||
{
|
||||
GetScreen()->TestDanglingEnds();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
}
|
||||
|
||||
SaveCopyInUndoList( my_clone, UR_NEW );
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <sch_bus_entry.h>
|
||||
|
@ -74,10 +74,8 @@ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY_BASE* BusEntry, c
|
|||
|
||||
s_LastShape = entry_shape == '/' ? '/' : '\\';
|
||||
|
||||
BusEntry->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
||||
BusEntry->SetBusEntryShape( s_LastShape );
|
||||
GetScreen()->TestDanglingEnds();
|
||||
BusEntry->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
|
||||
OnModify( );
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <macros.h>
|
||||
#include <kicad_string.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <gr_basic.h>
|
||||
#include <sch_screen.h>
|
||||
|
@ -956,7 +956,6 @@ bool LIB_PART::HasConversion() const
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::ClearStatus()
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
|
@ -965,157 +964,6 @@ void LIB_PART::ClearStatus()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aSyncPinEdit )
|
||||
{
|
||||
int itemCount = 0;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
item.ClearFlags( SELECTED );
|
||||
|
||||
if( ( item.m_Unit && item.m_Unit != aUnit )
|
||||
|| ( item.m_Convert && item.m_Convert != aConvert ) )
|
||||
{
|
||||
if( item.Type() != LIB_PIN_T )
|
||||
continue;
|
||||
|
||||
// Specific rules for pins:
|
||||
// - do not select pins in other units when synchronized pin edit mode is disabled
|
||||
// - do not select pins in other units when units are not interchangeable
|
||||
// - in other cases verify if the pin belongs to the requested unit
|
||||
if( !aSyncPinEdit || m_unitsLocked
|
||||
|| ( item.m_Convert && item.m_Convert != aConvert ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( item.Inside( aRect ) )
|
||||
{
|
||||
item.SetFlags( SELECTED );
|
||||
itemCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::MoveSelectedItems( const wxPoint& aOffset )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.SetOffset( aOffset );
|
||||
item.m_Flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::ClearSelectedItems()
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
item.m_Flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::DeleteSelectedItems()
|
||||
{
|
||||
LIB_ITEMS_CONTAINER::ITERATOR item = m_drawings.begin();
|
||||
|
||||
// We *do not* remove the 2 mandatory fields: reference and value
|
||||
// so skip them (do not remove) if they are flagged selected.
|
||||
// Skip also not visible items.
|
||||
// But I think fields must not be deleted by a block delete command or other global command
|
||||
// because they are not really graphic items
|
||||
while( item != m_drawings.end() )
|
||||
{
|
||||
if( item->Type() == LIB_FIELD_T )
|
||||
{
|
||||
item->ClearFlags( SELECTED );
|
||||
}
|
||||
|
||||
if( !item->IsSelected() )
|
||||
++item;
|
||||
else
|
||||
item = m_drawings.erase( item );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::CopySelectedItems( const wxPoint& aOffset )
|
||||
{
|
||||
std::vector< LIB_ITEM* > tmp;
|
||||
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
// We *do not* copy fields because they are unique for the whole component
|
||||
// so skip them (do not duplicate) if they are flagged selected.
|
||||
if( item.Type() == LIB_FIELD_T )
|
||||
item.ClearFlags( SELECTED );
|
||||
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.ClearFlags( SELECTED );
|
||||
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
|
||||
newItem->SetFlags( SELECTED );
|
||||
|
||||
// When push_back elements in buffer, a memory reallocation can happen
|
||||
// and will break pointers.
|
||||
// So, push_back later.
|
||||
tmp.push_back( newItem );
|
||||
}
|
||||
|
||||
for( auto item : tmp )
|
||||
m_drawings.push_back( item );
|
||||
|
||||
MoveSelectedItems( aOffset );
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::MirrorSelectedItemsH( const wxPoint& aCenter )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.MirrorHorizontal( aCenter );
|
||||
item.m_Flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::MirrorSelectedItemsV( const wxPoint& aCenter )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.MirrorVertical( aCenter );
|
||||
item.m_Flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_PART::RotateSelectedItems( const wxPoint& aCenter )
|
||||
{
|
||||
for( LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.Rotate( aCenter );
|
||||
item.m_Flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
|
||||
KICAD_T aType, const wxPoint& aPoint )
|
||||
{
|
||||
|
|
|
@ -578,70 +578,6 @@ public:
|
|||
*/
|
||||
void ClearStatus();
|
||||
|
||||
/**
|
||||
* Checks all draw objects of part to see if they are with block.
|
||||
*
|
||||
* Use this method to mark draw objects as selected during block
|
||||
* functions.
|
||||
*
|
||||
* @param aRect - The bounding rectangle to test in draw items are inside.
|
||||
* @param aUnit - The current unit number to test against.
|
||||
* @param aConvert - Are the draw items being selected a conversion.
|
||||
* @param aSyncPinEdit - Enable pin selection in other units.
|
||||
* @return The number of draw objects found inside the block select
|
||||
* rectangle.
|
||||
*/
|
||||
int SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aSyncPinEdit );
|
||||
|
||||
/**
|
||||
* Clears all the draw items marked by a block select.
|
||||
*/
|
||||
void ClearSelectedItems();
|
||||
|
||||
/**
|
||||
* Deletes the select draw items marked by a block select.
|
||||
*
|
||||
* The name and reference field will not be deleted. They are the
|
||||
* minimum drawing items required for any part. Their properties
|
||||
* can be changed but the cannot be removed.
|
||||
*/
|
||||
void DeleteSelectedItems();
|
||||
|
||||
/**
|
||||
* Move the selected draw items marked by a block select.
|
||||
*/
|
||||
void MoveSelectedItems( const wxPoint& aOffset );
|
||||
|
||||
/**
|
||||
* Make a copy of the selected draw items marked by a block select.
|
||||
*
|
||||
* Fields are not copied. Only part body items are copied.
|
||||
* Copying fields would result in duplicate fields which does not
|
||||
* make sense in this context.
|
||||
*/
|
||||
void CopySelectedItems( const wxPoint& aOffset );
|
||||
|
||||
/**
|
||||
* Horizontally (X axis) mirror selected draw items about a point.
|
||||
*
|
||||
* @param aCenter - Center point to mirror around.
|
||||
*/
|
||||
void MirrorSelectedItemsH( const wxPoint& aCenter );
|
||||
|
||||
/**
|
||||
* Vertically (Y axis) mirror selected draw items about a point.
|
||||
*
|
||||
* @param aCenter - Center point to mirror around.
|
||||
*/
|
||||
void MirrorSelectedItemsV( const wxPoint& aCenter );
|
||||
|
||||
/**
|
||||
* Rotate CCW selected draw items about a point.
|
||||
*
|
||||
* @param aCenter - Center point to mirror around.
|
||||
*/
|
||||
void RotateSelectedItems( const wxPoint& aCenter );
|
||||
|
||||
/**
|
||||
* Locate a draw object.
|
||||
*
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <eda_dde.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <menus_helpers.h>
|
||||
|
@ -235,6 +235,7 @@ bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
|
||||
// for next cursor position
|
||||
// ( shift or ctrl key down are PAN command with mouse wheel)
|
||||
|
@ -275,48 +276,6 @@ bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
|
|||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
||||
{
|
||||
// Filter out the 'fake' mouse motion after a keyboard movement
|
||||
if( !aHotKey && m_movingCursorWithKeyboard )
|
||||
{
|
||||
m_movingCursorWithKeyboard = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
|
||||
// for next cursor position
|
||||
// ( shift or ctrl key down are PAN command with mouse wheel)
|
||||
bool snapToGrid = true;
|
||||
|
||||
if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
|
||||
snapToGrid = false;
|
||||
|
||||
// Cursor is left off grid only if no block in progress
|
||||
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
snapToGrid = true;
|
||||
|
||||
wxPoint pos = aPosition;
|
||||
wxPoint oldpos = GetCrossHairPosition();
|
||||
bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
|
||||
|
||||
// Update the cursor position.
|
||||
SetCrossHairPosition( pos, snapToGrid );
|
||||
RefreshCrossHair( oldpos, aPosition, aDC );
|
||||
|
||||
if( aHotKey && OnHotKey( aDC, aHotKey, aPosition, NULL ) )
|
||||
{
|
||||
keyHandled = true;
|
||||
}
|
||||
|
||||
// Make sure current-part highlighting doesn't get lost in selection highlighting
|
||||
ClearSearchTreeSelection();
|
||||
|
||||
UpdateStatusBar();
|
||||
|
||||
return keyHandled;
|
||||
}
|
||||
|
||||
|
||||
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <kiway_express.h>
|
||||
#include <macros.h>
|
||||
#include <eda_dde.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
|
||||
#include <sch_edit_frame.h>
|
||||
#include <general.h>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_marker.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <bitmaps.h>
|
||||
#include <confirm.h>
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <wx/tooltip.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiface_i.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <grid_tricks.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_reference_list.h>
|
||||
#include <pgm_base.h>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <sch_edit_frame.h>
|
||||
#include <base_units.h>
|
||||
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <general.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <confirm.h>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <kicad_string.h>
|
||||
#include <gestfich.h>
|
||||
#include <pgm_base.h>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <class_libentry.h>
|
||||
#include <lib_text.h>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_screen.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -386,7 +386,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
|||
EDA_RECT oldClipBox;
|
||||
wxRect fitRect;
|
||||
wxDC* dc = GetDC();
|
||||
EDA_DRAW_PANEL* panel = m_parent->GetCanvas();
|
||||
auto panel = m_parent->GetCanvas();
|
||||
|
||||
wxBusyCursor dummy;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_bitmap.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <msgpanel.h>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <gr_basic.h>
|
||||
#include <base_struct.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <kicad_device_context.h>
|
||||
|
@ -119,8 +119,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
|
|||
}
|
||||
|
||||
// Prepare display to move the new item
|
||||
textItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
PrepareMoveItem( (SCH_ITEM*) textItem, aDC );
|
||||
PrepareMoveItem( (SCH_ITEM*) textItem, nullptr );
|
||||
|
||||
return textItem;
|
||||
}
|
||||
|
@ -217,9 +216,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
|
|||
* put in undo list later, at the end of the current command (if not aborted)
|
||||
*/
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
m_canvas->CrossHairOff( &dc ); // Erase schematic cursor
|
||||
text->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
m_canvas->CrossHairOff(); // Erase schematic cursor
|
||||
|
||||
// For an exiting item (i.e. already in list):
|
||||
// replace the existing item by the new text in list
|
||||
|
@ -227,16 +224,15 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
|
|||
{
|
||||
if( item == text )
|
||||
{
|
||||
screen->Remove( text );
|
||||
screen->Append( newtext );
|
||||
RemoveFromScreen( text );
|
||||
AddToScreen( newtext );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetRepeatItem( NULL );
|
||||
OnModify();
|
||||
newtext->Draw( m_canvas, &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
m_canvas->CrossHairOn( &dc ); // redraw schematic cursor
|
||||
m_canvas->CrossHairOn( ); // redraw schematic cursor
|
||||
|
||||
// if the old item is the current schematic item, replace it by the new text:
|
||||
if( screen->GetCurItem() == text )
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <general.h>
|
||||
|
||||
|
@ -56,31 +56,9 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
if( GetScreen() == NULL )
|
||||
return;
|
||||
|
||||
m_canvas->DrawBackGround( DC );
|
||||
|
||||
GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE );
|
||||
|
||||
DrawWorkSheet( DC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS,
|
||||
GetScreen()->GetFileName() );
|
||||
|
||||
#ifdef USE_WX_OVERLAY
|
||||
if( IsShown() )
|
||||
{
|
||||
m_overlay.Reset();
|
||||
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
|
||||
overlaydc.Clear();
|
||||
/* TODO: Investigate why toolbars are affected - to be searched in wxWidgets */
|
||||
m_mainToolBar->Refresh();
|
||||
m_drawToolBar->Refresh();
|
||||
m_optionsToolBar->Refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
if( m_canvas->IsMouseCaptured() )
|
||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
||||
|
||||
m_canvas->DrawCrossHair( DC );
|
||||
|
||||
// Display the sheet filename, and the sheet path, for non root sheets
|
||||
UpdateTitle();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiface_i.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <gestfich.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -47,6 +47,8 @@
|
|||
#include <dialogs/panel_eeschema_display_options.h>
|
||||
#include <widgets/widget_eeschema_color_config.h>
|
||||
#include <dialogs/panel_libedit_settings.h>
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
|
||||
#define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings.
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <kicad_string.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <general.h>
|
||||
#include <kicad_device_context.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -43,7 +43,6 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
|
|||
if( !curr_item || curr_item->GetFlags() )
|
||||
return;
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
switch( curr_item->Type() )
|
||||
{
|
||||
|
@ -55,8 +54,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
|
|||
newitem->ClearAnnotation( NULL );
|
||||
newitem->SetFlags( IS_NEW );
|
||||
// Draw the new part, MoveItem() expects it to be already on screen.
|
||||
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
PrepareMoveItem( newitem, &dc );
|
||||
PrepareMoveItem( newitem, nullptr );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -68,8 +66,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
|
|||
SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone();
|
||||
newitem->SetFlags( IS_NEW );
|
||||
// Draw the new item, MoveItem() expects it to be already on screen.
|
||||
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
PrepareMoveItem( newitem, &dc );
|
||||
PrepareMoveItem( newitem, nullptr );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <gestfich.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -370,7 +370,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
Zoom_Automatique( false );
|
||||
SetSheetNumberAndCount();
|
||||
m_canvas->Refresh( true );
|
||||
SyncView();
|
||||
GetScreen()->ClearDrawingState();
|
||||
|
||||
return true;
|
||||
|
@ -612,6 +612,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
|
|||
}
|
||||
|
||||
// It is finally safe to add the imported schematic.
|
||||
// fixme-gal: rebuild view
|
||||
screen->Append( newScreen );
|
||||
|
||||
SCH_SCREENS allScreens;
|
||||
|
@ -629,7 +630,8 @@ bool SCH_EDIT_FRAME::AppendSchematic()
|
|||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
Zoom_Automatique( false );
|
||||
SetSheetNumberAndCount();
|
||||
m_canvas->Refresh( true );
|
||||
SyncView();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -861,7 +863,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
|||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
Zoom_Automatique( false );
|
||||
SetSheetNumberAndCount();
|
||||
m_canvas->Refresh( true );
|
||||
SyncView();
|
||||
UpdateTitle();
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <kicad_string.h>
|
||||
#include <gestfich.h>
|
||||
|
@ -213,11 +213,12 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
|
|||
}
|
||||
else
|
||||
{
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
/*INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
m_canvas->CrossHairOff( &dc );
|
||||
SetCrossHairPosition( pos );
|
||||
m_canvas->CrossHairOn( &dc );
|
||||
m_canvas->CrossHairOn( &dc );*/
|
||||
// fixme-gal
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <pgm_base.h>
|
||||
#include <kiway.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <kicad_device_context.h>
|
||||
|
@ -286,7 +286,6 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aD
|
|||
component->GetMsgPanelInfo( m_UserUnits, items );
|
||||
|
||||
SetMsgPanel( items );
|
||||
component->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
component->SetFlags( IS_NEW );
|
||||
|
||||
if( m_autoplaceFields )
|
||||
|
@ -313,11 +312,9 @@ void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
|
|||
if( item->GetFlags() == 0 )
|
||||
SetUndoItem( item );
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
component->SetOrientation( aOrientation );
|
||||
|
||||
m_canvas->CrossHairOn( &dc );
|
||||
m_canvas->CrossHairOn( );
|
||||
|
||||
if( item->GetFlags() == 0 )
|
||||
{
|
||||
|
@ -340,7 +337,8 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
|
|||
wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T,
|
||||
wxT( "Cannot select unit of invalid schematic item." ) );
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
//fixme-gal
|
||||
//INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
||||
|
@ -370,10 +368,10 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
|
|||
if( !flags ) // No command in progress: save in undo list
|
||||
SaveCopyInUndoList( component, UR_CHANGED );
|
||||
|
||||
if( flags )
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
else
|
||||
component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
//if( flags )
|
||||
//component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
|
||||
//else
|
||||
//component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
/* Update the unit number. */
|
||||
component->SetUnitSelection( m_CurrentSheet, unit );
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <id.h>
|
||||
#include <bitmaps.h>
|
||||
|
@ -45,6 +45,7 @@
|
|||
#include <netlist_object.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
#include <view/view.h>
|
||||
|
||||
class HIERARCHY_NAVIG_DLG;
|
||||
|
||||
|
@ -307,5 +308,5 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
|||
// mainly when sheet size has changed
|
||||
// This second refresh clears artefacts because at this point,
|
||||
// all parameters are now updated
|
||||
m_canvas->Refresh();
|
||||
SyncView();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <erc.h>
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <eeschema_id.h>
|
||||
#include <hotkeys.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <lib_edit_frame.h>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_units.h>
|
||||
|
@ -525,7 +525,6 @@ void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
{
|
||||
m_initialPos = m_Pos;
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -556,7 +555,6 @@ void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
}
|
||||
|
||||
m_editState = 0;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
|
||||
m_Flags = aEditMode;
|
||||
|
@ -574,7 +572,6 @@ bool LIB_ARC::ContinueEdit( const wxPoint aPosition )
|
|||
{
|
||||
m_ArcEnd = aPosition;
|
||||
m_editState = 2;
|
||||
SetEraseLastDrawItem( false );
|
||||
return true; // Need third position to calculate center point.
|
||||
}
|
||||
}
|
||||
|
@ -588,14 +585,13 @@ void LIB_ARC::EndEdit( const wxPoint& aPosition, bool aAbort )
|
|||
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
|
||||
wxT( "Bad call to EndEdit(). LIB_ARC is not being edited." ) );
|
||||
|
||||
SetEraseLastDrawItem( false );
|
||||
m_lastEditState = 0;
|
||||
m_editState = 0;
|
||||
m_Flags = 0;
|
||||
}
|
||||
|
||||
|
||||
void LIB_ARC::calcEdit( const wxPoint& aPosition )
|
||||
void LIB_ARC::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
if( m_Flags == IS_RESIZED )
|
||||
{
|
||||
|
@ -707,7 +703,6 @@ void LIB_ARC::calcEdit( const wxPoint& aPosition )
|
|||
m_Pos.y = cY;
|
||||
CalcRadiusAngles();
|
||||
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else if( m_Flags == IS_MOVED )
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ class LIB_ARC : public LIB_ITEM
|
|||
*
|
||||
* @param aPosition - The current mouse position in drawing coordinates.
|
||||
*/
|
||||
void calcEdit( const wxPoint& aPosition ) override;
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
|
||||
public:
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <bezier_curves.h>
|
||||
|
@ -103,6 +103,8 @@ bool LIB_BEZIER::Inside( EDA_RECT& aRect ) const
|
|||
|
||||
void LIB_BEZIER::Move( const wxPoint& aPosition )
|
||||
{
|
||||
if ( !m_PolyPoints.size() )
|
||||
return;
|
||||
SetOffset( aPosition - m_PolyPoints[0] );
|
||||
}
|
||||
|
||||
|
@ -335,3 +337,11 @@ void LIB_BEZIER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITE
|
|||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) );
|
||||
}
|
||||
|
||||
wxPoint LIB_BEZIER::GetPosition() const
|
||||
{
|
||||
if( !m_PolyPoints.size() )
|
||||
return wxPoint(0, 0);
|
||||
|
||||
return m_PolyPoints[0];
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
void Move( const wxPoint& aPosition ) override;
|
||||
|
||||
wxPoint GetPosition() const override { return m_PolyPoints[0]; }
|
||||
wxPoint GetPosition() const override;
|
||||
|
||||
void MirrorHorizontal( const wxPoint& aCenter ) override;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_units.h>
|
||||
|
@ -278,11 +278,6 @@ void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
{
|
||||
m_initialPos = m_Pos;
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else if( aEditMode == IS_RESIZED )
|
||||
{
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
|
||||
m_Flags = aEditMode;
|
||||
|
@ -303,18 +298,14 @@ void LIB_CIRCLE::EndEdit( const wxPoint& aPosition, bool aAbort )
|
|||
wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
|
||||
wxT( "Bad call to EndEdit(). LIB_CIRCLE is not being edited." ) );
|
||||
|
||||
SetEraseLastDrawItem( false );
|
||||
m_Flags = 0;
|
||||
}
|
||||
|
||||
|
||||
void LIB_CIRCLE::calcEdit( const wxPoint& aPosition )
|
||||
void LIB_CIRCLE::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
if( m_Flags == IS_NEW || m_Flags == IS_RESIZED )
|
||||
{
|
||||
if( m_Flags == IS_NEW )
|
||||
SetEraseLastDrawItem();
|
||||
|
||||
m_Radius = KiROUND( GetLineLength( m_Pos, aPosition ) );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -42,7 +42,7 @@ class LIB_CIRCLE : public LIB_ITEM
|
|||
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
|
||||
const TRANSFORM& aTransform ) override;
|
||||
|
||||
void calcEdit( const wxPoint& aPosition ) override;
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
public:
|
||||
LIB_CIRCLE( LIB_PART * aParent );
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <msgpanel.h>
|
||||
|
||||
#include <general.h>
|
||||
|
@ -52,7 +52,6 @@ LIB_ITEM::LIB_ITEM( KICAD_T aType,
|
|||
m_Fill = aFillType;
|
||||
m_Parent = (EDA_ITEM*) aComponent;
|
||||
m_isFillable = false;
|
||||
m_eraseLastDrawItem = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,6 +116,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
GR_DRAWMODE aDrawMode, void* aData,
|
||||
const TRANSFORM& aTransform )
|
||||
{
|
||||
#if 0
|
||||
if( InEditMode() )
|
||||
{
|
||||
// Temporarily disable filling while the item is being edited.
|
||||
|
@ -136,7 +136,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
}
|
||||
#endif
|
||||
// Calculate the new attributes at the current cursor position.
|
||||
calcEdit( aOffset );
|
||||
CalcEdit( aOffset );
|
||||
|
||||
// Draw the items using the new attributes.
|
||||
drawEditGraphics( aPanel->GetClipBox(), aDC, color );
|
||||
|
@ -149,6 +149,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
{
|
||||
drawGraphic( aPanel, aDC, aOffset, aColor, aDrawMode, aData, aTransform );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ class PLOTTER;
|
|||
class LIB_ITEM;
|
||||
class LIB_PIN;
|
||||
class MSG_PANEL_ITEM;
|
||||
class EDA_DRAW_PANEL;
|
||||
|
||||
|
||||
extern const int fill_tab[];
|
||||
|
@ -92,20 +93,7 @@ class LIB_ITEM : public EDA_ITEM
|
|||
*/
|
||||
virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) {}
|
||||
|
||||
/**
|
||||
* Calculates the attributes of an item at \a aPosition when it is being edited.
|
||||
*
|
||||
* This method gets called by the Draw() method when the item is being edited. This
|
||||
* probably should be a pure virtual method but bezier curves are not yet editable in
|
||||
* the component library editor. Therefore, the default method does nothing.
|
||||
*
|
||||
* @param aPosition The current mouse position in drawing coordinates.
|
||||
*/
|
||||
virtual void calcEdit( const wxPoint& aPosition ) {}
|
||||
|
||||
bool m_eraseLastDrawItem; ///< Used when editing a new draw item to prevent drawing
|
||||
///< artifacts.
|
||||
|
||||
|
||||
friend class LIB_PART;
|
||||
|
||||
protected:
|
||||
|
@ -191,6 +179,18 @@ public:
|
|||
*/
|
||||
virtual void EndEdit( const wxPoint& aPosition, bool aAbort = false ) { m_Flags = 0; }
|
||||
|
||||
/**
|
||||
* Calculates the attributes of an item at \a aPosition when it is being edited.
|
||||
*
|
||||
* This method gets called by the Draw() method when the item is being edited. This
|
||||
* probably should be a pure virtual method but bezier curves are not yet editable in
|
||||
* the component library editor. Therefore, the default method does nothing.
|
||||
*
|
||||
* @param aPosition The current mouse position in drawing coordinates.
|
||||
*/
|
||||
virtual void CalcEdit( const wxPoint& aPosition ) {}
|
||||
|
||||
|
||||
/**
|
||||
* Draw an item
|
||||
*
|
||||
|
@ -369,8 +369,6 @@ public:
|
|||
*/
|
||||
bool InEditMode() const { return ( m_Flags & ( IS_NEW | IS_DRAGGED | IS_MOVED | IS_RESIZED ) ) != 0; }
|
||||
|
||||
void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; }
|
||||
|
||||
virtual COLOR4D GetDefaultColor();
|
||||
|
||||
void SetUnit( int aUnit ) { m_Unit = aUnit; }
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <base_struct.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <kicad_string.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_units.h>
|
||||
|
@ -547,7 +547,6 @@ void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
{
|
||||
m_initialPos = GetTextPos();
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -575,11 +574,10 @@ void LIB_FIELD::EndEdit( const wxPoint& aPosition, bool aAbort )
|
|||
m_Flags = 0;
|
||||
m_rotate = false;
|
||||
m_updateText = false;
|
||||
SetEraseLastDrawItem( false );
|
||||
}
|
||||
|
||||
|
||||
void LIB_FIELD::calcEdit( const wxPoint& aPosition )
|
||||
void LIB_FIELD::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
if( m_rotate )
|
||||
{
|
||||
|
|
|
@ -81,7 +81,7 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
|
|||
*
|
||||
* @param aPosition - The position to edit the circle in drawing coordinates.
|
||||
*/
|
||||
void calcEdit( const wxPoint& aPosition ) override;
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
friend class SCH_LEGACY_PLUGIN_CACHE; // Required to access m_name.
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <trigo.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <plotter.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -2000,3 +2000,17 @@ void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
void LIB_PIN::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
printf("m_Flags %x\n", m_Flags );
|
||||
if( m_Flags == IS_NEW )
|
||||
{
|
||||
SetPosition( aPosition );
|
||||
}
|
||||
else if( m_Flags == IS_MOVED )
|
||||
{
|
||||
printf("MOVEPIN\n");
|
||||
Move( aPosition );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,6 +489,8 @@ public:
|
|||
|
||||
EDA_ITEM* Clone() const override;
|
||||
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Build the pin basic info to display in message panel.
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_units.h>
|
||||
|
@ -401,14 +401,11 @@ void LIB_POLYLINE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
prevPoint = point;
|
||||
index++;
|
||||
}
|
||||
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else if( aEditMode == IS_MOVED )
|
||||
{
|
||||
m_initialCursorPos = aPosition;
|
||||
m_initialPos = m_PolyPoints[0];
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
|
||||
m_Flags = aEditMode;
|
||||
|
@ -457,16 +454,14 @@ void LIB_POLYLINE::EndEdit( const wxPoint& aPosition, bool aAbort )
|
|||
}
|
||||
|
||||
m_Flags = 0;
|
||||
SetEraseLastDrawItem( false );
|
||||
}
|
||||
|
||||
|
||||
void LIB_POLYLINE::calcEdit( const wxPoint& aPosition )
|
||||
void LIB_POLYLINE::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
if( m_Flags == IS_NEW )
|
||||
{
|
||||
m_PolyPoints[ GetCornerCount() - 1 ] = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else if( m_Flags == IS_RESIZED )
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ class LIB_POLYLINE : public LIB_ITEM
|
|||
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
|
||||
const TRANSFORM& aTransform ) override;
|
||||
|
||||
void calcEdit( const wxPoint& aPosition ) override;
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
public:
|
||||
LIB_POLYLINE( LIB_PART * aParent );
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_units.h>
|
||||
|
@ -332,13 +332,11 @@ void LIB_RECTANGLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
m_isHeightLocked = abs( m_End.y - aPosition.y ) >= MINIMUM_SELECTION_DISTANCE;
|
||||
}
|
||||
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else if( aEditMode == IS_MOVED )
|
||||
{
|
||||
m_initialPos = m_Pos;
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
|
||||
m_Flags = aEditMode;
|
||||
|
@ -362,16 +360,14 @@ void LIB_RECTANGLE::EndEdit( const wxPoint& aPosition, bool aAbort )
|
|||
m_Flags = 0;
|
||||
m_isHeightLocked = false;
|
||||
m_isWidthLocked = false;
|
||||
SetEraseLastDrawItem( false );
|
||||
}
|
||||
|
||||
|
||||
void LIB_RECTANGLE::calcEdit( const wxPoint& aPosition )
|
||||
void LIB_RECTANGLE::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
if( m_Flags == IS_NEW )
|
||||
{
|
||||
m_End = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else if( m_Flags == IS_RESIZED )
|
||||
{
|
||||
|
@ -385,7 +381,7 @@ void LIB_RECTANGLE::calcEdit( const wxPoint& aPosition )
|
|||
else if( m_isWidthLocked )
|
||||
{
|
||||
if( m_isStartPointSelected )
|
||||
m_Pos.y = aPosition.y;
|
||||
m_Pos.y = aPosition.y;
|
||||
else
|
||||
m_End.y = aPosition.y;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class LIB_RECTANGLE : public LIB_ITEM
|
|||
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
|
||||
const TRANSFORM& aTransform ) override;
|
||||
|
||||
void calcEdit( const wxPoint& aPosition ) override;
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
public:
|
||||
LIB_RECTANGLE( LIB_PART * aParent );
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <trigo.h>
|
||||
|
@ -378,7 +378,6 @@ void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
|
|||
{
|
||||
m_initialPos = GetTextPos();
|
||||
m_initialCursorPos = aPosition;
|
||||
SetEraseLastDrawItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -406,12 +405,13 @@ void LIB_TEXT::EndEdit( const wxPoint& aPosition, bool aAbort )
|
|||
m_Flags = 0;
|
||||
m_rotate = false;
|
||||
m_updateText = false;
|
||||
SetEraseLastDrawItem( false );
|
||||
}
|
||||
|
||||
|
||||
void LIB_TEXT::calcEdit( const wxPoint& aPosition )
|
||||
void LIB_TEXT::CalcEdit( const wxPoint& aPosition )
|
||||
{
|
||||
printf("textCalcEdit %d %d\n", aPosition.x, aPosition.y );
|
||||
|
||||
if( m_rotate )
|
||||
{
|
||||
SetTextAngle( GetTextAngle() == TEXT_ANGLE_VERT ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
|
||||
|
@ -426,11 +426,13 @@ void LIB_TEXT::calcEdit( const wxPoint& aPosition )
|
|||
|
||||
if( m_Flags == IS_NEW )
|
||||
{
|
||||
SetEraseLastDrawItem();
|
||||
SetTextPos( aPosition );
|
||||
}
|
||||
else if( m_Flags == IS_MOVED )
|
||||
{
|
||||
Move( m_initialPos + aPosition - m_initialCursorPos );
|
||||
printf("%p: move %d %d\n", this, GetPosition().x, GetPosition().y );
|
||||
}
|
||||
|
||||
printf("%p: move2 %d %d\n", this, GetPosition().x, GetPosition().y );
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
|
|||
COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
|
||||
const TRANSFORM& aTransform ) override;
|
||||
|
||||
void calcEdit( const wxPoint& aPosition ) override;
|
||||
void CalcEdit( const wxPoint& aPosition ) override;
|
||||
|
||||
public:
|
||||
LIB_TEXT( LIB_PART * aParent );
|
||||
|
|
|
@ -29,18 +29,176 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <general.h>
|
||||
#include <class_library.h>
|
||||
#include <lib_edit_frame.h>
|
||||
|
||||
#include <preview_items/selection_area.h>
|
||||
#include <sch_view.h>
|
||||
#include <view/view_group.h>
|
||||
|
||||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
||||
bool aErase );
|
||||
|
||||
|
||||
int LIB_EDIT_FRAME::BlockSelectItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock, int aUnit, int aConvert, bool aSyncPinEdit )
|
||||
{
|
||||
int itemCount = 0;
|
||||
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
item.ClearFlags( SELECTED );
|
||||
|
||||
if( ( item.GetUnit() && item.GetUnit() != aUnit )
|
||||
|| ( item.GetConvert() && item.GetConvert() != aConvert ) )
|
||||
{
|
||||
if( item.Type() != LIB_PIN_T )
|
||||
continue;
|
||||
|
||||
// Specific rules for pins:
|
||||
// - do not select pins in other units when synchronized pin edit mode is disabled
|
||||
// - do not select pins in other units when units are not interchangeable
|
||||
// - in other cases verify if the pin belongs to the requested unit
|
||||
if( !aSyncPinEdit || aPart->UnitsLocked()
|
||||
|| ( item.GetConvert() && item.GetConvert() != aConvert ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( item.Inside( *aBlock ) )
|
||||
{
|
||||
auto picker = ITEM_PICKER( &item );
|
||||
aBlock->PushItem( picker );
|
||||
item.SetFlags( SELECTED );
|
||||
itemCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
void LIB_EDIT_FRAME::BlockClearSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
item.ClearFlags();
|
||||
}
|
||||
aBlock->ClearItemsList();
|
||||
}
|
||||
|
||||
void LIB_EDIT_FRAME::BlockMoveSelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.SetOffset( aOffset );
|
||||
item.ClearFlags();
|
||||
}
|
||||
|
||||
// view update
|
||||
}
|
||||
|
||||
void LIB_EDIT_FRAME::BlockDeleteSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
LIB_ITEMS_CONTAINER::ITERATOR item = aPart->GetDrawItems().begin();
|
||||
|
||||
// We *do not* remove the 2 mandatory fields: reference and value
|
||||
// so skip them (do not remove) if they are flagged selected.
|
||||
// Skip also not visible items.
|
||||
// But I think fields must not be deleted by a block delete command or other global command
|
||||
// because they are not really graphic items
|
||||
while( item != aPart->GetDrawItems().end() )
|
||||
{
|
||||
if( item->Type() == LIB_FIELD_T )
|
||||
{
|
||||
item->ClearFlags( SELECTED );
|
||||
}
|
||||
|
||||
if( !item->IsSelected() )
|
||||
++item;
|
||||
else
|
||||
item = aPart->GetDrawItems().erase( item );
|
||||
}
|
||||
|
||||
// view update
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
std::vector< LIB_ITEM* > tmp;
|
||||
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
// We *do not* copy fields because they are unique for the whole component
|
||||
// so skip them (do not duplicate) if they are flagged selected.
|
||||
if( item.Type() == LIB_FIELD_T )
|
||||
item.ClearFlags( SELECTED );
|
||||
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.ClearFlags( SELECTED );
|
||||
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
|
||||
newItem->SetFlags( SELECTED );
|
||||
|
||||
// When push_back elements in buffer, a memory reallocation can happen
|
||||
// and will break pointers.
|
||||
// So, push_back later.
|
||||
tmp.push_back( newItem );
|
||||
}
|
||||
|
||||
for( auto item : tmp )
|
||||
aPart->GetDrawItems().push_back( item );
|
||||
|
||||
BlockMoveSelectedItems( aOffset, aPart, aBlock );
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::BlockMirrorSelectedItemsH( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.MirrorHorizontal( aCenter );
|
||||
item.ClearFlags();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::BlockMirrorSelectedItemsV( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.MirrorVertical( aCenter );
|
||||
item.ClearFlags();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::BlockRotateSelectedItems( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||
{
|
||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||
{
|
||||
if( !item.IsSelected() )
|
||||
continue;
|
||||
|
||||
item.Rotate( aCenter );
|
||||
item.ClearFlags();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int LIB_EDIT_FRAME::BlockCommand( EDA_KEY key )
|
||||
{
|
||||
int cmd = BLOCK_IDLE;
|
||||
|
@ -98,6 +256,19 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||
wxPoint pt;
|
||||
|
||||
auto panel =static_cast<SCH_DRAW_PANEL*>(m_canvas);
|
||||
auto view = panel->GetView();
|
||||
auto area = view->GetSelectionArea();
|
||||
|
||||
auto start = area->GetOrigin();
|
||||
auto end = area->GetEnd();
|
||||
|
||||
block->SetOrigin( wxPoint( start.x, start.y ) );
|
||||
block->SetEnd( wxPoint( end.x, end.y ) );
|
||||
|
||||
view->ShowSelectionArea( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
if( block->GetCount() )
|
||||
{
|
||||
BLOCK_STATE_T state = block->GetState();
|
||||
|
@ -121,10 +292,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
case BLOCK_DRAG_ITEM:
|
||||
case BLOCK_MOVE: // Move
|
||||
case BLOCK_DUPLICATE: // Duplicate
|
||||
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( *block,
|
||||
m_unit, m_convert,
|
||||
m_syncPinEdit );
|
||||
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
|
||||
|
||||
if( ItemCount )
|
||||
{
|
||||
nextCmd = true;
|
||||
|
@ -150,9 +321,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
case BLOCK_COPY: // Save a copy of items in the clipboard buffer
|
||||
case BLOCK_CUT:
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( *block, m_unit, m_convert,
|
||||
m_syncPinEdit );
|
||||
|
||||
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
|
||||
|
||||
if( ItemCount )
|
||||
{
|
||||
copySelectedItems();
|
||||
|
@ -160,13 +330,13 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
|
||||
if( cmd == BLOCK_COPY )
|
||||
{
|
||||
GetCurPart()->ClearSelectedItems();
|
||||
BlockClearSelectedItems( GetCurPart(), block );
|
||||
block->ClearItemsList();
|
||||
}
|
||||
else if( cmd == BLOCK_CUT )
|
||||
{
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
GetCurPart()->DeleteSelectedItems();
|
||||
BlockDeleteSelectedItems( GetCurPart(), block );
|
||||
OnModify();
|
||||
}
|
||||
}
|
||||
|
@ -174,15 +344,14 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
|
||||
case BLOCK_DELETE: // Delete
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( *block,
|
||||
m_unit, m_convert,
|
||||
m_syncPinEdit );
|
||||
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
|
||||
|
||||
if( ItemCount )
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
if( GetCurPart() )
|
||||
{
|
||||
GetCurPart()->DeleteSelectedItems();
|
||||
BlockDeleteSelectedItems( GetCurPart(), block );
|
||||
OnModify();
|
||||
}
|
||||
break;
|
||||
|
@ -198,9 +367,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
case BLOCK_MIRROR_X:
|
||||
case BLOCK_MIRROR_Y:
|
||||
if( GetCurPart() )
|
||||
ItemCount = GetCurPart()->SelectItems( *block,
|
||||
m_unit, m_convert,
|
||||
m_syncPinEdit );
|
||||
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
|
||||
|
||||
if( ItemCount )
|
||||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
|
@ -214,11 +382,11 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
int block_cmd = block->GetCommand();
|
||||
|
||||
if( block_cmd == BLOCK_MIRROR_Y)
|
||||
GetCurPart()->MirrorSelectedItemsH( pt );
|
||||
BlockMirrorSelectedItemsH( pt, GetCurPart(), block );
|
||||
else if( block_cmd == BLOCK_MIRROR_X)
|
||||
GetCurPart()->MirrorSelectedItemsV( pt );
|
||||
BlockMirrorSelectedItemsV( pt, GetCurPart(), block );
|
||||
else if( block_cmd == BLOCK_ROTATE )
|
||||
GetCurPart()->RotateSelectedItems( pt );
|
||||
BlockRotateSelectedItems( pt, GetCurPart(), block );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -241,8 +409,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
if( !nextCmd )
|
||||
{
|
||||
if( block->GetCommand() != BLOCK_SELECT_ITEMS_ONLY && GetCurPart() )
|
||||
GetCurPart()->ClearSelectedItems();
|
||||
|
||||
BlockClearSelectedItems( GetCurPart(), block );
|
||||
|
||||
block->SetState( STATE_NO_BLOCK );
|
||||
block->SetCommand( BLOCK_IDLE );
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
|
@ -251,6 +419,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
|||
m_canvas->Refresh( true );
|
||||
}
|
||||
|
||||
view->ShowPreview( false );
|
||||
view->ShowSelectionArea( false );
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
return nextCmd;
|
||||
}
|
||||
|
||||
|
@ -282,10 +454,10 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = block->GetMoveVector();
|
||||
pt.y *= -1;
|
||||
//pt.y *= -1;
|
||||
|
||||
if( GetCurPart() )
|
||||
GetCurPart()->MoveSelectedItems( pt );
|
||||
BlockMoveSelectedItems( pt, GetCurPart(), block );
|
||||
|
||||
m_canvas->Refresh( true );
|
||||
break;
|
||||
|
@ -297,10 +469,10 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = block->GetMoveVector();
|
||||
pt.y = -pt.y;
|
||||
//pt.y = -pt.y;
|
||||
|
||||
if( GetCurPart() )
|
||||
GetCurPart()->CopySelectedItems( pt );
|
||||
BlockCopySelectedItems( pt, GetCurPart(), block );
|
||||
|
||||
break;
|
||||
|
||||
|
@ -311,7 +483,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
SaveCopyInUndoList( GetCurPart() );
|
||||
|
||||
pt = block->GetMoveVector();
|
||||
pt.y = -pt.y;
|
||||
//pt.y = -pt.y;
|
||||
|
||||
pasteClipboard( pt );
|
||||
break;
|
||||
|
@ -324,18 +496,18 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
|
||||
pt = block->Centre();
|
||||
pt = GetNearestGridPosition( pt );
|
||||
pt.y = -pt.y;
|
||||
//pt.y = -pt.y;
|
||||
|
||||
if( GetCurPart() )
|
||||
{
|
||||
int block_cmd = block->GetCommand();
|
||||
|
||||
if( block_cmd == BLOCK_MIRROR_Y)
|
||||
GetCurPart()->MirrorSelectedItemsH( pt );
|
||||
BlockMirrorSelectedItemsH( pt, GetCurPart(), block );
|
||||
else if( block_cmd == BLOCK_MIRROR_X)
|
||||
GetCurPart()->MirrorSelectedItemsV( pt );
|
||||
BlockMirrorSelectedItemsV( pt, GetCurPart(), block );
|
||||
else if( block_cmd == BLOCK_ROTATE )
|
||||
GetCurPart()->RotateSelectedItems( pt );
|
||||
BlockRotateSelectedItems( pt, GetCurPart(), block );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -354,6 +526,10 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
|||
block->SetCommand( BLOCK_IDLE );
|
||||
GetScreen()->SetCurItem( NULL );
|
||||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
|
||||
|
||||
GetCanvas()->GetView()->ClearPreview();
|
||||
GetCanvas()->GetView()->ClearHiddenFlags();
|
||||
|
||||
m_canvas->Refresh( true );
|
||||
}
|
||||
|
||||
|
@ -418,7 +594,7 @@ void LIB_EDIT_FRAME::pasteClipboard( const wxPoint& aOffset )
|
|||
part->AddDrawItem( item );
|
||||
}
|
||||
|
||||
GetCurPart()->MoveSelectedItems( aOffset );
|
||||
BlockMoveSelectedItems( aOffset, GetCurPart(), &GetScreen()->m_BlockLocate );
|
||||
OnModify();
|
||||
}
|
||||
|
||||
|
@ -430,6 +606,10 @@ void LIB_EDIT_FRAME::pasteClipboard( const wxPoint& aOffset )
|
|||
void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
||||
bool aErase )
|
||||
{
|
||||
auto panel = static_cast<SCH_DRAW_PANEL*>(aPanel);
|
||||
auto view = panel->GetView();
|
||||
auto preview = view->GetPreview();
|
||||
|
||||
BASE_SCREEN* screen = aPanel->GetScreen();
|
||||
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
|
||||
|
||||
|
@ -443,34 +623,28 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
|
|||
|
||||
int unit = parent->GetUnit();
|
||||
int convert = parent->GetConvert();
|
||||
auto cp = parent->GetCrossHairPosition( true );
|
||||
auto lcp = block->GetLastCursorPosition();
|
||||
|
||||
auto opts = PART_DRAW_OPTIONS::Default();
|
||||
opts.draw_mode = g_XorMode;
|
||||
opts.only_selected = true;
|
||||
|
||||
if( aErase )
|
||||
{
|
||||
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
|
||||
component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, opts );
|
||||
|
||||
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
|
||||
{
|
||||
LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
|
||||
libItem->Draw( aPanel, aDC, block->GetMoveVector(), g_GhostColor, g_XorMode, nullptr, opts.transform );
|
||||
}
|
||||
}
|
||||
|
||||
// Repaint new view
|
||||
block->SetMoveVector( parent->GetCrossHairPosition() - block->GetLastCursorPosition() );
|
||||
|
||||
GRSetDrawMode( aDC, g_XorMode );
|
||||
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
|
||||
printf("cp %d %d\n", cp.x, cp.y);
|
||||
printf("lcp %d %d\n", lcp.x, lcp.y);
|
||||
|
||||
block->SetMoveVector( cp - lcp );
|
||||
|
||||
preview->Clear();
|
||||
|
||||
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
|
||||
{
|
||||
LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
|
||||
libItem->Draw( aPanel, aDC, block->GetMoveVector(), g_GhostColor, g_XorMode, nullptr, opts.transform );
|
||||
LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() );
|
||||
// if( copy->Type() != LIB_PIN_T )
|
||||
copy->Move( copy->GetPosition() + block->GetMoveVector() );
|
||||
|
||||
preview->Add( copy );
|
||||
view->Hide( libItem );
|
||||
}
|
||||
|
||||
component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, opts );
|
||||
view->SetVisible( preview, true );
|
||||
view->Hide( preview, false );
|
||||
view->Update( preview );
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <pgm_base.h>
|
||||
#include <kiface_i.h>
|
||||
#include <kiway_express.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <base_screen.h>
|
||||
#include <confirm.h>
|
||||
#include <eda_doc.h>
|
||||
|
@ -67,6 +67,7 @@
|
|||
#include <menus_helpers.h>
|
||||
#include <wx/progdlg.h>
|
||||
#include <tool/context_menu.h>
|
||||
#include <sch_view.h>
|
||||
|
||||
int LIB_EDIT_FRAME:: m_unit = 1;
|
||||
int LIB_EDIT_FRAME:: m_convert = 1;
|
||||
|
@ -267,7 +268,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
.Caption( _( "Libraries" ) ).MinSize( 250, -1 ).Resizable() );
|
||||
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
|
||||
|
||||
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( m_canvas->GetWindow(),
|
||||
wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
|
||||
|
||||
m_auimgr.Update();
|
||||
|
||||
|
@ -282,6 +284,9 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, ID_ZOOM_PAGE );
|
||||
wxPostEvent( this, evt );
|
||||
|
||||
SyncView();
|
||||
GetGalCanvas()->GetViewControls()->SetSnapping( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -671,7 +676,8 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
}
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
//fixme-gal
|
||||
//INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
|
@ -686,14 +692,14 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
if( item )
|
||||
{
|
||||
EndDrawGraphicItem( &dc );
|
||||
EndDrawGraphicItem( nullptr );
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
||||
if( item )
|
||||
{
|
||||
m_canvas->CrossHairOff( &dc );
|
||||
m_canvas->CrossHairOff( );
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
|
@ -701,18 +707,18 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case LIB_CIRCLE_T:
|
||||
case LIB_RECTANGLE_T:
|
||||
case LIB_POLYLINE_T:
|
||||
EditGraphicSymbol( &dc, item );
|
||||
EditGraphicSymbol( nullptr, item );
|
||||
break;
|
||||
|
||||
case LIB_TEXT_T:
|
||||
EditSymbolText( &dc, item );
|
||||
EditSymbolText( nullptr, item );
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
m_canvas->CrossHairOn( &dc );
|
||||
m_canvas->CrossHairOn( );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -725,11 +731,11 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
STATUS_FLAGS oldFlags = item->GetFlags();
|
||||
item->ClearFlags();
|
||||
item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
||||
/* item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
( (LIB_POLYLINE*) item )->DeleteSegment( GetCrossHairPosition( true ) );
|
||||
item->Draw( m_canvas, &dc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
DefaultTransform );*/
|
||||
item->SetFlags( oldFlags );
|
||||
m_lastDrawItem = NULL;
|
||||
}
|
||||
|
@ -737,7 +743,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_POPUP_LIBEDIT_DELETE_ITEM:
|
||||
if( item )
|
||||
deleteItem( &dc, item );
|
||||
deleteItem( nullptr, item );
|
||||
|
||||
break;
|
||||
|
||||
|
@ -746,9 +752,13 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
if( item->Type() == LIB_PIN_T )
|
||||
{
|
||||
StartMovePin( item );
|
||||
}
|
||||
else
|
||||
StartMoveDrawSymbol( &dc, item );
|
||||
{
|
||||
StartMoveDrawSymbol( nullptr, item );
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_MODIFY_ITEM:
|
||||
|
@ -763,7 +773,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|| item->Type() == LIB_ARC_T
|
||||
)
|
||||
{
|
||||
StartModifyDrawSymbol( &dc, item );
|
||||
StartModifyDrawSymbol( nullptr, item );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -772,7 +782,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
if( item == NULL )
|
||||
break;
|
||||
|
||||
m_canvas->CrossHairOff( &dc );
|
||||
m_canvas->CrossHairOff( nullptr );
|
||||
|
||||
if( item->Type() == LIB_FIELD_T )
|
||||
{
|
||||
|
@ -780,7 +790,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->CrossHairOn( &dc );
|
||||
m_canvas->CrossHairOn( );
|
||||
break;
|
||||
|
||||
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
|
||||
|
@ -803,65 +813,65 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_POPUP_ZOOM_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_ZOOM );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_DELETE_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_DELETE );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_DUPLICATE_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_DUPLICATE );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SELECT_ITEMS_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_SELECT_ITEMS_ONLY );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_MIRROR_Y_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_MIRROR_Y );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockPlace( &dc );
|
||||
HandleBlockPlace( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_MIRROR_X_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_MIRROR_X );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockPlace( &dc );
|
||||
HandleBlockPlace( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_ROTATE_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
block.SetCommand( BLOCK_ROTATE );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockPlace( &dc );
|
||||
HandleBlockPlace( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_PLACE_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockPlace( &dc );
|
||||
HandleBlockPlace( nullptr );
|
||||
break;
|
||||
|
||||
case wxID_COPY:
|
||||
block.SetCommand( BLOCK_COPY );
|
||||
block.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case wxID_PASTE:
|
||||
HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() );
|
||||
HandleBlockBegin( nullptr, BLOCK_PASTE, GetCrossHairPosition() );
|
||||
break;
|
||||
|
||||
case wxID_CUT:
|
||||
|
@ -870,7 +880,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
block.SetCommand( BLOCK_CUT );
|
||||
block.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -951,6 +961,8 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
|
|||
|
||||
// Ensure synchronized pin edit can be enabled only symbols with interchangeable units
|
||||
m_syncPinEdit = aPart && aPart->IsMulti() && !aPart->UnitsLocked();
|
||||
|
||||
RebuildView();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1182,7 +1194,6 @@ void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
|
|||
|
||||
void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||
{
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
BLOCK_SELECTOR& block = screen->m_BlockLocate;
|
||||
|
||||
|
@ -1207,14 +1218,14 @@ void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
block.SetMessageBlock( this );
|
||||
block.SetCommand( BLOCK_MIRROR_X );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
}
|
||||
else if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y )
|
||||
{
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
block.SetMessageBlock( this );
|
||||
block.SetCommand( BLOCK_MIRROR_Y );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1367,6 +1378,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC, LIB_ITEM* aItem )
|
|||
SetDrawItem( NULL );
|
||||
m_lastDrawItem = NULL;
|
||||
OnModify();
|
||||
RebuildView();
|
||||
m_canvas->CrossHairOn( aDC );
|
||||
}
|
||||
|
||||
|
@ -1674,6 +1686,35 @@ void LIB_EDIT_FRAME::ShowChangedLanguage()
|
|||
UpdateMsgPanel();
|
||||
}
|
||||
|
||||
void LIB_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
||||
{
|
||||
EDA_DRAW_FRAME::SetScreen( aScreen );
|
||||
}
|
||||
|
||||
void LIB_EDIT_FRAME::RebuildView()
|
||||
{
|
||||
auto view = GetCanvas()->GetView();
|
||||
view->Clear();
|
||||
view->DisplayComponent( m_my_part );
|
||||
view->HideWorksheet();
|
||||
view->ClearHiddenFlags();
|
||||
}
|
||||
|
||||
const BOX2I LIB_EDIT_FRAME::GetDocumentExtents() const
|
||||
{
|
||||
LIB_PART* part = GetCurPart();
|
||||
|
||||
if( !part )
|
||||
{
|
||||
return BOX2I( VECTOR2I(-100, -100), VECTOR2I( 200, 200 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
|
||||
return BOX2I( boundingBox.GetOrigin(), VECTOR2I( boundingBox.GetWidth(), boundingBox.GetHeight() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <general.h>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <gestfich.h>
|
||||
|
||||
|
@ -173,7 +173,9 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, const wxString& a
|
|||
|
||||
LIB_PART* lib_part = m_libMgr->GetBufferedPart( aEntry->GetName(), aLibrary );
|
||||
wxASSERT( lib_part );
|
||||
SetScreen( m_libMgr->GetScreen( lib_part->GetName(), aLibrary ) );
|
||||
|
||||
auto s = m_libMgr->GetScreen( lib_part->GetName(), aLibrary );
|
||||
SetScreen( s );
|
||||
SetCurPart( new LIB_PART( *lib_part ) );
|
||||
SetCurLib( aLibrary );
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <msgpanel.h>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <confirm.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <hotkeys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_screen.h>
|
||||
#include <msgpanel.h>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <gr_basic.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <gestfich.h>
|
||||
#include <eeschema_id.h>
|
||||
|
@ -119,8 +119,11 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
|
|||
|
||||
void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg )
|
||||
{
|
||||
wxSize image_size = m_canvas->GetClientSize();
|
||||
wxSize image_size;
|
||||
//fixme-gal do it properly
|
||||
|
||||
// = m_canvas->GetClientSize();
|
||||
#if 0
|
||||
wxClientDC dc( m_canvas );
|
||||
wxBitmap bitmap( image_size.x, image_size.y );
|
||||
wxMemoryDC memdc;
|
||||
|
@ -139,6 +142,7 @@ void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_j
|
|||
}
|
||||
|
||||
image.Destroy();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,5 +214,3 @@ void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod
|
|||
|
||||
part->Draw( m_canvas, aDC, plot_offset, m_unit, m_convert, PART_DRAW_OPTIONS::Default() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
|
||||
#include <lib_edit_frame.h>
|
||||
#include <class_libentry.h>
|
||||
|
@ -96,6 +96,7 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
|
|||
DisplayCmpDoc();
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
RebuildView();
|
||||
}
|
||||
|
||||
|
||||
|
@ -143,4 +144,5 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
|
|||
DisplayCmpDoc();
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
RebuildView();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <sch_component.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <base_units.h>
|
||||
#include <msgpanel.h>
|
||||
|
@ -45,6 +45,7 @@
|
|||
#include <../common/dialogs/dialog_display_info_HTML_base.h>
|
||||
#include <dialog_lib_edit_pin.h>
|
||||
|
||||
#include <sch_view.h>
|
||||
|
||||
extern void IncrementLabelMember( wxString& name, int aIncrement );
|
||||
|
||||
|
@ -54,7 +55,7 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
|
||||
|
||||
static wxPoint OldPos;
|
||||
static wxPoint PinPreviousPos;
|
||||
//static wxPoint PinPreviousPos;
|
||||
static ELECTRICAL_PINTYPE LastPinType = PIN_INPUT;
|
||||
static int LastPinOrient = PIN_RIGHT;
|
||||
static GRAPHIC_PINSHAPE LastPinShape = PINSHAPE_LINE;
|
||||
|
@ -144,10 +145,12 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
|
|||
/**
|
||||
* Clean up after aborting a move pin command.
|
||||
*/
|
||||
static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
||||
static void AbortPinMove( EDA_DRAW_PANEL* aPanel, wxDC* DC )
|
||||
{
|
||||
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
|
||||
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
|
||||
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
||||
|
||||
|
||||
if( parent == NULL )
|
||||
return;
|
||||
|
||||
|
@ -162,11 +165,14 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
|||
delete pin;
|
||||
else
|
||||
parent->RestoreComponent();
|
||||
|
||||
panel->GetView()->ClearPreview();
|
||||
panel->GetView()->ClearHiddenFlags();
|
||||
|
||||
|
||||
// clear edit flags
|
||||
parent->SetDrawItem( NULL );
|
||||
parent->SetLastDrawItem( NULL );
|
||||
Panel->Refresh( true );
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,6 +183,8 @@ void LIB_EDIT_FRAME::PlacePin()
|
|||
{
|
||||
LIB_PIN* cur_pin = (LIB_PIN*) GetDrawItem();
|
||||
|
||||
printf("PlacePin!\n");
|
||||
|
||||
// Some tests
|
||||
if( !cur_pin || cur_pin->Type() != LIB_PIN_T )
|
||||
{
|
||||
|
@ -218,7 +226,10 @@ void LIB_EDIT_FRAME::PlacePin()
|
|||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
|
||||
if( !status )
|
||||
{
|
||||
RebuildView();
|
||||
return;
|
||||
}
|
||||
else
|
||||
ask_for_pin = false;
|
||||
}
|
||||
|
@ -261,6 +272,10 @@ void LIB_EDIT_FRAME::PlacePin()
|
|||
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
|
||||
printf("Rebuild %d %d\n", cur_pin->GetPosition().x, cur_pin->GetPosition().y );
|
||||
RebuildView();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -296,7 +311,7 @@ void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem )
|
|||
|
||||
cur_pin->SetFlags( IS_LINKED | IS_MOVED );
|
||||
|
||||
PinPreviousPos = OldPos = cur_pin->GetPosition();
|
||||
//PinPreviousPos = OldPos = cur_pin->GetPosition();
|
||||
startPos.x = OldPos.x;
|
||||
startPos.y = -OldPos.y;
|
||||
|
||||
|
@ -330,35 +345,21 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
|
|||
if( cur_pin == NULL || cur_pin->Type() != LIB_PIN_T )
|
||||
return;
|
||||
|
||||
wxPoint pinpos = cur_pin->GetPosition();
|
||||
int show_opts = PIN_DRAW_TEXTS | PIN_DRAW_DANGLING | PIN_DANGLING_HIDDEN;
|
||||
|
||||
if( parent->GetShowElectricalType() )
|
||||
show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
|
||||
|
||||
// In LIB_PIN::Draw() a void* parameter used as flag to pass show_opts.
|
||||
// Build it:
|
||||
void* showOptions = reinterpret_cast<void*>( show_opts );
|
||||
|
||||
// Erase pin in old position
|
||||
if( aErase )
|
||||
{
|
||||
cur_pin->Move( PinPreviousPos );
|
||||
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode,
|
||||
showOptions, DefaultTransform );
|
||||
}
|
||||
|
||||
printf("DrawMovePin\n");
|
||||
|
||||
auto p = aPanel->GetParent()->GetCrossHairPosition( true );
|
||||
|
||||
// Redraw pin in new position
|
||||
cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
|
||||
cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, g_XorMode,
|
||||
showOptions, DefaultTransform );
|
||||
cur_pin->Move(p);
|
||||
|
||||
PinPreviousPos = cur_pin->GetPosition();
|
||||
auto view = parent->GetCanvas()->GetView();
|
||||
|
||||
/* Keep the original position for existing pin (for Undo command)
|
||||
* and the current position for a new pin */
|
||||
if( !cur_pin->IsNew() )
|
||||
cur_pin->Move( pinpos );
|
||||
auto copy_pin = static_cast<LIB_PIN*>( cur_pin->Clone() );
|
||||
|
||||
view->Hide( cur_pin );
|
||||
view->ClearPreview();
|
||||
view->AddToPreview( copy_pin );
|
||||
}
|
||||
|
||||
|
||||
|
@ -386,7 +387,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
|
|||
if( SynchronizePins() )
|
||||
pin->SetFlags( IS_LINKED );
|
||||
|
||||
pin->Move( GetCrossHairPosition( true ) );
|
||||
pin->Move( GetCrossHairPosition( ) );
|
||||
pin->SetLength( GetLastPinLength() );
|
||||
pin->SetOrientation( LastPinOrient );
|
||||
pin->SetType( LastPinType );
|
||||
|
@ -396,7 +397,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
|
|||
pin->SetConvert( LastPinCommonConvert ? 0 : m_convert );
|
||||
pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
|
||||
pin->SetVisible( LastPinVisible );
|
||||
PinPreviousPos = pin->GetPosition();
|
||||
//PinPreviousPos = pin->GetPosition();
|
||||
m_canvas->SetIgnoreMouseEvents( true );
|
||||
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
||||
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
||||
|
@ -412,22 +413,6 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
|
|||
{
|
||||
ClearTempCopyComponent();
|
||||
m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove );
|
||||
|
||||
if( DC )
|
||||
{
|
||||
int show_opts = PIN_DRAW_TEXTS | PIN_DRAW_DANGLING | PIN_DANGLING_HIDDEN;
|
||||
|
||||
if( GetShowElectricalType() )
|
||||
show_opts |= PIN_DRAW_ELECTRICAL_TYPE_NAME;
|
||||
|
||||
// In LIB_PIN::Draw() a void* parameter used as flag to pass show_opts.
|
||||
// Build it:
|
||||
void* showOptions = reinterpret_cast<void*>( show_opts );
|
||||
|
||||
pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED, GR_COPY,
|
||||
showOptions, DefaultTransform );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <base_units.h>
|
||||
#include <msgpanel.h>
|
||||
|
@ -43,6 +43,7 @@
|
|||
#include <lib_rectangle.h>
|
||||
#include <lib_text.h>
|
||||
|
||||
#include <sch_view.h>
|
||||
#include <dialogs/dialog_lib_edit_draw_item.h>
|
||||
|
||||
|
||||
|
@ -102,12 +103,13 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
|
|||
DrawItem->GetMsgPanelInfo( m_UserUnits, items );
|
||||
SetMsgPanel( items );
|
||||
m_canvas->Refresh();
|
||||
RebuildView();
|
||||
}
|
||||
|
||||
|
||||
static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
||||
static void AbortSymbolTraceOn( EDA_DRAW_PANEL* aPanel, wxDC* DC )
|
||||
{
|
||||
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) Panel->GetParent();
|
||||
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
|
||||
LIB_ITEM* item = parent->GetDrawItem();
|
||||
|
||||
if( item == NULL )
|
||||
|
@ -124,7 +126,13 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
|||
parent->RestoreComponent();
|
||||
|
||||
parent->SetDrawItem( NULL );
|
||||
Panel->Refresh();
|
||||
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(aPanel)->GetView();
|
||||
view->ClearPreview();
|
||||
view->ShowPreview( false );
|
||||
view->ClearHiddenFlags();
|
||||
printf("abort\n");
|
||||
parent->RebuildView();
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,6 +146,9 @@ LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_PART* LibEntry, wxDC* DC )
|
|||
// This is normal when adding new items to the current symbol
|
||||
ClearTempCopyComponent();
|
||||
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
|
||||
view->ShowPreview( true );
|
||||
|
||||
switch( GetToolId() )
|
||||
{
|
||||
case ID_LIBEDIT_BODY_ARC_BUTT:
|
||||
|
@ -227,13 +238,13 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
|
|||
|
||||
wxPoint pos = GetCrossHairPosition( true );
|
||||
|
||||
if( GetDrawItem()->ContinueEdit( pos ) )
|
||||
{
|
||||
GetDrawItem()->Draw( m_canvas, DC, pos, COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
return;
|
||||
}
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
|
||||
view->ShowPreview( true );
|
||||
|
||||
|
||||
if( GetDrawItem()->ContinueEdit( pos ) )
|
||||
return;
|
||||
|
||||
EndDrawGraphicItem( DC );
|
||||
}
|
||||
|
||||
|
@ -251,22 +262,21 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
|
|||
if( item == NULL )
|
||||
return;
|
||||
|
||||
item->SetEraseLastDrawItem( aErase );
|
||||
printf("CalcDraw!\n");
|
||||
|
||||
// if item is the reference field, we must add the current unit id
|
||||
if( item->Type() == LIB_FIELD_T )
|
||||
{
|
||||
int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit();
|
||||
wxString text = ((LIB_FIELD*)item)->GetFullText( unit );
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(aPanel)->GetView();
|
||||
|
||||
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
|
||||
COLOR4D::UNSPECIFIED, g_XorMode, &text,
|
||||
DefaultTransform );
|
||||
}
|
||||
else
|
||||
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
|
||||
COLOR4D::UNSPECIFIED, g_XorMode, NULL,
|
||||
DefaultTransform );
|
||||
auto p = aPanel->GetParent()->GetCrossHairPosition( true );
|
||||
|
||||
item->CalcEdit( p );
|
||||
|
||||
printf("cp: %d %d %d %d\n", item->GetPosition().x, item->GetPosition().y, p.x, p.y );
|
||||
|
||||
view->ClearPreview();
|
||||
|
||||
auto copy = static_cast<LIB_ITEM*>( item->Clone() );
|
||||
printf("cp: %d %d\n", copy->GetPosition().x, copy->GetPosition().y );
|
||||
view->AddToPreview( copy );
|
||||
}
|
||||
|
||||
|
||||
|
@ -277,6 +287,8 @@ void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC, LIB_ITEM* aItem )
|
|||
|
||||
SetCursor( wxCURSOR_HAND );
|
||||
|
||||
GetGalCanvas()->GetView()->Hide ( aItem );
|
||||
|
||||
TempCopyComponent();
|
||||
|
||||
// For fields only, move the anchor point of the field
|
||||
|
@ -296,6 +308,8 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC, LIB_ITEM* aItem )
|
|||
if( aItem == NULL )
|
||||
return;
|
||||
|
||||
printf("startmdifyraw\n");
|
||||
|
||||
TempCopyComponent();
|
||||
aItem->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) );
|
||||
m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
|
||||
|
@ -312,9 +326,16 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
|
|||
if( item == NULL )
|
||||
return;
|
||||
|
||||
item->SetEraseLastDrawItem( aErase );
|
||||
item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
|
||||
COLOR4D::UNSPECIFIED, g_XorMode, NULL, DefaultTransform );
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(aPanel)->GetView();
|
||||
|
||||
auto cp = aPanel->GetParent()->GetCrossHairPosition( true );
|
||||
|
||||
printf("SymbolDisplayDraw\n");
|
||||
|
||||
item->CalcEdit( cp );
|
||||
|
||||
view->ClearPreview();
|
||||
view->AddToPreview( item, false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -351,6 +372,14 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC )
|
|||
OnModify();
|
||||
|
||||
m_canvas->SetMouseCapture( NULL, NULL );
|
||||
m_canvas->Refresh();
|
||||
|
||||
auto view = static_cast<SCH_DRAW_PANEL*>(m_canvas)->GetView();
|
||||
|
||||
printf("end: pos %d %d\n", item->GetPosition().x, item->GetPosition().y );
|
||||
|
||||
view->ClearHiddenFlags();
|
||||
view->ClearPreview();
|
||||
RebuildView();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <kiway.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <kicad_string.h>
|
||||
#include <gestfich.h>
|
||||
|
@ -140,10 +140,10 @@ void LIB_EDIT_FRAME::LoadOneSymbol()
|
|||
|
||||
newItem->SetParent( part );
|
||||
part->AddDrawItem( newItem );
|
||||
item.ClearSelected();
|
||||
}
|
||||
|
||||
part->RemoveDuplicateDrawItems();
|
||||
part->ClearSelectedItems();
|
||||
|
||||
OnModify();
|
||||
m_canvas->Refresh();
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <kiway.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sim/sim_plot_frame.h>
|
||||
|
@ -50,6 +50,7 @@
|
|||
#include <netlist_object.h>
|
||||
#include <class_library.h> // for class SCHLIB_FILTER to filter power parts
|
||||
|
||||
#include <sch_view.h>
|
||||
|
||||
// TODO(hzeller): These pairs of elmenets should be represented by an object, but don't want
|
||||
// to refactor too much right now to not get in the way with other code changes.
|
||||
|
@ -61,6 +62,8 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
|||
{
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
wxPoint gridPosition = GetGridPosition( aPosition );
|
||||
printf("mousep %d %d gridp %d %d\n", aPosition.x, aPosition.y, gridPosition.x, gridPosition.y );
|
||||
|
||||
|
||||
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || ( item && item->GetFlags() ) )
|
||||
{
|
||||
|
@ -85,6 +88,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
|||
case SCH_BITMAP_T:
|
||||
case SCH_NO_CONNECT_T:
|
||||
addCurrentItemToList();
|
||||
GetCanvas()->GetView()->ClearPreview();
|
||||
return;
|
||||
|
||||
case SCH_LINE_T: // May already be drawing segment.
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <menus_helpers.h>
|
||||
|
@ -76,6 +76,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
bool blockActive = GetScreen()->IsBlockActive();
|
||||
wxString msg;
|
||||
|
||||
printf("on-rclick cur %p blk %d\n", item, blockActive ? 1 : 0 );
|
||||
|
||||
// Do not start a block command on context menu.
|
||||
m_canvas->SetCanStartBlock( -1 );
|
||||
|
||||
|
@ -140,6 +142,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
|
|||
bool actionCancelled = false;
|
||||
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled );
|
||||
|
||||
printf("Locateandshow %d %d item %p\n", aPosition.x, aPosition.y, item );
|
||||
|
||||
// If the clarify item selection context menu is aborted, don't show the context menu.
|
||||
if( item == NULL && actionCancelled )
|
||||
return false;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <general.h>
|
||||
|
@ -215,7 +215,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend )
|
|||
{
|
||||
aItem->SetFlags( STRUCT_DELETED );
|
||||
SaveCopyInUndoList( aItem, UR_DELETED, aAppend );
|
||||
screen->Remove( aItem );
|
||||
RemoveFromScreen( aItem );
|
||||
|
||||
std::vector< wxPoint > pts;
|
||||
aItem->GetConnectionPoints( pts );
|
||||
|
@ -231,7 +231,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend )
|
|||
}
|
||||
|
||||
|
||||
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
|
||||
void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
|
||||
const wxPoint& aMoveVector )
|
||||
{
|
||||
SCH_ITEM* newitem;
|
||||
|
@ -286,7 +286,7 @@ void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
|
|||
}
|
||||
|
||||
SetSchItemParent( newitem, screen );
|
||||
screen->Append( newitem );
|
||||
AddToScreen( newitem );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <base_units.h>
|
||||
#include <lib_edit_frame.h>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <class_library.h>
|
||||
#include <confirm.h>
|
||||
#include <invoke_sch_dialog.h>
|
||||
|
|
|
@ -24,8 +24,12 @@
|
|||
|
||||
#include <base_units.h>
|
||||
#include <kiway.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <class_library.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <lib_edit_frame.h>
|
||||
|
@ -330,3 +334,222 @@ bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
|
|||
|
||||
return success;
|
||||
}
|
||||
|
||||
void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
|
||||
{
|
||||
auto galCanvas = GetGalCanvas();
|
||||
auto 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;
|
||||
}
|
||||
|
||||
view->SetScale( scale / margin_scale_factor );
|
||||
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 Rect */
|
||||
void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& Rect )
|
||||
{
|
||||
auto view = GetGalCanvas()->GetView();
|
||||
BOX2I selectionBox ( Rect.GetPosition(), Rect.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;
|
||||
|
||||
view->SetScale( scale );
|
||||
view->SetCenter( selectionBox.Centre() );
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
|
||||
{
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
|
||||
{
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
SCH_DRAW_PANEL *SCH_BASE_FRAME::GetCanvas() const
|
||||
{
|
||||
return static_cast<SCH_DRAW_PANEL*>( GetGalCanvas() );
|
||||
}
|
||||
|
||||
|
||||
bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
|
||||
int aExplicitCommand )
|
||||
{
|
||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||
|
||||
if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
|
||||
return false;
|
||||
|
||||
if( aExplicitCommand == 0 )
|
||||
block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
|
||||
else
|
||||
block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
|
||||
|
||||
if( block->GetCommand() == 0 )
|
||||
return false;
|
||||
|
||||
switch( block->GetCommand() )
|
||||
{
|
||||
case BLOCK_IDLE:
|
||||
break;
|
||||
|
||||
case BLOCK_MOVE: // Move
|
||||
case BLOCK_DRAG: // Drag (block defined)
|
||||
case BLOCK_DRAG_ITEM: // Drag from a drag item command
|
||||
case BLOCK_DUPLICATE: // Duplicate
|
||||
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
|
||||
case BLOCK_DELETE: // Delete
|
||||
case BLOCK_COPY: // Copy
|
||||
case BLOCK_ROTATE: // Rotate 90 deg
|
||||
case BLOCK_FLIP: // Flip
|
||||
case BLOCK_ZOOM: // Window Zoom
|
||||
case BLOCK_MIRROR_X:
|
||||
case BLOCK_MIRROR_Y: // mirror
|
||||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
||||
block->InitData( m_canvas, aPosition );
|
||||
GetCanvas()->GetView()->ShowSelectionArea();
|
||||
break;
|
||||
|
||||
case BLOCK_PASTE:
|
||||
block->InitData( m_canvas, aPosition );
|
||||
GetCanvas()->GetView()->ShowSelectionArea();
|
||||
block->SetLastCursorPosition( wxPoint( 0, 0 ) );
|
||||
InitBlockPasteInfos();
|
||||
|
||||
if( block->GetCount() == 0 ) // No data to paste
|
||||
{
|
||||
DisplayError( this, wxT( "No block to paste" ), 20 );
|
||||
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
|
||||
m_canvas->SetMouseCaptureCallback( NULL );
|
||||
block->SetState( STATE_NO_BLOCK );
|
||||
block->SetMessageBlock( this );
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !m_canvas->IsMouseCaptured() )
|
||||
{
|
||||
block->ClearItemsList();
|
||||
DisplayError( this,
|
||||
wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
|
||||
block->SetState( STATE_NO_BLOCK );
|
||||
block->SetMessageBlock( this );
|
||||
return true;
|
||||
}
|
||||
|
||||
block->SetState( STATE_BLOCK_MOVE );
|
||||
m_canvas->CallMouseCapture( aDC, aPosition, false );
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
wxString msg;
|
||||
msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
|
||||
block->GetCommand();
|
||||
DisplayError( this, msg );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
block->SetMessageBlock( this );
|
||||
return true;
|
||||
}
|
||||
|
||||
void EDA_DRAW_FRAME::createCanvas()
|
||||
{
|
||||
KIGFX::GAL_DISPLAY_OPTIONS options;
|
||||
|
||||
m_canvas = new SCH_DRAW_PANEL( this, -1, wxPoint( 0,
|
||||
0 ), m_FrameSize, options, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
|
||||
|
||||
|
||||
m_useSingleCanvasPane = true;
|
||||
|
||||
SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
|
||||
UseGalCanvas( true );
|
||||
}
|
||||
|
||||
|
||||
void SCH_BASE_FRAME::AddToScreen( SCH_ITEM* aItem )
|
||||
{
|
||||
GetScreen()->Append( aItem );
|
||||
GetCanvas()->GetView()->Add( aItem );
|
||||
}
|
||||
|
||||
void SCH_BASE_FRAME::AddToScreen( DLIST<SCH_ITEM>& aItems )
|
||||
{
|
||||
std::vector<SCH_ITEM*> tmp;
|
||||
SCH_ITEM* itemList = aItems.begin();
|
||||
|
||||
while( itemList )
|
||||
{
|
||||
itemList->SetList( nullptr );
|
||||
GetCanvas()->GetView()->Add( itemList );
|
||||
itemList = itemList->Next();
|
||||
}
|
||||
|
||||
GetScreen()->Append( aItems );
|
||||
|
||||
}
|
||||
|
||||
void SCH_BASE_FRAME::RemoveFromScreen( SCH_ITEM* aItem )
|
||||
{
|
||||
GetCanvas()->GetView()->Remove( aItem );
|
||||
GetScreen()->Remove( aItem );
|
||||
}
|
||||
|
||||
void SCH_BASE_FRAME::SyncView()
|
||||
{
|
||||
auto screen = GetScreen();
|
||||
auto gal = GetGalCanvas()->GetGAL();
|
||||
|
||||
auto gs = screen->GetGridSize();
|
||||
|
||||
gal->SetGridSize( VECTOR2D( gs.x, gs.y ));
|
||||
|
||||
printf("SyncView: grid %d %d\n", (int)gs.x, (int)gs.y );
|
||||
|
||||
GetGalCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <draw_frame.h>
|
||||
|
||||
#include <sch_screen.h>
|
||||
#include "template_fieldnames.h"
|
||||
#include <sch_draw_panel.h>
|
||||
|
||||
class PAGE_INFO;
|
||||
class TITLE_BLOCK;
|
||||
|
@ -41,7 +41,7 @@ class PART_LIB;
|
|||
class SCHLIB_FILTER;
|
||||
class LIB_ID;
|
||||
class SYMBOL_LIB_TABLE;
|
||||
|
||||
class SCH_DRAW_PANEL;
|
||||
|
||||
/**
|
||||
* Load symbol from symbol library table.
|
||||
|
@ -78,12 +78,10 @@ LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable,
|
|||
class SCH_BASE_FRAME : public EDA_DRAW_FRAME
|
||||
{
|
||||
protected:
|
||||
TEMPLATES m_templateFieldNames;
|
||||
|
||||
wxPoint m_repeatStep; ///< the increment value of the position of an item
|
||||
///< when it is repeated
|
||||
int m_repeatDeltaLabel; ///< the increment value of labels like bus members
|
||||
///< when they are repeated
|
||||
wxPoint m_repeatStep; ///< the increment value of the position of an item
|
||||
///< when it is repeated
|
||||
int m_repeatDeltaLabel; ///< the increment value of labels like bus members
|
||||
///< when they are repeated
|
||||
|
||||
|
||||
public:
|
||||
|
@ -95,6 +93,7 @@ public:
|
|||
|
||||
virtual ~SCH_BASE_FRAME();
|
||||
|
||||
SCH_DRAW_PANEL *GetCanvas() const override;
|
||||
SCH_SCREEN* GetScreen() const override;
|
||||
|
||||
/**
|
||||
|
@ -209,27 +208,13 @@ public:
|
|||
|
||||
void OnConfigurePaths( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Return a template field names list for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames() const
|
||||
{
|
||||
return m_templateFieldNames.GetTemplateFieldNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for \a aName in the the template field name list.
|
||||
*
|
||||
* @param aName A wxString object containing the field name to search for.
|
||||
* @return the template fieldname if found; NULL otherwise.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAME* GetTemplateFieldName( const wxString& aName ) const
|
||||
{
|
||||
return m_templateFieldNames.GetFieldName( aName );
|
||||
}
|
||||
|
||||
virtual void OnEditSymbolLibTable( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Allows Eeschema to install the symbol library tables into the edit libraries dialog.
|
||||
*/
|
||||
void InstallLibraryTablesPanel( DIALOG_EDIT_LIBRARY_TABLES* aDialog ) override;
|
||||
|
||||
/**
|
||||
* Load symbol from symbol library table.
|
||||
*
|
||||
|
@ -240,7 +225,7 @@ public:
|
|||
* @return The symbol found in the library or NULL if the symbol was not found.
|
||||
*/
|
||||
LIB_ALIAS* GetLibAlias( const LIB_ID& aLibId, bool aUseCacheLib = false,
|
||||
bool aShowError = false );
|
||||
bool aShowErrorMsg = false );
|
||||
|
||||
LIB_PART* GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib = false,
|
||||
bool aShowErrorMsg = false );
|
||||
|
@ -264,6 +249,23 @@ 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& Rect ) override;
|
||||
|
||||
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) override;
|
||||
|
||||
virtual void RedrawScreen2( const wxPoint& posBefore ) override;
|
||||
|
||||
void AddToScreen( SCH_ITEM* aItem );
|
||||
void AddToScreen( DLIST<SCH_ITEM>& aItems );
|
||||
void RemoveFromScreen( SCH_ITEM* aItem );
|
||||
|
||||
void SyncView();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -319,6 +321,10 @@ protected:
|
|||
* @return True when all requested actions succeeded.
|
||||
*/
|
||||
bool saveSymbolLibTables( bool aGlobal, bool aProject );
|
||||
|
||||
virtual bool HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
|
||||
int aExplicitCommand = 0 ) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // SCH_BASE_FRAME_H_
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <trigo.h>
|
||||
#include <macros.h>
|
||||
#include <bitmaps.h>
|
||||
|
@ -128,7 +128,8 @@ void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset
|
|||
GRSetDrawMode( aDC, aDrawMode );
|
||||
#endif
|
||||
|
||||
m_image->DrawBitmap( aPanel, aDC, pos );
|
||||
//fixme-gal
|
||||
//m_image->DrawBitmap( aPanel, aDC, pos );
|
||||
}
|
||||
else // draws bounding box only (used to move items)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <trigo.h>
|
||||
#include <common.h>
|
||||
#include <richio.h>
|
||||
|
|
|
@ -48,6 +48,9 @@ protected:
|
|||
public:
|
||||
SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos = wxPoint( 0, 0 ), char shape = '\\' );
|
||||
|
||||
bool IsDanglingStart() const { return m_isDanglingStart; }
|
||||
bool IsDanglingEnd() const { return m_isDanglingEnd; }
|
||||
|
||||
// Do not create a copy constructor. The one generated by the compiler is adequate.
|
||||
|
||||
~SCH_BUS_ENTRY_BASE() { }
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <gr_basic.h>
|
||||
#include <kicad_string.h>
|
||||
#include <richio.h>
|
||||
|
|
|
@ -0,0 +1,670 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014-2017 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
|
||||
*/
|
||||
|
||||
|
||||
#include <view/wx_view_controls.h>
|
||||
#include <worksheet_viewitem.h>
|
||||
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <preview_items/selection_area.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <sch_sheet.h>
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
|
||||
SCH_DRAW_PANEL::SCH_DRAW_PANEL( 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, GAL_TYPE_OPENGL ),
|
||||
m_parent( aParentWindow )
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
m_defaultCursor = m_currentCursor = wxCURSOR_CROSS;
|
||||
m_showCrossHair = false;
|
||||
#else
|
||||
m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
|
||||
m_showCrossHair = true;
|
||||
#endif
|
||||
|
||||
m_view = new KIGFX::SCH_VIEW( true );
|
||||
m_view->SetGAL( m_gal );
|
||||
|
||||
|
||||
m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) );
|
||||
|
||||
m_view->SetPainter( m_painter.get() );
|
||||
m_view->SetScaleLimits( 2000000.0, 30000.0 );
|
||||
m_view->SetMirror( false, false );
|
||||
|
||||
setDefaultLayerOrder();
|
||||
setDefaultLayerDeps();
|
||||
|
||||
view()->UpdateAllLayersOrder();
|
||||
// View controls is the first in the event handler chain, so the Tool Framework operates
|
||||
// on updated viewport data.
|
||||
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
||||
|
||||
const wxEventType events[] =
|
||||
{
|
||||
wxEVT_LEFT_UP, wxEVT_LEFT_DOWN, wxEVT_LEFT_DCLICK,
|
||||
wxEVT_RIGHT_UP, wxEVT_RIGHT_DOWN, wxEVT_RIGHT_DCLICK,
|
||||
wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DOWN, wxEVT_MIDDLE_DCLICK,
|
||||
wxEVT_MOTION, wxEVT_MOUSEWHEEL,
|
||||
};
|
||||
|
||||
for( auto e : events )
|
||||
{
|
||||
Connect( e, wxMouseEventHandler( SCH_DRAW_PANEL::OnMouseEvent ),
|
||||
NULL, this );
|
||||
}
|
||||
|
||||
Connect( wxEVT_CHAR, wxKeyEventHandler( SCH_DRAW_PANEL::OnKeyEvent ), NULL, this );
|
||||
Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( SCH_DRAW_PANEL::OnCharHook ), NULL, this );
|
||||
|
||||
m_canStartBlock = -1; // Command block can start if >= 0
|
||||
m_abortRequest = false;
|
||||
m_enableMousewheelPan = false;
|
||||
m_enableZoomNoCenter = false;
|
||||
m_enableAutoPan = true;
|
||||
m_ignoreMouseEvents = false;
|
||||
// Be sure a mouse release button event will be ignored when creating the canvas
|
||||
// if the mouse click was not made inside the canvas (can happen sometimes, when
|
||||
// launching a editor from a double click made in another frame)
|
||||
m_ignoreNextLeftButtonRelease = true;
|
||||
|
||||
m_mouseCaptureCallback = NULL;
|
||||
m_endMouseCaptureCallback = NULL;
|
||||
|
||||
m_requestAutoPan = false;
|
||||
m_enableBlockCommands = false;
|
||||
m_minDragEventCount = 0;
|
||||
|
||||
|
||||
m_cursorLevel = 0;
|
||||
m_PrintIsMirrored = false;
|
||||
|
||||
m_ClickTimer = (wxTimer*) NULL;
|
||||
m_doubleClickInterval = 250;
|
||||
|
||||
m_gal->SetGridColor( COLOR4D(0.0, 0.0, 0.0, 1.0) );
|
||||
m_gal->SetCursorColor( COLOR4D(0.0, 0.0, 0.0, 1.0) );
|
||||
|
||||
m_viewControls->SetSnapping( true );
|
||||
|
||||
SetEvtHandlerEnabled( true );
|
||||
SetFocus();
|
||||
Show( true );
|
||||
Raise();
|
||||
StartDrawing();
|
||||
//printf("CreateGALPAnel\n");
|
||||
//m_selectionArea = new KIGFX::PREVIEW::SELECTION_AREA;
|
||||
}
|
||||
|
||||
|
||||
SCH_DRAW_PANEL::~SCH_DRAW_PANEL()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::DisplayComponent( const LIB_PART* aComponent )
|
||||
{
|
||||
view()->Clear();
|
||||
view()->DisplayComponent( const_cast<LIB_PART*>(aComponent) );
|
||||
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::DisplaySheet( const SCH_SHEET* aSheet )
|
||||
{
|
||||
view()->Clear();
|
||||
view()->DisplaySheet( const_cast<SCH_SHEET*>(aSheet) );
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::DisplaySheet( const SCH_SCREEN *aScreen )
|
||||
{
|
||||
view()->Clear();
|
||||
if( aScreen )
|
||||
view()->DisplaySheet( const_cast<SCH_SCREEN*>(aScreen) );
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::OnShow()
|
||||
{
|
||||
|
||||
//m_view->RecacheAllItems();
|
||||
}
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::setDefaultLayerOrder()
|
||||
{
|
||||
/* for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
||||
{
|
||||
LAYER_NUM layer = GAL_LAYER_ORDER[i];
|
||||
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
|
||||
|
||||
m_view->SetLayerOrder( layer, i );
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
bool SCH_DRAW_PANEL::SwitchBackend( GAL_TYPE aGalType )
|
||||
{
|
||||
bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
|
||||
setDefaultLayerDeps();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::setDefaultLayerDeps()
|
||||
{
|
||||
// caching makes no sense for Cairo and other software renderers
|
||||
auto target = KIGFX::TARGET_NONCACHED; //m_backend == GAL_TYPE_OPENGL ? KIGFX::TARGET_CACHED : KIGFX::TARGET_NONCACHED;
|
||||
|
||||
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
|
||||
m_view->SetLayerTarget( i, target );
|
||||
|
||||
m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY );
|
||||
|
||||
m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
|
||||
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
|
||||
m_view->SetLayerDisplayOnly( LAYER_DRC );
|
||||
}
|
||||
|
||||
|
||||
KIGFX::SCH_VIEW* SCH_DRAW_PANEL::view() const
|
||||
{
|
||||
return static_cast<KIGFX::SCH_VIEW*>( m_view );
|
||||
}
|
||||
|
||||
BASE_SCREEN* SCH_DRAW_PANEL::GetScreen()
|
||||
{
|
||||
return GetParent()->GetScreen();
|
||||
}
|
||||
|
||||
EDA_DRAW_FRAME* SCH_DRAW_PANEL::GetParent() const
|
||||
{
|
||||
return static_cast<EDA_DRAW_FRAME*>(m_parent); // static_cast<SCH_EDIT_FRAME*> (m_parent);
|
||||
}
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
|
||||
{
|
||||
int localbutt = 0;
|
||||
BASE_SCREEN* screen = GetScreen();
|
||||
auto controls = GetViewControls();
|
||||
auto vcp = VECTOR2I( controls->GetCursorPosition() );
|
||||
auto vmp = VECTOR2I( controls->GetMousePosition() );
|
||||
wxPoint cursorPos ( vcp.x, vcp.y );
|
||||
wxPoint mousePos ( vmp.x, vmp.y );
|
||||
|
||||
event.Skip();
|
||||
|
||||
if( !screen )
|
||||
return;
|
||||
|
||||
/* Adjust value to filter mouse displacement before consider the drag
|
||||
* mouse is really a drag command, not just a movement while click
|
||||
*/
|
||||
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
|
||||
|
||||
if( event.Leaving() )
|
||||
m_canStartBlock = -1;
|
||||
|
||||
if( !IsMouseCaptured() ) // No mouse capture in progress.
|
||||
m_requestAutoPan = false;
|
||||
|
||||
if( GetParent()->IsActive() )
|
||||
SetFocus();
|
||||
else
|
||||
return;
|
||||
|
||||
if( !event.IsButton() && !event.Moving() && !event.Dragging() )
|
||||
return;
|
||||
|
||||
if( event.RightDown() )
|
||||
{
|
||||
OnRightClick( event );
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_ignoreMouseEvents )
|
||||
return;
|
||||
|
||||
if( event.LeftDown() )
|
||||
localbutt = GR_M_LEFT_DOWN;
|
||||
|
||||
if( event.ButtonDClick( 1 ) )
|
||||
localbutt = GR_M_LEFT_DOWN | GR_M_DCLICK;
|
||||
|
||||
if( event.MiddleDown() )
|
||||
localbutt = GR_M_MIDDLE_DOWN;
|
||||
|
||||
// Compute the cursor position in drawing (logical) units.
|
||||
//GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );
|
||||
|
||||
int kbstat = 0;
|
||||
|
||||
if( event.ShiftDown() )
|
||||
kbstat |= GR_KB_SHIFT;
|
||||
|
||||
if( event.ControlDown() )
|
||||
kbstat |= GR_KB_CTRL;
|
||||
|
||||
if( event.AltDown() )
|
||||
kbstat |= GR_KB_ALT;
|
||||
|
||||
// Calling Double Click and Click functions :
|
||||
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
|
||||
{
|
||||
if( m_ClickTimer )
|
||||
{
|
||||
m_ClickTimer->Stop();
|
||||
wxDELETE( m_ClickTimer );
|
||||
}
|
||||
GetParent()->OnLeftDClick( nullptr, mousePos );
|
||||
|
||||
// inhibit a response to the mouse left button release,
|
||||
// because we have a double click, and we do not want a new
|
||||
// OnLeftClick command at end of this Double Click
|
||||
m_ignoreNextLeftButtonRelease = true;
|
||||
}
|
||||
else if( event.LeftUp() )
|
||||
{
|
||||
// A block command is in progress: a left up is the end of block
|
||||
// or this is the end of a double click, already seen
|
||||
// Note also m_ignoreNextLeftButtonRelease can be set by
|
||||
// the call to OnLeftClick(), so do not change it after calling OnLeftClick
|
||||
bool ignoreEvt = m_ignoreNextLeftButtonRelease;
|
||||
m_ignoreNextLeftButtonRelease = false;
|
||||
|
||||
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
|
||||
{
|
||||
EDA_ITEM* item = screen->GetCurItem();
|
||||
|
||||
// If we have an item already selected, or we are using a tool,
|
||||
// we won't use the disambiguation menu so process the click immediately
|
||||
if( ( item && item->GetFlags() ) || GetParent()->GetToolId() != ID_NO_TOOL_SELECTED )
|
||||
GetParent()->OnLeftClick( nullptr, mousePos );
|
||||
else
|
||||
{
|
||||
wxDELETE( m_ClickTimer );
|
||||
m_ClickTimer = new wxTimer(this, ID_MOUSE_DOUBLECLICK);
|
||||
m_ClickTimer->StartOnce( m_doubleClickInterval );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if( !event.LeftIsDown() )
|
||||
{
|
||||
/* be sure there is a response to a left button release command
|
||||
* even when a LeftUp event is not seen. This happens when a
|
||||
* double click opens a dialog box, and the release mouse button
|
||||
* is made when the dialog box is opened.
|
||||
*/
|
||||
m_ignoreNextLeftButtonRelease = false;
|
||||
}
|
||||
|
||||
if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) )
|
||||
{
|
||||
m_PanStartCenter = GetParent()->GetScrollCenterPosition();
|
||||
m_PanStartEventPosition = event.GetPosition();
|
||||
|
||||
// INSTALL_UNBUFFERED_DC( dc, this );
|
||||
CrossHairOff( );
|
||||
SetCurrentCursor( wxCURSOR_SIZING );
|
||||
}
|
||||
|
||||
if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) )
|
||||
{
|
||||
// INSTALL_UNBUFFERED_DC( dc, this );
|
||||
CrossHairOn();
|
||||
SetCursor( (wxStockCursor) m_defaultCursor );
|
||||
}
|
||||
|
||||
if( event.MiddleIsDown() )
|
||||
{
|
||||
wxPoint currentPosition = event.GetPosition();
|
||||
|
||||
double scale = GetParent()->GetScreen()->GetScalingFactor();
|
||||
int x = m_PanStartCenter.x +
|
||||
KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
|
||||
int y = m_PanStartCenter.y +
|
||||
KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
|
||||
|
||||
GetParent()->RedrawScreen( wxPoint( x, y ), false );
|
||||
}
|
||||
|
||||
// Calling the general function on mouse changes (and pseudo key commands)
|
||||
GetParent()->GeneralControl( nullptr, wxPoint(0, 0), /*event.GetLogicalPosition( DC )*/ 0 );
|
||||
|
||||
/*******************************/
|
||||
/* Control of block commands : */
|
||||
/*******************************/
|
||||
|
||||
// Command block can't start if mouse is dragging a new panel
|
||||
static SCH_DRAW_PANEL* lastPanel;
|
||||
if( lastPanel != this )
|
||||
{
|
||||
m_minDragEventCount = 0;
|
||||
m_canStartBlock = -1;
|
||||
}
|
||||
|
||||
/* A new command block can start after a release buttons
|
||||
* and if the drag is enough
|
||||
* This is to avoid a false start block when a dialog box is dismissed,
|
||||
* or when changing panels in hierarchy navigation
|
||||
* or when clicking while and moving mouse
|
||||
*/
|
||||
if( !event.LeftIsDown() && !event.MiddleIsDown() )
|
||||
{
|
||||
m_minDragEventCount = 0;
|
||||
m_canStartBlock = 0;
|
||||
|
||||
/* Remember the last cursor position when a drag mouse starts
|
||||
* this is the last position ** before ** clicking a button
|
||||
* this is useful to start a block command from the point where the
|
||||
* mouse was clicked first
|
||||
* (a filter creates a delay for the real block command start, and
|
||||
* we must remember this point)
|
||||
*/
|
||||
m_CursorStartPos = GetParent()->GetCrossHairPosition();
|
||||
}
|
||||
|
||||
if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
|
||||
{
|
||||
if( !screen->IsBlockActive() )
|
||||
{
|
||||
screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
|
||||
}
|
||||
|
||||
if( event.LeftDown() )
|
||||
{
|
||||
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
|
||||
{
|
||||
m_requestAutoPan = false;
|
||||
GetParent()->HandleBlockPlace( nullptr );
|
||||
m_ignoreNextLeftButtonRelease = true;
|
||||
}
|
||||
}
|
||||
else if( ( m_canStartBlock >= 0 ) && event.LeftIsDown() && !IsMouseCaptured() )
|
||||
{
|
||||
// Mouse is dragging: if no block in progress, start a block command.
|
||||
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
|
||||
{
|
||||
// Start a block command
|
||||
int cmd_type = kbstat;
|
||||
|
||||
// A block command is started if the drag is enough. A small
|
||||
// drag is ignored (it is certainly a little mouse move when
|
||||
// clicking) not really a drag mouse
|
||||
if( m_minDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
|
||||
m_minDragEventCount++;
|
||||
else
|
||||
{
|
||||
auto cmd = (GetParent()->GetToolId() == ID_ZOOM_SELECTION) ? BLOCK_ZOOM : 0;
|
||||
|
||||
printf("start block\n");
|
||||
|
||||
if( !GetParent()->HandleBlockBegin( nullptr, cmd_type, m_CursorStartPos, cmd ) )
|
||||
{
|
||||
// should not occur: error
|
||||
GetParent()->DisplayToolMsg(
|
||||
wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_requestAutoPan = true;
|
||||
SetCursor( wxCURSOR_SIZING );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( event.ButtonUp( wxMOUSE_BTN_LEFT ) )
|
||||
{
|
||||
/* Release the mouse button: end of block.
|
||||
* The command can finish (DELETE) or have a next command (MOVE,
|
||||
* COPY). However the block command is canceled if the block
|
||||
* size is small because a block command filtering is already
|
||||
* made, this case happens, but only when the on grid cursor has
|
||||
* not moved.
|
||||
*/
|
||||
#define BLOCK_MINSIZE_LIMIT 1
|
||||
bool BlockIsSmall =
|
||||
( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
|
||||
&& ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
|
||||
|
||||
if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
|
||||
{
|
||||
if( m_endMouseCaptureCallback )
|
||||
{
|
||||
m_endMouseCaptureCallback( this, nullptr );
|
||||
m_requestAutoPan = false;
|
||||
}
|
||||
|
||||
//SetCursor( (wxStockCursor) m_currentCursor );
|
||||
}
|
||||
else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
|
||||
{
|
||||
m_requestAutoPan = false;
|
||||
GetParent()->HandleBlockEnd( nullptr );
|
||||
//SetCursor( (wxStockCursor) m_currentCursor );
|
||||
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
|
||||
{
|
||||
m_requestAutoPan = true;
|
||||
SetCursor( wxCURSOR_HAND );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End of block command on a double click
|
||||
// To avoid an unwanted block move command if the mouse is moved while double clicking
|
||||
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
|
||||
{
|
||||
if( !screen->IsBlockActive() && IsMouseCaptured() )
|
||||
{
|
||||
m_endMouseCaptureCallback( this, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
lastPanel = this;
|
||||
|
||||
}
|
||||
|
||||
bool SCH_DRAW_PANEL::OnRightClick( wxMouseEvent& event )
|
||||
{
|
||||
auto controls = GetViewControls();
|
||||
auto vmp = controls->GetMousePosition();
|
||||
auto vsp = GetView()->ToScreen( vmp );
|
||||
wxPoint mouseWorldPos ( (int) vmp.x, (int) vmp.y );
|
||||
wxPoint mouseScreenPos ( (int) vsp.x, (int) vsp.y );
|
||||
|
||||
wxMenu MasterMenu;
|
||||
|
||||
if( !GetParent()->OnRightClick( mouseWorldPos, &MasterMenu ) )
|
||||
return false;
|
||||
|
||||
GetParent()->AddMenuZoomAndGrid( &MasterMenu );
|
||||
|
||||
m_ignoreMouseEvents = true;
|
||||
PopupMenu( &MasterMenu, event.GetPosition() );
|
||||
m_ignoreMouseEvents = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase )
|
||||
{
|
||||
wxCHECK_RET( m_mouseCaptureCallback != NULL, wxT( "Mouse capture callback not set." ) );
|
||||
|
||||
m_mouseCaptureCallback( this, aDC, aPosition, aErase );
|
||||
}
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::CallEndMouseCapture( wxDC* aDC )
|
||||
{
|
||||
|
||||
// CallEndMouseCapture is sometimes called with m_endMouseCaptureCallback == NULL
|
||||
// for instance after an ABORT in block paste.
|
||||
if( m_endMouseCaptureCallback )
|
||||
m_endMouseCaptureCallback( this, aDC );
|
||||
}
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::EndMouseCapture( int id, int cursor, const wxString& title,
|
||||
bool aCallEndFunc )
|
||||
{
|
||||
if( m_mouseCaptureCallback && m_endMouseCaptureCallback && aCallEndFunc )
|
||||
{
|
||||
m_endMouseCaptureCallback( this, nullptr );
|
||||
}
|
||||
|
||||
m_mouseCaptureCallback = NULL;
|
||||
m_endMouseCaptureCallback = NULL;
|
||||
m_requestAutoPan = false;
|
||||
|
||||
if( id != -1 && cursor != -1 )
|
||||
{
|
||||
//wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );
|
||||
GetParent()->SetToolID( id, cursor, title );
|
||||
}
|
||||
}
|
||||
|
||||
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::Refresh( bool aEraseBackground, const wxRect* aRect )
|
||||
{
|
||||
EDA_DRAW_PANEL_GAL::Refresh( aEraseBackground, aRect );
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::OnCharHook( wxKeyEvent& event )
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
|
||||
{
|
||||
int localkey;
|
||||
|
||||
localkey = event.GetKeyCode();
|
||||
|
||||
switch( localkey )
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case WXK_ESCAPE:
|
||||
m_abortRequest = true;
|
||||
|
||||
if( IsMouseCaptured() )
|
||||
EndMouseCapture();
|
||||
else
|
||||
EndMouseCapture( ID_NO_TOOL_SELECTED, 0 /*m_defaultCursor*/, wxEmptyString );
|
||||
break;
|
||||
}
|
||||
|
||||
/* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
|
||||
* They have an ascii code from 1 to 27 remapped
|
||||
* to GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z'
|
||||
*/
|
||||
if( event.ControlDown() && localkey >= WXK_CONTROL_A && localkey <= WXK_CONTROL_Z )
|
||||
localkey += 'A' - 1;
|
||||
|
||||
/* Disallow shift for keys that have two keycodes on them (e.g. number and
|
||||
* punctuation keys) leaving only the "letter keys" of A-Z.
|
||||
* Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
|
||||
* and Ctrl-( and Ctrl-5 (FR layout).
|
||||
* Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
|
||||
*/
|
||||
bool keyIsLetter = ( localkey >= 'A' && localkey <= 'Z' ) ||
|
||||
( localkey >= 'a' && localkey <= 'z' );
|
||||
|
||||
if( event.ShiftDown() && ( keyIsLetter || localkey > 256 ) )
|
||||
localkey |= GR_KB_SHIFT;
|
||||
|
||||
if( event.ControlDown() )
|
||||
localkey |= GR_KB_CTRL;
|
||||
|
||||
if( event.AltDown() )
|
||||
localkey |= GR_KB_ALT;
|
||||
|
||||
|
||||
// Some key commands use the current mouse position: refresh it.
|
||||
//pos = wxGetMousePosition() - GetScreenPosition();
|
||||
|
||||
// Compute the cursor position in drawing units. Also known as logical units to wxDC.
|
||||
//pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );
|
||||
|
||||
auto p = GetViewControls()->GetMousePosition();
|
||||
|
||||
wxPoint pos ((int)p.x, (int)p.y);
|
||||
|
||||
GetParent()->SetMousePosition( pos );
|
||||
|
||||
if( !GetParent()->GeneralControl( nullptr, pos, localkey ) )
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::SetCurrentCursor( int aCursor )
|
||||
{
|
||||
m_currentCursor = aCursor;
|
||||
SetCursor( (wxStockCursor) m_currentCursor );
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::SetCurrentCursor( const wxCursor& aCursor )
|
||||
{
|
||||
SetCursor( aCursor );
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::SetDefaultCursor()
|
||||
{
|
||||
SetCursor( (wxStockCursor) m_defaultCursor );
|
||||
}
|
||||
|
||||
void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent )
|
||||
{
|
||||
if( m_painter )
|
||||
static_cast<KIGFX::SCH_PAINTER*>(m_painter.get())->GetSettings()->ImportLegacyColors( nullptr );
|
||||
|
||||
EDA_DRAW_PANEL_GAL::onPaint( aEvent );
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
#ifndef __SCH_DRAW_PANEL_H
|
||||
#define __SCH_DRAW_PANEL_H
|
||||
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <base_struct.h>
|
||||
#include <gr_basic.h>
|
||||
#include <eda_rect.h>
|
||||
|
||||
#include <class_drawpanel.h>
|
||||
|
||||
|
||||
namespace KIGFX {
|
||||
class SCH_VIEW;
|
||||
namespace PREVIEW {
|
||||
class SELECTION_AREA;
|
||||
};
|
||||
};
|
||||
|
||||
class SCH_SHEET;
|
||||
class LIB_PART;
|
||||
class BASE_SCREEN;
|
||||
class SCH_SCREEN;
|
||||
class COLORS_DESIGN_SETTINGS;
|
||||
class SCH_EDIT_FRAME;
|
||||
|
||||
class SCH_DRAW_PANEL : public EDA_DRAW_PANEL, public EDA_DRAW_PANEL_GAL
|
||||
{
|
||||
public:
|
||||
SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
|
||||
const wxSize& aSize, KIGFX::GAL_DISPLAY_OPTIONS& aOptions,
|
||||
GAL_TYPE aGalType = GAL_TYPE_OPENGL );
|
||||
|
||||
~SCH_DRAW_PANEL();
|
||||
|
||||
virtual wxWindow* GetWindow() override { return this; };
|
||||
|
||||
/**
|
||||
* Function DisplayBoard FIXME
|
||||
* adds all items from the current board to the VIEW, so they can be displayed by GAL.
|
||||
* @param aBoard is the PCB to be loaded.
|
||||
*/
|
||||
void DisplayComponent( const LIB_PART *aComponent );
|
||||
void DisplaySheet( const SCH_SHEET *aSheet );
|
||||
void DisplaySheet( const SCH_SCREEN *aScreen );
|
||||
|
||||
/**
|
||||
* Function UseColorScheme
|
||||
* Applies layer color settings.
|
||||
* @param aSettings are the new settings.
|
||||
*/
|
||||
void UseColorScheme( const COLORS_DESIGN_SETTINGS* aSettings );
|
||||
|
||||
///> @copydoc EDA_DRAW_PANEL_GAL::OnShow()
|
||||
void OnShow() override;
|
||||
|
||||
bool SwitchBackend( GAL_TYPE aGalType ) override;
|
||||
void OnMouseEvent( wxMouseEvent& event );
|
||||
bool OnRightClick( wxMouseEvent& event );
|
||||
void OnKeyEvent( wxKeyEvent& event );
|
||||
void OnCharHook( wxKeyEvent& event );
|
||||
|
||||
BASE_SCREEN* GetScreen() override;
|
||||
virtual EDA_DRAW_FRAME* GetParent() const override;
|
||||
|
||||
virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) override;
|
||||
virtual void CallEndMouseCapture( wxDC* aDC ) override;
|
||||
virtual void EndMouseCapture( int aId = -1, int aCursorId = -1,
|
||||
const wxString& aTitle = wxEmptyString,
|
||||
bool aCallEndFunc = true ) override;
|
||||
|
||||
virtual void CrossHairOff( wxDC* DC=nullptr ) override;
|
||||
|
||||
// Show the cross hair.
|
||||
virtual void CrossHairOn( wxDC* DC=nullptr ) override;
|
||||
|
||||
KIGFX::SCH_VIEW* GetView() const { return view(); }
|
||||
|
||||
/// @copydoc wxWindow::Refresh()
|
||||
void Refresh( bool aEraseBackground = true, const wxRect* aRect = NULL ) override;
|
||||
|
||||
virtual void SetCurrentCursor( int aCursor ) override;
|
||||
virtual void SetCurrentCursor( const wxCursor& aCursor ) override;
|
||||
virtual void SetDefaultCursor() override;
|
||||
|
||||
virtual int GetDefaultCursor() const override
|
||||
{
|
||||
return EDA_DRAW_PANEL_GAL::GetDefaultCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetCurrentCursor
|
||||
* @return the current cursor shape, depending on the current selected tool
|
||||
*/
|
||||
virtual int GetCurrentCursor() const override
|
||||
{
|
||||
return EDA_DRAW_PANEL_GAL::GetCurrentCursor();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) override;
|
||||
|
||||
KIGFX::SCH_VIEW* view() const;
|
||||
|
||||
///> Reassigns layer order to the initial settings.
|
||||
void setDefaultLayerOrder();
|
||||
|
||||
///> Sets rendering targets & dependencies for layers.
|
||||
void setDefaultLayerDeps();
|
||||
|
||||
wxWindow* m_parent;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -30,7 +30,7 @@
|
|||
#include <kiface_i.h>
|
||||
#include <pgm_base.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <gestfich.h>
|
||||
#include <confirm.h>
|
||||
#include <base_units.h>
|
||||
|
@ -61,6 +61,8 @@
|
|||
#include <invoke_sch_dialog.h>
|
||||
#include <dialogs/dialog_schematic_find.h>
|
||||
#include <dialog_symbol_remap.h>
|
||||
#include <view/view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <wx/display.h>
|
||||
#include <build_version.h>
|
||||
|
@ -70,6 +72,11 @@
|
|||
#include <kiway.h>
|
||||
#include <dialogs/dialog_fields_editor_global.h>
|
||||
|
||||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
// non-member so it can be moved easily, and kept REALLY private.
|
||||
// Do NOT Clear() in here.
|
||||
static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
|
||||
|
@ -376,6 +383,9 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
m_undoItem = NULL;
|
||||
m_hasAutoSave = true;
|
||||
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
|
||||
|
||||
SetForceHVLines( true );
|
||||
SetSpiceAjustPassiveValues( false );
|
||||
|
||||
|
@ -398,7 +408,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
|
||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
m_canvas->SetEnableBlockCommands( true );
|
||||
if( m_canvas )
|
||||
m_canvas->SetEnableBlockCommands( true );
|
||||
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
|
@ -417,7 +428,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
|||
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
||||
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
|
||||
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
|
||||
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
||||
|
||||
m_auimgr.Update();
|
||||
|
@ -569,7 +580,9 @@ SCH_SHEET_PATH& SCH_EDIT_FRAME::GetCurrentSheet()
|
|||
|
||||
void SCH_EDIT_FRAME::SetCurrentSheet( const SCH_SHEET_PATH& aSheet )
|
||||
{
|
||||
auto c = static_cast<SCH_DRAW_PANEL*>(m_canvas);
|
||||
*m_CurrentSheet = aSheet;
|
||||
c->DisplaySheet( m_CurrentSheet->LastScreen() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1386,9 +1399,6 @@ void SCH_EDIT_FRAME::addCurrentItemToList( bool aRedraw )
|
|||
screen->SetCurItem( NULL );
|
||||
delete item;
|
||||
|
||||
if( aRedraw )
|
||||
GetCanvas()->Refresh();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1398,7 +1408,7 @@ void SCH_EDIT_FRAME::addCurrentItemToList( bool aRedraw )
|
|||
if( undoItem == item )
|
||||
{
|
||||
if( !screen->CheckIfOnDrawList( item ) ) // don't want a loop!
|
||||
screen->Append( item );
|
||||
AddToScreen( item );
|
||||
|
||||
SetRepeatItem( item );
|
||||
|
||||
|
@ -1516,4 +1526,21 @@ void SCH_EDIT_FRAME::ShowChangedLanguage()
|
|||
UpdateMsgPanel();
|
||||
}
|
||||
|
||||
void SCH_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
|
||||
{
|
||||
EDA_DRAW_FRAME::SetScreen( aScreen );
|
||||
auto c = static_cast<SCH_DRAW_PANEL*>(m_canvas);
|
||||
c->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
|
||||
auto bb = c->GetView()->CalculateExtents() ;
|
||||
BOX2D bb2 ( bb.GetOrigin(), bb.GetSize() );
|
||||
c->GetView()->SetViewport( bb2 );
|
||||
}
|
||||
|
||||
const BOX2I SCH_EDIT_FRAME::GetDocumentExtents() const
|
||||
{
|
||||
int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
|
||||
int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
|
||||
|
||||
return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <template_fieldnames.h>
|
||||
#include <block_commande.h>
|
||||
#include <sch_collectors.h>
|
||||
#include <sch_draw_panel.h>
|
||||
|
||||
// enum PINSHEETLABEL_SHAPE
|
||||
#include <sch_text.h>
|
||||
|
@ -886,9 +887,9 @@ private:
|
|||
void OnRescueProject( wxCommandEvent& event );
|
||||
void OnRemapSymbols( wxCommandEvent& aEvent );
|
||||
|
||||
// a helper function to run the dialog that allows one to rename the symbol
|
||||
// library Id of groups of components, for instance after a symbol has moved
|
||||
// from a library to another library
|
||||
// a helper function to run the dialog that allows to rename the symbol library Id of
|
||||
// groups of components, for instance after a symbol has moved from a library to
|
||||
// another library
|
||||
void OnEditComponentSymbolsId( wxCommandEvent& aEvent );
|
||||
void OnPreferencesOptions( wxCommandEvent& event );
|
||||
void OnCancelCurrentCommand( wxCommandEvent& aEvent );
|
||||
|
@ -1504,6 +1505,8 @@ public:
|
|||
*/
|
||||
void doUpdatePcb( const wxString& aUpdateOptions = "" );
|
||||
|
||||
void SetCurrentSheet( SCH_SHEET_PATH *aSheet );
|
||||
|
||||
/**
|
||||
* Allows Eeschema to install its preferences panels into the preferences dialog.
|
||||
*/
|
||||
|
@ -1516,6 +1519,12 @@ public:
|
|||
|
||||
void ShowChangedLanguage() override;
|
||||
|
||||
void DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
|
||||
const wxPoint& aMoveVector );
|
||||
|
||||
virtual void SetScreen( BASE_SCREEN* aScreen ) override;
|
||||
|
||||
virtual const BOX2I GetDocumentExtents() const override;
|
||||
|
||||
///> Probe cursor, used by circuit simulator
|
||||
const static wxCursor CURSOR_PROBE;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <base_struct.h>
|
||||
#include <gr_basic.h>
|
||||
#include <draw_graphic_text.h>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <trace_helpers.h>
|
||||
#include <sch_item_struct.h>
|
||||
#include <sch_screen.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <general.h>
|
||||
|
|
|
@ -42,7 +42,7 @@ class wxFindReplaceData;
|
|||
class PLOTTER;
|
||||
class NETLIST_OBJECT;
|
||||
class NETLIST_OBJECT_LIST;
|
||||
|
||||
class EDA_DRAW_PANEL;
|
||||
|
||||
enum DANGLING_END_T {
|
||||
UNKNOWN = 0,
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <trigo.h>
|
||||
#include <common.h>
|
||||
#include <richio.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotter.h>
|
||||
#include <base_units.h>
|
||||
#include <eeschema_config.h>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <trigo.h>
|
||||
#include <msgpanel.h>
|
||||
#include <bitmaps.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <common.h>
|
||||
#include <plotter.h>
|
||||
#include <bitmaps.h>
|
||||
|
@ -224,4 +224,3 @@ BITMAP_DEF SCH_NO_CONNECT::GetMenuImage() const
|
|||
{
|
||||
return noconn_xpm;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ public:
|
|||
return wxT( "SCH_NO_CONNECT" );
|
||||
}
|
||||
|
||||
wxSize GetSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
int GetPenSize() const override;
|
||||
|
||||
void SwapData( SCH_ITEM* aItem ) override;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@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
|
||||
*/
|
||||
|
||||
#ifndef __SCH_PAINTER_H
|
||||
#define __SCH_PAINTER_H
|
||||
|
||||
#include <painter.h>
|
||||
|
||||
class LIB_RECTANGLE;
|
||||
class LIB_PIN;
|
||||
class LIB_CIRCLE;
|
||||
class LIB_ITEM;
|
||||
class LIB_PART;
|
||||
class LIB_POLYLINE;
|
||||
class LIB_ARC;
|
||||
class LIB_FIELD;
|
||||
class LIB_TEXT;
|
||||
class SCH_COMPONENT;
|
||||
class SCH_FIELD;
|
||||
class SCH_JUNCTION;
|
||||
class SCH_LABEL;
|
||||
class SCH_TEXT;
|
||||
class SCH_HIERLABEL;
|
||||
class SCH_GLOBALLABEL;
|
||||
class SCH_SHEET;
|
||||
class SCH_SHEET_PIN;
|
||||
class SCH_MARKER;
|
||||
class SCH_NO_CONNECT;
|
||||
class SCH_LINE;
|
||||
class SCH_BUS_ENTRY_BASE;
|
||||
|
||||
namespace KIGFX
|
||||
{
|
||||
class GAL;
|
||||
class SCH_PAINTER;
|
||||
|
||||
|
||||
/**
|
||||
* Class SCH_RENDER_SETTINGS
|
||||
* Stores schematic-specific render settings.
|
||||
*/
|
||||
|
||||
class SCH_RENDER_SETTINGS : public RENDER_SETTINGS
|
||||
{
|
||||
public:
|
||||
friend class SCH_PAINTER;
|
||||
|
||||
SCH_RENDER_SETTINGS();
|
||||
|
||||
/// @copydoc RENDER_SETTINGS::ImportLegacyColors()
|
||||
void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) override;
|
||||
|
||||
/// @copydoc RENDER_SETTINGS::GetColor()
|
||||
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
|
||||
|
||||
bool IsBackgroundDark() const override
|
||||
{
|
||||
auto luma = m_layerColors[ LAYER_SCHEMATIC_BACKGROUND ].GetBrightness();
|
||||
|
||||
return luma < 0.5;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bool m_showPinsElectricalType;
|
||||
bool m_libraryEditorMode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Class SCH_PAINTER
|
||||
* Contains methods for drawing schematic-specific items.
|
||||
*/
|
||||
class SCH_PAINTER : public PAINTER
|
||||
{
|
||||
public:
|
||||
SCH_PAINTER( GAL* aGal );
|
||||
|
||||
/// @copydoc PAINTER::Draw()
|
||||
virtual bool Draw( const VIEW_ITEM*, int ) override;
|
||||
|
||||
/// @copydoc PAINTER::ApplySettings()
|
||||
virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
|
||||
{
|
||||
m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
|
||||
}
|
||||
|
||||
/// @copydoc PAINTER::GetSettings()
|
||||
virtual SCH_RENDER_SETTINGS* GetSettings() override
|
||||
{
|
||||
return &m_schSettings;
|
||||
}
|
||||
|
||||
private:
|
||||
void draw( LIB_RECTANGLE *, int );
|
||||
void draw( LIB_PIN *, int );
|
||||
void draw( LIB_CIRCLE *, int );
|
||||
void draw( LIB_ITEM *, int );
|
||||
void draw( LIB_PART *, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 );
|
||||
void draw( LIB_ARC *, int );
|
||||
void draw( LIB_POLYLINE *, int );
|
||||
void draw( LIB_FIELD *, int );
|
||||
void draw( LIB_TEXT *, int );
|
||||
void draw( SCH_COMPONENT *, int );
|
||||
void draw( SCH_JUNCTION *, int );
|
||||
void draw( SCH_FIELD *, int );
|
||||
void draw( SCH_TEXT *, int );
|
||||
void draw( SCH_LABEL *, int );
|
||||
void draw( SCH_HIERLABEL *, int );
|
||||
void draw( SCH_GLOBALLABEL *, int );
|
||||
void draw( SCH_SHEET *, int );
|
||||
void draw( SCH_SHEET_PIN *, int );
|
||||
void draw( SCH_NO_CONNECT *, int );
|
||||
void draw( SCH_MARKER *, int );
|
||||
void draw( SCH_LINE *, int );
|
||||
void draw ( SCH_BUS_ENTRY_BASE *aEntry, int aLayer );
|
||||
|
||||
|
||||
void defaultColors( const LIB_ITEM *aItem );
|
||||
|
||||
void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
|
||||
|
||||
SCH_RENDER_SETTINGS m_schSettings;
|
||||
};
|
||||
|
||||
}; // namespace KIGFX
|
||||
|
||||
|
||||
#endif
|
|
@ -36,7 +36,7 @@
|
|||
#include <eeschema_id.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiway.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_item_struct.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <plotter.h>
|
||||
|
@ -536,6 +536,8 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
|
|||
*/
|
||||
std::vector< SCH_ITEM* > junctions;
|
||||
|
||||
printf("DrawScreen\n");
|
||||
|
||||
// Ensure links are up to date, even if a library was reloaded for some reason:
|
||||
UpdateSymbolLinks();
|
||||
|
||||
|
@ -1604,6 +1606,12 @@ int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString&
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SCREEN::SetZoom( double iu_per_du )
|
||||
{
|
||||
printf("SetZoom!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREENS::BuildClientSheetPathList()
|
||||
{
|
||||
|
|
|
@ -116,6 +116,8 @@ public:
|
|||
|
||||
~SCH_SCREEN();
|
||||
|
||||
DLIST< SCH_ITEM > & GetDrawList() { return m_drawList; }
|
||||
|
||||
virtual wxString GetClass() const override
|
||||
{
|
||||
return wxT( "SCH_SCREEN" );
|
||||
|
@ -163,6 +165,7 @@ public:
|
|||
--m_modification_sync;
|
||||
}
|
||||
|
||||
virtual bool SetZoom( double iu_per_du ) override;
|
||||
/**
|
||||
* Copy the contents of \a aScreen into this #SCH_SCREEN object.
|
||||
*
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <trigo.h>
|
||||
#include <richio.h>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <plotter.h>
|
||||
#include <trigo.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <trigo.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <draw_graphic_text.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <plotter.h>
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @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
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <view/view.h>
|
||||
#include <view/view_group.h>
|
||||
|
||||
#include <view/wx_view_controls.h>
|
||||
#include <worksheet_viewitem.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
||||
#include <class_libentry.h>
|
||||
|
||||
#include "sch_view.h"
|
||||
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_screen.h>
|
||||
#include <preview_items/selection_area.h>
|
||||
|
||||
namespace KIGFX {
|
||||
|
||||
SCH_VIEW::SCH_VIEW( bool aIsDynamic ) :
|
||||
VIEW( aIsDynamic )
|
||||
{
|
||||
}
|
||||
|
||||
SCH_VIEW::~SCH_VIEW()
|
||||
{
|
||||
}
|
||||
|
||||
void SCH_VIEW::Add( KIGFX::VIEW_ITEM* aItem, int aDrawPriority )
|
||||
{
|
||||
//auto ei = static_cast<EDA_ITEM*>(aItem);
|
||||
//auto bb = ei->ViewBBox();
|
||||
//printf("Add %p [%s] %d %d - %d %d\n", aItem, "dupa", bb.GetOrigin().x, bb.GetOrigin().y, bb.GetWidth(), bb.GetHeight() );
|
||||
|
||||
//if(bb.GetOrigin().x < 0)
|
||||
//for(;;);
|
||||
|
||||
VIEW::Add( aItem, aDrawPriority );
|
||||
}
|
||||
|
||||
|
||||
void SCH_VIEW::Remove( KIGFX::VIEW_ITEM* aItem )
|
||||
{
|
||||
VIEW::Remove( aItem );
|
||||
}
|
||||
|
||||
void SCH_VIEW::Update( KIGFX::VIEW_ITEM* aItem, int aUpdateFlags )
|
||||
{
|
||||
VIEW::Update( aItem, aUpdateFlags );
|
||||
}
|
||||
|
||||
|
||||
void SCH_VIEW::Update( KIGFX::VIEW_ITEM* aItem )
|
||||
{
|
||||
VIEW::Update( aItem );
|
||||
}
|
||||
|
||||
|
||||
static const LAYER_NUM SCH_LAYER_ORDER[] =
|
||||
{
|
||||
LAYER_GP_OVERLAY,
|
||||
LAYER_DRC,
|
||||
LAYER_WORKSHEET
|
||||
};
|
||||
|
||||
void SCH_VIEW::DisplaySheet( SCH_SCREEN *aSheet )
|
||||
{
|
||||
|
||||
for( auto item = aSheet->GetDrawItems(); item; item = item->Next() )
|
||||
{
|
||||
//printf("-- ADD SCHITEM %p\n", item );
|
||||
Add(item);
|
||||
}
|
||||
|
||||
m_worksheet.reset ( new KIGFX::WORKSHEET_VIEWITEM( 1, &aSheet->GetPageSettings(), &aSheet->GetTitleBlock() ) );
|
||||
//m_worksheet->SetMilsToIUfactor(1);
|
||||
|
||||
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
|
||||
m_preview.reset( new KIGFX::VIEW_GROUP () );
|
||||
//printf("Display-screen\n");
|
||||
Add( m_worksheet.get() );
|
||||
Add( m_selectionArea.get() );
|
||||
Add( m_preview.get() );
|
||||
}
|
||||
|
||||
void SCH_VIEW::DisplaySheet( SCH_SHEET *aSheet )
|
||||
{
|
||||
DisplaySheet( aSheet->GetScreen() );
|
||||
}
|
||||
|
||||
void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
|
||||
{
|
||||
Clear();
|
||||
|
||||
for ( auto &item : aPart->GetDrawItems() )
|
||||
{
|
||||
//printf("-- ADD %p\n", &item );
|
||||
Add( &item );
|
||||
}
|
||||
|
||||
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
|
||||
m_preview.reset( new KIGFX::VIEW_GROUP () );
|
||||
//printf("Display-screen\n");
|
||||
Add( m_selectionArea.get() );
|
||||
Add( m_preview.get() );
|
||||
}
|
||||
|
||||
|
||||
void SCH_VIEW::ClearPreview()
|
||||
{
|
||||
m_preview->Clear();
|
||||
for( auto item : m_previewItems )
|
||||
delete item;
|
||||
|
||||
m_previewItems.clear();
|
||||
Update(m_preview.get());
|
||||
}
|
||||
|
||||
void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
|
||||
{
|
||||
m_preview->Add(aItem);
|
||||
if(owned)
|
||||
m_previewItems.push_back(aItem);
|
||||
|
||||
SetVisible(m_preview.get(), true);
|
||||
Hide(m_preview.get(), false);
|
||||
Update(m_preview.get());
|
||||
}
|
||||
|
||||
void SCH_VIEW::ShowSelectionArea( bool aShow )
|
||||
{
|
||||
SetVisible( m_selectionArea.get(), aShow );
|
||||
}
|
||||
|
||||
void SCH_VIEW::ShowPreview( bool aShow )
|
||||
{
|
||||
SetVisible( m_preview.get(), aShow );
|
||||
}
|
||||
|
||||
void SCH_VIEW::ClearHiddenFlags()
|
||||
{
|
||||
for( auto item : m_allItems )
|
||||
Hide ( item, false );
|
||||
}
|
||||
|
||||
void SCH_VIEW::HideWorksheet()
|
||||
{
|
||||
// SetVisible( m_worksheet.get(), false );
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef SCH_VIEW_H_
|
||||
#define SCH_VIEW_H_
|
||||
|
||||
#include <memory>
|
||||
#include <view/view.h>
|
||||
|
||||
|
||||
#include <view/wx_view_controls.h>
|
||||
#include <worksheet_viewitem.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
|
||||
class SCH_SHEET;
|
||||
class SCH_SCREEN;
|
||||
class LIB_PART;
|
||||
|
||||
namespace KIGFX {
|
||||
class VIEW_GROUP;
|
||||
|
||||
namespace PREVIEW {
|
||||
class SELECTION_AREA;
|
||||
|
||||
};
|
||||
|
||||
class WORKSHEET_VIEWITEM;
|
||||
|
||||
class SCH_VIEW : public KIGFX::VIEW
|
||||
{
|
||||
public:
|
||||
SCH_VIEW( bool aIsDynamic );
|
||||
~SCH_VIEW();
|
||||
|
||||
void DisplaySheet( SCH_SHEET *aSheet );
|
||||
void DisplaySheet( SCH_SCREEN *aSheet );
|
||||
void DisplayComponent( LIB_PART *aPart );
|
||||
|
||||
/// @copydoc VIEW::Add()
|
||||
virtual void Add( VIEW_ITEM* aItem, int aDrawPriority = -1 ) override;
|
||||
/// @copydoc VIEW::Remove()
|
||||
|
||||
virtual void Remove( VIEW_ITEM* aItem ) override;
|
||||
|
||||
/// @copydoc VIEW::Update()
|
||||
virtual void Update( VIEW_ITEM* aItem, int aUpdateFlags ) override;
|
||||
|
||||
/// @copydoc VIEW::Update()
|
||||
virtual void Update( VIEW_ITEM* aItem ) override;
|
||||
|
||||
// void SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet );
|
||||
KIGFX::PREVIEW::SELECTION_AREA* GetSelectionArea() const { return m_selectionArea.get(); }
|
||||
|
||||
KIGFX::VIEW_GROUP* GetPreview() const { return m_preview.get(); }
|
||||
|
||||
void ClearPreview();
|
||||
void AddToPreview( EDA_ITEM *aItem, bool makeCopy = true );
|
||||
|
||||
void ShowSelectionArea( bool aShow = true );
|
||||
void ShowPreview( bool aShow = true );
|
||||
|
||||
void ClearHiddenFlags();
|
||||
void HideWorksheet();
|
||||
|
||||
private:
|
||||
std::unique_ptr<WORKSHEET_VIEWITEM> m_worksheet;
|
||||
std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
|
||||
std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
|
||||
|
||||
std::vector<EDA_ITEM *> m_previewItems;
|
||||
};
|
||||
|
||||
}; // namespace
|
||||
|
||||
#endif
|
|
@ -31,7 +31,7 @@
|
|||
#include <kiway.h>
|
||||
#include <gr_basic.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <eda_doc.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include <sch_line.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <sch_view.h>
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
|
@ -112,7 +113,8 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
}
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
//INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
item = screen->GetCurItem(); // Can be modified by previous calls.
|
||||
|
||||
switch( id )
|
||||
|
@ -129,7 +131,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_CUT );
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
SetRepeatItem( NULL );
|
||||
SetSheetNumberAndCount();
|
||||
break;
|
||||
|
@ -138,21 +140,21 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_POPUP_COPY_BLOCK:
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_COPY );
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case wxID_PASTE:
|
||||
HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() );
|
||||
HandleBlockBegin( nullptr, BLOCK_PASTE, GetCrossHairPosition() );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
|
||||
SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '/' );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
SetBusEntryShape( &dc, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
|
||||
SetBusEntryShape( nullptr, dynamic_cast<SCH_BUS_ENTRY_BASE*>( item ), '\\' );
|
||||
break;
|
||||
|
||||
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
||||
|
@ -175,12 +177,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_POPUP_SCH_BEGIN_WIRE:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
OnLeftClick( &dc, GetCrossHairPosition() );
|
||||
OnLeftClick( nullptr, GetCrossHairPosition() );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_BEGIN_BUS:
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
OnLeftClick( &dc, GetCrossHairPosition() );
|
||||
OnLeftClick( nullptr, GetCrossHairPosition() );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_SET_SHAPE_TEXT:
|
||||
|
@ -231,7 +233,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_POPUP_SCH_RESIZE_SHEET:
|
||||
ReSizeSheet( (SCH_SHEET*) item, &dc );
|
||||
ReSizeSheet( (SCH_SHEET*) item, nullptr );
|
||||
|
||||
if( screen->TestDanglingEnds() )
|
||||
m_canvas->Refresh();
|
||||
|
@ -240,7 +242,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN:
|
||||
if( item != NULL && item->Type() == SCH_SHEET_T )
|
||||
screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
|
||||
screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, nullptr ) );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_CLEANUP_SHEET:
|
||||
|
@ -275,7 +277,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
if( item && item->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
ConvertPart( (SCH_COMPONENT*) item, &dc );
|
||||
ConvertPart( (SCH_COMPONENT*) item, nullptr );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -302,13 +304,13 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
case ID_POPUP_PLACE_BLOCK:
|
||||
m_canvas->SetAutoPanRequest( false );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
HandleBlockPlace( &dc );
|
||||
HandleBlockPlace( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_ZOOM_BLOCK:
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_ZOOM );
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_DELETE_BLOCK:
|
||||
|
@ -318,7 +320,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
SetSheetNumberAndCount();
|
||||
break;
|
||||
|
||||
|
@ -329,7 +331,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_DUPLICATE );
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_DRAG_BLOCK:
|
||||
|
@ -339,7 +341,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_DRAG );
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_ADD_JUNCTION:
|
||||
|
@ -354,7 +356,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
case ID_POPUP_SCH_ADD_LABEL:
|
||||
case ID_POPUP_SCH_ADD_GLABEL:
|
||||
screen->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ?
|
||||
screen->SetCurItem( CreateNewText( nullptr, id == ID_POPUP_SCH_ADD_LABEL ?
|
||||
LAYER_LOCLABEL : LAYER_GLOBLABEL ) );
|
||||
item = screen->GetCurItem();
|
||||
|
||||
|
@ -411,8 +413,6 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
|||
return;
|
||||
}
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case SCH_LINE_T:
|
||||
|
@ -430,7 +430,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
|||
case SCH_SHEET_PIN_T:
|
||||
case SCH_FIELD_T:
|
||||
case SCH_SHEET_T:
|
||||
PrepareMoveItem( item, &dc );
|
||||
PrepareMoveItem( item, nullptr );
|
||||
break;
|
||||
|
||||
case SCH_BITMAP_T:
|
||||
|
@ -438,7 +438,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
|||
// we cannot undraw/redraw a bitmap just using our xor mode
|
||||
// the MoveImage function handle this undraw/redraw difficulty
|
||||
// By redrawing the full bounding box
|
||||
MoveImage( (SCH_BITMAP*) item, &dc );
|
||||
// MoveImage( (SCH_BITMAP*) item, &dc );
|
||||
break;
|
||||
|
||||
case SCH_MARKER_T:
|
||||
|
@ -463,7 +463,7 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
|
|||
|
||||
if( screen->IsBlockActive() )
|
||||
{
|
||||
m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
|
||||
// m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
|
||||
screen->ClearBlockCommand();
|
||||
|
||||
// Stop the current command (if any) but keep the current tool
|
||||
|
@ -476,6 +476,10 @@ void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
|
|||
else // Deselect current tool
|
||||
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
||||
}
|
||||
|
||||
GetCanvas()->GetView()->ClearHiddenFlags();
|
||||
GetCanvas()->GetView()->ClearPreview();
|
||||
GetCanvas()->GetView()->ShowPreview( false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,12 +603,12 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
#ifdef KICAD_SPICE
|
||||
case ID_SIM_PROBE:
|
||||
SetToolID( id, -1, _( "Add a simulator probe" ) );
|
||||
m_canvas->SetCursor( CURSOR_PROBE );
|
||||
//m_canvas->SetCurrentCursor( CURSOR_PROBE );
|
||||
break;
|
||||
|
||||
case ID_SIM_TUNE:
|
||||
SetToolID( id, -1, _( "Select a value to be tuned" ) );
|
||||
m_canvas->SetCursor( CURSOR_TUNE );
|
||||
//m_canvas->SetCurrentCursor( CURSOR_TUNE );
|
||||
break;
|
||||
#endif /* KICAD_SPICE */
|
||||
|
||||
|
@ -619,8 +623,8 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|||
|
||||
wxPoint pos = data->GetPosition();
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
OnLeftClick( &dc, pos );
|
||||
// INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
OnLeftClick( nullptr, pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,25 +683,11 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
{
|
||||
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
||||
auto view = panel->GetView();
|
||||
|
||||
wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
|
||||
|
||||
SCH_COMPONENT* cmp = NULL;
|
||||
|
||||
if( item->Type() == SCH_COMPONENT_T )
|
||||
cmp = static_cast< SCH_COMPONENT* >( item );
|
||||
|
||||
#ifndef USE_WX_OVERLAY
|
||||
// Erase the current item at its current position.
|
||||
if( aErase )
|
||||
{
|
||||
if( cmp ) // Use fast mode (do not draw pin texts)
|
||||
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
|
||||
else
|
||||
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
}
|
||||
#endif
|
||||
|
||||
wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
|
||||
cpos -= item->GetStoredPos();
|
||||
|
||||
|
@ -706,10 +696,9 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|||
// Draw the item item at it's new position.
|
||||
item->SetWireImage(); // While moving, the item may choose to render differently
|
||||
|
||||
if( cmp ) // Use fast mode (do not draw pin texts)
|
||||
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, COLOR4D::UNSPECIFIED, false );
|
||||
else
|
||||
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
view->Hide( item );
|
||||
view->ClearPreview();
|
||||
view->AddToPreview( item, false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -718,9 +707,13 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
|||
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
|
||||
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
||||
auto view = panel->GetView();
|
||||
|
||||
parent->SetRepeatItem( NULL );
|
||||
screen->SetCurItem( NULL );
|
||||
view->ClearPreview();
|
||||
view->ClearHiddenFlags();
|
||||
|
||||
if( item == NULL ) /* no current item */
|
||||
return;
|
||||
|
@ -755,8 +748,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
|||
currentItem->SwapData( oldItem );
|
||||
|
||||
// Erase the wire representation before the 'normal' view is drawn.
|
||||
if ( item->IsWireImage() )
|
||||
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
view->Hide( item, false );
|
||||
|
||||
item->ClearFlags();
|
||||
}
|
||||
|
@ -850,13 +842,13 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
|||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
// INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
printf("OnRotate\n");
|
||||
// Allows block rotate operation on hot key.
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
{
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_ROTATE );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -873,6 +865,8 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
|||
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::RotatableItems,
|
||||
aEvent.GetInt() );
|
||||
|
||||
printf("Rotate Item %p", item);
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( (item == NULL) || (item->GetFlags() != 0) )
|
||||
return;
|
||||
|
@ -883,6 +877,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
|||
case SCH_COMPONENT_T:
|
||||
{
|
||||
SCH_COMPONENT* component = static_cast<SCH_COMPONENT*>( item );
|
||||
|
||||
if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
|
||||
OrientComponent( CMP_ROTATE_CLOCKWISE );
|
||||
else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
|
||||
|
@ -946,6 +941,8 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
|||
GetChars( item->GetClass() ) ) );
|
||||
}
|
||||
|
||||
GetCanvas()->GetView()->Update( item );
|
||||
|
||||
if( item->GetFlags() == 0 )
|
||||
screen->SetCurItem( NULL );
|
||||
}
|
||||
|
@ -1103,6 +1100,8 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
|||
GetChars( item->GetClass() ) ) );
|
||||
}
|
||||
|
||||
GetCanvas()->GetView()->Update( item );
|
||||
|
||||
if( item->GetFlags() == 0 )
|
||||
screen->SetCurItem( NULL );
|
||||
}
|
||||
|
@ -1160,14 +1159,14 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
|
|||
|
||||
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
|
||||
{
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
if( !HandleBlockBegin( &dc, dragType, GetCrossHairPosition() ) )
|
||||
// INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
//
|
||||
if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
|
||||
break;
|
||||
|
||||
// Give a non null size to the search block:
|
||||
screen->m_BlockLocate.Inflate( 1 );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1184,7 +1183,7 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
// INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
||||
|
||||
// Allows block rotate operation on hot key.
|
||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||
|
@ -1194,14 +1193,14 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
}
|
||||
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
||||
{
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->m_BlockLocate.SetMessageBlock( this );
|
||||
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
|
||||
HandleBlockEnd( &dc );
|
||||
HandleBlockEnd( nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1273,6 +1272,8 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
|||
;
|
||||
}
|
||||
|
||||
GetCanvas()->GetView()->Update( item );
|
||||
|
||||
if( item->GetFlags() == 0 )
|
||||
screen->SetCurItem( NULL );
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
#include <general.h>
|
||||
|
@ -41,7 +41,7 @@
|
|||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_bitmap.h>
|
||||
|
||||
#include <sch_view.h>
|
||||
|
||||
/* Functions to undo and redo edit commands.
|
||||
* commands to undo are stored in CurrentScreen->m_UndoList
|
||||
|
@ -282,7 +282,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
|
||||
// Copy the saved wires, buses, and junctions to the current screen.
|
||||
for( unsigned int i = 0; i < aList->GetCount(); i++ )
|
||||
GetScreen()->Append( (SCH_ITEM*) aList->GetPickedItem( i ) );
|
||||
AddToScreen( (SCH_ITEM*) aList->GetPickedItem( i ) );
|
||||
|
||||
aList->ClearItemsList();
|
||||
|
||||
|
@ -316,12 +316,14 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
|
||||
case UR_NEW: /* new items are deleted */
|
||||
aList->SetPickedItemStatus( UR_DELETED, ii );
|
||||
GetScreen()->Remove( item );
|
||||
RemoveFromScreen( item );
|
||||
|
||||
//schprintf("UndoRemFroMscreen %p %s\n", item, (const char *)item->GetClass().c_str() );
|
||||
break;
|
||||
|
||||
case UR_DELETED: /* deleted items are put in the draw item list, as new items */
|
||||
aList->SetPickedItemStatus( UR_NEW, ii );
|
||||
GetScreen()->Append( item );
|
||||
AddToScreen( item );
|
||||
break;
|
||||
|
||||
case UR_MOVED:
|
||||
|
@ -356,8 +358,8 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii );
|
||||
alt_item->SetNext( NULL );
|
||||
alt_item->SetBack( NULL );
|
||||
GetScreen()->Remove( item );
|
||||
GetScreen()->Append( alt_item );
|
||||
RemoveFromScreen( item );
|
||||
AddToScreen( alt_item );
|
||||
aList->SetPickedItem( alt_item, ii );
|
||||
aList->SetPickedItemLink( item, ii );
|
||||
break;
|
||||
|
@ -368,6 +370,8 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <kiface_i.h>
|
||||
#include <project.h>
|
||||
|
@ -37,6 +37,7 @@
|
|||
#include <sch_legacy_plugin.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <sch_view.h>
|
||||
|
||||
#include <dialogs/dialog_sch_sheet_props.h>
|
||||
|
||||
|
@ -297,6 +298,9 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy, b
|
|||
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
m_canvas->SetIgnoreMouseEvents( false );
|
||||
|
||||
GetCanvas()->GetView()->Update( aSheet );
|
||||
|
||||
OnModify();
|
||||
|
||||
return true;
|
||||
|
@ -317,9 +321,6 @@ static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const
|
|||
if( sheet == nullptr ) // Be sure we are using the right object
|
||||
return;
|
||||
|
||||
if( aErase )
|
||||
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
wxPoint pos = sheet->GetPosition();
|
||||
|
||||
int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
|
||||
|
@ -345,7 +346,10 @@ static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const
|
|||
wxPoint( pos.x + width, pos.y + height ) );
|
||||
sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
|
||||
|
||||
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
||||
auto view = panel->GetView();
|
||||
view->ClearPreview();
|
||||
view->AddToPreview( sheet, false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -362,26 +366,24 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
|||
|
||||
parent->SetRepeatItem( NULL );
|
||||
|
||||
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
|
||||
|
||||
if( item->IsNew() )
|
||||
{
|
||||
delete item;
|
||||
}
|
||||
else if( item->IsMoving() || item->IsResized() )
|
||||
{
|
||||
screen->Remove( item );
|
||||
parent->RemoveFromScreen( item );
|
||||
delete item;
|
||||
|
||||
item = parent->GetUndoItem();
|
||||
|
||||
wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
|
||||
|
||||
screen->Append( item );
|
||||
parent->AddToScreen( item );
|
||||
|
||||
// the owner of item is no more parent, this is the draw list of screen:
|
||||
parent->SetUndoItem( NULL );
|
||||
|
||||
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
||||
item->ClearFlags();
|
||||
}
|
||||
else
|
||||
|
@ -389,6 +391,10 @@ static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
|
|||
item->ClearFlags();
|
||||
}
|
||||
|
||||
auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
|
||||
auto view = panel->GetView();
|
||||
view->ClearPreview();
|
||||
|
||||
screen->SetCurItem( NULL );
|
||||
}
|
||||
|
||||
|
@ -473,7 +479,7 @@ void SCH_EDIT_FRAME::RotateHierarchicalSheet( SCH_SHEET* aSheet, bool aRotCCW )
|
|||
aSheet->Rotate( rotPoint );
|
||||
}
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
GetCanvas()->GetView()->Update( aSheet );
|
||||
OnModify();
|
||||
}
|
||||
|
||||
|
@ -496,6 +502,6 @@ void SCH_EDIT_FRAME::MirrorSheet( SCH_SHEET* aSheet, bool aFromXaxis )
|
|||
else // Mirror relative to vertical axis
|
||||
aSheet->MirrorY( mirrorPoint.x );
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
GetCanvas()->GetView()->Update( aSheet );
|
||||
OnModify();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <gr_basic.h>
|
||||
#include <macros.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <kiface_i.h>
|
||||
#include <bitmaps.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <kiface_i.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <msgpanel.h>
|
||||
#include <bitmaps.h>
|
||||
#include <eda_dockart.h>
|
||||
|
@ -197,7 +197,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
|||
m_auimgr.AddPane( m_cmpList, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
|
||||
.CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_cmpListWidth, -1 ) );
|
||||
|
||||
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
|
||||
m_auimgr.GetPane( m_libList ).Show( aLibraryName.empty() );
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <fctsys.h>
|
||||
#include <kiway.h>
|
||||
#include <pgm_base.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <eda_doc.h>
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue