Commit a6fc1329 authored by charras's avatar charras

More about undo/redo in pcbnew

parent 5c3f35c2
...@@ -265,7 +265,8 @@ wxString ReturnUnitSymbol( int Units ) ...@@ -265,7 +265,8 @@ wxString ReturnUnitSymbol( int Units )
void AddUnitSymbol( wxStaticText& Stext, int Units ) void AddUnitSymbol( wxStaticText& Stext, int Units )
/**************************************************/ /**************************************************/
{ {
wxString msg = Stext.GetLabel() + ReturnUnitSymbol( Units ); wxString msg = Stext.GetLabel();
msg += ReturnUnitSymbol( Units );
Stext.SetLabel( msg ); Stext.SetLabel( msg );
} }
......
...@@ -271,7 +271,6 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, ...@@ -271,7 +271,6 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand, UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint ) const wxPoint& aTransformPoint )
{ {
SCH_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
// Copy picker list: // Copy picker list:
...@@ -342,7 +341,9 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bo ...@@ -342,7 +341,9 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bo
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* alt_item; SCH_ITEM* alt_item;
for( unsigned ii = 0; ii < aList->GetCount(); ii++ ) // Undo in the reverse order of list creation: (this can allow stacked changes
// like the same item can be changes and deleted in the same complex command
for( int ii = aList->GetCount()-1; ii >= 0 ; ii-- )
{ {
ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii ); ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii );
item = (SCH_ITEM*) itemWrapper.m_PickedItem; item = (SCH_ITEM*) itemWrapper.m_PickedItem;
...@@ -420,12 +421,16 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event) ...@@ -420,12 +421,16 @@ void WinEDA_SchematicFrame::GetSchematicFromUndoList(wxCommandEvent& event)
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
/* Get the old wrapper and put it in RedoList */ /* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
GetScreen()->PushCommandToRedoList( List );
/* Undo the command */ /* Undo the command */
PutDataInPreviousState( List, false ); PutDataInPreviousState( List, false );
/* Put the old list in RedoList */
List->ReversePickersListOrder();
GetScreen()->PushCommandToRedoList( List );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
...@@ -451,13 +456,16 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event) ...@@ -451,13 +456,16 @@ void WinEDA_SchematicFrame::GetSchematicFromRedoList(wxCommandEvent& event)
return; return;
/* Get the old wrapper and put it in UndoList */ /* Get the old list */
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList(); PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromRedoList();
GetScreen()->PushCommandToUndoList( List );
/* Redo the command: */ /* Redo the command: */
PutDataInPreviousState( List, true ); PutDataInPreviousState( List, true );
/* Put the old list in UndoList */
List->ReversePickersListOrder();
GetScreen()->PushCommandToUndoList( List );
CurrentDrawItem = NULL; CurrentDrawItem = NULL;
GetScreen()->SetModify(); GetScreen()->SetModify();
SetSheetNumberAndCount(); SetSheetNumberAndCount();
......
...@@ -36,7 +36,7 @@ enum KICAD_T { ...@@ -36,7 +36,7 @@ enum KICAD_T {
TYPE_TRACK, // a track segment (segment on a copper layer) TYPE_TRACK, // a track segment (segment on a copper layer)
TYPE_VIA, // a via (like atrack segment on a copper layer) TYPE_VIA, // a via (like atrack segment on a copper layer)
TYPE_ZONE, // a segment used to fill a zome area (segment on a copper layer) TYPE_ZONE, // a segment used to fill a zome area (segment on a copper layer)
TYPE_MARKER_PCB, // a marker used to show something TYPE_MARKER_PCB, // a marker used to show something
TYPE_COTATION, // a dimension (graphic item) TYPE_COTATION, // a dimension (graphic item)
TYPE_MIRE, // a target (graphic item) TYPE_MIRE, // a target (graphic item)
TYPE_ZONE_EDGE_CORNER, // in zone outline: a point to define an outline TYPE_ZONE_EDGE_CORNER, // in zone outline: a point to define an outline
......
...@@ -173,7 +173,6 @@ public: ...@@ -173,7 +173,6 @@ public:
int DrawMode, int color, int type ); int DrawMode, int color, int type );
// Gestion des modules // Gestion des modules
void InstallModuleOptionsFrame( MODULE* Module, wxDC * DC );
MODULE* Copie_Module( MODULE* module ); MODULE* Copie_Module( MODULE* module );
/** Function Save_Module_In_Library /** Function Save_Module_In_Library
...@@ -202,9 +201,6 @@ public: ...@@ -202,9 +201,6 @@ public:
bool incremental ); bool incremental );
void Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest = false ); void Place_Module( MODULE* module, wxDC* DC, bool aDoNotRecreateRatsnest = false );
// Graphic items edition:
void InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem, wxDC* aDC );
// module texts // module texts
void RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ); void RotateTextModule( TEXTE_MODULE* Text, wxDC* DC );
void DeleteTextModule( TEXTE_MODULE* Text ); void DeleteTextModule( TEXTE_MODULE* Text );
...@@ -213,8 +209,7 @@ public: ...@@ -213,8 +209,7 @@ public:
TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC ); TEXTE_MODULE* CreateTextModule( MODULE* Module, wxDC* DC );
void InstallPadOptionsFrame( D_PAD* pad, wxDC* DC, const wxPoint& pos ); void InstallPadOptionsFrame( D_PAD* pad, wxDC* DC, const wxPoint& pos );
void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, void InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC );
wxDC* DC, const wxPoint& pos );
// Pads sur modules // Pads sur modules
void AddPad( MODULE* Module, bool draw ); void AddPad( MODULE* Module, bool draw );
......
...@@ -333,11 +333,13 @@ public: ...@@ -333,11 +333,13 @@ public:
// Graphic Segments type DRAWSEGMENT // Graphic Segments type DRAWSEGMENT
void Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ); void Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );
void Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ); void Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );
void InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem, wxDC* aDC ); // Graphic items edition
// Footprint edition (see also WinEDA_BasePcbFrame) // Footprint edition (see also WinEDA_BasePcbFrame)
void InstallModuleOptionsFrame( MODULE* Module, wxDC * DC );
void StartMove_Module( MODULE* module, wxDC* DC ); void StartMove_Module( MODULE* module, wxDC* DC );
bool Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDeleting ); bool Delete_Module( MODULE* module, wxDC* DC, bool aAskBeforeDeleting );
void Change_Side_Module( MODULE* Module, wxDC* DC ); void Change_Side_Module( MODULE* Module, wxDC* DC );
void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule ); void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
/** function Exchange_Module /** function Exchange_Module
...@@ -578,7 +580,7 @@ public: ...@@ -578,7 +580,7 @@ public:
DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, wxDC* DC ); DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, wxDC* DC );
void End_Edge( DRAWSEGMENT* Segment, wxDC* DC ); void End_Edge( DRAWSEGMENT* Segment, wxDC* DC );
void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ); void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );
void Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ); void Delete_Drawings_All_Layer( int aLayer );
// Dimension handling: // Dimension handling:
void Install_Edit_Cotation( COTATION* Cotation, wxDC* DC, const wxPoint& pos ); void Install_Edit_Cotation( COTATION* Cotation, wxDC* DC, const wxPoint& pos );
......
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -39,9 +39,12 @@ set(PCBNEW_SRCS ...@@ -39,9 +39,12 @@ set(PCBNEW_SRCS
dialog_display_options_base.cpp dialog_display_options_base.cpp
dialog_drc_base.cpp dialog_drc_base.cpp
dialog_drc.cpp dialog_drc.cpp
dialog_edit_module_for_BoardEditor.cpp
dialog_edit_module_for_BoardEditor_base.cpp
dialog_edit_module_for_modedit_base.cpp
dialog_edit_module_for_modedit.cpp
dialog_edit_module_text.cpp dialog_edit_module_text.cpp
dialog_edit_module_text_base.cpp dialog_edit_module_text_base.cpp
dialog_edit_module.cpp
dialog_exchange_modules_base.cpp dialog_exchange_modules_base.cpp
dialog_freeroute_exchange.cpp dialog_freeroute_exchange.cpp
# dialog_gendrill.cpp # dialog_gendrill.cpp
......
...@@ -156,10 +156,10 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage ) ...@@ -156,10 +156,10 @@ void SwapData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
EXCHG( ( (TRACK*) aItem )->m_Start, ( (TRACK*) aImage )->m_Start ); EXCHG( ( (DRAWSEGMENT*) aItem )->m_Start, ( (DRAWSEGMENT*) aImage )->m_Start );
EXCHG( ( (TRACK*) aItem )->m_End, ( (TRACK*) aImage )->m_End ); EXCHG( ( (DRAWSEGMENT*) aItem )->m_End, ( (DRAWSEGMENT*) aImage )->m_End );
EXCHG( ( (TRACK*) aItem )->m_Width, ( (TRACK*) aImage )->m_Width ); EXCHG( ( (DRAWSEGMENT*) aItem )->m_Width, ( (DRAWSEGMENT*) aImage )->m_Width );
EXCHG( ( (TRACK*) aItem )->m_Shape, ( (TRACK*) aImage )->m_Shape ); EXCHG( ( (DRAWSEGMENT*) aItem )->m_Shape, ( (DRAWSEGMENT*) aImage )->m_Shape );
break; break;
case TYPE_TRACK: case TYPE_TRACK:
...@@ -581,8 +581,8 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event ) ...@@ -581,8 +581,8 @@ void WinEDA_PcbFrame::GetBoardFromUndoList( wxCommandEvent& event )
/* Undo the command */ /* Undo the command */
PutDataInPreviousState( List, false ); PutDataInPreviousState( List, false );
/* Pu the old list in RedoList */ /* Put the old list in RedoList */
List->ReversePickersListOrder(); List->ReversePickersListOrder();
GetScreen()->PushCommandToRedoList( List ); GetScreen()->PushCommandToRedoList( List );
GetScreen()->SetModify(); GetScreen()->SetModify();
......
...@@ -239,8 +239,7 @@ void TEXTE_MODULE:: SetDrawCoord() ...@@ -239,8 +239,7 @@ void TEXTE_MODULE:: SetDrawCoord()
NORMALIZE_ANGLE_POS( angle ); NORMALIZE_ANGLE_POS( angle );
RotatePoint( &m_Pos.x, &m_Pos.y, angle ); RotatePoint( &m_Pos.x, &m_Pos.y, angle );
m_Pos.x += Module->m_Pos.x; m_Pos += Module->m_Pos;
m_Pos.y += Module->m_Pos.y;
} }
...@@ -250,10 +249,12 @@ void TEXTE_MODULE:: SetLocalCoord() ...@@ -250,10 +249,12 @@ void TEXTE_MODULE:: SetLocalCoord()
MODULE* Module = (MODULE*) m_Parent; MODULE* Module = (MODULE*) m_Parent;
if( Module == NULL ) if( Module == NULL )
{
m_Pos0 = m_Pos;
return; return;
}
m_Pos0.x = m_Pos.x - Module->m_Pos.x; m_Pos0 = m_Pos - Module->m_Pos;
m_Pos0.y = m_Pos.y - Module->m_Pos.y;
int angle = Module->m_Orient; int angle = Module->m_Orient;
NORMALIZE_ANGLE_POS( angle ); NORMALIZE_ANGLE_POS( angle );
...@@ -447,18 +448,12 @@ int TEXTE_MODULE::GetDrawRotation() ...@@ -447,18 +448,12 @@ int TEXTE_MODULE::GetDrawRotation()
// see class_text_mod.h // see class_text_mod.h
void TEXTE_MODULE::DisplayInfo( WinEDA_DrawFrame* frame ) void TEXTE_MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
{ {
wxString msg, Line;
int ii;
MODULE* module = (MODULE*) m_Parent; MODULE* module = (MODULE*) m_Parent;
if( module == NULL ) // Happens in modedit, and for new texts
wxASSERT( module );
if( !module )
return; return;
BOARD* board = (BOARD*) module->GetParent(); wxString msg, Line;
wxASSERT( board ); int ii;
static const wxString text_type_msg[3] = { static const wxString text_type_msg[3] = {
_( "Ref." ), _( "Value" ), _( "Text" ) _( "Ref." ), _( "Value" ), _( "Text" )
...@@ -484,11 +479,13 @@ void TEXTE_MODULE::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -484,11 +479,13 @@ void TEXTE_MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
msg = _( "Yes" ); msg = _( "Yes" );
Affiche_1_Parametre( frame, 25, _( "Display" ), msg, DARKGREEN ); Affiche_1_Parametre( frame, 25, _( "Display" ), msg, DARKGREEN );
ii = m_Layer; // Display text layer (use layer name if possible)
if( ii < NB_LAYERS ) BOARD* board = NULL;
msg = board->GetLayerName( ii ); board = (BOARD*) module->GetParent();
if( m_Layer < NB_LAYERS && board )
msg = board->GetLayerName( m_Layer );
else else
msg.Printf( wxT( "%d" ), ii ); msg.Printf( wxT( "%d" ), m_Layer );
Affiche_1_Parametre( frame, 31, _( "Layer" ), msg, DARKGREEN ); Affiche_1_Parametre( frame, 31, _( "Layer" ), msg, DARKGREEN );
msg = _( " No" ); msg = _( " No" );
......
/************************************************/
/* Module editor: Dialog box for editing module */
/* properties and carateristics */
/* include in modedit.cpp */
/************************************************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "bitmaps.h"
#include "appl_wxstruct.h"
#include "gestfich.h"
#include "3d_struct.h"
#include "3d_viewer.h"
#include "wxPcbStruct.h"
#include "dialog_edit_module.h"
extern bool GoToEditor;
/**************************************/
/* class WinEDA_ModulePropertiesFrame */
/**************************************/
BEGIN_EVENT_TABLE( WinEDA_ModulePropertiesFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_ModulePropertiesFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_ModulePropertiesFrame::OnCancelClick )
EVT_BUTTON( ID_MODULE_EDIT_ADD_TEXT, WinEDA_ModulePropertiesFrame::CreateTextModule )
EVT_BUTTON( ID_MODULE_EDIT_EDIT_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule )
EVT_BUTTON( ID_MODULE_EDIT_DELETE_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule )
EVT_BUTTON( ID_MODULE_PROPERTIES_EXCHANGE, WinEDA_ModulePropertiesFrame::ExchangeModule )
EVT_KICAD_CHOICEBOX( ID_MODULE_LISTBOX_SELECT, WinEDA_ModulePropertiesFrame::SelectTextListBox )
EVT_RADIOBOX( ID_LISTBOX_ORIENT_SELECT, WinEDA_ModulePropertiesFrame::ModuleOrientEvent )
EVT_BUTTON( ID_GOTO_MODULE_EDITOR, WinEDA_ModulePropertiesFrame::GotoModuleEditor )
END_EVENT_TABLE()
/**********************/
/* class Panel3D_Ctrl */
/**********************/
BEGIN_EVENT_TABLE( Panel3D_Ctrl, wxPanel )
EVT_BUTTON( ID_BROWSE_3D_LIB, Panel3D_Ctrl::Browse3DLib )
EVT_BUTTON( ID_ADD_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape )
EVT_BUTTON( ID_REMOVE_3D_SHAPE, Panel3D_Ctrl::AddOrRemove3DShape )
END_EVENT_TABLE()
/**************************************************************************************/
WinEDA_ModulePropertiesFrame::WinEDA_ModulePropertiesFrame( WinEDA_BasePcbFrame* parent,
MODULE* Module, wxDC* DC ) :
wxDialog( parent, -1, _( "Module properties" ), wxDefaultPosition, wxDefaultSize, DIALOG_STYLE )
/**************************************************************************************/
{
wxString number;
SetIcon( wxICON( icon_modedit ) ); // Give an icon
m_Parent = parent;
m_DC = DC;
m_LayerCtrl = NULL;
m_OrientCtrl = NULL;
m_OrientValue = NULL;
m_Doc = m_Keyword = NULL;
m_CurrentModule = Module;
m_DeleteFieddButton = NULL;
if( m_CurrentModule )
{
}
CreateControls();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
}
/*****************************************************/
void WinEDA_ModulePropertiesFrame::CreateControls()
/*****************************************************/
{
wxPoint pos;
wxButton* Button;
bool FullOptions = FALSE;
if( m_Parent->m_Ident == PCB_FRAME )
FullOptions = TRUE;
m_GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( m_GeneralBoxSizer );
m_NoteBook = new wxNotebook( this, ID_NOTEBOOK );
m_GeneralBoxSizer->Add( m_NoteBook, 0, wxGROW | wxALL, 5 );
// Add panels
m_PanelProperties = new wxPanel( m_NoteBook, -1 );
m_PanelPropertiesBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_PanelProperties->SetSizer( m_PanelPropertiesBoxSizer );
BuildPanelModuleProperties( FullOptions );
m_NoteBook->AddPage( m_PanelProperties, _( "Properties" ), TRUE );
m_Panel3D = new Panel3D_Ctrl( this, m_NoteBook, -1,
m_CurrentModule->m_3D_Drawings );
m_NoteBook->AddPage( m_Panel3D, _( "3D settings" ), FALSE );
/* creation des autres formes 3D */
Panel3D_Ctrl* panel3D = m_Panel3D, * nextpanel3D;
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
if( draw3D )
{
draw3D = (S3D_MASTER*) draw3D->Next();
for( ; draw3D != NULL; draw3D = (S3D_MASTER*) draw3D->Next() )
{
nextpanel3D = new Panel3D_Ctrl( this, m_NoteBook, -1, draw3D );
m_NoteBook->AddPage( nextpanel3D, _( "3D settings" ), FALSE );
panel3D->m_Pnext = nextpanel3D;
nextpanel3D->m_Pback = panel3D;
panel3D = nextpanel3D;
}
}
/* Creation des boutons de commande */
wxBoxSizer* ButtonsBoxSizer = new wxBoxSizer( wxHORIZONTAL );
m_GeneralBoxSizer->Add( ButtonsBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
Button = new wxButton( this, wxID_OK, _( "OK" ) );
ButtonsBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
ButtonsBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
}
/***********************************************************/
void Panel3D_Ctrl::AddOrRemove3DShape( wxCommandEvent& event )
/***********************************************************/
{
if( event.GetId() == ID_ADD_3D_SHAPE )
{
Panel3D_Ctrl* panel3D = new Panel3D_Ctrl( m_ParentFrame, m_Parent,
-1, NULL );
m_Parent->InsertPage( m_Parent->GetSelection() + 1,
panel3D, _( "3D settings" ), TRUE );
panel3D->m_Pback = this;
panel3D->m_Pnext = m_Pnext;
if( m_Pnext )
m_Pnext->m_Pback = panel3D;
m_Pnext = panel3D;
}
if( event.GetId() == ID_REMOVE_3D_SHAPE )
{
if( m_Pback )
{
m_Pback->m_Pnext = m_Pnext;
if( m_Pnext )
m_Pnext->m_Pback = m_Pback;
m_Parent->DeletePage( m_Parent->GetSelection() );
m_ParentFrame->Refresh( TRUE );
}
}
}
/***************************************************************************/
void WinEDA_ModulePropertiesFrame::BuildPanelModuleProperties( bool FullOptions )
/***************************************************************************/
/* creation du panel d'edition des proprietes du module
*/
{
wxButton* Button;
wxStaticText* StaticText;
wxBoxSizer* PropLeftSizer;
wxBoxSizer* PropRightSizer;
wxString msg;
m_ModPositionX = NULL;
m_ModPositionY = NULL;
/* Create a sizer for controls in the left column */
PropLeftSizer = new wxBoxSizer( wxVERTICAL );
m_PanelPropertiesBoxSizer->Add( PropLeftSizer, 0, wxGROW | wxALL, 5 );
/* Create a sizer for controls in the right column */
PropRightSizer = new wxBoxSizer( wxVERTICAL );
m_PanelPropertiesBoxSizer->Add( PropRightSizer, 0, wxGROW | wxALL, 5 );
if( FullOptions ) // Module is on a board
{
wxStaticText* XPositionStatic = new wxStaticText(m_PanelProperties, -1, _("X"));
wxStaticText* YPositionStatic = new wxStaticText(m_PanelProperties, -1, _("Y"));
Button = new wxButton( m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE,
_( "Change module(s)" ) );
PropRightSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( m_PanelProperties, ID_GOTO_MODULE_EDITOR,
_( "Edit Module" ) );
PropRightSizer->Add( Button, 0, wxGROW | wxALL, 5 );
wxStaticBox* positionBox = new wxStaticBox(m_PanelProperties, -1, _("Position") );
wxStaticBoxSizer* positionBoxSizer = new wxStaticBoxSizer( positionBox, wxVERTICAL );
PropRightSizer->Add(positionBoxSizer, 0, wxGROW | wxALL, 5 );
m_ModPositionX = new wxTextCtrl( m_PanelProperties, ID_MODULE_EDIT_X_POSITION, wxT(""),
wxDefaultPosition, wxDefaultSize, 0,
wxTextValidator(wxFILTER_NUMERIC, NULL), wxTextCtrlNameStr);
PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x, PCB_INTERNAL_UNIT );
AddUnitSymbol( *XPositionStatic, g_UnitMetric );
positionBoxSizer->Add( XPositionStatic, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
positionBoxSizer->Add( m_ModPositionX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_ModPositionY = new wxTextCtrl( m_PanelProperties, ID_MODULE_EDIT_Y_POSITION,
wxT(""), wxDefaultPosition, wxDefaultSize, 0,
wxTextValidator(wxFILTER_NUMERIC, NULL), wxTextCtrlNameStr);
PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *YPositionStatic, g_UnitMetric );
positionBoxSizer->Add( YPositionStatic, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
positionBoxSizer->Add( m_ModPositionY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
else // Module is edited in libedit
{
StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _(
"Doc" ), wxDefaultPosition, wxDefaultSize, 0 );
PropLeftSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_Doc = new wxTextCtrl( m_PanelProperties, -1,
m_CurrentModule->m_Doc );
PropLeftSizer->Add( m_Doc, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
StaticText = new wxStaticText( m_PanelProperties, wxID_STATIC, _(
"Keywords" ), wxDefaultPosition, wxDefaultSize, 0 );
PropLeftSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_Keyword = new wxTextCtrl( m_PanelProperties, -1,
m_CurrentModule->m_KeyWord );
PropLeftSizer->Add( m_Keyword, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
wxStaticBox* box = new wxStaticBox( m_PanelProperties, -1, _( "Fields:" ) );
m_TextListBox = new WinEDAChoiceBox( m_PanelProperties, ID_MODULE_LISTBOX_SELECT );
ReCreateFieldListBox();
m_TextListBox->SetSelection( 0 );
wxStaticBoxSizer* StaticBoxSizer = new wxStaticBoxSizer( box, wxVERTICAL );
PropLeftSizer->Add( StaticBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
StaticBoxSizer->Add( m_TextListBox, 0, wxGROW | wxALL, 5 );
Button = new wxButton( m_PanelProperties, ID_MODULE_EDIT_ADD_TEXT,
_( "Add Field" ) );
StaticBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
Button = new wxButton( m_PanelProperties, ID_MODULE_EDIT_EDIT_TEXT,
_( "Edit Field" ) );
StaticBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
m_DeleteFieddButton = Button = new wxButton( m_PanelProperties, ID_MODULE_EDIT_DELETE_TEXT,
_( "Delete Field" ) );
m_DeleteFieddButton->Enable( FALSE ); // Enable pour fields autres que ref et valeur
StaticBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
if( FullOptions )
{
wxString layer_list[2] = { _( "Component" ), _( "Copper" ) };
m_LayerCtrl = new wxRadioBox( m_PanelProperties, -1, _( "Layer" ), wxDefaultPosition,
wxSize( -1, -1 ), 2, layer_list, 1 );
m_LayerCtrl->SetSelection( (m_CurrentModule->GetLayer() == COPPER_LAYER_N) ? 1 : 0 );
PropLeftSizer->Add( m_LayerCtrl, 0, wxGROW | wxALL, 5 );
bool select = FALSE;
wxString orient_list[5] = {
_( "Normal" ), wxT( "+ 90.0" ), wxT( "- 90.0" ), wxT( "180.0" ), _( "User" )
};
m_OrientCtrl = new wxRadioBox( m_PanelProperties, ID_LISTBOX_ORIENT_SELECT, _( "Orient" ),
wxDefaultPosition, wxSize( -1, -1 ), 5, orient_list, 1 );
PropLeftSizer->Add( m_OrientCtrl, 0, wxGROW | wxALL, 5 );
switch( m_CurrentModule->m_Orient )
{
case 0:
m_OrientCtrl->SetSelection( 0 );
break;
case 900:
case -2700:
m_OrientCtrl->SetSelection( 1 );
break;
case -900:
case 2700:
m_OrientCtrl->SetSelection( 2 );
break;
case -1800:
case 1800:
m_OrientCtrl->SetSelection( 3 );
break;
default:
m_OrientCtrl->SetSelection( 4 );
select = TRUE;
break;
}
StaticText = new wxStaticText( m_PanelProperties,
wxID_STATIC, _(
"Orientation (in 0.1 degrees)" ), wxDefaultPosition, wxDefaultSize,
0 );
PropLeftSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
msg << m_CurrentModule->m_Orient;
m_OrientValue = new wxTextCtrl( m_PanelProperties, -1, msg );
m_OrientValue->Enable( select );
PropLeftSizer->Add( m_OrientValue, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
/* Controls on right side of the dialog */
wxString attribut_list[3] = { _( "Normal" ), _( "Normal+Insert" ), _( "Virtual" ) };
m_AttributsCtrl = new wxRadioBox( m_PanelProperties, -1, _( "Attributes" ), wxDefaultPosition,
wxSize( -1, -1 ), 3, attribut_list, 1 );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) );
m_AttributsCtrl->SetItemToolTip( 1,
_("Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file"));
m_AttributsCtrl->SetItemToolTip( 2,
_("Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ));
#endif
PropRightSizer->Add( m_AttributsCtrl, 0, wxGROW | wxALL, 5 );
switch( m_CurrentModule->m_Attributs & 255 )
{
case 0:
m_AttributsCtrl->SetSelection( 0 );
break;
case MOD_CMS:
m_AttributsCtrl->SetSelection( 1 );
break;
case MOD_VIRTUAL:
m_AttributsCtrl->SetSelection( 2 );
break;
default:
m_AttributsCtrl->SetSelection( 0 );
break;
}
wxString properties_list[2] = { _( "Free" ), _( "Locked" ) };
m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, -1, _(
"Move and Auto Place" ), wxDefaultPosition,
wxSize( -1, -1 ), 2, properties_list, 1 );
m_AutoPlaceCtrl->SetSelection(
(m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );
#endif
PropRightSizer->Add( m_AutoPlaceCtrl, 0, wxGROW | wxALL, 5 );
StaticText = new wxStaticText( m_PanelProperties, -1, _( "Rotation 90 degree" ) );
PropRightSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_CostRot90Ctrl = new wxSlider( m_PanelProperties, -1,
m_CurrentModule->m_CntRot90, 0, 10, wxDefaultPosition,
wxSize( 100, -1 ),
wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS );
PropRightSizer->Add( m_CostRot90Ctrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
StaticText = new wxStaticText( m_PanelProperties, -1, _( "Rotation 180 degree" ) );
PropRightSizer->Add( StaticText, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_CostRot180Ctrl = new wxSlider( m_PanelProperties,
-1,
m_CurrentModule->m_CntRot180,
0,
10,
wxDefaultPosition,
wxSize( 100, -1 ),
wxSL_HORIZONTAL + wxSL_AUTOTICKS + wxSL_LABELS );
PropRightSizer->Add( m_CostRot180Ctrl, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
/**************************************************************/
Panel3D_Ctrl::Panel3D_Ctrl( WinEDA_ModulePropertiesFrame* parentframe,
wxNotebook* parent,
int id, S3D_MASTER* struct3D ) :
wxPanel( parent, id )
/**************************************************************/
/* create the dialog panel managing 3D shape infos
*/
{
wxButton* button;
S3D_Vertex dummy_vertex;
wxBoxSizer* PropLeftSizer;
wxBoxSizer* PropRightSizer;
m_Pnext = m_Pback = NULL;
m_Parent = parent;
m_ParentFrame = parentframe;
wxBoxSizer* Panel3DBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( Panel3DBoxSizer );
wxStaticText* StaticText = new wxStaticText( this, wxID_STATIC, _( "3D Shape Name" ),
wxDefaultPosition, wxDefaultSize, 0 );
Panel3DBoxSizer->Add( StaticText, 0, wxGROW | wxALL | wxADJUST_MINSIZE, 5 );
m_3D_ShapeName = new wxTextCtrl( this, -1, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 );
if( struct3D )
m_3D_ShapeName->SetValue( struct3D->m_Shape3DName );
Panel3DBoxSizer->Add( m_3D_ShapeName, 0, wxGROW | wxALL, 5 );
wxBoxSizer* LowerBoxSizer = new wxBoxSizer( wxHORIZONTAL );
Panel3DBoxSizer->Add( LowerBoxSizer, 0, wxGROW | wxALL, 5 );
/* Create a sizer for controls in the left column */
PropLeftSizer = new wxBoxSizer( wxVERTICAL );
LowerBoxSizer->Add( PropLeftSizer, 0, wxGROW | wxALL, 5 );
/* Create a sizer for controls in the right column */
PropRightSizer = new wxBoxSizer( wxVERTICAL );
LowerBoxSizer->Add( PropRightSizer, 0, wxGROW | wxALL, 5 );
button = new wxButton( this, ID_BROWSE_3D_LIB, _( "Browse" ) );
PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
button = new wxButton( this, ID_ADD_3D_SHAPE, _( "Add 3D Shape" ) );
PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
if( (struct3D == NULL) || (struct3D->Back() != NULL) )
{
button = new wxButton( this, ID_REMOVE_3D_SHAPE, _( "Remove 3D Shape" ) );
PropRightSizer->Add( button, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
}
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( this, _( "Shape Scale:" ), BoxSizer,
2, 1 );
if( struct3D )
m_3D_Scale->SetValue( struct3D->m_MatScale );
PropLeftSizer->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( this, _( "Shape Offset:" ), BoxSizer,
2, 1 );
if( struct3D )
m_3D_Offset->SetValue( struct3D->m_MatPosition );
else
m_3D_Offset->SetValue( dummy_vertex );
PropLeftSizer->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( this, _( "Shape Rotation:" ), BoxSizer,
2, 1 );
if( struct3D )
m_3D_Rotation->SetValue( struct3D->m_MatRotation );
else
m_3D_Rotation->SetValue( dummy_vertex );
PropLeftSizer->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
if( struct3D == NULL )
{
dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0;
m_3D_Scale->SetValue( dummy_vertex );
}
}
/********************************/
Panel3D_Ctrl::~Panel3D_Ctrl()
/********************************/
{
delete m_3D_ShapeName;
delete m_3D_Scale;
delete m_3D_Offset;
delete m_3D_Rotation;
}
/***************************************************/
void Panel3D_Ctrl::Browse3DLib( wxCommandEvent& event )
/***************************************************/
{
wxString fullfilename, shortfilename;
wxString fullpath;
wxString mask = wxT( "*" );
fullpath = wxGetApp().ReturnLastVisitedLibraryPath(LIB3D_PATH);
mask += g_Shapes3DExtBuffer;
#ifdef __WINDOWS__
fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_Shapes3DExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( fullfilename == wxEmptyString )
return;
wxFileName fn = fullfilename;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the file path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
*/
shortfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath(fullfilename);
m_3D_ShapeName->SetValue( shortfilename );
}
/**********************************************************************/
void WinEDA_ModulePropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
EndModal( -1 );
}
/******************************************************************************/
void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event )
/******************************************************************************/
{
bool change_layer = FALSE;
wxPoint modpos;
if( m_CurrentModule->m_Flags == 0 ) // this is a simple edition, we must create an undo entry
{
if( m_Parent->m_Ident == PCB_FRAME )
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED );
else
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_MODEDIT );
}
if( m_DC )
{
m_Parent->DrawPanel->CursorOff( m_DC );
m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
}
// Set Module Position, if the dialog is called from the board editor
// if the dialog is called from the footprint editor, do nothing because the footprint is always in position 0,0
if ( m_ModPositionX && m_ModPositionY )
{
modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX, PCB_INTERNAL_UNIT );
modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY, PCB_INTERNAL_UNIT );
m_CurrentModule->SetPosition(modpos);
}
if( m_OrientValue )
{
long orient = 0; wxString msg = m_OrientValue->GetValue();
msg.ToLong( &orient );
if( m_CurrentModule->m_Orient != orient )
m_Parent->Rotate_Module( m_DC, m_CurrentModule,
orient, FALSE );
}
if( m_LayerCtrl )
{
if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT
{
if( m_CurrentModule->GetLayer() == COPPER_LAYER_N )
change_layer = TRUE;
}
else if( m_CurrentModule->GetLayer() == CMP_N )
change_layer = TRUE;
}
if( change_layer )
{
((WinEDA_PcbFrame*)m_Parent)->Change_Side_Module( m_CurrentModule, m_DC );
}
if( m_AutoPlaceCtrl->GetSelection() == 1 )
m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED;
else
m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED;
switch( m_AttributsCtrl->GetSelection() )
{
case 0:
m_CurrentModule->m_Attributs = 0;
break;
case 1:
m_CurrentModule->m_Attributs = MOD_CMS;
break;
case 2:
m_CurrentModule->m_Attributs = MOD_VIRTUAL;
break;
}
m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue();
m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue();
if( m_Doc )
m_CurrentModule->m_Doc = m_Doc->GetValue();
if( m_Keyword )
m_CurrentModule->m_KeyWord = m_Keyword->GetValue();
/* Update 3D shape list */
Panel3D_Ctrl* panel3D = m_Panel3D;
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
for( ; panel3D != NULL; panel3D = panel3D->m_Pnext )
{
wxString name3D = panel3D->m_3D_ShapeName->GetValue();;
if( name3D.IsEmpty() )
continue;
if( draw3D == NULL )
{
draw3D = new S3D_MASTER( draw3D );
m_CurrentModule->m_3D_Drawings.Append( draw3D );
}
draw3D->m_Shape3DName = name3D;
draw3D->m_MatScale = panel3D->m_3D_Scale->GetValue();
draw3D->m_MatRotation = panel3D->m_3D_Rotation->GetValue();
draw3D->m_MatPosition = panel3D->m_3D_Offset->GetValue();
draw3D = (S3D_MASTER*) draw3D->Next();
}
// Remove old extra 3D shapes
S3D_MASTER* nextdraw3D;
for( ; draw3D != NULL; draw3D = nextdraw3D )
{
nextdraw3D = (S3D_MASTER*) draw3D->Next();
delete m_CurrentModule->m_3D_Drawings.Remove( draw3D );
}
// Fill shape list with one void entry, if no entry
if( m_CurrentModule->m_3D_Drawings == NULL )
m_CurrentModule->m_3D_Drawings.PushBack( new S3D_MASTER( m_CurrentModule ) );
m_CurrentModule->Set_Rectangle_Encadrement();
m_Parent->GetScreen()->SetModify();
EndModal( 1 );
if( m_DC )
{
m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
m_Parent->DrawPanel->CursorOn( m_DC );
}
}
/************************************************************************/
void WinEDA_ModulePropertiesFrame::GotoModuleEditor( wxCommandEvent& event )
/************************************************************************/
{
GoToEditor = TRUE;
if( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non null timestamp
{
m_CurrentModule->m_TimeStamp = GetTimeStamp();
m_Parent->GetScreen()->SetModify();
}
Close( TRUE );
}
/**********************************************************************/
void WinEDA_ModulePropertiesFrame::ExchangeModule( wxCommandEvent& event )
/**********************************************************************/
{
((WinEDA_PcbFrame*)m_Parent)->InstallExchangeModuleFrame( m_CurrentModule );
// Attention: si il y a eu echange, m_CurrentModule a t delete!
m_Parent->SetCurItem( NULL );
Close( TRUE );
}
/*************************************************************************/
void WinEDA_ModulePropertiesFrame::ModuleOrientEvent( wxCommandEvent& event )
/*************************************************************************/
{
switch( m_OrientCtrl->GetSelection() )
{
case 0:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "0" ) );
break;
case 1:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "900" ) );
break;
case 2:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "2700" ) );
break;
case 3:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "1800" ) );
break;
default:
m_OrientValue->Enable( FALSE );
m_OrientValue->Enable( TRUE );
break;
}
}
/*************************************************************************/
void WinEDA_ModulePropertiesFrame::SelectTextListBox( wxCommandEvent& event )
/*************************************************************************/
{
SetTextListButtons();
}
/*************************************************************************/
void WinEDA_ModulePropertiesFrame::SetTextListButtons()
/*************************************************************************/
{
int choice = m_TextListBox->GetChoice();
if( m_DeleteFieddButton == NULL )
return;
if( choice > 1 ) // Texte autre que ref ou valeur selectionne
{
m_DeleteFieddButton->Enable( TRUE );
}
else
m_DeleteFieddButton->Enable( FALSE );
}
/***********************************************************/
void WinEDA_ModulePropertiesFrame::ReCreateFieldListBox()
/***********************************************************/
{
m_TextListBox->Clear();
m_TextListBox->Append( m_CurrentModule->m_Reference->m_Text );
m_TextListBox->Append( m_CurrentModule->m_Value->m_Text );
EDA_BaseStruct* item = m_CurrentModule->m_Drawings;
while( item )
{
if( item->Type() == TYPE_TEXTE_MODULE )
m_TextListBox->Append( ( (TEXTE_MODULE*) item )->m_Text );
item = item->Next();
}
SetTextListButtons();
}
/************************************************************************/
void WinEDA_ModulePropertiesFrame::CreateTextModule( wxCommandEvent& event )
/************************************************************************/
/* Cree un nouveau texte sur le module actif
* Le texte sera mis en fonction Move
*/
{
TEXTE_MODULE* Text;
/* Creation de la place en memoire : */
Text = m_Parent->CreateTextModule( m_CurrentModule, m_DC );
ReCreateFieldListBox();
m_TextListBox->SetSelection( 2 );
SetTextListButtons();
}
/****************************************************************************/
void WinEDA_ModulePropertiesFrame::EditOrDelTextModule( wxCommandEvent& event )
/****************************************************************************/
{
int TextType = m_TextListBox->GetChoice();
TEXTE_MODULE* Text = NULL;
if( TextType < 0 )
return; //No selection
if( m_DC )
m_Parent->DrawPanel->CursorOff( m_DC );
// Get a pointer on the field
if( TextType == 0 )
Text = m_CurrentModule->m_Reference;
else if( TextType == 1 )
Text = m_CurrentModule->m_Value;
else // Search the field 2 or more, because field 0 and 1 are ref and value
{
EDA_BaseStruct* item = m_CurrentModule->m_Drawings;
int jj = 2;
while( item )
{
if( item->Type() == TYPE_TEXTE_MODULE )
{
if( jj == TextType ) // Texte trouv
{
Text = (TEXTE_MODULE*) item;
break;
}
}
item = item->Next(); jj++;
}
}
if( Text )
{
if( event.GetId() == ID_MODULE_EDIT_DELETE_TEXT )
{
if( TextType < 2 ) // Ref or Value cannot be deleted
{
DisplayError( this, _( "Reference or Value cannot be deleted" ) );
goto out;
}
wxString Line;
Line.Printf( _( "Delete [%s]" ), Text->m_Text.GetData() );
if( !IsOK( this, Line ) )
goto out;
m_Parent->DeleteTextModule( Text );
ReCreateFieldListBox();
m_TextListBox->SetSelection( 0 );
}
else // Edition du champ
{
m_Parent->InstallTextModOptionsFrame( Text, m_DC, wxPoint( -1, -1 ) );
ReCreateFieldListBox();
m_TextListBox->SetSelection( TextType );
}
}
else
DisplayError( this,
wxT(
"WinEDA_ModulePropertiesFrame::EditOrDelTextModule() error: Field not found" )
);
out:
if( m_DC )
m_Parent->DrawPanel->CursorOn( m_DC );
SetTextListButtons();
}
/************************************************/
/* Module editor: Dialog box for editing module */
/* properties and carateristics */
/************************************************/
enum id_Module_properties
{
ID_GOTO_MODULE_EDITOR =1900,
ID_MODULE_PROPERTIES_EXCHANGE,
ID_MODULE_EDIT_ADD_TEXT,
ID_MODULE_EDIT_EDIT_TEXT,
ID_MODULE_EDIT_DELETE_TEXT,
ID_MODULE_LISTBOX_SELECT,
ID_LISTBOX_ORIENT_SELECT,
ID_BROWSE_3D_LIB,
ID_ADD_3D_SHAPE,
ID_REMOVE_3D_SHAPE,
ID_NOTEBOOK,
ID_MODULE_EDIT_X_POSITION,
ID_MODULE_EDIT_Y_POSITION
};
class Panel3D_Ctrl;
/**************************************/
/* class WinEDA_ModulePropertiesFrame */
/**************************************/
class WinEDA_ModulePropertiesFrame: public wxDialog
{
private:
WinEDA_BasePcbFrame * m_Parent;
wxDC * m_DC;
MODULE * m_CurrentModule;
wxNotebook* m_NoteBook;
wxPanel * m_PanelProperties;
Panel3D_Ctrl * m_Panel3D;
WinEDAChoiceBox * m_TextListBox;
wxRadioBox * m_LayerCtrl;
wxRadioBox * m_OrientCtrl;
wxTextCtrl * m_OrientValue;
wxRadioBox * m_AttributsCtrl;
wxRadioBox * m_AutoPlaceCtrl;
wxSlider * m_CostRot90Ctrl, * m_CostRot180Ctrl;
wxButton * m_DeleteFieddButton;
wxTextCtrl *m_Doc, *m_Keyword;
wxBoxSizer * m_GeneralBoxSizer;
wxBoxSizer* m_PanelPropertiesBoxSizer;
wxTextCtrl *m_ModPositionX, *m_ModPositionY;
wxString *m_ModPosXStr, *m_ModPosYStr;
public:
// Constructor and destructor
WinEDA_ModulePropertiesFrame(WinEDA_BasePcbFrame *parent,
MODULE * Module, wxDC * DC);
~WinEDA_ModulePropertiesFrame()
{
}
private:
void CreateControls();
void OnCancelClick(wxCommandEvent& event);
void OnOkClick(wxCommandEvent& event);
void CreateTextModule(wxCommandEvent& event);
void EditOrDelTextModule(wxCommandEvent& event);
void SelectTextListBox(wxCommandEvent& event);
void ReCreateFieldListBox();
void SetTextListButtons();
void BuildPanelModuleProperties(bool FullOptions);
void ModuleOrientEvent(wxCommandEvent& event);
void ExchangeModule(wxCommandEvent& event);
void GotoModuleEditor(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
/*********************************/
class Panel3D_Ctrl: public wxPanel
/*********************************/
/* panel d'entree des caract 3D */
{
public:
Panel3D_Ctrl * m_Pnext, * m_Pback; // Chainage
wxNotebook * m_Parent;
WinEDA_ModulePropertiesFrame * m_ParentFrame;
wxBoxSizer* m_Panel3DBoxSizer;
wxTextCtrl * m_3D_ShapeName;
WinEDA_VertexCtrl *m_3D_Scale, *m_3D_Offset, *m_3D_Rotation;
public:
Panel3D_Ctrl(WinEDA_ModulePropertiesFrame * parentframe,
wxNotebook * parent, int id, S3D_MASTER * struct3D);
~Panel3D_Ctrl();
void Browse3DLib(wxCommandEvent& event);
void AddOrRemove3DShape(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
/************************************************
* Module editor: Dialog box for editing module
* properties for the Board Editor
************************************************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "bitmaps.h"
#include "appl_wxstruct.h"
#include "gestfich.h"
#include "3d_struct.h"
#include "3d_viewer.h"
#include "wxPcbStruct.h"
#include "dialog_edit_module_for_BoardEditor.h"
/**************************************************************************************/
DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR( WinEDA_PcbFrame* aParent,
MODULE* aModule, wxDC* aDC ) :
DIALOG_MODULE_BOARD_EDITOR_BASE( aParent )
/**************************************************************************************/
{
m_Parent = aParent;
m_DC = aDC;
m_CurrentModule = aModule;
SetIcon( wxICON( icon_modedit ) ); // Give an icon
InitModeditProperties();
InitBoardProperties();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
}
DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR()
{
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
delete m_Shapes3D_list[ii];
m_Shapes3D_list.clear();
delete m_ReferenceCopy;
delete m_ValueCopy;
delete m_3D_Scale;
delete m_3D_Offset;
delete m_3D_Rotation;
}
/***************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties( )
/***************************************************************************/
/* creation du panel d'edition des proprietes du module
*/
{
PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x, PCB_INTERNAL_UNIT );
AddUnitSymbol( *XPositionStatic, g_UnitMetric );
PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *YPositionStatic, g_UnitMetric );
m_LayerCtrl->SetSelection( (m_CurrentModule->GetLayer() == COPPER_LAYER_N) ? 1 : 0 );
bool select = FALSE;
switch( m_CurrentModule->m_Orient )
{
case 0:
m_OrientCtrl->SetSelection( 0 );
break;
case 900:
case -2700:
m_OrientCtrl->SetSelection( 1 );
break;
case -900:
case 2700:
m_OrientCtrl->SetSelection( 2 );
break;
case -1800:
case 1800:
m_OrientCtrl->SetSelection( 3 );
break;
default:
m_OrientCtrl->SetSelection( 4 );
select = TRUE;
break;
}
wxString msg;
msg << m_CurrentModule->m_Orient;
m_OrientValue->SetValue( msg );
m_OrientValue->Enable( select );
}
/**********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
EndModal( -1 );
}
/************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::GotoModuleEditor( wxCommandEvent& event )
/************************************************************************/
{
if( m_CurrentModule->m_TimeStamp == 0 ) // Module Editor needs a non null timestamp
{
m_CurrentModule->m_TimeStamp = GetTimeStamp();
m_Parent->GetScreen()->SetModify();
}
EndModal( 2 );
}
/**********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::ExchangeModule( wxCommandEvent& event )
/**********************************************************************/
{
m_Parent->InstallExchangeModuleFrame( m_CurrentModule );
// Warning: m_CurrentModule was deleted by exchange module
m_Parent->SetCurItem( NULL );
EndModal( 0 );
}
/*************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::ModuleOrientEvent( wxCommandEvent& event )
/*************************************************************************/
{
switch( m_OrientCtrl->GetSelection() )
{
case 0:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "0" ) );
break;
case 1:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "900" ) );
break;
case 2:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "2700" ) );
break;
case 3:
m_OrientValue->Enable( FALSE );
m_OrientValue->SetValue( wxT( "1800" ) );
break;
default:
m_OrientValue->Enable( FALSE );
m_OrientValue->Enable( TRUE );
break;
}
}
/*******************************************************/
void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
/*******************************************************/
{
SetFocus();
m_LastSelected3DShapeIndex = -1;
/* Init 3D shape list */
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
while( draw3D )
{
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName);
draw3D = (S3D_MASTER*) draw3D->Next();
}
m_ReferenceCopy = new TEXTE_MODULE(NULL);
m_ValueCopy = new TEXTE_MODULE(NULL);
m_ReferenceCopy->Copy(m_CurrentModule->m_Reference);
m_ValueCopy->Copy(m_CurrentModule->m_Value);
m_ReferenceCtrl->SetValue( m_ReferenceCopy->m_Text );
m_ValueCtrl->SetValue( m_ValueCopy->m_Text );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) );
m_AttributsCtrl->SetItemToolTip( 1,
_(
"Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
m_AttributsCtrl->SetItemToolTip( 2,
_(
"Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
#endif
/* Controls on right side of the dialog */
switch( m_CurrentModule->m_Attributs & 255 )
{
case 0:
m_AttributsCtrl->SetSelection( 0 );
break;
case MOD_CMS:
m_AttributsCtrl->SetSelection( 1 );
break;
case MOD_VIRTUAL:
m_AttributsCtrl->SetSelection( 2 );
break;
default:
m_AttributsCtrl->SetSelection( 0 );
break;
}
m_AutoPlaceCtrl->SetSelection(
(m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );
#endif
m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 );
m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 );
// Initialize 3D parameters
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
}
/* Initialize 3D info displayed in dialog box from values in aStruct3DSource
*/
void DIALOG_MODULE_BOARD_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource )
{
if( aStruct3DSource )
{
m_3D_Scale->SetValue( aStruct3DSource->m_MatScale );
m_3D_Offset->SetValue( aStruct3DSource->m_MatPosition );
m_3D_Rotation->SetValue( aStruct3DSource->m_MatRotation );
}
else
{
S3D_Vertex dummy_vertex;
dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0;
m_3D_Scale->SetValue( dummy_vertex );
}
}
/** Copy 3D info displayed in dialog box to values in a item in m_Shapes3D_list
* @param aIndexSelection = item index in m_Shapes3D_list
*/
void DIALOG_MODULE_BOARD_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection )
{
if( aIndexSelection >= (int)m_Shapes3D_list.size() )
return;
S3D_MASTER * struct3DDest = m_Shapes3D_list[aIndexSelection];
struct3DDest->m_MatScale = m_3D_Scale->GetValue();
struct3DDest->m_MatRotation = m_3D_Rotation->GetValue();
struct3DDest->m_MatPosition = m_3D_Offset->GetValue();
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
/***********************************************************/
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection();
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Add3DShape(wxCommandEvent& event)
/***********************************************************/
{
Browse3DLib( event );
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Remove3DShape(wxCommandEvent& event)
/***********************************************************/
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
int ii = m_3D_ShapeNameListBox->GetSelection();
if( ii < 0 )
return;
m_Shapes3D_list.erase(m_Shapes3D_list.begin() + ii );
m_3D_ShapeNameListBox->Delete(ii);
if( m_3D_ShapeNameListBox->GetCount() == 0)
Transfert3DValuesToDisplay( NULL );
else
{
m_LastSelected3DShapeIndex = 0;
m_3D_ShapeNameListBox->SetSelection(m_LastSelected3DShapeIndex);
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
}
/*********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
/*********************************************************************/
{
wxString fullfilename, shortfilename;
wxString fullpath;
wxString mask = wxT( "*" );
fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH );
mask += g_Shapes3DExtBuffer;
#ifdef __WINDOWS__
fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_Shapes3DExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( fullfilename == wxEmptyString )
return;
wxFileName fn = fullfilename;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the file path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
*/
shortfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fullfilename );
S3D_MASTER* new3DShape = new S3D_MASTER(NULL);
new3DShape->m_Shape3DName = shortfilename;
m_Shapes3D_list.push_back( new3DShape );
m_3D_ShapeNameListBox->Append( shortfilename );
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
m_3D_ShapeNameListBox->SetSelection(m_LastSelected3DShapeIndex);
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
/******************************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
/******************************************************************************/
{
bool change_layer = FALSE;
wxPoint modpos;
if( m_CurrentModule->m_Flags == 0 ) // this is a simple edition, we must create an undo entry
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_CHANGED );
if( m_DC )
{
m_Parent->DrawPanel->CursorOff( m_DC );
m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
}
// Set Module Position
modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX, PCB_INTERNAL_UNIT );
modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY, PCB_INTERNAL_UNIT );
m_CurrentModule->SetPosition(modpos);
// Set orienta tion
long orient = 0;
wxString msg = m_OrientValue->GetValue();
msg.ToLong( &orient );
if( m_CurrentModule->m_Orient != orient )
m_CurrentModule->Rotate( m_CurrentModule->m_Pos, orient - m_CurrentModule->m_Orient );
if( m_LayerCtrl->GetSelection() == 0 ) // layer req = COMPONENT
{
if( m_CurrentModule->GetLayer() == COPPER_LAYER_N )
change_layer = TRUE;
}
else if( m_CurrentModule->GetLayer() == CMP_N )
change_layer = TRUE;
if( change_layer )
m_CurrentModule->Flip(m_CurrentModule->m_Pos);
if( m_AutoPlaceCtrl->GetSelection() == 1 )
m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED;
else
m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED;
switch( m_AttributsCtrl->GetSelection() )
{
case 0:
m_CurrentModule->m_Attributs = 0;
break;
case 1:
m_CurrentModule->m_Attributs = MOD_CMS;
break;
case 2:
m_CurrentModule->m_Attributs = MOD_VIRTUAL;
break;
}
m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue();
m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue();
// Init Fields:
m_CurrentModule->m_Reference->Copy(m_ReferenceCopy );
m_CurrentModule->m_Value->Copy(m_ValueCopy );
/* Update 3D shape list */
int ii = m_3D_ShapeNameListBox->GetSelection();
if ( ii >= 0 )
TransfertDisplayTo3DValues( ii );
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
{
S3D_MASTER* draw3DCopy = m_Shapes3D_list[ii];
if( draw3DCopy->m_Shape3DName.IsEmpty() )
continue;
if( draw3D == NULL )
{
draw3D = new S3D_MASTER( draw3D );
m_CurrentModule->m_3D_Drawings.Append( draw3D );
}
draw3D->m_Shape3DName = draw3DCopy->m_Shape3DName;
draw3D->m_MatScale = draw3DCopy->m_MatScale;
draw3D->m_MatRotation = draw3DCopy->m_MatRotation;
draw3D->m_MatPosition = draw3DCopy->m_MatPosition;
draw3D = draw3D->Next();
}
// Remove old extra 3D shapes
S3D_MASTER* nextdraw3D;
for( ; draw3D != NULL; draw3D = nextdraw3D )
{
nextdraw3D = (S3D_MASTER*) draw3D->Next();
delete m_CurrentModule->m_3D_Drawings.Remove( draw3D );
}
// Fill shape list with one void entry, if no entry
if( m_CurrentModule->m_3D_Drawings == NULL )
m_CurrentModule->m_3D_Drawings.PushBack( new S3D_MASTER( m_CurrentModule ) );
m_CurrentModule->Set_Rectangle_Encadrement();
m_Parent->GetScreen()->SetModify();
EndModal( 1 );
if( m_DC )
{
m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, GR_OR );
m_Parent->DrawPanel->CursorOn( m_DC );
}
}
/***********************************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnEditReference(wxCommandEvent& event)
/***********************************************************************/
{
wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
m_Parent->GetScreen()->m_Curseur = m_ReferenceCopy->m_Pos;
m_ReferenceCopy->SetParent(m_CurrentModule);
m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL );
m_Parent->GetScreen()->m_Curseur = tmp;
m_ReferenceCtrl->SetValue(m_ReferenceCopy->m_Text);
}
/***********************************************************/
void DIALOG_MODULE_BOARD_EDITOR::OnEditValue(wxCommandEvent& event)
/***********************************************************/
{
wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
m_Parent->GetScreen()->m_Curseur = m_ValueCopy->m_Pos;
m_ValueCopy->SetParent(m_CurrentModule);
m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL );
m_Parent->GetScreen()->m_Curseur = tmp;
m_ValueCtrl->SetValue(m_ValueCopy->m_Text);
}
/************************************************/
/* Module editor: Dialog box for editing module */
/* properties and carateristics */
/************************************************/
#include "dialog_edit_module_for_BoardEditor_base.h"
/**************************************/
/* class DIALOG_MODULE_BOARD_EDITOR */
/**************************************/
class DIALOG_MODULE_BOARD_EDITOR: public DIALOG_MODULE_BOARD_EDITOR_BASE
{
private:
WinEDA_PcbFrame * m_Parent;
wxDC * m_DC;
MODULE* m_CurrentModule;
TEXTE_MODULE* m_ReferenceCopy;
TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_MASTER*> m_Shapes3D_list;
int m_LastSelected3DShapeIndex;
WinEDA_VertexCtrl * m_3D_Scale;
WinEDA_VertexCtrl * m_3D_Offset;
WinEDA_VertexCtrl * m_3D_Rotation;
public:
// Constructor and destructor
DIALOG_MODULE_BOARD_EDITOR( WinEDA_PcbFrame* aParent, MODULE* aModule, wxDC* aDC );
~DIALOG_MODULE_BOARD_EDITOR();
private:
void InitBoardProperties();
void InitModeditProperties();
void Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource );
void TransfertDisplayTo3DValues( int aIndexSelection );
void OnEditValue( wxCommandEvent& event );
void OnEditReference( wxCommandEvent& event );
void On3DShapeSelection( wxCommandEvent& event );
void On3DShapeNameSelected( wxCommandEvent& event );
void Browse3DLib( wxCommandEvent& event );
void Add3DShape( wxCommandEvent& event );
void Remove3DShape( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void GotoModuleEditor( wxCommandEvent& event );
void ExchangeModule( wxCommandEvent& event );
void ModuleOrientEvent( wxCommandEvent& event );
};
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_edit_module_for_BoardEditor_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
m_GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
m_NoteBook = new wxNotebook( this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, 0 );
m_PanelProperties = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
wxBoxSizer* m_PanelPropertiesBoxSizer;
m_PanelPropertiesBoxSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* PropLeftSizer;
PropLeftSizer = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Fields:") ), wxVERTICAL );
wxStaticBoxSizer* sbSizerRef;
sbSizerRef = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Reference") ), wxHORIZONTAL );
m_ReferenceCtrl = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
sbSizerRef->Add( m_ReferenceCtrl, 1, 0, 5 );
m_button4 = new wxButton( m_PanelProperties, wxID_ANY, _("Edit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
sbSizerRef->Add( m_button4, 0, 0, 5 );
PropLeftSizer->Add( sbSizerRef, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerValue;
sbSizerValue = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Value") ), wxHORIZONTAL );
m_ValueCtrl = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
sbSizerValue->Add( m_ValueCtrl, 1, 0, 5 );
m_button5 = new wxButton( m_PanelProperties, wxID_ANY, _("Edit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
sbSizerValue->Add( m_button5, 0, 0, 5 );
PropLeftSizer->Add( sbSizerValue, 0, wxEXPAND, 5 );
wxString m_LayerCtrlChoices[] = { _("Top"), _("Bottom") };
int m_LayerCtrlNChoices = sizeof( m_LayerCtrlChoices ) / sizeof( wxString );
m_LayerCtrl = new wxRadioBox( m_PanelProperties, wxID_ANY, _("Side Select"), wxDefaultPosition, wxDefaultSize, m_LayerCtrlNChoices, m_LayerCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_LayerCtrl->SetSelection( 0 );
PropLeftSizer->Add( m_LayerCtrl, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerOrientation;
sbSizerOrientation = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Orientation") ), wxVERTICAL );
wxString m_OrientCtrlChoices[] = { _("Normal"), _("+ 90.0"), _("- 90.0"), _("180.0"), _("User") };
int m_OrientCtrlNChoices = sizeof( m_OrientCtrlChoices ) / sizeof( wxString );
m_OrientCtrl = new wxRadioBox( m_PanelProperties, ID_LISTBOX_ORIENT_SELECT, _("Orientation"), wxDefaultPosition, wxDefaultSize, m_OrientCtrlNChoices, m_OrientCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_OrientCtrl->SetSelection( 0 );
sbSizerOrientation->Add( m_OrientCtrl, 0, wxALL|wxEXPAND, 5 );
m_staticText4 = new wxStaticText( m_PanelProperties, wxID_ANY, _("Orientation (in 0.1 degrees)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText4->Wrap( -1 );
sbSizerOrientation->Add( m_staticText4, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_OrientValue = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbSizerOrientation->Add( m_OrientValue, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
PropLeftSizer->Add( sbSizerOrientation, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerPosition;
sbSizerPosition = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Position") ), wxVERTICAL );
XPositionStatic = new wxStaticText( m_PanelProperties, wxID_ANY, _("X"), wxDefaultPosition, wxDefaultSize, 0 );
XPositionStatic->Wrap( -1 );
sbSizerPosition->Add( XPositionStatic, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ModPositionX = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbSizerPosition->Add( m_ModPositionX, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
YPositionStatic = new wxStaticText( m_PanelProperties, wxID_ANY, _("Y"), wxDefaultPosition, wxDefaultSize, 0 );
YPositionStatic->Wrap( -1 );
sbSizerPosition->Add( YPositionStatic, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ModPositionY = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbSizerPosition->Add( m_ModPositionY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
PropLeftSizer->Add( sbSizerPosition, 0, wxEXPAND, 5 );
m_PanelPropertiesBoxSizer->Add( PropLeftSizer, 1, wxEXPAND, 5 );
m_PropRightSizer = new wxBoxSizer( wxVERTICAL );
m_buttonExchange = new wxButton( m_PanelProperties, ID_MODULE_PROPERTIES_EXCHANGE, _("Change Module(s)"), wxDefaultPosition, wxDefaultSize, 0 );
m_PropRightSizer->Add( m_buttonExchange, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonModuleEditor = new wxButton( m_PanelProperties, ID_GOTO_MODULE_EDITOR, _("Module Editor"), wxDefaultPosition, wxDefaultSize, 0 );
m_PropRightSizer->Add( m_buttonModuleEditor, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_PropRightSizer->Add( 0, 20, 0, 0, 5 );
wxString m_AttributsCtrlChoices[] = { _("Normal"), _("Normal+Insert"), _("Virtual") };
int m_AttributsCtrlNChoices = sizeof( m_AttributsCtrlChoices ) / sizeof( wxString );
m_AttributsCtrl = new wxRadioBox( m_PanelProperties, wxID_ANY, _("Attributs:"), wxDefaultPosition, wxDefaultSize, m_AttributsCtrlNChoices, m_AttributsCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AttributsCtrl->SetSelection( 0 );
m_PropRightSizer->Add( m_AttributsCtrl, 0, wxALL|wxEXPAND, 5 );
wxString m_AutoPlaceCtrlChoices[] = { _("Free"), _("Locked") };
int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString );
m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, wxID_ANY, _("Move and Auto Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AutoPlaceCtrl->SetSelection( 0 );
m_PropRightSizer->Add( m_AutoPlaceCtrl, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerAutoplace;
sbSizerAutoplace = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Auto Move and Place") ), wxVERTICAL );
m_staticText11 = new wxStaticText( m_PanelProperties, wxID_ANY, _("Rotation 90 degree"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
sbSizerAutoplace->Add( m_staticText11, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_CostRot90Ctrl = new wxSlider( m_PanelProperties, wxID_ANY, 0, 0, 10, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS );
sbSizerAutoplace->Add( m_CostRot90Ctrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticText12 = new wxStaticText( m_PanelProperties, wxID_ANY, _("Rotation 180 degree"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText12->Wrap( -1 );
sbSizerAutoplace->Add( m_staticText12, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_CostRot180Ctrl = new wxSlider( m_PanelProperties, wxID_ANY, 0, 0, 10, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS );
sbSizerAutoplace->Add( m_CostRot180Ctrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_PropRightSizer->Add( sbSizerAutoplace, 1, wxEXPAND, 5 );
m_PanelPropertiesBoxSizer->Add( m_PropRightSizer, 0, 0, 5 );
m_PanelProperties->SetSizer( m_PanelPropertiesBoxSizer );
m_PanelProperties->Layout();
m_PanelPropertiesBoxSizer->Fit( m_PanelProperties );
m_NoteBook->AddPage( m_PanelProperties, _("Properties"), true );
m_Panel3D = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
wxBoxSizer* bSizerMain3D;
bSizerMain3D = new wxBoxSizer( wxVERTICAL );
m_staticText3Dname = new wxStaticText( m_Panel3D, wxID_ANY, _("3D Shape Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3Dname->Wrap( -1 );
bSizerMain3D->Add( m_staticText3Dname, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_3D_ShapeNameListBox = new wxListBox( m_Panel3D, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE );
bSizerMain3D->Add( m_3D_ShapeNameListBox, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bLowerSizer3D;
bLowerSizer3D = new wxBoxSizer( wxHORIZONTAL );
m_Sizer3DValues = new wxStaticBoxSizer( new wxStaticBox( m_Panel3D, wxID_ANY, _("3D Scale and Pos") ), wxVERTICAL );
bLowerSizer3D->Add( m_Sizer3DValues, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer3DButtons;
bSizer3DButtons = new wxBoxSizer( wxVERTICAL );
m_buttonBrowse = new wxButton( m_Panel3D, ID_BROWSE_3D_LIB, _("Browse Shapes"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3DButtons->Add( m_buttonBrowse, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonAdd = new wxButton( m_Panel3D, ID_ADD_3D_SHAPE, _("Add 3D Shape"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3DButtons->Add( m_buttonAdd, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonRemove = new wxButton( m_Panel3D, ID_REMOVE_3D_SHAPE, _("Remove 3D Shape"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3DButtons->Add( m_buttonRemove, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
bLowerSizer3D->Add( bSizer3DButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain3D->Add( bLowerSizer3D, 1, wxEXPAND, 5 );
m_Panel3D->SetSizer( bSizerMain3D );
m_Panel3D->Layout();
bSizerMain3D->Fit( m_Panel3D );
m_NoteBook->AddPage( m_Panel3D, _("3D settings"), false );
m_GeneralBoxSizer->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 );
m_sdbSizerStdButtons = new wxStdDialogButtonSizer();
m_sdbSizerStdButtonsOK = new wxButton( this, wxID_OK );
m_sdbSizerStdButtons->AddButton( m_sdbSizerStdButtonsOK );
m_sdbSizerStdButtonsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerStdButtons->AddButton( m_sdbSizerStdButtonsCancel );
m_sdbSizerStdButtons->Realize();
m_GeneralBoxSizer->Add( m_sdbSizerStdButtons, 0, wxEXPAND|wxALIGN_RIGHT, 5 );
this->SetSizer( m_GeneralBoxSizer );
this->Layout();
// Connect Events
m_button4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditReference ), NULL, this );
m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditValue ), NULL, this );
m_OrientCtrl->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ModuleOrientEvent ), NULL, this );
m_buttonExchange->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ExchangeModule ), NULL, this );
m_buttonModuleEditor->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::GotoModuleEditor ), NULL, this );
m_3D_ShapeNameListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::On3DShapeNameSelected ), NULL, this );
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::Browse3DLib ), NULL, this );
m_buttonAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::Add3DShape ), NULL, this );
m_buttonRemove->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::Remove3DShape ), NULL, this );
m_sdbSizerStdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerStdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnOkClick ), NULL, this );
}
DIALOG_MODULE_BOARD_EDITOR_BASE::~DIALOG_MODULE_BOARD_EDITOR_BASE()
{
// Disconnect Events
m_button4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditReference ), NULL, this );
m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnEditValue ), NULL, this );
m_OrientCtrl->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ModuleOrientEvent ), NULL, this );
m_buttonExchange->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::ExchangeModule ), NULL, this );
m_buttonModuleEditor->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::GotoModuleEditor ), NULL, this );
m_3D_ShapeNameListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::On3DShapeNameSelected ), NULL, this );
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::Browse3DLib ), NULL, this );
m_buttonAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::Add3DShape ), NULL, this );
m_buttonRemove->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::Remove3DShape ), NULL, this );
m_sdbSizerStdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerStdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_BOARD_EDITOR_BASE::OnOkClick ), NULL, this );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_edit_module_for_BoardEditor_base__
#define __dialog_edit_module_for_BoardEditor_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/slider.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/listbox.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_NOTEBOOK 1000
#define ID_LISTBOX_ORIENT_SELECT 1001
#define ID_MODULE_PROPERTIES_EXCHANGE 1002
#define ID_GOTO_MODULE_EDITOR 1003
#define ID_BROWSE_3D_LIB 1004
#define ID_ADD_3D_SHAPE 1005
#define ID_REMOVE_3D_SHAPE 1006
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MODULE_BOARD_EDITOR_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MODULE_BOARD_EDITOR_BASE : public wxDialog
{
private:
wxBoxSizer* m_GeneralBoxSizer;
wxBoxSizer* m_PropRightSizer;
protected:
wxNotebook* m_NoteBook;
wxPanel* m_PanelProperties;
wxTextCtrl* m_ReferenceCtrl;
wxButton* m_button4;
wxTextCtrl* m_ValueCtrl;
wxButton* m_button5;
wxRadioBox* m_LayerCtrl;
wxRadioBox* m_OrientCtrl;
wxStaticText* m_staticText4;
wxTextCtrl* m_OrientValue;
wxStaticText* XPositionStatic;
wxTextCtrl* m_ModPositionX;
wxStaticText* YPositionStatic;
wxTextCtrl* m_ModPositionY;
wxButton* m_buttonExchange;
wxButton* m_buttonModuleEditor;
wxRadioBox* m_AttributsCtrl;
wxRadioBox* m_AutoPlaceCtrl;
wxStaticText* m_staticText11;
wxSlider* m_CostRot90Ctrl;
wxStaticText* m_staticText12;
wxSlider* m_CostRot180Ctrl;
wxPanel* m_Panel3D;
wxStaticText* m_staticText3Dname;
wxListBox* m_3D_ShapeNameListBox;
wxButton* m_buttonBrowse;
wxButton* m_buttonAdd;
wxButton* m_buttonRemove;
wxStdDialogButtonSizer* m_sdbSizerStdButtons;
wxButton* m_sdbSizerStdButtonsOK;
wxButton* m_sdbSizerStdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnEditReference( wxCommandEvent& event ){ event.Skip(); }
virtual void OnEditValue( wxCommandEvent& event ){ event.Skip(); }
virtual void ModuleOrientEvent( wxCommandEvent& event ){ event.Skip(); }
virtual void ExchangeModule( wxCommandEvent& event ){ event.Skip(); }
virtual void GotoModuleEditor( wxCommandEvent& event ){ event.Skip(); }
virtual void On3DShapeNameSelected( wxCommandEvent& event ){ event.Skip(); }
virtual void Browse3DLib( wxCommandEvent& event ){ event.Skip(); }
virtual void Add3DShape( wxCommandEvent& event ){ event.Skip(); }
virtual void Remove3DShape( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
public:
wxStaticBoxSizer* m_Sizer3DValues;
DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 422,583 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_MODULE_BOARD_EDITOR_BASE();
};
#endif //__dialog_edit_module_for_BoardEditor_base__
/*******************************************************************************************/
/* Dialog box for editing module properties and carateristics in module editor (modedit)*/
/*******************************************************************************************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
#include "bitmaps.h"
#include "appl_wxstruct.h"
#include "gestfich.h"
#include "3d_struct.h"
#include "3d_viewer.h"
#include "wxPcbStruct.h"
#include "dialog_edit_module_for_modedit.h"
/**************************************************************************************/
DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( WinEDA_ModuleEditFrame* aParent,
MODULE* aModule ) :
DIALOG_MODULE_MODULE_EDITOR_BASE( aParent )
/**************************************************************************************/
{
m_Parent = aParent;
m_CurrentModule = aModule;
SetIcon( wxICON( icon_modedit ) ); // Give an icon
InitModeditProperties();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
}
DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR()
{
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
delete m_Shapes3D_list[ii];
m_Shapes3D_list.clear();
delete m_ReferenceCopy;
delete m_ValueCopy;
delete m_3D_Scale;
delete m_3D_Offset;
delete m_3D_Rotation;
}
/***************************************/
void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
/***************************************/
{
SetFocus();
m_LastSelected3DShapeIndex = -1;
/* Init 3D shape list */
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
while( draw3D )
{
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName);
draw3D = (S3D_MASTER*) draw3D->Next();
}
m_DocCtrl->SetValue( m_CurrentModule->m_Doc );
m_KeywordCtrl->SetValue( m_CurrentModule->m_KeyWord);
m_ReferenceCopy = new TEXTE_MODULE(NULL);
m_ValueCopy = new TEXTE_MODULE(NULL);
m_ReferenceCopy->Copy(m_CurrentModule->m_Reference);
m_ValueCopy->Copy(m_CurrentModule->m_Value);
m_ReferenceCtrl->SetValue( m_ReferenceCopy->m_Text );
m_ValueCtrl->SetValue( m_ValueCopy->m_Text );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non smd components" ) );
m_AttributsCtrl->SetItemToolTip( 1,
_(
"Use this attribute for smd components.\nOnly components with this option are put in the footprint position list file" ) );
m_AttributsCtrl->SetItemToolTip( 2,
_(
"Use this attribute for \"virtual\" components drawn on board (like a old ISA PC bus connector)" ) );
#endif
/* Controls on right side of the dialog */
switch( m_CurrentModule->m_Attributs & 255 )
{
case 0:
m_AttributsCtrl->SetSelection( 0 );
break;
case MOD_CMS:
m_AttributsCtrl->SetSelection( 1 );
break;
case MOD_VIRTUAL:
m_AttributsCtrl->SetSelection( 2 );
break;
default:
m_AttributsCtrl->SetSelection( 0 );
break;
}
m_AutoPlaceCtrl->SetSelection(
(m_CurrentModule->m_ModuleStatus & MODULE_is_LOCKED) ? 1 : 0 );
#if wxCHECK_VERSION( 2, 8, 0 )
m_AutoPlaceCtrl->SetItemToolTip( 0, _( "Enable hotkey move commands and Auto Placement" ) );
m_AutoPlaceCtrl->SetItemToolTip( 1, _( "Disable hotkey move commands and Auto Placement" ) );
#endif
m_CostRot90Ctrl->SetValue( m_CurrentModule->m_CntRot90 );
m_CostRot180Ctrl->SetValue( m_CurrentModule->m_CntRot180 );
// Initialize 3D parameters
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, 2, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
}
/* Initialize 3D info displayed in dialog box from values in aStruct3DSource
*/
void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource )
{
if( aStruct3DSource )
{
m_3D_Scale->SetValue( aStruct3DSource->m_MatScale );
m_3D_Offset->SetValue( aStruct3DSource->m_MatPosition );
m_3D_Rotation->SetValue( aStruct3DSource->m_MatRotation );
}
else
{
S3D_Vertex dummy_vertex;
dummy_vertex.x = dummy_vertex.y = dummy_vertex.z = 1.0;
m_3D_Scale->SetValue( dummy_vertex );
}
}
/** Copy 3D info displayed in dialog box to values in a item in m_Shapes3D_list
* @param aIndexSelection = item index in m_Shapes3D_list
*/
void DIALOG_MODULE_MODULE_EDITOR::TransfertDisplayTo3DValues( int aIndexSelection )
{
if( aIndexSelection >= (int)m_Shapes3D_list.size() )
return;
S3D_MASTER * struct3DDest = m_Shapes3D_list[aIndexSelection];
struct3DDest->m_MatScale = m_3D_Scale->GetValue();
struct3DDest->m_MatRotation = m_3D_Rotation->GetValue();
struct3DDest->m_MatPosition = m_3D_Offset->GetValue();
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
/***********************************************************/
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection();
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::Add3DShape(wxCommandEvent& event)
/***********************************************************/
{
Browse3DLib( event );
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event)
/***********************************************************/
{
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
int ii = m_3D_ShapeNameListBox->GetSelection();
if( ii < 0 )
return;
m_Shapes3D_list.erase(m_Shapes3D_list.begin() + ii );
m_3D_ShapeNameListBox->Delete(ii);
if( m_3D_ShapeNameListBox->GetCount() == 0)
Transfert3DValuesToDisplay( NULL );
else
{
m_LastSelected3DShapeIndex = 0;
m_3D_ShapeNameListBox->SetSelection(m_LastSelected3DShapeIndex);
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
}
/*********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::Browse3DLib( wxCommandEvent& event )
/*********************************************************************/
{
wxString fullfilename, shortfilename;
wxString fullpath;
wxString mask = wxT( "*" );
fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH );
mask += g_Shapes3DExtBuffer;
#ifdef __WINDOWS__
fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif
fullfilename = EDA_FileSelector( _( "3D Shape:" ),
fullpath, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
g_Shapes3DExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
);
if( fullfilename == wxEmptyString )
return;
wxFileName fn = fullfilename;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
/* If the file path is already in the library search paths
* list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path.
* the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths
*/
shortfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fullfilename );
S3D_MASTER* new3DShape = new S3D_MASTER(NULL);
new3DShape->m_Shape3DName = shortfilename;
m_Shapes3D_list.push_back( new3DShape );
m_3D_ShapeNameListBox->Append( shortfilename );
if( m_LastSelected3DShapeIndex >= 0 )
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
m_3D_ShapeNameListBox->SetSelection(m_LastSelected3DShapeIndex);
Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}
/**********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
EndModal( -1 );
}
/******************************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
/******************************************************************************/
{
m_Parent->SaveCopyInUndoList( m_CurrentModule, UR_MODEDIT );
if( m_AutoPlaceCtrl->GetSelection() == 1 )
m_CurrentModule->m_ModuleStatus |= MODULE_is_LOCKED;
else
m_CurrentModule->m_ModuleStatus &= ~MODULE_is_LOCKED;
switch( m_AttributsCtrl->GetSelection() )
{
case 0:
m_CurrentModule->m_Attributs = 0;
break;
case 1:
m_CurrentModule->m_Attributs = MOD_CMS;
break;
case 2:
m_CurrentModule->m_Attributs = MOD_VIRTUAL;
break;
}
m_CurrentModule->m_CntRot90 = m_CostRot90Ctrl->GetValue();
m_CurrentModule->m_CntRot180 = m_CostRot180Ctrl->GetValue();
m_CurrentModule->m_Doc = m_DocCtrl->GetValue();
m_CurrentModule->m_KeyWord = m_KeywordCtrl->GetValue();
// Init Fields:
m_CurrentModule->m_Reference->Copy(m_ReferenceCopy );
m_CurrentModule->m_Value->Copy(m_ValueCopy );
/* Update 3D shape list */
int ii = m_3D_ShapeNameListBox->GetSelection();
if ( ii >= 0 )
TransfertDisplayTo3DValues( ii );
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ )
{
S3D_MASTER* draw3DCopy = m_Shapes3D_list[ii];
if( draw3DCopy->m_Shape3DName.IsEmpty() )
continue;
if( draw3D == NULL )
{
draw3D = new S3D_MASTER( draw3D );
m_CurrentModule->m_3D_Drawings.Append( draw3D );
}
draw3D->m_Shape3DName = draw3DCopy->m_Shape3DName;
draw3D->m_MatScale = draw3DCopy->m_MatScale;
draw3D->m_MatRotation = draw3DCopy->m_MatRotation;
draw3D->m_MatPosition = draw3DCopy->m_MatPosition;
draw3D = draw3D->Next();
}
// Remove old extra 3D shapes
S3D_MASTER* nextdraw3D;
for( ; draw3D != NULL; draw3D = nextdraw3D )
{
nextdraw3D = (S3D_MASTER*) draw3D->Next();
delete m_CurrentModule->m_3D_Drawings.Remove( draw3D );
}
// Fill shape list with one void entry, if no entry
if( m_CurrentModule->m_3D_Drawings == NULL )
m_CurrentModule->m_3D_Drawings.PushBack( new S3D_MASTER( m_CurrentModule ) );
m_CurrentModule->Set_Rectangle_Encadrement();
m_Parent->GetScreen()->SetModify();
EndModal( 1 );
}
/***********************************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event)
/***********************************************************************/
{
wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
m_Parent->GetScreen()->m_Curseur = m_ReferenceCopy->m_Pos;
m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL );
m_Parent->GetScreen()->m_Curseur = tmp;
m_ReferenceCtrl->SetValue(m_ReferenceCopy->m_Text);
}
/***********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event)
/***********************************************************/
{
wxPoint tmp = m_Parent->GetScreen()->m_Curseur;
m_Parent->GetScreen()->m_Curseur = m_ValueCopy->m_Pos;
m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL );
m_Parent->GetScreen()->m_Curseur = tmp;
m_ValueCtrl->SetValue(m_ValueCopy->m_Text);
}
/*****************************************************************************/
/* Module editor: Dialog box for editing module properties and carateristics */
/*****************************************************************************/
#ifndef __DIALOG_EDIT_MODULE_FOR_MODEDIT__
#define __DIALOG_EDIT_MODULE_FOR_MODEDIT__
// Include the wxFormBuider header base:
#include <vector>
#include "dialog_edit_module_for_modedit_base.h"
/**************************************/
/* class DIALOG_MODULE_MODULE_EDITOR */
/**************************************/
class DIALOG_MODULE_MODULE_EDITOR : public DIALOG_MODULE_MODULE_EDITOR_BASE
{
private:
WinEDA_ModuleEditFrame* m_Parent;
MODULE* m_CurrentModule;
TEXTE_MODULE* m_ReferenceCopy;
TEXTE_MODULE* m_ValueCopy;
std::vector <S3D_MASTER*> m_Shapes3D_list;
int m_LastSelected3DShapeIndex;
WinEDA_VertexCtrl * m_3D_Scale;
WinEDA_VertexCtrl * m_3D_Offset;
WinEDA_VertexCtrl * m_3D_Rotation;
public:
// Constructor and destructor
DIALOG_MODULE_MODULE_EDITOR( WinEDA_ModuleEditFrame* aParent, MODULE* aModule );
~DIALOG_MODULE_MODULE_EDITOR();
private:
void InitModeditProperties();
void Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource );
void TransfertDisplayTo3DValues( int aIndexSelection );
void OnEditValue( wxCommandEvent& event );
void OnEditReference( wxCommandEvent& event );
void On3DShapeSelection( wxCommandEvent& event );
void On3DShapeNameSelected( wxCommandEvent& event );
void Browse3DLib( wxCommandEvent& event );
void Add3DShape( wxCommandEvent& event );
void Remove3DShape( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
};
#endif // __DIALOG_EDIT_MODULE_FOR_MODEDIT__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_edit_module_for_Modedit_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_MODULE_MODULE_EDITOR_BASE::DIALOG_MODULE_MODULE_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
m_GeneralBoxSizer = new wxBoxSizer( wxVERTICAL );
m_NoteBook = new wxNotebook( this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, 0 );
m_PanelProperties = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
wxBoxSizer* m_PanelPropertiesBoxSizer;
m_PanelPropertiesBoxSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* PropLeftSizer;
PropLeftSizer = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Fields:") ), wxVERTICAL );
wxStaticBoxSizer* sbSizerDoc;
sbSizerDoc = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Doc") ), wxHORIZONTAL );
sbSizerDoc->SetMinSize( wxSize( 300,-1 ) );
m_DocCtrl = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbSizerDoc->Add( m_DocCtrl, 1, 0, 5 );
PropLeftSizer->Add( sbSizerDoc, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerKeysW;
sbSizerKeysW = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Keywords") ), wxHORIZONTAL );
m_KeywordCtrl = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbSizerKeysW->Add( m_KeywordCtrl, 1, 0, 5 );
PropLeftSizer->Add( sbSizerKeysW, 0, wxEXPAND, 5 );
PropLeftSizer->Add( 0, 20, 0, 0, 5 );
wxStaticBoxSizer* sbSizerRef;
sbSizerRef = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Reference") ), wxHORIZONTAL );
m_ReferenceCtrl = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
sbSizerRef->Add( m_ReferenceCtrl, 1, 0, 5 );
m_button4 = new wxButton( m_PanelProperties, wxID_ANY, _("Edit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
sbSizerRef->Add( m_button4, 0, 0, 5 );
PropLeftSizer->Add( sbSizerRef, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerValue;
sbSizerValue = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Value") ), wxHORIZONTAL );
m_ValueCtrl = new wxTextCtrl( m_PanelProperties, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
sbSizerValue->Add( m_ValueCtrl, 1, 0, 5 );
m_button5 = new wxButton( m_PanelProperties, wxID_ANY, _("Edit"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
sbSizerValue->Add( m_button5, 0, 0, 5 );
PropLeftSizer->Add( sbSizerValue, 0, wxEXPAND, 5 );
m_PanelPropertiesBoxSizer->Add( PropLeftSizer, 1, wxEXPAND, 5 );
m_PropRightSizer = new wxBoxSizer( wxVERTICAL );
wxString m_AttributsCtrlChoices[] = { _("Normal"), _("Normal+Insert"), _("Virtual") };
int m_AttributsCtrlNChoices = sizeof( m_AttributsCtrlChoices ) / sizeof( wxString );
m_AttributsCtrl = new wxRadioBox( m_PanelProperties, wxID_ANY, _("Attributs:"), wxDefaultPosition, wxDefaultSize, m_AttributsCtrlNChoices, m_AttributsCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AttributsCtrl->SetSelection( 0 );
m_PropRightSizer->Add( m_AttributsCtrl, 0, wxALL|wxEXPAND, 5 );
wxString m_AutoPlaceCtrlChoices[] = { _("Free"), _("Locked") };
int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString );
m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, wxID_ANY, _("Move and Auto Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AutoPlaceCtrl->SetSelection( 0 );
m_PropRightSizer->Add( m_AutoPlaceCtrl, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerAutoplace;
sbSizerAutoplace = new wxStaticBoxSizer( new wxStaticBox( m_PanelProperties, wxID_ANY, _("Auto Move and Place") ), wxVERTICAL );
m_staticText11 = new wxStaticText( m_PanelProperties, wxID_ANY, _("Rotation 90 degree"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText11->Wrap( -1 );
sbSizerAutoplace->Add( m_staticText11, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_CostRot90Ctrl = new wxSlider( m_PanelProperties, wxID_ANY, 0, 0, 10, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS );
sbSizerAutoplace->Add( m_CostRot90Ctrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticText12 = new wxStaticText( m_PanelProperties, wxID_ANY, _("Rotation 180 degree"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText12->Wrap( -1 );
sbSizerAutoplace->Add( m_staticText12, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_CostRot180Ctrl = new wxSlider( m_PanelProperties, wxID_ANY, 0, 0, 10, wxDefaultPosition, wxDefaultSize, wxSL_AUTOTICKS|wxSL_HORIZONTAL|wxSL_LABELS );
sbSizerAutoplace->Add( m_CostRot180Ctrl, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_PropRightSizer->Add( sbSizerAutoplace, 1, wxEXPAND, 5 );
m_PanelPropertiesBoxSizer->Add( m_PropRightSizer, 0, 0, 5 );
m_PanelProperties->SetSizer( m_PanelPropertiesBoxSizer );
m_PanelProperties->Layout();
m_PanelPropertiesBoxSizer->Fit( m_PanelProperties );
m_NoteBook->AddPage( m_PanelProperties, _("Properties"), true );
m_Panel3D = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
wxBoxSizer* bSizerMain3D;
bSizerMain3D = new wxBoxSizer( wxVERTICAL );
m_staticText3Dname = new wxStaticText( m_Panel3D, wxID_ANY, _("3D Shape Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3Dname->Wrap( -1 );
bSizerMain3D->Add( m_staticText3Dname, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_3D_ShapeNameListBox = new wxListBox( m_Panel3D, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE );
bSizerMain3D->Add( m_3D_ShapeNameListBox, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bLowerSizer3D;
bLowerSizer3D = new wxBoxSizer( wxHORIZONTAL );
m_Sizer3DValues = new wxStaticBoxSizer( new wxStaticBox( m_Panel3D, wxID_ANY, _("3D Scale and Pos") ), wxVERTICAL );
bLowerSizer3D->Add( m_Sizer3DValues, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer3DButtons;
bSizer3DButtons = new wxBoxSizer( wxVERTICAL );
m_buttonBrowse = new wxButton( m_Panel3D, ID_BROWSE_3D_LIB, _("Browse Shapes"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3DButtons->Add( m_buttonBrowse, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonAdd = new wxButton( m_Panel3D, ID_ADD_3D_SHAPE, _("Add 3D Shape"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3DButtons->Add( m_buttonAdd, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonRemove = new wxButton( m_Panel3D, ID_REMOVE_3D_SHAPE, _("Remove 3D Shape"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3DButtons->Add( m_buttonRemove, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
bLowerSizer3D->Add( bSizer3DButtons, 0, wxALIGN_CENTER_VERTICAL, 5 );
bSizerMain3D->Add( bLowerSizer3D, 1, wxEXPAND, 5 );
m_Panel3D->SetSizer( bSizerMain3D );
m_Panel3D->Layout();
bSizerMain3D->Fit( m_Panel3D );
m_NoteBook->AddPage( m_Panel3D, _("3D settings"), false );
m_GeneralBoxSizer->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 );
m_sdbSizerStdButtons = new wxStdDialogButtonSizer();
m_sdbSizerStdButtonsOK = new wxButton( this, wxID_OK );
m_sdbSizerStdButtons->AddButton( m_sdbSizerStdButtonsOK );
m_sdbSizerStdButtonsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerStdButtons->AddButton( m_sdbSizerStdButtonsCancel );
m_sdbSizerStdButtons->Realize();
m_GeneralBoxSizer->Add( m_sdbSizerStdButtons, 0, wxEXPAND|wxALIGN_RIGHT, 5 );
this->SetSizer( m_GeneralBoxSizer );
this->Layout();
// Connect Events
m_button4->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditReference ), NULL, this );
m_button5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditValue ), NULL, this );
m_3D_ShapeNameListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::On3DShapeNameSelected ), NULL, this );
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Browse3DLib ), NULL, this );
m_buttonAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Add3DShape ), NULL, this );
m_buttonRemove->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Remove3DShape ), NULL, this );
m_sdbSizerStdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerStdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnOkClick ), NULL, this );
}
DIALOG_MODULE_MODULE_EDITOR_BASE::~DIALOG_MODULE_MODULE_EDITOR_BASE()
{
// Disconnect Events
m_button4->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditReference ), NULL, this );
m_button5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnEditValue ), NULL, this );
m_3D_ShapeNameListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::On3DShapeNameSelected ), NULL, this );
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Browse3DLib ), NULL, this );
m_buttonAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Add3DShape ), NULL, this );
m_buttonRemove->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::Remove3DShape ), NULL, this );
m_sdbSizerStdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerStdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MODULE_MODULE_EDITOR_BASE::OnOkClick ), NULL, this );
}
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_edit_module_for_Modedit_base__
#define __dialog_edit_module_for_Modedit_base__
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/radiobox.h>
#include <wx/stattext.h>
#include <wx/slider.h>
#include <wx/panel.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/listbox.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
#define ID_NOTEBOOK 1000
#define ID_BROWSE_3D_LIB 1001
#define ID_ADD_3D_SHAPE 1002
#define ID_REMOVE_3D_SHAPE 1003
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MODULE_MODULE_EDITOR_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MODULE_MODULE_EDITOR_BASE : public wxDialog
{
private:
wxBoxSizer* m_GeneralBoxSizer;
wxBoxSizer* m_PropRightSizer;
protected:
wxNotebook* m_NoteBook;
wxPanel* m_PanelProperties;
wxTextCtrl* m_DocCtrl;
wxTextCtrl* m_KeywordCtrl;
wxTextCtrl* m_ReferenceCtrl;
wxButton* m_button4;
wxTextCtrl* m_ValueCtrl;
wxButton* m_button5;
wxRadioBox* m_AttributsCtrl;
wxRadioBox* m_AutoPlaceCtrl;
wxStaticText* m_staticText11;
wxSlider* m_CostRot90Ctrl;
wxStaticText* m_staticText12;
wxSlider* m_CostRot180Ctrl;
wxPanel* m_Panel3D;
wxStaticText* m_staticText3Dname;
wxListBox* m_3D_ShapeNameListBox;
wxButton* m_buttonBrowse;
wxButton* m_buttonAdd;
wxButton* m_buttonRemove;
wxStdDialogButtonSizer* m_sdbSizerStdButtons;
wxButton* m_sdbSizerStdButtonsOK;
wxButton* m_sdbSizerStdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnEditReference( wxCommandEvent& event ){ event.Skip(); }
virtual void OnEditValue( wxCommandEvent& event ){ event.Skip(); }
virtual void On3DShapeNameSelected( wxCommandEvent& event ){ event.Skip(); }
virtual void Browse3DLib( wxCommandEvent& event ){ event.Skip(); }
virtual void Add3DShape( wxCommandEvent& event ){ event.Skip(); }
virtual void Remove3DShape( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
public:
wxStaticBoxSizer* m_Sizer3DValues;
DIALOG_MODULE_MODULE_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Module properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 422,422 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_MODULE_MODULE_EDITOR_BASE();
};
#endif //__dialog_edit_module_for_Modedit_base__
...@@ -38,23 +38,18 @@ private: ...@@ -38,23 +38,18 @@ private:
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
}; };
/***************************************************************************/ /*************************************************************************************/
void WinEDA_BasePcbFrame::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, void WinEDA_BasePcbFrame::InstallTextModOptionsFrame( TEXTE_MODULE* TextMod, wxDC* DC )
wxDC* DC, const wxPoint& pos ) /**************************************************************************************/
/***************************************************************************/
{ {
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
DialogEditModuleText* frame = new DialogEditModuleText( this, DialogEditModuleText dialog( this, TextMod, DC );
TextMod, DC ); dialog.ShowModal();
frame->ShowModal(); frame->Destroy();
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
} }
DialogEditModuleText::DialogEditModuleText( WinEDA_BasePcbFrame* parent, DialogEditModuleText::DialogEditModuleText( WinEDA_BasePcbFrame* parent, TEXTE_MODULE* TextMod, wxDC* DC ) :
TEXTE_MODULE* TextMod,
wxDC* DC ) :
DialogEditModuleText_base(parent) DialogEditModuleText_base(parent)
{ {
...@@ -90,9 +85,14 @@ void DialogEditModuleText::OnInitDialog( wxInitDialogEvent& event ) ...@@ -90,9 +85,14 @@ void DialogEditModuleText::OnInitDialog( wxInitDialogEvent& event )
m_Module->m_Reference->m_Text.GetData(), m_Module->m_Reference->m_Text.GetData(),
m_Module->m_Value->m_Text.GetData(), m_Module->m_Value->m_Text.GetData(),
(float) (m_Module->m_Orient / 10) ); (float) (m_Module->m_Orient / 10) );
m_ModuleInfoText->SetLabel( msg );
} }
else
msg.Empty();
m_ModuleInfoText->SetLabel( msg );
if( m_CurrentTextMod->m_Type == TEXT_is_VALUE ) if( m_CurrentTextMod->m_Type == TEXT_is_VALUE )
m_TextDataTitle->SetLabel( _( "Value:" ) ); m_TextDataTitle->SetLabel( _( "Value:" ) );
else if( m_CurrentTextMod->m_Type == TEXT_is_DIVERS ) else if( m_CurrentTextMod->m_Type == TEXT_is_DIVERS )
...@@ -200,7 +200,8 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event ) ...@@ -200,7 +200,8 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
(m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) ); (m_CurrentTextMod->m_Flags & IS_MOVED) ? MoveVector : wxPoint( 0, 0 ) );
} }
m_Parent->GetScreen()->SetModify(); m_Parent->GetScreen()->SetModify();
( (MODULE*) m_CurrentTextMod->GetParent() )->m_LastEdit_Time = time( NULL ); if( m_Module )
m_Module->m_LastEdit_Time = time( NULL );
Close( TRUE ); Close( TRUE );
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "confirm.h" #include "confirm.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "wxPcbStruct.h"
#include "dialog_graphic_item_properties_base.h" #include "dialog_graphic_item_properties_base.h"
...@@ -24,37 +25,40 @@ ...@@ -24,37 +25,40 @@
class DialogGraphicItemProperties: public DialogGraphicItemProperties_base class DialogGraphicItemProperties: public DialogGraphicItemProperties_base
{ {
private: private:
WinEDA_BasePcbFrame* m_Parent; WinEDA_PcbFrame* m_Parent;
wxDC* m_DC; wxDC* m_DC;
DRAWSEGMENT* m_Item; DRAWSEGMENT* m_Item;
public: public:
DialogGraphicItemProperties( WinEDA_BasePcbFrame* aParent, DRAWSEGMENT * aItem, wxDC * aDC); DialogGraphicItemProperties( WinEDA_PcbFrame* aParent, DRAWSEGMENT * aItem, wxDC * aDC);
~DialogGraphicItemProperties() {}; ~DialogGraphicItemProperties() {};
private: private:
void OnInitDialog( wxInitDialogEvent& event ); void Init( );
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
void OnLayerChoice( wxCommandEvent& event ); void OnLayerChoice( wxCommandEvent& event );
}; };
DialogGraphicItemProperties::DialogGraphicItemProperties( WinEDA_BasePcbFrame* aParent, DRAWSEGMENT * aItem, wxDC * aDC): DialogGraphicItemProperties::DialogGraphicItemProperties( WinEDA_PcbFrame* aParent, DRAWSEGMENT * aItem, wxDC * aDC):
DialogGraphicItemProperties_base( aParent ) DialogGraphicItemProperties_base( aParent )
{ {
m_Parent = aParent; m_Parent = aParent;
m_DC = aDC; m_DC = aDC;
m_Item = aItem; m_Item = aItem;
Init();
Layout();
GetSizer()->SetSizeHints( this );
} }
/*******************************************************************************************/ /*******************************************************************************************/
void WinEDA_BasePcbFrame::InstallGraphicItemPropertiesDialog(DRAWSEGMENT * aItem, wxDC* aDC) void WinEDA_PcbFrame::InstallGraphicItemPropertiesDialog(DRAWSEGMENT * aItem, wxDC* aDC)
/*******************************************************************************************/ /*******************************************************************************************/
{ {
if ( aItem == NULL ) if ( aItem == NULL )
{ {
DisplayError(this, wxT("nstallGraphicItemPropertiesDialog() error: NULL item")); DisplayError(this, wxT("InstallGraphicItemPropertiesDialog() error: NULL item"));
return; return;
} }
DrawPanel->m_IgnoreMouseEvents = TRUE; DrawPanel->m_IgnoreMouseEvents = TRUE;
...@@ -66,7 +70,7 @@ void WinEDA_BasePcbFrame::InstallGraphicItemPropertiesDialog(DRAWSEGMENT * aItem ...@@ -66,7 +70,7 @@ void WinEDA_BasePcbFrame::InstallGraphicItemPropertiesDialog(DRAWSEGMENT * aItem
} }
/**************************************************************************/ /**************************************************************************/
void DialogGraphicItemProperties::OnInitDialog( wxInitDialogEvent& event ) void DialogGraphicItemProperties::Init( )
/**************************************************************************/ /**************************************************************************/
/* Initialize messages and values in text control, /* Initialize messages and values in text control,
* according to the item parameters values * according to the item parameters values
...@@ -102,6 +106,7 @@ void DialogGraphicItemProperties::OnInitDialog( wxInitDialogEvent& event ) ...@@ -102,6 +106,7 @@ void DialogGraphicItemProperties::OnInitDialog( wxInitDialogEvent& event )
break; break;
} }
AddUnitSymbol( *m_Start_Center_XText ); AddUnitSymbol( *m_Start_Center_XText );
PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->m_Start.x, PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->m_Start.x,
m_Parent->m_InternalUnits ); m_Parent->m_InternalUnits );
...@@ -163,9 +168,11 @@ void DialogGraphicItemProperties::OnLayerChoice( wxCommandEvent& event ) ...@@ -163,9 +168,11 @@ void DialogGraphicItemProperties::OnLayerChoice( wxCommandEvent& event )
/*******************************************************************/ /*******************************************************************/
void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event ) void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
/*******************************************************************/ /*******************************************************************/
/* Copy values in text contro to the item parameters /* Copy values in text control to the item parameters
*/ */
{ {
m_Parent->SaveCopyInUndoList( m_Item, UR_CHANGED );
wxString msg; wxString msg;
if ( m_DC ) if ( m_DC )
m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_XOR ); m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
......
...@@ -107,7 +107,6 @@ DialogGraphicItemProperties_base::DialogGraphicItemProperties_base( wxWindow* pa ...@@ -107,7 +107,6 @@ DialogGraphicItemProperties_base::DialogGraphicItemProperties_base( wxWindow* pa
this->Layout(); this->Layout();
// Connect Events // Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogGraphicItemProperties_base::OnInitDialog ) );
m_LayerSelection->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnLayerChoice ), NULL, this ); m_LayerSelection->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnLayerChoice ), NULL, this );
m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnOkClick ), NULL, this ); m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnOkClick ), NULL, this );
m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnCancelClick ), NULL, this ); m_buttonCANCEL->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnCancelClick ), NULL, this );
...@@ -116,7 +115,6 @@ DialogGraphicItemProperties_base::DialogGraphicItemProperties_base( wxWindow* pa ...@@ -116,7 +115,6 @@ DialogGraphicItemProperties_base::DialogGraphicItemProperties_base( wxWindow* pa
DialogGraphicItemProperties_base::~DialogGraphicItemProperties_base() DialogGraphicItemProperties_base::~DialogGraphicItemProperties_base()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DialogGraphicItemProperties_base::OnInitDialog ) );
m_LayerSelection->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnLayerChoice ), NULL, this ); m_LayerSelection->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnLayerChoice ), NULL, this );
m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnOkClick ), NULL, this ); m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnOkClick ), NULL, this );
m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnCancelClick ), NULL, this ); m_buttonCANCEL->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogGraphicItemProperties_base::OnCancelClick ), NULL, this );
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">DialogGraphicItemProperties_base</property> <property name="name">DialogGraphicItemProperties_base</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">348,247</property> <property name="size">399,247</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="title">Graphic item properties</property> <property name="title">Graphic item properties</property>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<event name="OnHibernate"></event> <event name="OnHibernate"></event>
<event name="OnIconize"></event> <event name="OnIconize"></event>
<event name="OnIdle"></event> <event name="OnIdle"></event>
<event name="OnInitDialog">OnInitDialog</event> <event name="OnInitDialog"></event>
<event name="OnKeyDown"></event> <event name="OnKeyDown"></event>
<event name="OnKeyUp"></event> <event name="OnKeyUp"></event>
<event name="OnKillFocus"></event> <event name="OnKillFocus"></event>
......
...@@ -58,14 +58,13 @@ class DialogGraphicItemProperties_base : public wxDialog ...@@ -58,14 +58,13 @@ class DialogGraphicItemProperties_base : public wxDialog
wxButton* m_buttonCANCEL; wxButton* m_buttonCANCEL;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
virtual void OnLayerChoice( wxCommandEvent& event ){ event.Skip(); } virtual void OnLayerChoice( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
public: public:
DialogGraphicItemProperties_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Graphic item properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 348,247 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU ); DialogGraphicItemProperties_base( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Graphic item properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 399,247 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU );
~DialogGraphicItemProperties_base(); ~DialogGraphicItemProperties_base();
}; };
......
...@@ -821,7 +821,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -821,7 +821,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_EDIT_TEXTMODULE: case ID_POPUP_PCB_EDIT_TEXTMODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) GetCurItem(), &dc, pos ); InstallTextModOptionsFrame( (TEXTE_MODULE*) GetCurItem(), &dc );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
...@@ -944,9 +944,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -944,9 +944,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_DELETE_DRAWING_LAYER: case ID_POPUP_PCB_DELETE_DRAWING_LAYER:
Delete_Drawings_All_Layer( (DRAWSEGMENT*) GetCurItem(), &dc ); if( GetCurItem()->m_Flags != 0 )
break;
Delete_Drawings_All_Layer( GetCurItem()->GetLayer() );
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DrawPanel->Refresh();
break; break;
case ID_POPUP_PCB_EDIT_DRAWING: case ID_POPUP_PCB_EDIT_DRAWING:
......
...@@ -115,7 +115,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -115,7 +115,7 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
DisplayOpt.DisplayDrawItems = track_fill_copy; DisplayOpt.DisplayDrawItems = track_fill_copy;
SetCurItem( NULL ); SetCurItem( NULL );
} }
else else if( Segment->m_Flags == 0)
{ {
Segment->Draw( DrawPanel, DC, GR_XOR ); Segment->Draw( DrawPanel, DC, GR_XOR );
Segment->m_Flags = 0; Segment->m_Flags = 0;
...@@ -128,30 +128,22 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC ) ...@@ -128,30 +128,22 @@ void WinEDA_PcbFrame::Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC )
/******************************************************************************/ /******************************************************************************/
void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ) void WinEDA_PcbFrame::Delete_Drawings_All_Layer( int aLayer )
/******************************************************************************/ /******************************************************************************/
{ {
int layer = Segment->GetLayer(); if( aLayer <= LAST_COPPER_LAYER )
if( layer <= LAST_COPPER_LAYER )
{ {
DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 ); DisplayError( this, _( "Copper layer global delete not allowed!" ), 20 );
return; return;
} }
if( Segment->m_Flags ) wxString msg = _( "Delete Layer " ) + GetBoard()->GetLayerName( aLayer );
{
DisplayError( this, _( "Segment is being edited" ), 10 );
return;
}
wxString msg = _( "Delete Layer " ) + GetBoard()->GetLayerName( layer );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
PICKED_ITEMS_LIST pickList; PICKED_ITEMS_LIST pickList;
ITEM_PICKER picker(NULL, UR_DELETED); ITEM_PICKER picker(NULL, UR_DELETED);
BOARD_ITEM* PtNext; BOARD_ITEM* PtNext;
for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext ) for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext )
{ {
...@@ -162,9 +154,9 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -162,9 +154,9 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
case TYPE_TEXTE: case TYPE_TEXTE:
case TYPE_COTATION: case TYPE_COTATION:
if( item->GetLayer() == layer ) case TYPE_MIRE:
if( item->GetLayer() == aLayer )
{ {
item->Draw( DrawPanel, DC, GR_XOR );
item->UnLink(); item->UnLink();
picker.m_PickedItem = item; picker.m_PickedItem = item;
pickList.PushItem(picker); pickList.PushItem(picker);
...@@ -172,15 +164,19 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC ...@@ -172,15 +164,19 @@ void WinEDA_PcbFrame::Delete_Drawings_All_Layer( DRAWSEGMENT* Segment, wxDC* DC
break; break;
default: default:
DisplayError( this, wxT( "Type Drawing Inconnu" ) ); {
wxString msg;
msg.Printf( wxT("Delete_Drawings_All_Layer() error: unknown type %d"), item->Type());
wxMessageBox( msg );
break; break;
} }
}
} }
if( pickList.GetCount() ) if( pickList.GetCount() )
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
SaveCopyInUndoList(Segment, UR_DELETED); SaveCopyInUndoList(pickList, UR_DELETED);
} }
} }
......
...@@ -7,46 +7,47 @@ ...@@ -7,46 +7,47 @@
#include "common.h" #include "common.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "gestfich.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "trigo.h" #include "trigo.h"
#include "bitmaps.h"
#include "3d_struct.h"
#include "3d_viewer.h" #include "3d_viewer.h"
#include "dialog_edit_module.h" #include "dialog_edit_module_for_BoardEditor.h"
#include "protos.h"
bool GoToEditor = FALSE;
/*******************************************************************/ /*******************************************************************/
void WinEDA_BasePcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC * DC ) void WinEDA_PcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
/*******************************************************************/ /*******************************************************************/
/* Fonction relai d'installation de la frame d'dition des proprietes /* Fonction relai d'installation de la frame d'dition des proprietes
* du module*/ * du module*/
{ {
WinEDA_ModulePropertiesFrame* frame = if( Module == NULL )
new WinEDA_ModulePropertiesFrame( this, Module, DC ); return;
frame->ShowModal(); frame->Destroy(); DIALOG_MODULE_BOARD_EDITOR* dialog =
new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC );
if( GoToEditor && GetScreen()->GetCurItem() ) int retvalue = dialog->ShowModal(); /* retvalue =
* -1 if abort,
* 0 if exchange module,
* 1 for normal edition
* and 2 for a goto editor command
*/
dialog->Destroy();
if( retvalue == 2 )
{ {
if( m_ModuleEditFrame == NULL ) if( m_ModuleEditFrame == NULL )
{ {
m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this, m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
_( "Module Editor" ), _( "Module Editor" ),
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
} }
m_ModuleEditFrame->Load_Module_From_BOARD( (MODULE*) GetScreen()->GetCurItem() ); m_ModuleEditFrame->Load_Module_From_BOARD( Module );
SetCurItem( NULL ); SetCurItem( NULL );
GoToEditor = FALSE;
m_ModuleEditFrame->Show( TRUE ); m_ModuleEditFrame->Show( TRUE );
m_ModuleEditFrame->Iconize( FALSE ); m_ModuleEditFrame->Iconize( FALSE );
} }
...@@ -59,30 +60,29 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod ) ...@@ -59,30 +60,29 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
/* /*
* Repositionne l'ancre sous le curseur souris * Repositionne l'ancre sous le curseur souris
* Le module doit etre d'abort selectionne
*/ */
{ {
wxPoint delta; wxPoint moveVector;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
D_PAD* pt_pad; D_PAD* pt_pad;
if( pt_mod == NULL ) if( pt_mod == NULL )
return; return;
delta = pt_mod->m_Pos - GetScreen()->m_Curseur; moveVector = pt_mod->m_Pos - GetScreen()->m_Curseur;
pt_mod->m_Pos = GetScreen()->m_Curseur; pt_mod->m_Pos = GetScreen()->m_Curseur;
/* Mise a jour des coord relatives des elements: /* Mise a jour des coord relatives des elements:
* les coordonnees relatives sont relatives a l'ancre, pour orient 0. * les coordonnees relatives sont relatives a l'ancre, pour orient 0.
* il faut donc recalculer deltaX et deltaY en orientation 0 */ * il faut donc recalculer deltaX et deltaY en orientation 0 */
RotatePoint( &delta, -pt_mod->m_Orient ); RotatePoint( &moveVector, -pt_mod->m_Orient );
/* Mise a jour des coord relatives des pads */ /* Mise a jour des coord relatives des pads */
pt_pad = (D_PAD*) pt_mod->m_Pads; pt_pad = (D_PAD*) pt_mod->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{ {
pt_pad->m_Pos0 += delta; pt_pad->m_Pos0 += moveVector;
} }
/* Mise a jour des coord relatives contours .. */ /* Mise a jour des coord relatives contours .. */
...@@ -94,14 +94,14 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod ) ...@@ -94,14 +94,14 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (EDGE_MODULE*) PtStruct ) #define STRUCT ( (EDGE_MODULE*) PtStruct )
STRUCT->m_Start0 += delta; STRUCT->m_Start0 += moveVector;
STRUCT->m_End0 += delta; STRUCT->m_End0 += moveVector;
break; break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (TEXTE_MODULE*) PtStruct ) #define STRUCT ( (TEXTE_MODULE*) PtStruct )
STRUCT->m_Pos0 += delta; STRUCT->m_Pos0 += moveVector;
break; break;
default: default:
...@@ -141,7 +141,7 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item ) ...@@ -141,7 +141,7 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
} }
DeleteTextModule( text ); DeleteTextModule( text );
} }
break; break;
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
Delete_Edge_Module( (EDGE_MODULE*) Item ); Delete_Edge_Module( (EDGE_MODULE*) Item );
...@@ -155,9 +155,9 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item ) ...@@ -155,9 +155,9 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
{ {
wxString Line; wxString Line;
Line.Printf( wxT( " Remove: StructType %d Inattendu" ), Line.Printf( wxT( " Remove: StructType %d Inattendu" ),
Item->Type() ); Item->Type() );
DisplayError( this, Line ); DisplayError( this, Line );
} }
break; break;
} }
} }
...@@ -22,7 +22,8 @@ static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC ); ...@@ -22,7 +22,8 @@ static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );
/* local variables */ /* local variables */
wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp wxPoint MoveVector; // Move vector for move edge, exported to dialog_edit mod_text.cpp
static wxPoint CursorInitialPosition; // Mouse cursor inital position for move command static wxPoint TextInitialPosition; // Mouse cursor inital position for undo/abort move command
static int TextInitialOrientation; // module text inital orientation for undo/abort move+rot command+rot
/******************************************************************************/ /******************************************************************************/
...@@ -39,7 +40,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) ...@@ -39,7 +40,8 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text = new TEXTE_MODULE( Module ); Text = new TEXTE_MODULE( Module );
/* Chainage de la nouvelle structure en tete de liste drawings */ /* Chainage de la nouvelle structure en tete de liste drawings */
Module->m_Drawings.PushFront( Text ); if( Module )
Module->m_Drawings.PushFront( Text );
Text->m_Flags = IS_NEW; Text->m_Flags = IS_NEW;
...@@ -52,10 +54,12 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC ) ...@@ -52,10 +54,12 @@ TEXTE_MODULE* WinEDA_BasePcbFrame::CreateTextModule( MODULE* Module, wxDC* DC )
Text->m_Pos = GetScreen()->m_Curseur; Text->m_Pos = GetScreen()->m_Curseur;
Text->SetLocalCoord(); Text->SetLocalCoord();
InstallTextModOptionsFrame( Text, NULL, wxPoint( -1, -1 ) ); InstallTextModOptionsFrame( Text, NULL );
DrawPanel->MouseToCursorSchema();
Text->m_Flags = 0; Text->m_Flags = 0;
Text->Draw( DrawPanel, DC, GR_OR ); if( DC )
Text->Draw( DrawPanel, DC, GR_OR );
Text->DisplayInfo( this ); Text->DisplayInfo( this );
...@@ -73,6 +77,12 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -73,6 +77,12 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
MODULE* module = (MODULE*) Text->GetParent(); MODULE* module = (MODULE*) Text->GetParent();
if( module && module->m_Flags == 0 && Text->m_Flags == 0 ) // simple rot command
{ // prepare undo command
if( this->m_Ident == PCB_FRAME )
SaveCopyInUndoList( module,UR_CHANGED );
}
// we expect MoveVector to be (0,0) if there is no move in progress // we expect MoveVector to be (0,0) if there is no move in progress
Text->Draw( DrawPanel, DC, GR_XOR, MoveVector ); Text->Draw( DrawPanel, DC, GR_XOR, MoveVector );
...@@ -85,7 +95,8 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -85,7 +95,8 @@ void WinEDA_BasePcbFrame::RotateTextModule( TEXTE_MODULE* Text, wxDC* DC )
Text->DisplayInfo( this ); Text->DisplayInfo( this );
module->m_LastEdit_Time = time( NULL ); if( module )
module->m_LastEdit_Time = time( NULL );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
...@@ -173,7 +184,8 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -173,7 +184,8 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )
MoveVector.x = MoveVector.y = 0; MoveVector.x = MoveVector.y = 0;
CursorInitialPosition = Text->m_Pos; TextInitialPosition = Text->m_Pos;
TextInitialOrientation = Text->m_Orient;
Text->DisplayInfo( this ); Text->DisplayInfo( this );
...@@ -190,7 +202,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -190,7 +202,7 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
/*************************************************************************/ /*************************************************************************/
/* Routine complementaire a StartMoveTexteModule(). /* Routine complementaire a StartMoveTexteModule().
* Place le texte en cours de deplacement ou nouvellement cree * Place le texte en cours de deplacement
*/ */
{ {
if( Text != NULL ) if( Text != NULL )
...@@ -202,18 +214,24 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) ...@@ -202,18 +214,24 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
MODULE* Module = (MODULE*) Text->GetParent(); MODULE* Module = (MODULE*) Text->GetParent();
if( Module ) if( Module )
{ {
int px = Text->m_Pos.x - Module->m_Pos.x; // Prepare undo command for Board Editor:
int py = Text->m_Pos.y - Module->m_Pos.y; if( m_Ident == PCB_FRAME )
RotatePoint( &px, &py, -Module->m_Orient ); {
Text->m_Pos0.x = px; EXCHG(Text->m_Pos, TextInitialPosition);
Text->m_Pos0.y = py; EXCHG(Text->m_Orient, TextInitialOrientation);
SaveCopyInUndoList(Module, UR_CHANGED);
EXCHG(Text->m_Pos, TextInitialPosition);
EXCHG(Text->m_Orient, TextInitialOrientation);
}
wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
RotatePoint( &textRelPos, -Module->m_Orient );
Text->m_Pos0 = textRelPos;
Text->m_Flags = 0; Text->m_Flags = 0;
Module->m_Flags = 0; Module->m_Flags = 0;
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
GetScreen()->SetModify(); GetScreen()->SetModify();
/* Redessin du Texte */ /* Redessin du Texte */
//Text->Draw( DrawPanel, DC, GR_OR );
DrawPanel->PostDirtyRect( Text->GetBoundingBox() ); DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
} }
} }
...@@ -232,20 +250,16 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ...@@ -232,20 +250,16 @@ static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase
{ {
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem(); TEXTE_MODULE* Text = (TEXTE_MODULE*) screen->GetCurItem();
MODULE* Module;
if( Text == NULL ) if( Text == NULL )
return; return;
Module = (MODULE*) Text->GetParent(); /* Undraw the text : */
/* effacement du texte : */
if( erase ) if( erase )
Text->Draw( panel, DC, GR_XOR, MoveVector ); Text->Draw( panel, DC, GR_XOR, MoveVector );
MoveVector.x = -(screen->m_Curseur.x - CursorInitialPosition.x); MoveVector = TextInitialPosition - screen->m_Curseur;
MoveVector.y = -(screen->m_Curseur.y - CursorInitialPosition.y);
/* Redessin du Texte */ /* Redraw the text */
Text->Draw( panel, DC, GR_XOR, MoveVector ); Text->Draw( panel, DC, GR_XOR, MoveVector );
} }
...@@ -200,7 +200,7 @@ static void AbortMoveAndEditTarget( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -200,7 +200,7 @@ static void AbortMoveAndEditTarget( WinEDA_DrawPanel* Panel, wxDC* DC )
} }
else /* it is an existing item: retrieve initial values of parameters */ else /* it is an existing item: retrieve initial values of parameters */
{ {
if( (MirePcb->m_Flags & IN_EDIT) ) if( (MirePcb->m_Flags & (IN_EDIT |IS_MOVED)) )
{ {
MirePcb->m_Pos = s_TargetCopy.m_Pos; MirePcb->m_Pos = s_TargetCopy.m_Pos;
MirePcb->m_Width = s_TargetCopy.m_Width; MirePcb->m_Width = s_TargetCopy.m_Width;
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "protos.h" #include "protos.h"
#include "dialog_edit_module_for_modedit.h"
#include "collectors.h" #include "collectors.h"
/****************************************************************************/ /****************************************************************************/
...@@ -396,10 +398,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -396,10 +398,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_EDIT_MODULE_PROPERTIES: case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
{ {
SET_DC;
SetCurItem( GetBoard()->m_Modules ); SetCurItem( GetBoard()->m_Modules );
InstallModuleOptionsFrame( (MODULE*) GetScreen()->GetCurItem(), &dc ); DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0; GetScreen()->GetCurItem()->m_Flags = 0;
if( ret > 0 )
DrawPanel->Refresh();
} }
break; break;
...@@ -453,10 +457,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -453,10 +457,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_MODULE: case ID_POPUP_PCB_EDIT_MODULE:
{ {
SET_DC; DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
InstallModuleOptionsFrame( (MODULE*) GetScreen()->GetCurItem(), &dc ); int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0;
GetScreen()->GetCurItem()->m_Flags = 0; GetScreen()->GetCurItem()->m_Flags = 0;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( ret > 0 )
DrawPanel->Refresh();
} }
break; break;
...@@ -504,9 +511,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -504,9 +511,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_TEXTMODULE: case ID_POPUP_PCB_EDIT_TEXTMODULE:
{ {
SET_DC; SET_DC;
InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(),
&dc, pos );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
break; break;
...@@ -522,8 +527,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -522,8 +527,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_ROTATE_TEXTMODULE: case ID_POPUP_PCB_ROTATE_TEXTMODULE:
{ {
SET_DC; SET_DC;
RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
&dc );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
break; break;
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "confirm.h" #include "confirm.h"
#include "3d_viewer.h"
#include "pcbnew.h" #include "pcbnew.h"
#include "wxPcbStruct.h" #include "wxPcbStruct.h"
#include "dialog_edit_module_for_modedit.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "protos.h" #include "protos.h"
...@@ -403,13 +405,19 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -403,13 +405,19 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case TYPE_MODULE: case TYPE_MODULE:
InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc ); {
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) DrawStruct );
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0;
GetScreen()->GetCurItem()->m_Flags = 0;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if( ret > 0 )
DrawPanel->Refresh();
}
break; break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc );
&dc, pos );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
......
...@@ -400,7 +400,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -400,7 +400,7 @@ void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
break; break;
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos ); InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
......
...@@ -165,21 +165,22 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -165,21 +165,22 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
createPopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu ); createPopUpMenuForFpTexts( (TEXTE_MODULE*) item, aPopMenu );
break; break;
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT: // Some graphic items on technical layers
if( (flags & IS_NEW) )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING,
_( "End Drawing" ), apply_xpm );
}
if( !flags ) if( !flags )
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
_( "Move Drawing" ), move_xpm ); _( "Move Drawing" ), move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _( "Delete Drawing" ), delete_xpm );
if( item->GetLayer() > LAST_COPPER_LAYER )
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING_LAYER,
_( "Delete All Drawing on Layer" ), delete_body_xpm );
} }
if( flags & IS_NEW )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_STOP_CURRENT_DRAWING,
_( "End Drawing" ), apply_xpm );
}
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING,
_( "Edit Drawing" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING,
_( "Delete Drawing" ), delete_xpm );
break; break;
case TYPE_ZONE: // Item used to fill a zone case TYPE_ZONE: // Item used to fill a zone
...@@ -218,9 +219,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -218,9 +219,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_COTATION, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_COTATION,
_( "Edit Dimension" ), edit_xpm ); _( "Edit Dimension" ), edit_xpm );
} ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_COTATION,
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_COTATION,
_( "Delete Dimension" ), delete_xpm ); _( "Delete Dimension" ), delete_xpm );
}
break; break;
case TYPE_MIRE: case TYPE_MIRE:
...@@ -228,11 +229,11 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -228,11 +229,11 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_MIRE_REQUEST,
_( "Move Target" ), move_xpm ); _( "Move Target" ), move_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_MIRE,
_( "Edit Target" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MIRE,
_( "Delete Target" ), delete_xpm );
} }
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_MIRE,
_( "Edit Target" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MIRE,
_( "Delete Target" ), delete_xpm );
break; break;
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
...@@ -709,9 +710,11 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m ...@@ -709,9 +710,11 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE, ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE,
_( "Edit" ), edit_text_xpm ); _( "Edit" ), edit_text_xpm );
if( FpText->m_Type == TEXT_is_DIVERS ) if( !flags && FpText->m_Type == TEXT_is_DIVERS ) // Graphic texts can be deleted only if are not currently edited
{
ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_DELETE_TEXTMODULE, ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_DELETE_TEXTMODULE,
_( "Delete" ), delete_xpm ); _( "Delete" ), delete_xpm );
}
if( !flags ) if( !flags )
{ {
......
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