committed by
Jeff Young
101 changed files with 3358 additions and 805 deletions
-
70eeschema/CMakeLists.txt
-
4eeschema/annotate.cpp
-
2eeschema/autoplace_fields.cpp
-
99eeschema/block.cpp
-
80eeschema/bus-wire-junction.cpp
-
6eeschema/busentry.cpp
-
154eeschema/class_libentry.cpp
-
64eeschema/class_libentry.h
-
45eeschema/controle.cpp
-
2eeschema/cross-probing.cpp
-
2eeschema/dialog_erc_listbox.h
-
2eeschema/dialogs/dialog_annotate.cpp
-
2eeschema/dialogs/dialog_edit_component_in_schematic.cpp
-
2eeschema/dialogs/dialog_edit_components_libid.cpp
-
2eeschema/dialogs/dialog_edit_label.cpp
-
2eeschema/dialogs/dialog_erc.cpp
-
1eeschema/dialogs/dialog_lib_edit_text.cpp
-
4eeschema/dialogs/dialog_print_using_printer.cpp
-
2eeschema/edit_bitmap.cpp
-
2eeschema/edit_component_in_schematic.cpp
-
16eeschema/edit_label.cpp
-
24eeschema/eeredraw.cpp
-
4eeschema/eeschema_config.cpp
-
2eeschema/erc.cpp
-
9eeschema/events_called_functions_for_edit.cpp
-
10eeschema/files-io.cpp
-
7eeschema/find.cpp
-
18eeschema/getpart.cpp
-
5eeschema/hierarch.cpp
-
2eeschema/highlight_connection.cpp
-
2eeschema/hotkeys.cpp
-
9eeschema/lib_arc.cpp
-
2eeschema/lib_arc.h
-
12eeschema/lib_bezier.cpp
-
2eeschema/lib_bezier.h
-
13eeschema/lib_circle.cpp
-
2eeschema/lib_circle.h
-
7eeschema/lib_draw_item.cpp
-
30eeschema/lib_draw_item.h
-
6eeschema/lib_field.cpp
-
2eeschema/lib_field.h
-
16eeschema/lib_pin.cpp
-
2eeschema/lib_pin.h
-
9eeschema/lib_polyline.cpp
-
2eeschema/lib_polyline.h
-
10eeschema/lib_rectangle.cpp
-
2eeschema/lib_rectangle.h
-
12eeschema/lib_text.cpp
-
2eeschema/lib_text.h
-
282eeschema/libedit/block_libedit.cpp
-
99eeschema/libedit/lib_edit_frame.cpp
-
2eeschema/libedit/lib_export.cpp
-
6eeschema/libedit/libedit.cpp
-
2eeschema/libedit/libedit_onleftclick.cpp
-
2eeschema/libedit/libedit_onrightclick.cpp
-
10eeschema/libedit/libedit_plot_component.cpp
-
4eeschema/libedit/libedit_undo_redo.cpp
-
2eeschema/libedit/libfield.cpp
-
83eeschema/libedit/pinedit.cpp
-
83eeschema/libedit/symbdraw.cpp
-
4eeschema/libedit/symbedit.cpp
-
6eeschema/onleftclick.cpp
-
6eeschema/onrightclick.cpp
-
8eeschema/operations_on_items_lists.cpp
-
2eeschema/plot_schematic_SVG.cpp
-
2eeschema/project_rescue.cpp
-
225eeschema/sch_base_frame.cpp
-
58eeschema/sch_base_frame.h
-
5eeschema/sch_bitmap.cpp
-
2eeschema/sch_bus_entry.cpp
-
3eeschema/sch_bus_entry.h
-
2eeschema/sch_component.cpp
-
670eeschema/sch_draw_panel.cpp
-
115eeschema/sch_draw_panel.h
-
41eeschema/sch_edit_frame.cpp
-
15eeschema/sch_edit_frame.h
-
2eeschema/sch_field.cpp
-
2eeschema/sch_item_struct.cpp
-
2eeschema/sch_item_struct.h
-
2eeschema/sch_junction.cpp
-
2eeschema/sch_line.cpp
-
2eeschema/sch_marker.cpp
-
3eeschema/sch_no_connect.cpp
-
5eeschema/sch_no_connect.h
-
1021eeschema/sch_painter.cpp
-
151eeschema/sch_painter.h
-
10eeschema/sch_screen.cpp
-
3eeschema/sch_screen.h
-
2eeschema/sch_sheet.cpp
-
2eeschema/sch_sheet_pin.cpp
-
2eeschema/sch_text.cpp
-
176eeschema/sch_view.cpp
-
72eeschema/sch_view.h
-
119eeschema/schedit.cpp
-
18eeschema/schematic_undo_redo.cpp
-
30eeschema/sheet.cpp
-
2eeschema/sheetlab.cpp
-
2eeschema/tool_sch.cpp
-
4eeschema/viewlib_frame.cpp
-
2eeschema/viewlibs.cpp
@ -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 |
|||
1021
eeschema/sch_painter.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -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 |
|||
@ -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 |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue