Fix up zoom and pan issues entering/leaving sheets.
This commit is contained in:
parent
929786ce50
commit
2d5baac77d
|
@ -43,7 +43,7 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) :
|
||||||
EDA_ITEM( aType )
|
EDA_ITEM( aType )
|
||||||
{
|
{
|
||||||
m_UndoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
m_UndoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
||||||
m_FirstRedraw = true;
|
m_Initialized = false;
|
||||||
m_ScreenNumber = 1;
|
m_ScreenNumber = 1;
|
||||||
m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1
|
m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1
|
||||||
m_Zoom = 32.0;
|
m_Zoom = 32.0;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <view/wx_view_controls.h>
|
#include <view/wx_view_controls.h>
|
||||||
#include <painter.h>
|
#include <painter.h>
|
||||||
|
#include <base_screen.h>
|
||||||
#include <gal/graphics_abstraction_layer.h>
|
#include <gal/graphics_abstraction_layer.h>
|
||||||
#include <gal/opengl/opengl_gal.h>
|
#include <gal/opengl/opengl_gal.h>
|
||||||
#include <gal/cairo/cairo_gal.h>
|
#include <gal/cairo/cairo_gal.h>
|
||||||
|
@ -150,6 +150,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||||
{
|
{
|
||||||
m_viewControls->UpdateScrollbars();
|
m_viewControls->UpdateScrollbars();
|
||||||
|
|
||||||
|
GetParentEDAFrame()->GetScreen()->SetZoom( GetLegacyZoom() );
|
||||||
|
|
||||||
|
VECTOR2D center = GetView()->GetCenter();
|
||||||
|
GetParentEDAFrame()->SetScrollCenterPosition( wxPoint( center.x, center.y ) );
|
||||||
|
|
||||||
// Drawing to a zero-width or zero-height GAL is fraught with peril.
|
// Drawing to a zero-width or zero-height GAL is fraught with peril.
|
||||||
if( GetClientRect().IsEmpty() )
|
if( GetClientRect().IsEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1030,15 +1030,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
||||||
GetGalCanvas()->GetViewControls()->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
|
GetGalCanvas()->GetViewControls()->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
|
||||||
GetGalCanvas()->GetViewControls()->EnableAutoPan( m_canvas->GetEnableAutoPan() );
|
GetGalCanvas()->GetViewControls()->EnableAutoPan( m_canvas->GetEnableAutoPan() );
|
||||||
}
|
}
|
||||||
else if( m_galCanvasActive )
|
|
||||||
{
|
|
||||||
// Switch to legacy renderer from GAL
|
|
||||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
|
||||||
// TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
|
|
||||||
m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
|
|
||||||
VECTOR2D center = view->GetCenter();
|
|
||||||
AdjustScrollBars( wxPoint( center.x, center.y ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
|
GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
|
||||||
|
|
||||||
|
|
|
@ -1250,9 +1250,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
||||||
else if( m_galCanvasActive )
|
else if( m_galCanvasActive )
|
||||||
{
|
{
|
||||||
// Switch to legacy renderer from GAL
|
// Switch to legacy renderer from GAL
|
||||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
m_canvas->SetZoom( GetGalCanvas()->GetLegacyZoom() );
|
||||||
// TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
|
|
||||||
m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
|
|
||||||
VECTOR2D center = view->GetCenter();
|
VECTOR2D center = view->GetCenter();
|
||||||
AdjustScrollBars( wxPoint( center.x, center.y ) );
|
AdjustScrollBars( wxPoint( center.x, center.y ) );
|
||||||
}
|
}
|
||||||
|
@ -1640,7 +1638,7 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
|
||||||
double bestzoom = BestZoom();
|
double bestzoom = BestZoom();
|
||||||
screen->SetScalingFactor( bestzoom );
|
screen->SetScalingFactor( bestzoom );
|
||||||
|
|
||||||
if( screen->m_FirstRedraw )
|
if( !screen->m_Initialized )
|
||||||
SetCrossHairPosition( GetScrollCenterPosition() );
|
SetCrossHairPosition( GetScrollCenterPosition() );
|
||||||
|
|
||||||
if( !IsGalCanvasActive() )
|
if( !IsGalCanvasActive() )
|
||||||
|
|
|
@ -365,6 +365,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
SchematicCleanUp( true );
|
SchematicCleanUp( true );
|
||||||
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
||||||
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
|
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
|
||||||
|
GetScreen()->m_Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||||
|
@ -821,7 +822,7 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||||
// Ensure the schematic is fully segmented on first display
|
// Ensure the schematic is fully segmented on first display
|
||||||
BreakSegmentsOnJunctions();
|
BreakSegmentsOnJunctions();
|
||||||
SchematicCleanUp( true );
|
SchematicCleanUp( true );
|
||||||
|
GetScreen()->m_Initialized = true;
|
||||||
|
|
||||||
SCH_TYPE_COLLECTOR components;
|
SCH_TYPE_COLLECTOR components;
|
||||||
SCH_SCREENS allScreens;
|
SCH_SCREENS allScreens;
|
||||||
|
|
|
@ -279,12 +279,10 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||||
SetSheetNumberAndCount();
|
SetSheetNumberAndCount();
|
||||||
m_canvas->SetCanStartBlock( -1 );
|
m_canvas->SetCanStartBlock( -1 );
|
||||||
|
|
||||||
if( screen->m_FirstRedraw )
|
if( !screen->m_Initialized )
|
||||||
{
|
{
|
||||||
Zoom_Automatique( false );
|
Zoom_Automatique( false );
|
||||||
screen->m_FirstRedraw = false;
|
screen->m_Initialized = true;
|
||||||
SetCrossHairPosition( GetScrollCenterPosition() );
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
|
|
||||||
// Ensure the schematic is fully segmented on first display
|
// Ensure the schematic is fully segmented on first display
|
||||||
BreakSegmentsOnJunctions();
|
BreakSegmentsOnJunctions();
|
||||||
|
@ -295,18 +293,13 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RedrawScreen( GetScrollCenterPosition(), true );
|
CenterScreen( GetScrollCenterPosition(), false );
|
||||||
|
// RedrawScreen() will set zoom to last used
|
||||||
|
RedrawScreen( GetScrollCenterPosition(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some items (wires, labels) can be highlighted. So prepare the highlight flag:
|
// Some items (wires, labels) can be highlighted. So prepare the highlight flag:
|
||||||
SetCurrentSheetHighlightFlags();
|
SetCurrentSheetHighlightFlags();
|
||||||
|
|
||||||
// Now refresh m_canvas. Should be not necessary, but because screen has changed
|
GetCanvas()->Refresh();
|
||||||
// the previous refresh has set all new draw parameters (scroll position ..)
|
|
||||||
// but most of time there were some inconsitencies about cursor parameters
|
|
||||||
// ( previous position of cursor ...) and artefacts can happen
|
|
||||||
// mainly when sheet size has changed
|
|
||||||
// This second refresh clears artefacts because at this point,
|
|
||||||
// all parameters are now updated
|
|
||||||
SyncView();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,59 +26,30 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <view/view_group.h>
|
#include <view/view_group.h>
|
||||||
|
|
||||||
#include <view/wx_view_controls.h>
|
#include <view/wx_view_controls.h>
|
||||||
#include <worksheet_viewitem.h>
|
#include <worksheet_viewitem.h>
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
|
|
||||||
#include <class_libentry.h>
|
#include <class_libentry.h>
|
||||||
|
|
||||||
#include "sch_view.h"
|
|
||||||
|
|
||||||
#include <sch_sheet.h>
|
#include <sch_sheet.h>
|
||||||
#include <sch_screen.h>
|
#include <sch_screen.h>
|
||||||
#include <preview_items/selection_area.h>
|
#include <preview_items/selection_area.h>
|
||||||
|
|
||||||
|
#include "sch_view.h"
|
||||||
|
|
||||||
|
|
||||||
namespace KIGFX {
|
namespace KIGFX {
|
||||||
|
|
||||||
|
|
||||||
SCH_VIEW::SCH_VIEW( bool aIsDynamic ) :
|
SCH_VIEW::SCH_VIEW( bool aIsDynamic ) :
|
||||||
VIEW( aIsDynamic )
|
VIEW( aIsDynamic )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SCH_VIEW::~SCH_VIEW()
|
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[] =
|
static const LAYER_NUM SCH_LAYER_ORDER[] =
|
||||||
{
|
{
|
||||||
|
@ -87,31 +58,30 @@ static const LAYER_NUM SCH_LAYER_ORDER[] =
|
||||||
LAYER_WORKSHEET
|
LAYER_WORKSHEET
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::DisplaySheet( SCH_SCREEN *aSheet )
|
void SCH_VIEW::DisplaySheet( SCH_SCREEN *aSheet )
|
||||||
{
|
{
|
||||||
|
|
||||||
for( auto item = aSheet->GetDrawItems(); item; item = item->Next() )
|
for( auto item = aSheet->GetDrawItems(); item; item = item->Next() )
|
||||||
{
|
|
||||||
//printf("-- ADD SCHITEM %p\n", item );
|
|
||||||
Add( item );
|
Add( item );
|
||||||
}
|
|
||||||
|
|
||||||
m_worksheet.reset ( new KIGFX::WORKSHEET_VIEWITEM( 1, &aSheet->GetPageSettings(), &aSheet->GetTitleBlock() ) );
|
|
||||||
//m_worksheet->SetMilsToIUfactor(1);
|
|
||||||
|
|
||||||
|
m_worksheet.reset( new KIGFX::WORKSHEET_VIEWITEM( 1, &aSheet->GetPageSettings(),
|
||||||
|
&aSheet->GetTitleBlock() ) );
|
||||||
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
|
m_selectionArea.reset( new KIGFX::PREVIEW::SELECTION_AREA( ) );
|
||||||
m_preview.reset( new KIGFX::VIEW_GROUP () );
|
m_preview.reset( new KIGFX::VIEW_GROUP () );
|
||||||
//printf("Display-screen\n");
|
|
||||||
Add( m_worksheet.get() );
|
Add( m_worksheet.get() );
|
||||||
Add( m_selectionArea.get() );
|
Add( m_selectionArea.get() );
|
||||||
Add( m_preview.get() );
|
Add( m_preview.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::DisplaySheet( SCH_SHEET *aSheet )
|
void SCH_VIEW::DisplaySheet( SCH_SHEET *aSheet )
|
||||||
{
|
{
|
||||||
DisplaySheet( aSheet->GetScreen() );
|
DisplaySheet( aSheet->GetScreen() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
|
void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -142,6 +112,7 @@ void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
|
||||||
void SCH_VIEW::ClearPreview()
|
void SCH_VIEW::ClearPreview()
|
||||||
{
|
{
|
||||||
m_preview->Clear();
|
m_preview->Clear();
|
||||||
|
|
||||||
for( auto item : m_previewItems )
|
for( auto item : m_previewItems )
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
|
@ -149,6 +120,7 @@ void SCH_VIEW::ClearPreview()
|
||||||
Update(m_preview.get());
|
Update(m_preview.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
|
void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
|
||||||
{
|
{
|
||||||
m_preview->Add( aItem );
|
m_preview->Add( aItem );
|
||||||
|
@ -161,6 +133,7 @@ void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
|
||||||
Update( m_preview.get() );
|
Update( m_preview.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::ShowSelectionArea( bool aShow )
|
void SCH_VIEW::ShowSelectionArea( bool aShow )
|
||||||
{
|
{
|
||||||
if( aShow )
|
if( aShow )
|
||||||
|
@ -174,21 +147,25 @@ void SCH_VIEW::ShowSelectionArea( bool aShow )
|
||||||
SetVisible( m_selectionArea.get(), aShow );
|
SetVisible( m_selectionArea.get(), aShow );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::ShowPreview( bool aShow )
|
void SCH_VIEW::ShowPreview( bool aShow )
|
||||||
{
|
{
|
||||||
SetVisible( m_preview.get(), aShow );
|
SetVisible( m_preview.get(), aShow );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::ClearHiddenFlags()
|
void SCH_VIEW::ClearHiddenFlags()
|
||||||
{
|
{
|
||||||
for( auto item : m_allItems )
|
for( auto item : m_allItems )
|
||||||
Hide ( item, false );
|
Hide ( item, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_VIEW::HideWorksheet()
|
void SCH_VIEW::HideWorksheet()
|
||||||
{
|
{
|
||||||
// SetVisible( m_worksheet.get(), false );
|
// SetVisible( m_worksheet.get(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,15 @@ class SCH_SHEET;
|
||||||
class SCH_SCREEN;
|
class SCH_SCREEN;
|
||||||
class LIB_PART;
|
class LIB_PART;
|
||||||
|
|
||||||
namespace KIGFX {
|
namespace KIGFX
|
||||||
|
{
|
||||||
class VIEW_GROUP;
|
class VIEW_GROUP;
|
||||||
|
class WORKSHEET_VIEWITEM;
|
||||||
|
|
||||||
namespace PREVIEW {
|
namespace PREVIEW
|
||||||
class SELECTION_AREA;
|
{
|
||||||
|
class SELECTION_AREA;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WORKSHEET_VIEWITEM;
|
|
||||||
|
|
||||||
class SCH_VIEW : public KIGFX::VIEW
|
class SCH_VIEW : public KIGFX::VIEW
|
||||||
{
|
{
|
||||||
|
@ -33,19 +33,6 @@ public:
|
||||||
void DisplaySheet( SCH_SCREEN *aSheet );
|
void DisplaySheet( SCH_SCREEN *aSheet );
|
||||||
void DisplayComponent( LIB_PART *aPart );
|
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::PREVIEW::SELECTION_AREA* GetSelectionArea() const { return m_selectionArea.get(); }
|
||||||
|
|
||||||
KIGFX::VIEW_GROUP* GetPreview() const { return m_preview.get(); }
|
KIGFX::VIEW_GROUP* GetPreview() const { return m_preview.get(); }
|
||||||
|
|
|
@ -204,7 +204,7 @@ public:
|
||||||
* > 0 except for schematics.
|
* > 0 except for schematics.
|
||||||
* false: when coordinates can only be >= 0
|
* false: when coordinates can only be >= 0
|
||||||
* Schematic */
|
* Schematic */
|
||||||
bool m_FirstRedraw;
|
bool m_Initialized;
|
||||||
|
|
||||||
// Undo/redo list of commands
|
// Undo/redo list of commands
|
||||||
UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data)
|
UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data)
|
||||||
|
|
Loading…
Reference in New Issue