Code cleaning and more about work items visibility

This commit is contained in:
charras 2010-01-30 20:17:56 +00:00
parent 6216eccd7d
commit 607ec762d3
12 changed files with 81 additions and 68 deletions

View File

@ -20,7 +20,6 @@ void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer)
DisplayOpt.DisplayPadFill = FILLED;
DisplayOpt.DisplayViaFill = FILLED;
DisplayOpt.DisplayPadNum = 0;
DisplayOpt.DisplayPadNoConn = 0;
DisplayOpt.DisplayPadIsol = 0;
DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;

View File

@ -101,7 +101,6 @@ public:
bool DisplayPadFill;
bool DisplayViaFill;
bool DisplayPadNum;
bool DisplayPadNoConn;
bool DisplayPadIsol;
int DisplayModEdge;

View File

@ -96,11 +96,8 @@ protected:
* <p>
* This function cannot be inline without including layer_widget.h in
* here and we do not want to do that.
* @param aRenderOnly: true to update render only, false (default) for full update
* if aRenderOnly = true, the page displayed by the layer manager is not changed
* if aRenderOnly = false, the page displayed after update is the layers list
*/
void syncLayerWidget(bool aRenderOnly = false);
void syncLayerWidget( );
/**
* Function syncLayerBox
@ -186,6 +183,34 @@ public:
void ReCreateMenuBar();
WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent );
/**
* Function IsElementVisible
* tests whether a given element category is visible. Keep this as an
* inline function.
* @param aPCB_VISIBLE is from the enum by the same name
* @return bool - true if the element is visible.
* @see enum PCB_VISIBLE
*/
bool IsElementVisible( int aPCB_VISIBLE )
{
return GetBoard()->IsElementVisible( aPCB_VISIBLE );
}
/**
* Function SetElementVisibility
* changes the visibility of an element category
* @param aPCB_VISIBLE is from the enum by the same name
* @param aNewState = The new visibility state of the element category
* @see enum PCB_VISIBLE
*/
void SetElementVisibility( int aPCB_VISIBLE, bool aNewState );
/**
* Function SetVisibleAlls
* Set the status of all visible element categories and layers to VISIBLE
*/
void SetVisibleAlls( );
/**
* Function ReFillLayerWidget
* changes out all the layers in m_Layers and may be called upon

View File

@ -392,6 +392,7 @@ void BOARD::SetVisibleElements( int aMask )
{
/* Call SetElementVisibility for each item,
* to ensure specific calculations that can be needed by some items
* just change the visibility flags could be not sufficient
*/
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
{
@ -408,9 +409,7 @@ void BOARD::SetVisibleAlls( )
* to ensure specific calculations that can be needed by some items
*/
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
{
SetElementVisibility( ii, true );
}
}

View File

@ -146,7 +146,6 @@ DISPLAY_OPTIONS::DISPLAY_OPTIONS()
DisplayPadFill = FILLED;
DisplayViaFill = FILLED;
DisplayPadNum = true;
DisplayPadNoConn = true;
DisplayPadIsol = true;
DisplayModEdge = true;

View File

@ -29,7 +29,7 @@ void WinEDA_PcbFrame::InstallDisplayOptionsDialog( wxCommandEvent& aEvent )
/*******************************************************************************/
Dialog_Display_Options::Dialog_Display_Options( WinEDA_BasePcbFrame* parent ) :
Dialog_Display_Options::Dialog_Display_Options( WinEDA_PcbFrame* parent ) :
DialogDisplayOptions_base(parent)
/*******************************************************************************/
{
@ -81,7 +81,7 @@ void Dialog_Display_Options::init()
m_OptDisplayModEdges->SetSelection( DisplayOpt.DisplayModEdge );
m_OptDisplayPadClearence->SetValue( DisplayOpt.DisplayPadIsol );
m_OptDisplayPadNumber->SetValue( DisplayOpt.DisplayPadNum );
m_OptDisplayPadNoConn->SetValue( DisplayOpt.DisplayPadNoConn );
m_OptDisplayPadNoConn->SetValue( m_Parent->IsElementVisible( PCB_VISIBLE(NO_CONNECTS_VISIBLE) ) );
m_OptDisplayDrawings->SetSelection( DisplayOpt.DisplayDrawItems );
m_ShowNetNamesOption->SetSelection( DisplayOpt.DisplayNetNamesMode);
@ -152,7 +152,8 @@ void Dialog_Display_Options::OnOkClick(wxCommandEvent& event)
m_Parent->m_DisplayPadNum = DisplayOpt.DisplayPadNum = m_OptDisplayPadNumber->GetValue();
DisplayOpt.DisplayPadNoConn = m_OptDisplayPadNoConn->GetValue();
m_Parent->SetElementVisibility( PCB_VISIBLE(NO_CONNECTS_VISIBLE),
m_OptDisplayPadNoConn->GetValue());
DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection();
DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();

View File

@ -6,13 +6,12 @@
class Dialog_Display_Options : public DialogDisplayOptions_base
{
private:
WinEDA_BasePcbFrame* m_Parent;
WinEDA_PcbFrame* m_Parent;
void init();
public:
Dialog_Display_Options( WinEDA_BasePcbFrame* parent );
Dialog_Display_Options(WinEDA_BasePcbFrame*, wxWindow*);
Dialog_Display_Options( WinEDA_PcbFrame* parent );
~Dialog_Display_Options( ) { };
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );

View File

@ -98,7 +98,7 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
Drc_On = m_DrcOn->GetValue();
if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() )
{
m_Board->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() );
m_Parent->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() );
m_Parent->DrawPanel->Refresh( );
}
g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue();
@ -159,20 +159,17 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
break;
case ID_TB_OPTIONS_SHOW_GRID:
GetBoard()->SetElementVisibility(GRID_VISIBLE, state);
syncLayerWidget( true );
SetElementVisibility(GRID_VISIBLE, state);
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SHOW_RATSNEST:
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, state);
syncLayerWidget( true );
SetElementVisibility(RATSNEST_VISIBLE, state);
DrawPanel->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
g_Show_Module_Ratsnest = state; // TODO: use the visibility list
syncLayerWidget( true );
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:

View File

@ -245,11 +245,16 @@ this file again."));
/* Rebuild the new pad list (for drc and ratsnet control ...) */
GetBoard()->m_Status_Pcb = 0;
/* Reset the layers and items visibility flag when loading a new config
/* Reset the items visibility flag when loading a new config
* Because it could creates SERIOUS mistakes for the user,
* if some enabled layers or items are not visible after loading a board...
* if board items are not visible after loading a board...
* Grid and ratsnest can be left to their previous state
*/
GetBoard()->m_BoardSettings->SetVisibleAlls( );
bool showGrid = IsElementVisible(GRID_VISIBLE);
bool showRats = IsElementVisible(RATSNEST_VISIBLE);
SetVisibleAlls( );
SetElementVisibility(GRID_VISIBLE, showGrid);
SetElementVisibility(RATSNEST_VISIBLE, showRats);
// Update info shown by the horizontal toolbars
GetBoard()->SetCurrentNetClass( NETCLASS::Default );

View File

@ -85,9 +85,6 @@ public:
PCB_LAYER_WIDGET( WinEDA_PcbFrame* aParent, wxWindow* aFocusOwner, int aPointSize = 10 );
void ReFill();
// Update Show/hide checkbox state in render page
// must be called when a Show/hide option is changed outside the layer manager
void RenderSynchronize( );
//-----<implement LAYER_WIDGET abstract callback functions>-----------
void OnLayerColorChange( int aLayer, int aColor );
@ -318,34 +315,6 @@ void PCB_LAYER_WIDGET::ReFill()
// m_Layers->Thaw();
}
// Update the checkboxes state of each row of the render.
void PCB_LAYER_WIDGET::RenderSynchronize( )
{
BOARD* brd = myframe->GetBoard();
wxSizerItemList& sizerslist = m_RenderFlexGridSizer->GetChildren();
for( unsigned ii=0; ii< PCB_VISIBLE(END_PCB_VISIBLE_LIST); ++ii )
{
unsigned idx = ii * m_RenderFlexGridSizer->GetCols();
// idx points the first size of a m_RenderFlexGridSizer row
// the checkbox to update is managed by the second sizer
idx = idx + 1;
if( idx >= sizerslist.size() )
break; // Should not occur
// Get the sizer that manages the check box to update
wxSizerItem * sizer = sizerslist[idx];
// Get the checkbox and update its state.
wxCheckBox* cb = (wxCheckBox*)sizer->GetWindow();
if( cb )
{
// Calculate the visible item id
int id = getDecodedId(cb->GetId());
cb->SetValue(brd->IsElementVisible(id));
}
}
}
//-----<LAYER_WIDGET callbacks>-------------------------------------------
void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, int aColor )
@ -854,7 +823,6 @@ void WinEDA_PcbFrame::ShowDesignRulesEditor( wxCommandEvent& event )
if( returncode == wxID_OK ) // New rules, or others changes.
{
ReCreateLayerBox( NULL );
// ReFillLayerWidget(); why?
GetScreen()->SetModify();
}
}
@ -905,10 +873,33 @@ void WinEDA_PcbFrame::SaveSettings()
}
void WinEDA_PcbFrame::syncLayerWidget( bool aRenderOnly)
void WinEDA_PcbFrame::syncLayerWidget( )
{
if( ! aRenderOnly )
m_Layers->SelectLayer( getActiveLayer() );
m_Layers->RenderSynchronize( );
m_Layers->SelectLayer( getActiveLayer() );
}
/**
* Function SetElementVisibility
* changes the visibility of an element category
* @param aPCB_VISIBLE is from the enum by the same name
* @param aNewState = The new visibility state of the element category
* @see enum PCB_VISIBLE
*/
void WinEDA_PcbFrame::SetElementVisibility( int aPCB_VISIBLE, bool aNewState )
{
GetBoard()->SetElementVisibility( aPCB_VISIBLE, aNewState );
m_Layers->SetRenderState( aPCB_VISIBLE, aNewState );
}
/**
* Function SetVisibleAlls
* Set the status of all visible element categories and layers to VISIBLE
*/
void WinEDA_PcbFrame::SetVisibleAlls( )
{
GetBoard()->SetVisibleAlls( );
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
m_Layers->SetRenderState( ii, true );
}

View File

@ -194,13 +194,11 @@ bool WinEDA_PcbFrame::Read_Config( const wxString& projectFileName )
* if board items are not visible after loading a board...
* Grid and ratsnest can be left to their previous state
*/
bool showGrid = GetBoard()->IsElementVisible(GRID_VISIBLE);
bool showRats = GetBoard()->IsElementVisible(RATSNEST_VISIBLE);
GetBoard()->SetVisibleAlls( );
GetBoard()->SetElementVisibility(GRID_VISIBLE, showGrid);
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, showRats);
DisplayOpt.DisplayPadNoConn = true;
bool showGrid = IsElementVisible(GRID_VISIBLE);
bool showRats = IsElementVisible(RATSNEST_VISIBLE);
SetVisibleAlls( );
SetElementVisibility(GRID_VISIBLE, showGrid);
SetElementVisibility(RATSNEST_VISIBLE, showRats);
return TRUE;
}

View File

@ -62,7 +62,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC,
frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum = false;
DisplayOpt.DisplayPadNoConn = false;
bool nctmp = frame->GetBoard()->IsElementVisible(NO_CONNECTS_VISIBLE);
DisplayOpt.DisplayPadIsol = false;
DisplayOpt.DisplayModEdge = FILLED;
DisplayOpt.DisplayModText = FILLED;
@ -190,6 +190,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* aDC,
frame->m_DisplayPadFill = DisplayOpt.DisplayPadFill;
frame->m_DisplayViaFill = DisplayOpt.DisplayViaFill;
frame->m_DisplayPadNum = DisplayOpt.DisplayPadNum;
frame->GetBoard()->SetElementVisibility(NO_CONNECTS_VISIBLE, nctmp);
}