GAL view in pad properties dialog - initial version.

This commit is contained in:
Maciej Suminski 2014-07-09 11:22:43 +02:00
parent 0a6de2e13f
commit 5134781a38
6 changed files with 141 additions and 9 deletions

View File

@ -272,9 +272,12 @@ BOX2D VIEW::GetViewport() const
}
void VIEW::SetViewport( const BOX2D& aViewport, bool aKeepAspect )
void VIEW::SetViewport( const BOX2D& aViewport )
{
VECTOR2D ssize = ToWorld( m_gal->GetScreenPixelSize(), false );
wxASSERT( ssize.x > 0 && ssize.y > 0 );
VECTOR2D centre = aViewport.Centre();
VECTOR2D vsize = aViewport.GetSize();
double zoom = 1.0 / std::max( fabs( vsize.x / ssize.x ), fabs( vsize.y / ssize.y ) );

View File

@ -159,9 +159,8 @@ public:
* Function SetViewport()
* Sets the visible area of the VIEW.
* @param aViewport: desired visible area, in world space coordinates.
* @param aKeepProportions: when true, the X/Y size proportions are kept.
*/
void SetViewport( const BOX2D& aViewport, bool aKeepProportions = true );
void SetViewport( const BOX2D& aViewport );
/**
* Function GetViewport()
@ -201,7 +200,7 @@ public:
* Function GetScale()
* @return Current scalefactor of this VIEW
*/
double GetScale() const
double GetScale() const
{
return m_scale;
}

View File

@ -117,6 +117,8 @@ private:
bool padValuesOK(); ///< test if all values are acceptable for the pad
void redraw();
/**
* Function setPadLayersList
* updates the CheckBox states in pad layers list,
@ -174,6 +176,21 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
else // We are editing a "master" pad, i.e. a pad used to create new pads
m_dummyPad->Copy( m_padMaster );
if( m_parent->IsGalCanvasActive() )
{
m_panelShowPadGal->UseColorScheme( m_board->GetColorsSettings() );
m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
m_panelShowPad->Hide();
m_panelShowPadGal->Show();
m_panelShowPadGal->GetView()->Add( m_dummyPad );
m_panelShowPadGal->StartDrawing();
}
else
{
m_panelShowPad->Show();
m_panelShowPadGal->Hide();
}
initValues();
m_sdbSizer1OK->SetDefault();
@ -537,7 +554,7 @@ void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
}
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
@ -566,7 +583,7 @@ void DIALOG_PAD_PROPERTIES::OnDrillShapeSelected( wxCommandEvent& event )
}
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
@ -599,7 +616,7 @@ void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
m_PadOrientCtrl->SetValue( msg );
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
@ -667,7 +684,7 @@ void DIALOG_PAD_PROPERTIES::setPadLayersList( LSET layer_mask )
void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
{
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
@ -758,6 +775,29 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
}
void DIALOG_PAD_PROPERTIES::redraw()
{
if( m_parent->IsGalCanvasActive() )
{
m_dummyPad->ViewUpdate();
BOX2I bbox = m_dummyPad->ViewBBox();
// Autozoom
m_panelShowPadGal->GetView()->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
// Add a margin
m_panelShowPadGal->GetView()->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
m_panelShowPadGal->Refresh();
}
else
{
m_panelShowPad->Refresh();
}
}
void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
{
if( !padValuesOK() )
@ -1132,7 +1172,7 @@ void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
if( m_canUpdate )
{
transferDataToPad( m_dummyPad );
m_panelShowPad->Refresh();
redraw();
}
}

View File

@ -536,6 +536,9 @@ DIALOG_PAD_PROPERTIES_BASE::DIALOG_PAD_PROPERTIES_BASE( wxWindow* parent, wxWind
bSizerDisplayPad->Add( m_panelShowPad, 4, wxRIGHT|wxTOP|wxEXPAND, 5 );
m_panelShowPadGal = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), wxDefaultSize, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
bSizerDisplayPad->Add( m_panelShowPadGal, 4, wxEXPAND|wxRIGHT|wxTOP, 5 );
bSizerUpper->Add( bSizerDisplayPad, 1, wxEXPAND|wxTOP|wxBOTTOM, 5 );

View File

@ -8310,6 +8310,91 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxRIGHT|wxTOP</property>
<property name="proportion">4</property>
<object class="CustomControl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="class">PCB_DRAW_PANEL_GAL</property>
<property name="close_button">1</property>
<property name="construction">m_panelShowPadGal = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), wxDefaultSize, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="declaration">PCB_DRAW_PANEL_GAL* m_panelShowPadGal;</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="include">#include &lt;pcb_draw_panel_gal.h&gt;</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelShowPadGal</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="settings"></property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>

View File

@ -30,6 +30,7 @@ class DIALOG_SHIM;
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/notebook.h>
#include <pcb_draw_panel_gal.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -143,6 +144,7 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM
wxStaticText* m_ThermalGapUnits;
wxStaticText* m_staticTextWarning;
wxPanel* m_panelShowPad;
PCB_DRAW_PANEL_GAL* m_panelShowPadGal;
wxStaticText* m_staticTextWarningPadFlipped;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;