Commit 28a3e584 authored by jean-pierre charras's avatar jean-pierre charras

Added grag labels patch

parent 30a54500
......@@ -605,24 +605,11 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct->m_Flags = 0;
// Sel .m_Flags to selected for a wire or bus in selected area if there is
// only one item:
if( pickedlist->GetCount() == 1 )
{
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( 0 );
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
Struct->m_Flags = SELECTED;
}
// Sel .m_Flags to selected for a wire or bus in selected area for a list
// of items:
else
{
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
Struct->m_Flags = SELECTED;
}
}
if( screen->m_BlockLocate.m_Command != BLOCK_DRAG )
return;
......@@ -653,6 +640,18 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*) (SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( ( Struct->Type() == TYPE_SCH_LABEL )
|| ( Struct->Type() == TYPE_SCH_GLOBALLABEL )
|| ( Struct->Type() == TYPE_SCH_HIERLABEL ) )
{
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) Struct )
if( !screen->m_BlockLocate.Inside( STRUCT->m_Pos ) )
{
AddPickedItem( screen, STRUCT->m_Pos );
}
}
if( Struct->Type() == TYPE_SCH_COMPONENT )
{
// Add all pins of the selected component to list
......
......@@ -54,42 +54,21 @@ void TestLabelForDangling( SCH_TEXT* label,
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList );
/* Returns TRUE if the point P is on the segment S.
* The segment is assumed horizontal or vertical.
*/
bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2,
int Px1, int Py1 )
/* Returns true if the point P is on the segment S. */
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint )
{
int Sxmin, Sxmax, Symin, Symax;
if( Sx1 == Sx2 ) /* Line S is vertical. */
{
Symin = MIN( Sy1, Sy2 );
Symax = MAX( Sy1, Sy2 );
wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
if( Px1 != Sx1 )
return FALSE;
// Use long long here to avoid overflow in calculations
if( (long long)vectSeg.x * vectPoint.y - (long long)vectSeg.y * vectPoint.x )
return false; /* Cross product non-zero, vectors not parallel */
if( Py1 >= Symin && Py1 <= Symax )
return TRUE;
else
return FALSE;
}
else if( Sy1 == Sy2 ) /* Line S is horizontal. */
{
Sxmin = MIN( Sx1, Sx2 );
Sxmax = MAX( Sx1, Sx2 );
if( ((long long)vectSeg.x * vectPoint.x + (long long)vectSeg.y * vectPoint.y) <
((long long)vectPoint.x * vectPoint.x + (long long)vectPoint.y * vectPoint.y) )
return false; /* Point not on segment */
if( Py1 != Sy1 )
return FALSE;
if( Px1 >= Sxmin && Px1 <= Sxmax )
return TRUE;
else
return FALSE;
}
else
return FALSE;
return true;
}
......@@ -133,7 +112,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
break;
if( STRUCT->GetLayer() == LAYER_BUS )
{
STRUCT->m_StartIsDangling = STRUCT->m_EndIsDangling = FALSE;
STRUCT->m_StartIsDangling = STRUCT->m_EndIsDangling = false;
break;
}
break;
......@@ -182,7 +161,7 @@ void TestWireForDangling( SCH_LINE* DrawRef, WinEDA_SchematicFrame* frame,
wxDC* DC )
{
DanglingEndHandle* terminal_item;
bool Sdangstate = TRUE, Edangstate = TRUE;
bool Sdangstate = true, Edangstate = true;
for( terminal_item = ItemList; terminal_item != NULL;
terminal_item = terminal_item->m_Pnext )
......@@ -192,13 +171,13 @@ void TestWireForDangling( SCH_LINE* DrawRef, WinEDA_SchematicFrame* frame,
if( (DrawRef->m_Start.x == terminal_item->m_Pos.x)
&& (DrawRef->m_Start.y == terminal_item->m_Pos.y) )
Sdangstate = FALSE;
Sdangstate = false;
if( (DrawRef->m_End.x == terminal_item->m_Pos.x)
&& (DrawRef->m_End.y == terminal_item->m_Pos.y) )
Edangstate = FALSE;
Edangstate = false;
if( (Sdangstate == FALSE) && (Edangstate == FALSE) )
if( (Sdangstate == false) && (Edangstate == false) )
break;
}
......@@ -220,7 +199,7 @@ void TestLabelForDangling( SCH_TEXT* label, WinEDA_SchematicFrame* frame,
wxDC* DC )
{
DanglingEndHandle* terminal_item;
bool dangstate = TRUE;
bool dangstate = true;
for( terminal_item = ItemList; terminal_item != NULL;
terminal_item = terminal_item->m_Pnext )
......@@ -235,16 +214,14 @@ void TestLabelForDangling( SCH_TEXT* label, WinEDA_SchematicFrame* frame,
case SHEET_LABEL_END:
if( ( label->m_Pos.x == terminal_item->m_Pos.x )
&& ( label->m_Pos.y == terminal_item->m_Pos.y ) )
dangstate = FALSE;
dangstate = false;
break;
case WIRE_START_END:
case BUS_START_END:
dangstate = !SegmentIntersect( terminal_item->m_Pos.x,
terminal_item->m_Pos.y,
terminal_item->m_Pnext->m_Pos.x,
terminal_item->m_Pnext->m_Pos.y,
label->m_Pos.x, label->m_Pos.y );
dangstate = !SegmentIntersect( terminal_item->m_Pos,
terminal_item->m_Pnext->m_Pos,
label->m_Pos );
terminal_item = terminal_item->m_Pnext;
break;
......@@ -256,7 +233,7 @@ void TestLabelForDangling( SCH_TEXT* label, WinEDA_SchematicFrame* frame,
break;
}
if( dangstate == FALSE )
if( dangstate == false )
break;
}
......@@ -417,8 +394,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
{
SCH_SHEET* sheet = (SCH_SHEET*) DrawItem;
BOOST_FOREACH( SCH_SHEET_PIN pinsheet, sheet->GetSheetPins() )
{
BOOST_FOREACH( SCH_SHEET_PIN pinsheet, sheet->GetSheetPins() ) {
wxASSERT( pinsheet.Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
item = new DanglingEndHandle( SHEET_LABEL_END );
......
......@@ -578,10 +578,13 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
wxPostEvent( this, eventMoveOrDragComponent );
break;
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
wxPostEvent( this, eventMoveOrDragComponent );
break;
case TYPE_SCH_TEXT:
case DRAW_PART_TEXT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
if( HK_Descr->m_Idcommand != HK_DRAG )
......
......@@ -1031,9 +1031,7 @@ static void SegmentToPointConnect( NETLIST_OBJECT* Jonction,
continue;
}
if( SegmentIntersect( Segment->m_Start.x, Segment->m_Start.y,
Segment->m_End.x, Segment->m_End.y,
Jonction->m_Start.x, Jonction->m_Start.y ) )
if( SegmentIntersect( Segment->m_Start, Segment->m_End, Jonction->m_Start ) )
{
/* Propagation Netcode has all the objects of the same Netcode. */
if( IsBus == 0 )
......
......@@ -342,6 +342,9 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
msg = AddHotkeyName( _( "Move Global Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg = AddHotkeyName( _( "Drag Global Label" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_text_xpm );
msg = AddHotkeyName( _( "Copy Global Label" ), s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
......@@ -376,6 +379,9 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
msg = AddHotkeyName( _( "Move Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg = AddHotkeyName( _( "Drag Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_text_xpm );
msg = AddHotkeyName( _( "Copy Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
......@@ -409,6 +415,9 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST, msg, move_text_xpm );
msg = AddHotkeyName( _( "Drag Label" ), s_Schematic_Hokeys_Descr,
HK_DRAG );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_text_xpm );
msg = AddHotkeyName( _( "Copy Label" ), s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM, msg, copy_button );
......
......@@ -17,9 +17,7 @@
#include "class_pin.h"
/* Local Variables : */
static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter,
SCH_SHEET_PIN* Struct );
/* Local functions : */
static void PlotTextField( PLOTTER* plotter, SCH_COMPONENT* DrawLibItem,
int FieldNumber, bool IsMulti, int DrawMode );
......@@ -304,46 +302,6 @@ static void PlotTextStruct( PLOTTER* plotter, SCH_TEXT* aSchText )
}
static void Plot_Hierarchical_PIN_Sheet( PLOTTER* plotter,
SCH_SHEET_PIN* aHierarchical_PIN )
{
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
int posx, tposx, posy, size;
static std::vector <wxPoint> Poly;
txtcolor = ReturnLayerColor( aHierarchical_PIN->GetLayer() );
posx = aHierarchical_PIN->m_Pos.x;
posy = aHierarchical_PIN->m_Pos.y;
size = aHierarchical_PIN->m_Size.x;
GRTextHorizJustifyType side;
if( aHierarchical_PIN->m_Edge )
{
tposx = posx - size;
side = GR_TEXT_HJUSTIFY_RIGHT;
}
else
{
tposx = posx + size + (size / 8);
side = GR_TEXT_HJUSTIFY_LEFT;
}
int thickness = aHierarchical_PIN->GetPenSize();
plotter->set_current_line_width( thickness );
plotter->text( wxPoint( tposx, posy ), txtcolor, aHierarchical_PIN->m_Text,
TEXT_ORIENT_HORIZ, wxSize( size, size ),
side, GR_TEXT_VJUSTIFY_CENTER, thickness,
aHierarchical_PIN->m_Italic, aHierarchical_PIN->m_Bold );
/* Draw the associated graphic symbol */
aHierarchical_PIN->CreateGraphicShape( Poly, aHierarchical_PIN->m_Pos );
plotter->poly( Poly.size(), &Poly[0].x, NO_FILL );
}
static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
{
EDA_Colors txtcolor = UNSPECIFIED_COLOR;
......@@ -399,9 +357,9 @@ static void PlotSheetStruct( PLOTTER* plotter, SCH_SHEET* Struct )
plotter->set_color( ReturnLayerColor( Struct->m_Layer ) );
/* Draw texts : SheetLabel */
BOOST_FOREACH( SCH_SHEET_PIN& label, Struct->GetSheetPins() )
BOOST_FOREACH( SCH_SHEET_PIN& pin_sheet, Struct->GetSheetPins() )
{
label.Plot( plotter );
pin_sheet.Plot( plotter );
}
}
......
......@@ -31,7 +31,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
/*********************/
/* DANGLING_ENDS.CPP */
/*********************/
bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2, int Px1, int Py1 );
bool SegmentIntersect( wxPoint aSegStart, wxPoint aSegEnd, wxPoint aTestPoint );
/****************/
/* BUS_WIRE_JUNCTION.CPP */
......
......@@ -414,7 +414,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_MOVE_CMP_REQUEST:
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..) or a hierachical sheet
// or a label
if( (screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT)
&& (screen->GetCurItem()->Type() != TYPE_SCH_LABEL)
&& (screen->GetCurItem()->Type() != TYPE_SCH_GLOBALLABEL)
&& (screen->GetCurItem()->Type() != TYPE_SCH_HIERLABEL)
&& (screen->GetCurItem()->Type() != DRAW_SHEET_STRUCT_TYPE) )
screen->SetCurItem( LocateSmallestComponent( screen ) );
if( screen->GetCurItem() == NULL )
......
......@@ -71,8 +71,6 @@ enum main_id
ID_V_TOOLBAR,
ID_OPT_TOOLBAR,
ID_AUX_TOOLBAR,
ID_AUX_V_TOOLBAR,
ID_TOOLBAR_UNUSED,
ID_GENERAL_HELP,
ID_LOCAL_HELP,
......
......@@ -269,7 +269,7 @@ public:
void ReCreateHToolbar();
void ReCreateAuxiliaryToolbar();
void ReCreateVToolbar();
void ReCreateAuxVToolbar();
void ReCreateMicrowaveVToolbar();
void ReCreateOptToolbar();
void ReCreateMenuBar();
WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent );
......
This diff is collapsed.
......@@ -378,7 +378,6 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawPanel->DrawGridAxis( DC, GR_XOR );
GetScreen()->m_GridOrigin = GetScreen()->m_Curseur;
DrawPanel->DrawGridAxis( DC, GR_COPY );
GetScreen()->SetModify();
break;
default:
......
......@@ -319,7 +319,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
ReCreateVToolbar();
ReCreateOptToolbar();
ReCreateAuxVToolbar();
ReCreateMicrowaveVToolbar();
m_auimgr.SetManagedWindow( this );
......@@ -370,6 +370,9 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
m_show_layer_manager_tools );
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
m_show_microwave_tools );
m_auimgr.GetPane( wxT( "m_AuxVToolBar" ) ).Show( m_show_microwave_tools );
}
if( DrawPanel )
......@@ -542,8 +545,7 @@ void WinEDA_PcbFrame::SaveSettings()
config->Write( PCB_SHOW_FULL_RATSNET_OPT, tmp );
config->Write( PCB_MAGNETIC_PADS_OPT, (long) g_MagneticPadOption );
config->Write( PCB_MAGNETIC_TRACKS_OPT, (long) g_MagneticTrackOption );
config->Write( SHOW_MICROWAVE_TOOLS,
( m_AuxVToolBar && m_AuxVToolBar->IsShown() ) ? true : false );
config->Write( SHOW_MICROWAVE_TOOLS, (long) m_show_microwave_tools );
config->Write( SHOW_LAYER_MANAGER_TOOLS, (long)m_show_layer_manager_tools );
}
......
......@@ -14,6 +14,7 @@
enum pcbnew_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_MICROWAVE_V_TOOLBAR,
ID_OPEN_MODULE_EDITOR,
ID_READ_NETLIST,
ID_PCB_CIRCLE_BUTT,
......
......@@ -476,13 +476,13 @@ void WinEDA_PcbFrame::ReCreateVToolbar()
/* Create the auxiliary vertical right toolbar, showing tools for
* microwave applications
*/
void WinEDA_PcbFrame::ReCreateAuxVToolbar()
void WinEDA_PcbFrame::ReCreateMicrowaveVToolbar()
{
if( m_AuxVToolBar )
return;
m_AuxVToolBar = new WinEDA_Toolbar( TOOLBAR_TOOL, this,
ID_AUX_V_TOOLBAR, FALSE );
ID_MICROWAVE_V_TOOLBAR, FALSE );
// Set up toolbar
m_AuxVToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
......
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