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 )
|
||||
{
|
||||
m_UndoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
||||
m_FirstRedraw = true;
|
||||
m_Initialized = false;
|
||||
m_ScreenNumber = 1;
|
||||
m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1
|
||||
m_Zoom = 32.0;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <view/view.h>
|
||||
#include <view/wx_view_controls.h>
|
||||
#include <painter.h>
|
||||
|
||||
#include <base_screen.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <gal/opengl/opengl_gal.h>
|
||||
#include <gal/cairo/cairo_gal.h>
|
||||
|
@ -150,6 +150,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
|||
{
|
||||
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.
|
||||
if( GetClientRect().IsEmpty() )
|
||||
return;
|
||||
|
|
|
@ -1030,15 +1030,6 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
|||
GetGalCanvas()->GetViewControls()->EnableMousewheelPan( m_canvas->GetEnableMousewheelPan() );
|
||||
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 );
|
||||
|
||||
|
|
|
@ -1250,9 +1250,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
|
|||
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() ) );
|
||||
m_canvas->SetZoom( GetGalCanvas()->GetLegacyZoom() );
|
||||
VECTOR2D center = view->GetCenter();
|
||||
AdjustScrollBars( wxPoint( center.x, center.y ) );
|
||||
}
|
||||
|
@ -1640,7 +1638,7 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
|
|||
double bestzoom = BestZoom();
|
||||
screen->SetScalingFactor( bestzoom );
|
||||
|
||||
if( screen->m_FirstRedraw )
|
||||
if( !screen->m_Initialized )
|
||||
SetCrossHairPosition( GetScrollCenterPosition() );
|
||||
|
||||
if( !IsGalCanvasActive() )
|
||||
|
|
|
@ -365,6 +365,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
SchematicCleanUp( true );
|
||||
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
||||
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
|
||||
GetScreen()->m_Initialized = true;
|
||||
}
|
||||
|
||||
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
|
||||
BreakSegmentsOnJunctions();
|
||||
SchematicCleanUp( true );
|
||||
|
||||
GetScreen()->m_Initialized = true;
|
||||
|
||||
SCH_TYPE_COLLECTOR components;
|
||||
SCH_SCREENS allScreens;
|
||||
|
|
|
@ -279,12 +279,10 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
|||
SetSheetNumberAndCount();
|
||||
m_canvas->SetCanStartBlock( -1 );
|
||||
|
||||
if( screen->m_FirstRedraw )
|
||||
if( !screen->m_Initialized )
|
||||
{
|
||||
Zoom_Automatique( false );
|
||||
screen->m_FirstRedraw = false;
|
||||
SetCrossHairPosition( GetScrollCenterPosition() );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
screen->m_Initialized = true;
|
||||
|
||||
// Ensure the schematic is fully segmented on first display
|
||||
BreakSegmentsOnJunctions();
|
||||
|
@ -295,18 +293,13 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
|||
}
|
||||
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:
|
||||
SetCurrentSheetHighlightFlags();
|
||||
|
||||
// Now refresh m_canvas. Should be not necessary, but because screen has changed
|
||||
// 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();
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
|
|
@ -26,59 +26,30 @@
|
|||
#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>
|
||||
|
||||
#include "sch_view.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[] =
|
||||
{
|
||||
|
@ -87,31 +58,30 @@ static const LAYER_NUM SCH_LAYER_ORDER[] =
|
|||
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_worksheet.reset( new KIGFX::WORKSHEET_VIEWITEM( 1, &aSheet->GetPageSettings(),
|
||||
&aSheet->GetTitleBlock() ) );
|
||||
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();
|
||||
|
@ -142,6 +112,7 @@ void SCH_VIEW::DisplayComponent( LIB_PART *aPart )
|
|||
void SCH_VIEW::ClearPreview()
|
||||
{
|
||||
m_preview->Clear();
|
||||
|
||||
for( auto item : m_previewItems )
|
||||
delete item;
|
||||
|
||||
|
@ -149,6 +120,7 @@ void SCH_VIEW::ClearPreview()
|
|||
Update(m_preview.get());
|
||||
}
|
||||
|
||||
|
||||
void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
|
||||
{
|
||||
m_preview->Add( aItem );
|
||||
|
@ -161,6 +133,7 @@ void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
|
|||
Update( m_preview.get() );
|
||||
}
|
||||
|
||||
|
||||
void SCH_VIEW::ShowSelectionArea( bool aShow )
|
||||
{
|
||||
if( aShow )
|
||||
|
@ -174,21 +147,25 @@ 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 );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -13,16 +13,16 @@ class SCH_SHEET;
|
|||
class SCH_SCREEN;
|
||||
class LIB_PART;
|
||||
|
||||
namespace KIGFX {
|
||||
namespace KIGFX
|
||||
{
|
||||
class VIEW_GROUP;
|
||||
|
||||
namespace PREVIEW {
|
||||
class SELECTION_AREA;
|
||||
|
||||
};
|
||||
|
||||
class WORKSHEET_VIEWITEM;
|
||||
|
||||
namespace PREVIEW
|
||||
{
|
||||
class SELECTION_AREA;
|
||||
};
|
||||
|
||||
class SCH_VIEW : public KIGFX::VIEW
|
||||
{
|
||||
public:
|
||||
|
@ -33,19 +33,6 @@ public:
|
|||
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(); }
|
||||
|
|
|
@ -204,7 +204,7 @@ public:
|
|||
* > 0 except for schematics.
|
||||
* false: when coordinates can only be >= 0
|
||||
* Schematic */
|
||||
bool m_FirstRedraw;
|
||||
bool m_Initialized;
|
||||
|
||||
// Undo/redo list of commands
|
||||
UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data)
|
||||
|
|
Loading…
Reference in New Issue