Commit 9b77f2a4 authored by jean-pierre charras's avatar jean-pierre charras

Formatting, code cleaning and fix erroneous or inconsistent comments in block functions

parent bc9d5217
...@@ -462,9 +462,9 @@ void WinEDA_DrawFrame::HandleBlockPlace( wxDC* DC ) ...@@ -462,9 +462,9 @@ void WinEDA_DrawFrame::HandleBlockPlace( wxDC* DC )
} }
int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC ) bool WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
{ {
return 0; return false;
} }
......
...@@ -101,19 +101,19 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos() ...@@ -101,19 +101,19 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos()
*/ */
void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
{ {
bool err = FALSE; bool err = false;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
err = TRUE; err = true;
DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) ); DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) );
} }
if( block->GetCount() == 0 ) if( block->GetCount() == 0 )
{ {
wxString msg; wxString msg;
err = TRUE; err = true;
msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd %d, state %d)" ), msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd %d, state %d)" ),
block->m_Command, block->m_State ); block->m_Command, block->m_State );
DisplayError( this, msg ); DisplayError( this, msg );
...@@ -124,7 +124,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -124,7 +124,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
switch( block->m_Command ) switch( block->m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = true;
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
...@@ -133,7 +133,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -133,7 +133,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector ); SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector );
MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector ); MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector );
...@@ -143,7 +143,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -143,7 +143,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector ); DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
...@@ -155,7 +155,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -155,7 +155,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_PASTE: case BLOCK_PASTE:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
PasteListOfItems( DC ); PasteListOfItems( DC );
block->ClearItemsList(); block->ClearItemsList();
break; break;
...@@ -194,16 +194,20 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -194,16 +194,20 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
} }
/* Manage end block command /**
* Returns: * Function HandleBlockEnd( )
* 0 if no features selected * Handle the "end" of a block command,
* 1 otherwise * i.e. is called at the end of the definition of the area of a block.
* -1 If control ended and components selection (block delete, block save) * depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/ */
int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) bool WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{ {
int ii = 0; bool nextcmd = false;
bool zoom_command = FALSE; bool zoom_command = false;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( block->GetCount() ) if( block->GetCount() )
...@@ -241,16 +245,16 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -241,16 +245,16 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->GetCount() ) if( block->GetCount() )
{ {
ii = 1; nextcmd = true;
CollectStructsToDrag( GetScreen() ); CollectStructsToDrag( GetScreen() );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
block->m_State = STATE_BLOCK_MOVE; block->m_State = STATE_BLOCK_MOVE;
} }
else else
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
} }
...@@ -258,10 +262,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -258,10 +262,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() ); PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
ii = -1;
DeleteItemsInList( DrawPanel, block->m_ItemsSelection ); DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
OnModify(); OnModify();
} }
...@@ -272,14 +275,13 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -272,14 +275,13 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: /* Save */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() ); PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection ); SaveStructListForPaste( block->m_ItemsSelection );
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector ); MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector );
ii = -1; }
}
block->ClearItemsList(); block->ClearItemsList();
break; break;
...@@ -292,7 +294,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -292,7 +294,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
zoom_command = TRUE; zoom_command = true;
break; break;
case BLOCK_SELECT_ITEMS_ONLY: /* Not used */ case BLOCK_SELECT_ITEMS_ONLY: /* Not used */
...@@ -305,7 +307,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -305,7 +307,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
GetScreen()->ClearDrawingState(); GetScreen()->ClearDrawingState();
} }
if( ii <= 0 ) if( ! nextcmd )
{ {
block->m_Flags = 0; block->m_Flags = 0;
block->m_State = STATE_NO_BLOCK; block->m_State = STATE_NO_BLOCK;
...@@ -319,7 +321,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -319,7 +321,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
if( zoom_command ) if( zoom_command )
Window_Zoom( GetScreen()->m_BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
return ii; return nextcmd ;
} }
...@@ -359,7 +361,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -359,7 +361,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_DRAG: /* move to Drag */ case BLOCK_DRAG: /* move to Drag */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
// Clear list of items to move, and rebuild it with items to drag: // Clear list of items to move, and rebuild it with items to drag:
block->ClearItemsList(); block->ClearItemsList();
...@@ -371,14 +373,14 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -371,14 +373,14 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
blockCmdFinished = false; blockCmdFinished = false;
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() ); CollectStructsToDrag( (SCH_SCREEN*) GetScreen() );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
block->m_State = STATE_BLOCK_MOVE; block->m_State = STATE_BLOCK_MOVE;
} }
break; break;
case BLOCK_DELETE: /* move to Delete */ case BLOCK_DELETE: /* move to Delete */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
DeleteItemsInList( DrawPanel, block->m_ItemsSelection ); DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
...@@ -390,7 +392,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -390,7 +392,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_SAVE: /* Save list in paste buffer*/ case BLOCK_SAVE: /* Save list in paste buffer*/
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
...@@ -408,7 +410,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -408,7 +410,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_ROTATE: case BLOCK_ROTATE:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
// blockCmdFinished = true; // blockCmdFinished = true;
...@@ -427,7 +429,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -427,7 +429,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
// blockCmdFinished = true; // blockCmdFinished = true;
...@@ -446,7 +448,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -446,7 +448,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
if( block->GetCount() ) if( block->GetCount() )
{ {
// blockCmdFinished = true; // blockCmdFinished = true;
......
...@@ -69,10 +69,10 @@ int WinEDA_LibeditFrame::ReturnBlockCommand( int key ) ...@@ -69,10 +69,10 @@ int WinEDA_LibeditFrame::ReturnBlockCommand( int key )
* 1 if HandleBlockPlace must follow (items found, and a block place * 1 if HandleBlockPlace must follow (items found, and a block place
* command must follow) * command must follow)
*/ */
int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) bool WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{ {
int ItemCount = 0; int ItemCount = 0;
int MustDoPlace = 0; int nextCmd = false;
wxPoint pt; wxPoint pt;
if( GetScreen()->m_BlockLocate.GetCount() ) if( GetScreen()->m_BlockLocate.GetCount() )
...@@ -104,7 +104,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -104,7 +104,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
g_EditPinByPinIsOn ); g_EditPinByPinIsOn );
if( ItemCount ) if( ItemCount )
{ {
MustDoPlace = 1; nextCmd = true;
if( DrawPanel->ManageCurseur != NULL ) if( DrawPanel->ManageCurseur != NULL )
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -117,7 +117,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -117,7 +117,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
MustDoPlace = 1; nextCmd = true;
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
break; break;
...@@ -165,7 +165,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -165,7 +165,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
break; break;
} }
if( MustDoPlace <= 0 ) if( ! nextCmd )
{ {
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
if ( m_component ) if ( m_component )
...@@ -182,7 +182,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -182,7 +182,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
} }
return MustDoPlace; return nextCmd;
} }
......
...@@ -25,10 +25,10 @@ class Dialog_BodyGraphicText_Properties; ...@@ -25,10 +25,10 @@ class Dialog_BodyGraphicText_Properties;
*/ */
class WinEDA_LibeditFrame : public WinEDA_DrawFrame class WinEDA_LibeditFrame : public WinEDA_DrawFrame
{ {
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit. LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
wxString m_oldRootName; ///< The actual pointer of the component loaded from wxString m_oldRootName; ///< The actual pointer of the component loaded from
///< a library. Do not do anything with this pointer. ///< a library. Do not do anything with this pointer.
///< It is to be used for reference purposes only. ///< It is to be used for reference purposes only.
public: public:
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any) WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
~WinEDA_LibeditFrame(); ~WinEDA_LibeditFrame();
void ReCreateMenuBar(); void ReCreateMenuBar();
/** /**
* Function EnsureActiveLibExists * Function EnsureActiveLibExists
...@@ -55,59 +55,59 @@ public: ...@@ -55,59 +55,59 @@ public:
* Function SetLanguage * Function SetLanguage
* is called on a language menu selection * is called on a language menu selection
*/ */
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
void InstallConfigFrame( wxCommandEvent& event ); void InstallConfigFrame( wxCommandEvent& event );
void InstallDimensionsDialog( wxCommandEvent& event ); void InstallDimensionsDialog( wxCommandEvent& event );
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
void OnPlotCurrentComponent( wxCommandEvent& event ); void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void OnImportPart( wxCommandEvent& event ); void OnImportPart( wxCommandEvent& event );
void OnExportPart( wxCommandEvent& event ); void OnExportPart( wxCommandEvent& event );
void OnSelectAlias( wxCommandEvent& event ); void OnSelectAlias( wxCommandEvent& event );
void OnSelectPart( wxCommandEvent& event ); void OnSelectPart( wxCommandEvent& event );
void DeleteOnePart( wxCommandEvent& event ); void DeleteOnePart( wxCommandEvent& event );
void CreateNewLibraryPart( wxCommandEvent& event ); void CreateNewLibraryPart( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event ); void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event ); void InstallFieldsEditorDialog( wxCommandEvent& event );
void LoadOneLibraryPart( wxCommandEvent& event ); void LoadOneLibraryPart( wxCommandEvent& event );
void OnViewEntryDoc( wxCommandEvent& event ); void OnViewEntryDoc( wxCommandEvent& event );
void OnCheckComponent( wxCommandEvent& event ); void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event ); void OnSelectBodyStyle( wxCommandEvent& event );
void OnEditPin( wxCommandEvent& event ); void OnEditPin( wxCommandEvent& event );
void OnRotatePin( wxCommandEvent& event ); void OnRotatePin( wxCommandEvent& event );
void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdateNotEditingPart( wxUpdateUIEvent& event ); void OnUpdateNotEditingPart( wxUpdateUIEvent& event );
void OnUpdateUndo( wxUpdateUIEvent& event ); void OnUpdateUndo( wxUpdateUIEvent& event );
void OnUpdateRedo( wxUpdateUIEvent& event ); void OnUpdateRedo( wxUpdateUIEvent& event );
void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event ); void OnUpdateSaveCurrentLib( wxUpdateUIEvent& event );
void OnUpdateViewDoc( wxUpdateUIEvent& event ); void OnUpdateViewDoc( wxUpdateUIEvent& event );
void OnUpdatePinByPin( wxUpdateUIEvent& event ); void OnUpdatePinByPin( wxUpdateUIEvent& event );
void OnUpdatePartNumber( wxUpdateUIEvent& event ); void OnUpdatePartNumber( wxUpdateUIEvent& event );
void OnUpdateDeMorganNormal( wxUpdateUIEvent& event ); void OnUpdateDeMorganNormal( wxUpdateUIEvent& event );
void OnUpdateDeMorganConvert( wxUpdateUIEvent& event ); void OnUpdateDeMorganConvert( wxUpdateUIEvent& event );
void OnUpdateSelectAlias( wxUpdateUIEvent& event ); void OnUpdateSelectAlias( wxUpdateUIEvent& event );
void UpdateAliasSelectList(); void UpdateAliasSelectList();
void UpdatePartSelectList(); void UpdatePartSelectList();
void DisplayLibInfos(); void DisplayLibInfos();
void RedrawActiveWindow( wxDC* DC, bool EraseBg ); void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
void ReCreateHToolbar(); void ReCreateHToolbar();
void ReCreateVToolbar(); void ReCreateVToolbar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
int BestZoom(); // Returns the best zoom int BestZoom(); // Returns the best zoom
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); } SCH_SCREEN* GetScreen() { return (SCH_SCREEN*) GetBaseScreen(); }
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels ); void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels );
void LoadSettings(); void LoadSettings();
void SaveSettings(); void SaveSettings();
/** /**
* Function CloseWindow * Function CloseWindow
...@@ -122,16 +122,18 @@ public: ...@@ -122,16 +122,18 @@ public:
Close( false ); Close( false );
} }
/** /**
* Function OnModify * Function OnModify
* Must be called after a schematic change * Must be called after a schematic change
* in order to set the "modify" flag of the current screen * in order to set the "modify" flag of the current screen
*/ */
void OnModify( ) void OnModify()
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
LIB_COMPONENT* GetComponent( void ) { return m_component; } LIB_COMPONENT* GetComponent( void ) { return m_component; }
CMP_LIBRARY* GetLibrary( void ) { return m_library; } CMP_LIBRARY* GetLibrary( void ) { return m_library; }
...@@ -166,7 +168,7 @@ public: ...@@ -166,7 +168,7 @@ public:
LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; } LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_DRAW_ITEM* drawItem ); void SetDrawItem( LIB_DRAW_ITEM* drawItem );
bool GetShowDeMorgan( void ) { return m_showDeMorgan; } bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
...@@ -179,14 +181,14 @@ public: ...@@ -179,14 +181,14 @@ public:
* create a temporary copy of the current edited component * create a temporary copy of the current edited component
* Used to prepare an Undo ant/or abort command before editing the component * Used to prepare an Undo ant/or abort command before editing the component
*/ */
void TempCopyComponent(); void TempCopyComponent();
/** /**
* Function RestoreComponent * Function RestoreComponent
* Restore the current edited component from its temporary copy. * Restore the current edited component from its temporary copy.
* Used to abort a command * Used to abort a command
*/ */
void RestoreComponent(); void RestoreComponent();
/** /**
* Function GetTempCopyComponent * Function GetTempCopyComponent
...@@ -210,7 +212,7 @@ private: ...@@ -210,7 +212,7 @@ private:
* The library list can be changed by the schematic editor after reloading a new schematic * The library list can be changed by the schematic editor after reloading a new schematic
* and the current m_library can point a non existent lib. * and the current m_library can point a non existent lib.
*/ */
virtual void OnActivate( wxActivateEvent& event ); virtual void OnActivate( wxActivateEvent& event );
// General: // General:
void SaveOnePartInMemory(); void SaveOnePartInMemory();
...@@ -241,7 +243,7 @@ private: ...@@ -241,7 +243,7 @@ private:
LIB_DRAW_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ); LIB_DRAW_ITEM* CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC );
void GraphicItemBeginDraw( wxDC* DC ); void GraphicItemBeginDraw( wxDC* DC );
void StartMoveDrawSymbol( wxDC* DC ); void StartMoveDrawSymbol( wxDC* DC );
void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc. void StartModifyDrawSymbol( wxDC* DC ); //<! Modify the item, adjust size etc.
void EndDrawGraphicItem( wxDC* DC ); void EndDrawGraphicItem( wxDC* DC );
void LoadOneSymbol(); void LoadOneSymbol();
void SaveOneSymbol(); void SaveOneSymbol();
...@@ -252,9 +254,9 @@ private: ...@@ -252,9 +254,9 @@ private:
public: public:
/* Block commands: */ /* Block commands: */
int ReturnBlockCommand( int key ); virtual int ReturnBlockCommand( int key );
void HandleBlockPlace( wxDC* DC ); virtual void HandleBlockPlace( wxDC* DC );
int HandleBlockEnd( wxDC* DC ); virtual bool HandleBlockEnd( wxDC* DC );
void PlacePin( wxDC* DC ); void PlacePin( wxDC* DC );
void GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ); void GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id );
...@@ -263,12 +265,12 @@ public: ...@@ -263,12 +265,12 @@ public:
void RepeatPinItem( wxDC* DC, LIB_PIN* Pin ); void RepeatPinItem( wxDC* DC, LIB_PIN* Pin );
protected: protected:
wxString m_ConfigPath; wxString m_ConfigPath;
wxString m_LastLibImportPath; wxString m_LastLibImportPath;
wxString m_LastLibExportPath; wxString m_LastLibExportPath;
/** Convert of the item currently being drawn. */ /** Convert of the item currently being drawn. */
bool m_drawSpecificConvert; bool m_drawSpecificConvert;
/** /**
* Specify which component parts the current draw item applies to. * Specify which component parts the current draw item applies to.
...@@ -298,22 +300,22 @@ protected: ...@@ -298,22 +300,22 @@ protected:
// Show the normal shape ( m_convert <= 1 ) or the converted shape // Show the normal shape ( m_convert <= 1 ) or the converted shape
// ( m_convert > 1 ) // ( m_convert > 1 )
static int m_convert; static int m_convert;
// true to force DeMorgan/normal tools selection enabled. // true to force DeMorgan/normal tools selection enabled.
// They are enabled when the loaded component has // They are enabled when the loaded component has
// Graphic items for converted shape // Graphic items for converted shape
// But under some circumstances (New component created) // But under some circumstances (New component created)
// these tools must left enable // these tools must left enable
static bool m_showDeMorgan; static bool m_showDeMorgan;
/// The current text size setting. /// The current text size setting.
static int m_textSize; static int m_textSize;
/// Current text orientation setting. /// Current text orientation setting.
static int m_textOrientation; static int m_textOrientation;
static wxSize m_clientSize; static wxSize m_clientSize;
friend class Dialog_BodyGraphicText_Properties; friend class Dialog_BodyGraphicText_Properties;
...@@ -324,7 +326,7 @@ protected: ...@@ -324,7 +326,7 @@ protected:
* @param aFileName = the full filename * @param aFileName = the full filename
* @param aFmt_jpeg = true to use JPEG ffile format, false to use PNG file format * @param aFmt_jpeg = true to use JPEG ffile format, false to use PNG file format
*/ */
void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ); void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg );
/** Virtual function PrintPage /** Virtual function PrintPage
...@@ -337,14 +339,14 @@ protected: ...@@ -337,14 +339,14 @@ protected:
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/ */
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMask, virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMask,
bool aPrintMirrorMode, void * aData = NULL); bool aPrintMirrorMode, void* aData = NULL );
/** /**
* Function SVG_Print_component * Function SVG_Print_component
* Creates the SVG print file for the current edited component. * Creates the SVG print file for the current edited component.
* @param aFullFileName = the full filename of the file * @param aFullFileName = the full filename of the file
*/ */
void SVG_Print_Component( const wxString& aFullFileName ); void SVG_Print_Component( const wxString& aFullFileName );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
......
...@@ -88,11 +88,11 @@ int WinEDA_GerberFrame::ReturnBlockCommand( int key ) ...@@ -88,11 +88,11 @@ int WinEDA_GerberFrame::ReturnBlockCommand( int key )
/* Routine to handle the BLOCK PLACE command */ /* Routine to handle the BLOCK PLACE command */
void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
{ {
bool err = FALSE; bool err = false;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
err = TRUE; err = true;
DisplayError( this, DisplayError( this,
wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
} }
...@@ -101,21 +101,21 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -101,21 +101,21 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
switch( GetScreen()->m_BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = true;
break; break;
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
Block_Move( DC ); Block_Move( DC );
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
Block_Duplicate( DC ); Block_Duplicate( DC );
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
...@@ -152,16 +152,20 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -152,16 +152,20 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
} }
/* Routine management command END BLOCK /**
* Returns: * Function HandleBlockEnd( )
* 0 if no and selects compounds * Handle the "end" of a block command,
* 1 otherwise * i.e. is called at the end of the definition of the area of a block.
* -1 If order is completed and components found (block delete, block save) * depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/ */
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) bool WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
{ {
int endcommande = TRUE; bool nextcmd = false;
bool zoom_command = FALSE; bool zoom_command = false;
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
...@@ -177,15 +181,15 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -177,15 +181,15 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list */ case BLOCK_PRESELECT_MOVE: /* Move with preselection list */
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
endcommande = FALSE; nextcmd = true;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
Block_Delete( DC ); Block_Delete( DC );
break; break;
...@@ -197,7 +201,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -197,7 +201,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
zoom_command = TRUE; zoom_command = true;
break; break;
case BLOCK_ABORT: case BLOCK_ABORT:
...@@ -206,7 +210,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -206,7 +210,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
break; break;
} }
if( endcommande == TRUE ) if( ! nextcmd )
{ {
GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
...@@ -220,7 +224,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -220,7 +224,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
if( zoom_command ) if( zoom_command )
Window_Zoom( GetScreen()->m_BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
return endcommande; return nextcmd ;
} }
...@@ -325,7 +329,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC ) ...@@ -325,7 +329,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
gerb_item->MoveAB( delta ); gerb_item->MoveAB( delta );
} }
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( true );
} }
......
...@@ -248,9 +248,9 @@ public: ...@@ -248,9 +248,9 @@ public:
void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); void InstallPcbGlobalDeleteFrame( const wxPoint& pos );
/* handlers for block commands */ /* handlers for block commands */
int ReturnBlockCommand( int key ); virtual int ReturnBlockCommand( int key );
virtual void HandleBlockPlace( wxDC* DC ); virtual void HandleBlockPlace( wxDC* DC );
virtual int HandleBlockEnd( wxDC* DC ); virtual bool HandleBlockEnd( wxDC* DC );
/* Block operations: */ /* Block operations: */
/** /**
......
...@@ -581,12 +581,40 @@ public: ...@@ -581,12 +581,40 @@ public:
void Key( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct ); void Key( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
/* Block operations. */ /* Block operations. */
int ReturnBlockCommand( int key );
void InitBlockPasteInfos(); void InitBlockPasteInfos();
void HandleBlockPlace( wxDC* DC );
int HandleBlockEnd( wxDC* DC );
void HandleBlockEndByPopUp( int Command, wxDC* DC ); void HandleBlockEndByPopUp( int Command, wxDC* DC );
/**
* Function ReturnBlockCommand
* Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
* corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
* block command is started by dragging the mouse.
* @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/
virtual int ReturnBlockCommand( int key );
/**
* Function HandleBlockPlace( )
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
* Parameters must be initialized in GetScreen()->m_BlockLocate
*/
virtual void HandleBlockPlace( wxDC* DC );
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC );
void RepeatDrawItem( wxDC* DC ); void RepeatDrawItem( wxDC* DC );
void TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ); void TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC );
......
...@@ -473,9 +473,36 @@ public: ...@@ -473,9 +473,36 @@ public:
/* Block operations: */ /* Block operations: */
int ReturnBlockCommand( int key ); /**
void HandleBlockPlace( wxDC* DC ); * Function ReturnBlockCommand
int HandleBlockEnd( wxDC* DC ); * Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
* corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
* block command is started by dragging the mouse.
* @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/
virtual int ReturnBlockCommand( int key );
/**
* Function HandleBlockPlace( )
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
* Parameters must be initialized in GetScreen()->m_BlockLocate
*/
virtual void HandleBlockPlace( wxDC* DC );
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC );
/** /**
* Function Block_SelectItems * Function Block_SelectItems
......
...@@ -445,12 +445,39 @@ public: ...@@ -445,12 +445,39 @@ public:
void DisplayUnitsMsg(); void DisplayUnitsMsg();
/* Handlers for block commands */ /* Handlers for block commands */
virtual int ReturnBlockCommand( int key );
virtual void InitBlockPasteInfos(); virtual void InitBlockPasteInfos();
virtual bool HandleBlockBegin( wxDC* DC, int cmd_type, virtual bool HandleBlockBegin( wxDC* DC, int cmd_type,const wxPoint& startpos );
const wxPoint& startpos );
virtual void HandleBlockPlace( wxDC* DC ); /**
virtual int HandleBlockEnd( wxDC* DC ); * Function ReturnBlockCommand
* Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
* corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
* block command is started by dragging the mouse.
* @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/
virtual int ReturnBlockCommand( int key );
/**
* Function HandleBlockPlace( )
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
* Parameters must be initialized in GetScreen()->m_BlockLocate
*/
virtual void HandleBlockPlace( wxDC* DC );
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC );
void CopyToClipboard( wxCommandEvent& event ); void CopyToClipboard( wxCommandEvent& event );
......
...@@ -43,14 +43,14 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -43,14 +43,14 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
bool aErase ); bool aErase );
static bool Block_Include_Modules = true; static bool blockIncludeModules = true;
static bool BlockIncludeLockedModules = true; static bool blockIncludeLockedModules = true;
static bool Block_Include_Tracks = true; static bool blockIncludeTracks = true;
static bool Block_Include_Zones = true; static bool blockIncludeZones = true;
static bool Block_Include_Draw_Items = true; static bool blockIncludeItemsOnTechLayers = true;
static bool Block_Include_Edges_Items = true; static bool blockIncludeBoardOutlineLayer = true;
static bool Block_Include_PcbTextes = true; static bool blockIncludePcbTexts = true;
static bool BlockDrawItems = true; static bool blockDrawItems = true;
/************************************/ /************************************/
/* class DIALOG_BLOCK_OPTIONS */ /* class DIALOG_BLOCK_OPTIONS */
...@@ -72,8 +72,14 @@ public: ...@@ -72,8 +72,14 @@ public:
private: private:
void ExecuteCommand( wxCommandEvent& event ); void ExecuteCommand( wxCommandEvent& event );
void OnCancel( wxCommandEvent& event ); void OnCancel( wxCommandEvent& event ) { EndModal( -1 ); }
void checkBoxClicked( wxCommandEvent& aEvent ); void checkBoxClicked( wxCommandEvent& aEvent )
{
if( m_Include_Modules->GetValue() )
m_IncludeLockedModules->Enable();
else
m_IncludeLockedModules->Disable();
}
}; };
...@@ -99,67 +105,57 @@ static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent, const wxString& t ...@@ -99,67 +105,57 @@ static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent, const wxString& t
} }
DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* parent, DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* aParent,
const wxString& title ) : const wxString& aTitle ) :
DIALOG_BLOCK_OPTIONS_BASE( parent, -1, title ) DIALOG_BLOCK_OPTIONS_BASE( aParent, -1, aTitle )
{ {
m_Parent = parent; m_Parent = aParent;
m_Include_Modules->SetValue( Block_Include_Modules ); m_Include_Modules->SetValue( blockIncludeModules );
m_IncludeLockedModules->SetValue( BlockIncludeLockedModules ); m_IncludeLockedModules->SetValue( blockIncludeLockedModules );
m_Include_Tracks->SetValue( Block_Include_Tracks ); m_Include_Tracks->SetValue( blockIncludeTracks );
m_Include_Zones->SetValue( Block_Include_Zones ); m_Include_Zones->SetValue( blockIncludeZones );
m_Include_Draw_Items->SetValue( Block_Include_Draw_Items ); m_Include_Draw_Items->SetValue( blockIncludeItemsOnTechLayers );
m_Include_Edges_Items->SetValue( Block_Include_Edges_Items ); m_Include_Edges_Items->SetValue( blockIncludeBoardOutlineLayer );
m_Include_PcbTextes->SetValue( Block_Include_PcbTextes ); m_Include_PcbTextes->SetValue( blockIncludePcbTexts );
m_DrawBlockItems->SetValue( BlockDrawItems ); m_DrawBlockItems->SetValue( blockDrawItems );
SetFocus(); SetFocus();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
Centre(); Centre();
} }
void DIALOG_BLOCK_OPTIONS::OnCancel( wxCommandEvent& WXUNUSED (event) )
{
EndModal( -1 );
}
void DIALOG_BLOCK_OPTIONS::checkBoxClicked( wxCommandEvent& WXUNUSED (aEvent) )
{
if( m_Include_Modules->GetValue() )
m_IncludeLockedModules->Enable();
else
m_IncludeLockedModules->Disable();
}
void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event ) void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
{ {
Block_Include_Modules = m_Include_Modules->GetValue(); blockIncludeModules = m_Include_Modules->GetValue();
BlockIncludeLockedModules = m_IncludeLockedModules->GetValue(); blockIncludeLockedModules = m_IncludeLockedModules->GetValue();
Block_Include_Tracks = m_Include_Tracks->GetValue(); blockIncludeTracks = m_Include_Tracks->GetValue();
Block_Include_Zones = m_Include_Zones->GetValue(); blockIncludeZones = m_Include_Zones->GetValue();
Block_Include_Draw_Items = m_Include_Draw_Items->GetValue(); blockIncludeItemsOnTechLayers = m_Include_Draw_Items->GetValue();
Block_Include_Edges_Items = m_Include_Edges_Items->GetValue(); blockIncludeBoardOutlineLayer = m_Include_Edges_Items->GetValue();
Block_Include_PcbTextes = m_Include_PcbTextes->GetValue(); blockIncludePcbTexts = m_Include_PcbTextes->GetValue();
BlockDrawItems = m_DrawBlockItems->GetValue(); blockDrawItems = m_DrawBlockItems->GetValue();
EndModal( 0 ); EndModal( 0 );
} }
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to /**
* the key (ALT, SHIFT ALT ..) * Function ReturnBlockCommand
* Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
* corresponding to the keys pressed (ALT, SHIFT, SHIFT ALT ..) when
* block command is started by dragging the mouse.
* @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/ */
int WinEDA_PcbFrame::ReturnBlockCommand( int key ) int WinEDA_PcbFrame::ReturnBlockCommand( int aKey )
{ {
int cmd = 0; int cmd = 0;
switch( key ) switch( aKey )
{ {
default: default:
cmd = key & 0x255; cmd = aKey & 0x255;
break; break;
case 0: case 0:
...@@ -191,7 +187,13 @@ int WinEDA_PcbFrame::ReturnBlockCommand( int key ) ...@@ -191,7 +187,13 @@ int WinEDA_PcbFrame::ReturnBlockCommand( int key )
} }
/* Routine to handle the BLOCK PLACE command */ /**
* Function HandleBlockPlace( )
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
* Parameters must be initialized in GetScreen()->m_BlockLocate
*/
void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
{ {
bool err = false; bool err = false;
...@@ -250,15 +252,20 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -250,15 +252,20 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
} }
/* Handle END BLOCK command. /**
* Returns: * Function HandleBlockEnd( )
* 0 if no features selected * Handle the "end" of a block command,
* 1 otherwise * i.e. is called at the end of the definition of the area of a block.
* -1 If order is completed and components found (block delete, block save) * depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/ */
int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) bool WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
{ {
int endcommande = true; bool nextcmd = false;
bool cancelCmd = false;
// If coming here after cancel block, clean up and exit // If coming here after cancel block, clean up and exit
if( GetScreen()->m_BlockLocate.m_State == STATE_NO_BLOCK ) if( GetScreen()->m_BlockLocate.m_State == STATE_NO_BLOCK )
...@@ -269,7 +276,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -269,7 +276,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
return 0; return false;
} }
// Show dialog if there are no selected items and // Show dialog if there are no selected items and
...@@ -279,79 +286,24 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -279,79 +286,24 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
{ {
if( !InstallBlockCmdFrame( this, _( "Block Operation" ) ) ) if( !InstallBlockCmdFrame( this, _( "Block Operation" ) ) )
{ {
DrawPanel->ManageCurseur = NULL; cancelCmd = true;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ManageCurseur( DrawPanel, DC, false ); // undraw block outline
GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->m_BlockLocate.ClearItemsList();
DisplayToolMsg( wxEmptyString );
DrawAndSizingBlockOutlines( DrawPanel, DC, false );
return 0;
} }
DrawAndSizingBlockOutlines( DrawPanel, DC, false ); else
Block_SelectItems();
// Exit if no items found
if( !GetScreen()->m_BlockLocate.GetCount() )
{ {
DrawPanel->ManageCurseur = NULL; DrawAndSizingBlockOutlines( DrawPanel, DC, false );
DrawPanel->ForceCloseManageCurseur = NULL; Block_SelectItems();
GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->m_BlockLocate.ClearItemsList();
DisplayToolMsg( wxEmptyString );
return 0;
}
wxPoint blockCenter; // Exit if no items found
if( !GetScreen()->m_BlockLocate.GetCount() )
// Move cursor to the best position in selected rect: cancelCmd = true;
// can be the block locate rect or the the smallest rectangle else
// containing the centers of all selected items. nextcmd = true;
// Unfortunately, this option gives unpredicatble results when flipping or mirroring blocks
#if 0 // set to 1 to use smallest rectangle center
// Move cursor to the center of
// Also set m_BlockLocate to the size of the rectangle.
PICKED_ITEMS_LIST* itemsList = &DrawPanel->GetScreen()->m_BlockLocate.m_ItemsSelection;
int minX, minY, maxX, maxY;
int tempX, tempY;
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( 0 );
minX = item->GetPosition().x;
minY = item->GetPosition().y;
maxX = minX;
maxY = minY;
for( unsigned ii = 1; ii < itemsList->GetCount(); ii++ )
{
item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
tempX = item->GetPosition().x;
tempY = item->GetPosition().y;
if( tempX > maxX )
maxX = tempX;
if( tempX < minX )
minX = tempX;
if( tempY > maxY )
maxY = tempY;
if( tempY < minY )
minY = tempY;
} }
blockCenter.x = ( minX + maxX ) / 2;
blockCenter.y = ( minY + maxY ) / 2;
GetScreen()->m_BlockLocate.SetOrigin( minX, minY );
GetScreen()->m_BlockLocate.SetEnd( maxX, maxY );
#else
blockCenter = GetScreen()->m_BlockLocate.Centre();
#endif
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = blockCenter;
GetScreen()->m_BlockLocate.SetLastCursorPosition( blockCenter );
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( DC );
} }
if( DrawPanel->ManageCurseur ) if( !cancelCmd && DrawPanel->ManageCurseur )
{
switch( GetScreen()->m_BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
...@@ -363,7 +315,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -363,7 +315,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
endcommande = false; nextcmd = true;
DrawPanel->ManageCurseur = drawMovingBlock; DrawPanel->ManageCurseur = drawMovingBlock;
DrawPanel->ManageCurseur( DrawPanel, DC, false ); DrawPanel->ManageCurseur( DrawPanel, DC, false );
break; break;
...@@ -408,8 +360,9 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -408,8 +360,9 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
default: default:
break; break;
} }
}
if( endcommande == true ) if( ! nextcmd )
{ {
GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
...@@ -420,7 +373,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -420,7 +373,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
} }
return endcommande; return nextcmd;
} }
...@@ -428,7 +381,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -428,7 +381,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
/** /**
* Function Block_SelectItems * Function Block_SelectItems
* Uses GetScreen()->m_BlockLocate * Uses GetScreen()->m_BlockLocate
* select items within the selected block. * select items within the selected block.
* selected items are put in the pick list * selected items are put in the pick list
* @param none * @param none
...@@ -442,13 +395,13 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -442,13 +395,13 @@ void WinEDA_PcbFrame::Block_SelectItems()
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection; PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
ITEM_PICKER picker( NULL, UR_UNSPECIFIED ); ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
if( Block_Include_Modules ) if( blockIncludeModules )
{ {
for( MODULE* module = m_Pcb->m_Modules; module != NULL; for( MODULE* module = m_Pcb->m_Modules; module != NULL;
module = module->Next() ) module = module->Next() )
{ {
if( module->HitTest( GetScreen()->m_BlockLocate ) if( module->HitTest( GetScreen()->m_BlockLocate )
&& ( !module->IsLocked() || BlockIncludeLockedModules ) ) && ( !module->IsLocked() || blockIncludeLockedModules ) )
{ {
picker.m_PickedItem = module; picker.m_PickedItem = module;
picker.m_PickedItemType = module->Type(); picker.m_PickedItemType = module->Type();
...@@ -458,7 +411,7 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -458,7 +411,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
} }
/* Remove tracks and vias */ /* Remove tracks and vias */
if( Block_Include_Tracks ) if( blockIncludeTracks )
{ {
for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL; for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL;
pt_segm = pt_segm->Next() ) pt_segm = pt_segm->Next() )
...@@ -475,10 +428,10 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -475,10 +428,10 @@ void WinEDA_PcbFrame::Block_SelectItems()
/* Select graphic items */ /* Select graphic items */
masque_layer = EDGE_LAYER; masque_layer = EDGE_LAYER;
if( Block_Include_Draw_Items ) if( blockIncludeItemsOnTechLayers )
masque_layer = ALL_LAYERS; masque_layer = ALL_LAYERS;
if( !Block_Include_Edges_Items ) if( !blockIncludeBoardOutlineLayer )
masque_layer &= ~EDGE_LAYER; masque_layer &= ~EDGE_LAYER;
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL;
...@@ -496,7 +449,7 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -496,7 +449,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
if( !Block_Include_PcbTextes ) if( !blockIncludePcbTexts )
break; break;
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) ) if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
...@@ -532,7 +485,7 @@ void WinEDA_PcbFrame::Block_SelectItems() ...@@ -532,7 +485,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
} }
/* Zone selection */ /* Zone selection */
if( Block_Include_Zones ) if( blockIncludeZones )
{ {
#if 0 #if 0
...@@ -581,64 +534,24 @@ static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -581,64 +534,24 @@ static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_MODULE: case TYPE_MODULE:
{
MODULE* module = (MODULE*) item;
frame->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK; frame->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
DrawModuleOutlines( aPanel, aDC, module ); DrawModuleOutlines( aPanel, aDC, (MODULE*) item );
break; break;
}
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
{
DRAWSEGMENT* segment = (DRAWSEGMENT*) item;
segment->Draw( aPanel, aDC, GR_XOR, aOffset );
break;
}
case TYPE_TEXTE: case TYPE_TEXTE:
{
TEXTE_PCB* text = (TEXTE_PCB*) item;
text->Draw( aPanel, aDC, GR_XOR, aOffset );
break;
}
case TYPE_TRACK: case TYPE_TRACK:
case TYPE_VIA: case TYPE_VIA:
{
TRACK* track = (TRACK*) item;
track->Draw( aPanel, aDC, GR_XOR, aOffset );
break;
}
case TYPE_MIRE: case TYPE_MIRE:
{ case TYPE_DIMENSION: // Currently markers are not affected by block commands
MIREPCB* mire = (MIREPCB*) item; case TYPE_MARKER_PCB:
mire->Draw( aPanel, aDC, GR_XOR, aOffset ); item->Draw( aPanel, aDC, GR_XOR, aOffset );
break;
}
case TYPE_DIMENSION:
{
DIMENSION* dimension = (DIMENSION*) item;
dimension->Draw( aPanel, aDC, GR_XOR, aOffset );
break; break;
}
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
{ item->Draw( aPanel, aDC, GR_XOR, aOffset );
ZONE_CONTAINER* zoneContainer = (ZONE_CONTAINER*) item; ((ZONE_CONTAINER*) item)->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
zoneContainer->Draw( aPanel, aDC, GR_XOR, aOffset );
zoneContainer->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
break; break;
}
// Currently markers are not affected by block commands
case TYPE_MARKER_PCB:
{
MARKER_PCB* pcbMarker = (MARKER_PCB*) item;
pcbMarker->Draw( aPanel, aDC, GR_XOR, aOffset );
break;
}
default: default:
break; break;
...@@ -661,7 +574,7 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -661,7 +574,7 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
{ {
screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector, screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector,
GR_XOR, BLOCK_OUTLINE_COLOR ); GR_XOR, BLOCK_OUTLINE_COLOR );
if( BlockDrawItems ) if( blockDrawItems )
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector ); drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector );
} }
} }
...@@ -677,7 +590,7 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -677,7 +590,7 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
{ {
screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector, screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector,
GR_XOR, BLOCK_OUTLINE_COLOR ); GR_XOR, BLOCK_OUTLINE_COLOR );
if( BlockDrawItems ) if( blockDrawItems )
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector ); drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector );
} }
} }
...@@ -812,7 +725,7 @@ void WinEDA_PcbFrame::Block_Rotate() ...@@ -812,7 +725,7 @@ void WinEDA_PcbFrame::Block_Rotate()
/** /**
* Function Block_Flip * Function Block_Flip
* Flip items within the selected block. * flips items within the selected block.
* The flip center is the center of the block * The flip center is the center of the block
* @param none * @param none
*/ */
...@@ -840,7 +753,7 @@ void WinEDA_PcbFrame::Block_Flip() ...@@ -840,7 +753,7 @@ void WinEDA_PcbFrame::Block_Flip()
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_MODULE: case TYPE_MODULE:
( (MODULE*) item )->m_Flags = 0; item->m_Flags = 0;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
break; break;
...@@ -902,7 +815,7 @@ void WinEDA_PcbFrame::Block_Move() ...@@ -902,7 +815,7 @@ void WinEDA_PcbFrame::Block_Move()
{ {
case TYPE_MODULE: case TYPE_MODULE:
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
( (MODULE*) item )->m_Flags = 0; item->m_Flags = 0;
break; break;
/* Move track segments */ /* Move track segments */
...@@ -939,7 +852,7 @@ void WinEDA_PcbFrame::Block_Move() ...@@ -939,7 +852,7 @@ void WinEDA_PcbFrame::Block_Move()
/** /**
* Function Block_Duplicate * Function Block_Duplicate
* Duplicate all items within the selected block. * duplicates all items within the selected block.
* New location is determined by the current offset from the selected block's * New location is determined by the current offset from the selected block's
* original location. * original location.
* @param none * @param none
...@@ -965,51 +878,51 @@ void WinEDA_PcbFrame::Block_Duplicate() ...@@ -965,51 +878,51 @@ void WinEDA_PcbFrame::Block_Duplicate()
switch( item->Type() ) switch( item->Type() )
{ {
case TYPE_MODULE: case TYPE_MODULE:
{ {
MODULE* module = (MODULE*) item; MODULE* module = (MODULE*) item;
MODULE* new_module; MODULE* new_module;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0; module->m_Flags = 0;
newitem = new_module = new MODULE( m_Pcb ); newitem = new_module = new MODULE( m_Pcb );
new_module->Copy( module ); new_module->Copy( module );
new_module->m_TimeStamp = GetTimeStamp(); new_module->m_TimeStamp = GetTimeStamp();
m_Pcb->m_Modules.PushFront( new_module ); m_Pcb->m_Modules.PushFront( new_module );
} }
break; break;
case TYPE_TRACK: case TYPE_TRACK:
case TYPE_VIA: case TYPE_VIA:
{ {
TRACK* track = (TRACK*) item; TRACK* track = (TRACK*) item;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
TRACK* new_track = track->Copy(); TRACK* new_track = track->Copy();
newitem = new_track; newitem = new_track;
m_Pcb->m_Track.PushFront( new_track ); m_Pcb->m_Track.PushFront( new_track );
} }
break; break;
case TYPE_ZONE: // SEG_ZONE items are now deprecated case TYPE_ZONE: // SEG_ZONE items are now deprecated
break; break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
{ {
ZONE_CONTAINER* new_zone = ZONE_CONTAINER* new_zone =
new ZONE_CONTAINER( (BOARD*) item->GetParent() ); new ZONE_CONTAINER( (BOARD*) item->GetParent() );
new_zone->Copy( (ZONE_CONTAINER*) item ); new_zone->Copy( (ZONE_CONTAINER*) item );
new_zone->m_TimeStamp = GetTimeStamp(); new_zone->m_TimeStamp = GetTimeStamp();
newitem = new_zone; newitem = new_zone;
m_Pcb->Add( new_zone ); m_Pcb->Add( new_zone );
} }
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
{ {
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb ); DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb );
new_drawsegment->Copy( (DRAWSEGMENT*) item ); new_drawsegment->Copy( (DRAWSEGMENT*) item );
m_Pcb->Add( new_drawsegment ); m_Pcb->Add( new_drawsegment );
newitem = new_drawsegment; newitem = new_drawsegment;
} }
break; break;
case TYPE_TEXTE: case TYPE_TEXTE:
{ {
...@@ -1021,22 +934,22 @@ void WinEDA_PcbFrame::Block_Duplicate() ...@@ -1021,22 +934,22 @@ void WinEDA_PcbFrame::Block_Duplicate()
break; break;
case TYPE_MIRE: case TYPE_MIRE:
{ {
MIREPCB* new_mire = new MIREPCB( m_Pcb ); MIREPCB* new_mire = new MIREPCB( m_Pcb );
new_mire->Copy( (MIREPCB*) item ); new_mire->Copy( (MIREPCB*) item );
m_Pcb->Add( new_mire ); m_Pcb->Add( new_mire );
newitem = new_mire; newitem = new_mire;
} }
break; break;
case TYPE_DIMENSION: case TYPE_DIMENSION:
{ {
DIMENSION* new_cotation = new DIMENSION( m_Pcb ); DIMENSION* new_cotation = new DIMENSION( m_Pcb );
new_cotation->Copy( (DIMENSION*) item ); new_cotation->Copy( (DIMENSION*) item );
m_Pcb->Add( new_cotation ); m_Pcb->Add( new_cotation );
newitem = new_cotation; newitem = new_cotation;
} }
break; break;
default: default:
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Duplicate( ) error: unexpected type" ) ); wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Duplicate( ) error: unexpected type" ) );
...@@ -1044,12 +957,12 @@ void WinEDA_PcbFrame::Block_Duplicate() ...@@ -1044,12 +957,12 @@ void WinEDA_PcbFrame::Block_Duplicate()
} }
if( newitem ) if( newitem )
{ {
newitem->Move( MoveVector ); newitem->Move( MoveVector );
picker.m_PickedItem = newitem; picker.m_PickedItem = newitem;
picker.m_PickedItemType = newitem->Type(); picker.m_PickedItemType = newitem->Type();
newList.PushItem( picker ); newList.PushItem( picker );
} }
} }
if( newList.GetCount() ) if( newList.GetCount() )
......
...@@ -86,16 +86,21 @@ int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key ) ...@@ -86,16 +86,21 @@ int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
} }
/* Command BLOCK END (end of block sizing) /**
* return : * Function HandleBlockEnd( )
* 0 if command finished (zoom, delete ...) * Handle the "end" of a block command,
* 1 if HandleBlockPlace must follow (items found, and a block place command * i.e. is called at the end of the definition of the area of a block.
* must follow) * depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/ */
int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
{ {
int ItemsCount = 0, MustDoPlace = 0; int itemsCount = 0;
MODULE* Currentmodule = GetBoard()->m_Modules; bool nextcmd = false;
MODULE* currentModule = GetBoard()->m_Modules;
if( GetScreen()->m_BlockLocate.GetCount() ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
...@@ -120,11 +125,11 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -120,11 +125,11 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
ItemsCount = MarkItemsInBloc( Currentmodule, itemsCount = MarkItemsInBloc( currentModule,
GetScreen()->m_BlockLocate ); GetScreen()->m_BlockLocate );
if( ItemsCount ) if( itemsCount )
{ {
MustDoPlace = 1; nextcmd = true;
if( DrawPanel->ManageCurseur != NULL ) if( DrawPanel->ManageCurseur != NULL )
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -137,16 +142,16 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -137,16 +142,16 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
MustDoPlace = 1; nextcmd = true;
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate ); itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( itemsCount )
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
DeleteMarkedItems( Currentmodule ); DeleteMarkedItems( currentModule );
break; break;
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: /* Save */
...@@ -154,20 +159,20 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -154,20 +159,20 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate ); itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( itemsCount )
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
case BLOCK_FLIP: /* mirror */ case BLOCK_FLIP: /* mirror */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate ); itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( itemsCount )
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
...@@ -181,11 +186,11 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -181,11 +186,11 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
break; break;
} }
if( MustDoPlace <= 0 ) if( !nextcmd )
{ {
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
{ {
ClearMarkItems( Currentmodule ); ClearMarkItems( currentModule );
} }
GetScreen()->m_BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
...@@ -199,7 +204,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -199,7 +204,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
} }
return MustDoPlace; return nextcmd;
} }
...@@ -214,7 +219,7 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -214,7 +219,7 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
*/ */
{ {
bool err = FALSE; bool err = FALSE;
MODULE* Currentmodule = GetBoard()->m_Modules; MODULE* currentModule = GetBoard()->m_Modules;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
...@@ -234,15 +239,15 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -234,15 +239,15 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
MoveMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector ); MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.m_MoveVector );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
CopyMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector ); CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.m_MoveVector );
break; break;
case BLOCK_PASTE: /* Paste */ case BLOCK_PASTE: /* Paste */
...@@ -252,13 +257,13 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -252,13 +257,13 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
case BLOCK_FLIP: /* Mirror by popup menu, from block move */ case BLOCK_FLIP: /* Mirror by popup menu, from block move */
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
SaveCopyInUndoList( Currentmodule, UR_MODEDIT ); SaveCopyInUndoList( currentModule, UR_MODEDIT );
RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() ); RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd
...@@ -295,7 +300,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -295,7 +300,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
BOARD_ITEM* item; BOARD_ITEM* item;
wxPoint move_offset; wxPoint move_offset;
MODULE* Currentmodule = MODULE* currentModule =
( (WinEDA_BasePcbFrame*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->GetBoard()->m_Modules; ( (WinEDA_BasePcbFrame*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->GetBoard()->m_Modules;
PtBlock = &screen->m_BlockLocate; PtBlock = &screen->m_BlockLocate;
...@@ -306,11 +311,11 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -306,11 +311,11 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode,
PtBlock->m_Color ); PtBlock->m_Color );
if( Currentmodule ) if( currentModule )
{ {
move_offset.x = -PtBlock->m_MoveVector.x; move_offset.x = -PtBlock->m_MoveVector.x;
move_offset.y = -PtBlock->m_MoveVector.y; move_offset.y = -PtBlock->m_MoveVector.y;
item = Currentmodule->m_Drawings; item = currentModule->m_Drawings;
for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() )
{ {
if( item->m_Selected == 0 ) if( item->m_Selected == 0 )
...@@ -328,7 +333,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -328,7 +333,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
} }
} }
D_PAD* pad = Currentmodule->m_Pads; D_PAD* pad = currentModule->m_Pads;
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
{ {
if( pad->m_Selected == 0 ) if( pad->m_Selected == 0 )
...@@ -346,9 +351,9 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -346,9 +351,9 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
PtBlock->m_Color ); PtBlock->m_Color );
if( Currentmodule ) if( currentModule )
{ {
item = Currentmodule->m_Drawings; item = currentModule->m_Drawings;
move_offset = - PtBlock->m_MoveVector; move_offset = - PtBlock->m_MoveVector;
for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() )
{ {
...@@ -367,7 +372,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -367,7 +372,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
} }
} }
D_PAD* pad = Currentmodule->m_Pads; D_PAD* pad = currentModule->m_Pads;
for( ; pad != NULL; pad = pad->Next() ) for( ; pad != NULL; pad = pad->Next() )
{ {
if( pad->m_Selected == 0 ) if( pad->m_Selected == 0 )
......
...@@ -93,9 +93,9 @@ public: ...@@ -93,9 +93,9 @@ public:
bool Clear_Pcb( bool aQuery ); bool Clear_Pcb( bool aQuery );
/* handlers for block commands */ /* handlers for block commands */
int ReturnBlockCommand( int key ); virtual int ReturnBlockCommand( int key );
virtual void HandleBlockPlace( wxDC* DC ); virtual void HandleBlockPlace( wxDC* DC );
virtual int HandleBlockEnd( wxDC* DC ); virtual bool HandleBlockEnd( wxDC* DC );
BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 ); BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment